2015-03-11 12:10:25 +00:00
|
|
|
# MiniUPnP project
|
2021-09-30 21:20:52 +00:00
|
|
|
# (c) 2018-2021 Thomas Bernard
|
2015-03-11 12:10:25 +00:00
|
|
|
# (c) 2015 Tomofumi Hayashi
|
2020-04-28 22:38:07 +00:00
|
|
|
# http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
2015-03-11 12:10:25 +00:00
|
|
|
# Author : Tomofumi Hayashi
|
|
|
|
# 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
|
2015-03-11 12:10:25 +00:00
|
|
|
#
|
|
|
|
# To install use :
|
2020-04-28 22:38:07 +00:00
|
|
|
# $ DESTDIR=/dummyinstalldir make install
|
2015-03-11 12:10:25 +00:00
|
|
|
# or :
|
2020-04-28 22:38:07 +00:00
|
|
|
# $ INSTALLPREFIX=/usr/local make install
|
2015-03-11 12:10:25 +00:00
|
|
|
# or :
|
2020-04-28 22:38:07 +00:00
|
|
|
# $ make install
|
2015-03-11 12:10:25 +00:00
|
|
|
# (default INSTALLPREFIX is /usr)
|
|
|
|
#
|
|
|
|
#
|
2020-06-03 21:54:24 +00:00
|
|
|
CONFIG_OPTIONS ?= $(cat .configure.cache)
|
2019-09-29 05:17:51 +00:00
|
|
|
CONFIG_OPTIONS += --firewall=nftables
|
2020-05-10 18:00:50 +00:00
|
|
|
#CFLAGS = -O -g #-DDEBUG
|
2015-03-11 12:10:25 +00:00
|
|
|
CFLAGS ?= -Os
|
|
|
|
CFLAGS += -fno-strict-aliasing
|
|
|
|
CFLAGS += -fno-common
|
2020-05-10 18:00:50 +00:00
|
|
|
CFLAGS += -fstack-protector -fPIE
|
|
|
|
CFLAGS += -D_FORTIFY_SOURCE=2
|
2018-02-23 15:37:18 +00:00
|
|
|
CPPFLAGS += -D_GNU_SOURCE
|
2015-03-11 12:10:25 +00:00
|
|
|
CFLAGS += -Wall
|
|
|
|
CFLAGS += -Wextra -Wstrict-prototypes -Wdeclaration-after-statement
|
|
|
|
#CFLAGS += -Wno-missing-field-initializers
|
2020-05-10 18:00:50 +00:00
|
|
|
LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
|
2015-03-11 12:10:25 +00:00
|
|
|
CC ?= gcc
|
|
|
|
RM = rm -f
|
|
|
|
INSTALL = install
|
|
|
|
STRIP ?= strip
|
|
|
|
PKG_CONFIG ?= pkg-config
|
|
|
|
CP = cp
|
2019-09-18 01:22:11 +00:00
|
|
|
DOXYGEN ?= doxygen
|
2015-03-11 12:10:25 +00:00
|
|
|
|
2021-09-30 21:20:52 +00:00
|
|
|
DEPFLAGS = -MM -MG -MT $(patsubst %.d,%.o,$@) -MT $@
|
|
|
|
# -M : with system headers, -MM : without
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
INSTALLPREFIX ?= $(PREFIX)/usr
|
|
|
|
SBININSTALLDIR = $(INSTALLPREFIX)/sbin
|
|
|
|
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
|
|
|
|
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
|
|
|
|
|
2020-05-04 00:01:36 +00:00
|
|
|
include config.mk
|
|
|
|
include $(SRCDIR)/gitrev.mk
|
|
|
|
include $(SRCDIR)/objects.mk
|
2019-10-05 19:59:42 +00:00
|
|
|
|
2020-05-04 00:01:36 +00:00
|
|
|
# sources in the netfilter_nft/ directory
|
|
|
|
NETFILTEROBJS = nftnlrdr.o nftpinhole.o nfct_get.o nftnlrdr_misc.o
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
|
|
|
|
|
2021-09-30 21:20:52 +00:00
|
|
|
DEP = $(ALLOBJS:.o=.d)
|
2020-05-04 00:01:36 +00:00
|
|
|
|
|
|
|
NFT_SCRIPTS = $(addprefix $(SRCDIR)/netfilter_nft/scripts/, \
|
|
|
|
nft_init.sh nft_removeall.sh nft_flush.sh nft_delete_chain.sh)
|
|
|
|
|
2015-03-11 12:10:25 +00:00
|
|
|
PCFILE_FOUND := $(shell $(PKG_CONFIG) --exists libnftnl; echo $$?)
|
|
|
|
|
|
|
|
ifeq (${PCFILE_FOUND},0)
|
|
|
|
|
2015-03-18 06:27:57 +00:00
|
|
|
PKG_CONFIG_LIBS = libnftnl libmnl
|
|
|
|
CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKG_CONFIG_LIBS))
|
|
|
|
LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l $(PKG_CONFIG_LIBS))
|
|
|
|
LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-L $(PKG_CONFIG_LIBS))
|
|
|
|
LDFLAGS += $(shell $(PKG_CONFIG) --libs-only-other $(PKG_CONFIG_LIBS))
|
2015-03-11 12:10:25 +00:00
|
|
|
else
|
|
|
|
|
|
|
|
endif # ifdef PCFILE_FOUND
|
|
|
|
|
2015-04-26 14:15:41 +00:00
|
|
|
#LDLIBS += -lnfnetlink
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l libssl)
|
|
|
|
|
2018-07-01 21:22:18 +00:00
|
|
|
TEST := $(shell $(PKG_CONFIG) --exists uuid && echo 1)
|
|
|
|
ifeq ($(TEST),1)
|
|
|
|
LDLIBS += $(shell $(PKG_CONFIG) --static --libs-only-l uuid)
|
|
|
|
else
|
|
|
|
$(info please install uuid-dev package / libuuid)
|
|
|
|
endif # ($(TEST),1)
|
|
|
|
|
2019-09-18 01:22:11 +00:00
|
|
|
# genuuid uses the uuidgen CLI tool which is part of libuuid
|
|
|
|
# from the e2fsprogs
|
|
|
|
# 'cat /proc/sys/kernel/random/uuid' could be also used
|
|
|
|
#
|
|
|
|
ifeq ($(TARGET_OPENWRT),)
|
|
|
|
UUIDEXECDIR=''
|
|
|
|
else
|
|
|
|
UUIDEXECDIR="$(STAGING_DIR_HOST)/bin/"
|
|
|
|
endif
|
|
|
|
UUID=$(shell ($(UUIDEXECDIR)genuuid || $(UUIDEXECDIR)uuidgen || $(UUIDEXECDIR)uuid) 2> /dev/null )
|
|
|
|
|
|
|
|
|
2015-03-11 12:10:25 +00:00
|
|
|
TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
|
|
|
|
|
2019-09-18 01:22:11 +00:00
|
|
|
EXECUTABLES = miniupnpd miniupnpdctl \
|
|
|
|
testupnpdescgen testgetifstats \
|
|
|
|
testupnppermissions testgetifaddr \
|
2015-03-11 12:10:25 +00:00
|
|
|
testgetroute testasyncsendto testportinuse
|
|
|
|
|
2019-09-18 01:22:11 +00:00
|
|
|
.PHONY: all clean install depend dox
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
all: $(EXECUTABLES)
|
|
|
|
|
|
|
|
clean:
|
2019-09-29 05:17:51 +00:00
|
|
|
$(RM) config.h
|
2015-03-11 12:10:25 +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) miniupnpdctl.o
|
2019-09-18 01:22:11 +00:00
|
|
|
$(RM) -r dox/
|
2015-03-11 12:10:25 +00:00
|
|
|
|
2020-05-04 00:01:36 +00:00
|
|
|
install: miniupnpd $(SRCDIR)/miniupnpd.8 $(SRCDIR)/miniupnpd.conf \
|
|
|
|
$(NFT_SCRIPTS) \
|
|
|
|
$(SRCDIR)/linux/miniupnpd.init.d.script
|
2015-03-11 12:10:25 +00:00
|
|
|
$(STRIP) miniupnpd
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(SBININSTALLDIR)
|
|
|
|
$(INSTALL) miniupnpd $(DESTDIR)$(SBININSTALLDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(ETCINSTALLDIR)
|
2020-05-04 00:01:36 +00:00
|
|
|
$(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)
|
2019-09-18 01:22:11 +00:00
|
|
|
sed -i -e "s/^uuid=[-0-9a-f]*/uuid=$(UUID)/" $(DESTDIR)$(ETCINSTALLDIR)/miniupnpd.conf
|
2015-03-11 12:10:25 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(PREFIX)/etc/init.d
|
2020-05-04 00:01:36 +00:00
|
|
|
$(INSTALL) $(SRCDIR)/linux/miniupnpd.init.d.script $(DESTDIR)$(PREFIX)/etc/init.d/miniupnpd
|
2015-03-11 12:10:25 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(MANINSTALLDIR)
|
2021-09-30 21:20:52 +00:00
|
|
|
$(INSTALL) --mode=0644 $(SRCDIR)/miniupnpd.8 $(DESTDIR)$(MANINSTALLDIR)
|
2015-03-11 12:10:25 +00:00
|
|
|
gzip -f $(DESTDIR)$(MANINSTALLDIR)/miniupnpd.8
|
|
|
|
|
2020-05-06 23:02:48 +00:00
|
|
|
include $(SRCDIR)/check.mk
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
|
|
|
|
|
|
|
|
testupnpdescgen: $(TESTUPNPDESCGENOBJS)
|
|
|
|
|
2020-05-04 00:01:36 +00:00
|
|
|
testgetifstats: testgetifstats.o getifstats.o
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
testupnppermissions: testupnppermissions.o upnppermissions.o
|
|
|
|
|
|
|
|
testgetifaddr: testgetifaddr.o getifaddr.o
|
|
|
|
|
2020-05-04 00:01:36 +00:00
|
|
|
testgetroute: testgetroute.o getroute.o upnputils.o
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
testasyncsendto: testasyncsendto.o asyncsendto.o upnputils.o \
|
2020-05-04 00:01:36 +00:00
|
|
|
getroute.o
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
testportinuse: testportinuse.o portinuse.o getifaddr.o \
|
2020-05-04 00:01:36 +00:00
|
|
|
nftnlrdr.o nftnlrdr_misc.o
|
2015-03-11 12:10:25 +00:00
|
|
|
|
|
|
|
miniupnpdctl: miniupnpdctl.o
|
|
|
|
|
2020-05-04 00:01:36 +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_nft/%.c
|
|
|
|
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
|
|
|
|
print-%:
|
|
|
|
@echo "$* = $($*)"
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
|
|
|
-include $(DEP)
|
|
|
|
endif
|