1 |
#--------------------------------------------------------------------------- |
2 |
# (C) 1999 - 2002 Jacob Dreyer - Geotechnical Software Services |
3 |
# jacob.dreyer@geosoft.no - http://geosoft.no |
4 |
# |
5 |
# This program is free software; you can redistribute it and/or |
6 |
# modify it under the terms of the GNU General Public License |
7 |
# as published by the Free Software Foundation; either version 2 |
8 |
# of the License, or (at your option) any later version. |
9 |
# |
10 |
# This program is distributed in the hope that it will be useful, |
11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 |
# GNU General Public License for more details. |
14 |
# |
15 |
# You should have received a copy of the GNU General Public License |
16 |
# along with this program; if not, write to the Free Software |
17 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 |
# MA 02111-1307, USA. |
19 |
#--------------------------------------------------------------------------- |
20 |
#--------------------------------------------------------------------------- |
21 |
# |
22 |
# GnuMake crash course: |
23 |
# |
24 |
# target : depends |
25 |
# rule |
26 |
# |
27 |
# target - the parameter given to make. I.e. what to build |
28 |
# depends - file or other targets target depends on |
29 |
# rule - how to create target (note that rule is preceeded by a TAB char) |
30 |
# $(VAR) - environment variable or variable defined above |
31 |
# $@ - Current target |
32 |
# $* - Current target without extension |
33 |
# $< - Current dependency |
34 |
# |
35 |
#--------------------------------------------------------------------------- |
36 |
IS_UNIX=1 |
37 |
|
38 |
#packages containing libraries |
39 |
PackageLibs = \ |
40 |
utils \ |
41 |
visitors \ |
42 |
math \ |
43 |
types \ |
44 |
primitives \ |
45 |
UseTheForce/DarkSide \ |
46 |
UseTheForce \ |
47 |
brains \ |
48 |
io \ |
49 |
integrators\ |
50 |
constraints \ |
51 |
minimizers \ |
52 |
selection \ |
53 |
restraints \ |
54 |
lattice \ |
55 |
hydrodynamics \ |
56 |
openbabel\ |
57 |
antlr\ |
58 |
mdParser |
59 |
#packages containing applications |
60 |
Applications = \ |
61 |
applications/oopse \ |
62 |
applications/dump2Xyz \ |
63 |
applications/staticProps \ |
64 |
applications/dynamicProps \ |
65 |
applications/simpleBuilder \ |
66 |
applications/randomBuilder \ |
67 |
applications/nanoparticleBuilder \ |
68 |
applications/thermalizer \ |
69 |
applications/atom2md \ |
70 |
applications/hydrodynamics \ |
71 |
applications/utilities |
72 |
|
73 |
|
74 |
Samples = \ |
75 |
samples/builders \ |
76 |
samples/alkane \ |
77 |
samples/argon \ |
78 |
samples/cutoff \ |
79 |
samples/dipole \ |
80 |
samples/gbljtest \ |
81 |
samples/lipid \ |
82 |
samples/metals/EAM \ |
83 |
samples/metals/EAM/nanoparticle \ |
84 |
samples/metals/EAM/nanorod \ |
85 |
samples/metals/Sutton-Chen \ |
86 |
samples/minimizer \ |
87 |
samples/thermoIntegration/liquid \ |
88 |
samples/thermoIntegration/solid \ |
89 |
samples/water/dimer \ |
90 |
samples/water/spce \ |
91 |
samples/water/ssd \ |
92 |
samples/water/ssde \ |
93 |
samples/water/ssdrf \ |
94 |
samples/water/ssd-ion \ |
95 |
samples/water/tip3p_ice \ |
96 |
samples/water/tip4p \ |
97 |
samples/zcons |
98 |
|
99 |
IncludeDirs = \ |
100 |
@MPI_INC_DIR@ \ |
101 |
@FFTW_INC_DIR@ \ |
102 |
@QHULL_INC_DIR@ \ |
103 |
@ZLIB_INC_DIR@ |
104 |
|
105 |
LibraryDirs = \ |
106 |
@MPI_LIB_DIR@ \ |
107 |
@FFTW_LIB_DIR@ \ |
108 |
@QHULL_LIB_DIR@ \ |
109 |
@CGAL_LIB_DIR@ \ |
110 |
@ZLIB_LIB_DIR@ |
111 |
|
112 |
Libraries = \ |
113 |
@LIBS@ \ |
114 |
@MPI_LIB@ \ |
115 |
@MPI_F90_LIB@ \ |
116 |
@FFTW_LIBS@ \ |
117 |
@QHULL@ \ |
118 |
@CGAL_LIBS@ \ |
119 |
@ZLIB@ |
120 |
|
121 |
OopseHome = @OOPSE_HOME@ |
122 |
ForceParamDir = $(OopseHome)/forceFields |
123 |
SampleSimDir = $(OopseHome)/samples |
124 |
InstallBinDir = $(OopseHome)/bin |
125 |
DocDir = $(OopseHome)/doc |
126 |
FrcDeclare = -DFRC_PATH="$(ForceParamDir)" |
127 |
F90Declare = -D__FORTRAN90 |
128 |
UseSingle = @USE_SINGLE_PRECISION@ |
129 |
ifeq "$(UseSingle)" "yes" |
130 |
SingleDeclare = -DSINGLE_PRECISION |
131 |
else |
132 |
SingleDeclare = |
133 |
endif |
134 |
ParallelDeclare = -DIS_MPI |
135 |
SinglePrecision = -DSINGLE_PRECISION |
136 |
UseMPI = @USE_MPI@ |
137 |
ModuleCase = @F90_MODULE_NAMES@ |
138 |
ModSuffix = @MOD@ |
139 |
LinkOptions = \ |
140 |
@LDFLAGS@ \ |
141 |
@FCLIBS@ \ |
142 |
@CXXFLAGS@ |
143 |
|
144 |
|
145 |
ParallelLinkOptions = \ |
146 |
@LDFLAGS@ \ |
147 |
@FCLIBS@ \ |
148 |
@CXXFLAGS@ |
149 |
|
150 |
#--------------------------------------------------------------------------- |
151 |
# |
152 |
# Directories |
153 |
# |
154 |
#--------------------------------------------------------------------------- |
155 |
|
156 |
SourceDir = $(DEV_ROOT)/src |
157 |
TargetDir = $(DEV_ROOT)/obj |
158 |
ParallelTargetDir = $(DEV_ROOT)/MPIobj |
159 |
LibDir = $(DEV_ROOT)/lib |
160 |
MakeDir = $(DEV_ROOT)/make |
161 |
MainMakefile = $(MakeDir)/Makefile |
162 |
BinDir = $(DEV_ROOT)/bin |
163 |
DocsDir = $(DEV_ROOT)/docs |
164 |
CurrentDir = $(CURDIR) |
165 |
CombinedStaticLib = $(LibDir)/libOOPSE.a |
166 |
CombinedParallelStaticLib = $(LibDir)/libOOPSE_MPI.a |
167 |
|
168 |
ifdef Source |
169 |
#get the relative path of current package to source directory |
170 |
# /home/maul/gezelter/src/code/src/UseTheForce/Darkside --> UseTheForce/Darkside |
171 |
#Package = $(shell echo $(CurrentDir) | sed -e 's/^.*\/src\/\(.*\)/\1/g') |
172 |
#use shell script to get the absolute path and then rip it off from $(CurrentDir) |
173 |
#Package = $(subst $(shell cd $(SourceDir); pwd)/,,$(CurrentDir)) |
174 |
# REMINDER: We are now using the Package line in each subdir makefile. |
175 |
# This avoids the strange path problem and the subshell |
176 |
|
177 |
PackageList = $(Package) |
178 |
PackageSourceDir = $(SourceDir)/$(Package) |
179 |
PackageTargetDir = $(TargetDir) |
180 |
PackageParallelTargetDir = $(ParallelTargetDir) |
181 |
JavaMainClass = $(subst /,.,$(Package)).$(Main) |
182 |
else |
183 |
PackageList = $(PackageLibs) $(JavaPackages) $(Applications) |
184 |
endif |
185 |
|
186 |
PackageListLoop = $(patsubst %,$(SourceDir)/%/.loop,$(PackageList)) |
187 |
|
188 |
JRE = $(JAVA_HOME)/jre/lib/rt.jar |
189 |
|
190 |
ifdef IS_UNIX |
191 |
X = : |
192 |
else |
193 |
X = \; |
194 |
endif |
195 |
|
196 |
#--------------------------------------------------------------------------- |
197 |
# |
198 |
# Classification of files |
199 |
# |
200 |
#--------------------------------------------------------------------------- |
201 |
|
202 |
# Source |
203 |
JavaFiles = $(filter %.java, $(Source)) |
204 |
CppFiles = $(filter %.cpp, $(Source)) |
205 |
CFiles = $(filter %.c, $(Source)) |
206 |
FortranFiles = $(filter %.f, $(Source)) |
207 |
F90Files = $(filter %.F90, $(Source)) |
208 |
CorbaFiles = $(filter %.idl, $(Source)) |
209 |
LexFiles = $(filter %.l, $(Source)) |
210 |
YaccFiles = $(filter %.y, $(Source)) |
211 |
OtherSourceFiles = $(filter-out $(JavaFiles) $(CppFiles) $(CFiles) \ |
212 |
$(FortranFiles) $(F90Files) $(LexFiles) \ |
213 |
$(YaccFiles) $(CorbaFiles), \ |
214 |
$(Source)) |
215 |
ManifestFile = $(PackageSourceDir)/Manifest |
216 |
|
217 |
SourceFiles = $(JavaFiles)\ |
218 |
$(CppFiles)\ |
219 |
$(CFiles)\ |
220 |
$(FortranFiles)\ |
221 |
$(F90Files)\ |
222 |
$(LexFiles)\ |
223 |
$(YaccFiles) |
224 |
|
225 |
# Target |
226 |
JavaClassFiles = $(JavaFiles:%.java= $(PackageTargetDir)/%.class) |
227 |
JavaClassFilesRel = $(JavaFiles:%.java= $(Package)/%.class) |
228 |
RmiStubFiles = $(RmiSource:%.java= $(PackageTargetDir)/%_Stub.class) |
229 |
RmiSkeletonFiles = $(RmiSource:%.java= $(PackageTargetDir)/%_Skel.class) |
230 |
JniClassFiles = $(JniSource:%.java= $(PackageTargetDir)/%.class) |
231 |
JniHeaders = $(JniSource:%.java= $(PackageSourceDir)/%.h) |
232 |
ObjectFiles = $(CFiles:%.c= $(PackageTargetDir)/%.o)\ |
233 |
$(CppFiles:%.cpp= $(PackageTargetDir)/%.o)\ |
234 |
$(FortranFiles:%.f= $(PackageTargetDir)/%.o)\ |
235 |
$(F90Files:%.F90= $(PackageTargetDir)/%.o)\ |
236 |
$(LexFiles:%.l= $(PackageTargetDir)/%.o)\ |
237 |
$(YaccFiles:%.y= $(PackageTargetDir)/%.o) |
238 |
ParallelObjectFiles = $(CFiles:%.c= $(PackageParallelTargetDir)/%.o)\ |
239 |
$(CppFiles:%.cpp= $(PackageParallelTargetDir)/%.o)\ |
240 |
$(FortranFiles:%.f= $(PackageParallelTargetDir)/%.o)\ |
241 |
$(F90Files:%.F90= $(PackageParallelTargetDir)/%.o)\ |
242 |
$(LexFiles:%.l= $(PackageParallelTargetDir)/%.o)\ |
243 |
$(YaccFiles:%.y= $(PackageParallelTargetDir)/%.o) |
244 |
|
245 |
DerivedSource = $(YaccFiles:%.y= %.h) \ |
246 |
$(YaccFiles:%.y= %.c) \ |
247 |
$(LexFiles:%.l= %.c) |
248 |
|
249 |
DerivedCFiles = $(YaccFiles:%.y= %.c) \ |
250 |
$(LexFiles:%.l= %.c) |
251 |
|
252 |
OtherTargetFiles = $(OtherSourceFiles:%=$(PackageTargetDir)/%) |
253 |
|
254 |
########################################################################### |
255 |
# |
256 |
# Figure out the names of the module files based on some work done by |
257 |
# configure. The tr function below is from John Graham-Cumming |
258 |
# (http://www.jgc.org). |
259 |
# |
260 |
# The tr function. Has three arguments: |
261 |
# |
262 |
# $1 The list of characters to translate from |
263 |
# $2 The list of characters to translate to |
264 |
# $3 The text to translate |
265 |
# |
266 |
# For example, $(call tr,A B C,1 2 3,CAPITAL) becomes 21PIT1L. |
267 |
|
268 |
tr = $(eval __t := $3) \ |
269 |
$(foreach c, \ |
270 |
$(join $(addsuffix :,$1),$2), \ |
271 |
$(eval __t := \ |
272 |
$(subst $(word 1,$(subst :, ,$c)),$(word 2,$(subst :, ,$c)), \ |
273 |
$(__t))))$(__t) |
274 |
|
275 |
# Common character classes for use with the tr function. Each of |
276 |
# these is actually a variable declaration and must be wrapped with |
277 |
# $() or ${} to be used. |
278 |
|
279 |
[A-Z] := A B C D E F G H I J K L M N O P Q R S T U V W X Y Z # |
280 |
[a-z] := a b c d e f g h i j k l m n o p q r s t u v w x y z # |
281 |
[0-9] := 0 1 2 3 4 5 6 7 8 9 # |
282 |
[A-F] := A B C D E F # |
283 |
|
284 |
# Figure out whether we have $(eval) or not (GNU Make 3.80 and above) |
285 |
# if we do not then we need to use the shell version of tr, and not the |
286 |
# faster tr function above: |
287 |
|
288 |
__have_eval := $(false) |
289 |
__ignore := $(eval __have_eval := $(true)) |
290 |
|
291 |
ifndef __have_eval |
292 |
uc = $(shell echo $1 | tr "a-z" "A-Z") |
293 |
lc = $(shell echo $1 | tr "A-Z" "a-z") |
294 |
else |
295 |
uc = $(call tr,$([a-z]),$([A-Z]),$1) |
296 |
lc = $(call tr,$([A-Z]),$([a-z]),$1) |
297 |
endif |
298 |
|
299 |
# OK, now we can actually use these functions to figure out the names |
300 |
# of the module files: |
301 |
|
302 |
ifneq "$(words $(Modules))" "0" |
303 |
ifeq "$(ModuleCase)" "UPPER" |
304 |
MODULES = $(call uc,$(Modules)) |
305 |
else |
306 |
ifeq "$(ModuleCase)" "lower" |
307 |
MODULES = $(call lc,$(Modules)) |
308 |
else |
309 |
MODULES = $(Modules) |
310 |
endif |
311 |
endif |
312 |
ModuleFiles = $(MODULES:%= $(PackageTargetDir)/%.$(ModSuffix)) |
313 |
ParallelModuleFiles = $(MODULES:%= $(PackageParallelTargetDir)/%.$(ModSuffix)) |
314 |
endif |
315 |
# |
316 |
########################################################################### |
317 |
|
318 |
ThirdPartyJarsTmp = $(patsubst %,$(LibDir)/%,$(JavaLibraries)) |
319 |
ThirdPartyJars = $(subst $(Space),$(X),$(ThirdPartyJarsTmp)) |
320 |
|
321 |
ifneq "$(words $(JavaFiles))" "0" |
322 |
JavaPackageName = $(subst /,.,$(Package)) |
323 |
JarFile = $(LibDir)/$(subst /,,$(Package)).jar |
324 |
endif |
325 |
|
326 |
#if Main is defined, do not build library. It may not be true sometimes |
327 |
ifneq "$(words $(ObjectFiles) $(ParallelObjectFiles))" "0" |
328 |
DependencyFile = $(PackageSourceDir)/Makedepend |
329 |
ifneq "$(words $(Main))" "0" |
330 |
Executable = $(BinDir)/$(Main) |
331 |
ifeq "$(BuiltParallelExe)" "1" |
332 |
ParallelExecutable = $(BinDir)/$(Main)_MPI |
333 |
endif |
334 |
else |
335 |
SharedLibrary = $(LibDir)/lib$(subst /,,$(patsubst %,oopse_%,$(Package)))_UP.so |
336 |
StaticLibrary = $(LibDir)/lib$(subst /,,$(patsubst %,oopse_%,$(Package)))_UP.a |
337 |
ParallelSharedLibrary = $(LibDir)/lib$(subst /,,$(patsubst %,oopse_%,$(Package)))_MPI.so |
338 |
ParallelStaticLibrary = $(LibDir)/lib$(subst /,,$(patsubst %,oopse_%,$(Package)))_MPI.a |
339 |
endif |
340 |
endif |
341 |
|
342 |
# |
343 |
# Misc |
344 |
# |
345 |
ClassPath = $(JRE)$(X)$(TargetDir)$(X)$(ThirdPartyJars) |
346 |
JavaPackageNames = $(subst /,.,$(JavaPackages)) |
347 |
IncludePath = -I$(SourceDir) $(IncludeDirs:%=-I%) |
348 |
LibDirs = -L$(LibDir) $(LibraryDirs:%=-L%) |
349 |
LocalLibs = $(subst /,,$(patsubst %, oopse_%_UP, $(PackageLibs))) |
350 |
ParallelLocalLibs= $(subst /,,$(patsubst %, oopse_%_MPI, $(PackageLibs))) |
351 |
LibList = $(LocalLibs:%=-l%) $(Libraries) |
352 |
LibNames = $(LocalLibs:%=$(LibDir)/lib%.a) |
353 |
ParallelLibList = $(ParallelLocalLibs:%=-l%) $(Libraries) |
354 |
ParallelLibNames = $(ParallelLocalLibs:%=$(LibDir)/lib%.a) |
355 |
|
356 |
|
357 |
#--------------------------------------------------------------------------- |
358 |
# |
359 |
# Tools & Options |
360 |
# |
361 |
#--------------------------------------------------------------------------- |
362 |
Print = @echo |
363 |
Move = mv -f |
364 |
Copy = cp |
365 |
CCompiler = @CC@ |
366 |
CppCompiler = @CXX@ |
367 |
Linker = @CXX@ |
368 |
MakeDepend = makedepend |
369 |
LN_S = @LN_S@ |
370 |
INSTALL = @INSTALL@ |
371 |
EGREP = @EGREP@ |
372 |
InstallProgram = @INSTALL_PROGRAM@ |
373 |
InstallScript = @INSTALL_SCRIPT@ |
374 |
InstallData = @INSTALL_DATA@ |
375 |
MkDir = @MKINSTALLDIRS@ |
376 |
Delete = rm -f |
377 |
StaticArchiver = @AR@ |
378 |
DynamicArchiver = @CC@ |
379 |
FortranCompiler = @FC@ |
380 |
JavaCompiler = $(JAVA_HOME)/bin/javac |
381 |
JavaArchiver = $(JAVA_HOME)/bin/jar |
382 |
JarSigner = $(JAVA_HOME)/bin/jarsigner |
383 |
JavadocGenerator = $(JAVA_HOME)/bin/javadoc |
384 |
JniCompiler = $(JAVA_HOME)/bin/javah |
385 |
RmiCompiler = $(JAVA_HOME)/bin/rmic |
386 |
JavaExecute = $(JAVA_HOME)/bin/java |
387 |
Purify = purify |
388 |
WordCount = wc |
389 |
List = cat |
390 |
Yacc = @YACC@ |
391 |
Lex = @LEX@ |
392 |
Ranlib = @RANLIB@ |
393 |
Doxygen = @DOXYGEN@ |
394 |
|
395 |
MakeOptions = -k |
396 |
MakeDependOptions = |
397 |
StaticArchiverOptions = rc |
398 |
DynamicArchiverOptions = -shared |
399 |
JavaArchiverOptions = |
400 |
JniOptions = |
401 |
RmiOptions = -d $(TargetDir) -classpath $(ClassPath) \ |
402 |
-sourcepath $(SourceDir) |
403 |
COptions = $(FrcDeclare) $(SingleDeclare) @CFLAGS@ |
404 |
CParallelOptions = $(FrcDeclare) $(SingleDeclare) $(ParallelDeclare) @CFLAGS@ |
405 |
CppOptions = $(FrcDeclare) $(SingleDeclare) @CXXFLAGS@ @CGAL_CPPFLAGS@ |
406 |
CppParallelOptions = $(FrcDeclare) $(SingleDeclare) $(ParallelDeclare) @CXXFLAGS@ @CGAL_CPPFLAGS@ |
407 |
ifeq "$(UseSingle)" "yes" |
408 |
FortranOptions = @FCFLAGS@ @MODDIRFLAG@$(SourceDir) @MODDIRFLAG@$(TargetDir) @PREPDEFFLAG@$(SingleDeclare) @FCFLAGS_SRCEXT@ |
409 |
FortranParallelOptions = @FCFLAGS@ @MODDIRFLAG@$(SourceDir) @MODDIRFLAG@$(ParallelTargetDir) @PREPDEFFLAG@$(SingleDeclare) @PREPDEFFLAG@$(ParallelDeclare) @FCFLAGS_SRCEXT@ |
410 |
else |
411 |
FortranOptions = @FCFLAGS@ @MODDIRFLAG@$(SourceDir) @MODDIRFLAG@$(TargetDir) @FCFLAGS_SRCEXT@ |
412 |
FortranParallelOptions = @FCFLAGS@ @MODDIRFLAG@$(SourceDir) @MODDIRFLAG@$(ParallelTargetDir) @PREPDEFFLAG@$(ParallelDeclare) @FCFLAGS_SRCEXT@ |
413 |
endif |
414 |
JavaCompilerOptions = -d $(TargetDir) -classpath $(ClassPath) \ |
415 |
-sourcepath $(SourceDir) -deprecation |
416 |
JavaRunOptions = -classpath $(ClassPath) |
417 |
PurifyOptions = |
418 |
JavadocOptions = -d $(DocsDir) \ |
419 |
-sourcepath $(SourceDir) \ |
420 |
-classpath $(ClassPath) \ |
421 |
-author \ |
422 |
-package \ |
423 |
-use \ |
424 |
-splitIndex \ |
425 |
-version \ |
426 |
-link file:$(JAVA_HOME)/docs/api \ |
427 |
-windowtitle $(JavadocWindowTitle) \ |
428 |
-doctitle $(JavadocDocTitle) \ |
429 |
-header $(JavadocHeader) \ |
430 |
-bottom $(JavadocFooter) |
431 |
WordCountOptions = --lines |
432 |
|
433 |
Empty = |
434 |
Space = $(Empty) $(Empty) |
435 |
|
436 |
|
437 |
#--------------------------------------------------------------------------- |
438 |
# |
439 |
# Install |
440 |
# |
441 |
#--------------------------------------------------------------------------- |
442 |
|
443 |
ifneq "$(words $(SampleFiles))" "0" |
444 |
MySample = $(subst $(shell cd $(DEV_ROOT)/samples; pwd)/,,$(CurrentDir)) |
445 |
MyInstallDir = $(SampleSimDir)/$(MySample) |
446 |
InstallFiles = $(SampleFiles) |
447 |
InstallCommand = $(InstallData) |
448 |
endif |
449 |
|
450 |
ifneq "$(words $(ScriptFiles))" "0" |
451 |
MyInstallDir = $(InstallBinDir) |
452 |
InstallFiles = $(ScriptFiles) |
453 |
InstallCommand = $(InstallProgram) |
454 |
endif |
455 |
|
456 |
ifneq "$(words $(DocFiles))" "0" |
457 |
MyInstallDir = $(InstallDocDir) |
458 |
InstallFiles = $(DocFiles) |
459 |
InstallCommand = $(InstallData) |
460 |
endif |
461 |
|
462 |
ifneq "$(words $(RootFiles))" "0" |
463 |
MyInstallDir = $(OopseHome) |
464 |
InstallFiles = $(RootFiles) |
465 |
InstallCommand = $(InstallData) |
466 |
endif |
467 |
|
468 |
ifneq "$(words $(Main))" "0" |
469 |
MyInstallDir = $(InstallBinDir) |
470 |
ifeq "$(UseMPI)" "yes" |
471 |
InstallFiles = $(Executable) $(ParallelExecutable) |
472 |
else |
473 |
InstallFiles = $(Executable) |
474 |
endif |
475 |
InstallCommand = $(InstallProgram) |
476 |
ifneq "$(words $(LinkTargets))" "0" |
477 |
MyLinkSource = $(patsubst %, $(MyInstallDir)/%,$(Main)) |
478 |
MyLinkTargets = $(patsubst %, $(MyInstallDir)/%,$(LinkTargets)) |
479 |
endif |
480 |
endif |
481 |
|
482 |
ifneq "$(words $(ForcefieldFiles))" "0" |
483 |
MyInstallDir = $(ForceParamDir) |
484 |
InstallFiles = $(ForcefieldFiles) |
485 |
InstallCommand = $(InstallData) |
486 |
endif |
487 |
|
488 |
ifneq "$(words $(InstallFiles))" "0" |
489 |
InstallList = |
490 |
else |
491 |
InstallList = $(patsubst %,$(DEV_ROOT)/%,$(Samples)) $(DEV_ROOT)/forceFields $(patsubst %, $(SourceDir)/%,$(Applications)) |
492 |
endif |
493 |
|
494 |
InstallListLoop = $(patsubst %,$(SourceDir)/%/.install,$(PackageList)) $(patsubst %,%/.install,$(InstallList)) |
495 |
|
496 |
|
497 |
|
498 |
#--------------------------------------------------------------------------- |
499 |
# |
500 |
# Rules |
501 |
# |
502 |
#--------------------------------------------------------------------------- |
503 |
default : build |
504 |
|
505 |
%.loop : |
506 |
@$(MAKE) $(MakeOptions) -C $(subst .loop,,$@) _$(MAKECMDGOALS)all |
507 |
|
508 |
# Create target directory |
509 |
$(PackageTargetDir) : |
510 |
$(MkDir) $@ |
511 |
|
512 |
$(BinDir) : |
513 |
$(MkDir) $@ |
514 |
|
515 |
# .c -> .o |
516 |
$(PackageTargetDir)/%.o : %.c $(MainMakefile) |
517 |
$(Print) $@ |
518 |
$(CCompiler) $(COptions) -c $(IncludePath) $< -o $@ |
519 |
|
520 |
$(PackageParallelTargetDir)/%.o : %.c $(MainMakefile) |
521 |
$(Print) $@ |
522 |
$(CCompiler) $(CParallelOptions) -c $(IncludePath) $< -o $@ |
523 |
|
524 |
ifeq "$(UseMPI)" "yes" |
525 |
%.o : %.c $(MainMakefile) |
526 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
527 |
$(MAKE) $(MakeOptions) $(PackageParallelTargetDir)/$@ |
528 |
else |
529 |
%.o : %.c $(MainMakefile) |
530 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
531 |
endif |
532 |
|
533 |
# .cpp -> .o |
534 |
$(PackageTargetDir)/%.o : %.cpp $(MainMakefile) |
535 |
$(CppCompiler) $(CppOptions) -c $(IncludePath) $< -o $@ |
536 |
|
537 |
$(PackageParallelTargetDir)/%.o : %.cpp $(MainMakefile) |
538 |
$(CppCompiler) $(CppParallelOptions) -c $(IncludePath) $< -o $@ |
539 |
|
540 |
ifeq "$(UseMPI)" "yes" |
541 |
%.o : %.cpp $(MainMakefile) |
542 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
543 |
$(MAKE) $(MakeOptions) $(PackageParallelTargetDir)/$@ |
544 |
else |
545 |
%.o : %.cpp $(MainMakefile) |
546 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
547 |
endif |
548 |
|
549 |
# .f -> .o |
550 |
$(PackageTargetDir)/%.o : %.f $(MainMakefile) |
551 |
$(FortranCompiler) $(FortranOptions) -c $< -o $@ |
552 |
|
553 |
$(PackageParallelTargetDir)/%.o : %.f $(MainMakefile) |
554 |
$(FortranCompiler) $(FortranParallelOptions) -c $< -o $@ |
555 |
|
556 |
ifeq "$(UseMPI)" "yes" |
557 |
%.o : %.f $(MainMakefile) |
558 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
559 |
$(MAKE) $(MakeOptions) $(PackageParallelTargetDir)/$@ |
560 |
else |
561 |
%.o : %.f $(MainMakefile) |
562 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
563 |
endif |
564 |
|
565 |
# .F90 -> .o |
566 |
$(PackageTargetDir)/%.o : %.F90 $(MainMakefile) |
567 |
$(FortranCompiler) $(FortranOptions) $(IncludePath) -c $< -o $@ |
568 |
if test -n "`ls *.$(ModSuffix)`"; then \ |
569 |
$(Move) `ls *.$(ModSuffix)` $(PackageTargetDir);\ |
570 |
fi |
571 |
|
572 |
$(PackageParallelTargetDir)/%.o : %.F90 $(MainMakefile) |
573 |
$(FortranCompiler) $(FortranParallelOptions) $(IncludePath) -c $< -o $@ |
574 |
if test -n "`ls *.$(ModSuffix)`"; then \ |
575 |
$(Move) "`ls *.$(ModSuffix)`" $(PackageParallelTargetDir);\ |
576 |
fi |
577 |
|
578 |
ifeq "$(UseMPI)" "yes" |
579 |
%.o : %.F90 $(MainMakefile) |
580 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
581 |
if test -n "`ls *.$(ModSuffix)`"; then\ |
582 |
$(Move) "`ls *.$(ModSuffix)`" $(PackageTargetDir);\ |
583 |
fi |
584 |
|
585 |
$(MAKE) $(MakeOptions) $(PackageParallelTargetDir)/$@ |
586 |
if test -n "`ls *.$(ModSuffix)`"; then\ |
587 |
$(Move) "`ls *.$(ModSuffix)`" $(PackageTargetDir);\ |
588 |
fi |
589 |
|
590 |
else |
591 |
%.o : %.F90 $(MainMakefile) |
592 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
593 |
if test -n "`ls *.$(ModSuffix)`"; then\ |
594 |
$(Move) "`ls *.$(ModSuffix)`" $(PackageTargetDir);\ |
595 |
fi |
596 |
endif |
597 |
|
598 |
|
599 |
# .java -> .class |
600 |
$(PackageTargetDir)/%.class : $(PackageSourceDir)/%.java |
601 |
$(JavaCompiler) $(JavaCompilerOptions) $< |
602 |
|
603 |
%.class : $(PackageSourceDir)/%.java |
604 |
@$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
605 |
|
606 |
# .class -> .h |
607 |
$(PackageSourceDir)/%.h : $(PackageTargetDir)/%.class |
608 |
$(JniCompiler) $(JniOptions) $(JavaPackageName).$* |
609 |
|
610 |
%.h : %.class |
611 |
$(MAKE) $(MakeOptions) $(PackageSourceDir)/$@ |
612 |
|
613 |
#.y -> .h |
614 |
%.h : %.y |
615 |
$(Yacc) -d $? |
616 |
@$(Move) y.tab.h $*.h |
617 |
@$(Delete) y.tab.c |
618 |
|
619 |
#.y -> .c |
620 |
%.c : %.y |
621 |
$(Yacc) -d $? |
622 |
@$(Move) y.tab.c $*.c |
623 |
@$(Delete) y.tab.h |
624 |
|
625 |
# .l -> .c |
626 |
%.c : %.l |
627 |
$(Print) $@ |
628 |
$(Print) $(Lex) -o$@ $? |
629 |
@$(Lex) -o$@ $? |
630 |
|
631 |
# .o -> .a |
632 |
|
633 |
$(LibDir)/%_UP.a : $(ObjectFiles) |
634 |
$(StaticArchiver) $(StaticArchiverOptions) $@ $(ObjectFiles) |
635 |
@touch $(LibDir)/.stamp_UP |
636 |
|
637 |
$(LibDir)/%_MPI.a: $(ParallelObjectFiles) |
638 |
$(StaticArchiver) $(StaticArchiverOptions) $@ $(ParallelObjectFiles) |
639 |
@touch $(LibDir)/.stamp_MPI |
640 |
|
641 |
%_UP.a : $(ObjectFiles) |
642 |
$(MAKE) $(MakeOptions) $(LibDir)/$@ |
643 |
|
644 |
%_MPI.a : $(ParallelObjectFiles) |
645 |
$(MAKE) $(MakeOptions) $(LibDir)/$@ |
646 |
|
647 |
# .o -> .so |
648 |
$(LibDir)/%_UP.so : $(ObjectFiles) |
649 |
$(DynamicArchiver) $(ObjectFiles) $(DynamicArchiverOptions) -o $@ |
650 |
|
651 |
$(LibDir)/%_MPI.so : $(ParallelObjectFiles) |
652 |
$(DynamicArchiver) $(ParallelObjectFiles) $(DynamicArchiverOptions) -o $@ |
653 |
|
654 |
%_UP.so : $(ObjectFiles) |
655 |
$(MAKE) $(MakeOptions) $(LibDir)/$@ |
656 |
|
657 |
%_MPI.so : $(ParallelObjectFiles) |
658 |
$(MAKE) $(MakeOptions) $(LibDir)/$@ |
659 |
|
660 |
# .class -> .jar |
661 |
$(LibDir)/%.jar : $(JavaClassFiles) $(OtherTargetFiles) |
662 |
$(Print) $@ |
663 |
@cd $(TargetDir); $(JavaArchiver) -cf $@ \ |
664 |
$(JavaClassFilesRel) $(OtherTargetFiles) |
665 |
|
666 |
%.jar : $(JavaClassFiles) $(OtherTargetFiles) |
667 |
$(MAKE) $(MakeOptions) $(LibDir)/$@ |
668 |
|
669 |
# .class -> JavaDoc |
670 |
javadoc : |
671 |
$(Print) $(JavaPackageNames) > $(DEV_ROOT)/packages.tmp |
672 |
$(JavadocGenerator) $(JavadocOptions) @$(DEV_ROOT)/packages.tmp |
673 |
$(Delete) $(DEV_ROOT)/packages.tmp |
674 |
$(Print) Done JavaDoc. |
675 |
|
676 |
# .class -> _Stub.class |
677 |
$(PackageTargetDir)/%_Stub.class : $(PackageTargetDir)/%.class |
678 |
$(Print) $@ |
679 |
$(RmiCompiler) $(RmiOptions) $(JavaPackageName).$* |
680 |
|
681 |
%_Stub.class : %.class |
682 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
683 |
|
684 |
# .class -> _Skel.class |
685 |
$(PackageTargetDir)/%_Skel.class : $(PackageTargetDir)/%.class |
686 |
$(Print) $@ |
687 |
$(RmiCompiler) $(RmiOptions) $(JavaPackageName).$* |
688 |
|
689 |
%_Skel.class : %.class |
690 |
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
691 |
|
692 |
document : |
693 |
$(Print) Generate Documentation for OOPSE-2.0 |
694 |
@cd $(DEV_ROOT)/src |
695 |
$(Doxygen) $(DEV_ROOT)/make/Doxyfile |
696 |
|
697 |
#GUN make funtions to merge the libraries |
698 |
find_objs = $(shell $(StaticArchiver) -t $(1) | $(EGREP) -v "SYMDEF") |
699 |
extract_objs = $(shell $(StaticArchiver) -x $(1) $(call find_objs, $(1))) |
700 |
create_archive = $(shell $(StaticArchiver) $(StaticArchiverOptions) $(2) $(call find_objs, $(1))) |
701 |
remove_objs = $(shell $(Delete) $(call find_objs, $(1))) |
702 |
do_create = $(call extract_objs,$(1))$(call create_archive,$(1),$(2))$(call remove_objs,$(1)) |
703 |
do_link = $(shell $(LN_S) $(1) $(2)) |
704 |
all_objs = $(foreach thisLib,$(LibNames), $(call find_objs, $(thisLib))) |
705 |
all_parallel_objs = $(foreach thisLib,$(ParallelLibNames), $(call find_objs, $(thisLib))) |
706 |
all_lib_objs = $(patsubst %,$(TargetDir)/%,$(call all_objs)) |
707 |
all_lib_parallel_objs = $(patsubst %,$(ParallelTargetDir)/%,$(call all_parallel_objs)) |
708 |
|
709 |
$(CombinedStaticLib) : $(LibDir)/.stamp_UP |
710 |
$(Print) creating $@ |
711 |
$(StaticArchiver) $(StaticArchiverOptions) $@ $(call all_lib_objs) |
712 |
$(Ranlib) $(CombinedStaticLib) |
713 |
|
714 |
$(CombinedParallelStaticLib) : $(LibDir)/.stamp_MPI |
715 |
$(Print) creating $@ |
716 |
$(StaticArchiver) $(StaticArchiverOptions) $@ $(call all_lib_parallel_objs) |
717 |
$(Ranlib) $(CombinedParallelStaticLib) |
718 |
|
719 |
# Executable |
720 |
$(Executable) : $(CombinedStaticLib) $(ObjectFiles) |
721 |
if test ! -d $(BinDir); then \ |
722 |
$(MkDir) $(BinDir) ;\ |
723 |
fi |
724 |
$(Linker) $(ObjectFiles) $(CombinedStaticLib) $(LinkOptions) $(LibDirs) $(Libraries) -o $@ |
725 |
|
726 |
$(ParallelExecutable) : $(CombinedParallelStaticLib) $(ParallelObjectFiles) |
727 |
if test ! -d $(BinDir); then \ |
728 |
$(MkDir) $(BinDir) ;\ |
729 |
fi |
730 |
$(Linker) $(ParallelObjectFiles) $(CombinedParallelStaticLib) $(ParallelLinkOptions) $(LibDirs) $(Libraries) -o $@ |
731 |
|
732 |
# Anything else is just copied from source to target |
733 |
$(PackageTargetDir)/% : $(PackageSourceDir)/% |
734 |
$(Print) $@ |
735 |
$(Copy) $< $@ |
736 |
|
737 |
# make (or make build) |
738 |
build : $(PackageListLoop) |
739 |
$(Print) Done build. |
740 |
|
741 |
_all : _buildall |
742 |
|
743 |
_buildall : |
744 |
ifeq "$(UseMPI)" "yes" |
745 |
_buildall : \ |
746 |
$(DependencyFile) \ |
747 |
$(PackageTargetDir) \ |
748 |
$(ObjectFiles) \ |
749 |
$(ParallelObjectFiles) \ |
750 |
$(JavaClassFiles) \ |
751 |
$(RmiStubFiles) \ |
752 |
$(RmiSkeletonFiles) \ |
753 |
$(OtherTargetFiles) \ |
754 |
$(StaticLibrary) \ |
755 |
$(ParallelStaticLibrary) \ |
756 |
$(JarFile) \ |
757 |
$(Executable) \ |
758 |
$(ParallelExecutable) |
759 |
else |
760 |
_buildall : \ |
761 |
$(DependencyFile) \ |
762 |
$(PackageTargetDir) \ |
763 |
$(ObjectFiles) \ |
764 |
$(JavaClassFiles) \ |
765 |
$(RmiStubFiles) \ |
766 |
$(RmiSkeletonFiles) \ |
767 |
$(OtherTargetFiles) \ |
768 |
$(StaticLibrary) \ |
769 |
$(JarFile) \ |
770 |
$(Executable) |
771 |
endif |
772 |
|
773 |
echo : $(PackageListLoop) |
774 |
$(Print) Done echo. |
775 |
|
776 |
_echoall : |
777 |
$(Print) $(Modules) |
778 |
|
779 |
# make clean |
780 |
clean : $(PackageListLoop) |
781 |
$(Print) Done clean. |
782 |
|
783 |
_cleanall : |
784 |
$(Delete) \ |
785 |
$(ObjectFiles) \ |
786 |
$(ModuleFiles) \ |
787 |
$(ParallelObjectFiles) \ |
788 |
$(ParallelModuleFiles) \ |
789 |
$(JarFile) \ |
790 |
$(SharedLibrary) \ |
791 |
$(StaticLibrary) \ |
792 |
$(ParallelSharedLibrary) \ |
793 |
$(ParallelStaticLibrary) \ |
794 |
$(CombinedStaticLib) \ |
795 |
$(CombinedParallelStaticLib) |
796 |
|
797 |
# make distclean |
798 |
distclean : $(PackageListLoop) |
799 |
$(Print) Done clean. |
800 |
|
801 |
_distcleanall : _cleanall |
802 |
$(Delete) $(Executable) \ |
803 |
$(ParallelExecutable) \ |
804 |
$(DependencyFile) |
805 |
|
806 |
# make depend |
807 |
depend : $(PackageListLoop) |
808 |
$(Print) Done dependencies. |
809 |
|
810 |
_dependall : $(DependencyFile) |
811 |
|
812 |
$(DependencyFile) : $(DerivedSource) |
813 |
$(Print) $@ |
814 |
@cd $(PackageSourceDir) |
815 |
|
816 |
ifneq "$(words $(CppFiles))" "0" |
817 |
$(DEV_ROOT)/scripts/filepp -I $(DEV_ROOT)/src -od '$$(TargetDir)/' -MM $(CppFiles)>> Make.cpptemp |
818 |
@cat Make.cpptemp >> $(DependencyFile) |
819 |
$(Delete) Make.cpptemp |
820 |
|
821 |
ifeq "$(UseMPI)" "yes" |
822 |
$(DEV_ROOT)/scripts/filepp -I $(DEV_ROOT)/src -od '$$(ParallelTargetDir)/' $(ParallelDeclare) -MM $(CppFiles)>> Make.cpptemp |
823 |
@cat Make.cpptemp >> $(DependencyFile) |
824 |
@$(Delete) Make.cpptemp |
825 |
endif |
826 |
|
827 |
endif |
828 |
|
829 |
ifneq "$(words $(CFiles))" "0" |
830 |
$(DEV_ROOT)/scripts/filepp -I $(DEV_ROOT)/src -od '$$(TargetDir)/' -MM $(CFiles) $(DerivedCFiles) >> Make.ctemp |
831 |
@cat Make.ctemp >> $(DependencyFile) |
832 |
$(Delete) Make.ctemp |
833 |
|
834 |
ifeq "$(UseMPI)" "yes" |
835 |
$(DEV_ROOT)/scripts/filepp -I $(DEV_ROOT)/src -od '$$(ParallelTargetDir)/' $(ParallelDeclare) -MM $(CFiles) $(DerivedCFiles) >> Make.ctemp |
836 |
@cat Make.ctemp >> $(DependencyFile) |
837 |
@$(Delete) Make.ctemp |
838 |
endif |
839 |
|
840 |
endif |
841 |
|
842 |
ifneq "$(words $(F90Files))" "0" |
843 |
$(DEV_ROOT)/scripts/filepp -I $(DEV_ROOT)/src -od '$$(TargetDir)/' $(F90Declare) -MM -mc $(ModuleCase) -ms $(ModSuffix) $(F90Files) > Make.ftemp |
844 |
@cat Make.ftemp >> $(DependencyFile) |
845 |
@$(Delete) Make.ftemp |
846 |
|
847 |
ifeq "$(UseMPI)" "yes" |
848 |
$(DEV_ROOT)/scripts/filepp -I $(DEV_ROOT)/src -od '$$(ParallelTargetDir)/' $(ParallelDeclare) $(F90Declare) -MM -mc $(ModuleCase) -ms $(ModSuffix) $(F90Files) >> Make.ftemp |
849 |
@cat Make.ftemp >> $(DependencyFile) |
850 |
@$(Delete) Make.ftemp |
851 |
endif |
852 |
|
853 |
endif |
854 |
|
855 |
# make lib |
856 |
lib : $(PackageListLoop) |
857 |
$(Print) Libraries built. |
858 |
|
859 |
_liball : $(JarFile) $(SharedLibrary) $(StaticLibrary) |
860 |
|
861 |
jar : $(JarFile) |
862 |
|
863 |
jarsign : $(JarFile) |
864 |
$(JarSigner) -keystore GeoSoftKeystore $(JarFile) myself |
865 |
|
866 |
#make install |
867 |
%.install : |
868 |
@$(MAKE) $(MakeOptions) -C $(subst .install,,$@) _installall |
869 |
|
870 |
install : $(InstallListLoop) |
871 |
$(Print) Done Install |
872 |
|
873 |
_installall : _buildall _installdata _installlinks |
874 |
|
875 |
$(MyInstallDir) : |
876 |
$(MkDir) $@ |
877 |
|
878 |
_installdata : $(MyInstallDir) |
879 |
$(Print) $(InstallFiles) |
880 |
ifneq "$(words $(InstallFiles))" "0" |
881 |
$(InstallCommand) $(InstallFiles) $(MyInstallDir) |
882 |
endif |
883 |
|
884 |
_installlinks : $(MyInstallDir) |
885 |
ifneq "$(words $(MyLinkTargets))" "0" |
886 |
@cd $(MyInstallDir) |
887 |
$(foreach thisLink,$(MyLinkTargets),$(call do_link,$(MyLinkSource),$(thisLink))) |
888 |
endif |
889 |
|
890 |
# make statistics |
891 |
_statisticsall : |
892 |
@$(Print) $(patsubst %,$(CurrentDir)/%,$(SourceFiles)) >> $(DEV_ROOT)/files.tmp |
893 |
|
894 |
statistics : $(PackageListLoop) |
895 |
@$(List) $(DEV_ROOT)/files.tmp | xargs $(WordCount) $(WordCountOptions) |
896 |
@$(Delete) $(DEV_ROOT)/files.tmp |
897 |
$(Print) Done statistics. |
898 |
|
899 |
# make pure |
900 |
#$(Executable).pure : |
901 |
# $(Purify) $(PurifyOptions) $(CppCompiler) $(LinkOptions) $(LibDirs) \ |
902 |
# $(LibList) $(ObjectFiles) -o $@ |
903 |
# |
904 |
#pure : $(Executable).pure |
905 |
|
906 |
#make cvslog |
907 |
cvslog: |
908 |
$(DEV_ROOT)/scripts/cvs2cl |
909 |
|
910 |
# Execute |
911 |
_runexe : |
912 |
$(Executable) $(RunParameters) |
913 |
|
914 |
_runjava : |
915 |
$(JavaExecute) $(JavaRunOptions) $(JavaMainClass) $(RunParameters) |
916 |
|
917 |
run : _runjava |
918 |
|
919 |
|
920 |
ifdef $(DependencyFile) |
921 |
-include $(DependencyFile) |
922 |
endif |