]> git.donarmstrong.com Git - lilypond.git/blob - stepmake/aclocal.m4
patch::: 1.1.35.jcn1: ps fixes -- huh?
[lilypond.git] / stepmake / aclocal.m4
1 dnl aclocal.m4   -*-shell-script-*-
2 dnl StepMake subroutines for configure.in
3
4 AC_DEFUN(AC_STEPMAKE_COMPILE, [
5     # -O is necessary to get inlining
6     OPTIMIZE=""
7     CXXFLAGS=${CXXFLAGS:-""}
8     CFLAGS=${CFLAGS:-""}
9     checking_b=yes
10     optimise_b=no
11     profile_b=no
12     debug_b=yes
13
14     AC_ARG_ENABLE(checking,
15     [  enable-checking         set runtime checks (assert calls). Default: on],
16     [checking_b=$enableval] )
17
18     # actually, the default is: tja='-O' to get inlining...
19     # off=''  --jcn
20
21     #actually, that sucks.
22     #  tja looks like a typo.  Default is optimisation off. --hwn
23     
24     AC_ARG_ENABLE(optimise,
25     [  enable-optimise         use maximal speed optimisations. Default: off],
26     [optimise_b=$enableval])
27     
28     AC_ARG_ENABLE(profiling, 
29     [  enable-profiling        compile with gprof support. Default: off],
30     [profile_b=$enableval])
31     
32     AC_ARG_ENABLE(debugging,
33     [  enable-debugging        set debug info. Default: on],
34     [debug_b=$enableval])
35
36     AC_ARG_ENABLE(mingw-prefix,
37     [  enable-mingw-prefix=DIR set the mingw32 directory (standalone windows32 exes)],
38     [MINGWPREFIX=$enableval],
39     [MINGWPREFIX=no])
40
41     if test "$printing_b" = no; then
42         # ugh
43         AC_DEFINE(NPRINT)
44         DEFINES="$DEFINES -DNPRINT"
45     fi
46         
47     if test "$checking_b" = no; then
48         # ugh
49         AC_DEFINE(NDEBUG)
50         DEFINES="$DEFINES -DNDEBUG"
51     fi
52
53     if test "$optimise_b" = yes; then
54         OPTIMIZE="-O2 -finline-functions"
55     fi
56
57     if test "$optimise_b" = no; then
58         OPTIMIZE=""
59     fi
60
61     if test $profile_b = yes; then
62         EXTRA_LIBES="-pg"
63         OPTIMIZE="$OPTIMIZE -pg"
64     fi
65
66     if test $debug_b = yes; then        
67         OPTIMIZE="$OPTIMIZE -g"
68     fi
69
70     # however, C++ support in mingw32 v 0.1.4 is still flaky
71     if test x$MINGWPREFIX != xno; then 
72         ICFLAGS="-I$MINGWPREFIX/include"
73         ILDFLAGS="-$MINGWPREFIX/lib"
74     fi
75
76     AC_PROG_CC
77     LD='$(CC)'
78     AC_SUBST(LD)
79
80     CFLAGS="$CFLAGS $OPTIMIZE"
81     CPPFLAGS=${CPPFLAGS:-""}
82     AC_SUBST(CFLAGS)
83     AC_SUBST(CPPFLAGS)
84     AC_SUBST(LDFLAGS)
85     AC_SUBST(ICFLAGS)
86     AC_SUBST(ILDFLAGS)
87     AC_SUBST(DEFINES)
88     AC_SUBST(EXTRA_LIBES)
89 ])
90
91 AC_DEFUN(AC_STEPMAKE_CXX, [
92     AC_LANG_CPLUSPLUS
93     AC_PROG_CXX
94
95     AC_CHECK_HEADER(FlexLexer.h, true,
96         AC_STEPMAKE_WARN(can"\'"t find flex header. Please install Flex headers correctly))
97
98     CPPFLAGS="$CPPFLAGS $DEFINES"
99     CXXFLAGS="$CXXFLAGS $OPTIMIZE"
100     LDFLAGS=$EXTRA_LIBES
101
102     AC_SUBST(CXXFLAGS)
103     AC_SUBST(CXX)
104     LD='$(CXX)'
105     AC_SUBST(LD)
106 ])
107
108 AC_DEFUN(AC_STEPMAKE_CXXTEMPLATE, [
109     AC_CACHE_CHECK([whether explicit instantiation is needed],
110         lily_cv_need_explicit_instantiation,
111         AC_TRY_LINK([
112     template <class T> struct foo { static int baz; };
113     template <class T> int foo<T>::baz = 1;
114     ], [ return foo<int>::baz; ],
115             lily_cv_need_explicit_instantiation=no,
116             lily_cv_need_explicit_instantiation=yes))
117     if test x"$lily_cv_need_explicit_instantiation"x = x"yes"x; then
118         AC_DEFINE(NEED_EXPLICIT_INSTANTIATION)
119     fi
120 ])
121
122 AC_DEFUN(AC_STEPMAKE_DATADIR, [
123     if test "$datadir" = "\${prefix}/share"; then
124             datadir='${prefix}/share/'$package
125     fi
126     DIR_DATADIR=${datadir}
127     presome=${prefix}
128     if test "$prefix" = "NONE"; then
129             presome=${ac_default_prefix}
130     fi
131     DIR_DATADIR=`echo ${DIR_DATADIR} | sed "s!\\\${prefix}!$presome!"`
132     AC_SUBST(datadir)
133     AC_SUBST(DIR_DATADIR)
134     AC_DEFINE_UNQUOTED(DIR_DATADIR, "${DIR_DATADIR}")
135 ])
136
137 AC_DEFUN(AC_STEPMAKE_END, [
138     AC_OUTPUT($CONFIGFILE.make:config.make.in)
139
140     rm -f GNUmakefile
141     cp make/toplevel.make.in ./GNUmakefile
142     chmod 444 GNUmakefile
143 ])
144
145 AC_DEFUN(AC_STEPMAKE_GXX, [
146     # ugh autoconf
147     # urg, egcs: how to check for egcs >= 1.1?
148     changequote(<<, >>)dnl
149     if $CXX --version | grep '2\.8' > /dev/null ||
150         $CXX --version | grep 'egcs' > /dev/null
151     changequote([, ])dnl
152     then
153             true
154     else
155             AC_STEPMAKE_WARN(can\'t find g++ 2.8 or egcs 1.1)
156     fi
157 ])
158
159 AC_DEFUN(AC_STEPMAKE_GUILE, [
160     # on some systems, -lguile succeeds for guile-1.3
161     # others need readline, dl (or even more)
162     # urg, must check for different functions in libguile
163     # to force new check iso reading from cache
164
165     # gh_scm2doubles,gh_doubles2scm are new in 1.3
166     GUILE_FLAGS
167     AC_CHECK_LIB(guile, gh_scm2doubles,
168       [LIBS="`echo $GUILE_LDFLAGS | sed -e 's/-L[[/-_a-zA-Z0-9]]\+ //g'` $LIBS"
169       AC_DEFINE(HAVE_LIBGUILE)], , $GUILE_LDFLAGS dnl
170     )
171     if test "$ac_cv_lib_guile_gh_scm2doubles" != yes ; then
172         AC_STEPMAKE_WARN(You should install guile 1.3 or newer)
173     fi
174 ])
175
176 AC_DEFUN(AC_STEPMAKE_INIT, [
177
178     . $srcdir/VERSION
179     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
180     if test x$MY_PATCH_LEVEL != x; then
181         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
182     fi
183
184     # urg: don't "fix" this: irix doesn't know about [:lower:] and [:upper:]
185     changequote(<<, >>)dnl
186     PACKAGE=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'`
187     package=`echo $PACKAGE_NAME | tr '[A-Z]' '[a-z]'`
188     changequote([, ])dnl
189
190     # No versioning on directory names of sub-packages 
191     # urg, urg
192     stepmake=${datadir}/stepmake
193     presome=${prefix}
194     if test "$prefix" = "NONE"; then
195             presome=${ac_default_prefix}
196     fi
197     stepmake=`echo ${stepmake} | sed "s!\\\${prefix}!$presome!"`
198
199     if test "x$PACKAGE" = "xSTEPMAKE"; then
200         echo Stepmake package!
201         (cd stepmake; rm -f stepmake; ln -s ../stepmake .)
202         (cd stepmake; rm -f bin; ln -s ../bin .)
203         AC_CONFIG_AUX_DIR(bin)
204         stepmake=stepmake
205     else
206         echo Package: $PACKAGE
207         # Check for installed stepmake
208         if test -d $stepmake; then
209             echo Using installed stepmake: $stepmake
210         else
211             stepmake='$(depth)'/stepmake
212             echo Using local stepmake: $datadir/stepmake not found
213         fi
214         AC_CONFIG_AUX_DIR(\
215           $HOME/usr/local/share/stepmake/bin\
216           $HOME/usr/local/lib/stepmake/bin\
217           $HOME/usr/share/stepmake/bin\
218           $HOME/usr/lib/stepmake/bin\
219           /usr/local/share/stepmake/bin\
220           /usr/local/lib/stepmake/bin\
221           /usr/share/stepmake/bin\
222           /usr/lib/stepmake/bin\
223           stepmake/bin\
224         )
225     fi
226
227     AC_SUBST(stepmake)
228     AC_SUBST(package)
229     AC_SUBST(PACKAGE)
230     AC_SUBST(PACKAGE_NAME)
231     AC_DEFINE_UNQUOTED(PACKAGE, "${PACKAGE_NAME}")
232     AC_DEFINE_UNQUOTED(TOPLEVEL_VERSION, "${FULL_VERSION}")
233
234     if test "$package_depth" = "" ; then
235         package_depth="."
236     else
237         package_depth="../$package_depth"
238     fi
239     export package_depth
240     AC_SUBST(package_depth)
241
242     AUTOGENERATE="This file was automatically generated by configure"
243     AC_SUBST(AUTOGENERATE)
244     absolute_builddir="`pwd`"
245     AC_SUBST(absolute_builddir)
246
247     STATE_VECTOR=`ls make/STATE-VECTOR 2>/dev/null`
248     if test "x$STATE_VECTOR" != "x"; then
249         STATE_VECTOR="\$(depth)/$STATE_VECTOR"
250     fi
251     AC_SUBST(STATE_VECTOR)
252
253     CONFIGSUFFIX=
254     AC_ARG_ENABLE(config,
255     [  enable-config=FILE      put configure settings in config-FILE.make],
256     [CONFIGSUFFIX=$enableval])
257
258     if test "$CONFIGSUFFIX" != "" ; then
259         CONFIGFILE=config-$CONFIGSUFFIX
260     else
261         CONFIGFILE=config
262     fi
263     AC_SUBST(CONFIGSUFFIX)
264      
265     AC_CANONICAL_HOST
266     AC_CHECK_PROGS(MAKE, gmake make, error)
267     AC_CHECK_PROGS(FIND, find, error)
268
269 dnl system supplied INSTALL is unsafe; use our own install.
270 dnl    AC_PROG_INSTALL
271 dnl    if test "$INSTALL" = "bin/install-sh"; then
272 dnl     export INSTALL="\$\(depth\)/bin/install-sh"
273 dnl    fi
274
275     AC_CHECK_PROGS(TAR, tar, error)
276     AC_CHECK_PROGS(BASH, bash, /bin/sh)
277
278     AC_PATH_PROG(PYTHON, ${PYTHON:-python}, -echo no python)
279     AC_SUBST(PYTHON)
280
281     if test $MAKE != "error" ; then
282         $MAKE -v 2> /dev/null | grep GNU > /dev/null
283         if test "$?" = 1
284         then
285                 AC_STEPMAKE_WARN(Please install *GNU* make) 
286         fi
287     fi 
288
289     AC_CHECK_SEARCH_RESULT($PYTHON, python, You should install Python)
290
291     if test "x$OSTYPE" = "xcygwin32" || test "x$OSTYPE" = "xWindows_NT"; then
292         LN=cp # hard link does not work under cygnus-nt
293         LN_S='cp -r' # symbolic link does not work for native nt
294         ZIP="zip -r -9" #
295         DOTEXE=.exe
296         # urg
297         # DIRSEP='\\'
298         # PATHSEP=';'
299         #
300         # cygwin fixes all these things.  
301         # it seems these were used because of dos-style TEXINPUTS and
302         # MFINPUTS needed for miktex.
303         # but this breaks parsing of all other cygwin/unix style paths.
304         #
305         # if your (mik)tex breaks, make a:
306         #    /usr/local/bin/tex:
307         #    #!/bin/sh
308         #    TEXINPUTS=`cygpath -pw $TEXINPUTS` /texmf/miktex/bin/tex $*
309         #
310         # and
311         #
312         #    /usr/local/bin/mf:
313         #    #!/bin/sh
314         #    MFINPUTS=`cygpath -pw $MFINPUTS` /texmf/miktex/bin/mf $*
315         #
316         # this way, you may have buildscripts/out/lilypond-profile 
317         # 'automatically' sourced from /usr/etc/profile.d/ too.
318         #
319         DIRSEP='/'
320         PATHSEP=':'
321         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
322     else
323         DIRSEP='/'
324         PATHSEP=':'
325         LN=ln
326         LN_S='ln -s'
327         ZIP="zip -r -9"
328         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-sh -c"
329     fi
330     AC_SUBST(DOTEXE)
331     AC_SUBST(ZIP)
332     AC_SUBST(LN)
333     AC_SUBST(LN_S)
334     AC_SUBST(INSTALL)
335     AC_DEFINE_UNQUOTED(DIRSEP, '${DIRSEP}')
336     AC_DEFINE_UNQUOTED(PATHSEP, '${PATHSEP}')
337     AC_SUBST(PATHSEP)
338     AC_SUBST(DIRSEP)
339   
340    
341     AC_STEPMAKE_DATADIR
342 ])
343
344 AC_DEFUN(AC_STEPMAKE_LEXYACC, [
345     # ugh, automake: we want (and check for) bison
346     AC_PROG_YACC
347     # ugh, automake: we want (and check for) flex
348     # AC_PROG_LEX
349     # urg: automake 1.3: hope this doesn't break 1.2 ac_cv_pro_lex_root hack...
350
351     # AC_DECL_YYTEXT
352     # ugh, ugh
353     ac_cv_prog_lex_root=lex.yy
354
355     AC_CHECK_PROGS(BISON, bison, error)
356     AC_CHECK_PROGS(FLEX, flex, error)
357     AC_CHECK_SEARCH_RESULT($BISON, bison,  Please install Bison, 1.25 or newer)
358     AC_CHECK_SEARCH_RESULT($FLEX,  flex, Please install Flex, 2.5 or newer)
359
360     if test $BISON != "error"; then
361         bison_version=`$BISON --version | sed 's/^.*version 1.//g'`
362         if test `echo $bison_version | sed 's/\..*$//g'` -lt 25; then
363             AC_STEPMAKE_WARN(Your bison is a bit old (1.$bison_version). You might have to install 1.25)
364         fi      
365     fi
366
367     AC_SUBST(BISON)
368     AC_SUBST(FLEX)
369 ])
370
371 AC_DEFUN(AC_STEPMAKE_LIB, [
372     AC_CHECK_PROGS(AR, ar, error)
373     AC_PROG_RANLIB
374
375     AC_SUBST(AR)
376     AC_SUBST(RANLIB)
377 ])
378
379 AC_DEFUN(AC_STEPMAKE_LIBTOOL, [
380     # libtool.info ...
381     # **Never** try to set library version numbers so that they correspond
382     # to the release number of your package.  This is an abuse that only
383     # fosters misunderstanding of the purpose of library versions.
384
385     REVISION=$PATCH_LEVEL
386     # CURRENT=$MINOR_VERSION
387     CURRENT=`expr $MINOR_VERSION + 1`
388     # AGE=$(expr $MAJOR_VERSION + 1)
389     AGE=$MAJOR_VERSION
390     AC_SUBST(CURRENT)
391     AC_SUBST(REVISION)
392     AC_SUBST(AGE)
393 ])
394
395 AC_DEFUN(AC_STEPMAKE_LOCALE, [
396     lang=English
397     ALL_LINGUAS="en nl"
398
399     # with/enable ??
400     AC_ARG_WITH(localedir,
401     [  with-localedir=LOCALE   use LOCALE as locale dir. Default: PREFIX/share/locale ],
402     localedir=$with_localedir,
403     localedir='${prefix}/share/locale')
404
405     AC_ARG_WITH(lang,
406     [  with-lang=LANG          use LANG as language to emit messages],
407     language=$with_lang,
408     language=English)
409
410     AC_MSG_CHECKING(language)    
411     case "$language" in
412       En* | en* | Am* | am* | US* | us*)
413             lang=English;;
414       NL | nl | Du* | du* | Ned* | ned*)
415             lang=Dutch;;
416       "")
417             lang=English;;
418       *)
419             lang=unknown;;
420     esac
421     AC_MSG_RESULT($lang)
422
423     if test "$lang" = "unknown" ; then
424         AC_STEPMAKE_WARN($language not supported; available are: $ALL_LINGUAS)
425     fi
426
427 ])
428
429 AC_DEFUN(AC_STEPMAKE_GETTEXT, [
430     DIR_LOCALEDIR=${localedir}
431     presome=${prefix}
432     if test "$prefix" = "NONE"; then
433             presome=${ac_default_prefix}
434     fi
435     DIR_LOCALEDIR=`echo ${DIR_LOCALEDIR} | sed "s!\\\${prefix}!$presome!"`
436     AC_SUBST(localedir)
437     AC_SUBST(DIR_LOCALEDIR)
438     AC_DEFINE_UNQUOTED(DIR_LOCALEDIR, "${DIR_LOCALEDIR}")
439
440     AC_CHECK_LIB(intl, gettext)
441     AC_CHECK_FUNCS(gettext)
442 ])
443
444 AC_DEFUN(AC_STEPMAKE_MAN, [
445     AC_CHECK_PROGS(GROFF, groff ditroff, -echo no groff)
446     AC_CHECK_PROGS(TROFF, troff, -echo no troff)
447     AC_CHECK_PROGS(TBL, tbl, cat)
448 ])
449
450 AC_DEFUN(AC_STEPMAKE_MSGFMT, [
451     # AC_CHECK_PROGS(MSGFMT, msgfmt, -echo no msgfmt)
452     AC_CHECK_PROGS(MSGFMT, msgfmt, \$(SHELL) \$(step-bindir)/fake-msgfmt.sh )
453     AC_MSG_CHECKING(whether msgfmt accepts -o)
454     msgfmt_output="`msgfmt -o bla 2>&1 | grep usage`"
455     if test "$msgfmt_output" = ""; then
456         AC_MSG_RESULT(yes)
457     else
458         # urg
459         MSGFMT="\$(SHELL) \$(step-bindir)/fake-msgfmt.sh"
460         AC_MSG_RESULT(no)
461         AC_STEPMAKE_WARN(please install msgfmt from GNU gettext)
462     fi
463     if test ! -n "$MSGFMT"; then
464         AC_STEPMAKE_WARN(please install msgfmt from GNU gettext)
465     fi
466 ])
467
468 AC_DEFUN(AC_STEPMAKE_TEXMF_DIRS, [
469     AC_ARG_ENABLE(tex-prefix,
470     [  enable-tex-prefix=DIR   set the tex-directory to find TeX subdirectories. (default: PREFIX)],
471     [TEXPREFIX=$enableval],
472     [TEXPREFIX=auto] )
473     
474     AC_ARG_ENABLE(tex-dir,
475     [  enable-tex-dir=DIR      set the directory to put $PACKAGE_NAME TeX files in. ],
476     [TEXDIR=$enableval],
477     [TEXDIR=auto] )
478
479     AC_ARG_ENABLE(mf-dir,
480     [  enable-mf-dir=DIR       set the directory to put $PACKAGE_NAME MetaFont files in. ],
481     [MFDIR=$enableval],
482     [MFDIR=auto])
483
484     if test "x$TEXPREFIX" = xauto ; then
485         AC_TEX_PREFIX(TEXPREFIX)
486     else
487      find_texprefix=$TEXPREFIX
488     fi
489
490     if test "x$MFDIR" = xauto; then
491         AC_MF_SUBDIR(MFDIR)
492     fi
493         
494     if test "x$TEXDIR" = xauto ; then
495         AC_TEX_SUBDIR(TEXDIR)
496     fi
497     AC_SUBST(TEXPREFIX)
498     AC_SUBST(TEXDIR)
499     AC_SUBST(MFDIR)
500 ])
501
502 AC_DEFUN(AC_STEPMAKE_TEXMF, [
503     # urg, never know what names these teTeX guys will think up
504
505     AC_CHECK_PROGS(METAFONT, mf, no)
506     if test "x$METAFONT" = "xno"; then
507         AC_CHECK_PROGS(MFONT, mfont, -echo no mf or mfont)
508         METAFONT=$MFONT
509     fi
510
511     AC_CHECK_PROGS(METAPOST, mp, no)
512     if test "x$METAPOST" = "xno"; then
513         AC_CHECK_PROGS(MPOST, mpost, -echo no mp or mpost)
514         METAPOST=$MPOST
515     fi
516
517     AC_CHECK_PROGS(INIMETAFONT, inimf, no)
518     if test "x$INIMETAFONT" = "xno"; then
519         AC_CHECK_PROGS(INIMFONT, inimfont, -echo no inimf or inimfont)
520         INIMETAFONT=$INIMFONT
521     fi
522
523     AC_CHECK_PROGS(INIMETAPOST, inimp, no)
524     if test "x$INIMETAPOST" = "xno"; then
525         AC_CHECK_PROGS(INIMPOST, inimpost, -echo no inimp or inimpost)
526         INIMETAPOST=$INIMPOST
527     fi
528
529     AC_SUBST(METAFONT)
530     AC_SUBST(METAPOST)
531     AC_SUBST(INIMETAFONT)
532     AC_SUBST(INIMETAPOST)
533 ])
534
535 AC_DEFUN(AC_STEPMAKE_WARN, [
536     AC_MSG_WARN($1)
537     warn_b=yes
538 ])
539
540 AC_DEFUN(AC_STEPMAKE_YODL, [
541     if test "x$YODL" = "x"; then 
542         AC_CHECK_PROGS(STRIPROFF, striproff, -echo no striproff)
543         AC_CHECK_PROGS(YODL, yodl, -echo no yodl)
544         AC_CHECK_PROGS(YODL2HTML, yodl2html, -echo no yodl)
545         AC_CHECK_PROGS(YODL2LATEX, yodl2latex, )
546         AC_CHECK_PROGS(YODL2MAN, yodl2man, -echo no yodl)
547         AC_CHECK_PROGS(YODL2MSLESS, yodl2msless, -echo no yodl)
548         AC_CHECK_PROGS(YODL2TEXINFO, yodl2texinfo, -echo no yodl)
549         AC_CHECK_PROGS(YODL2TXT, yodl2txt, -echo no yodl)
550         YODL2LESS_DIR='$(bindir)/'
551     else
552         AC_SUBST(STRIPROFF)
553         AC_SUBST(YODL)
554         AC_SUBST(YODL2HTML)
555         AC_SUBST(YODL2LATEX)
556         AC_SUBST(YODL2LESS_DIR)
557         AC_SUBST(YODL2MAN)
558         AC_SUBST(YODL2MSLESS)
559         AC_SUBST(YODL2TEXINFO)
560         AC_SUBST(YODL2TXT)
561         export STRIPROFF YODL YODL2HTML YODL2LATEX YODL2MAN YODL2MSLESS YODL2TEXINFO YODL2TXT
562     fi
563     if test "x$YODL" = "-echo no yodl"; then
564         AC_STEPMAKE_WARN(Did not find YODL (Yodl is Yet Oneother Document Language, see http://www.cs.uu.nl/~hanwen/yodl))
565     fi    
566 ])
567
568 dnl should cache result.
569 dnl should  look in $prefix first.
570 dnl should probably assume TDS
571
572 AC_DEFUN(AC_TEX_PREFIX, [
573     
574
575     AC_MSG_CHECKING(TeX/MF root dir directory)    
576
577     find_root_prefix="$prefix"
578     
579
580     test "x$find_root_prefix" = xNONE && find_root_prefix="$ac_default_prefix"
581     find_texpostfix="";
582     for postfix in "/lib/tex/" "/lib/texmf" "/lib" "/tex" "/texmf"; do
583         find_texprefix="$find_root_prefix$postfix"
584         if test -d $find_texprefix; then
585             find_texpostfix=$postfix
586             break;
587         fi
588     done
589     
590     if test "x$find_texpostfix" = x; then
591         find_texpostfix='/lib/texmf/tex'
592         AC_STEPMAKE_WARN(Cannot determine the TeX-directory. Please use --enable-tex-prefix)
593     fi
594
595     find_texprefix="$find_root_prefix/$find_texpostfix"
596
597     # only assign if variablename not empty
598     if test x != "x[$]$1"; then
599         $1='${prefix}'/"$find_texpostfix"
600     fi
601     AC_MSG_RESULT($find_texprefix)
602
603 ])
604  
605
606 # find a directory inside a prefix, 
607 # $1 the prefix (expanded version)
608 # $2 variable to assign
609 # $3 the directory name 
610 # $4 description
611 AC_DEFUN(AC_FIND_DIR_IN_PREFIX, [
612     
613     AC_MSG_CHECKING($4 directory)    
614     find_dirdir=`(cd $1; 
615       $FIND ./ -type d -a -name $3 -print |sort|head -1|sed 's#^\./##')`
616     
617
618     if test "x$find_dirdir" = x; then
619        find_dirdir="/$3";
620        AC_STEPMAKE_WARN(Cannot determine $4 subdirectory. Please set from command-line)
621         true
622     fi
623     $2=$find_dirdir
624     AC_MSG_RESULT($1/$find_dirdir)
625 ])
626
627 # ugh.  this is hopeless
628 AC_DEFUN(AC_KPSE_TEX_DIR, [
629         kpse_paths=`(kpsepath -n latex tex; kpsepath -n tex tex) | sed 's/:/ /g' | tr ' ' '\012' |sort | uniq -d`
630         kpse_syspaths=`echo $kpse_paths | grep '!'| sed 's/!//g'`
631         echo $kpse_paths
632         if test -w "$kpse_syspaths";
633         then
634                 dir=`echo $kpse_syspaths | head -1`
635         else
636                 dir=`echo $kpse_paths | grep -v '!'| head -1`
637         fi
638         if test "$prefix" = "NONE"; then
639                 local_prefix=$ac_default_prefix
640                 local_prefix_quote='${prefix}'
641
642         else
643                 local_prefix=$prefix
644                 local_prefix_quote=$prefix
645         fi
646         echo $local_prefix_quote = $local_prefix
647         echo $dir
648         echo $dir  | sed 's!'$local_prefix'!\$local_prefix_quote!g'
649 ])
650
651 AC_DEFUN(AC_TEX_SUBDIR, [
652 dnl    AC_REQUIRE([AC_TEX_PREFIX])
653     AC_FIND_DIR_IN_PREFIX($find_texprefix, $1, tex,TeX input)
654     $1="$TEXPREFIX/$$1"
655 ])
656
657 AC_DEFUN(AC_MF_SUBDIR, [
658 dnl     AC_REQUIRE([AC_TEX_PREFIX])
659     AC_FIND_DIR_IN_PREFIX($find_texprefix, $1, source, MF input)
660     $1="$TEXPREFIX/$$1"
661 ])
662
663 AC_DEFUN(AC_CHECK_SEARCH_RESULT, [
664         result="`echo \"$1\" | grep echo`"
665         if test "x$1" = "xerror" -o "x$result" != "x"; then
666                 AC_STEPMAKE_WARN(can\'t find $2. $3)
667         fi
668 ])
669
670 dnl   GUILE_FLAGS --- set flags for compiling and linking with Guile
671 dnl
672 dnl   This macro runs the `guile-config' script, installed with Guile,
673 dnl   to find out where Guile's header files and libraries are
674 dnl   installed.  It sets two variables, marked for substitution, as
675 dnl   by AC_SUBST.
676 dnl   
677 dnl     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
678 dnl             code that uses Guile header files.  This is almost
679 dnl             always just a -I flag.
680 dnl   
681 dnl     GUILE_LDFLAGS --- flags to pass to the linker to link a
682 dnl             program against Guile.  This includes `-lguile' for
683 dnl             the Guile library itself, any libraries that Guile
684 dnl             itself requires (like -lqthreads), and so on.  It may
685 dnl             also include a -L flag to tell the compiler where to
686 dnl             find the libraries.
687
688 AC_DEFUN([GUILE_FLAGS],[
689 ## The GUILE_FLAGS macro.
690   ## First, let's just see if we can find Guile at all.
691   AC_MSG_CHECKING(for Guile)
692   guile-config link > /dev/null || {
693     echo "configure: cannot find guile-config; is Guile installed?" 1>&2
694     exit 1
695   }
696   GUILE_CFLAGS="`guile-config compile`"
697   GUILE_LDFLAGS="`guile-config link`"
698   AC_SUBST(GUILE_CFLAGS)
699   AC_SUBST(GUILE_LDFLAGS)
700   AC_MSG_RESULT(yes)
701 ])
702
703
704 # Configure paths for GTK+
705 # Owen Taylor     97-11-3
706
707 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
708 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
709 dnl
710 AC_DEFUN(AM_PATH_GTK,
711 [dnl 
712 dnl Get the cflags and libraries from the gtk-config script
713 dnl
714   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
715   min_gtk_version=ifelse([$1], ,1.1.1,$1)
716   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
717   no_gtk=""
718   if test "$GTK_CONFIG" != "no" ; then
719     GTK_CFLAGS=`$GTK_CONFIG --cflags`
720     GTK_LIBS=`$GTK_CONFIG --libs`
721     ac_save_CFLAGS="$CFLAGS"
722     ac_save_LIBS="$LIBS"
723     ac_save_CXXFLAGS="$CXXFLAGS"
724     CFLAGS="$CFLAGS $GTK_CFLAGS"
725     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
726     LIBS="$LIBS $GTK_LIBS"
727 dnl
728 dnl Now check if the installed GTK is sufficiently new. (Also sanity
729 dnl checks the results of gtk-config to some extent)
730 dnl
731     AC_TRY_RUN([
732 #include <gtk/gtk.h>
733 #include <stdio.h>
734
735 int 
736 main ()
737 {
738   int major, minor, micro;
739
740   if (sscanf("$min_gtk_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
741      printf("%s, bad version string\n", "$min_gtk_version");
742      exit(1);
743    }
744
745    return !((gtk_major_version > major) ||
746             ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
747             ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)));
748 }
749 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
750      CFLAGS="$ac_save_CFLAGS"
751      CXXFLAGS="$ac_save_CXXFLAGS"
752      LIBS="$ac_save_LIBS"
753   else
754      no_gtk=yes
755   fi
756   if test "x$no_gtk" = x ; then
757      AC_MSG_RESULT(yes)
758      ifelse([$2], , :, [$2])     
759   else
760      AC_MSG_RESULT(no)
761      GTK_CFLAGS=""
762      GTK_LIBS=""
763      ifelse([$3], , :, [$3])
764   fi
765   CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
766   AC_SUBST(CXXFLAGS)
767   AC_SUBST(GTK_CFLAGS)
768   AC_SUBST(GTK_LIBS)
769 ])
770
771
772 # Configure paths for GTK--
773 # Erik Andersen 30 May 1998
774 # Modified by Tero Pulkkinen (added the compiler checks... I hope they work..)
775
776 dnl Test for GTK__, and define GTK___CFLAGS and GTK___LIBS
777 dnl   to be used as follows:
778 dnl AM_PATH_GTKMM([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
779 dnl
780
781 dnl Get the cflags and libraries from the gtkmm-config script
782 dnl
783 AC_ARG_WITH(gtkmm-prefix,[  --with-gtkmm-prefix=PREFIX
784                           Prefix where GTK-- is installed (optional)],
785             gtkmm_config_prefix="$withval", gtkmm_config_prefix="")
786 AC_ARG_WITH(gtkmm-exec-prefix,[  --with-gtkmm-exec-prefix=PREFIX
787                           Exec prefix where GTK-- is installed (optional)],
788             gtkmm_config_exec_prefix="$withval", gtkmm_config_exec_prefix="")
789 AC_ARG_ENABLE(gtkmmtest, [  --disable-gtkmmtest     Do not try to compile and run a test GTK-- program],
790                     , enable_gtkmmtest=yes)
791
792   if test x$gtkmm_config_exec_prefix != x ; then
793      gtkmm_config_args="$gtkmm_config_args --exec-prefix=$gtkmm_config_exec_prefix"
794      if test x${GTKMM_CONFIG+set} != xset ; then
795         GTKMM_CONFIG=$gtkmm_config_exec_prefix/bin/gtkmm-config
796      fi
797   fi
798   if test x$gtkmm_config_prefix != x ; then
799      gtkmm_config_args="$gtkmm_config_args --prefix=$gtkmm_config_prefix"
800      if test x${GTKMM_CONFIG+set} != xset ; then
801         GTKMM_CONFIG=$gtkmm_config_prefix/bin/gtkmm-config
802      fi
803   fi
804
805
806 AC_DEFUN(AM_PATH_GTKMM,
807 [dnl 
808
809 dnl
810 dnl Check if the installed GTK-- is sufficiently new.
811 dnl
812   AC_PATH_PROG(GTKMM_CONFIG, gtkmm-config, no)
813   min_gtkmm_version=ifelse([$1], ,0.9.14,$1)
814
815   AC_MSG_CHECKING(for GTK-- - version >= $min_gtkmm_version)
816   no_gtkmm=""
817   if test "$GTKMM_CONFIG" = "no" ; then
818     no_gtkmm=yes
819   else
820     AC_LANG_SAVE
821     AC_LANG_CPLUSPLUS
822
823     GTK___CFLAGS=`$GTKMM_CONFIG $gtkmm_config_args --cflags`
824     GTK___LIBS=`$GTKMM_CONFIG $gtkmm_config_args --libs`
825     gtkmm_config_major_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
826            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
827     gtkmm_config_minor_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
828            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
829     gtkmm_config_micro_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
830            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
831     if test "x$enable_gtkmmtest" = "xyes" ; then
832       ac_save_CXXFLAGS="$CXXFLAGS"
833       ac_save_LIBS="$LIBS"
834       CXXFLAGS="$CXXFLAGS $GTK___CFLAGS"
835       LIBS="$LIBS $GTK___LIBS"
836 dnl
837 dnl Now check if the installed GTK-- is sufficiently new. (Also sanity
838 dnl checks the results of gtkmm-config to some extent
839 dnl
840       rm -f conf.gtkmmtest
841       AC_TRY_RUN([
842 #include <gtk--.h>
843 #include <stdio.h>
844 #include <stdlib.h>
845
846 int 
847 main ()
848 {
849   int major, minor, micro;
850   char *tmp_version;
851
852   system ("touch conf.gtkmmtest");
853
854   /* HP/UX 0 (%@#!) writes to sscanf strings */
855   tmp_version = g_strdup("$min_gtkmm_version");
856   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
857      printf("%s, bad version string\n", "$min_gtkmm_version");
858      exit(1);
859    }
860
861   if ((gtkmm_major_version != $gtkmm_config_major_version) ||
862       (gtkmm_minor_version != $gtkmm_config_minor_version) ||
863       (gtkmm_micro_version != $gtkmm_config_micro_version))
864     {
865       printf("\n*** 'gtkmm-config --version' returned %d.%d.%d, but GTK-- (%d.%d.%d)\n", 
866              $gtkmm_config_major_version, $gtkmm_config_minor_version, $gtkmm_config_micro_version,
867              gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
868       printf ("*** was found! If gtkmm-config was correct, then it is best\n");
869       printf ("*** to remove the old version of GTK--. You may also be able to fix the error\n");
870       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
871       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
872       printf("*** required on your system.\n");
873       printf("*** If gtkmm-config was wrong, set the environment variable GTKMM_CONFIG\n");
874       printf("*** to point to the correct copy of gtkmm-config, and remove the file config.cache\n");
875       printf("*** before re-running configure\n");
876     } 
877 /* GTK-- does not have the GTKMM_*_VERSION constants */
878 /* 
879   else if ((gtkmm_major_version != GTKMM_MAJOR_VERSION) ||
880            (gtkmm_minor_version != GTKMM_MINOR_VERSION) ||
881            (gtkmm_micro_version != GTKMM_MICRO_VERSION))
882     {
883       printf("*** GTK-- header files (version %d.%d.%d) do not match\n",
884              GTKMM_MAJOR_VERSION, GTKMM_MINOR_VERSION, GTKMM_MICRO_VERSION);
885       printf("*** library (version %d.%d.%d)\n",
886              gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
887     }
888 */
889   else
890     {
891       if ((gtkmm_major_version > major) ||
892         ((gtkmm_major_version == major) && (gtkmm_minor_version > minor)) ||
893         ((gtkmm_major_version == major) && (gtkmm_minor_version == minor) && (gtkmm_micro_version >= micro)))
894       {
895         return 0;
896        }
897      else
898       {
899         printf("\n*** An old version of GTK-- (%d.%d.%d) was found.\n",
900                gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
901         printf("*** You need a version of GTK-- newer than %d.%d.%d. The latest version of\n",
902                major, minor, micro);
903         printf("*** GTK-- is always available from ftp://ftp.gtk.org.\n");
904         printf("***\n");
905         printf("*** If you have already installed a sufficiently new version, this error\n");
906         printf("*** probably means that the wrong copy of the gtkmm-config shell script is\n");
907         printf("*** being found. The easiest way to fix this is to remove the old version\n");
908         printf("*** of GTK--, but you can also set the GTKMM_CONFIG environment to point to the\n");
909         printf("*** correct copy of gtkmm-config. (In this case, you will have to\n");
910         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
911         printf("*** so that the correct libraries are found at run-time))\n");
912       }
913     }
914   return 1;
915 }
916 ],, no_gtkmm=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
917        CXXFLAGS="$ac_save_CXXFLAGS"
918        LIBS="$ac_save_LIBS"
919      fi
920   fi
921   if test "x$no_gtkmm" = x ; then
922      AC_MSG_RESULT(yes)
923      ifelse([$2], , :, [$2])     
924   else
925      AC_MSG_RESULT(no)
926      if test "$GTKMM_CONFIG" = "no" ; then
927        echo "*** The gtkmm-config script installed by GTK-- could not be found"
928        echo "*** If GTK-- was installed in PREFIX, make sure PREFIX/bin is in"
929        echo "*** your path, or set the GTK_CONFIG environment variable to the"
930        echo "*** full path to gtk-config."
931        echo "*** The gtkmm-config script was not available in GTK-- versions"
932        echo "*** prior to 0.9.12. Perhaps you need to update your installed"
933        echo "*** version to 0.9.12 or newer"
934      else
935        if test -f conf.gtkmmtest ; then
936         :
937        else
938           echo "*** Could not run GTK-- test program, checking why..."
939           CXXFLAGS="$CFLAGS $GTKMM_CXXFLAGS"
940           LIBS="$LIBS $GTK___LIBS"
941           AC_TRY_LINK([
942 #include <gtk--.h>
943 #include <stdio.h>
944 ],      [ return ((gtkmm_major_version) || (gtkmm_minor_version) || (gtkmm_micro_version)); ],
945         [ echo "*** The test program compiled, but did not run. This usually means"
946           echo "*** that the run-time linker is not finding GTK-- or finding the wrong"
947           echo "*** version of GTK--. If it is not finding GTK--, you'll need to set your"
948           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
949           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
950           echo "*** is required on your system"
951           echo "***"
952           echo "*** If you have an old version installed, it is best to remove it, although"
953           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
954         [ echo "*** The test program failed to compile or link. See the file config.log for the"
955           echo "*** exact error that occured. This usually means GTK-- was incorrectly installed"
956           echo "*** or that you have moved GTK-- since it was installed. In the latter case, you"
957           echo "*** may want to edit the gtkmm-config script: $GTKMM_CONFIG" ])
958           CXXFLAGS="$ac_save_CXXFLAGS"
959           LIBS="$ac_save_LIBS"
960        fi
961      fi
962      GTK___CFLAGS=""
963      GTK__LIBS=""
964      ifelse([$3], , :, [$3])
965      AC_LANG_RESTORE
966   fi
967   AC_SUBST(GTK___CFLAGS)
968   AC_SUBST(GTK___LIBS)
969   rm -f conf.gtkmmtest
970 ])
971
972 # Configure paths for GTK--DRAW
973 # Derek Quinn Wyatt   98-08-21  (adapted from Jan Nieuwenhuizen's code)
974
975 dnl AM_PATH_GTK__DRAW([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
976 dnl Test for GTK--DRAW, and define GTK___CFLAGS and GTK___LIBS
977 dnl
978 AC_DEFUN(AM_PATH_GTK__DRAW,
979 [dnl 
980 dnl Get the cflags and libraries from the gtk__-config script
981 dnl
982   AC_PATH_PROG(GTKMM_CONFIG, gtkmm-config, no)
983   min_gtk___version=ifelse([$1], ,0.0.5,$1)
984   AC_MSG_CHECKING(for GTK--DRAW - version >= $min_gtk___version)
985   no_gtk__=""
986   if test "$GTKMM_CONFIG" != "no" ; then
987     GTK___CFLAGS=`$GTKMM_CONFIG --cflags`
988     GTK___LIBS=`$GTKMM_CONFIG --libs`
989     GTK___DLIBS="$GTK___LIBS -lgtkmmdraw"
990     GTK___LIBS="$GTK___DLIBS"
991     ac_save_CFLAGS="$CFLAGS"
992     ac_save_LIBS="$LIBS"
993     ac_save_CXXFLAGS="$CXXFLAGS"
994     CFLAGS="$CFLAGS $GTK___CFLAGS"
995     CXXFLAGS="$CXXFLAGS $GTK___CFLAGS"
996     LIBS="$LIBS $GTK___LIBS"
997 dnl
998 dnl Now check if the installed GTK__ is sufficiently new. (Also sanity
999 dnl checks the results of gtk__-config to some extent)
1000 dnl
1001     AC_TRY_RUN([
1002 #include <gtk--.h>
1003 #include <stdio.h>
1004
1005 int 
1006 main ()
1007 {
1008   // urg
1009   return 0;
1010 }
1011 ],, no_gtk__=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1012      CFLAGS="$ac_save_CFLAGS"
1013      CXXFLAGS="$ac_save_CXXFLAGS"
1014      LIBS="$ac_save_LIBS"
1015   else
1016      no_gtk__=yes
1017   fi
1018   if test "x$no_gtk__" = x ; then
1019      AC_MSG_RESULT(yes)
1020      ifelse([$2], , :, [$2])     
1021   else
1022      AC_MSG_RESULT(no)
1023      GTK___CFLAGS=""
1024      GTK___LIBS=""
1025      ifelse([$3], , :, [$3])
1026   fi
1027   CXXFLAGS="$CXXFLAGS $GTK___CFLAGS"
1028   AC_SUBST(CXXFLAGS)
1029   AC_SUBST(GTK___CFLAGS)
1030   AC_SUBST(GTK___LIBS)
1031 ])
1032
1033 dnl   GUILE_FLAGS --- set flags for compiling and linking with Guile
1034 dnl
1035 dnl   This macro runs the `guile-config' script, installed with Guile,
1036 dnl   to find out where Guile's header files and libraries are
1037 dnl   installed.  It sets two variables, marked for substitution, as
1038 dnl   by AC_SUBST.
1039 dnl   
1040 dnl     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
1041 dnl             code that uses Guile header files.  This is almost
1042 dnl             always just a -I flag.
1043 dnl   
1044 dnl     GUILE_LDFLAGS --- flags to pass to the linker to link a
1045 dnl             program against Guile.  This includes `-lguile' for
1046 dnl             the Guile library itself, any libraries that Guile
1047 dnl             itself requires (like -lqthreads), and so on.  It may
1048 dnl             also include a -L flag to tell the compiler where to
1049 dnl             find the libraries.
1050
1051 AC_DEFUN([GUILE_FLAGS],[
1052 ## The GUILE_FLAGS macro.
1053   ## First, let's just see if we can find Guile at all.
1054   AC_MSG_CHECKING(for Guile)
1055   guile-config link > /dev/null || {
1056     echo "configure: cannot find guile-config; is Guile installed?" 1>&2
1057     exit 1
1058   }
1059   GUILE_CFLAGS="`guile-config compile`"
1060   GUILE_LDFLAGS="`guile-config link`"
1061   AC_SUBST(GUILE_CFLAGS)
1062   AC_SUBST(GUILE_LDFLAGS)
1063   AC_MSG_RESULT(yes)
1064 ])
1065