146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
if test ! "$output" -ot "$src"; then
return
fi
fi
if test "$debug" = yes; then
local dflag="-g dwarf2"
fi
report $asm $flags $dflag "-f$bin_fmt" -i "$gen" -i "$PWD" "$src" -o "$output";
}
comp_co() { comp_c $1 $2 "-c -fPIC"; }
comp_c(){
local src=$1
local output=$2
local flags=$3
if test -e "$output"; then
................................................................................
# only rebuild the file if the source file is newer
if test "$debug" = yes; then
local dflag="-g"
else
local dflag="-O4"
fi
if test "$assembly" = yes; then
report $cc $src $3 $dflag -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -ffreestanding -nostdlib "-L$to" -masm=intel -fverbose-asm -S "-o$output.s"
else
report $cc $src $3 $dflag -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/" -ffreestanding -nostdlib "-L$to" "-o$output"
fi
}
say "commencing libk build $build at $(timestamp)"
# set -x
# get type data
mkdir -p $gen
report $cc -D_emit_m4_include arch/typesize.c -o $gen/typesize
$gen/typesize > gen/typesize.m
# generate syscall tables
if test $posix = yes; then
# on posix, we simply abuse CPP to garner a list of syscalls;
# the file arch/posix/syscalls contains a list of syscalls
# we wish to import; we use sed to transform this into a form
# that cpp will fill out for us, producing a table that the
# awk scripts can handle and turn into a list of constants.
echo '#include <sys/syscall.h>' > $gen/system_calls.t.1 # this is the magic part
cat arch/posix/syscalls > $gen/system_calls.t.2
sed -e 's;^\(.*\)$;\1 SYS_\1;' -i $gen/system_calls.t.2
cat $gen/system_calls.t.1 $gen/system_calls.t.2 | cpp -P >$gen/system_calls.tbl
# generate errno tables the same way
echo '#include <errno.h>' > $gen/error_codes.t.1 # this is the magic part
cat arch/posix/errnos > $gen/error_codes.t.2
sed -e 's;^\(.*\)$;k_platform_error_\1 \1;' -i $gen/error_codes.t.2
cat $gen/error_codes.t.1 $gen/error_codes.t.2 | cpp -P | grep "^k_platform_error" >$gen/error_codes.tbl # haaaack
else
case $os in
*) noimpl 'system call table generation';;
esac
fi
# take the OS-specific system call tables that have been prepared
# for us above and feed them into awk scripts to generate C headers
awk -f arch/syscall.awk -v out=s <$gen/system_calls.tbl>$gen/system_calls.s
awk -f arch/syscall.awk -v out=h <$gen/system_calls.tbl>$gen/system_calls.h
# do the same with our error codes table
awk -f arch/errtbl.awk <$gen/error_codes.tbl >$gen/error_table.h
# generate symbol tables for error handling functions
mkdir -p "$to/k"
awk -f global/gen-conds.awk <global/modules >$to/k/internal.egroup.h
awk -f global/gen-ident.awk <global/modules >$gen/internal.ident.c
comp_co $gen/internal.ident.c $to/internal.ident.o
# first pass: copy all headers into place,
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
...
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
if test ! "$output" -ot "$src"; then
return
fi
fi
if test "$debug" = yes; then
local dflag="-g dwarf2"
fi
report $asm $flags $dflag "-f$bin_fmt" -I "$gen" -I "$PWD" -I "arch/$target" "$src" -o "$output";
}
comp_co() { comp_c $1 $2 "-c -fPIC"; }
comp_c(){
local src=$1
local output=$2
local flags=$3
if test -e "$output"; then
................................................................................
# only rebuild the file if the source file is newer
if test "$debug" = yes; then
local dflag="-g"
else
local dflag="-O4"
fi
if test "$assembly" = yes; then
report $cc $src $3 $dflag -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/$target" -isystem "$PWD" -ffreestanding -nostdlib "-L$to" -masm=intel -fverbose-asm -S "-o$output.s"
else
report $cc $src $3 $dflag -std=c11 -isystem "$to" -isystem "$gen" -isystem "arch/$target" -isystem "$PWD" -ffreestanding -nostdlib "-L$to" "-o$output"
fi
}
say "commencing libk build $build at $(timestamp)"
# set -x
# get type data
mkdir -p $gen
report $cc -D_emit_m4_include arch/typesize.c -o $gen/typesize
$gen/typesize > gen/typesize.m
# generate symbol tables for error handling functions
mkdir -p "$to/k"
awk -f global/gen-conds.awk <global/modules >$to/k/internal.egroup.h
awk -f global/gen-ident.awk <global/modules >$gen/internal.ident.c
comp_co $gen/internal.ident.c $to/internal.ident.o
# first pass: copy all headers into place,
|