You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl-cvs@perl.apache.org by do...@hyperreal.org on 1998/05/20 03:28:36 UTC

cvs commit: modperl/apaci Makefile.libdir Makefile.tmpl README libperl.module mod_perl.config mod_perl.config.sh

dougm       98/05/19 18:28:36

  Added:       apaci    Makefile.libdir Makefile.tmpl README libperl.module
                        mod_perl.config mod_perl.config.sh
  Log:
  APACI support added [Ralf S. Engelschall <rs...@engelschall.com>]
  
  Revision  Changes    Path
  1.1                  modperl/apaci/Makefile.libdir
  
  Index: Makefile.libdir
  ===================================================================
  This is a place-holder which indicates to Configure that it shouldn't
  provide the default targets when building the Makefile in this directory.
  Instead it'll just prepend all the important variable definitions, and
  copy the Makefile.tmpl onto the end.
  
  
  
  1.1                  modperl/apaci/Makefile.tmpl
  
  Index: Makefile.tmpl
  ===================================================================
  ##
  ##  Makefile.tmpl -- Makefile template for mod_perl (Apache-side)
  ##  Written by Ralf S. Engelschall <rs...@apache.org>
  ##
  
  #   Reassemble mod_perl parameters
  #   from Perl and Apache parameters
  MP_CC=$(PERL_CC)
  MP_CFLAGS=$(PERL_OPTIMIZE) $(PERL_CCFLAGS) $(PERL_INC) \
            $(PERL_DEFS) $(INCLUDES) $(CFLAGS)
  MP_CFLAGS_SHLIB=$(PERL_CCCDLFLAGS) $(MP_CFLAGS)
  MP_LD=$(PERL_LD)
  MP_LDFLAGS_SHLIB=$(PERL_LDDLFLAGS)
  MP_LIBS=$(PERL_LIBS)
  MP_XSUBPP=$(PERL_XSUBPP)
  MP_XSINIT=$(PERL_XSINIT)
  MP_RM=rm -f
  MP_AR=$(PERL_AR)
  MP_RANLIB=$(PERL_RANLIB)
  MP_STATIC_EXTS=$(PERL_STATIC_EXTS)
  MP_STATIC_SRCS=$(PERL_STATIC_SRCS)
  MP_STATIC_OBJS=$(PERL_STATIC_OBJS)
  MP_STATIC_OBJS_PIC=$(PERL_STATIC_OBJS_PIC)
  MP_LIBS=$(PERL_LIBS)
  
  ##
  ##  ____ DO NOT CHANGE ANYTHING BELOW THIS LINE ______________________
  ##
  
  #   the library to build
  MP_LIB=libperl.$(LIBEXT)
  
  #   the objects to use
  MP_OBJS=\
     mod_perl.o perlxsi.o perl_config.o perl_util.o perlio.o \
     $(MP_STATIC_OBJS)
  MP_OBJS_PIC=\
     mod_perl.lo perlxsi.lo perl_config.lo perl_util.lo perlio.lo \
     $(MP_STATIC_OBJS_PIC)
  
  all: lib
  
  lib: $(MP_LIB)
  
  libperl.a: $(MP_OBJS)
  	$(MP_RM) $@
  	$(MP_AR) crv $@ $(MP_OBJS)
  	$(MP_RANLIB) $@
  
  libperl.so: $(MP_OBJS_PIC)
  	$(MP_RM) $@
  	$(MP_LD) $(MP_LDFLAGS_SHLIB) -o $@ $(MP_OBJS_PIC) $(MP_LIBS)
  
  .SUFFIXES: .xs .c .o .lo
  
  .c.lo:
  	$(MP_CC) $(MP_CFLAGS_SHLIB) -c $< && mv $*.o $*.lo
  
  .c.o:
  	$(MP_CC) $(MP_CFLAGS) -c $<
  
  .xs.c:
  	$(MP_XSUBPP) $*.xs >$@
  
  perlxsi.c:
  	$(MP_XSINIT) -- -o perlxsi.c -std $(MP_STATIC_EXTS)
  
  clean:
  	$(MP_RM) $(MP_LIB)
  	$(MP_RM) $(MP_OBJS) 
  	$(MP_RM) $(MP_OBJS_PIC) 
  	$(MP_RM) $(MP_STATIC_SRCS)
  	$(MP_RM) perlxsi.c 
  
  distclean: clean
  	$(MP_RM) Makefile
  
  #   FOR STAND-ALONE BUILDING ONLY
  install:
  	$(APXS) -i -a -n perl libperl.so
  
  depend:
  	cp Makefile.tmpl Makefile.tmpl.bak \
  	    && sed -ne '1,/^# DO NOT REMOVE/p' Makefile.tmpl > Makefile.new \
  	    && gcc -MM $(INCLUDES) $(CFLAGS) *.c >> Makefile.new \
  	    && sed -e '1,$$s: $(INCDIR)/: $$(INCDIR)/:g' \
  	           -e '1,$$s: $(OSDIR)/: $$(OSDIR)/:g' Makefile.new \
  		> Makefile.tmpl \
  	    && rm Makefile.new
  
  # Dependencies
  $(MP_OBJS) $(MP_OBJS_PIC): Makefile
  
  # DO NOT REMOVE
  
  
  
  1.1                  modperl/apaci/README
  
  Index: README
  ===================================================================
  
    Description
    -----------
  
    This is the Apache-side of mod_perl. It is a hybrid build environment which
    can be both used to build mod_perl inside the Apache source tree via APACI
    or plain Configure script and outside the Apache source tree via the DSO
    tool APXS.
  
    Files
    -----
  
    README .............. this file
    Makefile.tmpl ....... Makefile template for Apache 1.3
    Makefile.libdir ..... indicator file for Apache 1.3 to use Makefile.tmpl
    configure ........... stand-alone configure script for APXS situation
    libperl.module ...... sourced Configure inline-script for standard situation
    mod_perl.config ..... the new mod_perl configuration file
    mod_perl.config.sh .. the workhorse which parses the config files and
                          generates Makefile parameters out of it by
                          extending the given parameters with Perl information
  
    Usage
    -----
  
    o Build mod_perl statically with httpd 
      _inside_ the Apache source tree via APACI:
  
      1. run perl Makefile.PL USE_APACI=1
         (this will:
          - copy apaci/* and src/modules/perl/* to $APACHE_SRC/modules/perl
          - generate $APACHE_SRC/modules/perl/mod_perl.config
         )
      2. Configure Apache while activating mod_perl
         $ cd $APACHE_SRC
         $ ./configure --activate-module=src/modules/perl/libperl.a
      3. Build and Install Apache with mod_perl
         $ make
         $ make install
  
    o Build mod_perl as a dynamic shared object (DSO) 
      _inside_ the Apache source tree via APACI:
  
      1. Move these mod_perl sources to $APACHE_SRC/src/modules/perl/
      2. Configure Apache while activating mod_perl
         $ cd $APACHE_SRC
         $ ./configure --activate-module=src/modules/perl/libperl.a \
                       --enable-shared=perl
      3. Build and Install Apache with mod_perl
         $ make
         $ make install
  
    o Build mod_perl as a dynamic shared object (DSO) 
      _outside_ the Apache source tree via APXS:
  
      1. Configure mod_perl via APXS
         $ ./configure [--with-apxs=/path/to/installed/apache/sbin/apxs]
      2. Build mod_perl DSO and install it into Apache installation
         $ make install
  
    Configuration
    -------------
  
    The configuration of mod_perl takes place via the file mod_perl.config.
    Either edit this file, accept the defaults or override it via either
  
      $ MODPERL_CONFIG='PERL=/path/to/my/preferred/bin/perl, PERL_SSI=yes'
      $ export MODPERL_CONFIG
      $ ./configure ...
  
    at the APACI configuration step or via
  
      $ ./configure ... 'PERL=/path/to/my/preferred/bin/perl, PERL_SSI=yes'
  
    at the local configuration step when using the APXS variant.
  
    Implemenation
    -------------
  
    Here is a flow control of the configuration:
  
    APACI variant:                                     APXS variant: 
    
    $ MODPERL_CONFIG=...                               $ ./configure ...
    $ cd $APACHE_SRC                                         |
    ./configure ...                                          |
          |                   mod_perl.config                |
          |exec                      |                       |exec
          |                          |read                   |
          V          exec            V                       |
     libperl.module  ------> mod_perl.config.sh <------------+
                                     |
                                     |
                                     V
                            (Makefile parameters)
                                     | 
                                     + 
                                Makefile.tmpl
                                     |
                                     |
                                     V
                                  Makefile
                                     
    Actually the merging of the Makefile parameters and the Makefile.tmpl is a
    little bit more complex: When using APACI the parameters are first stored in
    Apache's Makefile.config and then get merged with Makefile.tmpl by Apache's
    Configure in a later step while when using the APXS variants they are
    immediately stored in Makefile by our configure script together with
    Makefile.tmpl.
  
  
  
  1.1                  modperl/apaci/libperl.module
  
  Index: libperl.module
  ===================================================================
  ##
  ##  libperl.module -- mod_perl Apache source tree stub
  ##  Written by Ralf S. Engelschall <rs...@apache.org>
  ##
  ##  This script is _sourced_ by Apache's src/Configure script
  ##  while configuring the module subdirectories. We can use
  ##  two variables here to find ourself: $modfile, $modbase.
  ##  Additionally because we run inside src/Configure's namespace
  ##  we can directly adjust CFLAGS, LIBS, etc.
  ##
  
  Name: perl_module
  ConfigStart
  
      #   paths   
      my_dir="`echo ${modfile} | sed -e 's:/[^/]*$::'`"
      my_config="${my_dir}/mod_perl.config"
      my_config_sh="${my_dir}/mod_perl.config.sh"
      my_outfile="Makefile.config"
      my_prefix="      +"
  
      #   determine requested build-type
      case $modfile in
          *.so ) 
              my_buildtype="DSO"
              ;;
          *.a  ) 
              my_buildtype="OBJ"
              ;;
      esac
      echo "$my_prefix mod_perl build type: $my_buildtype"
  
      #   import MODPERL_CONFIG environment variable
      my_config_override=''
      if [ ".$MODPERL_CONFIG" != . ]; then
          my_config_override="$MODPERL_CONFIG"
      fi
  
      #   transform mod_perl config into Makefile config
      echo "$my_prefix setting up mod_perl build environment"
      $my_config_sh --config-file=$my_config \
                    --config-override="$my_config_override" \
                    --build-type=$my_buildtype \
                    --display-prefix="$my_prefix" >>$my_outfile
  
      #   additionally adjust the Apache build environment
      echo "$my_prefix adjusting Apache build environment"
      CFLAGS="$CFLAGS -DMOD_PERL"
      if [ ".$my_buildtype" = .OBJ ]; then
          my_perl_libs="`egrep '^PERL_LIBS=' $my_outfile | tail -1 | awk -F= '{ print $2 }'`"
          LIBS="$LIBS $my_perl_libs"
      fi
      if [ ".`egrep '^PERL_SSI=yes' $my_outfile`" != . ]; then
          echo "$my_prefix enabling Perl support for SSI (mod_include)"
          CFLAGS="$CFLAGS -DUSE_PERL_SSI"
          my_perl_inc="`egrep '^PERL_INC=' $my_outfile | tail -1 | awk -F= '{ print $2 }'`"
          INCLUDES="$INCLUDES -I\$(SRCDIR) $my_perl_inc"
      fi
  
  ConfigEnd
  
  
  
  
  1.1                  modperl/apaci/mod_perl.config
  
  Index: mod_perl.config
  ===================================================================
  ##
  ##  mod_perl.config -- mod_perl shared configuration file
  ##
  
  #   mod_perl version
  MOD_PERL_VERSION = 1.11_01-dev
  
  #   Perl interpreter to use 
  PERL = DEFAULT
  
  #   Apache hooks to use
  PERL_DISPATCH          = yes
  PERL_CHILD_INIT        = yes
  PERL_CHILD_EXIT        = yes
  PERL_RESTART           = yes
  PERL_POST_READ_REQUEST = yes
  PERL_TRANS             = yes
  PERL_HEADER_PARSER     = yes
  PERL_ACCESS            = yes
  PERL_AUTHEN            = yes
  PERL_AUTHZ             = yes
  PERL_TYPE              = yes
  PERL_FIXUP             = yes
  PERL_LOG               = yes
  PERL_INIT              = yes
  PERL_CLEANUP           = yes
  PERL_STACKED_HANDLERS  = yes
  PERL_SECTIONS          = yes
  PERL_METHOD_HANDLERS   = yes
  
  #   special triggers
  PERL_SSI    = no
  PERL_TRACE  = no
  
  #   Modules to compile statically into mod_perl
  PERL_STATIC_EXTS = Apache Apache::Constants Apache::ModuleConfig
  PERL_STATIC_SRCS = Apache.c Constants.c ModuleConfig.c
  
  
  
  
  1.1                  modperl/apaci/mod_perl.config.sh
  
  Index: mod_perl.config.sh
  ===================================================================
  ##
  ##  mod_perl.config.sh -- mod_perl configuration transformation script
  ##  Written by Ralf S. Engelschall <rs...@apache.org>
  ##
  
  DIFS=' 	
  '
  
  #   defaults
  config_file='mod_perl.config'
  build_type='OBJ'
  display_prefix=''
  tmpfile1=".tmp.$$.1"
  tmpfile2=".tmp.$$.2"
  
  #
  #   parse argument line
  #
  prev=''
  OIFS="$IFS" IFS="$DIFS"
  for option
  do
      if [ ".$prev" != . ]; then
          eval "$prev=\$option"
          prev=""
          continue
      fi
      case "$option" in
          -*=*) optarg=`echo "$option" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
             *) optarg='' ;;
      esac
      case "$option" in
          --config-file=*)     config_file="$optarg"    ;;
          --config-override=*) config_override="$optarg" ;;
          --build-type=*)      build_type="$optarg"     ;;
          --display-prefix=*)  display_prefix="$optarg" ;;
          * ) echo "$0:Error: invalid option '$option'" 1>&2; exit 1 ;;
      esac
  done
  IFS="$OIFS"
  if [ ".$prev" != . ]; then
      echo "$0:Error: missing argument to --`echo $prev | sed 's/_/-/g'`" 1>&2
      exit 1
  fi
  
  
  #
  #   import parameters from config file into
  #   own namespace to avoid conflicts with src/Configure
  #
  (cat $config_file; echo "$config_override" | sed -e 's:,[ 	]*:,:' | tr "," "\n") >$tmpfile1
  vars="`egrep '^[A-Z0-9_]*[ 	]*=' $tmpfile1 | sed -e 's:^\([A-Z0-9_]*\).*:\1:'`"
  OIFS="$IFS" IFS="$DIFS"
  for var in $vars; do
      egrep "^${var}[ 	]*=" $tmpfile1 | tail -1 >$tmpfile2
      val="`sed -e 's:^[A-Z0-9_]*[ 	]*=[ 	]*::' <$tmpfile2`"
      eval "param_${var}=\"${val}\""
  done
  IFS="$OIFS"
  
  #
  #   verbose message
  #
  echo "$display_prefix id: mod_perl/$param_MOD_PERL_VERSION" 1>&2
  
  #
  #   determine Perl interpreter and version
  #
  perl_interp="$param_PERL"
  if [ ".$perl_interp" = .DEFAULT ]; then
      if [ ".$PERL" != . ]; then
          perl_interp="$PERL"
      else 
          perl_interp=""
      fi
  fi
  if [ ".$perl_interp" = . ]; then
      OIFS=$IFS IFS=':'
      for my_dir in $PATH; do
          for my_exe in perl5 perl; do
              if test -f "$my_dir/$my_exe"; then
                  if test -x "$my_dir/$my_exe"; then
                      perl_interp="$my_dir/$my_exe"
                      break 2
                  fi
              fi
          done
      done
      IFS="$OIFS"
      perl_interp="`echo $perl_interp | sed -e 's://:/:'`"
  fi
  perl_version="`$perl_interp -e 'print $];'`"
  os_version="`$perl_interp -e 'print $^O;'`"
  
  #
  #   verbose message
  #
  echo "$display_prefix id: Perl/$perl_version ($os_version) [$perl_interp]" 1>&2
  
  #
  #   determine build tools and flags  
  #
  perl_cc="`$perl_interp -MConfig -e 'print $Config{cc}'`"
  perl_ccflags="`$perl_interp -MConfig -e 'print $Config{ccflags}'`"
  perl_optimize="`$perl_interp -MConfig -e 'print $Config{optimize}'`"
  perl_cccdlflags="`$perl_interp -MConfig -e 'print $Config{cccdlflags}'`"
  perl_ld="`$perl_interp -MConfig -e 'print $Config{ld}'`"
  perl_ldflags="`$perl_interp -MConfig -e 'print $Config{ldflags}'`"
  perl_lddlflags="`$perl_interp -MConfig -e 'print $Config{lddlflags}'`"
  cat >$tmpfile2 <<'EOT'
  use Config;
  my $ldopts = `$^X -MExtUtils::Embed -e ldopts -- -std @ARGV`;
  $ldopts =~ s,(-bE:)(perl\.exp),$1$Config{archlibexp}/CORE/$2, if($^O eq "aix");
  print $ldopts;
  EOT
  perl_libs="`$perl_interp $tmpfile2`"
  perl_inc="`$perl_interp -MExtUtils::Embed -e perl_inc`"
  perl_privlibexp="`$perl_interp -MConfig -e 'print $Config{privlibexp}'`"
  perl_archlibexp="`$perl_interp -MConfig -e 'print $Config{archlibexp}'`"
  perl_xsinit="$perl_interp -MExtUtils::Embed -e xsinit"
  perl_xsubpp="$perl_interp ${perl_privlibexp}/ExtUtils/xsubpp -typemap ${perl_privlibexp}/ExtUtils/typemap"
  perl_ar="`$perl_interp -MConfig -e 'print $Config{ar}'`"
  perl_ranlib=`$perl_interp -MConfig -e 'print $Config{ranlib}'`
  
  #
  #   determine static objects
  #
  perl_static_exts="$param_PERL_STATIC_EXTS"
  perl_static_srcs="$param_PERL_STATIC_SRCS"
  perl_static_objs="`echo $param_PERL_STATIC_SRCS | sed -e 's:\.c:.o:g'`"
  perl_static_objs_pic="`echo $param_PERL_STATIC_SRCS | sed -e 's:\.c:.lo:g'`"
  
  #
  #   determine defines
  #
  perl_defs=''
  perl_defs="$perl_defs -DMOD_PERL_VERSION=\\\"$param_MOD_PERL_VERSION\\\""
  perl_defs="$perl_defs -DMOD_PERL_STRING_VERSION=\\\"mod_perl/$param_MOD_PERL_VERSION\\\""
  OIFS="$IFS" IFS="$DIFS"
  for hook in \
      DISPATCH CHILD_INIT CHILD_EXIT RESTART POST_READ_REQUEST TRANS HEADER_PARSER \
      ACCESS AUTHEN AUTHZ TYPE FIXUP LOG INIT CLEANUP STACKED_HANDLERS SECTIONS \
      METHOD_HANDLERS SSI TRACE; do
      eval "val=\$param_PERL_${hook}"
      if [ ".$val" = .no ]; then
          perl_defs="$perl_defs -DNO_PERL_${hook}=1"
      fi
  done
  IFS="$OIFS"
  
  #
  #   output information as Makefile parameters
  #
  echo "PERL=$perl_interp"
  echo "PERL_CC=$perl_cc"
  echo "PERL_OPTIMIZE=$perl_optimize"
  echo "PERL_CCFLAGS=$perl_ccflags"
  echo "PERL_CCCDLFLAGS=$perl_cccdlflags"
  echo "PERL_DEFS=$perl_defs"
  echo "PERL_INC=$perl_inc"
  echo "PERL_LD=$perl_ld"
  echo "PERL_LDFLAGS=$perl_ldflags"
  echo "PERL_LDDLFLAGS=$perl_lddlflags"
  echo "PERL_LIBS=$perl_libs"
  echo "PERL_XSINIT=$perl_xsinit"
  echo "PERL_XSUBPP=$perl_xsubpp"
  echo "PERL_AR=$perl_ar"
  echo "PERL_RANLIB=$perl_ranlib"
  echo "PERL_STATIC_EXTS=$perl_static_exts"
  echo "PERL_STATIC_SRCS=$perl_static_srcs"
  echo "PERL_STATIC_OBJS=$perl_static_objs"
  echo "PERL_STATIC_OBJS_PIC=$perl_static_objs_pic"
  
  echo "PERL_SSI=$param_PERL_SSI"
  
  #
  #  cleanup
  #
  rm -f $tmpfile1 $tmpfile2