aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt (Red Hat) <rostedt@goodmis.org>2015-05-20 15:01:38 -0400
committerSteven Rostedt <rostedt@goodmis.org>2015-06-10 15:11:53 -0400
commitb9f9bbc7300d582d4aa4c646fb49069c02bf0411 (patch)
treec4cb65ad4d51f249a195d9ea919a73aa1f924ebd
parentdb4e8c9be31437a5cdda8231b5de13597da161f9 (diff)
downloadtrace-cmd-b9f9bbc7300d582d4aa4c646fb49069c02bf0411.tar.gz
trace-cmd: Don't fail build if libaudit is not installed
Add a test compile to make sure that libaudit is installed and define NO_AUDIT if it is not. When that happens, a warning will occur in building trace_profile() saying that it will use raw syscall numbers. Doing a make NO_AUDIT=1, will surpress that warning. Also fixed the NO_PTRACE to use "override" on changing of CFLAGS as without it, it has no affect. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--Makefile19
-rw-r--r--features.mk18
-rw-r--r--trace-profile.c10
3 files changed, 43 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 402f7114..a8e63ad0 100644
--- a/Makefile
+++ b/Makefile
@@ -160,7 +160,7 @@ bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
plugin_dir_SQ = $(subst ','\'',$(plugin_dir))
python_dir_SQ = $(subst ','\'',$(python_dir))
-LIBS = -L. -ltracecmd -ldl -laudit
+LIBS = -L. -ltracecmd -ldl
LIB_FILE = libtracecmd.a
PACKAGES= gtk+-2.0 libxml-2.0 gthread-2.0
@@ -231,12 +231,25 @@ override CFLAGS += -D_GNU_SOURCE
ifndef NO_PTRACE
ifneq ($(call try-cc,$(SOURCE_PTRACE),),y)
NO_PTRACE = 1
- CFLAGS += -DWARN_NO_PTRACE
+ override CFLAGS += -DWARN_NO_PTRACE
endif
endif
ifdef NO_PTRACE
-CFLAGS += -DNO_PTRACE
+override CFLAGS += -DNO_PTRACE
+endif
+
+ifndef NO_AUDIT
+ifneq ($(call try-cc,$(SOURCE_AUDIT),-laudit),y)
+ NO_AUDIT = 1
+ override CFLAGS += -DWARN_NO_AUDIT
+endif
+endif
+
+ifdef NO_AUDIT
+override CFLAGS += -DNO_AUDIT
+else
+LIBS += -laudit
endif
# Append required CFLAGS
diff --git a/features.mk b/features.mk
index cb2e8bd8..9c9d63c1 100644
--- a/features.mk
+++ b/features.mk
@@ -34,3 +34,21 @@ int main (void)
return ret;
}
endef
+
+define SOURCE_AUDIT
+#include <stdio.h>
+#include <libaudit.h>
+
+int main (void)
+{
+ char *name;
+ int ret;
+ ret = audit_detect_machine();
+ if (ret < 0)
+ return ret;
+ name = audit_syscall_to_name(1, ret);
+ if (!name)
+ return -1;
+ return ret;
+}
+endef
diff --git a/trace-profile.c b/trace-profile.c
index 24f98971..640dca82 100644
--- a/trace-profile.c
+++ b/trace-profile.c
@@ -23,11 +23,17 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifndef NO_AUDIT
#include <libaudit.h>
-
+#endif
#include "trace-local.h"
#include "trace-hash.h"
+#ifdef WARN_NO_AUDIT
+# warning "lib audit not found, using raw syscalls " \
+ "(install libaudit-devel and try again)"
+#endif
+
#define TASK_STATE_TO_CHAR_STR "RSDTtXZxKWP"
#define TASK_STATE_MAX 1024
@@ -848,6 +854,7 @@ static void func_print(struct trace_seq *s, struct event_hash *event_hash)
static void syscall_print(struct trace_seq *s, struct event_hash *event_hash)
{
+#ifndef NO_AUDIT
const char *name = NULL;
int machine;
@@ -860,6 +867,7 @@ static void syscall_print(struct trace_seq *s, struct event_hash *event_hash)
trace_seq_printf(s, "syscall:%s", name);
return;
fail:
+#endif
trace_seq_printf(s, "%s:%d", event_hash->event_data->event->name,
(int)event_hash->val);
}