Add command line arguments to genconfig.sh config script

This commit is contained in:
Thomas Bernard 2012-04-15 00:35:31 +02:00
parent 50cb647305
commit e982ebc9f5
4 changed files with 85 additions and 34 deletions

View File

@ -2,6 +2,7 @@ $Id: Changelog.txt,v 1.270 2012/04/14 22:26:09 nanard Exp $
2012/04/15: 2012/04/15:
More C++ => ANSI C comments to compile with -ansi option More C++ => ANSI C comments to compile with -ansi option
Add command line arguments to genconfig.sh config script.
2012/04/12: 2012/04/12:
Set TTL on SSDP Notify sockets (IPv4). TTL is set to 2 (recommendation from Set TTL on SSDP Notify sockets (IPv4). TTL is set to 2 (recommendation from

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.60 2012/02/06 16:28:25 nanard Exp $ # $Id: Makefile,v 1.62 2012/04/14 22:26:10 nanard Exp $
# MiniUPnP project # MiniUPnP project
# http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ # http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
# Author: Thomas Bernard # Author: Thomas Bernard
@ -10,6 +10,10 @@
# This Makefile is NOT compatible with GNU Make. # This Makefile is NOT compatible with GNU Make.
# Linux users, please use Makefile.linux : # Linux users, please use Makefile.linux :
# make -f Makefile.linux # make -f Makefile.linux
#
# options can be passed to genconfig.sh through CONFIG_OPTIONS :
# $ CONFIG_OPTIONS="--ipv6 --igd2" make
#
CFLAGS = -pipe -Wall -Os -ansi CFLAGS = -pipe -Wall -Os -ansi
#CFLAGS = -pipe -Wall -O -g -DDEBUG -ansi #CFLAGS = -pipe -Wall -O -g -DDEBUG -ansi
@ -184,7 +188,7 @@ testupnppermissions: config.h $(TESTUPNPPERMISSIONSOBJS)
# $(CC) $(CFLAGS) -o $@ $> # $(CC) $(CFLAGS) -o $@ $>
config.h: genconfig.sh config.h: genconfig.sh
./genconfig.sh ./genconfig.sh $(CONFIG_OPTIONS)
.SUFFIXES: .o .c .SUFFIXES: .o .c
.c.o: .c.o:

View File

@ -1,10 +1,13 @@
# $Id: Makefile.linux,v 1.61 2012/02/03 15:10:11 nanard Exp $ # $Id: Makefile.linux,v 1.63 2012/04/14 22:26:10 nanard Exp $
# MiniUPnP project # MiniUPnP project
# (c) 2006-2011 Thomas Bernard # (c) 2006-2012 Thomas Bernard
# http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/ # http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
# Author : Thomas Bernard # Author : Thomas Bernard
# for use with GNU Make # for use with GNU Make
# #
# options can be passed to genconfig.sh through CONFIG_OPTIONS :
# $ CONFIG_OPTIONS="--ipv6 --igd2" make -f Makefile.linux
#
# To install use : # To install use :
# $ PREFIX=/dummyinstalldir make -f Makefile.linux install # $ PREFIX=/dummyinstalldir make -f Makefile.linux install
# or : # or :
@ -17,7 +20,7 @@
# ./configure them and build them then miniupnpd will build using : # ./configure them and build them then miniupnpd will build using :
# $ IPTABLESPATH=/path/to/iptables-1.4.1 make -f Makefile.linux # $ IPTABLESPATH=/path/to/iptables-1.4.1 make -f Makefile.linux
# #
#CFLAGS = -Wall -O -D_GNU_SOURCE -g -DDEBUG #CFLAGS = -Wall -O -D_GNU_SOURCE -g -DDEBUG -ansi
CFLAGS ?= -Wall -Os -D_GNU_SOURCE -fno-strict-aliasing -Wstrict-prototypes CFLAGS ?= -Wall -Os -D_GNU_SOURCE -fno-strict-aliasing -Wstrict-prototypes
CC ?= gcc CC ?= gcc
RM = rm -f RM = rm -f
@ -152,7 +155,7 @@ testgetifaddr: testgetifaddr.o getifaddr.o
miniupnpdctl: miniupnpdctl.o miniupnpdctl: miniupnpdctl.o
config.h: genconfig.sh config.h: genconfig.sh
./genconfig.sh ./genconfig.sh $(CONFIG_OPTIONS)
depend: config.h depend: config.h
makedepend -f$(MAKEFILE_LIST) -Y \ makedepend -f$(MAKEFILE_LIST) -Y \
@ -166,7 +169,7 @@ miniupnpd.o: upnphttp.h upnpdescgen.h miniupnpdpath.h getifaddr.h upnpsoap.h
miniupnpd.o: options.h minissdp.h upnpredirect.h daemonize.h upnpevents.h miniupnpd.o: options.h minissdp.h upnpredirect.h daemonize.h upnpevents.h
miniupnpd.o: natpmp.h commonrdr.h upnputils.h ifacewatcher.h miniupnpd.o: natpmp.h commonrdr.h upnputils.h ifacewatcher.h
upnphttp.o: config.h upnphttp.h upnpdescgen.h miniupnpdpath.h upnpsoap.h upnphttp.o: config.h upnphttp.h upnpdescgen.h miniupnpdpath.h upnpsoap.h
upnphttp.o: upnpevents.h upnphttp.o: upnpevents.h upnputils.h
upnpdescgen.o: config.h getifaddr.h upnpredirect.h upnpdescgen.h upnpdescgen.o: config.h getifaddr.h upnpredirect.h upnpdescgen.h
upnpdescgen.o: miniupnpdpath.h upnpglobalvars.h upnppermissions.h upnpdescgen.o: miniupnpdpath.h upnpglobalvars.h upnppermissions.h
upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h upnpurns.h getconnstatus.h upnpdescgen.o: miniupnpdtypes.h upnpdescstrings.h upnpurns.h getconnstatus.h
@ -190,7 +193,7 @@ minissdp.o: upnputils.h codelength.h
natpmp.o: config.h natpmp.h upnpglobalvars.h upnppermissions.h natpmp.o: config.h natpmp.h upnpglobalvars.h upnppermissions.h
natpmp.o: miniupnpdtypes.h getifaddr.h upnpredirect.h commonrdr.h natpmp.o: miniupnpdtypes.h getifaddr.h upnpredirect.h commonrdr.h
upnpevents.o: config.h upnpevents.h miniupnpdpath.h upnpglobalvars.h upnpevents.o: config.h upnpevents.h miniupnpdpath.h upnpglobalvars.h
upnpevents.o: upnppermissions.h miniupnpdtypes.h upnpdescgen.h upnpevents.o: upnppermissions.h miniupnpdtypes.h upnpdescgen.h upnputils.h
upnputils.o: config.h upnputils.h upnputils.o: config.h upnputils.h
getconnstatus.o: getconnstatus.h getifaddr.h getconnstatus.o: getconnstatus.h getifaddr.h
linux/getifstats.o: config.h getifstats.h linux/getifstats.o: config.h getifstats.h

View File

@ -1,11 +1,33 @@
#! /bin/sh #! /bin/sh
# $Id: genconfig.sh,v 1.51 2011/11/18 11:54:00 nanard Exp $ # $Id: genconfig.sh,v 1.53 2012/04/14 22:26:10 nanard Exp $
# miniupnp daemon # miniupnp daemon
# http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/ # http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/
# (c) 2006-2011 Thomas Bernard # (c) 2006-2012 Thomas Bernard
# This software is subject to the conditions detailed in the # This software is subject to the conditions detailed in the
# LICENCE file provided within the distribution # LICENCE file provided within the distribution
for argv; do
case "$argv" in
--ipv6) IPV6=1 ;;
--igd2) IGD2=1 ;;
--strict) STRICT=1 ;;
--leasefile) LEASEFILE=1 ;;
--help|-h)
echo "Usage : $0 [options]"
echo " --ipv6 enable IPv6"
echo " --igd2 build an IGDv2 instead of an IGDv1"
echo " --strict be more strict regarding compliance with UPnP specifications"
echo " --leasefile enable lease file"
exit 1
;;
*)
echo "Option not recognized : $argv"
echo "use -h option to display help"
exit 1
;;
esac
done
RM="rm -f" RM="rm -f"
CONFIGFILE="config.h" CONFIGFILE="config.h"
CONFIGMACRO="__CONFIG_H__" CONFIGMACRO="__CONFIG_H__"
@ -44,7 +66,7 @@ ${RM} ${CONFIGFILE}
echo "/* MiniUPnP Project" >> ${CONFIGFILE} echo "/* MiniUPnP Project" >> ${CONFIGFILE}
echo " * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/" >> ${CONFIGFILE} echo " * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
echo " * (c) 2006-2011 Thomas Bernard" >> ${CONFIGFILE} echo " * (c) 2006-2012 Thomas Bernard" >> ${CONFIGFILE}
echo " * generated by $0 on `date` */" >> ${CONFIGFILE} echo " * generated by $0 on `date` */" >> ${CONFIGFILE}
echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE} echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
echo "#define $CONFIGMACRO" >> ${CONFIGFILE} echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
@ -77,7 +99,6 @@ case $OS_NAME in
if [ $MAJORVER -ge 5 ]; then if [ $MAJORVER -ge 5 ]; then
echo "#define PFRULE_HAS_ONRDOMAIN" >> ${CONFIGFILE} echo "#define PFRULE_HAS_ONRDOMAIN" >> ${CONFIGFILE}
fi fi
echo "#define USE_PF 1" >> ${CONFIGFILE}
FW=pf FW=pf
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
OS_URL=http://www.openbsd.org/ OS_URL=http://www.openbsd.org/
@ -96,25 +117,21 @@ case $OS_NAME in
if checkyesno ipfilter_enable; then if checkyesno ipfilter_enable; then
echo "Using ipf" echo "Using ipf"
FW=ipf FW=ipf
echo "#define USE_IPF 1" >> ${CONFIGFILE}
elif checkyesno pf_enable; then elif checkyesno pf_enable; then
echo "Using pf" echo "Using pf"
FW=pf FW=pf
echo "#define USE_PF 1" >> ${CONFIGFILE} elif checkyesno firewall_enable; then
# TODO : Add support for IPFW echo "Using ifpw"
# echo "#define USE_IPFW 1" >> ${CONFIGFILE} FW=ipfw
# FW=ipfw
else else
echo "Could not detect usage of ipf or pf. Compiling for pf by default" echo "Could not detect usage of ipf, pf, ipfw. Compiling for pf by default"
FW=pf FW=pf
echo "#define USE_PF 1" >> ${CONFIGFILE}
fi fi
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
OS_URL=http://www.freebsd.org/ OS_URL=http://www.freebsd.org/
;; ;;
pfSense) pfSense)
# we need to detect if PFRULE_INOUT_COUNTS macro is needed # we need to detect if PFRULE_INOUT_COUNTS macro is needed
echo "#define USE_PF 1" >> ${CONFIGFILE}
FW=pf FW=pf
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
OS_URL=http://www.pfsense.com/ OS_URL=http://www.pfsense.com/
@ -125,14 +142,11 @@ case $OS_NAME in
# source config file so we can probe vars # source config file so we can probe vars
. /etc/rc.conf . /etc/rc.conf
if checkyesno pf; then if checkyesno pf; then
echo "#define USE_PF 1" >> ${CONFIGFILE}
FW=pf FW=pf
elif checkyesno ipfilter; then elif checkyesno ipfilter; then
echo "#define USE_IPF 1" >> ${CONFIGFILE}
FW=ipf FW=ipf
else else
echo "Could not detect ipf nor pf, defaulting to pf." echo "Could not detect ipf nor pf, defaulting to pf."
echo "#define USE_PF 1" >> ${CONFIGFILE}
FW=pf FW=pf
fi fi
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
@ -144,10 +158,8 @@ case $OS_NAME in
# source config file so we can probe vars # source config file so we can probe vars
. /etc/rc.conf . /etc/rc.conf
if checkyesno pf; then if checkyesno pf; then
echo "#define USE_PF 1" >> ${CONFIGFILE}
FW=pf FW=pf
elif checkyesno ipfilter; then elif checkyesno ipfilter; then
echo "#define USE_IPF 1" >> ${CONFIGFILE}
FW=ipf FW=ipf
else else
echo "Could not detect ipf nor pf, defaulting to pf." echo "Could not detect ipf nor pf, defaulting to pf."
@ -158,7 +170,6 @@ case $OS_NAME in
OS_URL=http://www.dragonflybsd.org/ OS_URL=http://www.dragonflybsd.org/
;; ;;
SunOS) SunOS)
echo "#define USE_IPF 1" >> ${CONFIGFILE}
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
FW=ipf FW=ipf
echo "#define LOG_PERROR 0" >> ${CONFIGFILE} echo "#define LOG_PERROR 0" >> ${CONFIGFILE}
@ -203,13 +214,11 @@ case $OS_NAME in
;; ;;
esac esac
fi fi
echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
FW=netfilter FW=netfilter
;; ;;
OpenWRT) OpenWRT)
OS_URL=http://www.openwrt.org/ OS_URL=http://www.openwrt.org/
echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
FW=netfilter FW=netfilter
;; ;;
@ -219,7 +228,6 @@ case $OS_NAME in
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "#include <tomato_config.h>" >> ${CONFIGFILE} echo "#include <tomato_config.h>" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
echo "#ifdef LINUX26" >> ${CONFIGFILE} echo "#ifdef LINUX26" >> ${CONFIGFILE}
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
echo "#endif" >> ${CONFIGFILE} echo "#endif" >> ${CONFIGFILE}
@ -229,7 +237,6 @@ case $OS_NAME in
FW=netfilter FW=netfilter
;; ;;
Darwin) Darwin)
echo "#define USE_IPFW 1" >> ${CONFIGFILE}
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
FW=ipfw FW=ipfw
OS_URL=http://developer.apple.com/macosx OS_URL=http://developer.apple.com/macosx
@ -241,6 +248,26 @@ case $OS_NAME in
;; ;;
esac esac
case $FW in
pf)
echo "#define USE_PF 1" >> ${CONFIGFILE}
;;
ipf)
echo "#define USE_IPF 1" >> ${CONFIGFILE}
;;
ipfw)
echo "#define USE_IPFW 1" >> ${CONFIGFILE}
;;
netfilter)
echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
;;
*)
echo "Unknown Firewall/packet filtering software [$FW]"
echo "Please contact the author at http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/."
exit 1
;;
esac
echo "Configuring compilation for [$OS_NAME] [$OS_VERSION] with [$FW] firewall software." echo "Configuring compilation for [$OS_NAME] [$OS_VERSION] with [$FW] firewall software."
echo "Please edit config.h for more compilation options." echo "Please edit config.h for more compilation options."
@ -294,7 +321,11 @@ echo "#define USE_DAEMON" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE} echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE}
echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE} if [ -n "$LEASEFILE" ] ; then
echo "#define ENABLE_LEASEFILE" >> ${CONFIGFILE}
else
echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE}
fi
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "/* Define one or none of the two following macros in order to make some" >> ${CONFIGFILE} echo "/* Define one or none of the two following macros in order to make some" >> ${CONFIGFILE}
@ -306,13 +337,21 @@ echo "#define ENABLE_L3F_SERVICE" >> ${CONFIGFILE}
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "/* Enable IP v6 support */" >> ${CONFIGFILE} echo "/* Enable IP v6 support */" >> ${CONFIGFILE}
echo "/*#define ENABLE_IPV6*/" >> ${CONFIGFILE} if [ -n "$IPV6" ]; then
echo "#define ENABLE_IPV6" >> ${CONFIGFILE}
else
echo "/*#define ENABLE_IPV6*/" >> ${CONFIGFILE}
fi
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "/* Enable the support of IGD v2 specification." >> ${CONFIGFILE} echo "/* Enable the support of IGD v2 specification." >> ${CONFIGFILE}
echo " * This is not fully tested yet and can cause incompatibilities with some" >> ${CONFIGFILE} echo " * This is not fully tested yet and can cause incompatibilities with some" >> ${CONFIGFILE}
echo " * control points, so enable with care. */" >> ${CONFIGFILE} echo " * control points, so enable with care. */" >> ${CONFIGFILE}
echo "/*#define IGD_V2*/" >> ${CONFIGFILE} if [ -n "$IGD2" ]; then
echo "#define IGD_V2" >> ${CONFIGFILE}
else
echo "/*#define IGD_V2*/" >> ${CONFIGFILE}
fi
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "#ifdef IGD_V2" >> ${CONFIGFILE} echo "#ifdef IGD_V2" >> ${CONFIGFILE}
@ -341,7 +380,11 @@ echo "" >> ${CONFIGFILE}
echo "/* Enable to make MiniUPnPd more strict about UPnP conformance" >> ${CONFIGFILE} echo "/* Enable to make MiniUPnPd more strict about UPnP conformance" >> ${CONFIGFILE}
echo " * and the messages it receives from control points */" >> ${CONFIGFILE} echo " * and the messages it receives from control points */" >> ${CONFIGFILE}
echo "/*#define UPNP_STRICT*/" >> ${CONFIGFILE} if [ -n "$STRICT" ] ; then
echo "#define UPNP_STRICT" >> ${CONFIGFILE}
else
echo "/*#define UPNP_STRICT*/" >> ${CONFIGFILE}
fi
echo "" >> ${CONFIGFILE} echo "" >> ${CONFIGFILE}
echo "#endif" >> ${CONFIGFILE} echo "#endif" >> ${CONFIGFILE}