[PATCH] Introduced --with-gtk option for configure.ac

Dr Andrew John Hughes ahughes at redhat.com
Fri Jun 1 05:25:38 PDT 2012


On 10:50 Thu 31 May     , Peter Hatina wrote:
> On 05/30/2012 04:54 PM, Andrew Hughes wrote:
> > 
> > 
> > ----- Original Message -----
> >> Hi,
> >>
> >> I fixed the diff to meet Andrew Hughes suggestions. Hope, it's OK
> >> now.
> >>
> >> Peter Hatina
> >> EMEA ENG-Desktop Development
> >> Red Hat Czech, Brno
> >>
> >> ---
> >>  ChangeLog    |    8 ++++++++
> >>  NEWS         |    1 +
> >>  acinclude.m4 |   54
> >>  +++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >>  3 files changed, 62 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/ChangeLog b/ChangeLog
> >> index 82c0feb..d6f7e0c 100644
> >> --- a/ChangeLog
> >> +++ b/ChangeLog
> >> @@ -1,3 +1,11 @@
> >> +2012-05-28  Peter Hatina <phatina at redhat.com>
> >> +
> >> +	Introduced configure option --with-gtk=2.0|3.0 to be able to
> >> compile
> >> +	against different version of GTK+ (2.x or 3.x).
> >> +	*NEWS: mentioned bug fix
> >> +	*acinclude.m4: (GTK_SET_CXX_VARS) macro for settings GTK+ CFLAGS
> >> +	               (GTK_CHECK) macro for checking GTK+ version
> >> +
> >>  2012-05-02  Jiri Vanek  <jvanek at redhat.com>
> >>  
> >>  	Introduced new annotations Bug (to connect test/reproducer with
> >>  	documentation)
> >> diff --git a/NEWS b/NEWS
> >> index 8397639..30eb055 100644
> >> --- a/NEWS
> >> +++ b/NEWS
> >> @@ -16,6 +16,7 @@ New in release 1.3 (2012-XX-XX):
> >>    - PR895: IcedTea-Web searches for missing classes on each
> >>    loadClass or findClass
> >>  * Common
> >>    - PR918: java applet windows uses a low resulution black/white
> >>    icon
> >> +  - RHX720836: project can be compiled against GTK+ 2 or 3 libraries
> >>  
> >>  New in release 1.2 (2011-XX-XX):
> >>  * Security updates:
> >> diff --git a/acinclude.m4 b/acinclude.m4
> >> index a330d0f..5b801eb 100644
> >> --- a/acinclude.m4
> >> +++ b/acinclude.m4
> >> @@ -359,13 +359,65 @@ AC_ARG_ENABLE([plugin],
> >>  AC_MSG_RESULT(${enable_plugin})
> >>  ])
> >>  
> >> +dnl GTK_CHECK_VERSION([gtk version], [ACTION-IF-FOUND],
> >> [ACTION-IF-NOT])
> >> +AC_DEFUN([GTK_CHECK_VERSION],
> >> +[
> >> +  if $PKG_CONFIG --modversion gtk+-$1.0 &> /dev/null; then
> >> +    $2
> >> +  else
> >> +    $3
> >> +  fi
> >> +])
> >> +
> >> +dnl ITW_GTK_SET_CXX_VARS([gtk version])
> >> +AC_DEFUN([ITW_GTK_SET_CXX_VARS],
> >> +[
> >> +  GTK_CFLAGS=`$PKG_CONFIG --cflags gtk+-$1.0`
> >> +  GTK_LIBS=`$PKG_CONFIG --libs gtk+-$1.0`
> >> +])
> >> +
> >> +dnl ITW_GTK_CHECK([gtk version])
> >> +AC_DEFUN([ITW_GTK_CHECK],
> >> +[
> >> +  AC_CACHE_CHECK([for GTK+], [gtk_cv_version],
> >> +  [
> >> +    case "$1" in
> >> +      default)
> >> +        GTK_CHECK_VERSION(["3"],
> >> +          [echo -n `$PKG_CONFIG --modversion gtk+-3.0`
> >> +           ITW_GTK_SET_CXX_VARS(["3"])],
> >> +          [GTK_CHECK_VERSION(["2"],
> >> +             [echo -n `$PKG_CONFIG --modversion gtk+-2.0`
> >> +              ITW_GTK_SET_CXX_VARS(["2"])],
> >> +             [AC_MSG_RESULT([no])
> >> +              AC_MSG_ERROR([GTK+ not found])])])
> >> +          ;;
> >> +      *)
> >> +        GTK_CHECK_VERSION([$1],
> >> +          [echo -n `$PKG_CONFIG --modversion gtk+-$1.0`
> >> +           ITW_GTK_SET_CXX_VARS([$1])],
> >> +          [AC_MSG_RESULT([no])
> >> +           AC_MSG_ERROR([GTK+ $1 not found])])
> >> +        ;;
> >> +    esac
> >> +  ])
> >> +])
> >> +
> >>  AC_DEFUN_ONCE([IT_CHECK_PLUGIN_DEPENDENCIES],
> >>  [
> >>  dnl Check for plugin support headers and libraries.
> >>  dnl FIXME: use unstable
> >>  AC_REQUIRE([IT_CHECK_PLUGIN])
> >>  if test "x${enable_plugin}" = "xyes" ; then
> >> -  PKG_CHECK_MODULES(GTK, gtk+-2.0)
> >> +  AC_ARG_WITH([gtk],
> >> +    [AS_HELP_STRING([--with-gtk=[2|3|default]],
> >> +    [the GTK+ version to use (default: 3)])],
> >> +    [case "$with_gtk" in
> >> +       2|3|default) ;;
> >> +       *) AC_MSG_ERROR([invalid GTK+ version specified]) ;;
> >> +    esac],
> >> +    [with_gtk=default])
> >> +  ITW_GTK_CHECK([$with_gtk])
> >>    PKG_CHECK_MODULES(GLIB, glib-2.0)
> >>    AC_SUBST(GLIB_CFLAGS)
> >>    AC_SUBST(GLIB_LIBS)
> >> --
> >> 1.7.10.2
> >>
> >>
> > 
> > No.  I said it should be using the PKG_CHECK_MODULES macro from
> > pkgconfig as before, not just $PKG_CONFIG.  That was just an example
> > of one of the features you lost in changing this.
> 
> I decided to use $PKG_CONFIG directly to have the output of configure
> script as following:
> 
> "checking for GTK+... 3.4.3"
> 
> If I use PKG_CHECK_MODULES, then I get:
> 
> "checking for GTK+... yes"
> 
> Which does not tell me, what GTK+ libraries will be used for
> compilation. Especially in the case, when you do not explicitly specify
> --with-gtk=blabla. So if you know about any other way, how to achieve
> this, please, show me. I've been looking for this and haven't found
> anything useful. That's the only reason, I used $PKG_CONFIG.
> 
> regards,
> 
> -- 
> Peter Hatina
> EMEA ENG-Desktop Development
> Red Hat Czech, Brno

In exactly the same way you do now.  It's already *you* providing that output in:

> >> +          [GTK_CHECK_VERSION(["2"],
> >> +             [echo -n `$PKG_CONFIG --modversion gtk+-2.0`
> >> +              ITW_GTK_SET_CXX_VARS(["2"])],
> >> +             [AC_MSG_RESULT([no])
> >> +              AC_MSG_ERROR([GTK+ not found])])])
> >> +          ;;

PKG_CHECK_MODULES(GTK, gtk+-2.0, AC_MSG_CHECKING([which Gtk+ version was found]); GTK_VER=`$PKG_CONFIG --modversion gtk+-2.0`; AC_MSG_RESULT([$GTK_VER]))

You shouldn't be using a bare echo anyway as this wouldn't reach the logs.

I think I've written about half the patch for you now...
-- 
Andrew :)

Free Java Software Engineer
Red Hat, Inc. (http://www.redhat.com)

PGP Key: 248BDC07 (https://keys.indymedia.org/)
Fingerprint = EC5A 1F5E C0AD 1D15 8F1F  8F91 3B96 A578 248B DC07
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
Url : http://mail.openjdk.java.net/pipermail/distro-pkg-dev/attachments/20120601/e631398a/attachment.bin 


More information about the distro-pkg-dev mailing list