ENH: Update FreeFOAM contributions to GPL v3
[freefoam.git] / data / utilities / generateOpenFOAMDeps.py.in
blob30a393cad99eda6fad45f2ba344f927db3afa0e3
1 #!@PYTHON_EXECUTABLE@
2 #-------------------------------------------------------------------------------
3 # ______ _ ____ __ __
4 # | ____| _| |_ / __ \ /\ | \/ |
5 # | |__ _ __ ___ ___ / \| | | | / \ | \ / |
6 # | __| '__/ _ \/ _ ( (| |) ) | | |/ /\ \ | |\/| |
7 # | | | | | __/ __/\_ _/| |__| / ____ \| | | |
8 # |_| |_| \___|\___| |_| \____/_/ \_\_| |_|
10 # FreeFOAM: The Cross-Platform CFD Toolkit
12 # Copyright (C) 2008-2012 Michael Wild <themiwi@users.sf.net>
13 # Gerber van der Graaf <gerber_graaf@users.sf.net>
14 #-------------------------------------------------------------------------------
15 # License
16 # This file is part of FreeFOAM.
18 # FreeFOAM is free software: you can redistribute it and/or modify it
19 # under the terms of the GNU General Public License as published by the
20 # Free Software Foundation, either version 3 of the License, or (at your
21 # option) any later version.
23 # FreeFOAM is distributed in the hope that it will be useful, but WITHOUT
24 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
25 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26 # for more details.
28 # You should have received a copy of the GNU General Public License
29 # along with FreeFOAM. If not, see <http://www.gnu.org/licenses/>.
31 # Script
32 # generateOpenFOAMDeps
34 # Description
35 # Patches OpenFOAM to generate dependency files, runs Allwmake and then
36 # postprocesses the generated dependency files.
38 #------------------------------------------------------------------------------
40 """Usage: generateOpenFOAMDeps <WM_PROJECT_DIR>
42 Patches OpenFOAM to generate dependency files, runs Allwmake and then
43 postprocesses the generated dependency files.
45 Requires that WM_PROJECT_DIR be a git-checkout and that git-python is
46 installed and works.
48 Options
49 -------
50 <WM_PROJECT_DIR> Top-level OpenFOAM source directory
52 """
54 import sys
55 sys.path.insert(0, '@FOAM_PYTHON_DIR@')
56 from FreeFOAM.compat import *
57 import os
58 import os.path as op
59 import re
60 import git
61 import tempfile
62 import subprocess
64 blacklistPatterns = (
65 re.compile(r'^/usr/'),
68 # argument parsing
69 args = sys.argv[1:]
70 if len(args) != 1:
71 echo('Error: the path to the OpenFOAM installation is required',
72 file=sys.stderr)
73 sys.exit(1)
75 WM_PROJECT_DIR=op.abspath(args[0])
77 # set up environment
78 os.environ['FOAM_INST_DIR'] = op.dirname(WM_PROJECT_DIR)
79 os.environ['WM_COMPILER'] = 'FreeFOAM'
80 os.environ['WM_COMPILE_OPTION'] = 'Dep'
81 os.environ['WM_MPLIB'] = 'SYSTEMOPENMPI'
83 # sanity checks
84 if not op.exists(op.join(WM_PROJECT_DIR, 'bin/foamInstallationTest')):
85 echo('Error: %s/bin/foamInstallationTest is missing', file=sys.stderr)
86 sys.exit(1)
88 if not op.exists(op.join(WM_PROJECT_DIR, '.git/HEAD')):
89 echo('Error: %s/.git/HEAD is missing', file=sys.stderr)
90 sys.exit(1)
92 repo = git.Repo(WM_PROJECT_DIR)
94 if repo.is_dirty():
95 echo('Error: OpenFOAM checkout %s is dirty'%WM_PROJECT_DIR, file=sys.stderr)
96 sys.exit(1)
98 if repo.head.is_detached:
99 echo('Error: OpenFOACM checkout %s is detached'%WM_PROJECT_DIR, file=sys.stderr)
100 sys.exit(1)
102 # create new, temporary branch and check it out
103 orig_branch = repo.active_branch
104 try:
105 tmp_branch = repo.create_head('TMP_FREEFOAM_GENERATE_OPENFOAM_DEPS')
106 except OSError as e:
107 echo('Error: Creating temporary branch %s failed with:\n%s'%
108 ('TMP_FREEFOAM_GENERATE_OPENFOAM_DEPS', str(e)), file=sys.stderr)
109 sys.exit(1)
111 try:
112 tmp_branch.checkout()
113 except git.GitCommandError as e:
114 echo('Error: Checking out the temporary branch %s failed with:\n%s'%
115 ('TMP_FREEFOAM_GENERATE_OPENFOAM_DEPS', str(e)), file=sys.stderr)
116 sys.exit(1)
118 # apply patches
119 wmakePatch = tempfile.TemporaryFile()
120 wmakePatch.write(r"""
121 From 3e7ebcead5c87781e84752ce42647c24b18ce2da Mon Sep 17 00:00:00 2001
122 From: Michael Wild <themiwi@users.sourceforge.net>
123 Date: Mon, 25 Jul 2011 08:38:08 +0200
124 Subject: [PATCH] Patch wmake to only generate dependency files
126 Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
128 diff --git a/Allwmake b/Allwmake
129 index 55554dc..6047743 100755
130 --- a/Allwmake
131 +++ b/Allwmake
132 @@ -1,6 +1,8 @@
133 #!/bin/sh
134 cd ${0%/*} || exit 1 # run from this directory
136 +. etc/bashrc
138 if [ "$PWD" != "$WM_PROJECT_DIR" ]
139 then
140 echo "Error: Current directory is not \$WM_PROJECT_DIR"
141 @@ -15,7 +17,7 @@ fi
142 # build ThirdParty sources
143 if [ -d "$WM_THIRD_PARTY_DIR" ]
144 then
145 - ( cd $WM_THIRD_PARTY_DIR && ./Allwmake )
146 + : #( cd $WM_THIRD_PARTY_DIR && ./Allwmake )
149 # build OpenFOAM libraries and applications
150 diff --git a/wmake/Makefile b/wmake/Makefile
151 index 2f2be98..878a7be 100644
152 --- a/wmake/Makefile
153 +++ b/wmake/Makefile
154 @@ -41,7 +41,7 @@ SHELL = /bin/sh
155 #------------------------------------------------------------------------------
157 .SUFFIXES:
158 -.SUFFIXES: .o
159 +.SUFFIXES: .d
162 #------------------------------------------------------------------------------
163 @@ -106,7 +106,7 @@ SEXE = a.out
164 #------------------------------------------------------------------------------
166 GENERAL_RULES = $(WM_DIR)/rules/General
167 -RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
168 +RULES = $(WM_DIR)/rules/FreeFOAM
169 BIN = $(WM_DIR)/bin/$(WM_ARCH)$(WM_COMPILER)
171 include $(GENERAL_RULES)/general
172 @@ -148,16 +148,14 @@ LIB_HEADER_DIRS = \
174 $(EXE): $(OBJECTS)
175 @$(WM_SCRIPTS)/mkObjectDir $(EXE)
176 - $(LINKEXE) $(OBJECTS) -L$(LIB_WM_OPTIONS_DIR) \
177 - $(EXE_LIBS) $(PROJECT_LIBS) $(SYS_LIBS) $(LINK_LIBS) $(GLIBS) -o $(EXE)
178 + @touch $@
180 exe: $(SEXE)
181 @echo \'$(SEXE)\' is up to date.
183 $(SEXE): $(OBJECTS)
184 @$(WM_SCRIPTS)/mkObjectDir $(SEXE)
185 - $(LINKEXE) $(OBJECTS) $(EXE_LIBS) \
186 - $(SYS_LIBS) $(LINK_LIBS) $(GLIBS) -o $(SEXE)
187 + @touch $@
190 #------------------------------------------------------------------------------
191 @@ -171,7 +169,7 @@ $(LIB).$(SO): $(OBJECTS)
192 @$(WM_SCRIPTS)/mkObjectDir $(LIB)
193 @rm -f so_locations
194 @cd $(OBJECTS_DIR) ; \
195 - $(LINKLIBSO) $(LOCAL_OBJECTS) -L$(LIB_WM_OPTIONS_DIR) $(LIB_LIBS) $(GLIB_LIBS) -o $(LIB).$(SO)
196 + touch $@
198 lib: $(LIB).a
199 @echo \'$(LIB).a\' is up to date.
200 @@ -188,7 +186,7 @@ libo: $(LIB).o
201 $(LIB).o: $(OBJECTS)
202 @$(WM_SCRIPTS)/mkObjectDir $(LIB)
203 @rm -f $(LIB).o
204 - $(LD) -r -o $(LIB).o $(OBJECTS)
205 + @touch $@
207 jar: $(LIB).jar
208 @echo \'$(LIB).jar\' is up to date.
209 diff --git a/wmake/MakefileFiles b/wmake/MakefileFiles
210 index 6dc6e9d..d4f2d7d 100644
211 --- a/wmake/MakefileFiles
212 +++ b/wmake/MakefileFiles
213 @@ -30,7 +30,7 @@
214 #------------------------------------------------------------------------------
216 GENERAL_RULES = $(WM_DIR)/rules/General
217 -RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
218 +RULES = $(WM_DIR)/rules/FreeFOAM
219 OBJECTS_DIR = $(WM_OPTIONS)
220 FFLAGS =
222 diff --git a/wmake/MakefileOptions b/wmake/MakefileOptions
223 index db304ba..ee4a871 100644
224 --- a/wmake/MakefileOptions
225 +++ b/wmake/MakefileOptions
226 @@ -30,7 +30,7 @@
227 #------------------------------------------------------------------------------
229 GENERAL_RULES = $(WM_DIR)/rules/General
230 -RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
231 +RULES = $(WM_DIR)/rules/FreeFOAM
233 include $(GENERAL_RULES)/general
234 include $(RULES)/general
235 diff --git a/wmake/rules/FreeFOAM/X b/wmake/rules/FreeFOAM/X
236 new file mode 100644
237 index 0000000..6133345
238 --- /dev/null
239 +++ b/wmake/rules/FreeFOAM/X
240 @@ -0,0 +1,3 @@
241 +XFLAGS =
242 +XINC = $(XFLAGS) -I/usr/include/X11
243 +XLIBS =
244 diff --git a/wmake/rules/FreeFOAM/c b/wmake/rules/FreeFOAM/c
245 new file mode 100644
246 index 0000000..49c780b
247 --- /dev/null
248 +++ b/wmake/rules/FreeFOAM/c
249 @@ -0,0 +1,12 @@
250 +.SUFFIXES: .c .h
252 +cc = gcc
254 +cFLAGS = $(GFLAGS) $(cDEP) $(LIB_HEADER_DIRS)
256 +ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) $$SOURCE -M -MF $(subst .o,.d,$@)
258 +LINK_LIBS = $(cDBUG)
260 +LINKLIBSO =
261 +LINKEXE =
262 diff --git a/wmake/rules/FreeFOAM/c++ b/wmake/rules/FreeFOAM/c++
263 new file mode 100644
264 index 0000000..b68cefa
265 --- /dev/null
266 +++ b/wmake/rules/FreeFOAM/c++
267 @@ -0,0 +1,17 @@
268 +.SUFFIXES: .C .cxx .cc .cpp
270 +CC = g++
272 +ptFLAGS = -DNoRepository
274 +c++FLAGS = $(GFLAGS) $(ptFLAGS) $(LIB_HEADER_DIRS) -fPIC
276 +Ctoo = $(WM_SCHEDULER) $(CC) $(c++FLAGS) $$SOURCE -M -MF $(subst .o,.d,$@)
277 +cxxtoo = $(Ctoo)
278 +cctoo = $(Ctoo)
279 +cpptoo = $(Ctoo)
281 +LINK_LIBS = $(c++DBUG)
283 +LINKLIBSO =
284 +LINKEXE =
285 diff --git a/wmake/rules/FreeFOAM/general b/wmake/rules/FreeFOAM/general
286 new file mode 100644
287 index 0000000..27779cd
288 --- /dev/null
289 +++ b/wmake/rules/FreeFOAM/general
290 @@ -0,0 +1,10 @@
291 +CPP = cpp -traditional-cpp $(GFLAGS)
292 +LD = ld
294 +PROJECT_LIBS = -l$(WM_PROJECT) -ldl
296 +include $(GENERAL_RULES)/standard
298 +include $(RULES)/X
299 +include $(RULES)/c
300 +include $(RULES)/c++
301 diff --git a/wmake/rules/FreeFOAM/mplib b/wmake/rules/FreeFOAM/mplib
302 new file mode 100644
303 index 0000000..8a84b40
304 --- /dev/null
305 +++ b/wmake/rules/FreeFOAM/mplib
306 @@ -0,0 +1,3 @@
307 +PFLAGS =
308 +PINC =
309 +PLIBS =
310 diff --git a/wmake/rules/FreeFOAM/mplibSYSTEMOPENMPI b/wmake/rules/FreeFOAM/mplibSYSTEMOPENMPI
311 new file mode 100644
312 index 0000000..98fa814
313 --- /dev/null
314 +++ b/wmake/rules/FreeFOAM/mplibSYSTEMOPENMPI
315 @@ -0,0 +1 @@
316 +PFLAGS = -DOMPI_SKIP_MPICXX
317 diff --git a/wmake/rules/General/bison b/wmake/rules/General/bison
318 index fe2e00a..e4ed987 100644
319 --- a/wmake/rules/General/bison
320 +++ b/wmake/rules/General/bison
321 @@ -4,8 +4,8 @@ ytoo = bison -v -d -y $$SOURCE ; mv y.tab.c $*.c ; mv y.tab.h $*.h ; $(cc) $(cFL
323 Ytoo = bison -v -d -y $$SOURCE ; mv y.tab.c $*.C ; mv y.tab.h $*.H ; $(CC) $(c++FLAGS) -c $*.C -o $@
325 -.y.dep:
326 +.y.FreeFOAMdep:
327 $(MAKE_DEP)
329 -.Y.dep:
330 +.Y.FreeFOAMdep:
331 $(MAKE_DEP)
332 diff --git a/wmake/rules/General/btyacc b/wmake/rules/General/btyacc
333 index f868b05..4fa52e8 100644
334 --- a/wmake/rules/General/btyacc
335 +++ b/wmake/rules/General/btyacc
336 @@ -2,5 +2,5 @@
338 ytoo = btyacc -v -d $(SKELETON) $$SOURCE ; mv y_tab.c $*.C ; mv y_tab.h $*.H ; $(CC) $(c++FLAGS) -c $*.C -o $@
340 -.y.dep:
341 +.y.FreeFOAMdep:
342 $(MAKE_DEP)
343 diff --git a/wmake/rules/General/btyacc++ b/wmake/rules/General/btyacc++
344 index c65365c..b9f66b7 100644
345 --- a/wmake/rules/General/btyacc++
346 +++ b/wmake/rules/General/btyacc++
347 @@ -2,5 +2,5 @@
349 Ytoo = btyacc++ -v -d $(SKELETON) $$SOURCE ; mv y_tab.c $*.C ; mv y_tab.h $*.H ; $(CC) $(c++FLAGS) -c $*.C -o $@
351 -.Y.dep:
352 +.Y.FreeFOAMdep:
353 $(MAKE_DEP)
354 diff --git a/wmake/rules/General/byacc b/wmake/rules/General/byacc
355 index 919da82..8292151 100644
356 --- a/wmake/rules/General/byacc
357 +++ b/wmake/rules/General/byacc
358 @@ -2,5 +2,5 @@
360 ytoo = byacc -v $(YYPREFIX) -d $$SOURCE ; mv y.tab.c $*.C ; mv y.tab.h $*.H ; $(CC) $(c++FLAGS) -c $*.C -o $@
362 -.y.dep:
363 +.y.FreeFOAMdep:
364 $(MAKE_DEP)
365 diff --git a/wmake/rules/General/flex b/wmake/rules/General/flex
366 index 06defbb..11aeae7 100644
367 --- a/wmake/rules/General/flex
368 +++ b/wmake/rules/General/flex
369 @@ -2,5 +2,5 @@
371 ltoo = flex $$SOURCE ; mv lex.yy.c $*.c ; $(cc) $(cFLAGS) -c $*.c -o $@
373 -.l.dep:
374 +.l.FreeFOAMdep:
375 $(MAKE_DEP)
376 diff --git a/wmake/rules/General/flex++ b/wmake/rules/General/flex++
377 index 304b131..4a29dd9 100644
378 --- a/wmake/rules/General/flex++
379 +++ b/wmake/rules/General/flex++
380 @@ -1,6 +1,6 @@
381 .SUFFIXES: .L
383 -Ltoo = flex -+ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@
384 +Ltoo = flex -+ -f $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) $*.C -M -MF $(subst .o,.d,$@)
386 -.L.dep:
387 +.L.FreeFOAMdep:
388 $(MAKE_DEP)
389 diff --git a/wmake/rules/General/flex++.test b/wmake/rules/General/flex++.test
390 index 8503e57..bb0f976 100644
391 --- a/wmake/rules/General/flex++.test
392 +++ b/wmake/rules/General/flex++.test
393 @@ -1,6 +1,6 @@
394 .SUFFIXES: .L
396 -Ltoo = flex++ $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@
397 +Ltoo = flex++ $$SOURCE ; mv lex.yy.cc $*.C ; $(CC) $(c++FLAGS) $*.C -M -MF $(subst .o,.d,$@)
399 -.L.dep:
400 +.L.FreeFOAMdep:
401 $(MAKE_DEP)
402 diff --git a/wmake/rules/General/moc b/wmake/rules/General/moc
403 index e85cb47..67ffced 100644
404 --- a/wmake/rules/General/moc
405 +++ b/wmake/rules/General/moc
406 @@ -2,5 +2,5 @@
408 qttoo = $(QTDIR)/bin/moc -f $$SOURCE -o $*.C ; $(CC) $(c++FLAGS) -c $*.C -o $@
410 -.qt.dep:
411 +.qt.FreeFOAMdep:
412 $(MAKE_DEP)
413 diff --git a/wmake/rules/General/sourceToDep b/wmake/rules/General/sourceToDep
414 index 14e95d6..31ea59d 100644
415 --- a/wmake/rules/General/sourceToDep
416 +++ b/wmake/rules/General/sourceToDep
417 @@ -1,24 +1,24 @@
418 -.SUFFIXES: .c .cc .cxx .cpp .C .F .f .dep
419 +.SUFFIXES: .c .cc .cxx .cpp .C .F .f .FreeFOAMdep
421 MKDEP = $(BIN)/wmkdep -I$(*D) $(LIB_HEADER_DIRS)
423 -.c.dep:
424 +.c.FreeFOAMdep:
425 $(MAKE_DEP)
427 -.cc.dep:
428 +.cc.FreeFOAMdep:
429 $(MAKE_DEP)
431 -.cxx.dep:
432 +.cxx.FreeFOAMdep:
433 $(MAKE_DEP)
435 -.cpp.dep:
436 +.cpp.FreeFOAMdep:
437 $(MAKE_DEP)
439 -.C.dep:
440 +.C.FreeFOAMdep:
441 $(MAKE_DEP)
443 -.F.dep:
444 +.F.FreeFOAMdep:
445 $(MAKE_DEP)
447 -.f.dep:
448 +.f.FreeFOAMdep:
449 $(MAKE_DEP)
450 diff --git a/wmake/rules/General/version b/wmake/rules/General/version
451 index 11f83c7..22951dd 100644
452 --- a/wmake/rules/General/version
453 +++ b/wmake/rules/General/version
454 @@ -7,7 +7,7 @@ Cvertoo = \
455 sed -e 's/VERSION_STRING/$(shell wmakePrintBuild -major)/' \
456 -e 's/BUILD_STRING/$(shell wmakePrintBuild -update)/' \
457 $$SOURCE > $*.C; \
458 - $(CC) $(c++FLAGS) -c $*.C -o $@
459 + $(CC) $(c++FLAGS) $*.C -M -MF $(subst .o,.d,$@)
461 -.Cver.dep:
462 +.Cver.FreeFOAMdep:
463 $(MAKE_DEP)
464 diff --git a/wmake/rules/General/yacc b/wmake/rules/General/yacc
465 index f9d393e..b99597e 100644
466 --- a/wmake/rules/General/yacc
467 +++ b/wmake/rules/General/yacc
468 @@ -4,8 +4,8 @@ ytoo = yacc -v -d $$SOURCE ; mv y.tab.c $*.c ; mv y.tab.h $(@D)/parser.h ; $(CC)
470 Ytoo = yacc -v -d $$SOURCE ; mv y.tab.c $*.C ; mv y.tab.h $(@D)/parser.H ; $(CC) $(c++FLAGS) -c $*.C -o $@
472 -.y.dep:
473 +.y.FreeFOAMdep:
474 $(MAKE_DEP)
476 -.Y.dep:
477 +.Y.FreeFOAMdep:
478 $(MAKE_DEP)
479 diff --git a/wmake/scripts/addCompile b/wmake/scripts/addCompile
480 index 04f0919..bb394f9 100755
481 --- a/wmake/scripts/addCompile
482 +++ b/wmake/scripts/addCompile
483 @@ -33,10 +33,10 @@
484 #------------------------------------------------------------------------------
486 sourceName=${1##*/}
487 -objectName=${sourceName%.*}.o
488 +objectName=${sourceName%.*}.d
489 className=${sourceName%.*}.class
490 sub=${1##*.}
491 -depName=${1%.*}.dep
492 +depName=${1%.*}.FreeFOAMdep
494 sourceDir=${1%/*}
496 @@ -52,13 +52,13 @@ else
497 cat > $depName
500 -sed -e s%".*.o.*:"%'$(OBJECTS_DIR)/'"$objectName\:"% \
501 +sed -e s%".*.d.*:"%'$(OBJECTS_DIR)/'"$objectName\:"% \
502 -e s%$WM_PROJECT_DIR%'$(WM_PROJECT_DIR)'% \
503 >> $depName
505 echo '$(OBJECTS_DIR)/'$objectName': $(EXE_DEP)' >> $depName
506 echo '$(OBJECTS_DIR)/'$objectName':' >> $depName
507 -echo ' @SOURCE_DIR='$sourceDir >> $depName
508 -echo ' SOURCE='$1' ; $('$sub'too)' >> $depName
509 +echo ' @SOURCE_DIR=$(PWD)/'$sourceDir >> $depName
510 +echo ' SOURCE=$(PWD)/'$1' ; $('$sub'too)' >> $depName
512 #------------------------------------------------------------------------------
513 diff --git a/wmake/src/Makefile b/wmake/src/Makefile
514 index 81603b6..741a06e 100644
515 --- a/wmake/src/Makefile
516 +++ b/wmake/src/Makefile
517 @@ -48,7 +48,7 @@ SHELL = /bin/sh
518 #------------------------------------------------------------------------------
520 GENERAL_RULES = $(WM_DIR)/rules/General
521 -RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
522 +RULES = $(WM_DIR)/rules/FreeFOAM
523 BIN = $(WM_DIR)/bin/$(WM_ARCH)$(WM_COMPILER)
525 include $(RULES)/general
526 diff --git a/wmake/src/wmkdep.l b/wmake/src/wmkdep.l
527 index d22c695..78b2fab 100644
528 --- a/wmake/src/wmkdep.l
529 +++ b/wmake/src/wmkdep.l
530 @@ -166,10 +166,10 @@ int main(int argc, char* argv[])
531 /* initialise depFile to zero and use strncat rather than strncpy
532 because there is a bug in the SGI strncat that if 0 preceeds the .
533 it inserts a space */
534 - depFile = (char*)malloc(strlen(sourceFile) + 3);
535 + depFile = (char*)malloc(strlen(sourceFile) + 11);
536 depFile[0] = 0;
537 strncat(depFile, sourceFile, (dotPtr - sourceFile)/sizeof(char));
538 - strcat(depFile, ".dep");
539 + strcat(depFile, ".FreeFOAMdep");
541 if (strcmp(sourceExt, "java") == 0)
543 @@ -185,7 +185,7 @@ int main(int argc, char* argv[])
544 objectFile = (char*)malloc(strlen(sourceFile) + 16);
545 strcpy(objectFile, "$(OBJECTS_DIR)/");
546 strncat(objectFile, slashPtr, (dotPtr - slashPtr)/sizeof(char));
547 - strcat(objectFile, ".o");
548 + strcat(objectFile, ".d");
550 printf("%s: %s\n", objectFile, depFile);
552 diff --git a/wmake/wmakeDerivedFiles b/wmake/wmakeDerivedFiles
553 index 8d522e9..1fe8294 100755
554 --- a/wmake/wmakeDerivedFiles
555 +++ b/wmake/wmakeDerivedFiles
556 @@ -79,7 +79,7 @@ rm tmpSourceFile
557 # ~~~~~~~~~~~~~~~~
558 sed -e 's%.*/%%' \
559 -e 's%^%$(OBJECTS_DIR)/%' \
560 - -e 's%\.[a-zA-Z]*$%\.o%' \
561 + -e 's%\.[a-zA-Z]*$%\.d%' \
562 files.$$ > tmpObjectFiles
564 echo "OBJECTS = " > tmpObjectFiles2
565 @@ -95,7 +95,7 @@ rm tmpObjectFiles tmpObjectFiles2
566 # make localObjectFiles
567 # ~~~~~~~~~~~~~~~~~~~~~
568 sed -e 's%.*/%%' \
569 - -e 's%\.[a-zA-Z]*$%\.o%' \
570 + -e 's%\.[a-zA-Z]*$%\.d%' \
571 files.$$ > tmpLocalObjectFiles
573 echo "LOCAL_OBJECTS = " > tmpLocalObjectFiles2
574 @@ -110,7 +110,7 @@ rm tmpLocalObjectFiles tmpLocalObjectFiles2
576 # make dependencyFiles
577 # ~~~~~~~~~~~~~~~~~~~~
578 -sed 's/\.[a-zA-Z]*$/\.dep/' \
579 +sed 's/\.[a-zA-Z]*$/\.FreeFOAMdep/' \
580 files.$$ > tmpDependencyFiles
582 echo "DEPENDENCIES = " > tmpDependencyFiles2
583 @@ -125,7 +125,7 @@ rm tmpDependencyFiles tmpDependencyFiles2
585 # make includeDeps
586 # ~~~~~~~~~~~~~~~~
587 -sed -e 's/\.[a-zA-Z]*$/.dep/' \
588 +sed -e 's/\.[a-zA-Z]*$/.FreeFOAMdep/' \
589 -e 's/^/include /' \
590 files.$$ > includeDeps
593 1.7.4.1
594 """)
595 wmakePatch.seek(0)
597 s = True
598 try:
599 try:
600 repo.git.am(istream=wmakePatch)
601 except git.GitCommandError as e:
602 echo('Error: Failed to patch wmake:\n%s'%str(e), file=sys.stderr)
603 s = False
604 raise
605 wmakePatch.close()
607 try:
608 os.chdir(WM_PROJECT_DIR)
609 subprocess.check_call('./Allwmake')
610 except subprocess.CalledProcessError as e:
611 echo('Error: Running Allwmake failed with status %d:\n%s'%
612 (e.returncode, str(e)), file=sys.stderr)
613 s = False
614 raise
615 finally:
616 try:
617 orig_branch.checkout()
618 repo.delete_head(tmp_branch, force=True)
619 except Exception as e:
620 echo('Error: Failed restoring branch %s and deleting %s:\n%s'%
621 (orig_branch.name, tmp_branch.name, str(e)), file=sys.stderr)
622 s = False
624 if not s:
625 sys.exit(1)
627 # post-process
628 for parent, dirs, files in os.walk(WM_PROJECT_DIR):
629 if re.search(r'FreeFOAMDPDep(SYSTEMOPENMPI)?$', parent):
630 srcdir = op.dirname(op.dirname(parent))
631 for f in filter(lambda f: op.splitext(f)[1]=='.d', files):
632 f = op.join(parent, f)
633 lines = []
634 # sanitize strings
635 for l in open(f, 'rt'):
636 lines += l.strip().replace(' \\', '').split()
637 # remove first entry
638 del lines[0]
639 # resolve lnInclude entries, remove blacklisted files and strip prefix
640 length = len(lines)
641 for i, l in enumerate(reversed(lines)):
642 i = length-i-1
643 # if not absolute, make it so
644 if not op.isabs(l):
645 l = op.normpath(op.join(srcdir, l))
646 if l.find('lnInclude/') > -1:
647 # resolve
648 if op.exists(l) and op.islink(l):
649 ll = os.readlink(l)
650 if not op.isabs(ll):
651 ll = op.normpath(op.join(op.dirname(l), ll))
652 l = ll
653 else:
654 echo('WARNING: "%s" does not exist or is not a symlink'%l,
655 file=sys.stderr)
656 # remove blacklisted files
657 deleted=False
658 for p in blacklistPatterns:
659 if p.search(l) is not None:
660 del lines[i]
661 deleted=True
662 break
663 if deleted:
664 continue
665 # strip WM_PROJECT_DIR
666 if l.startswith(WM_PROJECT_DIR):
667 l = op.relpath(l, WM_PROJECT_DIR)
668 # write back
669 lines[i] = l
670 # remove duplicates and sort
671 lines = sorted(set(lines))
672 open(op.splitext(f)[0]+'.ofd', 'wt').write(('\n'.join(lines))+'\n')
674 # ------------------------- vim: set sw=3 sts=3 et: --------------- end-of-file