From 9ca8c4c3c1b2cb1b22a3ff04c1c37b0863dd87f6 Mon Sep 17 00:00:00 2001 From: midipix Date: Fri, 4 Mar 2016 13:32:05 -0500 Subject: created skeleton. --- sysinfo/host/host.sh | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 sysinfo/host/host.sh (limited to 'sysinfo/host/host.sh') diff --git a/sysinfo/host/host.sh b/sysinfo/host/host.sh new file mode 100755 index 0000000..e4079ee --- /dev/null +++ b/sysinfo/host/host.sh @@ -0,0 +1,82 @@ +#!/bin/sh + +error_msg() +{ + echo $@ >&2 +} + +host_test() +{ + mb_hdrdir=$(pwd)/build + mkdir -p $mb_hdrdir || exit 2 + + if [ -z "$mb_compiler" ]; then + echo "config error: compiler not set." + exit 2 + fi + + $mb_compiler -dM -E - < /dev/null > /dev/null && return 0 + + error_msg "config error: invalid compiler." + exit 2 +} + +host_endian_h() +{ + mb_header='endian.h' + rm -f "$mb_hdrdir"/$mb_header + + # portable + printf "#include <$mb_header>" | $mb_compiler $mb_cflags \ + -E - > /dev/null 2>/dev/null \ + && return 0 + + # non-portable + mb_hosthdr= + + [ -z $mb_hosthdr ] && printf "#include " | $mb_compiler $mb_cflags \ + -E - > /dev/null 2>/dev/null \ + && mb_hosthdr='sys/'$mb_header + + [ -z $mb_hosthdr ] && printf "#include " | $mb_compiler $mb_cflags \ + -E - > /dev/null 2>/dev/null \ + && mb_hosthdr='machine/'$mb_header + + if [ -z "$mb_hosthdr" ]; then + error_msg "config error: could not find an alternate <$mb_header>." + exit 2 + fi + + printf "#include <%s>\\n" $mb_hosthdr > "$mb_hdrdir"/$mb_header || exit 2 +} + + +# one: args +for arg ; do + case "$arg" in + --help) usage + ;; + --compiler=*) + mb_compiler=${arg#*=} + ;; + --cflags=*) + mb_cflags=${arg#*=} + ;; + *) + error_msg ${arg#}: "unsupported config argument." + exit 2 + ;; + esac +done + + +# two: test +host_test + + +# three: headers +host_endian_h + + +# all done +exit 0 -- cgit v1.2.3