forked from jhawthorn/meh
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
42 lines (29 loc) · 879 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
TARGET := meh
TESTTARGET := test/test
SRCFILES := $(wildcard src/*.c)
OBJFILES := $(SRCFILES:%.c=%.o)
DEPFILES := $(OBJFILES:%.o=%.d)
TESTCLEAN := $(TESTTARGET) $(TESTTARGET).d $(TESTTARGET).o
CLEANFILES := $(CLEANFILES) $(DEPFILES) $(OBJFILES) test/test.o test/test.d test/test $(TARGET)
LIBS ?= -lX11 -lXext -ljpeg -lpng -lgif
PREFIX ?= /usr/local
BINDIR = $(PREFIX)/bin
# User configuration
CONFIG ?= ../config
-include configs/$(CONFIG).mk
CFLAGS ?= -O3 -DNDEBUG
meh: $(OBJFILES)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
test: $(TESTTARGET)
./$(TESTTARGET)
test/test: test/test.o $(filter-out src/main.o src/xlib.o, $(OBJFILES))
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
-include $(DEPFILES)
%.o: %.c Makefile
$(CC) $(CFLAGS) -MMD -MP -MT "$*.d" -c -o $@ $<
install:
install -Dm 755 meh $(BINDIR)
# Clean
clean:
$(RM) $(CLEANFILES)
.PHONY: clean test