1#!/bin/sh
2# Run this to generate all the initial makefiles, etc.
3
4srcdir=`dirname $0`
5test -z "$srcdir" && srcdir=.
6
7ORIGDIR=`pwd`
8cd $srcdir
9PROJECT=chafa
10TEST_TYPE=-f
11FILE=chafa/Makefile.am
12DIE=0
13
14MISSING_TOOLS=
15
16MY_ECHO=$(which echo)
17[ x$MY_ECHO = x ] && MY_ECHO=echo
18
19(autoconf --version) < /dev/null > /dev/null 2>&1 || {
20        MISSING_TOOLS="${MISSING_TOOLS}autoconf "
21        DIE=1
22}
23
24(automake --version) < /dev/null > /dev/null 2>&1 || {
25        MISSING_TOOLS="${MISSING_TOOLS}automake "
26        DIE=1
27}
28
29(libtoolize --version) < /dev/null > /dev/null 2>&1 || {
30        MISSING_TOOLS="${MISSING_TOOLS}libtool "
31        DIE=1
32}
33
34(pkg-config --version) < /dev/null > /dev/null 2>&1 || {
35        MISSING_TOOLS="${MISSING_TOOLS}pkg-config "
36        DIE=1
37}
38
39if test "$DIE" -eq 1; then
40        ${MY_ECHO}
41        ${MY_ECHO} -e "Missing mandatory tools:\e[1;31m $MISSING_TOOLS"
42        ${MY_ECHO} -e "\e[0m"
43        ${MY_ECHO} "These are required for building Chafa from its git repository."
44        ${MY_ECHO} "You should be able to install them using your operating system's"
45        ${MY_ECHO} "package manager (apt-get, yum, zypper or similar). Alternately"
46        ${MY_ECHO} "they can be obtained directly from GNU: https://ftp.gnu.org/gnu/"
47        ${MY_ECHO}
48        ${MY_ECHO} "If you can't provide these tools, you may still be able to"
49        ${MY_ECHO} "build Chafa from a tarball release: https://hpjansson.org/chafa/releases/"
50        ${MY_ECHO}
51fi
52
53GTKDOCIZE=$(which gtkdocize 2>/dev/null)
54
55if test -z $GTKDOCIZE; then
56        ${MY_ECHO} -e "Missing optional tool:\e[1;33m gtk-doc"
57        ${MY_ECHO} -e "\e[0m"
58        ${MY_ECHO} "Without this, no developer documentation will be generated."
59        ${MY_ECHO}
60        rm -f gtk-doc.make
61        cat > gtk-doc.make <<EOF
62EXTRA_DIST =
63CLEANFILES =
64EOF
65else
66        gtkdocize || exit $?
67fi
68
69if test "$DIE" -eq 1; then
70        exit 1
71fi
72
73test $TEST_TYPE $FILE || {
74        ${MY_ECHO}
75        ${MY_ECHO} "You must run this script in the top-level $PROJECT directory."
76        ${MY_ECHO}
77        exit 1
78}
79
80if test x$NOCONFIGURE = x && test -z "$*"; then
81        ${MY_ECHO}
82        ${MY_ECHO} "I am going to run ./configure with no arguments - if you wish "
83        ${MY_ECHO} "to pass any to it, please specify them on the $0 command line."
84        ${MY_ECHO}
85fi
86
87am_opt="--include-deps --add-missing"
88
89${MY_ECHO} "Running libtoolize..."
90libtoolize --force --copy
91
92${MY_ECHO} "Running aclocal..."
93aclocal $ACLOCAL_FLAGS
94
95# optionally feature autoheader
96(autoheader --version)  < /dev/null > /dev/null 2>&1 && autoheader
97
98${MY_ECHO} "Running automake..."
99automake -a $am_opt
100
101${MY_ECHO} "Running autoconf..."
102autoconf
103
104cd $ORIGDIR
105
106conf_flags="--enable-maintainer-mode"
107
108if test x$NOCONFIGURE = x; then
109  ${MY_ECHO} Running $srcdir/configure $conf_flags "$@" ...
110  $srcdir/configure $conf_flags "$@" || exit 1
111else
112  ${MY_ECHO} Skipping configure process.
113fi
114