Update coding documentation
[geeqie.git] / scripts / check-compiles.sh
1 #!/bin/bash
2
3 #/*
4 # * Copyright (C) 2021 The Geeqie Team
5 # *
6 # * Author: Colin Clark  
7 # *  
8 # * This program is free software; you can redistribute it and/or modify
9 # * it under the terms of the GNU General Public License as published by
10 # * the Free Software Foundation; either version 2 of the License, or
11 # * (at your option) any later version.
12 # *
13 # * This program is distributed in the hope that it will be useful,
14 # * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # * GNU General Public License for more details.
17 # *
18 # * You should have received a copy of the GNU General Public License along
19 # * with this program; if not, write to the Free Software Foundation, Inc.,
20 # * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 # *
22 # *
23 # * Check that Geeqie compiles with both gcc and clang,
24 # * for both GTK2 and GTK3, and with and without optional modules.
25 #*/  
26
27 compile()
28 {
29         # Cannot have --enable-debug-flags with --disable-gtk3
30
31         declare -A variant
32         variant[0]="$disable_list --disable-gtk3"
33         variant[1]="--disable-gtk3"
34         variant[2]="--enable-debug-flags $disable_list"
35         variant[3]="--enable-debug-flags"
36         variant[4]="$disable_list"
37         variant[5]=""
38
39         for ((i = 0; i <= 5; i++))
40         do
41                 if [[ "${variant[$i]}" =~ "gtk3" ]]; then
42                         gtk="GTK2"
43                 else
44                         gtk="GTK3"
45                 fi
46                 if [[ "${variant[$i]}" =~ "disable-threads" ]]; then
47                         disabled="all disabled"
48                 else
49                         disabled="none disabled"
50                 fi
51                 if [[ "${variant[$i]}" =~ "--enable-debug-flags" ]]; then
52                         debug_flags="enable-debug-flags"
53                 else
54                         debug_flags=""
55                 fi
56
57                 echo -e " \e[32m $1 $gtk $debug_flags $disabled "
58                 sudo make maintainer-clean > /dev/null 2>&1
59                 ./autogen.sh " ${variant[$i]}" > /dev/null 2>&1
60                 make -j > /dev/null
61         done
62 }
63
64 disable_list=" "$(awk -F'[\[\]]' '/AC_HELP_STRING\(\[--disable-/ {if ($2 != "gtk3") print $2}' configure.ac | tr '\n' ' ')
65
66 echo "Disabled list: :$disable_list"
67
68 export CFLAGS="-Wno-deprecated-declarations"
69
70 export CC=clang
71 export CXX=clang++
72 compile "clang"
73
74 export CC=
75 export CXX=
76 compile "gcc"