]> git.donarmstrong.com Git - lilypond.git/blob - stepmake/aclocal.m4
Workaround for broken Debian gcc version string: 'gcc (GCC) 3.1.1
[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     ## Assume, and hunt for, dotted version multiplet.
27     changequote(<<, >>)dnl
28     "$1" --version 2>&1 | grep '[0-9]\.[0-9]' | head -1 | \
29         sed -e 's/.*[^-.0-9]\([0-9][0-9]*\.[0-9][.0-9]*\).*/\1/'
30     changequote([, ])dnl
31 ])
32
33 # Calculate simplistic numeric version from version string ($1)
34 # As yet, we have no need for something more elaborate.
35 AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [
36     echo "$1" | awk -F. '
37     {
38       if ([$]3) {three = [$]3}
39       else {three = 0}
40     }
41     {printf "%s%s%s\n", [$]1*100, [$]2*10, three}'
42 ])
43
44
45 # Add item ($2) to list ($1, one of 'OPTIONAL', 'REQUIRED')
46 AC_DEFUN(STEPMAKE_ADD_ENTRY, [
47     eval "$1"=\"`eval echo \"'$'$1\" \"$2\"`\"
48 ])
49
50 # Check if tested program ($2) was found ($1).
51 # If not, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED').
52 # We could abort here if a 'REQUIRED' program is not found
53 AC_DEFUN(STEPMAKE_OPTIONAL_REQUIRED, [
54     STEPMAKE_CHECK_SEARCH_RESULT($1)
55     if test $? -ne 0; then
56         STEPMAKE_ADD_ENTRY($3, $2)
57         if test "$3" = "REQUIRED"; then
58             command="echo ERROR: $2 not found"
59             # abort configure process here?
60         else
61             command="- echo $2 not found"
62         fi
63         eval "$1"='$command'
64         false
65     else
66         true
67     fi
68 ])
69
70
71 # Return if tested proram ($1) was found (true) or not (false).
72 AC_DEFUN(STEPMAKE_CHECK_SEARCH_RESULT, [
73     r="`eval echo '$'"$1"`"
74     if test -n "$r" -a "$r" != "error" -a "$r" != "no" && expr '`eval echo '$'"$1"`' : '.*\(echo\)' > /dev/null; then
75         true
76     else
77         ##STEPMAKE_WARN(cannot find $2. $3)
78         false
79     fi
80 ])
81
82
83 # Check version of program ($1)
84 # If version is smaller than requested ($3),
85 # add entry to missing-list ($2, one of 'OPTIONAL', 'REQUIRED').
86 AC_DEFUN(STEPMAKE_CHECK_VERSION, [
87     r="`eval echo '$'"$1"`"
88     AC_MSG_CHECKING("$r version")
89     #exe=`STEPMAKE_GET_EXECUTABLE($r)`
90     exe=`STEPMAKE_GET_EXECUTABLE($r)`
91     ver=`STEPMAKE_GET_VERSION($exe)`
92     num=`STEPMAKE_NUMERIC_VERSION($ver)`
93     req=`STEPMAKE_NUMERIC_VERSION($3)`
94     AC_MSG_RESULT("$ver")
95     if test "$num" -lt "$req"; then
96         STEPMAKE_ADD_ENTRY($2, "$r $3 (installed: $ver)")
97     fi
98 ])
99
100 ### Macros to build configure.in
101
102
103 AC_DEFUN(STEPMAKE_BIBTEX2HTML, [
104     STEPMAKE_PROGS(BIBTEX2HTML, bibtex2html bib2html, $1)
105     if test "$BIBTEX2HTML" = "bib2html"; then
106         BIBTEX2HTML_FLAGS='$< $(@)'
107     else
108         BIBTEX2HTML_FLAGS='-o $(@D)/$(*F) $<'
109     fi
110     AC_SUBST(BIBTEX2HTML)
111     AC_SUBST(BIBTEX2HTML_FLAGS)
112 ])
113
114
115 AC_DEFUN(STEPMAKE_BISON, [
116     # ugh, automake: we want (and check for) bison
117     AC_PROG_YACC
118     
119     STEPMAKE_PROGS(BISON, bison, $1)
120     
121     # urg.  should test functionality rather than version.
122     if test "$BISON" = "bison" -a -n "$2"; then
123         STEPMAKE_CHECK_VERSION(BISON, $1, $2)
124     fi
125 ])
126
127
128 AC_DEFUN(STEPMAKE_COMPILE, [
129     # -O is necessary to get inlining
130     CFLAGS=${CFLAGS-""}
131     CXXFLAGS=${CXXFLAGS-$CFLAGS}
132     LDFLAGS=${LDFLAGS-""}
133     checking_b=yes
134     optimise_b=yes
135     profile_b=no
136     debug_b=yes
137
138     AC_ARG_ENABLE(checking,
139     [  --enable-checking       set runtime checks (assert calls).  Default: on],
140     [checking_b=$enableval] )
141
142     AC_ARG_ENABLE(debugging,
143     [  --enable-debugging      compile with debugging info.  Default: on],
144     [debug_b=$enableval])
145
146     AC_ARG_ENABLE(optimising,
147     [  --enable-optimising      compile with optimising.  Default: on],
148     [optimise_b=$enableval])
149
150     AC_ARG_ENABLE(profiling, 
151     [  --enable-profiling      compile with gprof support.  Default: off],
152     [profile_b=$enableval])
153     
154
155     if test "$checking_b" = no; then
156         # ugh
157         AC_DEFINE(NDEBUG)
158         DEFINES="$DEFINES -DNDEBUG"
159     fi
160
161     if test "$optimise_b" = yes; then
162         OPTIMIZE="-O2 -finline-functions"
163     fi
164
165
166     if test $profile_b = yes; then
167         EXTRA_LIBES="-pg"
168         OPTIMIZE="$OPTIMIZE -pg"
169     fi
170
171     if test $debug_b = yes; then        
172         OPTIMIZE="$OPTIMIZE -g"
173     fi
174
175
176     AC_PROG_CC
177     STEPMAKE_OPTIONAL_REQUIRED(CC, cc, $1)
178     LD='$(CC)'
179     AC_SUBST(LD)
180
181     CFLAGS="$CFLAGS $OPTIMIZE"
182     CPPFLAGS=${CPPFLAGS-""}
183
184     AC_MSG_CHECKING([for IEEE-conformance compiler flags])
185     save_cflags="$CFLAGS"
186     case "$host" in
187         alpha*-*-*)
188             dnl should do compile test?
189             AC_MSG_RESULT(-mieee)
190             CFLAGS="-mieee $CFLAGS"
191             ;;
192         *)
193             AC_MSG_RESULT([none])
194             ;;
195     esac
196     AC_SUBST(cross_compiling)
197     AC_SUBST(CFLAGS)
198     AC_SUBST(CPPFLAGS)
199     AC_SUBST(LDFLAGS)
200     AC_SUBST(ICFLAGS)
201     AC_SUBST(ILDFLAGS)
202     AC_SUBST(DEFINES)
203     AC_SUBST(EXTRA_LIBES)
204 ])
205
206 AC_DEFUN(STEPMAKE_CXX, [
207     AC_LANG_CPLUSPLUS
208     AC_PROG_CXX
209     STEPMAKE_OPTIONAL_REQUIRED(CXX, c++, $1)
210
211     CPPFLAGS="$CPPFLAGS $DEFINES"
212     CXXFLAGS="$CXXFLAGS $OPTIMIZE"
213     LDFLAGS="$LDFLAGS $EXTRA_LIBES"
214
215     AC_SUBST(CXXFLAGS)
216     AC_SUBST(CXX)
217     LD='$(CXX)'
218     AC_SUBST(LD)
219 ])
220
221
222 AC_DEFUN(STEPMAKE_CXXTEMPLATE, [
223     AC_CACHE_CHECK([whether explicit instantiation is needed],
224         lily_cv_need_explicit_instantiation,
225         AC_TRY_LINK([
226     template <class T> struct foo { static int baz; };
227     template <class T> int foo<T>::baz = 1;
228     ], [ return foo<int>::baz; ],
229             lily_cv_need_explicit_instantiation=no,
230             lily_cv_need_explicit_instantiation=yes))
231     if test x"$lily_cv_need_explicit_instantiation"x = x"yes"x; then
232         AC_DEFINE(NEED_EXPLICIT_INSTANTIATION)
233     fi
234 ])
235
236
237 AC_DEFUN(STEPMAKE_DATADIR, [
238     if test "$datadir" = "\${prefix}/share"; then
239             datadir='${prefix}/share/'$package/$FULL_VERSION
240     fi
241     DIR_DATADIR=${datadir}
242     presome=${prefix}
243     if test "$prefix" = "NONE"; then
244             presome=${ac_default_prefix}
245     fi
246     DIR_DATADIR=`echo ${DIR_DATADIR} | sed "s!\\\${prefix}!$presome!"`
247
248     AC_SUBST(datadir)
249     AC_SUBST(DIR_DATADIR)
250
251     # we used to set DIR_SHAREDSTATEDIR here,
252     # but apparently that broke something
253     
254     AC_DEFINE_UNQUOTED(DIR_DATADIR, "${DIR_DATADIR}")
255 ])
256
257
258 AC_DEFUN(STEPMAKE_END, [
259     AC_SUBST(OPTIONAL)
260     AC_SUBST(REQUIRED)
261     
262     AC_OUTPUT($CONFIGFILE.make:config.make.in)
263
264     
265     if test -n "$OPTIONAL"; then
266         echo
267         echo "WARNING: Please consider installing optional programs: $OPTIONAL"
268     fi
269
270     if test -n "$REQUIRED"; then
271         echo
272         echo "ERROR: Please install required programs: $REQUIRED"
273     fi
274     
275     if test -n "$OPTIONAL$REQUIRED"; then
276         echo
277         echo "See INSTALL.txt for more information on how to build $PACKAGE_NAME"
278         echo "Remove config.cache before rerunning ./configure"
279     fi
280     
281     if test -n "$REQUIRED"; then
282         rm -f $srcdir/GNUmakefile
283         exit 1
284     fi
285
286     # regular in-place build
287     # test for srcdir_build = yes ?
288     if test "$builddir" = "."; then
289         rm -f $srcdir/GNUmakefile
290         cp $srcdir/GNUmakefile.in $srcdir/GNUmakefile
291         chmod 444 $srcdir/GNUmakefile
292     else # --srcdir build
293         rm -f GNUmakefile
294         cp $srcdir/make/srcdir.make.in GNUmakefile
295         chmod 444 GNUmakefile
296     fi
297 ])
298
299
300 AC_DEFUN(STEPMAKE_FLEX, [
301     # ugh, automake: we want (and check for) flex
302     # AC_PROG_LEX
303     # urg: automake 1.3: hope this doesn't break 1.2 ac_cv_pro_lex_root hack...
304
305     # AC_DECL_YYTEXT
306     # ugh, ugh
307     ac_cv_prog_lex_root=lex.yy
308     STEPMAKE_PROGS(FLEX, flex, $1)
309 ])
310
311
312 AC_DEFUN(STEPMAKE_FLEXLEXER, [
313     AC_HAVE_HEADERS(FlexLexer.h, true, false)
314     if test $? -ne 0; then
315         warn='FlexLexer.h (flex package)'
316         STEPMAKE_ADD_ENTRY($1, $warn)
317     fi
318 ])
319
320
321 AC_DEFUN(STEPMAKE_GCC, [
322     if test "$GCC" = "yes"; then
323         STEPMAKE_CHECK_VERSION(CC, $1, $2)
324     else
325         warn="$CC (Please install *GNU* cc)"
326         STEPMAKE_ADD_ENTRY($1, $warn)
327     fi
328 ])
329
330
331 AC_DEFUN(STEPMAKE_GETTEXT, [
332     DIR_LOCALEDIR=${localedir}
333     presome=${prefix}
334     if test "$prefix" = "NONE"; then
335             presome=${ac_default_prefix}
336     fi
337     DIR_LOCALEDIR=`echo ${DIR_LOCALEDIR} | sed "s!\\\${prefix}!$presome!"`
338     AC_SUBST(localedir)
339     AC_SUBST(DIR_LOCALEDIR)
340     AC_DEFINE_UNQUOTED(DIR_LOCALEDIR, "${DIR_LOCALEDIR}")
341
342     AC_CHECK_LIB(intl, gettext)
343     AC_CHECK_FUNCS(gettext)
344 ])
345
346
347 AC_DEFUN(STEPMAKE_GUILE, [
348     STEPMAKE_PATH_PROG(GUILE, guile, $1)
349 ])
350
351
352 #   STEPMAKE_GUILE_FLAGS --- set flags for compiling and linking with Guile
353 #
354 #   This macro runs the guile-config script, installed with Guile,
355 #   to find out where Guile's header files and libraries are
356 #   installed.  It sets two variables, marked for substitution, as
357 #   by AC_SUBST.
358 #   
359 #     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
360 #             code that uses Guile header files.  This is almost
361 #             always just a -I flag.
362 #   
363 #     GUILE_LDFLAGS --- flags to pass to the linker to link a
364 #             program against Guile.  This includes -lguile for
365 #             the Guile library itself, any libraries that Guile
366 #             itself requires (like -lqthreads), and so on.  It may
367 #             also include a -L flag to tell the compiler where to
368 #             find the libraries.
369
370 AC_DEFUN([STEPMAKE_GUILE_FLAGS], [
371     exe=`STEPMAKE_GET_EXECUTABLE($guile_config)`
372     if test -x $exe; then
373         AC_MSG_CHECKING("guile compile flags")
374         GUILE_CFLAGS="`$guile_config compile`"
375         AC_MSG_RESULT($GUILE_CFLAGS)
376         AC_MSG_CHECKING("guile link flags")
377         GUILE_LDFLAGS="`$guile_config link`"
378         AC_MSG_RESULT($GUILE_LDFLAGS)
379     fi
380     AC_SUBST(GUILE_CFLAGS)
381     AC_SUBST(GUILE_LDFLAGS)
382 ])
383
384
385 AC_DEFUN(STEPMAKE_GUILE_DEVEL, [
386     ## First, let's just see if we can find Guile at all.
387     AC_MSG_CHECKING("for guile-config")
388     for guile_config in guile-config $target-guile-config $build-guile-config; do
389         AC_MSG_RESULT("$guile_config")
390         if ! $guile_config --version > /dev/null 2>&1 ; then
391             AC_MSG_WARN("cannot execute $guile_config")
392             AC_MSG_CHECKING("if we are cross compiling")
393             GUILE_CONFIG='echo no guile-config'
394         else
395             GUILE_CONFIG=$guile_config
396             break
397         fi
398     done
399     STEPMAKE_OPTIONAL_REQUIRED(GUILE_CONFIG, $guile_config, $1)
400     if test $? -ne 0; then
401         STEPMAKE_ADD_ENTRY($1, 'guile-config (guile-devel, guile-dev or libguile-dev package)')
402     fi 
403
404     STEPMAKE_CHECK_SEARCH_RESULT(GUILE_CONFIG)
405     # urg.  should test functionality rather than version.
406     if test $? -eq 0 -a -n "$2"; then
407         STEPMAKE_CHECK_VERSION(GUILE_CONFIG, $1, $2)
408     fi
409
410     AC_SUBST(GUILE_CONFIG)
411     
412     guile_version="$ver"
413     changequote(<<, >>)dnl
414     GUILE_MAJOR_VERSION=`expr $guile_version : '\([0-9]*\)'`
415     GUILE_MINOR_VERSION=`expr $guile_version : '[0-9]*\.\([0-9]*\)'`
416     GUILE_PATCH_LEVEL=`expr $guile_version : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
417     changequote([, ])dnl
418     STEPMAKE_GUILE_FLAGS
419     AC_DEFINE_UNQUOTED(GUILE_MAJOR_VERSION, $GUILE_MAJOR_VERSION)
420     AC_DEFINE_UNQUOTED(GUILE_MINOR_VERSION, $GUILE_MINOR_VERSION)
421     AC_DEFINE_UNQUOTED(GUILE_PATCH_LEVEL, $GUILE_PATCH_LEVEL)
422 ])
423
424
425 AC_DEFUN(STEPMAKE_GXX, [
426     if test "$GXX" = "yes"; then
427         STEPMAKE_CHECK_VERSION(CXX, $1, $2)
428     else
429         warn="$CXX (Please install *GNU* c++)"
430         STEPMAKE_ADD_ENTRY($1, $warn)
431     fi
432 ])
433
434
435 AC_DEFUN(STEPMAKE_INIT, [
436
437     . $srcdir/VERSION
438     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
439     if test x$MY_PATCH_LEVEL != x; then
440         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
441     fi
442
443     # urg: don't "fix" this: irix doesn't know about [:lower:] and [:upper:]
444     changequote(<<, >>)dnl
445     PACKAGE=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'`
446     package=`echo $PACKAGE_NAME | tr '[A-Z]' '[a-z]'`
447     changequote([, ])dnl
448
449     # No versioning on directory names of sub-packages 
450     # urg, urg
451     stepmake=${datadir}/stepmake
452     presome=${prefix}
453     if test "$prefix" = "NONE"; then
454             presome=${ac_default_prefix}
455     fi
456     stepmake=`echo ${stepmake} | sed "s!\\\${prefix}!$presome!"`
457
458     # urg, how is this supposed to work?
459     if test "$program_prefix" = "NONE"; then
460           program_prefix=
461     fi
462     if test "$program_suffix" = "NONE"; then
463           program_suffix=
464     fi
465
466     AC_MSG_CHECKING(Package)
467     if test "x$PACKAGE" = "xSTEPMAKE"; then
468         AC_MSG_RESULT(Stepmake package!)
469
470         AC_MSG_CHECKING(builddir)
471         if test "$srcdir" = "."; then
472             builddir=.
473         else
474             absolute_builddir="`pwd`"
475             package_absolute_builddir="`dirname $absolute_builddir`"
476             package_srcdir="`dirname  $srcdir`"
477             builddir="`dirname $package_srcdir`/`basename $package_absolute_builddir`/`basename $absolute_builddir`"
478         fi
479         AC_MSG_RESULT($builddir)
480
481         (cd stepmake 2>/dev/null || mkdir stepmake)
482         (cd stepmake; rm -f bin; ln -s ../$srcdir/bin .)
483         AC_CONFIG_AUX_DIR(bin)
484         stepmake=stepmake
485     else
486         AC_MSG_RESULT($PACKAGE)
487
488         AC_MSG_CHECKING(builddir)
489         if test "$srcdir" = "."; then
490             builddir=.
491             srcdir_build=no
492         else
493             absolute_builddir="`pwd`"
494 #           builddir="`dirname  $srcdir`/`basename $absolute_builddir`"
495             builddir="`bash $srcdir/buildscripts/walk.sh \"$srcdir\"`"
496             srcdir_build=yes
497         fi
498         AC_MSG_RESULT($builddir)
499         if expr "$srcdir" : '/' > /dev/null 2>&1; then
500             absolute_srcdir=yes
501             STEPMAKE_WARN(Absolute --srcdir specified: $srcdir)
502         fi
503
504         AC_MSG_CHECKING(for stepmake)
505         # Check for installed stepmake
506         if test -d $stepmake; then
507             AC_MSG_RESULT($stepmake)
508         else
509             if test "$absolute_srcdir" != "yes"; then
510                 stepmake='$(depth)'/$srcdir/stepmake
511             else
512                 stepmake=$srcdir/stepmake
513             fi
514             AC_MSG_RESULT($srcdir/stepmake  ($datadir/stepmake not found))
515         fi
516
517         AC_CONFIG_AUX_DIR(\
518           $HOME/usr/local/share/stepmake/bin\
519           $HOME/usr/local/lib/stepmake/bin\
520           $HOME/usr/share/stepmake/bin\
521           $HOME/usr/lib/stepmake/bin\
522           /usr/local/share/stepmake/bin\
523           /usr/local/lib/stepmake/bin\
524           /usr/share/stepmake/bin\
525           /usr/lib/stepmake/bin\
526           stepmake/bin\
527           $srcdir/stepmake/bin\
528         )
529     fi
530
531     AC_SUBST(builddir)
532     AC_SUBST(stepmake)
533     AC_SUBST(package)
534     AC_SUBST(PACKAGE)
535     AC_SUBST(PACKAGE_NAME)
536     AC_DEFINE_UNQUOTED(PACKAGE, "${PACKAGE_NAME}")
537     AC_DEFINE_UNQUOTED(TOPLEVEL_VERSION, "${FULL_VERSION}")
538
539     if test "$package_depth" = "" ; then
540         package_depth="."
541     else
542         package_depth="../$package_depth"
543     fi
544     export package_depth
545     AC_SUBST(package_depth)
546
547     AUTOGENERATE="This file was automatically generated by configure"
548     AC_SUBST(AUTOGENERATE)
549
550     CONFIGSUFFIX=
551     AC_ARG_ENABLE(config,
552     [  --enable-config=CONF    put settings in config-CONF.make and config-CONF.h;
553                             do \`make conf=CONF' to get output in ./out-CONF],
554     [CONFIGURATION=$enableval])
555
556     ##'
557
558     test -n "$CONFIGURATION" && CONFIGSUFFIX="-$CONFIGURATION"
559     CONFIGFILE=config$CONFIGSUFFIX
560     AC_SUBST(CONFIGSUFFIX)
561      
562     AC_CANONICAL_HOST
563     STEPMAKE_PROGS(MAKE, gmake make, REQUIRED)
564     STEPMAKE_PROGS(FIND, find, REQUIRED)
565
566     STEPMAKE_PROGS(TAR, tar, REQUIRED)
567
568     if test "x`uname`" = "xHP-UX"; then
569         AC_PATH_PROG(BASH, bash, /bin/sh)
570         STEPMAKE_WARN(avoiding buggy /bin/sh)
571         AC_PATH_PROG(SHELL, bash, /bin/ksh)
572     else
573         AC_PATH_PROG(BASH, bash, /bin/sh)
574         SHELL=/bin/sh
575         AC_SUBST(SHELL)
576     fi
577
578     STEPMAKE_PATH_PROG(PYTHON, python, REQUIRED)
579
580     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
581         $MAKE -v 2> /dev/null | grep GNU > /dev/null
582         if test "$?" = 1; then
583             warn='make (Please install *GNU* make)'
584             # STEPMAKE_WARN($warn)
585             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
586         fi
587     fi 
588
589     if test "$OSTYPE" = "cygwin" -o "$OSTYPE" = "cygwin32" -o "$OSTYPE" = "Windows_NT"; then
590         LN=cp # hard link does not work under cygnus-nt
591         LN_S='cp -r' # symbolic link does not work for native nt
592         ZIP="zip -r -9" #
593         program_suffix=.exe
594         ROOTSEP=':'
595         DIRSEP='/'
596         PATHSEP=':'
597         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
598     else
599         ROOTSEP=':'
600         DIRSEP='/'
601         PATHSEP=':'
602         LN=ln
603         LN_S='ln -s'
604         ZIP="zip -r -9"
605         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-sh -c"
606     fi
607     AC_SUBST(program_prefix)
608     AC_SUBST(program_suffix)
609     AC_SUBST(ZIP)
610     AC_SUBST(LN)
611     AC_SUBST(LN_S)
612     AC_SUBST(INSTALL)
613     AC_DEFINE_UNQUOTED(DIRSEP, '${DIRSEP}')
614     AC_DEFINE_UNQUOTED(PATHSEP, '${PATHSEP}')
615     AC_SUBST(DIRSEP)
616     AC_SUBST(PATHSEP)
617     AC_SUBST(ROOTSEP)
618   
619     STEPMAKE_DATADIR
620 ])
621
622
623 AC_DEFUN(STEPMAKE_KPATHSEA, [
624
625     kpathsea_b=yes
626     #FIXME --with-xxx is meant for specifying a PATH too,
627     # so this should read: --enable-kpathsea,
628     # or --with-kpathsea-include=PATH --with-kpathsea-lib=PATH
629     AC_ARG_WITH(kpathsea,
630     [  --with-kpathsea         use kpathsea lib.  Default: on],
631     [kpathsea_b=$with_kpathsea])
632
633     if test "$kpathsea_b" != "no"; then 
634         AC_HAVE_HEADERS(kpathsea/kpathsea.h)
635         AC_CHECK_LIB(kpathsea, kpse_find_file)
636         AC_CHECK_FUNCS(kpse_find_file,, AC_ERROR(Cannot find kpathsea functions.  You should install kpathsea; see INSTALL.txt.  Rerun ./configure --without-kpathsea only if kpathsea is not available for your platform.))
637     fi
638     AC_MSG_CHECKING(whether to use kpathsea)
639     if test "$kpathsea_b" != no; then
640         AC_MSG_RESULT(yes)
641         KPATHSEA=1
642     else
643         AC_MSG_RESULT(no)
644         KPATHSEA=0
645     fi
646
647     AC_SUBST(KPATHSEA)
648     AC_DEFINE_UNQUOTED(KPATHSEA, $KPATHSEA)
649 ])
650
651
652 AC_DEFUN(STEPMAKE_LIB, [
653     STEPMAKE_PROGS(AR, ar, $1)
654     AC_PROG_RANLIB
655     STEPMAKE_OPTIONAL_REQUIRED(RANLIB, ranlib, $1)
656 ])
657
658
659 AC_DEFUN(STEPMAKE_LIBTOOL, [
660     # libtool.info ...
661     # **Never** try to set library version numbers so that they correspond
662     # to the release number of your package.  This is an abuse that only
663     # fosters misunderstanding of the purpose of library versions.
664
665     REVISION=$PATCH_LEVEL
666     # CURRENT=$MINOR_VERSION
667     CURRENT=`expr $MINOR_VERSION + 1`
668     # AGE=$(expr $MAJOR_VERSION + 1)
669     AGE=$MAJOR_VERSION
670     AC_SUBST(CURRENT)
671     AC_SUBST(REVISION)
672     AC_SUBST(AGE)
673 ])
674
675
676 AC_DEFUN(STEPMAKE_LOCALE, [
677     lang=English
678     ALL_LINGUAS="en nl"
679
680     # with/enable ??
681     AC_ARG_WITH(localedir,
682     [  --with-localedir=LOCALE use LOCALE as locale dir.  Default:
683                             PREFIX/share/locale ],
684     localedir=$with_localedir,
685     localedir='${prefix}/share/locale')
686
687     AC_ARG_WITH(lang,
688     [  --with-lang=LANG        use LANG as language to emit messages],
689     language=$with_lang,
690     language=English)
691
692     AC_MSG_CHECKING(language)    
693     case "$language" in
694       En* | en* | Am* | am* | US* | us*)
695             lang=English;;
696       NL | nl | Du* | du* | Ned* | ned*)
697             lang=Dutch;;
698       "")
699             lang=English;;
700       *)
701             lang=unknown;;
702     esac
703     AC_MSG_RESULT($lang)
704
705     if test "$lang" = "unknown" ; then
706         STEPMAKE_WARN($language not supported; available are: $ALL_LINGUAS)
707     fi
708
709 ])
710
711
712 AC_DEFUN(STEPMAKE_MAKEINFO, [
713     STEPMAKE_PROGS(MAKEINFO, makeinfo, $1)
714     if test "$MAKEINFO" = "makeinfo"; then
715         AC_MSG_CHECKING(whether makeinfo can split html by @node)
716         mkdir -p out
717         makeinfo --html --output=out/split <<EOF
718 \input texinfo
719 \input texinfo @c -*-texinfo-*-
720 @setfilename split.info
721 @settitle split.info
722 @bye
723 EOF
724         if test -d out/split; then
725             SPLITTING_MAKEINFO=yes
726             AC_MSG_RESULT(yes)
727             rm -rf out/split
728         else
729             AC_MSG_RESULT(no)
730             STEPMAKE_WARN(your html documentation will be one large file)
731             rm -rf out/split
732         fi
733     fi
734     AC_SUBST(SPLITTING_MAKEINFO)
735 ])
736
737
738
739 AC_DEFUN(STEPMAKE_MAN, [
740     STEPMAKE_PROGS(GROFF, groff ditroff, $1)
741     AC_SUBST(GROFF)
742     STEPMAKE_PROGS(TROFF, troff, $1)
743     AC_SUBST(TROFF)
744     STEPMAKE_PROGS(TBL, tbl, $1)
745     AC_SUBST(TBL)
746 ])
747
748
749 AC_DEFUN(STEPMAKE_MSGFMT, [
750     STEPMAKE_PROGS(MSGFMT, msgfmt, $1)
751 ])
752
753
754 # Check for program ($2), set full path result to ($1).
755 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
756 AC_DEFUN(STEPMAKE_PATH_PROG, [
757     AC_CHECK_PROGS($1, $2, no)
758     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
759     if test $? -eq 0; then
760         AC_PATH_PROG($1, $2)
761         if test -n "$4"; then
762             STEPMAKE_CHECK_VERSION($1, $3, $4)
763         fi
764     fi
765 ])
766
767
768 # Check for program in set of names ($2), set result to ($1) .
769 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
770 # If exists, and a minimal version ($4) is required
771 AC_DEFUN(STEPMAKE_PROGS, [
772     AC_CHECK_PROGS($1, $2, no)
773     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
774     if test $? -eq 0 -a -n "$4"; then
775         STEPMAKE_CHECK_VERSION($1, $3, $4)
776     fi
777 ])
778
779
780 AC_DEFUN(STEPMAKE_PERL, [
781     STEPMAKE_PATH_PROG(PERL, perl, $1)
782 ])
783
784
785 AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
786     AC_HAVE_HEADERS(python2.2/Python.h python2.1/Python.h python2.0/Python.h python2/Python.h python/Python.h python1.5/Python.h Python.h, PYTHON_HEADER=yes)
787     if test -z "$PYTHON_HEADER"; then
788         warn='python.h (python-devel, python-dev or libpython-dev package)'
789         STEPMAKE_ADD_ENTRY($1, $warn)
790     fi
791 ])
792
793
794 AC_DEFUN(STEPMAKE_TEXMF_DIRS, [
795     AC_ARG_ENABLE(tfm-path,
796     [  --enable-tfm-path=PATH  set path of tex directories where tfm files live,
797                             esp.: cmr10.tfm.  Default: use kpsewhich],
798     [tfm_path=$enableval],
799     [tfm_path=auto] )
800
801     # ugh
802     STEPMAKE_PROGS(KPSEWHICH, kpsewhich, OPTIONAL)
803     AC_MSG_CHECKING(for tfm path)
804
805     TFM_FONTS="cmr msam"
806
807     if test "x$tfm_path" = xauto ; then
808         if test "x$KPSEWHICH" != "xno" ; then
809             for i in $TFM_FONTS; do
810                 dir=`$KPSEWHICH tfm ${i}10.tfm`
811                 TFM_PATH="$TFM_PATH `dirname $dir`"
812             done
813         else
814             STEPMAKE_WARN(Please specify where cmr10.tfm lives:
815     ./configure --enable-tfm-path=/usr/local/TeX/lib/tex/fonts)
816         fi
817     else
818          TFM_PATH=$tfm_path
819     fi
820
821     TFM_PATH=`echo $TFM_PATH | tr ':' ' '`
822     AC_MSG_RESULT($TFM_PATH)
823     AC_SUBST(TFM_PATH)
824 ])
825
826
827 AC_DEFUN(STEPMAKE_TEXMF, [
828     # urg, never know what names these teTeX guys will think up
829
830     STEPMAKE_PROGS(METAFONT, mf mfont, $1)
831     STEPMAKE_PROGS(INIMETAFONT, inimf inimfont, $1)
832
833     AC_MSG_CHECKING(for working metafont mode)
834     modelist='ljfour lj4 lj3 lj2 ljet laserjet'
835     for MFMODE in $modelist; do
836         $METAFONT "\mode:=$MFMODE; mode_setup; end." > /dev/null 2>&1
837         if test -f mfput.tfm; then
838             break;
839         fi
840     done
841     AC_MSG_RESULT($MFMODE)
842
843     rm -f mfput.*
844
845     AC_SUBST(MFMODE)
846 ])
847
848
849 AC_DEFUN(STEPMAKE_WARN, [
850     AC_MSG_WARN($1)
851     warn_b=yes
852 ])
853
854