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