2 # $Id: genconfig.sh,v 1.34 2009/09/04 16:14:05 nanard Exp $
4 # http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/
5 # (c) 2006-2009 Thomas Bernard
6 # This software is subject to the conditions detailed in the
7 # LICENCE file provided within the distribution
11 CONFIGMACRO
="__CONFIG_H__"
13 # version reported in XML descriptions
14 #UPNP_VERSION=20070827
15 UPNP_VERSION
=`date +"%Y%m%d"`
17 LOG_MINIUPNPD
="LOG_DAEMON"
19 # detecting the OS name and version
23 # pfSense special case
24 if [ -f /etc
/platform
]; then
25 if [ `cat /etc/platform` = "pfSense" ]; then
27 OS_VERSION
=`cat /etc/version`
33 echo "/* MiniUPnP Project" >> ${CONFIGFILE}
34 echo " * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
35 echo " * (c) 2006-2009 Thomas Bernard" >> ${CONFIGFILE}
36 echo " * generated by $0 on `date` */" >> ${CONFIGFILE}
37 echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
38 echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
39 echo "" >> ${CONFIGFILE}
40 echo "#include <inttypes.h>" >> ${CONFIGFILE}
41 echo "" >> ${CONFIGFILE}
42 echo "#define UPNP_VERSION \"$UPNP_VERSION\"" >> ${CONFIGFILE}
47 MAJORVER
=`echo $OS_VERSION | cut -d. -f1`
48 MINORVER
=`echo $OS_VERSION | cut -d. -f2`
49 #echo "OpenBSD majorversion=$MAJORVER minorversion=$MINORVER"
50 # rtableid was introduced in OpenBSD 4.0
51 if [ $MAJORVER -ge 4 ]; then
52 echo "#define PFRULE_HAS_RTABLEID" >> ${CONFIGFILE}
54 # from the 3.8 version, packets and bytes counters are double : in/out
55 if [ \
( $MAJORVER -ge 4 \
) -o \
( $MAJORVER -eq 3 -a $MINORVER -ge 8 \
) ]; then
56 echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
58 echo "#define USE_PF 1" >> ${CONFIGFILE}
60 OS_URL
=http
://www.openbsd.org
/
63 VER
=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
64 if [ $VER -ge 700049 ]; then
65 echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
67 # new way to see which one to use PF or IPF.
68 # see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957
69 # source file with handy subroutines like checkyesno
71 # source config file so we can probe vars
73 if checkyesno ipfilter_enable
; then
76 echo "#define USE_IPF 1" >> ${CONFIGFILE}
77 elif checkyesno pf_enable
; then
80 echo "#define USE_PF 1" >> ${CONFIGFILE}
81 # TODO : Add support for IPFW
82 # echo "#define USE_IPFW 1" >> ${CONFIGFILE}
85 echo "Could not detect usage of ipf or pf. Compiling for pf by default"
87 echo "#define USE_PF 1" >> ${CONFIGFILE}
89 OS_URL
=http
://www.freebsd.org
/
92 # we need to detect if PFRULE_INOUT_COUNTS macro is needed
93 echo "#define USE_PF 1" >> ${CONFIGFILE}
95 OS_URL
=http
://www.pfsense.com
/
98 # source file with handy subroutines like checkyesno
100 # source config file so we can probe vars
102 if checkyesno pf
; then
103 echo "#define USE_PF 1" >> ${CONFIGFILE}
105 elif checkyesno ipfilter
; then
106 echo "#define USE_IPF 1" >> ${CONFIGFILE}
109 echo "Could not detect ipf nor pf, defaulting to pf."
110 echo "#define USE_PF 1" >> ${CONFIGFILE}
113 OS_URL
=http
://www.netbsd.org
/
116 echo "#define USE_PF 1" >> ${CONFIGFILE}
117 OS_URL
=http
://www.dragonflybsd.org
/
121 echo "#define USE_IPF 1" >> ${CONFIGFILE}
123 echo "#define LOG_PERROR 0" >> ${CONFIGFILE}
124 echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE}
125 OS_URL
=http
://www.sun.com
/solaris
/
128 OS_URL
=http
://www.kernel.org
/
129 KERNVERA
=`echo $OS_VERSION | awk -F. '{print $1}'`
130 KERNVERB
=`echo $OS_VERSION | awk -F. '{print $2}'`
131 KERNVERC
=`echo $OS_VERSION | awk -F. '{print $3}'`
132 KERNVERD
=`echo $OS_VERSION | awk -F. '{print $4}'`
133 #echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD"
134 # Debian GNU/Linux special case
135 if [ -f /etc
/debian_version
]; then
137 OS_VERSION
=`cat /etc/debian_version`
138 OS_URL
=http
://www.debian.org
/
140 # use lsb_release (Linux Standard Base) when available
141 LSB_RELEASE
=`which lsb_release`
142 if [ 0 -eq $?
]; then
143 OS_NAME
=`${LSB_RELEASE} -i -s`
144 OS_VERSION
=`${LSB_RELEASE} -r -s`
147 OS_URL
=http
://www.debian.org
/
148 OS_VERSION
=`${LSB_RELEASE} -c -s`
151 OS_URL
=http
://www.ubuntu.com
/
152 OS_VERSION
=`${LSB_RELEASE} -c -s`
156 echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
160 echo "#define USE_IPFW 1" >> ${CONFIGFILE}
162 OS_URL
=http
://developer.apple.com
/macosx
165 echo "Unknown OS : $OS_NAME"
166 echo "Please contact the author at http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/."
171 echo "Configuring compilation for [$OS_NAME] [$OS_VERSION] with [$FW] firewall software."
172 echo "Please edit config.h for more compilation options."
174 echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE}
175 echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE}
176 echo "#define OS_URL \"${OS_URL}\"" >> ${CONFIGFILE}
177 echo "" >> ${CONFIGFILE}
179 echo "/* syslog facility to be used by miniupnpd */" >> ${CONFIGFILE}
180 echo "#define LOG_MINIUPNPD ${LOG_MINIUPNPD}" >> ${CONFIGFILE}
181 echo "" >> ${CONFIGFILE}
183 echo "/* Uncomment the following line to allow miniupnpd to be" >> ${CONFIGFILE}
184 echo " * controlled by miniupnpdctl */" >> ${CONFIGFILE}
185 echo "/*#define USE_MINIUPNPDCTL*/" >> ${CONFIGFILE}
186 echo "" >> ${CONFIGFILE}
188 echo "/* Comment the following line to disable NAT-PMP operations */" >> ${CONFIGFILE}
189 echo "#define ENABLE_NATPMP" >> ${CONFIGFILE}
190 echo "" >> ${CONFIGFILE}
192 echo "/* Uncomment the following line to enable generation of" >> ${CONFIGFILE}
193 echo " * filter rules with pf */" >> ${CONFIGFILE}
194 echo "/*#define PF_ENABLE_FILTER_RULES*/">> ${CONFIGFILE}
195 echo "" >> ${CONFIGFILE}
197 echo "/* Uncomment the following line to enable caching of results of" >> ${CONFIGFILE}
198 echo " * the getifstats() function */" >> ${CONFIGFILE}
199 echo "/*#define ENABLE_GETIFSTATS_CACHING*/" >> ${CONFIGFILE}
200 echo "/* The cache duration is indicated in seconds */" >> ${CONFIGFILE}
201 echo "#define GETIFSTATS_CACHING_DURATION 2" >> ${CONFIGFILE}
202 echo "" >> ${CONFIGFILE}
204 echo "/* Uncomment the following line to enable multiple external ip support */" >> ${CONFIGFILE}
205 echo "/* note : Thas is EXPERIMENTAL, do not use that unless you know perfectly what you are doing */" >> ${CONFIGFILE}
206 echo "/*#define MULTIPLE_EXTERNAL_IP*/" >> ${CONFIGFILE}
207 echo "" >> ${CONFIGFILE}
209 echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE}
210 echo " * of BSD daemon() */" >> ${CONFIGFILE}
211 echo "#define USE_DAEMON" >> ${CONFIGFILE}
212 echo "" >> ${CONFIGFILE}
214 echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE}
215 echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE}
216 echo "" >> ${CONFIGFILE}
218 echo "/* Define one or none of the two following macros in order to make some" >> ${CONFIGFILE}
219 echo " * clients happy. It will change the XML Root Description of the IGD." >> ${CONFIGFILE}
220 echo " * Enabling the Layer3Forwarding Service seems to be the more compatible" >> ${CONFIGFILE}
221 echo " * option. */" >> ${CONFIGFILE}
222 echo "/*#define HAS_DUMMY_SERVICE*/" >> ${CONFIGFILE}
223 echo "#define ENABLE_L3F_SERVICE" >> ${CONFIGFILE}
224 echo "" >> ${CONFIGFILE}
226 echo "/* Experimental UPnP Events support. */" >> ${CONFIGFILE}
227 echo "/*#define ENABLE_EVENTS*/" >> ${CONFIGFILE}
228 echo "" >> ${CONFIGFILE}
230 echo "/* include interface name in pf and ipf rules */" >> ${CONFIGFILE}
231 echo "#define USE_IFNAME_IN_RULES" >> ${CONFIGFILE}
232 echo "" >> ${CONFIGFILE}
234 echo "#endif" >> ${CONFIGFILE}