2 OUTPUT=static_modules.h
7 #######################################################################
9 # Make static_modules.h from ../raddb/modules
11 # This process is a little complicated.
13 # We're trying to build a C header file, which defines a static
14 # structure, from the ../raddb/modules configuration file. We want
15 # to include ONLY the modules which are being built, and ignore the others.
17 #######################################################################
20 #######################################################################
22 # Root through ../raddb/modules:
26 # Remove blank lines (by looking for NON-blank lines)
28 # Remove '.so' trailers from the module config file
29 # also, replace the FIRST '../' with '/', the FIRST './' with '/',
30 # and the delete from the FIRST '/' to the LAST '/', which is followed
33 # The last sed rule is a bit iffy... It requires ALL modules to begin
34 # with rlm, and there to be NO module configuration parameters containing
35 # the string '/rlm'. It's rare, so I guess we're safe.
37 # Look for pre-build rlm_foo.o files. ONLY include the ones we're told
38 # too use, and ignore the rlm_bar.so's in ../raddb/modules which are
39 # there, but aren't in the MODULES list.
41 #######################################################################
42 MODULES=`echo $* | sed 's/ rlm/|rlm/g;s/\.o//g;'`
43 cat $INPUT | egrep -v '^#' \
46 | sed 's/\.so//;s/\.\.\//\//;s/\.\//\//;s/\/.*\/rlm/rlm/;' \
49 #######################################################################
51 # Create the output file a piece at a time.
53 #######################################################################
54 echo '#ifndef __STATIC_MODULES_H' >> $OUTPUT
55 echo '#define __STATIC_MODULES_H' >> $OUTPUT
58 echo '/* Automatically created header file: do not edit! */' >> $OUTPUT
61 # define the external functions by grabbing the module name
62 awk '{print "extern module_t " $2 ";"}' .tmp.$$ >> $OUTPUT
66 # initialize the array
67 echo 'static static_modules_t modules[] = {' >> $OUTPUT
69 # grab the two fields from the input, and add structure wrappers
70 awk '{print " {\"" $1 "\", \t&" $2 " },"}' .tmp.$$ >> $OUTPUT
72 # output a trailing empty structure for the array
73 echo ' { NULL, NULL }' >> $OUTPUT
75 # and close off the array
79 echo '#endif __STATIC_MODULES_H' >> $OUTPUT
81 #######################################################################
83 # Warn about modules in ../raddb/modules which will NOT be included
84 # in the static server.
86 # The 'sort' and 'uniq' are the to be sure we complain only once.
88 #######################################################################
89 cat $INPUT | egrep -v '^#' \
92 | egrep -v "$MODULES" \
93 | sed 's/\.so//;s/\.\.\//\//;s/\.\//\//;s/\/.*\/rlm/rlm/;' \
97 for x in `cat .tmp.$$`;do
98 echo Warning: Module $x will NOT be included in the server. >/dev/stderr
99 echo " Delete it from ../raddb/modules, or ensure that $x can be built." >/dev/stderr
102 #######################################################################
104 # Don't warn about modules in the MODULES list which are built, but are
105 # NOT in ../raddb/modules, and so will NOT be included in the server.
107 #######################################################################
109 # remove the intermediate config file