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