From ca7865b8b29e8a764e3511d556e16c00432c2fd2 Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Mon, 14 Dec 2009 17:21:54 -0200 Subject: [PATCH] Add a Makefile.introspection This will make it easier for third-party projects to use introspection by having easy make rules. --- Makefile.am | 3 + Makefile.introspection | 134 +++++++++++++++++++++ common.mk | 8 ++ gir/Makefile.am | 247 +++++++++++++++++--------------------- m4/introspection.m4 | 2 + tests/offsets/Makefile.am | 21 ++-- tests/scanner/Makefile.am | 108 ++++++----------- 7 files changed, 304 insertions(+), 219 deletions(-) create mode 100644 Makefile.introspection diff --git a/Makefile.am b/Makefile.am index d69ef0f..2bb5ee1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -32,6 +32,9 @@ pkgconfig_DATA = gobject-introspection-1.0.pc gobject-introspection-no-export-1. m4dir = $(datadir)/aclocal m4_DATA = m4/introspection.m4 +makedir = $(datadir)/share/gobject-introspection-1.0 +make_DATA = Makefile.introspection + EXTRA_DIST = \ COPYING.LGPL \ COPYING.GPL \ diff --git a/Makefile.introspection b/Makefile.introspection new file mode 100644 index 0000000..9d060d9 --- /dev/null +++ b/Makefile.introspection @@ -0,0 +1,134 @@ +# -*- Mode: make -*- +# Copyright 2009 Johan Dahlin +# +# This file is free software; the author(s) gives unlimited +# permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. +# +# * Input variables: +# +# INTROSPECTION_GIRS - List of GIRS that should be generated +# INTROSPECTION_SCANNER - Command to invoke scanner, normally set by +# GOBJECT_INTROSPECTION_REQUIRE/CHECK() in introspection.m4 +# INTROSPECTION_SCANNER_ARGS - Additional args to pass in to the scanner +# INTROSPECTION_COMPILER - Command to invoke compiler, normally set by +# GOBJECT_INTROSPECTION_REQUIRE/CHECK() in introspection.m4 +# INTROSPECTION_COMPILER_ARGS - Additional args to pass in to the compiler +# +# * Simple tutorial +# +# Add this to configure.ac: +# -Wno-portability to AM_INIT_AUTOMAKE +# GOBJECT_INTROSPECTION_CHECK([0.6.7]) +# +# Add this to Makefile.am where your library/program is built: +# include $(INTROSPECTION_MAKEFILE) +# INTROSPECTION_GIRS = YourLib-1.0.gir +# YourLib_1_0_gir_NAMESPACE = YourLib +# YourLib_1_0_gir_VERSION = 1.0 +# YourLib_1_0_gir_LIBS = libyourlib.la +# YourLib_1_0_gir_FILES = $(libyourlib_1_0_SOURCES) +# girdir = $(INTROSPECTION_GIRDIR) +# dist_gir_DATA = YourLib-1.0.gir +# typelibdir = $(INTROSPECTION_TYPELIBDIR) +# typelib_DATA = YourLib-1.0.typelib +# CLEANFILES = $(dist_gir_DATA) $(typelib_DATA) +# + +# Make sure the required variables are set, these should under normal +# circumstances come from introspection.m4 +$(if $(INTROSPECTION_GIRS),,$(error Need to define INTROSPECTION_GIRS)) +$(if $(INTROSPECTION_SCANNER),,$(error Need to define INTROSPECTION_SCANNER)) +$(if $(INTROSPECTION_COMPILER),,$(error Need to define INTROSPECTION_COMPILER)) + +# +# Creates a GIR by scanning C headers/sources +# $(1) - Name of the gir file (output) +# +# If output is Gtk-2.0.gir then you should name the variables like +# Gtk_2_0_gir_NAMESPACE, Gtk_2_0_gir_VERSION etc. +# Required variables: +# FILES - C sources and headers which should be scanned +# +# One of these variables are required: +# LIBS - Library where the symbol represented in the gir can be found +# PROGRAM - Program where the symbol represented in the gir can be found +# +# Optional variables +# NAMESPACE - Namespace of the gir, first letter capital, +# rest should be lower case, for instance: 'Gtk', 'Clutter', 'ClutterGtk'. +# If not present the namespace will be fetched from the gir filename, +# the part before the first dash. For 'Gtk-2.0', namespace will be 'Gtk'. +# VERSION - Version of the gir, if not present, will be fetched from gir +# filename, the part after the first dash. For 'Gtk-2.0', version will be '2.0'. +# LIBTOOL - Command to invoke libtool, usually set by automake +# SCANNERFLAGS - Flags to pass in to the scanner, see g-ir-scanner(1) for a list +# CFLAGS - Flags to pass in to the parser when scanning headers +# PACKAGES - list of pkg-config names which cflags are required to parse +# the headers of this gir +# INCLUDES - Gir files to include without the .gir suffix, for instance +# GLib-2.0, Gtk-2.0. This is needed for all libraries which you depend on that +# provides introspection information. +# +define introspection-scanner + +# Transform the gir filename to something which can reference through a variable +# without automake/make complaining, eg Gtk-2.0.gir -> Gtk_2_0_gir +_gir_name = $(subst -,_,$(subst .,_,$(1))) + +# Basic sanity check, to make sure required variables are set +$(if $($(_gir_name)_FILES),,$(error Need to define $(_gir_name)_FILES)) +$(if $(or $($(_gir_name)_LIBS), + $($(_gir_name)_PROGRAM)),, + $(error Need to define $(_gir_name)_LIBS or $(_gir_name)_PROGRAM)) + +# Namespace and Version is either fetched from the gir filename +# or the _NAMESPACE/_VERSION variable combo +_gir_namespace = $(or $($(_gir_name)_NAMESPACE),$(firstword $(subst -, ,$(1)))) +_gir_version = $(or $($(_gir_name)_VERSION),$(lastword $(subst -, ,$(1:.gir=)))) + +# _PROGRAM is an optional variable which needs it's own --program argument +_gir_program = $(if $($(_gir_name)_PROGRAM),--program=$($(_gir_name)_PROGRAM)) + +# Variables which provides a list of things +_gir_libraries = $(foreach lib,$($(_gir_name)_LIBS),--library=$(lib)) +_gir_packages = $(foreach pkg,$($(_gir_name)_PACKAGES),--pkg=$(pkg)) +_gir_includes = $(foreach include,$($(_gir_name)_INCLUDES),--include=$(include)) + +# Reuse the LIBTOOL variable from by automake if it's set +_gir_libtool = $(if $(LIBTOOL),--libtool="$(LIBTOOL)") + +# Only dependencies we know are actually filenames goes into _FILES, make +# sure these are built before running the scanner. Libraries and programs +# needs to be added manually. +$(1): $$($(_gir_name)_FILES) $(INTROSPECTION_PARSER) + ## Invoke the scanner + $(INTROSPECTION_SCANNER) $(INTROSPECTION_SCANNER_ARGS) \ + --namespace=$(_gir_namespace) \ + --nsversion=$(_gir_version) \ + $(_gir_libtool) \ + $(_gir_program) \ + $(_gir_libraries) \ + $(_gir_packages) \ + $(_gir_includes) \ + $($(_gir_name)_SCANNERFLAGS) \ + $($(_gir_name)_CFLAGS) \ + $($(_gir_name)_FILES) \ + ## Output should go last as it makes it easier to read compilation logs + --output $(1) +endef + +$(foreach gir,$(INTROSPECTION_GIRS),$(eval $(call introspection-scanner,$(gir)))) + +# +# Compiles a gir into a typelib +# $(1): gir filename (input) +# $(2): typelib filename (output) +# +define introspection-compiler +$(INTROSPECTION_COMPILER) $(INTROSPECTION_COMPILER_ARGS) --includedir=. $(1) -o $(2) +endef + +# Simple rule to compile a typelib. +%.typelib: %.gir $(INTROSPECTION_COMPILER) + $(call introspection-compiler,$<,$@) diff --git a/common.mk b/common.mk index de8333e..1f4d601 100644 --- a/common.mk +++ b/common.mk @@ -9,3 +9,11 @@ SCANNER_LIBS = \ $(top_srcdir)/giscanner/*.py \ $(top_builddir)/giscanner/libgiscanner.la \ $(top_builddir)/girepository/libgirepository-1.0.la + +INTROSPECTION_SCANNER = $(SCANNER) +INTROSPECTION_SCANNER_ARGS = $(SCANNER_ARGS) +INTROSPECTION_COMPILER = $(top_builddir)/tools/g-ir-compiler$(EXEEXT) +INTROSPECTION_COMPILER_ARGS = \ + --includedir=$(srcdir) \ + --includedir=$(top_srcdir)/gir \ + --includedir=$(top_builddir)/gir diff --git a/gir/Makefile.am b/gir/Makefile.am index efdcdb6..db182f8 100644 --- a/gir/Makefile.am +++ b/gir/Makefile.am @@ -1,24 +1,27 @@ include $(top_srcdir)/common.mk +include $(top_srcdir)/Makefile.introspection EXPECTEDGIRS = -BUILT_GIRSOURCES = +BUILT_GIRSOURCES = CLEANFILES = -EXTRA_DIST = - -BASE_GIRSOURCES = \ - cairo-1.0.gir \ - fontconfig-2.0.gir \ - freetype2-2.0.gir \ - GL-1.0.gir \ - libxml2-2.0.gir \ - xft-2.0.gir \ - xlib-2.0.gir \ - xfixes-4.0.gir +EXTRA_DIST = + +BASE_GIRSOURCES = \ + cairo-1.0.gir \ + fontconfig-2.0.gir \ + freetype2-2.0.gir \ + GL-1.0.gir \ + libxml2-2.0.gir \ + xft-2.0.gir \ + xlib-2.0.gir \ + xfixes-4.0.gir EXTRA_DIST += $(BASE_GIRSOURCES) +INTROSPECTION_GIRS = + # glib -GLIB_INCLUDEDIR=`pkg-config --variable=includedir glib-2.0`/glib-2.0 -GLIB_LIBDIR=`pkg-config --variable=libdir glib-2.0` +GLIB_INCLUDEDIR=$(shell pkg-config --variable=includedir glib-2.0)/glib-2.0 +GLIB_LIBDIR=$(shell pkg-config --variable=libdir glib-2.0) if OS_WIN32 GLIB_LIBRARY=libglib-2.0-0 @@ -26,33 +29,26 @@ else GLIB_LIBRARY=glib-2.0 endif -GLib-2.0.gir: $(SCANNER_BIN) $(SCANNER_LIBS) Makefile glib-2.0.c - $(SCANNER) \ - --namespace GLib --nsversion=2.0 \ - --noclosure \ - --output $@ \ - --strip-prefix=g \ - --libtool="$(LIBTOOL)" \ - --c-include="glib.h" \ - --library=$(GLIB_LIBRARY) \ - --pkg glib-2.0 \ - $(CPPFLAGS) \ - -I$(GLIB_INCLUDEDIR) \ - -I$(GLIB_LIBDIR)/glib-2.0/include \ - -DGETTEXT_PACKAGE=Dummy \ - -D__G_I18N_LIB_H__ \ - $(GLIB_LIBDIR)/glib-2.0/include/glibconfig.h \ - $(srcdir)/glib-2.0.c \ - -DGLIB_COMPILATION \ - $(GLIB_INCLUDEDIR)/glib/*.h - $(SCANNER) $(SCANNER_ARGS) \ - --xpath-assertions=$(srcdir)/GLib-2.0.xpath GLib-2.0.gir -BUILT_GIRSOURCES += GLib-2.0.gir +GLib_2_0_gir_LIBS = $(GLIB_LIBRARY) +GLib_2_0_gir_SCANNERFLAGS = --noclosure --strip-prefix=g --c-include="glib.h" +GLib_2_0_gir_PACKAGES = glib-2.0 +GLib_2_0_gir_CFLAGS = $(CPPFLAGS) \ + -I$(GLIB_INCLUDEDIR) \ + -I$(GLIB_LIBDIR)/glib-2.0/include \ + -DGETTEXT_PACKAGE=Dummy \ + -D__G_I18N_LIB_H__ +GLib_2_0_gir_ASSERTIONS = $(srcdir)/GLib-2.0.xpath +GLib_2_0_gir_FILES = \ + $(GLIB_LIBDIR)/glib-2.0/include/glibconfig.h \ + $(GLIB_INCLUDEDIR)/glib/*.h \ + $(srcdir)/glib-2.0.c + +INTROSPECTION_GIRS += GLib-2.0.gir EXTRA_DIST += glib-2.0.c GLib-2.0.xpath # gobject -GOBJECT_INCLUDEDIR=`pkg-config --variable=includedir gobject-2.0`/glib-2.0 -GOBJECT_LIBDIR=`pkg-config --variable=libdir gobject-2.0` +GOBJECT_INCLUDEDIR=$(shell pkg-config --variable=includedir gobject-2.0)/glib-2.0 +GOBJECT_LIBDIR=$(shell pkg-config --variable=libdir gobject-2.0) if OS_WIN32 GOBJECT_LIBRARY=libgobject-2.0-0 @@ -60,30 +56,25 @@ else GOBJECT_LIBRARY=gobject-2.0 endif -GObject-2.0.gir: GLib-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(SCANNER) \ - --namespace GObject --nsversion=2.0 \ - --noclosure \ - --output $@ \ - --strip-prefix=g \ - --libtool="$(LIBTOOL)" \ - --c-include="glib-object.h" \ - --include=GLib-2.0 \ - --library=$(GOBJECT_LIBRARY) \ - -I$(GOBJECT_INCLUDEDIR) \ - -I$(GOBJECT_LIBDIR)/glib-2.0/include \ - -DGOBJECT_COMPILATION \ - --pkg gobject-2.0 \ - $(srcdir)/gobject-2.0.c \ - $(GLIB_INCLUDEDIR)/gobject/*.h - $(SCANNER) $(SCANNER_ARGS) \ - --xpath-assertions=$(srcdir)/GObject-2.0.xpath GObject-2.0.gir -BUILT_GIRSOURCES += GObject-2.0.gir +GObject-2.0.gir: GLib-2.0.gir + +GObject_2_0_gir_LIBS = $(GOBJECT_LIBRARY) +GObject_2_0_gir_SCANNERFLAGS = --noclosure --strip-prefix=g --c-include="glib-object.h" +GObject_2_0_gir_PACKAGES = gobject-2.0 +GObject_2_0_gir_INCLUDES = GLib-2.0 +GObject_2_0_gir_CFLAGS = \ + -DGOBJECT_COMPILATION \ + -I$(GOBJECT_INCLUDEDIR) \ + -I$(GOBJECT_LIBDIR)/glib-2.0/include +GObject_2_0_gir_ASSERTIONS = $(srcdir)/GObject-2.0.xpath +GObject_2_0_gir_FILES = $(GLIB_INCLUDEDIR)/gobject/*.h $(srcdir)/gobject-2.0.c + +INTROSPECTION_GIRS += GObject-2.0.gir EXTRA_DIST += gobject-2.0.c GObject-2.0.xpath # gmodule -GMODULE_INCLUDEDIR=`pkg-config --variable=includedir gmodule-2.0`/glib-2.0 -GMODULE_LIBDIR=`pkg-config --variable=libdir gmodule-2.0` +GMODULE_INCLUDEDIR=$(shell pkg-config --variable=includedir gmodule-2.0)/glib-2.0 +GMODULE_LIBDIR=$(shell pkg-config --variable=libdir gmodule-2.0) if OS_WIN32 GMODULE_LIBRARY=libgmodule-2.0-0 @@ -91,26 +82,22 @@ else GMODULE_LIBRARY=gmodule-2.0 endif -GModule-2.0.gir: GLib-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) - $(SCANNER) \ - --namespace GModule --nsversion=2.0 \ - --add-include-path=. \ - --noclosure \ - --output $@ \ - --strip-prefix=g \ - --libtool="$(LIBTOOL)" \ - --c-include="gmodule.h" \ - --include=GLib-2.0 \ - --library=$(GMODULE_LIBRARY) \ - -I$(GMODULE_INCLUDEDIR) \ - -I$(GMODULE_LIBDIR)/glib-2.0/include \ - --pkg gmodule-2.0 \ - $(GLIB_INCLUDEDIR)/gmodule.h -BUILT_GIRSOURCES += GModule-2.0.gir +GModule-2.0.gir: GLib-2.0.gir + +GModule_2_0_gir_LIBS = $(GMODULE_LIBRARY) +GModule_2_0_gir_SCANNERFLAGS = --noclosure --strip-prefix=g --c-include="gmodule.h" +GModule_2_0_gir_PACKAGES = gmodule-2.0 +GModule_2_0_gir_INCLUDES = GLib-2.0 +GModule_2_0_gir_CFLAGS = \ + -I$(GMODULE_INCLUDEDIR) \ + -I$(GMODULE_LIBDIR)/glib-2.0/include +GModule_2_0_gir_FILES = $(GLIB_INCLUDEDIR)/gmodule.h + +INTROSPECTION_GIRS += GModule-2.0.gir # gio -GIO_INCLUDEDIR=`pkg-config --variable=includedir gio-2.0`/glib-2.0 -GIO_LIBDIR=`pkg-config --variable=libdir gio-2.0` +GIO_INCLUDEDIR=$(shell pkg-config --variable=includedir gio-2.0)/glib-2.0 +GIO_LIBDIR=$(shell pkg-config --variable=libdir gio-2.0) if OS_WIN32 GIO_LIBRARY=libgio-2.0-0 @@ -119,53 +106,48 @@ GIO_LIBRARY=gio-2.0 endif if HAVE_GIO_UNIX -GIO_UNIX_HDRS=`pkg-config --variable=includedir gio-unix-2.0`/gio-unix-2.0/gio/*.h +GIO_UNIX_HDRS=$(shell pkg-config --variable=includedir gio-unix-2.0)/gio-unix-2.0/gio/*.h else GIO_UNIX_HDRS= endif -Gio-2.0.gir: GObject-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile $(srcdir)/gio-2.0.c - $(SCANNER) \ - --namespace Gio --nsversion=2.0 \ - --add-include-path=. \ - --noclosure \ - --output $@ \ - --strip-prefix=g \ - --libtool="$(LIBTOOL)" \ - --c-include="gio/gio.h" \ - --include=GObject-2.0 \ - --library=$(GIO_LIBRARY) \ - -I$(GIO_INCLUDEDIR) \ - -I$(GIO_LIBDIR)/glib-2.0/include \ - -DGIO_COMPILATION \ - --pkg gio-2.0 \ - $(srcdir)/gio-2.0.c \ - $(GLIB_INCLUDEDIR)/gio/*.h \ - $(GIO_UNIX_HDRS) -BUILT_GIRSOURCES += Gio-2.0.gir +Gio-2.0.gir: GObject-2.0.gir + +Gio_2_0_gir_LIBS = $(GIO_LIBRARY) +Gio_2_0_gir_SCANNERFLAGS = --noclosure --strip-prefix=g --c-include="gio/gio.h" +Gio_2_0_gir_PACKAGES = gio-2.0 +Gio_2_0_gir_INCLUDES = GObject-2.0 +Gio_2_0_gir_CFLAGS = \ + -DGIO_COMPILATION \ + -I$(GIO_INCLUDEDIR) \ + -I$(GIO_LIBDIR)/glib-2.0/include +Gio_2_0_gir_FILES = \ + $(GIO_UNIX_HDRS) \ + $(GIO_INCLUDEDIR)/gio/*.h \ + $(srcdir)/gio-2.0.c + +INTROSPECTION_GIRS += Gio-2.0.gir EXTRA_DIST += gio-2.0.c # girepository -GIREPOSITORY_FILES = \ - $(top_srcdir)/girepository/girepository.c \ - $(top_srcdir)/girepository/girepository.h - -GIRepository-2.0.gir: GObject-2.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) $(GIREPOSITORY_FILES) - $(SCANNER) \ - --namespace GIRepository --nsversion=2.0 \ - --noclosure \ - --output $@ \ - --strip-prefix=g \ - --libtool="$(LIBTOOL)" \ - --c-include="girepository.h" \ - --include=GObject-2.0 \ - --library=girepository-1.0 \ - -I$(srcdir)/girepository \ - --pkg gobject-2.0 \ - --pkg-export gobject-introspection-1.0 \ - $(GIREPOSITORY_FILES) -BUILT_GIRSOURCES += GIRepository-2.0.gir - +GIRepository-2.0.gir: GObject-2.0.gir $(top_builddir)/girepository/libgirepository-1.0.la + +GIRepository_2_0_gir_LIBS = girepository-1.0 +GIRepository_2_0_gir_SCANNERFLAGS = \ + --noclosure \ + --strip-prefix=g \ + --c-include="girepository.h" \ + --pkg-export gobject-introspection-1.0 +GIRepository_2_0_gir_PACKAGES = gobject-2.0 +GIRepository_2_0_gir_INCLUDES = GObject-2.0 +GIRepository_2_0_gir_CFLAGS = -I$(srcdir)/girepository +GIRepository_2_0_gir_FILES = \ + $(top_srcdir)/girepository/girepository.c \ + $(top_srcdir)/girepository/girepository.h + +INTROSPECTION_GIRS += GIRepository-2.0.gir + +# everything LT_CURRENT = 1 LT_REVISION = 0 LT_AGE = 0 @@ -183,31 +165,26 @@ if OS_WIN32 libgirepository_everything_1_0_la_LDFLAGS += -no-undefined endif -Everything-$(TYPELIB_VERSION).gir: GObject-2.0.gir libgirepository-everything-1.0.la everything.c everything.h $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(SCANNER) \ - --include=GObject-2.0 \ - --libtool="$(LIBTOOL)" \ - --library=girepository-everything-1.0 \ - --namespace=Everything --nsversion=$(TYPELIB_VERSION) \ - --pkg gobject-2.0 \ - $(srcdir)/everything.h $(srcdir)/everything.c \ - --output $@ -BUILT_GIRSOURCES += Everything-$(TYPELIB_VERSION).gir +Everything-1.0.gir: Gio-2.0.gir libgirepository-everything-1.0.la + +Everything_1_0_gir_LIBS = libgirepository-everything-1.0.la +Everything_1_0_gir_PACKAGES = gobject-2.0 +Everything_1_0_gir_INCLUDES = GObject-2.0 +Everything_1_0_gir_FILES = $(srcdir)/everything.h $(srcdir)/everything.c + +INTROSPECTION_GIRS += Everything-$(TYPELIB_VERSION).gir EXPECTEDGIRS += Everything-$(TYPELIB_VERSION)-expected.gir # Generic rules -CLEANFILES += $(BUILT_GIRSOURCES) +CLEANFILES += $(INTROSPECTION_GIRS) -GIRSOURCES = \ - $(BASE_GIRSOURCES) \ - $(BUILT_GIRSOURCES) +GIRSOURCES = \ + $(BASE_GIRSOURCES) \ + $(INTROSPECTION_GIRS) girdir = $(GIR_DIR) dist_gir_DATA = $(GIRSOURCES) -%.typelib: %.gir $(top_builddir)/tools/g-ir-compiler$(EXEEXT) - $(top_builddir)/tools/g-ir-compiler$(EXEEXT) --includedir=. $(G_IR_COMPILER_OPTS) $< -o $@ - typelibsdir = $(libdir)/girepository-1.0 typelibs_DATA = $(GIRSOURCES:.gir=.typelib) @@ -228,7 +205,7 @@ check-local: $(CHECKGIRS) $(DEBUG) $(top_builddir)/tools/g-ir-generate$(EXEEXT) --includedir=. $< -o $@ testlib-%: %.test.gir $(top_builddir)/tools/g-ir-generate$(EXEEXT) - $(DEBUG) $(top_builddir)/tools/g-ir-compiler$(EXEEXT) --includedir=. $(G_IR_COMPILER_OPTS) $< -o $*.test.typelib + $(DEBUG) $(top_builddir)/tools/g-ir-compiler$(EXEEXT) --includedir=. $< -o $*.test.typelib cmp $*.typelib $*.test.typelib && rm $*.test.typelib testgir-%: %.test.gir diff --git a/m4/introspection.m4 b/m4/introspection.m4 index 6e2c565..589721c 100644 --- a/m4/introspection.m4 +++ b/m4/introspection.m4 @@ -61,6 +61,7 @@ m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], 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) @@ -69,6 +70,7 @@ m4_define([_GOBJECT_INTROSPECTION_CHECK_INTERNAL], 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") ]) diff --git a/tests/offsets/Makefile.am b/tests/offsets/Makefile.am index f1a88c8..2a68da4 100644 --- a/tests/offsets/Makefile.am +++ b/tests/offsets/Makefile.am @@ -1,8 +1,10 @@ include $(top_srcdir)/common.mk +include $(top_srcdir)/Makefile.introspection BUILT_SOURCES = CLEANFILES = EXTRA_DIST = +INTROSPECTION_GIRS = check_LTLIBRARIES = check_PROGRAMS = @@ -18,19 +20,12 @@ liboffsets_la_CPPFLAGS = $(GIREPO_CFLAGS) # dummy rpath to get built dynamically (huh?) liboffsets_la_LDFLAGS = -avoid-version -rpath $(libdir) -offsets-1.0.gir: liboffsets.la offsets.h $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(CHECK_DEBUG) $(SCANNER) \ - --include=GObject-2.0 \ - --libtool="$(LIBTOOL)" \ - --library=liboffsets.la \ - --namespace=offsets \ - --nsversion=1.0 \ - --pkg gobject-2.0 \ - $(srcdir)/offsets.h $(srcdir)/offsets.c \ - --output $@ - -%.typelib: %.gir $(top_builddir)/tools/g-ir-compiler$(EXEEXT) Makefile - $(top_builddir)/tools/g-ir-compiler --includedir=. --includedir=$(top_builddir)/gir $< -o $@ +offsets-1.0.gir: liboffsets.la offsets.h +offsets_1_0_gir_INCLUDES = GObject-2.0 +offsets_1_0_gir_LIBS = liboffsets.la +offsets_1_0_gir_PACKAGES = gobject-2.0 +offsets_1_0_gir_FILES = $(srcdir)/offsets.h $(srcdir)/offsets.c +INTROSPECTION_GIRS += offsets-1.0.gir CLEANFILES += offsets-1.0.gir offsets-1.0.typelib diff --git a/tests/scanner/Makefile.am b/tests/scanner/Makefile.am index 001a582..7e333ea 100644 --- a/tests/scanner/Makefile.am +++ b/tests/scanner/Makefile.am @@ -1,4 +1,5 @@ include $(top_srcdir)/common.mk +include $(top_srcdir)/Makefile.introspection # We need to build a shared library, which can be dlopened # it does not work with noinst_LTLIBRARIES @@ -34,75 +35,47 @@ EXPECTEDGIRS = $(GIRS:.gir=-expected.gir) TGIRS = $(GIRS:.gir=.tgir) CHECKTGIRS = $(GIRS:.gir=.tgir.check) EXPECTEDTGIRS = $(GIRS:.gir=-expected.tgir) -CLEANFILES = $(TYPELIBS) $(GIRS) +INTROSPECTION_GIRS = $(GIRS) +CLEANFILES = $(TYPELIBS) $(GIRS) BUILT_SOURCES = $(TYPELIBS) $(GIRS) $(TGIRS) EXTRA_DIST = $(EXPECTEDGIRS) $(EXPECTEDTGIRS) -annotation-1.0.gir: libannotation.la annotation.c annotation.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(CHECK_DEBUG) $(SCANNER) \ - --include=GObject-2.0 \ - --include=utility-1.0 \ - --libtool="$(LIBTOOL)" \ - --library=libannotation.la \ - --namespace=annotation \ - --nsversion=1.0 \ - --pkg gobject-2.0 \ - $(srcdir)/annotation.h $(srcdir)/annotation.c \ - --output $@ +annotation-1.0.gir: utility-1.0.gir libannotation.la +annotation_1_0_gir_PACKAGES = gobject-2.0 +annotation_1_0_gir_LIBS = libannotation.la +annotation_1_0_gir_INCLUDES = GObject-2.0 utility-1.0 +annotation_1_0_gir_FILES = $(libannotation_la_SOURCES) GIRS += annotation-1.0.gir -drawable-1.0.gir: libdrawable.la drawable.c drawable.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(CHECK_DEBUG) $(SCANNER) \ - --include=GObject-2.0 \ - --include=utility-1.0 \ - --libtool="$(LIBTOOL)" \ - --library=libdrawable.la \ - --namespace=drawable \ - --nsversion=1.0 \ - --pkg gobject-2.0 \ - $(srcdir)/drawable.h $(srcdir)/drawable.c \ - --output $@ +drawable-1.0.gir: utility-1.0.gir libdrawable.la +drawable_1_0_gir_PACKAGES = gobject-2.0 +drawable_1_0_gir_LIBS = libdrawable.la +drawable_1_0_gir_INCLUDES = GObject-2.0 utility-1.0 +drawable_1_0_gir_FILES = $(libdrawable_la_SOURCES) GIRS += drawable-1.0.gir -foo-1.0.gir: libfoo.la foo.c foo.h utility-1.0.gir $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(CHECK_DEBUG) $(SCANNER) \ - --include=GObject-2.0 \ - --include=utility-1.0 \ - --include=Gio-2.0 \ - --c-include="foo.h" \ - --libtool="$(LIBTOOL)" \ - --library=libfoo.la \ - --namespace=foo \ - --nsversion=1.0 \ - --pkg gobject-2.0 \ - $(srcdir)/foo.h $(srcdir)/foo.c \ - --output $@ +foo-1.0.gir: utility-1.0.gir libfoo.la +foo_1_0_gir_PACKAGES = gobject-2.0 +foo_1_0_gir_LIBS = libfoo.la +foo_1_0_gir_INCLUDES = GObject-2.0 Gio-2.0 utility-1.0 +foo_1_0_gir_FILES = $(srcdir)/foo.h $(srcdir)/foo.c +foo_1_0_gir_SCANNERFLAGS = --c-include="foo.h" GIRS += foo-1.0.gir -utility-1.0.gir: libutility.la utility.h $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(CHECK_DEBUG) $(SCANNER) \ - --include=GObject-2.0 \ - --libtool="$(LIBTOOL)" \ - --library=libutility.la \ - --namespace=utility \ - --nsversion=1.0 \ - --pkg gobject-2.0 \ - $(libutility_la_SOURCES) \ - --output $@ +utility-1.0.gir: libutility.la +utility_1_0_gir_PACKAGES = gobject-2.0 +utility_1_0_gir_LIBS = libutility.la +utility_1_0_gir_INCLUDES = GObject-2.0 +utility_1_0_gir_FILES = $(libutility_la_SOURCES) GIRS += utility-1.0.gir # This one tests different --namespace and --strip-prefix -GtkFrob-1.0.gir: libgtkfrob.la gtkfrob.h $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(CHECK_DEBUG) $(SCANNER) \ - --include=GObject-2.0 \ - --libtool="$(LIBTOOL)" \ - --library=libgtkfrob.la \ - --namespace=GtkFrob \ - --strip-prefix=Gtk \ - --nsversion=1.0 \ - --pkg gobject-2.0 \ - $(libgtkfrob_la_SOURCES) \ - --output $@ +GtkFrob-1.0.gir: libgtkfrob.la +GtkFrob_1_0_gir_PACKAGES = gobject-2.0 +GtkFrob_1_0_gir_LIBS = libgtkfrob.la +GtkFrob_1_0_gir_INCLUDES = GObject-2.0 +GtkFrob_1_0_gir_FILES = $(libgtkfrob_la_SOURCES) +GtkFrob_1_0_gir_SCANNERFLAGS = --strip-prefix=Gtk GIRS += GtkFrob-1.0.gir noinst_PROGRAMS = barapp @@ -110,17 +83,13 @@ noinst_PROGRAMS = barapp barapp_SOURCES = $(srcdir)/barapp.c $(srcdir)/barapp.h barapp_LDADD = $(top_builddir)/girepository/libgirepository-1.0.la barapp_LDFLAGS = -export-dynamic -BarApp-1.0.gir: barapp $(SCANNER_BIN) $(SCANNER_LIBS) Makefile - $(SCANNER) \ - --include=GObject-2.0 \ - --libtool="$(LIBTOOL)" \ - --program=./barapp \ - --namespace=BarApp \ - --strip-prefix=Bar \ - --nsversion=1.0 \ - --pkg gobject-2.0 \ - $(barapp_SOURCES) \ - --output $@ + +BarApp-1.0.gir: barapp +BarApp_1_0_gir_PACKAGES = gobject-2.0 +BarApp_1_0_gir_PROGRAM = ./barapp +BarApp_1_0_gir_INCLUDES = GObject-2.0 +BarApp_1_0_gir_FILES = $(barapp_SOURCES) +BarApp_1_0_gir_SCANNERFLAGS = --strip-prefix=Bar GIRS += BarApp-1.0.gir pre-check: @@ -143,9 +112,6 @@ post-check: %-expected.typelib: @true -%.typelib: %.gir $(top_builddir)/tools/g-ir-compiler$(EXEEXT) Makefile - $(top_builddir)/tools/g-ir-compiler --includedir=. --includedir=$(top_builddir)/gir $< -o $@ - %.tgir: %.typelib $(top_builddir)/tools/g-ir-generate$(EXEEXT) Makefile $(top_builddir)/tools/g-ir-generate --includedir=. --includedir=$(top_builddir)/gir $< -o $@ -- 2.39.2