File: rebuild.sh

package info (click to toggle)
icewm 2.1.2-1
  • links: PTS
  • area: main
  • in suites: bullseye
  • size: 11,900 kB
  • sloc: cpp: 62,372; ansic: 2,023; makefile: 1,500; sh: 558; perl: 286; xml: 241
file content (169 lines) | stat: -rwxr-xr-x 4,613 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
#!/usr/bin/env bash

usage () {
cat <<EOI
Usage: $0 [ options... ]
Options:
    -a : autoconf+cscope
    -c : CMake debug build
    -d : dependencies check
    -g : prefer GdkPixbuf rendering
    -i : prefer Imlib2 rendering
    -r : CMake release build
    -t : test configure options
    -j# : number of gmake procs
    --prefix=... : install prefix
    --with-xterm=... : set terminal
EOI
exit 0
}

unset ACONF DBGCM DEPEN RELCM TESTC GDK IM2 jobs prefix xterm
prefix=/usr
xterm=urxvt
GDK=ON
IM2=OFF

if ! command -v gmake >/dev/null ; then
    function gmake () {
        make "$@"
    }
fi

# parse argv
for x
do
    case $x in
        (-a) ACONF=1 ;;  # enable autoconf+cscope
        (-c) DBGCM=1 ;;  # enable CMake debug build
        (-d) DEPEN=1 ;;  # check the dependencies
        (-r) RELCM=1 ;;  # enable CMake release build
        (-t) TESTC=1 ;;  # test all combinations of configure options
        (-j*) jobs=$x ;; # number of gmake procs
        (-i) IM2=ON ; GDK=OFF ;; # enable Imlib2
        (-g) GDK=ON ; IM2=OFF ;; # enable gdkpixbuf
        (--prefix=*) prefix=${x#*=} ;; # install prefix
        (--with-xterm=*) xterm=${x#*=} ;; # set terminal
        (-h|--help|-?) usage ;;
        (*) echo "$0: Unknown option '$x'." >&2 ; exit 1 ;;
    esac
done

# set default
[[ -v ACONF || -v DBGCM || -v DEPEN || -v RELCM || -v TESTC ]] || ACONF=1

# gmake jobs
[[ -v jobs ]] || jobs=-j$(($(nproc 2>/dev/null||echo 4)<<1))

# check all POTFILES exist
if [[ -f po/POTFILES.in ]]; then
    fail=
    for file in $(< po/POTFILES.in ); do
        if [[ ! -f $file ]]; then
            echo "Missing $file is still in po/POTFILES.in!" >&2
            fail+="$file "
        fi
    done
    if [[ -n $fail ]]; then
        echo "Please update po/POTFILES.in for $fail!" >&2
        set -x
        exit 99
    fi
fi

if [[ -v ACONF ]]; then

    rm -f cscope.*
    ./autogen.sh
    ./configure.sh
    gmake clean
    gmake cscope
    cscope -b
    gmake "$jobs" clean all README

fi

if [[ -v DBGCM ]]; then

    # cmake cheat sheet... with Debian-style configuration
    mkdir -p builddir-debug || rm -rf builddir-debug/CMake*
    cd builddir-debug &&
    cmake .. \
        -DCONFIG_GDK_PIXBUF_XLIB=$GDK \
        -DCONFIG_IMLIB2=$IM2 \
        -DCONFIG_LIBRSVG=ON \
        -DCONFIG_XRANDR=ON \
        -DCONFIG_XPM=ON \
        -DCMAKE_CXX_COMPILER_ID=clang \
        -DCMAKE_CXX_COMPILER=clang++ \
        -DCMAKE_INSTALL_PREFIX=$prefix \
        -DCMAKE_BUILD_TYPE=RelWithDebInfo \
        -DICEHELPIDX=$prefix/share/doc/icewm-common/html/icewm.html \
        -DCFGDIR=/etc/X11/icewm \
        -DVERSION=10.9.8-debug \
        -DDOCDIR=$prefix/share/doc/icewm-common \
        -DCMAKE_VERBOSE_MAKEFILE=ON \
        -DXTERMCMD=$xterm &&
    gmake "$jobs"
fi

if [[ -v RELCM ]]; then

    # cmake release configuration
    [[ -d build ]] && rm -rf build
    mkdir -m 0700 build &&
    cd build &&
    cmake .. \
        -DCMAKE_BUILD_TYPE=MinSizeRel \
        -DCMAKE_INSTALL_PREFIX=$prefix \
        -DCONFIG_GDK_PIXBUF_XLIB=$GDK \
        -DCONFIG_IMLIB2=$IM2 \
        -DCONFIG_LIBRSVG=ON \
        -DCONFIG_XPM=ON \
        -DCMAKE_VERBOSE_MAKEFILE=ON \
        -DCONFIG_XRANDR=ON \
        -DENABLE_LTO=ON \
        -DXTERMCMD=$xterm &&
    gmake "$jobs"
fi

# check the dependencies
if [[ -v DEPEN ]]; then
    for p in \
        x11 xext xcomposite xdamage xfixes \
        xrender xrandr xinerama xft \
        fontconfig sm ice \
        sndfile alsa ao \
        gio-2.0 gio-unix-2.0 \
        gdk-pixbuf-xlib-2.0 librsvg-2.0 \
        imlib2 xpm libpng libjpeg
    do
        printf "%-20s: " "$p"
        pkg-config --modversion --print-errors --errors-to-stdout $p
    done
fi

# test combinations of configure options
if [[ -v TESTC ]]; then
    rm -f -- rebuild.log rebuild.err
    for i in {001..050} :; do
        rm -f -- rebuild.tmp
        gmake "$jobs" clean &>>rebuild.log
        # pick five configure options randomly:
        able=$(./configure --help=short |
              sed -e 's|\[.*||' |
              awk '{print $1}' |
              grep -e --enable- -e --disable- |
              grep -v -e -FEATURE -e -checking -e -tracking -e -maintainer |
              grep -v -e -rules -e -install -e -libtool -e -static -e -shared |
              shuf -n 5)
        echo "# $i: $(date +%T): ./configure $able" | tee rebuild.tmp
        ./configure $able &>>rebuild.tmp &&
        gmake "$jobs" &>>rebuild.tmp ||
        { echo "FAILED for $able !" |
            tee -a rebuild.err;
            mv -fv rebuild.tmp rebuild-$i.err
        }
    done |& tee -a rebuild.log
fi