-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
88 lines (69 loc) · 2.64 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#
FC= gfortran
EXECUTEABLE=GeoHBond.out
CFLAGS=-cpp -c -CC -ffree-form -DISPNTLIST=1
DFLAGS=-ggdb3 -pedantic -Wall -ffpe-trap=overflow -fcheck=all -fbacktrace \
-D__DEBUG=1
OFLAGS=-funroll-loops -D__DEBUG=0 -O2 #Turn on Compiler optimization
LDFLAGS=
WD=$(shell pwd)
SRC=$(addprefix $(WD)/,src)
BUILD=$(addprefix $(WD)/,build)
#a set of variables and names required for Program version documentation
COMPILE_TIME=$(shell date +"%a, %d.%m.%Y %H:%M:%S %Z")
MACHINE=$(shell echo $$HOSTNAME)
GIT_COMMIT=$(shell git rev-parse HEAD)
CFLAGS+=-D__PROGRAM_COMPILE_TIME="'$(COMPILE_TIME)'" \
-D__MACHINE_NAME="'$(MACHINE)'" -D__GIT_VERSION="'$(GIT_COMMIT)'"
#for GenStorMod define the CompileFlags to build AtomStorMod
CFLAGS+=-D__TYPE="type(Atom)" -D__USE_DECLARATION="use AtomMod, only : Atom" \
-D__MNAME="'AtomStorMod'" -D__MODULE_NAME="AtomStorMod"
#define empty files to indicate whether previous run was a debug or compile run
DBGFLAG=$(addprefix $(BUILD)/,.dbg)
CPLFLAG=$(addprefix $(BUILD)/,.cpl)
INCDIR=$(addprefix $(WD)/,../repo/include)
LIBDIR=$(addprefix $(WD)/,../repo/lib)
LIBS=-lfftw3 -lbase
T2AMODS=
T2BMODS= AtomListMod.F Molecule.F ReadPSFMod.F HBGeoSetup.F DetMolsMod.F \
GeoAnalysisMod.F
STRCMODS= GenGrids.F
LOCMODS= ProvideGeoMod.F DistancesMod.F BondMod.F Main.F
INCLUDE= $(addprefix $(SRC)/, Main_subroutines.F)
SOURCES=$(addprefix $(SRC)/, $(T2AMODS) $(T2BMODS) $(STRCMODS) $(LOCMODS))
OBJECTS=$(addprefix $(BUILD)/,$(T2AMODS:.f95=.o) $(T2BMODS:.F=.o) \
$(STRCMODS:.F=.o) $(LOCMODS:.F=.o))
.PHONY: directories clean all
all: CFLAGS:=$(CFLAGS) $(OFLAGS)
all: LDFLAGS:=$(OFLAGS)
all: directories $(CPLFLAG) $(SOURCES) $(EXECUTEABLE)
@echo ----------------------
@echo ***Build complete***
@echo ----------------------
$(EXECUTEABLE): $(OBJECTS)
$(FC) $(LDFLAGS) $^ -L$(LIBDIR) $(LIBS) -o $(BUILD)/$@
ln --force $(BUILD)/$(EXECUTEABLE) $(WD)
#bit of a hack. could be done better.
$(BUILD)/Main.o: $(SRC)/Main.F $(INCLUDE)
$(FC) $(CFLAGS) -I$(INCDIR) $< -J $(BUILD) -o $@
$(BUILD)/%.o: $(SRC)/%.f95
$(FC) $(CFLAGS) -I$(INCDIR) $< -J $(BUILD) -o $@
$(BUILD)/%.o: $(SRC)/%.F
$(FC) $(CFLAGS) -I$(INCDIR) $< -J $(BUILD) -o $@
directories:
@if [ ! \( -e $(BUILD) \) ];then mkdir $(BUILD);fi;
clean:
@if [ \( -e $(BUILD) \) ];then rm -r build;fi;
@echo ***Cleanup complete***
debug: CFLAGS:=$(CFLAGS) $(DFLAGS)
debug: LDFLAGS:=$(DFLAGS)
debug: directories $(DBGFLAG) $(SOURCES) $(EXECUTEABLE)
@echo '--------------------------'
@echo ' ***Build complete*** '
@echo '--------------------------'
$(DBGFLAG):
rm -f $(CPLFLAG) $(OBJECTS)
touch $(DBGFLAG)
$(CPLFLAG):
rm -f $(DBGFLAG) $(OBJECTS)
touch $(CPLFLAG)