1# Configure template for strace.
2#
3# Copyright (c) 1999-2001 Wichert Akkerman <wichert@deephackmode.org>
4# Copyright (c) 2002-2009 Roland McGrath <roland@redhat.com>
5# Copyright (c) 2006-2016 Dmitry V. Levin <ldv@altlinux.org>
6# Copyright (c) 2008-2015 Mike Frysinger <vapier@gentoo.org>
7# Copyright (c) 2015 Elvira Khabirova <lineprinter0@gmail.com>
8# Copyright (c) 2002-2018 The strace developers.
9# All rights reserved.
10#
11# Redistribution and use in source and binary forms, with or without
12# modification, are permitted provided that the following conditions
13# are met:
14# 1. Redistributions of source code must retain the above copyright
15#    notice, this list of conditions and the following disclaimer.
16# 2. Redistributions in binary form must reproduce the above copyright
17#    notice, this list of conditions and the following disclaimer in the
18#    documentation and/or other materials provided with the distribution.
19# 3. The name of the author may not be used to endorse or promote products
20#    derived from this software without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32
33AC_PREREQ(2.57)
34AC_INIT([strace],
35	m4_esyscmd([./git-version-gen .tarball-version]),
36	[strace-devel@lists.sourceforge.net],
37	[strace],
38	[https://strace.io])
39m4_define([copyright_year], m4_esyscmd([./copyright-year-gen .year]))
40m4_define([manpage_date], m4_esyscmd([./file-date-gen strace.1.in]))
41AC_COPYRIGHT([Copyright (c) 1999-]copyright_year[ The strace developers.])
42AC_CONFIG_SRCDIR([strace.c])
43AC_CONFIG_AUX_DIR([.])
44AC_CONFIG_HEADERS([config.h])
45AM_INIT_AUTOMAKE([foreign nostdinc dist-xz silent-rules parallel-tests 1.13])
46AM_MAINTAINER_MODE
47AC_CANONICAL_HOST
48
49RPM_CHANGELOGTIME="$(LC_TIME=C date '+%a %b %d %Y')"
50AC_SUBST(RPM_CHANGELOGTIME)
51DEB_CHANGELOGTIME="$(LC_TIME=C date -R)"
52AC_SUBST(DEB_CHANGELOGTIME)
53
54AC_PROG_CC
55AC_PROG_CC_STDC
56AC_PROG_CPP
57st_WARN_CFLAGS
58AX_PROG_CC_FOR_BUILD
59AC_PROG_INSTALL
60AC_PROG_RANLIB
61
62AC_USE_SYSTEM_EXTENSIONS
63AX_CODE_COVERAGE
64
65AC_DEFINE([COPYRIGHT_YEAR], "[copyright_year]", [Current copyright year.])
66AC_SUBST([COPYRIGHT_YEAR], [copyright_year])
67
68AC_DEFINE([MANPAGE_DATE], "[manpage_date]", [Date])
69AC_SUBST([MANPAGE_DATE], [manpage_date])
70
71AC_MSG_CHECKING([for supported architecture])
72arch_m32=
73arch_mx32=
74cc_flags_m32=-m32
75cc_flags_mx32=-mx32
76case "$host_cpu" in
77aarch64*)
78	arch=aarch64
79	arch_m32=arm
80	AC_DEFINE([AARCH64], 1, [Define for the AArch64 architecture.])
81	;;
82alpha*)
83	arch=alpha
84	AC_DEFINE([ALPHA], 1, [Define for the Alpha architecture.])
85	;;
86arc*)
87	arch=arc
88	AC_DEFINE([ARC], 1, [Define for the ARC architecture.])
89	;;
90arm*)
91	arch=arm
92	AC_DEFINE([ARM], 1, [Define for the ARM architecture.])
93	;;
94avr32*)
95	arch=avr32
96	AC_DEFINE([AVR32], 1, [Define for the AVR32 architecture.])
97	;;
98bfin)
99	arch=bfin
100	AC_DEFINE([BFIN], 1, [Define for the Blackfin architecture.])
101	;;
102hppa*|parisc*)
103	arch=hppa
104	AC_DEFINE([HPPA], 1, [Define for the HPPA architecture.])
105	;;
106i[[3456]]86|pentium)
107	arch=i386
108	AC_DEFINE([I386], 1, [Define for the i386 architecture.])
109	;;
110ia64)
111	arch=ia64
112	AC_DEFINE([IA64], 1, [Define for the IA64 architecture.])
113	;;
114m68k)
115	arch=m68k
116	AC_DEFINE([M68K], 1, [Define for the m68k architecture.])
117	;;
118metag*)
119	arch=metag
120	AC_DEFINE([METAG], 1, [Define for the Meta architecture.])
121	;;
122microblaze*)
123	arch=microblaze
124	AC_DEFINE([MICROBLAZE], 1, [Define for the MicroBlaze architecture.])
125	;;
126mips*)
127	arch=mips
128	AC_DEFINE([MIPS], 1, [Define for the MIPS architecture.])
129	;;
130nios2*)
131	arch=nios2
132	AC_DEFINE([NIOS2], 1, [Define for the Nios-II architecture.])
133	;;
134or1k*)
135	arch=or1k
136	AC_DEFINE([OR1K], 1, [Define for the OpenRISC 1000 architecture.])
137	;;
138powerpc*)
139	AC_DEFINE([POWERPC], 1, [Define for the PowerPC architecture.])
140	AC_TRY_COMPILE(
141[#ifndef __LP64__
142# error 32 bit
143#endif], [], arch=powerpc64, arch=powerpc)
144	if test "$arch" = "powerpc64"; then
145		arch_m32=powerpc
146		AC_DEFINE([POWERPC64], 1, [Define for the PowerPC64 architecture.])
147	fi
148	;;
149riscv*)
150	arch=riscv
151	AC_DEFINE([RISCV], 1, [Define for the RISC-V architecture])
152	;;
153s390)
154	arch=s390
155	AC_DEFINE([S390], 1, [Define for the S390 architecture.])
156	;;
157s390x)
158	arch=s390x
159	arch_m32=s390
160	cc_flags_m32=-m31
161	AC_DEFINE([S390X], 1, [Define for the S390x architecture.])
162	;;
163sh64*)
164	arch=sh64
165	AC_DEFINE([SH64], 1, [Define for the SH64 architecture.])
166	;;
167sh*)
168	arch=sh
169	AC_DEFINE([SH], 1, [Define for the SH architecture.])
170	;;
171sparc64*)
172	arch=sparc64
173	arch_m32=sparc
174	AC_DEFINE([SPARC64], 1, [Define for the SPARC64 architecture.])
175	;;
176sparc*)
177	arch=sparc
178	AC_DEFINE([SPARC], 1, [Define for the SPARC architecture.])
179	;;
180tile*)
181	arch=tile
182	AC_DEFINE([TILE], 1, [Define for the Tile architecture])
183	;;
184x86?64*)
185	arch_m32=i386
186	AC_TRY_COMPILE(
187[#ifndef __ILP32__
188# error not x32
189#endif], [], arch=x32, arch=x86_64)
190	if test "$arch" = "x86_64"; then
191		arch_mx32=x32
192		AC_DEFINE([X86_64], 1, [Define for the 64bit AMD x86-64 architecture.])
193	else
194		AC_DEFINE([X32], 1, [Define for the 32bit AMD x86-64 architecture.])
195	fi
196	;;
197xtensa*)
198	arch=xtensa
199	AC_DEFINE([XTENSA], 1, [Define for the Xtensa architecture])
200	;;
201*)
202	AC_MSG_RESULT([NO!])
203	AC_MSG_ERROR([architecture $host_cpu is not supported by strace])
204	;;
205esac
206AC_MSG_RESULT($arch)
207
208arch_native=$arch
209
210test -n "$arch_m32" ||
211	arch_m32=$arch
212test -n "$arch_mx32" ||
213	arch_mx32=$arch
214AC_SUBST(arch)
215AC_SUBST(arch_m32)
216AC_SUBST(arch_mx32)
217AC_SUBST(cc_flags_m32)
218AC_SUBST(cc_flags_mx32)
219AC_SUBST(arch_native)
220
221MIPS_ABI=
222if test "$arch" = mips; then
223	AC_CACHE_CHECK([for _MIPS_SIM], [st_cv__MIPS_SIM],
224		       [AC_COMPUTE_INT([st_cv__MIPS_SIM], [_MIPS_SIM], ,
225				       [AC_MSG_FAILURE([_MIPS_SIM cannot be determined])])])
226
227	# requires GCC >= 3.4
228	AC_CACHE_CHECK([for MIPS ABI], [st_cv_mips_abi],
229		[AC_COMPILE_IFELSE(
230			[AC_LANG_PROGRAM(, [[int i[_MIPS_SIM == _ABIO32 ? 1 : - 1];]])],
231			[st_cv_mips_abi=o32],
232		[AC_COMPILE_IFELSE(
233			[AC_LANG_PROGRAM(, [[int i[_MIPS_SIM == _ABIN32 ? 1 : - 1];]])],
234			[st_cv_mips_abi=n32],
235		[AC_COMPILE_IFELSE(
236			[AC_LANG_PROGRAM(, [[int i[_MIPS_SIM == _ABI64 ? 1 : - 1];]])],
237			[st_cv_mips_abi=n64],
238			[st_cv_mips_abi=unknown])])])])
239
240	case "$st_cv_mips_abi" in
241		o32) AC_DEFINE([LINUX_MIPSO32], [1], [Define for _ABIO32.]);;
242		n32) AC_DEFINE([LINUX_MIPSN32], [1], [Define for _ABIN32.]);;
243		n64) AC_DEFINE([LINUX_MIPSN64], [1], [Define for _ABI64.]);;
244		*) AC_MSG_ERROR([Unsupported _MIPS_SIM]);;
245	esac
246	MIPS_ABI="$st_cv_mips_abi"
247fi
248AC_SUBST(MIPS_ABI)
249
250AC_ARG_ENABLE([arm-oabi],
251	      [AS_HELP_STRING([--enable-arm-oabi],
252			      [enable OABI support on ARM EABI])],
253	      [], [enable_arm_oabi=no])
254case "$enable_arm_oabi" in
255	yes) enable_arm_oabi=1 ;;
256	no) enable_arm_oabi=0 ;;
257	*) AC_MSG_ERROR([bad value $enable_arm_oabi for arm-oabi option]) ;;
258esac
259AC_DEFINE_UNQUOTED([ENABLE_ARM_OABI], [$enable_arm_oabi],
260		   [Define to 1 if you want OABI support on ARM EABI.])
261
262AC_C_BIGENDIAN
263AC_C_TYPEOF
264
265AC_TYPE_UID_T
266
267AC_CHECK_FUNCS(m4_normalize([
268	accept4
269	be64toh
270	fallocate
271	fanotify_mark
272	fopen64
273	fork
274	fputs_unlocked
275	fstatat
276	ftruncate
277	futimens
278	iconv_open
279	if_indextoname
280	open64
281	prctl
282	preadv
283	process_vm_readv
284	pwritev
285	readahead
286	signalfd
287	stpcpy
288	strerror
289	strndup
290	strsignal
291	sync_file_range
292	utimensat
293]))
294
295AC_CHECK_TYPES([sig_atomic_t, struct sigcontext],,, [#include <signal.h>])
296
297AC_CHECK_TYPES([struct mmsghdr],,, [#include <sys/socket.h>])
298
299AC_CHECK_TYPES([__kernel_long_t, __kernel_ulong_t],,,
300[#include <asm/posix_types.h>])
301
302AC_CHECK_TYPES([struct stat64, struct __old_kernel_stat],,,
303[#include <sys/types.h>
304#include <asm/stat.h>])
305
306AC_CHECK_TYPES([struct user_desc],
307	       [AC_CHECK_MEMBERS([struct user_desc.lm],,,
308				 [#include <asm/ldt.h>])],,
309	       [#include <asm/ldt.h>])
310
311AC_CHECK_MEMBERS([struct stat.st_mtime_nsec, struct stat64.st_mtime_nsec],,,
312[#include <sys/types.h>
313#include <asm/stat.h>])
314
315AC_CHECK_TYPES(m4_normalize([
316	struct pt_all_user_regs,
317	struct ia64_fpreg,
318	struct ptrace_peeksiginfo_args
319]),,, [#include <sys/ptrace.h>])
320
321AC_CHECK_TYPES(m4_normalize([
322	struct flock,
323	struct flock64,
324	struct __kernel_flock,
325	struct __kernel_flock64
326]),,,
327[#include <sys/types.h>
328#include <linux/fcntl.h>])
329
330AC_CHECK_TYPES(m4_normalize([
331	struct crypto_report_aead,
332	struct crypto_report_blkcipher,
333	struct crypto_report_cipher,
334	struct crypto_report_hash,
335	struct crypto_report_rng
336]),,, [#include <linux/cryptouser.h>])
337
338AC_CHECK_TYPES(m4_normalize([
339	struct kcmp_epoll_slot
340]),,, [#include <linux/kcmp.h>])
341
342AC_CHECK_TYPES(m4_normalize([
343	struct keyctl_kdf_params
344]),,, [#include <linux/keyctl.h>])
345
346AC_CHECK_MEMBERS([struct timex.tai],,, [#include <sys/timex.h>])
347
348AC_CHECK_MEMBERS([struct utsname.domainname],,, [#include <sys/utsname.h>])
349
350AC_CHECK_MEMBERS(m4_normalize([
351	siginfo_t.si_syscall,
352	siginfo_t.si_timerid,
353	siginfo_t.si_overrun
354]),,, [#include <signal.h>])
355
356AC_CHECK_MEMBERS(m4_normalize([
357	struct perf_event_attr.precise_ip,
358	struct perf_event_attr.mmap_data,
359	struct perf_event_attr.sample_id_all,
360	struct perf_event_attr.exclude_host,
361	struct perf_event_attr.exclude_guest,
362	struct perf_event_attr.exclude_callchain_kernel,
363	struct perf_event_attr.exclude_callchain_user,
364	struct perf_event_attr.mmap2,
365	struct perf_event_attr.comm_exec,
366	struct perf_event_attr.use_clockid,
367	struct perf_event_attr.context_switch,
368	struct perf_event_attr.write_backward,
369	struct perf_event_attr.namespaces,
370	struct perf_event_attr.bp_type,
371	struct perf_event_attr.config1,
372	struct perf_event_attr.config2,
373	struct perf_event_attr.branch_sample_type,
374	struct perf_event_attr.sample_regs_user,
375	struct perf_event_attr.sample_stack_user,
376	struct perf_event_attr.sample_regs_intr,
377	struct perf_event_attr.aux_watermark,
378	struct perf_event_attr.sample_max_stack
379]),,, [#include <linux/perf_event.h>])
380
381AC_CHECK_HEADERS(m4_normalize([
382	asm/cachectl.h
383	asm/guarded_storage.h
384	asm/sysmips.h
385	bluetooth/bluetooth.h
386	elf.h
387	iconv.h
388	inttypes.h
389	linux/bsg.h
390	linux/cryptouser.h
391	linux/dm-ioctl.h
392	linux/dqblk_xfs.h
393	linux/falloc.h
394	linux/fib_rules.h
395	linux/fiemap.h
396	linux/genetlink.h
397	linux/hiddev.h
398	linux/if_addr.h
399	linux/if_link.h
400	linux/ip_vs.h
401	linux/ipc.h
402	linux/kcmp.h
403	linux/kvm.h
404	linux/memfd.h
405	linux/mmtimer.h
406	linux/msg.h
407	linux/neighbour.h
408	linux/netfilter/ipset/ip_set.h
409	linux/netfilter/nf_tables.h
410	linux/netfilter/nf_tables_compat.h
411	linux/netfilter/nfnetlink.h
412	linux/netfilter/nfnetlink_acct.h
413	linux/netfilter/nfnetlink_conntrack.h
414	linux/netfilter/nfnetlink_cthelper.h
415	linux/netfilter/nfnetlink_cttimeout.h
416	linux/netfilter/nfnetlink_log.h
417	linux/netfilter/nfnetlink_queue.h
418	linux/nsfs.h
419	linux/perf_event.h
420	linux/quota.h
421	linux/seccomp.h
422	linux/securebits.h
423	linux/sem.h
424	linux/shm.h
425	linux/userfaultfd.h
426	linux/utsname.h
427	mqueue.h
428	netinet/sctp.h
429	netipx/ipx.h
430	paths.h
431	scsi/sg.h
432	stropts.h
433	sys/conf.h
434	sys/eventfd.h
435	sys/fanotify.h
436	sys/ipc.h
437	sys/msg.h
438	sys/quota.h
439	sys/reg.h
440	sys/sem.h
441	sys/shm.h
442	sys/signalfd.h
443	sys/xattr.h
444	ustat.h
445]))
446
447AC_CHECK_HEADERS([asm/sigcontext.h],,, [#include <signal.h>])
448
449AC_CHECK_HEADERS([netinet/tcp.h netinet/udp.h],,, [#include <netinet/in.h>])
450
451AC_CHECK_HEADERS([linux/mqueue.h],,, [#include <linux/types.h>])
452
453AC_CHECK_HEADERS([linux/netfilter/xt_osf.h],,, [#include <linux/ip.h>
454#include <linux/tcp.h>])
455
456AC_CHECK_HEADERS(m4_normalize([
457	linux/netfilter_arp/arp_tables.h
458	linux/netfilter_bridge/ebtables.h
459	linux/netfilter_ipv4/ip_tables.h
460	linux/netfilter_ipv6/ip6_tables.h
461]),,, [#include <netinet/in.h>
462#include <net/if.h>])
463
464AC_CHECK_HEADERS([linux/input.h], [
465	AC_CHECK_MEMBERS([struct input_absinfo.resolution],,, [#include <linux/input.h>])
466])
467
468AC_CHECK_HEADERS([linux/bpf.h], [
469	AC_CHECK_MEMBERS(m4_normalize([
470		union bpf_attr.attach_flags,
471		union bpf_attr.bpf_fd,
472		union bpf_attr.flags,
473		union bpf_attr.info.info,
474		union bpf_attr.next_id,
475		union bpf_attr.numa_node,
476		union bpf_attr.prog_flags,
477		union bpf_attr.test.duration
478	]),,, [#include <linux/bpf.h>])
479])
480
481AC_CHECK_TYPES(m4_normalize([
482	struct br_mdb_entry,
483	struct br_port_msg
484]),,, [#include <linux/if_bridge.h>])
485AC_CHECK_MEMBERS(m4_normalize([
486	struct br_mdb_entry.flags,
487	struct br_mdb_entry.vid
488]),,, [#include <linux/if_bridge.h>])
489
490AC_CHECK_TYPES([struct dcbmsg],,, [#include <linux/dcbnl.h>])
491AC_CHECK_TYPES([struct ifaddrlblmsg],,, [#include <linux/if_addrlabel.h>])
492AC_CHECK_TYPES([struct netconfmsg],,, [#include <linux/netconf.h>])
493
494AC_CHECK_TYPES(m4_normalize([
495	struct rta_mfc_stats,
496	struct rtvia
497]),,, [#include <linux/rtnetlink.h>])
498
499AC_CHECK_MEMBERS([struct ndt_stats.ndts_table_fulls],,, [#include <linux/neighbour.h>])
500AC_CHECK_TYPES(m4_normalize([
501	struct ndt_config,
502	struct ndt_stats
503]),,, [#include <linux/neighbour.h>])
504
505AC_CHECK_TYPES(m4_normalize([
506	struct ifla_bridge_id,
507	struct ifla_port_vsi,
508	struct rtnl_link_stats64
509]),,, [#include <linux/if_link.h>])
510AC_CHECK_MEMBERS(m4_normalize([
511	struct rtnl_link_stats.rx_nohandler,
512	struct rtnl_link_stats64.rx_nohandler
513]),,, [#include <linux/if_link.h>])
514
515AC_CHECK_TYPES(m4_normalize([
516	struct gnet_stats_basic,
517	struct gnet_stats_queue,
518	struct gnet_stats_rate_est,
519	struct gnet_stats_rate_est64
520]),,, [#include <linux/gen_stats.h>])
521
522AC_CHECK_TYPES([struct tc_sizespec],,, [#include <linux/pkt_sched.h>])
523
524AC_CHECK_TYPES([struct fib_rule_uid_range],,, [#include <linux/fib_rules.h>])
525
526AC_CHECK_TYPES([struct statfs], [
527	AC_CHECK_MEMBERS(m4_normalize([
528		struct statfs.f_frsize,
529		struct statfs.f_flags,
530		struct statfs.f_fsid.val,
531		struct statfs.f_fsid.__val
532	]),,, [#include <linux/types.h>
533#include <asm/statfs.h>])
534],, [#include <linux/types.h>
535#include <asm/statfs.h>])
536
537AC_CHECK_TYPES([struct statfs64], [
538	AC_CHECK_MEMBERS(m4_normalize([
539		struct statfs64.f_frsize,
540		struct statfs64.f_flags,
541		struct statfs64.f_fsid.val,
542		struct statfs64.f_fsid.__val
543	]),,, [#include <linux/types.h>
544#include <asm/statfs.h>])
545],, [#include <linux/types.h>
546#include <asm/statfs.h>])
547
548AC_CHECK_TYPES([struct blk_user_trace_setup],,, [#include <linux/blktrace_api.h>])
549
550AC_CHECK_TYPES([struct mtd_write_req],,, [#include <mtd/mtd-abi.h>])
551
552AC_CHECK_MEMBERS([struct ubi_attach_req.max_beb_per1024],,, [#include <mtd/ubi-user.h>])
553
554AC_CHECK_TYPES(m4_normalize([
555	struct ptp_sys_offset
556]),,, [#include <linux/ptp_clock.h>])
557
558AC_CHECK_TYPES(m4_normalize([
559	struct kvm_regs,
560	struct kvm_sregs,
561	struct kvm_userspace_memory_region
562]),,, [#include <linux/kvm.h>])
563
564AC_CHECK_HEADERS([linux/btrfs.h], [
565	AC_CHECK_MEMBERS(m4_normalize([
566		struct btrfs_ioctl_feature_flags.compat_flags,
567		struct btrfs_ioctl_fs_info_args.nodesize,
568		struct btrfs_ioctl_defrag_range_args.start,
569		struct btrfs_ioctl_search_args_v2.buf_size
570		]),,, [ #include <stdio.h>
571#include <linux/btrfs.h>])
572	AC_CHECK_DECLS(m4_normalize([BTRFS_COMPRESS_NONE, BTRFS_COMPRESS_ZLIB,
573				BTRFS_COMPRESS_LZO]),,,[ #include <stdio.h>
574#include <linux/btrfs.h>])])
575
576AC_CHECK_DECLS([sys_errlist])
577AC_CHECK_DECLS(m4_normalize([
578	PTRACE_PEEKUSER,
579	PTRACE_POKEUSER
580]),,, [#include <sys/ptrace.h>])
581
582AC_CHECK_DECLS(m4_normalize([
583	P_PID,
584	P_PPID,
585	P_PGID,
586	P_SID,
587	P_CID,
588	P_UID,
589	P_GID,
590	P_ALL,
591	P_LWPID
592]),,, [#include <sys/wait.h>])
593
594AC_CHECK_DECLS(m4_normalize([
595	LO_FLAGS_READ_ONLY,
596	LO_FLAGS_USE_AOPS,
597	LO_FLAGS_AUTOCLEAR,
598	LO_FLAGS_PARTSCAN,
599	LO_FLAGS_DIRECT_IO
600]),,, [#include <linux/loop.h>])
601
602AC_CHECK_DECLS(m4_normalize([
603	CTL_PROC,
604	CTL_ARLAN,
605	CTL_S390DBF,
606	CTL_SUNRPC,
607	CTL_PM,
608	CTL_FRV,
609	KERN_PRINTK_RATELIMIT,
610	KERN_PRINTK_RATELIMIT_BURST,
611	KERN_PTY,
612	KERN_NGROUPS_MAX,
613	KERN_SPARC_SCONS_PWROFF,
614	KERN_HZ_TIMER,
615	KERN_UNKNOWN_NMI_PANIC,
616	KERN_BOOTLOADER_TYPE,
617	KERN_RANDOMIZE,
618	KERN_SETUID_DUMPABLE,
619	KERN_SPIN_RETRY,
620	KERN_ACPI_VIDEO_FLAGS,
621	KERN_IA64_UNALIGNED,
622	KERN_COMPAT_LOG,
623	KERN_MAX_LOCK_DEPTH,
624	KERN_NMI_WATCHDOG,
625	KERN_PANIC_ON_NMI,
626	NET_LLC,
627	NET_NETFILTER,
628	NET_DCCP,
629	NET_IRDA,
630	NET_CORE_DESTROY_DELAY,
631	NET_CORE_BUDGET,
632	NET_CORE_AEVENT_ETIME,
633	NET_CORE_AEVENT_RSEQTH,
634	NET_CORE_WARNINGS,
635	NET_IPV4_IGMP_MAX_MSF,
636	NET_TCP_NO_METRICS_SAVE,
637	NET_TCP_DEFAULT_WIN_SCALE,
638	NET_TCP_MODERATE_RCVBUF,
639	NET_TCP_TSO_WIN_DIVISOR,
640	NET_TCP_BIC_BETA,
641	NET_IPV4_ICMP_ERRORS_USE_INBOUND_IFADDR,
642	NET_TCP_CONG_CONTROL,
643	NET_TCP_ABC,
644	NET_IPV4_IPFRAG_MAX_DIST,
645	NET_TCP_MTU_PROBING,
646	NET_TCP_BASE_MSS,
647	NET_IPV4_TCP_WORKAROUND_SIGNED_WINDOWS,
648	NET_TCP_DMA_COPYBREAK,
649	NET_TCP_SLOW_START_AFTER_IDLE,
650	NET_CIPSOV4_CACHE_ENABLE,
651	NET_CIPSOV4_CACHE_BUCKET_SIZE,
652	NET_CIPSOV4_RBM_OPTFMT,
653	NET_CIPSOV4_RBM_STRICTVALID,
654	NET_TCP_AVAIL_CONG_CONTROL,
655	NET_TCP_ALLOWED_CONG_CONTROL,
656	NET_TCP_MAX_SSTHRESH,
657	NET_TCP_FRTO_RESPONSE,
658	NET_IPV4_ROUTE_GC_MIN_INTERVAL_MS,
659	NET_IPV4_CONF_FORCE_IGMP_VERSION,
660	NET_IPV4_CONF_ARP_ANNOUNCE,
661	NET_IPV4_CONF_ARP_IGNORE,
662	NET_IPV4_CONF_PROMOTE_SECONDARIES,
663	NET_IPV4_CONF_ARP_ACCEPT,
664	NET_IPV4_CONF_ARP_NOTIFY,
665	NET_IPV6_MLD_MAX_MSF,
666	NET_IPV6_ROUTE_GC_MIN_INTERVAL_MS,
667	VM_MAX_MAP_COUNT,
668	VM_LAPTOP_MODE,
669	VM_BLOCK_DUMP,
670	VM_HUGETLB_GROUP,
671	VM_VFS_CACHE_PRESSURE,
672	VM_LEGACY_VA_LAYOUT,
673	VM_SWAP_TOKEN_TIMEOUT
674]),,,
675[#include <sys/types.h>
676#include <linux/sysctl.h>])
677
678AC_CHECK_DECLS(m4_normalize([
679	V4L2_FIELD_ANY,
680	V4L2_FIELD_NONE,
681	V4L2_FIELD_TOP,
682	V4L2_FIELD_BOTTOM,
683	V4L2_FIELD_INTERLACED,
684	V4L2_FIELD_SEQ_TB,
685	V4L2_FIELD_SEQ_BT,
686	V4L2_FIELD_ALTERNATE,
687	V4L2_FIELD_INTERLACED_TB,
688	V4L2_FIELD_INTERLACED_BT,
689	V4L2_BUF_TYPE_VIDEO_CAPTURE,
690	V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
691	V4L2_BUF_TYPE_VIDEO_OUTPUT,
692	V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE,
693	V4L2_BUF_TYPE_VIDEO_OVERLAY,
694	V4L2_BUF_TYPE_VBI_CAPTURE,
695	V4L2_BUF_TYPE_VBI_OUTPUT,
696	V4L2_BUF_TYPE_SLICED_VBI_CAPTURE,
697	V4L2_BUF_TYPE_SLICED_VBI_OUTPUT,
698	V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY,
699	V4L2_BUF_TYPE_SDR_CAPTURE,
700	V4L2_BUF_TYPE_SDR_OUTPUT,
701	V4L2_TUNER_RADIO,
702	V4L2_TUNER_ANALOG_TV,
703	V4L2_TUNER_DIGITAL_TV,
704	V4L2_MEMORY_MMAP,
705	V4L2_MEMORY_USERPTR,
706	V4L2_MEMORY_OVERLAY,
707	V4L2_MEMORY_DMABUF,
708	V4L2_COLORSPACE_SMPTE170M,
709	V4L2_COLORSPACE_SMPTE240M,
710	V4L2_COLORSPACE_REC709,
711	V4L2_COLORSPACE_BT878,
712	V4L2_COLORSPACE_470_SYSTEM_M,
713	V4L2_COLORSPACE_470_SYSTEM_BG,
714	V4L2_COLORSPACE_JPEG,
715	V4L2_COLORSPACE_SRGB,
716	V4L2_PRIORITY_UNSET,
717	V4L2_PRIORITY_BACKGROUND,
718	V4L2_PRIORITY_INTERACTIVE,
719	V4L2_PRIORITY_RECORD,
720	V4L2_FRMSIZE_TYPE_DISCRETE,
721	V4L2_FRMSIZE_TYPE_CONTINUOUS,
722	V4L2_FRMSIZE_TYPE_STEPWISE,
723	V4L2_FRMIVAL_TYPE_DISCRETE,
724	V4L2_FRMIVAL_TYPE_CONTINUOUS,
725	V4L2_FRMIVAL_TYPE_STEPWISE,
726	V4L2_CTRL_TYPE_INTEGER,
727	V4L2_CTRL_TYPE_BOOLEAN,
728	V4L2_CTRL_TYPE_MENU,
729	V4L2_CTRL_TYPE_BUTTON,
730	V4L2_CTRL_TYPE_INTEGER64,
731	V4L2_CTRL_TYPE_CTRL_CLASS,
732	V4L2_CTRL_TYPE_STRING,
733	V4L2_CTRL_TYPE_BITMASK,
734	V4L2_CTRL_TYPE_INTEGER_MENU
735]),,, [#include <sys/time.h>
736#include <linux/ioctl.h>
737#include <linux/types.h>
738#include <linux/videodev2.h>])
739
740AC_CHECK_MEMBERS(m4_normalize([
741	struct v4l2_window.global_alpha,
742	struct v4l2_sdr_format.buffersize
743]),,, [#include <sys/time.h>
744#include <linux/ioctl.h>
745#include <linux/types.h>
746#include <linux/videodev2.h>])
747
748AC_CACHE_CHECK([for BLKGETSIZE64], [ac_cv_have_blkgetsize64],
749	[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
750#include <stdlib.h>
751#include <linux/fs.h>], [return !BLKGETSIZE64;])],
752			   [ac_cv_have_blkgetsize64=yes], [ac_cv_have_blkgetsize64=no])]
753	if test $ac_cv_have_blkgetsize64 = yes; then
754		AC_DEFINE([HAVE_BLKGETSIZE64], [1], [Define to 1 if you have BLKGETSIZE64.])
755	fi)
756
757AC_CHECK_SIZEOF([long])
758SIZEOF_LONG="$ac_cv_sizeof_long"
759AC_SUBST(SIZEOF_LONG)
760AC_CHECK_SIZEOF([long long])
761AC_CHECK_SIZEOF([off_t],,[#include <sys/types.h>])
762AC_CHECK_SIZEOF([kernel_long_t],,[#include "$srcdir/kernel_types.h"])
763SIZEOF_KERNEL_LONG_T="$ac_cv_sizeof_kernel_long_t"
764AC_SUBST(SIZEOF_KERNEL_LONG_T)
765AC_CHECK_SIZEOF([struct i64_i32],,[struct i64_i32 {long long i64; int i32;};])
766
767
768AC_CACHE_CHECK([for SIGRTMIN], [st_cv_SIGRTMIN],
769	       [[st_cv_SIGRTMIN="$(echo SIGRTMIN |
770			$CPP $CPPFLAGS -P -imacros asm/signal.h - |
771			grep '^[0-9]')"
772		 test -n "$st_cv_SIGRTMIN" || st_cv_SIGRTMIN=no]])
773if test "x$st_cv_SIGRTMIN" != xno; then
774	AC_DEFINE_UNQUOTED([ASM_SIGRTMIN], [$st_cv_SIGRTMIN],
775			   [SIGRTMIN defined in <asm/signal.h>])
776fi
777AC_CACHE_CHECK([for SA_RESTORER], [st_cv_SA_RESTORER],
778	       [st_cv_SA_RESTORER="$(echo SA_RESTORER |
779			$CPP $CPPFLAGS -P -imacros asm/signal.h - |
780			grep ^0x)"
781		test -n "$st_cv_SA_RESTORER" || st_cv_SA_RESTORER=no])
782if test "x$st_cv_SA_RESTORER" != xno; then
783	AC_DEFINE_UNQUOTED([ASM_SA_RESTORER], [$st_cv_SA_RESTORER],
784			   [SA_RESTORER defined in <asm/signal.h>])
785fi
786
787AC_CACHE_CHECK([for __builtin_popcount], [st_cv_have___builtin_popcount],
788	       [AC_LINK_IFELSE([AC_LANG_PROGRAM([], [__builtin_popcount(0)])],
789			       [st_cv_have___builtin_popcount=yes],
790			       [st_cv_have___builtin_popcount=no])])
791if test "x$st_cv_have___builtin_popcount" = xyes; then
792	AC_DEFINE([HAVE___BUILTIN_POPCOUNT], [1],
793		  [Define to 1 if the system provides __builtin_popcount function])
794fi
795
796AC_CACHE_CHECK([for program_invocation_name], [st_cv_have_program_invocation_name],
797	       [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <errno.h>]],
798						[[return !*program_invocation_name]])],
799			       [st_cv_have_program_invocation_name=yes],
800			       [st_cv_have_program_invocation_name=no])])
801if test "x$st_cv_have_program_invocation_name" = xyes; then
802	AC_DEFINE([HAVE_PROGRAM_INVOCATION_NAME], [1],
803		  [Define to 1 if the system provides program_invocation_name variable])
804fi
805
806AC_CHECK_LIB([dl], [dladdr], [dl_LIBS='-ldl'], [dl_LIBS=])
807if test "x$ac_cv_lib_dl_dladdr" = xyes; then
808	AC_DEFINE([HAVE_DLADDR], [1], [Define to 1 if the system provides dladdr])
809fi
810AC_SUBST(dl_LIBS)
811
812AC_PATH_PROG([PERL], [perl])
813
814AC_CHECK_TOOL([READELF], [readelf])
815
816dnl stack trace with libunwind
817libunwind_CPPFLAGS=
818libunwind_LDFLAGS=
819libunwind_LIBS=
820AC_ARG_WITH([libunwind],
821	    [AS_HELP_STRING([--with-libunwind],
822			    [use libunwind to implement stack tracing support])],
823	    [case "${withval}" in
824	     yes|no|check) ;;
825	     *) with_libunwind=yes
826		libunwind_CPPFLAGS="-I${withval}/include"
827		libunwind_LDFLAGS="-L${withval}/lib" ;;
828	     esac],
829	    [with_libunwind=check]
830)
831
832use_libunwind=no
833AS_IF([test "x$with_libunwind" != xno],
834      [saved_CPPFLAGS="$CPPFLAGS"
835       CPPFLAGS="$CPPFLAGS $libunwind_CPPFLAGS"
836
837       AC_CHECK_HEADERS([libunwind-ptrace.h],
838	 [saved_LDFLAGS="$LDFLAGS"
839	  LDFLAGS="$LDFLAGS $libunwind_LDFLAGS"
840
841	  AC_CHECK_LIB([unwind], [backtrace],
842	    [libunwind_LIBS="-lunwind $libunwind_LIBS"
843
844	     AC_MSG_CHECKING([for unw_create_addr_space in libunwind-generic])
845	     saved_LIBS="$LIBS"
846	     LIBS="-lunwind-generic $libunwind_LIBS $LIBS"
847
848	     AC_LINK_IFELSE(
849	       [AC_LANG_PROGRAM([[#include <libunwind-ptrace.h>]],
850				[[return !unw_create_addr_space(0, 0)]])
851	       ],
852	       [AC_MSG_RESULT([yes])
853		libunwind_LIBS="-lunwind-generic $libunwind_LIBS"
854
855		AC_CHECK_LIB([unwind-ptrace], [_UPT_create],
856		  [libunwind_LIBS="-lunwind-ptrace $libunwind_LIBS"
857		   use_libunwind=yes
858		  ],
859		  [if test "x$with_libunwind" != xcheck; then
860		     AC_MSG_FAILURE([failed to find _UPT_create in libunwind-ptrace])
861		   fi
862		  ],
863		  [$libunwind_LIBS]
864		)
865	       ],
866	       [AC_MSG_RESULT([no])
867		if test "x$with_libunwind" != xcheck; then
868		  AC_MSG_FAILURE([failed to find unw_create_addr_space in libunwind-generic])
869		fi
870	       ]
871	     )
872
873	     LIBS="$saved_LIBS"
874	    ],
875	    [if test "x$with_libunwind" != xcheck; then
876	       AC_MSG_FAILURE([failed to find libunwind])
877	     fi
878	    ],
879	    [$libunwind_LIBS]
880	  )
881
882	  LDFLAGS="$saved_LDFLAGS"
883	 ],
884	 [if test "x$with_libunwind" != xcheck; then
885	    AC_MSG_FAILURE([failed to find libunwind-ptrace.h])
886	  fi
887	 ]
888       )
889
890       CPPFLAGS="$saved_CPPFLAGS"
891      ]
892)
893
894dnl enable libunwind
895AC_MSG_CHECKING([whether to enable stack tracing support using libunwind])
896if test "x$use_libunwind" = xyes; then
897	AC_DEFINE([USE_LIBUNWIND], 1, [Compile stack tracing functionality])
898	AC_SUBST(libunwind_LIBS)
899	AC_SUBST(libunwind_LDFLAGS)
900	AC_SUBST(libunwind_CPPFLAGS)
901fi
902AM_CONDITIONAL([USE_LIBUNWIND], [test "x$use_libunwind" = xyes])
903AC_MSG_RESULT([$use_libunwind])
904
905dnl demangling symbols in the stack trace
906libiberty_CPPFLAGS=
907libiberty_LDFLAGS=
908libiberty_LIBS=
909AC_ARG_WITH([libiberty],
910	    [AS_HELP_STRING([--with-libiberty],
911			    [use libiberty to demangle symbols in stack trace])],
912	    [case "${withval}" in
913	     yes|no|check) ;;
914	     *) with_libiberty=yes
915		libiberty_CPPFLAGS="-I${withval}/include"
916		libiberty_LDFLAGS="-L${withval}/lib" ;;
917	     esac],
918	    [with_libiberty=check]
919)
920
921use_libiberty=no
922AS_IF([test "x$use_libunwind" = xyes && test "x$with_libiberty" != xno],
923      [saved_CPPFLAGS="$CPPFLAGS"
924       CPPFLAGS="$CPPFLAGS $libiberty_CPPFLAGS"
925       AC_CHECK_HEADERS([demangle.h libiberty/demangle.h],
926	 [saved_LDFLAGS="$LDFLAGS"
927	  LDFLAGS="$LDFLAGS $libiberty_LDFLAGS"
928	  AC_CHECK_LIB([iberty],[cplus_demangle],
929	    [libiberty_LIBS="-liberty"
930	     use_libiberty=yes
931	    ],
932	    [if test "x$with_libiberty" != xcheck; then
933	       AC_MSG_FAILURE([failed to find cplus_demangle in libiberty])
934	     fi
935	    ]
936	  )
937	  LDFLAGS="$saved_LDFLAGS"
938	 ],
939	 [if test "x$with_libiberty" != xcheck; then
940	      AC_MSG_FAILURE([failed to find demangle.h])
941	  fi
942	 ]
943       )
944       CPPFLAGS="$saved_CPPFLAGS"
945      ]
946)
947
948dnl enable libiberty
949AC_MSG_CHECKING([whether to enable demangling symbols in stack trace])
950if test "x$use_libiberty" = xyes; then
951	AC_DEFINE([USE_DEMANGLE], 1, [Do demangling symbols in stack trace])
952	AC_SUBST(libiberty_LIBS)
953	AC_SUBST(libiberty_LDFLAGS)
954	AC_SUBST(libiberty_CPPFLAGS)
955fi
956AM_CONDITIONAL([USE_DEMANGLE], [test "x$use_libiberty" = xyes])
957AC_MSG_RESULT([$use_libiberty])
958
959if test "$arch" = mips && test "$no_create" != yes; then
960	mkdir -p linux/mips
961	if $srcdir/linux/mips/genstub.sh linux/mips; then
962		AC_MSG_RESULT([Generated MIPS syscallent stubs])
963	else
964		AC_MSG_ERROR([Failed to generate syscallent stubs])
965	fi
966fi
967
968AC_ARG_ENABLE([mpers],
969	[AS_HELP_STRING([--enable-mpers=yes|no|check|m32|mx32],
970		[whether to enable multiple personalities support required
971		 for proper decoding of structures used by tracees with
972		 personalities that differ from the personality of strace,
973		 default is yes.])],
974	[case "$enableval" in
975		yes|no|check|m32|mx32) enable_mpers="$enableval" ;;
976		*) AC_MSG_ERROR([bad value $enableval for enable-mpers option.
977				 Valid options are: yes, no, check, m32, mx32.])
978		;;
979	 esac],
980	[enable_mpers=yes])
981
982st_MPERS([m32], [aarch64|powerpc64|riscv|s390x|sparc64|tile|x32|x86_64])
983st_MPERS([mx32], [x86_64])
984
985AX_VALGRIND_DFLT([sgcheck], [off])
986AX_VALGRIND_CHECK
987
988AC_CONFIG_FILES([Makefile
989		 tests/Makefile
990		 tests-m32/Makefile
991		 tests-mx32/Makefile
992		 strace.1
993		 strace-log-merge.1
994		 strace.spec
995		 debian/changelog])
996AC_OUTPUT
997