• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/sh
2#
3# Do some checking before 'git push'.
4
5# Set a stricter bash mode
6set -e
7set -u
8
9CORES=$(nproc)
10
11echo "Running: make distclean"
12make distclean > /dev/null || true
13
14# We define _GNU_SOURCE to avoid warnings with missing prototypes.
15# C89 does not know snprintf, strdup, strndup, popen, pclose
16CFLAGS="-std=gnu89 -pedantic -g -Wall -Wextra -Wstrict-prototypes -Wold-style-definition -Wwrite-strings -Wshadow -Wformat -Wformat-security -Wunreachable-code -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition"
17
18CACHEFILE=$PWD/config_check.cache
19
20# measure time consumed and print it at the end of the script
21START=$(date +%s.%N)
22
23# avoid annoying ar warning
24export ARFLAGS="cr"
25export AR_FLAGS="cr"
26
27echo "Running: ./autogen.sh"
28./autogen.sh > /dev/null
29echo
30
31for CC in gcc clang; do
32  export CC
33  echo
34  echo "*** Testing with CC=$CC"
35
36  # the compiler changed, so we have to remove the cache file here
37  rm -f $CACHEFILE
38
39  for options in \
40  "--enable-runtime=libicu --enable-builtin=libicu" \
41  "--enable-runtime=libidn2 --enable-builtin=libidn2" \
42  "--enable-runtime=libidn --enable-builtin=libidn" \
43  "--disable-runtime --enable-builtin=libicu"; do
44    export DISTCHECK_CONFIGURE_FLAGS="-q -C --cache-file=$CACHEFILE $options"
45    if test "$CC" = "clang"; then
46      echo
47      echo "  *** CC=$CC ./configure $DISTCHECK_CONFIGURE_FLAGS --enable-cfi"
48      ./configure $DISTCHECK_CONFIGURE_FLAGS --enable-cfi CFLAGS="$CFLAGS"
49      for xLCALL in C tr_TR.utf8; do
50        make -s clean
51        make -s check -j$CORES
52      done
53    fi
54
55    for flags in --enable-ubsan --enable-asan; do
56#      case "$flags" in *-asan) case $options in *libicu*) continue;; esac;; esac
57      echo
58      echo "  *** CC=$CC ./configure $DISTCHECK_CONFIGURE_FLAGS $flags"
59      ./configure $DISTCHECK_CONFIGURE_FLAGS $flags CFLAGS="$CFLAGS"
60      for xLCALL in C tr_TR.utf8; do
61        make -s clean
62        make -s check -j$CORES
63      done
64    done
65
66    echo
67    echo "  *** CC=$CC ./configure $DISTCHECK_CONFIGURE_FLAGS"
68    ./configure $DISTCHECK_CONFIGURE_FLAGS CFLAGS="$CFLAGS"
69    for xVALGRIND in 0 1; do
70      for xLCALL in C tr_TR.utf8; do
71        export TESTS_ENVIRONMENT="LC_ALL=$xLCALL VALGRIND_TESTS=$xVALGRIND"
72        echo "    *** TESTS_ENVIRONMENT=\"$TESTS_ENVIRONMENT\"" make check -j$CORES
73        make -s clean
74        make -s check -j$CORES
75      done
76    done
77
78    unset TESTS_ENVIRONMENT
79    export TESTS_ENVIRONMENT
80    echo
81    echo "  *** $CC: make distcheck CFLAGS=$CFLAGS -j$CORES"
82    ./configure $DISTCHECK_CONFIGURE_FLAGS CFLAGS="$CFLAGS"
83    make -s clean
84    make -s check -j$CORES
85    make -s distcheck CFLAGS="$CFLAGS" -j$CORES
86  done
87done
88
89END=$(date +%s.%N)
90echo
91echo "Duration: "$(echo "$END - $START" | bc)
92