mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-04 10:23:50 +00:00
eb3cf72900
Tests confuse compilation-database-driven code analysis tools (specifically, some tests stub out certain functions and the stubs sometimes get preferred over real definitions). So, make them optional.
169 lines
5.0 KiB
Makefile
169 lines
5.0 KiB
Makefile
# $Id: Makefile.linux,v 1.95 2017/12/12 11:40:14 nanard Exp $
|
|
# MiniUPnP project
|
|
# (c) 2006-2024 Thomas Bernard
|
|
# http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
|
# Author : Thomas Bernard
|
|
# for use with GNU Make
|
|
#
|
|
# options can be passed to configure through CONFIG_OPTIONS :
|
|
# $ CONFIG_OPTIONS="--ipv6 --igd2" make
|
|
#
|
|
# To install use :
|
|
# $ DESTDIR=/dummyinstalldir make install
|
|
# or :
|
|
# $ INSTALLPREFIX=/usr/local make install
|
|
# or :
|
|
# $ make install
|
|
# (default INSTALLPREFIX is /usr)
|
|
#
|
|
# 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 :
|
|
# $ IPTABLESPATH=/path/to/iptables-1.4.1 make
|
|
#
|
|
CONFIG_OPTIONS ?= $(shell cat .configure.cache)
|
|
ifeq ($(filter --firewall=iptables,$(CONFIG_OPTIONS)),)
|
|
CONFIG_OPTIONS += --firewall=iptables
|
|
endif
|
|
|
|
# Make sucks, prove me wrong
|
|
, := ,
|
|
ifeq ($(filter -D_FORTIFY_SOURCE=% -Wp$(,)-D_FORTIFY_SOURCE=%,$(CPPFLAGS) $(CFLAGS)),)
|
|
CPPFLAGS += -D_FORTIFY_SOURCE=2
|
|
endif
|
|
CPPFLAGS += -D_GNU_SOURCE
|
|
|
|
#CFLAGS = -O -g -DDEBUG
|
|
CFLAGS ?= -Os
|
|
CFLAGS += -fno-strict-aliasing
|
|
CFLAGS += -fno-common
|
|
CFLAGS += -fstack-protector -fPIE
|
|
CFLAGS += -Wall
|
|
CFLAGS += -Wextra -Wstrict-prototypes -Wdeclaration-after-statement
|
|
#CFLAGS += -Wno-missing-field-initializers
|
|
#CFLAGS += -ansi # iptables headers does use typeof which is a gcc extension
|
|
LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie
|
|
CC ?= gcc
|
|
RM = rm -f
|
|
INSTALL = install
|
|
STRIP ?= strip
|
|
CP = cp
|
|
DOXYGEN ?= doxygen
|
|
|
|
DEPDIR := .depend
|
|
DEPFLAGS = -MMD -MP -MF $(@:%.o=$(DEPDIR)/%.d) -MT $@
|
|
# -M : with system headers, -MM : without
|
|
|
|
INSTALLPREFIX ?= $(PREFIX)/usr
|
|
SBININSTALLDIR ?= $(INSTALLPREFIX)/sbin
|
|
ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
|
|
MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
|
|
|
|
include config.mk
|
|
include $(SRCDIR)/gitrev.mk
|
|
include $(SRCDIR)/objects.mk
|
|
|
|
# sources in netfilter/ directory
|
|
NETFILTEROBJS = iptcrdr.o iptpinhole.o nfct_get.o
|
|
|
|
ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(OTHEROBJS)
|
|
|
|
NETFILTER_SCRIPTS = $(addprefix $(SRCDIR)/netfilter/, \
|
|
iptables_init.sh iptables_removeall.sh \
|
|
ip6tables_init.sh ip6tables_removeall.sh \
|
|
miniupnpd_functions.sh)
|
|
|
|
#LDLIBS += -lnfnetlink
|
|
|
|
EXECUTABLES = miniupnpd miniupnpdctl
|
|
|
|
ifeq ($(TESTS), 1)
|
|
EXECUTABLES += testupnpdescgen testgetifstats \
|
|
testupnppermissions testgetifaddr \
|
|
testgetroute testasyncsendto testportinuse \
|
|
testssdppktgen testminissdp
|
|
endif
|
|
|
|
.PHONY: all clean install dox
|
|
|
|
all: $(EXECUTABLES)
|
|
|
|
clean:
|
|
$(RM) $(ALLOBJS)
|
|
$(RM) -r $(DEPDIR)
|
|
$(RM) $(EXECUTABLES)
|
|
$(RM) validateupnppermissions validategetifaddr validatessdppktgen
|
|
$(RM) -r dox/
|
|
|
|
install: miniupnpd $(SRCDIR)/miniupnpd.8 $(SRCDIR)/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) $(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) -m 0644 -b $(SRCDIR)/miniupnpd.conf $(DESTDIR)$(ETCINSTALLDIR)
|
|
sed -i -e "s/^uuid=[-0-9a-f]*/uuid=$(shell $(UUIDBIN))/" $(DESTDIR)$(ETCINSTALLDIR)/miniupnpd.conf
|
|
$(INSTALL) -d $(DESTDIR)$(PREFIX)/etc/init.d
|
|
$(INSTALL) $(SRCDIR)/linux/miniupnpd.init.d.script $(DESTDIR)$(PREFIX)/etc/init.d/miniupnpd
|
|
$(INSTALL) -d $(DESTDIR)$(MANINSTALLDIR)
|
|
$(INSTALL) -m 0644 $(SRCDIR)/miniupnpd.8 $(DESTDIR)$(MANINSTALLDIR)
|
|
gzip -f $(DESTDIR)$(MANINSTALLDIR)/miniupnpd.8
|
|
|
|
include $(SRCDIR)/check.mk
|
|
|
|
miniupnpd: $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
|
|
|
|
testupnpdescgen: testupnpdescgen.o upnpdescgen.o
|
|
|
|
testgetifstats: testgetifstats.o getifstats.o
|
|
|
|
testupnppermissions: testupnppermissions.o upnppermissions.o
|
|
|
|
testgetifaddr: testgetifaddr.o getifaddr.o
|
|
|
|
testgetroute: testgetroute.o getroute.o upnputils.o
|
|
|
|
testssdppktgen: testssdppktgen.o
|
|
|
|
testasyncsendto: testasyncsendto.o asyncsendto.o upnputils.o \
|
|
getroute.o
|
|
|
|
testportinuse: testportinuse.o portinuse.o getifaddr.o \
|
|
iptcrdr.o
|
|
|
|
testminissdp: testminissdp.o minissdp.o upnputils.o upnpglobalvars.o \
|
|
asyncsendto.o getroute.o
|
|
|
|
miniupnpdctl: miniupnpdctl.o
|
|
|
|
config.mk config.h: $(SRCDIR)/configure $(SRCDIR)/VERSION
|
|
$(SHELL) $< $(CONFIG_OPTIONS)
|
|
|
|
dox: $(SRCDIR)/miniupnpd.doxyconf
|
|
(cat $< ; echo "INPUT=$(SRCDIR)" ) | $(DOXYGEN) -
|
|
|
|
%.o: $(SRCDIR)/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
|
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
%.o: $(SRCDIR)/linux/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
|
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
%.o: $(SRCDIR)/netfilter/%.c $(DEPDIR)/%.d | $(DEPDIR)
|
|
$(CC) -c $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) $< -o $@
|
|
|
|
print-%:
|
|
@echo "$* = $($*)"
|
|
|
|
|
|
DEPFILES := $(ALLOBJS:%.o=$(DEPDIR)/%.d)
|
|
$(DEPDIR): ; @mkdir -p $@
|
|
$(DEPFILES):
|
|
|
|
-include $(wildcard $(DEPFILES))
|