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