xref: /imagick/util/calculate_cflags.php (revision 13ee61ca)
1<?php
2
3// Run with something like:
4// export CLFAGS=$(php util/calculate_cflags.php "8.0" "7.0.1-0")
5
6if ($argc !== 3) {
7    fwrite(STDERR, "usage php calculate_cflags.php \$PHP_VERSION \$IMAGEMAGICK_VERSION \n");
8    exit(-1);
9}
10
11$PHP_VERSION = $argv[1];
12$IMAGEMAGICK_VERSION = $argv[2];
13
14$message = sprintf(
15    "Calculating for PHP_VERSION [%s] IMAGEMAGICK_VERSION [%s]\n",
16    $PHP_VERSION,
17    $IMAGEMAGICK_VERSION
18);
19fwrite(STDERR, $message);
20
21$CFLAGS = array(
22    "-Wno-deprecated-declarations",
23    "-Wdeclaration-after-statement",
24    "-Werror",
25    "-Wall",
26    "-Wextra",
27    "-Wimplicit-function-declaration",
28    "-Wno-variadic-macros",
29    "-Wno-sign-compare",
30
31    //Errors in IM6.9.2-0
32    "-Wno-unused-parameter",
33    "-Wno-unused-variable"
34);
35
36
37if (strpos($IMAGEMAGICK_VERSION, "6.8") === 0) {
38    $CFLAGS = array("-Wno-deprecated-declarations");
39}
40
41
42if ($PHP_VERSION == "5.4" || $PHP_VERSION == "5.5") {
43    $CFLAGS = array("-Wno-deprecated-declarations");
44}
45else if ($PHP_VERSION == "5.6") {
46    $CFLAGS = array(
47        "-Wno-deprecated-declarations",
48        "-Wdeclaration-after-statement",
49        "-Werror",
50        "-Wall",
51        "-Wimplicit-function-declaration"
52    );
53}
54
55$result = implode(" ", $CFLAGS);
56echo $result;
57fwrite(STDERR, "Ok. CFLAGS are: $result\n");
58