From: Namhyung Kim <namhyung....@lge.com>

For building perf without name demangling, we can set NO_DEMANGLE=1 as
a argument of make.  It then defines NO_DEMANGLE macro for C code to
do the proper handling.  However it usually used in a negative
semantics - e.g. #ifndef - so we saw double negations which can be
misleading.  Convert it to a positive form to make it more readable.

Also add _SUPPORT suffix for consistency and make PACKAGE variable has
a string value "perf".

Cc: Markus Trippelsdorf <mar...@trippelsdorf.de>
Cc: Mike Frysinger <vap...@gentoo.org>
Signed-off-by: Namhyung Kim <namhy...@kernel.org>
---
 tools/perf/Makefile      | 12 +++++++-----
 tools/perf/util/symbol.h | 19 +++++++++++--------
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/tools/perf/Makefile b/tools/perf/Makefile
index 45f8920bab2b..dd5b9a0507c7 100644
--- a/tools/perf/Makefile
+++ b/tools/perf/Makefile
@@ -696,36 +696,38 @@ else
   endif
 endif
 
-ifdef NO_DEMANGLE
-       BASIC_CFLAGS += -DNO_DEMANGLE
-else
+ifndef NO_DEMANGLE
         ifdef HAVE_CPLUS_DEMANGLE
                EXTLIBS += -liberty
+               BASIC_CFLAGS += -DDEMANGLE_SUPPORT
                BASIC_CFLAGS += -DHAVE_CPLUS_DEMANGLE
         else
-               FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) 
-DPACKAGE='perf' -lbfd
+               FLAGS_BFD=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) 
-DPACKAGE='"perf"' -lbfd
                has_bfd := $(call try-cc,$(SOURCE_BFD),$(FLAGS_BFD))
                ifeq ($(has_bfd),y)
                        EXTLIBS += -lbfd
+                       BASIC_CFLAGS += -DDEMANGLE_SUPPORT
                else
                        FLAGS_BFD_IBERTY=$(FLAGS_BFD) -liberty
                        has_bfd_iberty := $(call 
try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY))
                        ifeq ($(has_bfd_iberty),y)
                                EXTLIBS += -lbfd -liberty
+                               BASIC_CFLAGS += -DDEMANGLE_SUPPORT
                        else
                                FLAGS_BFD_IBERTY_Z=$(FLAGS_BFD_IBERTY) -lz
                                has_bfd_iberty_z := $(call 
try-cc,$(SOURCE_BFD),$(FLAGS_BFD_IBERTY_Z))
                                ifeq ($(has_bfd_iberty_z),y)
                                        EXTLIBS += -lbfd -liberty -lz
+                                       BASIC_CFLAGS += -DDEMANGLE_SUPPORT
                                else
                                        FLAGS_CPLUS_DEMANGLE=$(ALL_CFLAGS) 
$(ALL_LDFLAGS) $(EXTLIBS) -liberty
                                        has_cplus_demangle := $(call 
try-cc,$(SOURCE_CPLUS_DEMANGLE),$(FLAGS_CPLUS_DEMANGLE))
                                        ifeq ($(has_cplus_demangle),y)
                                                EXTLIBS += -liberty
+                                               BASIC_CFLAGS += 
-DDEMANGLE_SUPPORT
                                                BASIC_CFLAGS += 
-DHAVE_CPLUS_DEMANGLE
                                        else
                                                msg := $(warning No 
bfd.h/libbfd found, install binutils-dev[el]/zlib-static to gain symbol 
demangling)
-                                               BASIC_CFLAGS += -DNO_DEMANGLE
                                        endif
                                endif
                        endif
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 8b6ef7fac745..e1484bb080e6 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -18,26 +18,29 @@
 #include <elf.h>
 #endif
 
-#ifdef HAVE_CPLUS_DEMANGLE
+#ifdef DEMANGLE_SUPPORT
+
+# ifdef HAVE_CPLUS_DEMANGLE
 extern char *cplus_demangle(const char *, int);
 
 static inline char *bfd_demangle(void __maybe_unused *v, const char *c, int i)
 {
        return cplus_demangle(c, i);
 }
-#else
-#ifdef NO_DEMANGLE
+# else /* HAVE_CPLUS_DEMANGLE */
+#  define PACKAGE "perf"
+#  include <bfd.h>
+# endif /* HAVE_CPLUS_DEMANGLE */
+
+#else /* DEMANGLE_SUPPORT */
+
 static inline char *bfd_demangle(void __maybe_unused *v,
                                 const char __maybe_unused *c,
                                 int __maybe_unused i)
 {
        return NULL;
 }
-#else
-#define PACKAGE 'perf'
-#include <bfd.h>
-#endif
-#endif
+#endif /* DEMANGLE_SUPPORT */
 
 int hex2u64(const char *ptr, u64 *val);
 char *strxfrchar(char *s, char from, char to);
-- 
1.7.11.4

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

Reply via email to