2016-02-10 20:37:00 +00:00
|
|
|
|
# $Id: Makefile,v 1.88 2016/02/10 20:32:43 nanard Exp $
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# MiniUPnP project
|
|
|
|
|
# http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
|
|
|
|
# Author: Thomas Bernard
|
|
|
|
|
#
|
|
|
|
|
# Makefile for miniupnpd (MiniUPnP daemon)
|
|
|
|
|
#
|
|
|
|
|
# This Makefile should work for *BSD and SunOS/Solaris.
|
|
|
|
|
# On Mac OS X, use "bsdmake" to build.
|
|
|
|
|
# This Makefile is NOT compatible with GNU Make.
|
|
|
|
|
# Linux users, please use Makefile.linux :
|
|
|
|
|
# make -f Makefile.linux
|
2012-04-14 22:35:31 +00:00
|
|
|
|
#
|
|
|
|
|
# options can be passed to genconfig.sh through CONFIG_OPTIONS :
|
|
|
|
|
# $ CONFIG_OPTIONS="--ipv6 --igd2" make
|
|
|
|
|
#
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
2012-05-01 09:34:41 +00:00
|
|
|
|
CFLAGS ?= -pipe -Os
|
|
|
|
|
#CFLAGS = -pipe -O -g -DDEBUG
|
2014-04-01 09:43:31 +00:00
|
|
|
|
#CFLAGS += -ansi
|
2012-05-01 09:34:41 +00:00
|
|
|
|
CFLAGS += -Wall
|
|
|
|
|
CFLAGS += -W
|
2012-05-24 16:24:55 +00:00
|
|
|
|
CFLAGS += -Wstrict-prototypes
|
|
|
|
|
#CFLAGS += -Wdeclaration-after-statement
|
|
|
|
|
#CFLAGS += -Wno-missing-field-initializers
|
|
|
|
|
CFLAGS += -fno-common
|
2011-09-28 19:13:20 +00:00
|
|
|
|
CC ?= gcc
|
|
|
|
|
RM = rm -f
|
|
|
|
|
MV = mv
|
|
|
|
|
INSTALL = install
|
|
|
|
|
STRIP = strip
|
|
|
|
|
|
|
|
|
|
# OSNAME and FWNAME are used for building OS or FW dependent code.
|
|
|
|
|
OSNAME != uname -s
|
|
|
|
|
ARCH != uname -m
|
|
|
|
|
.ifndef FWNAME
|
2014-04-17 10:54:14 +00:00
|
|
|
|
#.if exists(/usr/include/net/pfvar.h)
|
|
|
|
|
#FWNAME = pf
|
|
|
|
|
#.else
|
|
|
|
|
#FWNAME = ipf
|
|
|
|
|
#.endif
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
2014-04-18 08:26:09 +00:00
|
|
|
|
.if $(OSNAME) == "OpenBSD"
|
|
|
|
|
FWNAME = pf
|
|
|
|
|
.endif
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# better way to find if we are using ipf or pf
|
|
|
|
|
.if $(OSNAME) == "FreeBSD"
|
2016-12-28 11:10:06 +00:00
|
|
|
|
.if exists(/etc/rc.subr) && exists(/etc/default/rc.conf)
|
|
|
|
|
FWNAME != . /etc/rc.subr; . /etc/default/rc.conf; \
|
2011-09-28 19:13:20 +00:00
|
|
|
|
if checkyesno ipfilter_enable; then \
|
2014-04-07 10:39:05 +00:00
|
|
|
|
echo "ipf"; elif checkyesno pf_enable; then \
|
2014-06-21 06:23:16 +00:00
|
|
|
|
echo "pf"; elif checkyesno firewall_enable; then \
|
|
|
|
|
echo "ipfw"; else echo "pf"; fi
|
|
|
|
|
.else
|
|
|
|
|
FWNAME = pf
|
|
|
|
|
.endif
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
|
.if $(OSNAME) == "NetBSD"
|
2014-06-21 06:23:16 +00:00
|
|
|
|
.if exists(/etc/rc.subr) && exists(/etc/rc.conf)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
FWNAME != . /etc/rc.subr; . /etc/rc.conf; \
|
2014-06-21 06:23:16 +00:00
|
|
|
|
if checkyesno pf; then \
|
|
|
|
|
echo "pf"; elif checkyesno ipfilter; then \
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "ipf"; else echo "pf"; fi
|
2014-06-21 06:23:16 +00:00
|
|
|
|
.else
|
|
|
|
|
FWNAME = pf
|
|
|
|
|
.endif
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
|
.if $(OSNAME) == "DragonFly"
|
2014-06-21 06:23:16 +00:00
|
|
|
|
.if exists(/etc/rc.subr) && exists(/etc/rc.conf)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
FWNAME != . /etc/rc.subr; . /etc/rc.conf; \
|
2014-06-21 06:23:16 +00:00
|
|
|
|
if checkyesno pf; then \
|
|
|
|
|
echo "pf"; elif checkyesno ipfilter; then \
|
|
|
|
|
echo "ipf"; else echo "pf"; fi
|
|
|
|
|
.else
|
|
|
|
|
FWNAME = pf
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.endif
|
2012-05-31 13:33:16 +00:00
|
|
|
|
.endif
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
.if $(OSNAME) == "Darwin"
|
2014-03-18 08:34:25 +00:00
|
|
|
|
# Firewall is ipfw up to OS X 10.6 Snow Leopard
|
|
|
|
|
# and pf since OS X 10.7 Lion (Darwin 11.0)
|
|
|
|
|
FWNAME != [ `uname -r | cut -d. -f1` -ge 11 ] && echo "pf" || echo "ipfw"
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
2014-03-19 11:23:48 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# Solaris specific CFLAGS
|
|
|
|
|
.if $(OSNAME) == "SunOS"
|
|
|
|
|
CFLAGS += -DSOLARIS2=`uname -r | cut -d. -f2`
|
|
|
|
|
.if $(ARCH) == "amd64"
|
|
|
|
|
CFLAGS += -m64 -mcmodel=kernel -mno-red-zone -ffreestanding
|
|
|
|
|
.elif $(ARCH) == "sparc64"
|
|
|
|
|
CFLAGS += -m64 -mcmodel=medlow
|
|
|
|
|
.endif
|
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
|
STDOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
|
|
|
|
|
upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
|
2013-12-13 15:57:42 +00:00
|
|
|
|
options.o upnppermissions.o minissdp.o natpmp.o pcpserver.o \
|
2012-05-01 20:25:30 +00:00
|
|
|
|
upnpevents.o upnputils.o getconnstatus.o \
|
2014-03-14 11:08:13 +00:00
|
|
|
|
upnppinhole.o asyncsendto.o portinuse.o
|
2013-02-06 14:06:59 +00:00
|
|
|
|
BSDOBJS = bsd/getifstats.o bsd/ifacewatcher.o bsd/getroute.o
|
|
|
|
|
SUNOSOBJS = solaris/getifstats.o bsd/ifacewatcher.o bsd/getroute.o
|
|
|
|
|
MACOBJS = mac/getifstats.o bsd/ifacewatcher.o bsd/getroute.o
|
2012-04-20 14:50:24 +00:00
|
|
|
|
PFOBJS = pf/obsdrdr.o pf/pfpinhole.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
IPFOBJS = ipf/ipfrdr.o
|
2012-09-28 08:55:55 +00:00
|
|
|
|
IPFWOBJS = ipfw/ipfwrdr.o ipfw/ipfwaux.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
MISCOBJS = upnpreplyparse.o minixml.o
|
|
|
|
|
|
|
|
|
|
ALLOBJS = $(STDOBJS) $(MISCOBJS)
|
|
|
|
|
.if $(OSNAME) == "SunOS"
|
|
|
|
|
ALLOBJS += $(SUNOSOBJS)
|
|
|
|
|
TESTGETIFSTATSOBJS = testgetifstats.o solaris/getifstats.o
|
2013-02-06 14:06:59 +00:00
|
|
|
|
TESTGETROUTEOBJS = testgetroute.o upnputils.o bsd/getroute.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.elif $(OSNAME) == "Darwin"
|
|
|
|
|
ALLOBJS += $(MACOBJS)
|
|
|
|
|
TESTGETIFSTATSOBJS = testgetifstats.o mac/getifstats.o
|
2013-02-06 14:06:59 +00:00
|
|
|
|
TESTGETROUTEOBJS = testgetroute.o upnputils.o bsd/getroute.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.else
|
|
|
|
|
ALLOBJS += $(BSDOBJS)
|
|
|
|
|
TESTGETIFSTATSOBJS = testgetifstats.o bsd/getifstats.o
|
2013-02-06 14:06:59 +00:00
|
|
|
|
TESTGETROUTEOBJS = testgetroute.o upnputils.o bsd/getroute.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
|
.if $(FWNAME) == "pf"
|
|
|
|
|
ALLOBJS += $(PFOBJS)
|
|
|
|
|
.elif $(FWNAME) == "ipfw"
|
|
|
|
|
ALLOBJS += $(IPFWOBJS)
|
|
|
|
|
.else
|
|
|
|
|
ALLOBJS += $(IPFOBJS)
|
|
|
|
|
.endif
|
|
|
|
|
|
|
|
|
|
TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
|
|
|
|
|
TESTUPNPPERMISSIONSOBJS = testupnppermissions.o upnppermissions.o
|
|
|
|
|
TESTGETIFADDROBJS = testgetifaddr.o getifaddr.o
|
|
|
|
|
MINIUPNPDCTLOBJS = miniupnpdctl.o
|
2014-03-13 10:31:34 +00:00
|
|
|
|
TESTASYNCSENDTOOBJS = testasyncsendto.o asyncsendto.o upnputils.o bsd/getroute.o
|
2014-03-14 11:07:03 +00:00
|
|
|
|
TESTPORTINUSEOBJS = testportinuse.o portinuse.o getifaddr.o
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
|
|
|
|
|
testupnppermissions miniupnpdctl \
|
2014-03-14 11:07:03 +00:00
|
|
|
|
testgetifaddr testgetroute testasyncsendto \
|
2015-10-25 15:33:24 +00:00
|
|
|
|
testportinuse testssdppktgen
|
2014-03-14 11:07:03 +00:00
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
.if $(OSNAME) == "Darwin"
|
|
|
|
|
LIBS =
|
|
|
|
|
.else
|
|
|
|
|
LIBS = -lkvm
|
|
|
|
|
.endif
|
|
|
|
|
.if $(OSNAME) == "SunOS"
|
|
|
|
|
LIBS += -lsocket -lnsl -lkstat -lresolv
|
|
|
|
|
.endif
|
|
|
|
|
|
2014-04-09 13:35:06 +00:00
|
|
|
|
LIBS += -lssl -lcrypto
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# set PREFIX variable to install in the wanted place
|
|
|
|
|
|
|
|
|
|
INSTALLBINDIR = $(PREFIX)/sbin
|
|
|
|
|
INSTALLETCDIR = $(PREFIX)/etc
|
|
|
|
|
# INSTALLMANDIR = $(PREFIX)/man
|
|
|
|
|
INSTALLMANDIR = /usr/share/man
|
|
|
|
|
|
|
|
|
|
all: $(EXECUTABLES)
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
$(RM) $(STDOBJS) $(BSDOBJS) $(SUNOSOBJS) $(MACOBJS) $(EXECUTABLES) \
|
|
|
|
|
testupnpdescgen.o \
|
|
|
|
|
$(MISCOBJS) config.h testgetifstats.o testupnppermissions.o \
|
2014-02-18 08:34:42 +00:00
|
|
|
|
miniupnpdctl.o testgetifaddr.o testgetroute.o testasyncsendto.o \
|
2014-03-14 11:07:03 +00:00
|
|
|
|
testportinuse.o \
|
2011-09-28 19:13:20 +00:00
|
|
|
|
$(PFOBJS) $(IPFOBJS) $(IPFWOBJS)
|
2015-10-25 15:33:24 +00:00
|
|
|
|
$(RM) validateupnppermissions validategetifaddr validatessdppktgen
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
install: miniupnpd genuuid
|
|
|
|
|
$(STRIP) miniupnpd
|
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INSTALLBINDIR)
|
2014-02-14 08:56:10 +00:00
|
|
|
|
$(INSTALL) -m 755 miniupnpd $(DESTDIR)$(INSTALLBINDIR)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INSTALLETCDIR)
|
|
|
|
|
$(INSTALL) -b miniupnpd.conf $(DESTDIR)$(INSTALLETCDIR)
|
|
|
|
|
# TODO : install man page correctly
|
|
|
|
|
# $(INSTALL) -d $(INSTALLMANDIR)
|
2012-08-24 17:49:41 +00:00
|
|
|
|
# $(INSTALL) miniupnpd.8 $(INSTALLMANDIR)/cat8/miniupnpd.0
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
# genuuid is using the uuid cli tool available under OpenBSD 4.0 in
|
|
|
|
|
# the uuid-1.5.0 package
|
|
|
|
|
# any other cli tool returning a uuid on stdout should work.
|
|
|
|
|
UUID != if which uuidgen 2>&1 > /dev/null; then \
|
|
|
|
|
echo `uuidgen` ; \
|
|
|
|
|
elif which uuid 2>&1 > /dev/null; then \
|
|
|
|
|
echo `uuid` ; \
|
|
|
|
|
else echo "00000000-0000-0000-0000-000000000000"; \
|
|
|
|
|
fi
|
|
|
|
|
|
2015-11-19 11:54:56 +00:00
|
|
|
|
# bash or ksh
|
|
|
|
|
SH != which bash || which ksh
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
genuuid:
|
|
|
|
|
$(MV) miniupnpd.conf miniupnpd.conf.before
|
|
|
|
|
sed -e "s/^uuid=[-0-9a-fA-F]*/uuid=$(UUID)/" miniupnpd.conf.before > miniupnpd.conf
|
|
|
|
|
$(RM) miniupnpd.conf.before
|
|
|
|
|
|
2015-10-25 15:33:24 +00:00
|
|
|
|
check: validateupnppermissions validategetifaddr validatessdppktgen
|
|
|
|
|
|
|
|
|
|
validateupnppermissions: testupnppermissions testupnppermissions.sh
|
2015-11-19 11:54:56 +00:00
|
|
|
|
$(SH) ./testupnppermissions.sh
|
2015-10-25 15:33:24 +00:00
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
|
validategetifaddr: testgetifaddr testgetifaddr.sh
|
|
|
|
|
./testgetifaddr.sh
|
|
|
|
|
touch $@
|
|
|
|
|
|
|
|
|
|
validatessdppktgen: testssdppktgen
|
|
|
|
|
./testssdppktgen
|
|
|
|
|
touch $@
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
depend: config.h
|
|
|
|
|
mkdep $(ALLOBJS:.o=.c) testupnpdescgen.c testgetifstats.c \
|
2013-02-06 14:06:59 +00:00
|
|
|
|
testupnppermissions.c miniupnpdctl.c testgetifaddr.c \
|
2015-10-25 15:33:24 +00:00
|
|
|
|
testgetroute.c testportinuse.c testasyncsendto.c \
|
|
|
|
|
testssdppktgen.c
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
miniupnpd: config.h $(ALLOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(ALLOBJS) $(LIBS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
# BSDmake :
|
2016-02-10 20:37:00 +00:00
|
|
|
|
# $(CC) $(LDFLAGS) -o $@ $> $(LIBS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
miniupnpdctl: config.h $(MINIUPNPDCTLOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(MINIUPNPDCTLOBJS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
testupnpdescgen: config.h $(TESTUPNPDESCGENOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTUPNPDESCGENOBJS) $(LIBS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
testgetifstats: config.h $(TESTGETIFSTATSOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTGETIFSTATSOBJS) $(LIBS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
testgetifaddr: config.h $(TESTGETIFADDROBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTGETIFADDROBJS) $(LIBS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
testupnppermissions: config.h $(TESTUPNPPERMISSIONSOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTUPNPPERMISSIONSOBJS) $(LIBS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
2013-02-06 14:06:59 +00:00
|
|
|
|
testgetroute: config.h $(TESTGETROUTEOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTGETROUTEOBJS) $(LIBS)
|
2013-02-06 14:06:59 +00:00
|
|
|
|
|
2014-02-18 08:34:42 +00:00
|
|
|
|
testasyncsendto: config.h $(TESTASYNCSENDTOOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTASYNCSENDTOOBJS)
|
2014-02-18 08:34:42 +00:00
|
|
|
|
|
2014-03-14 11:07:03 +00:00
|
|
|
|
testportinuse: config.h $(TESTPORTINUSEOBJS)
|
2016-02-10 20:37:00 +00:00
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTPORTINUSEOBJS) $(LIBS)
|
2014-03-14 11:07:03 +00:00
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# gmake :
|
|
|
|
|
# $(CC) $(CFLAGS) -o $@ $^
|
|
|
|
|
# BSDmake :
|
|
|
|
|
# $(CC) $(CFLAGS) -o $@ $>
|
|
|
|
|
|
2012-05-24 16:25:42 +00:00
|
|
|
|
config.h: genconfig.sh VERSION
|
2012-04-14 22:35:31 +00:00
|
|
|
|
./genconfig.sh $(CONFIG_OPTIONS)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
.SUFFIXES: .o .c
|
|
|
|
|
.c.o:
|
|
|
|
|
$(CC) $(CFLAGS) -c -o $@ $<
|
|
|
|
|
|
|
|
|
|
# $(CC) $(CFLAGS) -c -o $(.TARGET) $(.IMPSRC)
|
|
|
|
|
|
2012-03-01 01:44:38 +00:00
|
|
|
|
|