From ea90d398922b6808dc6cc2b54a91011bcfc8dc02 Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Mon, 4 May 2020 02:01:36 +0200 Subject: [PATCH] miniupnpd: update linux makefiles --- miniupnpd/Makefile.linux | 16 +--- miniupnpd/Makefile.linux_nft | 169 ++++++++++------------------------- miniupnpd/objects.mk | 9 ++ 3 files changed, 58 insertions(+), 136 deletions(-) create mode 100644 miniupnpd/objects.mk diff --git a/miniupnpd/Makefile.linux b/miniupnpd/Makefile.linux index afe85fc..3687fb8 100644 --- a/miniupnpd/Makefile.linux +++ b/miniupnpd/Makefile.linux @@ -52,17 +52,8 @@ MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8 include config.mk include $(SRCDIR)/gitrev.mk +include $(SRCDIR)/objects.mk -BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \ - upnpreplyparse.o minixml.o portinuse.o \ - upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \ - options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \ - upnpevents.o upnputils.o getconnstatus.o \ - upnpstun.o \ - upnppinhole.o pcplearndscp.o asyncsendto.o - -# sources in linux/ directory -LNXOBJS = getifstats.o ifacewatcher.o getroute.o # sources in netfilter/ directory NETFILTEROBJS = iptcrdr.o iptpinhole.o nfct_get.o @@ -161,10 +152,11 @@ install: miniupnpd $(SRCDIR)/miniupnpd.8 miniupnpd.conf \ # 'cat /proc/sys/kernel/random/uuid' could be also used miniupnpd.conf: $(SRCDIR)/miniupnpd.conf ifeq ($(TARGET_OPENWRT),) - sed -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen||uuid) 2>/dev/null`/" $< > $@ + sed -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen||uuid) 2>/dev/null`/" $< > $@.tmp else - sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`($(STAGING_DIR_HOST)/bin/genuuid||$(STAGING_DIR_HOST)/bin/uuidgen||$(STAGING_DIR_HOST)/bin/uuid) 2>/dev/null`/" $< > $@ + sed -e "s/^uuid=[-0-9a-f]*/uuid=`($(STAGING_DIR_HOST)/bin/genuuid||$(STAGING_DIR_HOST)/bin/uuidgen||$(STAGING_DIR_HOST)/bin/uuid) 2>/dev/null`/" $< > $@.tmp endif + mv $@.tmp $@ check: validateupnppermissions validategetifaddr validatessdppktgen \ validateversion diff --git a/miniupnpd/Makefile.linux_nft b/miniupnpd/Makefile.linux_nft index 36cebef..958e41f 100644 --- a/miniupnpd/Makefile.linux_nft +++ b/miniupnpd/Makefile.linux_nft @@ -39,21 +39,20 @@ SBININSTALLDIR = $(INSTALLPREFIX)/sbin ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8 -include gitrev.mk +include config.mk +include $(SRCDIR)/gitrev.mk +include $(SRCDIR)/objects.mk -BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \ - upnpreplyparse.o minixml.o portinuse.o \ - upnpredirect.o getifaddr.o daemonize.o \ - options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \ - upnpglobalvars.o upnpevents.o upnputils.o getconnstatus.o \ - upnpstun.o upnppinhole.o pcplearndscp.o asyncsendto.o - -LNXOBJS = linux/getifstats.o linux/ifacewatcher.o linux/getroute.o -NETFILTEROBJS = netfilter_nft/nftnlrdr.o netfilter_nft/nftpinhole.o \ - netfilter_nft/nfct_get.o netfilter_nft/nftnlrdr_misc.o +# sources in the netfilter_nft/ directory +NETFILTEROBJS = nftnlrdr.o nftpinhole.o nfct_get.o nftnlrdr_misc.o ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) +DEP = $(ALLOBJS:o=.d) + +NFT_SCRIPTS = $(addprefix $(SRCDIR)/netfilter_nft/scripts/, \ + nft_init.sh nft_removeall.sh nft_flush.sh nft_delete_chain.sh) + PCFILE_FOUND := $(shell $(PKG_CONFIG) --exists libnftnl; echo $$?) ifeq (${PCFILE_FOUND},0) @@ -65,18 +64,10 @@ LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L $(PKG_CONFIG_LIBS)) LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-other $(PKG_CONFIG_LIBS)) else -ARCH ?= $(shell uname -m | grep -q "x86_64" && echo 64) endif # ifdef PCFILE_FOUND #LDLIBS += -lnfnetlink -TEST := $(shell $(PKG_CONFIG) --atleast-version=1.0.2 libnetfilter_conntrack && $(PKG_CONFIG) --atleast-version=1.0.3 libmnl && echo 1) -ifeq ($(TEST),1) -CPPFLAGS += -DUSE_NFCT -LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l libmnl) -LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l libnetfilter_conntrack) -endif # ($(TEST),1) - LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l libssl) TEST := $(shell $(PKG_CONFIG) --exists uuid && echo 1) @@ -120,24 +111,21 @@ clean: $(RM) miniupnpdctl.o $(RM) -r dox/ -install: miniupnpd miniupnpd.8 miniupnpd.conf \ - netfilter_nft/scripts/nft_init.sh \ - netfilter_nft/scripts/nft_removeall.sh \ - netfilter_nft/scripts/nft_flush.sh \ - netfilter_nft/scripts/nft_delete_chain.sh \ - linux/miniupnpd.init.d.script +install: miniupnpd $(SRCDIR)/miniupnpd.8 $(SRCDIR)/miniupnpd.conf \ + $(NFT_SCRIPTS) \ + $(SRCDIR)/linux/miniupnpd.init.d.script $(STRIP) miniupnpd $(INSTALL) -d $(DESTDIR)$(SBININSTALLDIR) $(INSTALL) miniupnpd $(DESTDIR)$(SBININSTALLDIR) $(INSTALL) -d $(DESTDIR)$(ETCINSTALLDIR) - $(INSTALL) netfilter_nft/scripts/nft_init.sh $(DESTDIR)$(ETCINSTALLDIR) - $(INSTALL) netfilter_nft/scripts/nft_removeall.sh $(DESTDIR)$(ETCINSTALLDIR) - $(INSTALL) netfilter_nft/scripts/nft_flush.sh $(DESTDIR)$(ETCINSTALLDIR) - $(INSTALL) netfilter_nft/scripts/nft_delete_chain.sh $(DESTDIR)$(ETCINSTALLDIR) - $(INSTALL) --mode=0644 -b miniupnpd.conf $(DESTDIR)$(ETCINSTALLDIR) + $(INSTALL) $(SRCDIR)/netfilter_nft/scripts/nft_init.sh $(DESTDIR)$(ETCINSTALLDIR) + $(INSTALL) $(SRCDIR)/netfilter_nft/scripts/nft_removeall.sh $(DESTDIR)$(ETCINSTALLDIR) + $(INSTALL) $(SRCDIR)/netfilter_nft/scripts/nft_flush.sh $(DESTDIR)$(ETCINSTALLDIR) + $(INSTALL) $(SRCDIR)/netfilter_nft/scripts/nft_delete_chain.sh $(DESTDIR)$(ETCINSTALLDIR) + $(INSTALL) --mode=0644 -b $(SRCDIR)/miniupnpd.conf $(DESTDIR)$(ETCINSTALLDIR) sed -i -e "s/^uuid=[-0-9a-f]*/uuid=$(UUID)/" $(DESTDIR)$(ETCINSTALLDIR)/miniupnpd.conf $(INSTALL) -d $(DESTDIR)$(PREFIX)/etc/init.d - $(INSTALL) linux/miniupnpd.init.d.script $(DESTDIR)$(PREFIX)/etc/init.d/miniupnpd + $(INSTALL) $(SRCDIR)/linux/miniupnpd.init.d.script $(DESTDIR)$(PREFIX)/etc/init.d/miniupnpd $(INSTALL) -d $(DESTDIR)$(MANINSTALLDIR) $(INSTALL) --mode=0644 miniupnpd.8 $(DESTDIR)$(MANINSTALLDIR) gzip -f $(DESTDIR)$(MANINSTALLDIR)/miniupnpd.8 @@ -147,112 +135,45 @@ miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) testupnpdescgen: $(TESTUPNPDESCGENOBJS) -testgetifstats: testgetifstats.o linux/getifstats.o +testgetifstats: testgetifstats.o getifstats.o testupnppermissions: testupnppermissions.o upnppermissions.o testgetifaddr: testgetifaddr.o getifaddr.o -testgetroute: testgetroute.o linux/getroute.o upnputils.o +testgetroute: testgetroute.o getroute.o upnputils.o testasyncsendto: testasyncsendto.o asyncsendto.o upnputils.o \ - linux/getroute.o + getroute.o testportinuse: testportinuse.o portinuse.o getifaddr.o \ - netfilter_nft/nftnlrdr.o netfilter_nft/nftnlrdr_misc.o + nftnlrdr.o nftnlrdr_misc.o miniupnpdctl: miniupnpdctl.o -config.h: configure VERSION - ./configure $(CONFIG_OPTIONS) +config.mk config.h: $(SRCDIR)/configure $(SRCDIR)/VERSION + $(SHELL) $< $(CONFIG_OPTIONS) -depend: config.h - makedepend -f$(MAKEFILE_LIST) -Y \ - $(ALLOBJS:.o=.c) $(TESTUPNPDESCGENOBJS:.o=.c) \ - testgetifstats.c testupnppermissions.c testgetifaddr.c \ - testgetroute.c testasyncsendto.c testportinuse.c \ - miniupnpdctl.c 2>/dev/null +depend: $(DEP) -dox: - $(DOXYGEN) miniupnpd.doxyconf +%.d: $(SRCDIR)/%.c + $(CC) $(CPPFLAGS) $(DEPFLAGS) -o $@ $< -# DO NOT DELETE +dox: $(SRCDIR)/miniupnpd.doxyconf + (cat $< ; echo "INPUT=$(SRCDIR)" ) | $(DOXYGEN) - -miniupnpd.o: config.h macros.h upnpglobalvars.h upnppermissions.h -miniupnpd.o: miniupnpdtypes.h upnphttp.h upnpdescgen.h miniupnpdpath.h -miniupnpd.o: getifaddr.h upnpsoap.h options.h minissdp.h upnpredirect.h -miniupnpd.o: upnppinhole.h daemonize.h upnpevents.h asyncsendto.h natpmp.h -miniupnpd.o: pcpserver.h commonrdr.h upnputils.h ifacewatcher.h -upnphttp.o: config.h upnphttp.h upnpdescgen.h miniupnpdpath.h upnpsoap.h -upnphttp.o: upnpevents.h upnputils.h -upnpdescgen.o: config.h getifaddr.h upnpredirect.h upnpdescgen.h -upnpdescgen.o: miniupnpdpath.h upnpglobalvars.h upnppermissions.h -upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h upnpurns.h getconnstatus.h -upnpsoap.o: macros.h config.h upnpglobalvars.h upnppermissions.h -upnpsoap.o: miniupnpdtypes.h upnphttp.h upnpsoap.h upnpreplyparse.h -upnpsoap.o: upnpredirect.h upnppinhole.h getifaddr.h getifstats.h -upnpsoap.o: getconnstatus.h upnpurns.h -upnpreplyparse.o: upnpreplyparse.h minixml.h -minixml.o: minixml.h -portinuse.o: macros.h config.h upnpglobalvars.h upnppermissions.h -portinuse.o: miniupnpdtypes.h getifaddr.h portinuse.h netfilter_nft/nftnlrdr.h -portinuse.o: commonrdr.h -upnpredirect.o: macros.h config.h upnpredirect.h upnpglobalvars.h -upnpredirect.o: upnppermissions.h miniupnpdtypes.h upnpevents.h portinuse.h -upnpredirect.o: netfilter_nft/nftnlrdr.h commonrdr.h -getifaddr.o: config.h getifaddr.h -daemonize.o: daemonize.h config.h -upnpglobalvars.o: config.h upnpglobalvars.h upnppermissions.h -upnpglobalvars.o: miniupnpdtypes.h upnpdescstrings.h -options.o: config.h options.h upnppermissions.h upnpglobalvars.h -options.o: miniupnpdtypes.h -upnppermissions.o: config.h upnppermissions.h -minissdp.o: config.h upnpdescstrings.h miniupnpdpath.h upnphttp.h -minissdp.o: upnpglobalvars.h upnppermissions.h miniupnpdtypes.h minissdp.h -minissdp.o: upnputils.h getroute.h asyncsendto.h codelength.h -natpmp.o: macros.h config.h natpmp.h upnpglobalvars.h upnppermissions.h -natpmp.o: miniupnpdtypes.h getifaddr.h upnpredirect.h commonrdr.h upnputils.h -natpmp.o: portinuse.h asyncsendto.h -pcpserver.o: config.h pcpserver.h macros.h upnpglobalvars.h upnppermissions.h -pcpserver.o: miniupnpdtypes.h pcplearndscp.h upnpredirect.h commonrdr.h -pcpserver.o: getifaddr.h asyncsendto.h pcp_msg_struct.h netfilter_nft/nftnlrdr.h -pcpserver.o: commonrdr.h -upnpevents.o: config.h upnpevents.h miniupnpdpath.h upnpglobalvars.h -upnpevents.o: upnppermissions.h miniupnpdtypes.h upnpdescgen.h upnputils.h -upnputils.o: config.h upnputils.h upnpglobalvars.h upnppermissions.h -upnputils.o: miniupnpdtypes.h getroute.h -getconnstatus.o: getconnstatus.h getifaddr.h -upnppinhole.o: macros.h config.h upnpredirect.h upnpglobalvars.h -upnppinhole.o: upnppermissions.h miniupnpdtypes.h upnpevents.h -upnppinhole.o: netfilter_nft/nftpinhole.h -pcplearndscp.o: config.h upnpglobalvars.h upnppermissions.h miniupnpdtypes.h -pcplearndscp.o: pcplearndscp.h -asyncsendto.o: asyncsendto.h -linux/getifstats.o: config.h getifstats.h -linux/ifacewatcher.o: config.h ifacewatcher.h config.h minissdp.h -linux/ifacewatcher.o: miniupnpdtypes.h getifaddr.h upnpglobalvars.h -linux/ifacewatcher.o: upnppermissions.h natpmp.h -linux/getroute.o: getroute.h upnputils.h -netfilter_nft/nftnlrdr.o: macros.h config.h netfilter_nft/nftnlrdr.h commonrdr.h -netfilter_nft/nftnlrdr.o: netfilter_nft/nftnlrdr_misc.h -netfilter_nft/nftnlrdr.o: config.h upnppermissions.h -netfilter_nft/nftnlrdr.o: miniupnpdtypes.h -netfilter_nft/nftnlrdr_misc.o: macros.h config.h netfilter_nft/nftnlrdr_misc.h -netfilter_nft/nftnlrdr_misc.o: commonrdr.h -netfilter_nft/nftpinhole.o: config.h netfilter_nft/nftpinhole.h -netfilter_nft/nftpinhole.o: netfilter_nft/nftnlrdr_misc.h -netfilter_nft/nftpinhole.o: upnppermissions.h config.h miniupnpdtypes.h -testupnpdescgen.o: macros.h config.h upnpdescgen.h upnpdescstrings.h -testupnpdescgen.o: getifaddr.h -upnpdescgen.o: config.h getifaddr.h upnpredirect.h upnpdescgen.h -upnpdescgen.o: miniupnpdpath.h upnpglobalvars.h upnppermissions.h -upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h upnpurns.h getconnstatus.h -testgetifstats.o: getifstats.h -testupnppermissions.o: upnppermissions.h config.h -testgetifaddr.o: config.h getifaddr.h -testgetroute.o: getroute.h upnputils.h upnpglobalvars.h upnppermissions.h -testgetroute.o: config.h miniupnpdtypes.h -testasyncsendto.o: miniupnpdtypes.h config.h upnputils.h asyncsendto.h -testportinuse.o: macros.h config.h portinuse.h -miniupnpdctl.o: macros.h -upnpstun.o: config.h upnpstun.h netfilter/iptcrdr.h +%.o: $(SRCDIR)/%.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +%.o: $(SRCDIR)/linux/%.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +%.o: $(SRCDIR)/netfilter_nft/%.c + $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ + +print-%: + @echo "$* = $($*)" + +ifneq ($(MAKECMDGOALS),clean) +-include $(DEP) +endif diff --git a/miniupnpd/objects.mk b/miniupnpd/objects.mk new file mode 100644 index 0000000..b1fa75b --- /dev/null +++ b/miniupnpd/objects.mk @@ -0,0 +1,9 @@ +BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \ + upnpreplyparse.o minixml.o portinuse.o \ + upnpredirect.o getifaddr.o daemonize.o \ + options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \ + upnpglobalvars.o upnpevents.o upnputils.o getconnstatus.o \ + upnpstun.o upnppinhole.o pcplearndscp.o asyncsendto.o + +# sources in linux/ directory +LNXOBJS = getifstats.o ifacewatcher.o getroute.o