xref: /imagick/configure-cflags.sh (revision 0a6c463a)
1#!/bin/bash
2#
3# Set CFLAGS to be strict for supported versions on Travis
4
5#containsElement () {
6#  local e
7#  for e in "${@:2}"; do [[ "$e" == "$1" ]] && return 0; done
8#  return 1
9#}
10
11
12# Bash return statements are not useful. You have to echo the value
13# and then capture it by calling the function with $( foo )
14function contains() {
15    local n=$#
16    local value=${!n}
17    for ((i=1;i < $#;i++)) {
18        if [ "${!i}" == "${value}" ]; then
19            echo "1"
20            return 0
21        fi
22    }
23    echo "0"
24    return 0
25}
26
27
28
29strictPHPVersions=()
30# strictPHPVersions+=("5.6")
31strictPHPVersions+=("7")
32strictPHPVersions+=("7.0")
33strictPHPVersions+=("7.1")
34
35strictImageMagickVersions=()
36strictImageMagickVersions+=("dev")
37strictImageMagickVersions+=("6.8.7-0")
38strictImageMagickVersions+=("6.7.5-3")
39strictImageMagickVersions+=("6.6.0-9")
40strictImageMagickVersions+=("7.0.8-4")
41strictImageMagickVersions+=("7.0.1-0")
42
43
44echo "TRAVIS_PHP_VERSION is ${TRAVIS_PHP_VERSION}"
45echo "IMAGEMAGICK_VERSION is ${IMAGEMAGICK_VERSION}"
46
47strictImageMagick=$(contains "${strictImageMagickVersions[@]}" "${IMAGEMAGICK_VERSION}" )
48strictPHP=$(contains "${strictPHPVersions[@]}" "${TRAVIS_PHP_VERSION}" )
49
50echo "strictImageMagick is ${strictImageMagick}"
51echo "strictPHP is ${strictPHP}"
52
53# TODO - test if this flag is usable for the tests on all appropriate platforms
54# -Wmaybe-uninitialized
55
56if [[ $strictPHP = '1' ]] && [[ $strictImageMagick = '1' ]]; then
57	CFLAGS="-Wno-deprecated-declarations -Wdeclaration-after-statement -Werror -Wall -Wextra -Wimplicit-function-declaration";
58else
59	CFLAGS="-Wno-deprecated-declarations";
60fi
61
62echo "Setting CFLAGS to ${CFLAGS}"
63
64export CFLAGS=$CFLAGS