1 include ../mk/cflags.mk
4 LDFLAGS += $(if $(DARWIN),-L/opt/local/lib,-Wl,-warn-common)
5 CFLAGS += --std=gnu99 -I../ -I../common $(if $(DARWIN),-I/opt/local/include,)
7 INSTALL_PROGS = $(addprefix install-,$(PROGRAMS))
9 all: $(GENERATED) $(LIBS) $(PROGRAMS) | $(GENERATED)
11 install: all $(INSTALL_PROGS)
13 $(INSTALL_PROGS): install-%:
14 install $* $(DESTDIR)$(prefix)/sbin
17 $(RM) $(LIBS:=.a) $(PROGRAMS) $(TESTS) .*.o .*.dep
23 .tags: $(shell git ls-files | egrep '\.[hc]$$')
26 headers: HEADACHEOPTS=-c mk/headache.cfg -h mk/COPYING
28 @which headache > /dev/null || \
29 ( echo "package headache not installed" ; exit 1 )
30 @git ls-files | egrep '(\.h|\.c|Makefile|*\.mk)$$' | xargs -t headache $(HEADACHEOPTS)
33 ./$< $@ || ($(RM) $@; exit 1)
36 ./$< $@ || ($(RM) $@; exit 1)
39 $(shell test -d $(@D) || mkdir -p $(@D))
40 $(CC) $(CFLAGS) -MMD -MT ".$*.dep $@" -MF .$*.dep -g -c -o $@ $<
48 $(LIBS:=.a): $$(patsubst %.c,.%.o,$$($$(patsubst %.a,%,$$@)_SOURCES)) Makefile
50 $(AR) rcs $@ $(filter %.o,$^)
52 $(PROGRAMS) $(TESTS): $$(patsubst %.c,.%.o,$$($$@_SOURCES)) Makefile
53 $(CC) -o $@ $(filter %.o,$^) $(LDFLAGS) $($@_LIBADD) $(filter %.a,$^)
55 -include $(foreach p,$(PROGRAMS) $(TESTS),$(patsubst %.c,.%.dep,$(filter %.c,$($p_SOURCES))))
57 .PHONY: install-dir $(INSTALL_PROGS)