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