-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
41 lines (25 loc) · 803 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
EXEC=meeshell
CC=gcc
INCLUDE_DIR=include/
BUILD_DIR=build/
SRC_DIR=src/
BUILD_FLAGS=--std=gnu11 -I $(INCLUDE_DIR)
DEBUG_FLAGS=-Wall -Wextra -Wpedantic -g -DDEBUG -fsanitize=address
SRC=$(filter-out $(SRC_DIR)test.c, $(wildcard $(SRC_DIR)*.c))
OBJ=$(patsubst $(SRC_DIR)%.c, $(BUILD_DIR)%.o, $(SRC))
all: clean $(EXEC)
debug: BUILD_FLAGS += $(DEBUG_FLAGS)
# Debug mode enabled
debug: $(EXEC)
$(EXEC): $(OBJ)
# Building target
$(CC) $(BUILD_FLAGS) $(OBJ) -o $(EXEC)
build_dir:
# Creating build directory
if [ ! -d $(BUILD_DIR) ]; then mkdir $(BUILD_DIR); fi
$(BUILD_DIR)%.o: $(SRC_DIR)%.c | build_dir
$(CC) $(BUILD_FLAGS) -c $< -o $@
clean:
# Cleaning up
if [ -d $(BUILD_DIR) ]; then rm -rf $(BUILD_DIR)/*; else mkdir $(BUILD_DIR); fi
if [ -f $(EXEC) ]; then rm $(EXEC); fi