Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / wmake / scripts / makeDerivedFiles
blobac77c17d8512dbe08ffd4e3d411b9851aab0128e
1 #!/bin/sh
2 #------------------------------------------------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
7 # \\/ M anipulation |
8 #-------------------------------------------------------------------------------
9 # License
10 # This file is part of OpenFOAM.
12 # OpenFOAM is free software: you can redistribute it and/or modify it
13 # under the terms of the GNU General Public License as published by
14 # the Free Software Foundation, either version 3 of the License, or
15 # (at your option) any later version.
17 # OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
18 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
20 # for more details.
22 # You should have received a copy of the GNU General Public License
23 # along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 # Script
26 # makeDerivedFiles
28 # Description
29 # Constructs all the file list for make given the source file list,
30 # written by hand or using makeFilesAndOptions.
32 #------------------------------------------------------------------------------
34 [ -d "$WM_OPTIONS" ] || {
35 echo "The '$WM_OPTIONS' directory does not exist, exiting" 1>&2
36 exit 1
39 # change to the $WM_OPTIONS directory
40 cd "$WM_OPTIONS" 2>/dev/null || {
41 echo "Could not change to directory '$WM_OPTIONS'" 1>&2
42 exit 1
45 # Find and keep macro definitions in files list
46 grep "=" files > filesMacros
48 # Remove all macro definitions from the files list
49 grep -v "=" files > filesPlusBlank
51 # Add a newline to files to ensure the last line is followed by a newline
52 echo "" >> filesPlusBlank
55 # Remove commented lines, blank lines, and trailing blanks from files
56 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
57 sed -e '/^#/ d' \
58 -e '/^[ \t]*$/ d' \
59 -e 's/[ \t]*$//' \
60 filesPlusBlank > files.$$
62 rm filesPlusBlank
65 # make sourceFiles
66 # ~~~~~~~~~~~~~~~~
67 echo "SOURCE = " > tmpSourceFile
68 cat files.$$ >> tmpSourceFile
70 sed -e 's/$/\\/' \
71 -e '$s/\\//' \
72 tmpSourceFile > sourceFiles
74 rm tmpSourceFile
77 # make objectFiles
78 # ~~~~~~~~~~~~~~~~
79 sed -e 's%.*/%%' \
80 -e 's%^%$(OBJECTS_DIR)/%' \
81 -e 's%\.[a-zA-Z]*$%\.o%' \
82 files.$$ > tmpObjectFiles
84 echo "OBJECTS = " > tmpObjectFiles2
85 cat tmpObjectFiles >> tmpObjectFiles2
87 sed -e 's/$/\\/' \
88 -e '$s/\\//' \
89 tmpObjectFiles2 > objectFiles
91 rm tmpObjectFiles tmpObjectFiles2
94 # make localObjectFiles
95 # ~~~~~~~~~~~~~~~~~~~~~
96 sed -e 's%.*/%%' \
97 -e 's%\.[a-zA-Z]*$%\.o%' \
98 files.$$ > tmpLocalObjectFiles
100 echo "LOCAL_OBJECTS = " > tmpLocalObjectFiles2
101 cat tmpLocalObjectFiles >> tmpLocalObjectFiles2
103 sed -e 's/$/\\/' \
104 -e '$s/\\//' \
105 tmpLocalObjectFiles2 > localObjectFiles
107 rm tmpLocalObjectFiles tmpLocalObjectFiles2
110 # make dependencyFiles
111 # ~~~~~~~~~~~~~~~~~~~~
112 sed 's/\.[a-zA-Z]*$/\.dep/' \
113 files.$$ > tmpDependencyFiles
115 echo "DEPENDENCIES = " > tmpDependencyFiles2
116 cat tmpDependencyFiles >> tmpDependencyFiles2
118 sed -e 's/$/\\/' \
119 -e '$s/\\//' \
120 tmpDependencyFiles2 > dependencyFiles
122 rm tmpDependencyFiles tmpDependencyFiles2
125 # make includeDeps
126 # ~~~~~~~~~~~~~~~~
127 sed -e 's/\.[a-zA-Z]*$/.dep/' \
128 -e 's/^/include /' \
129 files.$$ > includeDeps
131 rm files.$$
133 #------------------------------------------------------------------------------