0
votes

In my Automake project I have a certain number of sub-packages among which I want to switch depending on a configure time option. According to the Automake documentation this is possible: https://www.gnu.org/software/automake/manual/html_node/Subdirectories-with-AC_005fSUBST.html

So I am doing the following:

# configure.ac

if test_condition_1 ; then
    SUBDIR_TO_BUILD=dir1
elif test_condition_2 ; then 
    SUBDIR_TO_BUILD=dir2
else
    SUBDIR_TO_BUILD=dir3
fi

AC_SUBST(SUBDIR_TO_BUILD)
...

# Makefile.am
SUBDIR_TO_BUILD=@SUBDIR_TO_BUILD@
SUBDIRS=$(SUBDIR_TO_BUILD)
DIST_SUBDIRS=dir1 dir2 dir3
...

However, if I try running autoreconf I get the following error:

Makefile.am:4: error: required directory $(SUBDIR_TO_BUILD) does not exist
1

1 Answers

0
votes

Actually, I realised the above works. What I was really doing in the specific was to AC_SUBST a component of the subdirectory path rather than the full subdirectory path and assemble the final path in SUBDIRS as follows:

# Makefile.am
SUBDIR_TO_BUILD=@SUBDIR_TO_BUILD@
SUBDIRS=external/$(SUBDIR_TO_BUILD)
DIST_SUBDIRS=external/dir1 external/dir2 external/dir3
...

This causes the error. Although, I am not sure why the first works while the second does not.