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 config.mk, 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 config.mk, on first compilation. So that they 
can still be changed by editing config.mk if you want, and they're 
not hidden away in some 'ifeq' using included Makefile.

So the Makefile has this:

all: autoconfig $(BIN)

autoconfig:
        sh config.uname >> config.mk
        touch $@

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

#!/bin/sh

os=`uname`

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

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

Comments, anyone?

Nick

Reply via email to