summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2015-06-14 00:50:36 +0200
committerJens Georg <mail@jensge.org>2015-06-14 00:50:41 +0200
commitc4159e3a68f1243e6ab32375b30dd14e4dfff48c (patch)
tree0911f68c5981b48c5e9409b29017e7116becd453
parenta2b121a04cb57450af903e5df6fafb53c55617d4 (diff)
downloadgupnp-av-c4159e3a68f1243e6ab32375b30dd14e4dfff48c.tar.gz
Remove gnome-common
And fix compiler errors Signed-off-by: Jens Georg <mail@jensge.org>
-rw-r--r--configure.ac7
-rw-r--r--libgupnp-av/Makefile.am6
-rw-r--r--libgupnp-av/fragment-util.c84
-rw-r--r--libgupnp-av/gupnp-didl-lite-contributor.c3
-rw-r--r--libgupnp-av/gupnp-didl-lite-createclass.c3
-rw-r--r--libgupnp-av/gupnp-didl-lite-descriptor.c3
-rw-r--r--libgupnp-av/gupnp-didl-lite-descriptor.h3
-rw-r--r--libgupnp-av/gupnp-didl-lite-parser.c1
-rw-r--r--libgupnp-av/gupnp-didl-lite-resource.c6
-rw-r--r--libgupnp-av/gupnp-media-collection.c8
-rw-r--r--libgupnp-av/gupnp-protocol-info.c2
-rw-r--r--libgupnp-av/gupnp-search-criteria-parser.c6
-rw-r--r--libgupnp-av/gvalue-util.c2
-rw-r--r--libgupnp-av/xml-util.c6
-rw-r--r--m4/ax_append_compile_flags.m465
-rw-r--r--m4/ax_append_flag.m471
-rw-r--r--m4/ax_check_compile_flag.m474
-rw-r--r--m4/ax_check_enable_debug.m4113
-rw-r--r--m4/ax_compiler_flags.m4158
-rw-r--r--m4/ax_compiler_flags_cflags.m4133
-rw-r--r--m4/ax_compiler_flags_gir.m460
-rw-r--r--m4/ax_compiler_flags_ldflags.m475
-rw-r--r--m4/ax_is_release.m469
-rw-r--r--m4/ax_require_defined.m437
-rw-r--r--tests/Makefile.am7
-rw-r--r--tests/fragments.c8
-rw-r--r--tests/gtest/Makefile.am8
-rw-r--r--tests/gtest/test-didl-lite-object.c8
-rw-r--r--tests/gtest/test-media-collection.c28
29 files changed, 961 insertions, 93 deletions
diff --git a/configure.ac b/configure.ac
index 2d21e01..314555e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -15,12 +15,19 @@ AM_MAINTAINER_MODE([enable])
AM_SILENT_RULES([yes])
+AX_REQUIRE_DEFINED([GTK_DOC_CHECK])
+AX_REQUIRE_DEFINED([GOBJECT_INTROSPECTION_CHECK])
+AX_CHECK_ENABLE_DEBUG([yes])
+
# Check for programs
AC_PROG_CC
AM_PROG_CC_C_O
AC_HEADER_STDC
AC_FUNC_MMAP
+AX_IS_RELEASE([git-directory])
+AX_COMPILER_FLAGS([WARN_CFLAGS])
+
# Initialize libtool
LT_PREREQ([2.2])
LT_INIT([win32-dll])
diff --git a/libgupnp-av/Makefile.am b/libgupnp-av/Makefile.am
index 7db04eb..703da5c 100644
--- a/libgupnp-av/Makefile.am
+++ b/libgupnp-av/Makefile.am
@@ -9,7 +9,7 @@
# age to 0.
LTVERSION = 2:0:0
-AM_CFLAGS = $(LIBGUPNP_CFLAGS) -I$(top_srcdir) -DDATADIR="\"$(pkgdatadir)\""
+AM_CFLAGS = $(LIBGUPNP_CFLAGS) -I$(top_srcdir) -DDATADIR="\"$(pkgdatadir)\"" $(WARN_CFLAGS)
libgupnp_av_incdir = $(includedir)/gupnp-av-1.0/libgupnp-av
@@ -47,7 +47,7 @@ gupnp-av-marshal.h: gupnp-av-marshal.list
BUILT_SOURCES = gupnp-av-marshal.c gupnp-av-marshal.h
-libgupnp_av_1_0_la_LDFLAGS = -version-info $(LTVERSION) -no-undefined
+libgupnp_av_1_0_la_LDFLAGS = -version-info $(LTVERSION) -no-undefined $(WARN_LDFLAGS)
libgupnp_av_1_0_la_SOURCES = gupnp-didl-lite-object.c \
gupnp-didl-lite-object-private.h \
@@ -125,7 +125,7 @@ GUPnPAV_1_0_gir_INCLUDES = GObject-2.0 GSSDP-1.0 Soup-2.4 libxml2-2.0 GUPnP-1.0
GUPnPAV_1_0_gir_CFLAGS = $(AM_CFLAGS)
GUPnPAV_1_0_gir_LIBS = libgupnp-av-1.0.la
GUPnPAV_1_0_gir_NAMESPACE = GUPnPAV
-GUPnPAV_1_0_gir_SCANNERFLAGS = --identifier-prefix=GUPnP --symbol-prefix=gupnp --pkg-export=gupnp-av-1.0
+GUPnPAV_1_0_gir_SCANNERFLAGS = --identifier-prefix=GUPnP --symbol-prefix=gupnp --pkg-export=gupnp-av-1.0 $(WARN_SCANNERFLAGS)
GUPnPAV_1_0_gir_FILES = $(introspection_sources)
INTROSPECTION_GIRS += GUPnPAV-1.0.gir
diff --git a/libgupnp-av/fragment-util.c b/libgupnp-av/fragment-util.c
index 6fc6be2..bd8658c 100644
--- a/libgupnp-av/fragment-util.c
+++ b/libgupnp-av/fragment-util.c
@@ -136,41 +136,41 @@ is_read_only (const gchar *changed_element,
readonly_props = g_hash_table_new (g_str_hash,
g_str_equal);
- hash_table_add (readonly_props, "@id");
- hash_table_add (readonly_props, "@parentID");
- hash_table_add (readonly_props, "@refID");
- hash_table_add (readonly_props, "@restricted");
- hash_table_add (readonly_props, "@searchable");
- hash_table_add (readonly_props, "@childCount");
- hash_table_add (readonly_props, "searchClass");
- hash_table_add (readonly_props, "searchClass@name");
- hash_table_add (readonly_props, "searchClass@includeDerived");
- hash_table_add (readonly_props, "createClass");
- hash_table_add (readonly_props, "createClass@name");
- hash_table_add (readonly_props, "createClass@includeDerived");
- hash_table_add (readonly_props, "writeStatus");
- hash_table_add (readonly_props, "res@importUri");
- hash_table_add (readonly_props, "storageTotal");
- hash_table_add (readonly_props, "storageUsed");
- hash_table_add (readonly_props, "storageFree");
- hash_table_add (readonly_props, "storageMaxPartition");
- hash_table_add (readonly_props, "storageMedium");
- hash_table_add (readonly_props, "playbackCount");
- hash_table_add (readonly_props, "srsRecordScheduleID");
- hash_table_add (readonly_props, "srsRecordTaskID");
- hash_table_add (readonly_props, "price");
- hash_table_add (readonly_props, "price@currency");
- hash_table_add (readonly_props, "payPerView");
- hash_table_add (readonly_props, "dateTimeRange");
- hash_table_add (readonly_props,
+ hash_table_add (readonly_props, (gpointer) "@id");
+ hash_table_add (readonly_props, (gpointer) "@parentID");
+ hash_table_add (readonly_props, (gpointer) "@refID");
+ hash_table_add (readonly_props, (gpointer) "@restricted");
+ hash_table_add (readonly_props, (gpointer) "@searchable");
+ hash_table_add (readonly_props, (gpointer) "@childCount");
+ hash_table_add (readonly_props, (gpointer) "searchClass");
+ hash_table_add (readonly_props, (gpointer) "searchClass@name");
+ hash_table_add (readonly_props, (gpointer) "searchClass@includeDerived");
+ hash_table_add (readonly_props, (gpointer) "createClass");
+ hash_table_add (readonly_props, (gpointer) "createClass@name");
+ hash_table_add (readonly_props, (gpointer) "createClass@includeDerived");
+ hash_table_add (readonly_props, (gpointer) "writeStatus");
+ hash_table_add (readonly_props, (gpointer) "res@importUri");
+ hash_table_add (readonly_props, (gpointer) "storageTotal");
+ hash_table_add (readonly_props, (gpointer) "storageUsed");
+ hash_table_add (readonly_props, (gpointer) "storageFree");
+ hash_table_add (readonly_props, (gpointer) "storageMaxPartition");
+ hash_table_add (readonly_props, (gpointer) "storageMedium");
+ hash_table_add (readonly_props, (gpointer) "playbackCount");
+ hash_table_add (readonly_props, (gpointer) "srsRecordScheduleID");
+ hash_table_add (readonly_props, (gpointer) "srsRecordTaskID");
+ hash_table_add (readonly_props, (gpointer) "price");
+ hash_table_add (readonly_props, (gpointer) "price@currency");
+ hash_table_add (readonly_props, (gpointer) "payPerView");
+ hash_table_add (readonly_props, (gpointer) "dateTimeRange");
+ hash_table_add (readonly_props, (gpointer)
"dateTimeRange@daylightSaving");
- hash_table_add (readonly_props, "signalStrength");
- hash_table_add (readonly_props, "signalLocked");
- hash_table_add (readonly_props, "tuned");
- hash_table_add (readonly_props, "containerUpdateID");
- hash_table_add (readonly_props, "objectUpdateID");
- hash_table_add (readonly_props, "totalDeletedChildCount");
- hash_table_add (readonly_props, "res@updateCount");
+ hash_table_add (readonly_props, (gpointer) "signalStrength");
+ hash_table_add (readonly_props, (gpointer) "signalLocked");
+ hash_table_add (readonly_props, (gpointer) "tuned");
+ hash_table_add (readonly_props, (gpointer) "containerUpdateID");
+ hash_table_add (readonly_props, (gpointer) "objectUpdateID");
+ hash_table_add (readonly_props, (gpointer) "totalDeletedChildCount");
+ hash_table_add (readonly_props, (gpointer) "res@updateCount");
g_once_init_leave (&readonly_props_loaded, 1);
}
if (changed_element != NULL) {
@@ -335,7 +335,7 @@ independent_property_new (gboolean required)
static void
insert_indep_prop (GHashTable *props,
- gchar *name,
+ const gchar *name,
IndependentProperty *prop)
{
g_hash_table_insert (props, g_strdup (name), prop);
@@ -343,7 +343,7 @@ insert_indep_prop (GHashTable *props,
static void
insert_indep_prop_to_indep (IndependentProperty *prop,
- gchar *name,
+ const gchar *name,
IndependentProperty *req_prop)
{
insert_indep_prop (prop->required_indep_props, name, req_prop);
@@ -351,21 +351,21 @@ insert_indep_prop_to_indep (IndependentProperty *prop,
static void
add_dep_prop (IndependentProperty *indep,
- gchar *name)
+ const gchar *name)
{
hash_table_add (indep->required_dep_props, g_strdup (name));
}
static IndependentProperty *
-create_prop_with_required_dep_props (gboolean required,
- gchar *dep_prop,
+create_prop_with_required_dep_props (gboolean required,
+ const gchar *dep_prop,
...)
{
IndependentProperty *indep = independent_property_new (required);
if (dep_prop != NULL) {
va_list var_args;
- gchar *name = dep_prop;
+ const gchar *name = dep_prop;
va_start (var_args, dep_prop);
do {
@@ -716,9 +716,9 @@ fragment_util_check_fragments (DocNode *original,
/* If the child element is title or class,
* it must not be set to empty or removed.
*/
- if (g_strrstr (current_doc->children->children->name,
+ if (g_strrstr ((char *) current_doc->children->children->name,
"title") != NULL ||
- g_strrstr (current_doc->children->children->name,
+ g_strrstr ((char *) current_doc->children->children->name,
"class") != NULL) {
/* If the new tag has no corresponding title or class element */
if (new_doc->children->children == NULL) {
diff --git a/libgupnp-av/gupnp-didl-lite-contributor.c b/libgupnp-av/gupnp-didl-lite-contributor.c
index 005737d..b13ec95 100644
--- a/libgupnp-av/gupnp-didl-lite-contributor.c
+++ b/libgupnp-av/gupnp-didl-lite-contributor.c
@@ -31,6 +31,7 @@
#include <libgupnp/gupnp.h>
#include "gupnp-didl-lite-contributor.h"
+#include "gupnp-didl-lite-contributor-private.h"
#include "xml-util.h"
G_DEFINE_TYPE (GUPnPDIDLLiteContributor,
@@ -332,8 +333,6 @@ GUPnPDIDLLiteContributor *
gupnp_didl_lite_contributor_new_from_xml (xmlNode *xml_node,
GUPnPXMLDoc *xml_doc)
{
- GUPnPDIDLLiteContributor *contributor;
-
return g_object_new (GUPNP_TYPE_DIDL_LITE_CONTRIBUTOR,
"xml-node", xml_node,
"xml-doc", xml_doc,
diff --git a/libgupnp-av/gupnp-didl-lite-createclass.c b/libgupnp-av/gupnp-didl-lite-createclass.c
index f7210c0..6a01370 100644
--- a/libgupnp-av/gupnp-didl-lite-createclass.c
+++ b/libgupnp-av/gupnp-didl-lite-createclass.c
@@ -32,6 +32,7 @@
#include <string.h>
#include "gupnp-didl-lite-createclass.h"
+#include "gupnp-didl-lite-createclass-private.h"
#include "xml-util.h"
G_DEFINE_TYPE (GUPnPDIDLLiteCreateClass,
@@ -416,8 +417,6 @@ GUPnPDIDLLiteCreateClass *
gupnp_didl_lite_create_class_new_from_xml (xmlNode *xml_node,
GUPnPXMLDoc *xml_doc)
{
- GUPnPDIDLLiteCreateClass *create_class;
-
return g_object_new (GUPNP_TYPE_DIDL_LITE_CREATE_CLASS,
"xml-node", xml_node,
"xml-doc", xml_doc,
diff --git a/libgupnp-av/gupnp-didl-lite-descriptor.c b/libgupnp-av/gupnp-didl-lite-descriptor.c
index d185c04..5389c36 100644
--- a/libgupnp-av/gupnp-didl-lite-descriptor.c
+++ b/libgupnp-av/gupnp-didl-lite-descriptor.c
@@ -30,6 +30,7 @@
#include <string.h>
#include "gupnp-didl-lite-descriptor.h"
+#include "gupnp-didl-lite-descriptor-private.h"
#include "xml-util.h"
G_DEFINE_TYPE (GUPnPDIDLLiteDescriptor,
@@ -315,8 +316,6 @@ GUPnPDIDLLiteDescriptor *
gupnp_didl_lite_descriptor_new_from_xml (xmlNode *xml_node,
GUPnPXMLDoc *xml_doc)
{
- GUPnPDIDLLiteDescriptor *descriptor;
-
return g_object_new (GUPNP_TYPE_DIDL_LITE_DESCRIPTOR,
"xml-node", xml_node,
"xml-doc", xml_doc,
diff --git a/libgupnp-av/gupnp-didl-lite-descriptor.h b/libgupnp-av/gupnp-didl-lite-descriptor.h
index 2b685d6..d2942e7 100644
--- a/libgupnp-av/gupnp-didl-lite-descriptor.h
+++ b/libgupnp-av/gupnp-didl-lite-descriptor.h
@@ -72,6 +72,9 @@ typedef struct {
void (* _gupnp_reserved4) (void);
} GUPnPDIDLLiteDescriptorClass;
+GUPnPDIDLLiteDescriptor *
+gupnp_didl_lite_descriptor_new (void);
+
xmlNode *
gupnp_didl_lite_descriptor_get_xml_node (GUPnPDIDLLiteDescriptor *descriptor);
diff --git a/libgupnp-av/gupnp-didl-lite-parser.c b/libgupnp-av/gupnp-didl-lite-parser.c
index c11340e..cf6a6fe 100644
--- a/libgupnp-av/gupnp-didl-lite-parser.c
+++ b/libgupnp-av/gupnp-didl-lite-parser.c
@@ -228,7 +228,6 @@ gupnp_didl_lite_parser_parse_didl_recursive (GUPnPDIDLLiteParser *parser,
{
xmlDoc *doc;
xmlNode *element;
- xmlNs **ns_list;
xmlNs *upnp_ns = NULL;
xmlNs *dc_ns = NULL;
xmlNs *dlna_ns = NULL;
diff --git a/libgupnp-av/gupnp-didl-lite-resource.c b/libgupnp-av/gupnp-didl-lite-resource.c
index eddabfc..b0744b7 100644
--- a/libgupnp-av/gupnp-didl-lite-resource.c
+++ b/libgupnp-av/gupnp-didl-lite-resource.c
@@ -859,8 +859,6 @@ gupnp_didl_lite_resource_new_from_xml (xmlNode *xml_node,
xmlNs *dlna_ns,
xmlNs *pv_ns)
{
- GUPnPDIDLLiteResource *resource;
-
return g_object_new (GUPNP_TYPE_DIDL_LITE_RESOURCE,
"xml-node", xml_node,
"xml-doc", xml_doc,
@@ -1924,7 +1922,7 @@ gupnp_didl_lite_resource_set_subtitle_file_uri
xmlSetNsProp (resource->priv->xml_node,
resource->priv->pv_ns,
(unsigned char *) "subtitleFileUri",
- uri);
+ (unsigned char *) uri);
}
g_object_notify (G_OBJECT (resource), "subtitle-file-uri");
@@ -1961,7 +1959,7 @@ gupnp_didl_lite_resource_set_subtitle_file_type
xmlSetNsProp (resource->priv->xml_node,
resource->priv->pv_ns,
(unsigned char *) "subtitleFileType",
- type);
+ (unsigned char *) type);
}
g_object_notify (G_OBJECT (resource), "subtitle-file-type");
diff --git a/libgupnp-av/gupnp-media-collection.c b/libgupnp-av/gupnp-media-collection.c
index e00f82c..f55ed41 100644
--- a/libgupnp-av/gupnp-media-collection.c
+++ b/libgupnp-av/gupnp-media-collection.c
@@ -503,12 +503,12 @@ gupnp_media_collection_get_author (GUPnPMediaCollection *collection)
GUPnPDIDLLiteItem *
gupnp_media_collection_add_item (GUPnPMediaCollection *collection)
{
+ GUPnPDIDLLiteItem *item = NULL;
+
g_return_val_if_fail (collection != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), NULL);
g_return_val_if_fail (collection->priv->mutable, NULL);
- GUPnPDIDLLiteItem *item = NULL;
-
if (collection->priv->container != NULL)
item = gupnp_didl_lite_writer_add_container_child_item
(collection->priv->writer,
@@ -566,11 +566,11 @@ gupnp_media_collection_get_string (GUPnPMediaCollection *collection)
GList *
gupnp_media_collection_get_items (GUPnPMediaCollection *collection)
{
+ GList *tmp = NULL, *iter;
+
g_return_val_if_fail (collection != NULL, NULL);
g_return_val_if_fail (GUPNP_IS_MEDIA_COLLECTION (collection), NULL);
- GList *tmp = NULL, *iter;
-
for (iter = collection->priv->items; iter != NULL; iter = iter->next) {
tmp = g_list_prepend (tmp, g_object_ref (iter->data));
}
diff --git a/libgupnp-av/gupnp-protocol-info.c b/libgupnp-av/gupnp-protocol-info.c
index 8888e56..19e5a07 100644
--- a/libgupnp-av/gupnp-protocol-info.c
+++ b/libgupnp-av/gupnp-protocol-info.c
@@ -603,7 +603,7 @@ gupnp_protocol_info_class_init (GUPnPProtocolInfoClass *klass)
* Return value: A new #GUPnPProtocolInfo object. Unref after usage.
**/
GUPnPProtocolInfo *
-gupnp_protocol_info_new ()
+gupnp_protocol_info_new (void)
{
return g_object_new (GUPNP_TYPE_PROTOCOL_INFO,
NULL);
diff --git a/libgupnp-av/gupnp-search-criteria-parser.c b/libgupnp-av/gupnp-search-criteria-parser.c
index c6fb141..46635b5 100644
--- a/libgupnp-av/gupnp-search-criteria-parser.c
+++ b/libgupnp-av/gupnp-search-criteria-parser.c
@@ -179,13 +179,13 @@ gupnp_search_criteria_parser_init (GUPnPSearchCriteriaParser *parser)
/* Set up GScanner */
parser->priv->scanner = g_scanner_new (NULL);
- parser->priv->scanner->config->cset_skip_characters = " \t\n\r\012"
+ parser->priv->scanner->config->cset_skip_characters = (char *)" \t\n\r\012"
"\013\014\015";
parser->priv->scanner->config->scan_identifier_1char = TRUE;
- parser->priv->scanner->config->cset_identifier_first = G_CSET_a_2_z
+ parser->priv->scanner->config->cset_identifier_first = (char *) G_CSET_a_2_z
"_*<>=!@"
G_CSET_A_2_Z;
- parser->priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z
+ parser->priv->scanner->config->cset_identifier_nth = (char *)G_CSET_a_2_z
"_0123456789=:@"
G_CSET_A_2_Z
G_CSET_LATINS
diff --git a/libgupnp-av/gvalue-util.c b/libgupnp-av/gvalue-util.c
index 1342ddc..daece3b 100644
--- a/libgupnp-av/gvalue-util.c
+++ b/libgupnp-av/gvalue-util.c
@@ -111,8 +111,6 @@ gvalue_util_set_value_from_string (GValue *value,
g_ascii_strcasecmp (str, "no") == 0)
g_value_set_boolean (value, FALSE);
else {
- int i;
-
i = atoi (str);
g_value_set_boolean (value, i ? TRUE : FALSE);
}
diff --git a/libgupnp-av/xml-util.c b/libgupnp-av/xml-util.c
index 951cd01..d1a55fb 100644
--- a/libgupnp-av/xml-util.c
+++ b/libgupnp-av/xml-util.c
@@ -29,8 +29,8 @@
typedef struct _GUPnPXMLNamespaceDescription
{
- char *uri;
- char *prefix;
+ const char *uri;
+ const char *prefix;
} GUPnPXMLNamespaceDescription;
@@ -41,7 +41,7 @@ static GUPnPXMLNamespaceDescription gupnp_xml_namespaces[] =
{ "urn:schemas-dlna-org:metadata-1-0/", "dlna" },
{ "http://www.pv.com/pvns/", "pv" },
{ "urn:schemas-upnp-org:metadata-1-0/upnp/", "upnp" },
- NULL
+ { NULL }
};
xmlNode *
diff --git a/m4/ax_append_compile_flags.m4 b/m4/ax_append_compile_flags.m4
new file mode 100644
index 0000000..dc7b866
--- /dev/null
+++ b/m4/ax_append_compile_flags.m4
@@ -0,0 +1,65 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_append_compile_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_APPEND_COMPILE_FLAGS([FLAG1 FLAG2 ...], [FLAGS-VARIABLE], [EXTRA-FLAGS])
+#
+# DESCRIPTION
+#
+# For every FLAG1, FLAG2 it is checked whether the compiler works with the
+# flag. If it does, the flag is added FLAGS-VARIABLE
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. During the check the flag is always added to the
+# current language's flags.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# NOTE: This macro depends on the AX_APPEND_FLAG and
+# AX_CHECK_COMPILE_FLAG. Please keep this macro in sync with
+# AX_APPEND_LINK_FLAGS.
+#
+# LICENSE
+#
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_APPEND_COMPILE_FLAGS],
+[AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+for flag in $1; do
+ AX_CHECK_COMPILE_FLAG([$flag], [AX_APPEND_FLAG([$flag], [$2])], [], [$3])
+done
+])dnl AX_APPEND_COMPILE_FLAGS
diff --git a/m4/ax_append_flag.m4 b/m4/ax_append_flag.m4
new file mode 100644
index 0000000..aeab899
--- /dev/null
+++ b/m4/ax_append_flag.m4
@@ -0,0 +1,71 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_append_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_APPEND_FLAG(FLAG, [FLAGS-VARIABLE])
+#
+# DESCRIPTION
+#
+# FLAG is appended to the FLAGS-VARIABLE shell variable, with a space
+# added in between.
+#
+# If FLAGS-VARIABLE is not specified, the current language's flags (e.g.
+# CFLAGS) is used. FLAGS-VARIABLE is not changed if it already contains
+# FLAG. If FLAGS-VARIABLE is unset in the shell, it is set to exactly
+# FLAG.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 5
+
+AC_DEFUN([AX_APPEND_FLAG],
+[dnl
+AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_SET_IF
+AS_VAR_PUSHDEF([FLAGS], [m4_default($2,_AC_LANG_PREFIX[FLAGS])])
+AS_VAR_SET_IF(FLAGS,[
+ AS_CASE([" AS_VAR_GET(FLAGS) "],
+ [*" $1 "*], [AC_RUN_LOG([: FLAGS already contains $1])],
+ [
+ AS_VAR_APPEND(FLAGS," $1")
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
+ ],
+ [
+ AS_VAR_SET(FLAGS,[$1])
+ AC_RUN_LOG([: FLAGS="$FLAGS"])
+ ])
+AS_VAR_POPDEF([FLAGS])dnl
+])dnl AX_APPEND_FLAG
diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4
new file mode 100644
index 0000000..ca36397
--- /dev/null
+++ b/m4/ax_check_compile_flag.m4
@@ -0,0 +1,74 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT])
+#
+# DESCRIPTION
+#
+# Check whether the given FLAG works with the current language's compiler
+# or gives an error. (Warnings, however, are ignored)
+#
+# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
+# success/failure.
+#
+# If EXTRA-FLAGS is defined, it is added to the current language's default
+# flags (e.g. CFLAGS) when the check is done. The check is thus made with
+# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to
+# force the compiler to issue an error when a bad flag is given.
+#
+# INPUT gives an alternative input source to AC_COMPILE_IFELSE.
+#
+# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this
+# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG.
+#
+# LICENSE
+#
+# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
+# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com>
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by the
+# Free Software Foundation, either version 3 of the License, or (at your
+# option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
+# Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+# As a special exception, the respective Autoconf Macro's copyright owner
+# gives unlimited permission to copy, distribute and modify the configure
+# scripts that are the output of Autoconf when processing the Macro. You
+# need not follow the terms of the GNU General Public License when using
+# or distributing such scripts, even though portions of the text of the
+# Macro appear in them. The GNU General Public License (GPL) does govern
+# all other use of the material that constitutes the Autoconf Macro.
+#
+# This special exception to the GPL applies to versions of the Autoconf
+# Macro released by the Autoconf Archive. When you make and distribute a
+# modified version of the Autoconf Macro, you may extend this special
+# exception to the GPL to apply to your modified version as well.
+
+#serial 4
+
+AC_DEFUN([AX_CHECK_COMPILE_FLAG],
+[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF
+AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl
+AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [
+ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS
+ _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1"
+ AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])],
+ [AS_VAR_SET(CACHEVAR,[yes])],
+ [AS_VAR_SET(CACHEVAR,[no])])
+ _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags])
+AS_VAR_IF(CACHEVAR,yes,
+ [m4_default([$2], :)],
+ [m4_default([$3], :)])
+AS_VAR_POPDEF([CACHEVAR])dnl
+])dnl AX_CHECK_COMPILE_FLAGS
diff --git a/m4/ax_check_enable_debug.m4 b/m4/ax_check_enable_debug.m4
new file mode 100644
index 0000000..37add91
--- /dev/null
+++ b/m4/ax_check_enable_debug.m4
@@ -0,0 +1,113 @@
+# ===========================================================================
+# http://autoconf-archive.cryp.to/ax_check_enable_debug.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# Check for the presence of an --enable-debug option to configure and
+# allow/avoid compiled debugging flags appropriately.
+#
+# AX_CHECK_ENABLE_DEBUG([enable by default=yes/info/profile/no],
+# [ENABLE DEBUG VARIABLES …],
+# [DISABLE DEBUG VARIABLES NDEBUG …])
+#
+# DESCRIPTION
+#
+# Check for the presence of an --enable-debug option to configure, with the
+# specified default value used when the option is not present. Return the
+# value in the variable $ax_enable_debug.
+#
+# Specifying 'yes' adds '-g -O0' to the compilation flags for all languages.
+# Specifying 'info' adds '-g' to the compilation flags. Specifying 'profile'
+# adds '-g -pg' to the compilation flags and '-pg' to the linking flags.
+# Otherwise, nothing is added.
+#
+# Define the variables listed in the second argument if debug is enabled,
+# defaulting to no variables. Defines the variables listed in the third
+# argument if debug is disabled, defaulting to NDEBUG. All lists of
+# variables should be space-separated.
+#
+# If debug is not enabled, ensure AC_PROG_* will not add debugging flags.
+# Should be invoked prior to any AC_PROG_* compiler checks.
+#
+# LAST MODIFICATION
+#
+# 2014-05-12
+#
+# COPYLEFT
+#
+# Copyright (c) 2011 Rhys Ulerich <rhys.ulerich@gmail.com>
+# Copyright © 2014 Philip Withnall <philip@tecnocode.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+AC_DEFUN([AX_CHECK_ENABLE_DEBUG],[
+ AC_BEFORE([$0],[AC_PROG_CC])dnl
+ AC_BEFORE([$0],[AC_PROG_CXX])dnl
+ AC_BEFORE([$0],[AC_PROG_F77])dnl
+ AC_BEFORE([$0],[AC_PROG_FC])dnl
+
+ AC_MSG_CHECKING(whether to enable debugging)
+
+ m4_define(ax_enable_debug_default,[m4_tolower(m4_normalize(ifelse([$1],,[no],[$1])))])
+ m4_define(ax_enable_debug_vars,[m4_normalize(ifelse([$2],,,[$2]))])
+ m4_define(ax_disable_debug_vars,[m4_normalize(ifelse([$3],,[NDEBUG],[$3]))])
+
+ AC_ARG_ENABLE(debug,
+ [AS_HELP_STRING([--enable-debug]@<:@=ax_enable_debug_default@:>@,[compile with debugging; one of yes/info/profile/no])],
+ [],enable_debug=ax_enable_debug_default)
+ if test "x$enable_debug" = "xyes" || test "x$enable_debug" = "x"; then
+ AC_MSG_RESULT(yes)
+ CFLAGS="${CFLAGS} -g -O0"
+ CXXFLAGS="${CXXFLAGS} -g -O0"
+ FFLAGS="${FFLAGS} -g -O0"
+ FCFLAGS="${FCFLAGS} -g -O0"
+ OBJCFLAGS="${OBJCFLAGS} -g -O0"
+
+ dnl Define various variables if debugging is enabled.
+ m4_map_args_w(ax_enable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is enabled])])
+ else
+ if test "x$enable_debug" = "xinfo"; then
+ AC_MSG_RESULT(info)
+ CFLAGS="${CFLAGS} -g"
+ CXXFLAGS="${CXXFLAGS} -g"
+ FFLAGS="${FFLAGS} -g"
+ FCFLAGS="${FCFLAGS} -g"
+ OBJCFLAGS="${OBJCFLAGS} -g"
+ elif test "x$enable_debug" = "xprofile"; then
+ AC_MSG_RESULT(profile)
+ CFLAGS="${CFLAGS} -g -pg"
+ CXXFLAGS="${CXXFLAGS} -g -pg"
+ FFLAGS="${FFLAGS} -g -pg"
+ FCFLAGS="${FCFLAGS} -g -pg"
+ OBJCFLAGS="${OBJCFLAGS} -g -pg"
+ LDFLAGS="${LDFLAGS} -pg"
+ else
+ AC_MSG_RESULT(no)
+ dnl Ensure AC_PROG_CC/CXX/F77/FC/OBJC will not enable debug flags
+ dnl by setting any unset environment flag variables
+ if test "x${CFLAGS+set}" != "xset"; then
+ CFLAGS=""
+ fi
+ if test "x${CXXFLAGS+set}" != "xset"; then
+ CXXFLAGS=""
+ fi
+ if test "x${FFLAGS+set}" != "xset"; then
+ FFLAGS=""
+ fi
+ if test "x${FCFLAGS+set}" != "xset"; then
+ FCFLAGS=""
+ fi
+ if test "x${OBJCFLAGS+set}" != "xset"; then
+ OBJCFLAGS=""
+ fi
+ fi
+
+ dnl Define various variables if debugging is disabled.
+ dnl assert.h is a NOP if NDEBUG is defined, so define it by default.
+ m4_map_args_w(ax_disable_debug_vars, [AC_DEFINE(], [,,[Define if debugging is disabled])])
+ fi
+ ax_enable_debug=$enable_debug
+])
diff --git a/m4/ax_compiler_flags.m4 b/m4/ax_compiler_flags.m4
new file mode 100644
index 0000000..6cfe398
--- /dev/null
+++ b/m4/ax_compiler_flags.m4
@@ -0,0 +1,158 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS([CFLAGS-VARIABLE], [LDFLAGS-VARIABLE], [IS-RELEASE], [EXTRA-BASE-CFLAGS], [EXTRA-YES-CFLAGS], [UNUSED], [UNUSED], [UNUSED], [EXTRA-BASE-LDFLAGS], [EXTRA-YES-LDFLAGS], [UNUSED], [UNUSED], [UNUSED])
+#
+# DESCRIPTION
+#
+# Check for the presence of an --enable-compile-warnings option to
+# configure, defaulting to "error" in normal operation, or "yes" if
+# IS-RELEASE is equal to "yes". Return the value in the variable
+# $ax_enable_compile_warnings.
+#
+# Depending on the value of --enable-compile-warnings, different compiler
+# warnings are checked to see if they work with the current compiler and,
+# if so, are appended to CFLAGS-VARIABLE and LDFLAGS-VARIABLE. This
+# allows a consistent set of baseline compiler warnings to be used across
+# a code base, irrespective of any warnings enabled locally by individual
+# developers. By standardising the warnings used by all developers of a
+# project, the project can commit to a zero-warnings policy, using -Werror
+# to prevent compilation if new warnings are introduced. This makes
+# catching bugs which are flagged by warnings a lot easier.
+#
+# By providing a consistent --enable-compile-warnings argument across all
+# projects using this macro, continuous integration systems can easily be
+# configured the same for all projects. Automated systems or build
+# systems aimed at beginners may want to pass the --disable-Werror
+# argument to unconditionally prevent warnings being fatal.
+#
+# --enable-compile-warnings can take the values:
+#
+# * no: Base compiler warnings only; not even -Wall.
+# * yes: The above, plus a broad range of useful warnings.
+# * error: The above, plus -Werror so that all warnings are fatal.
+# Use --disable-Werror to override this and disable fatal
+# warnings.
+#
+# The set of base and enabled flags can be augmented using the
+# EXTRA-*-CFLAGS and EXTRA-*-LDFLAGS variables, which are tested and
+# appended to the output variable if --enable-compile-warnings is not
+# "no". Flags should not be disabled using these arguments, as the entire
+# point of AX_COMPILER_FLAGS is to enforce a consistent set of useful
+# compiler warnings on code, using warnings which have been chosen for low
+# false positive rates. If a compiler emits false positives for a
+# warning, a #pragma should be used in the code to disable the warning
+# locally. See:
+#
+# https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/Diagnostic-Pragmas.html#Diagnostic-Pragmas
+#
+# The EXTRA-* variables should only be used to supply extra warning flags,
+# and not general purpose compiler flags, as they are controlled by
+# configure options such as --disable-Werror.
+#
+# IS-RELEASE can be used to disable -Werror when making a release, which
+# is useful for those hairy moments when you just want to get the release
+# done as quickly as possible. Set it to "yes" to disable -Werror. By
+# default, it uses the value of $ax_is_release, so if you are using the
+# AX_IS_RELEASE macro, there is no need to pass this parameter. For
+# example:
+#
+# AX_IS_RELEASE([git-directory])
+# AX_COMPILER_FLAGS()
+#
+# CFLAGS-VARIABLE defaults to WARN_CFLAGS, and LDFLAGS-VARIABLE defaults
+# to WARN_LDFLAGS. Both variables are AC_SUBST-ed by this macro, but must
+# be manually added to the CFLAGS and LDFLAGS variables for each target in
+# the code base.
+#
+# If C++ language support is enabled with AC_PROG_CXX, which must occur
+# before this macro in configure.ac, warning flags for the C++ compiler
+# are AC_SUBST-ed as WARN_CXXFLAGS, and must be manually added to the
+# CXXFLAGS variables for each target in the code base. EXTRA-*-CFLAGS can
+# be used to augment the base and enabled flags.
+#
+# Warning flags for g-ir-scanner (from GObject Introspection) are
+# AC_SUBST-ed as WARN_SCANNERFLAGS. This variable must be manually added
+# to the SCANNERFLAGS variable for each GIR target in the code base. If
+# extra g-ir-scanner flags need to be enabled, the AX_COMPILER_FLAGS_GIR
+# macro must be invoked manually.
+#
+# AX_COMPILER_FLAGS may add support for other tools in future, in addition
+# to the compiler and linker. No extra EXTRA-* variables will be added
+# for those tools, and all extra support will still use the single
+# --enable-compile-warnings configure option. For finer grained control
+# over the flags for individual tools, use AX_COMPILER_FLAGS_CFLAGS,
+# AX_COMPILER_FLAGS_LDFLAGS and AX_COMPILER_FLAGS_* for new tools.
+#
+# The UNUSED variables date from a previous version of this macro, and are
+# automatically appended to the preceding non-UNUSED variable. They should
+# be left empty in new uses of the macro.
+#
+# LICENSE
+#
+# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+# Copyright (c) 2015 David King <amigadave@amigadave.com>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 13
+
+# _AX_COMPILER_FLAGS_LANG([LANGNAME])
+m4_defun([_AX_COMPILER_FLAGS_LANG],
+[m4_ifdef([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [],
+ [m4_define([_AX_COMPILER_FLAGS_LANG_]$1[_enabled], [])dnl
+ AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_]$1[FLAGS])])dnl
+])
+
+AC_DEFUN([AX_COMPILER_FLAGS],[
+ # C support is enabled by default.
+ _AX_COMPILER_FLAGS_LANG([C])
+ # Only enable C++ support if AC_PROG_CXX is called. The redefinition of
+ # AC_PROG_CXX is so that a fatal error is emitted if this macro is called
+ # before AC_PROG_CXX, which would otherwise cause no C++ warnings to be
+ # checked.
+ AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [_AX_COMPILER_FLAGS_LANG([CXX])],
+ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[_AX_COMPILER_FLAGS_LANG([CXX])])])
+ AX_REQUIRE_DEFINED([AX_COMPILER_FLAGS_LDFLAGS])
+
+ # Default value for IS-RELEASE is $ax_is_release
+ ax_compiler_flags_is_release=m4_tolower(m4_normalize(ifelse([$3],,
+ [$ax_is_release],
+ [$3])))
+
+ AC_ARG_ENABLE([compile-warnings],
+ AS_HELP_STRING([--enable-compile-warnings=@<:@no/yes/error@:>@],
+ [Enable compiler warnings and errors]),,
+ [AS_IF([test "$ax_compiler_flags_is_release" = "yes"],
+ [enable_compile_warnings="yes"],
+ [enable_compile_warnings="error"])])
+ AC_ARG_ENABLE([Werror],
+ AS_HELP_STRING([--disable-Werror],
+ [Unconditionally make all compiler warnings non-fatal]),,
+ [enable_Werror=maybe])
+
+ # Return the user's chosen warning level
+ AS_IF([test "$enable_Werror" = "no" -a \
+ "$enable_compile_warnings" = "error"],[
+ enable_compile_warnings="yes"
+ ])
+
+ ax_enable_compile_warnings=$enable_compile_warnings
+
+ AX_COMPILER_FLAGS_CFLAGS([$1],[$ax_compiler_flags_is_release],
+ [$4],[$5 $6 $7 $8])
+ m4_ifdef([_AX_COMPILER_FLAGS_LANG_CXX_enabled],
+ [AX_COMPILER_FLAGS_CXXFLAGS([WARN_CXXFLAGS],
+ [$ax_compiler_flags_is_release],
+ [$4],[$5 $6 $7 $8])])
+ AX_COMPILER_FLAGS_LDFLAGS([$2],[$ax_compiler_flags_is_release],
+ [$9],[$10 $11 $12 $13])
+ AX_COMPILER_FLAGS_GIR([WARN_SCANNERFLAGS],[$ax_compiler_flags_is_release])
+])dnl AX_COMPILER_FLAGS
diff --git a/m4/ax_compiler_flags_cflags.m4 b/m4/ax_compiler_flags_cflags.m4
new file mode 100644
index 0000000..f470f8f
--- /dev/null
+++ b/m4/ax_compiler_flags_cflags.m4
@@ -0,0 +1,133 @@
+# ============================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_cflags.html
+# ============================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS_CFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS])
+#
+# DESCRIPTION
+#
+# Add warning flags for the C compiler to VARIABLE, which defaults to
+# WARN_CFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be
+# manually added to the CFLAGS variable for each target in the code base.
+#
+# This macro depends on the environment set up by AX_COMPILER_FLAGS.
+# Specifically, it uses the value of $ax_enable_compile_warnings to decide
+# which flags to enable.
+#
+# LICENSE
+#
+# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 11
+
+AC_DEFUN([AX_COMPILER_FLAGS_CFLAGS],[
+ AC_REQUIRE([AC_PROG_SED])
+ AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS])
+ AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+ AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+
+ # Variable names
+ m4_define(ax_warn_cflags_variable,
+ [m4_normalize(ifelse([$1],,[WARN_CFLAGS],[$1]))])
+
+ AC_LANG_PUSH([C])
+
+ # Always pass -Werror=unknown-warning-option to get Clang to fail on bad
+ # flags, otherwise they are always appended to the warn_cflags variable, and
+ # Clang warns on them for every compilation unit.
+ # If this is passed to GCC, it will explode, so the flag must be enabled
+ # conditionally.
+ AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
+ ax_compiler_flags_test="-Werror=unknown-warning-option"
+ ],[
+ ax_compiler_flags_test=""
+ ])
+
+ # Base flags
+ AX_APPEND_COMPILE_FLAGS([ dnl
+ -fno-strict-aliasing dnl
+ $3 dnl
+ ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
+
+ AS_IF([test "$ax_enable_compile_warnings" != "no"],[
+ # "yes" flags
+ AX_APPEND_COMPILE_FLAGS([ dnl
+ -Wall dnl
+ -Wextra dnl
+ -Wundef dnl
+ -Wnested-externs dnl
+ -Wwrite-strings dnl
+ -Wpointer-arith dnl
+ -Wmissing-declarations dnl
+ -Wmissing-prototypes dnl
+ -Wstrict-prototypes dnl
+ -Wredundant-decls dnl
+ -Wno-unused-parameter dnl
+ -Wno-missing-field-initializers dnl
+ -Wdeclaration-after-statement dnl
+ -Wformat=2 dnl
+ -Wold-style-definition dnl
+ -Wcast-align dnl
+ -Wformat-nonliteral dnl
+ -Wformat-security dnl
+ -Wsign-compare dnl
+ -Wstrict-aliasing dnl
+ -Wshadow dnl
+ -Winline dnl
+ -Wpacked dnl
+ -Wmissing-format-attribute dnl
+ -Wmissing-noreturn dnl
+ -Winit-self dnl
+ -Wredundant-decls dnl
+ -Wmissing-include-dirs dnl
+ -Wunused-but-set-variable dnl
+ -Warray-bounds dnl
+ -Wimplicit-function-declaration dnl
+ -Wreturn-type dnl
+ -Wswitch-enum dnl
+ -Wswitch-default dnl
+ $4 dnl
+ $5 dnl
+ $6 dnl
+ $7 dnl
+ ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
+ ])
+ AS_IF([test "$ax_enable_compile_warnings" = "error"],[
+ # "error" flags; -Werror has to be appended unconditionally because
+ # it's not possible to test for
+ #
+ # suggest-attribute=format is disabled because it gives too many false
+ # positives
+ AX_APPEND_FLAG([-Werror],ax_warn_cflags_variable)
+
+ AX_APPEND_COMPILE_FLAGS([ dnl
+ -Wno-suggest-attribute=format dnl
+ ],ax_warn_cflags_variable,[$ax_compiler_flags_test])
+ ])
+
+ # In the flags below, when disabling specific flags, always add *both*
+ # -Wno-foo and -Wno-error=foo. This fixes the situation where (for example)
+ # we enable -Werror, disable a flag, and a build bot passes CFLAGS=-Wall,
+ # which effectively turns that flag back on again as an error.
+ for flag in $ax_warn_cflags_variable; do
+ AS_CASE([$flag],
+ [-Wno-*=*],[],
+ [-Wno-*],[
+ AX_APPEND_COMPILE_FLAGS([-Wno-error=$(AS_ECHO([$flag]) | $SED 's/^-Wno-//')],
+ ax_warn_cflags_variable,
+ [$ax_compiler_flags_test])
+ ])
+ done
+
+ AC_LANG_POP([C])
+
+ # Substitute the variables
+ AC_SUBST(ax_warn_cflags_variable)
+])dnl AX_COMPILER_FLAGS
diff --git a/m4/ax_compiler_flags_gir.m4 b/m4/ax_compiler_flags_gir.m4
new file mode 100644
index 0000000..180f50d
--- /dev/null
+++ b/m4/ax_compiler_flags_gir.m4
@@ -0,0 +1,60 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_gir.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS_GIR([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS])
+#
+# DESCRIPTION
+#
+# Add warning flags for the g-ir-scanner (from GObject Introspection) to
+# VARIABLE, which defaults to WARN_SCANNERFLAGS. VARIABLE is AC_SUBST-ed
+# by this macro, but must be manually added to the SCANNERFLAGS variable
+# for each GIR target in the code base.
+#
+# This macro depends on the environment set up by AX_COMPILER_FLAGS.
+# Specifically, it uses the value of $ax_enable_compile_warnings to decide
+# which flags to enable.
+#
+# LICENSE
+#
+# Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 4
+
+AC_DEFUN([AX_COMPILER_FLAGS_GIR],[
+ AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+
+ # Variable names
+ m4_define(ax_warn_scannerflags_variable,
+ [m4_normalize(ifelse([$1],,[WARN_SCANNERFLAGS],[$1]))])
+
+ # Base flags
+ AX_APPEND_FLAG([$3],ax_warn_scannerflags_variable)
+
+ AS_IF([test "$ax_enable_compile_warnings" != "no"],[
+ # "yes" flags
+ AX_APPEND_FLAG([ dnl
+ --warn-all dnl
+ $4 dnl
+ $5 dnl
+ $6 dnl
+ $7 dnl
+ ],ax_warn_scannerflags_variable)
+ ])
+ AS_IF([test "$ax_enable_compile_warnings" = "error"],[
+ # "error" flags
+ AX_APPEND_FLAG([ dnl
+ --warn-error dnl
+ ],ax_warn_scannerflags_variable)
+ ])
+
+ # Substitute the variables
+ AC_SUBST(ax_warn_scannerflags_variable)
+])dnl AX_COMPILER_FLAGS
diff --git a/m4/ax_compiler_flags_ldflags.m4 b/m4/ax_compiler_flags_ldflags.m4
new file mode 100644
index 0000000..f393ba4
--- /dev/null
+++ b/m4/ax_compiler_flags_ldflags.m4
@@ -0,0 +1,75 @@
+# =============================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_compiler_flags_ldflags.html
+# =============================================================================
+#
+# SYNOPSIS
+#
+# AX_COMPILER_FLAGS_LDFLAGS([VARIABLE], [IS-RELEASE], [EXTRA-BASE-FLAGS], [EXTRA-YES-FLAGS])
+#
+# DESCRIPTION
+#
+# Add warning flags for the linker to VARIABLE, which defaults to
+# WARN_LDFLAGS. VARIABLE is AC_SUBST-ed by this macro, but must be
+# manually added to the LDFLAGS variable for each target in the code base.
+#
+# This macro depends on the environment set up by AX_COMPILER_FLAGS.
+# Specifically, it uses the value of $ax_enable_compile_warnings to decide
+# which flags to enable.
+#
+# LICENSE
+#
+# Copyright (c) 2014, 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 4
+
+AC_DEFUN([AX_COMPILER_FLAGS_LDFLAGS],[
+ AX_REQUIRE_DEFINED([AX_APPEND_COMPILE_FLAGS])
+ AX_REQUIRE_DEFINED([AX_APPEND_FLAG])
+ AX_REQUIRE_DEFINED([AX_CHECK_COMPILE_FLAG])
+
+ # Variable names
+ m4_define(ax_warn_ldflags_variable,
+ [m4_normalize(ifelse([$1],,[WARN_LDFLAGS],[$1]))])
+
+ # Always pass -Werror=unknown-warning-option to get Clang to fail on bad
+ # flags, otherwise they are always appended to the warn_ldflags variable,
+ # and Clang warns on them for every compilation unit.
+ # If this is passed to GCC, it will explode, so the flag must be enabled
+ # conditionally.
+ AX_CHECK_COMPILE_FLAG([-Werror=unknown-warning-option],[
+ ax_compiler_flags_test="-Werror=unknown-warning-option"
+ ],[
+ ax_compiler_flags_test=""
+ ])
+
+ # Base flags
+ AX_APPEND_COMPILE_FLAGS([ dnl
+ -Wl,--no-as-needed dnl
+ $3 dnl
+ ],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
+
+ AS_IF([test "$ax_enable_compile_warnings" != "no"],[
+ # "yes" flags
+ AX_APPEND_COMPILE_FLAGS([$4 $5 $6 $7],
+ ax_warn_ldflags_variable,
+ [$ax_compiler_flags_test])
+ ])
+ AS_IF([test "$ax_enable_compile_warnings" = "error"],[
+ # "error" flags; -Werror has to be appended unconditionally because
+ # it's not possible to test for
+ #
+ # suggest-attribute=format is disabled because it gives too many false
+ # positives
+ AX_APPEND_COMPILE_FLAGS([ dnl
+ -Wl,--fatal-warnings dnl
+ ],ax_warn_ldflags_variable,[$ax_compiler_flags_test])
+ ])
+
+ # Substitute the variables
+ AC_SUBST(ax_warn_ldflags_variable)
+])dnl AX_COMPILER_FLAGS
diff --git a/m4/ax_is_release.m4 b/m4/ax_is_release.m4
new file mode 100644
index 0000000..9ec6746
--- /dev/null
+++ b/m4/ax_is_release.m4
@@ -0,0 +1,69 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_is_release.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_IS_RELEASE(POLICY)
+#
+# DESCRIPTION
+#
+# Determine whether the code is being configured as a release, or from
+# git. Set the ax_is_release variable to 'yes' or 'no'.
+#
+# If building a release version, it is recommended that the configure
+# script disable compiler errors and debug features, by conditionalising
+# them on the ax_is_release variable. If building from git, these
+# features should be enabled.
+#
+# The POLICY parameter specifies how ax_is_release is determined. It can
+# take the following values:
+#
+# * git-directory: ax_is_release will be 'no' if a '.git' directory exists
+# * minor-version: ax_is_release will be 'no' if the minor version number
+# in $PACKAGE_VERSION is odd; this assumes
+# $PACKAGE_VERSION follows the 'major.minor.micro' scheme
+# * micro-version: ax_is_release will be 'no' if the micro version number
+# in $PACKAGE_VERSION is odd; this assumes
+# $PACKAGE_VERSION follows the 'major.minor.micro' scheme
+# * always: ax_is_release will always be 'yes'
+# * never: ax_is_release will always be 'no'
+#
+# Other policies may be added in future.
+#
+# LICENSE
+#
+# Copyright (c) 2015 Philip Withnall <philip@tecnocode.co.uk>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved.
+
+#serial 3
+
+AC_DEFUN([AX_IS_RELEASE],[
+ AC_BEFORE([AC_INIT],[$0])
+
+ m4_case([$1],
+ [git-directory],[
+ # $is_release = (.git directory does not exist)
+ AS_IF([test -d .git],[ax_is_release=no],[ax_is_release=yes])
+ ],
+ [minor-version],[
+ # $is_release = ($minor_version is even)
+ minor_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
+ AS_IF([test "$(( $minor_version % 2 ))" -ne 0],
+ [ax_is_release=no],[ax_is_release=yes])
+ ],
+ [micro-version],[
+ # $is_release = ($micro_version is even)
+ micro_version=`echo "$PACKAGE_VERSION" | sed 's/[[^.]]*\.[[^.]]*\.\([[^.]]*\).*/\1/'`
+ AS_IF([test "$(( $micro_version % 2 ))" -ne 0],
+ [ax_is_release=no],[ax_is_release=yes])
+ ],
+ [always],[ax_is_release=yes],
+ [never],[ax_is_release=no],
+ [
+ AC_MSG_ERROR([Invalid policy. Valid policies: git-directory, minor-version.])
+ ])
+])
diff --git a/m4/ax_require_defined.m4 b/m4/ax_require_defined.m4
new file mode 100644
index 0000000..cae1111
--- /dev/null
+++ b/m4/ax_require_defined.m4
@@ -0,0 +1,37 @@
+# ===========================================================================
+# http://www.gnu.org/software/autoconf-archive/ax_require_defined.html
+# ===========================================================================
+#
+# SYNOPSIS
+#
+# AX_REQUIRE_DEFINED(MACRO)
+#
+# DESCRIPTION
+#
+# AX_REQUIRE_DEFINED is a simple helper for making sure other macros have
+# been defined and thus are available for use. This avoids random issues
+# where a macro isn't expanded. Instead the configure script emits a
+# non-fatal:
+#
+# ./configure: line 1673: AX_CFLAGS_WARN_ALL: command not found
+#
+# It's like AC_REQUIRE except it doesn't expand the required macro.
+#
+# Here's an example:
+#
+# AX_REQUIRE_DEFINED([AX_CHECK_LINK_FLAG])
+#
+# LICENSE
+#
+# Copyright (c) 2014 Mike Frysinger <vapier@gentoo.org>
+#
+# Copying and distribution of this file, with or without modification, are
+# permitted in any medium without royalty provided the copyright notice
+# and this notice are preserved. This file is offered as-is, without any
+# warranty.
+
+#serial 1
+
+AC_DEFUN([AX_REQUIRE_DEFINED], [dnl
+ m4_ifndef([$1], [m4_fatal([macro ]$1[ is not defined; is a m4 file missing?])])
+])dnl AX_REQUIRE_DEFINED
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cac3776..6f81053 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,7 +2,9 @@ SUBDIRS = gtest
common_cflags = \
$(LIBGUPNP_CFLAGS) \
- -I$(top_srcdir) -Wno-unused-parameters
+ -I$(top_srcdir) \
+ $(WARN_CFLAGS) \
+ -Wno-unused-parameters
common_ldadd = \
$(top_builddir)/libgupnp-av/libgupnp-av-1.0.la \
$(LIBGUPNP_LIBS)
@@ -21,13 +23,16 @@ check_PROGRAMS = \
check_search_SOURCES = check-search.c
check_search_LDADD = $(common_ldadd)
check_search_CFLAGS = $(common_cflags)
+check_search_LDFLAGS = $(WARN_LDFLAGS)
check_feature_list_parser_SOURCES = check-feature-list-parser.c
check_feature_list_parser_LDADD = $(common_ldadd)
check_feature_list_parser_CFLAGS = $(common_cflags)
+check_feature_list_parser_LDFLAGS = $(WARN_LDFLAGS)
fragments_SOURCES = fragments.c
fragments_LDADD = $(common_ldadd)
fragments_CFLAGS = $(common_cflags) -DABS_TOP_SRCDIR="\"$(abs_top_srcdir)\""
+fragments_LDFLAGS = $(WARN_LDFLAGS)
TESTS = $(check_PROGRAMS)
diff --git a/tests/fragments.c b/tests/fragments.c
index 44fb617..b93b439 100644
--- a/tests/fragments.c
+++ b/tests/fragments.c
@@ -85,7 +85,7 @@ get_item (GUPnPDIDLLiteWriter *writer, guint id, guint parent_id)
return object;
}
-static gchar *current_fragments[] = {
+static const gchar *current_fragments[] = {
/* 1 */
"<upnp:class>object.item.audioItem.musicTrack</upnp:class>",
/* 2 */
@@ -96,7 +96,7 @@ static gchar *current_fragments[] = {
"<dc:title>Try a little tenderness</dc:title>"
};
-static gchar *new_fragments[] = {
+static const gchar *new_fragments[] = {
/* 1 */
"<upnp:class>object.item.audioItem.musicTrack</upnp:class>"
"<upnp:genre>Obscure</upnp:genre>",
@@ -141,9 +141,9 @@ int main (void)
object = get_item (writer, 18, 13);
debug_dump (object);
result = gupnp_didl_lite_object_apply_fragments (object,
- current_fragments,
+ (char **) current_fragments,
G_N_ELEMENTS (current_fragments),
- new_fragments,
+ (char **) new_fragments,
G_N_ELEMENTS (new_fragments));
debug_dump (object);
if (result != GUPNP_DIDL_LITE_FRAGMENT_RESULT_OK) {
diff --git a/tests/gtest/Makefile.am b/tests/gtest/Makefile.am
index ff38b80..7f23a87 100644
--- a/tests/gtest/Makefile.am
+++ b/tests/gtest/Makefile.am
@@ -12,17 +12,22 @@ check_PROGRAMS = \
test-cds-last-change-parser
test_regression_SOURCES = test-regression.c
+test_regression_LDFLAGS = $(WARN_LDFLAGS)
test_didl_lite_object_SOURCES = test-didl-lite-object.c
+test_didl_lite_object_LDFLAGS = $(WARN_LDFLAGS)
test_media_collection_SOURCES = \
test-media-collection.c
+test_media_collection_LDFLAGS = $(WARN_LDFLAGS)
test_last_change_parser_SOURCES = \
test-last-change-parser.c
+test_last_change_parser_LDFLAGS = $(WARN_LDFLAGS)
test_cds_last_change_parser_SOURCES = \
test-cds-last-change-parser.c
+test_cds_last_change_parser_LDFLAGS = $(WARN_LDFLAGS)
LDADD = \
$(top_builddir)/libgupnp-av/libgupnp-av-1.0.la \
@@ -31,7 +36,8 @@ LDADD = \
AM_CFLAGS = \
$(LIBGUPNP_CFLAGS) \
-I $(top_srcdir) \
- -DDATA_PATH="\"$(srcdir)\""
+ -DDATA_PATH="\"$(srcdir)\"" \
+ $(WARN_CFLAGS)
EXTRA_DIST = data/cds-last-change/00-cds-last-change.xml \
data/cds-last-change/01-cds-last-change.xml \
diff --git a/tests/gtest/test-didl-lite-object.c b/tests/gtest/test-didl-lite-object.c
index 8b3913c..92f1285 100644
--- a/tests/gtest/test-didl-lite-object.c
+++ b/tests/gtest/test-didl-lite-object.c
@@ -27,20 +27,20 @@ namespace_getters (void)
namespace = gupnp_didl_lite_object_get_upnp_namespace (object);
g_assert (namespace != NULL);
- g_assert_cmpstr (namespace->prefix, ==, "upnp");
+ g_assert_cmpstr ((char *) namespace->prefix, ==, "upnp");
namespace = gupnp_didl_lite_object_get_dlna_namespace (object);
g_assert (namespace != NULL);
- g_assert_cmpstr (namespace->prefix, ==, "dlna");
+ g_assert_cmpstr ((char *) namespace->prefix, ==, "dlna");
namespace = gupnp_didl_lite_object_get_dc_namespace (object);
g_assert (namespace != NULL);
- g_assert_cmpstr (namespace->prefix, ==, "dc");
+ g_assert_cmpstr ((char *) namespace->prefix, ==, "dc");
namespace = gupnp_didl_lite_object_get_pv_namespace (object);
g_assert (namespace != NULL);
- g_assert_cmpstr (namespace->prefix, ==, "pv");
+ g_assert_cmpstr ((char *) namespace->prefix, ==, "pv");
}
int
diff --git a/tests/gtest/test-media-collection.c b/tests/gtest/test-media-collection.c
index 930d872..07b1e23 100644
--- a/tests/gtest/test-media-collection.c
+++ b/tests/gtest/test-media-collection.c
@@ -165,8 +165,8 @@
#define TEST_PARSE_NO_XML "This is just some random text"
-void
-test_didl_collection_construction ()
+static void
+test_didl_collection_construction (void)
{
GUPnPMediaCollection *collection;
@@ -217,8 +217,8 @@ test_didl_collection_construction ()
g_object_unref (collection);
}
-void
-test_didl_collection_parse_flat ()
+static void
+test_didl_collection_parse_flat (void)
{
GUPnPMediaCollection *collection;
GList *items, *it;
@@ -245,8 +245,8 @@ test_didl_collection_parse_flat ()
g_list_free_full (items, (GDestroyNotify) g_object_unref);
}
-void
-test_didl_collection_parse_full ()
+static void
+test_didl_collection_parse_full (void)
{
GUPnPMediaCollection *collection;
GList *items, *it;
@@ -290,8 +290,8 @@ ignore_xml_parse_error (G_GNUC_UNUSED const gchar *log_domain,
return TRUE;
}
-void
-test_didl_collection_parse_invalid ()
+static void
+test_didl_collection_parse_invalid (void)
{
GUPnPMediaCollection *collection;
GList *items;
@@ -304,8 +304,8 @@ test_didl_collection_parse_invalid ()
g_object_unref (collection);
}
-void
-test_didl_collection_create_flat ()
+static void
+test_didl_collection_create_flat (void)
{
GUPnPMediaCollection *collection;
GUPnPDIDLLiteItem *item;
@@ -355,8 +355,8 @@ test_didl_collection_create_flat ()
TEST_CREATE_FLAT);
}
-void
-test_didl_collection_create_full ()
+static void
+test_didl_collection_create_full (void)
{
GUPnPMediaCollection *collection;
GUPnPDIDLLiteItem *item;
@@ -409,8 +409,8 @@ test_didl_collection_create_full ()
TEST_CREATE_FULL);
}
-void
-test_didl_collection_create_reparent ()
+static void
+test_didl_collection_create_reparent (void)
{
GUPnPMediaCollection *collection;
GUPnPDIDLLiteItem *item;