2011-09-28 19:13:20 +00:00
|
|
|
# MiniUPnP project
|
|
|
|
# http://miniupnp.free.fr/
|
|
|
|
# Author: Thomas Bernard
|
|
|
|
# This Makefile should work for MacOSX
|
|
|
|
#
|
2013-12-16 12:03:54 +00:00
|
|
|
# To compile with pf with OS X 10.7+, you need to specify
|
|
|
|
# path to XNU bsd sources :
|
|
|
|
# INCLUDES="-I.../xnu/bsd I.../xnu/libkern" make -f Makefile.macosx
|
|
|
|
#
|
2011-09-28 19:13:20 +00:00
|
|
|
# To install use :
|
|
|
|
# $ PREFIX=/dummyinstalldir make -f Makefile.macosx install
|
|
|
|
# or :
|
|
|
|
# $ make -f Makefile.macosx install
|
|
|
|
#
|
|
|
|
CFLAGS = -Wall -O -g3 -DDEBUG
|
|
|
|
#CFLAGS = -Wall -Os
|
2013-12-16 12:03:54 +00:00
|
|
|
#CC = gcc #better use clang !
|
2011-09-28 19:13:20 +00:00
|
|
|
RM = rm -f
|
|
|
|
MV = mv
|
|
|
|
INSTALL = install
|
|
|
|
STRIP = strip
|
|
|
|
|
2013-12-16 12:03:54 +00:00
|
|
|
CFLAGS += -DMACOSX
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
# OSNAME and FWNAME are used for building OS or FW dependent code.
|
|
|
|
OSNAME = $(shell uname)
|
|
|
|
ARCH = $(shell uname -p)
|
2013-12-16 12:03:54 +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 = $(shell [ `uname -r | cut -d. -f1` -ge 11 ] && echo "pf" || echo "ipfw" )
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
STD_OBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
|
|
|
|
upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
|
|
|
|
options.o upnppermissions.o minissdp.o natpmp.o \
|
|
|
|
upnpevents.o getconnstatus.o upnputils.o
|
|
|
|
MAC_OBJS = mac/getifstats.o bsd/ifacewatcher.o
|
2012-09-19 12:46:44 +00:00
|
|
|
IPFW_OBJS = ipfw/ipfwrdr.o ipfw/ipfwaux.o
|
2013-12-16 12:03:54 +00:00
|
|
|
PF_OBJS = pf/obsdrdr.o pf/pfpinhole.o
|
2011-09-28 19:13:20 +00:00
|
|
|
MISC_OBJS = upnpreplyparse.o minixml.o
|
|
|
|
|
2013-12-16 12:03:54 +00:00
|
|
|
ALL_OBJS = $(STD_OBJS) $(MISC_OBJS) $(MAC_OBJS)
|
|
|
|
ifeq ($(FWNAME), ipfw)
|
|
|
|
ALL_OBJS += $(IPFW_OBJS)
|
|
|
|
else
|
|
|
|
ALL_OBJS += $(PF_OBJS)
|
|
|
|
CFLAGS += -DPF
|
|
|
|
endif
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
TEST_UPNPDESCGEN_OBJS = testupnpdescgen.o upnpdescgen.o
|
|
|
|
TEST_GETIFSTATS_OBJS = testgetifstats.o mac/getifstats.o
|
|
|
|
TEST_UPNPPERMISSIONS_OBJS = testupnppermissions.o upnppermissions.o
|
|
|
|
TEST_GETIFADDR_OBJS = testgetifaddr.o getifaddr.o
|
|
|
|
MINIUPNPDCTL_OBJS = miniupnpdctl.o
|
|
|
|
|
|
|
|
EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
|
|
|
|
testupnppermissions miniupnpdctl \
|
|
|
|
testgetifaddr
|
|
|
|
|
|
|
|
LIBS =
|
|
|
|
|
|
|
|
# set PREFIX variable to install in the wanted place
|
|
|
|
|
|
|
|
INSTALL_BINDIR = $(PREFIX)/sbin
|
|
|
|
INSTALL_ETCDIR = $(PREFIX)/etc/miniupnpd
|
2012-08-24 17:49:41 +00:00
|
|
|
INSTALL_MANDIR = $(PREFIX)/share/man/man8
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
all: $(EXECUTABLES)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(ALL_OBJS) $(EXECUTABLES) \
|
|
|
|
testupnpdescgen.o testgetifstats.o testupnppermissions.o \
|
2011-12-31 08:12:39 +00:00
|
|
|
miniupnpdctl.o testgetifaddr.o config.h \
|
|
|
|
mac/org.tuxfamily.miniupnpd.plist
|
2011-09-28 19:13:20 +00:00
|
|
|
|
2011-12-31 06:22:48 +00:00
|
|
|
install: miniupnpd genuuid genlaunchd
|
2011-09-28 19:13:20 +00:00
|
|
|
$(STRIP) miniupnpd
|
|
|
|
$(INSTALL) -d $(INSTALL_BINDIR)
|
|
|
|
$(INSTALL) miniupnpd $(INSTALL_BINDIR)
|
|
|
|
$(INSTALL) -d $(INSTALL_ETCDIR)
|
2011-12-31 06:22:48 +00:00
|
|
|
$(INSTALL) -m 0644 -b miniupnpd.conf $(INSTALL_ETCDIR)
|
2011-09-28 19:13:20 +00:00
|
|
|
$(INSTALL) -d $(INSTALL_MANDIR)
|
2012-08-24 17:49:41 +00:00
|
|
|
$(INSTALL) miniupnpd.8 $(INSTALL_MANDIR)
|
2011-09-28 19:13:20 +00:00
|
|
|
$(INSTALL) -d $(PREFIX)/Library/LaunchDaemons
|
|
|
|
$(INSTALL) mac/org.tuxfamily.miniupnpd.plist $(PREFIX)/Library/LaunchDaemons
|
2011-12-31 06:22:48 +00:00
|
|
|
#$(INSTALL) ipfw/ipfw_init.sh $(INSTALL_ETCDIR)
|
|
|
|
#$(INSTALL) ipfw/ipfw_removeall.sh $(INSTALL_ETCDIR)
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
genuuid:
|
|
|
|
$(MV) miniupnpd.conf miniupnpd.conf.before
|
2011-12-31 08:12:39 +00:00
|
|
|
sed -e "s/^uuid=[-0-9a-fA-F]*/uuid=`uuidgen 2>/dev/null`/" miniupnpd.conf.before > miniupnpd.conf
|
2011-09-28 19:13:20 +00:00
|
|
|
$(RM) miniupnpd.conf.before
|
|
|
|
|
2011-12-31 06:22:48 +00:00
|
|
|
genlaunchd:
|
|
|
|
sed -e "s|INSTALLPREFIX|$(PREFIX)|g" mac/org.tuxfamily.miniupnpd.plist.before > mac/org.tuxfamily.miniupnpd.plist
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
depend: config.h
|
|
|
|
mkdep $(ALL_OBJS:.o=.c) testupnpdescgen.c testgetifstats.c \
|
|
|
|
testupnppermissions.c miniupnpdctl.c testgetifaddr.c
|
|
|
|
|
|
|
|
miniupnpd: config.h $(ALL_OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(ALL_OBJS) $(LIBS)
|
|
|
|
|
|
|
|
miniupnpdctl: config.h $(MINIUPNPDCTL_OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(MINIUPNPDCTL_OBJS)
|
|
|
|
|
|
|
|
testupnpdescgen: config.h $(TEST_UPNPDESCGEN_OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(TEST_UPNPDESCGEN_OBJS)
|
|
|
|
|
|
|
|
testgetifstats: config.h $(TEST_GETIFSTATS_OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(TEST_GETIFSTATS_OBJS) $(LIBS)
|
|
|
|
|
|
|
|
testgetifaddr: config.h $(TEST_GETIFADDR_OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(TEST_GETIFADDR_OBJS)
|
|
|
|
|
|
|
|
testupnppermissions: config.h $(TEST_UPNPPERMISSIONS_OBJS)
|
|
|
|
$(CC) $(CFLAGS) -o $@ $(TEST_UPNPPERMISSIONS_OBJS)
|
|
|
|
|
|
|
|
|
|
|
|
config.h: genconfig.sh
|
|
|
|
./genconfig.sh
|
|
|
|
|
|
|
|
.SUFFIXES: .o .c
|
|
|
|
.c.o:
|
2013-12-16 12:03:54 +00:00
|
|
|
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
2011-09-28 19:13:20 +00:00
|
|
|
# $(CC) $(CFLAGS) -c -o $(.TARGET) $(.IMPSRC)
|