]> git.donarmstrong.com Git - lilypond.git/blob - stepmake/aclocal.m4
* config.make.in (datadir): Add datarootdir to silence autoconf.
[lilypond.git] / stepmake / aclocal.m4
1 dnl aclocal.m4   -*-shell-script-*-
2 dnl StepMake subroutines for configure.in
3
4
5 ### mostly interal macros
6
7 # Get full path of executable ($1)
8 AC_DEFUN(STEPMAKE_GET_EXECUTABLE, [
9     ## which doesn't work in ash, if /usr/bin/which isn't installed
10     ## type -p doesn't work in ash
11     ## command -v doesn't work in zsh
12     ## command -v "$1" 2>&1
13     ## this test should work in ash, bash, pdksh (ksh), zsh
14     type -p $1 2>/dev/null | tail -n 1 | awk '{print $NF}'
15 ])
16
17
18 # Get version string from executable ($1)
19 AC_DEFUN(STEPMAKE_GET_VERSION, [
20     ## "$1" --version 2>&1 | grep -v '^$' | head -n 1 | awk '{print $NF}'
21     ##
22     ## ARG.
23     ## Workaround for broken Debian gcc version string:
24     ##     gcc (GCC) 3.1.1 20020606 (Debian prerelease)
25     ##
26     ## -V: Workaround for python
27
28     changequote(<<, >>)#dnl
29     ## Assume and hunt for dotted version multiplet.
30     ## use eval trickery, because we cannot use multi-level $() instead of ``
31     ## for compatibility reasons.
32     ## FIXME: what systems still do not have $() in /bin/sh?
33     eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 | grep '[0-9]\.[0-9]' \
34         | head -n 1 \
35         | sed -e 's/.*[^-.0-9]\([0-9][0-9]*\.[0-9][.0-9]*\).*/\1/' \
36             -e 's/^[^.0-9]*//' -e 's/[^.0-9]*$//'\`\"
37     if test -z "$_ver"; then
38         ## If empty, try date [fontforge]
39         eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 | grep '[0-9]\{6,8\}' \
40             | head -n 1 \
41             | sed -e 's/^[^.0-9]*//' -e 's/[^.0-9]*$//'\`\"
42     fi
43     echo "$_ver"
44     changequote([, ])#dnl
45 ])
46
47 # Calculate simplistic numeric version from version string ($1)
48 # As yet, we have no need for something more elaborate.
49 AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [
50     echo "$1" | awk -F. '
51     {
52       if ([$]3) {three = [$]3}
53       else {three = 0}
54     }
55     {printf "%.0f\n", [$]1*1000000 + [$]2*1000 + three}'
56 ])
57
58
59 # Add item ($2) to list ($1, one of 'OPTIONAL', 'REQUIRED')
60 AC_DEFUN(STEPMAKE_ADD_ENTRY, [
61     eval "$1"=\"`eval echo \"'$'$1\" \"$2\"`\"
62 ])
63
64 # Check if tested program ($2) was found ($1).
65 # If not, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED').
66 # We could abort here if a 'REQUIRED' program is not found
67 AC_DEFUN(STEPMAKE_OPTIONAL_REQUIRED, [
68     STEPMAKE_CHECK_SEARCH_RESULT($1)
69     if test $? -ne 0; then
70         STEPMAKE_ADD_ENTRY($3, $2)
71         if test "$3" = "REQUIRED"; then
72             command="echo ERROR: $2 not found"
73             # abort configure process here?
74         else
75             command="- echo $2 not found"
76         fi
77         eval "$1"='$command'
78         false
79     else
80         true
81     fi
82 ])
83
84
85 # Return if tested proram ($1) was found (true) or not (false).
86 AC_DEFUN(STEPMAKE_CHECK_SEARCH_RESULT, [
87     r="`eval echo '$'"$1"`"
88     if test -n "$r" -a "$r" != "error" -a "$r" != "no" && expr '`eval echo '$'"$1"`' : '.*\(echo\)' > /dev/null; then
89         true
90     else
91         ##STEPMAKE_WARN(cannot find $2. $3)
92         false
93     fi
94 ])
95
96
97 # Check version of program ($1)
98 # If version ($4: optional argument, supply if version cannot be
99 # parsed using --version or -V ) is smaller than requested ($3), add
100 # entry to missing-list ($2, one of 'OPTIONAL', 'REQUIRED').
101 AC_DEFUN(STEPMAKE_CHECK_VERSION, [
102     r="`eval echo '$'"$1"`"
103     AC_MSG_CHECKING([$r version])
104     exe=`STEPMAKE_GET_EXECUTABLE($r)`
105     if test -n "$4"; then
106         ver="$4"
107     else
108         ver=`STEPMAKE_GET_VERSION($exe)`
109     fi
110     num=`STEPMAKE_NUMERIC_VERSION($ver)`
111     req=`STEPMAKE_NUMERIC_VERSION($3)`
112     AC_MSG_RESULT([$ver])
113     if test "$num" -lt "$req"; then
114         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
115     fi
116     vervar="`echo $1 | tr '[a-z]' '[A-Z]'`_VERSION"
117     eval `echo $vervar=$num`
118 ##    AC_SUBST(`eval echo $vervar`)
119 ])
120
121 # Check version of program ($1)
122 # If version is greater than or equals unsupported ($3),
123 # add entry to unsupported list ($2, 'UNSUPPORTED')
124 AC_DEFUN(STEPMAKE_CHECK_VERSION_UNSUPPORTED, [
125     r="`eval echo '$'"$1"`"
126     AC_MSG_CHECKING([$r version])
127     exe=`STEPMAKE_GET_EXECUTABLE($r)`
128     ver=`STEPMAKE_GET_VERSION($exe)`
129     num=`STEPMAKE_NUMERIC_VERSION($ver)`
130     sup=`STEPMAKE_NUMERIC_VERSION($3)`
131     AC_MSG_RESULT([$ver])
132     if test "$num" -ge "$sup"; then
133         STEPMAKE_ADD_ENTRY($2, ["$r < $3 (installed: $ver)"])
134     fi
135 ])
136
137 ### Macros to build configure.in
138
139
140 AC_DEFUN(STEPMAKE_BIBTEX2HTML, [
141     STEPMAKE_PROGS(BIBTEX2HTML, bibtex2html bib2html, $1)
142     if test "$BIBTEX2HTML" = "bib2html"; then
143         BIBTEX2HTML_FLAGS='$< $(@)'
144     else
145         BIBTEX2HTML_FLAGS='-o $(@D)/$(*F) $<'
146     fi
147     AC_SUBST(BIBTEX2HTML)
148     AC_SUBST(BIBTEX2HTML_FLAGS)
149 ])
150
151
152 AC_DEFUN(STEPMAKE_BISON, [
153     # ugh, automake: we want (and check for) bison
154     AC_PROG_YACC
155     
156     STEPMAKE_PROGS(BISON, bison, $1)
157     
158     # urg.  should test functionality rather than version.
159     if test "$BISON" = "bison" -a -n "$2"; then
160         STEPMAKE_CHECK_VERSION(BISON, $1, $2)
161     fi
162 ])
163
164
165 AC_DEFUN(STEPMAKE_COMPILE, [
166     # -O is necessary to get inlining
167     CFLAGS=${CFLAGS-""}
168     CXXFLAGS=${CXXFLAGS-$CFLAGS}
169     LDFLAGS=${LDFLAGS-""}
170     optimise_b=yes
171     profile_b=no
172     debug_b=yes
173     pipe_b=yes
174
175     AC_ARG_ENABLE(debugging,
176     [  --enable-debugging      compile with debugging info.  Default: on],
177     [debug_b=$enableval])
178
179     AC_ARG_ENABLE(optimising,
180     [  --enable-optimising     compile with optimising.  Default: on],
181     [optimise_b=$enableval])
182
183     AC_ARG_ENABLE(profiling, 
184     [  --enable-profiling      compile with gprof support.  Default: off],
185     [profile_b=$enableval])
186     
187     AC_ARG_ENABLE(pipe, 
188     [  --enable-pipe           compile with -pipe.  Default: on],
189     [pipe_b=$enableval])
190
191     if test "$optimise_b" = yes; then
192         AC_DEFINE(NDEBUG)
193         DEFINES="$DEFINES -DNDEBUG"
194         OPTIMIZE=" -O2 -finline-functions"
195     fi
196
197     if test $profile_b = yes; then
198         EXTRA_LIBS="-pg"
199         OPTIMIZE="$OPTIMIZE -pg"
200     fi
201
202     if test $debug_b = yes; then
203         OPTIMIZE="$OPTIMIZE -g"
204     fi
205  
206     AC_PROG_CC
207     STEPMAKE_OPTIONAL_REQUIRED(CC, cc, $1)
208     LD='$(CC)'
209     AC_SUBST(LD)
210
211     # If -pipe requested, test if it works and add to CFLAGS.
212     if test "$pipe_b" = yes; then
213         save_cflags="$CFLAGS"
214         CFLAGS=" -pipe $CFLAGS";
215         AC_CACHE_CHECK([whether compiler understands -pipe],
216             [stepmake_cflags_pipe],
217             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[/* -pipe test */]])],
218                 [stepmake_cflags_pipe=yes],
219                 [stepmake_cflags_pipe=no]))
220         CFLAGS=$save_cflags
221         if test $stepmake_cflags_pipe = yes; then
222             OPTIMIZE="$OPTIMIZE -pipe"
223         fi
224     fi
225
226     CFLAGS="$CFLAGS $OPTIMIZE"
227     CPPFLAGS=${CPPFLAGS-""}
228
229     AC_MSG_CHECKING([for IEEE-conformance compiler flags])
230     save_cflags="$CFLAGS"
231     case "$host" in
232         alpha*-*-*)
233             dnl should do compile test?
234             AC_MSG_RESULT(-mieee)
235             CFLAGS=" -mieee $CFLAGS"
236             ;;
237         *)
238             AC_MSG_RESULT([none])
239             ;;
240     esac
241
242     AC_SUBST(cross_compiling)
243     AC_SUBST(CFLAGS)
244     AC_SUBST(CPPFLAGS)
245     AC_SUBST(LDFLAGS)
246     AC_SUBST(DEFINES)
247     AC_SUBST(EXTRA_LIBS)
248 ])
249
250 AC_DEFUN(STEPMAKE_CXX, [
251     AC_LANG([C++])
252     AC_PROG_CXX
253     STEPMAKE_OPTIONAL_REQUIRED(CXX, c++, $1)
254
255     CXXFLAGS="$CXXFLAGS $OPTIMIZE"
256     LD='$(CXX)'
257
258     AC_SUBST(CXX)
259     AC_SUBST(CXXFLAGS)
260     AC_SUBST(LD)
261 ])
262
263
264 AC_DEFUN(STEPMAKE_CXXTEMPLATE, [
265     AC_CACHE_CHECK([whether explicit instantiation is needed],
266         lily_cv_need_explicit_instantiation,
267         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
268     template <class T> struct foo { static int baz; };
269     template <class T> int foo<T>::baz = 1;
270     ]], [[ return foo<int>::baz; ]])],[lily_cv_need_explicit_instantiation=no],[lily_cv_need_explicit_instantiation=yes]))
271     if test x"$lily_cv_need_explicit_instantiation"x = x"yes"x; then
272         AC_DEFINE(NEED_EXPLICIT_INSTANTIATION)
273     fi
274 ])
275
276
277 AC_DEFUN(STEPMAKE_DATADIR, [
278     if test "$datadir" = "\${prefix}/share"; then
279             datadir='${prefix}/share'
280     fi
281     presome=${prefix}
282     if test "$prefix" = "NONE"; then
283         presome=${ac_default_prefix}
284     fi
285     
286     build_package_datadir=$ugh_ugh_autoconf250_builddir/out$CONFIGSUFFIX/share/$package
287     
288     DATADIR=`echo ${datadir} | sed "s!\\\${datarootdir}!${prefix}/share!"`
289     DATADIR=`echo ${datadir} | sed "s!\\\${prefix}!$presome!"`
290     BUILD_PACKAGE_DATADIR=`echo ${build_package_datadir} | sed "s!\\\${prefix}!$presome!"`
291     
292     AC_SUBST(datadir)
293     AC_SUBST(datarootdir)
294     AC_SUBST(build_package_datadir)
295     AC_DEFINE_UNQUOTED(DATADIR, ["${DATADIR}"])
296     AC_DEFINE_UNQUOTED(BUILD_PACKAGE_DATADIR, ["${BUILD_PACKAGE_DATADIR}"])
297 ])
298
299 ## ugh: cut & paste programming from datadir. 
300 AC_DEFUN(STEPMAKE_LIBDIR, [
301
302     if test "$libdir" = "\${exec_prefix}/lib"; then
303         libdir='${exec_prefix}/lib'
304     fi
305     presome=$exec_prefix
306     build_package_libdir=$ugh_ugh_autoconf250_builddir/out$CONFIGSUFFIX/lib/$package
307     
308     LIBDIR=`echo ${libdir} | sed "s!\\\${exec_prefix}!$presome!"`
309     BUILD_PACKAGE_LIBDIR=`echo ${build_package_libdir} | sed "s!\\\${exec_prefix}!$presome!"`
310     
311     AC_SUBST(libdir)
312     AC_SUBST(build_package_libdir)
313     AC_DEFINE_UNQUOTED(LIBDIR, ["${LIBDIR}"])
314     AC_DEFINE_UNQUOTED(BUILD_PACKAGE_LIBDIR, ["${BUILD_PACKAGE_LIBDIR}"])
315 ])
316
317
318 AC_DEFUN(STEPMAKE_END, [
319     AC_SUBST(OPTIONAL)
320     AC_SUBST(REQUIRED)
321     
322     AC_CONFIG_FILES([$CONFIGFILE.make:config.make.in])
323     AC_OUTPUT
324     
325     if test -n "$OPTIONAL"; then
326         echo
327         echo "WARNING: Please consider installing optional programs: $OPTIONAL"
328     fi
329
330     if test -n "$REQUIRED"; then
331         echo
332         echo "ERROR: Please install required programs: $REQUIRED"
333     fi
334     
335     if test -n "$UNSUPPORTED"; then
336         echo
337         echo "ERROR: Please use older version of programs: $UNSUPPORTED"
338     fi
339     
340     if test -n "$OPTIONAL$REQUIRED$UNSUPPORTED"; then
341         echo
342         echo "See INSTALL.txt for more information on how to build $PACKAGE_NAME"
343         if test -f config.cache ; then
344             echo "Remove config.cache before rerunning ./configure"
345         fi 
346     fi
347     
348     if test -n "$REQUIRED$UNSUPPORTED"; then
349         rm -f $srcdir/GNUmakefile
350         exit 1
351     fi
352
353     # regular in-place build
354     # test for srcdir_build = yes ?
355     if test "$srcdir_build" = "yes"; then
356         rm -f $srcdir/GNUmakefile
357         cp $srcdir/GNUmakefile.in $srcdir/GNUmakefile
358         chmod 444 $srcdir/GNUmakefile
359     else
360         if test -f $srcdir/GNUmakefile; then
361             cat <<EOF
362 Source directory already configured.  Please clean the source directory
363
364      make -C $srcdir distclean
365
366 and rerun configure.
367 EOF
368             exit 2
369         fi
370
371         for d in 2 3 4 ; do
372             for mf in `cd $srcdir ; find -maxdepth $d -mindepth $d -name GNUmakefile`; do
373                 mkdir -p $(dirname $mf)
374                 cat <<EOF | $PYTHON -  > $mf
375 print 'depth=' + ('../' * ( $d-1 ) )
376 print 'include \$(depth)/config\$(if \$(conf),-\$(conf),).make'
377 print 'include \$(configure-srcdir)/$mf'
378 EOF
379             done
380             for mf in `cd $srcdir ; find -maxdepth $d -mindepth $d -name '*.make' | grep -v config.make `; do
381                 mkdir -p $(dirname $mf)
382                 cat <<EOF | $PYTHON -  > $mf
383 print 'include \$(depth)/config\$(if \$(conf),-\$(conf),).make'
384 print 'include \$(configure-srcdir)/$mf'
385 EOF
386             done
387         done
388
389         
390         cat <<EOF > GNUmakefile
391 depth = ./
392 include config\$(if \$(conf),-\$(conf),).make
393 include \$(configure-srcdir)/GNUmakefile.in
394 EOF
395         AC_SUBST(VPATH)
396     fi
397 ])
398
399
400 AC_DEFUN(STEPMAKE_FLEX, [
401     # ugh, automake: we want (and check for) flex
402     # AC_PROG_LEX
403     # urg: automake 1.3: hope this doesn't break 1.2 ac_cv_pro_lex_root hack...
404
405     # AC_PROG_LEX()
406     # ugh, ugh
407     ac_cv_prog_lex_root=lex.yy
408     STEPMAKE_PROGS(FLEX, flex, $1)
409 ])
410
411
412 AC_DEFUN(STEPMAKE_FLEXLEXER, [
413     AC_CHECK_HEADERS([FlexLexer.h],[true],[false])
414     if test $? -ne 0; then
415         warn='FlexLexer.h (flex package)'
416         STEPMAKE_ADD_ENTRY($1, $warn)
417     fi
418     # check for yyFlexLexer.yy_current_buffer,
419     # in 2.5.4 <= flex < 2.5.29
420     AC_LANG_PUSH(C++)
421     AC_CACHE_CHECK([for yyFlexLexer.yy_current_buffer],
422         [stepmake_flexlexer_yy_current_buffer],
423         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
424 using namespace std;
425 #include <FlexLexer.h>
426 class yy_flex_lexer: public yyFlexLexer
427 {
428   public:
429     yy_flex_lexer ()
430     {
431       yy_current_buffer = 0;
432     }
433 };
434 ]])],
435             [stepmake_flexlexer_yy_current_buffer=yes],
436             [stepmake_flexlexer_yy_current_buffer=no]))
437     if test $stepmake_flexlexer_yy_current_buffer = yes; then
438         AC_DEFINE(HAVE_FLEXLEXER_YY_CURRENT_BUFFER, 1, [Define to 1 if yyFlexLexer has yy_current_buffer.])
439     fi
440     AC_LANG_POP(C++)
441 ])
442   
443
444
445 AC_DEFUN(STEPMAKE_FLEXLEXER_LOCATION, [
446         AC_MSG_CHECKING([FlexLexer.h location])
447
448         # ugh.
449         cat <<EOF > conftest.cc
450 using namespace std;
451 #include <FlexLexer.h>
452 EOF
453         FLEXLEXER_FILE=`$CXX -E conftest.cc | \
454           sed 's!# 1 "\(.*FlexLexer.h\)"!@FLEXLEXER@\1@@!g' | grep '@@' | \
455           sed 's!.*@FLEXLEXER@\(.*\)@@.*$!\1!g' ` 1> /dev/null 2> /dev/null
456         rm conftest.cc
457         AC_SUBST(FLEXLEXER_FILE)
458         AC_MSG_RESULT($FLEXLEXER_FILE)
459 ])
460
461 AC_DEFUN(STEPMAKE_GCC, [
462     if test "$GCC" = "yes"; then
463         STEPMAKE_CHECK_VERSION(CC, $1, $2)
464     else
465         warn="$CC (Please install *GNU* cc)"
466         STEPMAKE_ADD_ENTRY($1, $warn)
467     fi
468 ])
469
470 AC_DEFUN(STEPMAKE_GETTEXT, [
471     presome=${prefix}
472     if test "$prefix" = "NONE"; then
473             presome=${ac_default_prefix}
474     fi
475     LOCALEDIR=`echo ${localedir} | sed "s!\\\${prefix}!$presome!"`
476     
477     AC_SUBST(localedir)
478     AC_DEFINE_UNQUOTED(LOCALEDIR, ["${LOCALEDIR}"])
479     # ouch.  autoconf <= 2.57's gettext check fails for
480     # g++ >= 3.3 (with -std=gnu++98, the default).
481     # While the check is OK for g++ -std=c++98,
482     # LilyPond needs GNU g++, so who is to blame here?
483     # Use a workaround until this is resolved:
484     # for g++ >= 3.3, select C language.
485     GCC_UNSUPPORTED=
486     STEPMAKE_CHECK_VERSION_UNSUPPORTED(CXX, GCC_UNSUPPORTED, 3.3)
487     if test -n "$GCC_UNSUPPORTED"; then
488         AC_MSG_WARN([autoconf <= 2.59 with g++ >= 3.3 gettext test broken.])
489         AC_MSG_WARN([Trying gcc, cross fingers.])
490         AC_LANG_PUSH(C)
491     fi
492     AC_CHECK_LIB(intl, gettext)
493     AC_CHECK_FUNCS(gettext)
494     if test -n "$GCC_UNSUPPORTED"; then
495         AC_LANG_POP(C)
496     fi
497 ])
498
499
500 AC_DEFUN(STEPMAKE_GUILE, [
501     STEPMAKE_PATH_PROG(GUILE, guile, $1)
502 ])
503
504
505 #   STEPMAKE_GUILE_FLAGS --- set flags for compiling and linking with Guile
506 #
507 #   This macro runs the guile-config script, installed with Guile,
508 #   to find out where Guile's header files and libraries are
509 #   installed.  It sets two variables, marked for substitution, as
510 #   by AC_SUBST.
511 #   
512 #     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
513 #             code that uses Guile header files.  This is almost
514 #             always just a -I flag.
515 #   
516 #     GUILE_LDFLAGS --- flags to pass to the linker to link a
517 #             program against Guile.  This includes -lguile for
518 #             the Guile library itself, any libraries that Guile
519 #             itself requires (like -lqthreads), and so on.  It may
520 #             also include a -L flag to tell the compiler where to
521 #             find the libraries.
522
523 AC_DEFUN([STEPMAKE_GUILE_FLAGS], [
524     exe=`STEPMAKE_GET_EXECUTABLE($guile_config)`
525     if test -x $exe; then
526         AC_MSG_CHECKING([guile compile flags])
527         GUILE_CFLAGS="`$guile_config compile`"
528         AC_MSG_RESULT($GUILE_CFLAGS)
529         AC_MSG_CHECKING([guile link flags])
530         GUILE_LDFLAGS="`$guile_config link`"
531         AC_MSG_RESULT($GUILE_LDFLAGS)
532     fi
533     AC_SUBST(GUILE_CFLAGS)
534     AC_SUBST(GUILE_LDFLAGS)
535 ])
536
537
538 AC_DEFUN(STEPMAKE_GUILE_DEVEL, [
539     ## First, let's just see if we can find Guile at all.
540     test -n "$target_alias" && target_guile_config=$target_alias-guile-config
541     test -n "$host_alias" && host_guile_config=$host_alias-guile-config
542     AC_MSG_CHECKING([for guile-config])
543     for guile_config in $GUILE_CONFIG $target_guile_config $host_guile_config $build_guile_config guile-config; do
544         AC_MSG_RESULT([$guile_config])
545         if ! $guile_config --version > /dev/null 2>&1 ; then
546             AC_MSG_WARN([cannot execute $guile_config])
547             AC_MSG_CHECKING([if we are cross compiling])
548             GUILE_CONFIG='echo no guile-config'
549         else
550             GUILE_CONFIG=$guile_config
551             break
552         fi
553     done
554     STEPMAKE_OPTIONAL_REQUIRED(GUILE_CONFIG, $guile_config, $1)
555     if test $? -ne 0; then
556         STEPMAKE_ADD_ENTRY($1, 'guile-config (guile-devel, guile-dev or libguile-dev package)')
557     fi 
558
559     STEPMAKE_CHECK_SEARCH_RESULT(GUILE_CONFIG)
560     # urg.  should test functionality rather than version.
561     if test $? -eq 0 -a -n "$2"; then
562         STEPMAKE_CHECK_VERSION(GUILE_CONFIG, $1, $2)
563     fi
564
565     AC_SUBST(GUILE_CONFIG)
566     
567     guile_version="$ver"
568     changequote(<<, >>)#dnl
569     GUILE_MAJOR_VERSION=`expr $guile_version : '\([0-9]*\)'`
570     GUILE_MINOR_VERSION=`expr $guile_version : '[0-9]*\.\([0-9]*\)'`
571     GUILE_PATCH_LEVEL=`expr $guile_version : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
572     changequote([, ])#dnl
573     STEPMAKE_GUILE_FLAGS
574     save_CPPFLAGS="$CPPFLAGS"
575     save_LIBS="$LIBS"
576     CPPFLAGS="$GUILE_CFLAGS $CPPFLAGS"
577     LIBS="$GUILE_LDFLAGS $LIBS"
578     AC_CHECK_HEADERS([libguile.h])
579     AC_CHECK_LIB(guile, scm_boot_guile)
580     AC_CHECK_FUNCS(scm_boot_guile,,libguile_b=no)
581     if test "$libguile_b" = "no"; then
582             warn='libguile (libguile-dev, guile-devel or guile-dev
583    package).'
584             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
585     fi
586     CPPFLAGS="$save_CPPFLAGS"
587     LIBS="$save_LIBS"
588     AC_DEFINE_UNQUOTED(GUILE_MAJOR_VERSION, $GUILE_MAJOR_VERSION)
589     AC_DEFINE_UNQUOTED(GUILE_MINOR_VERSION, $GUILE_MINOR_VERSION)
590     AC_DEFINE_UNQUOTED(GUILE_PATCH_LEVEL, $GUILE_PATCH_LEVEL)
591 ])
592
593
594 AC_DEFUN(STEPMAKE_DLOPEN, [
595     AC_CHECK_LIB(dl, dlopen)
596     AC_CHECK_FUNCS(dlopen)
597 ])
598
599 AC_DEFUN(STEPMAKE_GXX, [
600     if test "$GXX" = "yes"; then
601         STEPMAKE_CHECK_VERSION(CXX, $1, $2)
602     else
603         warn="$CXX (Please install *GNU* c++)"
604         STEPMAKE_ADD_ENTRY($1, $warn)
605     fi
606 ])
607
608
609 AC_DEFUN(STEPMAKE_INIT, [
610
611     AC_PREREQ(2.50)
612     . $srcdir/VERSION
613     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
614     MICRO_VERSION=$PATCH_LEVEL
615     TOPLEVEL_VERSION=$FULL_VERSION
616     if test x$MY_PATCH_LEVEL != x; then
617         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
618     fi
619     VERSION=$FULL_VERSION
620     export MAJOR_VERSION MINOR_VERSION PATCH_LEVEL
621     # urg: don't "fix" this: irix doesn't know about [:lower:] and [:upper:]
622     changequote(<<, >>)#dnl
623     PACKAGE=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'`
624     package=`echo $PACKAGE_NAME | tr '[A-Z]' '[a-z]'`
625     changequote([, ])#dnl
626
627     # No versioning on directory names of sub-packages 
628     # urg, urg
629     stepmake=${datadir}/stepmake
630     presome=${prefix}
631     if test "$prefix" = "NONE"; then
632             presome=${ac_default_prefix}
633     fi
634     stepmake=`echo ${stepmake} | sed "s!\\\${prefix}!$presome!"`
635
636     # urg, how is this supposed to work?
637     if test "$program_prefix" = "NONE"; then
638           program_prefix=
639     fi
640     if test "$program_suffix" = "NONE"; then
641           program_suffix=
642     fi
643
644     AC_MSG_CHECKING(Package)
645     if test "$PACKAGE" = "STEPMAKE"; then
646         AC_MSG_RESULT(Stepmake package!)
647
648         AC_MSG_CHECKING(builddir)
649
650         ugh_ugh_autoconf250_builddir="`pwd`"
651         
652         if test "$srcdir" = "."; then
653             srcdir_build=yes
654         else
655             srcdir_build=no
656             package_builddir="`dirname $ugh_ugh_autoconf250_builddir`"
657             package_srcdir="`dirname  $srcdir`"
658         fi
659         AC_MSG_RESULT($ugh_ugh_autoconf250_builddir)
660
661         (cd stepmake 2>/dev/null || mkdir stepmake)
662         (cd stepmake; rm -f bin; ln -s ../$srcdir/bin .)
663         stepmake=stepmake
664     else
665         AC_MSG_RESULT($PACKAGE)
666
667         AC_MSG_CHECKING(builddir)
668         ugh_ugh_autoconf250_builddir="`pwd`"
669         if test "$srcdir" = "."; then
670             srcdir_build=yes
671         else
672             srcdir_build=no
673         fi
674         AC_MSG_RESULT($ugh_ugh_autoconf250_builddir)
675
676         AC_MSG_CHECKING(for stepmake)
677         # Check for installed stepmake
678         if test -d $stepmake; then
679             AC_MSG_RESULT($stepmake)
680         else
681             stepmake="`cd $srcdir/stepmake; pwd`"
682             AC_MSG_RESULT([$srcdir/stepmake  ($datadir/stepmake not found)])
683         fi
684     fi
685
686     AC_SUBST(ugh_ugh_autoconf250_builddir)
687
688     # Use absolute directory for non-srcdir builds, so that build
689     # dir can be moved.
690     if test "$srcdir_build" = "no" ;  then 
691         srcdir="`cd $srcdir; pwd`"
692     fi
693     
694     AC_SUBST(srcdir)
695     AC_SUBST(stepmake)
696     AC_SUBST(package)
697     AC_SUBST(PACKAGE)
698     AC_SUBST(PACKAGE_NAME)
699     AC_SUBST(VERSION)
700     AC_SUBST(MAJOR_VERSION)
701     AC_SUBST(MINOR_VERSION)
702     AC_SUBST(MICRO_VERSION)
703
704     # stepmake nonstandard names
705     AC_SUBST(PATCH_LEVEL)
706     AC_SUBST(TOPLEVEL_VERSION)
707     
708     # We don't need the upper case variant,
709     # so stick to macros are uppercase convention.
710     # AC_DEFINE_UNQUOTED(package, ["${package}"])
711     # AC_DEFINE_UNQUOTED(PACKAGE, ["${PACKAGE}"])
712     AC_DEFINE_UNQUOTED(PACKAGE, ["${package}"])
713     AC_DEFINE_UNQUOTED(PACKAGE_NAME, ["${PACKAGE_NAME}"])
714     AC_DEFINE_UNQUOTED(TOPLEVEL_VERSION, ["${FULL_VERSION}"])
715
716     if test -z "$package_depth"; then
717         package_depth="."
718     else
719         package_depth="../$package_depth"
720     fi
721     export package_depth
722     AC_SUBST(package_depth)
723
724     AUTOGENERATE="This file was automatically generated by configure"
725     AC_SUBST(AUTOGENERATE)
726
727     CONFIGSUFFIX=
728     AC_ARG_ENABLE(config,
729     [  --enable-config=CONF    put settings in config-CONF.make and config-CONF.h;
730                             do `make conf=CONF' to get output in ./out-CONF],
731     [CONFIGURATION=$enableval])
732
733     ##'`#
734
735     test -n "$CONFIGURATION" && CONFIGSUFFIX="-$CONFIGURATION"
736     CONFIGFILE=config$CONFIGSUFFIX
737     AC_SUBST(CONFIGSUFFIX)
738      
739     AC_CANONICAL_HOST
740     STEPMAKE_PROGS(MAKE, gmake make, REQUIRED)
741     STEPMAKE_PROGS(FIND, find, REQUIRED)
742
743     STEPMAKE_PROGS(TAR, tar, REQUIRED)
744
745     if test "$(echo 2)" != "2" ||
746         test "x`uname`" = "xHP-UX"; then
747         AC_PATH_PROG(KSH, ksh, /bin/ksh)
748         AC_PATH_PROG(BASH, bash, $KSH)
749         STEPMAKE_WARN(avoiding buggy /bin/sh)
750         AC_PATH_PROG(SHELL, bash, $KSH)
751     else
752         SHELL=/bin/sh
753         AC_PATH_PROG(BASH, bash, $SHELL)
754     fi
755     AC_SUBST(SHELL)
756
757     STEPMAKE_PYTHON(REQUIRED, 1.5)
758
759     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
760         $MAKE -v 2> /dev/null | grep GNU > /dev/null
761         if test "$?" = 1; then
762             warn='make (Please install *GNU* make)'
763             # STEPMAKE_WARN($warn)
764             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
765         fi
766     fi
767
768     ROOTSEP=':'
769     DIRSEP='/'
770     PATHSEP=':'
771     LN=ln
772     LN_S='ln -s'
773     ZIP="zip -r -9"
774
775     AC_SUBST(program_prefix)
776     AC_SUBST(program_suffix)
777     AC_SUBST(ZIP)
778     AC_SUBST(LN)
779     AC_SUBST(LN_S)
780     AC_DEFINE_UNQUOTED(DIRSEP, ['${DIRSEP}'])
781     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
782     AC_SUBST(DIRSEP)
783     AC_SUBST(PATHSEP)
784     AC_SUBST(ROOTSEP)
785   
786     STEPMAKE_DATADIR
787     STEPMAKE_LIBDIR
788 ])
789
790     
791 AC_DEFUN(STEPMAKE_KPATHSEA, [
792         
793     AC_ARG_WITH(kpathsea-include,
794         [  --with-kpathsea-include=DIR
795                           location of the kpathsea include dir],[
796             if test "$withval" = "yes" -o "$withval" = "no"; then
797                 AC_MSG_WARN(Usage: --with-kpathsea-include=includedir)
798             else
799                 CPPFLAGS="$CPPFLAGS -I${withval}"
800             fi
801             ])
802     
803     AC_ARG_WITH(kpathsea-lib,
804         [  --with-kpathsea-lib=DIR location of the kpathsea lib dir],[
805             if test "$withval" = "yes" -o "$withval" = "no"; then
806                 AC_MSG_WARN(Usage: --with-kpathsea-lib=libdir)
807             else
808                 LDFLAGS="$LDFLAGS -L${withval}"
809             fi
810             ])
811     
812     kpathsea_b=yes
813     AC_ARG_ENABLE(kpathsea,
814     [  --enable-kpathsea         use kpathsea lib.  Default: on],
815     [kpathsea_b=$enableval])
816
817     save_LIBS="$LIBS"
818     if test "$kpathsea_b" != "no"; then 
819         AC_CHECK_HEADERS([kpathsea/kpathsea.h],,kpathsea_b=no)
820         AC_CHECK_LIB(kpathsea, kpse_find_file)
821         AC_CHECK_FUNCS(kpse_find_file,,kpathsea_b=no)
822         if test "$kpathsea_b" = "no"; then
823             STEPMAKE_ADD_ENTRY(OPTIONAL, $warn)
824         fi
825     fi
826
827     save_CFLAGS="$CFLAGS"
828     CFLAGS=`echo "-shared $CFLAGS" | sed -e 's/ -g//'`
829     AC_MSG_CHECKING([for shared libkpathsea])
830     AC_TRY_LINK([#include <kpathsea/kpathsea.h>],
831                  [kpse_var_expand ("\$TEXMF");],
832                  [have_libkpathsea_so=maybe;
833                   shared_size=`wc -c conftest$ac_exeext`;
834                   shared_size=`echo $shared_size | sed -e 's/ .*//g'`],
835                  [have_libkpathsea_so=no])
836
837     if test "$have_libkpathsea_so" = "maybe"; then
838         if test "$shared_size" -lt 40000 ; then
839           have_libkpathsea_so=yes
840         else
841           have_libkpathsea_so=no
842         fi
843     fi
844     
845     AC_MSG_RESULT($have_libkpathsea_so)
846     if test "$have_libkpathsea_so" = "yes"; then
847         AC_DEFINE(HAVE_LIBKPATHSEA_SO)
848     fi
849     CFLAGS="$save_CFLAGS"
850
851     KPATHSEA_LIBS="$LIBS"
852     LIBS="$save_LIBS"
853     AC_MSG_CHECKING(whether to use kpathsea)
854     if test "$kpathsea_b" != no; then
855         AC_MSG_RESULT(yes)
856         KPATHSEA=1
857     else
858         AC_MSG_RESULT(no)
859         KPATHSEA=0
860     fi
861
862     AC_SUBST(KPATHSEA)
863     AC_SUBST(KPATHSEA_LIBS)
864     AC_SUBST(HAVE_LIBKPATHSEA_SO, $have_libkpathsea_so)
865     AC_DEFINE_UNQUOTED(KPATHSEA, $KPATHSEA)
866 ])
867
868
869 AC_DEFUN(STEPMAKE_LIB, [
870     STEPMAKE_PROGS(AR, ar, $1)
871     AC_PROG_RANLIB
872     STEPMAKE_OPTIONAL_REQUIRED(RANLIB, ranlib, $1)
873 ])
874
875
876 AC_DEFUN(STEPMAKE_LIBTOOL, [
877     # libtool.info ...
878     # **Never** try to set library version numbers so that they correspond
879     # to the release number of your package.  This is an abuse that only
880     # fosters misunderstanding of the purpose of library versions.
881
882     REVISION=$PATCH_LEVEL
883     # CURRENT=$MINOR_VERSION
884     CURRENT=`expr $MINOR_VERSION + 1`
885     # AGE=`expr $MAJOR_VERSION + 1`
886     AGE=$MAJOR_VERSION
887     AC_SUBST(CURRENT)
888     AC_SUBST(REVISION)
889     AC_SUBST(AGE)
890 ])
891
892
893 AC_DEFUN(STEPMAKE_LOCALE, [
894     lang=English
895     ALL_LINGUAS="en nl"
896
897     # with/enable ??
898     AC_ARG_WITH(localedir,
899     [  --with-localedir=DIR    location of locales.  Default: PREFIX/share/locale ],
900     localedir=$with_localedir,
901     localedir='${prefix}/share/locale')
902
903     AC_ARG_WITH(lang,
904     [  --with-lang=LANG        use LANG as language to emit messages],
905     language=$with_lang,
906     language=English)
907
908     AC_MSG_CHECKING(language)    
909     case "$language" in
910       En* | en* | Am* | am* | US* | us*)
911             lang=English;;
912       NL | nl | Du* | du* | Ned* | ned*)
913             lang=Dutch;;
914       "")
915             lang=English;;
916       *)
917             lang=unknown;;
918     esac
919     AC_MSG_RESULT($lang)
920
921     if test "$lang" = "unknown" ; then
922         STEPMAKE_WARN($language not supported; available are: $ALL_LINGUAS)
923     fi
924
925 ])
926
927
928 AC_DEFUN(STEPMAKE_MAKEINFO, [
929     STEPMAKE_PROGS(MAKEINFO, makeinfo, $1)
930 ])
931
932
933 AC_DEFUN(STEPMAKE_MAN, [
934     STEPMAKE_PROGS(GROFF, groff ditroff, $1)
935     AC_SUBST(GROFF)
936     STEPMAKE_PROGS(TROFF, troff, $1)
937     AC_SUBST(TROFF)
938     STEPMAKE_PROGS(TBL, tbl, $1)
939     AC_SUBST(TBL)
940 ])
941
942
943 AC_DEFUN(STEPMAKE_MSGFMT, [
944     STEPMAKE_PROGS(MSGFMT, msgfmt, $1)
945 ])
946
947
948 # Check for program ($2), set full path result to ($1).
949 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
950 AC_DEFUN(STEPMAKE_PATH_PROG, [
951     AC_CHECK_PROGS($1, $2, no)
952     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
953     if test $? -eq 0; then
954         AC_PATH_PROG($1, $2)
955         if test -n "$4"; then
956             STEPMAKE_CHECK_VERSION($1, $3, $4)
957         fi
958     fi
959 ])
960
961
962 # Check for program in set of names ($2), set result to ($1) .
963 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
964 # If exists, and a minimal version ($4) is required
965 AC_DEFUN(STEPMAKE_PROGS, [
966     AC_CHECK_PROGS($1, $2, no)
967     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
968     if test $? -eq 0 -a -n "$4"; then
969         STEPMAKE_CHECK_VERSION($1, $3, $4)
970     fi
971 ])
972
973
974 AC_DEFUN(STEPMAKE_PERL, [
975     STEPMAKE_PATH_PROG(PERL, perl, $1)
976 ])
977
978
979 AC_DEFUN(STEPMAKE_PYTHON, [
980     unset pv
981     AC_MSG_CHECKING([for python])
982     for python in $PYTHON python python2 python2.4 python2.3 python2.2 python2.1 python2.0; do
983         AC_MSG_RESULT([$python])
984         if ! $python -V > /dev/null 2>&1 ; then
985             #AC_MSG_WARN([cannot execute $python])
986             PYTHON='echo no python'
987         else
988             unset pv
989             STEPMAKE_CHECK_VERSION(python, pv, $2)
990             if test -z "$pv"; then
991                 PYTHON=$python
992                 break
993             fi
994         fi
995     done
996     if test -n "$pv"; then
997         STEPMAKE_ADD_ENTRY($1, $pv)
998     fi
999     # clear cached value since arg 2 might point us to a new binary
1000     unset ac_cv_path_PYTHON
1001
1002     AC_PATH_PROG(PYTHON, $PYTHON)
1003     AC_SUBST(PYTHON)
1004 ])
1005
1006 AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
1007     AC_ARG_WITH(python-include,
1008         [  --with-python-include=DIR
1009                           location of the python include dir],[
1010             if test "$withval" = "yes" -o "$withval" = "no"; then
1011                 AC_MSG_WARN(Usage: --with-python-include=includedir)
1012             else
1013                 PYTHON_CFLAGS="-I${withval}"
1014             fi
1015             ])
1016     
1017     AC_ARG_WITH(python-lib,
1018         [  --with-python-lib=NAME  name of the python lib],[
1019             if test "$withval" = "yes" -o "$withval" = "no"; then
1020                 AC_MSG_WARN(Usage: --with-python-lib=name)
1021             else
1022                 LDFLAGS="$LDFLAGS -l${withval}"
1023             fi
1024             ])
1025     
1026     if test "$cross_compiling" = "no" -a -z "$PYTHON_CFLAGS"; then
1027         changequote(<<, >>)#dnl
1028         # alternatively, for python >= 2.0
1029         # 'import sys, distutils.sysconfig; sys.stdout.write (distutils.sysconfig.get_python_inc ())'
1030         PYTHON_INCLUDE=`$PYTHON -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'`
1031         PYTHON_CFLAGS="-I$PYTHON_INCLUDE"
1032         changequote([, ])#dnl
1033     fi
1034     
1035     if test "$cross_compiling" = "yes" -a -z "$PYTHON_CFLAGS"; then
1036         PYTHON_CFLAGS=`python-config --cflags`
1037         PYTHON_LDFLAGS=`python-config --ldflags`
1038     fi
1039     
1040     if test -z "$PYTHON_HEADER"; then
1041         CPPFLAGS="$PYTHON_CFLAGS $CPPFLAGS"
1042         AC_CHECK_HEADERS([Python.h],[PYTHON_HEADER=yes])
1043     fi
1044     
1045     if test -z "$PYTHON_HEADER"; then
1046         warn="Python.h (python-devel, python-dev or libpython-dev package)"
1047         STEPMAKE_ADD_ENTRY($1, $warn)
1048     fi
1049 ])
1050
1051
1052
1053 AC_DEFUN(STEPMAKE_STL_DATA_METHOD, [
1054     AC_LANG_PUSH(C++)
1055     AC_CACHE_CHECK([for stl.data () method],
1056         [stepmake_stl_data_method],
1057         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1058 #include <vector>
1059 using namespace std;
1060 vector <int> v;
1061 void *p = v.data ();
1062 ]])],
1063             [stepmake_stl_data_method=yes],
1064             [stepmake_stl_data_method=no]))
1065     if test $stepmake_stl_data_method = yes; then
1066         AC_DEFINE(HAVE_STL_DATA_METHOD, 1, [define if stl classes have data () method])
1067     fi
1068     AC_LANG_POP(C++)
1069 ])
1070
1071
1072 AC_DEFUN(STEPMAKE_TEXMF_DIRS, [
1073     # ugh
1074     STEPMAKE_PROGS(KPSEWHICH, kpsewhich, OPTIONAL)
1075 ])
1076
1077 AC_DEFUN(STEPMAKE_TEXMF, [
1078     STEPMAKE_PROGS(METAFONT, mf-nowin mf mfw mfont, $1)
1079     # STEPMAKE_PROGS(INIMETAFONT, inimf inimfont "$METAFONT -ini", $1)
1080
1081     AC_MSG_CHECKING(for working metafont mode)
1082     modelist='ljfour lj4 lj3 lj2 ljet laserjet'
1083     for MFMODE in $modelist; do
1084         $METAFONT -progname=mf "\mode:=$MFMODE; mode_setup; end." > /dev/null 2>&1
1085         if test -f mfput.tfm; then
1086             break;
1087         fi
1088     done
1089     AC_MSG_RESULT($MFMODE)
1090
1091     rm -f mfput.*
1092
1093     AC_SUBST(MFMODE)
1094 ])
1095
1096
1097 AC_DEFUN(STEPMAKE_WARN, [
1098     AC_MSG_WARN($1)
1099     warn_b=yes
1100 ])
1101
1102
1103 dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1104 dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1105 dnl also defines GSTUFF_PKG_ERRORS on error
1106 AC_DEFUN(PKG_CHECK_MODULES, [
1107   succeeded=no
1108
1109   if test -z "$PKG_CONFIG"; then
1110     AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1111   fi
1112
1113   if test "$PKG_CONFIG" = "no" ; then
1114      echo "*** The pkg-config script could not be found. Make sure it is"
1115      echo "*** in your path, or set the PKG_CONFIG environment variable"
1116      echo "*** to the full path to pkg-config."
1117      echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
1118   else
1119      PKG_CONFIG_MIN_VERSION=0.9.0
1120      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
1121         AC_MSG_CHECKING(for $2)
1122
1123         if $PKG_CONFIG --exists "$2" ; then
1124             AC_MSG_RESULT(yes)
1125             succeeded=yes
1126
1127             AC_MSG_CHECKING($1_CFLAGS)
1128             $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
1129             AC_MSG_RESULT($$1_CFLAGS)
1130
1131             AC_MSG_CHECKING($1_LIBS)
1132             $1_LIBS=`$PKG_CONFIG --libs "$2"`
1133             AC_MSG_RESULT($$1_LIBS)
1134         else
1135             $1_CFLAGS=""
1136             $1_LIBS=""
1137             ## If we have a custom action on failure, don't print errors, but 
1138             ## do set a variable so people can do so.
1139             $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
1140             ifelse([$4], ,echo $$1_PKG_ERRORS,)
1141         fi
1142
1143         AC_SUBST($1_CFLAGS)
1144         AC_SUBST($1_LIBS)
1145      fi
1146   fi
1147
1148   if test $succeeded = yes; then
1149      ifelse([$3], , :, [$3])
1150   else
1151      ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
1152   fi
1153 ])
1154
1155 AC_DEFUN(STEPMAKE_FREETYPE2, [
1156     PKG_CHECK_MODULES(FREETYPE2, $1 >= $3, have_freetype2=yes, true)
1157     if test "$have_freetype2" = yes; then
1158         AC_DEFINE(HAVE_FREETYPE2)
1159         save_CPPFLAGS="$CPPFLAGS"
1160         save_LIBS="$LIBS"
1161         CPPFLAGS="$FREETYPE2_CFLAGS $CPPFLAGS"
1162         LIBS="$FREETYPE2_LIBS $LIBS"
1163         AC_SUBST(FREETYPE2_CFLAGS)
1164         AC_SUBST(FREETYPE2_LIBS)
1165         CPPFLAGS="$save_CPPFLAGS"
1166         LIBS="$save_LIBS"
1167     else
1168         # UGR
1169         #r="lib$1-dev or $1-devel"
1170         r="libfreetype6-dev or freetype?-devel"
1171         ver="`pkg-config --modversion $1`"
1172         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1173     fi
1174 ])
1175
1176 AC_DEFUN(STEPMAKE_GTK2, [
1177     PKG_CHECK_MODULES(GTK2, $1 >= $3, have_gtk2=yes, true)
1178     if test "$have_gtk2" = yes ; then
1179         AC_DEFINE(HAVE_GTK2)
1180         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1181         save_CPPFLAGS="$CPPFLAGS"
1182         save_LIBS="$LIBS"
1183         CPPFLAGS="$GTK2_CFLAGS $CPPFLAGS"
1184         LIBS="$GTK2_LIBS $LIBS"
1185         AC_SUBST(GTK2_CFLAGS)
1186         AC_SUBST(GTK2_LIBS)
1187         CPPFLAGS="$save_CPPFLAGS"
1188         LIBS="$save_LIBS"
1189     else
1190         # UGR
1191         # r="lib$1-dev or $1-devel"
1192         r="libgtk2.0-dev or gtk2-devel"
1193         ver="`pkg-config --modversion $1`"
1194         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1195     fi
1196 ])
1197
1198 AC_DEFUN(STEPMAKE_PANGO, [
1199     PKG_CHECK_MODULES(PANGO, $1 >= $3, have_pango16=yes, true)
1200     if test "$have_pango16" = yes ; then
1201         AC_DEFINE(HAVE_PANGO16)
1202         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1203         save_CPPFLAGS="$CPPFLAGS"
1204         save_LIBS="$LIBS"
1205         CPPFLAGS="$PANGO_CFLAGS $CPPFLAGS"
1206         LIBS="$PANGO_LIBS $LIBS"
1207         AC_CHECK_HEADERS([pango/pangofc-fontmap.h])
1208         AC_CHECK_FUNCS([pango_fc_font_map_add_decoder_find_func])
1209         AC_SUBST(PANGO_CFLAGS)
1210         AC_SUBST(PANGO_LIBS)
1211         CPPFLAGS="$save_CPPFLAGS"
1212         LIBS="$save_LIBS"
1213     else
1214         # UGR
1215         #r="lib$1-dev or $1-devel"
1216         r="libpango1.0-dev or pango1.0-devel"
1217         ver="`pkg-config --modversion $1`"
1218         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1219     fi
1220 ])
1221
1222 AC_DEFUN(STEPMAKE_PANGO_FT2, [
1223     PKG_CHECK_MODULES(PANGO_FT2, $1 >= $3, have_pangoft2=yes, true)
1224     if test "$have_pangoft2" = yes ; then
1225         AC_DEFINE(HAVE_PANGO16)
1226         AC_DEFINE(HAVE_PANGO_FT2)
1227         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1228         save_CPPFLAGS="$CPPFLAGS"
1229         save_LIBS="$LIBS"
1230         CPPFLAGS="$CPPFLAGS $PANGO_FT2_CFLAGS"
1231         LIBS="$PANGO_FT2_LIBS $LIBS"
1232         AC_CHECK_HEADERS([pango/pangoft2.h])
1233         AC_CHECK_FUNCS([pango_ft2_font_map_create_context])
1234         AC_SUBST(PANGO_FT2_CFLAGS)
1235         AC_SUBST(PANGO_FT2_LIBS)
1236         CPPFLAGS="$save_CPPFLAGS"
1237         LIBS="$save_LIBS"
1238     else
1239         # UGR
1240         #r="lib$1-dev or $1-devel"e
1241         r="libpango1.0-dev or pango?-devel"
1242         ver="`pkg-config --modversion $1`"
1243         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1244     fi
1245 ])
1246
1247 AC_DEFUN(STEPMAKE_FONTCONFIG, [
1248     PKG_CHECK_MODULES(FONTCONFIG, $1 >= $3, have_fontconfig=yes, true)
1249     if test "$have_fontconfig" = yes ; then
1250         AC_DEFINE(HAVE_FONTCONFIG)
1251         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1252         save_CPPFLAGS="$CPPFLAGS"
1253         save_LIBS="$LIBS"
1254         CPPFLAGS="$FONTCONFIG_CFLAGS $CPPFLAGS"
1255         LIBS="$FONTCONFIG_LIBS $LIBS"
1256         AC_SUBST(FONTCONFIG_CFLAGS)
1257         AC_SUBST(FONTCONFIG_LIBS)
1258         CPPFLAGS="$save_CPPFLAGS"
1259         LIBS="$save_LIBS"
1260     else
1261         r="lib$1-dev or $1-devel"
1262         ver="`pkg-config --modversion $1`"
1263         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1264     fi
1265 ])
1266
1267 AC_DEFUN(STEPMAKE_WINDOWS, [
1268     AC_CYGWIN
1269     AC_MINGW32
1270
1271     if test "$CYGWIN" = "yes"; then
1272         LN_S='cp -r' # Cygwin symbolic links do not work for native apps.
1273         program_suffix=.exe
1274         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
1275     elif test "$MINGW32" = "yes"; then
1276         LN='cp -r'
1277         LN_S='cp -r'
1278         program_suffix=.exe
1279         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
1280         PATHSEP=';'
1281     fi
1282
1283     AC_SUBST(LN)
1284     AC_SUBST(LN_S)
1285     AC_DEFINE_UNQUOTED(DIRSEP, ['${DIRSEP}'])
1286     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
1287     AC_SUBST(DIRSEP)
1288     AC_SUBST(PATHSEP)
1289     AC_SUBST(program_suffix)
1290
1291     AC_MSG_CHECKING([for some flavor of Windows])
1292     if test "$CYGWIN$MINGW32" = "nono"; then
1293         PLATFORM_WINDOWS=no
1294     else
1295         PLATFORM_WINDOWS=yes
1296     fi
1297     AC_MSG_RESULT([$PLATFORM_WINDOWS])
1298     AC_SUBST(PLATFORM_WINDOWS)
1299     STEPMAKE_PROGS(WINDRES, $target-windres windres, x)
1300     AC_SUBST(WINDRES)
1301 ])