-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
34 lines (27 loc) · 888 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
CFLAGS_EXTRA =
CFLAGS_DEBUG = -g -DDEBUG
CFLAGS_RELEASE = -O2
CFLAGS = -I./include -Wall -pedantic-errors $(CFLAGS_EXTRA)
SRCDIRS = $(shell find src -type d)
OBJDIRS = $(SRCDIRS:src%=obj%)
DEPSDIRS = $(SRCDIRS:src%=deps%)
SRCS = $(shell find src -name '*.c' -type f)
OBJS = $(SRCS:src/%.c=obj/%.o)
TARGET = ./bin/akarin
PREFIX = /usr/local/bin
.PHONY: debug release clean install
debug: CFLAGS += $(CFLAGS_DEBUG)
release: CFLAGS += $(CFLAGS_RELEASE)
debug release: $(TARGET)
$(TARGET): $(OBJS)
@mkdir -p bin
$(CC) $(CFLAGS) $(OBJS) -o $(TARGET)
obj/%.o: src/%.c
@mkdir -p $(OBJDIRS) $(DEPSDIRS)
$(CC) $(CFLAGS) -c $< -o $@
$(CC) $(CFLAGS) -MT $@ -MM $< > deps/$*.d
clean:
$(RM) -rf ./obj ./bin ./deps
install:
install -m 755 $(TARGET) $(PREFIX)
-include $(shell find deps -name '*.d' -type f 2> /dev/null)