httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@engelschall.com (Ralf S. Engelschall)
Subject Re: [CONTRIB] Autoconf Interface Emulation
Date Mon, 02 Mar 1998 07:29:51 GMT

In article <199803011615.RAA19738@en1.engelschall.com> you wrote:

> Autoconf Interface Emulation (AIE)
> ----------------------------------
> [...]

Seems (perhaps because of the tarfile) the opinions are given without deep
code review. So here are the four files for better review for those of us who
are a little bit lazy and don't want to try it out theirself:

===Makefile================================================================
##
##  Makefile -- Top-level Makefile for building Apache
##
##  This Makefile builds either a "standard" Apache. If you want to build a
##  custom Apache, read the instructions in the src/ directory in the file
##  INSTALL.
##

SHELL           = /bin/sh

PERL            = @PERL@

MKDIR           = ./aux/mkdir.sh
INSTALL         = ./aux/install.sh -c
INSTALL_PROGRAM = $(INSTALL) -s -m 755
INSTALL_SCRIPT  = $(INSTALL) -m 755
INSTALL_DATA    = $(INSTALL) -m 644
CP              = cp

prefix          = @prefix@
exec_prefix     = @exec_prefix@
bindir          = @bindir@
sbindir         = @sbindir@
libexecdir      = @libexecdir@
mandir          = @mandir@
sysconfdir      = @sysconfdir@
datadir         = @datadir@
localstatedir   = @localstatedir@

all: build

build:
	cd src; $(MAKE) $(MFLAGS) all support

install: build
	$(MKDIR) $(bindir)
	$(MKDIR) $(sbindir)
	$(MKDIR) $(libexecdir)
	$(MKDIR) $(mandir)/man1
	$(MKDIR) $(mandir)/man8
	$(MKDIR) $(sysconfdir)
	$(MKDIR) $(datadir)/htdocs
	$(MKDIR) $(datadir)/icons
	$(MKDIR) $(datadir)/cgi-bin
	$(MKDIR) $(localstatedir)/logs
	$(MKDIR) $(localstatedir)/run
	$(MKDIR) $(localstatedir)/proxy
	$(INSTALL_PROGRAM) src/httpd $(libexecdir)/httpd
	sed -e 's;PIDFILE=.*;PIDFILE=$(localstatedir)/run/httpd.pid;' \
    	-e 's;HTTPD=.*;HTTPD=$(libexecdir)/httpd;' \
    	< src/support/apachectl > .install.tmp && \
    	$(INSTALL_SCRIPT) .install.tmp $(sbindir)/apachectl
	sed -e 's;^#!/.*;#!$(PERL);' \
    	< src/support/dbmmanage > .install.tmp && \
    	$(INSTALL_SCRIPT) .install.tmp $(sbindir)/dbmmanage
	$(INSTALL_PROGRAM) src/support/htpasswd $(bindir)/htpasswd
	$(INSTALL_PROGRAM) src/support/htdigest $(bindir)/htdigest
	$(INSTALL_PROGRAM) src/support/logresolve $(sbindir)/logresolve
	$(INSTALL_PROGRAM) src/support/rotatelogs $(sbindir)/rotatelogs
	$(INSTALL_DATA) src/support/httpd.8 $(mandir)/man8/httpd.8
	$(INSTALL_DATA) src/support/apachectl.1 $(mandir)/man1/apachectl.1
	$(INSTALL_DATA) src/support/htpasswd.1 $(mandir)/man1/htpasswd.1
	for conf in httpd.conf access.conf srm.conf; do \
    	sed -e 's;@@ServerRoot@@/htdocs;$(datadir)/htdocs;' \
        	-e 's;@@ServerRoot@@/icons;$(datadir)/icons;' \
        	-e 's;@@ServerRoot@@/cgi-bin;$(datadir)/cgi-bin;' \
        	-e 's;@@ServerRoot@@/proxy;$(localstatedir)/proxy;' \
        	-e 's;@@ServerRoot@@;$(prefix);' \
        	-e 's;logs/accept.lock;$(localstatedir)/run/httpd.lock;' \
        	-e 's;logs/apache_status;$(localstatedir)/run/httpd.scoreboard;' \
        	-e 's;logs/httpd.pid;$(localstatedir)/run/httpd.pid;' \
        	-e 's;logs/access_log;$(localstatedir)/logs/access_log;' \
        	-e 's;logs/error_log;$(localstatedir)/logs/error_log;' \
        	< conf/$$conf-dist > .install.tmp && \
    	$(INSTALL_DATA) .install.tmp $(sysconfdir)/$$conf; \
	done
	$(CP) conf/mime.types $(sysconfdir)/mime.types
	$(CP) conf/magic $(sysconfdir)/magic
	$(CP) -R -p htdocs/* $(datadir)/htdocs/
	$(CP) -R -p icons/* $(datadir)/icons/
	$(CP) -R -p cgi-bin/* $(datadir)/cgi-bin/
	-@rm -f .install.tmp
    
clean:
	cd src; $(MAKE) $(MFLAGS) clean

distclean:
	@$(MAKE) $(MFLAGS) clean
	-rm -f src/support/Makefile
	-rm -f src/main/Makefile
	-rm -f src/ap/Makefile
	-rm -f src/regex/Makefile
	-rm -f src/os/unix/Makefile
	-rm -f src/modules/experimental/Makefile
	-rm -f src/modules/extra/Makefile
	-rm -f src/modules/standard/Makefile
	-rm -f src/modules/proxy/Makefile
	-rm -f src/modules/Makefile
	-rm -f src/Makefile
	-rm -f src/Makefile.config
	-rm -f src/Configuration.gen
	-rm -f Makefile

===configure================================================================
#!/bin/sh
##
##  configure -- GNU Autoconf-style top-level configuration script
##  Written by Ralf S. Engelschall, <rse@apache.org>
##


##
##  determine default parameters
##
IFS='
'

#   default modes
quiet=no

#   default paths
prefix='/usr/local/apache'
exec_prefix='$prefix'
bindir='$exec_prefix/bin'
sbindir='$exec_prefix/sbin'
libexecdir='$exec_prefix/libexec'
mandir='$prefix/man'
sysconfdir='$prefix/etc'
datadir='$prefix/share'
localstatedir='$prefix/var'

#   determine rules
rules=""
rulelist=""
for rule in `grep '^Rule' src/Configuration.tmpl`; do
    rule=`echo "$rule" | sed -e 's/^Rule[ ]*//'`
    name=`echo "$rule" | sed -e 's/=.*$//'`
    namelow=`echo "$name" | tr "A-Z" "a-z"`
    arg=`echo "$rule" | sed -e 's/^.*=//'`
    eval "rule_$namelow=$arg"
    rules="$rules:$namelow"
    rulelist="$rulelist:$name=$arg"
done

#   determine modules
modules=""
modulelist=""
for module in `grep '^[# ]*AddModule' src/Configuration.tmpl`; do
    add=yes
    if [ ".`echo $module | grep '^#'`" != . ]; then
        add=no
    fi
    module=`echo "$module" |\
            sed -e 's%^.*/\(.*\)$%\1%' \
                -e 's/\.[oa]$//' \
                -e 's/^mod_//' \
                -e 's/^lib//'`
    eval "module_$module=$add"
    modules="$modules:$module"
    modulelist="$modulelist:$module=$add"
done


##
##  parse argument line options
##
apc_prev=
for apc_option; do
    #   if previous option needs an argument, assign it.
    if [ -n "$apc_prev" ]; then
        eval "$apc_prev=\$apc_option"
        apc_prev=
        continue
    fi
    #   split out arguments
    case "$apc_option" in
        -*=*) apc_optarg=`echo "$apc_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
           *) apc_optarg= ;;
    esac

    #  accept only the most important GNU Autoconf-style options
    case "$apc_option" in
        --help | -help | -h )
            echo "Usage: configure [options]"
            echo "Options: [defaults in brackets after descriptions]"
            echo ""
            echo " --help                print this message"
            echo " --quiet, --silent     do not print messages"
            echo ""
            echo " --prefix=PREFIX       install architecture-independent files in PREFIX"
            echo "                       [$prefix]"
            echo " --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX"
            echo "                       [same as prefix]"
            echo " --bindir=DIR          install user     executables in DIR  [EPREFIX/bin]"
            echo " --sbindir=DIR         install sysadmin executables in DIR  [EPREFIX/sbin]"
            echo " --libexecdir=DIR      install program  executables in DIR  [EPREFIX/libexec]"
            echo " --mandir=DIR          install manual pages in DIR          [PREFIX/man]"
            echo " --sysconfdir=DIR      install configuration files in DIR   [PREFIX/etc]"
            echo " --datadir=DIR         install read-only  data files in DIR [PREFIX/share]"
            echo " --localstatedir=DIR   install modifiable data files in DIR [PREFIX/var]"
            echo ""
            echo " --enable-rule=NAME    enable  a particular Rule named 'NAME'"
            echo " --disable-rule=NAME   disable a particular Rule named 'NAME'"
            echo "$rulelist" |\
                sed -e 's/^://' |\
                tr ":" "\n" |\
                sort | fmt 54 55 |\
                sed -e 's/^/                       [/' -e 's/$/]/'
            echo ""
            echo " --enable-module=NAME  enable  a particular Module named 'NAME'"
            echo " --disable-module=NAME disable a particular Module named 'NAME'"
            echo "$modulelist" |\
                sed -e 's/^://' |\
                tr ":" "\n" |\
                sort |\
                fmt 54 55 |\
                sed -e 's/^/                       [/' -e 's/$/]/'
            echo ""
            exit 0
            ;;
        --quiet | --silent) 
            quiet=yes
            ;;
        --prefix=*)        prefix="$apc_optarg"        ;;
        --exec-prefix=*)   exec_prefix="$apc_optarg"   ;;
        --bindir=*)        bindir="$apc_optarg"        ;;
        --sbindir=*)       sbindir="$apc_optarg"       ;;
        --libexecdir=*)    libexecdir="$apc_optarg"    ;;
        --mandir=*)        mandir="$apc_optarg"        ;;
        --sysconfdir=*)    sysconfdir="$apc_optarg"    ;;
        --datadir=*)       datadir="$apc_optarg"       ;;
        --localstatedir=*) localstatedir="$apc_optarg" ;;
        --enable-*)
            apc_feature=`echo $apc_option | sed -e 's/-*enable-//' -e 's/=.*//'`
            apc_feature=`echo $apc_feature | sed 's/-/_/g'`
            case "$apc_option" in
                *=*) ;;
                  *) apc_optarg=yes ;;
            esac
            case "$apc_feature" in
                rule   )
                    apc_optarg=`echo "$apc_optarg" | tr "A-Z" "a-z"`
                    eval "rule_${apc_optarg}=yes"
                    ;;
                module ) 
                    case $apc_optarg in
                       all ) 
                           for module in `echo "$modules" | sed -e 's/^://' | tr ":" "\n"`;
do
                               eval "module_${module}=yes" 
                           done
                           ;;
                       * ) 
                           eval "module_${apc_optarg}=yes" 
                           ;;
                    esac
                    ;;
            esac
            ;;
        --disable-*)
            apc_feature=`echo $apc_option | sed -e 's/-*disable-//' -e 's/=.*//'`
            apc_feature=`echo $apc_feature| sed 's/-/_/g'`
            case "$apc_option" in
                *=*) ;;
                  *) apc_optarg=yes ;;
            esac
            case "$apc_feature" in
                rule   ) 
                    apc_optarg=`echo "$apc_optarg" | tr "A-Z" "a-z"`
                    eval "rule_${apc_optarg}=no"
                    ;;
                module )
                    case $apc_optarg in
                       all ) 
                           for module in `echo "$modules" | sed -e 's/^://' | tr ":" "\n"`;
do
                               eval "module_${module}=no" 
                           done
                           ;;
                       * ) 
                           eval "module_${apc_optarg}=no" 
                           ;;
                    esac
                    ;;
            esac
            ;;
    esac
done
if [ -n "$apc_prev" ]; then
    echo "configure:ERROR: missing argument to --`echo $apc_prev | sed 's/_/-/g'`" 1>&2
    exit 1
fi


##
##  configure the source tree
##

#   display version information
if [ $quiet = no ]; then
    APV=`cat src/include/httpd.h |\
         grep "#define SERVER_BASEVERSION" |\
         sed -e 's/^[^"]*"//' -e 's/".*$//' -e 's/^Apache\///'`
    echo "Configuring for Apache, Version $APV"
fi

#   expand path variables
for var in exec_prefix bindir sbindir \
           libexecdir mandir sysconfdir datadir localstatedir; do
    eval "val=\$$var";
    eval "$var=\"$val$subdir\""
    case $var in
       sysconfdir|datadir|localstatedir ) 
           eval "val=\$$var"
           case $val in
               *apache | *apache* ) ;;
               * ) eval "$var=\$$var/apache" ;;
           esac
           ;;
    esac
done

#   determine path to Perl interpreter
PERL=no-perl-on-this-system
for dir in `echo $PATH | tr ":" "\n"`; do
    for exe in perl5 perl miniperl; do
         if test -f "$dir/$exe"; then
             if test -x "$dir/$exe"; then
                 PERL="$dir/$exe"
             fi
         fi
    done
done

#   create Makefile from Makefile.in
if [ $quiet = no ]; then
    echo "Creating Makefile"
fi
sed <Makefile.tmpl >Makefile \
-e "s%@PERL@%$PERL%g" \
-e "s%@prefix@%$prefix%g" \
-e "s%@exec_prefix@%$exec_prefix%g" \
-e "s%@bindir@%$bindir%g" \
-e "s%@sbindir@%$sbindir%g" \
-e "s%@libexecdir@%$libexecdir%g" \
-e "s%@mandir@%$mandir%g" \
-e "s%@sysconfdir@%$sysconfdir%g" \
-e "s%@datadir@%$datadir%g" \
-e "s%@localstatedir@%$localstatedir%g"

#   override default paths in src/include/httpd.h
CFLAGS="$CFLAGS '-DHTTPD_ROOT=\"$prefix\"'"
CFLAGS="$CFLAGS '-DDEFAULT_PIDLOG=\"$localstatedir/run/httpd.pid\"'"
CFLAGS="$CFLAGS '-DDEFAULT_SCOREBOARD=\"$localstatedir/run/httpd.scoreboard\"'"
CFLAGS="$CFLAGS '-DDEFAULT_LOCKFILE=\"$localstatedir/run/httpd.lock\"'"
CFLAGS="$CFLAGS '-DDEFAULT_XFERLOG=\"$localstatedir/logs/access_log\"'"
CFLAGS="$CFLAGS '-DDEFAULT_ERRORLOG=\"$localstatedir/logs/error_log\"'"
CFLAGS="$CFLAGS '-DTYPES_CONFIG_FILE=\"$sysconfdir/mime.types\"'"
CFLAGS="$CFLAGS '-DSERVER_CONFIG_FILE=\"$sysconfdir/httpd.conf\"'"
CFLAGS="$CFLAGS '-DACCESS_CONFIG_FILE=\"$sysconfdir/access.conf\"'"
CFLAGS="$CFLAGS '-DRESOURCE_CONFIG_FILE=\"$sysconfdir/srm.conf\"'"

#   create src/Configuration.gen file
if [ $quiet = no ]; then
    echo "Creating Configuration.gen in src"
fi
rm -f sedsubst 2>/dev/null
touch sedsubst
for var in CFLAGS LDFLAGS LIBS INCLUDES CC OPTIM RANLIB; do
    eval "val=\$$var";
    if [ ".$val" != . ]; then
        case $var in 
            CFLAGS|LDFLAGS|LIBS|INCLUDES) var="EXTRA_$var" ;;
        esac
        echo "-e s%^#*\\($var=\\).*%\\1$val%g" >>sedsubst
    fi
done
for rule in `echo "$rules" | sed -e 's/^://' | tr ":" "\n"`; do
    name="`echo $rule | tr "a-z" "A-Z"`"
    eval "val=\$rule_$rule"
    echo "-e s%^\\(Rule $name=\\).*%\\1$val%g" >>sedsubst
done
for module in `echo "$modules" | sed -e 's/^://' | tr ":" "\n"`; do
    eval "add=\$module_$module"
    if [ $add = yes ]; then
        echo "-e s%^.*\\(AddModule.*$module\\..*\\)%\\1%g" >>sedsubst
    else
        echo "-e s%^.*\\(AddModule.*$module\\..*\\)%# \\1%g" >>sedsubst
    fi
done
sed `cat sedsubst` <src/Configuration.tmpl >src/Configuration.gen
rm -f sedsubst 2>/dev/null

#   create all other Makefiles by running 
#   the src/Configure script 
if [ $quiet = yes ]; then
    (cd src; ./Configure -file Configuration.gen >/dev/null);
else
    (cd src; ./Configure -file Configuration.gen |\
     sed -e '/^Using config file:.*/d' \
         -e 's/Makefile in /Makefile in src\//' \
         -e 's/Makefile$/Makefile in src/')
fi

===aux/mkdir.sh================================================================
#!/bin/sh
## 
##  mkdir.sh -- make directory hierarchy
##
##  Based on `mkinstalldirs' from Noah Friedman <friedman@prep.ai.mit.edu>
##  as of 1994-03-25, which was placed in the Public Domain
##

errstatus=0
for file in ${1+"$@"} ; do 
    set fnord `echo ":$file" |\
               sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'`
    shift
    pathcomp=
    for d in ${1+"$@"}; do
        pathcomp="$pathcomp$d"
        case "$pathcomp" in
            -* ) pathcomp=./$pathcomp ;;
        esac
        if test ! -d "$pathcomp"; then
            echo "mkdir $pathcomp" 1>&2
            mkdir "$pathcomp" || errstatus=$?
        fi
        pathcomp="$pathcomp/"
    done
done
exit $errstatus

===aux/install.sh================================================================
#!/bin/sh
##
##  install.sh -- install a program, script or datafile
##
##  Based on `install-sh' from the X Consortium's X11R5 distribution
##  as of 89/12/18 which is freely available.
##

#
#   put in absolute paths if you don't have them in your path; 
#   or use env. vars.
#
mvprog="${MVPROG-mv}"
cpprog="${CPPROG-cp}"
chmodprog="${CHMODPROG-chmod}"
chownprog="${CHOWNPROG-chown}"
chgrpprog="${CHGRPPROG-chgrp}"
stripprog="${STRIPPROG-strip}"
rmprog="${RMPROG-rm}"

#
#   parse argument line
#
instcmd="$mvprog"
chmodcmd=""
chowncmd=""
chgrpcmd=""
stripcmd=""
rmcmd="$rmprog -f"
mvcmd="$mvprog"
src=""
dst=""
while [ ".$1" != . ]; do
    case $1 in
        -c) instcmd="$cpprog"
            shift; continue
            ;;
        -m) chmodcmd="$chmodprog $2"
            shift; shift; continue
            ;;
        -o) chowncmd="$chownprog $2"
            shift; shift; continue
            ;;
        -g) chgrpcmd="$chgrpprog $2"
            shift; shift; continue
            ;;
        -s) stripcmd="$stripprog"
            shift; continue;;
        *)  if [ ".$src" = . ]; then
                src=$1
            else
                dst=$1
            fi
            shift; continue
            ;;
    esac
done
if [ ".$src" = . ]; then
     echo "install.sh: no input file specified"
     exit 1
fi
if [ ".$dst" = . ]; then
     echo "install.sh: no destination specified"
     exit 1
fi

#
#  If destination is a directory, append the input filename; if
#  your system does not like double slashes in filenames, you may
#  need to add some logic
#
if [ -d $dst ]; then
    dst="$dst/`basename $src`"
fi

#  Make a temp file name in the proper directory.
dstdir=`dirname $dst`
dsttmp=$dstdir/#inst.$$#

#  Move or copy the file name to the temp name
$instcmd $src $dsttmp

#  And set any options; do chmod last to preserve setuid bits
if [ ".$chowncmd" != . ]; then $chowncmd $dsttmp; fi
if [ ".$chgrpcmd" != . ]; then $chgrpcmd $dsttmp; fi
if [ ".$stripcmd" != . ]; then $stripcmd $dsttmp; fi
if [ ".$chmodcmd" != . ]; then $chmodcmd $dsttmp; fi

#  Now rename the file to the real destination.
$rmcmd $dst
$mvcmd $dsttmp $dst

exit 0


Mime
View raw message