ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/OpenMD/branches/development/make/Makefile.in
Revision: 1544
Committed: Fri Mar 18 19:31:52 2011 UTC (14 years, 4 months ago) by gezelter
File size: 28797 byte(s)
Log Message:
More modifications for paralllel rewrite

File Contents

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