Merge pull request #643 from pcercuei/update-lightrec-20220408
[pcsx_rearmed.git] / deps / lightning / configure.ac
... / ...
CommitLineData
1dnl
2dnl Copyright 2000, 2001, 2002, 2012-2019 Free Software Foundation, Inc.
3dnl
4dnl This file is part of GNU lightning.
5dnl
6dnl GNU lightning is free software; you can redistribute it and/or modify it
7dnl under the terms of the GNU Lesser General Public License as published
8dnl by the Free Software Foundation; either version 3, or (at your option)
9dnl any later version.
10dnl
11dnl GNU lightning is distributed in the hope that it will be useful, but
12dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14dnl License for more details.
15dnl
16
17AC_PREREQ(2.64)
18AC_INIT([GNU lightning], 2.1.3, pcpa@gnu.org, lightning)
19AC_CONFIG_AUX_DIR([build-aux])
20AC_CANONICAL_TARGET
21AC_CONFIG_SRCDIR([Makefile.am])
22AM_INIT_AUTOMAKE([dist-bzip2])
23m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
24AC_CONFIG_MACRO_DIR([m4])
25
26AC_CONFIG_HEADERS([config.h])
27
28AC_PROG_CC
29gl_EARLY
30AM_PROG_AR
31LT_INIT
32gl_INIT
33
34case "$target_cpu" in
35 ia64)
36 case "$host_os" in
37 # Only supported mode
38 *hpux*)
39 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -mlp64" ;;
40 *) ;;
41 esac ;;
42 *mips*)
43 case "$host_os" in
44 # (Hack) Flags to pass configure with gcc 3.x
45 # Should not set LIGHTNINT_CFLAGS
46 *irix*)
47 CFLAGS="$CFLAGS -D__c99 -Drestrict=";;
48 *) ;;
49 esac ;;
50 alpha*)
51 case "$host_os" in
52 osf*)
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"
58 else
59 CFLAGS="$CFLAGS -ieee_with_no_inexact"
60 fi ;;
61 *) ;;
62 esac ;;
63 *) ;;
64esac
65
66AC_CHECK_FUNCS(mremap ffsl getopt_long_only isnan isinf,,)
67
68AC_CHECK_HEADERS([getopt.h stdint.h],,,)
69
70AC_ARG_ENABLE(disassembler,
71 AS_HELP_STRING([--enable-disassembler],
72 [Enable jit disassembler using binutils]),
73 [DISASSEMBLER=$enableval], [DISASSEMBLER=auto])
74if test "x$DISASSEMBLER" != "xno"; then
75 # FIXME need to check for libiberty first or will fail to link
76 AC_CHECK_LIB(iberty, htab_try_create, ,
77 [HAVE_IBERTY="no"])
78 AC_CHECK_LIB(bfd, bfd_init, ,
79 [HAVE_BFD="no"])
80 AC_CHECK_LIB(z, compressBound, ,
81 [HAVE_Z="no"])
82 AC_CHECK_LIB(opcodes, init_disassemble_info, ,
83 [HAVE_OPCODES="no"])
84 if test "x$HAVE_IBERTY" = "xno" -o \
85 "x$HAVE_BFD" = "xno" -o \
86 "x$HAVE_Z" = "xno" -o \
87 "x$HAVE_OPCODES" = "xno"; then
88 if test "x$DISASSEMBLER" != "xauto"; then
89 AC_MSG_ERROR([binutils not found, see http://www.gnu.org/software/binutils/])
90 else
91 AC_MSG_WARN([binutils not found, see http://www.gnu.org/software/binutils/])
92 DISASSEMBLER="no"
93 fi
94 fi
95fi
96AM_CONDITIONAL(with_disassembler, [test "x$DISASSEMBLER" != "xno"])
97if test "x$DISASSEMBLER" != "xno"; then
98 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1"
99 save_CFLAGS=$CFLAGS
100 CFLAGS="$CFLAGS -I$PWD/include -D_GNU_SOURCE"
101 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
102 #include <lightning.h>
103 #include <lightning/jit_private.h>
104 #include <dis-asm.h>
105 int main(int argc, char *argv[])
106 {
107 disassembler_ftype print;
108 bfd *abfd;
109 print = disassembler(abfd);
110 return 0;
111 }
112 )], [ac_cv_test_new_disassembler=no],,)
113 CFLAGS="$save_CFLAGS"
114 if test "x$ac_cv_test_new_disassembler" != "xno"; then
115 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DBINUTILS_2_29=1"
116 fi
117fi
118
119AC_ARG_ENABLE(devel-disassembler,
120 AS_HELP_STRING([--enable-devel-disassembler],
121 [Enable extra disassembly options]),
122 [DEVEL_DISASSEMBLER=$enableval], [DEVEL_DISASSEMBLER=no])
123if test "x$DEVEL_DISASSEMBLER" != "xno"; then
124 if test "x$DISASSEMBLER" = "xno"; then
125 AC_MSG_ERROR(devel-disassembler needs disassembler enabled)
126 fi
127 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEVEL_DISASSEMBLER=1"
128fi
129
130AC_ARG_ENABLE(assertions,
131 AS_HELP_STRING([--enable-assertions],
132 [Enable runtime code generation assertions]),
133 [DEBUG=$enableval], [DEBUG=auto])
134if test "x$DEBUG" = xyes; then
135 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEBUG=1"
136else
137 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DNDEBUG"
138 DEBUG=no
139fi
140
141# This option is only useful during development.
142AC_ARG_ENABLE(devel-get-jit-size,
143 AS_HELP_STRING([--enable-devel-get-jit-size],
144 [Devel mode to regenerate jit size information]),
145 [GET_JIT_SIZE=$enableval], [GET_JIT_SIZE=no])
146AM_CONDITIONAL(get_jit_size, [test $GET_JIT_SIZE = yes])
147
148case "$host_os" in
149 *bsd*|osf*) SHLIB="" ;;
150 *hpux*) SHLIB="-ldld" ;;
151 *) SHLIB="-ldl" ;;
152esac
153AC_SUBST(SHLIB)
154
155cpu=
156case "$target_cpu" in
157 i?86|x86_64|amd64) cpu=x86 ;;
158 *arm*) cpu=arm ;;
159 *mips*) cpu=mips ;;
160 *powerpc*) cpu=ppc ;;
161 *sparc*) cpu=sparc ;;
162 ia64) cpu=ia64 ;;
163 hppa*) cpu=hppa ;;
164 aarch64) cpu=aarch64 ;;
165 s390*) cpu=s390 ;;
166 alpha*) cpu=alpha ;;
167 riscv*) cpu=riscv ;;
168 *) ;;
169esac
170AM_CONDITIONAL(cpu_arm, [test cpu-$cpu = cpu-arm])
171AM_CONDITIONAL(cpu_mips, [test cpu-$cpu = cpu-mips])
172AM_CONDITIONAL(cpu_ppc, [test cpu-$cpu = cpu-ppc])
173AM_CONDITIONAL(cpu_sparc, [test cpu-$cpu = cpu-sparc])
174AM_CONDITIONAL(cpu_x86, [test cpu-$cpu = cpu-x86])
175AM_CONDITIONAL(cpu_ia64, [test cpu-$cpu = cpu-ia64])
176AM_CONDITIONAL(cpu_hppa, [test cpu-$cpu = cpu-hppa])
177AM_CONDITIONAL(cpu_aarch64, [test cpu-$cpu = cpu-aarch64])
178AM_CONDITIONAL(cpu_s390, [test cpu-$cpu = cpu-s390])
179AM_CONDITIONAL(cpu_alpha, [test cpu-$cpu = cpu-alpha])
180AM_CONDITIONAL(cpu_riscv, [test cpu-$cpu = cpu-riscv])
181
182# Test x87 if both, x87 and sse2 available
183ac_cv_test_x86_x87=
184# Test arm instruction set if thumb instruction set available
185ac_cv_test_arm_arm=
186# Test sofware float if vfp available and not using hard float abi
187ac_cv_test_arm_swf=
188
189save_CFLAGS=$CFLAGS
190CFLAGS="$CFLAGS -I$PWD/include -D_GNU_SOURCE"
191if test x$cpu = x; then
192 AC_MSG_ERROR([cpu $target_cpu not supported])
193elif test $cpu = x86; then
194 AC_RUN_IFELSE([AC_LANG_SOURCE([[
195 #include <lightning.h>
196 int main(void) {
197 int ac, flags;
198 unsigned int eax, ebx, ecx, edx;
199 if (__WORDSIZE == 64)
200 return 1;
201 __asm__ volatile ("pushfl;\n\t"
202 "popl %0;\n\t"
203 "movl \$0x240000, %1;\n\t"
204 "xorl %0, %1;\n\t"
205 "pushl %1;\n\t"
206 "popfl;\n\t"
207 "pushfl;\n\t"
208 "popl %1;\n\t"
209 "xorl %0, %1;\n\t"
210 "pushl %0;\n\t"
211 "popfl"
212 : "=r" (flags), "=r" (ac));
213 if ((ac & (1 << 21)) == 0)
214 return 1;
215 __asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
216 : "=a" (eax), "=r" (ebx),
217 "=c" (ecx), "=d" (edx)
218 : "0" (1));
219 return (edx & 1 << 26) ? 0 : 1;
220 }
221 ]])],[ac_cv_test_x86_x87=yes],[],[ac_cv_test_x86_x87=no])
222elif test $cpu = arm; then
223 AC_RUN_IFELSE([AC_LANG_SOURCE([[
224 #include <stdio.h>
225 int main(void) {
226 #if defined(__linux__)
227 FILE *fp;
228 char buf[128];
229 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
230 return 1;
231 while (fgets(buf, sizeof(buf), fp)) {
232 if (strncmp(buf, "Features\t:", 10) == 0 &&
233 strstr(buf + 10, "thumb")) {
234 fclose(fp);
235 return 0;
236 }
237 }
238 fclose(fp);
239 #elif defined(__thumb2__)
240 return 0;
241 #endif
242 return 1;
243 }
244 ]])],[ac_cv_test_arm_arm=yes],[],[ac_cv_test_arm_arm=no])
245 AC_RUN_IFELSE([AC_LANG_SOURCE([[
246 #include <stdio.h>
247 int main(void) {
248 #if defined(__linux__)
249 FILE *fp;
250 char buf[128];
251 # if !defined(__ARM_PCS_VFP)
252 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
253 return 1;
254 while (fgets(buf, sizeof(buf), fp)) {
255 if (strncmp(buf, "Features\t:", 10) == 0 &&
256 strstr(buf + 10, "vfp")) {
257 fclose(fp);
258 return 0;
259 }
260 }
261 fclose(fp);
262 # endif
263 #endif
264 return 1;
265 }
266 ]])],[ac_cv_test_arm_swf=yes],[],[ac_cv_test_arm_swf=no])
267elif test $cpu = ppc; then
268 if test "x$DISASSEMBLER" != "xno"; then
269 save_LIBS="$LIBS"
270 LIBS="$LIBS $SHLIB"
271 AC_CHECK_FUNCS(disassemble_init_for_target disassemble_init_powerpc)
272 LIBS="$save_LIBS"
273 fi
274fi
275CFLAGS=$save_CFLAGS
276
277AM_CONDITIONAL(test_x86_x87, [test x$ac_cv_test_x86_x87 = xyes])
278AM_CONDITIONAL(test_arm_arm, [test x$ac_cv_test_arm_arm = xyes])
279AM_CONDITIONAL(test_arm_swf, [test x$ac_cv_test_arm_swf = xyes])
280
281AM_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])
282
283if test $cpu = arm; then
284 AC_CHECK_LIB(m, sqrtf, ,
285 [AC_MSG_ERROR([sqrtf required but not available])])
286fi
287AC_SUBST(cpu)
288
289AC_SUBST([LIGHTNING_CFLAGS])
290
291if test $ac_cv_header_stdint_h = yes; then
292 AC_SUBST(MAYBE_INCLUDE_STDINT_H, ["#include <stdint.h>"])
293fi
294
295AC_OUTPUT([Makefile
296 lightning.pc
297 gnulib-lib/Makefile
298 doc/Makefile
299 include/Makefile
300 include/lightning/Makefile
301 include/lightning.h
302 lib/Makefile
303 check/Makefile])