1#!/bin/sh
2# $MirOS: src/usr.sbin/httpd/configure,v 1.3 2005/10/21 11:09:43 tg Exp $
3#
4## ====================================================================
5## The Apache Software License, Version 1.1
6##
7## Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
8## reserved.
9##
10## Redistribution and use in source and binary forms, with or without
11## modification, are permitted provided that the following conditions
12## are met:
13##
14## 1. Redistributions of source code must retain the above copyright
15##    notice, this list of conditions and the following disclaimer.
16##
17## 2. Redistributions in binary form must reproduce the above copyright
18##    notice, this list of conditions and the following disclaimer in
19##    the documentation and/or other materials provided with the
20##    distribution.
21##
22## 3. The end-user documentation included with the redistribution,
23##    if any, must include the following acknowledgment:
24##       "This product includes software developed by the
25##        Apache Software Foundation (http://www.apache.org/)."
26##    Alternately, this acknowledgment may appear in the software itself,
27##    if and wherever such third-party acknowledgments normally appear.
28##
29## 4. The names "Apache" and "Apache Software Foundation" must
30##    not be used to endorse or promote products derived from this
31##    software without prior written permission. For written
32##    permission, please contact apache@apache.org.
33##
34## 5. Products derived from this software may not be called "Apache",
35##    nor may "Apache" appear in their name, without prior written
36##    permission of the Apache Software Foundation.
37##
38## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
39## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
40## OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
41## DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
42## ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
44## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
45## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
46## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
47## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
48## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49## SUCH DAMAGE.
50## ====================================================================
51##
52## This software consists of voluntary contributions made by many
53## individuals on behalf of the Apache Software Foundation.  For more
54## information on the Apache Software Foundation, please see
55## <http://www.apache.org/>.
56##
57## Portions of this software are based upon public domain software
58## originally written at the National Center for Supercomputing Applications,
59## University of Illinois, Urbana-Champaign.
60##
61
62##
63##  configure -- httpd Autoconf-style Interface (APACI)
64##
65##  Initially written by Ralf S. Engelschall <rse@apache.org>
66##
67
68## Force SSL_BASE=SYSTEM
69SSL_BASE=SYSTEM
70export SSL_BASE
71
72#   default input separator chars: <space><tab><cr>
73DIFS='
74'
75
76##
77##  avoid brain dead shells on Ultrix and friends
78##
79if [ -f /bin/sh5 ]; then
80    if [ ".$APACI_SH5_UPGRADE_STEP" != .done ]; then
81         APACI_SH5_UPGRADE_STEP=done
82         export APACI_SH5_UPGRADE_STEP
83         exec /bin/sh5 $0 "$@"
84    fi
85fi
86
87##
88##  the paths to the httpd source tree
89##
90top=.
91mkf=Makefile
92src=src
93aux=src/helpers
94sedsubst=src/.apaci.sedsubst
95addconf=src/.apaci.addconf
96tplconf=src/.apaci.tplconf
97pldconf=src/.apaci.pldconf
98configlayout=config.layout
99configstatus=config.status
100shadow=''
101
102##
103##  pre-determine runtime modes
104##
105help=no
106quiet=no
107verbose=no
108case "$*" in
109    --help|*--help|*--help* )
110        help=yes; quiet=yes
111        echo "[hang on a moment, generating help]"
112        echo ""
113        ;;
114    --quiet|*--quiet|*--quiet* )
115        quiet=yes
116        ;;
117    --verbose|*--verbose|*--verbose*|-v|*-v|*-v* )
118        verbose=yes
119        ;;
120    * )
121        ;;
122esac
123
124##
125##  determine platform id
126##
127PLATFORM="`sh $aux/GuessOS`"
128
129##
130##  display version information
131##
132if [ "x$quiet" = "xno" ]; then
133    APV=`cat $src/include/httpd.h |\
134         grep "#define SERVER_BASEREVISION" |\
135         sed -e 's/^[^"]*"//' -e 's/".*$//' -e 's/^\///'`
136    echo "Configuring for MirOS httpd, Version $APV"
137fi
138
139##
140##  important hint for the first-time users
141##
142if [ $# -eq 0 ]; then
143    echo " + Warning: Configuring httpd with default settings."
144    echo " + This is probably not what you really want."
145    echo " + Please read the README.configure and INSTALL files"
146    echo " + first or at least run '$0 --help' for"
147    echo " + a compact summary of available options."
148fi
149
150##
151##
152##  determine path to (optional) Perl interpreter
153##
154PERL=no-perl-on-this-system
155perlpath="`sh $aux/PrintPath perl5 perl miniperl`"
156if [ "x$perlpath" != "x" ]; then
157    PERL="$perlpath"
158fi
159
160##
161##  look for deadly broken echo commands which interpret escape
162##  sequences `\XX' *per default*. For those we first try the -E option
163##  and if it then is still broken we give a warning message.
164##  If it works set the `Safe Echo Option' (SEO) variable.
165##
166SEO='' # CHANGE THIS VARIABLE HERE IF YOU HAVE PROBLEMS WITH ECHO!
167bytes=`echo $SEO '\1' | wc -c | awk '{ printf("%s", $1); }'`
168if [ "x$bytes" != "x3" ]; then
169    bytes=`echo -E '\1' | wc -c | awk '{ printf("%s", $1); }'`
170    if [ "x$bytes" != "x3" ]; then
171        echo " + Warning: Your 'echo' command is slightly broken."
172        echo " + It interprets escape sequences per default. We already"
173        echo " + tried 'echo -E' but had no real success. If errors occur"
174        echo " + please set the SEO variable in 'configure' manually to"
175        echo " + the required 'echo' options, i.e. those which force your"
176        echo " + 'echo' to not interpret escape sequences per default."
177    else
178        SEO='-E'
179    fi
180fi
181
182##
183##  look for the best Awk we can find because some
184##  standard Awks are really braindead and cause
185##  problems for our scripts under some platforms.
186##
187AWK=awk
188awkpath="`sh $aux/PrintPath nawk gawk awk`"
189if [ "x$awkpath" != "x" ]; then
190    AWK="$awkpath"
191fi
192
193##
194## Look for a good Tar. If we don't find 'GNU tar' then make
195## sure ours can handle the '-h' (don't copy symlink, copy
196## the actual data) option.
197##
198TAR=tar
199tarpath="`sh $aux/PrintPath gtar gnutar tar`"
200if [ "x$tarpath" != "x" ]; then
201    TAR="$tarpath"
202fi
203case "`$TAR -tf /dev/null --version 2>/dev/null`" in
204    *GNU*) TAROPT="-hcf" ;;
205    *) if $TAR -hcf - Makefile.tmpl > /dev/null 2>&1
206       then
207           TAROPT="-hcf"
208       else
209           TAROPT="-cf"
210       fi
211       ;;
212esac
213
214##
215## Request USTAR format for tar files on OS/390
216## Request that prelink step be used for 390
217##
218case $PLATFORM in
219    *-IBM-OS390*)
220       TAROPT="${TAROPT}U"
221       ;;
222esac
223
224##
225##  determine path to sh, it's not /bin/sh on ALL systems
226##
227case x"$SHELL" in
228x/bin/*sh)	;;
229*)		SHELL=/bin/sh ;;
230esac
231if [ ! -f "$SHELL" ]; then
232    SHELL="`sh $aux/PrintPath sh`"
233    if [ "x$SHELL" = "x" ]; then
234        echo "configure:Error: Cannot determine path to Bourne-Shell" 1>&2
235        exit 1
236    fi
237fi
238
239##
240##  determine default parameters
241##
242
243#   default paths
244prefix=UNSET
245
246#   layout configuration
247with_layout=0
248show_layout=0
249
250#   suexec defaults
251suexec=0
252suexec_ok=0
253suexec_docroot='$datadir/htdocs'
254suexec_logexec='$logfiledir/suexec_log'
255suexec_caller=www
256suexec_userdir=public_html
257suexec_uidmin=100
258suexec_gidmin=100
259suexec_safepath="/usr/local/bin:/usr/bin:/bin"
260# if the umask is undefined, we don't change it
261#suexec_umask=0755
262
263#   the installation flags
264iflags_program="-m 755 -s"
265iflags_core="-m 755"
266iflags_dso="-m 755"
267iflags_script="-m 755"
268iflags_data="-m 644"
269
270#   ssl defaults
271ssl=0
272
273#   various other flags
274support=1
275confadjust=1
276permute=''
277
278#   determine rules
279rules=''
280rulelist=''
281OIFS="$IFS"
282IFS='
283'
284for rule in `grep '^Rule' $src/Configuration.tmpl`; do
285    rule=`echo "$rule" | sed -e 's/^Rule[ 	]*//'`
286    name=`echo "$rule" | sed -e 's/=.*$//'`
287    namelow=`echo "$name" | tr '[A-Z]' '[a-z]'`
288    arg=`echo "$rule" | sed -e 's/^.*=//'`
289    eval "rule_$namelow=$arg"
290    rules="$rules:$namelow"
291    rulelist="$rulelist:$name=$arg"
292done
293IFS="$OIFS"
294rules=`echo $rules | sed -e 's/^://'`
295
296#   determine modules
297modules=''
298modulelist=''
299OIFS="$IFS"
300IFS='
301'
302for module in `egrep '^[# 	]*(Add|Shared)Module' $src/Configuration.tmpl`; do
303    add=yes
304    share=no
305    if [ "x`echo $module | grep '^#'`" != "x" ]; then
306        add=no
307    fi
308    if [ "x`echo $module | grep 'SharedModule'`" != "x" ]; then
309        share=yes
310    fi
311    module=`echo "$module" |\
312            sed -e 's%^.*/\(.*\)$%\1%' \
313                -e 's/\.[oa]$//' \
314                -e 's/\.module$//' \
315                -e 's/^mod_//' \
316                -e 's/^lib//'`
317    eval "module_$module=$add"
318    eval "shared_$module=$share"
319    modules="${modules}:$module"
320    modulelist="${modulelist}:$module=$add"
321    if [ "x$share" = "xyes" ]; then
322        modulelist="${modulelist}*"
323    fi
324done
325IFS="$OIFS"
326modules=`echo $modules | sed -e 's/^://'`
327
328#   backward compatibility for old src/Configuration.tmpl
329#   parameter names to the canonical Autoconf-style shell
330#   variable names.
331OIFS="$IFS"
332IFS="$DIFS"
333for var in CFLAGS LDFLAGS LIBS INCLUDES DEPS; do
334    eval "val=\$EXTRA_$var"
335    if [ "x$val" != "x" ]; then
336        eval "$var=\$val"
337        eval "EXTRA_$var=\"\"; export EXTRA_$var"
338        echo " + Hint: please use $var instead of EXTRA_$var next time"
339    fi
340done
341IFS="$OIFS"
342
343##
344## Platform-specific defaults
345##
346case $PLATFORM in
347    *-apple-rhapsody*)
348	default_layout="Mac OS X Server"
349	iflags_core="${iflags_core} -S \"-S\""
350	iflags_dso="${iflags_dso} -S \"-S\""
351	;;
352    *-apple-darwin*)
353	default_layout="Darwin"
354	iflags_core="${iflags_core} -S \"-S\""
355	iflags_dso="${iflags_dso} -S \"-S\""
356	;;
357    *OS/2* )
358        default_layout="Apache"
359        iflags_program="${iflags_program} -e .exe"
360        iflags_core="${iflags_core} -e .exe"
361        ;;
362    *MPE/iX* )
363	default_layout="Apache"
364	iflags_program="-m 755"
365	;;
366    *)
367	default_layout="Apache"
368	;;
369esac
370
371##
372##  support for the default layout
373##
374case "$*" in
375    *--with-layout=* )
376        ;;
377    * )
378        if [ "x$*" = "x" ]; then
379            set -- --with-layout="$default_layout"
380        else
381            set -- --with-layout="$default_layout" "$@"
382        fi
383        ;;
384esac
385
386##
387##  Initialize server user ID and group ID variables
388##
389conf_user=""
390conf_group=""
391
392##
393##  Iterate over the command line options the first time.
394##
395##  This time we pre-process options which need high priority
396##  on the command line independent of their position, so they
397##  can be overridden by others.
398##
399apc_prev=''
400OIFS1="$IFS"
401IFS="$DIFS"
402for apc_option
403do
404    #   if previous option needs an argument, assign it.
405    if [ "x$apc_prev" != "x" ]; then
406        eval "$apc_prev=\$apc_option"
407        apc_prev=""
408        continue
409    fi
410    #   split out arguments
411    case "$apc_option" in
412        -*=*) apc_optarg=`echo "$apc_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
413           *) apc_optarg= ;;
414    esac
415    #  pre-process only a few options now
416    case "$apc_option" in
417        --help | -h | -help )
418            echo "Usage: configure [options]"
419            echo "Options: [defaults in brackets after descriptions]"
420            echo "General options:"
421            echo " --quiet, --silent      do not print messages"
422            echo " --verbose, -v          print even more messages"
423            echo " --shadow[=DIR]         switch to a shadow tree (under DIR) for building"
424            echo ""
425            echo "Stand-alone options:"
426            echo " --help, -h             print this message"
427            echo " --show-layout          print installation path layout (check and debug)"
428            echo ""
429            echo "Installation layout options:"
430            echo " --with-layout=[F:]ID   use installation path layout ID (from file F)"
431            echo " --target=TARGET        install name-associated files using basename TARGET"
432            echo " --prefix=PREFIX        install architecture-independent files in PREFIX"
433            echo " --exec-prefix=EPREFIX  install architecture-dependent files in EPREFIX"
434            echo " --bindir=DIR           install user     executables in DIR"
435            echo " --sbindir=DIR          install sysadmin executables in DIR"
436            echo " --libexecdir=DIR       install program  executables in DIR"
437            echo " --mandir=DIR           install manual pages in DIR"
438            echo " --sysconfdir=DIR       install configuration files in DIR"
439            echo " --datadir=DIR          install read-only data files in DIR"
440            echo " --iconsdir=DIR         install read-only icon files in DIR"
441            echo " --htdocsdir=DIR        install read-only welcome pages in DIR"
442            echo " --manualdir=DIR        install read-only on-line documentation in DIR"
443            echo " --cgidir=DIR           install read-only cgi files in DIR"
444            echo " --includedir=DIR       install includes files in DIR"
445            echo " --localstatedir=DIR    install modifiable data files in DIR"
446            echo " --runtimedir=DIR       install runtime data in DIR"
447            echo " --logfiledir=DIR       install logfile data in DIR"
448            echo " --proxycachedir=DIR    install proxy cache data in DIR"
449            echo ""
450            echo "Configuration options:"
451            echo " --enable-rule=NAME     enable  a particular Rule named 'NAME'"
452            echo " --disable-rule=NAME    disable a particular Rule named 'NAME'"
453            ${SHELL} $aux/ppl.sh $rulelist
454            echo " --add-module=FILE      on-the-fly copy & activate a 3rd-party Module"
455            echo " --activate-module=FILE on-the-fly activate existing 3rd-party Module"
456            echo " --permute-module=N1:N2 on-the-fly permute module 'N1' with module 'N2'"
457            echo " --enable-module=NAME   enable  a particular Module named 'NAME'"
458            echo " --disable-module=NAME  disable a particular Module named 'NAME'"
459            ${SHELL} $aux/ppl.sh $modulelist
460            echo " --enable-shared=NAME   enable  build of Module named 'NAME' as a DSO"
461            echo " --disable-shared=NAME  disable build of Module named 'NAME' as a DSO"
462            echo " --with-perl=FILE       path to the optional Perl interpreter"
463            echo " --with-port=PORT       set the port number for httpd.conf"
464            echo " --without-support      disable the build and installation of support tools"
465            echo " --without-confadjust   disable the user/situation adjustments in config"
466            echo " --without-execstrip    disable the stripping of executables on installation"
467            echo " --server-uid=UID       set the user ID the web server should run as [nobody]"
468            echo " --server-gid=GID       set the group ID the web server UID is a memeber of [#-1]"
469            echo ""
470            echo "suEXEC options:"
471            echo " --enable-suexec        enable the suEXEC feature"
472            echo " --suexec-caller=NAME   set the suEXEC username of the allowed caller [$suexec_caller]"
473            echo " --suexec-docroot=DIR   set the suEXEC root directory [PREFIX/share/htdocs]"
474            echo " --suexec-logfile=FILE  set the suEXEC logfile [PREFIX/var/log/suexec_log]"
475            echo " --suexec-userdir=DIR   set the suEXEC user subdirectory [$suexec_userdir]"
476            echo " --suexec-uidmin=UID    set the suEXEC minimal allowed UID [$suexec_uidmin]"
477            echo " --suexec-gidmin=GID    set the suEXEC minimal allowed GID [$suexec_gidmin]"
478            echo " --suexec-safepath=PATH set the suEXEC safe PATH [$suexec_safepath]"
479            echo " --suexec-umask=UMASK   set the umask for the suEXEC'd script [server's umask]"
480            echo ""
481            echo "Deprecated options:"
482            echo " --layout               backward compat only: use --show-layout"
483            echo " --compat               backward compat only: use --with-layout=Apache"
484            exit 0
485            ;;
486        --with-layout=*|--compat)
487            if [ "x$apc_option" = "x--compat" ]; then
488                apc_optarg="Apache"
489            fi
490            case $apc_optarg in
491                *:* )
492                    file=`echo $apc_optarg | sed -e 's/:.*//'`
493                    name=`echo $apc_optarg | sed -e 's/.*://'`
494                    ;;
495                * )
496                    name=$apc_optarg
497                    file=$configlayout
498                    ;;
499            esac
500            if [ ! -f "$file" ]; then
501                echo "configure:Error: Path layout definition file $file not found" 1>&2
502                exit 1
503            fi
504            (echo ''; cat $file; echo '') |\
505            sed -e "1,/[ 	]*<[Ll]ayout[ 	]*$name[ 	]*>[ 	]*/d" \
506                -e '/[ 	]*<\/Layout>[ 	]*/,$d' \
507                -e "s/^[ 	]*//g" \
508                -e "s/:[ 	]*/=\'/g" \
509                -e "s/[ 	]*$/'/g" \
510                >$pldconf
511            . $pldconf
512            OOIFS="$IFS"  # most likely not needed: jmj
513            IFS="$DIFS"   # ditto
514            for var in prefix exec_prefix bindir sbindir libexecdir mandir \
515                       sysconfdir datadir iconsdir htdocsdir manualdir cgidir \
516                       includedir localstatedir runtimedir logfiledir \
517                       proxycachedir; do
518                eval "val=\"\$$var\""
519                case $val in
520                    *+ )
521                        val=`echo $val | sed -e 's;\+$;;'`
522                        eval "$var=\"\$val\""
523                        eval "autosuffix_$var=yes"
524                        ;;
525                    * )
526                        eval "autosuffix_$var=no"
527                        ;;
528                esac
529            done
530            IFS="$OOIFS"
531            rm -f $pldconf 2>/dev/null
532            if [ "x$prefix" = "xUNSET" ]; then
533                echo "configure:Error: Path layout definition not found or incorrect" 1>&2
534                exit 1
535            fi
536            if [ "x$quiet" = "xno" ]; then
537                echo " + using installation path layout: $name ($file)"
538            fi
539            name_layout=$name
540            with_layout=1
541            ;;
542        *)
543            ;;
544    esac
545done
546
547##
548##  Iterate over the command line options the second time.
549##
550##  This time we parse the standard options.
551##
552addconf_created=0
553apc_prev=''
554for apc_option
555do
556    #   if previous option needs an argument, assign it.
557    if [ "x$apc_prev" != "x" ]; then
558        eval "$apc_prev=\$apc_option"
559        apc_prev=""
560        continue
561    fi
562    #   split out arguments
563    case "$apc_option" in
564        -*=*) apc_optarg=`echo "$apc_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
565           *) apc_optarg= ;;
566    esac
567    #  accept only the most important GNU Autoconf-style options
568    case "$apc_option" in
569        --help|-h|-help|--with-layout=*|-compat)
570            #   just ignore already parsed options
571            ;;
572        --quiet | --silent)
573            quiet=yes
574            ;;
575        --verbose | -v)
576            verbose=yes
577            ;;
578        --shadow*)
579            #   if we use an external shadow tree, first shadow all of ourself
580            #   to this tree and switch over to to it for internal (=platform)
581            #   shadowing...
582            case "$apc_option" in
583                --shadow=*)
584                    shadow="$apc_optarg"
585                    if [ "x$quiet" = "xno" ]; then
586                        echo " + creating external package shadow tree ($shadow)"
587                    fi
588                    rm -rf $shadow 2>/dev/null
589                    ${SHELL} $aux/mkshadow.sh . $shadow
590                    for file in $mkf $sedsubst $addconf $tplconf $pldconf $configstatus; do
591                        rm -f $shadow/$file 2>/dev/null
592                    done
593                    if [ "x$quiet" = "xno" ]; then
594                        echo " + switching to external package shadow tree ($shadow)"
595                    fi
596                    cd $shadow
597                    ;;
598            esac
599            #   determine GNU platform triple
600            gnutriple=`echo "$PLATFORM" | sed -e 's:/:-:g' | $AWK '{ printf("%s",$1); }'`
601            #   create Makefile wrapper (the first time only)
602            if [ "x`ls $top/src.* 2>/dev/null`" = "x" ]; then
603                if [ "x$quiet" = "xno" ]; then
604                    echo " + creating Makefile (shadow wrapper)"
605                fi
606                echo "##" > Makefile
607                echo "##  httpd Makefile (shadow wrapper)" >> Makefile
608                echo "##" >> Makefile
609                echo "" >> Makefile
610                if [ "x$shadow" != "x" ]; then
611                    echo "SHADOW=$shadow" >> Makefile
612                else
613                    echo "SHADOW=." >> Makefile
614                fi
615                #   (the use of `awk' and not `$AWK' here is correct, because this
616                #   Makefile is for platform bootstrapping, so don't hardcode paths)
617                echo "GNUTRIPLE=\`${SHELL} $aux/GuessOS | sed -e 's:/:-:g' | awk '{ printf(\"%s\",\$\$1); }'\`" >> Makefile
618                echo "" >> Makefile
619                echo "all build install install-quiet clean distclean:" >> Makefile
620                echo "	@cd \$(SHADOW); \$(MAKE) -f Makefile.\$(GNUTRIPLE) \$(MFLAGS) \$@" >> Makefile
621                echo "" >> Makefile
622            fi
623            #   set shadow paths
624            shadowmkf="Makefile.$gnutriple"
625            shadowsrc="src.$gnutriple"
626            shadowaux="src.$gnutriple/helpers"
627            shadowsedsubst="src.$gnutriple/.apaci.sedsubst"
628            shadowaddconf="src.$gnutriple/.apaci.addconf"
629            shadowtplconf="src.$gnutriple/.apaci.tplconf"
630            #   (re)create shadow tree
631            if [ "x$quiet" = "xno" ]; then
632                echo " + creating internal platform shadow tree ($shadowsrc)"
633            fi
634            rm -rf $shadowsrc
635            ${SHELL} $aux/mkshadow.sh $src $shadowsrc
636            #   delegate us to the shadow paths
637            mkf=$shadowmkf
638            src=$shadowsrc
639            aux=$shadowaux
640            sedsubst=$shadowsedsubst
641            addconf=$shadowaddconf
642            tplconf=$shadowtplconf
643            ;;
644        --show-layout|--layout)
645            show_layout=1
646            ;;
647        --target=*)
648            TARGET="$apc_optarg"
649            ;;
650        --prefix=*)
651            prefix="$apc_optarg"
652            autosuffix_prefix=no
653            ;;
654        --exec-prefix=*)
655            exec_prefix="$apc_optarg"
656            autosuffix_exec_prefix=no
657            ;;
658        --bindir=*)
659            bindir="$apc_optarg"
660            autosuffix_bindir=no
661            ;;
662        --sbindir=*)
663            sbindir="$apc_optarg"
664            autosuffix_sbindir=no
665            ;;
666        --libexecdir=*)
667            libexecdir="$apc_optarg"
668            autosuffix_libexecdir=no
669            ;;
670        --mandir=*)
671            mandir="$apc_optarg"
672            autosuffix_mandir=no
673            ;;
674        --sysconfdir=*)
675            sysconfdir="$apc_optarg"
676            autosuffix_sysconfdir=no
677            ;;
678        --datadir=*)
679            datadir="$apc_optarg"
680            autosuffix_datadir=no
681            ;;
682        --iconsdir=*)
683            iconsdir="$apc_optarg"
684            autosuffix_iconsdir=no
685            ;;
686        --htdocsdir=*)
687            htdocsdir="$apc_optarg"
688            autosuffix_htdocsdir=no
689            ;;
690        --manualdir=*)
691            manualdir="$apc_optarg"
692            autosuffix_manualdir=no
693            ;;
694        --cgidir=*)
695            cgidir="$apc_optarg"
696            autosuffix_cgidir=no
697            ;;
698        --includedir=*)
699            includedir="$apc_optarg"
700            autosuffix_includedir=no
701            ;;
702        --localstatedir=*)
703            localstatedir="$apc_optarg"
704            autosuffix_localstatedir=no
705            ;;
706        --runtimedir=*)
707            runtimedir="$apc_optarg"
708            autosuffix_runtimedir=no
709            ;;
710        --logfiledir=*)
711            logfiledir="$apc_optarg"
712            autosuffix_logfiledir=no
713            ;;
714        --proxycachedir=*)
715            proxycachedir="$apc_optarg"
716            autosuffix_proxycachedir=no
717            ;;
718        --add-module=*)
719            file="$apc_optarg"
720            if [ "x`echo $file | egrep '/?mod_[a-zA-Z0-9][a-zA-Z0-9_]*\.c$'`" = "x" ]; then
721                echo "configure:Error: Module filename doesn't match '/?mod_[a-zA-Z0-9][a-zA-Z0-9_]*\.c'" 1>&2
722                exit 1
723            fi
724            if [ ! -f $file ]; then
725                echo "configure:Error: Module source $file not found" 1>&2
726                exit 1
727            fi
728            modfilec=`echo $file | sed -e 's;^.*/;;'`
729            modfileo=`echo $file | sed -e 's;^.*/;;' -e 's;\.c$;.o;'`
730            if [ "x$file" != "x$src/modules/extra/$modfilec" ]; then
731                cp $file $src/modules/extra/$modfilec
732            fi
733            if [ "x$addconf_created" = "x0" ]; then
734                addconf_created=1
735                rm -f $addconf 2>/dev/null
736                touch $addconf 2>/dev/null
737            fi
738            echo "" >>$addconf
739            echo "## On-the-fly added module" >>$addconf
740            echo "## (configure --add-module=$file)" >>$addconf
741            echo "AddModule modules/extra/$modfileo" >>$addconf
742            module=`echo "$modfileo" |\
743                    sed -e 's%^.*/\(.*\)$%\1%' \
744                        -e 's/\.[^.]*$//' \
745                        -e 's/^mod_//' \
746                        -e 's/^lib//'`
747            eval "module_$module=yes"
748            eval "shared_$module=no"
749            modules="${modules}:$module"
750            modulelist="${modulelist}:$module=yes"
751            if [ "x$quiet" = "xno" ]; then
752                echo " + on-the-fly added and activated $module module (modules/extra/$modfileo)"
753            fi
754            ;;
755        --activate-module=*)
756            file="$apc_optarg"
757            case $file in
758                src/modules/* ) ;;
759                *)  echo "configure:Error: Module source already has to be below src/modules/ to be activated" 1>&2
760                    exit 1
761                    ;;
762            esac
763            modfile=`echo $file | sed -e 's;^src/;;'`
764            if [ "x$addconf_created" = "x0" ]; then
765                addconf_created=1
766                rm -f $addconf 2>/dev/null
767                touch $addconf 2>/dev/null
768            fi
769            echo "" >>$addconf
770            echo "## On-the-fly activated module" >>$addconf
771            echo "## (configure --activate-module=$file)" >>$addconf
772            echo "AddModule $modfile" >>$addconf
773            module=`echo "$modfile" |\
774                    sed -e 's%^.*/\(.*\)$%\1%' \
775                        -e 's/\.[^.]*$//' \
776                        -e 's/^mod_//' \
777                        -e 's/^lib//'`
778            eval "module_$module=yes"
779            eval "shared_$module=no"
780            modules="${modules}:$module"
781            modulelist="${modulelist}:$module=yes"
782            if [ "x$quiet" = "xno" ]; then
783                echo " + activated $module module ($modfile)"
784            fi
785            ;;
786        --enable-*)
787            apc_feature=`echo $apc_option | sed -e 's/-*enable-//' -e 's/=.*//'`
788            apc_feature=`echo $apc_feature | sed 's/-/_/g'`
789            case "$apc_option" in
790                *=*) ;;
791                  *) apc_optarg=yes ;;
792            esac
793            case "$apc_feature" in
794                rule   )
795                    apc_optarg=`echo "$apc_optarg" | tr '[A-Z]' '[a-z]'`
796                    apc_optarg_real=`echo "$apc_optarg" | tr '[a-z]' '[A-Z]'`
797                    eval "exists=\$rule_${apc_optarg}"
798                    if [ "x$exists" = "x" ]; then
799                        echo "configure:Error: No such rule named '${apc_optarg_real}'" 1>&2
800                        exit 1
801                    fi
802                    eval "rule_${apc_optarg}=yes"
803                    ;;
804                module )
805                    case $apc_optarg in
806                       all )
807                           OOIFS="$IFS"
808                           IFS=':'
809                           for module in $modules; do
810                               eval "module_${module}=yes"
811                           done
812                           IFS="$OOIFS"
813                           module_auth_digest=no # conflict with mod_digest
814                           ;;
815                       most )
816                           OOIFS="$IFS"
817                           IFS=':'
818                           for module in $modules; do
819                               eval "module_${module}=yes"
820                           done
821                           IFS="$OOIFS"
822                           module_auth_db=no     # not all platforms have -ldb
823                           module_mmap_static=no # not all platforms have mmap()
824                           module_so=no          # not all platforms have dlopen()
825                           module_example=no     # only for developers
826                           module_auth_digest=no # conflict with mod_digest
827                           module_log_agent=no   # deprecated
828                           module_log_referer=no # deprecated
829                           ;;
830                       * )
831                           eval "exists=\$module_${apc_optarg}"
832                           if [ "x$exists" = "x" ]; then
833                               echo "configure:Error: No such module named '${apc_optarg}'" 1>&2
834                               exit 1
835                           fi
836                           eval "module_${apc_optarg}=yes"
837                           ;;
838                    esac
839                    ;;
840                shared )
841                    case $apc_optarg in
842                       max )
843                           OOIFS="$IFS"
844                           IFS=':'
845                           for module in $modules; do
846                               eval "shared_${module}=yes"
847                           done
848                           IFS="$OOIFS"
849                           shared_so=no        # because of bootstrapping
850                           ;;
851                       remain )
852                           OOIFS="$IFS"
853                           IFS=':'
854                           for module in $modules; do
855                               eval "add=\$module_${module}"
856                               if [ "x$add" = "xno" ]; then
857                                   eval "module_${module}=yes"
858                                   eval "shared_${module}=yes"
859                               fi
860                           done
861                           IFS="$OOIFS"
862                           shared_so=no
863                           ;;
864                       * )
865                           eval "exists=\$module_${apc_optarg}"
866                           if [ "x$exists" = "x" ]; then
867                               echo "configure:Error: No such module named '${apc_optarg}'" 1>&2
868                               exit 1
869                           fi
870                           eval "shared_${apc_optarg}=yes"
871                           ;;
872                    esac
873                    ;;
874                suexec )
875                    suexec=1
876                    ;;
877                * )
878                    echo "configure:Error: invalid option '$apc_option'" 1>&2
879                    exit 1
880                    ;;
881            esac
882            ;;
883        --disable-*)
884            apc_feature=`echo $apc_option | sed -e 's/-*disable-//' -e 's/=.*//'`
885            apc_feature=`echo $apc_feature| sed 's/-/_/g'`
886            case "$apc_option" in
887                *=*) ;;
888                  *) apc_optarg=yes ;;
889            esac
890            case "$apc_feature" in
891                rule   )
892                    apc_optarg=`echo "$apc_optarg" | tr '[A-Z]' '[a-z]'`
893                    apc_optarg_real=`echo "$apc_optarg" | tr '[a-z]' '[A-Z]'`
894                    eval "exists=\$rule_${apc_optarg}"
895                    if [ "x$exists" = "x" ]; then
896                        echo "configure:Error: No such rule named '${apc_optarg_real}'" 1>&2
897                        exit 1
898                    fi
899                    eval "rule_${apc_optarg}=no"
900                    ;;
901                module )
902                    case $apc_optarg in
903                       all )
904                           OOIFS="$IFS"
905                           IFS=':'
906                           for module in $modules; do
907                               eval "module_${module}=no"
908                           done
909                           IFS="$OOIFS"
910                           ;;
911                       * )
912                           eval "exists=\$module_${apc_optarg}"
913                           if [ "x$exists" = "x" ]; then
914                               echo "configure:Error: No such module named '${apc_optarg}'" 1>&2
915                               exit 1
916                           fi
917                           eval "module_${apc_optarg}=no"
918                           ;;
919                    esac
920                    ;;
921                shared )
922                    case $apc_optarg in
923                       all )
924                           OOIFS="$IFS"
925                           IFS=':'
926                           for module in $modules; do
927                               eval "shared_${module}=no"
928                           done
929                           IFS="$OOIFS"
930                           ;;
931                       * )
932                           eval "exists=\$module_${apc_optarg}"
933                           if [ "x$exists" = "x" ]; then
934                               echo "configure:Error: No such module named '${apc_optarg}'" 1>&2
935                               exit 1
936                           fi
937                           eval "shared_${apc_optarg}=no"
938                           ;;
939                    esac
940                    ;;
941                * )
942                    echo "configure:Error: invalid option '$apc_option'" 1>&2
943                    exit 1
944                    ;;
945            esac
946            ;;
947        --permute-module=*:*)
948            mod1=`echo $apc_optarg | sed -e 's/:.*//'`
949            mod2=`echo $apc_optarg | sed -e 's/.*://'`
950            for mod in $mod1 $mod2; do
951                case $mod in
952                    BEGIN|END)
953                        ;;
954                    *)  eval "exists=\$module_${mod}"
955                        if [ "x$exists" = "x" ]; then
956                            echo "configure:Error: No such module named '${mod}'" 1>&2
957                            exit 1
958                        fi
959                        ;;
960                esac
961            done
962            case $mod1:$mod2 in
963                BEGIN:END|*:BEGIN|END:*)
964                    echo "configure:Error: Invalid combination of pseudo module identifiers" 1>&2
965                    exit 1
966                    ;;
967            esac
968            permute="${permute},${mod1}:${mod2}"
969            ;;
970        --with-perl=*)
971            PERL="$apc_optarg"
972            ;;
973        --with-port=*)
974            port="$apc_optarg"
975            ;;
976        --without-support)
977            support=0
978            ;;
979        --without-confadjust)
980            confadjust=0
981            ;;
982        --without-execstrip)
983            iflags_program=`echo "$iflags_program" | sed -e 's/-s//'`
984            ;;
985        --suexec-caller=*)
986            suexec_caller="$apc_optarg"
987            suexec_ok=1
988            ;;
989        --suexec-docroot=*)
990            suexec_docroot="$apc_optarg"
991            suexec_ok=1
992            ;;
993        --suexec-logfile=*)
994            suexec_logexec="$apc_optarg"
995            suexec_ok=1
996            ;;
997        --suexec-userdir=*)
998            suexec_userdir="$apc_optarg"
999            suexec_ok=1
1000            ;;
1001        --suexec-uidmin=*)
1002            suexec_uidmin="$apc_optarg"
1003            suexec_ok=1
1004            ;;
1005        --suexec-gidmin=*)
1006            suexec_gidmin="$apc_optarg"
1007            suexec_ok=1
1008            ;;
1009        --suexec-safepath=*)
1010            suexec_safepath="$apc_optarg"
1011            suexec_ok=1
1012            ;;
1013        --suexec-umask=*)
1014            suexec_umask_val="$apc_optarg"
1015            suexec_umask="-DSUEXEC_UMASK=0$apc_optarg"
1016            suexec_ok=1
1017            ;;
1018        --server-uid=*)
1019            conf_user="$apc_optarg"
1020	    # protect the '#' against interpretation as comment
1021	    case x"${conf_user}" in
1022              "#"*)  conf_user="\\\\${conf_user}";;
1023              "\\#"*)conf_user="\\${conf_user}";;
1024            esac
1025            ;;
1026        --server-gid=*)
1027            conf_group="$apc_optarg"
1028	    # protect the '#' against interpretation as comment
1029	    case x"${conf_group}" in
1030              "#"*)  conf_group="\\\\${conf_group}";;
1031              "\\#"*)conf_group="\\${conf_group}";;
1032            esac
1033            ;;
1034        * )
1035            echo "configure:Error: invalid option '$apc_option'" 1>&2
1036            exit 1
1037            ;;
1038    esac
1039done
1040IFS="$OIFS1"
1041if [ "x$apc_prev" != "x" ]; then
1042    echo "configure:Error: missing argument to --`echo $apc_prev | sed 's/_/-/g'`" 1>&2
1043    exit 1
1044fi
1045if [ "x$addconf_created" = "x0" ]; then
1046    rm -f $addconf 2>/dev/null
1047    touch $addconf 2>/dev/null
1048fi
1049
1050##
1051##   create a config status script for restoring
1052##   the configuration via a simple shell script
1053##
1054rm -f $configstatus 2>/dev/null
1055echo "#!$SHELL" >$configstatus
1056echo "##" >>$configstatus
1057echo "##  $configstatus -- APACI auto-generated configuration restore script" >>$configstatus
1058echo "##" >>$configstatus
1059echo "##  Use this shell script to re-run the APACI configure script for" >>$configstatus
1060echo "##  restoring your configuration. Additional parameters can be supplied." >>$configstatus
1061echo "##" >>$configstatus
1062echo "" >>$configstatus
1063for var in CC CPP OPTIM CFLAGS CFLAGS_SHLIB LDFLAGS LD_SHLIB LDFLAGS_SHLIB \
1064           LDFLAGS_SHLIB_EXPORT LIBS INCLUDES RANLIB DEPS TARGET EAPI_MM SSL_BASE; do
1065    eval "val=\"\$$var\""
1066    if [ "x$val" != "x" ]; then
1067        echo "$var=$val" |\
1068        sed -e 's:\(["$\\]\):\\\1:g' \
1069            -e 's:\([A-Z]*=\):\1":' \
1070            -e 's:$:" \\:' >>$configstatus
1071    fi
1072done
1073echo $SEO "${SHELL} ./configure \\" >>$configstatus
1074for arg
1075do
1076    echo "$arg" |\
1077    sed -e 's:\(["$\\]\):\\\1:g' \
1078        -e 's:^:":' \
1079        -e 's:$:" \\:' >>$configstatus
1080done
1081echo '"$@"' >>$configstatus
1082echo '' >>$configstatus
1083chmod a+x $configstatus
1084
1085##
1086##  a few errors and warnings
1087##
1088if [ "x$suexec" = "x1" ]; then
1089    if [ "x$suexec_ok" = "x0" ]; then
1090        echo "configure:Error: You enabled the suEXEC feature via --enable-suexec but"
1091        echo "                 without explicitly configuring it via at least one"
1092        echo "                 --suexec-xxxxx option. Seems like you are still not"
1093        echo "                 familiar with the suEXEC risks. Please read the INSTALL"
1094        echo "                 and htdocs/manual/suexec.html documents first."
1095        exit 1
1096    fi
1097    if [ "x`${SHELL} $aux/getuid.sh`" != "x0" ]; then
1098        echo " + Warning: You have enabled the suEXEC feature. Be aware that you need" 1>&2
1099        echo " + root privileges to complete the final installation step." 1>&2
1100    fi
1101fi
1102if [ "x$PERL" = "xno-perl-on-this-system" ]; then
1103    if [ "x$quiet" = "xno" ]; then
1104        echo " + Warning: no Perl interpreter detected for support scripts."
1105        echo " + Perhaps you need to specify one with --with-perl=FILE."
1106    fi
1107fi
1108
1109##
1110##  SSL support
1111##
1112if [ ".$module_ssl" = .yes ]; then
1113    ssl=1
1114fi
1115
1116##
1117##  target name
1118##
1119if [ "x$TARGET" != "x" ]; then
1120    thetarget="$TARGET"
1121else
1122    thetarget=httpd
1123fi
1124
1125##
1126##  expand path variables and make sure
1127##  they do not end in a backslash
1128##
1129OIFS="$IFS"
1130IFS="$DIFS"
1131for var in prefix exec_prefix bindir sbindir libexecdir mandir \
1132           sysconfdir datadir iconsdir htdocsdir manualdir cgidir \
1133           includedir localstatedir runtimedir logfiledir \
1134           proxycachedir suexec_docroot suexec_logexec ; do
1135    eval "val=\"\$$var\"";
1136    val=`echo $val | sed -e 's:\(.\)/*$:\1:'`
1137    eval "$var=\"$val\""
1138    #   expand value
1139    eval "val=\$$var"
1140    #   automatically add target suffix to path when it's
1141    #   requested (path has a trailing plus in config.layout) and
1142    #   looks reasonable (i.e. when "apache" or target-name
1143    #   still not part of path)
1144    eval "autosuffix=\$autosuffix_$var"
1145    if [ "x$autosuffix" = "xyes" ]; then
1146        addtarget=no
1147        if [ "x`echo $val | grep apache`" = "x" ]; then
1148            if [ "x`echo $val | grep $thetarget`" = "x" ]; then
1149                addtarget=yes
1150            fi
1151        fi
1152        if [ "x$addtarget" = "xyes" ]; then
1153            eval "$var=\"\$$var/$thetarget\""
1154        fi
1155    fi
1156done
1157IFS="$OIFS"
1158
1159##
1160##  determine special configurable Makefile targets
1161##
1162if [ "x$support" = "x1" ]; then
1163    build_support='build-support'
1164    if [ "x$name_layout" = "xBinaryDistribution" ]; then
1165        install_support='install-binsupport'
1166    else
1167        install_support='install-support'
1168    fi
1169    clean_support='clean-support'
1170    distclean_support='distclean-support'
1171else
1172    build_support=''
1173    install_support=''
1174    clean_support=''
1175    distclean_support=''
1176fi
1177
1178##
1179##  determine special configuration parameters
1180##
1181##  The checks via /etc/passwd and /etc/group will obviously fail
1182##  on platforms using NIS. But then you propably do not want a
1183##  UID/GID as production oriented as a web server in NIS anyway.
1184##
1185if [ "x$port" != "x" ]; then
1186    conf_port=$port
1187else
1188    conf_port="80"
1189fi
1190conf_port_ssl="443"
1191conf_serveradmin="you@your.address"
1192conf_servername="new.host.name"
1193if [ "x$confadjust" = "x1" ]; then
1194    if [ -f /etc/passwd ]; then
1195        if [ "x$conf_user" = "x" ]; then
1196        for uid in nobody www daemon demon http httpd; do
1197            if [ "x`egrep \^${uid}: /etc/passwd`" != "x" ]; then
1198                conf_user="$uid"
1199                break
1200            fi
1201        done
1202        fi
1203        if [ "x$conf_group" = "x" ]; then
1204        for gid in nobody nogroup www daemon demon http httpd; do
1205            if [ "x`egrep \^${gid}: /etc/group`" != "x" ]; then
1206                conf_group="$gid"
1207                break
1208            fi
1209        done
1210    fi
1211    fi
1212    if [ "x`${SHELL} $aux/getuid.sh`" != "x0" -a "x$port" = "x" ]; then
1213        conf_port="8080"
1214        conf_port_ssl="8443"
1215    fi
1216    conf_serveradmin="`${SHELL} $aux/buildinfo.sh -n %u@%h%d`"
1217    conf_servername="`${SHELL} $aux/buildinfo.sh -n %h%d`"
1218fi
1219
1220##
1221## Default server user id and group id if not specified on configure invocation and none
1222## of the ids in /etc/passwd or /etc/group worked.
1223##
1224if [ "x$conf_user" = "x" ]; then
1225    conf_user="nobody"
1226fi
1227if [ "x$conf_group" = "x" ]; then
1228    conf_group="\\\\#-1"
1229fi
1230
1231##
1232##  determine prefix-relative paths for directories
1233##  because httpd supports them for the -d and -f
1234##  options, the LoadModule directive, etc.
1235##
1236##  [we have to make sure that it ends with a slash
1237##   or we cannot support the case where the relative
1238##   path is just the emtpy one, i.e. ""]
1239##
1240runtimedir_relative=`echo $runtimedir | sed -e "s:^$prefix/*::" -e 's:\(.\)$:\1/:'`
1241logfiledir_relative=`echo $logfiledir | sed -e "s:^$prefix/*::" -e 's:\(.\)$:\1/:'`
1242sysconfdir_relative=`echo $sysconfdir | sed -e "s:^$prefix/*::" -e 's:\(.\)$:\1/:'`
1243libexecdir_relative=`echo $libexecdir | sed -e "s:^$prefix/*::" -e 's:\(.\)$:\1/:'`
1244
1245##
1246##  check and debug
1247##
1248if [ "x$show_layout" = "x1" ]; then
1249    echo ""
1250    echo "Installation paths:"
1251    echo "               prefix: $prefix"
1252    echo "          exec_prefix: $exec_prefix"
1253    echo "               bindir: $bindir"
1254    echo "              sbindir: $sbindir"
1255    echo "           libexecdir: $libexecdir"
1256    echo "               mandir: $mandir"
1257    echo "           sysconfdir: $sysconfdir"
1258    echo "              datadir: $datadir"
1259    echo "             iconsdir: $iconsdir"
1260    echo "            htdocsdir: $htdocsdir"
1261    echo "            manualdir: $manualdir"
1262    echo "               cgidir: $cgidir"
1263    echo "           includedir: $includedir"
1264    echo "        localstatedir: $localstatedir"
1265    echo "           runtimedir: $runtimedir"
1266    echo "           logfiledir: $logfiledir"
1267    echo "        proxycachedir: $proxycachedir"
1268    echo ""
1269    echo "Compilation paths:"
1270    echo "           HTTPD_ROOT: $prefix"
1271    echo "      SHARED_CORE_DIR: $libexecdir"
1272    echo "       DEFAULT_PIDLOG: ${runtimedir_relative}${thetarget}.pid"
1273    echo "   DEFAULT_SCOREBOARD: ${runtimedir_relative}${thetarget}.scoreboard"
1274    echo "     DEFAULT_LOCKFILE: ${runtimedir_relative}${thetarget}.lock"
1275    echo "     DEFAULT_ERRORLOG: ${logfiledir_relative}error_log"
1276    echo "    TYPES_CONFIG_FILE: ${sysconfdir_relative}mime.types"
1277    echo "   SERVER_CONFIG_FILE: ${sysconfdir_relative}${thetarget}.conf"
1278    echo "   ACCESS_CONFIG_FILE: ${sysconfdir_relative}access.conf"
1279    echo " RESOURCE_CONFIG_FILE: ${sysconfdir_relative}srm.conf"
1280    echo " SSL_CERTIFICATE_FILE: ${sysconfdir_relative}ssl.crt/server.crt"
1281    echo ""
1282    if [ "x$suexec" = "x1" ]; then
1283        echo "suEXEC setup:"
1284        echo "        suexec binary: $sbindir/suexec"
1285        echo "        document root: $suexec_docroot"
1286        echo "       userdir suffix: $suexec_userdir"
1287        echo "              logfile: $suexec_logexec"
1288        echo "            safe path: $suexec_safepath"
1289        echo "            caller ID: $suexec_caller"
1290        echo "      minimum user ID: $suexec_uidmin"
1291        echo "     minimum group ID: $suexec_gidmin"
1292        if [ "x$suexec_umask" != "x" ]; then
1293            echo "                umask: $suexec_umask_val"
1294	else
1295            echo "                umask: running server's"
1296        fi
1297        echo ""
1298    fi
1299    exit 0
1300fi
1301
1302##
1303##  create Makefile from Makefile.tmpl
1304##
1305if [ "x$quiet" = "xno" ]; then
1306    echo "Creating $mkf"
1307fi
1308sed <Makefile.tmpl >$mkf \
1309-e "s%@PLATFORM@%$PLATFORM%g" \
1310-e "s%@PERL@%$PERL%g" \
1311-e "s%@TAR@%$TAR%g" \
1312-e "s%@TAROPT@%$TAROPT%g" \
1313-e "s%@SRC@%$src%g" \
1314-e "s%@MKF@%$mkf%g" \
1315-e "s%@AUX@%$aux%g" \
1316-e "s%@TARGET@%$thetarget%g" \
1317-e "s%@IFLAGS_PROGRAM@%$iflags_program%g" \
1318-e "s%@IFLAGS_CORE@%$iflags_core%g" \
1319-e "s%@IFLAGS_DSO@%$iflags_dso%g" \
1320-e "s%@IFLAGS_SCRIPT@%$iflags_script%g" \
1321-e "s%@IFLAGS_DATA@%$iflags_data%g" \
1322-e "s%@prefix@%$prefix%g" \
1323-e "s%@exec_prefix@%$exec_prefix%g" \
1324-e "s%@bindir@%$bindir%g" \
1325-e "s%@sbindir@%$sbindir%g" \
1326-e "s%@libexecdir@%$libexecdir%g" \
1327-e "s%@libexecdir_relative@%$libexecdir_relative%g" \
1328-e "s%@mandir@%$mandir%g" \
1329-e "s%@sysconfdir@%$sysconfdir%g" \
1330-e "s%@datadir@%$datadir%g" \
1331-e "s%@iconsdir@%$iconsdir%g" \
1332-e "s%@htdocsdir@%$htdocsdir%g" \
1333-e "s%@manualdir@%$manualdir%g" \
1334-e "s%@cgidir@%$cgidir%g" \
1335-e "s%@localstatedir@%$localstatedir%g" \
1336-e "s%@includedir@%$includedir%g" \
1337-e "s%@runtimedir@%$runtimedir%g" \
1338-e "s%@logfiledir@%$logfiledir%g" \
1339-e "s%@proxycachedir@%$proxycachedir%g" \
1340-e "s%@suexec@%$suexec%g" \
1341-e "s%@suexec_caller@%$suexec_caller%g" \
1342-e "s%@suexec_docroot@%$suexec_docroot%g" \
1343-e "s%@suexec_logexec@%$suexec_logexec%g" \
1344-e "s%@suexec_userdir@%$suexec_userdir%g" \
1345-e "s%@suexec_uidmin@%$suexec_uidmin%g" \
1346-e "s%@suexec_gidmin@%$suexec_gidmin%g" \
1347-e "s%@suexec_safepath@%$suexec_safepath%g" \
1348-e "s%@suexec_umask@%$suexec_umask%g" \
1349-e "s%@ssl@%$ssl%g" \
1350-e "s%@conf_user@%$conf_user%g" \
1351-e "s%@conf_group@%$conf_group%g" \
1352-e "s%@conf_port@%$conf_port%g" \
1353-e "s%@conf_port_ssl@%$conf_port_ssl%g" \
1354-e "s%@conf_serveradmin@%$conf_serveradmin%g" \
1355-e "s%@conf_servername@%$conf_servername%g" \
1356-e "s%@build_support@%$build_support%g" \
1357-e "s%@install_support@%$install_support%g" \
1358-e "s%@clean_support@%$clean_support%g" \
1359-e "s%@distclean_support@%$distclean_support%g" \
1360-e "s%@SHELL@%$SHELL%g"
1361
1362##
1363##  override default paths in $src/include/httpd.h
1364##  via command line arguments for the compiler
1365##  supplied by a little shell script named $src/apaci
1366##
1367echo "#!$SHELL" >$src/apaci
1368echo "## USED AS A COMMAND LINE EXPANDER TO OVERRIDE PATHS" >>$src/apaci
1369echo "## WITHOUT DISTURBING THE KNOWN MAKE BUILD PROCESS DISPLAY" >>$src/apaci
1370echo "echo '-DHTTPD_ROOT=\"$prefix\"'" >>$src/apaci
1371echo "echo '-DSUEXEC_BIN=\"$sbindir/suexec\"'" >>$src/apaci
1372echo "echo '-DSHARED_CORE_DIR=\"$libexecdir\"'" >>$src/apaci
1373echo "echo '-DDEFAULT_PIDLOG=\"${runtimedir_relative}${thetarget}.pid\"'" >>$src/apaci
1374echo "echo '-DDEFAULT_SCOREBOARD=\"${runtimedir_relative}${thetarget}.scoreboard\"'" >>$src/apaci
1375echo "echo '-DDEFAULT_LOCKFILE=\"${runtimedir_relative}${thetarget}.lock\"'" >>$src/apaci
1376echo "echo '-DDEFAULT_ERRORLOG=\"${logfiledir_relative}error_log\"'" >>$src/apaci
1377echo "echo '-DTYPES_CONFIG_FILE=\"${sysconfdir_relative}mime.types\"'" >>$src/apaci
1378echo "echo '-DSERVER_CONFIG_FILE=\"${sysconfdir_relative}${thetarget}.conf\"'" >>$src/apaci
1379echo "echo '-DACCESS_CONFIG_FILE=\"${sysconfdir_relative}access.conf\"'" >>$src/apaci
1380echo "echo '-DRESOURCE_CONFIG_FILE=\"${sysconfdir_relative}srm.conf\"'" >>$src/apaci
1381echo "echo '-DSSL_CERTIFICATE_FILE=\"${sysconfdir_relative}ssl.crt/server.crt\"'" >>$src/apaci
1382echo "echo '-DEAPI_MM_CORE_PATH=\"${runtimedir_relative}${thetarget}.mm\"'" >>$src/apaci
1383chmod a+x $src/apaci
1384CFLAGS="$CFLAGS \\\`\$(SRCDIR)/apaci\\\`"
1385
1386##
1387##  create $src/Configuration.apaci file
1388##
1389if [ "x$quiet" = "xno" ]; then
1390    echo "Creating Configuration.apaci in $src"
1391fi
1392rm -f $sedsubst 2>/dev/null
1393touch $sedsubst
1394
1395#   generate settings from imported environment variables
1396OIFS="$IFS"
1397IFS="$DIFS"
1398for var in CC CPP OPTIM CFLAGS CFLAGS_SHLIB LDFLAGS LD_SHLIB LDFLAGS_SHLIB \
1399           LDFLAGS_SHLIB_EXPORT LIBS INCLUDES RANLIB DEPS TARGET EAPI_MM SSL_BASE; do
1400    eval "val=\"\$$var\"";
1401    if [ "x$val" != "x" ]; then
1402        case $var in
1403            CFLAGS|LDFLAGS|LIBS|INCLUDES|DEPS)
1404                echo $SEO "s%^#*\\(EXTRA_$var=\\).*%\\1$val%g" >>$sedsubst
1405                ;;
1406            *)
1407                echo $SEO "s%^#*\\($var=\\).*%\\1$val%g" >>$sedsubst
1408                ;;
1409        esac
1410        eval "$var=\"\"; export $var"
1411    fi
1412done
1413IFS="$OIFS"
1414
1415#   generate rule directives
1416OIFS="$IFS"
1417IFS=':'
1418for rule in $rules; do
1419    name="`echo $rule | tr '[a-z]' '[A-Z]'`"
1420    eval "val=\$rule_$rule"
1421    echo $SEO "s%^\\(Rule $name=\\).*%\\1$val%g" >>$sedsubst
1422    if [ "x$verbose" = "xyes" ]; then
1423        echo " + Rule $name=$val"
1424    fi
1425done
1426IFS="$OIFS"
1427
1428#   consistency checks for shared object support
1429some_shares=0
1430OIFS="$IFS"
1431IFS=':'
1432for module in $modules; do
1433    eval "share=\$shared_$module"
1434    if [ "x$share" = "xyes" ]; then
1435        some_shares=1
1436    fi
1437done
1438IFS="$OIFS"
1439if [ "x$some_shares" = "x1" ]; then
1440    if [ "x$module_so" = "xno" ]; then
1441        module_so=yes
1442        if [ "x$quiet" = "xno" ]; then
1443            echo " + enabling mod_so for DSO support"
1444        fi
1445    fi
1446fi
1447if [ "x$shared_so" = "xyes" ]; then
1448    shared_so=no
1449    echo "configure:Error: Module mod_so cannot be made a DSO itself" 1>&2
1450    exit 1
1451fi
1452
1453#   module permutation support
1454if [ "x$permute" != "x" ]; then
1455    sed -e '/## mod_mmap_static/,$d' <src/Configuration.tmpl >$tplconf
1456    OIFS="$IFS"
1457    IFS='
1458'
1459    for line in `cat src/Configuration.tmpl $addconf | egrep '^[# ]*(Add|Shared)Module'`; do
1460        name=`echo "$line" |\
1461              sed -e 's%^.*/\(.*\)$%\1%' \
1462                  -e 's/\.[oa]$//' \
1463                  -e 's/\.module$//' \
1464                  -e 's/^mod_//' \
1465                  -e 's/^lib//'`
1466        echo "${name}:${line}"
1467    done |\
1468    $AWK -F: '
1469        BEGIN {
1470            n = 0;
1471        }
1472        {
1473            module_pos[$1]  = n;
1474            module_list[n]  = $1;
1475            module_line[$1] = $2;
1476            n++;
1477        }
1478        END {
1479            pn = split(permute, perm, ",");
1480            for (p = 1; p <= pn; p++) {
1481                split(perm[p], m, ":")
1482                m1 = m[1];
1483                m2 = m[2];
1484                if (m1 == "BEGIN") {
1485                    for (i = module_pos[m2]-1; i >= 0; i--) {
1486                        n1 = module_list[i];
1487                        n2 = module_list[i+1];
1488                        module_list[i]   = n2;
1489                        module_list[i+1] = n1;
1490                        module_pos[n1]   = i+1;
1491                        module_pos[n2]   = i;
1492                    }
1493                }
1494                else if (m2 == "END") {
1495                    for (i = module_pos[m1]; i < n-1; i++) {
1496                        n1 = module_list[i];
1497                        n2 = module_list[i+1];
1498                        module_list[i]   = n2;
1499                        module_list[i+1] = n1;
1500                        module_pos[n1]   = i+1;
1501                        module_pos[n2]   = i;
1502                    }
1503                }
1504                else {
1505                    p1 = module_pos[m1];
1506                    p2 = module_pos[m2];
1507                    n1 = module_list[p1];
1508                    n2 = module_list[p2];
1509                    module_list[p1] = n2;
1510                    module_list[p2] = n1;
1511                    module_pos[m1] = p2;
1512                    module_pos[m2] = p1;
1513                }
1514            }
1515            for (i = 0; i < n; i++) {
1516                name = module_list[i];
1517                printf("%s\n", module_line[name]);
1518            }
1519        }
1520    ' "permute=$permute" >>$tplconf
1521    IFS="$OIFS"
1522else
1523    cat $src/Configuration.tmpl $addconf >$tplconf
1524fi
1525
1526#   generate module directives
1527#   (paths are modules/foo/mod_bar.ext and modules/foo/libbar.ext)
1528OIFS="$IFS"
1529IFS=':'
1530for module in $modules; do
1531    eval "add=\$module_$module"
1532    if [ "x$add" = "xyes" ]; then
1533        echo $SEO "s%^.*\\(AddModule.*mod_$module\\..*\\)%\\1%g" >>$sedsubst
1534        echo $SEO "s%^.*\\(AddModule.*lib$module\\..*\\)%\\1%g" >>$sedsubst
1535        echo $SEO "s%^.*\\(SharedModule.*mod_$module\\..*\\)%\\1%g" >>$sedsubst
1536        echo $SEO "s%^.*\\(SharedModule.*lib$module\\..*\\)%\\1%g" >>$sedsubst
1537        m="yes"
1538    else
1539        echo $SEO "s%^.*\\(AddModule.*mod_$module\\..*\\)%# \\1%g" >>$sedsubst
1540        echo $SEO "s%^.*\\(AddModule.*lib$module\\..*\\)%# \\1%g" >>$sedsubst
1541        echo $SEO "s%^.*\\(SharedModule.*mod_$module\\..*\\)%# \\1%g" >>$sedsubst
1542        echo $SEO "s%^.*\\(SharedModule.*lib$module\\..*\\)%# \\1%g" >>$sedsubst
1543        m=no
1544    fi
1545    eval "share=\$shared_$module"
1546    if [ "x$share" = "xyes" ]; then
1547        echo $SEO "s%^\\(.*\\)AddModule\\(.*mod_$module\\.\\)[oam].*\\(.*\\)%\\1SharedModule\\2so\\3%g" >>$sedsubst
1548        echo $SEO "s%^\\(.*\\)AddModule\\(.*lib$module\\.\\)[oam].*\\(.*\\)%\\1SharedModule\\2so\\3%g" >>$sedsubst
1549        m="$m [shared]"
1550    fi
1551    if [ "x$verbose" = "xyes" ]; then
1552        echo " + Module $module: $m"
1553    fi
1554done
1555IFS="$OIFS"
1556
1557# translate module names to dll names for OS/2 so that they are no more
1558# than 8 characters long and have an extension of "dll" instead of "so"
1559case $PLATFORM in
1560    *OS/2* )
1561        echo $SEO "s%/mod_\\(.\\{1,8\\}\\).*\\.so%/\\1\\.dll%" >>$sedsubst
1562        echo $SEO "s%/\\(lib.*\\)\\.so$%/\\1.dll%" >>$sedsubst
1563        ;;
1564    *cygwin* )
1565        echo $SEO "s%/\\(mod_.*\\)\\.so$%/\\1.dll%" >>$sedsubst
1566        echo $SEO "s%/\\(lib.*\\)\\.so$%/\\1.dll%" >>$sedsubst
1567        ;;
1568esac
1569
1570#   split sedsubst into chunks of 50 commands
1571#   to workaround limits in braindead seds
1572files=`$AWK <$sedsubst '
1573    BEGIN { line=0; cnt=0; }
1574    {
1575        if (line % 50 == 0) {
1576            file = sedsubst "." cnt;
1577            printf("%s\n", file);
1578            cnt++;
1579        }
1580        line++;
1581        print $0 >file;
1582    }
1583' "sedsubst=$sedsubst"`
1584OIFS="$IFS"
1585IFS="$DIFS"
1586substcmd=""
1587for file in $files; do
1588    substcmd="${substcmd} sed -f $file |"
1589done
1590substcmd="${substcmd} cat"
1591IFS="$OIFS"
1592
1593#   and finally translate the config template
1594#   according to our defined configuration
1595eval "cat $tplconf | $substcmd >$src/Configuration.apaci"
1596
1597#   cleanup
1598rm -f $sedsubst $sedsubst.[0-9] 2>/dev/null
1599rm -f $addconf 2>/dev/null
1600rm -f $tplconf 2>/dev/null
1601
1602##
1603##  create all other Makefiles by running the proprietary
1604##  $src/Configure script with our custom Configuration.apaci file
1605##
1606if [ "x$verbose" = "xyes" ]; then
1607    vflag="-v";
1608fi
1609exec 4>&1
1610rc=`if [ "x$quiet" = "xyes" ]; then
1611    (cd $src; ${SHELL} ./Configure ${vflag} -file Configuration.apaci >/dev/null; echo $? >&3; );
1612else
1613    (cd $src; (${SHELL} ./Configure ${vflag} -file Configuration.apaci; echo $? >&3; ) |\
1614     sed -e '/^Using config file:.*/d' \
1615         -e "s:Makefile in :Makefile in $src\\/:" \
1616         -e "s:Makefile\$:Makefile in $src:" >&4 )
1617fi 3>&1`
1618
1619## Ugly. So far, we've only used -eq, so just in case, use this
1620## stupid code unless we're *sure* that -ne is also available
1621if [ $rc -eq 0 ]; then
1622    :
1623else
1624    exit 1
1625fi
1626
1627##
1628##  final hints
1629##
1630if [ "x$quiet" = "xno" ]; then
1631    if [ "x$shadow" != "x" ]; then
1632        echo "Hint: You now have to build inside $shadow."
1633        echo "This can be done either by running the canonical commands"
1634        echo "  \$ cd $shadow"
1635        echo "  \$ make"
1636        echo "  \$ make install"
1637        echo "or by running this alternative commands"
1638        echo "  \$ make -f $shadow/Makefile"
1639        echo "  \$ make -f $shadow/Makefile install"
1640    fi
1641fi
1642