tentative fix for issue 3 (ex 53)
[mplib] / src / texk / kpathsea / withenable.ac
1 dnl withenable.ac: --with and --enable options.
2
3 dnl --enable-maintainer-mode as implemented in automake.
4 AM_MAINTAINER_MODE
5
6 dnl These are standard among *NIX systems, but not when cross-compiling
7 AC_DEFUN([CF_SUBST],
8 [AC_MSG_CHECKING(for $1 (symbol $2))
9 AC_CACHE_VAL(cf_cv_subst_$2,[
10 test -z "[$]$2" && $2=$3
11 cf_cv_subst_$2=[$]$2])
12 $2=${cf_cv_subst_$2}
13 AC_MSG_RESULT([$]$2)
14 AC_SUBST($2)
15 ])dnl
16 CF_SUBST(loader,LD,ld)
17 CF_SUBST(archiver,AR,ar)
18 CF_SUBST(archiver options,ARFLAGS,rc)
19
20 AC_ARG_WITH([mktexmf-default],
21 [  --without-mktexmf-default    do not run mktexmf if MF source missing],
22   , [with_mktexmf_default=yes])
23 AC_ARG_WITH([mktexpk-default],
24 [  --without-mktexpk-default    do not run mktexpk if PK font missing],
25   , [with_mktexpk_default=yes])
26 AC_ARG_WITH([mktextfm-default],
27 [  --without-mktextfm-default   do not run mktextfm if TFM file missing],
28    , [with_mktextfm_default=yes])
29 AC_ARG_WITH([mkocp-default],
30 [  --without-mkocp-default      do not run mkocp if OCP file missing],
31    , [with_mkocp_default=yes])
32 AC_ARG_WITH([mkofm-default],
33 [  --without-mkofm-default      do not run mkofm if OFM file missing],
34    , [with_mkofm_default=yes])
35 AC_ARG_WITH([mktexfmt-default],
36 [  --with-mktexfmt-default      run mktexfmt if format file missing])
37 AC_ARG_WITH([mktextex-default],
38 [  --with-mktextex-default      run mktextex if TeX source missing],
39   [with_mktextex_default=yes], [with_mktextex_default=no])
40
41 dnl Check whether we can find a texmf tree.  Look at the most common spots.
42 dnl Not a switch, but something that must be included everywhere, even at
43 dnl at the top level, so putting it in common.ac is not enough.
44 AC_MSG_CHECKING(where the main texmf tree is located)
45 case $prefix in
46   */) prefix=`echo "$prefix" | sed 's@/*$@@'`;;
47 esac
48 texmfmain=
49 if test "x$datadir" != 'x${prefix}/share'; then
50   # First case, datadir is defined...
51   eval p=\"$datadir\"
52   # Unconditionally set the directory, but...
53   texmfmain=`echo "$p/texmf" | sed 's,//*,/,g'`
54   # ... do complain if it wasn't found.
55   if test -d "$texmfmain"; then
56     AC_MSG_RESULT("$texmfmain")
57   else
58     AC_MSG_RESULT([not found])
59     AC_MSG_WARN([No texmf tree found at $texmfmain.
60   *****************************************************************
61   * Error: The main texmf tree was not found.                     *
62   * If you do not have the files, you should be able to them from *
63   * the same place you got these sources from, or from one of the *
64   * CTAN hosts.                                                   *
65   *****************************************************************
66   Winging it.])
67   fi
68 else
69   # Second case, datadir is default...
70   if test "x$prefix" = "xNONE"; then
71     p="$ac_default_prefix"
72   else
73     eval p=\"$prefix\"
74   fi
75   for e in share/texmf lib/texmf texmf; do
76     if test -d "$p/$e"; then
77       texmfmain='${prefix}'/"$e"
78       break
79     fi
80   done
81   if test -z "$texmfmain" && test "x$prefix" = "xNONE"; then
82      # Still no texmfmain found, no prefix set, perhaps kpsewhich is
83      # installed and can help us out.
84      texmfmain=`kpsewhich --expand-path='$TEXMFMAIN'` 2>/dev/null
85   fi
86   texmfmain=`echo "$texmfmain" | sed 's,//*,/,g'`
87   if test -n "$texmfmain"; then
88     AC_MSG_RESULT("$texmfmain")
89   else
90     eval texmfmain="$datadir/texmf"
91     AC_MSG_RESULT([not found])
92     AC_MSG_WARN([The main texmf tree was not found at $texmfmain.
93   *****************************************************************
94   * Error: The main texmf tree was not found.                     *
95   * Use the --datadir option to specify its parent directory.     *
96   * If you do not have the files, you should be able to them from *
97   * the same place you got these sources from, or from one of the *
98   * CTAN hosts.                                                   *
99   *****************************************************************
100   Winging it by pretending $texmfmain is correct.])
101   fi
102 fi
103 AC_SUBST(texmfmain)