Sync with TL 36055; fixed a bug on setting mu unit; a better mp_initialize_decimal_math
[luatex.git] / source / m4 / kpse-setup.m4
blobb9c9bcce005888d860d22e015ce0706366529eba
1 # Private macros for the TeX Live (TL) tree.
2 # Copyright (C) 2009-2015 Peter Breitenlohner <tex-live@tug.org>
4 # This file is free software; the copyright holder
5 # gives unlimited permission to copy and/or distribute it,
6 # with or without modifications, as long as this notice is preserved.
8 # KPSE_SETUP(TOP-LEVEL)
9 # ---------------------
10 # Initialize path prefix kpse_TL to top-level TeX Live (TL) directory.
11 # Sinclude all withenable.ac files providing:
12 #   configure options --with-system-LIB, --with-LIB-includes, and --with-LIB-libdir
13 #     for libraries
14 #   configure option --disable-PKG or --enable-PKG for programs
15 #   additional program specific configure options (if any)
16 #   library dependencies for programs and libraries
17 AC_DEFUN([KPSE_SETUP], [dnl
18 AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
19 AC_REQUIRE([_KPSE_MSG_WARN_PREPARE])[]dnl
20 m4_define([kpse_TL], [$1])[]dnl
21 m4_define([kpse_indent_26], [28])[]dnl
22 AC_ARG_ENABLE([all-pkgs],
23               AS_HELP_STRING([--disable-all-pkgs],
24                              [do not build packages unless explicitly enabled]))[]dnl
25 test "x$enable_all_pkgs" = xno || enable_all_pkgs=yes
26 AC_ARG_ENABLE([native-texlive-build],
27               AS_HELP_STRING([--disable-native-texlive-build],
28                              [do not build for the TeX Live binary distribution]))[]dnl
29 AS_CASE([$enable_native_texlive_build],
30         [yes | no], [:],
31         [enable_native_texlive_build=yes
32          ac_configure_args="$ac_configure_args '--enable-native-texlive-build'"])
33 AS_CASE([$enable_largefile],
34         [yes | no], [:],
35         [enable_largefile=yes
36          ac_configure_args="$ac_configure_args '--enable-largefile'"])
37 AS_CASE([$enable_silent_rules],
38         [yes | no], [:],
39         [enable_silent_rules=no
40          ac_configure_args="$ac_configure_args '--disable-silent-rules'"])
41 AS_CASE([$enable_multiplatform],
42         [yes | no], [:],
43         [enable_multiplatform=$enable_native_texlive_build
44          ac_configure_args="$ac_configure_args '--enable-multiplatform=$enable_native_texlive_build'"])
45 AS_CASE([$enable_cxx_runtime_hack],
46         [yes | no], [:],
47         [enable_cxx_runtime_hack=$enable_native_texlive_build
48          ac_configure_args="$ac_configure_args '--enable-cxx-runtime-hack=$enable_native_texlive_build'"])
49 AS_CASE([$enable_libtool_hack],
50         [yes | no], [:],
51         [AS_CASE([$host_os],
52                  [do-not-match],
53                    [enable_libtool_hack=no],
54                  [enable_libtool_hack=yes])
55          ac_configure_args="$ac_configure_args '--enable-libtool-hack=$enable_libtool_hack'"])
56 AS_CASE([$enable_shared],
57         [no], [:],
58         [yes ], [AS_IF([test "x$enable_native_texlive_build" = xyes],
59                        [AC_MSG_ERROR([you can not use a shared Kpathsea library for a native TeX Live build])])],
60         [enable_shared=no
61          ac_configure_args="$ac_configure_args '--disable-shared'"])
62 dnl Automatically pass this option to all subdirectories.
63 AS_CASE([$enable_texlive_build],
64         [yes], [:],
65         [no], [AC_MSG_ERROR([you can not configure the TeX Live tree with `--disable-texlive-build'])],
66         [enable_texlive_build=yes
67          ac_configure_args="$ac_configure_args '--enable-texlive-build'"])
68 KPSE_OPTIONS
69 KPSE_ENABLE_CXX_HACK
70 KPSE_ENABLE_LT_HACK
71 KPSE_LIBS_PREPARE
72 KPSE_MKTEX_PREPARE
73 KPSE_WEB2C_PREPARE
74 KPSE_CHECK_WIN32
75 AS_CASE([$with_x:$kpse_cv_have_win32],
76         [yes:no | no:*], [:],
77         [yes:*], [AC_MSG_ERROR([you can not use `--with-x' for WIN32])],
78         [*:no], [with_x=yes
79                  AC_MSG_NOTICE([Assuming `--with-x'])
80                  ac_configure_args="$ac_configure_args '--with-x'"],
81         [with_x=no
82          AC_MSG_NOTICE([WIN32 -> `--without-x'])
83          ac_configure_args="$ac_configure_args '--without-x'"])
84 AS_CASE([$enable_luajittex],
85         [yes | no], [:],
86           [AS_CASE([$host],
87                    [alpha* | sparc* | x86_64-*-cygwin | powerpc-*-darwin* ],
88                      [AC_MSG_NOTICE([$host -> `--disable-luajittex'])
89                       ac_configure_args="$ac_configure_args '--disable-luajittex'"])])        
90 KPSE_FOR_PKGS([utils], [m4_sinclude(kpse_TL[utils/]Kpse_Pkg[/ac/withenable.ac])])
91 KPSE_FOR_PKGS([texk], [m4_sinclude(kpse_TL[texk/]Kpse_Pkg[/ac/withenable.ac])])
92 KPSE_FOR_PKGS([libs], [m4_sinclude(kpse_TL[libs/]Kpse_Pkg[/ac/withenable.ac])])
93 KPSE_FOR_PKGS([texlibs], [m4_sinclude(kpse_TL[texk/]Kpse_Pkg[/ac/withenable.ac])])
94 ]) # KPSE_SETUP
96 # KPSE_ENABLE_PROG(PROG, REQUIRED-LIBS, OPTIONS, [COMMENT])
97 # ---------------------------------------------------------
98 # Provide the configure option --enable-PROG if the option `disable' is
99 # specified, or -disable-PROG otherwise.
100 # Define the list of libraries required from the TL tree (if any).
101 # Options:
102 #          disable - do not build by default
103 #          native - impossible to cross compile
104 #          x - requires X11
105 AC_DEFUN([KPSE_ENABLE_PROG], [dnl
106 m4_define([have_]AS_TR_SH($1))[]dnl
107 m4_pushdef([Kpse_enable], m4_if(m4_index([ $3 ], [ disable ]), [-1], [yes], [no]))[]dnl
108 AC_ARG_ENABLE([$1],
109               AS_HELP_STRING([[--]m4_if(Kpse_enable, [yes], [dis], [en])[able-$1]],
110                               m4_if(Kpse_enable, [yes],
111                                     [do not ])[build the $1 ]m4_ifval([$4],
112                                                                       [($4) ])[package]))[]dnl
113 m4_if(m4_index([ $3 ], [ x ]), [-1], , [AS_IF([test "x$with_x" = xno],
114       [AS_CASE([$enable_[]AS_TR_SH($1)],
115                [""], [AC_MSG_NOTICE([`--without-x' -> `--disable-$1'])
116                       enable_[]AS_TR_SH($1)=no
117                       ac_configure_args="$ac_configure_args '--disable-$1'"],
118                [yes], [AC_MSG_ERROR([Sorry, incompatible options `--without-x' and `--enable-$1'])])])
119 ])[]dnl m4_if
120 AS_CASE([$enable_[]AS_TR_SH($1)],
121   m4_if(m4_index([ $3 ], [ native ]), [-1],
122         [[yes|no], []],
123         [[yes], [AS_IF([test "x$cross_compiling" = xyes],
124                        [AC_MSG_ERROR([Unable to cross compile $1])])],
125          [no], []]),
126   [m4_if(m4_index([ $3 ], [ native ]), [-1], ,
127          [if test "x$cross_compiling" = xyes; then
128             AC_MSG_NOTICE([Cross compiling -> `--disable-$1'])
129             enable_[]AS_TR_SH($1)=no
130             ac_configure_args="$ac_configure_args '--disable-$1'"
131           else])
132    enable_[]AS_TR_SH($1)=m4_if(Kpse_enable, [yes], [$enable_all_pkgs], [no])
133      AC_MSG_NOTICE([Assuming `--enable-$1=$enable_]AS_TR_SH($1)['])
134      ac_configure_args="$ac_configure_args '--enable-$1=$enable_[]AS_TR_SH($1)'"
135    m4_if(m4_index([ $3 ], [ native ]), [-1], , [fi])])
136 m4_popdef([Kpse_enable])[]dnl
137 m4_ifval([$2], [
138 test "x$enable_[]AS_TR_SH($1)" = xno || {
139 AC_FOREACH([Kpse_Lib], [$2], [  need_[]AS_TR_SH(Kpse_Lib)=yes
141 ])[]dnl m4_ifval
142 ]) # KPSE_ENABLE_PROG
144 # KPSE_WITH_LIB(LIB, REQUIRED-LIBS, OPTIONS)
145 # ------------------------------------------
146 # For generic libraries in libs/LIB.
147 # Unless the option `tree' is specified, provide the configure options
148 # --with-system-LIB, --with-LIB-includes, and --with-LIB-libdir.
149 # Define the list of libraries required from the TL tree (if any).
150 # Options:
151 #          tree - only use library from the TL tree
153 # At the top-level we build a (reversed) list of potential system libraries.
154 AC_DEFUN([KPSE_WITH_LIB], [_KPSE_WITH_LIB([libs], $@)])
155 m4_define([kpse_sys_libs_pkgs], [])[]dnl initialize the list.
157 # KPSE_WITH_TEXLIB(LIB, REQUIRED-LIBS, OPTIONS)
158 # ---------------------------------------------
159 # As above, but for TeX specific libraries in texk/LIB.
160 AC_DEFUN([KPSE_WITH_TEXLIB], [_KPSE_WITH_LIB([texk], $@)])
161 m4_define([kpse_sys_texk_pkgs], [])[]dnl initialize the list.
163 # _KPSE_WITH_LIB(DIR, LIB, REQUIRED-LIBS, OPTIONS)
164 # ------------------------------------------------
165 # Internal subroutine for KPSE_WITH_LIB and KPSE_WITH_TEXLIB.
166 m4_define([_KPSE_WITH_LIB], [dnl
167 m4_define([have_]AS_TR_SH($2))[]dnl
168 m4_if(m4_index([ $4 ], [ tree ]), [-1],
169 [KPSE_]AS_TR_CPP([$2])[_OPTIONS([with-system])[]dnl
170 if test "x$with_system_[]AS_TR_SH($2)" = x; then
171   if test -f $srcdir/kpse_TL[]$1/$2/configure; then
172     AC_MSG_NOTICE([Assuming `$2' headers and library from TL tree])
173     with_system_[]AS_TR_SH($2)=no
174   else
175     AC_MSG_NOTICE([Assuming installed `$2' headers and library])
176     with_system_[]AS_TR_SH($2)=yes
177   fi
178   ac_configure_args="$ac_configure_args '--with-system-$2=$with_system_[]AS_TR_SH($2)'"
179 m4_ifset([kpse_TL], [], dnl top level only
180 [elif test "x$with_system_[]AS_TR_SH($2)" = xyes; then
181   AC_MSG_NOTICE([Using installed `$2' headers and library])
182 else
183   AC_MSG_NOTICE([Using `$2' headers and library from TL tree])
184   if test "x$with_system_[]AS_TR_SH($2)" != xno; then
185     with_system_[]AS_TR_SH($2)=no
186     ac_configure_args="$ac_configure_args '--without-system-$2'"
187   fi
188 m4_define([kpse_sys_$1_pkgs],
189           [$2]m4_ifval([kpse_sys_$1_pkgs], [ _m4_defn([kpse_sys_$1_pkgs])]))[]dnl
190 ])[]dnl m4_ifset
192 m4_ifval([$3],
193 [if test "x$with_system_[]AS_TR_SH($2)" = xyes; then
194 AC_FOREACH([Kpse_Lib], [$3],
195 [  if test "x$with_system_[]AS_TR_SH(Kpse_Lib)" = x; then
196     AC_MSG_NOTICE([  ->  installed `AS_TR_SH(Kpse_Lib)' headers and library])
197     with_system_[]AS_TR_SH(Kpse_Lib)=yes
198     ac_configure_args="$ac_configure_args '--with-system-Kpse_Lib'"
199   elif test "x$with_system_[]AS_TR_SH(Kpse_Lib)" != xyes; then
200     AC_MSG_ERROR([Sorry, `--with-system-$2' requires `--with-system-Kpse_Lib'])
201   fi
202 ])fi
203 ])[]dnl m4_ifval
204 ])[]dnl m4_if
205 m4_ifval([$3], [
206 test "x$need_[]AS_TR_SH($2)" = xyes && {
207 AC_FOREACH([Kpse_Lib], [$3], [  need_[]AS_TR_SH(Kpse_Lib)=yes
209 ])[]dnl m4_ifval
210 ]) # _KPSE_WITH_LIB
212 # KPSE_TRY_LIB(LIB, PROLOGUE, BODY)
213 # ---------------------------------
214 # When the user requests to use an installed version of a required library,
215 # check that the flags derived from --with-LIB-includes and --with-LIB-libdir
216 # or determined otherwise provide the required functionality.
217 AC_DEFUN([KPSE_TRY_LIB], [dnl
218 if test "x$need_[]AS_TR_SH($1):$with_system_[]AS_TR_SH($1)" = xyes:yes; then
219   AC_MSG_CHECKING([requested system `$1' library])
220   CPPFLAGS="$AS_TR_CPP($1)_INCLUDES $CPPFLAGS"
221   LIBS="$AS_TR_CPP($1)_LIBS $LIBS"
222   AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],
223                  [syslib_used=yes kpse_res=ok],
224                  [syslib_status=no kpse_res=failed])
225   AC_MSG_RESULT([$kpse_res])
227 ]) # KPSE_TRY_LIB
229 # KPSE_TRY_LIBXX(LIB, PROLOGUE, BODY)
230 # -----------------------------------
231 # As above, but for C++.
232 AC_DEFUN([KPSE_TRY_LIBXX], [dnl
233 AC_REQUIRE([AC_PROG_CXX])[]dnl
234 AC_LANG_PUSH([C++])[]dnl
235 KPSE_TRY_LIB($@)[]dnl
236 AC_LANG_POP([C++])[]dnl
237 ]) # KPSE_TRY_LIBXX
239 # KPSE_RECURSE_LIBS(LIST, TEXT, [PREFIX])
240 # ---------------------------------------
241 # Determine which of the libraries in kpse_LIST_pkgs to build.
242 AC_DEFUN([KPSE_RECURSE_LIBS], [dnl
243 m4_pushdef([Kpse_add], [$][1="$3Kpse_Pkg $$][1"])[]dnl prepend
244 _KPSE_RECURSE([$1], [$2 libraries],
245               [test "x$with_system_[]Kpse_pkg" != xyes && test "x$need_[]Kpse_pkg" = xyes],
246               [$3])[]dnl
247 m4_popdef([Kpse_add])[]dnl
248 ]) # KPSE_RECURSE_LIBS
250 # KPSE_RECURSE_PROGS(LIST, TEXT)
251 # ------------------------------
252 # Determine which of the programs in kpse_LIST_pkgs to build.
253 AC_DEFUN([KPSE_RECURSE_PROGS], [dnl
254 m4_pushdef([Kpse_add], [$][1="$$][1 Kpse_Pkg"])[]dnl append
255 _KPSE_RECURSE([$1], [$2 programs],
256               [test "x$enable_[]Kpse_pkg" = xyes])[]dnl
257 m4_popdef([Kpse_add])[]dnl
258 ]) # KPSE_RECURSE_PROGS
260 # _KPSE_RECURSE(LIST, TEXT, COND, [PREFIX])
261 # -----------------------------------------
262 # Internal subroutine.  Determine which of the libraries or programs in
263 # kpse_LIST_pkgs to build, and set output variables MAKE_SUBDIRS and
264 # CONF_SUBDIRS.  Cause 'make dist', 'configure -hr', and 'autoreconf'
265 # to recurse into all existing ones.
266 m4_define([_KPSE_RECURSE], [dnl
267 AC_MSG_CHECKING([for $2 to build])
268 MAKE_SUBDIRS=
269 CONF_SUBDIRS=
270 KPSE_FOR_PKGS([$1], [dnl
271 m4_ifdef([have_]Kpse_pkg, [dnl
272 if test -x $srcdir/$4Kpse_Pkg/configure; then
273   $3 && Kpse_add([MAKE_SUBDIRS])
274   Kpse_add([CONF_SUBDIRS])
275   if false; then
276     AC_CONFIG_SUBDIRS($4Kpse_Pkg)
277   fi
279 ])[]dnl m4_ifdef
281 AC_SUBST([MAKE_SUBDIRS])[]dnl
282 AC_SUBST([CONF_SUBDIRS])[]dnl
283 AC_MSG_RESULT([$MAKE_SUBDIRS])[]dnl
284 ]) # _KPSE_RECURSE