summaryrefslogtreecommitdiffstats
path: root/scripts/features.mk
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:26:15 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 07:26:15 +0000
commitc72e01b9ea891fa5cbbbe9876bdfb49079b55be7 (patch)
tree44c55a81a281a6c211745c0abc68352aeaf0180f /scripts/features.mk
parentInitial commit. (diff)
downloadlibtracefs-803ed2a4230ec919f62a7b6fee2f054699f753a7.tar.xz
libtracefs-803ed2a4230ec919f62a7b6fee2f054699f753a7.zip
Adding upstream version 1.6.4.upstream/1.6.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/features.mk')
-rw-r--r--scripts/features.mk37
1 files changed, 37 insertions, 0 deletions
diff --git a/scripts/features.mk b/scripts/features.mk
new file mode 100644
index 0000000..9c7f8c3
--- /dev/null
+++ b/scripts/features.mk
@@ -0,0 +1,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