summaryrefslogtreecommitdiff
path: root/check_boost.sh
blob: 2ffb8244f732a5d27579a213e3a1922a405c5a9c (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
#!/bin/bash -e

# This script is invoked by "make check" to verify that we have
# correctly declared the exact set of Boost include files that
# "configure" should look for.
#
# Currently, this assumes that every occurrence of "boost/foo.hpp" is
# significant.  If stray strings that look like that find their way
# into the source code or configure, we'll have to look at #include
# lines and/or mark off the section of configure with a tag (and,
# e.g., use "awk" instead of "grep").

echo "Verifying that the configure check tests the correct set of header files."

RESULT=0

BOOST_PATTERN='boost/[a-zA-Z0-9_./-]*\.hpp'
# Exclude headers that are only used, e.g., to write configure tests.
BOOST_CONFIGURE_PATTERN="$BOOST_PATTERN"' dnl$'

SRCDIR=${srcdir:-.}

if [ ! -f $SRCDIR/configure.ac ]
then
  echo "Could not locate configure.ac."
  exit 2
fi

# Check that the source code and the configure check look for the same
# Boost headers.
SRC_OCCURRENCES=$((find $SRCDIR/src \( -name \*.cc -or -name \*.h \) -print0; find $SRCDIR/tests \( -name \*.cc -or -name \*.h \) -print0) \
                  | xargs -0 grep -h --only-matching "$BOOST_PATTERN" | sort -u)

if ! grep -h --only-matching "$BOOST_CONFIGURE_PATTERN" $SRCDIR/configure.ac | sed 's/ dnl$//' | sort -c
then
  echo "The list of Boost headers in configure.ac is not sorted."
  RESULT=2
fi

CONFIGURE_OCCURRENCES=$(grep -h --only-matching "$BOOST_CONFIGURE_PATTERN" $SRCDIR/configure.ac | sed 's/ dnl$//' | sort -u)

if ! cmp <(echo "$SRC_OCCURRENCES") <(echo "$CONFIGURE_OCCURRENCES") >/dev/null
then
    ONLY_SRC=$(comm -2 -3 <(echo "$SRC_OCCURRENCES") <(echo "$CONFIGURE_OCCURRENCES"))
    ONLY_CONFIG=$(comm -1 -3 <(echo "$SRC_OCCURRENCES") <(echo "$CONFIGURE_OCCURRENCES"))
    echo "Mismatch in Boost header file declarations."
    if [ -n "$ONLY_SRC" ]
    then
	echo "The following headers occur only in the source code:"
	echo "$ONLY_SRC"
    fi
    if [ -n "$ONLY_CONFIG" ]
    then
	echo "The following headers occur only in the configure script:"
	echo "$ONLY_CONFIG"
    fi

    echo "*** BOOST CONFIGURE CHECK MISMATCH."
    echo "*** Please update the configure script to match the source code."

    RESULT=1
fi

exit $RESULT