shithub: rgbds

Download patch

ref: f9a1aba0d8c5b718d02ea7824670bbf6eb6f50be
parent: fe65e07cb6812424869bf069ea1e9b0f721a6e15
author: Antonio Niño Díaz <[email protected]>
date: Sat Jul 15 16:10:28 EDT 2017

Allow CFLAGS to be modified from make command line

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 <[email protected]>

--- a/Makefile
+++ b/Makefile
@@ -16,8 +16,13 @@
 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 @@
 	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 @@
 .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.