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