On 10/28/2012 12:00 PM, Vincent Torri wrote: > On Sun, Oct 28, 2012 at 11:57 AM, Stefano Lattarini > <[email protected]> wrote: >> On 10/28/2012 11:34 AM, Vincent Torri wrote: >>> Hey >>> >>> Our project build some modules as shared lib. We added the possibility >>> to statically link them to the library with autoconf. We then define >>> BUILD_STATIC automake conditionnal to select what we want. The tree >>> directories are: >>> >>> src/lib <--- where the lib is >>> src/module <-- where the module is. >>> >>> * in src/module/Makefile.am: >>> >>> if ! BUILD_STATIC >>> >>> pkg_LTLIBRARIES = module.la >>> module_la_SOURCES = foo.c >>> >>> else >>> >>> noinst_LTLIBRARIES = mylib_module.la >>> mylib_module_la_SOURCES = foo.c >>> >>> endif >>> >>> * and in src/lib/Makefile.am >>> >>> if BUILD_STATIC >>> >>> SUBDIRS += ../module >>> >> Yikes! Recursing into a sibling directory, rather than just children >> ones, is asking for problems IMO. >> >>> mylib_la_LIBADD += ../module/mylib_module.la >>> >>> endif >>> >>> It works well, until I use the maintainer-clean rule. Indeed, because >>> of the SUBDIRS in src/lib/Makefile.am, maintainer-clean is launched >>> twice, hence an error as there is no Makefile anymore in src/module >>> when the 2nd maintainer-clean rule is executed. >>> >>> I also tried this in src/lib/Makefile.am: >>> >>> if BUILD_STATIC >>> >>> mylib_la_SOURCES += ../module/foo.c >>> >>> endif >>> >>> but then same kind of error, with foo.Plo in src/module/.deps when the >>> 2nd maintainer-clean rule is launched : that file does not exist >>> anymore >>> >>> Does someone know what I have to do ? >>> >> My advice: re-organize your build system to avoid recursive make >> invocations where not actually necessary. > > that's the second version above in src/lib/Makefile.am : I add to > mylib_la_SOURCES the file that is in another directory, so no > SUBDIRS,right ? > Ah OK, but in general having '..' components in a _SOURCES entry can be problematic. IMHO you should write a Makefile.am in src/ that builds objects and libraries in both the src/lib and src/modules subdirectories, and get rid of the Makefile.am files in both those subdirs.
HTH, Stefano
