File: configure

package info (click to toggle)
pimd 2.3.2-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,416 kB
  • sloc: ansic: 17,991; sh: 318; makefile: 156
file content (318 lines) | stat: -rwxr-xr-x 9,908 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
#!/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 <MCAST_ADDR> masklen <PREFIX_LEN>]", e.g.
#      phyint fxp0 scoped "addr" masklen "len"
#   Support contributed by Marian Stagarescu <marian@cidera.com>
#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 <MCGROUP> masklen <LEN>]\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