Tomato 1.26 beta(1766)
[tomato.git] / release / src / router / miniupnpd / Makefile.linux
blob2eab30fb66c6fc1e063b0cc71c17d7408075f00a
1 # $Id: Makefile.linux,v 1.46 2009/04/25 23:16:38 nanard Exp $
2 # MiniUPnP project
3 # http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
4 # Author : Thomas Bernard
5 # for use with GNU Make
7 # To install use :
8 # $ PREFIX=/dummyinstalldir make -f Makefile.linux install
9 # or :
10 # $ INSTALLPREFIX=/usr/local make -f Makefile.linux install
11 # or :
12 # $ make -f Makefile.linux install
14 # if your system hasn't iptables libiptc headers and binary correctly
15 # installed, you need to get iptables sources from http://netfilter.org/
16 # ./configure them and build them then miniupnpd will build using :
17 # $ IPTABLESPATH=/path/to/iptables-1.4.1 make -f Makefile.linux
19 #CFLAGS = -Wall -O -D_GNU_SOURCE -g -DDEBUG
20 CFLAGS = -Wall -Os -D_GNU_SOURCE
21 CC = gcc
22 RM = rm -f
23 INSTALL = install
24 STRIP = strip
26 INSTALLPREFIX ?= $(PREFIX)/usr
27 SBININSTALLDIR = $(INSTALLPREFIX)/sbin
28 ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
30 BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
31            upnpreplyparse.o minixml.o \
32                    upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
33            options.o upnppermissions.o minissdp.o natpmp.o \
34            upnpevents.o
36 LNXOBJS = linux/getifstats.o
37 NETFILTEROBJS = netfilter/iptcrdr.o
39 ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
41 LIBS = -liptc
43 ifdef IPTABLESPATH
44 CFLAGS := $(CFLAGS) -I$(IPTABLESPATH)/include/
45 LDFLAGS := $(LDFLAFGS) -L$(IPTABLESPATH)/libiptc/
46 # get iptables version and set IPTABLES_143 macro if needed
47 IPTABLESVERSION := $(shell grep "\#define VERSION" $(IPTABLESPATH)/config.h | tr -d \" |cut -d" " -f3 )
48 IPTABLESVERSION1 := $(shell echo $(IPTABLESVERSION) | cut -d. -f1 )
49 IPTABLESVERSION2 := $(shell echo $(IPTABLESVERSION) | cut -d. -f2 )
50 IPTABLESVERSION3 := $(shell echo $(IPTABLESVERSION) | cut -d. -f3 )
51 # test if iptables >= 1.4.3
52 TEST := $(shell [ \( \( $(IPTABLESVERSION1) -ge 1 \) -a \( $(IPTABLESVERSION2) -ge 4 \) \) -a \( $(IPTABLESVERSION3) -ge 3 \) ] && echo 1 )
53 ifeq ($(TEST), 1)
54 CFLAGS := $(CFLAGS) -DIPTABLES_143
55 # the following sucks, but works
56 #LIBS = $(IPTABLESPATH)/libiptc/.libs/libip4tc.o
57 LIBS = $(IPTABLESPATH)/libiptc/.libs/libiptc.a
58 else
59 LIBS = $(IPTABLESPATH)/libiptc/libiptc.a
60 endif
61 endif
63 TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
65 EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
66               testupnppermissions miniupnpdctl testgetifaddr
68 .PHONY: all clean install depend genuuid
70 all:    $(EXECUTABLES)
72 clean:
73         $(RM) $(ALLOBJS)
74         $(RM) $(EXECUTABLES)
75         $(RM) testupnpdescgen.o testgetifstats.o
76         $(RM) testupnppermissions.o
77         $(RM) miniupnpdctl.o
79 install:        miniupnpd genuuid
80         $(STRIP) miniupnpd
81         $(INSTALL) -d $(SBININSTALLDIR)
82         $(INSTALL) miniupnpd $(SBININSTALLDIR)
83         $(INSTALL) -d $(ETCINSTALLDIR)
84         $(INSTALL) netfilter/iptables_init.sh $(ETCINSTALLDIR)
85         $(INSTALL) netfilter/iptables_removeall.sh $(ETCINSTALLDIR)
86         $(INSTALL) --mode=0644 -b miniupnpd.conf $(ETCINSTALLDIR)
87         $(INSTALL) -d $(PREFIX)/etc/init.d
88         $(INSTALL) linux/miniupnpd.init.d.script $(PREFIX)/etc/init.d/miniupnpd
90 # genuuid is using the uuidgen CLI tool which is part of libuuid
91 # from the e2fsprogs
92 genuuid:
93         sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen) 2>/dev/null`/" miniupnpd.conf
95 miniupnpd:      $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(LIBS)
97 testupnpdescgen:        $(TESTUPNPDESCGENOBJS)
99 testgetifstats: testgetifstats.o linux/getifstats.o
101 testupnppermissions:    testupnppermissions.o upnppermissions.o
103 testgetifaddr:  testgetifaddr.o getifaddr.o
105 miniupnpdctl:   miniupnpdctl.o
107 config.h:       genconfig.sh
108         ./genconfig.sh
110 depend: config.h
111         makedepend -f$(MAKEFILE_LIST) -Y \
112         $(ALLOBJS:.o=.c) $(TESTUPNPDESCGENOBJS:.o=.c) \
113         testgetifstats.c 2>/dev/null
115 # DO NOT DELETE
117 miniupnpd.o: config.h upnpglobalvars.h upnppermissions.h miniupnpdtypes.h
118 miniupnpd.o: upnphttp.h upnpdescgen.h miniupnpdpath.h getifaddr.h upnpsoap.h
119 miniupnpd.o: options.h minissdp.h upnpredirect.h daemonize.h upnpevents.h
120 miniupnpd.o: natpmp.h commonrdr.h
121 upnphttp.o: config.h upnphttp.h upnpdescgen.h miniupnpdpath.h upnpsoap.h
122 upnphttp.o: upnpevents.h
123 upnpdescgen.o: config.h upnpdescgen.h miniupnpdpath.h upnpglobalvars.h
124 upnpdescgen.o: upnppermissions.h miniupnpdtypes.h upnpdescstrings.h
125 upnpsoap.o: config.h upnpglobalvars.h upnppermissions.h miniupnpdtypes.h
126 upnpsoap.o: upnphttp.h upnpsoap.h upnpreplyparse.h upnpredirect.h getifaddr.h
127 upnpsoap.o: getifstats.h
128 upnpreplyparse.o: upnpreplyparse.h minixml.h
129 minixml.o: minixml.h
130 upnpredirect.o: config.h upnpredirect.h upnpglobalvars.h upnppermissions.h
131 upnpredirect.o: miniupnpdtypes.h upnpevents.h netfilter/iptcrdr.h commonrdr.h
132 getifaddr.o: getifaddr.h
133 daemonize.o: daemonize.h config.h
134 upnpglobalvars.o: config.h upnpglobalvars.h upnppermissions.h
135 upnpglobalvars.o: miniupnpdtypes.h
136 options.o: options.h config.h upnppermissions.h upnpglobalvars.h
137 options.o: miniupnpdtypes.h
138 upnppermissions.o: config.h upnppermissions.h
139 minissdp.o: config.h upnpdescstrings.h miniupnpdpath.h upnphttp.h
140 minissdp.o: upnpglobalvars.h upnppermissions.h miniupnpdtypes.h minissdp.h
141 minissdp.o: codelength.h
142 natpmp.o: config.h natpmp.h upnpglobalvars.h upnppermissions.h
143 natpmp.o: miniupnpdtypes.h getifaddr.h upnpredirect.h commonrdr.h
144 upnpevents.o: config.h upnpevents.h miniupnpdpath.h upnpglobalvars.h
145 upnpevents.o: upnppermissions.h miniupnpdtypes.h upnpdescgen.h
146 linux/getifstats.o: getifstats.h config.h
147 netfilter/iptcrdr.o: netfilter/iptcrdr.h commonrdr.h config.h
148 netfilter/iptcrdr.o: upnpglobalvars.h upnppermissions.h miniupnpdtypes.h
149 testupnpdescgen.o: config.h upnpdescgen.h
150 upnpdescgen.o: config.h upnpdescgen.h miniupnpdpath.h upnpglobalvars.h
151 upnpdescgen.o: upnppermissions.h miniupnpdtypes.h upnpdescstrings.h
152 testgetifstats.o: getifstats.h