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 |
| 6 | |
| 7 | LDLIBS+=$(shell pkg-config --libs $(PACKAGE_DEPS)) |
| 8 | CFLAGS+=$(shell pkg-config --cflags $(PACKAGE_DEPS)) -Werror |
| 9 | |
| 10 | INSTALLDEPS?=install-bins |
| 11 | BIN_SUFFIX?=.exe |
| 12 | DEFAULT_ALL?=$(BINS) |
| 13 | |
| 14 | all: $(DEFAULT_ALL) |
| 15 | |
| 16 | %.o: %.c |
| 17 | $(CC) -c $(CFLAGS) -fPIC -o $@ $< |
| 18 | |
| 19 | $(BINS): %: %.o $(EXTRA_OBJS) |
| 20 | $(CC) $(LDFLAGS) -o $@$(BIN_SUFFIX) $^ $(LDLIBS) |
| 21 | |
| 22 | install-bins: |
| 23 | @mkdir -p $(DESTDIR)$(sbindir) |
| 24 | @for b in $(BINS); do \ |
| 25 | install $$b$(BIN_SUFFIX) $(DESTDIR)$(sbindir) || exit 1; \ |
| 26 | done |
| 27 | |
| 28 | install: all $(INSTALLDEPS) |
| 29 | |
| 30 | clean: $(CLEANDEPS) |
| 31 | rm -rf *.o $(BINS:=$(BIN_SUFFIX)) |