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