Added COMMON_ADD Makefile facility

Added the makefile variable ${COMMON_ADD} that will add flags
to all compile and link commands. The ${COMMON_ADD} flags are
appended to both ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}.  This
facility is available to nearly all platforms except those with
very old make comamnds that do not understand the += operator.

Example on masOS (Darwin), one may invoke clang's -fsanitize
facility by:

    make clobber all COMMON_ADD='-fsanitize=undefined -fsanitize=address'

Another example.  To force C warnings to be treated as errors:

    make COMMON_ADD='-Werror'
This commit is contained in:
Landon Curt Noll
2017-05-23 02:08:33 -07:00
parent 44ffb0eec9
commit 188fd372ea
3 changed files with 256 additions and 2 deletions

View File

@@ -522,6 +522,23 @@ LD_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
#
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use gcc's -Werror to force warnings
# to become errors, call make with:
#
# make .. COMMON_ADD='-Werror'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
#if 0 /* start of skip for non-Gnu makefiles */
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
#endif /* end of skip for non-Gnu makefiles */
#
CCWARN= -Wall
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
@@ -572,6 +589,24 @@ LD_STATIC= ${DARWIN_ARCH}
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
#
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use clang's -fsanitize for calc testing,
# which requires a common set of flags to be passed to
# every compile and link, then call make with:
#
# make .. COMMON_ADD='-fsanitize=undefined -fsanitize=address'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
#if 0 /* start of skip for non-Gnu makefiles */
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
#endif /* end of skip for non-Gnu makefiles */
#
CCWARN= -Wall
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
@@ -635,6 +670,23 @@ LD_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
#
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use gcc's -Werror to force warnings
# to become errors, call make with:
#
# make .. COMMON_ADD='-Werror'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
#if 0 /* start of skip for non-Gnu makefiles */
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
#endif /* end of skip for non-Gnu makefiles */
#
CCWARN= -Wall
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
@@ -680,6 +732,23 @@ LD_STATIC=
LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
#
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use gcc's -Werror to force warnings
# to become errors, call make with:
#
# make .. COMMON_ADD='-Werror'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
#if 0 /* start of skip for non-Gnu makefiles */
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
#endif /* end of skip for non-Gnu makefiles */
#
CCWARN= -Wall
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
@@ -719,6 +788,23 @@ LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
LD_STATIC=
#
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use gcc's -Werror to force warnings
# to become errors, call make with:
#
# make .. COMMON_ADD='-Werror'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
#if 0 /* start of skip for non-Gnu makefiles */
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
#endif /* end of skip for non-Gnu makefiles */
#
CCWARN= -Wall
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
@@ -756,6 +842,23 @@ LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
LD_STATIC=
#
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use gcc's -Werror to force warnings
# to become errors, call make with:
#
# make .. COMMON_ADD='-Werror'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
#if 0 /* start of skip for non-Gnu makefiles */
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
#endif /* end of skip for non-Gnu makefiles */
#
CCWARN= -Wall
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long
@@ -896,6 +999,23 @@ LIBCALC_STATIC=
LIBCUSTCALC_STATIC=
LD_STATIC=
#
# If you want to add flags to all compiler and linker
# run (via ${COMMON_CFLAGS} and ${COMMON_LDFLAGS}),
# set ${COMMON_ADD}.
#
# For example to use gcc's -Werror to force warnings
# to become errors, call make with:
#
# make .. COMMON_ADD='-Werror'
#
# This facility requires a Gnu Makefile, or a make command
# that understands the += make operand.
#
#if 0 /* start of skip for non-Gnu makefiles */
COMMON_CFLAGS+= ${COMMON_ADD}
COMMON_LDFLAGS+= ${COMMON_ADD}
#endif /* end of skip for non-Gnu makefiles */
#
CCWARN= -Wall
WNO_IMPLICT= -Wno-implicit
WNO_ERROR_LONG_LONG= -Wno-error=long-long