Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 1 | TOP := $(abspath $(dir $(lastword $(MAKEFILE_LIST)))) |
| 2 | |
| 3 | .DEFAULT_GOAL := all |
| 4 | sbindir=/usr/sbin |
| 5 | libdir=/usr/lib |
Brad Bishop | b408ac0 | 2016-06-20 10:00:32 -0400 | [diff] [blame] | 6 | includedir=/usr/include |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 7 | |
| 8 | LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS)) |
Brad Bishop | c034d2d | 2016-06-19 20:53:35 -0400 | [diff] [blame] | 9 | ALL_CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -fPIC -Werror $(CFLAGS) |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 10 | |
| 11 | INSTALLDEPS?=install-bins |
| 12 | BIN_SUFFIX?=.exe |
| 13 | DEFAULT_ALL?=$(BINS) |
| 14 | |
| 15 | all: $(DEFAULT_ALL) |
| 16 | |
| 17 | %.o: %.c |
Brad Bishop | c034d2d | 2016-06-19 20:53:35 -0400 | [diff] [blame] | 18 | $(CC) -c $(ALL_CFLAGS) -o $@ $< |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 19 | |
| 20 | $(BINS): %: %.o $(EXTRA_OBJS) |
Brad Bishop | c034d2d | 2016-06-19 20:53:35 -0400 | [diff] [blame] | 21 | $(CC) $(CFLAGS) $(LDFLAGS) -o $@$(BIN_SUFFIX) $^ $(LDLIBS) |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 22 | |
Patrick Williams | df417fd | 2016-06-21 15:08:45 -0500 | [diff] [blame] | 23 | install-bins: $(BINS) |
Brad Bishop | 40a360c | 2016-05-28 18:41:04 -0400 | [diff] [blame] | 24 | @mkdir -p $(DESTDIR)$(sbindir) |
| 25 | @for b in $(BINS); do \ |
| 26 | install $$b$(BIN_SUFFIX) $(DESTDIR)$(sbindir) || exit 1; \ |
| 27 | done |
| 28 | |
| 29 | install: all $(INSTALLDEPS) |
| 30 | |
| 31 | clean: $(CLEANDEPS) |
| 32 | rm -rf *.o $(BINS:=$(BIN_SUFFIX)) |