33 |
|
# $< - Current dependency |
34 |
|
# |
35 |
|
#--------------------------------------------------------------------------- |
36 |
+ |
|
37 |
+ |
include $(DEV_ROOT)/make/Make.conf.in |
38 |
|
#--------------------------------------------------------------------------- |
39 |
|
# |
40 |
|
# Directories |
52 |
|
Package = $(subst $(SourceDir)/,,$(CurrentDir)) |
53 |
|
PackageList = $(Package) |
54 |
|
PackageSourceDir = $(SourceDir)/$(Package) |
55 |
< |
PackageTargetDir = $(TargetDir)/$(Package) |
55 |
> |
PackageTargetDir = $(TargetDir) |
56 |
|
JavaMainClass = $(subst /,.,$(Package)).$(Main) |
57 |
|
else |
58 |
|
PackageList = $(Packages) $(JavaPackages) |
81 |
|
FortranFiles = $(filter %.f, $(Source)) |
82 |
|
F90Files = $(filter %.F90, $(Source)) |
83 |
|
CorbaFiles = $(filter %.idl, $(Source)) |
84 |
+ |
LexFiles = $(filter %.l, $(Source)) |
85 |
+ |
YaccFiles = $(filter %.y, $(Source)) |
86 |
|
OtherSourceFiles = $(filter-out $(JavaFiles) $(CppFiles) $(CFiles) \ |
87 |
< |
$(FortranFiles) $(F90Files) \ |
88 |
< |
$(CorbaFiles), \ |
87 |
> |
$(FortranFiles) $(F90Files) $(LexFiles) \ |
88 |
> |
$(YaccFiles) $(CorbaFiles), \ |
89 |
|
$(Source)) |
90 |
|
ManifestFile = $(PackageSourceDir)/Manifest |
91 |
|
SourceFiles = $(JavaFiles:%.java= $(PackageSourceDir)/%.java)\ |
92 |
|
$(CppFiles:%.cpp= $(PackageSourceDir)/%.cpp)\ |
93 |
|
$(CFiles:%.c= $(PackageSourceDir)/%.c)\ |
94 |
|
$(FortranFiles:%.f= $(PackageSourceDir)/%.f)\ |
95 |
< |
$(F90Files:%.F90= $(PackageSourceDir)/%.F90) |
95 |
> |
$(F90Files:%.F90= $(PackageSourceDir)/%.F90)\ |
96 |
> |
$(LexFiles:%.l= $(PackageSourceDir)/%.l)\ |
97 |
> |
$(YaccFiles:%.y= $(PackageSourceDir)/%.y)\ |
98 |
|
|
99 |
+ |
|
100 |
|
# Target |
101 |
|
JavaClassFiles = $(JavaFiles:%.java= $(PackageTargetDir)/%.class) |
102 |
|
JavaClassFilesRel = $(JavaFiles:%.java= $(Package)/%.class) |
107 |
|
ObjectFiles = $(CFiles:%.c= $(PackageTargetDir)/%.o)\ |
108 |
|
$(CppFiles:%.cpp= $(PackageTargetDir)/%.o)\ |
109 |
|
$(FortranFiles:%.f= $(PackageTargetDir)/%.o)\ |
110 |
< |
$(F90Files:%.F90= $(PackageTargetDir)/%.o) |
110 |
> |
$(F90Files:%.F90= $(PackageTargetDir)/%.o)\ |
111 |
> |
$(LexFiles:%.l= $(PackageTargetDir)/%.o)\ |
112 |
> |
$(YaccFiles:%.y= $(PackageTargetDir)/%.o) |
113 |
> |
|
114 |
> |
DerivedSource = $(YaccFiles:%.y= %.h) \ |
115 |
> |
$(YaccFiles:%.y= %.c) \ |
116 |
> |
$(LexFiles:%.l= %.c) |
117 |
> |
|
118 |
> |
DerivedCFiles = $(YaccFiles:%.y= %.c) \ |
119 |
> |
$(LexFiles:%.l= %.c) |
120 |
> |
|
121 |
|
OtherTargetFiles = $(OtherSourceFiles:%=$(PackageTargetDir)/%) |
122 |
|
|
123 |
|
ThirdPartyJarsTmp = $(patsubst %,$(LibDir)/%,$(JavaLibraries)) |
127 |
|
JavaPackageName = $(subst /,.,$(Package)) |
128 |
|
JarFile = $(LibDir)/$(subst /,,$(Package)).jar |
129 |
|
endif |
130 |
+ |
|
131 |
+ |
#if Main is defined, do not build library. It may not be true sometimes |
132 |
|
ifneq "$(words $(ObjectFiles))" "0" |
133 |
|
DependencyFile = $(PackageSourceDir)/Makedepend |
115 |
– |
SharedLibrary = $(LibDir)/lib$(subst /,,$(Package)).so |
116 |
– |
StaticLibrary = $(LibDir)/lib$(subst /,,$(Package)).a |
134 |
|
ifneq "$(Main)" "" |
135 |
|
Executable = $(BinDir)/$(Main) |
136 |
+ |
else |
137 |
+ |
SharedLibrary = $(LibDir)/lib$(subst /,,$(Package)).so |
138 |
+ |
StaticLibrary = $(LibDir)/lib$(subst /,,$(Package)).a |
139 |
|
endif |
140 |
|
endif |
141 |
|
# |
155 |
|
# |
156 |
|
#--------------------------------------------------------------------------- |
157 |
|
Print = @echo |
158 |
+ |
Move = mv |
159 |
|
Copy = cp |
160 |
< |
CCompiler = gcc |
161 |
< |
CppCompiler = gcc |
162 |
< |
Linker = gcc |
160 |
> |
CCompiler = icc |
161 |
> |
CppCompiler = icpc |
162 |
> |
Linker = icpc |
163 |
|
MakeDepend = makedepend |
164 |
|
MakeDir = mkdir -p |
165 |
|
Delete = rm -fr |
166 |
|
StaticArchiver = ar |
167 |
< |
DynamicArchiver = gcc |
168 |
< |
FortranCompiler = f77 |
169 |
< |
F90Compiler = f90 |
167 |
> |
DynamicArchiver = icc |
168 |
> |
FortranCompiler = ifort |
169 |
> |
F90Compiler = ifort |
170 |
|
JavaCompiler = $(JAVA_HOME)/bin/javac |
171 |
|
JavaArchiver = $(JAVA_HOME)/bin/jar |
172 |
|
JarSigner = $(JAVA_HOME)/bin/jarsigner |
177 |
|
Purify = purify |
178 |
|
WordCount = wc |
179 |
|
List = cat |
180 |
+ |
Yacc = bison -y |
181 |
+ |
Lex = flex |
182 |
|
|
183 |
+ |
|
184 |
|
MakeOptions = -k -s |
185 |
|
MakeDependOptions = |
186 |
|
StaticArchiverOptions = rc |
190 |
|
RmiOptions = -d $(TargetDir) -classpath $(ClassPath) \ |
191 |
|
-sourcepath $(SourceDir) |
192 |
|
FortranOptions = |
193 |
< |
F90Options = |
193 |
> |
F90Options = -I$(SourceDir) -module $(TargetDir) |
194 |
|
JavaCompilerOptions = -d $(TargetDir) -classpath $(ClassPath) \ |
195 |
|
-sourcepath $(SourceDir) -deprecation |
196 |
|
JavaRunOptions = -classpath $(ClassPath) |
229 |
|
$(MakeDir) $@ |
230 |
|
|
231 |
|
# .c -> .o |
232 |
< |
$(PackageTargetDir)/%.o : $(PackageTargetDir) $(PackageSourceDir)/%.c |
232 |
> |
$(PackageTargetDir)/%.o : $(PackageSourceDir)/%.c |
233 |
|
$(Print) $@ |
234 |
+ |
$(Print) $(CCompiler) $(COptions) -c $(IncludePath) $< -o $@ |
235 |
|
@$(CCompiler) $(COptions) -c $(IncludePath) $< -o $@ |
236 |
|
|
237 |
|
%.o : $(PackageSourceDir)/%.c |
238 |
|
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
239 |
|
|
240 |
< |
# .cc -> .o |
241 |
< |
$(PackageTargetDir)/%.o : $(PackageSourceDir)/%.cc |
240 |
> |
# .cpp -> .o |
241 |
> |
$(PackageTargetDir)/%.o : $(PackageSourceDir)/%.cpp |
242 |
|
$(Print) $@ |
243 |
+ |
$(Print) $(CppCompiler) $(CppOptions) -c $(IncludePath) $< -o $@ |
244 |
|
$(CppCompiler) $(CppOptions) -c $(IncludePath) $< -o $@ |
245 |
|
|
246 |
< |
%.o : $(PackageSourceDir)/%.cc |
246 |
> |
%.o : $(PackageSourceDir)/%.cpp |
247 |
|
$(MAKE) $(MakeOptions) $(PackageTargetDir)/$@ |
248 |
|
|
249 |
|
# .f -> .o |
250 |
|
$(PackageTargetDir)/%.o : $(PackageSourceDir)/%.f |
251 |
|
$(Print) $@ |
252 |
+ |
$(Print) $(FortranCompiler) $(FortranOptions) -c $< -o $@ |
253 |
|
@$(FortranCompiler) $(FortranOptions) -c $< -o $@ |
254 |
|
|
255 |
|
%.o : $(PackageSourceDir)/%.f |
258 |
|
# .F90 -> .o |
259 |
|
$(PackageTargetDir)/%.o : $(PackageSourceDir)/%.F90 |
260 |
|
$(Print) $@ |
261 |
+ |
$(Print) $(F90Compiler) $(F90Options) -c $< -o $@ |
262 |
|
@$(F90Compiler) $(F90Options) -c $< -o $@ |
263 |
|
|
264 |
|
%.o : $(PackageSourceDir)/%.F90 |
267 |
|
# .java -> .class |
268 |
|
$(PackageTargetDir)/%.class : $(PackageSourceDir)/%.java |
269 |
|
$(Print) $@ |
270 |
+ |
$(Print) $(JavaCompiler) $(JavaCompilerOptions) $< |
271 |
|
@$(JavaCompiler) $(JavaCompilerOptions) $< |
272 |
|
|
273 |
|
%.class : $(PackageSourceDir)/%.java |
276 |
|
# .class -> .h |
277 |
|
$(PackageSourceDir)/%.h : $(PackageTargetDir)/%.class |
278 |
|
$(Print) $@ |
279 |
+ |
$(Print) $(JniCompiler) $(JniOptions) $(JavaPackageName).$* |
280 |
|
$(JniCompiler) $(JniOptions) $(JavaPackageName).$* |
281 |
|
|
282 |
|
%.h : %.class |
283 |
|
$(MAKE) $(MakeOptions) $(PackageSourceDir)/$@ |
284 |
|
|
285 |
+ |
#.y -> .h |
286 |
+ |
$(PackageSourceDir)/%.h : $(PackageSourceDir)/%.y |
287 |
+ |
$(Print) $@ |
288 |
+ |
$(Print) @$(Yacc) -d $? |
289 |
+ |
@$(Yacc) -d $? |
290 |
+ |
@$(Move) y.tab.h $*.h |
291 |
+ |
@$(Delete) y.tab.c |
292 |
+ |
|
293 |
+ |
#.y -> .c |
294 |
+ |
$(PackageSourceDir)/%.c : $(PackageSourceDir)/%.y |
295 |
+ |
$(Print) $@ |
296 |
+ |
$(Print) $(Yacc) -d $? |
297 |
+ |
@$(Yacc) -d $? |
298 |
+ |
@$(Move) y.tab.c $*.c |
299 |
+ |
@$(Delete) y.tab.h |
300 |
+ |
|
301 |
+ |
# .l -> .c |
302 |
+ |
$(PackageSourceDir)/%.c : $(PackageSourceDir)/%.l |
303 |
+ |
$(Print) $@ |
304 |
+ |
$(Print) $(Lex) -o$@ $? |
305 |
+ |
@$(Lex) -o$@ $? |
306 |
+ |
|
307 |
|
# .o -> .a |
308 |
|
$(LibDir)/%.a : $(ObjectFiles) |
309 |
|
$(Print) $@ |
310 |
+ |
$(Print) $(StaticArchiver) $(StaticArchiverOptions) $@ $(ObjectFiles) |
311 |
|
@$(StaticArchiver) $(StaticArchiverOptions) $@ $(ObjectFiles) |
312 |
|
|
313 |
|
%.a : $(ObjectFiles) |
316 |
|
# .o -> .so |
317 |
|
$(LibDir)/%.so : $(ObjectFiles) |
318 |
|
$(Print) $@ |
319 |
+ |
$(Print) $(DynamicArchiver) $(ObjectFiles) $(DynamicArchiverOptions) -o $@ |
320 |
|
$(DynamicArchiver) $(ObjectFiles) $(DynamicArchiverOptions) -o $@ |
321 |
|
|
322 |
|
%.so : $(ObjectFiles) |
325 |
|
# .class -> .jar |
326 |
|
$(LibDir)/%.jar : $(JavaClassFiles) $(OtherTargetFiles) |
327 |
|
$(Print) $@ |
328 |
+ |
$(Print) $(JavaArchiver) -cf $@ $(JavaClassFilesRel) $(OtherTargetFiles) |
329 |
|
@cd $(TargetDir); $(JavaArchiver) -cf $@ \ |
330 |
|
$(JavaClassFilesRel) $(OtherTargetFiles) |
331 |
|
|
404 |
|
|
405 |
|
_dependall : $(DependencyFile) |
406 |
|
|
407 |
< |
$(DependencyFile) : |
408 |
< |
$(Print) $@ |
409 |
< |
@cd $(PackageSourceDir); \ |
410 |
< |
$(MakeDepend) $(MakeDependOptions) -f- -p$(PackageTargetDir)/ \ |
411 |
< |
$(IncludePath) $(Source) > $(DependencyFile) |
407 |
> |
$(DependencyFile) : $(DerivedSource) |
408 |
> |
$(Print) $@ |
409 |
> |
@cd $(PackageSourceDir) |
410 |
> |
touch Make.temp |
411 |
> |
ifdef $(CppFiles) |
412 |
> |
$(CppCompiler) $(IncludePath) -MM $(CppFiles) > Make.temp |
413 |
> |
endif |
414 |
> |
ifdef $(CFiles) |
415 |
> |
$(CCompiler) $(IncludePath) -MM $(CFiles) $(DerivedCFiles) >> Make.temp |
416 |
> |
endif |
417 |
> |
cat Make.temp | sed 's/^[a-zA-Z0-9]/$$\(DEV_ROOT\)\/obj\/&/g' >> $(DependencyFile) |
418 |
> |
cat Make.temp | sed 's/^[a-zA-Z0-9]/$$\(DEV_ROOT\)\/MPIobj\/&/g' >> $(DependencyFile) |
419 |
> |
#ifdef $(F90Files) |
420 |
> |
$(DEV_ROOT)/scripts/sfmakedepend -I $(DEV_ROOT)/src -d '$$(DEV_ROOT)/obj' -f ./Make.ftemp -h *.F90 |
421 |
> |
cat Make.ftemp >> $(DependencyFile) |
422 |
> |
#endif |
423 |
> |
$(Delete) Make.temp Make.ftemp |
424 |
|
|
425 |
|
# make lib |
426 |
|
lib : $(PackageListLoop) |