This repository has been archived by the owner on Sep 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
makefile_f90
170 lines (122 loc) · 3.84 KB
/
makefile_f90
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
160
161
162
163
164
165
166
167
168
169
170
# ======== COMPILER ========
FC = gfortran
#FC = nagfor
#FC = g95
ifeq ($(FC),nagfor)
OPTNAGFOR = -w=x95 -DNAGFOR
endif
ifeq ($(FC),gfortran)
OPTGFORTRAN = -m64
endif
OPT = $(OPTNAGFOR) $(OPTGFORTRAN) -O3 \
-DSSHT_VERSION=\"1.0b1\" -DSSHT_BUILD=\"`svnversion -n .`\"
#-g3 -ggdb
# ======== LINKS ========
UNAME := $(shell uname)
PROGDIR = ..
SSHTDIR = $(PROGDIR)/ssht
SSHTLIB = $(SSHTDIR)/lib/f90
SSHTLIBNM= ssht
SSHTINC = $(SSHTDIR)/include/f90
SSHTSRC = $(SSHTDIR)/src/f90
SSHTMOD = $(SSHTDIR)/src/f90/mod
SSHTPROG = $(SSHTDIR)/src/f90/prog
SSHTBIN = $(SSHTDIR)/bin/f90
SSHTOBJ = $(SSHTINC)
SSHTDOC = $(SSHTDIR)/doc/f90
FFTWLIB = $(PROGDIR)/fftw/lib
FFTWLIBNM = fftw3
# ======== SOURCE LOCATIONS ========
vpath %.f90 $(SSHTMOD)
vpath %.f90 $(SSHTPROG)
# ======== FFFLAGS ========
ifeq ($(FC),nagfor)
FFLAGSNAGFOR = -mdir $(SSHTINC)
endif
ifeq ($(FC),gfortran)
FFLAGSGFORTRAN = -J$(SSHTINC)
endif
FFLAGS = -I$(SSHTINC) $(FFLAGSNAGFOR) $(FFLAGSGFORTRAN)
# ======== LDFLAGS ========
LDFLAGS = -L$(SSHTLIB) -l$(SSHTLIBNM) \
-L$(FFTWLIB) -l$(FFTWLIBNM)
# ======== PPFLAGS ========
ifeq ($(FC),nagfor)
PPFLAGS = -fpp $(OPT)
else ifeq ($(FC),g95)
PPFLAGS = -cpp $(OPT)
else ifeq ($(FC),gfortran)
PPFLAGS = -cpp $(OPT)
endif
# ======== OBJECT FILES TO MAKE ========
SSHTOBJS = $(SSHTOBJ)/ssht_types_mod.o \
$(SSHTOBJ)/ssht_error_mod.o \
$(SSHTOBJ)/ssht_dl_mod.o \
$(SSHTOBJ)/ssht_sampling_mod.o \
$(SSHTOBJ)/ssht_core_mod.o
# ======== MAKE RULES ========
$(SSHTOBJ)/%.o: %.f90
$(FC) $(FFLAGS) $(FFLAGSPROG) $(PPFLAGS) -c $< -o $@
.PHONY: default
default: lib test about
.PHONY: all
all: lib test about
.PHONY: test
test: $(SSHTBIN)/ssht_test about
.PHONY: runtest
runtest: test
$(SSHTBIN)/ssht_test 64 0
# Library
.PHONY: lib
lib: $(SSHTLIB)/lib$(SSHTLIBNM).a
$(SSHTLIB)/lib$(SSHTLIBNM).a: $(SSHTOBJS)
ar -r $(SSHTLIB)/lib$(SSHTLIBNM).a $(SSHTOBJS)
# Documentation
.PHONY: doc
doc:
doxygen $(SSHTSRC)/doxygen.config
.PHONY: cleandoc
cleandoc:
rm -f $(SSHTDOC)/html/*
# Cleaning up
.PHONY: clean
clean: tidy
rm -f $(SSHTOBJ)/*.mod
rm -f $(SSHTOBJ)/*.o
rm -f $(SSHTLIB)/lib$(SSHTLIBNM).a
rm -f $(SSHTBIN)/*
.PHONY: tidy
tidy:
rm -f $(SSHTMOD)/*~
rm -f $(SSHTPROG)/*~
.PHONY: cleanall
cleanall: clean cleandoc
# Module dependencies
$(SSHTOBJ)/ssht_types_mod.o: $(SSHTMOD)/ssht_types_mod.f90
$(SSHTOBJ)/ssht_error_mod.o: $(SSHTMOD)/ssht_error_mod.f90 \
$(SSHTOBJ)/ssht_types_mod.o
$(SSHTOBJ)/ssht_dl_mod.o: $(SSHTMOD)/ssht_dl_mod.f90 \
$(SSHTOBJ)/ssht_types_mod.o
$(SSHTOBJ)/ssht_sampling_mod.o: $(SSHTMOD)/ssht_sampling_mod.f90 \
$(SSHTOBJ)/ssht_types_mod.o \
$(SSHTOBJ)/ssht_error_mod.o
$(SSHTOBJ)/ssht_core_mod.o: $(SSHTMOD)/ssht_core_mod.f90 \
$(SSHTOBJ)/ssht_types_mod.o \
$(SSHTOBJ)/ssht_error_mod.o \
$(SSHTOBJ)/ssht_sampling_mod.o \
$(SSHTOBJ)/ssht_dl_mod.o
# Program dependencies and compilation
$(SSHTOBJ)/ssht_test.o: $(SSHTPROG)/ssht_test.f90 $(SSHTLIB)/lib$(SSHTLIBNM).a
$(SSHTBIN)/ssht_test: $(SSHTOBJ)/ssht_test.o
$(FC) \
-o $(SSHTBIN)/ssht_test \
$(SSHTOBJ)/ssht_test.o \
$(LDFLAGS) $(PPFLAGS)
.PHONY: about
about: $(SSHTBIN)/ssht_about
$(SSHTOBJ)/ssht_about.o: $(SSHTPROG)/ssht_about.f90
$(SSHTBIN)/ssht_about: $(SSHTOBJ)/ssht_about.o lib
$(FC) \
-o $(SSHTBIN)/ssht_about \
$(SSHTOBJ)/ssht_about.o \
$(LDFLAGS) $(PPFLAGS)