cosmetix in gen-boiler
[k8jam.git] / defaults / Jambase.boiler
blob62a4e93b2a750cbd1c835277e53f158df283fd6c
2 # 'boilerplate' code
4 rule -Generate-Boiler- {
5   local _f = $(FORCE) ;
6   NotFile gen-boiler ;
7   Always gen-boiler ;
8   if $(_f) {
9     _f = "_-boiler-target-force-_" ;
10   } else {
11     _f = "_-boiler-target-noforce-_" ;
12   }
13   NotFile $(_f) ;
14   NoCare $(_f) ;
15   AGenBoiler gen-boiler $(_f) ;
17 actions quietly AGenBoiler {
19 fregen="$(<[2])"
20 if [ "z$fregen" != "z_-boiler-target-force-_" ]; then
21   fregen="ona"
22 else
23   fregen="tan"
27 dirhassrc() {
28   local llist
29   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.cpp" -regex "^./[^._].*$"`
30   if [ "z$llist" = "z" ]; then
31     llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.c" -regex "^./[^._].*$"`
32     if [ "z$llist" = "z" ]; then
33       return 0
34     fi
35   fi
36   return 1
39 dirhascpp() {
40   local llist
41   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.cpp" -regex "^./[^._].*$"`
42   if [ "z$llist" = "z" ]; then
43     return 0
44   fi
45   return 1
48 dirhash() {
49   local llist
50   llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.h" -regex "^./[^._].*$"`
51   if [ "z$llist" = "z" ]; then
52     llist=`find "$1" -mindepth 1 -maxdepth 1 -type f -name "*.hpp" -regex "^./[^._].*$"`
53     if [ "z$llist" = "z" ]; then
54       return 0
55     fi
56   fi
57   return 1
61 prjname="$(MAIN)"
62 if [ "z$prjname" = "z" ]; then
63   prjname="mainprj"
66 for dname in `find . -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`; do
67   fname="$dname/Jamfile"
68   xskip="ona"
69   if [ "$fregen" == "ona" ]; then
70     if [ -e "${fname}" ]; then
71       xskip="tan"
72     fi
73   fi
74   if [ "$xskip" != "tan" ]; then
75     dirhassrc "$dname"
76     if [ "$?" = "0" ]; then
77       xskip="tan"
78     fi
79   fi
80   if [ "$xskip" = "tan" ]; then
81     echo "SKIP: $fname"
82   else
83     echo "GENF: $fname"
84     dpp=`echo "$dname" | sed 's/^\.\//TOP /;' | sed 's/\// /g;'`
85     echo "SubDir $dpp ;" >"$fname"
86     echo "" >>"$fname"
87     echo "" >>"$fname"
88     if [ "$dname" != "./src" ]; then
89       dpp=`basename "$dname"`
90       fc=`echo "$dpp" | cut -c1-3`
91       if [ "z$fc" != "zlib" ]; then dpp="lib${dpp}"; fi
92       echo "Library ${dpp}.a :" >>"$fname"
93     else
94       dirhascpp "$dname"
95       if [ "$?" = "0" ]; then
96         echo "Main ${prjname} :" >>"$fname"
97       else
98         echo "C++Main ${prjname} :" >>"$fname"
99       fi
100     fi
101     llist=`find "$dname" -mindepth 1 -maxdepth 1 -type f -name "*.c" -regex "^./[^._].*$"`
102     for lname in $llist; do
103       dpp=`basename "$lname"`
104       echo "  $dpp" >>"$fname"
105     done
106     llist=`find "$dname" -mindepth 1 -maxdepth 1 -type f -name "*.cpp" -regex "^./[^._].*$"`
107     for lname in $llist; do
108       dpp=`basename "$lname"`
109       echo "  $dpp" >>"$fname"
110     done
111     echo ";" >>"$fname"
112     llist=`find "$dname" -mindepth 1 -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`
113     if [ "z$llist" != "z" ]; then
114       if [ "$dname" = "./src" ]; then
115         llibs=""
116         for lname in $llist; do
117           dirhassrc "$lname"
118           if [ "$?" != "0" ]; then
119             dpp=`basename "$lname"`
120             fc=`echo "$dpp" | cut -c1-3`
121             if [ "z$fc" != "zlib" ]; then dpp="lib${dpp}"; fi
122             llibs="${llibs} ${dpp}.a"
123           fi
124         done
125         if [ "z$llibs" != "z" ]; then
126           echo "LinkLibraries ${prjname} :" >>"$fname"
127           for lname in $llibs; do
128             echo "  ${lname}" >>"$fname"
129           done
130           echo ";" >>"$fname"
131         fi
132       fi
133       echo "" >>"$fname"
134       echo "" >>"$fname"
135       for lname in $llist; do
136         dirhassrc "$lname"
137         if [ "$?" = "1" ]; then
138           dpp=`echo "$lname" | sed 's/^\.\//TOP /;' | sed 's/\// /g;'`
139           echo "SubInclude $dpp ;" >>"$fname"
140         fi
141       done
142     fi
143   fi
144 done
147 fname="./Jamfile"
148 xskip="ona"
149 if [ "$fregen" == "ona" ]; then
150   if [ -e "$fname" ]; then
151     xskip="tan"
152   fi
154 if [ "$xskip" = "tan" ]; then
155   echo "SKIP: $fname"
156 else
157   echo "GENF: $fname"
158   echo "SubDir TOP ;" >"$fname"
159   echo "" >>"$fname"
160   echo "" >>"$fname"
161   for dname in `find . -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`; do
162     dirhassrc "$dname"
163     if [ "$?" = "1" ]; then
164       dpp=`echo "$dname" | sed 's/^\.\//TOP /;' | sed 's/\// /g;'`
165       echo "SubInclude $dpp ;" >>"$fname"
166     fi
167   done
170 fname="./Jamrules"
171 xskip="ona"
172 if [ "$fregen" == "ona" ]; then
173   if [ -e "$fname" ]; then
174     xskip="tan"
175   fi
177 if [ "$xskip" = "tan" ]; then
178   echo "SKIP: $fname"
179 else
180   echo "GENF: $fname"
181   echo "set-profile ;" >"$fname"
182   echo "set-target-locations ;" >>"$fname"
183   firsthdrs="tan"
184   for dname in `find . -maxdepth 8 -type d -name "[^._]*" -regex "^./[^._].*$"`; do
185     dirhassrc "$dname"
186     if [ "$?" = "0" ]; then
187       dirhash "$dname"
188       if [ "$?" = "1" ]; then
189         if [ "$firsthdrs" = "tan" ]; then
190           firsthdrs="ona"
191           echo "" >>"$fname"
192           echo "" >>"$fname"
193         fi
194         dpp=`echo "$dname" | sed 's/^\.\//\(TOP)\//;'`
195         echo "HDRS += \$$dpp ;" >>"$fname"
196       fi
197     fi
198   done
199   if [ "$firsthdrs" = "tan" ]; then
200     echo "" >>"$fname"
201     echo "" >>"$fname"
202   fi
203   dollar="\$"
204   echo "if ([ FileExists ${dollar}(TOP)/Jamrules.local ]) {" >>"$fname"
205   echo "  include ${dollar}(TOP)/Jamrules.local ;" >>"$fname"
206   echo "}" >>"$fname"
210 -Generate-Boiler- ;