blob: 11964469279bb8e4161a0dbcd70f8a1bc56d5e9b (
plain)
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
96
97
98
99
100
101
|
# Copyright (c) 2009-2014 by Aleksey Cheusov
#
# See LICENSE file in the distribution.
############################################################
# include file, not executable
# common variables and functions for mkc_check_xxx executables
if test "$pathpart" = ''; then
echo "You've found a bug, please contact the author" 1>&2
exit 1
fi
MKC_CACHEDIR=${MKC_CACHEDIR:-.}
CC=${CC:-cc}
if test -x "$MKC_CACHEDIR"; then
:
else
mkdir -p "$MKC_CACHEDIR"
fi
tmpc=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.c
tmpo=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.o
tmperr=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.err
tmpexe=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.exe
cache=$MKC_CACHEDIR/_mkc_${pathpart}${MKC_NOCACHE}.res
printme (){
if test "$MKC_VERBOSE" != 1; then
return
fi
if test "$MKC_SHOW_CACHED" = 1 || test -z "$cached"; then
printf "$@"
fi
}
cleanup (){
rm -f "$tmpexe" "$tmpo"
if test "$MKC_DELETE_TMPFILES" = 1; then
if test "$KEEP_SOURCE" != 1; then
rm -f "$tmpc"
fi
rm -f "$tmperr"
fi
}
cleanup_all (){
MKC_DELETE_TMPFILES=1
KEEP_SOURCE=0
rm -f "$cache"
cleanup
}
check_and_cache (){
# $1 - message
# $2 - cache file name
# $@ - args...
_msg="$1"
_cache="$2"
shift; shift
if test "$MKC_NOCACHE" != 1 && test -f "$_cache"; then
cached=1
printme '%s' "$_msg... (cached) " 1>&2
ret=`cat "$cache"`
else
printme '%s' "$_msg... " 1>&2
# test itself
ret=`check_itself "$@" 2>"$tmperr"`
if test "$MKC_NOCACHE" = 1; then
rm -f $tmpc $tmpo $tmpexe $tmperr
else
echo "$ret" > "$_cache"
fi
fi
}
find_n_match (){
# $1 - progname
# $2 - opts
# $3 - regexp for matching
__prog=`which $1 2>/dev/null`
if test -n "$__prog" &&
"$__prog" $2 2>/dev/null < /dev/null |
grep -i "$3" > /dev/null
then
echo "$__prog"
exit 0
fi
}
if test -n "$delcache"; then
cleanup_all
exit 0
fi
|