[PATCH 6/6] perf_counter: tools: Makefile tweaks for 64-bit powerpc

From: Paul Mackerras
Date: Wed Jun 17 2009 - 07:56:38 EST

On 64-bit powerpc, perf needs to be built as a 64-bit executable.
This arranges to add the -m64 flag to CFLAGS if we are running on
a 64-bit machine, indicated by the result of uname -m ending in "64".
This means that we'll use -m64 on x86_64 machines as well.

This also removes the -Werror flag when building on a 64-bit powerpc
machine. The userspace definition of u64 is unsigned long rather
than unsigned long long, meaning that gcc warns every time a u64
is printed with %Lx or %llx (though that does work properly).
In future we may use PRI64 etc. for printing 64-bit quantities,
which would eliminate these warnings.

Signed-off-by: Paul Mackerras <paulus@xxxxxxxxx>
tools/perf/Makefile | 14 +++++++++++++-
1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index e8346f9..eddd61a 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -157,9 +157,21 @@ uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
uname_V := $(shell sh -c 'uname -v 2>/dev/null || echo not')

+# If we're on a 64-bit kernel, use -m64
+ifneq ($(patsubst %64,%,$(uname_M)),$(uname_M))
+ M64 := -m64
+# Don't use -Werror on ppc64; we get warnings due to using
+# %Lx formats on __u64, which is unsigned long.
+Werror := -Werror
+ifeq ($(uname_M),ppc64)
+ Werror :=
# CFLAGS and LDFLAGS are for the users to override from the command line.

-CFLAGS = -ggdb3 -Wall -Werror -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -O6
+CFLAGS = $(M64) -ggdb3 -Wall $(Werror) -Wstrict-prototypes -Wmissing-declarations -Wmissing-prototypes -std=gnu99 -Wdeclaration-after-statement -O6
LDFLAGS = -lpthread -lrt -lelf -lm

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/