I am stuck with a strange variable expansion. Let me explain.
I have a project that uses automake, composed by configure.ac
, Makefile.am
.
Basically, in Makefile.am
I'm doing:
ARCH = $(shell ${CURDIR}/./arch.sh)
...
noinst_HEADERS = license/${ARCH}/lchecker.h
proj_SOURCES = main.c license/${ARCH}/lchecker.c
proj_LDFLAGS = -avoid-version -Llicense/${ARCH}
./arch is doing just uname -m
to determine the architecture needed, because I have to enter the correct directory.
When I run the build, I have this error:
Makefile:622: license/x86_64/.deps/lchecker.Po: No such file or directory
make[1]: *** No rule to make target 'license/x86_64/.deps/lchecker.Po'. Stop.
and if I enter the license
directory, I notice a new dir created called ${ARCH}/
where I find the missing .deps
from license/x86_64
.
I'm pretty sure it is an incorrect expansion problem; I've tried many ways but I failed.
Can anyone explain to me the right way to do this? Reading around the net I see that Makefile.am
has a different syntax from Makefile
.
UPDATE:
I tried to add some changes to see if the variable is corretly defined:
AC_DEFINE([ARCH], ["$ARCH"], [arch check])
echo ARCH = "$ARCH"
printf x86_64
so the variable in defined in configure.ac, but the expansion is not correct again in Makefile.am.
In your configure.ac
, use the macro AC_SUBST(varname,[value])
to create a make-variable varname
in each the generated makefiles that will
have the value to which value
was evaluated at the time when the makefile was generated.
value
may be a shell-expansion. So e.g.
AC_SUBST(ARCH,[`./arch.sh`])
in configure.ac
will create in each makefile the assignment:
ARCH = x86_64
assuming that x86_64
is the standard output of ./arch.sh
at ./configure
-time
in the build directory. You may then assume that this variable is so assigned
in your Makefile.am
and write the like of:
noinst_HEADERS = license/${ARCH}/lchecker.h