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