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