Debian Codegraph @

m4/kpse-setup.m4

raw
1 # $Id: kpse-setup.m4 75857 2025-07-22 16:56:22Z karl $
2 # Private macros for the TeX Live (TL) tree.
3 # Copyright 2015-2025 Karl Berry <[email protected]>
4 # Copyright 2009-2015 Peter Breitenlohner <[email protected]>
5 #
6 # This file is free software; the copyright holder
7 # gives unlimited permission to copy and/or distribute it,
8 # with or without modifications, as long as this notice is preserved.
9
10 # KPSE_SETUP(TOP-LEVEL)
11 # ---------------------
12 # Initialize path prefix kpse_TL to top-level TeX Live (TL) directory.
13 # Sinclude all pkgdir/ac/withenable.ac files, which are supposed to provide:
14 # configure options for libraries:
15 # --with-system-LIB --with-LIB-includes --with-LIB-libdir
16 # configure options for programs:
17 # --disable-PROG --enable-PROG
18 # additional program specific configure options (if any)
19 # library dependencies for programs and libraries
20 AC_DEFUN([KPSE_SETUP], [dnl
21 echo 'tldbg:[$0] called (toplevel=[$1])' >&AS_MESSAGE_LOG_FD
22 AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
23 AC_REQUIRE([_KPSE_MSG_WARN_PREPARE])[]dnl
24 m4_define([kpse_TL], [$1])[]dnl
25 m4_define([kpse_indent_26], [28])[]dnl
26 AC_ARG_ENABLE([all-pkgs],
27 AS_HELP_STRING([--disable-all-pkgs],
28 [do not build packages unless explicitly enabled]))[]dnl
29 test "x$enable_all_pkgs" = xno || enable_all_pkgs=yes
30 AC_ARG_ENABLE([native-texlive-build],
31 AS_HELP_STRING([--disable-native-texlive-build],
32 [do not build for the TeX Live binary distribution]))[]dnl
33 AS_CASE([$enable_native_texlive_build],
34 [yes | no], [:],
35 [enable_native_texlive_build=yes
36 ac_configure_args="$ac_configure_args '--enable-native-texlive-build'"])
37 AS_CASE([$enable_largefile],
38 [yes | no], [:],
39 [enable_largefile=yes
40 ac_configure_args="$ac_configure_args '--enable-largefile'"])
41 AS_CASE([$enable_silent_rules],
42 [yes | no], [:],
43 [enable_silent_rules=no
44 ac_configure_args="$ac_configure_args '--disable-silent-rules'"])
45 AS_CASE([$enable_multiplatform],
46 [yes | no], [:],
47 [enable_multiplatform=$enable_native_texlive_build
48 ac_configure_args="$ac_configure_args '--enable-multiplatform=$enable_native_texlive_build'"])
49 AS_CASE([$enable_cxx_runtime_hack],
50 [yes | no], [:],
51 [enable_cxx_runtime_hack=$enable_native_texlive_build
52 ac_configure_args="$ac_configure_args '--enable-cxx-runtime-hack=$enable_native_texlive_build'"])
53 AS_CASE([$enable_libtool_hack],
54 [yes | no], [:],
55 [AS_CASE([$host_os],
56 [do-not-match],
57 [enable_libtool_hack=no],
58 [enable_libtool_hack=yes])
59 ac_configure_args="$ac_configure_args '--enable-libtool-hack=$enable_libtool_hack'"])
60 AS_CASE([$enable_shared:$host_os],
61 [no:* | yes:mingw* | yes:cygwin*], [:],
62 [yes:* ], [AS_IF([test "x$enable_native_texlive_build" = xyes],
63 [AC_MSG_ERROR([you can not use a shared Kpathsea library for a native TeX Live build])])],
64 [enable_shared=no
65 ac_configure_args="$ac_configure_args '--disable-shared'"])
66 dnl Automatically pass this option to all subdirectories.
67 AS_CASE([$enable_texlive_build],
68 [yes], [:],
69 [no], [AC_MSG_ERROR([you can not configure the TeX Live tree with `--disable-texlive-build'])],
70 [enable_texlive_build=yes
71 ac_configure_args="$ac_configure_args '--enable-texlive-build'"])
72 KPSE_OPTIONS
73 KPSE_ENABLE_CXX_HACK
74 KPSE_ENABLE_LT_HACK
75 KPSE_LIBS_PREPARE
76 KPSE_MKTEX_PREPARE
77 KPSE_WEB2C_PREPARE
78
79 # We must enable system extensions before any compiler call to avoid
80 # (valid) autoconf warnings. Because different configure.ac's use
81 # different kpse setup routines, we call the ac_use_system_extensions
82 # macro both here and in kpse_basic (in kpse-common.m4).
83 #
84 # Fortunately, Autoconf defines the system_extensions macro to only have
85 # any effect once (with ac_defun_once), so it's harmless to call it
86 # multiple time.
87 #
88 # LuaTeX requires system extensions for socket support. Also, since
89 # SyncTeX, some libraries, and others unconditionally #define
90 # GNU_SOURCE, it seems more consistent to always use it.
91 #
92 AC_USE_SYSTEM_EXTENSIONS
93
94 # this macro, kpse_check_win32, is the first compiler call for
95 # configure.ac files that use this function (kpse setup).
96 KPSE_CHECK_WIN32
97 # end call to kpse_check_win32.
98
99 AS_CASE([$with_x:$kpse_cv_have_win32],
100 [yes:no | no:*], [:],
101 [yes:*], [AC_MSG_ERROR([you can not use `--with-x' for Windows])],
102 [*:no], [with_x=yes
103 AC_MSG_NOTICE([Assuming `--with-x'])
104 ac_configure_args="$ac_configure_args '--with-x'"],
105 [with_x=no
106 AC_MSG_NOTICE([WIN32 -> `--without-x'])
107 ac_configure_args="$ac_configure_args '--without-x'"])
108 AC_FOREACH([Kpse_Pkg], [luajittex luajithbtex mfluajit mfluajit-nowin], [dnl
109 AS_CASE([$enable_[]AS_TR_SH([Kpse_Pkg])],
110 [yes | no], [:],
111 [AS_CASE([$host],
112 [alpha* | sparc* | x86_64-*-solaris* | powerpc* ],
113 [AC_MSG_NOTICE([$host -> `--disable-]Kpse_Pkg['])
114 ac_configure_args="$ac_configure_args '--disable-]Kpse_Pkg['"])])
115 ])
116 KPSE_FOR_PKGS([utils], [m4_sinclude(kpse_TL[utils/]Kpse_Pkg[/ac/withenable.ac])])
117 KPSE_FOR_PKGS([texk], [m4_sinclude(kpse_TL[texk/]Kpse_Pkg[/ac/withenable.ac])])
118 KPSE_FOR_PKGS([libs], [m4_sinclude(kpse_TL[libs/]Kpse_Pkg[/ac/withenable.ac])])
119 KPSE_FOR_PKGS([texlibs], [m4_sinclude(kpse_TL[texk/]Kpse_Pkg[/ac/withenable.ac])])
120
121 # end of kpse_setup macro.
122 echo 'tldbg:[$0] done (toplevel=[$1])' >&AS_MESSAGE_LOG_FD
123 ]) # end kpse_setup
124
125 # KPSE_ENABLE_PROG(PROG, REQUIRED-LIBS, OPTIONS, [COMMENT])
126 # ---------------------------------------------------------
127 # Provide the configure option --enable-PROG if the option `disable' is
128 # specified, or -disable-PROG otherwise.
129 # Define the list of libraries required from the TL tree (if any).
130 # Options:
131 # disable - do not build by default
132 # native - impossible to cross compile
133 # x - requires X11
134 # If given, the COMMENT is used in the help string.
135 AC_DEFUN([KPSE_ENABLE_PROG], [dnl
136 echo 'tldbg:[$0] called: prog=[$1], libs=[$2], options=[$3], comment=[$4].' >&AS_MESSAGE_LOG_FD
137 m4_define([have_]AS_TR_SH($1))[]dnl
138 m4_pushdef([Kpse_enable], m4_if(m4_index([ $3 ], [ disable ]), [-1], [yes], [no]))[]dnl
139 echo 'tldbg:[$0] enabling: $1 -> Kpse_enable' >&AS_MESSAGE_LOG_FD
140 AC_ARG_ENABLE([$1],
141 AS_HELP_STRING([[--]m4_if(Kpse_enable, [yes], [dis], [en])[able-$1]],
142 m4_if(Kpse_enable, [yes],
143 [do not ])[build the $1 ]m4_ifval([$4],
144 [($4) ])[package]))[]dnl
145 #
146 m4_if(m4_index([ $3 ], [ x ]), [-1], , [AS_IF([test "x$with_x" = xno],
147 [AS_CASE([$enable_[]AS_TR_SH($1)],
148 [""], [AC_MSG_NOTICE([`--without-x' -> `--disable-$1'])
149 enable_[]AS_TR_SH($1)=no
150 ac_configure_args="$ac_configure_args '--disable-$1'"],
151 [yes], [AC_MSG_ERROR([Sorry, incompatible options `--without-x' and `--enable-$1'])])])
152 ])[]dnl end m4_if
153 #
154 AS_CASE([$enable_[]AS_TR_SH($1)],
155 m4_if(m4_index([ $3 ], [ native ]), [-1],
156 [[yes|no], []],
157 [[yes], [AS_IF([test "x$cross_compiling" = xyes],
158 [AC_MSG_ERROR([Unable to cross compile $1])])],
159 [no], []]),
160 [m4_if(m4_index([ $3 ], [ native ]), [-1], ,
161 [if test "x$cross_compiling" = xyes; then
162 AC_MSG_NOTICE([Cross compiling -> `--disable-$1'])
163 enable_[]AS_TR_SH($1)=no
164 ac_configure_args="$ac_configure_args '--disable-$1'"
165 else])
166 enable_[]AS_TR_SH($1)=m4_if(Kpse_enable, [yes], [$enable_all_pkgs], [no])
167 AC_MSG_NOTICE([Assuming `--enable-$1=$enable_]AS_TR_SH($1)['])
168 ac_configure_args="$ac_configure_args '--enable-$1=$enable_[]AS_TR_SH($1)'"
169 m4_if(m4_index([ $3 ], [ native ]), [-1], , [fi])])
170 m4_popdef([Kpse_enable])[]dnl
171 #
172 # setting need_ for each of [$2]:
173 m4_ifval([$2], [
174 test "x$enable_[]AS_TR_SH($1)" = xno || {
175 AC_FOREACH([Kpse_Lib], [$2], [ need_[]AS_TR_SH(Kpse_Lib)=yes
176 ])}
177 ])[]dnl end m4_ifval
178
179 echo 'tldbg:[$0] done (prog=[$1])' >&AS_MESSAGE_LOG_FD
180 ]) # end kpse_enable_prog
181
182 # KPSE_WITH_LIB(LIB, REQUIRED-LIBS, OPTIONS)
183 # ------------------------------------------
184 # For generic libraries in libs/LIB.
185 # Unless the option `tree' is specified, provide the configure options
186 # --with-system-LIB, --with-LIB-includes, and --with-LIB-libdir.
187 # Define the list of libraries required from the TL tree (if any).
188 # Options:
189 # tree - only use library from the TL tree
190 #
191 # At the top-level we build a (reversed) list of potential system libraries.
192 AC_DEFUN([KPSE_WITH_LIB], [_KPSE_WITH_LIB([libs], $@)])
193 m4_define([kpse_sys_libs_pkgs], [])[]dnl initialize the list.
194
195 # KPSE_WITH_TEXLIB(LIB, REQUIRED-LIBS, OPTIONS)
196 # ---------------------------------------------
197 # As above, but for TeX specific libraries in texk/LIB.
198 AC_DEFUN([KPSE_WITH_TEXLIB], [_KPSE_WITH_LIB([texk], $@)])
199 m4_define([kpse_sys_texk_pkgs], [])[]dnl initialize the list.
200
201 # _KPSE_WITH_LIB(DIR, LIB, REQUIRED-LIBS, OPTIONS)
202 # ------------------------------------------------
203 # Internal subroutine for KPSE_WITH_LIB and KPSE_WITH_TEXLIB.
204 m4_define([_KPSE_WITH_LIB], [dnl
205 m4_define([have_]AS_TR_SH($2))[]dnl
206 m4_if(m4_index([ $4 ], [ tree ]), [-1],
207 [KPSE_]AS_TR_CPP([$2])[_OPTIONS([with-system])[]dnl
208 if test "x$with_system_[]AS_TR_SH($2)" = x; then
209 if test -f $srcdir/kpse_TL[]$1/$2/configure; then
210 AC_MSG_NOTICE([Assuming `$2' headers and library from TL tree])
211 with_system_[]AS_TR_SH($2)=no
212 else
213 AC_MSG_NOTICE([Assuming installed `$2' headers and library])
214 with_system_[]AS_TR_SH($2)=yes
215 fi
216 ac_configure_args="$ac_configure_args '--with-system-$2=$with_system_[]AS_TR_SH($2)'"
217 m4_ifset([kpse_TL], [], dnl top level only
218 [elif test "x$with_system_[]AS_TR_SH($2)" = xyes; then
219 AC_MSG_NOTICE([Using installed `$2' headers and library])
220 else
221 AC_MSG_NOTICE([Using `$2' headers and library from TL tree])
222 if test "x$with_system_[]AS_TR_SH($2)" != xno; then
223 with_system_[]AS_TR_SH($2)=no
224 ac_configure_args="$ac_configure_args '--without-system-$2'"
225 fi
226 m4_define([kpse_sys_$1_pkgs],
227 [$2]m4_ifval([kpse_sys_$1_pkgs], [ _m4_defn([kpse_sys_$1_pkgs])]))[]dnl
228 ])[]dnl m4_ifset
229 fi
230 m4_ifval([$3],
231 [if test "x$with_system_[]AS_TR_SH($2)" = xyes; then
232 AC_FOREACH([Kpse_Lib], [$3],
233 [ if test "x$with_system_[]AS_TR_SH(Kpse_Lib)" = x; then
234 AC_MSG_NOTICE([ -> installed `AS_TR_SH(Kpse_Lib)' headers and library])
235 with_system_[]AS_TR_SH(Kpse_Lib)=yes
236 ac_configure_args="$ac_configure_args '--with-system-Kpse_Lib'"
237 elif test "x$with_system_[]AS_TR_SH(Kpse_Lib)" != xyes; then
238 AC_MSG_ERROR([Sorry, `--with-system-$2' requires `--with-system-Kpse_Lib'])
239 fi
240 ])fi
241 ])[]dnl m4_ifval
242 ])[]dnl m4_if
243 m4_ifval([$3], [
244 test "x$need_[]AS_TR_SH($2)" = xyes && {
245 AC_FOREACH([Kpse_Lib], [$3], [ need_[]AS_TR_SH(Kpse_Lib)=yes
246 ])}
247 ])[]dnl m4_ifval
248 ]) # end _kpse_with_lib
249
250 # KPSE_TRY_LIB(LIB, PROLOGUE, BODY)
251 # ---------------------------------
252 # When the user requests to use an installed version of a required library,
253 # check that the flags derived from --with-LIB-includes and --with-LIB-libdir
254 # or determined otherwise provide the required functionality.
255 AC_DEFUN([KPSE_TRY_LIB], [dnl
256 if test "x$need_[]AS_TR_SH($1):$with_system_[]AS_TR_SH($1)" = xyes:yes; then
257 AC_MSG_CHECKING([requested system `$1' library])
258 CPPFLAGS="$AS_TR_CPP($1)_INCLUDES $CPPFLAGS"
259 LIBS="$AS_TR_CPP($1)_LIBS $LIBS"
260 AC_LINK_IFELSE([AC_LANG_PROGRAM([[$2]], [[$3]])],
261 [syslib_used=yes kpse_res=ok],
262 [syslib_status=no kpse_res=failed])
263 AC_MSG_RESULT([$kpse_res])
264 fi
265 ]) # end kpse_try_lib
266
267 # KPSE_TRY_LIBXX(LIB, PROLOGUE, BODY)
268 # -----------------------------------
269 # As above, but for C++.
270 AC_DEFUN([KPSE_TRY_LIBXX], [dnl
271 AC_REQUIRE([AC_PROG_CXX])[]dnl
272 AC_LANG_PUSH([C++])[]dnl
273 KPSE_TRY_LIB($@)[]dnl
274 AC_LANG_POP([C++])[]dnl
275 ]) # end kpse_try_libxx
276
277 # KPSE_RECURSE_LIBS(LIST, TEXT, [PREFIX])
278 # ---------------------------------------
279 # Determine which of the libraries in kpse_LIST_pkgs to build.
280 AC_DEFUN([KPSE_RECURSE_LIBS], [dnl
281 m4_pushdef([Kpse_add], [$][1="$3Kpse_Pkg $$][1"])[]dnl prepend
282 _KPSE_RECURSE([$1], [$2 libraries],
283 [test "x$with_system_[]Kpse_pkg" != xyes && test "x$need_[]Kpse_pkg" = xyes],
284 [$3])[]dnl
285 m4_popdef([Kpse_add])[]dnl
286 ]) # end kpse_recurse_libs
287
288 # KPSE_RECURSE_PROGS(LIST, TEXT)
289 # ------------------------------
290 # Determine which of the programs in kpse_LIST_pkgs to build.
291 AC_DEFUN([KPSE_RECURSE_PROGS], [dnl
292 m4_pushdef([Kpse_add], [$][1="$$][1 Kpse_Pkg"])[]dnl append
293 echo 'tldbg:[$0] calling with: $1 $2' >&AS_MESSAGE_LOG_FD
294 _KPSE_RECURSE([$1], [$2 programs],
295 [test "x$enable_[]Kpse_pkg" = xyes])[]dnl
296 m4_popdef([Kpse_add])[]dnl
297 ]) # end kpse_recurse_progs
298
299 # _KPSE_RECURSE(LIST, TEXT, COND, [PREFIX])
300 # -----------------------------------------
301 # Internal subroutine. Determine which of the libraries or programs in
302 # kpse_LIST_pkgs to build: if a package's source directory contains a
303 # configure script, then add to CONF_SUBDIRS. If COND is true, also add
304 # to MAKE_SUBDIRS. PREFIX, if present, is prepended to the package name
305 # for the directory.
306 #
307 # Thus if a directory has a configure script, the configure must succeed,
308 # even if the package has been disabled. This is suboptimal, but see below.
309 #
310 m4_define([_KPSE_RECURSE], [dnl
311 AC_MSG_CHECKING([for $2 to build])
312 echo 'tldbg:[$0] called: list=[$1], text=[$2], cond=[$3], prefix=[$4].' >&AS_MESSAGE_LOG_FD
313 MAKE_SUBDIRS=
314 CONF_SUBDIRS=
315 KPSE_FOR_PKGS([$1], [dnl
316 echo 'tldbg:[$0] checking: Kpse_pkg' >&AS_MESSAGE_LOG_FD
317 m4_ifdef([have_]Kpse_pkg, [dnl
318 if test -x $srcdir/$4Kpse_Pkg/configure; then
319 echo 'tldbg:[$0] have configure, adding to CONF_SUBDIRS: Kpse_pkg' >&AS_MESSAGE_LOG_FD
320 Kpse_add([CONF_SUBDIRS])
321 if $3; then
322 echo 'tldbg:[$0] $3 true, adding to MAKE_SUBDIRS: Kpse_pkg' >&AS_MESSAGE_LOG_FD
323 Kpse_add([MAKE_SUBDIRS])
324 else
325 echo 'tldbg:[$0] $3 false, omitting from MAKE_SUBDIRS: Kpse_Pkg' >&AS_MESSAGE_LOG_FD
326 fi
327
328 else
329 echo 'tldbg:[$0] omitting from CONF_SUBDIRS, no (executable) configure: '"$srcdir"'/$4Kpse_Pkg/configure' >&AS_MESSAGE_LOG_FD
330 fi
331 ], [
332 echo 'tldbg:[$0] omitting from CONF_SUBDIRS, [have_]Kpse_pkg not defined' >&AS_MESSAGE_LOG_FD
333 ])dnl m4_ifdef
334 ])dnl
335 AC_SUBST([MAKE_SUBDIRS])[]dnl
336 AC_SUBST([CONF_SUBDIRS])[]dnl
337 dnl No dnl here to avoid following code getting pasted on:
338 AC_MSG_RESULT([$MAKE_SUBDIRS])
339 dnl
340 dnl Turns out they're normally different, because of xindy.
341 dnl if test x"$MAKE_SUBDIRS" != x"$CONF_SUBDIRS"; then
342 dnl AC_MSG_NOTICE([$2 to configure is different: $CONF_SUBDIRS])
343 dnl fi
344 dnl
345 dnl Historic (and current) method: assume all directories present will be
346 dnl configured, but only make if the package is enabled. This works in
347 dnl the cut-down pdftex source tree, but means that configure always has
348 dnl to succeed; not desirable in, e.g., 2017 when dvisvgm newly required
349 dnl C++11. But for 2018, all kinds of other things also require C++11, so
350 dnl might as well go back to it instead of debugging further.
351 dnl #old if test -x $srcdir/$4Kpse_Pkg/configure; then
352 dnl #old $3 && Kpse_add([MAKE_SUBDIRS])
353 dnl #old Kpse_add([CONF_SUBDIRS])
354 dnl #old fi
355 dnl
356 dnl new (and not used) method: don't try to configure if a package has
357 dnl been disabled, even if the directory exists. This is more intuitive,
358 dnl but does not work in the cut-down pdftex source tree.
359 dnl #new if test -x $srcdir/$4Kpse_Pkg/configure && $3; then
360 dnl #new Kpse_add([CONF_SUBDIRS])
361 dnl #new Kpse_add([MAKE_SUBDIRS])
362 dnl #new fi
363 echo 'tldbg:[$0] done (list=[$1])' >&AS_MESSAGE_LOG_FD
364 ]) # end _kpse_recurse