summaryrefslogtreecommitdiff
path: root/autogen.sh
blob: 4ea8d757f99e30361409a3449906572f5c9a79d2 (plain)
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
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

: ${srcdir=$(dirname $0)}
: ${srcdir:=.}
: ${SAVE_DIST_FILES:=0}
: ${MAKE:=make}

olddir=$(pwd)
# shellcheck disable=SC2016
PKG_NAME=$(autoconf --trace 'AC_INIT:$1' configure.ac)
WANT_GTK_DOC=0
GCC_VERSION=$(gcc --version | head -1 | awk '{print $3}')
GCC_MAJOR_VERSION=$(echo "$GCC_VERSION" | awk -F. '{print $1}')
FEDORA_PKG1='autoconf automake libtool gettext-devel'
FEDORA_PKG2='glib2-devel gtk2-devel gtk3-devel
 wayland-devel'
FEDORA_PKG3='cldr-emoji-annotation iso-codes-devel unicode-emoji unicode-ucd
 xkeyboard-config-devel'

CFLAGS=${CFLAGS-"-Wall -Wformat -Werror=format-security"}
(test $GCC_MAJOR_VERSION -ge 10) && {
    CFLAGS="$CFLAGS -fanalyzer -fsanitize=address -fsanitize=leak"
    FEDORA_PKG1="$FEDORA_PKG1 libasan"
}

cd "$srcdir"

(test -f configure.ac \
  && test -f README ) || {
    echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
    echo " top-level $PKG_NAME directory"
    exit 1
}

(test $(grep -q "^GTK_DOC_CHECK" configure.ac)) || {
    WANT_GTK_DOC=1
    FEDORA_PKG2="$FEDORA_PKG2 gtk-doc"
}

(test -f ChangeLog) || {
    touch ChangeLog
}

(test "x$DISABLE_INSTALL_PKGS" = "x") && {
    (test -f /etc/fedora-release ) && {
        rpm -q $FEDORA_PKG1 || exit 1
        rpm -q $FEDORA_PKG2 || exit 1
        rpm -q $FEDORA_PKG3 || exit 1
        dnf update --assumeno $FEDORA_PKG1 || exit 1
        dnf update --assumeno $FEDORA_PKG2 || exit 1
        dnf update --assumeno $FEDORA_PKG3 || exit 1
    }
}

CONFIGFLAGS="$@"
(test "$#" = 0 -a "x$NOCONFIGURE" = "x" ) && {
    echo "*** WARNING: I am going to run 'configure' with no arguments." >&2
    echo "*** If you wish to pass any to it, please specify them on the" >&2
    echo "*** '$0' command line." >&2
    echo "" >&2
    (test $WANT_GTK_DOC -eq 1) && CONFIGFLAGS="--enable-gtk-doc $@"
}

(test $WANT_GTK_DOC -eq 1) && gtkdocize --copy

ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I m4" REQUIRED_AUTOMAKE_VERSION=1.11 \
autoreconf --verbose --force --install || exit 1

cd "$olddir"
(test "x$NOCONFIGURE" = "x" ) && {
    echo "$srcdir/configure $CONFIGFLAGS"
    $srcdir/configure $CONFIGFLAGS || exit 1
    (test "$1" = "--help" ) && {
        exit 0
    } || {
        echo "Now type '$MAKE' to compile $PKG_NAME" || exit 1
    }
} || {
    echo "Skipping configure process."
}

cd "$srcdir"
(test "x$SAVE_DIST_FILES" = "x0" ) && {
    # rm engine/simple.xml.in src/ibusemojigen.h src/ibusunicodegen.h
    for d in engine src src/compose; do
        echo "$MAKE -C $d maintainer-clean-generic"
        $MAKE -C $d maintainer-clean-generic
   done
} || :
cd "$olddir"