Debian Codegraph @

macros/mate-autogen

raw ◀ ▶
1 Debian patch touch this file
•1 #!/bin/bash
2 #
3 # mate-common - Run this to generate all the initial makefiles, etc.
4 #
5 # Copyright (C) 2011 Perberos <[email protected]>
6 #
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19
20 #name of package
21 test "PKG_NAME" || PKG_NAME=Package
22 test "$srcdir" || srcdir=.
23
24 # default version requirements ...
25 test "$REQUIRED_AUTORECONF_VERSION" || REQUIRED_AUTORECONF_VERSION=2.53
26 test "$REQUIRED_GLIB_GETTEXT_VERSION" || REQUIRED_GLIB_GETTEXT_VERSION=2.2.0
27 test "$REQUIRED_INTLTOOL_VERSION" || REQUIRED_INTLTOOL_VERSION=0.25
28 test "$REQUIRED_PKG_CONFIG_VERSION" || REQUIRED_PKG_CONFIG_VERSION=0.14.0
29 test "$REQUIRED_GTK_DOC_VERSION" || REQUIRED_GTK_DOC_VERSION=1.0
30 test "$REQUIRED_DOC_COMMON_VERSION" || REQUIRED_DOC_COMMON_VERSION=1.1.0
31
32 # a list of required m4 macros. Package can set an initial value
33 test "$REQUIRED_M4MACROS" || REQUIRED_M4MACROS=
34 test "$FORBIDDEN_M4MACROS" || FORBIDDEN_M4MACROS=
35
36 # Not all echo versions allow -n, so we check what is possible. This test is
37 # based on the one in autoconf.
38 ECHO_C=
39 ECHO_N=
40 case `echo -n x` in
41 -n*)
42 case `echo 'x\c'` in
43 *c*) ;;
44 *) ECHO_C='\c';;
45 esac;;
46 *)
47 ECHO_N='-n';;
48 esac
49
50 # some terminal codes ...
51 if tty 1>/dev/null 2>&1; then
52 boldface="`tput bold 2>/dev/null`"
53 normal="`tput sgr0 2>/dev/null`"
54 else
55 boldface=
56 normal=
57 fi
58 printbold() {
59 echo $ECHO_N "$boldface" $ECHO_C
60 echo "$@"
61 echo $ECHO_N "$normal" $ECHO_C
62 }
63 printerr() {
64 echo "$@" >&2
65 }
66
67 # Usage:
68 # compare_versions MIN_VERSION ACTUAL_VERSION
69 # returns true if ACTUAL_VERSION >= MIN_VERSION
70 compare_versions() {
71 ch_min_version=$1
72 ch_actual_version=$2
73 ch_status=0
74 IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="."
75 set $ch_actual_version
76 for ch_min in $ch_min_version; do
77 ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
78 if [ -z "$ch_min" ]; then break; fi
79 if [ -z "$ch_cur" ]; then ch_status=1; break; fi
80 if [ $ch_cur -gt $ch_min ]; then break; fi
81 if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
82 done
83 IFS="$ch_save_IFS"
84 return $ch_status
85 }
86
87 # Usage:
88 # version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
89 # checks to see if the package is available
90 version_check() {
91 vc_package=$1
92 vc_variable=$2
93 vc_checkprogs=$3
94 vc_min_version=$4
95 vc_source=$5
96 vc_status=1
97 local ${vc_variable}_VERSION
98
99 vc_checkprog=`eval echo "\\$$vc_variable"`
100 if [ -n "$vc_checkprog" ]; then
101 printbold "using $vc_checkprog for $vc_package"
102 return 0
103 fi
104
105 printbold "checking for $vc_package >= $vc_min_version..."
106 for vc_checkprog in $vc_checkprogs; do
107 echo $ECHO_N " testing $vc_checkprog... " $ECHO_C
108 if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
109 vc_actual_version=`$vc_checkprog --version | head -n 1 | \
110 sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
111 if compare_versions $vc_min_version $vc_actual_version; then
112 echo "found $vc_actual_version"
113 # set variables
114 eval "$vc_variable=$vc_checkprog; \
115 ${vc_variable}_VERSION=$vc_actual_version"
116 vc_status=0
117 break
118 else
119 echo "too old (found version $vc_actual_version)"
120 fi
121 else
122 echo "not found."
123 fi
124 done
125 if [ "$vc_status" != 0 ]; then
126 printerr "***Error***: You must have $vc_package >= $vc_min_version installed"
127 printerr " to build $PKG_NAME. Download the appropriate package for"
128 printerr " from your distribution or get the source tarball at"
129 printerr " $vc_source"
130 printerr
131 exit $vc_status
132 fi
133 return $vc_status
134 }
135
136 # Usage:
137 # require_m4macro filename.m4
138 # adds filename.m4 to the list of required macros
139 require_m4macro() {
140 case "$REQUIRED_M4MACROS" in
141 $1\ * | *\ $1\ * | *\ $1) ;;
142 *) REQUIRED_M4MACROS="$REQUIRED_M4MACROS $1" ;;
143 esac
144 }
145
146 forbid_m4macro() {
147 case "$FORBIDDEN_M4MACROS" in
148 $1\ * | *\ $1\ * | *\ $1) ;;
149 *) FORBIDDEN_M4MACROS="$FORBIDDEN_M4MACROS $1" ;;
150 esac
151 }
152
153 # Usage:
154 # add_to_cm_macrodirs dirname
155 # Adds the dir to $cm_macrodirs, if it's not there yet.
156 add_to_cm_macrodirs() {
157 case $cm_macrodirs in
158 "$1 "* | *" $1 "* | *" $1") ;;
159 *) cm_macrodirs="$cm_macrodirs $1";;
160 esac
161 }
162
163 # Usage:
164 # print_m4macros_error
165 # Prints an error message saying that autoconf macros were misused
166 print_m4macros_error() {
167 printerr "***Error***: some autoconf macros required to build $PKG_NAME"
168 printerr " were not found in your aclocal path, or some forbidden"
169 printerr " macros were found. Perhaps you need to adjust your"
170 printerr " ACLOCAL_FLAGS?"
171 printerr
172 }
173
174 # Usage:
175 # check_m4macros
176 # Checks that all the requested macro files are in the aclocal macro path
177 # Uses REQUIRED_M4MACROS and ACLOCAL variables.
178 check_m4macros() {
179 # construct list of macro directories
180 cm_macrodirs=`aclocal --print-ac-dir`
181 # aclocal also searches a version specific dir, eg. /usr/share/aclocal-1.9
182 # but it contains only Automake's own macros, so we can ignore it.
183
184 # Read the dirlist file
185 if [ -s $cm_macrodirs/dirlist ]; then
186 cm_dirlist=`sed 's/[ ]*#.*//;/^$/d' $cm_macrodirs/dirlist`
187 if [ -n "$cm_dirlist" ] ; then
188 for cm_dir in $cm_dirlist; do
189 if [ -d $cm_dir ]; then
190 add_to_cm_macrodirs $cm_dir
191 fi
192 done
193 fi
194 fi
195
196 # Parse $ACLOCAL_FLAGS
197 set - $ACLOCAL_FLAGS
198 while [ $# -gt 0 ]; do
199 if [ "$1" = "-I" ]; then
200 add_to_cm_macrodirs "$2"
201 shift
202 fi
203 shift
204 done
205
206 cm_status=0
207 if [ -n "$REQUIRED_M4MACROS" ]; then
208 printbold "Checking for required M4 macros..."
209 # check that each macro file is in one of the macro dirs
210 for cm_macro in $REQUIRED_M4MACROS; do
211 cm_macrofound=false
212 for cm_dir in $cm_macrodirs; do
213 if [ -f "$cm_dir/$cm_macro" ]; then
214 cm_macrofound=true
215 break
216 fi
217 # The macro dir in Cygwin environments may contain a file
218 # called dirlist containing other directories to look in.
219 if [ -f "$cm_dir/dirlist" ]; then
220 for cm_otherdir in `cat $cm_dir/dirlist`; do
221 if [ -f "$cm_otherdir/$cm_macro" ]; then
222 cm_macrofound=true
223 break
224 fi
225 done
226 fi
227 done
228 if $cm_macrofound; then
229 :
230 else
231 printerr " $cm_macro not found"
232 cm_status=1
233 fi
234 done
235 fi
236 if [ "$cm_status" != 0 ]; then
237 print_m4macros_error
238 exit $cm_status
239 fi
240 if [ -n "$FORBIDDEN_M4MACROS" ]; then
241 printbold "Checking for forbidden M4 macros..."
242 # check that each macro file is in one of the macro dirs
243 for cm_macro in $FORBIDDEN_M4MACROS; do
244 cm_macrofound=false
245 for cm_dir in $cm_macrodirs; do
246 if [ -f "$cm_dir/$cm_macro" ]; then
247 cm_macrofound=true
248 break
249 fi
250 done
251 if $cm_macrofound; then
252 printerr " $cm_macro found (should be cleared from macros dir)"
253 cm_status=1
254 fi
255 done
256 fi
257 if [ "$cm_status" != 0 ]; then
258 print_m4macros_error
259 exit $cm_status
260 fi
261 }
262
263 # try to catch the case where the macros/ directory hasn't been cleared out.
264 forbid_m4macro mate-cxx-check.m4
265
266 want_glib_gettext=false
267 want_intltool=false
268 want_pkg_config=false
269 want_gtk_doc=false
270 want_yelp_tools=false
271 want_maintainer_mode=false
272
273 version_check autoreconf AUTORECONF 'autoreconf' $REQUIRED_AUTORECONF_VERSION \
274 "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTORECONF_VERSION.tar.gz"
275
276 find_configure_files() {
277 configure_ac=
278 if test -f "$1/configure.ac"; then
279 configure_ac="$1/configure.ac"
280 elif test -f "$1/configure.in"; then
281 configure_ac="$1/configure.in"
282 fi
283 if test "x$configure_ac" != x; then
284 echo "$configure_ac"
285 autoconf -t 'AC_CONFIG_SUBDIRS:$1' "$configure_ac" | while read dir; do
286 find_configure_files "$1/$dir"
287 done
288 fi
289 }
290
291 configure_files="`find_configure_files .`"
292
293 for configure_ac in $configure_files; do
294 dirname=`dirname $configure_ac`
295 if [ -f $dirname/NO-AUTO-GEN ]; then
296 echo skipping $dirname -- flagged as no auto-gen
297 continue
298 fi
299 if grep "^AM_GLIB_GNU_GETTEXT" $configure_ac >/dev/null; then
300 want_glib_gettext=true
301 fi
302 if grep "^AC_PROG_INTLTOOL" $configure_ac >/dev/null ||
303 grep "^IT_PROG_INTLTOOL" $configure_ac >/dev/null; then
304 want_intltool=true
305 fi
306 if grep "^PKG_CHECK_MODULES" $configure_ac >/dev/null; then
307 want_pkg_config=true
308 fi
309 if grep "^GTK_DOC_CHECK" $configure_ac >/dev/null; then
310 want_gtk_doc=true
311 fi
312 if grep "^YELP_HELP_INIT" $configure_ac >/dev/null; then
313 want_yelp_tools=true
314 fi
315
316 # check that AM_MAINTAINER_MODE is used
317 if grep "^AM_MAINTAINER_MODE" $configure_ac >/dev/null; then
318 want_maintainer_mode=true
319 fi
320
321 if grep "^APPDATA_XML" $configure_ac >/dev/null; then
322 require_m4macro appdata-xml.m4
323 fi
324
325 # check to make sure mate-common macros can be found ...
326 if grep "^MATE_COMMON_INIT" $configure_ac >/dev/null ||
327 grep "^MATE_DEBUG_CHECK" $configure_ac >/dev/null ||
328 grep "^MATE_MAINTAINER_MODE_DEFINES" $configure_ac >/dev/null; then
329 require_m4macro mate-common.m4
330 fi
331 if grep "^MATE_COMPILE_WARNINGS" $configure_ac >/dev/null ||
332 grep "^MATE_CXX_WARNINGS" $configure_ac >/dev/null; then
333 require_m4macro mate-compiler-flags.m4
334 fi
335 if grep "^MATE_CODE_COVERAGE" $configure_ac >/dev/null; then
336 require_m4macro mate-code-coverage.m4
337 fi
338 done
339
340 if $want_glib_gettext; then
341 version_check glib-gettext GLIB_GETTEXTIZE glib-gettextize $REQUIRED_GLIB_GETTEXT_VERSION \
342 "ftp://ftp.gtk.org/pub/gtk/v2.2/glib-$REQUIRED_GLIB_GETTEXT_VERSION.tar.gz"
343 require_m4macro glib-gettext.m4
344 fi
345
346 if $want_intltool; then
347 version_check intltool INTLTOOLIZE intltoolize $REQUIRED_INTLTOOL_VERSION \
348 "https://launchpad.net/intltool/+download"
349 require_m4macro intltool.m4
350 fi
351
352 if $want_pkg_config; then
353 version_check pkg-config PKG_CONFIG pkg-config $REQUIRED_PKG_CONFIG_VERSION \
354 "'http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-$REQUIRED_PKG_CONFIG_VERSION.tar.gz"
355 require_m4macro pkg.m4
356 fi
357
358 if $want_gtk_doc; then
359 version_check gtk-doc GTKDOCIZE gtkdocize $REQUIRED_GTK_DOC_VERSION \
360 "http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/"
361 require_m4macro gtk-doc.m4
362 fi
363
364 if $want_yelp_tools; then
365 require_m4macro yelp.m4
366 fi
367
368 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
369 version_check mate-common DOC_COMMON mate-doc-common \
370 $REQUIRED_DOC_COMMON_VERSION " "
371 fi
372
373 check_m4macros
374
375 if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then
376 printerr "**Warning**: I am going to run \`configure' with no arguments."
377 printerr "If you wish to pass any to it, please specify them on the"
378 printerr \`$0\'" command line."
379 printerr
380 fi
381
382 topdir=`pwd`
383 for configure_ac in $configure_files; do
384 dirname=`dirname $configure_ac`
385 basename=`basename $configure_ac`
386 if [ -f $dirname/NO-AUTO-GEN ]; then
387 echo skipping $dirname -- flagged as no auto-gen
388 elif [ ! -w $dirname ]; then
389 echo skipping $dirname -- directory is read only
390 else
391 printbold "Processing $configure_ac"
392 cd $dirname
393
394 # if the AC_CONFIG_MACRO_DIR() macro is used, create that directory
395 # This is a automake bug fixed in automake 1.13.2
396 # See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13514
397 m4dir=`autoconf --trace 'AC_CONFIG_MACRO_DIR:$1'`
398 if [ -n "$m4dir" ]; then
399 mkdir -p $m4dir
400 fi
401
402 if grep "^AM_GLIB_GNU_GETTEXT" $basename >/dev/null; then
403 printbold "Running $GLIB_GETTEXTIZE... Ignore non-fatal messages."
404 echo "no" | $GLIB_GETTEXTIZE --force --copy || exit 1
405 fi
406
407 if grep "^GTK_DOC_CHECK" $basename >/dev/null; then
408 printbold "Running $GTKDOCIZE..."
409 $GTKDOCIZE --copy || exit 1
410 fi
411
412 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
413 printbold "Running mate-doc-common..."
414 mate-doc-common --copy || exit 1
415 fi
416
417 if grep "^AC_PROG_INTLTOOL" $basename >/dev/null ||
418 grep "^IT_PROG_INTLTOOL" $basename >/dev/null; then
419 printbold "Running $INTLTOOLIZE..."
420 $INTLTOOLIZE --force --copy --automake || exit 1
421 fi
422 # Now that all the macros are sorted, run autoreconf ...
423 printbold "Running autoreconf..."
424 autoreconf --verbose --force --install -Wno-portability || exit 1
425
426 cd "$topdir"
427 fi
428 done
429
430 conf_flags=""
431
432 if $want_maintainer_mode; then
433 conf_flags="--enable-maintainer-mode"
434 fi
435
436 if test x$NOCONFIGURE = x; then
437 printbold Running $srcdir/configure $conf_flags "$@" ...
438 $srcdir/configure $conf_flags "$@" \
439 && echo Now type \`make\' to compile $PKG_NAME || exit 1
440 else
441 echo Skipping configure process.
442 fi