Annotation of embedaddon/miniupnpd/Makefile.linux, revision 1.1.1.3

1.1.1.3 ! misho       1: # $Id: Makefile.linux,v 1.75 2012/08/24 18:09:20 nanard Exp $
1.1       misho       2: # MiniUPnP project
1.1.1.3 ! misho       3: # (c) 2006-2012 Thomas Bernard
1.1       misho       4: # http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
                      5: # Author : Thomas Bernard
                      6: # for use with GNU Make
                      7: #
1.1.1.3 ! misho       8: # options can be passed to genconfig.sh through CONFIG_OPTIONS :
        !             9: # $ CONFIG_OPTIONS="--ipv6 --igd2" make -f Makefile.linux
        !            10: #
1.1       misho      11: # To install use :
                     12: # $ PREFIX=/dummyinstalldir make -f Makefile.linux install
                     13: # or :
                     14: # $ INSTALLPREFIX=/usr/local make -f Makefile.linux install
                     15: # or :
                     16: # $ make -f Makefile.linux install
                     17: #
                     18: # if your system hasn't iptables libiptc headers and binary correctly
                     19: # installed, you need to get iptables sources from http://netfilter.org/
                     20: # ./configure them and build them then miniupnpd will build using :
                     21: # $ IPTABLESPATH=/path/to/iptables-1.4.1 make -f Makefile.linux
                     22: #
1.1.1.3 ! misho      23: #CFLAGS = -O -g -DDEBUG
        !            24: CFLAGS ?= -Os
        !            25: CFLAGS += -fno-strict-aliasing
        !            26: CFLAGS += -fno-common
        !            27: CFLAGS += -D_GNU_SOURCE
        !            28: CFLAGS += -Wall
        !            29: CFLAGS += -Wextra -Wstrict-prototypes -Wdeclaration-after-statement
        !            30: #CFLAGS += -Wno-missing-field-initializers
        !            31: #CFLAGS += -ansi       # iptables headers does use typeof which is a gcc extension
1.1.1.2   misho      32: CC ?= gcc
1.1       misho      33: RM = rm -f
                     34: INSTALL = install
1.1.1.2   misho      35: STRIP ?= strip
                     36: CP = cp
                     37: 
1.1       misho      38: 
                     39: INSTALLPREFIX ?= $(PREFIX)/usr
                     40: SBININSTALLDIR = $(INSTALLPREFIX)/sbin
                     41: ETCINSTALLDIR = $(PREFIX)/etc/miniupnpd
1.1.1.3 ! misho      42: MANINSTALLDIR = $(INSTALLPREFIX)/share/man/man8
1.1       misho      43: 
                     44: BASEOBJS = miniupnpd.o upnphttp.o upnpdescgen.o upnpsoap.o \
                     45:            upnpreplyparse.o minixml.o \
1.1.1.3 ! misho      46:            upnpredirect.o getifaddr.o daemonize.o upnpglobalvars.o \
1.1       misho      47:            options.o upnppermissions.o minissdp.o natpmp.o \
1.1.1.3 ! misho      48:            upnpevents.o upnputils.o getconnstatus.o \
        !            49:            upnppinhole.o
1.1       misho      50: 
1.1.1.3 ! misho      51: LNXOBJS = linux/getifstats.o linux/ifacewatcher.o linux/getroute.o
        !            52: NETFILTEROBJS = netfilter/iptcrdr.o netfilter/iptpinhole.o
1.1       misho      53: 
                     54: ALLOBJS = $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS)
                     55: 
1.1.1.2   misho      56: ifeq "$(wildcard /etc/gentoo-release )" ""
                     57: LIBS ?= -liptc
1.1.1.3 ! misho      58: else # gentoo
1.1       misho      59: # the following is better, at least on gentoo with iptables 1.4.6
                     60: # see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1618
1.1.1.2   misho      61: # and http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=2183
                     62: LIBS ?= -lip4tc
1.1.1.3 ! misho      63: CFLAGS := -DIPTABLES_143 $(CFLAGS)
1.1.1.2   misho      64: endif
1.1       misho      65: 
1.1.1.2   misho      66: ARCH ?= $(shell uname -m | grep -q "x86_64" && echo 64)
1.1       misho      67: ifdef IPTABLESPATH
                     68: CFLAGS := $(CFLAGS) -I$(IPTABLESPATH)/include/
                     69: LDFLAGS := $(LDFLAFGS) -L$(IPTABLESPATH)/libiptc/
                     70: # get iptables version and set IPTABLES_143 macro if needed
1.1.1.2   misho      71: ifeq ($(TARGET_OPENWRT),)
1.1       misho      72: IPTABLESVERSION := $(shell grep "\#define VERSION" $(IPTABLESPATH)/config.h | tr -d \" |cut -d" " -f3 )
                     73: IPTABLESVERSION1 := $(shell echo $(IPTABLESVERSION) | cut -d. -f1 )
                     74: IPTABLESVERSION2 := $(shell echo $(IPTABLESVERSION) | cut -d. -f2 )
                     75: IPTABLESVERSION3 := $(shell echo $(IPTABLESVERSION) | cut -d. -f3 )
                     76: # test if iptables version >= 1.4.3
                     77: TEST := $(shell [ \( \( $(IPTABLESVERSION1) -ge 1 \) -a \( $(IPTABLESVERSION2) -ge 4 \) \) -a \( $(IPTABLESVERSION3) -ge 3 \) ] && echo 1 )
                     78: ifeq ($(TEST), 1)
                     79: CFLAGS := $(CFLAGS) -DIPTABLES_143
                     80: # the following sucks, but works
1.1.1.2   misho      81: LIBS = $(IPTABLESPATH)/libiptc/.libs/libip4tc.o
                     82: #LIBS = $(IPTABLESPATH)/libiptc/.libs/libiptc.a
1.1.1.3 ! misho      83: else # ifeq ($(TEST), 1)
1.1       misho      84: LIBS = $(IPTABLESPATH)/libiptc/libiptc.a
1.1.1.3 ! misho      85: endif # ifeq ($(TEST), 1)
        !            86: else # ($(TARGET_OPENWRT),)
        !            87: # openWRT :
1.1       misho      88: # check for system-wide iptables files. Test if iptables version >= 1.4.3
1.1.1.3 ! misho      89: # the following test has to be verified :
1.1       misho      90: TEST := $(shell test -f /usr/include/iptables/internal.h && grep -q "\#define IPTABLES_VERSION" /usr/include/iptables/internal.h && echo 1)
                     91: ifeq ($(TEST), 1)
                     92: CFLAGS := $(CFLAGS) -DIPTABLES_143
                     93: LIBS = -liptc
1.1.1.3 ! misho      94: endif  # ($(TEST), 1)
1.1       misho      95: TEST_LIB := $(shell test -f /usr/lib$(ARCH)/libiptc.a && echo 1)
                     96: ifeq ($(TEST_LIB), 1)
                     97: LIBS = -liptc /usr/lib$(ARCH)/libiptc.a
1.1.1.3 ! misho      98: endif # ($(TEST_LIB), 1)
        !            99: endif # ($(TARGET_OPENWRT),)
        !           100: else # ifdef IPTABLESPATH
        !           101: # IPTABLESPATH not defined
        !           102: # the following test has to be verified :
        !           103: TEST := $(shell test -f /usr/include/xtables.h && grep -q "XTABLES_VERSION_CODE" /usr/include/xtables.h && echo 1)
        !           104: ifeq ($(TEST), 1)
        !           105: CFLAGS := $(CFLAGS) -DIPTABLES_143
        !           106: LIBS = -liptc
        !           107: TESTIP4TC := $(shell test -f /lib/libip4tc.so && echo 1)
        !           108: ifeq ($(TESTIP4TC), 1)
        !           109: LIBS := $(LIBS) -lip4tc
        !           110: endif # ($(TESTIP4TC), 1)
        !           111: TESTIP6TC := $(shell test -f /lib/libip6tc.so && echo 1)
        !           112: ifeq ($(TESTIP6TC), 1)
        !           113: LIBS := $(LIBS) -lip6tc
        !           114: endif # ($(TESTIP6TC), 1)
        !           115: endif # ($(TEST), 1)
        !           116: endif # ifdef IPTABLESPATH
        !           117: 
        !           118: LIBS += -lnfnetlink
1.1       misho     119: 
                    120: TESTUPNPDESCGENOBJS = testupnpdescgen.o upnpdescgen.o
                    121: 
                    122: EXECUTABLES = miniupnpd testupnpdescgen testgetifstats \
1.1.1.3 ! misho     123:               testupnppermissions miniupnpdctl testgetifaddr \
        !           124:               testgetroute
1.1       misho     125: 
                    126: .PHONY:        all clean install depend genuuid
                    127: 
                    128: all:   $(EXECUTABLES)
                    129: 
                    130: clean:
                    131:        $(RM) $(ALLOBJS)
                    132:        $(RM) $(EXECUTABLES)
                    133:        $(RM) testupnpdescgen.o testgetifstats.o
                    134:        $(RM) testupnppermissions.o testgetifaddr.o
1.1.1.3 ! misho     135:        $(RM) testgetroute.o
1.1       misho     136:        $(RM) miniupnpdctl.o
                    137: 
1.1.1.3 ! misho     138: install:       miniupnpd miniupnpd.8 miniupnpd.conf genuuid \
        !           139:        netfilter/iptables_init.sh netfilter/iptables_removeall.sh \
        !           140:        netfilter/ip6tables_init.sh netfilter/ip6tables_removeall.sh \
        !           141:        linux/miniupnpd.init.d.script
1.1       misho     142:        $(STRIP) miniupnpd
                    143:        $(INSTALL) -d $(SBININSTALLDIR)
                    144:        $(INSTALL) miniupnpd $(SBININSTALLDIR)
                    145:        $(INSTALL) -d $(ETCINSTALLDIR)
                    146:        $(INSTALL) netfilter/iptables_init.sh $(ETCINSTALLDIR)
                    147:        $(INSTALL) netfilter/iptables_removeall.sh $(ETCINSTALLDIR)
1.1.1.3 ! misho     148:        $(INSTALL) netfilter/ip6tables_init.sh $(ETCINSTALLDIR)
        !           149:        $(INSTALL) netfilter/ip6tables_removeall.sh $(ETCINSTALLDIR)
1.1       misho     150:        $(INSTALL) --mode=0644 -b miniupnpd.conf $(ETCINSTALLDIR)
                    151:        $(INSTALL) -d $(PREFIX)/etc/init.d
                    152:        $(INSTALL) linux/miniupnpd.init.d.script $(PREFIX)/etc/init.d/miniupnpd
1.1.1.3 ! misho     153:        $(INSTALL) miniupnpd.8 $(MANINSTALLDIR)
        !           154:        gzip $(MANINSTALLDIR)/miniupnpd.8
1.1       misho     155: 
                    156: # genuuid is using the uuidgen CLI tool which is part of libuuid
                    157: # from the e2fsprogs
                    158: genuuid:
1.1.1.2   misho     159: ifeq ($(TARGET_OPENWRT),)
                    160:        sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`(genuuid||uuidgen||uuid) 2>/dev/null`/" miniupnpd.conf
                    161: else
                    162:        sed -i -e "s/^uuid=[-0-9a-f]*/uuid=`($(STAGING_DIR_HOST)/bin/genuuid||$(STAGING_DIR_HOST)/bin/uuidgen||$(STAGING_DIR_HOST)/bin/uuid) 2>/dev/null`/" miniupnpd.conf
                    163: endif
1.1       misho     164: 
                    165: miniupnpd:     $(BASEOBJS) $(LNXOBJS) $(NETFILTEROBJS) $(LIBS)
                    166: 
                    167: testupnpdescgen:       $(TESTUPNPDESCGENOBJS)
                    168: 
                    169: testgetifstats:        testgetifstats.o linux/getifstats.o
                    170: 
                    171: testupnppermissions:   testupnppermissions.o upnppermissions.o
                    172: 
                    173: testgetifaddr: testgetifaddr.o getifaddr.o
                    174: 
1.1.1.3 ! misho     175: testgetroute:  testgetroute.o linux/getroute.o upnputils.o -lnfnetlink
        !           176: 
1.1       misho     177: miniupnpdctl:  miniupnpdctl.o
                    178: 
1.1.1.3 ! misho     179: config.h:      genconfig.sh VERSION
        !           180:        ./genconfig.sh $(CONFIG_OPTIONS)
1.1       misho     181: 
                    182: depend:        config.h
                    183:        makedepend -f$(MAKEFILE_LIST) -Y \
                    184:        $(ALLOBJS:.o=.c) $(TESTUPNPDESCGENOBJS:.o=.c) \
                    185:        testgetifstats.c 2>/dev/null
                    186: 
                    187: # DO NOT DELETE
                    188: 
1.1.1.3 ! misho     189: miniupnpd.o: config.h macros.h upnpglobalvars.h upnppermissions.h
        !           190: miniupnpd.o: miniupnpdtypes.h upnphttp.h upnpdescgen.h miniupnpdpath.h
        !           191: miniupnpd.o: getifaddr.h upnpsoap.h options.h minissdp.h upnpredirect.h
        !           192: miniupnpd.o: upnppinhole.h daemonize.h upnpevents.h natpmp.h commonrdr.h
        !           193: miniupnpd.o: upnputils.h ifacewatcher.h
1.1       misho     194: upnphttp.o: config.h upnphttp.h upnpdescgen.h miniupnpdpath.h upnpsoap.h
1.1.1.3 ! misho     195: upnphttp.o: upnpevents.h upnputils.h
1.1.1.2   misho     196: upnpdescgen.o: config.h getifaddr.h upnpredirect.h upnpdescgen.h
                    197: upnpdescgen.o: miniupnpdpath.h upnpglobalvars.h upnppermissions.h
                    198: upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h upnpurns.h getconnstatus.h
1.1.1.3 ! misho     199: upnpsoap.o: macros.h config.h upnpglobalvars.h upnppermissions.h
        !           200: upnpsoap.o: miniupnpdtypes.h upnphttp.h upnpsoap.h upnpreplyparse.h
        !           201: upnpsoap.o: upnpredirect.h upnppinhole.h getifaddr.h getifstats.h
        !           202: upnpsoap.o: getconnstatus.h upnpurns.h
1.1       misho     203: upnpreplyparse.o: upnpreplyparse.h minixml.h
                    204: minixml.o: minixml.h
1.1.1.3 ! misho     205: upnpredirect.o: macros.h config.h upnpredirect.h upnpglobalvars.h
        !           206: upnpredirect.o: upnppermissions.h miniupnpdtypes.h upnpevents.h
        !           207: upnpredirect.o: netfilter/iptcrdr.h commonrdr.h
1.1.1.2   misho     208: getifaddr.o: config.h getifaddr.h
1.1       misho     209: daemonize.o: daemonize.h config.h
                    210: upnpglobalvars.o: config.h upnpglobalvars.h upnppermissions.h
                    211: upnpglobalvars.o: miniupnpdtypes.h
                    212: options.o: options.h config.h upnppermissions.h upnpglobalvars.h
                    213: options.o: miniupnpdtypes.h
                    214: upnppermissions.o: config.h upnppermissions.h
                    215: minissdp.o: config.h upnpdescstrings.h miniupnpdpath.h upnphttp.h
                    216: minissdp.o: upnpglobalvars.h upnppermissions.h miniupnpdtypes.h minissdp.h
1.1.1.3 ! misho     217: minissdp.o: upnputils.h getroute.h codelength.h
        !           218: natpmp.o: macros.h config.h natpmp.h upnpglobalvars.h upnppermissions.h
        !           219: natpmp.o: miniupnpdtypes.h getifaddr.h upnpredirect.h commonrdr.h upnputils.h
1.1       misho     220: upnpevents.o: config.h upnpevents.h miniupnpdpath.h upnpglobalvars.h
1.1.1.3 ! misho     221: upnpevents.o: upnppermissions.h miniupnpdtypes.h upnpdescgen.h upnputils.h
1.1.1.2   misho     222: upnputils.o: config.h upnputils.h
                    223: getconnstatus.o: getconnstatus.h getifaddr.h
1.1.1.3 ! misho     224: upnppinhole.o: macros.h config.h upnpredirect.h upnpglobalvars.h
        !           225: upnppinhole.o: upnppermissions.h miniupnpdtypes.h upnpevents.h
        !           226: upnppinhole.o: netfilter/iptpinhole.h
1.1.1.2   misho     227: linux/getifstats.o: config.h getifstats.h
                    228: linux/ifacewatcher.o: config.h ifacewatcher.h config.h minissdp.h
                    229: linux/ifacewatcher.o: miniupnpdtypes.h getifaddr.h upnpglobalvars.h
                    230: linux/ifacewatcher.o: upnppermissions.h natpmp.h
1.1.1.3 ! misho     231: linux/getroute.o: getroute.h upnputils.h
        !           232: netfilter/iptcrdr.o: macros.h config.h netfilter/iptcrdr.h commonrdr.h
        !           233: netfilter/iptcrdr.o: config.h upnpglobalvars.h upnppermissions.h
        !           234: netfilter/iptcrdr.o: miniupnpdtypes.h
        !           235: netfilter/iptpinhole.o: config.h netfilter/iptpinhole.h upnpglobalvars.h
        !           236: netfilter/iptpinhole.o: upnppermissions.h config.h miniupnpdtypes.h
        !           237: netfilter/iptpinhole.o: netfilter/tiny_nf_nat.h
        !           238: testupnpdescgen.o: macros.h config.h upnpdescgen.h
1.1.1.2   misho     239: upnpdescgen.o: config.h getifaddr.h upnpredirect.h upnpdescgen.h
                    240: upnpdescgen.o: miniupnpdpath.h upnpglobalvars.h upnppermissions.h
                    241: upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h upnpurns.h getconnstatus.h
1.1       misho     242: testgetifstats.o: getifstats.h

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>