aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 3b9a1058c16fe8d2a3a7571d92b7042c7dec700a (plain)
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
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 $(DESTDIR)$(BINDIR)/meh

# Clean
clean:
	$(RM) $(CLEANFILES)

.PHONY: clean test