From 34d77fa2eb9ff0f065dfab81caa360ea02b27d5b Mon Sep 17 00:00:00 2001 From: Gergely Polonkai Date: Tue, 1 Mar 2016 17:42:19 +0100 Subject: [PATCH] Update autogen and toplevel Makefile This is partly to fix an issue with the INSTALL file missing --- Makefile.am | 9 ++- autogen.sh | 109 ++++++++++++++++++++++++++------ configure.ac | 164 ++++++++++++++++++++++++++++++++++++++---------- src/Makefile.am | 96 +++++++++++++++++++++------- 4 files changed, 304 insertions(+), 74 deletions(-) diff --git a/Makefile.am b/Makefile.am index 991a947..67bd4ec 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,10 +1,15 @@ -ACLOCAL_AMFLAGS = -I m4 +ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS} + +# Set up subdirectories to traverse SUBDIRS = src if ENABLE_GTK_DOC SUBDIRS += docs/reference/matrix-glib endif +# Specify files to include in dist + +# in share/doc/ matrixglibdocdir = ${prefix}/doc/matrix-glib matrixglibdoc_DATA = \ README \ @@ -20,6 +25,8 @@ EXTRA_DIST = $(matrixglibdoc_DATA) \ autogen.sh \ config.rpath +# Lists of generated files you want to be able to clean + MAINTAINERCLEANFILES = \ $(srcdir)/aclocal.m4 \ $(srcdir)/compile \ diff --git a/autogen.sh b/autogen.sh index ba5d157..eb7937e 100755 --- a/autogen.sh +++ b/autogen.sh @@ -1,18 +1,78 @@ #! /bin/sh +# Run this to generate all the initial makefiles, etc. srcdir=`dirname "$0"` test -z "$srcdir" && srcdir=. -PKG_NAME="matrix-client-glib" +DIE=0 +PKG_NAME="matrix-glib" (test -f "$srcdir/configure.ac" \ && test -f "$srcdir/src/matrix-client.c") || { - echo "**Error**: Directory "\`$srcdir\'" does not look like the" - echo " top-level $PKG_NAME directory" + echo -n "**Error**: Directory "\`$srcdir\'" does not look like the" + echo " top-level $PKG_NAME directory" + exit 1 } -cd "$srcdir" +(autoconf --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`autoconf' installed." + echo "Download the appropriate package for your distribution," + echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/" + + DIE=1 +} + +(grep "^LT_INIT" $srcdir/configure.ac >/dev/null) && { + (libtool --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`libtool' installed." + echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" + + DIE=1 + } +} + +(automake --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: You must have \`automake' installed." + echo "You can get it from: ftp://ftp.gnu.org/pub/gnu/" + + DIE=1 + NO_AUTOMAKE=yes +} + +# if no automake, don't bother testing for aclocal +test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || { + echo + echo "**Error**: Missing \`aclocal'. The version of \`automake'" + echo "installed doesn't appear recent enough." + echo "You can get automake from ftp://ftp.gnu.org/pub/gnu/" + + DIE=1 +} + +if test "$DIE" -eq 1; then + exit 1 +fi + +if test -z "$*"; then + echo "**Warning**: I am going to run \`configure' with no arguments." + echo "If you wish to pass any to it, please specify them on the" + echo \`$0\'" command line." + echo +fi + +case $CC in +xlc ) + am_opt=--include-deps;; +esac + +coin="$srcdir/configure.ac" +dr=`dirname $coin` + +cd $dr m4dir=`grep '^AC_CONFIG_MACRO_DIR' configure.ac \ | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' \ @@ -24,10 +84,16 @@ if test -n "$m4dir"]; then m4dir="-I $m4dir" fi -echo "Running libtoolize" -libtoolize --force --copy || exit $? +aclocalinclude="$ACLOCAL_FLAGS" -GTKDOCIZE=$(which gtkdocize 2>/dev/null) +if grep "^LT_INIT" "$coin" > /dev/null; then + if test -z "$NO_LIBTOOLIZE"; then + echo "Running libtoolize ..." + libtoolize --force --copy || exit $? + fi +fi + +GTKDOCIZE=$(which gtkdocize 2> /dev/null) if test -z "$GTKDOCIZE"; then echo "You don't have gtk-doc installed, and thus won't be able to generate documentation" @@ -38,23 +104,28 @@ EXTRA_DIST = CLEANFILES = EOF else - echo "Running gtkdocize" + echo "Running gtkdocize ..." gtkdocize --copy || exit $? fi -echo "Running aclocal" -aclocal $m4dir $ACLOCAL_FLAGS || exit $? +echo "Running aclocal $aclocalinclude ..." +aclocal $m4dir $ACLOCAL_FLAGS $aclocalinclude || exit $? -echo "Running autoconf" -autoconf || exit $? - -if grep '^A[CM]_CONFIG_HEADER' configure.ac > /dev/null; then - echo "Running autoheader" +if grep "^A[CM]_CONFIG_HEADER" "$coin" > /dev/null; then + echo "Running autoheader ..." autoheader || exit $? - test -f config.h.in && touch config.h.in fi -echo "Running automake" -automake --gnu --add-missing --copy -Wno-portability || exit $? +echo "Running automake --gnu $am_opt ..." +automake --add-missing --copy --gnu $am_opt -Wno-portability || exit $? -"$srcdir/configure" "$@" +echo "Running autoconf ..." +autoconf || exit $? + +if test x$NOCONFIGURE = x; then + echo Running "$srcdir/configure" "$@" ... + "$srcdir/configure" "$@" \ + && echo Now type \`make\' to compile. || exit 1 +else + echo Skipping configure process. +fi diff --git a/configure.ac b/configure.ac index 65e3b01..dfcad69 100644 --- a/configure.ac +++ b/configure.ac @@ -1,22 +1,131 @@ -m4_define([matrix_glib_minor_version], [0]) +# Process this file with autoconf to produce a configure script + +# Sections +# Version numbers +# Setup +# Dependencies +# Output + +### Version numbers + +# Release Version m4_define([matrix_glib_major_version], [0]) +m4_define([matrix_glib_minor_version], [0]) m4_define([matrix_glib_micro_version], [1]) -m4_define([matrix_glib_version], [matrix_glib_major_version.matrix_glib_minor_version.matrix_glib_micro_version]) +m4_define([matrix_glib_nano_version], [0]) + +# LT_VERSION +# If library source has changed since last release, increment revision +# If public symbols have been added, removed or changed since last +# release, increment current and set revision to 0 +# If public symbols have been added since last release, increment age +# If public symbols have been removed since last release, set age to 0 +m4_define([matrix_glib_lt_current], [0]) +m4_define([matrix_glib_lt_revision], [0]) +m4_define([matrix_glib_lt_age], [0]) + +# Combine numbers to various version variables (different uses) +# Display the nano_version only if it's not '0' +m4_define([matrix_glib_base_version], + matrix_glib_major_version.matrix_glib_minor_version.matrix_glib_micro_version) +m4_define([matrix_glib_full_version], + [m4_if(matrix_glib_nano_version, [0], + matrix_glib_base_version, + matrix_glib_base_version.matrix_glib_nano_version)]) + +# You should set project_released to one in order to mark this as a +# released version and to avoid date on version numbers +m4_define(matrix_glib_released, [0]) +m4_define([matrix_glib_maybe_datestamp], + m4_if(matrix_glib_released, [1], + [], + [m4_esyscmd([date +.%Y%m%d | tr -d '\n\r'])])) + +m4_define([matrix_glib_version], matrix_glib_full_version[]matrix_glib_maybe_datestamp) +m4_define([matrix_glib_major_minor_version], matrix_glib_major_version.matrix_glib_minor_version) +m4_define([matrix_glib_module_version], matrix_glib_lt_current) m4_define([matrix_glib_api_version], [matrix_glib_major_version.0]) -m4_define([matrix_api_version], [0.5.2]) -AC_INIT([MatrixGlib], [matrix_glib_version], [gergely@polonkai.eu], [matrix-glib]) -AM_INIT_AUTOMAKE([-Wall foreign]) -AC_CONFIG_HEADERS([config.h]) +### Setup + +# Initialise autoconf with project details, version +AC_INIT([MatrixGlib], matrix_glib_version, + [gergely@polonkai.eu], [matrix-glib]) +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +AC_PREREQ([2.65]) +AC_COPYRIGHT([Copyright (C) 2015,2016 Gergely Polonkai]) + +# Configure various files and settings for autoconf/automake AC_CONFIG_MACRO_DIR([m4]) -AM_SILENT_RULES([yes]) +AC_CONFIG_SRCDIR([Makefile.am]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_SRCDIR([configure.ac]) +AM_INIT_AUTOMAKE([1.11 dist-xz no-define + no-dist-gzip tar-ustar -Wno-portability]) +AM_MAINTAINER_MODE([enable]) +AC_PROG_CC +AM_PROG_CC_C_O +AM_PROG_AR +AC_PROG_LIBTOOL + +# Initialise libtool (handles library creation) with versions from above +LT_INIT(win32-dll) + +PKG_PROG_PKG_CONFIG([0.21]) + +AC_SUBST([CFLAGS]) +AC_SUBST([CPPFLAGS]) +AC_SUBST([LDFLAGS]) + +AC_SUBST([LT_CURRENT], matrix_glib_lt_current) +AC_SUBST([LT_REVISION], matrix_glib_lt_revision) +AC_SUBST([LT_AGE], matrix_glib_lt_age) + +AC_SUBST([MATRIX_GLIB_MAJOR_MINOR_VERSION], matrix_glib_major_minor_version) + +# This is used to identify a set of API compatible between versions +# - If new versions are compatible with the actual one, just leave +# this untouched +# - If new version breaks API change it in order to allow parallel +# installations with old versions. Change name of pc files to use +# a new API, too +AC_SUBST([API_VERSION], matrix_glib_api_version) + +AC_SUBST([MATRIX_GLIB_VERSION], matrix_glib_base_version) + +### Dependencies + +GLIB_REQUIRED=2.38.0 +SOUP_REQUIRED=2.44.2 +JSON_REQUIRED=0.16.2 + +# Check GLib +PKG_CHECK_MODULES([GLIB], + [glib-2.0 >= $GLIB_REQUIRED]) + +# Check GObject +PKG_CHECK_MODULES([GOBJECT], + [gobject-2.0 >= $GLIB_REQUIRED]) + +# Check for libSoup +PKG_CHECK_MODULES([SOUP], [libsoup-2.4 >= $SOUP_REQUIRED]) + +# Check for JSON-GLib +PKG_CHECK_MODULES([JSON], [json-glib-1.0 >= $JSON_REQUIRED]) + +# Check for GObject Introspection +GOBJECT_INTROSPECTION_CHECK([1.32.0]) + +debug=no AC_ARG_ENABLE(debug, - AC_HELP_STRING([--enable-debug], - [compile with debugging support]), - [enable_debug=$enableval], [enable_debug=no]) + AS_HELP_STRING([--enable-debug], + [compile with debugging support]), + [debug=$enableval], [debug=no]) +AM_CONDITIONAL([DEBUG], [test $debug = yes]) -if test x"$enable_debug" = x"$enableval"; then +if test x"$debug" = x"$enableval"; then AC_DEFINE([DEBUG], [1], [Define if debugging should be enabled]) if test x"$cflags_set" != x"set"; then @@ -27,19 +136,11 @@ if test x"$enable_debug" = x"$enableval"; then fi fi -AC_SUBST([MATRIX_GLIB_MAJOR_VERSION], [matrix_glib_major_version]) -AC_SUBST([MATRIX_GLIB_MINOR_VERSION], [matrix_glib_minor_version]) -AC_SUBST([MATRIX_GLIB_MICRO_VERSION], [matrix_glib_micro_version]) -AC_SUBST([MATRIX_GLIB_VERSION], [matrix_glib_version]) -AC_SUBST([MATRIX_GLIB_API_VERSION], [matrix_glib_api_version]) -AC_SUBST([MATRIX_GLIB_API_VERSION_U], [AS_TR_SH([matrix_glib_api_version])]) -AC_SUBST([MATRIX_API_VERSION], [matrix_api_version]) - -AC_PROG_CC -AM_PROG_CC_C_O -AM_PROG_AR -AC_PROG_LIBTOOL -LT_INIT +AC_SUBST([MATRIX_GLIB_MAJOR_VERSION], matrix_glib_major_version) +AC_SUBST([MATRIX_GLIB_MINOR_VERSION], matrix_glib_minor_version) +AC_SUBST([MATRIX_GLIB_MICRO_VERSION], matrix_glib_micro_version) +AC_SUBST([MATRIX_GLIB_API_VERSION], matrix_glib_api_version) +AC_SUBST([MATRIX_GLIB_API_VERSION_U], [AS_TR_SH(matrix_glib_api_version)]) m4_ifdef([GTK_DOC_CHECK], [ GTK_DOC_CHECK([1.20], [--flavour no-tmpl]) @@ -47,17 +148,9 @@ GTK_DOC_CHECK([1.20], [--flavour no-tmpl]) AM_CONDITIONAL([ENABLE_GTK_DOC], false) ]) -GOBJECT_INTROSPECTION_CHECK([1.0]) - -PKG_PROG_PKG_CONFIG AC_PATH_PROG([GLIB_MKENUMS], [glib-mkenums]) AC_PATH_PROG([GLIB_GENMARSHAL], [glib-genmarshal]) -PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.38]) -PKG_CHECK_MODULES([GOBJECT], [gobject-2.0 >= 2.38]) -PKG_CHECK_MODULES([SOUP], [libsoup-2.4]) -PKG_CHECK_MODULES([JSON], [json-glib-1.0]) - LIBMATRIX_GLIB_LIBS='$(top_builddir)/src/libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la' AC_SUBST(LIBMATRIX_GLIB_LIBS) @@ -73,3 +166,10 @@ AM_COND_IF([ENABLE_GTK_DOC], [ ]) ]) AC_OUTPUT + +# Print configuration summary +echo "" +echo " Configuration summary for Matrix-$MATRIX_GLIB_VERSION" +echo " Installation prefix: $prefix" +echo " Debug: $debug" +echo "" diff --git a/src/Makefile.am b/src/Makefile.am index f58c150..4c34d1f 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,6 +1,14 @@ AM_CPPFLAGS = -DG_LOG_DOMAIN=\"Matrix-GLib\" +# Empty variables for elements to be added later +CLEANFILES = +BUILT_SOURCES = +EXTRA_DIST = + +# Libraries to create lib_LTLIBRARIES = libmatrix-glib-0.0.la + +# Binaries to create bin_PROGRAMS = test-api-client INST_H_SRC_FILES = \ @@ -22,24 +30,37 @@ matrix_enum_headers = \ $(NULL) libmatrix_glib_0_0_la_SOURCES = \ + $(INST_H_BUILT_FILES) \ + matrix-marshalers.c \ matrix-version.c \ matrix-types.c \ matrix-api.c \ matrix-http-api.c \ matrix-enumtypes.c \ utils.c \ - matrix-marshalers.c \ matrix-client.c \ matrix-http-client.c \ $(INST_H_SRC_FILES) \ - $(INST_H_BUILT_FILES) \ $(NULL) -libmatrix_glib_0_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) $(SOUP_CFLAGS) $(JSON_CFLAGS) -libmatrix_glib_0_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(SOUP_LIBS) $(JSON_LIBS) -libmatrix_glib_0_0_la_DEPENDENCIES = +libmatrix_glib_0_0_la_CFLAGS = \ + $(GLIB_CFLAGS) \ + $(GOBJECT_CFLAGS) \ + $(SOUP_CFLAGS) \ + $(JSON_CFLAGS) \ + $(NULL) -BUILT_SOURCES = \ +libmatrix_glib_0_0_la_LIBADD = \ + $(GLIB_LIBS) \ + $(GOBJECT_LIBS) \ + $(SOUP_LIBS) \ + $(JSON_LIBS) \ + $(NULL) + +libmatrix_glib_0_0_la_LDFLAGS = \ + -version-info "$(LT_CURRENT)":"$(LT_REVISION)":"$(LT_AGE)" + +BUILT_SOURCES += \ matrix-enumtypes.c \ matrix-enumtypes.h \ matrix-marshalers.c \ @@ -48,10 +69,13 @@ BUILT_SOURCES = \ test_api_client_SOURCES = test-api-client.c test_api_client_CFLAGS = $(libmatrix_glib_0_0_la_CFLAGS) -test_api_client_LDADD = $(libmatrix_glib_0_0_la_LIBADD) libmatrix-glib-0.0.la +test_api_client_LDADD = \ + $(libmatrix_glib_0_0_la_LIBADD) \ + libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la \ + $(NULL) -CLEANFILES = $(BUILT_SOURCES) -EXTRA_DIST = \ +CLEANFILES += $(BUILT_SOURCES) +EXTRA_DIST += \ matrix-enumtypes.h.template \ matrix-enumtypes.c.template \ matrix-marshalers.list \ @@ -59,32 +83,60 @@ EXTRA_DIST = \ $(NULL) matrix-enumtypes.h: $(matrix_enum_headers) matrix-enumtypes.h.template - $(AM_V_GEN) $(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > $@.tmp \ + $(AM_V_GEN) $(GLIB_MKENUMS) --template $(filter %.template,$^) \ + $(filter-out %.template,$^) > $@.tmp \ && mv $@.tmp $@ matrix-enumtypes.c: $(matrix_enum_headers) matrix-enumtypes.h matrix-enumtypes.c.template - $(AM_V_GEN) $(GLIB_MKENUMS) --template $(filter %.template,$^) $(filter-out %.template,$^) > $@.tmp \ + $(AM_V_GEN) $(GLIB_MKENUMS) --template $(filter %.template,$^) \ + $(filter-out %.template,$^) > $@.tmp \ && mv $@.tmp $@ matrix-marshalers.h: matrix-marshalers.list - $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_matrix_marshal $(srcdir)/matrix-marshalers.list --header --valist-marshallers >> xgen-gmlh \ - && (cmp -s xgen-gmlh matrix-marshalers.h || cp xgen-gmlh matrix-marshalers.h) \ + $(AM_V_GEN) $(GLIB_GENMARSHAL) --prefix=_matrix_marshal \ + $(srcdir)/matrix-marshalers.list \ + --header \ + --valist-marshallers >> xgen-gmlh \ + && (cmp -s xgen-gmlh matrix-marshalers.h \ + || cp xgen-gmlh matrix-marshalers.h) \ && rm -f xgen-gmlh matrix-marshalers.c: matrix-marshalers.list $(AM_V_GEN) (echo "#include \"matrix-marshalers.h\""; \ - $(GLIB_GENMARSHAL) --prefix=_matrix_marshal $(srcdir)/matrix-marshalers.list --body --valist-marshallers) >> xgen-gmlc \ + $(GLIB_GENMARSHAL) --prefix=_matrix_marshal \ + $(srcdir)/matrix-marshalers.list \ + --body \ + --valist-marshallers) >> xgen-gmlc \ && cp xgen-gmlc matrix-marshalers.c \ && rm -f xgen-gmlc include $(INTROSPECTION_MAKEFILE) -Matrix-$(MATRIX_GLIB_API_VERSION).gir: libmatrix-glib-0.0.la -Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_FILES = $(INST_H_SRC_FILES) $(INST_H_BUILT_FILES) $(filter %.c,$(libmatrix_glib_0_0_la_SOURCES)) -Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_LIBS = libmatrix-glib-0.0.la -Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_SCANNERFLAGS = --identifier-prefix=Matrix --symbol-prefix=matrix --warn-all -Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_INCLUDES = GLib-2.0 GObject-2.0 Soup-2.4 Json-1.0 -Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_CFLAGS = -D__MATRIX_GLIB_BUILDING__ -I$(top_srcdir) -I$(srcdir) -I$(builddir) -Matrix_@MATRIX_GLIB_API_VERSION_U@_gir_EXPORT_PACKAGES = matrix-glib +Matrix-0.0.gir: libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la + +Matrix_0_0_gir_FILES = \ + $(INST_H_SRC_FILES) \ + $(INST_H_BUILT_FILES) \ + $(filter %.c,$(libmatrix_glib_0_0_la_SOURCES)) \ + $(NULL) + +Matrix_0_0_gir_LIBS = libmatrix-glib-$(MATRIX_GLIB_API_VERSION).la + +Matrix_0_0_gir_SCANNERFLAGS = \ + --identifier-prefix=Matrix \ + --symbol-prefix=matrix \ + --warn-all \ + $(NULL) + +Matrix_0_0_gir_INCLUDES = GLib-2.0 GObject-2.0 Soup-2.4 Json-1.0 + +Matrix_0_0_gir_CFLAGS = \ + -D__MATRIX_GLIB_BUILDING__ \ + -I$(top_srcdir) \ + -I$(srcdir) \ + -I$(builddir) \ + $(NULL) + +Matrix_0_0_gir_EXPORT_PACKAGES = matrix-glib INTROSPECTION_GIRS = Matrix-$(MATRIX_GLIB_API_VERSION).gir girdir = $(datadir)/gir-1.0 @@ -93,7 +145,7 @@ gir_DATA = Matrix-$(MATRIX_GLIB_API_VERSION).gir typelibsdir = $(libdir)/girepository-1.0 typelibs_DATA = Matrix-$(MATRIX_GLIB_API_VERSION).typelib -headerdir = $(includedir)/swe-glib +headerdir = $(includedir)/matrix-glib-$(MATRIX_GLIB_API_VERSION) header_DATA = \ $(INST_H_SRC_FILES) \ $(INST_H_BUILT_FILES) \