From 4ded79d54dd514c7f7d711e38ec4277f4427c78e Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Sun, 27 Jun 2010 02:55:13 +0200 Subject: [PATCH] gobject: implement gobject introspection --- Makefile.am | 4 +- avahi-gobject/.gitignore | 2 + avahi-gobject/AvahiCore-0.6.gir | 59 +++++++++++++++++++++ avahi-gobject/Makefile.am | 30 ++++++++++- common/.gitignore | 1 + common/introspection.m4 | 94 +++++++++++++++++++++++++++++++++ configure.ac | 7 +++ 7 files changed, 195 insertions(+), 2 deletions(-) create mode 100644 avahi-gobject/AvahiCore-0.6.gir create mode 100644 common/introspection.m4 diff --git a/Makefile.am b/Makefile.am index 982a83d..a800687 100644 --- a/Makefile.am +++ b/Makefile.am @@ -49,7 +49,8 @@ EXTRA_DIST = \ avahi-compat-howl.pc.in \ avahi-ui.pc.in \ avahi-ui-gtk3.pc.in \ - doxygen_to_devhelp.xsl + doxygen_to_devhelp.xsl \ + common/introspection.m4 SUBDIRS = \ common \ @@ -223,6 +224,7 @@ MOSTLYCLEANFILES = $(DX_CLEANFILES) DISTCHECK_CONFIGURE_FLAGS = \ --disable-monodoc \ + --enable-introspection \ --with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) homepage: diff --git a/avahi-gobject/.gitignore b/avahi-gobject/.gitignore index 1466c78..402b45c 100644 --- a/avahi-gobject/.gitignore +++ b/avahi-gobject/.gitignore @@ -1,3 +1,5 @@ +*.typelib +Avahi-0.6.gir ga-*-enumtypes.c ga-*-enumtypes.h *.o diff --git a/avahi-gobject/AvahiCore-0.6.gir b/avahi-gobject/AvahiCore-0.6.gir new file mode 100644 index 0000000..8b25fc1 --- /dev/null +++ b/avahi-gobject/AvahiCore-0.6.gir @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/avahi-gobject/Makefile.am b/avahi-gobject/Makefile.am index bfb3393..02f2b94 100644 --- a/avahi-gobject/Makefile.am +++ b/avahi-gobject/Makefile.am @@ -20,6 +20,9 @@ AM_CFLAGS=-I$(top_srcdir) # This cool debug trap works on i386/gcc only AM_CFLAGS+='-DDEBUG_TRAP=__asm__("int $$3")' +EXTRA_DIST = \ + AvahiCore-0.6.gir + if HAVE_GOBJECT if HAVE_DBUS @@ -88,7 +91,6 @@ signals-marshal.h: signals-marshal.list signals-marshal.c: signals-marshal.list $(AM_V_GEN)(echo "#include \"signals-marshal.h\"" ; glib-genmarshal --body --prefix=_ga_signals_marshal $< ) > $@ - # rules for making the glib enum objects %-enumtypes.h: %.h Makefile.in $(AM_V_GEN)glib-mkenums \ @@ -107,6 +109,32 @@ signals-marshal.c: signals-marshal.list --vtail " { 0, NULL, NULL }\n };\n etype = g_@type@_register_static (\"@EnumName@\", values);\n }\n return etype;\n}\n" \ $< > $@ +-include $(INTROSPECTION_MAKEFILE) +INTROSPECTION_GIRS = +INTROSPECTION_SCANNER_ARGS = --add-include-path=$(srcdir) +INTROSPECTION_COMPILER_ARGS = --includedir=$(srcdir) + +if HAVE_INTROSPECTION +introspection_sources = $(libavahi_gobject_la_SOURCES) + +Avahi-0.6.gir: $(lib_LTLIBRARIES) +Avahi_0_6_gir_INCLUDES = GObject-2.0 AvahiCore-0.6 +Avahi_0_6_gir_CFLAGS = $(libavahi_gobject_la_CFLAGS) +Avahi_0_6_gir_LIBS = $(lib_LTLIBRARIES) +Avahi_0_6_gir_FILES = $(addprefix $(srcdir)/, $(CORE_SOURCES)) $(BUILT_SOURCES) +Avahi_0_6_gir_SCANNERFLAGS = --strip-prefix=Ga +INTROSPECTION_GIRS += Avahi-0.6.gir +INTROSPECTION_INSTALL_GIRS = AvahiCore-0.6.gir $(INTROSPECTION_GIRS) + +girdir = $(datadir)/gir-1.0 +gir_DATA = $(INTROSPECTION_INSTALL_GIRS) + +typelibdir = $(libdir)/girepository-1.0 +typelib_DATA = $(INTROSPECTION_INSTALL_GIRS:.gir=.typelib) + +CLEANFILES += $(INTROSPECTION_GIRS) $(typelib_DATA) +endif + endif endif diff --git a/common/.gitignore b/common/.gitignore index de8ddd7..1012b7f 100644 --- a/common/.gitignore +++ b/common/.gitignore @@ -1,3 +1,4 @@ +intltool.m4 ChangeLog gettext.m4 iconv.m4 diff --git a/common/introspection.m4 b/common/introspection.m4 new file mode 100644 index 0000000..bfc52be --- /dev/null +++ b/common/introspection.m4 @@ -0,0 +1,94 @@ +dnl -*- mode: autoconf -*- +dnl Copyright 2009 Johan Dahlin +dnl +dnl This file is free software; the author(s) gives unlimited +dnl permission to copy and/or distribute it, with or without +dnl modifications, as long as this notice is preserved. +dnl + +# serial 1 + +m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], +[ + AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first + AC_BEFORE([LT_INIT],[$0])dnl setup libtool first + + dnl enable/disable introspection + m4_if([$2], [require], + [dnl + enable_introspection=yes + ],[dnl + AC_ARG_ENABLE(introspection, + AS_HELP_STRING([--enable-introspection[=@<:@no/auto/yes@:>@]], + [Enable introspection for this build]),, + [enable_introspection=auto]) + ])dnl + + AC_MSG_CHECKING([for gobject-introspection]) + + dnl presence/version checking + AS_CASE([$enable_introspection], + [no], [dnl + found_introspection="no (disabled, use --enable-introspection to enable)" + ],dnl + [yes],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0],, + AC_MSG_ERROR([gobject-introspection-1.0 is not installed])) + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], + found_introspection=yes, + AC_MSG_ERROR([You need to have gobject-introspection >= $1 installed to build AC_PACKAGE_NAME])) + ],dnl + [auto],[dnl + PKG_CHECK_EXISTS([gobject-introspection-1.0 >= $1], found_introspection=yes, found_introspection=no) + ],dnl + [dnl + AC_MSG_ERROR([invalid argument passed to --enable-introspection, should be one of @<:@no/auto/yes@:>@]) + ])dnl + + AC_MSG_RESULT([$found_introspection]) + + INTROSPECTION_SCANNER= + INTROSPECTION_COMPILER= + INTROSPECTION_GENERATE= + INTROSPECTION_GIRDIR= + INTROSPECTION_TYPELIBDIR= + if test "x$found_introspection" = "xyes"; then + INTROSPECTION_SCANNER=`$PKG_CONFIG --variable=g_ir_scanner gobject-introspection-1.0` + INTROSPECTION_COMPILER=`$PKG_CONFIG --variable=g_ir_compiler gobject-introspection-1.0` + INTROSPECTION_GENERATE=`$PKG_CONFIG --variable=g_ir_generate gobject-introspection-1.0` + INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir gobject-introspection-1.0` + INTROSPECTION_TYPELIBDIR="$($PKG_CONFIG --variable=typelibdir gobject-introspection-1.0)" + INTROSPECTION_CFLAGS=`$PKG_CONFIG --cflags gobject-introspection-1.0` + INTROSPECTION_LIBS=`$PKG_CONFIG --libs gobject-introspection-1.0` + INTROSPECTION_MAKEFILE=`$PKG_CONFIG --variable=datadir gobject-introspection-1.0`/gobject-introspection-1.0/Makefile.introspection + fi + AC_SUBST(INTROSPECTION_SCANNER) + AC_SUBST(INTROSPECTION_COMPILER) + AC_SUBST(INTROSPECTION_GENERATE) + AC_SUBST(INTROSPECTION_GIRDIR) + AC_SUBST(INTROSPECTION_TYPELIBDIR) + AC_SUBST(INTROSPECTION_CFLAGS) + AC_SUBST(INTROSPECTION_LIBS) + AC_SUBST(INTROSPECTION_MAKEFILE) + + AM_CONDITIONAL(HAVE_INTROSPECTION, test "x$found_introspection" = "xyes") +]) + + +dnl Usage: +dnl GOBJECT_INTROSPECTION_CHECK([minimum-g-i-version]) + +AC_DEFUN([GOBJECT_INTROSPECTION_CHECK], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1]) +]) + +dnl Usage: +dnl GOBJECT_INTROSPECTION_REQUIRE([minimum-g-i-version]) + + +AC_DEFUN([GOBJECT_INTROSPECTION_REQUIRE], +[ + _GOBJECT_INTROSPECTION_CHECK_INTERNAL([$1], [require]) +]) diff --git a/configure.ac b/configure.ac index 42d7d22..1be1f60 100644 --- a/configure.ac +++ b/configure.ac @@ -21,6 +21,7 @@ AC_PREREQ(2.63) AC_INIT([avahi],[0.6.25],[avahi (at) lists (dot) freedesktop (dot) org]) AC_CONFIG_SRCDIR([avahi-core/server.c]) +AC_CONFIG_MACRO_DIR([common]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign 1.11 -Wall -Wno-portability silent-rules tar-pax]) @@ -468,6 +469,11 @@ if test "x$HAVE_GOBJECT" = "xyes" ; then fi AM_CONDITIONAL(HAVE_GOBJECT, test "x$HAVE_GOBJECT" = "xyes") +# +# Introspection support. +# +GOBJECT_INTROSPECTION_CHECK([0.6.7]) + # # Check for Qt 3 # @@ -1136,6 +1142,7 @@ echo " CFLAGS: ${CFLAGS} Enable GLIB: ${HAVE_GLIB} Enable GLIB GObject: ${HAVE_GOBJECT} + Enable GObject Introspection: ${found_introspection} Enable GTK 2.0: ${HAVE_GTK} Enable GTK 3.0: ${HAVE_GTK3} Enable D-Bus: ${HAVE_DBUS} -- 2.39.2