autoconf: use AS_INIT_GENERATED to generate a script in a subdirectory

90 views Asked by At

How can I use AS_INIT_GENERATE to generate a script that is not in the same directory as the configure script, in particular so that VPATH builds will be honoured?

For example, for a configure.ac file containing

AC_PREREQ([2.68])
AC_INIT([example],[0.1])
AS_INIT_GENERATED([src/file.sh]) || AS_EXIT
AC_OUTPUT

running the commands

~ $ autoreconf .
~ $ mkdir build && cd build
~/build $ ../configure

results in the error message

../configure: line 1648: src/file.sh: No such file or directory
../configure: line 1655: src/file.sh: No such file or directory

I guess I'd have to make sure that the src directory exists before I call AS_INIT_GENERATE to create src/file.sh, or maybe I'm doing it all wrong?

1

There are 1 answers

2
Jack Kelly On BEST ANSWER

Try something like this:

AC_PREREQ([2.68])
AC_INIT([example],[0.1])
test -d src || AS_MKDIR_P([src]) dnl <----- Create 'src' if it doesn't exist.
AS_INIT_GENERATED([src/file.sh]) || AS_EXIT
AC_OUTPUT