simplified boiler generator
[k8jam.git] / defaults / Jambase.boiler
blob01d31da2fabe9a63cf52d2d1515ea69941e40e0a
1 # This program is free software: you can redistribute it and/or modify
2 # it under the terms of the GNU General Public License as published by
3 # the Free Software Foundation, either version 3 of the License, or
4 # (at your option) any later version.
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
9 # GNU General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
15 # 'boilerplate' code
17 rule -Generate-Boiler- {
18   local _f = $(FORCE) ;
19   NotFile gen-boiler ;
20   Always gen-boiler ;
21   if $(_f) {
22     _f = '_-boiler-target-force-_' ;
23   } else {
24     _f = '_-boiler-target-noforce-_' ;
25   }
26   NotFile $(_f) ;
27   NoCare $(_f) ;
28   AGenBoiler gen-boiler $(_f) ;
32 actions quietly AGenBoiler {
34 fregen="$(<[2])"
35 if [ "z$fregen" != "z_-boiler-target-force-_" ]; then
36   fregen="ona"
37 else
38   fregen="tan"
42 dir_has_src() {
43   local llist
44   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.c" -regex "^./[^._].*$"`
45   if [ "z$llist" != "z" ]; then
46     return 1
47   fi
48   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.d" -regex "^./[^._].*$"`
49   if [ "z$llist" != "z" ]; then
50     return 1
51   fi
52   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.cpp" -regex "^./[^._].*$"`
53   if [ "z$llist" != "z" ]; then
54     return 1
55   fi
56   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.c++" -regex "^./[^._].*$"`
57   if [ "z$llist" != "z" ]; then
58     return 1
59   fi
60   return 0
64 dir_has_h() {
65   local llist
66   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.h" -regex "^./[^._].*$"`
67   if [ "z$llist" = "z" ]; then
68     llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.hpp" -regex "^./[^._].*$"`
69     if [ "z$llist" = "z" ]; then
70       return 0
71     fi
72   fi
73   return 1
77 prjname="$(MAIN)"
78 if [ "z$prjname" = "z" ]; then
79   prjname="mainprj"
82 for dname in `find . -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`; do
83   fname="$dname/Jamfile"
84   xskip="ona"
85   if [ "$fregen" == "ona" ]; then
86     if [ -e "${fname}" ]; then
87       xskip="tan"
88     fi
89   fi
90   if [ "$xskip" != "tan" ]; then
91     dir_has_src "$dname"
92     if [ "$?" = "0" ]; then
93       xskip="tan"
94     fi
95   fi
96   if [ "$xskip" = "tan" ]; then
97     echo "SKIP: $fname"
98   else
99     echo "GENF: $fname"
100     dpp=`echo "$dname" | sed 's/^\.\//TOP /;' | sed 's/\// /g;'`
101     echo "SubDir $dpp ;" >"$fname"
102     echo "" >>"$fname"
103     echo "" >>"$fname"
104     if [ "$dname" != "./src" ]; then
105       dpp=`basename "$dname"`
106       fc=`echo "$dpp" | cut -c1-3`
107       if [ "z$fc" != "zlib" ]; then dpp="lib${dpp}"; fi
108       echo "Library ${dpp}.a :" >>"$fname"
109     else
110       echo "Main ${prjname} :" >>"$fname"
111     fi
112     llist=`find "$dname" -mindepth 1 -maxdepth 1 -type f -name "*.c" -regex "^./[^._].*$"`
113     for lname in $llist; do
114       dpp=`basename "$lname"`
115       echo "  $dpp" >>"$fname"
116     done
117     llist=`find "$dname" -mindepth 1 -maxdepth 1 -type f -name "*.d" -regex "^./[^._].*$"`
118     for lname in $llist; do
119       dpp=`basename "$lname"`
120       echo "  $dpp" >>"$fname"
121     done
122     llist=`find "$dname" -mindepth 1 -maxdepth 1 -type f -name "*.cpp" -regex "^./[^._].*$"`
123     for lname in $llist; do
124       dpp=`basename "$lname"`
125       echo "  $dpp" >>"$fname"
126     done
127     llist=`find "$dname" -mindepth 1 -maxdepth 1 -type f -name "*.c++" -regex "^./[^._].*$"`
128     for lname in $llist; do
129       dpp=`basename "$lname"`
130       echo "  $dpp" >>"$fname"
131     done
132     echo ";" >>"$fname"
133     llist=`find "$dname" -mindepth 1 -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`
134     if [ "z$llist" != "z" ]; then
135       if [ "$dname" = "./src" ]; then
136         llibs=""
137         for lname in $llist; do
138           dir_has_src "$lname"
139           if [ "$?" != "0" ]; then
140             dpp=`basename "$lname"`
141             fc=`echo "$dpp" | cut -c1-3`
142             if [ "z$fc" != "zlib" ]; then dpp="lib${dpp}"; fi
143             llibs="${llibs} ${dpp}.a"
144           fi
145         done
146         if [ "z$llibs" != "z" ]; then
147           echo "LinkLibraries ${prjname} :" >>"$fname"
148           for lname in $llibs; do
149             echo "  ${lname}" >>"$fname"
150           done
151           echo ";" >>"$fname"
152         fi
153       fi
154       echo "" >>"$fname"
155       echo "" >>"$fname"
156       for lname in $llist; do
157         dir_has_src "$lname"
158         if [ "$?" = "1" ]; then
159           dpp=`echo "$lname" | sed 's/^\.\//TOP /;' | sed 's/\// /g;'`
160           echo "SubInclude $dpp ;" >>"$fname"
161         fi
162       done
163     fi
164   fi
165 done
168 fname="./Jamfile"
169 xskip="ona"
170 if [ "$fregen" == "ona" ]; then
171   if [ -e "$fname" ]; then
172     xskip="tan"
173   fi
175 if [ "$xskip" = "tan" ]; then
176   echo "SKIP: $fname"
177 else
178   echo "GENF: $fname"
179   echo "SubDir TOP ;" >"$fname"
180   echo "" >>"$fname"
181   echo "" >>"$fname"
182   for dname in `find . -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`; do
183     dir_has_src "$dname"
184     if [ "$?" = "1" ]; then
185       dpp=`echo "$dname" | sed 's/^\.\//TOP /;' | sed 's/\// /g;'`
186       echo "SubInclude $dpp ;" >>"$fname"
187     fi
188   done
191 fname="./Jamrules"
192 xskip="ona"
193 if [ "$fregen" == "ona" ]; then
194   if [ -e "$fname" ]; then
195     xskip="tan"
196   fi
198 if [ "$xskip" = "tan" ]; then
199   echo "SKIP: $fname"
200 else
201   dollar="\$"
202   echo "GENF: $fname"
203   echo "softinclude ${dollar}(TOP)/Jamrules.configure ;" >"$fname"
204   echo "" >>"$fname"
205   echo "set-profile ;" >>"$fname"
206   echo "set-target-locations ;" >>"$fname"
207   firsthdrs="tan"
208   for dname in `find . -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`; do
209     dir_has_src "$dname"
210     if [ "$?" = "0" ]; then
211       dir_has_h "$dname"
212       if [ "$?" = "1" ]; then
213         if [ "$firsthdrs" = "tan" ]; then
214           firsthdrs="ona"
215           echo "" >>"$fname"
216           echo "" >>"$fname"
217         fi
218         dpp=`echo "$dname" | sed 's/^\.\//\(TOP)\//;'`
219         echo "HDRS += \$$dpp ;" >>"$fname"
220       fi
221     fi
222   done
223   if [ "$firsthdrs" = "tan" ]; then
224     echo "" >>"$fname"
225     echo "" >>"$fname"
226   fi
227   echo "softinclude ${dollar}(TOP)/Jamrules.local ;" >>"$fname"
228   echo "softinclude ${dollar}(TOP)/Jamrules.libs ;" >>"$fname"
229   echo "softinclude ${dollar}(TOP)/Jamrules.install ;" >>"$fname"
233 -Generate-Boiler- ;