You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Ralf S. Engelschall" <rs...@engelschall.com> on 1998/08/04 17:00:57 UTC

[ANNOUNCE] Apache C-style Pre-Processor (ACPP)

Every day some new stuff - I know I'm boring... ;-)
Today I want to direct your attention to a tarball named

  acpp-1.3.1-1.0.0.tar.gz 

which I've placed under (the CONTRIBution area)

  ftp://ftp.apache.org/apache/dist/contrib/misc/

It's a package which can be semi-automatically applied to a fresh Apache 1.3.1
source tree and provides a C-style pre-processor (CPP) for the Apache
configuration files.

What's the intend? Some time ago we already discussed that blowing up httpd
itself with stuff like <IfModule>, <IfDefine>, etc.  is acceptable to some
degree but we don't want even more. OTOH there are situation where one at
least wants e.g. macros to bundle some complicated functionality. For instance
bundling virtual host sections, complex rewrite rules, etc.

Because we now don't want to blow up httpd any more with such stuff,
there are only two options remaining:

  1. Using a real run-time pre-processor (ala C/C++ & CPP)
  2. Using an off-line config file generation tool (ala Sendmail & m4)

Approach 2) has the drawback that you have for instance httpd.conf.in and
httpd.conf files staying around and you have to remind you not to read
(because they're unreadable) or even edit the httpd.conf file.  Instead you
then work with httpd.conf.in, only. Hmmm... too strange because a too large
transition for the typical situation. Approach 1) is nicer here: As long as
you don't want any advanced configuration features you don't have to use them.
And when you want to use them you can directly use them inside httpd.conf.
And because the "unreadable" expanded version (think about expanded includes
and macros) is only internally seen by httpd, one also isn't confused.

Ok, lets try approach 1) and give httpd a nice pre-processor for the config
files. I decided to use the CPP from the LCC distribution, because both
license issues (GPL software cannot be used inside Apache, etc) and
portability (-Wall-cleaness is minimum) were my major goals (Initially I used
an extracted CPP from GCC 2.7.2.2 but it's GPL and its source is a real
nightmare). The CPP from LCC is tiny, fast and I was able to adjust it
internally to fit our special situation. Special, why? Because we already use
sharp-comments in our configuration files and these give to be accepted by the
CPP instead of interpreted as #xxx directives.

So, httpd is blown up only minimally: A new -P option to enable the
preprocessor and a corresponding -I option to set some additional paths for
the #include directives. And, VERY IMPORTANT, the config line reading stuff
was extended to recognize the line control (#line X "XXXX") which the
pre-processor generates (that's why BSD m4 is not an option, it doesn't
generate it and GNU m4 is GPL). Because error messages have to be show the
correct location, even inside include files and even when macros expand a lot
of stuff.

How can you play with it (extracted from the README):

  1. You need a fresh Apache source tree of a particular Apache 1.3.x
     version. Which one you can determine from the VERSION file of the ACPP
     distribution: The contents 1.3.x+1.y.z indicated that this is ACPP/1.y.z
     for Apache/1.3.x and hence you need a fresh extracted apache_1.3.x.tar.gz
     tarball. 
     
     In short:
     
     $ lynx -dump http://www.apache.org/dist/apache_1.3.x.tar.gz
     $ gunzip -c apache_1.3.x.tar.gz | tar xvf -

  2. You need the extracted ACPP distribution:

     $ gunzip -c apache-1.3.x-acpp-1.y.z.tar.gz | tar xvf -

  3. Apply the ACPP source extension and patches to the Apache source tree:

     $ cd apache-1.3.x-acpp-1.y.z
     $ ./configure --with-apache=../apache_1.3.x

  4. Now you can switch to the Apache source tree and proceed as
     usual. The difference is just that you now have an additional
     configuration rule available named `USE_ACPP' which can be
     used to build and install Apache with ACPP.

     In short:

     $ cd ../apache_1.3.x
     $ ./configure --prefix=/path/to/apache/install \
                   --enable-rule=USE_ACPP \
                   ...
     $ make
     $ make install

  5. Your installed Apache should behave exactly as the original
     Apache. But you now have two additional command line options available:
     -P for enabling the configuration pre-processor and -I for setting
     include paths for its #include directive. So, read your preferred ANSI C
     reference manual about pre-processor directives and bask in the glow with
     your new toy ;_)

That's all. If you have any suggestions, let it me know.

Oh yes, BTW, as you already noticed because of an external distribution
instead of a "[PATCH]" posting: I don't even try to incorporate this into the
official Apache source tree, because I'm sure some people exists who would
vote -1 because of whatever reasons. So, don't ask why exactly I created a
stand-alone distribution out of it. It's mainly because I want to avoid any
hot discussions about blowing up the source and not blowing up the source ;-)

                                       Ralf S. Engelschall
                                       rse@engelschall.com
                                       www.engelschall.com

Re: [ANNOUNCE] Apache C-style Pre-Processor (ACPP)

Posted by Dean Gaudet <dg...@arctic.org>.
but... but... I just use m4.  Other folks use perl.  More powerful than
cpp :)

Dean