@@ -23,13 +23,25 @@ # TODO: make it possible for user to change # default set with environment vars modules=(kcore kmem kstr kio kgraft kfile) +# compose an arch tuple. this is used in +# places, mostly to select the correct +# version of assembly files for a given +# platform (each has an arch tuple in its +# name, following the linkage specifier) target=$arch.$os if test "$bits" != ""; then target=$target.$bits fi +# determine whether we have unix or posix +# APIs depending on the operating system. +# presumably if the user is running a bash +# 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;; hai) posix=yes; unix=no;; *) posix=no; unix=no;; @@ -81,15 +93,36 @@ check m4 "the path to your m4 installation" export build=$(global/build-id.sh) -case $os in - lin) p_headers_syscall=${p_headers_syscall:-/usr/include/asm/unistd_${bits}.h} - p_headers_errno=${p_headers_errno:-/usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h};; +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=${p_headers_syscall:-/usr/include/sys/syscall.h} - p_headers_errno=${p_headers_errno:-/usr/include/errno.h};; -esac + 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 \