b9cb06b Improve compiler flag handling

Authored and Committed by andyp a year ago
    Improve compiler flag handling
    
    Autoconf recommends against using CFLAGS to set global compiler flags
    and in fact it causes us problems because CFLAGS is implicitly added at
    the end of the compiler flags, so there's no room for overriding the
    global options (which is meant to be CFLAGS's purpose). The same applies
    to CPPFLAGS.
    
    Instead, set AM_CFLAGS and AM_CPPFLAGS in configure.ac. Autoconf
    provides the "AM_CFLAGS = @AM_CFLAGS@" substitution to set the make
    variable so that is not required. We no longer have to save and restore
    the user-provided CFLAGS in configure.ac manually. The downside is that
    when a program_CFLAGS per-target variable is defined, AM_CFLAGS does not
    get implicitly added, so set that manually in cases where it's needed.
    
    With this patch, CFLAGS can be set at configure time and at build time
    (e.g. 'make CFLAGS=-fsanitize=address') to augment the "global" compiler
    options and we also have the ability to augment them on a per-target
    basis, as the "global" flags are no longer appended to the end of the
    compiler options implicitly.
    
    Signed-off-by: Andrew Price <anprice@redhat.com>
    
        
file modified
+14 -8
file modified
+2 -0
file modified
+2 -0
file modified
+2 -0
file modified
+2 -0
file modified
+1 -1
file modified
+1 -0
file modified
+6 -2
file modified
+2 -0
file modified
+2 -0