coin-or-tools / BuildTools

Macros and patches for GNU autotools
https://coin-or-tools.github.io/BuildTools/
Other
3 stars 7 forks source link

Questions about current master #134

Closed tkralphs closed 4 years ago

tkralphs commented 4 years ago

I have a few questions regarding the proper setup with the BuildTools master branch (the "new" build system).

  1. Why is XYZ_BUILD now defined by manually adding a compiler flag in Makefile.am instead of being added to the list of compiler flags automatically in coin.m4 as previously? The previous way seemed easier, but maybe just shifting the complexity out of coin.m4?
  2. Where do we properly add extra directories where headers can be found? SYMPHONY has it's headers in a separate include direectory, not in src. I used to add that extra directory to DEFAULT_INCLUDES, but autoconf now complains about this. I'm currently adding them to AM_CPPFLAGS directly, but this is related to the next question.
  3. Should we add additional flags (such as XyzLib_CFLAGS and such) to AM_CPPFLAGS or directly to libXyz_la_CPPFLAGS? There seems to be a mix of practices going on in Cbc. For example, we have
    libCbc_la_CPPFLAGS = -DCBC_BUILD $(CBCLIB_CFLAGS)

    but then later, we have

    AM_CPPFLAGS += $(CBCGENERIC_CFLAGS)

    Either way seems to work, but just want to have some canonical way of doing it across all projects that is uniform.

  4. At one time, we were defining libXyz_la_DEPENDENCIES, but now we aren't doing that anymore. Everything seems to work fine, but I just wanted to understand the change.

I'm having some other issues with SYMPHONY, but I'm trying to work those out and then will post about it separately.

svigerske commented 4 years ago

One may have several XYZ_BUILD within one project, in particular when several libraries are build, and it's important to get only the right XYZ_BUILD defined at the right places. Maybe it would be possible to just add -DXYZ_BUILD to XYZ_CFLAGS (again). One would need to try this. I don't remember whether there was an obstacle.

The automake manual suggests to add our -I flags to AM_CPPFLAGS. DEFAULT_INCLUDES is set by autoconf to a useful value. I don't know what autoconf complains if you add to or reset DEFAULT_INCLUDES, but it should be ok to just add to AM_CPPFLAGS.

AM_CPPFLAGS is the one that is shared among all libraries and programs within one Makefile. For Cbc/src/Makefile, there are two libraries (libCbc and libCbcSolver) that need slightly different compiler flags (the XYZ_BUILD) and so I put the flags into the library-specific libXyz_la_CPPFLAGS. Maybe cbc_generic_CPPFLAGS = $(CBCGENERIC_CFLAGS) would work, too. But in simpler cases, setting AM_CPPFLAGS is preferable, I think.

automake tries to define libXyz_la_DEPENDENCIES automatically if possible. I believe that it takes the conent of LIBADD or LDADD and picks the name of actual libraries from it and removes other linker flags. This works in easy cases where the libraries are known at time where automake is run. If variables are used in LIBADD or LDADD which value is only known after configure is run, then the libraries in these variables do not make it into the dependencies. This was a problem for the monolithic builds, because a change of, e.g., Clp, did not trigger a rebuild of Cbc, and so libXyz_la_DEPENDENCIES was specified explicitly. But now that we build only against installed projects, it seems normal to only track dependencies within a project. If you install new version of the Clp library (without header changes), a make in Cbc will probably not trigger relinking of cbc anymore, but this wouldn't be expected behavior anymore. Though, with libtool and the dependencies tracking in the .la files, maybe there is some other magic happening.

tkralphs commented 4 years ago

Thanks for the thorough reply. It all makes sense, except for one thing. According to the documentation (and according to my own experience now with SYMPHONY), Ant specified _CPPFLAGS variable over-rides AM_CPPFLAGS (not adds to it). AM_CPPFLAGS are more like a default set rather than a base set. Since the libraries and the binaries all have _CPPFLAGS variables in the Cbc setup, it looks to me like AM_CPPFLAGS are always ignored.

svigerske commented 4 years ago

OK, I'll have a look into Cbc in the next days.

tkralphs commented 4 years ago

I'll close this for now unless you want it as a reminder to look at Cbc.

svigerske commented 4 years ago

f7285e1e6 adds -DXYZ_BUILD into XYZ_CFLAGS.