2020-05-11 21:30:19 +00:00
|
|
|
# $Id: Makefile.bsd,v 1.100 2020/05/10 22:44:41 nanard Exp $
|
2011-09-28 19:13:20 +00:00
|
|
|
# MiniUPnP project
|
2020-04-20 22:13:26 +00:00
|
|
|
# http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/
|
2011-09-28 19:13:20 +00:00
|
|
|
# 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.
|
2020-04-28 22:38:07 +00:00
|
|
|
# Linux users, please use Makefile.linux
|
2012-04-14 22:35:31 +00:00
|
|
|
#
|
2020-04-28 22:38:07 +00:00
|
|
|
# options can be passed to configure through CONFIG_OPTIONS :
|
2012-04-14 22:35:31 +00:00
|
|
|
# $ 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
|
2019-09-24 09:20:17 +00:00
|
|
|
DOXYGEN ?= doxygen
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2020-06-03 21:54:24 +00:00
|
|
|
.ifndef CONFIG_OPTIONS
|
|
|
|
CONFIG_OPTIONS != cat .configure.cache
|
|
|
|
.endif
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
# OSNAME and FWNAME are used for building OS or FW dependent code.
|
|
|
|
OSNAME != uname -s
|
|
|
|
ARCH != uname -m
|
|
|
|
|
2020-04-20 22:13:26 +00:00
|
|
|
.ifndef FWNAME
|
|
|
|
.include "bsdmake.inc"
|
2014-03-19 11:23:48 +00:00
|
|
|
.endif
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
# Solaris specific CFLAGS
|
|
|
|
.if $(OSNAME) == "SunOS"
|
2020-05-11 21:30:19 +00:00
|
|
|
CPPFLAGS += -DSOLARIS2=`uname -r | cut -d. -f2`
|
2011-09-28 19:13:20 +00:00
|
|
|
.if $(ARCH) == "amd64"
|
|
|
|
CFLAGS += -m64 -mcmodel=kernel -mno-red-zone -ffreestanding
|
|
|
|
.elif $(ARCH) == "sparc64"
|
|
|
|
CFLAGS += -m64 -mcmodel=medlow
|
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
2020-04-06 10:00:09 +00:00
|
|
|
ISGITREPO != git rev-parse --is-inside-work-tree 2> /dev/null || echo "false"
|
2019-10-05 19:59:42 +00:00
|
|
|
.if $(ISGITREPO) == "true"
|
2020-10-31 09:50:11 +00:00
|
|
|
GITREF != git describe --exact-match --tags 2> /dev/null || echo "`git rev-parse --abbrev-ref HEAD`-`git rev-parse --short HEAD`"
|
|
|
|
CPPFLAGS += -DMINIUPNPD_GIT_REF=\"$(GITREF)\"
|
2019-10-05 19:59:42 +00:00
|
|
|
.endif
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
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 \
|
2018-05-19 11:31:08 +00:00
|
|
|
upnpstun.o \
|
2014-03-14 11:08:13 +00:00
|
|
|
upnppinhole.o asyncsendto.o portinuse.o
|
2020-05-11 21:30:19 +00:00
|
|
|
OS_OBJS = getifstats.o ifacewatcher.o getroute.o
|
|
|
|
PFOBJS = obsdrdr.o pfpinhole.o
|
|
|
|
IPFOBJS = ipfrdr.o
|
|
|
|
IPFWOBJS = ipfwrdr.o ipfwaux.o
|
2011-09-28 19:13:20 +00:00
|
|
|
MISCOBJS = upnpreplyparse.o minixml.o
|
|
|
|
|
|
|
|
ALLOBJS = $(STDOBJS) $(MISCOBJS)
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS := $(ALLOBJS:S/^/$(SRCDIR)\//:S/.o$/.c/)
|
|
|
|
|
|
|
|
TESTGETIFSTATSOBJS = testgetifstats.o getifstats.o
|
|
|
|
TESTGETROUTEOBJS = testgetroute.o upnputils.o getroute.o
|
|
|
|
|
|
|
|
ALLOBJS += $(OS_OBJS)
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
.if $(OSNAME) == "SunOS"
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS += $(SRCDIR)/solaris/getifstats.c
|
2011-09-28 19:13:20 +00:00
|
|
|
.elif $(OSNAME) == "Darwin"
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS += $(SRCDIR)/mac/getifstats.c
|
2011-09-28 19:13:20 +00:00
|
|
|
.else
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS += $(SRCDIR)/bsd/getifstats.c
|
2011-09-28 19:13:20 +00:00
|
|
|
.endif
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS += $(SRCDIR)/bsd/ifacewatcher.c $(SRCDIR)/bsd/getroute.c
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
.if $(FWNAME) == "pf"
|
|
|
|
ALLOBJS += $(PFOBJS)
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS += $(PFOBJS:S/^/$(SRCDIR)\/pf\//:S/.o$/.c/)
|
2011-09-28 19:13:20 +00:00
|
|
|
.elif $(FWNAME) == "ipfw"
|
|
|
|
ALLOBJS += $(IPFWOBJS)
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS += $(IPFWOBJS:S/^/$(SRCDIR)\/ipfw\//:S/.o$/.c/)
|
2011-09-28 19:13:20 +00:00
|
|
|
.else
|
|
|
|
ALLOBJS += $(IPFOBJS)
|
2020-05-11 21:30:19 +00:00
|
|
|
ALLSRCS += $(IPFOBJS:S/^/$(SRCDIR)\/ipf\//:S/.o$/.c/)
|
2011-09-28 19:13:20 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
|
|
|
|
TESTUPNPPERMISSIONSOBJS = testupnppermissions.o upnppermissions.o
|
|
|
|
TESTGETIFADDROBJS = testgetifaddr.o getifaddr.o
|
|
|
|
MINIUPNPDCTLOBJS = miniupnpdctl.o
|
2020-05-11 21:30:19 +00:00
|
|
|
TESTASYNCSENDTOOBJS = testasyncsendto.o asyncsendto.o upnputils.o getroute.o
|
2014-03-14 11:07:03 +00:00
|
|
|
TESTPORTINUSEOBJS = testportinuse.o portinuse.o getifaddr.o
|
2017-12-12 09:08:44 +00:00
|
|
|
TESTMINISSDPOBJS = testminissdp.o minissdp.o upnputils.o upnpglobalvars.o \
|
2020-05-11 21:30:19 +00:00
|
|
|
asyncsendto.o getroute.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 \
|
2017-12-12 09:08:44 +00:00
|
|
|
testportinuse testssdppktgen testminissdp
|
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
|
2020-06-10 17:37:09 +00:00
|
|
|
MANPREFIX ?= $(PREFIX)
|
|
|
|
INSTALLMANDIR = $(MANPREFIX)/man
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
all: $(EXECUTABLES)
|
|
|
|
|
|
|
|
clean:
|
2020-05-11 21:30:19 +00:00
|
|
|
$(RM) $(ALLOBJS)
|
|
|
|
$(RM) $(EXECUTABLES)
|
|
|
|
$(RM) $(TESTUPNPDESCGENOBJS)
|
|
|
|
$(RM) $(TESTUPNPPERMISSIONSOBJS)
|
|
|
|
$(RM) $(TESTGETIFADDROBJS)
|
|
|
|
$(RM) $(MINIUPNPDCTLOBJS)
|
|
|
|
$(RM) $(TESTASYNCSENDTOOBJS)
|
|
|
|
$(RM) $(TESTPORTINUSEOBJS)
|
|
|
|
$(RM) $(TESTMINISSDPOBJS)
|
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)
|
2020-06-10 17:37:09 +00:00
|
|
|
$(INSTALL) -d $(DESTDIR)$(INSTALLMANDIR)
|
2020-10-24 13:17:59 +00:00
|
|
|
$(INSTALL) -m 644 miniupnpd.8 $(DESTDIR)$(INSTALLMANDIR)/man8/miniupnpd.8
|
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
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2020-05-11 21:30:19 +00:00
|
|
|
validateupnppermissions: $(SRCDIR)/testupnppermissions.sh testupnppermissions
|
|
|
|
$(SRCDIR)/testupnppermissions.sh
|
2015-10-25 15:33:24 +00:00
|
|
|
touch $@
|
|
|
|
|
2020-05-11 21:30:19 +00:00
|
|
|
validategetifaddr: $(SRCDIR)/testgetifaddr.sh testgetifaddr
|
|
|
|
$(SRCDIR)/testgetifaddr.sh
|
2015-10-25 15:33:24 +00:00
|
|
|
touch $@
|
|
|
|
|
|
|
|
validatessdppktgen: testssdppktgen
|
|
|
|
./testssdppktgen
|
|
|
|
touch $@
|
|
|
|
|
2020-05-11 21:30:19 +00:00
|
|
|
depend: $(ALLSRCS)
|
|
|
|
mkdep $(CPPFLAGS) $(.ALLSRC)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2019-09-24 09:20:17 +00:00
|
|
|
dox: miniupnpd.doxyconf
|
|
|
|
$(DOXYGEN) $>
|
|
|
|
|
2020-05-11 21:30:19 +00:00
|
|
|
miniupnpd: $(ALLOBJS)
|
2020-10-22 18:45:15 +00:00
|
|
|
$(CC) $(CFLAGS) $(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
|
|
|
|
2017-12-12 09:08:44 +00:00
|
|
|
testminissdp: config.h $(TESTMINISSDPOBJS)
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(TESTMINISSDPOBJS) $(LIBS)
|
|
|
|
|
2020-05-11 21:30:19 +00:00
|
|
|
testssdppktgen: testssdppktgen.o
|
|
|
|
$(CC) $(LDFLAGS) -o $@ $(.ALLSRC) $(LIBS)
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
# gmake :
|
|
|
|
# $(CC) $(CFLAGS) -o $@ $^
|
|
|
|
# BSDmake :
|
|
|
|
# $(CC) $(CFLAGS) -o $@ $>
|
|
|
|
|
2020-05-11 21:30:19 +00:00
|
|
|
config.h: $(SRCDIR)/configure $(SRCDIR)/VERSION
|
|
|
|
$(SRCDIR)/configure $(CONFIG_OPTIONS)
|
|
|
|
|
|
|
|
$(STDOBJS) $(MISCOBJS): $(SRCDIR)/$(@:.o=.c)
|
|
|
|
$(PFOBJS): $(SRCDIR)/pf/$(@:.o=.c)
|
|
|
|
$(IPFOBJS): $(SRCDIR)/ipf/$(@:.o=.c)
|
|
|
|
$(IPFWOBJS): $(SRCDIR)/ipfw/$(@:.o=.c)
|
|
|
|
|
|
|
|
.if $(OSNAME) == "SunOS"
|
|
|
|
getifstats.o: $(SRCDIR)/solaris/getifstats.c
|
|
|
|
.elif $(OSNAME) == "Darwin"
|
|
|
|
getifstats.o: $(SRCDIR)/mac/getifstats.c
|
|
|
|
.else
|
|
|
|
getifstats.o: $(SRCDIR)/bsd/getifstats.c
|
|
|
|
.endif
|
|
|
|
ifacewatcher.o getroute.o: $(SRCDIR)/bsd/$(@:.o=.c)
|
|
|
|
|
|
|
|
# make(1) specifies that $ is escaped with a backslash,
|
|
|
|
# not a preceding $ as usual, but FreeBSD 12.1 make does otherwise
|
|
|
|
.if $(OSNAME) == "FreeBSD"
|
|
|
|
$(EXECUTABLES:S/$$/.o/): $(SRCDIR)/$(@:.o=.c)
|
|
|
|
.else
|
|
|
|
$(EXECUTABLES:S/\$/.o/): $(SRCDIR)/$(@:.o=.c)
|
|
|
|
.endif
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
.SUFFIXES: .o .c
|
|
|
|
.c.o:
|
2020-05-11 21:30:19 +00:00
|
|
|
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2020-05-11 21:30:19 +00:00
|
|
|
# $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $(.TARGET) $(.IMPSRC)
|
2011-09-28 19:13:20 +00:00
|
|
|
|