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