views:

147

answers:

1

hi all

i created a configure.ac file like this: AC_INIT() set

the purpose of this is to print every available environment variable the configure script creates using 'set' so i do:

user@host:~$ autoconf
user@host:~$ ./configure

which prints a bunch of variables like

build=
cache_file=/dev/null
IFS='   
'
LANG=C
LANGUAGE=C
datarootdir='${prefix}/share'
mandir='${datarootdir}/man'
no_create=

so far so good the problem is:

  1. i want to expand the variables like '${prefix}/share' - but pipeing everything in a file 'example.sh' and execute it using bash doesnt work cause bash claims about modifying read only variables like UID and expansion itself doesnt seem to work either
  2. i tried using a makefile for this where expansion works, but it claims about newlines in strings, like in the above output the line IFS=' causes an error message Makefile:24: *** missing separator. Stop.

anyone has a brighter idea to get a fully expanded version of configures output?

thx all

+2  A: 

The Autoconf manual (I cannot recall or find exactly where) recommends to "manually" do such a kind of variable substitution from within a Makefile.in (or .am if you happen to use Automake):

Makefile.in

[...]
foo.sh: foo.sh.in
        $(SED) \
            -e 's|[@]prefix@|$(prefix)|g' \
            -e 's|[@]exec_prefix@|$(exec_prefix)|g' \
            -e 's|[@]bindir@|$(bindir)|g' \
            -e 's|[@]datarootdir@|$(datarootdir)|g' \
            < "$<" > "$@"
[...]

foo.sh.in

#!/bin/sh
datarootdir=@datarootdir@
du "$datarootdir"
ndim