From f9a1aba0d8c5b718d02ea7824670bbf6eb6f50be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Ni=C3=B1o=20D=C3=ADaz?= Date: Sat, 15 Jul 2017 20:10:28 +0100 Subject: [PATCH] Allow CFLAGS to be modified from make command line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, if the user wanted to modify CFLAGS, it was necessary to add the options used in the Makefile as well, which doesn't make sense. This patch splits CFLAGS into CFLAGS and the previously removed REALCFLAGS so that the user can modify the arguments passed to the compiler without having to worry about things like passing the list of include directories. Signed-off-by: Antonio Niño Díaz --- Makefile | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 6bc164e4..cc2f55d6 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,12 @@ PNGLDFLAGS := `${PKG_CONFIG} --static --libs-only-L libpng` PNGLDLIBS := `${PKG_CONFIG} --static --libs-only-l libpng` WARNFLAGS := -Wall -Werror -CFLAGS := ${WARNFLAGS} -g -std=c99 -D_POSIX_C_SOURCE=200809L -Iinclude + +# Overridable CFLAGS +CFLAGS := -g +# Non-overridable CFLAGS +REALCFLAGS := ${CFLAGS} ${WARNFLAGS} -std=c99 -D_POSIX_C_SOURCE=200809L \ + -Iinclude YFLAGS := LFLAGS := --nounistd @@ -77,16 +82,16 @@ rgbgfx_obj := \ src/extern/err.o rgbasm: ${rgbasm_obj} - $Q${CC} ${CFLAGS} -o $@ ${rgbasm_obj} -lm + $Q${CC} ${REALCFLAGS} -o $@ ${rgbasm_obj} -lm rgblink: ${rgblink_obj} - $Q${CC} ${CFLAGS} -o $@ ${rgblink_obj} + $Q${CC} ${REALCFLAGS} -o $@ ${rgblink_obj} rgbfix: ${rgbfix_obj} - $Q${CC} ${CFLAGS} -o $@ ${rgbfix_obj} + $Q${CC} ${REALCFLAGS} -o $@ ${rgbfix_obj} rgbgfx: ${rgbgfx_obj} - $Q${CC} ${CFLAGS} ${PNGLDFLAGS} -o $@ ${rgbgfx_obj} ${PNGLDLIBS} + $Q${CC} ${REALCFLAGS} ${PNGLDFLAGS} -o $@ ${rgbgfx_obj} ${PNGLDLIBS} # Rules to process files @@ -96,11 +101,11 @@ rgbgfx: ${rgbgfx_obj} .l.o: $Q${RM} $*.c $Q${LEX} ${LFLAGS} -o $*.c $< - $Q${CC} ${CFLAGS} -c -o $@ $*.c + $Q${CC} ${REALCFLAGS} -c -o $@ $*.c $Q${RM} $*.c .c.o: - $Q${CC} ${CFLAGS} ${PNGCFLAGS} -c -o $@ $< + $Q${CC} ${REALCFLAGS} ${PNGCFLAGS} -c -o $@ $< # Target used to remove all files generated by other Makefile targets.