#!/bin/sh # # --enable-broken-crc: # If your RP is buggy cisco PIM-SMv2 implementation that computes # the PIM-Register checksum over the whole pkt instead only over # the header, you need to define this. Otherwise, all your PIM-Register # may be dropped by the cisco-RP. #DEFS += -DBROKEN_CISCO_CHECKSUM # # --enable-kernel-encap: # Register kernel encapsulation. Your kernel must support registers # kernel encapsulation to be able to use it. #DEFS += -DPIM_REG_KERNEL_ENCAP # # --enable-kernel-mfc: # (*,G) kernel MFC support. Use it ONLY with (*,G) capable kernel #DEFS += -DKERNEL_MFC_WC_G # # --enable-memory-save: # Saves 4 bytes per unconfigured interface per routing entry. If set, # configuring such interface will restart the daemon and will flush # the routing table. #DEFS += -DSAVE_MEMORY # # --enable-scoped-acls: # Scoped access control list support in pimd.conf. If you want to # install NUL OIF for the "scoped groups", use the following syntax: # "phyint IFNAME [scoped masklen ]", e.g. # phyint fxp0 scoped "addr" masklen "len" # Support contributed by Marian Stagarescu #DEFS += -DSCOPED_ACL # OS=`uname` CFG=config.mk TMP=`mktemp /tmp/XXXXXX` BUGREPORT_URL="https://github.com/troglobit/pimd/issues" # Defaults debug=0 disable_genid=0 embedded_libc=0 print() { case $OS in Linux) /bin/echo -ne "$*" ;; *) printf "$*" ;; esac } heading() { echo "# This makefile snippet is generated by the pimd configure script." > $CFG echo >> $CFG echo "# Initial definitions ..." >> $CFG echo "# -D_GNU_SOURCE Use GNU extensions, where possible" >> $CFG echo "# -D_BSD_SOURCE Use functions derived from 4.3 BSD Unix rather than POSIX.1" >> $CFG echo "# In GLIBC >= v2.20 this is replaced with -D_DEFAULT_SOURCE " >> $CFG echo "# -DPIM Enable PIM extensions in RSRR" >> $CFG echo "DEFS = -D_BSD_SOURCE -D_DEFAULT_SOURCE -D_GNU_SOURCE -DPIM" >> $CFG echo "# EXTRA_OBJS = For locally provided objects missing on some platforms, e.g., strlcpy.o" >> $CFG echo "# EXTRA_LIBS = For platform specific libraries, e.g., -lutil" >> $CFG echo >> $CFG echo "# $OS specific settings ..." >> $CFG } usage() { print "Run this script to configure pimd for your system.\n" print "\n" print "Usage: configure [ARG]\n" print "\n" print " --debug Enable debuggable build, -g and -O0\n" print " --prefix=PATH Base installation directory, default: /usr/local/\n" print " --sysconfdir=PATH Path to pimd.conf, default: /etc/\n" print " --embedded-libc Linux system with uClibc or musl libc. These two\n" print " C libraries have strlcpy() and strlcat()" print "\n" print "By default 'make install' installs files to /usr/local/{sbin, share, man} and\n" print "/etc/, this can be changed with the --prefix and --syconfdir options. On top of\n" print "this you can also set DESTDIR when installing, to get another root directory.\n" print "\n" print " --enable-broken-crc Interop with older broken Cisco firmware that did\n" print " checksum in PIM Register messages slightly wrong.\n" print " Should not be needed anymore.\n" print " --enable-kernel-encap Specialized kernels do PIM Register encapsulation\n" print " by themselves, speeding up processing considerably.\n" print " \e[1mNot on Linux/*BSD\e[0m, needs pimkern-PATCH_6!\n" print " --enable-kernel-mfc Specialized kernels may have (*,G) MFC support.\n" print " \e[1mNot on Linux/*BSD\e[0m, need pimkern-PATCH_7!\n" print " --enable-memory-save Save 4 bytes/unconfigured interface/routing entry\n" print " Must restart pimd and cause routing table to be\n" print " flushed when configuring new interfaces.\n" print " --enable-scoped-acls Scoped access control list support in pimd.conf\n" print " phyint IFNAME [scoped masklen ]\n" print " phyint fxp0 scoped 239.0.0.0 masklen 8\n" print " --enable-rsrr Routing Support for Resource Reservations, defined in\n" print " http://tools.ietf.org/html/draft-ietf-rsvp-routing-02\n" print " currently used by RSVP. \e[1mEXPERIMENTAL\e[0m\n" print "\n" print " --disable-pim-genid Disable Generation ID in PIM Hello, RFC3973\n" print " --disable-exit-on-error Do not exit on error messages (LOG_ERR)\n" print " --disable-masklen-check Allow virtual tunctl VIFs with masklen 32\n" print "\n" print " --with-includes=PATH Use this if the multicast header files are not in\n" print " a standard location on your system. E.g., /sys\n" print " --with-max-vifs=MAXVIFS Kernel maximum number of allowed VIFs, default: 32\n" print " \e[1mNote:\e[0m Try multiple routing tables instead!\n" print "\n" print "Report bugs to $BUGREPORT_URL\n" print "\n" exit 1 } echo > $TMP echo "# Configured settings/features ..." >> $TMP while [ "$*" != "" ]; do opt=`expr -- "$1" : "--\([^=]*\)=.*"` arg=`expr -- "$1" : "--[^=]*=\(.*\)"` if [ -z "$opt" ]; then opt=`expr -- "$1" : "--\(.*\)"` if [ -z "$opt" ]; then opt=`expr -- "$1" : "-\(.*\)"` fi fi shift case $opt in debug) debug=1; ;; prefix) echo "prefix = $arg" >> $TMP echo "sysconfdir += $arg/etc" >> $TMP ;; sysconfdir) echo "sysconfdir = $arg" >> $TMP ;; embedded-libc) embedded_libc=1 ;; enable-broken-crc) echo "DEFS += -DBROKEN_CISCO_CHECKSUM" >> $TMP ;; enable-kernel-encap) echo "DEFS += -DPIM_REG_KERNEL_ENCAP" >> $TMP ;; enable-kernel-mfc) echo "DEFS += -DKERNEL_MFC_WC_G" >> $TMP ;; enable-memory-save) echo "DEFS += -DSAVE_MEMORY" >> $TMP ;; enable-scoped-acls) echo "DEFS += -DSCOPED_ACL" >> $TMP ;; enable-rsrr) echo "DEFS += -DRSRR" >> $TMP echo "EXTRA_OBJS += rsrr.o" >> $TMP ;; enable-pim-hello-genid) echo "PIM Hello GenID is enabled by default." ;; disable-pim-genid) disable_genid=1 ;; disable-exit-on-error) echo "DEFS += -DCONTINUE_ON_ERROR" >> $TMP ;; disable-masklen-check) echo "DEFS += -DDISABLE_MASKLEN_CHECK" >> $TMP ;; with-includes) echo "INCLUDES += -I$arg" >> $TMP ;; with-max-vifs) echo "DEFS += -DCUSTOM_MAX_VIFS=$arg" >> $TMP ;; help | h) usage ;; *) echo "Skipping unknown option: $opt" ;; esac done echo "DEFS += -DPACKAGE_BUGREPORT=\\\"$BUGREPORT_URL\\\"" >> $TMP if [ $disable_genid -ne 1 ]; then echo "DEFS += -DENABLE_PIM_HELLO_GENID" >> $TMP fi ## BSDI -D__bsdi__ is defined by the OS #INCLUDES = -Iinclude #DEFS += #EXTRA_OBJS = strlcpy.o pidfile.o ## SunOS, OSF1, gcc #INCLUDES = -Iinclude -Iinclude/sunos-gcc #DEFS += -DSunOS=43 #EXTRA_OBJS = strlcpy.o pidfile.o ## SunOS, OSF1, cc #INCLUDES = -Iinclude -Iinclude/sunos-cc #DEFS += -DSunOS=43 #EXTRA_OBJS = strlcpy.o pidfile.o ## IRIX #INCLUDES = -Iinclude #DEFS += -D_BSD_SIGNALS -DIRIX #EXTRA_OBJS = strlcpy.o pidfile.o ## Solaris 2.5, gcc #INCLUDES = -Iinclude #DEFS += -DSYSV -DSunOS=55 ## Solaris 2.5, cc #INCLUDES = -Iinclude #DEFS += -DSYSV -DSunOS=55 ## Solaris 2.6 #INCLUDES = -Iinclude #DEFS += -DSYSV -DSunOS=56 ## Solaris 2.x #EXTRA_OBJS = strlcpy.o pidfile.o #EXTRA_LIBS = -L/usr/ucblib -lucb -L/usr/lib -lsocket -lnsl case $OS in Linux) heading echo "INCLUDES = -Iinclude" >> $CFG echo "DEFS += -DRAW_OUTPUT_IS_RAW -DIOCTL_OK_ON_RAW_SOCKET" >> $CFG echo "ROUTER_OBJS += netlink.o" >> $CFG if [ $embedded_libc -ne 1 ]; then echo "EXTRA_OBJS = libite/strlcpy.o libite/strlcat.o" >> $CFG fi echo "EXTRA_OBJS += libite/pidfile.o libite/strtonum.o" >> $CFG echo "EXTRA_LIBS =" >> $CFG ;; FreeBSD) heading echo "INCLUDES =" >> $CFG echo "ROUTER_OBJS += routesock.o" >> $CFG echo "EXTRA_OBJS = libite/pidfile.o" >> $CFG echo "EXTRA_LIBS =" >> $CFG ;; NetBSD) heading echo "INCLUDES =" >> $CFG echo "ROUTER_OBJS += routesock.o" >> $CFG echo "EXTRA_OBJS = libite/strtonum.o" >> $CFG echo "EXTRA_LIBS = -lutil" >> $CFG ;; OpenBSD) heading echo "INCLUDES =" >> $CFG echo "ROUTER_OBJS += routesock.o" >> $CFG echo "EXTRA_OBJS =" >> $CFG echo "EXTRA_LIBS = -lutil" >> $CFG ;; *) rm $CFG echo "$OS is currently unsupported. Help out at https://github.com/troglobit/pimd/" exit 1 ;; esac echo >> $CFG echo "# Build specific settings ..." >> $CFG if [ $debug -eq 1 ]; then echo "CFLAGS += -O0 -g" >> $CFG else echo "CFLAGS += -O2" >> $CFG fi cat $TMP >> $CFG rm $TMP if [ ! -e libite/lite.h ]; then print " FIXDEP libite/lite.h missing ... " git submodule update --init >/dev/null if [ $? -ne 0 ]; then print "FAILED! No Internet access?" exit 1 fi print "OK\n" fi exit 0