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