On Thu, 8 Aug 2002, Brian Candler wrote:
> I am trying to make a single configuration file which behaves differently
> depending on flags set in a master config file.
My goodness, people want more and more features, don't they? :-)
> Essentially what I am trying to simulate is:
>
> .include /etc/config # contains "FOO=yes" (or may not)
>
> .ifdef FOO # or .if FOO=yes
> ...series of lines
> .endif
One of the reasons that I never implemented such complications is the
design of Exim. It exec()s very often, and each time it reads its
configuration file. That's why I never implemented .include until people
made so much fuss that I gave in.
> Does anyone know of a way to achieve what I want? My attempts so far are
> documented below :-)
I play games in my test suite by using -D, but not as flexibly as you
want. In my case the "...series of lines" is usually just one line that
is expanded, so you can use -D to control the expansion.
> FOO=configure-foo
> .include /usr/exim/FOO
> # Nope: says 'failed to open included configuration file /usr/exim/FOO'
That one *might* be relatively easy to change (I haven't looked at the
code). I'll take a look at it when I can. At present, it does .include
processing before macro processing.
> FOO=.include /usr/exim/configure-foo
> FOO
> # Nope: says 'main option "" unknown'
That I think would automatically get fixed if I fix the first one - i.e.
if macro expansion happened before noticing .include
> FOO=#
> FOO .include /usr/exim/configure-foo
>
> works as expected, but
>
> FOO=
> FOO .include /usr/exim/configure-foo
>
> fails with 'main option "" unknown'
Again that's related to the order of processing.
All these points noted for looking at in due course, but don't hold your
breath.
Philip
--
Philip Hazel University of Cambridge Computing Service,
ph10@??? Cambridge, England. Phone: +44 1223 334714.