miniupnpd: improve configure script for cross builds

This commit is contained in:
Thomas Bernard 2022-05-18 09:55:52 +02:00
parent 6d59337a57
commit 047fe367dd
No known key found for this signature in database
GPG Key ID: DB511043A31ACAAF
2 changed files with 116 additions and 67 deletions

View File

@ -1,4 +1,7 @@
$Id: Changelog.txt,v 1.487 2022/02/19 22:45:06 nanard Exp $ $Id: Changelog.txt,v 1.488 2022/05/18 07:50:46 nanard Exp $
2022/05/18:
improve configure script for cross builds
2022/02/19: 2022/02/19:
prefer non-reserved over reserved addresses in getifaddr() prefer non-reserved over reserved addresses in getifaddr()

60
miniupnpd/configure vendored
View File

@ -1,5 +1,5 @@
#! /bin/sh #! /bin/sh
# $Id: configure,v 1.119 2022/02/19 21:44:50 nanard Exp $ # $Id: configure,v 1.120 2022/05/18 07:50:48 nanard Exp $
# vim: tabstop=4 shiftwidth=4 noexpandtab # vim: tabstop=4 shiftwidth=4 noexpandtab
# #
# miniupnp daemon # miniupnp daemon
@ -17,6 +17,7 @@ UPNP_VERSION_MINOR=1
# IPV6, IGD2, STRICT, DEBUG, LEASFILE, VENDORCFG, PCP_PEER, # IPV6, IGD2, STRICT, DEBUG, LEASFILE, VENDORCFG, PCP_PEER,
# PORTINUSE, DISABLEPPPCONN, FW, IPTABLESPATH, TARGET_OPENWRT, # PORTINUSE, DISABLEPPPCONN, FW, IPTABLESPATH, TARGET_OPENWRT,
# PKG_CONFIG, NO_BACKGROUND_NO_PIDFILE, DYNAMIC_OS_VERSION # PKG_CONFIG, NO_BACKGROUND_NO_PIDFILE, DYNAMIC_OS_VERSION
# OS_NAME, OS_VERSION, OS_MACHINE, V6SOCKETS_ARE_V6ONLY
if [ -z "$DYNAMIC_OS_VERSION" ] ; then if [ -z "$DYNAMIC_OS_VERSION" ] ; then
DYNAMIC_OS_VERSION=1 DYNAMIC_OS_VERSION=1
@ -48,8 +49,16 @@ case "$argv" in
--iptablespath=*) --iptablespath=*)
IPTABLESPATH=$(echo $argv | cut -d= -f2) ;; IPTABLESPATH=$(echo $argv | cut -d= -f2) ;;
--getifaddrs) GETIFADDRS=1 ;; --getifaddrs) GETIFADDRS=1 ;;
--v6sockets-v6only) V6SOCKETS_ARE_V6ONLY=1 ;;
--host-os=*)
OS_NAME=$(echo $argv | cut -d= -f2) ;;
--host-os-version=*)
OS_VERSION=$(echo $argv | cut -d= -f2) ;;
--host-machine=*)
OS_MACHINE=$(echo $argv | cut -d= -f2) ;;
--help|-h) --help|-h)
echo "Usage : $0 [options]" echo "Usage : $0 [options]"
echo " --help this help"
echo " --ipv6 enable IPv6" echo " --ipv6 enable IPv6"
echo " --igd2 build an IGDv2 instead of an IGDv1" echo " --igd2 build an IGDv2 instead of an IGDv1"
echo " --strict be more strict regarding compliance with UPnP specifications" echo " --strict be more strict regarding compliance with UPnP specifications"
@ -64,6 +73,10 @@ case "$argv" in
echo " --iptablespath=/path/to/iptables use a specific version of iptables" echo " --iptablespath=/path/to/iptables use a specific version of iptables"
echo " --disable-fork Do not go to background and do not write pid file" echo " --disable-fork Do not go to background and do not write pid file"
echo " --getifaddrs Force use getifaddrs() to obtain interface addresses" echo " --getifaddrs Force use getifaddrs() to obtain interface addresses"
echo " --v6sockets-v6only v6 sockets don't do v4, ie sysctl net.inet6.ip6.v6only=1"
echo " --host-os=<name> For cross build. result of uname -s on the host machine"
echo " --host-os-version=x.x For cross build. result of uname -r on the host machine"
echo " --host-machine=<arch> For cross build. result of uname -m on the host machine"
exit 1 exit 1
;; ;;
*) *)
@ -93,12 +106,14 @@ fi
# Facility to syslog # Facility to syslog
LOG_MINIUPNPD="LOG_DAEMON" LOG_MINIUPNPD="LOG_DAEMON"
# Makefile to use
MAKEFILE=
if [ -z "$OS_NAME" ] ; then
# detecting the OS name and version # detecting the OS name and version
OS_NAME=`uname -s` OS_NAME=`uname -s`
OS_VERSION=`uname -r` OS_VERSION=`uname -r`
OS_MACHINE=`uname -m` OS_MACHINE=`uname -m`
# Makefile to use
MAKEFILE=
# pfSense special case # pfSense special case
if [ -f /etc/platform ]; then if [ -f /etc/platform ]; then
@ -133,11 +148,20 @@ if [ -f ./os.openembedded ]; then
OS_VERSION=$(cat ./os.openembedded) OS_VERSION=$(cat ./os.openembedded)
fi fi
else
CROSSBUILD=1
if [ -z "$OS_VERSION" ] || [ -z "$OS_MACHINE" ] ; then
echo "OS_NAME set to \"$OS_NAME\"."
echo "Please also set OS_VERSION/--host-os-version and OS_MACHINE/--host-machine"
exit 1
fi
fi
${RM} ${CONFIGFILE} ${RM} ${CONFIGFILE}
echo "/* MiniUPnP Project" >> ${CONFIGFILE} echo "/* MiniUPnP Project" >> ${CONFIGFILE}
echo " * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/" >> ${CONFIGFILE} echo " * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
echo " * (c) 2006-2021 Thomas Bernard" >> ${CONFIGFILE} echo " * (c) 2006-2022 Thomas Bernard" >> ${CONFIGFILE}
echo " * generated by $0 on `date`" >> ${CONFIGFILE} echo " * generated by $0 on `date`" >> ${CONFIGFILE}
echo " * `uname -a`" >> ${CONFIGFILE} echo " * `uname -a`" >> ${CONFIGFILE}
if [ -z "$*" ] ; then if [ -z "$*" ] ; then
@ -215,22 +239,31 @@ case $OS_NAME in
OS_URL=http://www.openbsd.org/ OS_URL=http://www.openbsd.org/
# net.inet6.ip6.v6only has been removed in recent OpenBSD versions # net.inet6.ip6.v6only has been removed in recent OpenBSD versions
# Default to 1 in that case # Default to 1 in that case
if [ "$CROSSBUILD" != "1" ] && [ -z "$V6SOCKETS_ARE_V6ONLY" ] ; then
if sysctl net.inet6.ip6 | grep net.inet6.ip6.v6only ; then if sysctl net.inet6.ip6 | grep net.inet6.ip6.v6only ; then
V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only` V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only`
else else
V6SOCKETS_ARE_V6ONLY=1 V6SOCKETS_ARE_V6ONLY=1
fi fi
fi
;; ;;
FreeBSD | GNU/kFreeBSD) FreeBSD | GNU/kFreeBSD)
MAKEFILE=Makefile.bsd MAKEFILE=Makefile.bsd
if [ "$CROSSBUILD" != "1" ] ; then
VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'` VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
if [ $VER -ge 700049 ]; then if [ $VER -ge 700049 ]; then
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE} echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
fi fi
else
VER=`echo $OS_VERSION | cut -d. -f1`
if [ $VER -ge 7 ]; then
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
fi
fi
HAVE_IP_MREQN=1 HAVE_IP_MREQN=1
# new way to see which one to use PF or IPF. # new way to see which one to use PF or IPF.
# see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957 # see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957
if [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/defaults/rc.conf ] ; then if [ "$CROSSBUILD" != "1" ] && [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/defaults/rc.conf ] ; then
# source file with handy subroutines like checkyesno # source file with handy subroutines like checkyesno
. /etc/rc.subr . /etc/rc.subr
# source config file so we can probe vars # source config file so we can probe vars
@ -259,7 +292,9 @@ case $OS_NAME in
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/
if [ "$CROSSBUILD" != "1" ] && [ -z "$V6SOCKETS_ARE_V6ONLY" ] ; then
V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only` V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only`
fi
;; ;;
pfSense) pfSense)
MAKEFILE=Makefile.bsd MAKEFILE=Makefile.bsd
@ -267,11 +302,13 @@ case $OS_NAME in
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/
if [ "$CROSSBUILD" != "1" ] && [ -z "$V6SOCKETS_ARE_V6ONLY" ] ; then
V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only` V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only`
fi
;; ;;
NetBSD) NetBSD)
MAKEFILE=Makefile.bsd MAKEFILE=Makefile.bsd
if [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ] ; then if [ "$CROSSBUILD" != "1" ] && [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ] ; then
# source file with handy subroutines like checkyesno # source file with handy subroutines like checkyesno
. /etc/rc.subr . /etc/rc.subr
# source config file so we can probe vars # source config file so we can probe vars
@ -291,7 +328,7 @@ case $OS_NAME in
;; ;;
DragonFly) DragonFly)
MAKEFILE=Makefile.bsd MAKEFILE=Makefile.bsd
if [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ] ; then if [ "$CROSSBUILD" != "1" ] && [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ] ; then
# source file with handy subroutines like checkyesno # source file with handy subroutines like checkyesno
. /etc/rc.subr . /etc/rc.subr
# source config file so we can probe vars # source config file so we can probe vars
@ -337,6 +374,7 @@ case $OS_NAME in
if [ \( $KERNVERA -ge 3 \) -o \( $KERNVERA -eq 2 -a $KERNVERB -ge 4 \) ]; then if [ \( $KERNVERA -ge 3 \) -o \( $KERNVERA -eq 2 -a $KERNVERB -ge 4 \) ]; then
HAVE_IP_MREQN=1 HAVE_IP_MREQN=1
fi fi
if [ "$CROSSBUILD" != "1" ] ; then
# Debian GNU/Linux special case # Debian GNU/Linux special case
if [ -f /etc/debian_version ]; then if [ -f /etc/debian_version ]; then
OS_NAME=Debian OS_NAME=Debian
@ -378,7 +416,9 @@ case $OS_NAME in
;; ;;
esac esac
fi fi
fi
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE} echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
if [ "$CROSSBUILD" != "1" ] ; then
if [ -z ${FW} ]; then if [ -z ${FW} ]; then
# test the current environment to determine which to use # test the current environment to determine which to use
# Would be better to check for actual presence of nftable rules, but that requires root privileges # Would be better to check for actual presence of nftable rules, but that requires root privileges
@ -388,7 +428,10 @@ case $OS_NAME in
FW=iptables FW=iptables
fi fi
fi fi
if [ -z "$V6SOCKETS_ARE_V6ONLY" ] ; then
V6SOCKETS_ARE_V6ONLY=`$(find /sbin /bin /usr/sbin /usr/bin -name sysctl) -n net.ipv6.bindv6only` V6SOCKETS_ARE_V6ONLY=`$(find /sbin /bin /usr/sbin /usr/bin -name sysctl) -n net.ipv6.bindv6only`
fi
fi
;; ;;
OpenWrt) OpenWrt)
OS_URL=http://www.openwrt.org/ OS_URL=http://www.openwrt.org/
@ -436,6 +479,9 @@ case $OS_NAME in
;; ;;
*) *)
echo "Unknown OS : $OS_NAME" echo "Unknown OS : $OS_NAME"
echo "Supported OS_NAME / --host-os values : "
# find all the cases in this "case $OS_NAME in" statement :
awk '/# OS Specific stuff/{if(b>0){b=0}else{b=NR}} (b>0&&NR>b){print}' "$0" | grep '^ [^\(]*)$' | grep -v '*)' | tr ')|' " \n" | tr -d '\t ' | sort | tr "\n" " " ; echo ""
echo "Please contact the author at http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/." echo "Please contact the author at http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/."
exit 1 exit 1
;; ;;