File: mkc_check_header.in

package info (click to toggle)
mk-configure 0.36.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 3,996 kB
  • sloc: ansic: 4,974; makefile: 1,387; sh: 1,087; cpp: 177; perl: 101; yacc: 85; lex: 21
file content (95 lines) | stat: -rwxr-xr-x 1,748 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/sh

############################################################
# Copyright (c) 2009-2010 by Aleksey Cheusov
#
# See LICENSE file in the distribution.
############################################################

set -e

LC_ALL=C
export LC_ALL

: ${CHECK_COMMON_SH_DIR:=@mkc_libexecdir@}

##################################################
# options
usage (){
    cat <<EOF
mkc_check_header detects presense of header file
by compiling a test program.

Usage: mkc_check_header [OPTIONS] <headers>

OPTIONS:
   -h        display this screen
   -d        delete cache file
   -e        check for existance of header file (cc -E vs. cc -c)
Examples:
   mkc_check_header stdint.h
   mkc_check_header getopt.h
EOF
}

CC_OPTS='-c'
partpath='header'
msg_addon="using ${CC} -c"

while test $# -ne 0; do
    case "$1" in
	-h) usage; exit 0;;
	-d) delcache=1;;
	-e) partpath=hdr; CC_OPTS='-E'; msg_addon="using ${CC} -E";;
	*) break;;
    esac
    shift
done

if test $# -eq 0; then
    usage
    exit 1
fi

##################################################
# initializing

pathpart="$partpath"_`echo "$1" | sed 's/^.*,//' | tr /. __`

. ${CHECK_COMMON_SH_DIR}/mkc_check_common.sh

##################################################
# test

check_itself (){
    get_includes "$@" > "$tmpc"

    cat >> "$tmpc" <<EOF
int __fake_variable;
EOF

    if $CC $CC_OPTS -o "${tmpo}" $CPPFLAGS $CFLAGS "${tmpc}" 2>"${tmperr}"
    then
	echo 1
    else
	echo 0
    fi
}

check_and_cache "checking $1 $msg_addon" "$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