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