]> git.donarmstrong.com Git - lilypond.git/blob - stepmake/aclocal.m4
* config.make.in (prefix): Prepend $(DESTDIR) to allow install
[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 "%d\n", [$]1*1000000 + [$]2*1000 + 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'
240     fi
241     presome=${prefix}
242     if test "$prefix" = "NONE"; then
243         presome=${ac_default_prefix}
244     fi
245     
246     package_datadir=$datadir/$package
247     local_package_datadir=$package_datadir/$FULL_VERSION
248     build_package_datadir=$builddir/share/$package
249     
250     DATADIR=$(echo ${datadir} | sed "s!\\\${prefix}!$presome!")
251     PACKAGE_DATADIR=$(echo ${package_datadir} | sed "s!\\\${prefix}!$presome!")
252     LOCAL_PACKAGE_DATADIR=$(echo ${local_package_datadir} | sed "s!\\\${prefix}!$presome!")
253     BUILD_PACKAGE_DATADIR=$(echo ${build_package_datadir} | sed "s!\\\${prefix}!$presome!")
254     
255     AC_SUBST(datadir)
256     AC_SUBST(package_datadir)
257     AC_SUBST(local_package_datadir)
258     AC_SUBST(build_package_datadir)
259     AC_DEFINE_UNQUOTED(DATADIR, "${DATADIR}")
260     AC_DEFINE_UNQUOTED(PACKAGE_DATADIR, "${PACKAGE_DATADIR}")
261     AC_DEFINE_UNQUOTED(LOCAL_PACKAGE_DATADIR, "${LOCAL_PACKAGE_DATADIR}")
262     AC_DEFINE_UNQUOTED(BUILD_PACKAGE_DATADIR, "${BUILD_PACKAGE_DATADIR}")
263 ])
264
265
266 AC_DEFUN(STEPMAKE_END, [
267     AC_SUBST(OPTIONAL)
268     AC_SUBST(REQUIRED)
269     
270     AC_OUTPUT($CONFIGFILE.make:config.make.in)
271
272     
273     if test -n "$OPTIONAL"; then
274         echo
275         echo "WARNING: Please consider installing optional programs: $OPTIONAL"
276     fi
277
278     if test -n "$REQUIRED"; then
279         echo
280         echo "ERROR: Please install required programs: $REQUIRED"
281     fi
282     
283     if test -n "$OPTIONAL$REQUIRED"; then
284         echo
285         echo "See INSTALL.txt for more information on how to build $PACKAGE_NAME"
286         echo "Remove config.cache before rerunning ./configure"
287     fi
288     
289     if test -n "$REQUIRED"; then
290         rm -f $srcdir/GNUmakefile
291         exit 1
292     fi
293
294     # regular in-place build
295     # test for srcdir_build = yes ?
296     if test "$srcdir_build" = "yes"; then
297         rm -f $srcdir/GNUmakefile
298         cp $srcdir/GNUmakefile.in $srcdir/GNUmakefile
299         chmod 444 $srcdir/GNUmakefile
300     else # --srcdir build
301         rm -f GNUmakefile
302         cp $srcdir/make/srcdir.make.in GNUmakefile
303         chmod 444 GNUmakefile
304     fi
305 ])
306
307
308 AC_DEFUN(STEPMAKE_FLEX, [
309     # ugh, automake: we want (and check for) flex
310     # AC_PROG_LEX
311     # urg: automake 1.3: hope this doesn't break 1.2 ac_cv_pro_lex_root hack...
312
313     # AC_DECL_YYTEXT
314     # ugh, ugh
315     ac_cv_prog_lex_root=lex.yy
316     STEPMAKE_PROGS(FLEX, flex, $1)
317 ])
318
319
320 AC_DEFUN(STEPMAKE_FLEXLEXER, [
321     AC_HAVE_HEADERS(FlexLexer.h, true, false)
322     if test $? -ne 0; then
323         warn='FlexLexer.h (flex package)'
324         STEPMAKE_ADD_ENTRY($1, $warn)
325     fi
326 ])
327
328
329 AC_DEFUN(STEPMAKE_GCC, [
330     if test "$GCC" = "yes"; then
331         STEPMAKE_CHECK_VERSION(CC, $1, $2)
332     else
333         warn="$CC (Please install *GNU* cc)"
334         STEPMAKE_ADD_ENTRY($1, $warn)
335     fi
336 ])
337
338
339 AC_DEFUN(STEPMAKE_GETTEXT, [
340     presome=${prefix}
341     if test "$prefix" = "NONE"; then
342             presome=${ac_default_prefix}
343     fi
344     LOCALEDIR=$(echo ${localedir} | sed "s!\\\${prefix}!$presome!")
345     
346     AC_SUBST(localedir)
347     AC_DEFINE_UNQUOTED(LOCALEDIR, "${LOCALEDIR}")
348     AC_CHECK_LIB(intl, gettext)
349     AC_CHECK_FUNCS(gettext)
350 ])
351
352
353 AC_DEFUN(STEPMAKE_GUILE, [
354     STEPMAKE_PATH_PROG(GUILE, guile, $1)
355 ])
356
357
358 #   STEPMAKE_GUILE_FLAGS --- set flags for compiling and linking with Guile
359 #
360 #   This macro runs the guile-config script, installed with Guile,
361 #   to find out where Guile's header files and libraries are
362 #   installed.  It sets two variables, marked for substitution, as
363 #   by AC_SUBST.
364 #   
365 #     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
366 #             code that uses Guile header files.  This is almost
367 #             always just a -I flag.
368 #   
369 #     GUILE_LDFLAGS --- flags to pass to the linker to link a
370 #             program against Guile.  This includes -lguile for
371 #             the Guile library itself, any libraries that Guile
372 #             itself requires (like -lqthreads), and so on.  It may
373 #             also include a -L flag to tell the compiler where to
374 #             find the libraries.
375
376 AC_DEFUN([STEPMAKE_GUILE_FLAGS], [
377     exe=`STEPMAKE_GET_EXECUTABLE($guile_config)`
378     if test -x $exe; then
379         AC_MSG_CHECKING("guile compile flags")
380         GUILE_CFLAGS="`$guile_config compile`"
381         AC_MSG_RESULT($GUILE_CFLAGS)
382         AC_MSG_CHECKING("guile link flags")
383         GUILE_LDFLAGS="`$guile_config link`"
384         AC_MSG_RESULT($GUILE_LDFLAGS)
385     fi
386     AC_SUBST(GUILE_CFLAGS)
387     AC_SUBST(GUILE_LDFLAGS)
388 ])
389
390
391 AC_DEFUN(STEPMAKE_GUILE_DEVEL, [
392     ## First, let's just see if we can find Guile at all.
393     AC_MSG_CHECKING("for guile-config")
394     for guile_config in guile-config $target-guile-config $build-guile-config; do
395         AC_MSG_RESULT("$guile_config")
396         if ! $guile_config --version > /dev/null 2>&1 ; then
397             AC_MSG_WARN("cannot execute $guile_config")
398             AC_MSG_CHECKING("if we are cross compiling")
399             GUILE_CONFIG='echo no guile-config'
400         else
401             GUILE_CONFIG=$guile_config
402             break
403         fi
404     done
405     STEPMAKE_OPTIONAL_REQUIRED(GUILE_CONFIG, $guile_config, $1)
406     if test $? -ne 0; then
407         STEPMAKE_ADD_ENTRY($1, 'guile-config (guile-devel, guile-dev or libguile-dev package)')
408     fi 
409
410     STEPMAKE_CHECK_SEARCH_RESULT(GUILE_CONFIG)
411     # urg.  should test functionality rather than version.
412     if test $? -eq 0 -a -n "$2"; then
413         STEPMAKE_CHECK_VERSION(GUILE_CONFIG, $1, $2)
414     fi
415
416     AC_SUBST(GUILE_CONFIG)
417     
418     guile_version="$ver"
419     changequote(<<, >>)dnl
420     GUILE_MAJOR_VERSION=`expr $guile_version : '\([0-9]*\)'`
421     GUILE_MINOR_VERSION=`expr $guile_version : '[0-9]*\.\([0-9]*\)'`
422     GUILE_PATCH_LEVEL=`expr $guile_version : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
423     changequote([, ])dnl
424     STEPMAKE_GUILE_FLAGS
425     AC_DEFINE_UNQUOTED(GUILE_MAJOR_VERSION, $GUILE_MAJOR_VERSION)
426     AC_DEFINE_UNQUOTED(GUILE_MINOR_VERSION, $GUILE_MINOR_VERSION)
427     AC_DEFINE_UNQUOTED(GUILE_PATCH_LEVEL, $GUILE_PATCH_LEVEL)
428 ])
429
430
431 AC_DEFUN(STEPMAKE_GXX, [
432     if test "$GXX" = "yes"; then
433         STEPMAKE_CHECK_VERSION(CXX, $1, $2)
434     else
435         warn="$CXX (Please install *GNU* c++)"
436         STEPMAKE_ADD_ENTRY($1, $warn)
437     fi
438 ])
439
440
441 AC_DEFUN(STEPMAKE_INIT, [
442
443     . $srcdir/VERSION
444     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
445     if test x$MY_PATCH_LEVEL != x; then
446         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
447     fi
448
449     # urg: don't "fix" this: irix doesn't know about [:lower:] and [:upper:]
450     changequote(<<, >>)dnl
451     PACKAGE=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'`
452     package=`echo $PACKAGE_NAME | tr '[A-Z]' '[a-z]'`
453     changequote([, ])dnl
454
455     # No versioning on directory names of sub-packages 
456     # urg, urg
457     stepmake=${datadir}/stepmake
458     presome=${prefix}
459     if test "$prefix" = "NONE"; then
460             presome=${ac_default_prefix}
461     fi
462     stepmake=`echo ${stepmake} | sed "s!\\\${prefix}!$presome!"`
463
464     # urg, how is this supposed to work?
465     if test "$program_prefix" = "NONE"; then
466           program_prefix=
467     fi
468     if test "$program_suffix" = "NONE"; then
469           program_suffix=
470     fi
471
472     AC_MSG_CHECKING(Package)
473     if test "$PACKAGE" = "STEPMAKE"; then
474         AC_MSG_RESULT(Stepmake package!)
475
476         AC_MSG_CHECKING(builddir)
477         builddir="`pwd`"
478         if test "$srcdir" = "."; then
479             srcdir_build=yes
480         else
481             srcdir_build=no
482             package_builddir="`dirname $builddir`"
483             package_srcdir="`dirname  $srcdir`"
484         fi
485         AC_MSG_RESULT($builddir)
486
487         (cd stepmake 2>/dev/null || mkdir stepmake)
488         (cd stepmake; rm -f bin; ln -s ../$srcdir/bin .)
489         AC_CONFIG_AUX_DIR(bin)
490         stepmake=stepmake
491     else
492         AC_MSG_RESULT($PACKAGE)
493
494         AC_MSG_CHECKING(builddir)
495         builddir="`pwd`"
496         if test "$srcdir" = "."; then
497             srcdir_build=yes
498         else
499             srcdir_build=no
500         fi
501         AC_MSG_RESULT($builddir)
502
503         AC_MSG_CHECKING(for stepmake)
504         # Check for installed stepmake
505         if test -d $stepmake; then
506             AC_MSG_RESULT($stepmake)
507         else
508             stepmake="`cd $srcdir/stepmake; pwd`"
509             AC_MSG_RESULT($srcdir/stepmake  ($datadir/stepmake not found))
510         fi
511
512         AC_CONFIG_AUX_DIR(\
513           $HOME/usr/local/share/stepmake/bin\
514           $HOME/usr/local/lib/stepmake/bin\
515           $HOME/usr/share/stepmake/bin\
516           $HOME/usr/lib/stepmake/bin\
517           /usr/local/share/stepmake/bin\
518           /usr/local/lib/stepmake/bin\
519           /usr/share/stepmake/bin\
520           /usr/lib/stepmake/bin\
521           stepmake/bin\
522           $srcdir/stepmake/bin\
523         )
524     fi
525
526     AC_SUBST(builddir)
527     AC_SUBST(stepmake)
528     AC_SUBST(package)
529     AC_SUBST(PACKAGE)
530     AC_SUBST(PACKAGE_NAME)
531     AC_DEFINE_UNQUOTED(PACKAGE, "${PACKAGE_NAME}")
532     AC_DEFINE_UNQUOTED(TOPLEVEL_VERSION, "${FULL_VERSION}")
533
534     if test -z "$package_depth"; then
535         package_depth="."
536     else
537         package_depth="../$package_depth"
538     fi
539     export package_depth
540     AC_SUBST(package_depth)
541
542     AUTOGENERATE="This file was automatically generated by configure"
543     AC_SUBST(AUTOGENERATE)
544
545     CONFIGSUFFIX=
546     AC_ARG_ENABLE(config,
547     [  --enable-config=CONF    put settings in config-CONF.make and config-CONF.h;
548                             do \`make conf=CONF' to get output in ./out-CONF],
549     [CONFIGURATION=$enableval])
550
551     ##'
552
553     test -n "$CONFIGURATION" && CONFIGSUFFIX="-$CONFIGURATION"
554     CONFIGFILE=config$CONFIGSUFFIX
555     AC_SUBST(CONFIGSUFFIX)
556      
557     AC_CANONICAL_HOST
558     STEPMAKE_PROGS(MAKE, gmake make, REQUIRED)
559     STEPMAKE_PROGS(FIND, find, REQUIRED)
560
561     STEPMAKE_PROGS(TAR, tar, REQUIRED)
562
563     if test "x`uname`" = "xHP-UX"; then
564         AC_PATH_PROG(BASH, bash, /bin/sh)
565         STEPMAKE_WARN(avoiding buggy /bin/sh)
566         AC_PATH_PROG(SHELL, bash, /bin/ksh)
567     else
568         AC_PATH_PROG(BASH, bash, /bin/sh)
569         SHELL=/bin/sh
570         AC_SUBST(SHELL)
571     fi
572
573     STEPMAKE_PATH_PROG(PYTHON, python, REQUIRED)
574
575     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
576         $MAKE -v 2> /dev/null | grep GNU > /dev/null
577         if test "$?" = 1; then
578             warn='make (Please install *GNU* make)'
579             # STEPMAKE_WARN($warn)
580             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
581         fi
582     fi 
583
584     if test "$OSTYPE" = "cygwin" -o "$OSTYPE" = "cygwin32" -o "$OSTYPE" = "Windows_NT"; then
585         LN=cp # hard link does not work under cygnus-nt
586         LN_S='cp -r' # symbolic link does not work for native nt
587         ZIP="zip -r -9" #
588         program_suffix=.exe
589         ROOTSEP=':'
590         DIRSEP='/'
591         PATHSEP=':'
592         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
593     else
594         ROOTSEP=':'
595         DIRSEP='/'
596         PATHSEP=':'
597         LN=ln
598         LN_S='ln -s'
599         ZIP="zip -r -9"
600         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-sh -c"
601     fi
602     AC_SUBST(program_prefix)
603     AC_SUBST(program_suffix)
604     AC_SUBST(ZIP)
605     AC_SUBST(LN)
606     AC_SUBST(LN_S)
607     AC_SUBST(INSTALL)
608     AC_DEFINE_UNQUOTED(DIRSEP, '${DIRSEP}')
609     AC_DEFINE_UNQUOTED(PATHSEP, '${PATHSEP}')
610     AC_SUBST(DIRSEP)
611     AC_SUBST(PATHSEP)
612     AC_SUBST(ROOTSEP)
613   
614     STEPMAKE_DATADIR
615 ])
616
617     
618 AC_DEFUN(STEPMAKE_KPATHSEA, [
619         
620     AC_ARG_WITH(kpathsea-include,
621         [  --with-kpathsea-include=DIR
622                           location of the kpathsea include dir],[
623             if test "$withval" = "yes" -o "$withval" = "no"; then
624                 AC_MSG_WARN(Usage: --with-kpathsea-include=includedir)
625             else
626                 CPPFLAGS="$CPPFLAGS -I${withval}"
627             fi
628             ])
629     
630     AC_ARG_WITH(kpathsea-lib,
631         [  --with-kpathsea-lib=DIR location of the kpathsea lib dir],[
632             if test "$withval" = "yes" -o "$withval" = "no"; then
633                 AC_MSG_WARN(Usage: --with-kpathsea-lib=libdir)
634             else
635                 LDFLAGS="$LDFLAGS -L${withval}"
636             fi
637             ])
638     
639     kpathsea_b=yes
640     #FIXME --with-xxx is meant for specifying a PATH too,
641     # so this should read: --enable-kpathsea,
642     # or --with-kpathsea-include=PATH --with-kpathsea-lib=PATH
643     AC_ARG_WITH(kpathsea,
644     [  --with-kpathsea         use kpathsea lib.  Default: on],
645     [kpathsea_b=$with_kpathsea])
646
647     if test "$kpathsea_b" != "no"; then 
648         AC_HAVE_HEADERS(kpathsea/kpathsea.h)
649         AC_CHECK_LIB(kpathsea, kpse_find_file)
650         AC_CHECK_FUNCS(kpse_find_file,,kpathsea_b=no)
651         if test "$kpathsea_b" = "no"; then
652             warn='kpathsea (libkpathsea-dev or kpathsea-devel package)
653    Else, please specify the location of your kpathsea using
654    --with-kpathea-include and --with-kpathsea-lib options.  You should
655    install kpathsea; see INSTALL.txt.  Rerun ./configure
656    --without-kpathsea only if kpathsea is not available for your
657    platform.'
658             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
659         fi
660     fi
661     AC_MSG_CHECKING(whether to use kpathsea)
662     if test "$kpathsea_b" != no; then
663         AC_MSG_RESULT(yes)
664         KPATHSEA=1
665     else
666         AC_MSG_RESULT(no)
667         KPATHSEA=0
668     fi
669
670     AC_SUBST(KPATHSEA)
671     AC_DEFINE_UNQUOTED(KPATHSEA, $KPATHSEA)
672 ])
673
674
675 AC_DEFUN(STEPMAKE_LIB, [
676     STEPMAKE_PROGS(AR, ar, $1)
677     AC_PROG_RANLIB
678     STEPMAKE_OPTIONAL_REQUIRED(RANLIB, ranlib, $1)
679 ])
680
681
682 AC_DEFUN(STEPMAKE_LIBTOOL, [
683     # libtool.info ...
684     # **Never** try to set library version numbers so that they correspond
685     # to the release number of your package.  This is an abuse that only
686     # fosters misunderstanding of the purpose of library versions.
687
688     REVISION=$PATCH_LEVEL
689     # CURRENT=$MINOR_VERSION
690     CURRENT=`expr $MINOR_VERSION + 1`
691     # AGE=$(expr $MAJOR_VERSION + 1)
692     AGE=$MAJOR_VERSION
693     AC_SUBST(CURRENT)
694     AC_SUBST(REVISION)
695     AC_SUBST(AGE)
696 ])
697
698
699 AC_DEFUN(STEPMAKE_LOCALE, [
700     lang=English
701     ALL_LINGUAS="en nl"
702
703     # with/enable ??
704     AC_ARG_WITH(localedir,
705     [  --with-localedir=LOCALE use LOCALE as locale dir.  Default:
706                             PREFIX/share/locale ],
707     localedir=$with_localedir,
708     localedir='${prefix}/share/locale')
709
710     AC_ARG_WITH(lang,
711     [  --with-lang=LANG        use LANG as language to emit messages],
712     language=$with_lang,
713     language=English)
714
715     AC_MSG_CHECKING(language)    
716     case "$language" in
717       En* | en* | Am* | am* | US* | us*)
718             lang=English;;
719       NL | nl | Du* | du* | Ned* | ned*)
720             lang=Dutch;;
721       "")
722             lang=English;;
723       *)
724             lang=unknown;;
725     esac
726     AC_MSG_RESULT($lang)
727
728     if test "$lang" = "unknown" ; then
729         STEPMAKE_WARN($language not supported; available are: $ALL_LINGUAS)
730     fi
731
732 ])
733
734
735 AC_DEFUN(STEPMAKE_MAKEINFO, [
736     STEPMAKE_PROGS(MAKEINFO, makeinfo, $1)
737     if test "$MAKEINFO" = "makeinfo"; then
738         AC_MSG_CHECKING(whether makeinfo can split html by @node)
739         mkdir -p out
740         makeinfo --html --output=out/split <<EOF
741 \input texinfo
742 \input texinfo @c -*-texinfo-*-
743 @setfilename split.info
744 @settitle split.info
745 @bye
746 EOF
747         if test -d out/split; then
748             SPLITTING_MAKEINFO=yes
749             AC_MSG_RESULT(yes)
750             rm -rf out/split
751         else
752             AC_MSG_RESULT(no)
753             STEPMAKE_WARN(your html documentation will be one large file)
754             rm -rf out/split
755         fi
756     fi
757     AC_SUBST(SPLITTING_MAKEINFO)
758 ])
759
760
761
762 AC_DEFUN(STEPMAKE_MAN, [
763     STEPMAKE_PROGS(GROFF, groff ditroff, $1)
764     AC_SUBST(GROFF)
765     STEPMAKE_PROGS(TROFF, troff, $1)
766     AC_SUBST(TROFF)
767     STEPMAKE_PROGS(TBL, tbl, $1)
768     AC_SUBST(TBL)
769 ])
770
771
772 AC_DEFUN(STEPMAKE_MSGFMT, [
773     STEPMAKE_PROGS(MSGFMT, msgfmt, $1)
774 ])
775
776
777 # Check for program ($2), set full path result to ($1).
778 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
779 AC_DEFUN(STEPMAKE_PATH_PROG, [
780     AC_CHECK_PROGS($1, $2, no)
781     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
782     if test $? -eq 0; then
783         AC_PATH_PROG($1, $2)
784         if test -n "$4"; then
785             STEPMAKE_CHECK_VERSION($1, $3, $4)
786         fi
787     fi
788 ])
789
790
791 # Check for program in set of names ($2), set result to ($1) .
792 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
793 # If exists, and a minimal version ($4) is required
794 AC_DEFUN(STEPMAKE_PROGS, [
795     AC_CHECK_PROGS($1, $2, no)
796     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
797     if test $? -eq 0 -a -n "$4"; then
798         STEPMAKE_CHECK_VERSION($1, $3, $4)
799     fi
800 ])
801
802
803 AC_DEFUN(STEPMAKE_PERL, [
804     STEPMAKE_PATH_PROG(PERL, perl, $1)
805 ])
806
807
808 AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
809     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)
810     if test -z "$PYTHON_HEADER"; then
811         warn='python.h (python-devel, python-dev or libpython-dev package)'
812         STEPMAKE_ADD_ENTRY($1, $warn)
813     fi
814 ])
815
816
817 AC_DEFUN(STEPMAKE_TEXMF_DIRS, [
818     AC_ARG_ENABLE(tfm-path,
819     [  --enable-tfm-path=PATH  set path of tex directories where tfm files live,
820                             esp.: cmr10.tfm.  Default: use kpsewhich],
821     [tfm_path=$enableval],
822     [tfm_path=auto] )
823
824     # ugh
825     STEPMAKE_PROGS(KPSEWHICH, kpsewhich, OPTIONAL)
826     AC_MSG_CHECKING(for tfm path)
827
828     TFM_FONTS="cmr msam"
829
830     if test "x$tfm_path" = xauto ; then
831         if test "x$KPSEWHICH" != "xno" ; then
832             for i in $TFM_FONTS; do
833                 dir=`$KPSEWHICH tfm ${i}10.tfm`
834                 TFM_PATH="$TFM_PATH `dirname $dir`"
835             done
836         else
837             STEPMAKE_WARN(Please specify where cmr10.tfm lives:
838     ./configure --enable-tfm-path=/usr/local/TeX/lib/tex/fonts)
839         fi
840     else
841          TFM_PATH=$tfm_path
842     fi
843
844     TFM_PATH=`echo $TFM_PATH | tr ':' ' '`
845     AC_MSG_RESULT($TFM_PATH)
846     AC_SUBST(TFM_PATH)
847 ])
848
849
850 AC_DEFUN(STEPMAKE_TEXMF, [
851     # urg, never know what names these teTeX guys will think up
852
853     STEPMAKE_PROGS(METAFONT, mf mfont, $1)
854     STEPMAKE_PROGS(INIMETAFONT, inimf inimfont, $1)
855
856     AC_MSG_CHECKING(for working metafont mode)
857     modelist='ljfour lj4 lj3 lj2 ljet laserjet'
858     for MFMODE in $modelist; do
859         $METAFONT "\mode:=$MFMODE; mode_setup; end." > /dev/null 2>&1
860         if test -f mfput.tfm; then
861             break;
862         fi
863     done
864     AC_MSG_RESULT($MFMODE)
865
866     rm -f mfput.*
867
868     AC_SUBST(MFMODE)
869 ])
870
871
872 AC_DEFUN(STEPMAKE_WARN, [
873     AC_MSG_WARN($1)
874     warn_b=yes
875 ])
876
877