-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.macosx
executable file
·132 lines (108 loc) · 4.26 KB
/
Makefile.macosx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# MiniUPnP project
# http://miniupnp.free.fr/
# Author: Thomas Bernard
# This Makefile should work for MacOSX
#
# 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
#
# To install use :
# $ PREFIX=/dummyinstalldir make -f Makefile.macosx install
# or :
# $ make -f Makefile.macosx install
#
CFLAGS = -Wall -O -g3 -DDEBUG
#CFLAGS = -Wall -Os
#CC = gcc #better use clang !
RM = rm -f
MV = mv
INSTALL = install
STRIP = strip
# OSNAME and FWNAME are used for building OS or FW dependent code.
OSNAME = $(shell uname)
ARCH = $(shell uname -p)
# 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" )
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 \
upnppinhole.o asyncsendto.o portinuse.o pcpserver.o
MAC_OBJS = mac/getifstats.o bsd/ifacewatcher.o bsd/getroute.o
IPFW_OBJS = ipfw/ipfwrdr.o ipfw/ipfwaux.o
PF_OBJS = pf/obsdrdr.o
# pf/pfpinhole.o # SHOULD be used, but doesn't compile on e.g. OS X 10.9.
MISC_OBJS = upnpreplyparse.o minixml.o
ALL_OBJS = $(STD_OBJS) $(MISC_OBJS) $(MAC_OBJS)
ifeq ($(FWNAME), ipfw)
ALL_OBJS += $(IPFW_OBJS)
else
ALL_OBJS += $(PF_OBJS)
CFLAGS += -DPF
endif
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
TEST_PORTINUSE_OBJS = testportinuse.o portinuse.o getifaddr.o
TEST_ASYNCSENDTO_OBJS = testasyncsendto.o asyncsendto.o upnputils.o bsd/getroute.o
MINIUPNPDCTL_OBJS = miniupnpdctl.o
EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
testupnppermissions miniupnpdctl \
testgetifaddr testportinuse testasyncsendto
LIBS =
# set PREFIX variable to install in the wanted place
INSTALL_BINDIR = $(PREFIX)/sbin
INSTALL_ETCDIR = $(PREFIX)/etc/miniupnpd
INSTALL_MANDIR = $(PREFIX)/share/man/man8
all: $(EXECUTABLES)
clean:
$(RM) $(ALL_OBJS) $(EXECUTABLES) \
testupnpdescgen.o testgetifstats.o testupnppermissions.o \
miniupnpdctl.o testgetifaddr.o config.h \
mac/org.tuxfamily.miniupnpd.plist
install: miniupnpd genuuid genlaunchd
$(STRIP) miniupnpd
$(INSTALL) -d $(INSTALL_BINDIR)
$(INSTALL) miniupnpd $(INSTALL_BINDIR)
$(INSTALL) -d $(INSTALL_ETCDIR)
$(INSTALL) -m 0644 -b miniupnpd.conf $(INSTALL_ETCDIR)
$(INSTALL) -d $(INSTALL_MANDIR)
$(INSTALL) miniupnpd.8 $(INSTALL_MANDIR)
$(INSTALL) -d $(PREFIX)/Library/LaunchDaemons
$(INSTALL) mac/org.tuxfamily.miniupnpd.plist $(PREFIX)/Library/LaunchDaemons
#$(INSTALL) ipfw/ipfw_init.sh $(INSTALL_ETCDIR)
#$(INSTALL) ipfw/ipfw_removeall.sh $(INSTALL_ETCDIR)
genuuid:
$(MV) miniupnpd.conf miniupnpd.conf.before
sed -e "s/^uuid=[-0-9a-fA-F]*/uuid=`uuidgen 2>/dev/null`/" miniupnpd.conf.before > miniupnpd.conf
$(RM) miniupnpd.conf.before
genlaunchd:
sed -e "s|INSTALLPREFIX|$(PREFIX)|g" mac/org.tuxfamily.miniupnpd.plist.before > mac/org.tuxfamily.miniupnpd.plist
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)
testasyncsendto: config.h $(TEST_ASYNCSENDTO_OBJS)
$(CC) $(CFLAGS) -o $@ $(TEST_ASYNCSENDTO_OBJS)
testportinuse: config.h $(TEST_PORTINUSE_OBJS)
$(CC) $(CFLAGS) -o $@ $(TEST_PORTINUSE_OBJS)
config.h: genconfig.sh
./genconfig.sh
.SUFFIXES: .o .c
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
# $(CC) $(CFLAGS) -c -o $(.TARGET) $(.IMPSRC)