miniupnpd: allow to build in another directory. use .d for depends

This commit is contained in:
Thomas Bernard 2020-05-04 01:31:31 +02:00
parent 9ffc336b5c
commit 4f67061e08
No known key found for this signature in database
GPG Key ID: 0FF11B67A5C0863C
8 changed files with 76 additions and 135 deletions

View File

@ -1,4 +1,5 @@
*.o
*.d
*.bak
config.h
ipfw/testipfwrdr

View File

@ -42,13 +42,16 @@ PKG_CONFIG ?= pkg-config
CP = cp
DOXYGEN ?= doxygen
DEPFLAGS = -MM -MG -MT $(patsubst %.d,%.o,$@) -MT $@
# -M : with system headers, -MM : without
INSTALLPREFIX ?= $(PREFIX)/usr
SBININSTALLDIR = $(INSTALLPREFIX)/sbin
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
include gitrev.mk config.mk
include config.mk
include $(SRCDIR)/gitrev.mk
BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpreplyparse.o minixml.o portinuse.o \
@ -58,11 +61,20 @@ BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpstun.o \
upnppinhole.o pcplearndscp.o asyncsendto.o
LNXOBJS = linux/getifstats.o linux/ifacewatcher.o linux/getroute.o
NETFILTEROBJS = netfilter/iptcrdr.o netfilter/iptpinhole.o netfilter/nfct_get.o
# sources in linux/ directory
LNXOBJS = getifstats.o ifacewatcher.o getroute.o
# sources in netfilter/ directory
NETFILTEROBJS = iptcrdr.o iptpinhole.o nfct_get.o
ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
DEP = $(ALLOBJS:.o=.d)
NETFILTER_SCRIPTS = $(addprefix $(SRCDIR)/netfilter/, \
iptables_init.sh iptables_removeall.sh \
ip6tables_init.sh ip6tables_removeall.sh \
miniupnpd_functions.sh)
ifneq ($(IPTABLES_PCFILE_FOUND),1)
ifeq "$(wildcard /etc/gentoo-release )" ""
@ -106,16 +118,14 @@ EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
testgetroute testasyncsendto testportinuse \
testssdppktgen testminissdp
.PHONY: all clean install depend genuuid dox
.PHONY: all clean install depend dox
all: $(EXECUTABLES)
config.mk: configure
./configure $(CONFIG_OPTIONS)
clean:
$(RM) config.h
$(RM) $(ALLOBJS)
$(RM) $(DEP)
$(RM) $(EXECUTABLES)
$(RM) testupnpdescgen.o testgetifstats.o
$(RM) testupnppermissions.o testgetifaddr.o
@ -127,171 +137,100 @@ clean:
$(RM) validateupnppermissions validategetifaddr validatessdppktgen
$(RM) -r dox/
install: miniupnpd miniupnpd.8 miniupnpd.conf genuuid \
netfilter/iptables_init.sh netfilter/iptables_removeall.sh \
netfilter/ip6tables_init.sh netfilter/ip6tables_removeall.sh \
netfilter/miniupnpd_functions.sh \
linux/miniupnpd.init.d.script
install: miniupnpd $(SRCDIR)/miniupnpd.8 miniupnpd.conf \
$(NETFILTER_SCRIPTS) \
$(SRCDIR)/linux/miniupnpd.init.d.script
$(STRIP) miniupnpd
$(INSTALL) -d $(DESTDIR)$(SBININSTALLDIR)
$(INSTALL) miniupnpd $(DESTDIR)$(SBININSTALLDIR)
$(INSTALL) -d $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) netfilter/iptables_init.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) netfilter/iptables_removeall.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) netfilter/ip6tables_init.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) netfilter/ip6tables_removeall.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) netfilter/miniupnpd_functions.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) --mode=0644 -b miniupnpd.conf $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) $(SRCDIR)/netfilter/iptables_init.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) $(SRCDIR)/netfilter/iptables_removeall.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) $(SRCDIR)/netfilter/ip6tables_init.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) $(SRCDIR)/netfilter/ip6tables_removeall.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) $(SRCDIR)/netfilter/miniupnpd_functions.sh $(DESTDIR)$(ETCINSTALLDIR)
$(INSTALL) --mode=0644 -b $(SRCDIR)/miniupnpd.conf $(DESTDIR)$(ETCINSTALLDIR)
$(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)
$(INSTALL) --mode=0644 $(SRCDIR)/miniupnpd.8 $(DESTDIR)$(MANINSTALLDIR)
gzip -f $(DESTDIR)$(MANINSTALLDIR)/miniupnpd.8
# genuuid is using the uuidgen CLI tool which is part of libuuid
# from the e2fsprogs
# 'cat /proc/sys/kernel/random/uuid' could be also used
genuuid:
miniupnpd.conf: $(SRCDIR)/miniupnpd.conf
ifeq ($(TARGET_OPENWRT),)
sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen||uuid) 2>/dev/null`/" miniupnpd.conf
sed -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen||uuid) 2>/dev/null`/" $< > $@
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`/" miniupnpd.conf
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`/" $< > $@
endif
check: validateupnppermissions validategetifaddr validatessdppktgen \
validateversion
validateversion: miniupnpd VERSION
validateversion: miniupnpd $(SRCDIR)/VERSION
./miniupnpd --version
[ "`./miniupnpd --version | head -1 | cut -d' ' -f-2`" = "miniupnpd `cat VERSION`" ]
[ "`./miniupnpd --version | head -1 | cut -d' ' -f-2`" = "miniupnpd `cat $(SRCDIR)/VERSION`" ]
touch $@
validateupnppermissions: testupnppermissions testupnppermissions.sh
./testupnppermissions.sh
touch $@
validategetifaddr: testgetifaddr testgetifaddr.sh
./testgetifaddr.sh
validate%: $(SRCDIR)/test%.sh test%
$(SHELL) $<
touch $@
validatessdppktgen: testssdppktgen
./testssdppktgen
./$<
touch $@
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
testssdppktgen: testssdppktgen.o
testasyncsendto: testasyncsendto.o asyncsendto.o upnputils.o \
linux/getroute.o
getroute.o
testportinuse: testportinuse.o portinuse.o getifaddr.o \
netfilter/iptcrdr.o
iptcrdr.o
testminissdp: testminissdp.o minissdp.o upnputils.o upnpglobalvars.o \
asyncsendto.o linux/getroute.o
asyncsendto.o getroute.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 testssdppktgen.c 2>/dev/null
depend: $(DEP)
dox: miniupnpd.doxyconf
$(DOXYGEN) $<
%.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 upnpglobalvars.h upnppermissions.h
upnphttp.o: miniupnpdtypes.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/iptcrdr.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/iptcrdr.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 macros.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/iptcrdr.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.h
upnppinhole.o: netfilter/iptpinhole.h
pcplearndscp.o: config.h upnpglobalvars.h upnppermissions.h miniupnpdtypes.h
pcplearndscp.o: pcplearndscp.h
asyncsendto.o: asyncsendto.h upnputils.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/iptcrdr.o: macros.h config.h netfilter/iptcrdr.h commonrdr.h
netfilter/iptcrdr.o: config.h upnpglobalvars.h upnppermissions.h
netfilter/iptcrdr.o: miniupnpdtypes.h
netfilter/iptpinhole.o: config.h netfilter/iptpinhole.h upnpglobalvars.h
netfilter/iptpinhole.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
testssdppktgen.o: macros.h config.h miniupnpdpath.h upnphttp.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/%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
print-%:
@echo "$* = $($*)"
ifneq ($(MAKECMDGOALS),clean)
-include $(DEP)
endif

11
miniupnpd/configure vendored
View File

@ -66,6 +66,7 @@ case "$argv" in
esac
done
BASEDIR=`dirname "$0"`
RM="rm -f"
MV="mv"
CONFIGFILE=`mktemp tmp.config.h.XXXXXXXXXX`
@ -140,7 +141,7 @@ echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
echo "#include <inttypes.h>" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
echo "#define MINIUPNPD_VERSION \"`cat VERSION`\"" >> ${CONFIGFILE}
echo "#define MINIUPNPD_VERSION \"`cat ${BASEDIR}/VERSION`\"" >> ${CONFIGFILE}
echo "#define MINIUPNPD_DATE \"$MINIUPNPD_DATE\"" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE}
@ -436,6 +437,8 @@ case $FW in
echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
echo "#define USE_IPTABLES 1" >> ${CONFIGFILE}
echo "# generated by $0 on `date`" > config.mk
echo "SRCDIR = ${BASEDIR}" >> config.mk
echo "CPPFLAGS += -I." >> config.mk
if [ "$PKG_CONFIG" ] ; then
if ${PKG_CONFIG} --exists libiptc ; then
IPTABLESVERSION=`${PKG_CONFIG} --modversion libiptc`
@ -535,13 +538,13 @@ if [ "$FW" = "iptables" ] || [ "$FW" = "nftables" ] ; then
if ${PKG_CONFIG} --exists libcap-ng ; then
echo "detected libcap-ng `${PKG_CONFIG} --modversion libcap-ng`"
echo "CFLAGS += `${PKG_CONFIG} --cflags libcap-ng`" >> config.mk
echo "LDLIBS += `${PKG_CONFIG} --static --libs-only-l libcap-ng`" >> config.mk
echo "LDLIBS += `${PKG_CONFIG} --libs-only-l libcap-ng`" >> config.mk
echo "LDFLAGS += `${PKG_CONFIG} --libs-only-L --libs-only-other libcap-ng`" >> config.mk
echo "#define HAS_LIBCAP_NG" >> ${CONFIGFILE}
elif ${PKG_CONFIG} --exists libcap ; then
echo "detected libcap `${PKG_CONFIG} --modversion libcap`"
echo "CFLAGS += `${PKG_CONFIG} --cflags libcap`" >> config.mk
echo "LDLIBS += `${PKG_CONFIG} --static --libs-only-l libcap`" >> config.mk
echo "LDLIBS += `${PKG_CONFIG} --libs-only-l libcap`" >> config.mk
echo "LDFLAGS += `${PKG_CONFIG} --libs-only-L --libs-only-other libcap`" >> config.mk
echo "#define HAS_LIBCAP" >> ${CONFIGFILE}
fi
@ -552,7 +555,7 @@ if [ "$MAKEFILE" = "Makefile.bsd" ] || [ "$OS_NAME" = "Darwin" ] || [ "$OS_NAME"
echo "FWNAME = $FW" > bsdmake.inc
fi
if [ "$MAKEFILE" ] ; then
cp -v $MAKEFILE Makefile
cp -v "${BASEDIR}/${MAKEFILE}" Makefile
fi
# UUID API

View File

@ -11,7 +11,7 @@
#include <string.h>
#include <time.h>
#include "../config.h"
#include "config.h"
#include "../getifstats.h"
#ifdef GET_WIRELESS_STATS

View File

@ -1,7 +1,7 @@
/* $Id: ifacewatcher.c,v 1.10 2019/10/02 22:02:02 nanard Exp $ */
/* MiniUPnP project
* http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
* (c) 2006-2019 Thomas Bernard
* (c) 2006-2020 Thomas Bernard
*
* ifacewatcher.c
*
@ -48,7 +48,7 @@
#include <stdlib.h>
#include <signal.h>
#include "../config.h"
#include "config.h"
#include "../macros.h"
#ifdef USE_IFACEWATCHER

View File

@ -835,7 +835,6 @@ FILE_PATTERNS = *.c \
*.hpp \
*.h++ \
*.cs \
*.d \
*.php \
*.php4 \
*.php5 \

View File

@ -20,7 +20,7 @@
#include <linux/version.h>
#include "../config.h"
#include "config.h"
#ifdef IPTABLES_143
/* IPTABLES API version >= 1.4.3 */
@ -61,7 +61,6 @@
#endif
#include "../macros.h"
#include "../config.h"
#include "iptcrdr.h"
#include "../upnpglobalvars.h"

View File

@ -12,7 +12,7 @@
#include <arpa/inet.h>
#include <sys/queue.h>
#include "../config.h"
#include "config.h"
#include "../macros.h"
#include "iptpinhole.h"
#include "../upnpglobalvars.h"