-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
39 lines (28 loc) · 949 Bytes
/
Makefile
File metadata and controls
39 lines (28 loc) · 949 Bytes
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
36
37
38
GCC = gcc
INCLUDE = -Iinclude
LINKS =
CFLAGS = --std=gnu99 -O2
# Debug flags
# CFLAGS = $(CFLAGS) -g -Wall -Wextra -Wshadow -Wcast-align -fsanitize={address,undefined}
INC = $(shell find include/ -type f -name '*.h')
SRC = $(shell find src/ -type f -name '*.c' ! -name 'main.c')
OBJ = $(patsubst src/%.c, build/obj/%.o, $(SRC))
BIN = $(patsubst src/%.c, build/bin/%, src/main.c)
TEST_SRC = $(shell find test/ -type f -name '*.c')
TEST_BIN = $(patsubst test/%.c, build/bin/%, $(TEST_SRC))
all: build $(BIN) $(TEST_BIN)
build: $(OBJ)
build/bin/main: src/main.c $(OBJ)
@mkdir -p "$(@D)"
@echo Compiling "$<"
@$(GCC) $(CFLAGS) "$<" $(OBJ) -o "$@" $(INCLUDE) $(LINKS)
build/bin/%: test/%.c $(OBJ)
@mkdir -p "$(@D)"
@echo Compiling "$<"
@$(GCC) $(CFLAGS) "$<" $(OBJ) -o "$@" $(INCLUDE) $(LINKS)
build/obj/%.o: src/%.c
@mkdir -p "$(@D)"
@echo Compiling "$<"
@$(GCC) $(CFLAGS) -c "$<" -o "$@" $(INCLUDE) $(LINKS)
clear:
@rm -rf build