-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
224 lines (182 loc) · 5.4 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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# Define VPATH
VPATH ?= $(shell pwd)
# Define default target:
.PHONY: default
default: lib
# SMEKASETTINGS (DO NOT DELETE)
# DO NOT CHANGE CONTENT IN THIS BLOCK
# IT MAY BE OVERWRITTEN WHEN REINSTALLING SMEKA
#
# This Makefile was created by smeka:
# github.com/zerothi/smeka
# Top-directory of Makefile/source tree
# If need set, do so ABOVE this block!
TOP_DIR ?= .
# Directory of smeka default Makefiles
SMEKA_DIR = smeka
# Include the smeka settings!
include $(TOP_DIR)/$(SMEKA_DIR)/Makefile.smeka
# SMEKAENDSETTINGS (DO NOT DELETE)
# Define internal fdict library build
.PHONY: prep-fdict lib-fdict clean-fdict
prep-fdict:
($(MKDIR) $(MKDIR_FLAG_PARENT) fdict/obj ; cd fdict/obj ; \
$(ECHO) "TOP_DIR =../../$(TOP_DIR)/fdict" > Makefile ; \
$(ECHO) "include ../../$(TOP_DIR)/fdict/Makefile" >> Makefile )
lib-fdict: prep-fdict
ifdef SETUP
$(MAKE) -C fdict/obj SETUP=../../$(SETUP)
else
$(MAKE) -C fdict/obj
endif
install-fdict:
ifdef SETUP
$(MAKE) -C fdict/obj SETUP=../../$(SETUP) $(MAKECMDGOALS)
else
$(MAKE) -C fdict/obj $(MAKECMDGOALS)
endif
clean-fdict: prep-fdict
ifdef SETUP
$(MAKE) -C fdict/obj SETUP=../../$(SETUP) clean
else
$(MAKE) -C fdict/obj clean
endif
# Define options for compilation
#### MPI
MPI ?= 0
ifneq ($(MPI),0)
# Define a parallel NCDF
FPPFLAGS += -DNCDF_PARALLEL
endif
ifneq (,$(findstring -UNCDF_PARALLEL,$(FPPFLAGS)))
# user wants to disable NCDF_PARALLEL
MPI=0
else
ifneq (,$(findstring -DNCDF_PARALLEL,$(FPPFLAGS)))
MPI=1
endif
endif
#### NetCDF-4 API
CDF ?= 3
ifeq ($(CDF),4)
# Define NetCDF with _4 support
FPPFLAGS += -DNCDF_4
endif
# Force if set by the user
ifneq (,$(findstring -UNCDF_4,$(FPPFLAGS)))
# user wants to disable NCDF_4
CDF = 3
else
ifneq (,$(findstring -DNCDF_4,$(FPPFLAGS)))
CDF = 4
endif
endif
# The linker is a fortran compiler
LINK := $(FC)
##
# Figure out if the fdict library is linked manually.
# In this case we do not add dependency on the
ifeq (,$(findstring fdict,$(LIBS)))
# In this instance the fdict library is build internally
# Not found, we need to create correct dependency.
$(OBJECTS): lib-fdict
$(NCDF_LIB_STATIC): | lib-fdict
$(NCDF_LIB_SHARED): | lib-fdict
# Add clean-target dependency
clean: clean-fdict
install: install-fdict
# Now create the correct linker flags etc. for internal linking
INCLUDES += -Ifdict/obj
# For tests
LIBS += -Lfdict/obj -lfdict
# When using the internal library we force the copy (the user
# *must* not change the settings)
settings.bash: lib-fdict FORCE
-$(CP) fdict/obj/settings.bash .
.PHONY: copy-fdict copy
copy-fdict: prep-fdict
$(MAKE) -C fdict/obj copy
copy: copy-fdict
else
# In this instance the fdict library is supplied externally
# The variable FDICT_PREFIX should be present
ifdef FDICT_PREFIX
settings.bash: FORCE
-cp $(FDICT_PREFIX)/bin/settings.bash .
else
$(info ncdf-build:)
$(info ncdf-build: FDICT_PREFIX is not defined, we default to the internal one)
$(info ncdf-build:)
settings.bash:
VPATH=$(TOP_DIR) $(TOP_DIR)/setup.sh --default
endif
endif
# Create target
.PHONY: lib
lib: settings.bash netcdf_ncdf.inc
# Include the makefile in the src directory
include $(TOP_DIR)/src/Makefile.inc
# Include the makefile in the test directory
include $(TOP_DIR)/test/Makefile.inc
# Libraries depend on the objects
ifneq ($(LIBRARIES),)
$(LIBRARIES): $(OBJECTS)
$(OBJECTS): settings.bash
lib: $(LIBRARIES)
endif
##
# This handy target copies from the SOURCES_DIR all sources
# to the current directory
# But ONLY if the current directory is not the top of the project
.PHONY: copy-ncdf copy
copy-ncdf:
ifeq ($(TOP_DIR),.)
@$(ECHO) ""
@$(ECHO) "make copy does not work when executed from the top ncdf directory"
@$(ECHO) "Please create an object directory with an appropriate Makefile"
@$(ECHO) ""
else
$(CP) $(SOURCES_DIR)/src/*.f90 $(SOURCES_DIR)/src/*.inc .
endif
copy: copy-ncdf
# Create source target for creating _only_ the sources.
.PHONY: source
source: source-src
# Dependent on the option we can fake a VPATH to contain
# any pre-created sources, if they exist we can simply use those
SOURCES_DIR = $(TOP_DIR)/sources
ifeq ($(CDF),4)
SOURCES_DIR := $(SOURCES_DIR)_4
endif
ifneq ($(MPI),0)
SOURCES_DIR := $(SOURCES_DIR)_parallel
endif
##
# Distribution targets for creating the distribution of flook
# Create distribution for releases
.PHONY: dist-fdict dist-ncdf dist-assemble dist
dist-fdict:
git submodule sync fdict
git submodule init fdict
git submodule update fdict
(cd fdict ; make dist ; mv fdict-*.tar.gz .. )
dist-ncdf:
git archive --format=tar --prefix ncdf-$(PROJECT_VERSION)/ HEAD > ncdf-$(PROJECT_VERSION).tar
# Force the creation of the 3 pre-defined source directories
$(MAKE) source CDF=3 MPI=0
$(MAKE) source CDF=4 MPI=0
$(MAKE) source CDF=4 MPI=1
# Clean up
$(RM) *.inc
tar --transform 's,^,ncdf-$(PROJECT_VERSION)/,' -rf ncdf-$(PROJECT_VERSION).tar sources*
-@$(RM) $(RM_FLAG_FORCE) ncdf-$(PROJECT_VERSION).tar.gz
gzip ncdf-$(PROJECT_VERSION).tar
dist-assemble: dist-fdict dist-ncdf
-$(RM) $(RM_FLAG_FORCE) $(RM_FLAG_RECURSE) .tmp_dist
($(MKDIR) .tmp_dist ; cd .tmp_dist ; \
tar xfz ../ncdf-$(PROJECT_VERSION).tar.gz ; cd ncdf-$(PROJECT_VERSION) ; \
tar xfz ../../fdict-*.tar.gz ; mv fdict-*/* fdict/ ; $(RM) $(RM_FLAG_FORCE) $(RM_FLAG_RECURSE) fdict-* ; \
cd .. ; $(RM) ../ncdf-$(PROJECT_VERSION).tar.gz ; \
tar cfz ../ncdf-$(PROJECT_VERSION).tar.gz ncdf-$(PROJECT_VERSION) ; \
$(RM) $(RM_FLAG_FORCE) $(RM_FLAG_RECURSE) .tmp_dist ../fdict-*.tar.gz)
dist: dist-assemble