[kea-dev] Makefile.am guideline

Stephen Morris stephen at isc.org
Mon Sep 14 11:48:09 UTC 2015


On 03/09/2015 13:24, Francis Dupont wrote:
> This is a proposal for a new Makefile.am section of coding guidelines.
> 
> First when there is a least a subdirectory the SUBDIRS entry, e.g.:
> SUBDIRS = . tests

Suggest a slight rephrasing of this:

+++
If there is are one or more subdirectories, the first line in the file
should be the SUBDIRS entry, e.g.

SUBDIRS = . test

If relevant (as is usually the case), the current directory should be
included in the list at the appropriate point in the list.
---

> Followed by AM_CPPFLAGS set to source and build tree at the second level
> and external dependency includes and CPPFLAGS, e.g.:
> AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
> AM_CPPFLAGS += $(BOOST_INCLUDES)

Again, a slight rephrasing is suggested:

+++
Next should be the setting of the AM_CPPFLAGS, which applies to every
module built with C++ in the Makefile.am, e.g.

AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_builddir)/src/lib
AM_CPPFLAGS += $(BOOST_INCLUDES)

This can be overriden on a per-module basis in the file by specifying
the variable module_CPPFLAGS.  (Note that if the CPPFLAGS environment
variable is set, its flags are appended to the command line after
AM_CPPFLAGS.)
---

> Directory variables should be relative (i.e., no abs_top_builddir)
> for efficiency.

[Question: why is this?]

> Third (or more) levels should not be used, e.g.:

Suggest: "To make the files easier to understand, third (or more) levels
should not be used, e.g."

> NO += -I$(top_srcdir)/src/lib/dns -I$(top_builddir)/src/lib/dns
> 
> AM_CXXFLAGS should be initialized to KEA_CXXFLAGS, e.g.:
> AM_CXXFLAGS = $(KEA_CXXFLAGS)

I would add a sentence explaining the difference between the "CPPFLAGS"
and "CXXFLAGS" variables, as both end up on the C++ command line.

> When executables are build, AM_LDFLAGS must be conditionally set
> to static, e.g.:
> if USE_STATIC_LINK
> AM_LDFLAGS = -static
> endif

OK

> At the exception of archives, (dynamic) libraries and executables should

s/At the exception/With the exception/

> be linked with all dependencies in the opposite order of src/lib/Makefile.am
> for shared libraries (so finishing by libkea-exceptions.la) followed
> y external dependencies. The idea is to not rely on libtool which has
> shown some problems handling dependencies.
> 
> Dynamic Shared Objects built as modules to be dynamically loaded must have
> no dependency when static linking is enforced: their undefined symbols
> should be resolved using executables they are loaded into.
> 
> PS: please comment/improve if you think this should not go as it is
> into coding guidelines.

It's a good start.  Let's put it in the coding guidelines.  We can
always add to it/modify it as needed.

Stephen



More information about the kea-dev mailing list