From 02ef2ff1ef9ac55ec1d910832691abaf287ecc27 Mon Sep 17 00:00:00 2001 From: Chris Novakovic Date: Mon, 15 Apr 2019 01:46:02 +0100 Subject: [PATCH] Makefile: define CFLAGS directly in place of CUDD_XCFLAGS In the top-level makefile, CFLAGS is defined in terms of CUDD_XCFLAGS on every OS and architecture; the only difference between them is that CFLAGS incorporates the value of OPTIMISE, whereas CUDD_XCFLAGS doesn't. This is because the CUDD makefile draws a distinction between "machine-independent flags" (ICFLAGS) and "machine-dependent flags" (XCFLAGS), and the optimisation level is a machine-independent flag. The same is true of DEBUG (-g) and WARNINGS (-Ox), but for some reason they aren't treated the same way as OPTIMISE. Rather than defining CFLAGS in terms of CUDD_XCFLAGS, do the following: * define CFLAGS directly; * remove CUDD_XCFLAGS; * define ICFLAGS and XCFLAGS in the CUDD-related targets in terms of the relevant flags in CFLAGS - i.e., extract the values (if any) of DEBUG, OPTIMISE and WARNINGS from CFLAGS and pass them to the CUDD makefile as ICFLAGS, and whatever's left as XCFLAGS. This will also help to standardise the compiler flags used across all the libraries (e.g., currently CUDD is compiled with -g but nothing else is). The use of $(filter-out) means that weird things might happen if DEBUG, OPTIMISE or WARNINGS ever contain % symbols, but this (hopefully) isn't likely... --- prism/Makefile | 68 ++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/prism/Makefile b/prism/Makefile index 16e92359..7f039e0e 100644 --- a/prism/Makefile +++ b/prism/Makefile @@ -150,19 +150,23 @@ export CC CXX LD JAVAC JAVACC # Flags etc. # ############## +# Tell compiler to generate debug information? +# (WARNING: must not contain a % symbol!) DEBUG = #DEBUG = -g +# Compiler optimisation level: +# (WARNING: must not contain a % symbol!) OPTIMISE = -O3 #OPTIMISE = -# warnings we'd like to get +# Compiler warnings to enable: +# (WARNING: must not contain a % symbol!) WARNINGS = -Wformat # Flags for compilation/linking # Flags to generate shared libraries # Executable/library naming conventions -# Option to pass to CUDD makefile # Suffix for binary distribution directory # Place to look for (JNI) headers # (requires GNU make for conditional evaluation) @@ -171,25 +175,22 @@ WARNINGS = -Wformat ifeq ($(OSTYPE),linux) ifeq ($(ARCH),amd64) # Position Independent Code required on AMD64/Itanium - CUDD_XCFLAGS = -m64 -fPIC -DPIC -DHAVE_IEEE_754 -DBSD -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 $(DEBUG) $(WARNINGS) - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) - CXXFLAGS = --std=c++11 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) + CFLAGS = -m64 -fPIC -DPIC -DHAVE_IEEE_754 -DBSD -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS = --std=c++11 $(CFLAGS) + LDFLAGS = $(CFLAGS) BINDISTSUFFIX = linux64 else ifeq ($(ARCH),ia64) # Position Independent Code required on AMD64/Itanium # Note: We omit the -m64 flag from here since it seems to be unsupported by gcc on IA64 - CUDD_XCFLAGS = -fPIC -DPIC -DHAVE_IEEE_754 -DBSD -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 $(DEBUG) $(WARNINGS) - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) - CXXFLAGS = --std=c++11 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) + CFLAGS = -fPIC -DPIC -DHAVE_IEEE_754 -DBSD -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS = --std=c++11 $(CFLAGS) + LDFLAGS = $(CFLAGS) BINDISTSUFFIX = linux64 else - CUDD_XCFLAGS = -m32 -malign-double -DHAVE_IEEE_754 -DBSD $(DEBUG) $(WARNINGS) - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) - CXXFLAGS = --std=c++11 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) + CFLAGS = -m32 -malign-double -DHAVE_IEEE_754 -DBSD $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS = --std=c++11 $(CFLAGS) + LDFLAGS = $(CFLAGS) BINDISTSUFFIX = linux32 endif endif @@ -205,10 +206,9 @@ ifeq ($(OSTYPE),linux) endif # Solaris ifeq ($(OSTYPE),solaris) - CUDD_XCFLAGS = -mcpu=ultrasparc -DHAVE_IEEE_754 -DUNIX100 -DEPD_BIG_ENDIAN $(DEBUG) $(WARNINGS) - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) - CXXFLAGS = --std=c++11 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) + CFLAGS = -mcpu=ultrasparc -DHAVE_IEEE_754 -DUNIX100 -DEPD_BIG_ENDIAN $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS = --std=c++11 $(CFLAGS) + LDFLAGS = $(CFLAGS) BINDISTSUFFIX = solaris BIN_TARGETS=prism.linux xprism.linux JFLAGS = -encoding UTF8 @@ -222,18 +222,16 @@ endif # Cygwin ifeq ($(OSTYPE),cygwin) ifeq ($(ARCH),x86_64) - CUDD_XCFLAGS = -malign-double -DHAVE_IEEE_754 -DHAVE_GETRLIMIT=0 -DRLIMIT_DATA_DEFAULT=268435456 -DHAVE_SYS_RESOURCE_H=0 -DHAVE_SYS_WAIT_H=0 -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=4 $(DEBUG) $(WARNINGS) -static-libgcc -static-libstdc++ - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) + CFLAGS = -malign-double -DHAVE_IEEE_754 -DHAVE_GETRLIMIT=0 -DRLIMIT_DATA_DEFAULT=268435456 -DHAVE_SYS_RESOURCE_H=0 -DHAVE_SYS_WAIT_H=0 -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=4 $(DEBUG) $(OPTIMISE) $(WARNINGS) -static-libgcc -static-libstdc++ # need -DWIN32 for lpsolve (WIN32 is only defined by mingw/gcc without --std=c++11) - CXXFLAGS = --std=c++11 -DWIN32 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive + CXXFLAGS = --std=c++11 -DWIN32 $(CFLAGS) + LDFLAGS = $(CFLAGS) -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive BINDISTSUFFIX = win64 else - CUDD_XCFLAGS = -march=i686 -malign-double -DHAVE_IEEE_754 -DHAVE_GETRLIMIT=0 -DRLIMIT_DATA_DEFAULT=268435456 -DHAVE_SYS_RESOURCE_H=0 -DHAVE_SYS_WAIT_H=0 $(DEBUG) $(WARNINGS) -static-libgcc -static-libstdc++ - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) + CFLAGS = -march=i686 -malign-double -DHAVE_IEEE_754 -DHAVE_GETRLIMIT=0 -DRLIMIT_DATA_DEFAULT=268435456 -DHAVE_SYS_RESOURCE_H=0 -DHAVE_SYS_WAIT_H=0 $(DEBUG) $(OPTIMISE) $(WARNINGS) -static-libgcc -static-libstdc++ # need -DWIN32 for lpsolve (WIN32 is only defined by mingw/gcc without --std=c++11) - CXXFLAGS = --std=c++11 -DWIN32 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive + CXXFLAGS = --std=c++11 -DWIN32 $(CFLAGS) + LDFLAGS = $(CFLAGS) -Wl,--add-stdcall-alias -Wl,-Bstatic,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive BINDISTSUFFIX = win32 endif BIN_TARGETS=prism.cygwin xprism.linux prism.bat.win xprism.bat.win @@ -249,17 +247,15 @@ endif # Darwin ifeq ($(OSTYPE),darwin) ifeq ($(ARCH),x86_64) - CUDD_XCFLAGS = -arch x86_64 -fPIC -DPIC -DHAVE_IEEE_754 -DBSD -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 -fno-common $(DEBUG) $(WARNINGS) - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) - CXXFLAGS = --std=c++11 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) -Wl,-search_paths_first + CFLAGS = -arch x86_64 -fPIC -DPIC -DHAVE_IEEE_754 -DBSD -DSIZEOF_VOID_P=8 -DSIZEOF_LONG=8 -fno-common $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS = --std=c++11 $(CFLAGS) + LDFLAGS = $(CFLAGS) -Wl,-search_paths_first BINDISTSUFFIX = osx64 BIN_TARGETS=prism.darwin64 xprism.linux else - CUDD_XCFLAGS = -arch i386 -DHAVE_IEEE_754 -DBSD -fno-common $(DEBUG) $(WARNINGS) - CFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) - CXXFLAGS = --std=c++11 $(CUDD_XCFLAGS) $(OPTIMISE) - LDFLAGS = $(CUDD_XCFLAGS) $(OPTIMISE) -Wl,-search_paths_first + CFLAGS = -arch i386 -DHAVE_IEEE_754 -DBSD -fno-common $(DEBUG) $(OPTIMISE) $(WARNINGS) + CXXFLAGS = --std=c++11 $(CFLAGS) + LDFLAGS = $(CFLAGS) -Wl,-search_paths_first BINDISTSUFFIX = osx32 BIN_TARGETS=prism.darwin32 xprism.linux endif @@ -328,7 +324,7 @@ cuddpackage: checks @(if [ ! -h $(CUDD_DIR) ]; then \ echo Making cudd ...; \ cd $(CUDD_DIR) && \ - $(MAKE) XCFLAGS="$(CUDD_XCFLAGS)"; \ + $(MAKE) ICFLAGS="$(DEBUG) $(OPTIMISE) $(WARNINGS)" XCFLAGS="$(filter-out $(DEBUG) $(OPTIMISE) $(WARNINGS),$(CFLAGS))"; \ else \ echo Skipping cudd make since it is a symlink...; \ fi) @@ -337,7 +333,7 @@ cuddpackage: checks cuddpackageforce: checks @echo Making cudd ...; \ cd $(CUDD_DIR) && \ - $(MAKE) XCFLAGS="$(CUDD_XCFLAGS)"; + $(MAKE) ICFLAGS="$(DEBUG) $(OPTIMISE) $(WARNINGS)" XCFLAGS="$(filter-out $(DEBUG) $(OPTIMISE) $(WARNINGS),$(CFLAGS))" # Use this to force a rebuild (with javacc) of the main parser parser: