Re: [dev] Reasonable Makefiles

From: Nick <>
Date: Mon, 10 Mar 2014 16:35:57 -0400

Quoth Nick:
> Basically because I'm replacing a autotools horrorshow with
> plain make, but am not sure what the nicest way of allowing compile-
> time feature disabling is. Can 'ifdef' be relied upon, and does it
> tend to produce unreadable and buggy makefiles in anyone's
> experience? Are there other options, beyond asking people to comment
> out certain lines in a, to e.g. disable some LDFLAGS?

So I changed my goal slightly to just do basic build variable
adjustments based on the system.

I ended up creating a bourne script called config.uname, which sets
a few sensible defaults for weird systems (like OSX & solaris), and
appends them to the, on first compilation. So that they
can still be changed by editing if you want, and they're
not hidden away in some 'ifeq' using included Makefile.

So the Makefile has this:

all: autoconfig $(BIN)

        sh config.uname >>
        touch $_AT_

and config.uname is a shell script along these lines:



case $os in
        Darwin )
                echo 'Configuring for Darwin' >&2
                echo '# Extra configuration for Darwin (from config.uname)'
                echo 'EXTRA_CPPFLAGS = -I/opt/local/include'

It seems to me like a pretty reasonable and usable way of doing some
basic autoconfiguration for different systems.

Comments, anyone?

Received on Mon Mar 10 2014 - 21:35:57 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 10 2014 - 21:48:06 CET