Hi Steve, On Fri, 30 Aug 2002 13:07:06 -0500 Stephen Sanders <ssanders@ku.edu> wrote concerning "Help needed with conditionals in Makefile.am": > Hi, > This is mostly directed to Christian, but maybe someone else will > also know the answer: > > On Christian's suggestion, I've finally managed to get a stub class > compiled and linked as both a dynamic library and as a loadable > module on Mac OSX. I would now like to work through the brat > Makefile.am files to produce both libraries and loadable modules > for OSX. However, I'm having trouble seeing how to do this so that > a OSX build will coexist with the normal build instructions. > > What somewhat works is the following: > > ------configure.in------- > > AC_INIT(foo.cc) > AM_INIT_AUTOMAKE(foo, 1.0) > AM_CONDITIONAL(MACOSX, test `root-config --arch` = macosx ) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ The right way to do it, though you should use the architecture spotted by `config.guess' and avaliable in the configure file has `$host', rather than the one deduced by ROOT. Try echoing out `$host' to see what it is on your MacOSX platform. > -----Makefile.am----- > AM_CPPFLAGS := `root-config --cflags` > ROOTCONFIG = `root-config --glibs` Don't do this. Just use the variable `$(ROOTCONF)' or the subsitution variable `@ROOTCONF@' directly. That is, like AM_CPPFLAGS = -I@ROOTINCDIR@ ROOTALLLIBS = -L@ROOTLIBDIR@ @ROOTGLIBS@ @ROOTAUXLIBS@ which ofcourse regquires you use the autoconf macro `ROOT_PATH' in the `configure.in' script. Get it from `build/misc/root.m4' in the ROOT source tree, or in `<datadir>/aclocal/root.m4' in the installation directory. > if MACOSX > pkglib_LTLIBRARIES = libfoo.la libfoo2.la > libfoo2_la_SOURCES = foo.cxx foodict.cc > libfoo2_la_LDFLAGS = -module -no-version $(ROOTCONFIG) > else > pkglib_LTLIBRARIES = libfoo.la > endif This won't work, as you saw. Instead do: if MACOSX MODULE = foo.la else MODULE = endif pkglib_LTLIBRARIES = libfoo.la $(MODULE) libfoo_la_SOURCES = foo.cxx foodict.cxx libfoo_la_LDFLAGS = -version-info 0:0:0 -L@ROOTLIBDIR@ libfoo_la_LIBADD = @ROOTGLIBS@ @ROOTAUXLIBS@ foo_la_SOURCES = foo.cxx foodict.cxx foo_la_LDFLAGS = -module -avoid-version -L@ROOTLIBDIR@ foo_la_LIBADD = @ROOTGLIBS@ @ROOTAUXLIBS@ The problem is, that primaries, like `LTLIBRARIES' can not be defined conditionatlly, but can contain conditional variables. This will give you /usr/lib/foo/libfoo.so.0.0.0 /usr/lib/foo/libfoo.so.0 -> libfoo.so.0.0.0 /usr/lib/foo/libfoo.so -> libfoo.so.0 /usr/lib/foo/libfoo.la /usr/lib/foo/foo.so /usr/lib/foo/foo.la Now, you can in a portable way load the library/module libfoo.so/foo.so in ROOT by doing gSystem->Load("foo"); as TSystem::Load will prepend "lib" it self, and try various types of endings like .so, .sl, .dll, .a I've put an example here [1] > However, I have the following problems: > For MacOSX > >>The loadable module library ends up with the name libfoo2.so. I > need to get this renamed to libfoo.so Erh, not really do you? Then the binaries that are in fact linked against the library will use the loadable module, and not the shared library. > >>automake complains about libfoo.la already being defined. It > appears that it does this check BEFORE > evaluating the conditional. This has to do with the conditional definition of a primary. > Is there a cleaner way of handing conditionals? One that works!? Oh, it does work, you just have to do it right :-) Take a look in the Automake manual, as well as the `Goat book' [2] In the example I made, I used an `--enable-module/--disable-module' to emulate compiling on MacOSX or something else, but it's the same however you define your condition. Yours, ____ | Christian Holm Christensen |_| | ------------------------------------------------------------- | | Address: Sankt Hansgade 23, 1. th. Phone: (+45) 35 35 96 91 _| DK-2200 Copenhagen N Cell: (+45) 24 61 85 91 _| Denmark Office: (+45) 353 25 305 ____| Email: cholm@nbi.dk Web: www.nbi.dk/~cholm | | [1] http://www.nbi.dk/~cholm/foo-1.0.tar.gz [2] http://sources.redhat.com/autobook/
This archive was generated by hypermail 2b30 : Mon Sep 02 2002 - 05:58:00 EDT