2 dnl Copyright 2000, 2001, 2002, 2012-2019 Free Software Foundation, Inc.
4 dnl This file is part of GNU lightning.
6 dnl GNU lightning is free software; you can redistribute it and/or modify it
7 dnl under the terms of the GNU Lesser General Public License as published
8 dnl by the Free Software Foundation; either version 3, or (at your option)
11 dnl GNU lightning is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 dnl License for more details.
18 AC_INIT([GNU lightning], 2.1.3, pcpa@gnu.org, lightning)
19 AC_CONFIG_AUX_DIR([build-aux])
21 AC_CONFIG_SRCDIR([Makefile.am])
22 AM_INIT_AUTOMAKE([dist-bzip2])
23 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
24 AC_CONFIG_MACRO_DIR([m4])
26 AC_CONFIG_HEADERS([config.h])
39 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -mlp64" ;;
44 # (Hack) Flags to pass configure with gcc 3.x
45 # Should not set LIGHTNINT_CFLAGS
47 CFLAGS="$CFLAGS -D__c99 -Drestrict=";;
53 # Get proper varargs and mmap prototypes and definitions
54 CFLAGS="$CFLAGS -D_ANSI_C_SOURCE -D_XOPEN_SOURCE_EXTENDED -D_OSF_SOURCE -D_POSIX_C_SOURCE=199309L"
55 # Want to generate NaN with 0.0/0.0 and Inf with 1.0/0.0
56 if test x$GCC = "xyes"; then
57 CFLAGS="$CFLAGS -mieee"
59 CFLAGS="$CFLAGS -ieee_with_no_inexact"
66 AC_CHECK_FUNCS(mmap mremap ffsl getopt_long_only isnan isinf,,)
68 AC_CHECK_HEADERS([getopt.h stdint.h],,,)
70 AC_ARG_ENABLE(disassembler,
71 AS_HELP_STRING([--enable-disassembler],
72 [Enable jit disassembler using binutils]),
73 [DISASSEMBLER=$enableval], [DISASSEMBLER=auto])
74 if test "x$DISASSEMBLER" != "xno"; then
76 AC_CHECK_LIB(iberty, htab_try_create, ,
78 AC_CHECK_LIB(bfd, bfd_init, ,
80 AC_CHECK_LIB(z, compressBound, ,
82 AC_CHECK_LIB(opcodes, init_disassemble_info, ,
85 if test "x$HAVE_IBERTY" = "xno"; then
86 if test "x$DISASSEMBLER" = "xyes"; then
87 AC_MSG_ERROR([libiberty not found])
89 AC_MSG_WARN([libiberty not found])
94 if test "x$HAVE_BFD" = "xno"; then
95 if test "x$DISASSEMBLER" = "xyes"; then
96 AC_MSG_ERROR([binutils BFD not found, see http://www.gnu.org/software/binutils/])
98 AC_MSG_WARN([binutils BFD not found, see http://www.gnu.org/software/binutils/])
103 if test "x$HAVE_Z" = "xno"; then
104 if test "x$DISASSEMBLER" = "xyes"; then
105 AC_MSG_ERROR([zlib not found, see https://zlib.net/])
107 AC_MSG_WARN([zlib not found, see https://zlib.net/])
112 if test "x$HAVE_OPCODES" = "xno"; then
113 if test "x$DISASSEMBLER" = "xyes"; then
114 AC_MSG_ERROR([binutils opcodes not found, see https://www.gnu.org/software/binutils/])
116 AC_MSG_WARN([binutils opcodes not found, see https://www.gnu.org/software/binutils/])
122 AM_CONDITIONAL(with_disassembler, [test "x$DISASSEMBLER" != "xno"])
123 if test "x$DISASSEMBLER" != "xno"; then
124 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1"
126 CFLAGS="$CFLAGS -I$PWD/include -D_GNU_SOURCE"
127 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
128 #include <lightning.h>
129 #include <lightning/jit_private.h>
131 int main(int argc, char *argv[])
133 disassembler_ftype print;
135 print = disassembler(abfd);
138 )], [ac_cv_test_new_disassembler=no],,)
139 CFLAGS="$save_CFLAGS"
140 if test "x$ac_cv_test_new_disassembler" != "xno"; then
141 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DBINUTILS_2_29=1"
145 AC_ARG_ENABLE(devel-disassembler,
146 AS_HELP_STRING([--enable-devel-disassembler],
147 [Enable extra disassembly options]),
148 [DEVEL_DISASSEMBLER=$enableval], [DEVEL_DISASSEMBLER=no])
149 if test "x$DEVEL_DISASSEMBLER" != "xno"; then
150 if test "x$DISASSEMBLER" = "xno"; then
151 AC_MSG_ERROR(devel-disassembler needs disassembler enabled)
153 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEVEL_DISASSEMBLER=1"
156 AC_ARG_ENABLE(assertions,
157 AS_HELP_STRING([--enable-assertions],
158 [Enable runtime code generation assertions]),
159 [DEBUG=$enableval], [DEBUG=auto])
160 if test "x$DEBUG" = xyes; then
161 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEBUG=1"
163 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DNDEBUG"
167 # This option is only useful during development.
168 AC_ARG_ENABLE(devel-get-jit-size,
169 AS_HELP_STRING([--enable-devel-get-jit-size],
170 [Devel mode to regenerate jit size information]),
171 [GET_JIT_SIZE=$enableval], [GET_JIT_SIZE=no])
172 AM_CONDITIONAL(get_jit_size, [test $GET_JIT_SIZE = yes])
175 *bsd*|osf*) SHLIB="" ;;
176 *hpux*) SHLIB="-ldld" ;;
182 case "$target_cpu" in
183 i?86|x86_64|amd64) cpu=x86 ;;
186 *powerpc*) cpu=ppc ;;
187 *sparc*) cpu=sparc ;;
190 aarch64) cpu=aarch64 ;;
196 AM_CONDITIONAL(cpu_arm, [test cpu-$cpu = cpu-arm])
197 AM_CONDITIONAL(cpu_mips, [test cpu-$cpu = cpu-mips])
198 AM_CONDITIONAL(cpu_ppc, [test cpu-$cpu = cpu-ppc])
199 AM_CONDITIONAL(cpu_sparc, [test cpu-$cpu = cpu-sparc])
200 AM_CONDITIONAL(cpu_x86, [test cpu-$cpu = cpu-x86])
201 AM_CONDITIONAL(cpu_ia64, [test cpu-$cpu = cpu-ia64])
202 AM_CONDITIONAL(cpu_hppa, [test cpu-$cpu = cpu-hppa])
203 AM_CONDITIONAL(cpu_aarch64, [test cpu-$cpu = cpu-aarch64])
204 AM_CONDITIONAL(cpu_s390, [test cpu-$cpu = cpu-s390])
205 AM_CONDITIONAL(cpu_alpha, [test cpu-$cpu = cpu-alpha])
206 AM_CONDITIONAL(cpu_riscv, [test cpu-$cpu = cpu-riscv])
208 # Test x87 if both, x87 and sse2 available
210 # Test arm instruction set if thumb instruction set available
212 # Test sofware float if vfp available and not using hard float abi
216 CFLAGS="$CFLAGS -I$PWD/include -D_GNU_SOURCE"
217 if test x$cpu = x; then
218 AC_MSG_ERROR([cpu $target_cpu not supported])
219 elif test $cpu = x86; then
220 AC_RUN_IFELSE([AC_LANG_SOURCE([[
221 #include <lightning.h>
224 unsigned int eax, ebx, ecx, edx;
225 if (__WORDSIZE == 64)
227 __asm__ volatile ("pushfl;\n\t"
229 "movl \$0x240000, %1;\n\t"
238 : "=r" (flags), "=r" (ac));
239 if ((ac & (1 << 21)) == 0)
241 __asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
242 : "=a" (eax), "=r" (ebx),
243 "=c" (ecx), "=d" (edx)
245 return (edx & 1 << 26) ? 0 : 1;
247 ]])],[ac_cv_test_x86_x87=yes],[],[ac_cv_test_x86_x87=no])
248 elif test $cpu = arm; then
249 AC_RUN_IFELSE([AC_LANG_SOURCE([[
252 #if defined(__linux__)
255 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
257 while (fgets(buf, sizeof(buf), fp)) {
258 if (strncmp(buf, "Features\t:", 10) == 0 &&
259 strstr(buf + 10, "thumb")) {
265 #elif defined(__thumb2__)
270 ]])],[ac_cv_test_arm_arm=yes],[],[ac_cv_test_arm_arm=no])
271 AC_RUN_IFELSE([AC_LANG_SOURCE([[
274 #if defined(__linux__)
277 # if !defined(__ARM_PCS_VFP)
278 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
280 while (fgets(buf, sizeof(buf), fp)) {
281 if (strncmp(buf, "Features\t:", 10) == 0 &&
282 strstr(buf + 10, "vfp")) {
292 ]])],[ac_cv_test_arm_swf=yes],[],[ac_cv_test_arm_swf=no])
293 elif test $cpu = ppc; then
294 if test "x$DISASSEMBLER" != "xno"; then
297 AC_CHECK_FUNCS(disassemble_init_for_target disassemble_init_powerpc)
303 AM_CONDITIONAL(test_x86_x87, [test x$ac_cv_test_x86_x87 = xyes])
304 AM_CONDITIONAL(test_arm_arm, [test x$ac_cv_test_arm_arm = xyes])
305 AM_CONDITIONAL(test_arm_swf, [test x$ac_cv_test_arm_swf = xyes])
307 AM_CONDITIONAL(test_nodata, [test cpu-$cpu = cpu-mips -o cpu-$cpu = cpu-ppc -o cpu-$cpu = cpu-sparc -o cpu-$cpu = cpu-x86 -o cpu-$cpu = cpu-ia64 -o cpu-$cpu = cpu-hppa -o cpu-$cpu = cpu-s390 -o cpu-$cpu = cpu-alpha])
309 if test $cpu = arm; then
310 AC_CHECK_LIB(m, sqrtf, ,
311 [AC_MSG_ERROR([sqrtf required but not available])])
315 AC_SUBST([LIGHTNING_CFLAGS])
317 if test $ac_cv_header_stdint_h = yes; then
318 AC_SUBST(MAYBE_INCLUDE_STDINT_H, ["#include <stdint.h>"])
326 include/lightning/Makefile