httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Sutton <...@hyperreal.org>
Subject cvs commit: apachen/src Configure
Date Sun, 10 Aug 1997 13:29:08 GMT
pcs         97/08/10 06:29:08

  Modified:    src      Configure
  Log:
  Source re-org: new style Configure
  
  Revision  Changes    Path
  1.127     +272 -119  apachen/src/Configure
  
  Index: Configure
  ===================================================================
  RCS file: /export/home/cvs/apachen/src/Configure,v
  retrieving revision 1.126
  retrieving revision 1.127
  diff -u -r1.126 -r1.127
  --- Configure	1997/08/09 00:55:52	1.126
  +++ Configure	1997/08/10 13:29:06	1.127
  @@ -22,6 +22,8 @@
   ##
   file=Configuration
   tmpfile=htconf.$$
  +tmpfile2=$tmpfile.2
  +tmpfile3=$tmpfile.3
   makefile_tmpl=Makefile.tmpl
   
   ####################################################################
  @@ -77,6 +79,7 @@
   # we bail out
   #
   if egrep -v '^%?Module[ 	]+[A-Za-z0-9_]+[ 	]+[^ 	]+$' $tmpfile \
  + | egrep -v '^%?AddModule[ 	]+[^ 	]+$' \
    | grep -v = > /dev/null
   then
     echo "Syntax error --- The configuration file is used only to"
  @@ -94,39 +97,6 @@
   if [ -f modules.c ] ; then mv modules.c modules.c.bak; fi
   
   ####################################################################
  -# Start building the modules.c file from what was included
  -# in Configuration
  -####
  -sed -e 's/_module//' $tmpfile | awk >modules.c '\
  -   BEGIN { modules[n++] = "core" ; pmodules[pn++] = "core"} \
  -   /^Module/ { modules[n++] = $2 ; pmodules[pn++] = $2 } \
  -   /^%Module/ { pmodules[pn++] = $2 } \
  -   END { print "/* modules.c --- automatically generated by Apache"; \
  -	 print " * configuration script.  DO NOT HAND EDIT!!!!!"; \
  -	 print " */"; \
  -	 print ""; \
  -	 print "#include \"httpd.h\""; \
  -	 print "#include \"http_config.h\""; \
  -	 print ""; \
  -	 for (i = 0; i < pn; ++i) { \
  -	     printf ("extern module %s_module;\n", pmodules[i]); \
  -	 } \
  -	 print ""; \
  -	 print "module *prelinked_modules[] = {"; \
  -	 for (i = 0; i < n; ++i) { \
  -	     printf "  &%s_module,\n", modules[i]; \
  -	 } \
  -	 print "  NULL"; \
  -	 print "};"; \
  -	 print "module *preloaded_modules[] = {"; \
  -	 for (i = 0; i < pn; ++i) { \
  -	     printf "  &%s_module,\n", pmodules[i]; \
  -	 } \
  -	 print "  NULL"; \
  -	 print "};"; \
  -   }'
  -
  -####################################################################
   # Start creating the Makefile. We add some comments and
   # then fold in the modules that were included in Configuration
   #
  @@ -137,17 +107,6 @@
   echo "# is re-run" >> Makefile
   echo "#" >> Makefile
   
  -awk >>Makefile <$tmpfile '\
  -   /^Module/ { modules[n++] = $3 } \
  -   /^%Module/ { modules[n++] = $3 } \
  -   END { print "MODULES=\\"; \
  -	 for (i = 0; i < n; ++i) { \
  -	     if (i < n-1) printf ("  %s \\\n", modules[i]); \
  -	     else printf ("  %s\n", modules[i]); \
  -	 } \
  -	 print "" \
  -       }'
  -
   ####################################################################
   # Now we create a stub file, called Makefile.config, which
   # just includes those assignments (eg: CC=gcc) in Configuration
  @@ -197,6 +156,9 @@
   
   PLAT=`./helpers/GuessOS`
   
  +SHELL="/bin/sh"
  +OSDIR="os/unix"
  +
   case "$PLAT" in
       *MPE/iX*)
           OS='MPE/iX'
  @@ -538,6 +500,7 @@
   ####################################################################
   # Show user what OS we came up with
   #
  +SRCDIR=`pwd`
   echo " + configured for $OS platform"
   
   ####################################################################
  @@ -642,61 +605,11 @@
   ####################################################################
   # Now we do some general checks and some intelligent Configuration
   # control.
  -#
  -# First, we adjust as needed depending on which modules are
  -# being used.
  -#
  -
  -#
  -# Are they using the status monitor module? If so, check
  -# for STATUS rule and add if needed.
  -#
  -STAT_MOD="mod_status"
  -if grep "$STAT_MOD" Makefile > /dev/null; then
  -    if [ "$RULE_STATUS" = "yes" ]; then
  -	CFLAGS="$CFLAGS -DSTATUS"
  -    fi
  -fi
  -
  -#
  -# Now HS's POSIX regex implementation if needed/wanted
  -#
  -if [ "$RULE_WANTHSREGEX" = "yes" ]; then
  -    REGLIB="regex/libregex.a"
  -    INCLUDES="$INCLUDES -Iregex"
  -fi
  -
  -#
  -# Now SOCKS4.
  -#  NOTE: We assume that if they are using SOCKS4, then they've
  -#   adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
  -#   otherwise we assume "-L/usr/local/lib -lsocks"
  -#
  -if [ "$RULE_SOCKS4" = "yes" ]; then
  -    # Set flag and check Makefile for -lsocks line
  -    CFLAGS="$CFLAGS -Dconnect=Rconnect -Dselect=Rselect"
  -    CFLAGS="$CFLAGS -Dgethostbyname=Rgethostbyname"
  -    if grep "EXTRA_" Makefile | grep "\-lsocks" > /dev/null; then : ;
  -    else
  -	LIBS="$LIBS -L/usr/local/lib -lsocks"
  -    fi
  -    if [ "$OS" = "Solaris 2" ]; then
  -	LIBS="$LIBS -lresolv"
  -    fi
  -fi
   
   ####################################################################
   # Continue building Makefile.config. We can add all flags with
   # the exception of LIBS at this point
   #
  -echo "CFLAGS1=$CFLAGS">> Makefile.config
  -echo "INCLUDES1=$INCLUDES">> Makefile.config
  -echo "LDFLAGS1=$LDFLAGS">> Makefile.config
  -echo "BROKEN_BPRINTF_FLAGS=$OSBPRINTF">> Makefile.config
  -echo "REGLIB=$REGLIB">> Makefile.config
  -echo "RANLIB=$RANLIB">> Makefile.config
  -echo "SHELL=$SHELL">> Makefile.config
  -
   ####################################################################
   # Use TestCompile to see if $(CC) is ANSI and as a "final" sanity
   # check
  @@ -751,20 +664,216 @@
   esac
   
   #
  -# Are they using dbm/db auth? If so, add DBM/DB library.
  +# Now HS's POSIX regex implementation if needed/wanted
   #
  -if grep mod_auth_dbm Makefile > /dev/null; then
  -    LIBS="$LIBS $DBM_LIB"
  -    if [ "X$DBM_LIB" != "X" ]; then
  -	echo " + using $DBM_LIB for mod_auth_dbm"
  -    fi
  +if [ "$RULE_WANTHSREGEX" = "yes" ]; then
  +    REGLIB="regex/libregex.a"
  +    INCLUDES="$INCLUDES -I${SRCDIR}/regex"
   fi
  -if grep mod_auth_db Makefile > /dev/null; then
  -    LIBS="$LIBS $DB_LIB"
  -    if [ "X$DB_LIB" != "X" ]; then
  -	echo " + using $DB_LIB for mod_auth_db"
  +
  +#
  +# Now SOCKS4.
  +#  NOTE: We assume that if they are using SOCKS4, then they've
  +#   adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
  +#   otherwise we assume "-L/usr/local/lib -lsocks"
  +#
  +if [ "$RULE_SOCKS4" = "yes" ]; then
  +    # Set flag and check Makefile for -lsocks line
  +    CFLAGS="$CFLAGS -Dconnect=Rconnect -Dselect=Rselect"
  +    CFLAGS="$CFLAGS -Dgethostbyname=Rgethostbyname"
  +    if grep "EXTRA_" Makefile | grep "\-lsocks" > /dev/null; then : ;
  +    else
  +	LIBS="$LIBS -L/usr/local/lib -lsocks"
  +    fi
  +    if [ "$OS" = "Solaris 2" ]; then
  +	LIBS="$LIBS -lresolv"
       fi
   fi
  + 
  +#
  +# Find out what modules we want and try and configure things for them
  +# Module lines can look like this:
  +#
  +#  Module  name_module    some/path/mod_name[.[oa]]
  +#  AddModule              some/path/mod_name[.[oa]]
  +#
  +# In both cases, the some/path can either be an arbitrary path (including
  +# an absolue path), or a path like "modules/DIR", in which case we _might_
  +# auto-generate a Makefile in modules/DIR (see later).
  +#
  +# The first case is the original style, where we give the module's
  +# name as well as it's binary file location - either a .o or .a.
  +#
  +# The second format is new, and means we do not repeat the module
  +# name, which is already part of the module source or definition.
  +# The way we find the module name (and other optional information about
  +# the module) is like this:
  +#
  +#  1 If extension is not given or is .c, assume .o was given and goto 3
  +#  2 If extension if .module, go to D1
  +#  3 If extension is .o, look for a corresponding .c file and if
  +#      found, go to C1
  +#  4 If no .c file was found, look for a .module file (Apache module
  +#      definition file). If found, go to D1
  +#  5 Assume module name is the "name" part of "mod_name", as in
  +#      name_module.
  +#
  +# If a C file is found:
  +#
  +# C1 Look for module name given by an MODULE: line (e.g. MODULE: name_module)
  +#      If found assume module contains a definition, and go to D1
  +# C2 If not found, look for a module name given on the declaration of the
  +#      module structure (e.g. module name_module).
  +# C3 If neither given, go to 4 above.
  +#
  +# If a definition file is found, or a .c file includes a module definition:
  +#
  +# D1 Get the module name from the MODULE: name= line
  +# D2 Get other module options (libraries etc). To be done later.
  +#
  +
  +# For now, we will convert the AddModule lines into Module format
  +# lines, so the rest of Configure can do its stuff without too much
  +# additional hackery. It would be nice to reduce the number of times
  +# we have to awk the $tmpfile, though.
  +
  +# MODFILES contains a list of module filenames (could be .c, .o, .a
  +#    or .module files) from AddModule lines only
  +# MODDIRS contains a list of subdirectories under 'modules' which
  +#    contain modules we want to build from both AddModule and Module
  +#    lines
  +
  +MODFILES=`awk <$tmpfile '$1 == "AddModule" { printf "%s ", $2 }'`
  +MODDIRS=`awk < $tmpfile '\
  +	($1 == "Module" && $3 ~ /^modules\//) { \
  +	    split ($3, pp, "/"); \
  +	if (! SEEN[pp[2]]) { printf "%s ", pp[2]; SEEN[pp[2]] = 1; } \
  +    	} \
  +	($1 == "AddModule" && $2 ~ /^modules\//) { \
  +	    split ($2, pp, "/"); \
  +	if (! SEEN[pp[2]]) { printf "%s ", pp[2]; SEEN[pp[2]] = 1; } \
  +    	} \
  +'`
  +
  +#
  +# Now autoconfigure each of the modules specified by AddModule.
  +# Use tmpfile2 for the module definition file, and tmpfile3 for the
  +# shell commands to be executed for this module.
  +#
  +
  +for modfile in $MODFILES ; do
  +#	echo Trying to find $modfile
  +	rm -f $tmpfile2 $tmpfile3
  +	modname=
  +
  +	ext=`echo $modfile | sed 's/^.*\.//'`
  +	modbase=`echo $modfile | sed 's/\.[^.]*$//'`
  +	if [ x$ext = x$modfile ]; then ext=o; modbase=$modfile; modfile=$modbase.o; fi
  +	if [ x$ext = x ] ; then ext=o; modbase=$modfile; fi
  +
  +	# modbase is the path+filename without extension, ext is the
  +	# extension given, or if none, o
  +#	echo bas=$modbase ext=$ext
  +
  +	if [ -r $modbase.module ] ; then
  +		cat $modbase.module > $tmpfile2
  +	elif [ -e $modbase.c ] ; then
  +		# Guess module structure name in case there is not
  +		# module definition in this file
  +		modname=`grep '^module .*;' $modbase.c | head -1 |\
  +			sed 's/^module.*[ 	][ 	]*//' | \
  +			sed 's/[ 	]*;[ 	]*$//'`
  +		# Get any module definition part
  +		if fgrep "MODULE-DEFINITION-" $modbase.c > /dev/null; then
  +		cat $modbase.c | \
  +		sed '1,/MODULE-DEFINITION-START/d;/MODULE-DEFINITION-END/,$d' \
  +			> $tmpfile2
  +		fi
  +	fi		
  +	if [ -r $tmpfile2 ] ; then
  +		# Read a module definition from .module or .c
  +		modname=`fgrep "Name:" $tmpfile2 | sed 's/^.*Name:[ 	]*//'`
  +		cat $tmpfile2 | sed '1,/ConfigStart/d;/ConfigEnd/,$d' > \
  +			$tmpfile3
  +		. $tmpfile3
  +		rm -f $tmpfile2 $tmpfile3
  +		ext=o
  +	fi
  +	if [ -z "$modname" ] ; then
  +		modname=`echo $modbase | sed 's/^.*\///' | \
  +			sed 's/^mod_//' | sed 's/^lib//' | sed 's/$/_module/'`
  +	fi
  +	echo "Adding Module $modname $modbase.$ext"
  +	echo "Module $modname $modbase.$ext" >>$tmpfile
  +done
  +
  +# $tmpfile now contains Module lines for all the modules we want
  +
  +# create modules.c
  +
  +sed -e 's/_module//' $tmpfile | awk >modules.c '\
  +   BEGIN { modules[n++] = "core" ; pmodules[pn++] = "core"} \
  +   /^Module/ { modules[n++] = $2 ; pmodules[pn++] = $2 } \
  +   /^%Module/ { pmodules[pn++] = $2 } \
  +   END { print "/* modules.c --- automatically generated by Apache"; \
  +	 print " * configuration script.  DO NOT HAND EDIT!!!!!"; \
  +	 print " */"; \
  +	 print ""; \
  +	 print "#include \"httpd.h\""; \
  +	 print "#include \"http_config.h\""; \
  +	 print ""; \
  +	 for (i = 0; i < pn; ++i) { \
  +	     printf ("extern module %s_module;\n", pmodules[i]); \
  +	 } \
  +	 print ""; \
  +	 print "module *prelinked_modules[] = {"; \
  +	 for (i = 0; i < n; ++i) { \
  +	     printf "  &%s_module,\n", modules[i]; \
  +	 } \
  +	 print "  NULL"; \
  +	 print "};"; \
  +	 print "module *preloaded_modules[] = {"; \
  +	 for (i = 0; i < pn; ++i) { \
  +	     printf "  &%s_module,\n", pmodules[i]; \
  +	 } \
  +	 print "  NULL"; \
  +	 print "};"; \
  +   }'
  +
  +# Add the module targets to the Makefile
  +
  +awk >>Makefile <$tmpfile '\
  +   /^Module/ { modules[n++] = $3 } \
  +   /^%Module/ { modules[n++] = $3 } \
  +   END { print "MODULES=\\"; \
  +	 for (i = 0; i < n; ++i) { \
  +	     if (i < n-1) printf ("  %s \\\n", modules[i]); \
  +	     else printf ("  %s\n", modules[i]); \
  +	 } \
  +	 print "" \
  +       }'
  +
  +####################################################################
  +# Continue building Makefile.config. We can add all flags with
  +# the exception of LIBS at this point
  +#
  +echo  >> Makefile
  +if [ "x$CC" != "x" ]; then
  +    echo "CC=$CC" >> Makefile.config
  +fi
  +if [ "x$OPTIM" != "x" ]; then
  +    echo "OPTIM=$OPTIM" >> Makefile.config
  +fi
  +echo "CFLAGS1=$CFLAGS">> Makefile.config
  +echo "INCLUDES1=$INCLUDES -I${SRCDIR}/core">> Makefile.config
  +echo "LIBS1=$LIBS">> Makefile.config
  +echo "LDFLAGS1=$LDFLAGS">> Makefile.config
  +echo "BROKEN_BPRINTF_FLAGS=$OSBPRINTF">> Makefile.config
  +echo "REGLIB=$REGLIB">> Makefile.config
  +echo "RANLIB=$RANLIB">> Makefile.config
  +echo "SHELL=$SHELL">> Makefile.config
  +echo "OSOBJ=${SRCDIR}/$OSDIR/os.o">> Makefile.config
  +echo "OSDIR=${SRCDIR}/$OSDIR">> Makefile.config
   
   ####################################################################
   # NOW we finish Makefile.config
  @@ -773,6 +882,8 @@
   echo >> Makefile.config
   echo "#### End of Configure created section ####">> Makefile.config
   
  +cp $OSDIR/os.h core/os.h
  +
   ####################################################################
   # Now (finish) creating the makefiles
   #
  @@ -782,11 +893,16 @@
   sed -e "s#@@Configuration@@#$file#" "$makefile_tmpl" >>Makefile
   awk >>Makefile <$tmpfile \
      '($1 == "Module" && $3 ~ /modules\//) { printf "%s: modules/last-built ; @cat
/dev/null\n\n", $3, $3}'
  -cat Makefile.config ../support/Makefile.tmpl > ../support/Makefile
   
   #
  -# ./modules/Makefile
  +# directories to create makefiles in
   #
  +MAKEDIRS="support core $OSDIR"
  +for dir in $MAKEDIRS ; do
  +	echo Creating Makefile in $dir
  +	cat Makefile.config $dir/Makefile.tmpl > $dir/Makefile
  +done
  +
   cat << EOF > modules/Makefile
   # 
   # Simple Makefile for modules in src/modules.
  @@ -804,17 +920,14 @@
   echo "INCLUDES2=$INCLUDES2">> modules/Makefile
   echo "MOD_CFLAGS=\$(INCLUDES2) \$(AUX_CFLAGS)">> modules/Makefile
   
  -awk >> modules/Makefile < $tmpfile '\
  -   BEGIN {printf "MODULES="} \
  -   ($1 == "Module" && $3 ~ /modules\//) {split ($3, pp, "/"); printf "%s ", pp[2]}
\
  -   END {printf "\n"}'
  -
  -awk >> modules/Makefile < $tmpfile '\
  -   BEGIN {printf "CLEANERS="} \
  -   ($1 == "Module" && $3 ~ /modules\//) {split ($3, pp, "/"); printf "%s_clean
", pp[2]} \
  -   END {printf "\n"}'
  +CLEANERS=""
  +for i in $MODDIRS ; do
  +	CLEANERS="$CLEANERS${i}_clean "
  +done
   
   cat << EOF >> modules/Makefile
  +MODULES=$MODDIRS
  +CLEANERS=$CLEANERS
   
   default: \$(MODULES)
   	@echo "Done building module subdirectories"
  @@ -822,14 +935,54 @@
   clean: \$(CLEANERS)
   	@echo "Done cleaning module subdirectories"
   
  -placeholder \$(MODULES): ForceMe
  +\$(MODULES): ForceMe
   	(cd \$@; \$(MAKE) CC='\$(CC)' AUX_CFLAGS='\$(MOD_CFLAGS)' RANLIB='\$(RANLIB)')
   
   ForceMe:
   
   EOF
   
  -awk >>modules/Makefile <$tmpfile \
  -   '($1 == "Module" && $3 ~ /modules\//) { split ($3, pp, "/"); \
  -   printf "%s_clean:\n\t(cd %s; $(MAKE) clean)\n\n", pp[2], pp[2]}'
  +(
  +for i in $MODDIRS ; do
  +	echo "${i}_clean:"
  +	echo "	(cd ${i}; \$(MAKE) clean)"
  +	echo ""
  +done
  +) >> modules/Makefile
  +
  +for moddir in $MODDIRS ; do
  +	if [ ! -e modules/$moddir/Makefile.tmpl ] ; then
  +		continue
  +	fi
  +	echo "Creating Makefile in modules/$moddir"
  +
  +	cat Makefile.config > modules/$moddir/Makefile
  +	awk >> modules/$moddir/Makefile < $tmpfile '\
  +	    BEGIN { printf "OBJS=" }\
  +	    ($1 == "Module" && $3 ~ /^modules\/'$moddir'\//) { \
  +		split ($3, pp, "/"); \
  +		printf "%s ", pp[3]; \
  +	    	} \
  +	   END {printf "\n"}'
  +
  +	cat << 'EOF' >> modules/$moddir/Makefile
  +CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
  +LIBS=$(EXTRA_LIBS) $(LIBS1)
  +INCLUDES=$(INCLUDES1) $(EXTRA_INCLUDES)
  +LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
  +INCDIR=../../core
  +
  +all:	$(OBJS)
  +
  +.c.o:
  +	$(CC) -c $(INCLUDES) $(CFLAGS) $(SPACER) $<
  +
  +clean:
  +	rm -f $(OBJS)
  +
  +EOF
  +cat >> modules/$moddir/Makefile < modules/$moddir/Makefile.tmpl
  +
  +done
  +
   
  
  
  

Mime
View raw message