From 520916a5ab2df22991dddd66fef0bea7e278abac Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Mon, 6 Apr 2020 12:00:53 +1000 Subject: [PATCH 1/8] Optimisation flags needed at compile-time. Modernised remaineder of Makefile --- src/Makefile | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/src/Makefile b/src/Makefile index c4e9f7b06..4fe4d5579 100755 --- a/src/Makefile +++ b/src/Makefile @@ -7,24 +7,23 @@ # (note uppercase 'CPP' and no whitespace around '=') CPP = g++ -cpp = $(CPP) - - -# build COMPAS +BOOST = -$(info Building COMPAS with $(CPP)) -CFLAGS = -g +EXE = COMPAS +# build COMPAS +ifeq ($(filter clean,$(MAKECMDGOALS)),) + $(info Building $(EXE) with $(CPP)) +endif -BOOST = -CFLAGS = -I. +CXXFLAGS = -g -std=c++11 -Wall -march=native -O3 FCFLAGS = -ICFLAGS = -I$(BOOST)/include -Wall -std=c++11 -LFLAGS = -L$(BOOST)/lib -lgsl -lgslcblas -lstdc++ -lm -lz -ldl -march=k8 -lboost_filesystem -lboost_program_options -lboost_system -std=c++11 -O3 -SOURCES = \ +ICFLAGS = -I$(BOOST)/include -I. +LFLAGS = -L$(BOOST)/lib -lgsl -lgslcblas -lstdc++ -lm -lz -ldl -lboost_filesystem -lboost_program_options -lboost_system -Xlinker -rpath -Xlinker $(BOOST)/lib +SOURCES = \ utils.cpp \ - \ + \ Options.cpp \ Log.cpp \ Rand.cpp \ @@ -70,27 +69,27 @@ SOURCES = \ OBJI = $(SOURCES:.cpp=.o) -all: COMPAS +all: $(EXE) @echo $(OBJI) -.cpp.o: - $(CPP) -c $(CFLAGS) $(FCFLAGS) $(ICFLAGS) $? +.cpp.o: $(SOURCES) + $(CPP) $(CXXFLAGS) $(FCFLAGS) $(ICFLAGS) -c $? -COMPAS: $(OBJI) +$(EXE): $(OBJI) @echo $(SOURCES) @echo $(OBJI) - $(CPP) -o COMPAS $(OBJI) $(ICFLAGS) $(LFLAGS) + $(CPP) $(OBJI) $(LFLAGS) -o $@ +.phony: clean static clean: - rm -f *.o - -static: COMPAS_STATIC - @echo $OBJI + rm -f $(OBJI) -COMPAS_STATIC: $(OBJI) - @echo $(SOURCES) +static: $(EXE)_STATIC @echo $(OBJI) - $(CPP) -o COMPAS $(OBJI) $(ICFLAGS) $(LFLAGS) -static +$(EXE)_STATIC: $(OBJI) + @echo $(SOURCES) + @echo $(OBJI) + $(CPP) $(OBJI) $(LFLAGS) -static -o $@ From e9d2a1c006e657d4ca00c16d18d40e8631e37036 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Mon, 6 Apr 2020 12:01:40 +1000 Subject: [PATCH 2/8] Attempting white-space fix --- src/Makefile | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Makefile b/src/Makefile index 4fe4d5579..c97838ad0 100755 --- a/src/Makefile +++ b/src/Makefile @@ -28,42 +28,42 @@ SOURCES = \ Log.cpp \ Rand.cpp \ Errors.cpp \ - \ - BaseStar.cpp \ - \ + \ + BaseStar.cpp \ + \ Star.cpp \ - \ - MainSequence.cpp \ - MS_lte_07.cpp \ - MS_gt_07.cpp \ - \ + \ + MainSequence.cpp \ + MS_lte_07.cpp \ + MS_gt_07.cpp \ + \ CH.cpp \ - \ - GiantBranch.cpp \ + \ + GiantBranch.cpp \ HG.cpp \ FGB.cpp \ CHeB.cpp \ EAGB.cpp \ TPAGB.cpp \ - \ + \ HeMS.cpp \ HeHG.cpp \ HeGB.cpp \ - \ + \ HeWD.cpp \ COWD.cpp \ ONeWD.cpp \ - \ + \ NS.cpp \ BH.cpp \ MR.cpp \ - \ + \ AIS.cpp \ - \ - BinaryConstituentStar.cpp \ - BaseBinaryStar.cpp \ - BinaryStar.cpp \ - \ + \ + BinaryConstituentStar.cpp \ + BaseBinaryStar.cpp \ + BinaryStar.cpp \ + \ main.cpp OBJI = $(SOURCES:.cpp=.o) From 1d794a8601b50644e28e003f150703f7f08465db Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Mon, 6 Apr 2020 22:06:38 +1000 Subject: [PATCH 3/8] Removed unused variable --- src/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index c97838ad0..37f549e30 100755 --- a/src/Makefile +++ b/src/Makefile @@ -18,7 +18,6 @@ ifeq ($(filter clean,$(MAKECMDGOALS)),) endif CXXFLAGS = -g -std=c++11 -Wall -march=native -O3 -FCFLAGS = ICFLAGS = -I$(BOOST)/include -I. LFLAGS = -L$(BOOST)/lib -lgsl -lgslcblas -lstdc++ -lm -lz -ldl -lboost_filesystem -lboost_program_options -lboost_system -Xlinker -rpath -Xlinker $(BOOST)/lib SOURCES = \ @@ -73,7 +72,7 @@ all: $(EXE) @echo $(OBJI) .cpp.o: $(SOURCES) - $(CPP) $(CXXFLAGS) $(FCFLAGS) $(ICFLAGS) -c $? + $(CPP) $(CXXFLAGS) $(ICFLAGS) -c $? $(EXE): $(OBJI) From daa540ac514b57814dad7c6fc8138c3282af7af3 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Mon, 6 Apr 2020 22:15:01 +1000 Subject: [PATCH 4/8] Changed to the fixed assignment --- src/Makefile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index 37f549e30..02b79ee38 100755 --- a/src/Makefile +++ b/src/Makefile @@ -7,20 +7,20 @@ # (note uppercase 'CPP' and no whitespace around '=') CPP = g++ -BOOST = +BOOST := -EXE = COMPAS +EXE := COMPAS # build COMPAS ifeq ($(filter clean,$(MAKECMDGOALS)),) $(info Building $(EXE) with $(CPP)) endif -CXXFLAGS = -g -std=c++11 -Wall -march=native -O3 -ICFLAGS = -I$(BOOST)/include -I. -LFLAGS = -L$(BOOST)/lib -lgsl -lgslcblas -lstdc++ -lm -lz -ldl -lboost_filesystem -lboost_program_options -lboost_system -Xlinker -rpath -Xlinker $(BOOST)/lib -SOURCES = \ +CXXFLAGS := -g -std=c++11 -Wall -march=native -O3 +ICFLAGS := -I$(BOOST)/include -I. +LFLAGS := -L$(BOOST)/lib -lgsl -lgslcblas -lstdc++ -lm -lz -ldl -lboost_filesystem -lboost_program_options -lboost_system -Xlinker -rpath -Xlinker $(BOOST)/lib +SOURCES := \ utils.cpp \ \ Options.cpp \ @@ -65,7 +65,7 @@ SOURCES = \ \ main.cpp -OBJI = $(SOURCES:.cpp=.o) +OBJI := $(SOURCES:.cpp=.o) all: $(EXE) From 32baaaf3b8bedbd247a2e80d6f209a9991f9d5d3 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Mon, 6 Apr 2020 22:16:01 +1000 Subject: [PATCH 5/8] Remove the executables when cleaning --- src/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Makefile b/src/Makefile index 02b79ee38..517a446a8 100755 --- a/src/Makefile +++ b/src/Makefile @@ -82,7 +82,7 @@ $(EXE): $(OBJI) .phony: clean static clean: - rm -f $(OBJI) + rm -f $(OBJI) $(EXE) $(EXE)_STATIC static: $(EXE)_STATIC @echo $(OBJI) From bca3ad4f790b89a8c0ff83ea214f814247ea20f9 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 7 Apr 2020 10:28:35 +1000 Subject: [PATCH 6/8] Added the header files as a dependency --- src/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Makefile b/src/Makefile index 517a446a8..e7b27a825 100755 --- a/src/Makefile +++ b/src/Makefile @@ -67,6 +67,10 @@ SOURCES := \ OBJI := $(SOURCES:.cpp=.o) +# Create the list of header files, and remove +# main.h from this auto-generated list +INCL := $(SOURCES:.cpp=.h) +INCL := $(filter-out main.h,$(INCL)) all: $(EXE) @echo $(OBJI) From 11a73b399a4b595bc50c7142f1f478fe0d2a60c9 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 7 Apr 2020 10:29:26 +1000 Subject: [PATCH 7/8] Altered the sequence of targets to how match how make works --- src/Makefile | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Makefile b/src/Makefile index e7b27a825..15f03cfb0 100755 --- a/src/Makefile +++ b/src/Makefile @@ -75,19 +75,11 @@ INCL := $(filter-out main.h,$(INCL)) all: $(EXE) @echo $(OBJI) -.cpp.o: $(SOURCES) - $(CPP) $(CXXFLAGS) $(ICFLAGS) -c $? - - $(EXE): $(OBJI) @echo $(SOURCES) @echo $(OBJI) $(CPP) $(OBJI) $(LFLAGS) -o $@ -.phony: clean static -clean: - rm -f $(OBJI) $(EXE) $(EXE)_STATIC - static: $(EXE)_STATIC @echo $(OBJI) @@ -96,3 +88,10 @@ $(EXE)_STATIC: $(OBJI) @echo $(SOURCES) @echo $(OBJI) $(CPP) $(OBJI) $(LFLAGS) -static -o $@ + +.cpp.o: $(SOURCES) $(INCL) Makefile + $(CPP) $(CXXFLAGS) $(ICFLAGS) -c $? + +.phony: clean static +clean: + rm -f $(OBJI) $(EXE) $(EXE)_STATIC From 0c574b46cfa1678239499cc075b02b07a6f29752 Mon Sep 17 00:00:00 2001 From: Manodeep Sinha Date: Tue, 7 Apr 2020 11:11:54 +1000 Subject: [PATCH 8/8] Added a way for a non-optimised build --- src/Makefile | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/Makefile b/src/Makefile index 15f03cfb0..26952bd86 100755 --- a/src/Makefile +++ b/src/Makefile @@ -17,7 +17,20 @@ ifeq ($(filter clean,$(MAKECMDGOALS)),) $(info Building $(EXE) with $(CPP)) endif -CXXFLAGS := -g -std=c++11 -Wall -march=native -O3 + +OPTFLAGS := +ifneq ($(filter fast,$(MAKECMDGOALS)),) + $(info Adding optimisation flags into the compilation - will take longer to build) + OPTFLAGS += -march=native -O3 +endif + +ifneq ($(filter staticfast,$(MAKECMDGOALS)),) + $(info Adding optimisation flags into the (static) compilation - will take longer to build) + OPTFLAGS += -march=native -O3 +endif + + +CXXFLAGS := -g -std=c++11 -Wall $(OPTFLAGS) ICFLAGS := -I$(BOOST)/include -I. LFLAGS := -L$(BOOST)/lib -lgsl -lgslcblas -lstdc++ -lm -lz -ldl -lboost_filesystem -lboost_program_options -lboost_system -Xlinker -rpath -Xlinker $(BOOST)/lib SOURCES := \ @@ -83,7 +96,6 @@ $(EXE): $(OBJI) static: $(EXE)_STATIC @echo $(OBJI) - $(EXE)_STATIC: $(OBJI) @echo $(SOURCES) @echo $(OBJI) @@ -92,6 +104,10 @@ $(EXE)_STATIC: $(OBJI) .cpp.o: $(SOURCES) $(INCL) Makefile $(CPP) $(CXXFLAGS) $(ICFLAGS) -c $? -.phony: clean static +.phony: clean static fast staticfast + +fast: $(EXE) +staticfast:$(EXE)_STATIC + clean: rm -f $(OBJI) $(EXE) $(EXE)_STATIC