3 # IRC - Internet Relay Chat, tools/transition
4 # Copyright (C) 2001 Kevin L. Mitchell <klmitch@mit.edu>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 1, or (at your option)
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # $Id: transition,v 1.1 2001-06-21 23:28:53 kev Exp $
22 # Better than having evals all over the place
30 # Set up an echo that doesn't newline-terminate
31 if test x`echo -n` = x-n; then
41 # Debugging notices, enabled only if $DEBUG has something in it
42 if test x"$DEBUG" = x; then
58 # Get base directory; first step, how were we called?
61 basedir=`echo $0 | sed -e 's@/[^/]*@@g'`
69 # Now locate the ircd subdirectory
70 if test -d $basedir/ircd; then
72 elif test -d $basedir/../ircd; then
74 elif test -d ./ircd; then
77 echo "Cannot find base ircd directory!" >&2
81 # Finally, canonicalize it
87 deb "Base directory: $basedir"
89 # This is where our ./configure-parsable results will go
90 cache_file=$basedir/config.cache
92 # Now locate .config and config.cache
96 # If the config subdirectory isn't there anymore, don't bother checking there
97 if test -d $basedir/config; then
98 if test -r $basedir/config/.config; then
99 config_in=$basedir/config/.config
102 if test -r $basedir/config/config.cache; then
103 config_cache_in=$basedir/config/config.cache
107 # Last ditch effort...try ../.config
108 if test x"$config_in" = x; then
109 if test -r $basedir/../.config; then
110 config_in=$basedir/../.config
112 echo "Cannot find original .config file!" >&2
117 # Last ditch effort...try ../.config.cache
118 if test x"$config_cache_in" = x; then
119 if test -r $basedir/../.config.cache; then
120 config_cache_in=$basedir/../.config.cache
122 echo "Cannot find original config.cache file!" >&2
127 # Now load the two data files
128 echo "Loading old config.cache file $config_cache_in"
130 echo "Loading old .config file $config_in"
133 # Now we have to track down the defaults so we will know what to generate
135 if test ! -r $basedir/ircd/ircd_features.c; then
136 echo "Cannot find default features!" >&2
140 echo_n "Loading feature default values; please be patient... "
143 exec 4<$basedir/ircd/ircd_features.c
144 while read line <&4; do
145 # if a line has '(' but not ')', then we hang them until we find the
146 # matching ')'; this is not robust!
147 if test x"$hangline" != x; then
148 line="$hangline $line"
152 if test x"`echo "$line" | grep '(' 2>/dev/null`" != x -a \
153 x"`echo "$line" | grep ')' 2>/dev/null`" = x; then
158 # Now we process the line we read...
160 \#*) # We want to ignore the #define, since it's a false positive
163 F_[NIBS]*) # Found one of the feature define macros
164 type=`echo "$line" | sed -e 's/^F_\([NIBS]\).*$/\1/g'`
165 arglist=`echo "$line" | sed -e 's/^F_[NIBS](\(.*\)),.*/\1/g' \
168 # Now we must parse the arguments
174 for arg in $arglist; do
176 [NIBS]0) # First argument is always the name of the feature
180 I2) # Second argument of F_I() is the numerical value
184 B2) # Second argument of F_B() is a numerical value
185 # We must convert this numerical value to "y" or "n"
186 if test x"$arg" = x0; then
193 [ST]2) # Second argument of F_S() is a string value; must
194 # take into account unquoted possibilities, though
195 dequote=`echo "$arg" | sed -e 's/^"\(.*\)"$/\1/g'`
196 if test x"$dequote" = x"$arg"; then
205 # Next time through, we'll be testing the next argument
206 argnum=`expr $argnum + 1`
210 deb "Loaded feature \"$name\" of type \"$type\"; default: \"$value\""
212 # Store the information we extracted
213 setvar type_$name $type
214 setvar def_$name "$value"
216 # Keep a list of features we've checked
217 features="$features $name"
224 echo "Converting some options that are still compile-time"
226 unet_cv_prefix=`echo $SPATH | sed -e 's@/bin/ircd@@g'`
227 deb "Installation directory (derived from SPATH)... $unet_cv_prefix"
229 deb_n "Enable debugging (DEBUGMODE)... "
230 if test x"$DEBUGMODE" = xy; then
231 unet_cv_enable_debug=yes
233 unet_cv_enable_debug=no
235 deb "$unet_cv_enable_debug"
237 deb_n "Enable assertion checking (CONFIG_NDEBUG)... "
238 if test x"$CONFIG_NDEBUG" = xy; then
239 unet_cv_enable_asserts=yes
241 unet_cv_enable_asserts=no
243 deb "$unet_cv_enable_asserts"
245 deb_n "Force inlining of some critical functions (FORCEINLINE)... "
246 if test x"$FORCEINLINE" = xy; then
247 unet_cv_enable_inlines=yes
249 unet_cv_enable_inlines=no
251 deb "$unet_cv_enable_inlines"
253 unet_cv_with_symlink=$SYMLINK
254 deb "Symlink name (SYMLINK)... $unet_cv_with_symlink"
256 unet_cv_with_mode=$IRCDMODE
257 deb "Binary permissions (IRCDMODE)... $unet_cv_with_mode"
259 unet_cv_with_owner=$IRCDOWN
260 deb "Binary owner (IRCDOWN)... $unet_cv_with_owner"
262 unet_cv_with_group=$IRCDGRP
263 deb "Binary group owner (IRCDGRP)... $unet_cv_with_group"
265 unet_cv_with_domain=$DOMAINNAME
266 deb "Local domain name (DOMAINNAME)... $unet_cv_with_domain"
268 deb_n "Enable CHROOT operation (CHROOTDIR)... "
269 if test x"$CHROOTDIR" = xy; then
271 unet_cv_with_chroot=$DPATH
273 unet_cv_with_chroot=no
275 deb "$unet_cv_with_chroot"
277 unet_cv_with_dpath=$DPATH
278 deb "Data path (DPATH)... $unet_cv_with_dpath"
280 unet_cv_with_cpath=$CPATH
281 deb "Configuration file (CPATH)... $unet_cv_with_cpath"
283 # LPATH may not be set; if it's not, we'll just ignore it here and let
284 # ./configure fill it in appropriately
285 if test x"$LPATH" != x; then
286 unet_cv_with_lpath=$LPATH
287 deb "Debug log file (LPATH)... $unet_cv_with_lpath"
290 unet_cv_with_maxcon=$MAXCONNECTIONS
291 deb "Maximum number of connections (MAXCONNECTIONS)... $unet_cv_with_maxcon"
293 # Shouldn't run ./configure before the transition script, but we can deal
294 if test -r "$cache_file"; then
295 echo "WARNING: Destroying new config.cache file $cache_file" >&2
299 # Create the cache file...
300 echo "Creating new config.cache file $cache_file"
303 # This section is copied from a GNU autoconf-generated configure script
304 ###############################################################################
305 cat > confcache <<\EOF
306 # This file is a shell script that caches the results of configure
307 # tests run on this system so they can be shared between configure
308 # scripts and configure runs. It is not useful on other systems.
309 # If it contains results you don't want to keep, you may remove or edit it.
311 # By default, configure uses ./config.cache as the cache file,
312 # creating it if it does not exist already. You can give configure
313 # the --cache-file=FILE option to use a different cache file; that is
314 # what configure does when it calls configure scripts in
315 # subdirectories, so they share the cache.
316 # Giving --cache-file=/dev/null disables caching, for debugging configure.
317 # config.status only pays attention to the cache file if you give it the
318 # --recheck option to rerun configure.
321 # The following way of writing the cache mishandles newlines in values,
322 # but we know of no workaround that is simple, portable, and efficient.
323 # So, don't put newlines in cache variables' values.
324 # Ultrix sh set writes to stderr and can't be redirected directly,
325 # and sets the high bit in the cache file unless we assign to the vars.
327 case `(ac_space=' '; set | grep ac_space) 2>&1` in
329 # `set' does not quote correctly, so add quotes (double-quote substitution
330 # turns \\\\ into \\, and sed turns \\ into \).
333 -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p"
336 # `set' quotes correctly as required by POSIX, so do not add quotes.
337 sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p'
340 if cmp -s $cache_file confcache; then
343 if test -w $cache_file; then
344 echo "updating cache $cache_file"
345 cat confcache > $cache_file
347 echo "not updating unwritable cache $cache_file"
351 ###############################################################################
353 # If they ran ./configure before, there'll be a config.status hanging around;
354 # if so, we can run that to integrate the config.cache we just generated.
355 if test -x $basedir/config.status; then
356 echo "Running $basedir/config.status to update configuration"
359 # Have to run it twice to get the Makefile recreated
360 ./config.status --recheck
365 # Now we need to track down ircd.conf so we can add the F-lines.
366 echo_n "Locating IRCD configuration file... "
367 case $unet_cv_with_cpath in
368 /*) # CPATH is absolute
369 conf_file=$unet_cv_with_cpath
372 *) # CPATH is relative to DPATH
373 conf_file=$unet_cv_with_dpath/$unet_cv_with_cpath
376 # suppress duplicate '/'
377 conf_file=`echo "$conf_file" | sed -e 's@//*@/@g'`
380 # if we can't find the .conf, use "flines.conf" in the base directory (so
381 # they'll be easy to find).
382 if test ! -r $conf_file; then
384 conf_file=$basedir/flines.conf
385 if test ! -r $conf_file; then
388 echo "WARNING: Unable to read ircd.conf; you will need to add the" >&2
389 echo " F-lines manually. For your convenience, they will be" >&2
390 echo " placed in $conf_file." >&2
393 # here's where we take the old .config and compare it to the feature defaults
394 echo_n "Building feature table... "
395 for feature in $features; do
396 defval=`getvar def_$feature`
397 value=`getvar $feature`
399 if test x"$value" = x -o x"$value" = x"$defval"; then
400 setvar FEAT_$feature $defval
402 setvar FEAT_$feature $value
406 # We won't add an F-line for DOMAINNAME, since (hopefully) the right one is
407 # already compiled in
408 FEAT_DOMAINNAME=DOMAINNAME
410 # Have to make sure we have a RANDOM_SEED to enhance randomness...
411 FEAT_RANDOM_SEED=$RANDOM_SEED
413 # This feature changed names to be consistent...
414 FEAT_OPER_LBADCHAN=$LOCAL_BADCHAN
416 # DEFAULT_LIST_PARAM is perhaps the most complicated to transition, but
417 # this'll do the trick...
418 if test x"$CONFIG_LIST" = xy; then
419 FEAT_DEFAULT_LIST_PARAM=$DEFAULT_LIST_PARAM
421 FEAT_DEFAULT_LIST_PARAM=0
426 # Now we just generate the F-lines
427 echo_n "Generating F-lines... "
430 # The various log files are set up first--these are all that were defined
432 if test x"$CONFIG_LOG_WHOX" = xy; then
433 echo "F:LOG:WHO:FILE:$WPATH" >&4
435 if test x"$CONFIG_LOG_GLINES" = xy; then
436 echo "F:LOG:GLINE:FILE:$GPATH" >&4
438 if test x"$CONFIG_LOG_USERS" = xy; then
439 echo "F:LOG:USER:FILE:$FNAME_USERLOG" >&4
441 if test x"$CONFIG_LOG_OPERS" = xy; then
442 echo "F:LOG:OPER:FILE:$FNAME_OPERLOG" >&4
445 # Now we traverse the entire feature table and compare values with their
447 for feature in $features; do
448 type=`getvar type_$feature`
449 defval=`getvar def_$feature`
450 value=`getvar FEAT_$feature`
452 if test x"$defval" != x"$value"; then
453 if test x"$type" = xB; then
454 # Must map booleans yet again; I prefer TRUE/FALSE
455 if test x"$value" = xy; then
463 echo "F:$feature:$value" >&4
469 echo_n "Transition is complete."
470 if test ! -r $basedir/config.status; then
471 echo_n " You should now run ./configure."
476 if test x"$fline_conf" = xyes; then
477 echo "Don't forget to add the F-lines to your ircd.conf. They can be"
478 echo "found in $conf_file."
480 echo "Don't forget to verify the F-lines in your ircd.conf!"