Use dos.library/CreateNewProc() instead of alib/CreateNewProcTags()
[tangerine.git] / compiler / c_lib / source / lib_source / genshared.in
blob52e8a4406d0987f11ae3b4c7fb29f8a42989caa9
1 #!/bin/sh
3 AWK=@AWK@
5 case $1 in
6 -libdefs )
7 mode=libdefs
8 ;;
9 -functable )
10 mode=functable
12 -fd )
13 mode=fd
15 -proto )
16 mode=proto
18 -pproto )
19 mode=pproto
21 -clib )
22 mode=clib
24 -pclib )
25 mode=pclib
27 -inline )
28 mode=inline
30 -defines )
31 mode=defines
33 -pdefines )
34 mode=pdefines
36 # -pragma )
37 # mode=pragma
38 # ;;
39 -* )
40 echo "Unknown option $1"
41 exit 10
43 * )
44 echo "Expecting operation mode as first argument"
45 exit 10
46 esac
48 shift
50 prefix=.
51 confdir=.
52 output=""
53 scriptdir=`dirname $0`
54 libdefsfile=libdefs.h
55 debug=0
56 test=0
57 hasrt=0
59 while [ $# -ne 0 ] ; do
60 case $1 in
61 -prefix | --prefix )
62 prefix="$2"
63 shift
65 -libdefsfile )
66 libdefsfile="$2"
67 shift
69 -output )
70 output="$2"
71 shift
73 -debug )
74 debug=1
76 -test )
77 test=1
79 -confdir )
80 confdir="$2"
81 shift
83 -hasrt )
84 hasrt=1
86 *.c )
87 srcs="$srcs $1"
89 esac
90 shift
91 done
93 if [ ! -f "$confdir/lib.conf" ]; then
94 echo "Can't find lib.conf in $confdir"
95 exit 10
98 libname=`grep '^name' "$confdir/lib.conf" | sed 's/^name[^a-zA-Z_]*//'`
99 LIBNAME=`awk </dev/null 'BEGIN { print toupper("'$libname'"); }'`
101 case $mode in
102 libdefs )
103 if [ "x$output" = "x" ]; then
104 outname="libdefs.h"
105 else
106 outname="$output"
108 out="$prefix/$outname"
109 $AWK -f "$scriptdir/genlibdefs.awk" lib.conf > $out.new
110 $scriptdir/moveifchanged $out.new $out
112 functable )
113 if [ "x$output" = "x" ]; then
114 outname="functable.c"
115 else
116 outname="$output"
118 out="$prefix/$outname"
119 $AWK -f "$scriptdir/genfunctable.awk" $srcs > $out.new
120 $scriptdir/moveifchanged $out.new $out
122 fd )
123 echo "Regenerating fd files for $libname"
124 if [ "x$output" = "x" ]; then
125 outname="$libname"_lib.fd
126 else
127 outname="$output"
129 if [ -d "$prefix/fd" ]; then
130 out="$prefix/fd/$outname"
131 else
132 out="$prefix/$outname"
134 $AWK -f "$scriptdir/genfd.awk" $srcs > $out.new
135 $scriptdir/moveifchanged $out.new $out
137 proto )
138 echo "Regenerating proto files for $libname"
139 if [ "x$output" = "x" ]; then
140 outname="$libname".h
141 else
142 outname="$output"
144 if [ -d "$prefix/proto" ]; then
145 out="$prefix/proto/$outname"
146 else
147 out="$prefix/$outname"
149 echo "#ifndef PROTO_"$LIBNAME"_H" > $out.new
150 echo "#define PROTO_"$LIBNAME"_H" >> $out.new
151 echo >> $out.new
152 echo "/*" >> $out.new
153 echo " Copyright © 1995-2004, The AROS Development Team. All rights reserved." >> $out.new
154 echo " Automatically generated by $0" >> $out.new
155 echo "*/" >> $out.new
156 echo >> $out.new
157 echo "#ifndef AROS_SYSTEM_H" >> $out.new
158 echo "# include <aros/system.h>" >> $out.new
159 echo "#endif" >> $out.new
160 echo >> $out.new
161 if [ -f headers.tmpl ]; then
162 $AWK '
163 $1 == "##begin" && $2 == "proto" { doprint=1; next; }
164 $1 == "##end" && $2 == "proto" { doprint=0; next; }
165 { if (doprint) print; }
166 ' headers.tmpl >> $out.new
168 echo "#include <clib/"$libname"_protos.h>" >> $out.new
169 echo "#include <defines/"$libname".h>" >> $out.new
170 echo >> $out.new
171 if [ $hasrt -ne 0 ]; then
172 echo "#if defined(ENABLE_RT) && ENABLE_RT && !defined(ENABLE_RT_"$LIBNAME")" >> $out.new
173 echo "# define ENABLE_RT_"$LIBNAME" 1" >> $out.new
174 echo "# include <aros/rt.h>" >> $out.new
175 echo "#endif" >> $out.new
176 echo >> $out.new
178 echo "#endif /* PROTO_"$LIBNAME"_H */" >> $out.new
179 $scriptdir/moveifchanged $out.new $out
181 pproto )
182 echo "Regenerating private proto files for $libname"
183 if [ "x$output" = "x" ]; then
184 outname="$libname"_private.h
185 else
186 outname="$output"
188 if [ -d "$prefix/proto" ]; then
189 out="$prefix/proto/$outname"
190 else
191 out="$prefix/$outname"
193 echo "#ifndef PROTO_"$LIBNAME"_PRIVATE_H" > $out.new
194 echo "#define PROTO_"$LIBNAME"_PRIVATE_H" >> $out.new
195 echo >> $out.new
196 echo "/*" >> $out.new
197 echo " Copyright © 1995-2004, The AROS Development Team. All rights reserved." >> $out.new
198 echo " Automatically generated by $0" >> $out.new
199 echo "*/" >> $out.new
200 echo >> $out.new
201 echo "#ifndef PROTO_"$LIBNAME"_H" >> $out.new
202 echo "# include <proto/"$libname".h>" >> $out.new
203 echo "#endif" >> $out.new
204 echo >> $out.new
205 echo "#include <clib/"$libname"_private_protos.h>" >> $out.new
206 echo "#include <defines/"$libname"_private.h>" >> $out.new
207 echo >> $out.new
208 echo "#endif /* PROTO_"$LIBNAME"_PRIVATE_H */" >> $out.new
209 $scriptdir/moveifchanged $out.new $out
211 defines )
212 echo "Regenerating defines files for $libname"
213 if [ "x$output" = "x" ]; then
214 outname="$libname".h
215 else
216 outname="$output"
218 if [ -d "$prefix/defines" ]; then
219 out="$prefix/defines/$outname"
220 else
221 out="$prefix/$outname"
223 $AWK -v file=$libdefsfile -f $scriptdir/gendefines.awk $srcs > $out.new
224 $scriptdir/moveifchanged $out.new $out
226 pdefines )
227 echo "Regenerating private defines files for $libname"
228 if [ "x$output" = "x" ]; then
229 outname="$libname"_private.h
230 else
231 outname="$output"
233 if [ -d "$prefix/defines" ]; then
234 out="$prefix/defines/$outname"
235 else
236 out="$prefix/$outname"
238 $AWK -v file=$libdefsfile -f $scriptdir/genpdefines.awk $srcs > $out.new
239 $scriptdir/moveifchanged $out.new $out
241 clib )
242 echo "Regenerating clib files for $libname"
243 if [ "x$output" = "x" ]; then
244 outname="$libname"_protos.h
245 else
246 outname="$output"
248 if [ -d "$prefix/clib" ]; then
249 out="$prefix/clib/$outname"
250 else
251 out="$prefix/$outname"
253 $AWK -v file=$libdefsfile -f $scriptdir/genclib.awk $srcs > $out.new
254 $scriptdir/moveifchanged $out.new $out
256 pclib )
257 echo "Regenerating private clib files for $libname"
258 if [ "x$output" = "x" ]; then
259 outname="$libname"_private_protos.h
260 else
261 outname="$output"
263 if [ -d "$prefix/clib" ]; then
264 out="$prefix/clib/$outname"
265 else
266 out="$prefix/$outname"
268 $AWK -v file=$libdefsfile -f $scriptdir/genpclib.awk $srcs > $out.new
269 $scriptdir/moveifchanged $out.new $out
271 # pragma )
272 # genpragma
273 # ;;
274 inline )
275 echo "Regenerating inline for $libname"
276 if [ "x$output" = "x" ]; then
277 outname="$libname".h
278 else
279 outname="$output"
281 if [ -d "$prefix/inline" ]; then
282 out="$prefix/inline/$outname"
283 else
284 out="$prefix/$outname"
286 $AWK -v file=$libdefsfile -f $scriptdir/geninline.awk $srcs > $out.new
287 $scriptdir/moveifchanged $out.new $out
290 esac