This question extends question How to handle subprojects with autotools?
So I have some project with its own Makefile (not GNU autotools) in
modules/libfoo
I added SUBDIRS = include/jsonbox Makefile.am and it compiles fine, but only if I invoke ./configure and make from top dir.
If I create a subdir, say build, and run ../configure from it I got an error during make:
Making all in modules/libfoo
/bin/sh: line 17: cd: modules/libfoo: No such file or directory
make: *** [all-recursive] Error 1
Is it possible to handle this? I need several build dirs for different archs and CFLAGS.
EDIT:
As it sugected in docs I created a GNUmakefile.in in a nested project. But it still doesn’t work with VPATH:
Making all in modules/libfoo
make[1]: Entering directory `/home/galadog/test/build/moudles/libfoo'
GNUmakefile:2: Makefile: No such file or directory
make[1]: *** No rule to make target `Makefile'. Stop.
make[1]: Leaving directory `/home/galadog/test/build/moudles/libfoo'
make: *** [all-recursive] Error 1
Edit2
The actual Makefile can be seen here:
https://github.com/anhero/JsonBox/blob/master/Makefile
Sadly, you can’t achieve this correctly without either:
The docs you linked are mostly focused on working around the issues with
make distcheck, without supporting actual builds.There’s, however, one simple hack which would work with minimal work required — it is to copy the whole sub-tree to the build directory. It is not a very good solution but it will make sub-tree builds working:
But as I said, it’s ugly. The upstream Makefile still needs to define correct automake targets (
all,installetc.), so in your case you would as well to need to add aGNUmakefilein the project subdir like:which would provide a dummy target to avoid
*** No rule to make target 'install'; and possibly that as well. ThenEXTRA_DISTif you want to usemake distbut that’s all covered in the linked doc.Honestly, you’re on a slippery ground. If I were you, I would either simply not use that project and ignore it because maintaining it will be harder than writing the same thing from scratch.
The second solution I would consider, and one which would work correct would be to duplicate the Makefile in your main
Makefile.amand not use recursive automake for that subdirectory: