release r24
[pcsx_rearmed.git] / deps / lightning / configure.ac
CommitLineData
4a71579b 1dnl
79bfeef6 2dnl Copyright 2000, 2001, 2002, 2012-2023 Free Software Foundation, Inc.
4a71579b
PC
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 17AC_PREREQ([2.71])
ba86ff93 18AC_INIT([GNU lightning],[2.2.2],[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 ;;
79bfeef6
PC
63 aarch64)
64 case "$host_os" in
65 darwin*)
66 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DPACKED_STACK=1" ;;
67 *) ;;
68 esac ;;
4a71579b
PC
69 *) ;;
70esac
71
40a44dcb 72AC_CHECK_FUNCS(mmap mremap ffsl getopt_long_only isnan isinf,,)
4a71579b
PC
73
74AC_CHECK_HEADERS([getopt.h stdint.h],,,)
75
76AC_ARG_ENABLE(disassembler,
77 AS_HELP_STRING([--enable-disassembler],
78 [Enable jit disassembler using binutils]),
79 [DISASSEMBLER=$enableval], [DISASSEMBLER=auto])
80if test "x$DISASSEMBLER" != "xno"; then
40a44dcb 81
4a71579b
PC
82 AC_CHECK_LIB(iberty, htab_try_create, ,
83 [HAVE_IBERTY="no"])
84 AC_CHECK_LIB(bfd, bfd_init, ,
85 [HAVE_BFD="no"])
86 AC_CHECK_LIB(z, compressBound, ,
87 [HAVE_Z="no"])
88 AC_CHECK_LIB(opcodes, init_disassemble_info, ,
89 [HAVE_OPCODES="no"])
40a44dcb
PC
90
91 if test "x$HAVE_IBERTY" = "xno"; then
92 if test "x$DISASSEMBLER" = "xyes"; then
93 AC_MSG_ERROR([libiberty not found])
94 else
95 AC_MSG_WARN([libiberty not found])
96 DISASSEMBLER="no"
97 fi
4a71579b 98 fi
40a44dcb
PC
99
100 if test "x$HAVE_BFD" = "xno"; then
101 if test "x$DISASSEMBLER" = "xyes"; then
102 AC_MSG_ERROR([binutils BFD not found, see http://www.gnu.org/software/binutils/])
103 else
104 AC_MSG_WARN([binutils BFD not found, see http://www.gnu.org/software/binutils/])
105 DISASSEMBLER="no"
106 fi
107 fi
108
109 if test "x$HAVE_Z" = "xno"; then
110 if test "x$DISASSEMBLER" = "xyes"; then
111 AC_MSG_ERROR([zlib not found, see https://zlib.net/])
112 else
113 AC_MSG_WARN([zlib not found, see https://zlib.net/])
114 DISASSEMBLER="no"
115 fi
116 fi
117
118 if test "x$HAVE_OPCODES" = "xno"; then
119 if test "x$DISASSEMBLER" = "xyes"; then
120 AC_MSG_ERROR([binutils opcodes not found, see https://www.gnu.org/software/binutils/])
121 else
122 AC_MSG_WARN([binutils opcodes not found, see https://www.gnu.org/software/binutils/])
123 DISASSEMBLER="no"
124 fi
125 fi
126
4a71579b
PC
127fi
128AM_CONDITIONAL(with_disassembler, [test "x$DISASSEMBLER" != "xno"])
129if test "x$DISASSEMBLER" != "xno"; then
130 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1"
131 save_CFLAGS=$CFLAGS
c0c16242 132 CFLAGS="$CFLAGS -D_GNU_SOURCE"
4a71579b 133 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
4a71579b
PC
134 #include <dis-asm.h>
135 int main(int argc, char *argv[])
136 {
137 disassembler_ftype print;
138 bfd *abfd;
139 print = disassembler(abfd);
140 return 0;
141 }
142 )], [ac_cv_test_new_disassembler=no],,)
ba3814c1
PC
143 AC_COMPILE_IFELSE([AC_LANG_SOURCE(
144 #include <dis-asm.h>
145 int main(int argc, char *argv[])
146 {
147 struct disassemble_info dinfo;
148 INIT_DISASSEMBLE_INFO(dinfo, NULL, NULL, NULL);
149 return 0;
150 }
151 )], [ac_cv_test_new_disassemble_info=yes],[ac_cv_test_new_disassemble_info=no],)
4a71579b
PC
152 CFLAGS="$save_CFLAGS"
153 if test "x$ac_cv_test_new_disassembler" != "xno"; then
154 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DBINUTILS_2_29=1"
155 fi
ba3814c1
PC
156 if test "x$ac_cv_test_new_disassemble_info" != "xno"; then
157 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DBINUTILS_2_38=1"
158 fi
4a71579b
PC
159fi
160
161AC_ARG_ENABLE(devel-disassembler,
162 AS_HELP_STRING([--enable-devel-disassembler],
163 [Enable extra disassembly options]),
164 [DEVEL_DISASSEMBLER=$enableval], [DEVEL_DISASSEMBLER=no])
165if test "x$DEVEL_DISASSEMBLER" != "xno"; then
166 if test "x$DISASSEMBLER" = "xno"; then
167 AC_MSG_ERROR(devel-disassembler needs disassembler enabled)
168 fi
169 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEVEL_DISASSEMBLER=1"
170fi
171
79bfeef6
PC
172# This option is only useful during development.
173AC_ARG_ENABLE(devel-get-jit-size,
174 AS_HELP_STRING([--enable-devel-get-jit-size],
175 [Devel mode to regenerate jit size information]),
176 [GET_JIT_SIZE=$enableval], [GET_JIT_SIZE=no])
177AM_CONDITIONAL(get_jit_size, [test $GET_JIT_SIZE = yes])
178
4a71579b
PC
179AC_ARG_ENABLE(assertions,
180 AS_HELP_STRING([--enable-assertions],
181 [Enable runtime code generation assertions]),
182 [DEBUG=$enableval], [DEBUG=auto])
79bfeef6
PC
183
184# This option might be made default in the future
185# Currently it is only useful to ensure existing code will work
186# if PACKED_STACK is also defined.
187AC_ARG_ENABLE(devel-strong-type-checking,
188 AS_HELP_STRING([--enable-devel-strong-type-checking],
189 [Devel mode for strong type checking]),
190 [STRONG_TYPE_CHECKING=$enableval], [STRONG_TYPE_CHECKING=no])
191if test "x$DEBUG" = xyes -o x"$STRONG_TYPE_CHECKING" = xyes; then
4a71579b
PC
192 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDEBUG=1"
193else
194 LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DNDEBUG"
195 DEBUG=no
196fi
79bfeef6 197AM_CONDITIONAL(strong_type_checking, [test $STRONG_TYPE_CHECKING = yes])
4a71579b 198
79bfeef6
PC
199AC_CHECK_LIB(dl, dlopen, [HAVE_LIBDL="yes"])
200AC_CHECK_LIB(dld, dlopen, [HAVE_LIBDLD="yes"])
4a71579b 201
79bfeef6
PC
202if test "x$HAVE_LIBDL" = xyes; then
203 SHLIB="-ldl";
204elif test "x$HAVE_LIBDLD" = xyes; then
205 SHLIB="-ldld";
206else
207 SHLIB="";
208fi
4a71579b
PC
209AC_SUBST(SHLIB)
210
211cpu=
212case "$target_cpu" in
213 i?86|x86_64|amd64) cpu=x86 ;;
214 *arm*) cpu=arm ;;
215 *mips*) cpu=mips ;;
216 *powerpc*) cpu=ppc ;;
217 *sparc*) cpu=sparc ;;
218 ia64) cpu=ia64 ;;
219 hppa*) cpu=hppa ;;
220 aarch64) cpu=aarch64 ;;
221 s390*) cpu=s390 ;;
222 alpha*) cpu=alpha ;;
223 riscv*) cpu=riscv ;;
24d91c0d 224 loongarch*) cpu=loongarch ;;
4a71579b
PC
225 *) ;;
226esac
24d91c0d
PC
227AM_CONDITIONAL(cpu_arm, [test cpu-$cpu = cpu-arm])
228AM_CONDITIONAL(cpu_mips, [test cpu-$cpu = cpu-mips])
229AM_CONDITIONAL(cpu_ppc, [test cpu-$cpu = cpu-ppc])
230AM_CONDITIONAL(cpu_sparc, [test cpu-$cpu = cpu-sparc])
231AM_CONDITIONAL(cpu_x86, [test cpu-$cpu = cpu-x86])
232AM_CONDITIONAL(cpu_ia64, [test cpu-$cpu = cpu-ia64])
233AM_CONDITIONAL(cpu_hppa, [test cpu-$cpu = cpu-hppa])
234AM_CONDITIONAL(cpu_aarch64, [test cpu-$cpu = cpu-aarch64])
235AM_CONDITIONAL(cpu_s390, [test cpu-$cpu = cpu-s390])
236AM_CONDITIONAL(cpu_alpha, [test cpu-$cpu = cpu-alpha])
237AM_CONDITIONAL(cpu_riscv, [test cpu-$cpu = cpu-riscv])
238AM_CONDITIONAL(cpu_loongarch, [test cpu-$cpu = cpu-loongarch])
4a71579b
PC
239
240# Test x87 if both, x87 and sse2 available
241ac_cv_test_x86_x87=
242# Test arm instruction set if thumb instruction set available
243ac_cv_test_arm_arm=
244# Test sofware float if vfp available and not using hard float abi
245ac_cv_test_arm_swf=
246
247save_CFLAGS=$CFLAGS
c0c16242 248CFLAGS="$CFLAGS -D_GNU_SOURCE"
4a71579b
PC
249if test x$cpu = x; then
250 AC_MSG_ERROR([cpu $target_cpu not supported])
251elif test $cpu = x86; then
252 AC_RUN_IFELSE([AC_LANG_SOURCE([[
4a71579b
PC
253 int main(void) {
254 int ac, flags;
255 unsigned int eax, ebx, ecx, edx;
79bfeef6 256 if (sizeof(long) == 8)
4a71579b
PC
257 return 1;
258 __asm__ volatile ("pushfl;\n\t"
259 "popl %0;\n\t"
260 "movl \$0x240000, %1;\n\t"
261 "xorl %0, %1;\n\t"
262 "pushl %1;\n\t"
263 "popfl;\n\t"
264 "pushfl;\n\t"
265 "popl %1;\n\t"
266 "xorl %0, %1;\n\t"
267 "pushl %0;\n\t"
268 "popfl"
269 : "=r" (flags), "=r" (ac));
270 if ((ac & (1 << 21)) == 0)
271 return 1;
272 __asm__ volatile ("xchgl %%ebx, %1; cpuid; xchgl %%ebx, %1"
273 : "=a" (eax), "=r" (ebx),
274 "=c" (ecx), "=d" (edx)
275 : "0" (1));
276 return (edx & 1 << 26) ? 0 : 1;
277 }
278 ]])],[ac_cv_test_x86_x87=yes],[],[ac_cv_test_x86_x87=no])
279elif test $cpu = arm; then
280 AC_RUN_IFELSE([AC_LANG_SOURCE([[
281 #include <stdio.h>
282 int main(void) {
283 #if defined(__linux__)
284 FILE *fp;
285 char buf[128];
286 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
287 return 1;
288 while (fgets(buf, sizeof(buf), fp)) {
289 if (strncmp(buf, "Features\t:", 10) == 0 &&
290 strstr(buf + 10, "thumb")) {
291 fclose(fp);
292 return 0;
293 }
294 }
295 fclose(fp);
296 #elif defined(__thumb2__)
297 return 0;
298 #endif
299 return 1;
300 }
301 ]])],[ac_cv_test_arm_arm=yes],[],[ac_cv_test_arm_arm=no])
302 AC_RUN_IFELSE([AC_LANG_SOURCE([[
303 #include <stdio.h>
304 int main(void) {
305 #if defined(__linux__)
306 FILE *fp;
307 char buf[128];
308 # if !defined(__ARM_PCS_VFP)
309 if ((fp = fopen("/proc/cpuinfo", "r")) == NULL)
310 return 1;
311 while (fgets(buf, sizeof(buf), fp)) {
312 if (strncmp(buf, "Features\t:", 10) == 0 &&
313 strstr(buf + 10, "vfp")) {
314 fclose(fp);
315 return 0;
316 }
317 }
318 fclose(fp);
319 # endif
320 #endif
321 return 1;
322 }
323 ]])],[ac_cv_test_arm_swf=yes],[],[ac_cv_test_arm_swf=no])
324elif test $cpu = ppc; then
325 if test "x$DISASSEMBLER" != "xno"; then
326 save_LIBS="$LIBS"
327 LIBS="$LIBS $SHLIB"
328 AC_CHECK_FUNCS(disassemble_init_for_target disassemble_init_powerpc)
329 LIBS="$save_LIBS"
330 fi
331fi
332CFLAGS=$save_CFLAGS
333
334AM_CONDITIONAL(test_x86_x87, [test x$ac_cv_test_x86_x87 = xyes])
335AM_CONDITIONAL(test_arm_arm, [test x$ac_cv_test_arm_arm = xyes])
336AM_CONDITIONAL(test_arm_swf, [test x$ac_cv_test_arm_swf = xyes])
337
338AM_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])
339
340if test $cpu = arm; then
341 AC_CHECK_LIB(m, sqrtf, ,
342 [AC_MSG_ERROR([sqrtf required but not available])])
343fi
344AC_SUBST(cpu)
345
346AC_SUBST([LIGHTNING_CFLAGS])
347
348if test $ac_cv_header_stdint_h = yes; then
349 AC_SUBST(MAYBE_INCLUDE_STDINT_H, ["#include <stdint.h>"])
350fi
351
24d91c0d 352AC_CONFIG_FILES([Makefile
4a71579b 353 lightning.pc
519a9ea1 354 gnulib-lib/Makefile
4a71579b
PC
355 doc/Makefile
356 include/Makefile
357 include/lightning/Makefile
358 include/lightning.h
359 lib/Makefile
360 check/Makefile])
24d91c0d 361AC_OUTPUT