aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 40fed53f938af88fcda5e618b9662b3ca4445f5b (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
43
44
45
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
DATAROOTDIR = $(PREFIX)/share
MANDIR = $(DATAROOTDIR)/man

# 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
	install -D doc/meh.1 $(DESTDIR)$(MANDIR)/man1/meh.1

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

.PHONY: clean test