summaryrefslogtreecommitdiffstats
path: root/scripts/features.mk
blob: 9c7f8c3076b3692274dad075a1a82c38f2aad995 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# SPDX-License-Identifier: GPL-2.0

# taken from perf which was based on Linux Kbuild
# try-cc
# Usage: option = $(call try-cc, source-to-build, cc-options)
try-cc = $(shell sh -c							\
	'TMP="$(BUILD_OUTPUT)$(TMPOUT).$$$$";						\
	echo "$(1)" |							\
	$(CC) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y;	\
	rm -f "$$TMP"')

define SOURCE_PTRACE
#include <stdio.h>
#include <sys/ptrace.h>

int main (void)
{
	int ret;
	ret = ptrace(PTRACE_ATTACH, 0, NULL, 0);
	ptrace(PTRACE_TRACEME, 0, NULL, 0);
	ptrace(PTRACE_GETSIGINFO, 0, NULL, NULL);
	ptrace(PTRACE_GETEVENTMSG, 0, NULL, NULL);
	ptrace(PTRACE_SETOPTIONS, NULL, NULL,
		       PTRACE_O_TRACEFORK |
		       PTRACE_O_TRACEVFORK |
		       PTRACE_O_TRACECLONE |
		       PTRACE_O_TRACEEXIT);
	ptrace(PTRACE_CONT, NULL, NULL, 0);
	ptrace(PTRACE_DETACH, 0, NULL, NULL);
	ptrace(PTRACE_SETOPTIONS, 0, NULL,
	       PTRACE_O_TRACEFORK |
	       PTRACE_O_TRACEVFORK |
	       PTRACE_O_TRACECLONE |
	       PTRACE_O_TRACEEXIT);
	return ret;
}
endef