pcs         98/02/03 02:49:27

  Modified:    src      Configure
  Log:
  Add support for building shared modules. A new Configuration command,
  SharedModule, indicates that a module should be built as a shared library.
  For example:
  
     SharedModule modules/standard/mod_status.so
  
  (note the change of extension).
  
  Building Apache will then build modules/standard/mod_status.so. This should
  be copied into somewhere under the server root and loaded with a directive 
like:
  
     LoadModule status_module modules/mod_status.so
  
  The compiler and linker flags for creating shareable and shared modules will
  need adding for the supported OSes. I've put some default ones in for FreeBSD
  and Linux. This can also be set in the Configuration file (if set here, it 
will
  override the defaults contained within the Configure script). If there are no
  SharedModule lines none of these extra options will be used anywhere in the
  build process. If the final link of httpd requires any extra libraries
  (typically -ldl) this will have to be given on EXTRA_LIBS in Configuration.
  
  The Configure variables and Configuration options are
  
    CFLAGS_SHLIB     Options when building .o files ready for sharing
                     (e.g. -fpic)
    LDFLAGS_SHLIB    Options when linking .o files to .so (e.g. -Bshareable,
                     -export, -assert pure-text)
    LDFLAGS_SHLIB_EXPORT
                     Options required when linking httpd so that it exports
                     its symbols for linking at runtime (e.g. -Bdynamic,
                     -rdynamic, -export-dynamic)
  
  The options used in Configure could be placed in Configuration like this:
  
    CFLAGS_SHLIB=-fpic
    LDFLAGS_SHLIB=-Bshareable
    LDFLAGS_SHLIB_EXPORT=-rdynamic
  
  Revision  Changes    Path
  1.181     +62 -4     apache-1.3/src/Configure
  
  Index: Configure
  ===================================================================
  RCS file: /export/home/cvs/apache-1.3/src/Configure,v
  retrieving revision 1.180
  retrieving revision 1.181
  diff -u -r1.180 -r1.181
  --- Configure 1998/02/01 16:33:10     1.180
  +++ Configure 1998/02/03 10:49:27     1.181
  @@ -71,9 +71,12 @@
    sed 's/^Rule[       ]*/##Rule:/' | \
    sed 's/^[   ]*AddModule/AddModule/' | \
    sed 's/^[        ]*%AddModule/%AddModule/' | \
  + sed 's/^[        ]*SharedModule/SharedModule/' | \
    sed 's/^[   ]*Module/Module/' | \
    sed 's/^[        ]*%Module/%Module/' > $tmpfile
   
  +using_shlib=`grep  '^SharedModule' $tmpfile >/dev/null && echo 1`
  +
   #
   # Only "assignment" ("=") statements and Module lines
   # should be left at this point. If there is other stuff
  @@ -81,6 +84,7 @@
   #
   if egrep -v '^%?Module[      ]+[A-Za-z0-9_]+[        ]+[^    ]+$' $tmpfile \
    | egrep -v '^%?AddModule[   ]+[^    ]+$' \
  + | egrep -v '^SharedModule[  ]+[^    ]+$' \
    | grep -v = > /dev/null
   then
     echo "Syntax error --- The configuration file is used only to"
  @@ -88,6 +92,7 @@
     echo "options or Configure rules, and I don't see that at all:"
     egrep -v '^%?Module[       ]+[A-Za-z0-9_]+[        ]+[^    ]+$' $tmpfile \
      | egrep -v '^%?AddModule[         ]+[^    ]+$'  \
  +   | egrep -v '^%?SharedModule[      ]+[^    ]+$'  \
      | grep -v =
     exitcode=1
     exit 1
  @@ -316,11 +321,15 @@
        OS='Linux'
        CFLAGS="$CFLAGS -DLINUX=2"
        LIBS="$LIBS -lm"
  +     CFLAGS_SHLIB="-fpic"
  +     LDFLAGS_SHLIB="-Bshareable"
        ;;
       *-linux1)
        DEF_WANTHSREGEX=yes
        OS='Linux'
        CFLAGS="$CFLAGS -DLINUX=1"
  +     CFLAGS_SHLIB="-fpic"
  +     LDFLAGS_SHLIB="-Bshareable"
        ;;
       *-lynx-lynxos)
        OS='LynxOS 2.x'
  @@ -352,6 +361,8 @@
        LIBS="$LIBS -lcrypt"
        DBM_LIB=""
        DB_LIB=""
  +     CFLAGS_SHLIB="-fpic"
  +     LDFLAGS_SHLIB="-Bshareable"
        ;;
       *-openbsd*)
        OS='OpenBSD'
  @@ -636,6 +647,8 @@
   # Look for OPTIM and save for later
   #
   TOPTIM=`egrep '^OPTIM=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  +TLDFLAGS_SHLIB=`egrep '^LDFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= 
'{print $2}'`
  +TCFLAGS_SHLIB=`egrep '^CFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= 
'{print $2}'`
   
   ####################################################################
   # Set the value of CC if need be
  @@ -644,6 +657,26 @@
       echo "CC=$CC" >> Makefile.config
   fi
   
  +if [ "x$using_shlib" = "x1" ] ; then
  +    #
  +    # Set the value of the shared libary flags, if they aren't explicitly
  +    # set in the configuration file
  +    #
  +    if [ "x$TCFLAGS_SHLIB" = "x" ]; then
  +        echo "CFLAGS_SHLIB=$CFLAGS_SHLIB" >> Makefile.config
  +    fi
  +    if [ "x$TLDFLAGS_SHLIB" = "x" ]; then
  +        echo "LDFLAGS_SHLIB=$LDFLAGS_SHLIB" >> Makefile.config
  +    fi
  +    if [ "x$TLDFLAGS_SHLIB_EXPORT" = "x" ]; then
  +        if [ "x$TCC" = "xgcc" ] ||
  +     [ "x$TCC" = "x" -a "x$CC" = "xgcc" ] ; then
  +     LDFLAGS_SHLIB_EXPORT=-rdynamic
  +        fi
  +        echo "LDFLAGS_SHLIB_EXPORT=$LDFLAGS_SHLIB_EXPORT" >> Makefile.config
  +    fi
  +fi   # end of $using_shlib section
  +
   ####################################################################
   # Now we do some OS specific adjustments... for some OSs, we need
   # to adjust CFLAGS and/or OPTIM depending on which compiler we
  @@ -794,7 +827,7 @@
                SEEN[pp[2]] = 1
            }
        }
  -     ($1 == "AddModule" && $2 ~ /^modules\//) { 
  +     (($1 == "AddModule" || $1 == "SharedModule") && $2 ~ /^modules\//) { 
            split ($2, pp, "/")
            if (! SEEN[pp[2]]) {
                printf "%s ", pp[2]
  @@ -1089,10 +1122,35 @@
                    printf "\n"
                }'
   
  +         $CAT << 'EOF' >> $moddir/Makefile
  +
  +all: lib shlib
  +
  +EOF
            echo "LIB=lib$basedir.a" >> $moddir/Makefile
  +         awk >> $moddir/Makefile < $tmpfile '
  +         ($1 == "SharedModule" && $2 ~ /^modules\/'$basedir'\//) {
  +             split($2, pp, "/")
  +             shlibs=shlibs " " pp[3]
  +             so=pp[3]
  +             split(pp[3], parts, ".")
  +             base=parts[1]
  +             shlibsobj=shlibsobj " " base "-so.o"
  +             comp=comp base ".so: " base "-so.o\n"
  +             comp=comp "     $(LD) $(LDFLAGS) $(LDFLAGS_SHLIB) -o " base 
".so $<\n"
  +             comp=comp base "-so.o: " base ".c\n"
  +             comp=comp "     $(CC) $(CFLAGS) $(INCLUDES) $(CFLAGS_SHLIB) -c 
-o " base "-so.o $<\n"
  +         }
  +         END { 
  +             printf "SHLIBS=%s\n", shlibs;
  +             printf "SHLIBS_OBJ=%s\n", shlibsobj;
  +             print "\n" comp "\n" }'
  +
            $CAT << 'EOF' >> $moddir/Makefile
   
  -all: $(LIB)
  +lib: $(LIB) 
  +
  +shlib:       $(SHLIBS)
   
   $(LIB): $(OBJS)
        rm -f $@
  @@ -1103,9 +1161,9 @@
        $(CC) -c $(INCLUDES) $(CFLAGS) $(SPACER) $<
   
   clean:
  -     rm -f *.o $(LIB)
  +     rm -f *.o $(LIB) $(SHLIB)
   
  -$(OBJS): Makefile
  +$(OBJS) $(SHLIBS) $(SHLIBS_OBJ): Makefile
   EOF
        fi
   
  
  
  

Reply via email to