tools/adflib: build only host variant which is used by Sam440 target
[AROS.git] / workbench / network / stacks / AROSTCP / bsdsocket / kern / config_var.awk
blob4d728bbc7f396a52bff5aafb7b7cd18ea82c2ff4
1 # -*- C -*- --- well, not actually...
3 # Copyright (C) 1993 AmiTCP/IP Group, <amitcp-group@hut.fi>
4 # Helsinki University of Technology, Finland.
5 # All rights reserved.
6 # Copyright (C) 2005 - 2007 The AROS Dev Team
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston,
20 # MA 02111-1307, USA.
23 BEGIN {
24 FS="[\t ]*;[\t ]*";
25 level=1;
26 tab="";
27 vars="";
28 var2="";
29 GFN = "kern/variables.src (" FILENAME ")";
30 TEXTARGET=0;CTARGET=0;TEXITARGET=0
31 if (TARGETTI == "TEX") {
32 TEXTARGET = 1;
33 startcomment = "% -*- LaTeX -*-";
34 comment = "%";
35 endcomment = "%";
36 }else if (TARGETTI == "TEXINFO") {
37 level = 0;
38 TEXITARGET = 1;
39 startcomment = "@c -*- Texinfo -*-";
40 comment = "@c ";
41 endcomment = "@c ";
42 } else if (TARGETTI == "C") {
43 CTARGET = 1;
44 startcomment = "/* -*- C -*-";
45 comment = " *";
46 endcomment = " */";
47 } else printf "Unknown target format '%s'\n",TARGETTI > "/dev/stderr"
48 print startcomment;
49 printf "%s This file is automatically generated from %s\n", comment, GFN;
50 print comment;
51 printf "%s Do not change this file\n", comment;
52 print endcomment;
53 if (CTARGET) {
54 print "";
55 print "\#include <sys/param.h>";
56 print "\#include <netinet/in.h>";
57 print "\#include <kern/amiga_includes.h>";
58 print "\#include <kern/amiga_config.h>";
59 print "\#include <sys/socket.h>";
60 print "";
64 # skip comments and empty lines
65 /^#/ { next }
66 /^ *$/ { next }
67 # Collect global variables
68 /^global/ {
69 gsub("^global ", "");
70 globals = globals "\n" $0;
71 next;
73 # Change _ to \_ in TeX
74 TEXTARGET && /_/ { gsub("_","\\_") }
75 # Generate indentation, add environment parenthesis
76 level != $2 && TEXTARGET {
77 if (level < $2)
78 for(i=level; i < $2; i++) {
79 tab = sprintf("%"2*i"s", "");
80 print tab "\\begin{description}";
82 else
83 for(i=level; i > $2; i--) {
84 tab = sprintf("% "2*i "s", "");
85 print tab "\\end{description}";
87 level = $2;
88 tab = sprintf("%" 2*level "s", "");
89 print "";
91 TEXTARGET {
92 n = split($1,temp,"=");
93 printf "%s\\item[\\code{%s}] %s\n",tab,temp[n],$3;
94 if(n>1) {
95 printf tab " \\Alias%s{%s",(n>2)?"es":"",temp[1];
96 for(i=2;i<n;i++)
97 printf "{\\rm ,} %s",temp[i];
98 print "}";
100 print "";
101 if ($2 == 1) {
102 # Skip C declarations
103 getline dummy;
104 getline dummy;
108 # TEXINFO
110 $2 == 2 && TEXITARGET {
111 if (level == 1)
112 print "@table @code";
113 n = split($1,temp,"=");print "level=" $2, n > "/dev/stderr"
114 printf "@item %s\n",temp[n];
115 for(i=1;i<n;i++) {
116 printf "@itemx %s\n",temp[i];
118 gsub("\\\\n","\n",$3) # replace with newlines
119 print $3;print "";
120 level = $2;
121 print "";
123 $2 == 1 && TEXITARGET {
124 if (level == 2)
125 print "@end table";
126 if (level != 0)
127 print "@end deffn\n";
128 n = split($1,temp,"="); print "level=" $2, n > "/dev/stderr"
129 printf "@deffn {AREXX Variable} %s\n",temp[n];
130 for(i=1;i<n;i++) {
131 printf "@deffnx {AREXX Variable} %s\n",temp[i];
133 gsub("\\\\n","\n",$3) # replace with newlines
134 print $3;print "";
135 level = $2;
136 print "";
138 if ($2 == 1) {
139 # Skip C declarations
140 getline dummy;
141 getline dummy;
144 ($2 != 1 && $2 != 2) && TEXITARGET {
145 print FILENAME ":" FNR ": Invalid level: " $2 > "/dev/stderr"
148 # Make a C file
150 CTARGET {
151 n = split($1, temp, "=");
152 if ($2 == 1) {
153 if (length(var2) > 0) {
154 printf "/* %s */\n#define KW_%s \\\n \"", varcom, curvar;
155 n2 = split(var2, t2, ",");
156 cnt = 0;
157 for (i = 1; i < n2; i++) {
158 if ((cnt + length(t2[i])) > 60) {
159 printf "\" \\\n \"";
160 cnt=0;
162 cnt += length(t2[i]);
163 printf "%s,",t2[i];
165 if (length(t2[n2]) + cnt > 60)
166 printf "\" \\\n \"";
167 printf "%s\"\n\n", t2[n2];
169 curvar=temp[n];
170 varcom=$3;
171 if (length(vars) > 0) {
172 vars=vars "," $1;
173 } else {
174 vars=$1;
176 var2 = "";
177 # Get external vars
178 getline extern;
179 externs = externs "\n" extern;
180 # get variables line
181 getline varline;
182 if (length(varlines) > 0) {
183 varlines = varlines ",\n" varline;
184 } else {
185 varlines = varline;
187 } else {
188 if(length(var2) == 0) {
189 var2=$1;
190 } else {
191 var2 = var2 "," $1;
196 END {
197 if (TEXTARGET) {
198 for(i = level; i > 1; i--)
199 print "\\end{description}";
200 } else if(TEXITARGET) {
201 if (level == 2)
202 print "@end table";
203 if (level != 0)
204 print "@end deffn\n";
205 } else if(CTARGET) {
206 if (length(var2) > 0) {
207 printf "/* %s */\n#define KW_%s \\\n \"", varcom, curvar;
208 n2 = split(var2, t2, ",");
209 cnt = 0;
210 for(i=1;i<n2;i++) {
211 if((cnt+length(t2[i]))>60) {
212 printf "\" \\\n \"";
213 cnt=0;
215 cnt += length(t2[i]);
216 printf "%s,",t2[i];
218 if (length(t2[n2])+cnt> 60) printf "\" \\\n \"";
219 printf "%s\"\n\n", t2[n2];
222 if (length(vars) > 0) {
223 printf "/* %s */\nSTRPTR KW_%s =\n \"", "Level 1 variables", "VARS";
224 n2 = split(vars, t2, ","); cnt=0;
225 for(i=1; i<n2; i++) {
226 if(cnt + length(t2[i]) > 60) {
227 printf "\"\n \"";
228 cnt=0;
230 cnt+=length(t2[i]);
231 printf "%s,",t2[i];
233 printf "%s\";\n\n", t2[n2];
235 if (length(externs)) {
236 print "/* extern declarations */";
237 print externs;
238 print;
240 if (length(globals)) {
241 printf "/* Global variables */";
242 print globals;
243 print;
245 if (length(varlines)) {
246 print "struct cfg_variable variables[] = {";
247 print varlines;
248 print "};";