Migrate xmpp-caps.xml to XDG cache dir
[pidgin-git.git] / autogen.sh
blob4314f2905520c9acb6a22eb096d7d0d48460cefe
1 #! /bin/sh
2 # Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
3 # Copyright (C) 2003-2008 Gary Kramlich <grim@reaperworld.com>
5 # This program is free software; you can redistribute it and/or modify it
6 # under the terms of the GNU General Public License as published by the Free
7 # Software Foundation; either version 2 of the License, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful, but WITHOUT
11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 # more details.
15 # You should have received a copy of the GNU General Public License along with
16 # this program; if not, write to the Free Software Foundation, Inc., 51
17 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 ###############################################################################
20 # Usage
21 ###############################################################################
22 # This script uses a config file that can be used to stash common arguments
23 # passed to configure or environment variables that need to be set before
24 # configure is called. The configuration file is a simple shell script that
25 # gets sourced.
27 # By default, the config file that is used is named 'autogen.args'. This can
28 # be configured below.
30 # Available options that are handled are as follow:
31 # ACLOCAL_FLAGS - command line arguments to pass to aclocal
32 # AUTOCONF_FLAGS - command line arguments to pass to autoconf
33 # AUTOHEADER_FLAGS - command line arguments to pass to autoheader
34 # AUTOMAKE_FLAGS - command line arguments to pass to automake flags
35 # CONFIGURE_FLAGS - command line arguments to pass to configure
36 # GLIB_GETTEXTIZE_FLAGS - command line arguments to pass to glib-gettextize
37 # GTKDOCIZE_FLAGS - command line arguments to pass to gtkdocize
38 # INTLTOOLIZE_FLAGS - command line arguments to pass to intltoolize
39 # LIBTOOLIZE_FLAGS - command line arguments to pass to libtoolize
41 # Other helpful notes:
42 # If you're using a different c compiler, you can override the environment
43 # variable in 'autogen.args'. For example, say you're using distcc, just add
44 # the following to 'autogen.args':
46 # CC="distcc"
48 # This will work for any influential environment variable to configure.
49 ###############################################################################
50 PACKAGE="Pidgin"
51 ARGS_FILE="autogen.args"
52 export CFLAGS
53 export LDFLAGS
55 DEFAULT_ACLOCAL_FLAGS="-I m4macros"
57 libtoolize="libtoolize"
58 case $(uname -s) in
59 Darwin*)
60 libtoolize="glibtoolize"
62 BREW=$(which brew)
64 if [ -n ${BREW} ] ; then
65 GETTEXT_PREFIX=$(${BREW} --prefix gettext 2>/dev/null)
66 if [ -n ${GETTEXT_PREFIX} ] ; then
67 PATH=${GETTEXT_PREFIX}/bin:$PATH
68 DEFAULT_ACLOCAL_FLAGS="${DEFAULT_ACLOCAL_FLAGS} -I ${GETTEXT_PREFIX}/share/aclocal"
71 GI_PREFIX=$(${BREW} --prefix gobject-introspection)
72 if [ -n ${GI_PREFIX} ] ; then
73 PATH=${GI_PREFIX}/bin:$PATH
74 DEFAULT_ACLOCAL_FLAGS="${DEFAULT_ACLOCAL_FLAGS} -I ${GI_PREFIX}/share/aclocal"
79 esac
81 ###############################################################################
82 # Some helper functions
83 ###############################################################################
84 check () {
85 CMD=$1
87 printf "%s" "checking for ${CMD}... "
88 BIN=`which ${CMD} 2>/dev/null`
90 if [ x"${BIN}" = x"" ] ; then
91 echo "not found."
92 echo "${CMD} is required to build ${PACKAGE}!"
93 exit 1;
96 echo "${BIN}"
99 run_or_die () { # beotch
100 CMD=$1
101 shift
103 OUTPUT=`mktemp autogen-XXXXXX`
105 printf "running %s %s... " ${CMD} "$*"
106 ${CMD} ${@} >${OUTPUT} 2>&1
108 if [ $? != 0 ] ; then
109 echo "failed."
110 cat ${OUTPUT}
111 rm -f ${OUTPUT}
112 exit 1
113 else
114 echo "done."
115 cat ${OUTPUT}
117 rm -f ${OUTPUT}
121 check_gtkdoc() {
122 printf "checking for gtkdocize... "
123 GTKDOCIZE=`which gtkdocize 2>/dev/null`
125 if [ x"${GTKDOCIZE}" = x"" ] ; then
126 echo "not found."
127 echo "EXTRA_DIST =" > gtk-doc.make
128 echo "You don't have gtk-doc installed, and thus won't be able to
129 generate the documentation.
131 else
132 echo "${GTKDOCIZE}"
133 run_or_die ${GTKDOCIZE} ${GTKDOCIZE_FLAGS}
137 cleanup () {
138 rm -f autogen-??????
139 echo
140 exit 2
143 ###############################################################################
144 # We really start here, yes, very sneaky!
145 ###############################################################################
146 trap cleanup 2
148 FIGLET=`which figlet 2> /dev/null`
149 if [ x"${FIGLET}" != x"" ] ; then
150 ${FIGLET} -f small ${PACKAGE}
151 echo "build system is being generated"
152 else
153 echo "autogenerating build system for '${PACKAGE}'"
156 ###############################################################################
157 # Look for our args file
158 ###############################################################################
159 printf "%s" "checking for ${ARGS_FILE}: "
160 if [ -f ${ARGS_FILE} ] ; then
161 echo "found."
162 printf "%s" "sourcing ${ARGS_FILE}: "
163 . "`dirname "$0"`"/${ARGS_FILE}
164 echo "done."
165 else
166 echo "not found."
169 ###############################################################################
170 # Work inside the source directory
171 ##############################################################################
172 test -z "$SRCDIR" && SRCDIR=`dirname "$0"`
173 test -z "$SRCDIR" && SRCDIR=.
175 OLDDIR=`pwd`
176 cd "$SRCDIR"
178 ###############################################################################
179 # Check for our required helpers
180 ###############################################################################
181 check "$libtoolize"; LIBTOOLIZE=${BIN};
182 check "glib-gettextize"; GLIB_GETTEXTIZE=${BIN};
183 check "intltoolize"; INTLTOOLIZE=${BIN};
184 check "sed"; SED=${BIN};
185 check "aclocal"; ACLOCAL=${BIN};
186 check "autoheader"; AUTOHEADER=${BIN};
187 check "automake"; AUTOMAKE=${BIN};
188 check "autoconf"; AUTOCONF=${BIN};
190 ###############################################################################
191 # Run all of our helpers
192 ###############################################################################
193 run_or_die ${LIBTOOLIZE} ${LIBTOOLIZE_FLAGS:-"-c -f --automake"}
194 run_or_die ${GLIB_GETTEXTIZE} ${GLIB_GETTEXTIZE_FLAGS:-"--force --copy"}
195 run_or_die ${INTLTOOLIZE} ${INTLTOOLIZE_FLAGS:-"-c -f --automake"}
196 # This call to sed is needed to work around an annoying bug in intltool 0.40.6
197 # See https://developer.pidgin.im/ticket/9520 for details
198 run_or_die ${SED} -i -e "s:'\^\$\$lang\$\$':\^\$\$lang\$\$:g" po/Makefile.in.in
199 # glib-gettextize doesn't seems to use AM_V_GEN macro
200 ${SED} -i -e "s:\\tfile=\`echo:\\t@echo -e \" GEN\\\\t\$\@\"; file=\`echo:g" po/Makefile.in.in
201 run_or_die ${ACLOCAL} ${ACLOCAL_FLAGS:-"${DEFAULT_ACLOCAL_FLAGS}"}
202 run_or_die ${AUTOHEADER} ${AUTOHEADER_FLAGS}
203 check_gtkdoc
204 run_or_die ${AUTOMAKE} ${AUTOMAKE_FLAGS:-"-a -c --gnu"}
205 run_or_die ${AUTOCONF} ${AUTOCONF_FLAGS}
207 ###############################################################################
208 # Run configure
209 ###############################################################################
210 cd "$OLDDIR"
211 if test -z "$NOCONFIGURE"; then
212 echo "running $SRCDIR/configure ${CONFIGURE_FLAGS} $@"
213 "$SRCDIR/configure" ${CONFIGURE_FLAGS} $@