Debian Codegraph @

m4/kpse-luajit-flags.m4

raw
1 # $Id: kpse-luajit-flags.m4 73471 2025-01-15 22:51:07Z karl $
2 # Public macros for the TeX Live (TL) tree.
3 # Copyright 2019-2025 Karl Berry <[email protected]>
4 # Copyright 2014 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_LUAJIT_FLAGS
11 # -----------------
12 # Set the make variables LUAJIT_INCLUDES and LUAJIT_LIBS to the CPPFLAGS and
13 # LIBS required for the `-ltexluajit' library in libs/luajit/ of the TL tree.
14 AC_DEFUN([KPSE_LUAJIT_FLAGS], [dnl
15 echo 'tldbg:[$0] called.' >&AS_MESSAGE_LOG_FD
16 _KPSE_LIB_FLAGS([luajit], [texluajit], [lt],
17 [-IBLD/libs/luajit/include],
18 [BLD/libs/luajit/libtexluajit.la],
19 [],
20 [],
21 [${top_builddir}/../../libs/luajit/include/luajit.h])[]dnl
22 #
23 # checking for openbsd for additional jit libraries needed, which is the
24 # case for clang; no point in going to the trouble elsewhere since no
25 # other system needs it.
26 case $build_os in
27 openbsd*)
28 AC_MSG_CHECKING([on openbsd if additional jit libraries are needed])
29 AC_LINK_IFELSE(
30 [AC_LANG_PROGRAM(
31 [[#include "stdint.h"
32 typedef struct _Unwind_Context _Unwind_Context;
33 extern uintptr_t _Unwind_GetCFA(_Unwind_Context *);]],
34 [[_Unwind_Context *ctx;
35 _Unwind_GetCFA(ctx);]]
36 )],
37 [AC_MSG_RESULT([no])],
38 [
39 jitlibs="-lc++abi -lpthread"
40 save_LIBS=$LIBS
41 LIBS="$LIBS $jitlibs"
42 AC_LINK_IFELSE(
43 [AC_LANG_PROGRAM(
44 [[#include "stdint.h"
45 typedef struct _Unwind_Context _Unwind_Context;
46 extern uintptr_t _Unwind_GetCFA(_Unwind_Context *);]],
47 [[_Unwind_Context *ctx;
48 _Unwind_GetCFA(ctx);]]
49 )],
50 [
51 AC_MSG_RESULT(["$jitlibs"])
52 LIBLUAJIT_LDEXTRA="$LIBLUAJIT_LDEXTRA $jitlibs"
53 ],
54 [AC_MSG_FAILURE([luajit could not be linked])]
55 )
56 LIBS=$save_LIBS
57 ]
58 )
59 ;;
60 esac
61 echo 'tldbg:[$0] done.' >&AS_MESSAGE_LOG_FD
62 ]) # KPSE_LUAJIT_FLAGS
63
64 # KPSE_LUAJIT_OPTIONS([WITH-SYSTEM])
65 # ----------------------------------
66 AC_DEFUN([KPSE_LUAJIT_OPTIONS], [_KPSE_LIB_OPTIONS([luajit], [$1], [pkg-config])])
67
68 # KPSE_LUAJIT_SYSTEM_FLAGS
69 # ------------------------
70 AC_DEFUN([KPSE_LUAJIT_SYSTEM_FLAGS], [_KPSE_PKG_CONFIG_FLAGS([luajit], [luajit])])
71
72 # KPSE_LUAJIT_DEFINES
73 # -------------------
74 # Set the make variable LUAJIT_DEFINES to the CPPFLAGS required when
75 # compiling or using the `-ltexluajit' library.
76 # Set the make variable LUAJIT_LDEXTRA to the LDFLAGS required when
77 # linking with the `-lluajit' library.
78 AC_DEFUN([KPSE_LUAJIT_DEFINES], [dnl
79 AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
80 AC_SUBST([LUAJIT_DEFINES], ['-DLUAJIT_ENABLE_LUA52COMPAT -DLUAI_HASHLIMIT=6'])
81 AS_CASE([$host_os:$host_cpu],
82 [*darwin*:x86_64], [LUAJIT_LDEXTRA='-pagezero_size 10000 -image_base 100000000'])
83 AC_SUBST([LUAJIT_LDEXTRA])
84 ]) # KPSE_LUAJIT_DEFINES