-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathMakefile
201 lines (136 loc) · 5.25 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
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#
# --- Makefile for Kiwi Core Tools ---
#
# Override default settings in file 'Makefile.local'
# (see 'Makefile.local.example')
#
#### Basic settings ------------------------------------------------------------
SHELL = /bin/sh
MAKEDEPEND = ./fdepend.pl -g -d -i hdf5.mod -i omp_lib.mod -i kiwi_home.mod
OBJDEPEND = ./objdepend.pl
FORTRANC := gfortran
INSTALL := /usr/bin/install
#### Preset selection ----------------------------------------------------------
# Can use 'fast' or 'debug' with gfortran, g95 and ifort. You may have to create
# a custom preset when using a different compiler (see below and example in
# Makefile.local.example).
PRESET := fast
#### Installation prefixes -----------------------------------------------------
prefix = /usr/local
datarootdir = $(prefix)/share
datadir = $(datarootdir)
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
#### Default library includes and linker settings ------------------------------
INCDUMMYOMP = -Idummy_omp_lib
LIBDUMMYOMP = dummy_omp_lib/omp_lib.o
INCMSEED =
LIBMSEED = mseed/mseed_simple.o -lmseed
INCHDF = $(shell pkg-config hdf5 --cflags)
LIBHDF = $(shell pkg-config hdf5 --libs-only-L) -lhdf5_fortran -lhdf5 -lz
INCSAC =
LIBSAC = -lsacio
INCFFTW =
LIBFFTW = -lfftw3f
LIBSMINPACK = -Lsminpack -lsminpack
#### Compiler and linker flag defaults -----------------------------------------
CFLAGS = $(INCMSEED) $(INCHDF) $(INCSAC) $(INCFFTW) \
$(CFLAGS_$(FORTRANC)_$(PRESET)) #
LDFLAGS = $(LIBMSEED) $(LIBSAC) $(LIBHDF) $(LIBSMINPACK) $(LIBFFTW) \
$(LDFLAGS_$(FORTRANC)_$(PRESET)) #
#### Compiler specific presets ------------------------------------------------
CFLAGS_ifort_fast = -openmp
LDFLAGS_ifort_fast = -openmp
CFLAGS_ifort_debug = -openmp -g -warn all -ftrapuv -debug all
LDFLAGS_ifort_debug = -openmp
CFLAGS_g95_fast = $(INCDUMMYOMP) -O3
LDFLAGS_g95_fast = $(LIBDUMMYOMP)
CFLAGS_g95_debug = $(INCDUMMYOMP) -g -Wall -ftrace=full -fbounds-check
LDFLAGS_g95_debug = $(LIBDUMMYOMP) -g -Wall -ftrace=full -fbounds-check
CFLAGS_gfortran_fast = $(INCDUMMYOMP) -O3
LDFLAGS_gfortran_fast = $(LIBDUMMYOMP)
CFLAGS_gfortran_debug = $(INCDUMMYOMP) -g -Wall
LDFLAGS_gfortran_debug = $(LIBDUMMYOMP)
#### ---------------------------------------------------------------------------
MACHINE := $(shell ./hostinfo.pl --machine)
OS := $(shell ./hostinfo.pl --os)
-include Makefile.local
# communicate compiler settings to submake (for sminpack)
export FORTRANC
SRCS := $(shell ls *.f90)
TARGETS := eulermt source_info minimizer gfdb_build gfdb_extract gfdb_redeploy \
gfdb_info gfdb_specialextract gfdb_build_ahfull differential_azidist \
eikonal_benchmark crust ahfull
TESTS_SRCS := $(shell ls test_*.f90)
TESTS = $(TESTS_SRCS:.f90=)
.PHONY : clean clean-deps tests targets all check install uninstall
# reset make's default suffix list for implicit rules, set our own
.SUFFIXES :
.SUFFIXES : .f90 .o .d .mod
all : targets
$(TARGETS) $(TESTS) : .sminpackdone .mseedsimple .dummyomplib .dummysacio
kiwi_home.f90 :
echo "module kiwi_home" > kiwi_home.f90
echo "character (len=*), parameter :: kiwi_home_dir = \"$(datadir)/kiwi\"" >> kiwi_home.f90
echo "end module" >> kiwi_home.f90
.sminpackdone :
$(MAKE) -C sminpack/ && touch .sminpackdone
.mseedsimple :
$(MAKE) -C mseed/ && touch .mseedsimple
.dummyomplib :
$(MAKE) -C dummy_omp_lib/ && touch .dummyomplib
.dummysacio :
$(MAKE) -C dummy_sacio/ && touch .dummysacio
targets : $(TARGETS)
install : targets
$(INSTALL) -d $(bindir)
$(INSTALL) $(TARGETS) $(bindir)
$(INSTALL) -d $(datadir)/kiwi
for f in `find aux -type d -and -not -path '*/.svn*'` ; do \
$(INSTALL) -d $(datadir)/kiwi/$$f ; done
for f in `find aux -type f -and -not -path '*/.svn/*'` ; do \
$(INSTALL) $$f $(datadir)/kiwi/$$f ; done
@echo
@echo '-----------------------------------------------------------------------'
@echo ' Installation complete.'
@echo ' Please adjust your environment variables:'
@echo
@echo ' * PATH should contain:'
@echo ' ' $(bindir)
@echo '-----------------------------------------------------------------------'
uninstall :
rm -rf -d $(datadir)/kiwi
cd $(bindir) ; rm -f $(TARGETS)
tests : $(TESTS)
printvars :
@echo FORTRANC = $(FORTRANC)
@echo CFLAGS = $(CFLAGS)
@echo LDFLAGS = $(LDFLAGS)
check : tests
@for t in $(TESTS); do ./$$t ; done
$(TARGETS) $(TESTS) :
$(FORTRANC) $(filter %.o,$^) $(OMPLIB_$(FORTRANC)) $(LDFLAGS) -o $@
# implicit rules for generating depfiles
%.d : %.f90
@$(MAKEDEPEND) $<
@echo determining dependencies for $<...
progobjects.do : $(SRCS:.f90=.d)
@$(OBJDEPEND) $(TARGETS) $(TESTS) -- $(SRCS:.f90=.d) > $@
@echo determining dependencies for executables...
# implicit rule for compiling
%.o : %.f90
$(FORTRANC) -c $(CFLAGS) $<
kiwi_home.o kiwi_home.mod : kiwi_home.f90
$(FORTRANC) -c $(CFLAGS) $<
minimizer.o : kiwi_home.mod
clean :
rm -f *.o *.mod $(TESTS) $(TARGETS) .sminpackdone .mseedsimple .dummysacio .dummyomplib dummy_omp_lib/omp_lib.o dummy_omp_lib/omp_lib.mod kiwi_home.f90
$(MAKE) -C sminpack/ clean
$(MAKE) -C mseed/ clean
$(MAKE) -C dummy_omp_lib/ clean
$(MAKE) -C dummy_sacio/ clean
clean-deps : clean
rm -f *.d *.do
# include auto-created dependencies
-include progobjects.do
-include $(SRCS:.f90=.d)