-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile_old
160 lines (118 loc) · 4.61 KB
/
Makefile_old
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#Modules
_MODULE_SOURCES=AlphaHouseMod.f90 Input.f90 StringModule.f90 LineModule.f90 PageModule.f90 AlphaEvolveMod.f90 AlphaStatMod.f90 IntelRNGMod.f90 OrderPackMod.f90 IndividualModule.f90 UtilitySubroutines.f90
_PROGRAM_SOURCES=main.f90
DEPENDENCIES=
ifeq ($(OS),Windows_NT)
OSFLAG="OS_WIN"
EXE=.exe
RM=del
OBJECTDIR=objs\\
SRCDIR=src\\
TESTDIR=tests\\
TARGET_DIR=bin\\
MKDIR=mkdir
OBJ := .obj
#For the extra programs that need to be defined
ABOPT := -static -Qmkl
VERSION:=$(shell git rev-parse --short HEAD)
DEBUG_FLAGS= -finstrument-functions /debug /Od /traceback /heap-arrays /check:bounds
PROGRAM:=$(NAME)
#TODO heap arrays because default stack size is 2gb on windows.
FFLAGS= -fpp /heap-arrays -D $(OSFLAG) -DVERS=""commit-$(VERSION)""
else
OSFLAG:="OS_UNIX"
#This gets the name of the current folder and the current commit and sets the program name to that.
FOLDERNAME:=$(shell basename $(shell pwd)) #Name of program goes here
NAME:=$(strip $(FOLDERNAME))
# VERSION:=$(shell git rev-parse --short HEAD)
SUBVERSION:=0
#MASTERVERSION:=$(shell git describe --tag | cut -d "-" -f 1)
PROGRAM:=$(NAME)#_$(VERSION)#$(MASTERVERSION)
RM=rm -rf
MAKEDIR=mkdir -p
LIBNETCDF := -L$(NETCDF)/lib -lnetcdff
INCNETCDF := -I$(NETCDF)/include
PFUNIT=/usr/local/pFUnit_serial
MKLROOT := /opt/intel/mkl
# On Eddie2
# MKLROOT:=/exports/applications/apps/intel/ClusterStudio2013/mkl
# On Eddie3
# MKLROOT := /exports/applications/apps/SL7/intel/parallel_studio_xe_2016/mkl
MKLLIB := -L$(MKLROOT)/lib -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core -lpthread -lm -Wl,-rpath,$(MKLROOT)/lib -Wl,-rpath,/opt/intel/lib
MKLINC := -I$(MKLROOT)/include
endif
#Filenames
OBJECTDIR=objs/
SRCDIR=src/
TESTDIR=tests/
TARGETDIR=bin/
DOXYGENDIR=DoxygenDoc/
PFUNITFLAGS:=-I./$(OBJECTDIR) -I$(PFUNIT)/mod -I$(PFUNIT)/include -lpfunit -module $(OBJECTDIR) -fpp -L$(PFUNIT)/lib
LDFLAGS:=
DRIVER:=$(PFUNIT)/include/driver.f90
HDF5FLAGS:=
#Compiler and flags
CC:=g++
CFLAGS:= -std=c++0x -Wextra -Wall
FC=ifort
FFLAGS= -fpp -module $(OBJECTDIR) -D $(OSFLAG) -DVERS=""commit-$(VERSION)"" -mkl
DEBUG_FLAGS=-traceback -g -debug all -warn all -check bounds -check format \
-check output_conversion -check pointers
SUPER_DEBUG_FLAGS=$(DEBUG_FLAGS) -ftrapuv -check all -gen-interfaces -warn interfaces
PRODUCTION_FLAG=-fast
MODULE_SOURCES=$(patsubst %, $(SRCDIR)%, $(_MODULE_SOURCES))
PROGRAM_SOURCES=$(patsubst %, $(SRCDIR)%, $(_PROGRAM_SOURCES))
SOURCES=$(MODULE_SOURCES) $(PROGRAM_SOURCES)
MODULE_OBJECTS =$(patsubst $(SRCDIR)%.f90, $(OBJECTDIR)%.o, $(MODULE_SOURCES))
PROGRAM_OBJECTS=$(patsubst $(SRCDIR)%.f90, $(OBJECTDIR)%.o, $(PROGRAM_SOURCES))
OBJECTS= $(MODULE_OBJECTS) $(PROGRAM_OBJECTS)
PFTESTS:=$(wildcard $(TESTDIR)*.pf)
F90TESTS:=$(PFTESTS:.pf=.F90)
F90FINISHED:= $(F90TESTS:.F90=.o)
BUILDDATE=$(shell date +%Y%m%d-%H:%M:%S)
all: directories $(PROGRAM) $(DEPENDENCIES)
build: all doc tests cleanTest
debug: FFLAGS:=$(FFLAGS) $(DEBUG_FLAGS)
debug: $(PROGRAM)
superdebug: FFLAGS:=$(FFLAGS) $(SUPER_DEBUG_FLAGS)
superdebug: all
production: FFLAGS:=$(FFLAGS) $(PRODUCTION_FLAG)
production: PROGRAM:=$(NAME)
production: all
doc:
doxygen Doxygen.txt > $(DOXYGENDIR)Doxygen.log
tests: $(F90TESTS) $(F90FINISHED)
cp $(TESTDIR)testSuites.inc .
$(FC) -o tests.x $(addprefix $(OBJECTDIR), $(notdir $(F90FINISHED))) $(MODULE_OBJECTS) $(DRIVER) $(PFUNITFLAGS) $(MKLINC) $(MKLLIB) $(FFLAGS)
$(RM) testSuites.inc
./tests.x -xml test_output
testsDebug : FFLAGS:=$(FFLAGS) $(DEBUG_FLAGS)
testsDebug : tests
clean: cleanIntermediate
$(RM) $(TARGETDIR)$(NAME)*
cleanIntermediate: cleanTest
$(RM) $(OBJECTDIR)*
cleanTest:
$(RM) $(TESTDIR)*.F90
$(RM) $(OBJECTDIR)tests.x
$(RM) $(OBJECTDIR)testSuites.inc
$(RM) tests.x
$(RM) testSuites.inc
$(PROGRAM):$(OBJECTS)
$(FC) -o $(TARGETDIR)$(PROGRAM) $^ $(FFLAGS) $(MKLINC) $(MKLLIB) $(LDFLAGS)
$(OBJECTDIR)%.o: $(SRCDIR)%.f90
$(FC) -o $@ -c $< $(FFLAGS) $(MKLINC) $(MKLLIB) $(LDFLAGS)
directories:
$(MAKEDIR) $(SRCDIR)
$(MAKEDIR) $(TESTDIR)
$(MAKEDIR) $(OBJECTDIR)
$(MAKEDIR) $(TARGETDIR)
$(MAKEDIR) $(DOXYGENDIR)
list: #Taken from http://stackoverflow.com/questions/4219255/how-do-you-get-the-list-of-targets-in-a-makefile. Answer by mklement0.
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
#$(OBJECTDIR)%.o: %.F90
# $(FC) -o $@ -c $< $(FFLAGS) $(PFUNITFLAGS) $(MKLLIB) $(MKLINC) $(LDFLAGS)
%.o:%.F90
$(FC) -c -o $(addprefix $(OBJECTDIR), $(notdir $@)) $< $(PFUNITFLAGS) -module $(OBJECTDIR) $(LDFLAGS)
%.F90: %.pf
$(PFUNIT)/bin/pFUnitParser.py $< $@