miniupnp/miniupnpd/Makefile.bsd

261 lines
7.3 KiB
Makefile
Raw Normal View History

# $Id: Makefile.bsd,v 1.100 2020/05/10 22:44:41 nanard Exp $
2011-09-28 19:13:20 +00:00
# MiniUPnP project
# 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
#
2020-04-28 22:38:07 +00:00
# options can be passed to configure through CONFIG_OPTIONS :
# $ CONFIG_OPTIONS="--ipv6 --igd2" make
#
2011-09-28 19:13:20 +00:00
CFLAGS ?= -pipe -Os
#CFLAGS = -pipe -O -g -DDEBUG
2014-04-01 09:43:31 +00:00
#CFLAGS += -ansi
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
# OSNAME and FWNAME are used for building OS or FW dependent code.
OSNAME != uname -s
ARCH != uname -m
.ifndef FWNAME
.include "bsdmake.inc"
.endif
2011-09-28 19:13:20 +00:00
# Solaris specific CFLAGS
.if $(OSNAME) == "SunOS"
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
ISGITREPO != git rev-parse --is-inside-work-tree 2> /dev/null || echo "false"
.if $(ISGITREPO) == "true"
GITREF != git rev-parse --short HEAD
GITBRANCH != git rev-parse --abbrev-ref HEAD
CPPFLAGS += -DMINIUPNPD_GIT_REF=\"$(GITBRANCH)-$(GITREF)\"
.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 \
upnpevents.o upnputils.o getconnstatus.o \
upnpstun.o \
upnppinhole.o asyncsendto.o portinuse.o
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)
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"
ALLSRCS += $(SRCDIR)/solaris/getifstats.c
2011-09-28 19:13:20 +00:00
.elif $(OSNAME) == "Darwin"
ALLSRCS += $(SRCDIR)/mac/getifstats.c
2011-09-28 19:13:20 +00:00
.else
ALLSRCS += $(SRCDIR)/bsd/getifstats.c
2011-09-28 19:13:20 +00:00
.endif
ALLSRCS += $(SRCDIR)/bsd/ifacewatcher.c $(SRCDIR)/bsd/getroute.c
2011-09-28 19:13:20 +00:00
.if $(FWNAME) == "pf"
ALLOBJS += $(PFOBJS)
ALLSRCS += $(PFOBJS:S/^/$(SRCDIR)\/pf\//:S/.o$/.c/)
2011-09-28 19:13:20 +00:00
.elif $(FWNAME) == "ipfw"
ALLOBJS += $(IPFWOBJS)
ALLSRCS += $(IPFWOBJS:S/^/$(SRCDIR)\/ipfw\//:S/.o$/.c/)
2011-09-28 19:13:20 +00:00
.else
ALLOBJS += $(IPFOBJS)
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
TESTASYNCSENDTOOBJS = testasyncsendto.o asyncsendto.o upnputils.o getroute.o
TESTPORTINUSEOBJS = testportinuse.o portinuse.o getifaddr.o
TESTMINISSDPOBJS = testminissdp.o minissdp.o upnputils.o upnpglobalvars.o \
asyncsendto.o getroute.o
2011-09-28 19:13:20 +00:00
EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
testupnppermissions miniupnpdctl \
testgetifaddr testgetroute testasyncsendto \
testportinuse testssdppktgen testminissdp
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) $(ALLOBJS)
$(RM) $(EXECUTABLES)
$(RM) $(TESTUPNPDESCGENOBJS)
$(RM) $(TESTUPNPPERMISSIONSOBJS)
$(RM) $(TESTGETIFADDROBJS)
$(RM) $(MINIUPNPDCTLOBJS)
$(RM) $(TESTASYNCSENDTOOBJS)
$(RM) $(TESTPORTINUSEOBJS)
$(RM) $(TESTMINISSDPOBJS)
$(RM) validateupnppermissions validategetifaddr validatessdppktgen
2011-09-28 19:13:20 +00:00
install: miniupnpd genuuid
$(STRIP) miniupnpd
$(INSTALL) -d $(DESTDIR)$(INSTALLBINDIR)
$(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
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
check: validateupnppermissions validategetifaddr validatessdppktgen
validateupnppermissions: $(SRCDIR)/testupnppermissions.sh testupnppermissions
$(SRCDIR)/testupnppermissions.sh
touch $@
validategetifaddr: $(SRCDIR)/testgetifaddr.sh testgetifaddr
$(SRCDIR)/testgetifaddr.sh
touch $@
validatessdppktgen: testssdppktgen
./testssdppktgen
touch $@
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) $>
miniupnpd: $(ALLOBJS)
$(CC) $(LDFLAGS) -o $@ $(ALLOBJS) $(LIBS)
2011-09-28 19:13:20 +00:00
# BSDmake :
# $(CC) $(LDFLAGS) -o $@ $> $(LIBS)
2011-09-28 19:13:20 +00:00
miniupnpdctl: config.h $(MINIUPNPDCTLOBJS)
$(CC) $(LDFLAGS) -o $@ $(MINIUPNPDCTLOBJS)
2011-09-28 19:13:20 +00:00
testupnpdescgen: config.h $(TESTUPNPDESCGENOBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTUPNPDESCGENOBJS) $(LIBS)
2011-09-28 19:13:20 +00:00
testgetifstats: config.h $(TESTGETIFSTATSOBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTGETIFSTATSOBJS) $(LIBS)
2011-09-28 19:13:20 +00:00
testgetifaddr: config.h $(TESTGETIFADDROBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTGETIFADDROBJS) $(LIBS)
2011-09-28 19:13:20 +00:00
testupnppermissions: config.h $(TESTUPNPPERMISSIONSOBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTUPNPPERMISSIONSOBJS) $(LIBS)
2011-09-28 19:13:20 +00:00
testgetroute: config.h $(TESTGETROUTEOBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTGETROUTEOBJS) $(LIBS)
testasyncsendto: config.h $(TESTASYNCSENDTOOBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTASYNCSENDTOOBJS)
testportinuse: config.h $(TESTPORTINUSEOBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTPORTINUSEOBJS) $(LIBS)
testminissdp: config.h $(TESTMINISSDPOBJS)
$(CC) $(LDFLAGS) -o $@ $(TESTMINISSDPOBJS) $(LIBS)
testssdppktgen: testssdppktgen.o
$(CC) $(LDFLAGS) -o $@ $(.ALLSRC) $(LIBS)
2011-09-28 19:13:20 +00:00
# gmake :
# $(CC) $(CFLAGS) -o $@ $^
# BSDmake :
# $(CC) $(CFLAGS) -o $@ $>
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:
$(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
2011-09-28 19:13:20 +00:00
# $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $(.TARGET) $(.IMPSRC)
2011-09-28 19:13:20 +00:00