blob: 0c8f7c561eb3968af2b741ec928e3791ff40ad55 (
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
|
#!/bin/bash
#
# This checks that each header file can be compiled on its own.
#
sh_cc=
sh_dir=
sh_base=${0##*/}
sh_tmpfile=/tmp/$sh_base-$USER.$$.c
sh_outfile=$sh_tmpfile.out
cd ${0%/*}
sh_dir=${PWD%/*}
function fail
{
local msg="$*"
[[ -z "$msg" ]] && msg="failed"
echo "$sh_base: $msg" >&2
exit 1
}
function check_file
{
local file res
file=$1
cat > $sh_tmpfile <<EOF
#include "$sh_dir/$file"
int
main(void)
{
return (0);
}
EOF
[[ $? -eq 0 ]] || fail "can't write to temporary file"
$sh_cc -o $sh_outfile $sh_tmpfile
res=$?
rm $sh_tmpfile $sh_outfile
[[ $? -eq 0 ]] || fail "$file is not clean"
}
if [[ $# -lt 2 ]]; then
echo "$sh_base: <compiler> <file 0> [file 1] [file n]"
fi
sh_cc=$1
shift
for file in "$@"; do
check_file $file
done
|