-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
48 lines (32 loc) · 933 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
36
37
38
39
40
41
42
43
44
45
46
47
48
CC = /usr/bin/gcc
CFLAGS = -Wall -Wpedantic -Wextra -Wstrict-aliasing -Wfloat-equal -Wundef -Wshadow -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wunreachable-code -lm
LD = /usr/bin/gcc
LDFLAGS =
OBJDIR = obj
BINDIR = bin
SRC = $(wildcard *.c) $(wildcard ex*/*.c)
OBJ = $(SRC:%.c=%.o)
DEP = $(SRC:%.c=%.d)
DRDIR =
all: release debug
debug: CFLAGS += -g
debug: DRDIR = debug
debug: $(BINDIR)/debug/main
release: CFLAGS += -O3
release: DRDIR = release
release: $(BINDIR)/release/main
$(BINDIR)/debug/main: $(OBJ:%.o=$(OBJDIR)/debug/%.o)
$(LD) $(LDFLAGS) $^ -o $@
$(BINDIR)/release/main: $(OBJ:%.o=$(OBJDIR)/release/%.o)
$(LD) $(LDFLAGS) $^ -o $@
-include $(DEP: %.d=$(OBJDIR)/$(DRDIR)/%.o)
$(OBJDIR)/release/%.o: %.c
$(CC) -MMD $(CFLAGS) -c -o $@ $<
$(OBJDIR)/debug/%.o: %.c
$(CC) -MMD $(CFLAGS) -c -o $@ $<
print-% : ; @echo $* = $($*)
clean:
-rm obj/*/*.o
-rm obj/*/*.d
-rm bin/*/*
.PHONY: all clean