mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-04 02:23:24 +00:00
miniupnpd: Makefile: generate dep-files during compilation
Implement the "Auto-Dependency Generation"[1] writeup by Paul D. Smith and generate dep-files at the compilation time instead of requiring a separate preprocessor pass. This removes the `depend` target as it is not needed anymore. [1]: https://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
This commit is contained in:
parent
a715632987
commit
2f851743e0
@ -49,7 +49,8 @@ PKG_CONFIG ?= pkg-config
|
||||
CP = cp
|
||||
DOXYGEN ?= doxygen
|
||||
|
||||
DEPFLAGS = -MM -MG -MT $(patsubst %.d,%.o,$@) -MT $@
|
||||
DEPDIR := .depend
|
||||
DEPFLAGS = -MMD -MP -MF $(@:%.o=$(DEPDIR)/%.d) -MT $@
|
||||
# -M : with system headers, -MM : without
|
||||
|
||||
INSTALLPREFIX ?= $(PREFIX)/usr
|
||||
@ -66,8 +67,6 @@ NETFILTEROBJS = iptcrdr.o iptpinhole.o nfct_get.o
|
||||
|
||||
ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(OTHEROBJS)
|
||||
|
||||
DEP = $(ALLOBJS:.o=.d)
|
||||
|
||||
NETFILTER_SCRIPTS = $(addprefix $(SRCDIR)/netfilter/, \
|
||||
iptables_init.sh iptables_removeall.sh \
|
||||
ip6tables_init.sh ip6tables_removeall.sh \
|
||||
@ -118,14 +117,14 @@ EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
|
||||
testgetroute testasyncsendto testportinuse \
|
||||
testssdppktgen testminissdp
|
||||
|
||||
.PHONY: all clean install depend dox
|
||||
.PHONY: all clean install dox
|
||||
|
||||
all: $(EXECUTABLES)
|
||||
|
||||
clean:
|
||||
$(RM) config.h
|
||||
$(RM) $(ALLOBJS)
|
||||
$(RM) $(DEP)
|
||||
$(RM) -r $(DEPDIR)
|
||||
$(RM) $(EXECUTABLES)
|
||||
$(RM) testupnpdescgen.o testgetifstats.o
|
||||
$(RM) testupnppermissions.o testgetifaddr.o
|
||||
@ -198,26 +197,24 @@ miniupnpdctl: miniupnpdctl.o
|
||||
config.mk config.h: $(SRCDIR)/configure $(SRCDIR)/VERSION
|
||||
$(SHELL) $< $(CONFIG_OPTIONS)
|
||||
|
||||
depend: $(DEP)
|
||||
|
||||
%.d: $(SRCDIR)/%.c
|
||||
$(CC) $(CPPFLAGS) $(DEPFLAGS) -o $@ $<
|
||||
|
||||
dox: $(SRCDIR)/miniupnpd.doxyconf
|
||||
(cat $< ; echo "INPUT=$(SRCDIR)" ) | $(DOXYGEN) -
|
||||
|
||||
%.o: $(SRCDIR)/%.c
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
%.o: $(SRCDIR)/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
||||
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
|
||||
%.o: $(SRCDIR)/linux/%.c
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
%.o: $(SRCDIR)/linux/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
||||
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
|
||||
%.o: $(SRCDIR)/netfilter/%.c
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
%.o: $(SRCDIR)/netfilter/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
||||
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
|
||||
print-%:
|
||||
@echo "$* = $($*)"
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(DEP)
|
||||
endif
|
||||
|
||||
DEPFILES := $(ALLOBJS:%.o=$(DEPDIR)/%.d)
|
||||
$(DEPDIR): ; @mkdir -p $@
|
||||
$(DEPFILES):
|
||||
|
||||
-include $(wildcard $(DEPFILES))
|
||||
|
@ -44,7 +44,8 @@ PKG_CONFIG ?= pkg-config
|
||||
CP = cp
|
||||
DOXYGEN ?= doxygen
|
||||
|
||||
DEPFLAGS = -MM -MG -MT $(patsubst %.d,%.o,$@) -MT $@
|
||||
DEPDIR := .depend
|
||||
DEPFLAGS = -MMD -MP -MF $(@:%.o=$(DEPDIR)/%.d) -MT $@
|
||||
# -M : with system headers, -MM : without
|
||||
|
||||
INSTALLPREFIX ?= $(PREFIX)/usr
|
||||
@ -61,8 +62,6 @@ NETFILTEROBJS = nftnlrdr.o nftpinhole.o nfct_get.o nftnlrdr_misc.o
|
||||
|
||||
ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(OTHEROBJS)
|
||||
|
||||
DEP = $(ALLOBJS:.o=.d)
|
||||
|
||||
NFT_SCRIPTS = $(addprefix $(SRCDIR)/netfilter_nft/scripts/, \
|
||||
nft_init.sh nft_removeall.sh nft_flush.sh nft_delete_chain.sh)
|
||||
|
||||
@ -109,13 +108,14 @@ EXECUTABLES = miniupnpd miniupnpdctl \
|
||||
testupnppermissions testgetifaddr \
|
||||
testgetroute testasyncsendto testportinuse
|
||||
|
||||
.PHONY: all clean install depend dox
|
||||
.PHONY: all clean install dox
|
||||
|
||||
all: $(EXECUTABLES)
|
||||
|
||||
clean:
|
||||
$(RM) config.h
|
||||
$(RM) $(ALLOBJS)
|
||||
$(RM) -r $(DEPDIR)
|
||||
$(RM) $(EXECUTABLES)
|
||||
$(RM) testupnpdescgen.o testgetifstats.o
|
||||
$(RM) testupnppermissions.o testgetifaddr.o
|
||||
@ -169,26 +169,24 @@ miniupnpdctl: miniupnpdctl.o
|
||||
config.mk config.h: $(SRCDIR)/configure $(SRCDIR)/VERSION
|
||||
$(SHELL) $< $(CONFIG_OPTIONS)
|
||||
|
||||
depend: $(DEP)
|
||||
|
||||
%.d: $(SRCDIR)/%.c
|
||||
$(CC) $(CPPFLAGS) $(DEPFLAGS) -o $@ $<
|
||||
|
||||
dox: $(SRCDIR)/miniupnpd.doxyconf
|
||||
(cat $< ; echo "INPUT=$(SRCDIR)" ) | $(DOXYGEN) -
|
||||
|
||||
%.o: $(SRCDIR)/%.c
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
%.o: $(SRCDIR)/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
||||
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
|
||||
%.o: $(SRCDIR)/linux/%.c
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
%.o: $(SRCDIR)/linux/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
||||
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
|
||||
%.o: $(SRCDIR)/netfilter_nft/%.c
|
||||
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
%.o: $(SRCDIR)/netfilter_nft/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
||||
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
||||
|
||||
print-%:
|
||||
@echo "$* = $($*)"
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(DEP)
|
||||
endif
|
||||
|
||||
DEPFILES := $(ALLOBJS:%.o=$(DEPDIR)/%.d)
|
||||
$(DEPDIR): ; @mkdir -p $@
|
||||
$(DEPFILES):
|
||||
|
||||
-include $(wildcard $(DEPFILES))
|
||||
|
Loading…
x
Reference in New Issue
Block a user