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