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