1: # $Id: Makefile,v 1.1.1.3 2013/07/22 00:32:35 misho Exp $
2: # MiniUPnP project
3: # http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4: # Author: Thomas Bernard
5: #
6: # Makefile for miniupnpd (MiniUPnP daemon)
7: #
8: # This Makefile should work for *BSD and SunOS/Solaris.
9: # On Mac OS X, use "bsdmake" to build.
10: # This Makefile is NOT compatible with GNU Make.
11: # Linux users, please use Makefile.linux :
12: # make -f Makefile.linux
13: #
14: # options can be passed to genconfig.sh through CONFIG_OPTIONS :
15: # $ CONFIG_OPTIONS="--ipv6 --igd2" make
16: #
17:
18: CFLAGS ?= -pipe -Os
19: #CFLAGS = -pipe -O -g -DDEBUG
20: CFLAGS += -ansi
21: CFLAGS += -Wall
22: CFLAGS += -W
23: CFLAGS += -Wstrict-prototypes
24: #CFLAGS += -Wdeclaration-after-statement
25: #CFLAGS += -Wno-missing-field-initializers
26: CFLAGS += -fno-common
27: CC ?= gcc
28: RM = rm -f
29: MV = mv
30: INSTALL = install
31: STRIP = strip
32:
33: # OSNAME and FWNAME are used for building OS or FW dependent code.
34: OSNAME != uname -s
35: ARCH != uname -m
36: .ifndef FWNAME
37: .if exists(/usr/include/net/pfvar.h)
38: FWNAME = pf
39: .else
40: FWNAME = ipf
41: .endif
42: .endif
43:
44: # better way to find if we are using ipf or pf
45: .if defined(/etc/rc.subr) && defined(/etc/rc.conf)
46: .if $(OSNAME) == "FreeBSD"
47: FWNAME != . /etc/rc.subr; . /etc/rc.conf; \
48: if checkyesno ipfilter_enable; then \
49: echo "ipf"; else echo "pf"; fi
50: .endif
51:
52: .if $(OSNAME) == "NetBSD"
53: FWNAME != . /etc/rc.subr; . /etc/rc.conf; \
54: if checkyesno ipfilter; then \
55: echo "ipf"; else echo "pf"; fi
56: .endif
57:
58: .if $(OSNAME) == "DragonFly"
59: FWNAME != . /etc/rc.subr; . /etc/rc.conf; \
60: if chechyesno ipfilter; then \
61: echo "ipf"; else echo "pf"; fi
62: .endif
63: .endif
64:
65: .if $(OSNAME) == "Darwin"
66: FWNAME = ipfw
67: .endif
68:
69: # Solaris specific CFLAGS
70: .if $(OSNAME) == "SunOS"
71: CFLAGS += -DSOLARIS2=`uname -r | cut -d. -f2`
72: .if $(ARCH) == "amd64"
73: CFLAGS += -m64 -mcmodel=kernel -mno-red-zone -ffreestanding
74: .elif $(ARCH) == "sparc64"
75: CFLAGS += -m64 -mcmodel=medlow
76: .endif
77: .endif
78:
79: STDOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
80: upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
81: options.o upnppermissions.o minissdp.o natpmp.o \
82: upnpevents.o upnputils.o getconnstatus.o \
83: upnppinhole.o
84: BSDOBJS = bsd/getifstats.o bsd/ifacewatcher.o bsd/getroute.o
85: SUNOSOBJS = solaris/getifstats.o bsd/ifacewatcher.o bsd/getroute.o
86: MACOBJS = mac/getifstats.o bsd/ifacewatcher.o bsd/getroute.o
87: PFOBJS = pf/obsdrdr.o pf/pfpinhole.o
88: IPFOBJS = ipf/ipfrdr.o
89: IPFWOBJS = ipfw/ipfwrdr.o ipfw/ipfwaux.o
90: MISCOBJS = upnpreplyparse.o minixml.o
91:
92: ALLOBJS = $(STDOBJS) $(MISCOBJS)
93: .if $(OSNAME) == "SunOS"
94: ALLOBJS += $(SUNOSOBJS)
95: TESTGETIFSTATSOBJS = testgetifstats.o solaris/getifstats.o
96: TESTGETROUTEOBJS = testgetroute.o upnputils.o bsd/getroute.o
97: .elif $(OSNAME) == "Darwin"
98: ALLOBJS += $(MACOBJS)
99: TESTGETIFSTATSOBJS = testgetifstats.o mac/getifstats.o
100: TESTGETROUTEOBJS = testgetroute.o upnputils.o bsd/getroute.o
101: .else
102: ALLOBJS += $(BSDOBJS)
103: TESTGETIFSTATSOBJS = testgetifstats.o bsd/getifstats.o
104: TESTGETROUTEOBJS = testgetroute.o upnputils.o bsd/getroute.o
105: .endif
106:
107: .if $(FWNAME) == "pf"
108: ALLOBJS += $(PFOBJS)
109: .elif $(FWNAME) == "ipfw"
110: ALLOBJS += $(IPFWOBJS)
111: .else
112: ALLOBJS += $(IPFOBJS)
113: .endif
114:
115: TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
116: TESTUPNPPERMISSIONSOBJS = testupnppermissions.o upnppermissions.o
117: TESTGETIFADDROBJS = testgetifaddr.o getifaddr.o
118: MINIUPNPDCTLOBJS = miniupnpdctl.o
119:
120: EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
121: testupnppermissions miniupnpdctl \
122: testgetifaddr testgetroute
123: .if $(OSNAME) == "Darwin"
124: LIBS =
125: .else
126: LIBS = -lkvm
127: .endif
128: .if $(OSNAME) == "SunOS"
129: LIBS += -lsocket -lnsl -lkstat -lresolv
130: .endif
131:
132: # set PREFIX variable to install in the wanted place
133:
134: INSTALLBINDIR = $(PREFIX)/sbin
135: INSTALLETCDIR = $(PREFIX)/etc
136: # INSTALLMANDIR = $(PREFIX)/man
137: INSTALLMANDIR = /usr/share/man
138:
139: all: $(EXECUTABLES)
140:
141: clean:
142: $(RM) $(STDOBJS) $(BSDOBJS) $(SUNOSOBJS) $(MACOBJS) $(EXECUTABLES) \
143: testupnpdescgen.o \
144: $(MISCOBJS) config.h testgetifstats.o testupnppermissions.o \
145: miniupnpdctl.o testgetifaddr.o testgetroute.o \
146: $(PFOBJS) $(IPFOBJS) $(IPFWOBJS)
147:
148: install: miniupnpd genuuid
149: $(STRIP) miniupnpd
150: $(INSTALL) -d $(DESTDIR)$(INSTALLBINDIR)
151: $(INSTALL) -m 555 miniupnpd $(DESTDIR)$(INSTALLBINDIR)
152: $(INSTALL) -d $(DESTDIR)$(INSTALLETCDIR)
153: $(INSTALL) -b miniupnpd.conf $(DESTDIR)$(INSTALLETCDIR)
154: # TODO : install man page correctly
155: # $(INSTALL) -d $(INSTALLMANDIR)
156: # $(INSTALL) miniupnpd.8 $(INSTALLMANDIR)/cat8/miniupnpd.0
157:
158: # genuuid is using the uuid cli tool available under OpenBSD 4.0 in
159: # the uuid-1.5.0 package
160: # any other cli tool returning a uuid on stdout should work.
161: UUID != if which uuidgen 2>&1 > /dev/null; then \
162: echo `uuidgen` ; \
163: elif which uuid 2>&1 > /dev/null; then \
164: echo `uuid` ; \
165: else echo "00000000-0000-0000-0000-000000000000"; \
166: fi
167:
168: genuuid:
169: $(MV) miniupnpd.conf miniupnpd.conf.before
170: sed -e "s/^uuid=[-0-9a-fA-F]*/uuid=$(UUID)/" miniupnpd.conf.before > miniupnpd.conf
171: $(RM) miniupnpd.conf.before
172:
173: depend: config.h
174: mkdep $(ALLOBJS:.o=.c) testupnpdescgen.c testgetifstats.c \
175: testupnppermissions.c miniupnpdctl.c testgetifaddr.c \
176: testgetroute.c
177:
178: miniupnpd: config.h $(ALLOBJS)
179: $(CC) $(CFLAGS) -o $@ $(ALLOBJS) $(LIBS)
180:
181: # BSDmake :
182: # $(CC) $(CFLAGS) -o $@ $> $(LIBS)
183:
184: miniupnpdctl: config.h $(MINIUPNPDCTLOBJS)
185: $(CC) $(CFLAGS) -o $@ $(MINIUPNPDCTLOBJS)
186:
187: testupnpdescgen: config.h $(TESTUPNPDESCGENOBJS)
188: $(CC) $(CFLAGS) -o $@ $(TESTUPNPDESCGENOBJS)
189:
190: testgetifstats: config.h $(TESTGETIFSTATSOBJS)
191: $(CC) $(CFLAGS) -o $@ $(TESTGETIFSTATSOBJS) $(LIBS)
192:
193: testgetifaddr: config.h $(TESTGETIFADDROBJS)
194: $(CC) $(CFLAGS) -o $@ $(TESTGETIFADDROBJS)
195:
196: testupnppermissions: config.h $(TESTUPNPPERMISSIONSOBJS)
197: $(CC) $(CFLAGS) -o $@ $(TESTUPNPPERMISSIONSOBJS)
198:
199: testgetroute: config.h $(TESTGETROUTEOBJS)
200: $(CC) $(CFLAGS) -o $@ $(TESTGETROUTEOBJS)
201:
202: # gmake :
203: # $(CC) $(CFLAGS) -o $@ $^
204: # BSDmake :
205: # $(CC) $(CFLAGS) -o $@ $>
206:
207: config.h: genconfig.sh VERSION
208: ./genconfig.sh $(CONFIG_OPTIONS)
209:
210: .SUFFIXES: .o .c
211: .c.o:
212: $(CC) $(CFLAGS) -c -o $@ $<
213:
214: # $(CC) $(CFLAGS) -c -o $(.TARGET) $(.IMPSRC)
215:
216:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>