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