From: Sami Kerola Date: Thu, 18 Aug 2016 20:34:36 +0000 (+0100) Subject: build-sys: use pkg-config to find gtk+-2.0 X-Git-Tag: v0.88~30^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5f8083d91d06cceddf9b74ab9b0a66504459f67f;p=thirdparty%2Fmtr.git build-sys: use pkg-config to find gtk+-2.0 --- diff --git a/Makefile.am b/Makefile.am index d15a6d5..0e740a9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -23,10 +23,14 @@ if IPINFO mtr_SOURCES += asn.c asn.h endif -EXTRA_mtr_SOURCES = curses.c \ - gtk.c +EXTRA_mtr_SOURCES = curses.c +if WITH_GTK +mtr_SOURCES += gtk.c +endif + +mtr_DEPENDENCIES = $(CURSES_OBJ) +mtr_LDFLAGS = $(CURSES_OBJ) mtr_INCLUDES = $(GLIB_CFLAGS) -I$(top_builddir) -I$(top_srcdir) -mtr_DEPENDENCIES = $(GTK_OBJ) $(CURSES_OBJ) -mtr_LDFLAGS = $(GTK_OBJ) $(CURSES_OBJ) -mtr_LDADD = $(GLIB_LIBS) $(RESOLV_LIBS) +mtr_CFLAGS = $(GTK_CFLAGS) $(NCURSES_CFLAGS) +mtr_LDADD = $(GTK_LIBS) $(NCURSES_LDADD) $(RESOLV_LIBS) diff --git a/configure.ac b/configure.ac index e737f54..92e2cef 100644 --- a/configure.ac +++ b/configure.ac @@ -15,10 +15,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])], [AC_SUBST([AM_DEFAULT_VERBOSITY], [1])]) -AC_SUBST([GTK_OBJ]) AC_SUBST([CURSES_OBJ]) - -GTK_OBJ=gtk.o CURSES_OBJ=curses.o AC_PROG_CC @@ -78,34 +75,14 @@ AC_CHECK_LIB([m], [floor], [], [AC_MSG_ERROR([No math library found])]) # Find GTK AC_ARG_WITH([gtk], - [AS_HELP_STRING([--without-gtk], [Do not try to use GTK+ at all])], + [AS_HELP_STRING([--without-gtk], [Build without the GTK+2.0 interface])], [], [with_gtk=yes]) -AS_IF([test "x$with_gtk" = "xyes"], [WANTS_GTK=yes], [WANTS_GTK=no]) - -m4_ifndef([AM_PATH_GTK_2_0], - [m4_defun([AM_PATH_GTK_2_0], [ - AC_MSG_ERROR([dnl -Could not locate the gtk2 automake macros, these are usually located in - .../share/aclocal/gtk-2.0.m4 -Before running bootstrap try setting the environment variable - ACLOCAL_PATH="/own/dir" -or configure --without-gtk.]) - ]) -]) - -AS_IF([test "x$WANTS_GTK" = "xyes"], [ - AM_PATH_GTK_2_0([2.6.0], [ - CFLAGS="$CFLAGS $GTK_CFLAGS" - LIBS="$LIBS $GTK_LIBS -lm" - ], [ - AC_MSG_WARN([Building without GTK2 display support]) - AC_DEFINE([NO_GTK], [1], [Define if you don't have the GTK+ libraries available.]) - GTK_OBJ="" - ]) -], [ - AC_DEFINE([NO_GTK], [1], [Define if you don't have the GTK+ libraries available.]) - GTK_OBJ="" +AS_IF([test "x$with_gtk" = "xyes"], + [PKG_CHECK_MODULES([GTK], [gtk+-2.0], + [AC_DEFINE([HAVE_GTK], [1], [Define if gtk+-2.0 library available])], + [with_gtk=no]) ]) +AM_CONDITIONAL([WITH_GTK], [test "x$with_gtk" = xyes]) # Enable ipinfo AC_ARG_WITH([ipinfo], diff --git a/display.c b/display.c index ed05035..0c5b0e9 100644 --- a/display.c +++ b/display.c @@ -45,15 +45,15 @@ extern int DisplayMode; #include "mtr-curses.h" #endif -#ifdef NO_GTK +#ifdef HAVE_GTK +#include "mtr-gtk.h" +#else // No support for gtk mode, allow the calls to remain in the code. #define gtk_open() #define gtk_close() #define gtk_redraw() #define gtk_keyaction() 0 #define gtk_loop() {fprintf (stderr, "No GTK support. Sorry.\n"); exit(EXIT_FAILURE); } -#else -#include "mtr-gtk.h" #endif #ifdef NO_SPLIT @@ -78,17 +78,17 @@ extern int DisplayMode; #define DEFAULT_DISPLAY DisplayCurses #endif -#ifdef NO_GTK -#define UNUSED_IF_NO_GTK UNUSED -#else +#ifdef HAVE_GTK #define UNUSED_IF_NO_GTK +#else +#define UNUSED_IF_NO_GTK UNUSED #endif void display_detect(int *argc UNUSED_IF_NO_GTK, char ***argv UNUSED_IF_NO_GTK) { DisplayMode = DEFAULT_DISPLAY; -#ifndef NO_GTK +#ifdef HAVE_GTK if(gtk_detect(argc, argv)) { DisplayMode = DisplayGTK; } diff --git a/gtk.c b/gtk.c index a785fd4..e55f489 100644 --- a/gtk.c +++ b/gtk.c @@ -25,7 +25,7 @@ #include #include -#ifndef NO_GTK +#ifdef HAVE_GTK #include #include #include