Merge branch 'upstream/OpenFOAM-1.7.x' into upstream/OpenFOAM
[freefoam.git] / wmake / wmakeDerivedFiles
blob8d522e9e32c714e85a4799db4261860ce18ea67e
1 #!/bin/sh
2 #---------------------------------*- sh -*-------------------------------------
3 # ========= |
4 # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 # \\ / O peration |
6 # \\ / A nd | Copyright (C) 1991-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 # wmakeDerivedFiles
28 # Description
29 # Constructs all the file list for make given the source file list
30 # (which written by hand or using makeFilesAndDirectories.)
32 #------------------------------------------------------------------------------
34 if [ ! -d "$WM_OPTIONS" ]
35 then
36 echo "The $WM_OPTIONS directory does not exist, exiting" 1>&2
37 exit 1
40 # change to the $WM_OPTIONS directory
41 cd $WM_OPTIONS 2>/dev/null || {
42 echo "Could not change to directory '$WM_OPTIONS'" 1>&2
43 exit 1
46 # Find and keep macro definitions in files list
47 grep "=" files > filesMacros
49 # Remove all macro definitions from the files list
50 grep -v "=" files > filesPlusBlank
52 # Add a newline to files to make sure the last line is followed by a newline
53 echo "" >> filesPlusBlank
56 # Remove commented lines blank lines, and trailing blanks from files
57 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
58 sed -e '/^#/ d' \
59 -e '/^[ \t]*$/ d' \
60 -e 's/[ \t]*$//' \
61 filesPlusBlank > files.$$
63 rm filesPlusBlank
66 # make sourceFiles
67 # ~~~~~~~~~~~~~~~~
68 echo "SOURCE = " > tmpSourceFile
69 cat files.$$ >> tmpSourceFile
71 sed -e 's/$/\\/' \
72 -e '$s/\\//' \
73 tmpSourceFile > sourceFiles
75 rm tmpSourceFile
78 # make objectFiles
79 # ~~~~~~~~~~~~~~~~
80 sed -e 's%.*/%%' \
81 -e 's%^%$(OBJECTS_DIR)/%' \
82 -e 's%\.[a-zA-Z]*$%\.o%' \
83 files.$$ > tmpObjectFiles
85 echo "OBJECTS = " > tmpObjectFiles2
86 cat tmpObjectFiles >> tmpObjectFiles2
88 sed -e 's/$/\\/' \
89 -e '$s/\\//' \
90 tmpObjectFiles2 > objectFiles
92 rm tmpObjectFiles tmpObjectFiles2
95 # make localObjectFiles
96 # ~~~~~~~~~~~~~~~~~~~~~
97 sed -e 's%.*/%%' \
98 -e 's%\.[a-zA-Z]*$%\.o%' \
99 files.$$ > tmpLocalObjectFiles
101 echo "LOCAL_OBJECTS = " > tmpLocalObjectFiles2
102 cat tmpLocalObjectFiles >> tmpLocalObjectFiles2
104 sed -e 's/$/\\/' \
105 -e '$s/\\//' \
106 tmpLocalObjectFiles2 > localObjectFiles
108 rm tmpLocalObjectFiles tmpLocalObjectFiles2
111 # make dependencyFiles
112 # ~~~~~~~~~~~~~~~~~~~~
113 sed 's/\.[a-zA-Z]*$/\.dep/' \
114 files.$$ > tmpDependencyFiles
116 echo "DEPENDENCIES = " > tmpDependencyFiles2
117 cat tmpDependencyFiles >> tmpDependencyFiles2
119 sed -e 's/$/\\/' \
120 -e '$s/\\//' \
121 tmpDependencyFiles2 > dependencyFiles
123 rm tmpDependencyFiles tmpDependencyFiles2
126 # make includeDeps
127 # ~~~~~~~~~~~~~~~~
128 sed -e 's/\.[a-zA-Z]*$/.dep/' \
129 -e 's/^/include /' \
130 files.$$ > includeDeps
132 rm files.$$
134 cd ..
136 #------------------------------------------------------------------------------