From 2ce3c2d25d2ea5f3ab53683cc8eb7bd81b602c9a Mon Sep 17 00:00:00 2001 From: Paul McCarthy <pauldmccarthy@gmail.com> Date: Thu, 6 Aug 2020 12:06:40 +0100 Subject: [PATCH] RF: Honour compilation flags defined in the environment --- config/buildSettings.mk | 32 ++++++++++++------------ config/common/vars.mk | 54 ++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 41 deletions(-) diff --git a/config/buildSettings.mk b/config/buildSettings.mk index 695449c..aa95394 100644 --- a/config/buildSettings.mk +++ b/config/buildSettings.mk @@ -12,14 +12,14 @@ SYSTYPE := $(shell uname -s) # Standard commands # ##################################################################### -SHELL = /bin/sh -RM = /bin/rm -CP = /bin/cp -MV = /bin/mv -CHMOD = /bin/chmod -MKDIR = /bin/mkdir -INSTALL = install -p -TCLSH = ${FSLDIR}/bin/fsltclsh +SHELL ?= /bin/sh +RM ?= /bin/rm +CP ?= /bin/cp +MV ?= /bin/mv +CHMOD ?= /bin/chmod +MKDIR ?= /bin/mkdir +INSTALL ?= install -p +TCLSH ?= ${FSLDIR}/bin/fsltclsh ##################################################################### # @@ -53,10 +53,10 @@ ARCHLIBS = ifeq ($(SYSTYPE), Darwin) # Commands -CC = cc -CXX = c++ -CXX11 = clang++ -RANLIB = ranlib +CC ?= cc +CXX ?= c++ +CXX11 ?= clang++ +RANLIB ?= ranlib # Compiler flags ARCHCXXFLAGS += -arch x86_64 -O3 -ansi -Wall -pedantic @@ -87,10 +87,10 @@ endif # if Darwin ifeq ($(SYSTYPE), Linux) # Commands -CC = gcc -CXX = c++ -CXX11 = c++ -RANLIB = echo +CC ?= gcc +CXX ?= c++ +CXX11 ?= c++ +RANLIB ?= echo # Compiler flags ARCHCFLAGS += -m64 -fPIC -O3 -fexpensive-optimizations \ diff --git a/config/common/vars.mk b/config/common/vars.mk index d211aec..2c8426f 100644 --- a/config/common/vars.mk +++ b/config/common/vars.mk @@ -7,38 +7,38 @@ PROJNAME = # Project-specific compiler/linker flags - these # can be overridden in the project Makefile -USRLDFLAGS = +USRLDFLAGS = USRINCFLAGS = -USRCFLAGS = +USRCFLAGS = USRCXXFLAGS = -LIBS = +LIBS = # Project outputs - these variables control # what gets installed from a project. May # be customised/overridden in project # Makefiles -HFILES = *.h -AFILES = *.a -SOFILES = *.so -XFILES = -SCRIPTS = -TCLFILES = *.tcl -MANFILES = man/* +HFILES = *.h +AFILES = *.a +SOFILES = *.so +XFILES = +SCRIPTS = +TCLFILES = *.tcl +MANFILES = man/* TESTXILES = # Final install destinations for project outputs -DESTDIR = ${FSLDEVDIR} -dest_INCDIR = ${DESTDIR}/include -dest_LIBDIR = ${DESTDIR}/lib -dest_BINDIR = ${DESTDIR}/bin -dest_MANDIR = ${DESTDIR}/man -dest_TCLDIR = ${DESTDIR}/tcl -dest_DOCDIR = ${DESTDIR}/doc +DESTDIR = ${FSLDEVDIR} +dest_INCDIR = ${DESTDIR}/include +dest_LIBDIR = ${DESTDIR}/lib +dest_BINDIR = ${DESTDIR}/bin +dest_MANDIR = ${DESTDIR}/man +dest_TCLDIR = ${DESTDIR}/tcl +dest_DOCDIR = ${DESTDIR}/doc dest_REFDOCDIR = ${DESTDIR}/refdoc # Standard header/library locations for compiling/linking -INCDIR = ${FSLDIR}/include -LIBDIR = ${FSLDIR}/lib +INCDIR = ${FSLDIR}/include +LIBDIR = ${FSLDIR}/lib DEVINCDIR = ${FSLDEVDIR}/include DEVLIBDIR = ${FSLDEVDIR}/lib @@ -49,6 +49,11 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR} # Final compiler/linker flags ############################# +# Honour any flags provided by the environment +CFLAGS ?= +CXXFLAGS ?= +LDFLAGS ?= + # All projects must use these flags for # compilation/linking, using the form: # @@ -57,9 +62,8 @@ INCFLAGS = ${USRINCFLAGS} -I. -I${DEVINCDIR} -I${INCDIR} # # LDFLAGS *must* come at the end, to ensure proper linking. -LDFLAGS = ${ARCHLDFLAGS} ${USRLDFLAGS} \ - -L. -L${DEVLIBDIR} -L${LIBDIR} \ - ${LIBS} ${ARCHLIBS} - -CFLAGS = ${ARCHCFLAGS} ${USRCFLAGS} ${USRINCFLAGS} ${INCFLAGS} -CXXFLAGS = ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${USRINCFLAGS} ${INCFLAGS} +LDFLAGS += ${ARCHLDFLAGS} ${USRLDFLAGS} \ + -L. -L${DEVLIBDIR} -L${LIBDIR} \ + ${LIBS} ${ARCHLIBS} +CFLAGS += ${ARCHCFLAGS} ${USRCFLAGS} ${INCFLAGS} +CXXFLAGS += ${ARCHCXXFLAGS} ${USRCXXFLAGS} ${INCFLAGS} -- GitLab