This repository has been archived by the owner on Aug 15, 2018. It is now read-only.
forked from bendudson/BOUT
-
Notifications
You must be signed in to change notification settings - Fork 5
/
make.config.franklin
202 lines (159 loc) · 7.43 KB
/
make.config.franklin
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
# configuration file for BOUT++
# September 2008: Converted to use autoconf. Can be manually edited
# for the (very) rare occasions when autoconf fails
# extra compilation flags:
# -DCHECK Enables a host of additional checks on each operation
# such as uninitialised data. Helps when debugging
# -DTRACK Keeps track of variable names.
# Enables more useful error messages
# for SSE2: -msse2 -mfpmath=sse
#
# This must also specify one or more file formats
# -DPDBF PDB format (need to include pdb_format.cxx)
# -DNCDF NetCDF format (nc_format.cxx)
# Created this variable so that a user won't overwrite the CFLAGS variable
# on the command line, just add to this one
BOUT_FLAGS = $(CFLAGS) -O -DCHECK=2 -DSIGHANDLE -DNCDF -DBOUT_HAS_PVODE
# Specify the MPI C++ compiler in CXX
CXX = CC
CC = $(CXX)
AR = ar
RANLIB = ranlib
MKDIR = mkdir -p
####################################################################
# Do not need to alter anything below
####################################################################
LD = $(CXX)
####################################################################
# Extra (optional) source files, includes and libs
# NOTE: EXTRA_SRC must include a solver (solver.cxx or ida_solver.cxx)
# and a file format (nc_format.cxx or pdb_format.cxx)
####################################################################
EXTRA_INCS = -I/opt/fftw/3.2.2.1/include -I/opt/cray/netcdf/4.1.1.0/netcdf-pgi//include
EXTRA_LIBS = -L/opt/fftw/3.2.2.1/lib -lfftw3 -L/opt/cray/netcdf/4.1.1.0/netcdf-pgi//lib -lnetcdf_c++ -lnetcdf -L$(BOUT_TOP)/lib -lpvode -lpvpre -L/opt/cray/hdf5/default/hdf5-pgi/lib/ -lhdf5_cpp -lhdf5_hl -lhdf5 -lz
PRECON_SOURCE =
FILEIO_SOURCE = nc_format.cxx
FACETS_SOURCE =
####################################################################
# These are used for compiling physics modules using BOUT++ library
####################################################################
# Files that are needed by configure and should be dependencies for 'all'
OBJ = $(SOURCEC:%.cxx=%.o)
LIB = $(BOUT_TOP)/lib/libbout++.a
BOUT_INCLUDE = -I$(BOUT_TOP)/include $(CXXINCLUDE) $(EXTRA_INCS)
BOUT_LIBS = -lm -L$(BOUT_TOP)/lib -lbout++ $(EXTRA_LIBS)
DEPS = $(SOURCEC:.cxx=.d)
CHANGED = $(shell find -f $(BOUT_TOP)/include $(BOUT_TOP)/src -type f \( -name \*.cxx -or -name \*.h \) -newer $(LIB) -print 2> /dev/null)
# Need to use ifndef because TARGET could be set in a file (as opposed to the command line or environment variable)
# This will set a default if no TARGET is provided
ifndef TARGET
TARGET = $(SOURCEC:%.cxx=%)
endif
####################################################################
# Definining stuff for recursive make
####################################################################
# Phony targets since they are directory names
.PHONY: $(DIRS) lib install
all: $(BOUT_TOP)/config.status $(BOUT_TOP)/make.config $(DIRS) $(TARGET)
####################################################################
# Recursively run make through subdirs
####################################################################
$(DIRS):
@$(MAKE) --no-print-directory -s -C $@ all
# Create 'lib' and 'include' incase they don't exist
$(BOUT_TOP)/include $(BOUT_TOP)/lib:
$(MKDIR) $@
####################################################################
# Install header files and libraries
####################################################################
prefix = /usr/local
exec_prefix = ${prefix}
install: all
@$(MKDIR) $(DESTDIR)${prefix}
@$(MKDIR) $(DESTDIR)${prefix}/include
@$(MKDIR) $(DESTDIR)${prefix}/lib
@echo "Installing header files into $(DESTDIR)${prefix}/include"
@cp include/*.hxx $(DESTDIR)${prefix}/include
@echo "Installing library files into $(DESTDIR)${exec_prefix}/lib"
@cp lib/*.a $(DESTDIR)${exec_prefix}/lib
####################################################################
# A bit of a clever hack that determines wheter the TARGET variable is 'lib'
# then, if true, adds the .o files to libbout++.a, else, it links the .o's
# into an executable
####################################################################
ifeq ("$(TARGET)", "lib")
#BEGIN 'lib'
####################################################################
# The prerquisites of any .o file should depend on
# $(BOUT_TOP)/make.config
# $(BOUT_TOP)/makefile
# which are generated by configuration
####################################################################
-include $(DEPS)
# This automatically generates dependency rules
%.d : %.cxx
-@$(CXX) $(BOUT_INCLUDE) $(BOUT_FLAGS) -MF"$@" -MG -MP -MM -MT"$(<:.cxx=.o)" -fsyntax-only "$<" 2> /dev/null
####################################################################
# Notes about the different flags:
# -MF write the generated dependency rule to a file
# -MG assume missing headers will be generated and don't stop with an error
# -MM generate dependency rule for prerequisite, skipping system headers
# -MP add phony target for each header to prevent errors when header is missing
# -MT add a target to the generated dependency
####################################################################
####################################################################
# Builds the library with $(OBJ) which is defined from the SOURCEC variable
####################################################################
lib: makefile $(BOUT_TOP)/make.config $(BOUT_TOP)/include $(BOUT_TOP)/lib $(OBJ)
ifneq ("$(OBJ)foo", "foo")
@echo "Adding $(OBJ) to libbout++.a"
@$(AR) cru $(LIB) $(OBJ)
@$(RANLIB) $(LIB)
endif
#END 'lib'
else
####################################################################
# Make libbout++.a if it doesn't exist with the checklib target
####################################################################
%.a:
@echo "Rebuilding out-of-date bout++ library"
@$(MAKE) --no-print-directory -C $(BOUT_TOP)
####################################################################
# Make the target (e.g. gas_compress)
####################################################################
$(TARGET).cxx: checklib
$(TARGET).o: $(LIB)
$(TARGET): makefile $(BOUT_TOP)/make.config $(OBJ)
@echo " Linking" $(TARGET)
@$(LD) -o $(TARGET) $(OBJ) $(BOUT_LIBS)
checklib:
ifneq ("$(CHANGED)foo", "foo")
@echo "Rebuilding out-of-date bout++ library"
@$(MAKE) --no-print-directory -C $(BOUT_TOP)
endif
endif
%.o: $(BOUT_TOP)/make.config %.cxx
@echo " Compiling " $(@F:.o=.cxx)
@$(CXX) $(BOUT_INCLUDE) $(BOUT_FLAGS) -c $(@F:.o=.cxx) -o $@
####################################################################
# Clean target. Pretty self explanatory.
# NOTE: See that double colon (::) below? That's signifies a rule that can be added to later
# See:
# http://owen.sj.ca.us/~rk/howto/slides/make/slides/makecolon.html
####################################################################
clean::
-@$(RM) -rf $(OBJ) $(DEPS) $(TARGET)
@for pp in $(DIRS); do echo " " $$pp cleaned; $(MAKE) --no-print-directory -C $$pp clean; done
distclean: clean
@echo include cleaned
# Removing the externalpackage installation. When we have more packages, need a better way
@$(RM) -rf $(BOUT_TOP)/include/pvode
@echo lib cleaned
@$(RM) -rf $(BOUT_TOP)/lib/*
-@$(RM) $(BOUT_TOP)/externalpackages/PVODE/lib/*.a
-@$(RM) $(BOUT_TOP)/externalpackages/PVODE/source/obj/*.o
-@$(RM) $(BOUT_TOP)/externalpackages/PVODE/precon/obj/*.o
-@$(RM) -rf $(BOUT_TOP)/autom4te.cache make.config
@echo externalpackages cleaned
@touch $(BOUT_TOP)/configure
@echo autom4te.cache cleaned