Index: build.sh ================================================================== --- build.sh +++ build.sh @@ -40,11 +40,11 @@ # script there is some degree of posix # support available, but we might still be # building for windows from within cygwin # or whatever case $os in - lin|?bsd|and|dar|osx) posix=yes; unix=yes;; + lin|?bsd|and|dar|osx|nix) posix=yes; unix=yes;; hai) posix=yes; unix=no;; *) posix=no; unix=no;; esac case $os.$bits in @@ -93,50 +93,26 @@ check asm "an assembler that takes Intel syntax and nasm-style-macros" check m4 "the path to your m4 installation" export build=$(global/build-id.sh) -if test "$p_headers_syscall" = ""; then - case $os in - lin) headers_syscall_search=( - /usr/include/asm/unistd_${bits}.h - /usr/include/asm-generic/unistd.h - /usr/include/*-linux-gnu/asm/unistd_${bits}.h - );; - - fbsd) p_headers_syscall_search=( - /usr/include/sys/syscall.h - );; - esac -fi - if test "$p_headers_errno" = ""; then case $os in lin) p_headers_errno="${p_headers_errno:-/usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h}";; fbsd) p_headers_errno="${p_headers_errno:-/usr/include/errno.h}";; esac fi -for f in "${headers_syscall_search[@]}"; do - test -e "$f" || continue - p_headers_syscall="$f" - say "using syscall headers at $f" - break; -done - -check p_headers_syscall \ - 'the location of a header defining your syscall numbers' check p_headers_errno \ 'the location of a header defining the values of each errno symbol' macro_compile_env="-Datom_target_arch=$arch -Datom_target_os=$os -Dtarget_posix=$posix -Dtarget_unix=$unix" if test "$bits" != ""; then macro_compile_env="$macro_compile_env -Datom_target_bits=$bits" fi - if test "$COLORTERM" != ""; then announce() { test "$verbose" = "silent" && return color="$1" cmd="$2"; shift 2; @@ -164,13 +140,13 @@ local output=$2 local flags=$3 if test -e "$output"; then if test ! "$output" -ot "$src"; then return - fi + fi fi - $m4 $macro_compile_env -I "$gen" $flags "$src" > "$output" + $m4 $macro_compile_env -I "$gen" $flags "$src" > "$output" announce 207 $m4 $macro_compile_env -I "$gen" $flags "$src" \> "$output" # yes, this is incredibly stupid. if you know a better way, feel # free to submit a fix. the problem is there's no way to pass > # to report in such a way that it'll do the right thing, and if # you just write > it redirects *report's* output, instead of @@ -211,23 +187,36 @@ mkdir -p $gen $cc -D_emit_m4_include arch/typesize.c -o $gen/typesize $gen/typesize > gen/typesize.m # generate syscall tables -case $os in - lin) grep -h "#define __NR_" $p_headers_syscall | sed 's;^#define __NR_;;' > $gen/calls.tbl;; - fbsd) grep -h "#define SYS_" $p_headers_syscall | sed 's;^#define SYS_;;' | sed 's;[\t ]\+; ;' > $gen/calls.tbl;; - *) noimpl 'system call table generation';; -esac - -cat $p_headers_syscall $gen/calls.tbl | cpp -P | - awk -f arch/syscall.awk -v out=s >$gen/system_calls.s -cat $p_headers_syscall $gen/calls.tbl | cpp -P | - awk -f arch/syscall.awk -v out=h >$gen/system_calls.h +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 ' > $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 +else + case $os in + # lin) grep -h "#define __NR_" $p_headers_syscall | sed 's;^#define __NR_;;' > $gen/system_calls.tbl;; + # fbsd) grep -h "#define SYS_" $p_headers_syscall | sed 's;^#define SYS_;;' | sed 's;[\t ]\+; ;' > $gen/system_calls.tbl;; + *) noimpl 'system call table generation';; + esac +fi +# cat $p_headers_syscall $gen/system_calls.tbl | cpp -P | +awk -f arch/syscall.awk -v out=s <$gen/system_calls.tbl>$gen/system_calls.s +# cat $p_headers_syscall $gen/system_calls.tbl | cpp -P | +awk -f arch/syscall.awk -v out=h <$gen/system_calls.tbl>$gen/system_calls.h # generate errno tables -grep -h "#[ ]*define[ ]\+E" $p_headers_errno | sed 's;^#[\t ]*define[\t ]\+\(E[A-Z0-9]\+\).*$;k_platform_error_\1 \1;' > $gen/error_names.tbl +grep -h "#[ ]*define[ ]\+E" $p_headers_errno | + sed 's;^#[\t ]*define[\t ]\+\(E[A-Z0-9]\+\).*$;k_platform_error_\1 \1;' >\ + $gen/error_names.tbl cat $p_headers_errno $gen/error_names.tbl | cpp -P >$gen/error_numbers.tbl awk -f arch/errtbl.awk <$gen/error_numbers.tbl >$gen/error_table.h # generate symbol tables for error handling functions mkdir -p "$out/k"