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