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