miniupnp/miniupnpd/Makefile.linux

298 lines
11 KiB
Makefile
Raw Normal View History

# $Id: Makefile.linux,v 1.95 2017/12/12 11:40:14 nanard Exp $
2011-09-28 19:13:20 +00:00
# MiniUPnP project
2020-04-28 22:38:07 +00:00
# (c) 2006-2020 Thomas Bernard
# http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
2011-09-28 19:13:20 +00:00
# Author : Thomas Bernard
# for use with GNU Make
#
2020-04-28 22:38:07 +00:00
# options can be passed to configure through CONFIG_OPTIONS :
# $ CONFIG_OPTIONS="--ipv6 --igd2" make
#
2011-09-28 19:13:20 +00:00
# To install use :
2020-04-28 22:38:07 +00:00
# $ DESTDIR=/dummyinstalldir make install
2011-09-28 19:13:20 +00:00
# or :
2020-04-28 22:38:07 +00:00
# $ INSTALLPREFIX=/usr/local make install
2011-09-28 19:13:20 +00:00
# or :
2020-04-28 22:38:07 +00:00
# $ make install
# (default INSTALLPREFIX is /usr)
2011-09-28 19:13:20 +00:00
#
# if your system hasn't iptables libiptc headers and binary correctly
# installed, you need to get iptables sources from http://netfilter.org/
# ./configure them and build them then miniupnpd will build using :
2020-04-28 22:38:07 +00:00
# $ IPTABLESPATH=/path/to/iptables-1.4.1 make
2011-09-28 19:13:20 +00:00
#
CONFIG_OPTIONS += --firewall=iptables
#CFLAGS = -O -g -DDEBUG
CFLAGS ?= -Os
CFLAGS += -fno-strict-aliasing
CFLAGS += -fno-common
CFLAGS += -fstack-protector -fPIE
CFLAGS += -D_FORTIFY_SOURCE=2
CPPFLAGS += -D_GNU_SOURCE
CFLAGS += -Wall
CFLAGS += -Wextra -Wstrict-prototypes -Wdeclaration-after-statement
2012-05-24 16:24:55 +00:00
#CFLAGS += -Wno-missing-field-initializers
2012-06-08 18:17:35 +00:00
#CFLAGS += -ansi # iptables headers does use typeof which is a gcc extension
LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
2011-09-28 19:13:20 +00:00
CC ?= gcc
RM = rm -f
INSTALL = install
STRIP ?= strip
PKG_CONFIG ?= pkg-config
2011-09-28 19:13:20 +00:00
CP = cp
2019-09-24 09:20:17 +00:00
DOXYGEN ?= doxygen
2011-09-28 19:13:20 +00:00
INSTALLPREFIX ?= $(PREFIX)/usr
SBININSTALLDIR = $(INSTALLPREFIX)/sbin
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
2011-09-28 19:13:20 +00:00
include gitrev.mk config.mk
2011-09-28 19:13:20 +00:00
BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
upnpreplyparse.o minixml.o portinuse.o \
upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
2013-12-13 13:41:21 +00:00
options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \
upnpevents.o upnputils.o getconnstatus.o \
upnpstun.o \
2014-02-25 10:10:05 +00:00
upnppinhole.o pcplearndscp.o asyncsendto.o
2011-09-28 19:13:20 +00:00
LNXOBJS = linux/getifstats.o linux/ifacewatcher.o linux/getroute.o
2013-07-09 13:36:53 +00:00
NETFILTEROBJS = netfilter/iptcrdr.o netfilter/iptpinhole.o netfilter/nfct_get.o
2011-09-28 19:13:20 +00:00
ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
ifneq ($(IPTABLES_PCFILE_FOUND),1)
2011-09-28 19:13:20 +00:00
ifeq "$(wildcard /etc/gentoo-release )" ""
LDLIBS ?= -liptc
2011-09-28 19:13:20 +00:00
else # gentoo
# the following is better, at least on gentoo with iptables 1.4.6
2015-10-25 15:19:21 +00:00
# see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1618
2011-09-28 19:13:20 +00:00
# and http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=2183
LDLIBS ?= -lip4tc
CPPFLAGS := -DIPTABLES_143 $(CPPFLAGS)
2011-09-28 19:13:20 +00:00
endif
endif # ifneq ($(IPTABLES_PCFILE_FOUND),1)
2011-09-28 19:13:20 +00:00
#LDLIBS += -lnfnetlink
2019-08-29 20:44:40 +00:00
# OpenWrt packager disables https server for IGD v2 and hardcodes libuuid support
ifeq ($(TARGET_OPENWRT),)
LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l libssl)
2014-04-09 13:35:06 +00:00
2016-02-12 14:29:49 +00:00
TEST := $(shell $(PKG_CONFIG) --exists uuid && echo 1)
ifeq ($(TEST),1)
LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l uuid)
2016-02-12 14:29:49 +00:00
else
$(info please install uuid-dev package / libuuid)
endif # ($(TEST),1)
2019-08-29 20:44:40 +00:00
endif # ($(TARGET_OPENWRT,)
2014-04-09 13:35:06 +00:00
GLIBC_VERSION := $(shell ldd --version | head -n 1 | sed 's/^.* //')
GLIBC_VERSION_MAJOR = $(shell echo $(GLIBC_VERSION) | cut -f 1 -d . )
GLIBC_VERSION_MINOR = $(shell echo $(GLIBC_VERSION) | cut -f 2 -d . )
# clock_gettime() needs -lrt when glibc version < 2.17
LDLIBS += $(shell if [ $(GLIBC_VERSION_MAJOR) -lt 2 ] \
|| [ \( $(GLIBC_VERSION_MAJOR) -eq 2 \) -a \( $(GLIBC_VERSION_MINOR) -lt 17 \) ] ; \
then echo "-lrt" ; fi )
2011-09-28 19:13:20 +00:00
TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
testupnppermissions miniupnpdctl testgetifaddr \
testgetroute testasyncsendto testportinuse \
testssdppktgen testminissdp
2011-09-28 19:13:20 +00:00
2019-09-24 09:20:17 +00:00
.PHONY: all clean install depend genuuid dox
2011-09-28 19:13:20 +00:00
all: $(EXECUTABLES)
config.mk: configure
./configure $(CONFIG_OPTIONS)
2011-09-28 19:13:20 +00:00
clean:
$(RM) config.h
2011-09-28 19:13:20 +00:00
$(RM) $(ALLOBJS)
$(RM) $(EXECUTABLES)
$(RM) testupnpdescgen.o testgetifstats.o
$(RM) testupnppermissions.o testgetifaddr.o
$(RM) testgetroute.o testasyncsendto.o
$(RM) testportinuse.o
$(RM) testminissdp.o
$(RM) testssdppktgen.o
2011-09-28 19:13:20 +00:00
$(RM) miniupnpdctl.o
$(RM) validateupnppermissions validategetifaddr validatessdppktgen
2019-09-24 09:20:17 +00:00
$(RM) -r dox/
2011-09-28 19:13:20 +00:00
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
2011-09-28 19:13:20 +00:00
$(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) -d $(DESTDIR)$(PREFIX)/etc/init.d
$(INSTALL) 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
2011-09-28 19:13:20 +00:00
# genuuid is using the uuidgen CLI tool which is part of libuuid
# from the e2fsprogs
2013-05-03 09:34:39 +00:00
# 'cat /proc/sys/kernel/random/uuid' could be also used
2011-09-28 19:13:20 +00:00
genuuid:
ifeq ($(TARGET_OPENWRT),)
sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen||uuid) 2>/dev/null`/" miniupnpd.conf
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
endif
2019-10-05 20:31:24 +00:00
check: validateupnppermissions validategetifaddr validatessdppktgen \
validateversion
validateversion: miniupnpd VERSION
./miniupnpd --version
[ "`./miniupnpd --version | head -1 | cut -d' ' -f-2`" = "miniupnpd `cat VERSION`" ]
touch $@
2015-09-22 14:02:19 +00:00
validateupnppermissions: testupnppermissions testupnppermissions.sh
./testupnppermissions.sh
touch $@
2015-09-22 14:51:56 +00:00
validategetifaddr: testgetifaddr testgetifaddr.sh
./testgetifaddr.sh
touch $@
validatessdppktgen: testssdppktgen
./testssdppktgen
touch $@
miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
2011-09-28 19:13:20 +00:00
testupnpdescgen: $(TESTUPNPDESCGENOBJS)
testgetifstats: testgetifstats.o linux/getifstats.o
testupnppermissions: testupnppermissions.o upnppermissions.o
testgetifaddr: testgetifaddr.o getifaddr.o
testgetroute: testgetroute.o linux/getroute.o upnputils.o
testssdppktgen: testssdppktgen.o
testasyncsendto: testasyncsendto.o asyncsendto.o upnputils.o \
linux/getroute.o
testportinuse: testportinuse.o portinuse.o getifaddr.o \
netfilter/iptcrdr.o
testminissdp: testminissdp.o minissdp.o upnputils.o upnpglobalvars.o \
asyncsendto.o linux/getroute.o
2011-09-28 19:13:20 +00:00
miniupnpdctl: miniupnpdctl.o
2020-04-28 22:38:07 +00:00
config.h: configure VERSION
./configure $(CONFIG_OPTIONS)
2011-09-28 19:13:20 +00:00
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
2011-09-28 19:13:20 +00:00
2019-09-24 09:20:17 +00:00
dox: miniupnpd.doxyconf
$(DOXYGEN) $<
2011-09-28 19:13:20 +00:00
# DO NOT DELETE
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
2011-09-28 19:13:20 +00:00
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
2011-09-28 19:13:20 +00:00
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
2011-09-28 19:13:20 +00:00
upnpreplyparse.o: upnpreplyparse.h minixml.h
minixml.o: minixml.h
portinuse.o: macros.h config.h upnpglobalvars.h upnppermissions.h
2013-12-13 11:29:01 +00:00
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
2011-09-28 19:13:20 +00:00
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
2011-09-28 19:13:20 +00:00
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
2014-01-27 10:09:30 +00:00
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
2011-09-28 19:13:20 +00:00
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
2014-01-27 10:09:30 +00:00
upnputils.o: miniupnpdtypes.h getroute.h
2011-09-28 19:13:20 +00:00
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
2011-09-28 19:13:20 +00:00
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
2011-09-28 19:13:20 +00:00
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
2018-07-06 11:36:23 +00:00
upnpstun.o: config.h upnpstun.h netfilter/iptcrdr.h