Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 1 | .DEFAULT_GOAL := all |
2 | sbindir=/usr/sbin | ||||
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 3 | |
4 | LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS)) | ||||
Brad Bishop | c034d2d | 2016-06-19 20:53:35 -0400 | [diff] [blame] | 5 | ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS) |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 6 | |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 7 | BIN_SUFFIX?=.exe |
Brad Bishop | 059cffb | 2016-08-23 10:47:19 -0400 | [diff] [blame] | 8 | .PHONY: $(SUBDIRS) |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 9 | |
Brad Bishop | 059cffb | 2016-08-23 10:47:19 -0400 | [diff] [blame] | 10 | all: $(BINS:=$(BIN_SUFFIX)) $(SUBDIRS) |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 11 | |
12 | %.o: %.c | ||||
Brad Bishop | c034d2d | 2016-06-19 20:53:35 -0400 | [diff] [blame] | 13 | $(CC) -c $(ALL_CFLAGS) -o $@ $< |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 14 | |
Brad Bishop | 059cffb | 2016-08-23 10:47:19 -0400 | [diff] [blame] | 15 | $(SUBDIRS): |
16 | $(MAKE) -C $@ | ||||
17 | |||||
Brad Bishop | 37d0aa5 | 2016-06-27 13:35:11 -0400 | [diff] [blame] | 18 | $(BINS:=$(BIN_SUFFIX)): %$(BIN_SUFFIX): %.o $(EXTRA_OBJS) |
19 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(LDLIBS) | ||||
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 20 | |
Brad Bishop | 37d0aa5 | 2016-06-27 13:35:11 -0400 | [diff] [blame] | 21 | install: $(BINS:=$(BIN_SUFFIX)) |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 22 | @mkdir -p $(DESTDIR)$(sbindir) |
Brad Bishop | 37d0aa5 | 2016-06-27 13:35:11 -0400 | [diff] [blame] | 23 | @for b in $(BINS:=$(BIN_SUFFIX)); do \ |
24 | install $$b $(DESTDIR)$(sbindir) || exit 1; \ | ||||
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 25 | done |
Brad Bishop | 059cffb | 2016-08-23 10:47:19 -0400 | [diff] [blame] | 26 | @for d in $(SUBDIRS); do \ |
27 | $(MAKE) -C $$d $@ || exit 1; \ | ||||
28 | done | ||||
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 29 | |
Brad Bishop | 489bf65 | 2016-06-27 13:10:05 -0400 | [diff] [blame] | 30 | clean: |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 31 | rm -rf *.o $(BINS:=$(BIN_SUFFIX)) |
Brad Bishop | 059cffb | 2016-08-23 10:47:19 -0400 | [diff] [blame] | 32 | @for d in $(SUBDIRS); do \ |
33 | $(MAKE) -C $$d $@ || exit 1; \ | ||||
34 | done |