1 dnl Process this file with autoconf to produce a configure script.
3 dnl Copyright (C) 2014, 2015 Peter Breitenlohner <tex-live@tug.org>
5 dnl This file is free software; the copyright holder
6 dnl gives unlimited permission to copy and/or distribute it,
7 dnl with or without modifications, as long as this notice is preserved.
9 m4_include([version.ac])[] dnl define luajit_version
10 AC_INIT([luajit for TeX Live], luajit_version, [tex-k@tug.org])
12 AC_CONFIG_SRCDIR([LuaJIT-src/src/luajit.h])
13 AC_CONFIG_AUX_DIR([../../build-aux])
14 AC_CONFIG_MACRO_DIRS([../../m4 m4])
26 AC_SUBST([LUAJITVERSION], [luajit_version])
27 KPSE_LT_VERSION([luajit])
31 KPSE_DLL_NAME([texluajit], [texluajit])
33 AC_CHECK_SIZEOF([void *])
34 ac_configure_args="$ac_configure_args HOST_PTR_SIZE='$ac_cv_sizeof_void_p'"
36 AC_SEARCH_LIBS([sqrt], [m])
37 AC_SEARCH_LIBS([dlopen], [dl])
40 KPSE_LARGEFILE([LUAJIT_DEFINES])
43 [cygwin* | mingw* | msys*], [LJHOST='Windows'],
44 [darwin*], [LJHOST='Darwin'],
45 [solaris* | sunos*], [LJHOST='SunOS'],
46 [linux*], [LJHOST='Linux'],
47 [freebsd*], [LJHOST='FreeBSD'],
51 [Windows], [LJVM_MODE=peobj
52 LUAJIT_CFLAGS="$LUAJIT_CFLAGS -malign-double"],
53 [Darwin | iOS], [LJVM_MODE=machasm],
55 lj_save_CFLAGS=$CFLAGS
56 CFLAGS="$CFLAGS -fno-stack-protector"
57 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
58 [LUAJIT_CFLAGS="$LUAJIT_CFLAGS -fno-stack-protector"])
59 CFLAGS=$lj_save_CFLAGS
60 AM_CONDITIONAL([PEOBJ], [test "x$LJVM_MODE" = xpeobj])
62 AC_SUBST([LUAJIT_CFLAGS])
66 AS_CASE([$host_os:$host_cpu],
67 [*darwin*:x86_64], [LIBLUAJIT_LDEXTRA='-image_base 7fff04c4a000'])
68 AC_SUBST([LIBLUAJIT_LDEXTRA])
70 AM_CONDITIONAL([build], [test "x$enable_build" != xno])
72 if test "x$enable_build" != xno || test -f config.force; then
74 AS_IF([test "x$lj_cpp" != xok],
75 [AC_MSG_ERROR([Sorry, can not preprocess <lj_arch.h>])])
77 echo timestamp >config.force
80 # Check log2, on some systems is still not defined
82 AC_CHECK_DECLS([log2], [], [LUAJIT_HAS_NOT_LOG2=[-DLUAJIT_NO_LOG2]], [[#include <math.h>]])
83 AC_SUBST([LUAJIT_HAS_NOT_LOG2])
88 AC_SUBST([LUAJIT_TREE], [LuaJIT-src])
90 dnl Not used but avoids putting a zillion useless -D's on the command line.
91 AC_CONFIG_HEADERS([config.h])
93 AC_CONFIG_FILES([Makefile include/Makefile texluajit.pc])
95 dnl Pass DASM_ARCH to the subdirectory native,
96 dnl which must be configured for the build system.
97 AC_CONFIG_COMMANDS_POST([ac_configure_args="$ac_configure_args DASM_ARCH=$DASM_ARCH"])
98 KPSE_NATIVE_SUBDIRS([native])