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 this:
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:
${prefix}/share
- but piping
everything to a file example.sh
and executing it using bash doesn't work, because bash complains about modifying read-only variables like UID
and expansion itself doesn't seem to work either.makefile
for this where expansion works, but it complains about newlines in strings, like in the above output the line IFS=' causes an error message Makefile:24: *** missing separator. Stop.
Does anyone have an idea how to get a fully expanded version of configure's output?
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With