Skip to content

Commit f0ab925

Browse files
authored
fix: removing redundant makefile.docker, streamline makefile (#1416)
1 parent 80fee92 commit f0ab925

File tree

3 files changed

+49
-231
lines changed

3 files changed

+49
-231
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ RUN mkdir obj bin logs
2323
ENV COMPAS_ROOT_DIR /app/COMPAS
2424

2525
# Compile COMPAS
26-
RUN cd src && make -f Makefile.docker -j $(nproc)
26+
RUN cd src && make DOCKER_BUILD=1 -j $(nproc)
2727

2828
# Run COMPAS
2929
# CMD [ "python", "src/pythonSubmitDefault.py" ]

src/Makefile

Lines changed: 48 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,29 @@
88

99
CPP := g++
1010

11-
# gsl directories
11+
# Build configuration: DOCKER_BUILD=1 for Docker, otherwise local
12+
ifeq ($(DOCKER_BUILD),1)
13+
# Docker-specific settings
14+
ODIR := ../obj
15+
BDIR := ../bin
16+
OPTFLAGS_SPECIFIC := -O3
17+
CXXFLAGS_SPECIFIC :=
18+
LFLAGS_SPECIFIC :=
19+
else
20+
# Local-specific settings
21+
ODIR := obj
22+
BDIR := bin
23+
OPTFLAGS_SPECIFIC := -march=native -O3
24+
CXXFLAGS_SPECIFIC := -g -fnon-call-exceptions -Woverloaded-virtual
25+
LFLAGS_SPECIFIC := -rdynamic
26+
endif
27+
28+
# Common variables for both builds
29+
EXE := $(BDIR)/COMPAS
30+
SOURCES := $(wildcard *.cpp)
31+
OBJS := $(patsubst %.cpp,$(ODIR)/%.o,$(SOURCES))
32+
33+
# GSL, Boost, and HDF5 directories
1234
GSLINCDIR := /include
1335
GSLLIBDIR := /lib
1436

@@ -20,114 +42,47 @@ BOOSTLIBDIR := /lib
2042
HDF5INCDIR := /usr/include/hdf5/serial
2143
HDF5LIBDIR := /usr/lib/x86_64-linux-gnu/hdf5/serial
2244

23-
EXE := COMPAS
24-
25-
# build COMPAS
26-
ifeq ($(filter clean,$(MAKECMDGOALS)),)
27-
$(info Building $(EXE) with $(CPP))
28-
endif
29-
30-
45+
# Define flags
3146
OPTFLAGS :=
32-
ifneq ($(filter fast,$(MAKECMDGOALS)),)
33-
$(info Adding optimisation flags into the compilation - will take longer to build)
34-
OPTFLAGS += -march=native -O3
47+
ifneq ($(filter fast staticfast,$(MAKECMDGOALS)),)
48+
$(info Adding optimisation flags into the compilation - will take longer to build)
49+
OPTFLAGS += $(OPTFLAGS_SPECIFIC)
3550
endif
3651

37-
ifneq ($(filter staticfast,$(MAKECMDGOALS)),)
38-
$(info Adding optimisation flags into the (static) compilation - will take longer to build)
39-
OPTFLAGS += -march=native -O3
40-
endif
41-
42-
43-
CXXFLAGS := -std=c++17 -g -fnon-call-exceptions -Wall -Woverloaded-virtual -Wno-vla-extension $(OPTFLAGS)
52+
CXXFLAGS := -std=c++17 -Wall $(OPTFLAGS) $(CXXFLAGS_SPECIFIC)
4453
ICFLAGS := -I$(GSLINCDIR) -I$(BOOSTINCDIR) -I$(HDF5INCDIR) -I.
4554

4655
LIBS := -lm -lz -ldl -lpthread
4756
GSLLIBS := -lgsl -lgslcblas
4857
BOOSTLIBS := -lboost_filesystem -lboost_program_options -lboost_system
4958
HDF5LIBS := -lhdf5_hl_cpp -lhdf5_cpp -lhdf5_hl -lhdf5
50-
LFLAGS := -L$(GSLLIBDIR) -L$(BOOSTLIBDIR) -L$(HDF5LIBDIR) -Xlinker -rpath -rdynamic -Xlinker $(BOOSTLIBDIR) $(HDF5LIBS) $(LIBS) $(GSLLIBS) $(BOOSTLIBS)
51-
52-
SOURCES := \
53-
profiling.cpp \
54-
utils.cpp \
55-
yaml.cpp \
56-
vector3d.cpp \
57-
\
58-
Rand.cpp \
59-
Options.cpp \
60-
Log.cpp \
61-
Errors.cpp \
62-
\
63-
BaseStar.cpp \
64-
\
65-
Star.cpp \
66-
\
67-
MainSequence.cpp \
68-
MS_lte_07.cpp \
69-
MS_gt_07.cpp \
70-
\
71-
CH.cpp \
72-
\
73-
GiantBranch.cpp \
74-
HG.cpp \
75-
FGB.cpp \
76-
CHeB.cpp \
77-
EAGB.cpp \
78-
TPAGB.cpp \
79-
\
80-
HeMS.cpp \
81-
HeHG.cpp \
82-
HeGB.cpp \
83-
\
84-
Remnants.cpp \
85-
\
86-
WhiteDwarfs.cpp \
87-
HeWD.cpp \
88-
COWD.cpp \
89-
ONeWD.cpp \
90-
\
91-
NS.cpp \
92-
BH.cpp \
93-
MR.cpp \
94-
\
95-
BinaryConstituentStar.cpp \
96-
BaseBinaryStar.cpp \
97-
BinaryStar.cpp \
98-
\
99-
main.cpp
100-
101-
OBJI := $(SOURCES:.cpp=.o)
102-
103-
# Create the list of header files, and remove
104-
# main.h from this auto-generated list
105-
INCL := $(SOURCES:.cpp=.h)
106-
INCL := $(filter-out main.h,$(INCL))
59+
LFLAGS := -L$(GSLLIBDIR) -L$(BOOSTLIBDIR) -L$(HDF5LIBDIR) -Xlinker -rpath -Xlinker $(BOOSTLIBDIR) $(HDF5LIBS) $(LIBS) $(GSLLIBS) $(BOOSTLIBS) $(LFLAGS_SPECIFIC)
10760

108-
all: $(EXE)
109-
@echo $(OBJI)
61+
.PHONY: all static fast staticfast clean
11062

111-
$(EXE): $(OBJI)
112-
@echo $(SOURCES)
113-
@echo $(OBJI)
114-
$(CPP) $(OBJI) $(LFLAGS) -o $@
63+
# Main targets
64+
all: $(EXE)
11565

11666
static: $(EXE)_STATIC
117-
@echo $(OBJI)
11867

119-
$(EXE)_STATIC: $(OBJI)
120-
@echo $(SOURCES)
121-
@echo $(OBJI)
122-
$(CPP) $(OBJI) $(LFLAGS) -static -o $@
68+
fast: all
69+
70+
staticfast: static
12371

124-
%.o: %.cpp
125-
$(CPP) $(CXXFLAGS) $(ICFLAGS) -c $?
72+
$(EXE): $(OBJS)
73+
@mkdir -p $(BDIR)
74+
$(CPP) $(OBJS) $(LFLAGS) -o $@
12675

127-
.phony: clean static fast staticfast
76+
$(EXE)_STATIC: $(OBJS)
77+
@mkdir -p $(BDIR)
78+
$(CPP) $(OBJS) $(LFLAGS) -static -o $@
12879

129-
fast: $(EXE)
130-
staticfast:$(EXE)_STATIC
80+
# Pattern rule to compile source files into object files
81+
$(ODIR)/%.o: %.cpp
82+
@mkdir -p $(ODIR)
83+
$(CPP) $(CXXFLAGS) $(ICFLAGS) -o $@ -c $<
13184

85+
# Clean-up rule
13286
clean:
133-
rm -f $(OBJI) $(EXE) $(EXE)_STATIC
87+
@echo "Removing generated files..."
88+
@rm -rf $(ODIR) $(BDIR)

src/Makefile.docker

Lines changed: 0 additions & 137 deletions
This file was deleted.

0 commit comments

Comments
 (0)