Commit f9f526ec authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf tools: Convert to GTK2_SUPPORT

For building perf without gtk+2, we can set NO_GTK2=1 as a argument of
make.  It then defines NO_GTK2_SUPPORT 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.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1348824728-14025-8-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 1254b51e
...@@ -583,17 +583,15 @@ ifndef NO_NEWT ...@@ -583,17 +583,15 @@ ifndef NO_NEWT
endif endif
endif endif
ifdef NO_GTK2 ifndef NO_GTK2
BASIC_CFLAGS += -DNO_GTK2_SUPPORT
else
FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null) FLAGS_GTK2=$(ALL_CFLAGS) $(ALL_LDFLAGS) $(EXTLIBS) $(shell pkg-config --libs --cflags gtk+-2.0 2>/dev/null)
ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2)),y) ifneq ($(call try-cc,$(SOURCE_GTK2),$(FLAGS_GTK2)),y)
msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev); msg := $(warning GTK2 not found, disables GTK2 support. Please install gtk2-devel or libgtk2.0-dev);
BASIC_CFLAGS += -DNO_GTK2_SUPPORT
else else
ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y) ifeq ($(call try-cc,$(SOURCE_GTK2_INFOBAR),$(FLAGS_GTK2)),y)
BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR BASIC_CFLAGS += -DHAVE_GTK_INFO_BAR
endif endif
BASIC_CFLAGS += -DGTK2_SUPPORT
BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null) BASIC_CFLAGS += $(shell pkg-config --cflags gtk+-2.0 2>/dev/null)
EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null) EXTLIBS += $(shell pkg-config --libs gtk+-2.0 2>/dev/null)
LIB_OBJS += $(OUTPUT)ui/gtk/browser.o LIB_OBJS += $(OUTPUT)ui/gtk/browser.o
......
...@@ -34,14 +34,14 @@ static inline int ui_helpline__show_help(const char *format __maybe_unused, ...@@ -34,14 +34,14 @@ static inline int ui_helpline__show_help(const char *format __maybe_unused,
} }
#endif /* NEWT_SUPPORT */ #endif /* NEWT_SUPPORT */
#ifdef NO_GTK2_SUPPORT #ifdef GTK2_SUPPORT
int perf_gtk__show_helpline(const char *format, va_list ap);
#else
static inline int perf_gtk__show_helpline(const char *format __maybe_unused, static inline int perf_gtk__show_helpline(const char *format __maybe_unused,
va_list ap __maybe_unused) va_list ap __maybe_unused)
{ {
return 0; return 0;
} }
#else #endif /* GTK2_SUPPORT */
int perf_gtk__show_helpline(const char *format, va_list ap);
#endif /* NO_GTK2_SUPPORT */
#endif /* _PERF_UI_HELPLINE_H_ */ #endif /* _PERF_UI_HELPLINE_H_ */
...@@ -33,14 +33,7 @@ extern int pager_use_color; ...@@ -33,14 +33,7 @@ extern int pager_use_color;
extern int use_browser; extern int use_browser;
#if !defined(NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) #if defined(NEWT_SUPPORT) || defined(GTK2_SUPPORT)
static inline void setup_browser(bool fallback_to_pager)
{
if (fallback_to_pager)
setup_pager();
}
static inline void exit_browser(bool wait_for_ok __maybe_unused) {}
#else
void setup_browser(bool fallback_to_pager); void setup_browser(bool fallback_to_pager);
void exit_browser(bool wait_for_ok); void exit_browser(bool wait_for_ok);
...@@ -55,17 +48,26 @@ static inline int ui__init(void) ...@@ -55,17 +48,26 @@ static inline int ui__init(void)
static inline void ui__exit(bool wait_for_ok __maybe_unused) {} static inline void ui__exit(bool wait_for_ok __maybe_unused) {}
#endif #endif
#ifdef NO_GTK2_SUPPORT #ifdef GTK2_SUPPORT
int perf_gtk__init(void);
void perf_gtk__exit(bool wait_for_ok);
#else
static inline int perf_gtk__init(void) static inline int perf_gtk__init(void)
{ {
return -1; return -1;
} }
static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {} static inline void perf_gtk__exit(bool wait_for_ok __maybe_unused) {}
#else
int perf_gtk__init(void);
void perf_gtk__exit(bool wait_for_ok);
#endif #endif
#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */
#else /* NEWT_SUPPORT || GTK2_SUPPORT */
static inline void setup_browser(bool fallback_to_pager)
{
if (fallback_to_pager)
setup_pager();
}
static inline void exit_browser(bool wait_for_ok __maybe_unused) {}
#endif /* NEWT_SUPPORT || GTK2_SUPPORT */
char *alias_lookup(const char *alias); char *alias_lookup(const char *alias);
int split_cmdline(char *cmdline, const char ***argv); int split_cmdline(char *cmdline, const char ***argv);
......
...@@ -49,7 +49,7 @@ int dump_printf(const char *fmt, ...) ...@@ -49,7 +49,7 @@ int dump_printf(const char *fmt, ...)
return ret; return ret;
} }
#if !defined(NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) #if !defined(NEWT_SUPPORT) && !defined(GTK2_SUPPORT)
int ui__warning(const char *format, ...) int ui__warning(const char *format, ...)
{ {
va_list args; va_list args;
......
...@@ -15,7 +15,14 @@ void trace_event(union perf_event *event); ...@@ -15,7 +15,14 @@ void trace_event(union perf_event *event);
struct ui_progress; struct ui_progress;
struct perf_error_ops; struct perf_error_ops;
#if !defined(NEWT_SUPPORT) && defined(NO_GTK2_SUPPORT) #if defined(NEWT_SUPPORT) || defined(GTK2_SUPPORT)
#include "../ui/progress.h"
int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
#include "../ui/util.h"
#else
static inline void ui_progress__update(u64 curr __maybe_unused, static inline void ui_progress__update(u64 curr __maybe_unused,
u64 total __maybe_unused, u64 total __maybe_unused,
const char *title __maybe_unused) {} const char *title __maybe_unused) {}
...@@ -34,13 +41,7 @@ perf_error__unregister(struct perf_error_ops *eops __maybe_unused) ...@@ -34,13 +41,7 @@ perf_error__unregister(struct perf_error_ops *eops __maybe_unused)
return 0; return 0;
} }
#else /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */ #endif /* NEWT_SUPPORT || GTK2_SUPPORT */
#include "../ui/progress.h"
int ui__error(const char *format, ...) __attribute__((format(printf, 1, 2)));
#include "../ui/util.h"
#endif /* !NEWT_SUPPORT && NO_GTK2_SUPPORT */
int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2))); int ui__warning(const char *format, ...) __attribute__((format(printf, 1, 2)));
int ui__error_paranoid(void); int ui__error_paranoid(void);
......
...@@ -187,7 +187,11 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self ...@@ -187,7 +187,11 @@ static inline int hist_entry__tui_annotate(struct hist_entry *self
#define K_RIGHT -2 #define K_RIGHT -2
#endif #endif
#ifdef NO_GTK2_SUPPORT #ifdef GTK2_SUPPORT
int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
void(*timer)(void *arg), void *arg,
int refresh);
#else
static inline static inline
int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused, int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused,
const char *help __maybe_unused, const char *help __maybe_unused,
...@@ -197,11 +201,6 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused, ...@@ -197,11 +201,6 @@ int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist __maybe_unused,
{ {
return 0; return 0;
} }
#else
int perf_evlist__gtk_browse_hists(struct perf_evlist *evlist, const char *help,
void(*timer)(void *arg), void *arg,
int refresh);
#endif #endif
unsigned int hists__sort_list_width(struct hists *self); unsigned int hists__sort_list_width(struct hists *self);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment