-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
158 lines (132 loc) · 3.21 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
# Makefile -- Use this to build on *NIX systems.
# Options set on command line.
debug = not-set
mpi = not-set
shared = not-set
precision = not-set
verbose = not-set
prefix = not-set
sanitize = not-set
CC = not-set
CXX = not-set
FC = not-set
netcdf_fflags = not-set
netcdf_flibs = not-set
# This proxies everything to the builddir cmake.
cputype = $(shell uname -m | sed "s/\\ /_/g")
systype = $(shell uname -s)
BUILDDIR := build/$(systype)-$(cputype)
CONFIG_FLAGS = -DUNIX=1 -Wno-dev
# Process configuration options.
# Verbose builds?
ifeq ($(verbose), 1)
CONFIG_FLAGS += -DCMAKE_VERBOSE_MAKEFILE=1
endif
# MPI
ifeq ($(mpi), 1)
BUILDDIR := ${BUILDDIR}-mpi
CC = mpicc
CXX = mpicxx
FC = mpif90
CONFIG_FLAGS += -DHAVE_MPI=1
else
ifeq ($(CC), not-set)
CC = cc
endif
ifeq ($(CXX), not-set)
CXX = c++
endif
ifeq ($(FC), not-set)
FC = gfortran
endif
CONFIG_FLAGS += -DHAVE_MPI=0
endif
# Shared libs?
ifeq ($(shared), 1)
BUILDDIR := ${BUILDDIR}-shared
CONFIG_FLAGS += -DBUILD_SHARED_LIBS=ON
else
BUILDDIR := ${BUILDDIR}-static
CONFIG_FLAGS += -DBUILD_SHARED_LIBS=OFF
endif
# Precision.
ifneq ($(precision), not-set)
BUILDDIR := ${BUILDDIR}-$(precision)
CONFIG_FLAGS += -DECOSYS_PRECISION=$(precision)
else
BUILDDIR := ${BUILDDIR}-double
CONFIG_FLAGS += -DECOSYS_PRECISION=double
endif
BUILDDIR := ${BUILDDIR}-`basename ${CC}`
CONFIG_FLAGS += -DCC=${CC} -DCXX=${CXX}
ifneq ($(FC), )
CONFIG_FLAGS += -DFC=${FC}
endif
# Debugging symbols
ifeq ($(debug), not-set)
BUILDDIR := ${BUILDDIR}-Debug
CONFIG_FLAGS += -DCMAKE_BUILD_TYPE=Debug
else
ifeq ($(debug), 0)
BUILDDIR := ${BUILDDIR}-Release
CONFIG_FLAGS += -DCMAKE_BUILD_TYPE=Release
else
BUILDDIR := ${BUILDDIR}-Debug
CONFIG_FLAGS += -DCMAKE_BUILD_TYPE=Debug
endif
endif
# Installation prefix.
ifeq ($(prefix), not-set)
prefix = $(CURDIR)/local
endif
CONFIG_FLAGS += -DCMAKE_INSTALL_PREFIX:PATH=$(prefix)
# Special considerations for specific systems.
ifeq ($(systype), Darwin)
CONFIG_FLAGS += -DAPPLE=1
else
ifeq ($(systype), Linux)
CONFIG_FLAGS += -DLINUX=1
endif
endif
# Address sanitizer.
ifeq ($(sanitize), 1)
BUILDDIR := ${BUILDDIR}-AddressSanitizer
CONFIG_FLAGS += -DADDRESS_SANITIZER=1
endif
# netcdf
ifneq ($(netcdf_fflags), not-set)
NETCDF_FFLAGS = $(netcdf_fflags)
else
NETCDF_FFLAGS = $(shell nc-config --prefix)/include
endif
ifneq ($(netcdf_flibs), not-set)
NETCDF_FLIBS = $(netcdf_flibs)
else
NETCDF_FLIBS = $(shell nc-config --flibs)
endif
CONFIG_FLAGS += -DTPL_NETCDF_INCLUDE_DIRS=" $(NETCDF_FFLAGS)"
CONFIG_FLAGS += -DTPL_NETCDF_LIBRARIES="$(NETCDF_FLIBS)"
define run-config
@mkdir -p $(BUILDDIR)
@cd $(BUILDDIR) && cmake $(CURDIR) $(CONFIG_FLAGS)
endef
all test clean install:
@if [ ! -f $(BUILDDIR)/Makefile ]; then \
more INSTALL; \
else \
$(MAKE) -C $(BUILDDIR) $@ --no-print-directory $(MAKEFLAGS); \
fi
config: distclean
$(run-config)
distclean:
@rm -rf $(BUILDDIR)
@rm -rf ./local
stats:
@python tools/gather_stats.py
prepend-license:
@python tools/prepend_license.py
ctags-emacs :
@ctags -e -f ETAGS -R --exclude=.git --exclude=build
#dist:
# utils/mkdist.sh $(PKGNAME)
.PHONY: config distclean all clean install uninstall