2017-12-12 11:46:59 +00:00
|
|
|
# $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
|
2012-04-14 22:35:31 +00:00
|
|
|
#
|
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
|
2013-02-09 15:17:23 +00:00
|
|
|
# (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
|
|
|
#
|
2020-06-03 21:54:24 +00:00
|
|
|
CONFIG_OPTIONS ?= $(cat .configure.cache)
|
2019-09-29 05:17:51 +00:00
|
|
|
CONFIG_OPTIONS += --firewall=iptables
|
2012-05-01 09:34:41 +00:00
|
|
|
#CFLAGS = -O -g -DDEBUG
|
|
|
|
CFLAGS ?= -Os
|
|
|
|
CFLAGS += -fno-strict-aliasing
|
|
|
|
CFLAGS += -fno-common
|
2019-02-04 14:41:38 +00:00
|
|
|
CFLAGS += -fstack-protector -fPIE
|
|
|
|
CFLAGS += -D_FORTIFY_SOURCE=2
|
2014-04-29 20:56:24 +00:00
|
|
|
CPPFLAGS += -D_GNU_SOURCE
|
2012-05-01 09:34:41 +00:00
|
|
|
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
|
2019-02-04 14:41:38 +00:00
|
|
|
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
|
2014-04-29 20:47:01 +00:00
|
|
|
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
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
DEPFLAGS = -MM -MG -MT $(patsubst %.d,%.o,$@) -MT $@
|
|
|
|
# -M : with system headers, -MM : without
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
INSTALLPREFIX ?= $(PREFIX)/usr
|
|
|
|
SBININSTALLDIR = $(INSTALLPREFIX)/sbin
|
|
|
|
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
|
2012-08-24 18:13:15 +00:00
|
|
|
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
include config.mk
|
|
|
|
include $(SRCDIR)/gitrev.mk
|
2020-05-04 00:01:36 +00:00
|
|
|
include $(SRCDIR)/objects.mk
|
2019-10-05 19:59:42 +00:00
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
# sources in netfilter/ directory
|
|
|
|
NETFILTEROBJS = iptcrdr.o iptpinhole.o nfct_get.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
|
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
DEP = $(ALLOBJS:.o=.d)
|
|
|
|
|
|
|
|
NETFILTER_SCRIPTS = $(addprefix $(SRCDIR)/netfilter/, \
|
|
|
|
iptables_init.sh iptables_removeall.sh \
|
|
|
|
ip6tables_init.sh ip6tables_removeall.sh \
|
|
|
|
miniupnpd_functions.sh)
|
|
|
|
|
2020-04-28 23:51:00 +00:00
|
|
|
ifneq ($(IPTABLES_PCFILE_FOUND),1)
|
2013-05-03 09:33:36 +00:00
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
ifeq "$(wildcard /etc/gentoo-release )" ""
|
2014-04-29 20:53:29 +00:00
|
|
|
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
|
2014-04-29 20:53:29 +00:00
|
|
|
LDLIBS ?= -lip4tc
|
2014-04-29 20:56:24 +00:00
|
|
|
CPPFLAGS := -DIPTABLES_143 $(CPPFLAGS)
|
2011-09-28 19:13:20 +00:00
|
|
|
endif
|
|
|
|
|
2020-04-28 23:51:00 +00:00
|
|
|
endif # ifneq ($(IPTABLES_PCFILE_FOUND),1)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2015-04-26 14:15:41 +00:00
|
|
|
#LDLIBS += -lnfnetlink
|
2012-06-23 23:41:47 +00:00
|
|
|
|
2019-08-29 20:44:40 +00:00
|
|
|
# OpenWrt packager disables https server for IGD v2 and hardcodes libuuid support
|
|
|
|
ifeq ($(TARGET_OPENWRT),)
|
2014-04-29 20:53:29 +00:00
|
|
|
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)
|
2016-02-11 10:39:28 +00:00
|
|
|
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
|
|
|
|
2021-07-15 08:31:15 +00:00
|
|
|
ifneq ($(shell ldd --version | grep GLIBC),)
|
2018-07-14 12:23:13 +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 )
|
2021-07-15 08:31:15 +00:00
|
|
|
endif
|
2018-07-14 12:23:13 +00:00
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
|
|
|
|
|
|
|
|
EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
|
2012-06-23 23:41:47 +00:00
|
|
|
testupnppermissions miniupnpdctl testgetifaddr \
|
2015-10-24 15:02:11 +00:00
|
|
|
testgetroute testasyncsendto testportinuse \
|
2017-12-12 11:46:59 +00:00
|
|
|
testssdppktgen testminissdp
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
.PHONY: all clean install depend dox
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
all: $(EXECUTABLES)
|
|
|
|
|
|
|
|
clean:
|
2019-09-29 05:17:51 +00:00
|
|
|
$(RM) config.h
|
2011-09-28 19:13:20 +00:00
|
|
|
$(RM) $(ALLOBJS)
|
2020-05-03 23:31:31 +00:00
|
|
|
$(RM) $(DEP)
|
2011-09-28 19:13:20 +00:00
|
|
|
$(RM) $(EXECUTABLES)
|
|
|
|
$(RM) testupnpdescgen.o testgetifstats.o
|
|
|
|
$(RM) testupnppermissions.o testgetifaddr.o
|
2014-02-18 08:34:42 +00:00
|
|
|
$(RM) testgetroute.o testasyncsendto.o
|
2014-12-15 10:59:17 +00:00
|
|
|
$(RM) testportinuse.o
|
2019-03-22 14:36:58 +00:00
|
|
|
$(RM) testminissdp.o
|
|
|
|
$(RM) testssdppktgen.o
|
2011-09-28 19:13:20 +00:00
|
|
|
$(RM) miniupnpdctl.o
|
2015-10-25 15:33:24 +00:00
|
|
|
$(RM) validateupnppermissions validategetifaddr validatessdppktgen
|
2019-09-24 09:20:17 +00:00
|
|
|
$(RM) -r dox/
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
install: miniupnpd $(SRCDIR)/miniupnpd.8 miniupnpd.conf \
|
|
|
|
$(NETFILTER_SCRIPTS) \
|
|
|
|
$(SRCDIR)/linux/miniupnpd.init.d.script
|
2011-09-28 19:13:20 +00:00
|
|
|
$(STRIP) miniupnpd
|
2013-02-09 15:17:23 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(SBININSTALLDIR)
|
|
|
|
$(INSTALL) miniupnpd $(DESTDIR)$(SBININSTALLDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(ETCINSTALLDIR)
|
2020-05-03 23:31:31 +00:00
|
|
|
$(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)
|
2013-02-09 15:17:23 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(PREFIX)/etc/init.d
|
2020-05-03 23:31:31 +00:00
|
|
|
$(INSTALL) $(SRCDIR)/linux/miniupnpd.init.d.script $(DESTDIR)$(PREFIX)/etc/init.d/miniupnpd
|
2013-02-09 15:17:23 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(MANINSTALLDIR)
|
2020-05-03 23:31:31 +00:00
|
|
|
$(INSTALL) --mode=0644 $(SRCDIR)/miniupnpd.8 $(DESTDIR)$(MANINSTALLDIR)
|
2014-10-08 11:24:01 +00:00
|
|
|
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
|
2020-05-03 23:31:31 +00:00
|
|
|
miniupnpd.conf: $(SRCDIR)/miniupnpd.conf
|
2011-09-28 19:13:20 +00:00
|
|
|
ifeq ($(TARGET_OPENWRT),)
|
2020-05-04 00:01:36 +00:00
|
|
|
sed -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen||uuid) 2>/dev/null`/" $< > $@.tmp
|
2011-09-28 19:13:20 +00:00
|
|
|
else
|
2020-05-04 00:01:36 +00:00
|
|
|
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
|
2011-09-28 19:13:20 +00:00
|
|
|
endif
|
2020-05-04 00:01:36 +00:00
|
|
|
mv $@.tmp $@
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2020-05-06 23:02:48 +00:00
|
|
|
include $(SRCDIR)/check.mk
|
2015-10-24 15:02:11 +00:00
|
|
|
|
2014-04-29 20:53:29 +00:00
|
|
|
miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
testupnpdescgen: $(TESTUPNPDESCGENOBJS)
|
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
testgetifstats: testgetifstats.o getifstats.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
testupnppermissions: testupnppermissions.o upnppermissions.o
|
|
|
|
|
|
|
|
testgetifaddr: testgetifaddr.o getifaddr.o
|
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
testgetroute: testgetroute.o getroute.o upnputils.o
|
2012-06-23 23:41:47 +00:00
|
|
|
|
2015-10-24 15:02:11 +00:00
|
|
|
testssdppktgen: testssdppktgen.o
|
|
|
|
|
2014-03-03 11:35:12 +00:00
|
|
|
testasyncsendto: testasyncsendto.o asyncsendto.o upnputils.o \
|
2020-05-03 23:31:31 +00:00
|
|
|
getroute.o
|
2014-02-18 08:34:42 +00:00
|
|
|
|
2014-03-14 11:07:03 +00:00
|
|
|
testportinuse: testportinuse.o portinuse.o getifaddr.o \
|
2020-05-03 23:31:31 +00:00
|
|
|
iptcrdr.o
|
2014-03-14 11:07:03 +00:00
|
|
|
|
2017-12-12 11:46:59 +00:00
|
|
|
testminissdp: testminissdp.o minissdp.o upnputils.o upnpglobalvars.o \
|
2020-05-03 23:31:31 +00:00
|
|
|
asyncsendto.o getroute.o
|
2017-12-12 11:46:59 +00:00
|
|
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
miniupnpdctl: miniupnpdctl.o
|
|
|
|
|
2020-05-03 23:31:31 +00:00
|
|
|
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)/linux/%.c
|
|
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
|
|
|
|
%.o: $(SRCDIR)/netfilter/%.c
|
|
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
|
|
|
|
print-%:
|
|
|
|
@echo "$* = $($*)"
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
-include $(DEP)
|
|
|
|
endif
|