Author: Michael R. Crusoe
Description: improve the build hardening
--- raxml.orig/Makefile.AVX.PTHREADS.gcc
+++ raxml/Makefile.AVX.PTHREADS.gcc
@@ -3,8 +3,11 @@
 
 CC = gcc 
 
-CFLAGS := -D_USE_PTHREADS  -D__SIM_SSE3 -O2 -D_GNU_SOURCE -msse3 -fomit-frame-pointer -funroll-loops  -D__AVX #-Wall -pedantic -Wunused-parameter -Wredundant-decls  -Wreturn-type  -Wswitch-default -Wunused-value -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int -Wimport  -Wunused  -Wunused-function  -Wunused-label -Wno-int-to-pointer-cast -Wbad-function-cast  -Wmissing-declarations -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition -Wstrict-prototypes  -Wdeclaration-after-statement -Wpointer-sign -Wextra -Wredundant-decls -Wunused -Wunused-function -Wunused-parameter -Wunused-value  -Wunused-variable -Wformat  -Wformat-nonliteral -Wparentheses -Wsequence-point -Wuninitialized -Wundef -Wbad-function-cast
+CFLAGS += -D_USE_PTHREADS  -D__SIM_SSE3 -O2 -D_GNU_SOURCE -fomit-frame-pointer -funroll-loops  -D__AVX #-Wall -pedantic -Wunused-parameter -Wredundant-decls  -Wreturn-type  -Wswitch-default -Wunused-value -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int -Wimport  -Wunused  -Wunused-function  -Wunused-label -Wno-int-to-pointer-cast -Wbad-function-cast  -Wmissing-declarations -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition -Wstrict-prototypes  -Wdeclaration-after-statement -Wpointer-sign -Wextra -Wredundant-decls -Wunused -Wunused-function -Wunused-parameter -Wunused-value  -Wunused-variable -Wformat  -Wformat-nonliteral -Wparentheses -Wsequence-point -Wuninitialized -Wundef -Wbad-function-cast
 
+ifeq (amd64,$(shell dpkg-architecture -q DEB_TARGET_ARCH_CPU))
+	CFLAGS += -mavx -msse3
+endif
 
 LIBRARIES = -lm -pthread 
 
@@ -20,10 +23,10 @@
 	$(CC) -o raxmlHPC-PTHREADS-AVX $(objs) $(LIBRARIES) $(LDFLAGS) 
 
 avxLikelihood.o : avxLikelihood.c $(GLOBAL_DEPS)
-		$(CC) $(CFLAGS) -mavx -c -o avxLikelihood.o avxLikelihood.c
+		$(CC) $(CPPFLAGS) $(CFLAGS) -c -o avxLikelihood.o avxLikelihood.c
 
 fastDNAparsimony.o : fastDNAparsimony.c $(GLOBAL_DEPS)
-		   $(CC) $(CFLAGS) -mavx -c -o fastDNAparsimony.o fastDNAparsimony.c
+		   $(CC) $(CPPFLAGS) $(CFLAGS) -c -o fastDNAparsimony.o fastDNAparsimony.c
 
 #rev_functions.o : rev_functions.c $(GLOBAL_DEPS)
 rmqs.o : rmqs.c $(GLOBAL_DEPS)
@@ -49,7 +52,7 @@
  mem_alloc.o eigen.o  : mem_alloc.c  $(GLOBAL_DEPS)
 
 eigen.o : eigen.c $(GLOBAL_DEPS)
-	$(CC) -c -o eigen.o eigen.c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o eigen.o eigen.c 
 clean : 
 	$(RM) *.o raxmlHPC-PTHREADS-AVX
 
--- raxml.orig/Makefile.PTHREADS.gcc
+++ raxml/Makefile.PTHREADS.gcc
@@ -4,7 +4,7 @@
 CC = gcc 
 
 
-CFLAGS = -D_GNU_SOURCE -fomit-frame-pointer -funroll-loops -O2  -D_USE_PTHREADS -msse #-Wall -Wunused-parameter -Wredundant-decls  -Wreturn-type  -Wswitch-default -Wunused-value -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int -Wimport  -Wunused  -Wunused-function  -Wunused-label -Wno-int-to-pointer-cast -Wbad-function-cast  -Wmissing-declarations -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition -Wstrict-prototypes  -Wpointer-sign -Wextra -Wredundant-decls -Wunused -Wunused-function -Wunused-parameter -Wunused-value  -Wunused-variable -Wformat  -Wformat-nonliteral -Wparentheses -Wsequence-point -Wuninitialized -Wundef -Wbad-function-cast
+CFLAGS += -D_GNU_SOURCE -fomit-frame-pointer -funroll-loops -O2  -D_USE_PTHREADS -msse #-Wall -Wunused-parameter -Wredundant-decls  -Wreturn-type  -Wswitch-default -Wunused-value -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int -Wimport  -Wunused  -Wunused-function  -Wunused-label -Wno-int-to-pointer-cast -Wbad-function-cast  -Wmissing-declarations -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition -Wstrict-prototypes  -Wpointer-sign -Wextra -Wredundant-decls -Wunused -Wunused-function -Wunused-parameter -Wunused-value  -Wunused-variable -Wformat  -Wformat-nonliteral -Wparentheses -Wsequence-point -Wuninitialized -Wundef -Wbad-function-cast
 
 
 LIBRARIES = -lm -pthread
@@ -45,8 +45,8 @@
 mem_alloc.o eigen.o  : mem_alloc.c  $(GLOBAL_DEPS)
 
 eigen.o : eigen.c $(GLOBAL_DEPS)
-	$(CC) -c -o eigen.o eigen.c 
+	$(CC) $(CPPFLAGS) $(CFLAGS) -c -o eigen.o eigen.c 
 clean : 
 	$(RM) *.o raxmlHPC-PTHREADS
 
-dev : raxmlHPC-PTHREADS
\ No newline at end of file
+dev : raxmlHPC-PTHREADS
--- raxml.orig/Makefile.SSE3.PTHREADS.gcc
+++ raxml/Makefile.SSE3.PTHREADS.gcc
@@ -3,7 +3,7 @@
 
 CC = gcc 
 
-CFLAGS = -D_USE_PTHREADS -D__SIM_SSE3 -D_GNU_SOURCE -msse3 -O2 -fomit-frame-pointer -funroll-loops  #-Wall -pedantic -Wunused-parameter -Wredundant-decls  -Wreturn-type  -Wswitch-default -Wunused-value -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int -Wimport  -Wunused  -Wunused-function  -Wunused-label -Wno-int-to-pointer-cast -Wbad-function-cast  -Wmissing-declarations -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition -Wstrict-prototypes  -Wdeclaration-after-statement -Wpointer-sign -Wextra -Wredundant-decls -Wunused -Wunused-function -Wunused-parameter -Wunused-value  -Wunused-variable -Wformat  -Wformat-nonliteral -Wparentheses -Wsequence-point -Wuninitialized -Wundef -Wbad-function-cast
+CFLAGS += -D_USE_PTHREADS -D__SIM_SSE3 -D_GNU_SOURCE -msse3 -O2 -fomit-frame-pointer -funroll-loops  #-Wall -pedantic -Wunused-parameter -Wredundant-decls  -Wreturn-type  -Wswitch-default -Wunused-value -Wimplicit  -Wimplicit-function-declaration  -Wimplicit-int -Wimport  -Wunused  -Wunused-function  -Wunused-label -Wno-int-to-pointer-cast -Wbad-function-cast  -Wmissing-declarations -Wmissing-prototypes  -Wnested-externs  -Wold-style-definition -Wstrict-prototypes  -Wdeclaration-after-statement -Wpointer-sign -Wextra -Wredundant-decls -Wunused -Wunused-function -Wunused-parameter -Wunused-value  -Wunused-variable -Wformat  -Wformat-nonliteral -Wparentheses -Wsequence-point -Wuninitialized -Wundef -Wbad-function-cast
 
 
 LIBRARIES = -lm -pthread 
@@ -41,11 +41,11 @@
 fastSearch.o : fastSearch.c $(GLOBAL_DEPS)
 leaveDropping.o : leaveDropping.c $(GLOBAL_DEPS)
 ancestralStates.o : ancestralStates.c $(GLOBAL_DEPS)
- mem_alloc.o eigen.o  : mem_alloc.c  $(GLOBAL_DEPS)
+mem_alloc.o eigen.o  : mem_alloc.c  $(GLOBAL_DEPS)
 
 eigen.o : eigen.c $(GLOBAL_DEPS)
-	$(CC) -c -o eigen.o eigen.c 
+	$(CC) $(CFLAGS) $(CPPFLAGS) -c -o eigen.o eigen.c 
 clean : 
 	$(RM) *.o raxmlHPC-PTHREADS-SSE3
 
-dev : raxmlHPC-PTHREADS-SSE3
\ No newline at end of file
+dev : raxmlHPC-PTHREADS-SSE3
