lightrec: hack to fix a wrong assumption
[pcsx_rearmed.git] / deps / lightning / configure.ac
CommitLineData
4a71579b
PC
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.
519a9ea1 10dnl
4a71579b
PC
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
24d91c0d
PC
17AC_PREREQ([2.71])
18AC_INIT([GNU lightning],[2.1.3],[pcpa@gnu.org],[lightning])
519a9ea1 19AC_CONFIG_AUX_DIR([build-aux])
4a71579b
PC
20AC_CANONICAL_TARGET
21AC_CONFIG_SRCDIR([Makefile.am])
22AM_INIT_AUTOMAKE([dist-bzip2])
23m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
519a9ea1 24AC_CONFIG_MACRO_DIR([m4])
4a71579b 25
519a9ea1 26AC_CONFIG_HEADERS([config.h])
4a71579b
PC
27
28AC_PROG_CC
519a9ea1
PC
29gl_EARLY
30AM_PROG_AR
31LT_INIT
32gl_INIT
4a71579b
PC
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
40a44dcb 66AC_CHECK_FUNCS(mmap mremap ffsl getopt_long_only isnan isinf,,)
4a71579b
PC
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
40a44dcb 75
4a71579b
PC
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"])
40a44dcb
PC
84
85 if test "x$HAVE_IBERTY" = "xno"; then
86 if test "x$DISASSEMBLER" = "xyes"; then
87 AC_MSG_ERROR([libiberty not found])
88 else
89 AC_MSG_WARN([libiberty not found])
90 DISASSEMBLER="no"
91 fi
4a71579b 92 fi
40a44dcb
PC
93
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/])
97 else
98 AC_MSG_WARN([binutils BFD not found, see http://www.gnu.org/software/binutils/])
99 DISASSEMBLER="no"
100 fi
101 fi
102
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/])
106 else
107 AC_MSG_WARN([zlib not found, see https://zlib.net/])
108 DISASSEMBLER="no"
109 fi
110 fi
111
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/])
115 else
116 AC_MSG_WARN([binutils opcodes not found, see https://www.gnu.org/software/binutils/])
117 DISASSEMBLER="no"
118 fi
119 fi
120
4a71579b
PC
121fi
122AM_CONDITIONAL(with_disassembler, [test "x$DISASSEMBLER" != "xno"])
123if test "x$DISASSEMBLER" != "xno"; then
124 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1"
125 save_CFLAGS=$CFLAGS
c0c16242 126 CFLAGS="$CFLAGS -D_GNU_SOURCE"
4a71579b 127 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
4a71579b
PC
128 #include <dis-asm.h>
129 int main(int argc, char *argv[])
130 {
131 disassembler_ftype print;
132 bfd *abfd;
133 print = disassembler(abfd);
134 return 0;
135 }
136 )], [ac_cv_test_new_disassembler=no],,)
ba3814c1
PC
137 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
138 #include <dis-asm.h>
139 int main(int argc, char *argv[])
140 {
141 struct disassemble_info dinfo;
142 INIT_DISASSEMBLE_INFO(dinfo, NULL, NULL, NULL);
143 return 0;
144 }
145 )], [ac_cv_test_new_disassemble_info=yes],[ac_cv_test_new_disassemble_info=no],)
4a71579b
PC
146 CFLAGS="$save_CFLAGS"
147 if test "x$ac_cv_test_new_disassembler" != "xno"; then
148 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DBINUTILS_2_29=1"
149 fi
ba3814c1
PC
150 if test "x$ac_cv_test_new_disassemble_info" != "xno"; then
151 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DBINUTILS_2_38=1"
152 fi
4a71579b
PC
153fi
154
155AC_ARG_ENABLE(devel-disassembler,
156 AS_HELP_STRING([--enable-devel-disassembler],
157 [Enable extra disassembly options]),
158 [DEVEL_DISASSEMBLER=$enableval], [DEVEL_DISASSEMBLER=no])
159if test "x$DEVEL_DISASSEMBLER" != "xno"; then
160 if test "x$DISASSEMBLER" = "xno"; then
161 AC_MSG_ERROR(devel-disassembler needs disassembler enabled)
162 fi
163 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEVEL_DISASSEMBLER=1"
164fi
165
166AC_ARG_ENABLE(assertions,
167 AS_HELP_STRING([--enable-assertions],
168 [Enable runtime code generation assertions]),
169 [DEBUG=$enableval], [DEBUG=auto])
170if test "x$DEBUG" = xyes; then
171 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEBUG=1"
172else
173 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DNDEBUG"
174 DEBUG=no
175fi
176
177# This option is only useful during development.
178AC_ARG_ENABLE(devel-get-jit-size,
179 AS_HELP_STRING([--enable-devel-get-jit-size],
180 [Devel mode to regenerate jit size information]),
181 [GET_JIT_SIZE=$enableval], [GET_JIT_SIZE=no])
182AM_CONDITIONAL(get_jit_size, [test $GET_JIT_SIZE = yes])
183
184case "$host_os" in
185 *bsd*|osf*) SHLIB="" ;;
186 *hpux*) SHLIB="-ldld" ;;
187 *) SHLIB="-ldl" ;;
188esac
189AC_SUBST(SHLIB)
190
191cpu=
192case "$target_cpu" in
193 i?86|x86_64|amd64) cpu=x86 ;;
194 *arm*) cpu=arm ;;
195 *mips*) cpu=mips ;;
196 *powerpc*) cpu=ppc ;;
197 *sparc*) cpu=sparc ;;
198 ia64) cpu=ia64 ;;
199 hppa*) cpu=hppa ;;
200 aarch64) cpu=aarch64 ;;
201 s390*) cpu=s390 ;;
202 alpha*) cpu=alpha ;;
203 riscv*) cpu=riscv ;;
24d91c0d 204 loongarch*) cpu=loongarch ;;
4a71579b
PC
205 *) ;;
206esac
24d91c0d
PC
207AM_CONDITIONAL(cpu_arm, [test cpu-$cpu = cpu-arm])
208AM_CONDITIONAL(cpu_mips, [test cpu-$cpu = cpu-mips])
209AM_CONDITIONAL(cpu_ppc, [test cpu-$cpu = cpu-ppc])
210AM_CONDITIONAL(cpu_sparc, [test cpu-$cpu = cpu-sparc])
211AM_CONDITIONAL(cpu_x86, [test cpu-$cpu = cpu-x86])
212AM_CONDITIONAL(cpu_ia64, [test cpu-$cpu = cpu-ia64])
213AM_CONDITIONAL(cpu_hppa, [test cpu-$cpu = cpu-hppa])
214AM_CONDITIONAL(cpu_aarch64, [test cpu-$cpu = cpu-aarch64])
215AM_CONDITIONAL(cpu_s390, [test cpu-$cpu = cpu-s390])
216AM_CONDITIONAL(cpu_alpha, [test cpu-$cpu = cpu-alpha])
217AM_CONDITIONAL(cpu_riscv, [test cpu-$cpu = cpu-riscv])
218AM_CONDITIONAL(cpu_loongarch, [test cpu-$cpu = cpu-loongarch])
4a71579b
PC
219
220# Test x87 if both, x87 and sse2 available
221ac_cv_test_x86_x87=
222# Test arm instruction set if thumb instruction set available
223ac_cv_test_arm_arm=
224# Test sofware float if vfp available and not using hard float abi
225ac_cv_test_arm_swf=
226
227save_CFLAGS=$CFLAGS
c0c16242 228CFLAGS="$CFLAGS -D_GNU_SOURCE"
4a71579b
PC
229if test x$cpu = x; then
230 AC_MSG_ERROR([cpu $target_cpu not supported])
231elif test $cpu = x86; then
232 AC_RUN_IFELSE([AC_LANG_SOURCE([[
4a71579b
PC
233 int main(void) {
234 int ac, flags;
235 unsigned int eax, ebx, ecx, edx;
236 if (__WORDSIZE == 64)
237 return 1;
238 __asm__ volatile ("pushfl;\n\t"
239 "popl %0;\n\t"
240 "movl \$0x240000, %1;\n\t"
241 "xorl %0, %1;\n\t"
242 "pushl %1;\n\t"
243 "popfl;\n\t"
244 "pushfl;\n\t"
245 "popl %1;\n\t"
246 "xorl %0, %1;\n\t"
247 "pushl %0;\n\t"
248 "popfl"
249 : "=r" (flags), "=r" (ac));
250 if ((ac & (1 << 21)) == 0)
251 return 1;
252 __asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
253 : "=a" (eax), "=r" (ebx),
254 "=c" (ecx), "=d" (edx)
255 : "0" (1));
256 return (edx & 1 << 26) ? 0 : 1;
257 }
258 ]])],[ac_cv_test_x86_x87=yes],[],[ac_cv_test_x86_x87=no])
259elif test $cpu = arm; then
260 AC_RUN_IFELSE([AC_LANG_SOURCE([[
261 #include <stdio.h>
262 int main(void) {
263 #if defined(__linux__)
264 FILE *fp;
265 char buf[128];
266 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
267 return 1;
268 while (fgets(buf, sizeof(buf), fp)) {
269 if (strncmp(buf, "Features\t:", 10) == 0 &&
270 strstr(buf + 10, "thumb")) {
271 fclose(fp);
272 return 0;
273 }
274 }
275 fclose(fp);
276 #elif defined(__thumb2__)
277 return 0;
278 #endif
279 return 1;
280 }
281 ]])],[ac_cv_test_arm_arm=yes],[],[ac_cv_test_arm_arm=no])
282 AC_RUN_IFELSE([AC_LANG_SOURCE([[
283 #include <stdio.h>
284 int main(void) {
285 #if defined(__linux__)
286 FILE *fp;
287 char buf[128];
288 # if !defined(__ARM_PCS_VFP)
289 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
290 return 1;
291 while (fgets(buf, sizeof(buf), fp)) {
292 if (strncmp(buf, "Features\t:", 10) == 0 &&
293 strstr(buf + 10, "vfp")) {
294 fclose(fp);
295 return 0;
296 }
297 }
298 fclose(fp);
299 # endif
300 #endif
301 return 1;
302 }
303 ]])],[ac_cv_test_arm_swf=yes],[],[ac_cv_test_arm_swf=no])
304elif test $cpu = ppc; then
305 if test "x$DISASSEMBLER" != "xno"; then
306 save_LIBS="$LIBS"
307 LIBS="$LIBS $SHLIB"
308 AC_CHECK_FUNCS(disassemble_init_for_target disassemble_init_powerpc)
309 LIBS="$save_LIBS"
310 fi
311fi
312CFLAGS=$save_CFLAGS
313
314AM_CONDITIONAL(test_x86_x87, [test x$ac_cv_test_x86_x87 = xyes])
315AM_CONDITIONAL(test_arm_arm, [test x$ac_cv_test_arm_arm = xyes])
316AM_CONDITIONAL(test_arm_swf, [test x$ac_cv_test_arm_swf = xyes])
317
318AM_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])
319
320if test $cpu = arm; then
321 AC_CHECK_LIB(m, sqrtf, ,
322 [AC_MSG_ERROR([sqrtf required but not available])])
323fi
324AC_SUBST(cpu)
325
326AC_SUBST([LIGHTNING_CFLAGS])
327
328if test $ac_cv_header_stdint_h = yes; then
329 AC_SUBST(MAYBE_INCLUDE_STDINT_H, ["#include <stdint.h>"])
330fi
331
24d91c0d 332AC_CONFIG_FILES([Makefile
4a71579b 333 lightning.pc
519a9ea1 334 gnulib-lib/Makefile
4a71579b
PC
335 doc/Makefile
336 include/Makefile
337 include/lightning/Makefile
338 include/lightning.h
339 lib/Makefile
340 check/Makefile])
24d91c0d 341AC_OUTPUT