summaryrefslogtreecommitdiff
path: root/scripts/mkc_check_header
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/mkc_check_header')
-rwxr-xr-xscripts/mkc_check_header85
1 files changed, 85 insertions, 0 deletions
diff --git a/scripts/mkc_check_header b/scripts/mkc_check_header
new file mode 100755
index 0000000..9398c3a
--- /dev/null
+++ b/scripts/mkc_check_header
@@ -0,0 +1,85 @@
+#!/bin/sh
+
+############################################################
+# Copyright (c) 2009-2010 by Aleksey Cheusov
+#
+# See LICENSE file in the distribution.
+############################################################
+
+set -e
+
+LC_ALL=C
+export LC_ALL
+
+##################################################
+# options
+usage (){
+ cat <<EOF
+mkc_check_header detects presense of header file
+by compiling a test program.
+
+Usage: mkc_check_header [OPTIONS] header.h
+
+Examples:
+ mkc_check_header stdint.h
+ mkc_check_header getopt.h
+EOF
+}
+
+if test $# -eq 0; then
+ usage
+ exit 1
+fi
+if test "_$1" = '_-h'; then
+ usage
+ exit 0
+fi
+if test "_$1" = '_-d'; then
+ delcache=1
+ shift
+fi
+
+##################################################
+# initializing
+
+pathpart=header_`echo $1 | tr /. __`
+
+. mkc_check_common.sh
+
+##################################################
+# test
+
+check_itself (){
+ cat > "$tmpc" <<EOF
+#include <$1>
+int main ()
+{
+ return 0;
+}
+EOF
+
+ if $CC -c -o "${tmpo}" $CPPFLAGS $CFLAGS "${tmpc}" 2>"${tmperr}"
+ then
+ echo 1
+ else
+ echo 0
+ fi
+}
+
+check_and_cache "checking for header $1" "$cache" "$@"
+
+##################################################
+# clean-ups
+
+cleanup
+
+##################################################
+# finishing
+
+if test "$ret" -eq 1; then
+ printme 'yes\n' 1>&2
+else
+ printme 'no\n' 1>&2
+fi
+
+echo $ret