I'm not a fan of autoconf, but in the interest of principle of least surprise, I'm trying to make my (non-autoconf) configure scripts behave as closely as possible to what users expect from an autoconf-based build system. The GNU coding standards are actually rather reasonable on this topic, and explicitly mention the possibility of not using autoconf/automake but providing a compatible interface in another way:
https://www.gnu.org/prep/standards/standards.html#Configuration
One issue I cannot find any good description of, however, is how to best handle CFLAGS. It's clear to me that any essential flags (like -I$(srcdir)/inc
) that are none of the user's business don't belong in CFLAGS in either the configure script or the makefile, as overriding them would completely break the build. So these I've either hard-coded in the makefile, or (if they require some detection) put the detection logic in configure, but passed them through a separate make variable instead of CFLAGS so they won't get overridden.
What I'm still unclear on how to handle best, though, is optional things like optimization levels/options, warning flags, debugging, etc. Should flags enabled by things like --enable-debug
or --enable-warnings
get added to CFLAGS
or passed in some other make variable? What if they conflict with flags already in user-provided CFLAGS
?
I can see where for a lot of projects the answer might should just be "don't mess with that at all and let the user choose their CFLAGS
", but some of my usage cases are projects where the user base is generally interested in having out-of-the-box optimized and debugging configurations.
Edit: Another issue I forgot: when it comes to detecting and automatically using certain CFLAGS that aren't essential but preferred, should this be done only if the user left CFLAGS
blank in the environment, or always?