build: Improve handling of compiler options.
authorAndre Noll <maan@tuebingen.mpg.de>
Sun, 25 Apr 2021 22:56:16 +0000 (00:56 +0200)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 28 Apr 2021 21:16:13 +0000 (23:16 +0200)
Introduce LLS_CFLAGS and STRICT_CFLAGS to avoid duplicating the flags
in the various cc recipes. We don't touch CFLAGS or CPPFLAGS in the
Makefile but include it the cc commands to let the user override
our settings.

Makefile

index 31c2102a940a2ec372f78d5906e9da48852d6fc7..f7e19fb8901d98dbfd90965f521b892bc45cdc0e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -95,13 +95,16 @@ lsg_objs := lopsubgen.o lsg.o lopsubgen.lsg.o lopsub.o version.o
 liblopsub_objs := config_file.o lopsub.o version.o
 lopsubex_objs := lopsubex.o lopsubex.lsg.o $(liblopsub_objs)
 
 liblopsub_objs := config_file.o lopsub.o version.o
 lopsubex_objs := lopsubex.o lopsubex.lsg.o $(liblopsub_objs)
 
+LLS_CFLAGS := -g -fPIC
+STRICT_CFLAGS := -Wall
+
 $(lsg_objs) $(liblopsub_objs) $(lopsubex_objs): %.o: %.c
 lopsubgen.o config_file.o:
 $(lsg_objs) $(liblopsub_objs) $(lopsubex_objs): %.o: %.c
 lopsubgen.o config_file.o:
-       $(CC) -g -c -fPIC -o $@ ${@:.o=.c}
+       $(CC) $(CPPFLAGS) $(LLS_CFLAGS) $(CFLAGS) -c -o $@ ${@:.o=.c}
 lsg1.o: lsg.c lsg.h
 lsg1.o: lsg.c lsg.h
-       $(CC) -g -DSTAGE1 -Wall -c $< -o $@
+       $(CC) $(CPPFLAGS) $(LLS_CFLAGS) $(STRICT_CFLAGS) $(CFLAGS) -DSTAGE1 -c -o $@ $<
 %.o: %.c
 %.o: %.c
-       $(CC) -Wall -I. -g -c -fPIC -o $@ $<
+       $(CC) -I. $(CPPFLAGS) $(LLS_CFLAGS) $(STRICT_CFLAGS) $(CFLAGS) -c -o $@ $<
 
 # linking
 lopsubgen-stage1: $(lsg1_objs)
 
 # linking
 lopsubgen-stage1: $(lsg1_objs)