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
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],
31 [enable_native_texlive_build=yes
32 ac_configure_args="$ac_configure_args '--enable-native-texlive-build'"])
33 AS_CASE([$enable_largefile],
36 ac_configure_args="$ac_configure_args '--enable-largefile'"])
37 AS_CASE([$enable_silent_rules],
39 [enable_silent_rules=no
40 ac_configure_args="$ac_configure_args '--disable-silent-rules'"])
41 AS_CASE([$enable_multiplatform],
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],
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],
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:$host_os],
57 [no:* | yes:mingw* | yes:cygwin*], [:],
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])])],
61 ac_configure_args="$ac_configure_args '--disable-shared'"])
62 dnl Automatically pass this option to all subdirectories.
63 AS_CASE([$enable_texlive_build],
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'"])
75 AS_CASE([$with_x:$kpse_cv_have_win32],
77 [yes:*], [AC_MSG_ERROR([you can not use `--with-x' for WIN32])],
79 AC_MSG_NOTICE([Assuming `--with-x'])
80 ac_configure_args="$ac_configure_args '--with-x'"],
82 AC_MSG_NOTICE([WIN32 -> `--without-x'])
83 ac_configure_args="$ac_configure_args '--without-x'"])
84 AC_FOREACH([Kpse_Pkg], [luajittex mfluajit], [dnl
85 AS_CASE([$enable_]Kpse_Pkg,
88 [alpha* | sparc* | x86_64-*-cygwin | powerpc-*-darwin* ],
89 [AC_MSG_NOTICE([$host -> `--disable-]Kpse_Pkg['])
90 ac_configure_args="$ac_configure_args '--disable-]Kpse_Pkg['"])])
92 KPSE_FOR_PKGS([utils], [m4_sinclude(kpse_TL[utils/]Kpse_Pkg[/ac/withenable.ac])])
93 KPSE_FOR_PKGS([texk], [m4_sinclude(kpse_TL[texk/]Kpse_Pkg[/ac/withenable.ac])])
94 KPSE_FOR_PKGS([libs], [m4_sinclude(kpse_TL[libs/]Kpse_Pkg[/ac/withenable.ac])])
95 KPSE_FOR_PKGS([texlibs], [m4_sinclude(kpse_TL[texk/]Kpse_Pkg[/ac/withenable.ac])])
98 # KPSE_ENABLE_PROG(PROG, REQUIRED-LIBS, OPTIONS, [COMMENT])
99 # ---------------------------------------------------------
100 # Provide the configure option --enable-PROG if the option `disable' is
101 # specified, or -disable-PROG otherwise.
102 # Define the list of libraries required from the TL tree (if any).
104 # disable - do not build by default
105 # native - impossible to cross compile
107 AC_DEFUN([KPSE_ENABLE_PROG], [dnl
108 m4_define([have_]AS_TR_SH($1))[]dnl
109 m4_pushdef([Kpse_enable], m4_if(m4_index([ $3 ], [ disable ]), [-1], [yes], [no]))[]dnl
111 AS_HELP_STRING([[--]m4_if(Kpse_enable, [yes], [dis], [en])[able-$1]],
112 m4_if(Kpse_enable, [yes],
113 [do not ])[build the $1 ]m4_ifval([$4],
114 [($4) ])[package]))[]dnl
115 m4_if(m4_index([ $3 ], [ x ]), [-1], , [AS_IF([test "x$with_x" = xno],
116 [AS_CASE([$enable_[]AS_TR_SH($1)],
117 [""], [AC_MSG_NOTICE([`--without-x' -> `--disable-$1'])
118 enable_[]AS_TR_SH($1)=no
119 ac_configure_args="$ac_configure_args '--disable-$1'"],
120 [yes], [AC_MSG_ERROR([Sorry, incompatible options `--without-x' and `--enable-$1'])])])
122 AS_CASE([$enable_[]AS_TR_SH($1)],
123 m4_if(m4_index([ $3 ], [ native ]), [-1],
125 [[yes], [AS_IF([test "x$cross_compiling" = xyes],
126 [AC_MSG_ERROR([Unable to cross compile $1])])],
128 [m4_if(m4_index([ $3 ], [ native ]), [-1], ,
129 [if test "x$cross_compiling" = xyes; then
130 AC_MSG_NOTICE([Cross compiling -> `--disable-$1'])
131 enable_[]AS_TR_SH($1)=no
132 ac_configure_args="$ac_configure_args '--disable-$1'"
134 enable_[]AS_TR_SH($1)=m4_if(Kpse_enable, [yes], [$enable_all_pkgs], [no])
135 AC_MSG_NOTICE([Assuming `--enable-$1=$enable_]AS_TR_SH($1)['])
136 ac_configure_args="$ac_configure_args '--enable-$1=$enable_[]AS_TR_SH($1)'"
137 m4_if(m4_index([ $3 ], [ native ]), [-1], , [fi])])
138 m4_popdef([Kpse_enable])[]dnl
140 test "x$enable_[]AS_TR_SH($1)" = xno || {
141 AC_FOREACH([Kpse_Lib], [$2], [ need_[]AS_TR_SH(Kpse_Lib)=yes
144 ]) # KPSE_ENABLE_PROG
146 # KPSE_WITH_LIB(LIB, REQUIRED-LIBS, OPTIONS)
147 # ------------------------------------------
148 # For generic libraries in libs/LIB.
149 # Unless the option `tree' is specified, provide the configure options
150 # --with-system-LIB, --with-LIB-includes, and --with-LIB-libdir.
151 # Define the list of libraries required from the TL tree (if any).
153 # tree - only use library from the TL tree
155 # At the top-level we build a (reversed) list of potential system libraries.
156 AC_DEFUN([KPSE_WITH_LIB], [_KPSE_WITH_LIB([libs], $@)])
157 m4_define([kpse_sys_libs_pkgs], [])[]dnl initialize the list.
159 # KPSE_WITH_TEXLIB(LIB, REQUIRED-LIBS, OPTIONS)
160 # ---------------------------------------------
161 # As above, but for TeX specific libraries in texk/LIB.
162 AC_DEFUN([KPSE_WITH_TEXLIB], [_KPSE_WITH_LIB([texk], $@)])
163 m4_define([kpse_sys_texk_pkgs], [])[]dnl initialize the list.
165 # _KPSE_WITH_LIB(DIR, LIB, REQUIRED-LIBS, OPTIONS)
166 # ------------------------------------------------
167 # Internal subroutine for KPSE_WITH_LIB and KPSE_WITH_TEXLIB.
168 m4_define([_KPSE_WITH_LIB], [dnl
169 m4_define([have_]AS_TR_SH($2))[]dnl
170 m4_if(m4_index([ $4 ], [ tree ]), [-1],
171 [KPSE_]AS_TR_CPP([$2])[_OPTIONS([with-system])[]dnl
172 if test "x$with_system_[]AS_TR_SH($2)" = x; then
173 if test -f $srcdir/kpse_TL[]$1/$2/configure; then
174 AC_MSG_NOTICE([Assuming `$2' headers and library from TL tree])
175 with_system_[]AS_TR_SH($2)=no
177 AC_MSG_NOTICE([Assuming installed `$2' headers and library])
178 with_system_[]AS_TR_SH($2)=yes
180 ac_configure_args="$ac_configure_args '--with-system-$2=$with_system_[]AS_TR_SH($2)'"
181 m4_ifset([kpse_TL], [], dnl top level only
182 [elif test "x$with_system_[]AS_TR_SH($2)" = xyes; then
183 AC_MSG_NOTICE([Using installed `$2' headers and library])
185 AC_MSG_NOTICE([Using `$2' headers and library from TL tree])
186 if test "x$with_system_[]AS_TR_SH($2)" != xno; then
187 with_system_[]AS_TR_SH($2)=no
188 ac_configure_args="$ac_configure_args '--without-system-$2'"
190 m4_define([kpse_sys_$1_pkgs],
191 [$2]m4_ifval([kpse_sys_$1_pkgs], [ _m4_defn([kpse_sys_$1_pkgs])]))[]dnl
195 [if test "x$with_system_[]AS_TR_SH($2)" = xyes; then
196 AC_FOREACH([Kpse_Lib], [$3],
197 [ if test "x$with_system_[]AS_TR_SH(Kpse_Lib)" = x; then
198 AC_MSG_NOTICE([ -> installed `AS_TR_SH(Kpse_Lib)' headers and library])
199 with_system_[]AS_TR_SH(Kpse_Lib)=yes
200 ac_configure_args="$ac_configure_args '--with-system-Kpse_Lib'"
201 elif test "x$with_system_[]AS_TR_SH(Kpse_Lib)" != xyes; then
202 AC_MSG_ERROR([Sorry, `--with-system-$2' requires `--with-system-Kpse_Lib'])
208 test "x$need_[]AS_TR_SH($2)" = xyes && {
209 AC_FOREACH([Kpse_Lib], [$3], [ need_[]AS_TR_SH(Kpse_Lib)=yes
214 # KPSE_TRY_LIB(LIB, PROLOGUE, BODY)
215 # ---------------------------------
216 # When the user requests to use an installed version of a required library,
217 # check that the flags derived from --with-LIB-includes and --with-LIB-libdir
218 # or determined otherwise provide the required functionality.
219 AC_DEFUN([KPSE_TRY_LIB], [dnl
220 if test "x$need_[]AS_TR_SH($1):$with_system_[]AS_TR_SH($1)" = xyes:yes; then
221 AC_MSG_CHECKING([requested system `$1' library])
222 CPPFLAGS="$AS_TR_CPP($1)_INCLUDES $CPPFLAGS"
223 LIBS="$AS_TR_CPP($1)_LIBS $LIBS"
224 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],
225 [syslib_used=yes kpse_res=ok],
226 [syslib_status=no kpse_res=failed])
227 AC_MSG_RESULT([$kpse_res])
231 # KPSE_TRY_LIBXX(LIB, PROLOGUE, BODY)
232 # -----------------------------------
233 # As above, but for C++.
234 AC_DEFUN([KPSE_TRY_LIBXX], [dnl
235 AC_REQUIRE([AC_PROG_CXX])[]dnl
236 AC_LANG_PUSH([C++])[]dnl
237 KPSE_TRY_LIB($@)[]dnl
238 AC_LANG_POP([C++])[]dnl
241 # KPSE_RECURSE_LIBS(LIST, TEXT, [PREFIX])
242 # ---------------------------------------
243 # Determine which of the libraries in kpse_LIST_pkgs to build.
244 AC_DEFUN([KPSE_RECURSE_LIBS], [dnl
245 m4_pushdef([Kpse_add], [$][1="$3Kpse_Pkg $$][1"])[]dnl prepend
246 _KPSE_RECURSE([$1], [$2 libraries],
247 [test "x$with_system_[]Kpse_pkg" != xyes && test "x$need_[]Kpse_pkg" = xyes],
249 m4_popdef([Kpse_add])[]dnl
250 ]) # KPSE_RECURSE_LIBS
252 # KPSE_RECURSE_PROGS(LIST, TEXT)
253 # ------------------------------
254 # Determine which of the programs in kpse_LIST_pkgs to build.
255 AC_DEFUN([KPSE_RECURSE_PROGS], [dnl
256 m4_pushdef([Kpse_add], [$][1="$$][1 Kpse_Pkg"])[]dnl append
257 _KPSE_RECURSE([$1], [$2 programs],
258 [test "x$enable_[]Kpse_pkg" = xyes])[]dnl
259 m4_popdef([Kpse_add])[]dnl
260 ]) # KPSE_RECURSE_PROGS
262 # _KPSE_RECURSE(LIST, TEXT, COND, [PREFIX])
263 # -----------------------------------------
264 # Internal subroutine. Determine which of the libraries or programs in
265 # kpse_LIST_pkgs to build, and set output variables MAKE_SUBDIRS and
266 # CONF_SUBDIRS. Cause 'make dist', 'configure -hr', and 'autoreconf'
267 # to recurse into all existing ones.
268 m4_define([_KPSE_RECURSE], [dnl
269 AC_MSG_CHECKING([for $2 to build])
272 KPSE_FOR_PKGS([$1], [dnl
273 m4_ifdef([have_]Kpse_pkg, [dnl
274 if test -x $srcdir/$4Kpse_Pkg/configure; then
275 $3 && Kpse_add([MAKE_SUBDIRS])
276 Kpse_add([CONF_SUBDIRS])
278 AC_CONFIG_SUBDIRS($4Kpse_Pkg)
283 AC_SUBST([MAKE_SUBDIRS])[]dnl
284 AC_SUBST([CONF_SUBDIRS])[]dnl
285 AC_MSG_RESULT([$MAKE_SUBDIRS])[]dnl