Use dos.library/CreateNewProc() instead of alib/CreateNewProcTags()
[tangerine.git] / compiler / c_lib / source / lib_source / genclib.awk
blob1a015795fcbd23610f0c1800795956b508f3f57c
1 BEGIN {
2 stderr="/dev/stderr";
4 if (file == "")
6 file = "libdefs.h";
8 while ((getline < file) > 0)
10 if ($2 == "BASENAME")
12 lib = $3;
13 basename = $3;
15 else if ($2 == "LIBBASE")
17 libbase = $3;
19 else if ($2 == "LIBBASETYPEPTR")
21 libbtp = $3;
22 for (t=4; t<=NF; t++)
23 libbtp=libbtp" "$t;
25 else if ($2 == "NT_TYPE")
27 if( $3 == "NT_RESOURCE" )
29 firstlvo = 0;
30 libext = ".resource";
32 else if( $3 == "NT_DEVICE" )
34 firstlvo = 6;
35 libext = ".device";
37 else
39 firstlvo = 4;
40 libext = ".library";
45 verbose_pattern = libbase"[ \\t]*,[ \\t]*[0-9]+[ \\t]*,[ \\t]*"basename;
47 close (file);
49 BASENAME=toupper(basename);
51 print "#ifndef CLIB_"BASENAME"_PROTOS_H"
52 print "#define CLIB_"BASENAME"_PROTOS_H"
53 print ""
54 print "/*"
55 print " Copyright © 1995-2003, The AROS Development Team. All rights reserved."
56 print " *** Automatically generated by genclib.awk. Do not edit ***"
57 print ""
58 print " Desc: Prototypes for "basename libext
59 print " Lang: english"
60 print "*/"
61 print ""
62 print "#ifndef AROS_LIBCALL_H"
63 print "# include <aros/libcall.h>"
64 print "#endif"
65 print ""
67 file = "headers.tmpl"
68 doprint = 0;
69 emit = 0;
70 doParse = 0;
71 nifct = 0;
72 doInsertFct = 0;
74 while ((getline < file) > 0)
76 if ($1=="##begin" && $2 == "clib")
77 doprint = 1;
78 else if ($1=="##end" && $2 == "clib")
79 doprint = 0;
80 else if ($1=="##begin" && $2 == "insert_fct")
81 doParse = 1;
82 else if ($1=="##end" && $2 == "insert_fct")
83 doParse = 0
84 else if (doprint)
86 print;
87 emit ++;
89 else if(doParse)
92 if($1 == "PRE") {sub(/^PRE / , ""); insert_pre = $0;}
93 if($1 == "POST"){sub(/^POST /, ""); insert_post = $0;}
94 if($1 == "FCT") {insert_fct[nifct++] = $2;}
99 if (emit > 0)
100 print ""
102 print "/* Prototypes */"
104 /AROS_LH[0-9]/ { isprivate=0; }
105 /AROS_NTLH[0-9]/ { isprivate=0; }
106 /AROS_PLH[0-9]/ { isprivate=1; }
107 /AROS_(NT)?LH(A|(QUAD)?[0-9])/ {
108 line=$0;
110 isarg=match(line,/AROS_LHA/);
111 gsub(/AROS_(NT)?LH/,"AROS_LP",line);
112 gsub(/^[ \t]+/,"",line);
113 if (!isarg)
115 call=line;
116 narg=0;
118 doInsertFct = 0;
119 for (i = 0; (i < nifct && doInsertFct == 0); i++)
121 if(call ~ insert_fct[i]) doInsertFct = 1;
125 else
127 arg[narg++]=line;
130 /LIBBASE[ \t]*,[ \t]*[0-9]+/ || $0 ~ verbose_pattern {
131 line=$0;
132 gsub(/LIBBASETYPEPTR/,libbtp,line);
133 gsub(/LIBBASE/,libbase,line);
134 gsub(/BASENAME/,basename,line);
135 gsub(/[ \t]*[)][ \t]*$/,"",line);
136 gsub(/^[ \t]+/,"",line);
137 na=split(line,a,",");
138 lvo=int(a[3]);
140 if (lvo > firstlvo && !isprivate)
142 if(doInsertFct) print insert_pre
143 print call
145 for (t=0; t<narg; t++)
146 print "\t"arg[t]
147 print "\t"line")";
149 if(doInsertFct) print insert_post
150 print ""
152 narg=0;
154 END {
155 print "#endif /* CLIB_"BASENAME"_PROTOS_H */"