home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1999 April / PCO0499.ISO / filesbbs / os2 / apach134.arj / APACH134.ZIP / src / Configure < prev    next >
Encoding:
Text File  |  1999-01-09  |  55.6 KB  |  2,027 lines

  1. #!/bin/sh
  2. ## ====================================================================
  3. ## Copyright (c) 1995-1999 The Apache Group.  All rights reserved.
  4. ##
  5. ## Redistribution and use in source and binary forms, with or without
  6. ## modification, are permitted provided that the following conditions
  7. ## are met:
  8. ##
  9. ## 1. Redistributions of source code must retain the above copyright
  10. ##    notice, this list of conditions and the following disclaimer. 
  11. ##
  12. ## 2. Redistributions in binary form must reproduce the above copyright
  13. ##    notice, this list of conditions and the following disclaimer in
  14. ##    the documentation and/or other materials provided with the
  15. ##    distribution.
  16. ##
  17. ## 3. All advertising materials mentioning features or use of this
  18. ##    software must display the following acknowledgment:
  19. ##    "This product includes software developed by the Apache Group
  20. ##    for use in the Apache HTTP server project (http://www.apache.org/)."
  21. ##
  22. ## 4. The names "Apache Server" and "Apache Group" must not be used to
  23. ##    endorse or promote products derived from this software without
  24. ##    prior written permission. For written permission, please contact
  25. ##    apache@apache.org.
  26. ##
  27. ## 5. Products derived from this software may not be called "Apache"
  28. ##    nor may "Apache" appear in their names without prior written
  29. ##    permission of the Apache Group.
  30. ##
  31. ## 6. Redistributions of any form whatsoever must retain the following
  32. ##    acknowledgment:
  33. ##    "This product includes software developed by the Apache Group
  34. ##    for use in the Apache HTTP server project (http://www.apache.org/)."
  35. ##
  36. ## THIS SOFTWARE IS PROVIDED BY THE APACHE GROUP ``AS IS'' AND ANY
  37. ## EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  38. ## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  39. ## PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE APACHE GROUP OR
  40. ## ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  41. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  42. ## NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  43. ## LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  44. ## HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  45. ## STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  46. ## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
  47. ## OF THE POSSIBILITY OF SUCH DAMAGE.
  48. ## ====================================================================
  49. ##
  50. ## This software consists of voluntary contributions made by many
  51. ## individuals on behalf of the Apache Group and was originally based
  52. ## on public domain software written at the National Center for
  53. ## Supercomputing Applications, University of Illinois, Urbana-Champaign.
  54. ## For more information on the Apache Group and the Apache HTTP server
  55. ## project, please see <http://www.apache.org/>.
  56.  
  57. # Uses 6 supplemental scripts located in ./helpers:
  58. #    CutRule: Determines the value for a specified Rule
  59. #    GuessOS: Uses uname to determine OS/platform
  60. #    PrintPath: generic "type" or "whence" replacement
  61. #    TestCompile: Can check for libs and if $(CC) is ANSI
  62. #     (i.e., a simple "sanity check")
  63. #    mfhead:
  64. #    fp2rp:
  65. #    slo.sh:
  66.  
  67. exitcode=0
  68. trap 'rm -f $tmpfile $tmpfile2 $tmpfile3 $tmpconfig $awkfile; exit $exitcode' 0 1 2 3 15
  69.  
  70. ####################################################################
  71. ## Set up some defaults
  72. ##
  73. file=Configuration
  74. tmpfile=htconf.$$
  75. tmpfile2=$tmpfile.2
  76. tmpfile3=$tmpfile.3
  77. awkfile=$tmpfile.4
  78. tmpconfig=$tmpfile.5
  79. SUBDIRS="ap main modules"
  80.  
  81. ####################################################################
  82. ## Now handle any arguments, which, for now, is -file
  83. ## to select an alternate Configuration file
  84. ##
  85. while [ "x$1" != "x" ]; do
  86.   if [ "x$1" = "x-file" ] ; then
  87.     shift 1; file=$1; shift 1
  88.     if [ ! -r $file ]; then
  89.       echo "$file does not exist or is not readable."
  90.       exitcode=1
  91.       exit 1
  92.     fi
  93.   else
  94.     echo "ERROR: Bad command line option '$1'"
  95.     echo "  Please read the file INSTALL."
  96.     exit 1
  97.   fi
  98. done
  99. if [ ! -r $file ]; then
  100.   echo "Can't see or read \"$file\""
  101.   echo "Please copy Configuration.tmpl to $file, edit it for your platform,"
  102.   echo "and re-run $0 again."
  103.   exitcode=1
  104.   exit 1
  105. fi
  106.  
  107. ####################################################################
  108. ## Now see if Configuration.tmpl is more recent than $file. If
  109. ## so, then we complain and bail out
  110. ##
  111. if ls -lt Configuration.tmpl $file | head -1 | \
  112.   grep 'Configuration.tmpl' > /dev/null
  113. then
  114.   echo "Configuration.tmpl is more recent than $file;"
  115.   echo "Make sure that $file is valid and, if it is, simply"
  116.   echo "'touch $file' and re-run $0 again."
  117.   exitcode=1
  118.   exit 1
  119. fi
  120.  
  121. echo "Using config file: $file"
  122.  
  123. ####################################################################
  124. ## From the Configuration file, create a "cleaned-up" version
  125. ## that's easy to scan
  126. ##
  127.  
  128. # Strip comments and blank lines, remove whitespace around
  129. # "=" assignments, change Rules to comments and then remove whitespace
  130. # before Module declarations
  131. sed 's/#.*//' $file | \
  132.  sed '/^[     ]*$/d' | \
  133.  sed 's/[     ]*$//' | \
  134.  sed 's/[     ]*=[     ]*/=/' | \
  135.  sed '/^Rule[     ]*/d' | \
  136.  sed 's/^[     ]*AddModule/AddModule/' | \
  137.  sed 's/^[     ]*%AddModule/%AddModule/' | \
  138.  sed 's/^[     ]*SharedModule/SharedModule/' | \
  139.  sed 's/^[     ]*Module/Module/' | \
  140.  sed 's/^[     ]*%Module/%Module/' > $tmpfile
  141.  
  142. # Determine if shared objects are used
  143. using_shlib=`grep  '^SharedModule' $tmpfile >/dev/null && echo 1`
  144.  
  145. # But perhaps later via apxs when just mod_so is compiled in!
  146. if [ "x$using_shlib" = "x" ]; then
  147.     using_shlib=`grep  '^AddModule modules/standard/mod_so.o' $tmpfile >/dev/null && echo 1`
  148. fi
  149.  
  150. # Only "assignment" ("=") statements and Module lines
  151. # should be left at this point. If there is other stuff
  152. # we bail out
  153. if egrep -v '^%?Module[     ]+[A-Za-z0-9_]+[     ]+[^     ]+$' $tmpfile \
  154.  | egrep -v '^%?AddModule[     ]+[^     ]+$' \
  155.  | egrep -v '^SharedModule[     ]+[^     ]+$' \
  156.  | grep -v = > /dev/null
  157. then
  158.   echo "Syntax error --- The configuration file is used only to"
  159.   echo "define the list of included modules or to set Makefile"
  160.   echo "options or Configure rules, and I don't see that at all:"
  161.   egrep -v '^%?Module[     ]+[A-Za-z0-9_]+[     ]+[^     ]+$' $tmpfile \
  162.    | egrep -v '^%?AddModule[     ]+[^     ]+$'  \
  163.    | egrep -v '^%?SharedModule[     ]+[^     ]+$'  \
  164.    | grep -v =
  165.   exitcode=1
  166.   exit 1
  167. fi
  168.  
  169. ####################################################################
  170. ## If we find the directory /usr/local/etc/httpd and there is
  171. ## no HTTPD_ROOT flag set in the Configuration file we assume
  172. ## that the user was using the old default root directory
  173. ## and issue a notice about it.
  174. ##
  175. if [ $file != "Configuration.apaci" ]
  176. then
  177.   if [ -d /usr/local/etc/httpd/ ]
  178.   then
  179.     if egrep '^EXTRA_CFLAGS.*HTTPD_ROOT' $file >/dev/null
  180.     then
  181.       :
  182.     else
  183.       echo " | Please note that the default httpd root directory has changed"
  184.       echo " | from '/usr/local/etc/httpd/' to '/usr/local/apache/.'"
  185.       echo " | You may add '-DHTTPD_ROOT=\\\"/usr/local/etc/httpd\\\"' to EXTRA_CFLAGS"
  186.       echo " | in your Configuration file (and re-run Configure) or start"
  187.       echo " | httpd with the option '-d /usr/local/etc/httpd' if you still"
  188.       echo " | want to use the old root directory for your server."
  189.     fi
  190.   fi
  191. fi
  192.  
  193. ####################################################################
  194. ## Start creating the Makefile. We add some comments and
  195. ## then fold in the modules that were included in Configuration
  196. ##
  197. echo "Creating Makefile"
  198. ./helpers/mfhead . $file > Makefile
  199.  
  200. ####################################################################
  201. ## Now we create a stub file, called Makefile.config, which
  202. ## just includes those assignments (eg: CC=gcc) in Configuration
  203. ##
  204. awk >Makefile.config <$tmpfile '
  205.     BEGIN {
  206.     print "##"
  207.     print "##  Inherited Makefile options from Configure script"
  208.     print "##  (Begin of automatically generated section)"
  209.     print "##"
  210.     print "SRCDIR=."
  211.     } 
  212.     /\=/ { print } 
  213.     '
  214.  
  215. ####################################################################
  216. ## Extract the rules.
  217. ##
  218. RULE_WANTHSREGEX=`./helpers/CutRule WANTHSREGEX $file`
  219. RULE_STATUS=`./helpers/CutRule STATUS $file`
  220. RULE_SOCKS4=`./helpers/CutRule SOCKS4 $file`
  221. RULE_SOCKS5=`./helpers/CutRule SOCKS5 $file`
  222. RULE_IRIXNIS=`./helpers/CutRule IRIXNIS $file`
  223. RULE_IRIXN32=`./helpers/CutRule IRIXN32 $file`
  224. RULE_PARANOID=`./helpers/CutRule PARANOID $file`
  225. RULE_SHARED_CORE=`./helpers/CutRule SHARED_CORE $file`
  226. RULE_SHARED_CHAIN=`./helpers/CutRule SHARED_CHAIN $file`
  227.  
  228. ####################################################################
  229. ## Rule SHARED_CORE implies required DSO support
  230. ##
  231. if [ "$RULE_SHARED_CORE" = "yes" ]; then
  232.     using_shlib=1
  233. fi
  234.  
  235. ####################################################################
  236. ## Preset some "constants";
  237. ## can be overridden on a per-platform basis below.
  238. ##
  239. DBM_LIB="-ldbm"
  240. DB_LIB="-ldb"
  241. SHELL="/bin/sh"
  242. SUBTARGET="target_static"
  243. SHLIB_SUFFIX_NAME=""
  244. SHLIB_SUFFIX_LIST=""
  245. CAT="cat"
  246.  
  247. ####################################################################
  248. ## Now we determine the OS/Platform automagically, thanks to
  249. ## GuessOS, a home-brewed OS-determiner ala config.guess
  250. ##
  251. ## We adjust CFLAGS, LIBS, LDFLAGS and INCLUDES (and other Makefile
  252. ## options) as required. Setting CC and OPTIM here has no effect
  253. ## if they were set in Configure.
  254. ##
  255. ## Also, we set DEF_WANTHSREGEX and to the appropriate
  256. ## value for each platform.
  257. ##
  258. ## As more PLATFORMs are added to Configuration.tmpl, be sure to
  259. ## add the required lines below.
  260. ##
  261. PLAT=`./helpers/GuessOS`
  262. SHELL="/bin/sh"
  263. OSDIR="os/unix"
  264.  
  265. case "$PLAT" in
  266.     *mint)
  267.     OS="MiNT"
  268.     CFLAGS="-DMINT"
  269.     LIBS="$LIBS -lportlib -lsocket"
  270.     DEF_WANTHSREGEX=yes
  271.     ;;
  272.     *MPE/iX*)
  273.     OS='MPE/iX'
  274.     CFLAGS="$CFLAGS -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE"
  275.     LIBS="$LIBS -lsocket -lsvipc"
  276.     LDFLAGS="$LDFLAGS -Xlinker \"-WL,cap=ia,ba,ph,pm;nmstack=1024000\""
  277.     CAT="/bin/cat" # built-in cat is badly broken for stdin redirection
  278.     ;;
  279.     *-apple-aux3*)
  280.     OS='A/UX 3.1.x'
  281.     CFLAGS="$CFLAGS -DAUX3 -D_POSIX_SOURCE"
  282.     LIBS="$LIBS -lposix -lbsd"
  283.     LDFLAGS="$LDFLAGS -s"
  284.     DEF_WANTHSREGEX=no
  285.     ;;
  286.     i386-ibm-aix*)
  287.     OS='IBM AIX PS/2'
  288.     CFLAGS="$CFLAGS -DAIX=1 -U__STR__ -DUSEBCOPY"
  289.     DEF_WANTHSREGEX=no
  290.     ;;
  291.     *-ibm-aix[1-2].*)
  292.     OS='IBM AIX 1.x/2.x'
  293.     CFLAGS="$CFLAGS -DAIX=1 -DNEED_RLIM_T -U__STR__"
  294.     ;;
  295.     *-ibm-aix3.*)
  296.     OS='IBM AIX 3.x'
  297.     CFLAGS="$CFLAGS -DAIX=30 -DNEED_RLIM_T -U__STR__"
  298.     ;;
  299.     *-ibm-aix4.1)
  300.     OS='IBM AIX 4.1'
  301.     CFLAGS="$CFLAGS -DAIX=41 -DNEED_RLIM_T -U__STR__"
  302.     ;;
  303.     *-ibm-aix4.2)
  304.     OS='IBM AIX 4.2'
  305.     CFLAGS="$CFLAGS -DAIX=42 -U__STR__"
  306.     LDFLAGS="$LDFLAGS -lm"
  307.     ;;
  308.     *-ibm-aix4.3)
  309.     OS='IBM AIX 4.3'
  310.     CFLAGS="$CFLAGS -DAIX=43 -U__STR__"
  311.     LDFLAGS="$LDFLAGS -lm"
  312.     ;;
  313.     *-ibm-aix*)
  314.     OS='IBM AIX'
  315.     CFLAGS="$CFLAGS -DAIX=1 -U__STR__"
  316.     LDFLAGS="$LDFLAGS -lm"
  317.     ;;
  318.     *-apollo-*)
  319.     OS='Apollo Domain'
  320.     CFLAGS="$CFLAGS -DAPOLLO"
  321.     ;;
  322.     *-dg-dgux*)
  323.     OS='DG/UX 5.4'
  324.     CFLAGS="$CFLAGS -DDGUX"
  325.     DEF_WANTHSREGEX=yes
  326.     ;;
  327.     *OS/2*)
  328.     OSDIR="os/os2"
  329.     DEF_WANTHSREGEX=yes
  330.     OS='EMX OS/2'
  331.     CFLAGS="$CFLAGS -DOS2 -Zbsd-signals -Zbin-files -DTCPIPV4 -g"
  332.     LDFLAGS="$LDFLAGS -Zexe"
  333.     LIBS="$LIBS -lsocket -lufc -lbsd"
  334.     DBM_LIB="-lgdbm"
  335.     SHELL=sh
  336.     ;;
  337.     *-hi-hiux)
  338.     OS='HI-UX'
  339.     CFLAGS="$CFLAGS -DHIUX"
  340.     ;;
  341.     *-hp-hpux11.*)
  342.     OS='HP-UX 11'
  343.     CFLAGS="$CFLAGS -DHPUX11"
  344.     RANLIB="/bin/true"
  345.     LIBS="$LIBS -lm -lpthread"
  346.     DEF_WANTHSREGEX=yes
  347.     ;;
  348.     *-hp-hpux10.*)
  349.     OS='HP-UX 10'
  350.     CFLAGS="$CFLAGS -DHPUX10"
  351.     RANLIB="/bin/true"
  352.      case "$PLAT" in
  353.        *-hp-hpux10.01)
  354.            # We know this is a problem in 10.01.
  355.            # Not a problem in 10.20.  Otherwise, who knows?
  356.            CFLAGS="$CFLAGS -DSELECT_NEEDS_CAST"
  357.            ;;         
  358.      esac
  359.     DEF_WANTHSREGEX=yes
  360.     ;;
  361.     *-hp-hpux*)
  362.     OS='HP-UX'
  363.     CFLAGS="$CFLAGS -DHPUX"
  364.     RANLIB="/bin/true"
  365.     DEF_WANTHSREGEX=yes
  366.     LIBS="$LIBS -lm"
  367.     ;;
  368.     *-sgi-irix64)
  369.     # Note: We'd like to see patches to compile 64-bit, but for now...
  370.     echo "You are running 64-bit Irix. For now, we will compile 32-bit"
  371.     echo "but if you would care to port to 64-bit, send us the patches."
  372.     DEF_WANTHSREGEX=yes
  373.     DBM_LIB=""
  374.     if [ "$RULE_IRIXNIS" = "yes" ]; then
  375.         OS='SGI IRIX-64 w/NIS'
  376.         CFLAGS="$CFLAGS -DIRIX"
  377.         LIBS="$LIBS -lsun"
  378.     else
  379.         OS='SGI IRIX-64'
  380.         CFLAGS="$CFLAGS -DIRIX"
  381.     fi
  382.     ;;
  383.     *-sgi-irix32)
  384.     DEF_WANTHSREGEX=yes
  385.     DBM_LIB=""
  386.     if [ "$RULE_IRIXN32" = "yes" ]; then
  387.         if [ "$RULE_IRIXNIS" = "yes" ]; then
  388.         OS='SGI IRIX-32 w/NIS'
  389.         else
  390.         OS='SGI IRIX-32'
  391.         fi
  392.     else
  393.         if [ "$RULE_IRIXNIS" = "yes" ]; then
  394.         OS='SGI IRIX w/NIS'
  395.         else
  396.         OS='SGI IRIX'
  397.         fi
  398.     fi
  399.     CC='cc'
  400.     CFLAGS="$CFLAGS -DIRIX"
  401.     ;;
  402.     *-sgi-irix)
  403.     DEF_WANTHSREGEX=yes
  404.     DBM_LIB=""
  405.     if [ "$RULE_IRIXNIS" = "yes" ]; then
  406.         OS='SGI IRIX w/NIS'
  407.         CFLAGS="$CFLAGS -DIRIX"
  408.         LIBS="$LIBS -lsun"
  409.     else
  410.         OS='SGI IRIX'
  411.         CFLAGS="$CFLAGS -DIRIX"
  412.     fi
  413.     ;;
  414.     *-linux2)
  415.     DEF_WANTHSREGEX=yes
  416.     OS='Linux'
  417.     CFLAGS="$CFLAGS -DLINUX=2"
  418.     LIBS="$LIBS -lm"
  419.     ;;
  420.     *-linux1)
  421.     DEF_WANTHSREGEX=yes
  422.     OS='Linux'
  423.     CFLAGS="$CFLAGS -DLINUX=1"
  424.     ;;
  425.     *-lynx-lynxos)
  426.     OS='LynxOS 2.x'
  427.     CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__ -DLYNXOS"
  428.     LIBS="$LIBS -lbsd -lcrypt"
  429.     DEF_WANTHSREGEX=yes
  430.     ;;
  431.     *486-*-bsdi*)
  432.     OS='BSDI w/486'
  433.     CFLAGS="$CFLAGS -m486"
  434.     DBM_LIB=""
  435.     DB_LIB=""
  436.     ;;
  437.     *-bsdi*)
  438.     OS='BSDI'
  439.     DBM_LIB=""
  440.     DB_LIB=""
  441.     ;;
  442.     *-netbsd*)
  443.     OS='NetBSD'
  444.     CFLAGS="$CFLAGS -DNETBSD"
  445.     LIBS="$LIBS -lcrypt"
  446.     DBM_LIB=""
  447.     DB_LIB=""
  448.     DEF_WANTHSREGEX=no
  449.     ;;
  450.     *-freebsd*)
  451.         PLATOSVERS=`echo $PLAT | sed 's/^.*freebsd//'`
  452.     OS="FreeBSD $PLATOSVERS"
  453.     case "$PLATOSVERS" in
  454.         [23]*)
  455.         DEF_WANTHSREGEX=no
  456.         CFLAGS="$CFLAGS -funsigned-char"
  457.         ;;
  458.     esac
  459.     LIBS="$LIBS -lcrypt"
  460.     DBM_LIB=""
  461.     DB_LIB=""
  462.     ;;
  463.     *-openbsd*)
  464.     OS='OpenBSD'
  465.     DBM_LIB=""
  466.     ;;
  467.     *-next-nextstep*)
  468.     OS='NeXTStep'
  469.     OPTIM='-O'
  470.     CFLAGS="$CFLAGS -DNEXT"
  471.     DEF_WANTHSREGEX=yes
  472.     ;;
  473.     *-next-openstep*)
  474.     OS='OpenStep/Mach'
  475.     CC='cc'
  476.     OPTIM='-O'
  477.     CFLAGS="$CFLAGS -DNEXT"
  478.     CFLAGS_SHLIB='-dynamic -fno-common'
  479.     LD_SHLIB='cc'
  480.     LDFLAGS_SHLIB='-dynamiclib -undefined warning'
  481.     DEF_WANTHSREGEX=yes
  482.     ;;
  483.     *-apple-rhapsody*)
  484.     OS='Mac OS X Server'
  485.     CFLAGS="$CFLAGS -DRHAPSODY"
  486.     DEF_WANTHSREGEX=yes
  487.     ;;
  488.     *-dec-osf*)
  489.     OS='DEC OSF/1'
  490.     CFLAGS="$CFLAGS -DOSF1"
  491.     LIBS="$LIBS -lm"
  492.     ;;
  493.     *-qnx)
  494.     OS='QNX'
  495.     CFLAGS="$CFLAGS -DQNX"
  496.     LIBS="$LIBS -N128k -lsocket -lunix"
  497.     DEF_WANTHSREGEX=yes
  498.     ;;
  499.     *-qnx32)
  500.         CC='cc -F'
  501.     OS='QNX32'
  502.     CFLAGS="$CFLAGS -DQNX -mf -3"
  503.     LIBS="$LIBS -N128k -lsocket -lunix"
  504.     DEF_WANTHSREGEX=yes
  505.     ;;
  506.     *-isc4*)
  507.     OS='ISC 4'
  508.     CC='gcc'
  509.     CFLAGS="$CFLAGS -posix -DISC"
  510.     LDFLAGS="$LDFLAGS -posix"
  511.     LIBS="$LIBS -linet"
  512.     DEF_WANTHSREGEX=yes
  513.     ;;
  514.     *-sco3*)
  515.     OS='SCO 3'
  516.     CFLAGS="$CFLAGS -DSCO -Oacgiltz"
  517.     LIBS="$LIBS -lPW -lsocket -lmalloc -lcrypt_i"
  518.     DEF_WANTHSREGEX=yes
  519.     ;;
  520.     *-sco5*)
  521.     OS='SCO 5'
  522.     CFLAGS="$CFLAGS -DSCO5"
  523.     LIBS="$LIBS -lsocket -lmalloc -lprot -ltinfo -lx -lm"
  524.     DEF_WANTHSREGEX=no
  525.     ;;
  526.     *-sco_sv*|*-SCO_SV*)
  527.     OS='SCO SV'
  528.     CFLAGS="$CFLAGS -DSCO"
  529.     LIBS="$LIBS -lPW -lsocket -lmalloc -lcrypt_i"
  530.     DEF_WANTHSREGEX=yes
  531.     ;;
  532.     *-solaris2*)
  533.         PLATOSVERS=`echo $PLAT | sed 's/^.*solaris2.//'`
  534.     OS="Solaris $PLATOSVERS"
  535.     CFLAGS="$CFLAGS -DSOLARIS2=$PLATOSVERS"
  536.     LIBS="$LIBS -lsocket -lnsl"
  537.     DBM_LIB=""
  538.     case "$PLATOSVERS" in
  539.         2[01234]*)
  540.         DEF_WANTHSREGEX=yes
  541.         ;;
  542.         *)
  543.         DEF_WANTHSREGEX=no
  544.         ;;
  545.     esac
  546.     ;;
  547.     *-sunos4*)
  548.     OS='SunOS 4'
  549.     CFLAGS="$CFLAGS -DSUNOS4 -DUSEBCOPY"
  550.     DEF_WANTHSREGEX=yes
  551.     ;;
  552.     *-unixware1)
  553.     DEF_WANTHSREGEX=yes
  554.     OS='UnixWare 1.x'
  555.     CFLAGS="$CFLAGS -DUW=100"
  556.     LIBS="$LIBS -lsocket -lnsl -lcrypt"
  557.     ;;
  558.     *-unixware2)
  559.     DEF_WANTHSREGEX=yes
  560.     OS='UnixWare 2.x'
  561.     CFLAGS="$CFLAGS -DUW=200"
  562.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  563.     ;;
  564.     *-unixware211)
  565.     OS='UnixWare 2.1.1'
  566.     CFLAGS="$CFLAGS -DUW=211"
  567.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  568.     ;;
  569.     *-unixware212)
  570.     OS='UnixWare 2.1.2'
  571.     CFLAGS="$CFLAGS -DUW=212"
  572.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  573.     DBM_LIB=""
  574.     ;;
  575.     *-unixware7)
  576.     OS='UnixWare 7'
  577.     CFLAGS="$CFLAGS -DUW=700"
  578.     LIBS="$LIBS -lsocket -lnsl -lcrypt -lgen"
  579.     DBM_LIB=""
  580.     ;;
  581.     maxion-*-sysv4*)
  582.         OS='SVR4'
  583.     CFLAGS="$CFLAGS -DSVR4"
  584.     DEF_WANTHSREGEX=yes
  585.     LIBS="$LIBS -lsocket -lnsl -lc -lgen"
  586.     ;;
  587.     *-*-powermax*)
  588.     OS='SVR4'
  589.     CFLAGS="$CFLAGS -DSVR4"
  590.     DEF_WANTHSREGEX=yes
  591.     LIBS="$LIBS -lsocket -lnsl -lgen"
  592.     LD_SHLIB='cc'
  593.     LDFLAGS_SHLIB="-Zlink=so"
  594.     LDFLAGS_SHLIB_EXPORT="-Zlink=dynamic -Wl,-Bexport"
  595.     CFLAGS_SHLIB='-Zpic'
  596.     ;;
  597.     TPF)
  598.        OS='TPF'
  599.        OSDIR='os/tpf'
  600.        CC='c89'
  601.        CFLAGS="$CFLAGS -DTPF -DCHARSET_EBCDIC -D_POSIX_SOURCE"
  602.        DEF_WANTHSREGEX=yes
  603.        LIBS="$LIBS"
  604.        SUBTARGET="target_compile_only"
  605.        ;;
  606.     BS2000*-siemens-sysv4*)
  607.     OS='BS2000'
  608.     OSDIR='os/bs2000'
  609.     CC='c89 -XLLML -XLLMK'
  610.     CFLAGS="$CFLAGS -DCHARSET_EBCDIC -DSVR4 -D_XPG_IV"
  611.     DEF_WANTHSREGEX=yes
  612.     LIBS="$LIBS -lsocket -lnsl -lc"
  613.     DBM_LIB=""
  614.     ;;
  615.     *-siemens-sysv4*)
  616.     OS='SVR4'
  617.     CFLAGS="$CFLAGS -DSVR4 -D_XPG_IV -DHAS_DLFCN -DUSE_MMAP_FILES -DUSE_SYSVSEM_SERIALIZED_ACCEPT -DNEED_UNION_SEMUN"
  618.     DEF_WANTHSREGEX=yes
  619.     LIBS="$LIBS -lsocket -lnsl -lc"
  620.     DBM_LIB=""
  621.     ;;
  622.     pyramid-pyramid-svr4)
  623.     OS='SVR4'
  624.     CFLAGS="$CFLAGS -DSVR4 -DNO_LONG_DOUBLE"
  625.     DEF_WANTHSREGEX=yes
  626.     LIBS="$LIBS -lsocket -lnsl -lc"
  627.     ;;
  628.     DS/90\ 7000-*-sysv4*)
  629.     OS='UXP/DS'
  630.     CFLAGS="$CFLAGS -DUXPDS"
  631.     LIBS="$LIBS -lsocket -lnsl"
  632.     DEF_WANTHSREGEX=yes
  633.     ;;
  634.     *-tandem-sysv4*)
  635.     OS='SVR4'
  636.     CFLAGS="$CFLAGS -DSVR4"
  637.     LIBS="$LIBS -lsocket -lnsl"
  638.     DEF_WANTHSREGEX=yes
  639.     ;;
  640.     *-ncr-sysv4)
  641.     OS='NCR MP/RAS'
  642.     CFLAGS="$CFLAGS -DSVR4 -DMPRAS"
  643.     LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
  644.     DEF_WANTHSREGEX=yes
  645.     ;;
  646.     *-sysv4*)
  647.     OS='SVR4'
  648.     CFLAGS="$CFLAGS -DSVR4"
  649.     LIBS="$LIBS -lsocket -lnsl -lc"
  650.     ;;
  651.     88k-encore-sysv4)
  652.     OS='Encore UMAX V'
  653.     CFLAGS="$CFLAGS -DSVR4 -DENCORE"
  654.     DEF_WANTHSREGEX=yes
  655.     LIBS="$LIBS -lPW"
  656.     ;;
  657.     *-uts*)
  658.     OS='Amdahl UTS'
  659.     CFLAGS="$CFLAGS -Xa -eft -DUTS21 -DUSEBCOPY"
  660.     LIBS="$LIBS -lsocket -lbsd -la"
  661.     DEF_WANTHSREGEX=yes
  662.     ;;
  663.     *-ultrix)
  664.     OS='ULTRIX'
  665.     CFLAGS="-DULTRIX"
  666.     DEF_WANTHSREGEX=yes
  667.     SHELL="/bin/sh5"
  668.     ;;
  669.     *powerpc-tenon-machten*)
  670.     OS='MachTen PPC'
  671.     LDFLAGS="$LDFLAGS -Xlstack=0x14000 -Xldelcsect"
  672.     ;;
  673.     *-machten*)
  674.     OS='MachTen 68K'
  675.     LDFLAGS="$LDFLAGS -stack 0x14000"
  676.     DEF_WANTHSREGEX=yes
  677.     ;;
  678.     *convex-v11*)
  679.     OS='CONVEXOS11'
  680.     CFLAGS="$CFLAGS -ext -DCONVEXOS11"
  681.     OPTIM="-O1" # scalar optimization only
  682.     CC='cc'
  683.     DEF_WANTHSREGEX=yes
  684.     ;;
  685.     i860-intel-osf1)
  686.     DEF_WANTHSREGEX=yes
  687.     OS='Paragon OSF/1'
  688.     CFLAGS="$CFLAGS -DPARAGON"
  689.     ;;
  690.     *DYNIX*)
  691.     DEF_WANTHSREGEX=yes
  692.     OS='SEQUENT'
  693.     CFLAGS="$CFLAGS -DSEQUENT"
  694.     ;;
  695.     *NEWS-OS*)
  696.     DEF_WANTHSREGEX=yes
  697.     OS='SONY NEWS-OS'
  698.     CFLAGS="$CFLAGS -DNEWSOS"
  699.     ;;
  700.     *-riscix)
  701.     OS='Acorn RISCix'
  702.     CFLAGS="$CFLAGS -DRISCIX"
  703.     OPTIM="-O"
  704.     MAKE="make"
  705.     DEF_WANTHSREGEX=yes
  706.     ;;
  707.     *-BeOS*)
  708.     OS='BeOS';
  709.     CFLAGS="$CFLAGS -DBEOS"
  710.     DEF_WANTHSREGEX=yes
  711.     ;;
  712.     4850-*.*)
  713.     OS='NCR MP/RAS'
  714.     CFLAGS="$CFLAGS -DSVR4 -DMPRAS"
  715.     DEF_WANTHSREGEX=yes
  716.     LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
  717.     ;;
  718.     drs6000*)
  719.     OS='DRS6000'
  720.     CFLAGS="$CFLAGS -DSVR4"
  721.     DEF_WANTHSREGEX=yes
  722.     LIBS="$LIBS -lsocket -lnsl -lc -L/usr/ucblib -lucb"
  723.     ;;
  724.     m88k-*-CX/SX|CYBER)
  725.     OS='Cyberguard CX/SX'
  726.     CFLAGS="$CFLAGS -D_CX_SX -Xa"
  727.     DEF_WANTHSREGEX=yes
  728.     CC='cc'
  729.     RANLIB='true'
  730.     ;;
  731.     *) # default: Catch systems we don't know about
  732.     OS='Unknown and unsupported OS'
  733.         echo Sorry, but we cannot grok \"$PLAT\"
  734.     echo uname -m
  735.     uname -m
  736.     echo uname -r
  737.     uname -r
  738.     echo uname -s
  739.     uname -s
  740.     echo uname -v
  741.     uname -v
  742.     echo uname -X
  743.     uname -X
  744.     echo Ideally, read the file PORTING, do what it says, and send the
  745.     echo resulting patches to The Apache Group by filling out a report
  746.     echo form at http://www.apache.org/bug_report.html. If you don\'t 
  747.     echo wish to do the port yourself, please submit this output rather 
  748.     echo than the patches. Thank you.
  749.     echo
  750.     echo Pressing on with the build process, but all bets are off.
  751.     echo Do not be surprised if it fails. If it works, and even
  752.     echo if it does not, please contact the above address.
  753.     echo
  754.     ;;
  755. esac
  756.  
  757. ####################################################################
  758. ## set this if we haven't
  759. ##
  760. if [ "x${MAKE}" = "x" ]; then
  761.     MAKE='make'; export MAKE
  762. fi
  763.  
  764. ####################################################################
  765. ## Show user what OS we came up with
  766. ##
  767. echo " + configured for $OS platform"
  768. SUBDIRS="$OSDIR $SUBDIRS"
  769.  
  770. ####################################################################
  771. # Continue building the stub file
  772. # Set variables as soon as possible so that TestCompile can use them
  773. ##
  774. echo >>Makefile.config "OSDIR=\$(SRCDIR)/$OSDIR"
  775. echo >>Makefile.config "INCDIR=\$(SRCDIR)/include"
  776. echo >>Makefile.config "INCLUDES0=-I\$(OSDIR) -I\$(INCDIR)"
  777. echo >>Makefile.config "SHELL=$SHELL"
  778.  
  779. ####################################################################
  780. ## And adjust/override WANTHSREGEX as needed
  781. ##
  782. if [ "$RULE_WANTHSREGEX" = "default" ]; then
  783.     if [ "x$DEF_WANTHSREGEX" = "x" ]; then
  784.         RULE_WANTHSREGEX=yes
  785.     else
  786.         RULE_WANTHSREGEX=$DEF_WANTHSREGEX
  787.     fi
  788. fi
  789.  
  790. ####################################################################
  791. ## Now we determine the C-compiler and optimization level
  792. ## to use. Settings of CC and OPTIM in Configuration have
  793. ## the highest precedence; next comes any settings from
  794. ## the above "OS-specific" section. If still unset,
  795. ## then we look for a known compiler somewhere in PATH
  796. ##
  797.  
  798. # First, look for a CC=<whatever> setting in Configuration (recall, we
  799. # copied these to Makefile.config)
  800. #
  801. # If $TCC is null, then no such line exists in Configuration
  802. #
  803. TCC=`egrep '^CC=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  804. if [ "x$TCC" = "x" ]; then
  805.     if [ "x$CC" = "x" ]; then
  806.     # At this point, CC is not set in Configuration or above, so we
  807.     # try to find one
  808.     for compilers in "gcc" "cc" "acc" "c89"
  809.     do
  810.         lookedfor="$lookedfor $compilers"
  811.         if ./helpers/PrintPath -s $compilers; then
  812.         COMPILER="$compilers"
  813.         break
  814.         fi
  815.     done
  816.     if [ "x$COMPILER" = "x" ]; then
  817.         echo "Error: could not find any of these C compilers"
  818.         echo " anywhere in your PATH: $lookedfor"
  819.         echo "Configure terminated"
  820.         exitcode=1
  821.         exit 1
  822.     fi
  823.     CC=$COMPILER
  824.     fi
  825.     echo " + setting C compiler to $CC"
  826. fi
  827.  
  828. ####################################################################
  829. ## Write the value of $CC to Makefile.config... We only do this
  830. ## is not done already (ie: a 'CC=' line was in Configuration).
  831. ## If there was an entry for it, then set $CC for our own internal
  832. ## use.
  833. ##
  834. if [ "x$TCC" = "x" ]; then
  835.     echo "CC=$CC" >> Makefile.config
  836. else
  837.     CC=$TCC
  838. fi
  839.  
  840. ####################################################################
  841. ## Now check how we can _directly_ run the C pre-processor
  842. ##
  843. TCPP=`egrep '^CPP=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  844. if [ "x$TCPP" != "x" ]; then
  845.     CPP=`CC=$CC CPP=$TCPP ./helpers/findcpp.sh`
  846. else
  847.     CPP=`CC=$CC ./helpers/findcpp.sh`
  848. fi
  849. if [ "x$TCPP" = "x" ]; then
  850.     echo "CPP=$CPP" >> Makefile.config
  851. fi 
  852. echo " + setting C pre-processor to $CPP"
  853.  
  854. ####################################################################
  855. ## Now check for existance of non-standard system header files
  856. ## and start generation of the ap_config_auto.h header
  857. ##
  858. AP_CONFIG_AUTO_H="include/ap_config_auto.h"
  859. echo "/*" >$AP_CONFIG_AUTO_H
  860. echo " *  ap_config_auto.h -- Automatically determined configuration stuff" >>$AP_CONFIG_AUTO_H
  861. echo " *  THIS FILE WAS AUTOMATICALLY GENERATED - DO NOT EDIT!" >>$AP_CONFIG_AUTO_H
  862. echo " */" >>$AP_CONFIG_AUTO_H
  863. echo "" >>$AP_CONFIG_AUTO_H
  864. echo "#ifndef AP_CONFIG_AUTO_H" >>$AP_CONFIG_AUTO_H
  865. echo "#define AP_CONFIG_AUTO_H" >>$AP_CONFIG_AUTO_H
  866.  
  867. echo " + checking for system header files"
  868. CHECK_FOR_HEADERS="dlfcn.h dl.h bstring.h crypt.h unistd.h sys/resource.h sys/select.h sys/processor.h"
  869. for header in $CHECK_FOR_HEADERS; do
  870.     echo "" >>$AP_CONFIG_AUTO_H
  871.     echo "/* check: #include <$header> */" >>$AP_CONFIG_AUTO_H
  872.     name="`echo $header | sed -e 's:/:_:g' -e 's:\.:_:g' | tr '[a-z]' '[A-Z]'`"
  873.     CPP=$CPP ./helpers/checkheader.sh $header
  874.     if [ $? -eq 0 ]; then
  875.     echo "#ifndef HAVE_${name}" >>$AP_CONFIG_AUTO_H
  876.     echo "#define HAVE_${name} 1" >>$AP_CONFIG_AUTO_H
  877.     echo "#endif" >>$AP_CONFIG_AUTO_H
  878.     else
  879.     echo "#ifdef HAVE_${name}" >>$AP_CONFIG_AUTO_H
  880.     echo "#undef HAVE_${name}" >>$AP_CONFIG_AUTO_H
  881.     echo "#endif" >>$AP_CONFIG_AUTO_H
  882.     fi
  883. done
  884.  
  885. ####################################################################
  886. # Special AIX 4.x support: need to check for sys/processor.h
  887. # to decide whether the Processor Binding can be used or not
  888. case "$PLAT" in
  889.     *-ibm-aix*)
  890.     CPP=$CPP ./helpers/checkheader.sh sys/processor.h
  891.     if [ $? -eq 0 ]; then
  892.         CFLAGS="$CFLAGS -DAIX_BIND_PROCESSOR"
  893.     fi
  894.     ;;
  895. esac
  896.  
  897. ####################################################################
  898. ## Look for OPTIM and save for later
  899. ##
  900. TOPTIM=`egrep '^OPTIM=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  901. TRANLIB=`egrep '^RANLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  902. TTARGET=`egrep '^TARGET=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  903.  
  904. ####################################################################
  905. ## Check for user provided flags for shared object support
  906. ##
  907. TLD_SHLIB=`egrep '^LD_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  908. TLDFLAGS_SHLIB=`egrep '^LDFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  909. TLDFLAGS_SHLIB_EXPORT=`egrep '^LDFLAGS_SHLIB_EXPORT=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  910. TCFLAGS_SHLIB=`egrep '^CFLAGS_SHLIB=' Makefile.config | tail -1 | awk -F= '{print $2}'`
  911.  
  912. ####################################################################
  913. ## Handle TARGET name
  914. ##
  915. if [ "x$TTARGET" = "x" ]; then
  916.     TARGET=httpd
  917.     echo "TARGET=$TARGET" >> Makefile.config
  918. else
  919.     TARGET=$TTARGET
  920. fi
  921. if [ "x$TARGET" != "xhttpd" ]; then
  922.     echo " + using custom target name: $TARGET"
  923.     CFLAGS="$CFLAGS -DTARGET=\\\"$TARGET\\\""
  924. fi
  925.  
  926. ####################################################################
  927. ## We adjust now CFLAGS_SHLIB, LDFLAGS_SHLIB and LDFLAGS_SHLIB_EXPORT as
  928. ## required.  For more platforms just add the required lines below.
  929. ##
  930. if [ "x$using_shlib" = "x1" ] ; then
  931.     LD_SHLIB="ld"
  932.     DEF_SHARED_CORE=no
  933.     DEF_SHARED_CHAIN=no
  934.     SHLIB_SUFFIX_NAME=so
  935.     SHLIB_SUFFIX_DEPTH=all
  936.     SHLIB_EXPORT_FILES=no
  937.     case "$PLAT" in
  938.     *-linux1)
  939.         CFLAGS_SHLIB="-fpic"
  940.         LDFLAGS_SHLIB="-Bshareable"
  941.         LDFLAGS_SHLIB_EXPORT="-rdynamic"
  942.         ;;
  943.     *-linux2)
  944.         CFLAGS_SHLIB="-fpic"
  945.         LDFLAGS_SHLIB="-Bshareable"
  946.         LDFLAGS_SHLIB_EXPORT="-rdynamic"
  947.         SHLIB_SUFFIX_DEPTH=0
  948.         ;;
  949.     *-freebsd2*)
  950.         CFLAGS_SHLIB="-fpic"
  951.         LDFLAGS_SHLIB="-Bshareable"
  952.         LDFLAGS_SHLIB_EXPORT=""
  953.         SHLIB_SUFFIX_DEPTH=2
  954.         ;;
  955.     *-freebsd3*)
  956.         CFLAGS_SHLIB="-fpic"
  957.         LDFLAGS_SHLIB="-Bshareable"
  958.         OBJFORMAT=`test -x /usr/bin/objformat && /usr/bin/objformat || echo aout` 
  959.         if [ "x$OBJFORMAT" = "xelf" ]; then
  960.         LDFLAGS_SHLIB_EXPORT="-Wl,-E"
  961.         SHLIB_SUFFIX_DEPTH=0
  962.         else
  963.         LDFLAGS_SHLIB_EXPORT=""
  964.         SHLIB_SUFFIX_DEPTH=2
  965.         fi  
  966.         ;;
  967.     *-openbsd*)
  968.         CFLAGS_SHLIB="-fPIC"
  969.         LDFLAGS_SHLIB="-Bforcearchive -Bshareable"
  970.         LDFLAGS_SHLIB_EXPORT=""
  971.         SHLIB_SUFFIX_DEPTH=2
  972.         ;;
  973.     alpha-*-netbsd*|mips-*-netbsd*|powerpc-*-netbsd*)
  974.         CFLAGS_SHLIB="-fpic -DPIC"
  975.         LDFLAGS_SHLIB="-shared"
  976.         LDFLAGS_SHLIB_EXPORT=""
  977.         SHLIB_SUFFIX_DEPTH=2
  978.         ;;
  979.     *-netbsd*)
  980.         CFLAGS_SHLIB="-fpic -DPIC"
  981.         LDFLAGS_SHLIB="-Bshareable"
  982.         LDFLAGS_SHLIB_EXPORT=""
  983.         SHLIB_SUFFIX_DEPTH=2
  984.         ;;
  985.     *-bsdi)
  986.         CFLAGS_SHLIB="-fPIC"
  987.         LDFLAGS_SHLIB="-shared"
  988.         LDFLAGS_SHLIB_EXPORT="-rdynamic"
  989.         ;;
  990.     *-apple-rhapsody*)
  991.         LD_SHLIB="cc"
  992.         CFLAGS_SHLIB=""
  993.         LDFLAGS_SHLIB='$(EXTRA_LDFLAGS) -bundle -undefined suppress'
  994.         LDFLAGS_SHLIB_EXPORT=""
  995.         SHLIB_SUFFIX_DEPTH=0
  996.         ;;
  997.     *-solaris2*)
  998.         case $CC in
  999.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1000.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1001.         esac
  1002.         LDFLAGS_SHLIB="-G"
  1003.         LDFLAGS_SHLIB_EXPORT=""
  1004.         SHLIB_SUFFIX_DEPTH=1
  1005.         ;;
  1006.     *-sunos4*)
  1007.         case $CC in
  1008.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1009.         */acc|acc ) CFLAGS_SHLIB="-pic" ;;
  1010.         esac
  1011.         LDFLAGS_SHLIB="-assert pure-text"
  1012.         LDFLAGS_SHLIB_EXPORT=""
  1013.         ;;
  1014.     *-sgi-irix32)
  1015.         case $CC in
  1016.         */gcc|gcc )
  1017.             CFLAGS_SHLIB="-fpic"
  1018.             N32FLAG=""
  1019.             ;;
  1020.         */cc|cc )
  1021.             CFLAGS_SHLIB="-KPIC"
  1022.             N32FLAG="-n32"
  1023.             ;;
  1024.         esac
  1025.         if [ "$RULE_IRIXN32" = "yes" ]; then
  1026.         LDFLAGS_SHLIB="$N32FLAG -shared"
  1027.         else
  1028.         LDFLAGS_SHLIB="-shared"
  1029.         fi
  1030.         LDFLAGS_SHLIB_EXPORT=""
  1031.         ;;
  1032.     *-sgi-irix64)
  1033.         case $CC in
  1034.         */gcc|gcc )
  1035.             CFLAGS_SHLIB="-fpic"
  1036.             N32FLAG=""
  1037.             ;;
  1038.         */cc|cc )
  1039.             CFLAGS_SHLIB="-KPIC"
  1040.             N32FLAG="-n32"
  1041.             ;;
  1042.         esac
  1043.         if [ "$RULE_IRIXN32" = "yes" ]; then
  1044.         LDFLAGS_SHLIB="$N32FLAG -shared"
  1045.         else
  1046.         LDFLAGS_SHLIB="-shared"
  1047.         fi
  1048.         LDFLAGS_SHLIB_EXPORT=""
  1049.         ;;
  1050.     *-sgi-irix)
  1051.         case $CC in
  1052.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1053.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1054.         esac
  1055.         LDFLAGS_SHLIB="-shared"
  1056.         LDFLAGS_SHLIB_EXPORT=""
  1057.         ;;
  1058.     *-dec-osf*)
  1059.         case $CC in
  1060.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1061.         */cc|cc   ) CFLAGS_SHLIB="" ;;
  1062.         esac
  1063.         LDFLAGS_SHLIB="-shared -expect_unresolved '*' -s"
  1064.         LDFLAGS_SHLIB_EXPORT=""
  1065.         ;;
  1066.     *-unixware*)
  1067.         case $CC in
  1068.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1069.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1070.         esac
  1071.         LDFLAGS_SHLIB="-Bdynamic -G"
  1072.         LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
  1073.         ;;
  1074.      *-sco5*)
  1075.          case $CC in
  1076.          */gcc*|gcc* ) CFLAGS_SHLIB="-fpic" ;;
  1077.          */cc*|cc*   ) CFLAGS_SHLIB="-KPIC" ;;
  1078.          esac
  1079.          LDFLAGS_SHLIB="-G"
  1080.          LDFLAGS_SHLIB_EXPORT="-Wl,-Bexport"
  1081.          SHLIB_SUFFIX_DEPTH=1
  1082.          ;;
  1083.     RM*-siemens-sysv4*)
  1084.         # MIPS hosts can take advantage of the LDFLAGS_SHLIB_EXPORT switch
  1085.         case $CC in
  1086.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1087.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1088.         esac
  1089.         LDFLAGS_SHLIB="-G"
  1090.         LDFLAGS_SHLIB_EXPORT="-Wl,-Blargedynsym"
  1091.         ;;
  1092.     *-siemens-sysv4*)
  1093.         # Older SINIX machines must be linked as "shared core"-Apache
  1094.         case $CC in
  1095.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1096.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1097.         esac
  1098.         LDFLAGS_SHLIB="-G"
  1099.         LDFLAGS_SHLIB_EXPORT=""
  1100.         SHLIB_SUFFIX_DEPTH=0
  1101.         DEF_SHARED_CORE=yes
  1102.         ;;
  1103.     *-sysv4*)
  1104.         case $CC in
  1105.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1106.         */cc|cc   ) CFLAGS_SHLIB="-KPIC" ;;
  1107.         esac
  1108.         LDFLAGS_SHLIB="-G"
  1109.         LDFLAGS_SHLIB_EXPORT=""
  1110.         DEF_SHARED_CORE=yes
  1111.         ;;
  1112.     *-hp-hpux9.*)
  1113.         case $CC in
  1114.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1115.         */cc|cc   ) CFLAGS_SHLIB="+z" ;;
  1116.         esac
  1117.         LDFLAGS_SHLIB="-b"
  1118.         LDFLAGS_SHLIB_EXPORT="-Wl,-E -Wl,-B,deferred"
  1119.         SHLIB_SUFFIX_NAME=sl
  1120.         ;;
  1121.     *-hp-hpux10.*|*-hp-hpux11.*)
  1122.         case $CC in
  1123.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1124.         */cc|cc   ) CFLAGS_SHLIB="+z" ;;
  1125.         esac
  1126.         LDFLAGS_SHLIB="-b"
  1127.         LDFLAGS_SHLIB_EXPORT="-Wl,-E -Wl,-B,deferred -Wl,+s"
  1128.         SHLIB_SUFFIX_NAME=sl
  1129.         ;;
  1130.     *-ibm-aix*)
  1131.         case $CC in
  1132.         */gcc|gcc ) CFLAGS_SHLIB="-fpic" ;;
  1133.         */cc|cc   ) CFLAGS_SHLIB="" ;;
  1134.         esac
  1135.         case $PLAT in
  1136.         *-ibm-aix4*)
  1137.             LDFLAGS_SHLIB="-H512 -T512 -bhalt:4 -bM:SRE -bnoentry"
  1138.             ;;
  1139.         *-ibm-aix*)
  1140.             LDFLAGS_SHLIB="-H512 -T512 -bhalt:4 -bM:SRE -e _nostart"
  1141.             ;;
  1142.         esac
  1143.         LDFLAGS_SHLIB="$LDFLAGS_SHLIB -bI:\$(SRCDIR)/support/httpd.exp "
  1144.         LDFLAGS_SHLIB="$LDFLAGS_SHLIB -bE:\`echo \$@|sed -e 's:\.so\$\$:.exp:'\`"
  1145.         LDFLAGS_SHLIB="$LDFLAGS_SHLIB -lc"
  1146.         LDFLAGS_SHLIB_EXPORT="-Wl,-bE:\$(SRCDIR)/support/httpd.exp"
  1147.         SHLIB_EXPORT_FILES=yes
  1148.         ;;
  1149.     *-*-powermax*)
  1150.         LD_SHLIB='cc'
  1151.         LDFLAGS_SHLIB="-Zlink=so"
  1152.         LDFLAGS_SHLIB_EXPORT="-Zlink=dynamic -Wl,-Bexport"
  1153.         CFLAGS_SHLIB='-Zpic'
  1154.         ;;
  1155.     *)
  1156.         ##  ok, no known explict support for shared objects
  1157.         ##  on this platform, but we give not up immediately.
  1158.         ##  We take a second chance by guessing the compiler
  1159.         ##  and linker flags from the Perl installation
  1160.         ##  if it exists.
  1161.         PERL=
  1162.         for dir in `echo $PATH | sed -e 's/:/ /g'`
  1163.         do
  1164.         if [ -f "$dir/perl5" ]; then
  1165.             PERL="$dir/perl5"
  1166.             break
  1167.         fi
  1168.         if [ -f "$dir/perl" ]; then
  1169.             PERL="$dir/perl"
  1170.             break
  1171.         fi
  1172.         done
  1173.         if [ "x$PERL" != "x" ]; then
  1174.         #   cool, Perl is installed on this platform...
  1175.         if [ "x`$PERL -V:dlsrc 2>/dev/null | grep dlopen`" != "x" ]; then
  1176.             #   ...and actually uses the dlopen-style interface,
  1177.             #   so we can guess the flags from its knowledge
  1178.             CFLAGS_SHLIB="`$PERL -V:cccdlflags | cut -d\' -f2`"
  1179.             LDFLAGS_SHLIB="`$PERL -V:lddlflags | cut -d\' -f2`"
  1180.             LDFLAGS_SHLIB_EXPORT="`$PERL -V:ccdlflags | cut -d\' -f2`"
  1181.             #   but additionally we have to inform the
  1182.             #   user that we are just guessing the flags
  1183.             echo ""
  1184.             echo "** WARNING: We have no explicit knowledge about shared object"
  1185.             echo "** support for your particular platform. But perhaps you have"
  1186.             echo "** luck: We were able to guess the compiler and linker flags"
  1187.             echo "** for creating shared objects from your Perl installation."
  1188.             echo "** If they actually work, please send the following information"
  1189.             echo "** for inclusion into later releases to new-httpd@apache.org or make"
  1190.             echo "** a suggestion report at http://www.apache.org/bug_report.html:"
  1191.             echo "**     PLATFORM=$PLAT"
  1192.             echo "**     CFLAGS_SHLIB=$CFLAGS_SHLIB"
  1193.             echo "**     LDFLAGS_SHLIB=$LDFLAGS_SHLIB"
  1194.             echo "**     LDFLAGS_SHLIB_EXPORT=$LDFLAGS_SHLIB_EXPORT"
  1195.             echo ""
  1196.         fi
  1197.         fi
  1198.         ;;
  1199.     esac
  1200. fi
  1201.  
  1202. ####################################################################
  1203. ## Check if we really have some information to compile
  1204. ## the shared objects if SharedModule was used.
  1205. ##
  1206. if [ "x$using_shlib" = "x1" ] ; then
  1207.     if [ "x$TCFLAGS_SHLIB"  = "x" -a "x$CFLAGS_SHLIB"  = "x"  -a \
  1208.      "x$TLDFLAGS_SHLIB" = "x" -a "x$LDFLAGS_SHLIB" = "x" ]; then
  1209.     echo ""
  1210.     echo "** FAILURE: Sorry, no shared object support available."
  1211.     echo "** Either compile all modules statically (use AddModule instead"
  1212.     echo "** of SharedModule in the Configuration file) or at least provide"
  1213.     echo "** us with the appropriate compiler and linker flags via the"
  1214.     echo "** CFLAGS_SHLIB, LDFLAGS_SHLIB and LDFLAGS_SHLIB_EXPORT entries"
  1215.     echo "** in the Configuration file."
  1216.     echo ""
  1217.     exit 1
  1218.     fi
  1219. fi
  1220.  
  1221. ####################################################################
  1222. ## Now we do some OS specific adjustments... for some OSs, we need
  1223. ## to adjust CFLAGS and/or OPTIM depending on which compiler we
  1224. ## are going to use. This is easy, since this can be gleamed from
  1225. ## Makefile.config
  1226. ##
  1227. case "$OS" in
  1228.     'ULTRIX')
  1229.     case "$CC" in
  1230.         */cc|cc ) CFLAGS="$CFLAGS -std" ;;
  1231.     esac
  1232.     ;;
  1233.     'SCO 5')
  1234.     case "$CC" in
  1235.         */cc|cc ) CFLAGS="$CFLAGS -K noinline" ;;
  1236.     esac
  1237.     ;;
  1238.     'HI-UX')
  1239.     case "$CC" in
  1240.         */cc|cc )
  1241.         CFLAGS="$CFLAGS -Aa -D_HIUX_SOURCE"
  1242.         OPTIM=" "
  1243.         TOPTIM=""
  1244.         ;;
  1245.     esac
  1246.     ;;
  1247.     'HP-UX'|'HP-UX 10'|'HP-UX 11')
  1248.     case "$CC" in
  1249.         */cc|cc )
  1250.         CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
  1251.         OPTIM=" "
  1252.         TOPTIM=""
  1253.         ;;
  1254.     esac
  1255.     ;;
  1256.     *IRIX-64*)
  1257.     if [ "$RULE_IRIXN32" = "yes" ]; then
  1258.         case "$CC" in
  1259.         */cc|cc )
  1260.             CFLAGS="$CFLAGS -n32"
  1261.             LDFLAGS="$LDFLAGS -n32"
  1262.         ;;
  1263.         esac
  1264.     fi
  1265.     ;;
  1266.     *IRIX-32*)
  1267.     if [ "$RULE_IRIXN32" = "yes" ]; then
  1268.         case "$CC" in
  1269.         */cc|cc )
  1270.             CFLAGS="$CFLAGS -n32"
  1271.             LDFLAGS="$LDFLAGS -n32"
  1272.         ;;
  1273.         esac
  1274.     fi
  1275.     ;;
  1276.     IBM?AIX?4.[123])
  1277.     case $CC in
  1278.         */cc|cc ) 
  1279.         CFLAGS="$CFLAGS -qnogenpcomp -qnousepcomp"
  1280.         ;;
  1281.     esac
  1282.     ;;
  1283. esac
  1284.  
  1285. ####################################################################
  1286. ## OK, now we can write OPTIM
  1287. ##
  1288. if [ "x$TOPTIM" = "x" ]; then
  1289.     echo "OPTIM=$OPTIM" >> Makefile.config
  1290. fi
  1291.  
  1292. ####################################################################
  1293. ## OK, now handle RANLIB
  1294. ##
  1295. if [ "x$RANLIB" = "x" ]; then
  1296.     if [ "x$TRANLIB" != "x" ]; then
  1297.     RANLIB=$TRANLIB
  1298.     else
  1299.     if ./helpers/PrintPath -s ranlib; then
  1300.         RANLIB="ranlib"
  1301.     else
  1302.         RANLIB="true"
  1303.     fi
  1304.     fi
  1305. fi
  1306.  
  1307. ####################################################################
  1308. ## Now we do some general checks and some intelligent Configuration
  1309. ## control.
  1310.  
  1311. # Use TestCompile to look for various LIBS
  1312. case "$PLAT" in
  1313.     *-linux*)
  1314.     # newer systems using glibc 2.x need -lcrypt
  1315.     if ./helpers/TestCompile lib crypt; then
  1316.         LIBS="$LIBS -lcrypt"
  1317.     fi
  1318.     ;;
  1319.  
  1320.     *-dg-dgux*)
  1321.     # R4.11MU02 requires -lsocket -lnsl ... no idea if it's earlier or
  1322.     # later than what we already knew about.  PR#732
  1323.     if ./helpers/TestCompile lib socket; then
  1324.         LIBS="$LIBS -lsocket"
  1325.     fi
  1326.     if ./helpers/TestCompile lib nsl; then
  1327.         LIBS="$LIBS -lnsl"
  1328.     fi
  1329.     ;;
  1330. esac
  1331.  
  1332. # SOCKS4 support:
  1333. # We assume that if they are using SOCKS4, then they've
  1334. # adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
  1335. # otherwise we assume "-L/usr/local/lib -lsocks"
  1336. if [ "$RULE_SOCKS4" = "yes" ]; then
  1337.     echo " + enabling SOCKS4 support"
  1338.     CFLAGS="$CFLAGS -DSOCKS -DSOCKS4"
  1339.     CFLAGS="$CFLAGS -Dconnect=Rconnect -Dselect=Rselect"
  1340.     CFLAGS="$CFLAGS -Dgethostbyname=Rgethostbyname"
  1341.     if [ "x`egrep '^EXTRA_L' Makefile.config | grep lsocks`" = "x" ]; then
  1342.     LIBS="$LIBS -L/usr/local/lib -lsocks"
  1343.     fi
  1344.     case $PLAT in
  1345.     *-solaris2* )
  1346.         LIBS="$LIBS -lresolv"
  1347.         ;;
  1348.     esac
  1349. fi
  1350.  
  1351. # SOCKS5 support:
  1352. # We assume that if they are using SOCKS5, then they've
  1353. # adjusted EXTRA_LIBS and/or EXTRA_LDFLAGS as required,
  1354. # otherwise we assume "-L/usr/local/lib -lsocks5"
  1355. if [ "$RULE_SOCKS5" = "yes" ]; then
  1356.     echo " + enabling SOCKS5 support"
  1357.     CFLAGS="$CFLAGS -DSOCKS -DSOCKS5"
  1358.     CFLAGS="$CFLAGS -Dconnect=SOCKSconnect -Dselect=SOCKSselect"
  1359.     CFLAGS="$CFLAGS -Dgethostbyname=SOCKSgethostbyname -Dclose=SOCKSclose"
  1360.     if [ "x`egrep '^EXTRA_L' Makefile.config | grep lsocks5`" = "x" ]; then
  1361.     LIBS="$LIBS -L/usr/local/lib -lsocks5"
  1362.     fi
  1363.     case $PLAT in
  1364.     *-solaris2* )
  1365.         LIBS="$LIBS -lresolv"
  1366.         ;;
  1367.     esac
  1368. fi
  1369.  
  1370. ####################################################################
  1371. ## Find out what modules we want and try and configure things for them
  1372. ## Module lines can look like this:
  1373. ##
  1374. ##  Module  name_module    some/path/mod_name[.[oa]]
  1375. ##  AddModule              some/path/mod_name[.[oa]]
  1376. ##
  1377. ## In both cases, the some/path can either be an arbitrary path (including
  1378. ## an absolute path), or a path like "modules/DIR", in which case we _might_
  1379. ## auto-generate a Makefile in modules/DIR (see later).
  1380. ##
  1381. ## The first case is the original style, where we give the module's
  1382. ## name as well as it's binary file location - either a .o or .a.
  1383. ##
  1384. ## The second format is new, and means we do not repeat the module
  1385. ## name, which is already part of the module source or definition.
  1386. ## The way we find the module name (and other optional information about
  1387. ## the module) is like this:
  1388. ##
  1389. ##  1 If extension is not given or is .c, assume .o was given and goto 3
  1390. ##  2 If extension is .module, go to D1
  1391. ##  3 If extension is .o, look for a corresponding .c file and if
  1392. ##      found, go to C1
  1393. ##  4 If no .c file was found, look for a .module file (Apache module
  1394. ##      definition file). If found, go to D1
  1395. ##  5 Assume module name is the "name" part of "mod_name", as in
  1396. ##      name_module.
  1397. ##
  1398. ## If a C file is found:
  1399. ##
  1400. ## C1 Look for module name given by an MODULE: line (e.g. MODULE: name_module)
  1401. ##      If found assume module contains a definition, and go to D1
  1402. ## C2 If not found, look for a module name given on the declaration of the
  1403. ##      module structure (e.g. module name_module).
  1404. ## C3 If neither given, go to 4 above.
  1405. ##
  1406. ## If a definition file is found, or a .c file includes a module definition:
  1407. ##
  1408. ## D1 Get the module name from the MODULE: name= line
  1409. ## D2 Get other module options (libraries etc). To be done later.
  1410. ##
  1411. ##
  1412. ## For now, we will convert the AddModule lines into Module format
  1413. ## lines, so the rest of Configure can do its stuff without too much
  1414. ## additional hackery. It would be nice to reduce the number of times
  1415. ## we have to awk the $tmpfile, though.
  1416.  
  1417. ## MODFILES contains a list of module filenames (could be .c, .o, .so, .a
  1418. ##    or .module files) from AddModule lines only
  1419. ## MODDIRS contains a list of subdirectories under 'modules' which
  1420. ##    contain modules we want to build from both AddModule and Module
  1421. ##    lines
  1422.  
  1423. echo " + adding selected modules"
  1424.  
  1425. MODFILES=`awk <$tmpfile '($1 == "AddModule" || $1 == "SharedModule") { printf "%s ", $2 }'`
  1426. MODDIRS=`awk < $tmpfile '
  1427.     ($1 == "Module" && $3 ~ /^modules\//) {
  1428.         split ($3, pp, "/")
  1429.         if (! SEEN[pp[2]]) {
  1430.         printf "%s ", pp[2]
  1431.         SEEN[pp[2]] = 1
  1432.         }
  1433.         }
  1434.     (($1 == "AddModule" || $1 == "SharedModule") && $2 ~ /^modules\//) { 
  1435.         split ($2, pp, "/")
  1436.         if (! SEEN[pp[2]]) {
  1437.         printf "%s ", pp[2]
  1438.         SEEN[pp[2]] = 1
  1439.         } 
  1440.         }'`
  1441. MODDIRS_NO_SO=`awk < $tmpfile '
  1442.     ($1 == "Module" && $3 ~ /^modules\//) {
  1443.         split ($3, pp, "/")
  1444.         if (! SEEN[pp[2]]) {
  1445.         printf "%s ", pp[2]
  1446.         SEEN[pp[2]] = 1
  1447.         }
  1448.         }
  1449.     (($1 == "AddModule") && $2 ~ /^modules\//) { 
  1450.         split ($2, pp, "/")
  1451.         if (! SEEN[pp[2]]) {
  1452.         printf "%s ", pp[2]
  1453.         SEEN[pp[2]] = 1
  1454.         } 
  1455.         }'`
  1456.  
  1457. # Now autoconfigure each of the modules specified by AddModule.
  1458. # Use tmpfile2 for the module definition file, and tmpfile3 for the
  1459. # shell commands to be executed for this module.
  1460.  
  1461. for modfile in $MODFILES ; do
  1462.     rm -f $tmpfile2 $tmpfile3
  1463.     modname=''
  1464.  
  1465.     ext=`echo $modfile | sed 's/^.*\.//'`
  1466.     modbase=`echo $modfile | sed 's/\.[^.]*$//'`
  1467.     if [ "x$ext" = "x$modfile" ]; then ext=o; modbase=$modfile; modfile=$modbase.o; fi
  1468.     if [ "x$ext" = "x" ] ; then ext=o; modbase=$modfile; fi
  1469.     if [ "x$ext" = "xc" ] ; then ext=o; fi
  1470.  
  1471.     # modbase is the path+filename without extension, ext is the
  1472.     # extension given, or if none, o
  1473.     if [ -r $modbase.module ] ; then
  1474.         $CAT $modbase.module > $tmpfile2
  1475.     else
  1476.         if [ -f $modbase.c ] ; then
  1477.         # Guess module structure name in case there is no
  1478.         # module definition in this file
  1479.         modname=`egrep '^module .*;' $modbase.c | head -1 |\
  1480.             sed 's/^module.*[     ][     ]*//' | \
  1481.             sed 's/[     ]*;[     ]*$//'`
  1482.         # Get any module definition part
  1483.         if grep "MODULE-DEFINITION-" $modbase.c > /dev/null; then
  1484.         $CAT $modbase.c | \
  1485.         sed '1,/MODULE-DEFINITION-START/d;/MODULE-DEFINITION-END/,$d' \
  1486.             > $tmpfile2
  1487.         fi
  1488.         fi
  1489.     fi        
  1490.     if [ -r $tmpfile2 ] ; then
  1491.         # Read a module definition from .module or .c
  1492.         modname=`grep "Name:" $tmpfile2 | sed 's/^.*Name:[     ]*//'`
  1493.         if grep "ConfigStart" $tmpfile2 > /dev/null \
  1494.          && grep "ConfigEnd" $tmpfile2 > /dev/null; then
  1495.             sed '1,/ConfigStart/d;/ConfigEnd/,$d' $tmpfile2 > \
  1496.              $tmpfile3
  1497.             echo "    o $modname uses ConfigStart/End"
  1498.             if [ "$RULE_PARANOID" = "yes" ]; then
  1499.             sed 's/^/>> /' $tmpfile3
  1500.             fi
  1501.             . ./$tmpfile3
  1502.         fi
  1503.         rm -f $tmpfile2 $tmpfile3
  1504.         if [ "$ext" != "so" ]; then
  1505.             ext=o
  1506.         fi
  1507.     fi
  1508.     if [ "x$modname" = "x" ] ; then
  1509.         modname=`echo $modbase | sed 's/^.*\///' | \
  1510.             sed 's/^mod_//' | sed 's/^lib//' | sed 's/$/_module/'`
  1511.     fi
  1512.     if [ "$ext" != "so" ]; then
  1513.         echo "Module $modname $modbase.$ext" >>$tmpfile
  1514.     fi
  1515.     #   optionally generate export file for some linkers 
  1516.     if [ "$ext" = "so" -a "$SHLIB_EXPORT_FILES" = "yes" ]; then
  1517.         echo "$modname" >$modbase.exp
  1518.     fi
  1519. done
  1520. # $tmpfile now contains Module lines for all the modules we want
  1521.  
  1522. ####################################################################
  1523. ## Now HS's POSIX regex implementation if needed/wanted. We do it
  1524. ## now since AddModule may have changed it
  1525. ##
  1526. if [ "$RULE_WANTHSREGEX" = "yes" ]; then
  1527.     REGLIB="regex/libregex.a"
  1528.     SUBDIRS="regex $SUBDIRS"
  1529.     CFLAGS="$CFLAGS -DUSE_HSREGEX"
  1530. fi
  1531.  
  1532. ####################################################################
  1533. ## Now the SHARED_CHAIN stuff
  1534. ##
  1535. LIBS_SHLIB=''
  1536. if [ "x$using_shlib" = "x1" ] ; then
  1537.     if [ "$RULE_SHARED_CHAIN" = "default" ] ; then
  1538.     RULE_SHARED_CHAIN=$DEF_SHARED_CHAIN
  1539.     fi
  1540.     if [ "$RULE_SHARED_CHAIN" = "yes" ]; then
  1541.     echo " + enabling DSO files to be linked against others"
  1542.     #   determine libraries which can be safely linked
  1543.     #   to our DSO files, i.e. PIC libraries and shared libraries
  1544.     extra_ldflags="`grep EXTRA_LDFLAGS= Makefile.config`"
  1545.     extra_libs="`grep EXTRA_LIBS= Makefile.config`"
  1546.     eval "`./helpers/slo.sh $LDFLAGS $LIBS $extra_ldflags $extra_libs`"
  1547.     LIBS_SHLIB="$SLO_DIRS_PIC $SLO_LIBS_PIC $SLO_DIRS_DSO $SLO_LIBS_DSO"
  1548.     fi
  1549. fi
  1550.  
  1551. ####################################################################
  1552. ## Now the SHARED_CORE stuff
  1553. ##
  1554. if [ "x$using_shlib" = "x1" ] ; then
  1555.     if [ "$RULE_SHARED_CORE" = "default" ] ; then
  1556.     RULE_SHARED_CORE=$DEF_SHARED_CORE
  1557.     fi
  1558.     if [ "$RULE_SHARED_CORE" = "yes" ]; then
  1559.     echo " + enabling generation of Apache core as DSO"
  1560.     #    shuffle compiler flags from shlib variant to standard
  1561.     CFLAGS="$CFLAGS $CFLAGS_SHLIB"
  1562.     CFLAGS_SHLIB=""
  1563.     #    indicate that Rule SHARED_CORE is active
  1564.     CFLAGS="$CFLAGS -DSHARED_CORE"
  1565.     #    select the special subtarget for shared core generation
  1566.     SUBTARGET=target_shared
  1567.     #    determine additional suffixes for libhttpd.so
  1568.     V=1 R=3 P=4
  1569.     if [ "$SHLIB_SUFFIX_DEPTH" = "0" ]; then
  1570.         SHLIB_SUFFIX_LIST=""
  1571.     fi
  1572.     if [ "$SHLIB_SUFFIX_DEPTH" = "1" ]; then
  1573.         SHLIB_SUFFIX_LIST="$V"
  1574.     fi
  1575.     if [ "$SHLIB_SUFFIX_DEPTH" = "2" ]; then
  1576.         SHLIB_SUFFIX_LIST="$V.$R"
  1577.     fi
  1578.     if [ "$SHLIB_SUFFIX_DEPTH" = "3" ]; then
  1579.         SHLIB_SUFFIX_LIST="$V.$R.$P"
  1580.     fi
  1581.     if [ "$SHLIB_SUFFIX_DEPTH" = "all" ]; then
  1582.         SHLIB_SUFFIX_LIST="$V $V.$R $V.$R.$P"
  1583.     fi
  1584.     fi
  1585. fi
  1586.  
  1587. ####################################################################
  1588. ## Set the value of the shared libary flags, if they aren't explicitly
  1589. ## set in the configuration file
  1590. ##
  1591. if [ "x$using_shlib" = "x1" ] ; then
  1592.     if [ "x$TCFLAGS_SHLIB" = "x" ]; then
  1593.     echo "CFLAGS_SHLIB=$CFLAGS_SHLIB -DSHARED_MODULE" >> Makefile.config
  1594.     fi
  1595.     if [ "x$TLD_SHLIB" = "x" ]; then
  1596.     echo "LD_SHLIB=$LD_SHLIB" >> Makefile.config
  1597.     fi
  1598.     if [ "x$TLDFLAGS_SHLIB" = "x" ]; then
  1599.     echo "LDFLAGS_SHLIB=$LDFLAGS_SHLIB" >> Makefile.config
  1600.     fi
  1601.     if [ "x$TLDFLAGS_SHLIB_EXPORT" = "x" ]; then
  1602.     echo "LDFLAGS_SHLIB_EXPORT=$LDFLAGS_SHLIB_EXPORT" >> Makefile.config
  1603.     fi
  1604. fi
  1605.  
  1606. ####################################################################
  1607. ## Now create modules.c
  1608. ##
  1609. $CAT > $awkfile <<'EOFM'
  1610.     BEGIN {
  1611.     modules[n++] = "core"
  1612.     pmodules[pn++] = "core"
  1613.     } 
  1614.     /^Module/ { modules[n++] = $2 ; pmodules[pn++] = $2 } 
  1615.     /^%Module/ { pmodules[pn++] = $2 } 
  1616.     END {
  1617.     print "/*"
  1618.     print " * modules.c --- automatically generated by Apache"
  1619.     print " * configuration script.  DO NOT HAND EDIT!!!!!"
  1620.     print " */"
  1621.     print ""
  1622.     print "#include \"httpd.h\""
  1623.     print "#include \"http_config.h\""
  1624.     print ""
  1625.     for (i = 0; i < pn; ++i) {
  1626.         printf ("extern module %s_module;\n", pmodules[i])
  1627.     }
  1628.     print ""
  1629.     print "/*"
  1630.     print " *  Modules which implicitly form the"
  1631.     print " *  list of activated modules on startup,"
  1632.     print " *  i.e. these are the modules which are"
  1633.     print " *  initially linked into the Apache processing"
  1634.     print " *  [extendable under run-time via AddModule]"
  1635.     print " */"
  1636.     print "module *ap_prelinked_modules[] = {"
  1637.     for (i = 0; i < n; ++i) {
  1638.         printf "  &%s_module,\n", modules[i]
  1639.     }
  1640.     print "  NULL"
  1641.     print "};"
  1642.     print ""
  1643.     print "/*"
  1644.     print " *  Modules which initially form the"
  1645.     print " *  list of available modules on startup,"
  1646.     print " *  i.e. these are the modules which are"
  1647.     print " *  initially loaded into the Apache process"
  1648.     print " *  [extendable under run-time via LoadModule]"
  1649.     print " */"
  1650.     print "module *ap_preloaded_modules[] = {"
  1651.     for (i = 0; i < pn; ++i) {
  1652.         printf "  &%s_module,\n", pmodules[i]
  1653.     }
  1654.     print "  NULL"
  1655.     print "};"
  1656.     print ""
  1657.     }
  1658. EOFM
  1659. $CAT $tmpfile | sed 's/_module//' | awk -f $awkfile > modules.c 
  1660.  
  1661. ####################################################################
  1662. ## figure out which module dir require use to autocreate a Makefile.
  1663. ## for these dirs we must not list the object files from the AddModule
  1664. ## lines individually since the auto-generated Makefile will create
  1665. ## a library called libMODDIR.a for it (MODDIR is the module dir
  1666. ## name). We create two variable here:
  1667. ##
  1668. ##   AUTODIRS   Space separated list of module directories, relative to
  1669. ##              src
  1670. ##   AUTOLIBS   Space separated list of auto-generated library files
  1671. ##
  1672. for moddir in $MODDIRS 
  1673. do
  1674.     if [ -f modules/$moddir/Makefile.tmpl ] ; then
  1675.         AUTODIRS="$AUTODIRS modules/$moddir"
  1676.     fi
  1677. done
  1678. for moddir in $MODDIRS_NO_SO
  1679. do
  1680.     if [ -f modules/$moddir/Makefile.tmpl ] ; then
  1681.         AUTOLIBS="$AUTOLIBS modules/$moddir/lib$moddir.a"
  1682.     fi
  1683. done
  1684.  
  1685. ####################################################################
  1686. ## Add the module targets to the Makefile. Do not add individual object
  1687. ## targets for auto-generated directories.
  1688. ##
  1689. $CAT > $awkfile <<EOF1
  1690.     BEGIN {
  1691.     split ("$AUTODIRS", tmp, " ")
  1692. EOF1
  1693. $CAT >> $awkfile <<'EOF2'
  1694.     for ( key in tmp ) {
  1695.         autodirs[tmp[key]] = 1
  1696.     }
  1697.      }
  1698.     /^Module/ { modules[n++] = $3 }
  1699.     /^%Module/ { modules[n++] = $3 }
  1700.     END {
  1701.     print "MODULES= \\"
  1702.     for (i = 0; i < n; ++i) {
  1703.         split (modules[i], pp, "/")
  1704.         dir = pp[1] "/" pp[2] 
  1705.         inthere = 0
  1706.         for ( tdir in autodirs ) {
  1707.         if (tdir == dir) 
  1708.             inthere = 1
  1709.         }
  1710.         if (inthere == 1)
  1711.         continue
  1712.         else
  1713.         printf ("  %s \\\n", modules[i])
  1714.     }
  1715.     }
  1716. EOF2
  1717. awk -f $awkfile >>Makefile <$tmpfile
  1718.  
  1719. ####################################################################
  1720. ## Now add the auto-generated library targets.  Need to use awk so we
  1721. ## don't hang a continuation on the last line.
  1722. ##
  1723. $CAT > $awkfile <<'EOF4'
  1724.     {
  1725.     z = 0
  1726.     split ($0, libs)
  1727.     for ( lib in libs ) {
  1728.         if (z != 0)
  1729.         printf (" \\\n")
  1730.         z++
  1731.         printf ("  %s", libs[lib])
  1732.     }
  1733.     }
  1734.     END {
  1735.     printf ("\n")
  1736.     }
  1737. EOF4
  1738. echo "$AUTOLIBS" | awk -f $awkfile >>Makefile
  1739. echo "" >>Makefile
  1740.  
  1741. ####################################################################
  1742. ## Now add the target for the main Makefile
  1743. ##
  1744. echo "SUBDIRS=$SUBDIRS" >> Makefile
  1745. echo "SUBTARGET=$SUBTARGET" >> Makefile
  1746. echo "SHLIB_SUFFIX_NAME=$SHLIB_SUFFIX_NAME" >> Makefile
  1747. echo "SHLIB_SUFFIX_LIST=$SHLIB_SUFFIX_LIST" >> Makefile
  1748. echo "" >> Makefile
  1749.  
  1750. ####################################################################
  1751. ## Determine GNU Make variant because
  1752. ## it uses ugly looking built-in directory walk messages
  1753. ## while we are already using our own messages
  1754. ##
  1755. if [ "x`${MAKE} -v 2>/dev/null | grep 'GNU Make'`" = "x" ]; then
  1756.     MFLAGS_STATIC=
  1757. else
  1758.     MFLAGS_STATIC=--no-print-directory
  1759. fi
  1760.  
  1761. ####################################################################
  1762. ## Continue building Makefile.config. Fill in all entries except
  1763. ## for $LIBS at this point. This implies that anything below
  1764. ## can only alter $LIBS
  1765. ##
  1766. echo "CFLAGS1=$CFLAGS" >>Makefile.config
  1767. echo "INCLUDES1=$INCLUDES" >>Makefile.config
  1768. echo "LIBS_SHLIB=$LIBS_SHLIB" >>Makefile.config
  1769. echo "LDFLAGS1=$LDFLAGS" >>Makefile.config
  1770. echo "MFLAGS_STATIC=$MFLAGS_STATIC" >>Makefile.config
  1771. echo "REGLIB=$REGLIB" >>Makefile.config
  1772. echo "RANLIB=$RANLIB" >>Makefile.config
  1773.  
  1774. ####################################################################
  1775. ## Some OS-related stuff for the DSO mechanism:
  1776. ## Finding the vendor DSO functions
  1777. ##
  1778. if [ "x$using_shlib" = "x1" ] ; then
  1779.     DL_LIB=""
  1780.     case $PLAT in
  1781.     *-ibm-aix* )
  1782.         DL_LIB="-lld"
  1783.         ;;
  1784.     *-hp-hpux*)
  1785.         if ./helpers/TestCompile func shl_load; then
  1786.         :
  1787.         else
  1788.         if ./helpers/TestCompile lib dld; then
  1789.             DL_LIB="-ldld"
  1790.         fi
  1791.         fi
  1792.         ;;
  1793.     * )
  1794.         if ./helpers/TestCompile func dlopen; then
  1795.         :
  1796.         else
  1797.         if ./helpers/TestCompile lib dl; then
  1798.             DL_LIB="-ldl"
  1799.         fi
  1800.         fi
  1801.         ;;
  1802.     esac
  1803.     if [ "x$DL_LIB" != "x" ]; then
  1804.     LIBS="$LIBS $DL_LIB"
  1805.     echo " + using $DL_LIB for vendor DSO support"
  1806.     fi
  1807. fi
  1808.  
  1809. ####################################################################
  1810. ## Finish building ap_config_auto.h
  1811. ##
  1812. ## We pick out all -D's from CFLAGS and insert them as defines into
  1813. ## ap_config_auto.h so they are available to external modules needing to
  1814. ## include Apache header files.
  1815. ##
  1816. TEXTRA_CFLAGS=`egrep '^EXTRA_CFLAGS=' Makefile.config | tail -1 |\
  1817.            sed -e 's;^EXTRA_CFLAGS=;;' -e 's;\`.*\`;;'`
  1818. tmpstr=`echo $CFLAGS $TEXTRA_CFLAGS |\
  1819.     sed -e 's;[     ]-;!-;g' -e 's/\\\"/\"/g' -e 's/\([^\\]\)"/\1/g'`
  1820. OIFS="$IFS"
  1821. IFS='!'
  1822. for cflag in $tmpstr; do
  1823.     echo "$cflag" >>$tmpconfig
  1824. done
  1825. IFS="$OIFS"
  1826. awk >>$AP_CONFIG_AUTO_H <$tmpconfig '
  1827.     /^-D.*/ {
  1828.     i = index($0, "=")
  1829.     if (i > 0) {
  1830.         define = substr($0, 3, i-3)
  1831.         value  = substr($0, i+1, length($0)-i)
  1832.     }
  1833.     else {
  1834.         define = substr($0, 3, length($0)-2)
  1835.         value  = "1";
  1836.     }
  1837.     printf ("\n/* build flag: %s */\n", $0)
  1838.     printf ("#ifndef %s\n#define %s %s\n#endif\n", define, define, value)
  1839.     }
  1840. '
  1841.  
  1842. # finish header file
  1843. echo "" >>$AP_CONFIG_AUTO_H
  1844. echo "#endif /* AP_CONFIG_AUTO_H */" >>$AP_CONFIG_AUTO_H
  1845.  
  1846. ####################################################################
  1847. ## Finish creating the Makefile.config file
  1848. ##
  1849. echo "LIBS1=$LIBS">> Makefile.config
  1850. echo "##" >> Makefile.config
  1851. echo "##  (End of automatically generated section)">> Makefile.config
  1852. echo "##" >> Makefile.config
  1853. echo "" >> Makefile.config
  1854.  
  1855. ####################################################################
  1856. ## Use TestCompile to see if $(CC) is ANSI and as a "final" sanity
  1857. ## check
  1858. ##
  1859.  
  1860. if [ "$OS" = "TPF" ] ; then
  1861.     :
  1862. else
  1863.    echo " + doing sanity check on compiler and options"
  1864.    if ./helpers/TestCompile sanity; then
  1865.       :
  1866.    else
  1867.    echo "** A test compilation with your Makefile configuration"
  1868.    echo "** failed. This is most likely because your C compiler"
  1869.    echo "** is not ANSI. Apache requires an ANSI C Compiler, such"
  1870.    echo "** as gcc. The above error message from your compiler"
  1871.    echo "** will also provide a clue."
  1872.    echo " Aborting!"
  1873.    exitcode=1
  1874.    exit 1
  1875.    fi
  1876. fi
  1877.  
  1878. ####################################################################
  1879. ## Now (finish) creating the makefiles
  1880. ##
  1881.  
  1882. # ./Makefile
  1883. $CAT Makefile.config >> Makefile
  1884. sed -e "s#@@Configuration@@#$file#" "Makefile.tmpl" >>Makefile
  1885.  
  1886. # xxx/Makefile
  1887. MAKEDIRS="support main ap regex $OSDIR"
  1888. for dir in $MAKEDIRS ; do
  1889.     echo Creating Makefile in $dir
  1890.     ./helpers/mfhead $dir $file > $dir/Makefile
  1891.     $CAT Makefile.config $dir/Makefile.tmpl |\
  1892.     sed -e "s:^SRCDIR=.*:SRCDIR=`./helpers/fp2rp $dir`:" >> $dir/Makefile
  1893. done
  1894.  
  1895. ####################################################################
  1896. ## Now create the modules/Makefile
  1897. ##
  1898. ./helpers/mfhead modules $file > modules/Makefile
  1899. $CAT Makefile.config | sed -e 's:^SRCDIR=.*:SRCDIR=..:' >> modules/Makefile
  1900.  
  1901. $CAT << EOF >> modules/Makefile
  1902. MODULES=$MODDIRS
  1903. CFLAGS=\$(OPTIM) \$(CFLAGS1) \$(EXTRA_CFLAGS)
  1904.  
  1905. default: all
  1906.  
  1907. all clean distclean depend :: 
  1908.     @for i in \$(MODULES); do \\
  1909.         echo "===> \$(SDP)modules/\$\$i"; \\
  1910.         (cd \$\$i && \$(MAKE) \$(MFLAGS_STATIC) SDP='\$(SDP)' CC='\$(CC)' AUX_CFLAGS='\$(CFLAGS)' RANLIB='\$(RANLIB)' \$@) || exit 1; \\
  1911.         echo "<=== \$(SDP)modules/\$\$i"; \\
  1912.     done
  1913.  
  1914. EOF
  1915.  
  1916. ####################################################################
  1917. ## Now create modules/xxx/Makefile
  1918. ##
  1919. for moddir in $AUTODIRS ; do
  1920.     echo "Creating Makefile in $moddir"
  1921.  
  1922.     ./helpers/mfhead $moddir $file > $moddir/Makefile
  1923.     $CAT Makefile.config |\
  1924.     sed -e "s:^SRCDIR=.*:SRCDIR=`./helpers/fp2rp $moddir`:" >> $moddir/Makefile
  1925.     $CAT << 'EOF' >> $moddir/Makefile
  1926. ##
  1927. ##  Default Makefile options from Configure script
  1928. ##  (Begin of automatically generated section)
  1929. ##
  1930. CFLAGS=$(OPTIM) $(CFLAGS1) $(EXTRA_CFLAGS)
  1931. LIBS=$(EXTRA_LIBS) $(LIBS1)
  1932. INCLUDES=$(INCLUDES1) $(INCLUDES0) $(EXTRA_INCLUDES)
  1933. LDFLAGS=$(LDFLAGS1) $(EXTRA_LDFLAGS)
  1934. INCDIR=$(SRCDIR)/include
  1935. EOF
  1936.     if [ -f $moddir/Makefile.libdir ]; then
  1937.         basedir=`echo $moddir | sed 's@^[^/]*/@@g'`
  1938.         awk >> $moddir/Makefile < $tmpfile '
  1939.         ($2 ~ /^modules\/'$basedir'\//) {
  1940.             split($2, pp, "/");
  1941.             split(pp[3], parts, ".");
  1942.             libext=parts[2];
  1943.         }
  1944.         END { 
  1945.             printf "LIBEXT=%s\n", libext;
  1946.         }'
  1947.         # it's responsible for the rest of its Makefile...
  1948.     else
  1949.         basedir=`echo $moddir | sed 's@^[^/]*/@@g'`
  1950.         OBJS=`awk < $tmpfile '
  1951.         ($1 == "Module" && $3 ~ /^modules\/'$basedir'\//) { 
  1952.             split ($3, pp, "/")
  1953.             printf "%s ", pp[3] 
  1954.         } 
  1955.         '`
  1956.         echo "OBJS=$OBJS" >> $moddir/Makefile
  1957.         if [ "x$OBJS" != "x" ]; then
  1958.         echo "LIB=lib$basedir.a" >> $moddir/Makefile
  1959.         else
  1960.         #   essential!
  1961.         echo "LIB=" >> $moddir/Makefile
  1962.         fi
  1963.         awk >> $moddir/Makefile < $tmpfile '
  1964.         ($1 == "SharedModule" && $2 ~ /^modules\/'$basedir'\//) {
  1965.         split($2, pp, "/")
  1966.         shlibs=shlibs " " pp[3]
  1967.         so=pp[3]
  1968.         split(pp[3], parts, ".")
  1969.         base=parts[1]
  1970.         objspic=objspic " " base ".lo"
  1971.         }
  1972.         END { 
  1973.         printf "SHLIBS=%s\n", shlibs;
  1974.         printf "OBJS_PIC=%s\n", objspic;
  1975.         }'
  1976.  
  1977.         $CAT << 'EOF' >> $moddir/Makefile
  1978.  
  1979. all: lib shlib
  1980.  
  1981. lib:    $(LIB) 
  1982.  
  1983. shlib:    $(SHLIBS)
  1984.  
  1985. dummy $(LIB): $(OBJS)
  1986.     rm -f $@
  1987.     ar cr $@ $(OBJS)
  1988.     $(RANLIB) $@
  1989.  
  1990. .SUFFIXES: .o .so
  1991.  
  1992. .c.o:
  1993.     $(CC) -c $(INCLUDES) $(CFLAGS) $<
  1994.  
  1995. .c.so:
  1996.     $(CC) -c $(INCLUDES) $(CFLAGS) $(CFLAGS_SHLIB) $< && mv $*.o $*.lo
  1997.     $(LD_SHLIB) $(LDFLAGS_SHLIB) -o $@ $*.lo $(LIBS_SHLIB)
  1998.  
  1999. clean:
  2000.     rm -f $(LIB) $(OBJS) $(SHLIBS) $(OBJS_PIC)
  2001.  
  2002. distclean: clean
  2003.     rm -f Makefile
  2004.  
  2005. #   NOT FOR END USERS!
  2006. depend:
  2007.     cp Makefile.tmpl Makefile.tmpl.bak \
  2008.         && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
  2009.         && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
  2010.         && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
  2011.            -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
  2012.         > Makefile.tmpl \
  2013.         && rm Makefile.new
  2014.  
  2015. EOF
  2016.     fi
  2017.  
  2018.     $CAT << 'EOF' >> $moddir/Makefile
  2019. ##
  2020. ##  (End of automatically generated section)
  2021. ##
  2022. EOF
  2023.     $CAT >> $moddir/Makefile < $moddir/Makefile.tmpl
  2024.  
  2025. done
  2026.  
  2027.