Commit 2cb8ffbe authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

check for pkg.m4.

2001-12-09  Sven Neumann  <sven@gimp.org>

	* autogen.sh: check for pkg.m4.

	* configure.in: removed logic to extract GLIB CFLAGS and LDFLAGS
	from the GTK CFLAGS and LDFLAGS. Use AM_PATH_GLIB_2_0() instead.
	This change will break things on awfully misconfigured systems.
	Simplified the checks and moved version numbers to the top to ease
	maintainance. Check if gtk-doc is suffiently new.

	* app/main.c: removed the GimpConfig test code.

	* app/config/Makefile.am
	* app/config/test-config.c: added a (yet very small) standalone test
	suite for GimpConfig.

	* app/config/gimpconfig.[ch]
	* app/config/gimpconfig-deserialize.[ch]: allow to specify if
	unknown tokens should be stored or should cause a parser error.
	Changed code to store unknown tokens to use a list since a hash
	table seems to be overkill here.
parent 85783edf
2001-12-09 Sven Neumann <sven@gimp.org>
* autogen.sh: check for pkg.m4.
* configure.in: removed logic to extract GLIB CFLAGS and LDFLAGS
from the GTK CFLAGS and LDFLAGS. Use AM_PATH_GLIB_2_0() instead.
This change will break things on awfully misconfigured systems.
Simplified the checks and moved version numbers to the top to ease
maintainance. Check if gtk-doc is suffiently new.
* app/main.c: removed the GimpConfig test code.
* app/config/Makefile.am
* app/config/test-config.c: added a (yet very small) standalone test
suite for GimpConfig.
* app/config/gimpconfig.[ch]
* app/config/gimpconfig-deserialize.[ch]: allow to specify if
unknown tokens should be stored or should cause a parser error.
Changed code to store unknown tokens to use a list since a hash
table seems to be overkill here.
2001-12-09 Sven Neumann <sven@gimp.org>
* app/config/gimpconfig-params.[ch]
......
......@@ -4,3 +4,5 @@ Makefile.in
.libs
*.lo
libappconfig.la
test-config
foorc
......@@ -29,3 +29,14 @@ INCLUDES = @STRIP_BEGIN@ \
$(GLIB_CFLAGS) \
-I$(includedir) \
@STRIP_END@
#
# test programs, not to be installed
#
noinst_PROGRAMS = test-config
test_config_DEPENDENCIES = \
libappconfig.a \
../base/libappbase.a
test_config_LDADD = $(GLIB_LIBS) $(test_config_DEPENDENCIES)
......@@ -64,7 +64,8 @@ static GTokenType gimp_config_deserialize_any (GValue *value,
gboolean
gimp_config_deserialize_properties (GObject *object,
GScanner *scanner)
GScanner *scanner,
gboolean store_unknown_tokens)
{
GObjectClass *klass;
GParamSpec **property_specs;
......@@ -102,11 +103,9 @@ gimp_config_deserialize_properties (GObject *object,
{
next = g_scanner_peek_next_token (scanner);
/* if we expected a symbol, but got an identifier,
try parsing it with gimp_config_deserialize_unknown */
if (next != token &&
! (token == G_TOKEN_SYMBOL && next == G_TOKEN_IDENTIFIER))
! (store_unknown_tokens &&
token == G_TOKEN_SYMBOL && next == G_TOKEN_IDENTIFIER))
{
break;
}
......@@ -165,8 +164,9 @@ gimp_config_deserialize_unknown (GObject *object,
g_scanner_get_next_token (scanner);
gimp_config_add_unknown_token (object,
key, g_strdup (scanner->value.v_string));
gimp_config_add_unknown_token (object, key, scanner->value.v_string);
g_free (key);
return G_TOKEN_RIGHT_PAREN;
}
......
......@@ -24,7 +24,8 @@
gboolean gimp_config_deserialize_properties (GObject *object,
GScanner *scanner);
GScanner *scanner,
gboolean store_unknown_tokens);
#endif /* __GIMP_CONFIG_DESERIALIZE_H__ */
......@@ -30,15 +30,18 @@
#include "gimpconfig-serialize.h"
#include "gimpconfig-deserialize.h"
#define GIMP_CONFIG_UNKNOWN_TOKENS "gimp-config-unknown-tokens"
/*
* The GimpConfig serialization and deserialization interface.
*/
static void gimp_config_iface_init (GimpConfigInterface *gimp_config_iface);
static void gimp_config_iface_serialize (GObject *object,
FILE *file);
static gboolean gimp_config_iface_deserialize (GObject *object,
GScanner *scanner);
GScanner *scanner,
gboolean store_unknown);
GType
......@@ -83,9 +86,12 @@ gimp_config_iface_serialize (GObject *object,
static gboolean
gimp_config_iface_deserialize (GObject *object,
GScanner *scanner)
GScanner *scanner,
gboolean store_unknown)
{
return gimp_config_deserialize_properties (object, scanner);
return gimp_config_deserialize_properties (object,
scanner,
store_unknown);
}
gboolean
......@@ -116,7 +122,8 @@ gimp_config_serialize (GObject *object,
gboolean
gimp_config_deserialize (GObject *object,
const gchar *filename)
const gchar *filename,
gboolean store_unknown)
{
GimpConfigInterface *gimp_config_iface;
gint fd;
......@@ -143,7 +150,7 @@ gimp_config_deserialize (GObject *object,
g_scanner_input_file (scanner, fd);
scanner->input_name = filename;
success = gimp_config_iface->deserialize (object, scanner);
success = gimp_config_iface->deserialize (object, scanner, store_unknown);
g_scanner_destroy (scanner);
close (fd);
......@@ -151,80 +158,135 @@ gimp_config_deserialize (GObject *object,
return success;
}
/*
* Code to store and lookup unknown tokens (string key/value pairs).
*/
#define GIMP_CONFIG_UNKNOWN_TOKENS "gimp-config-unknown-tokens"
typedef struct
{
gchar *key;
gchar *value;
} GimpConfigToken;
static void gimp_config_destroy_unknown_tokens (GSList *unknown_tokens);
void
gimp_config_add_unknown_token (GObject *object,
gchar *key,
gchar *value)
gimp_config_add_unknown_token (GObject *object,
const gchar *key,
const gchar *value)
{
GHashTable *unknown_tokens;
GimpConfigToken *token;
GSList *unknown_tokens;
GSList *last;
GSList *list;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (key != NULL);
g_return_if_fail (value != NULL);
unknown_tokens =
(GHashTable *) g_object_get_data (object, GIMP_CONFIG_UNKNOWN_TOKENS);
unknown_tokens = (GSList *) g_object_get_data (object,
GIMP_CONFIG_UNKNOWN_TOKENS);
for (last = NULL, list = unknown_tokens;
list;
last = list, list = g_slist_next (list))
{
token = (GimpConfigToken *) list->data;
if (strcmp (token->key, key) == 0)
{
/* FIXME: should we emit a warning here ?? */
g_free (token->value);
token->value = g_strdup (value);
return;
}
}
if (!unknown_tokens)
token = g_new (GimpConfigToken, 1);
token->key = g_strdup (key);
token->value = g_strdup (value);
if (last)
{
g_slist_append (last, token);
}
else
{
unknown_tokens = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_free);
unknown_tokens = g_slist_append (NULL, token);
g_object_set_data_full (object, GIMP_CONFIG_UNKNOWN_TOKENS,
unknown_tokens,
(GDestroyNotify) g_hash_table_destroy);
(GDestroyNotify) gimp_config_destroy_unknown_tokens);
}
g_hash_table_replace (unknown_tokens, key, value);
}
const gchar *
gimp_config_lookup_unknown_token (GObject *object,
const gchar *key)
{
GHashTable *unknown_tokens;
GimpConfigToken *token;
GSList *unknown_tokens;
GSList *list;
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
g_return_val_if_fail (key != NULL, NULL);
unknown_tokens =
(GHashTable *) g_object_get_data (object, GIMP_CONFIG_UNKNOWN_TOKENS);
unknown_tokens = (GSList *) g_object_get_data (object,
GIMP_CONFIG_UNKNOWN_TOKENS);
if (!unknown_tokens)
return NULL;
for (list = unknown_tokens; list; list = g_slist_next (list))
{
token = (GimpConfigToken *) list->data;
return (const gchar *) g_hash_table_lookup (unknown_tokens, key);
}
if (strcmp (token->key, key) == 0)
return token->value;
}
/* for debugging only */
return NULL;
}
void
gimp_config_debug_notify_callback (GObject *object,
GParamSpec *pspec)
gimp_config_foreach_unknown_token (GObject *object,
GimpConfigForeachFunc func,
gpointer user_data)
{
GimpConfigToken *token;
GSList *unknown_tokens;
GSList *list;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (G_IS_PARAM_SPEC (pspec));
g_return_if_fail (func != NULL);
unknown_tokens = (GSList *) g_object_get_data (object,
GIMP_CONFIG_UNKNOWN_TOKENS);
if (g_value_type_transformable (pspec->value_type, G_TYPE_STRING))
for (list = unknown_tokens; list; list = g_slist_next (list))
{
GValue src = { 0, };
GValue dest = { 0, };
g_value_init (&src, pspec->value_type);
g_object_get_property (object, pspec->name, &src);
token = (GimpConfigToken *) list->data;
func (token->key, token->value, user_data);
}
}
g_value_init (&dest, G_TYPE_STRING);
g_value_transform (&src, &dest);
g_print ("%s::%s -> %s\n",
g_type_name (G_TYPE_FROM_INSTANCE (object)), pspec->name,
g_value_get_string (&dest));
static void
gimp_config_destroy_unknown_tokens (GSList *unknown_tokens)
{
GimpConfigToken *token;
GSList *list;
g_value_unset (&src);
g_value_unset (&dest);
}
else
for (list = unknown_tokens; list; list = g_slist_next (list))
{
g_print ("%s: %s changed\n",
g_type_name (G_TYPE_FROM_INSTANCE (object)), pspec->name);
token = (GimpConfigToken *) list->data;
g_free (token->key);
g_free (token->value);
g_free (token);
}
g_slist_free (unknown_tokens);
}
......@@ -37,26 +37,31 @@ struct _GimpConfigInterface
void (* serialize) (GObject *object,
FILE *fd);
gboolean (* deserialize) (GObject *object,
GScanner *scanner);
GScanner *scanner,
gboolean store_unknown);
};
typedef void (*GimpConfigForeachFunc) (const gchar *key,
const gchar *value,
gpointer user_data);
GType gimp_config_interface_get_type (void) G_GNUC_CONST;
gboolean gimp_config_serialize (GObject *object,
const gchar *filename);
gboolean gimp_config_deserialize (GObject *object,
const gchar *filename);
const gchar *filename,
gboolean store_unknown);
void gimp_config_add_unknown_token (GObject *object,
gchar *key,
gchar *value);
const gchar *key,
const gchar *value);
const gchar * gimp_config_lookup_unknown_token (GObject *object,
const gchar *key);
/* for debugging only */
void gimp_config_debug_notify_callback (GObject *object,
GParamSpec *pspec);
void gimp_config_foreach_unknown_token (GObject *object,
GimpConfigForeachFunc func,
gpointer user_data);
#endif /* __GIMP_CONFIG_H__ */
......@@ -42,9 +42,6 @@
#include "core/core-types.h"
#include "config/gimpconfig.h"
#include "config/gimpbaseconfig.h"
#include "gui/gui.h"
#include "appenv.h"
......@@ -145,26 +142,6 @@ main (int argc,
gui_libs_init (&argc, &argv);
}
/* test code for GimpConfig, will go away */
{
GimpBaseConfig *config;
gchar *filename;
config = g_object_new (GIMP_TYPE_BASE_CONFIG, NULL);
g_signal_connect (G_OBJECT (config), "notify",
G_CALLBACK (gimp_config_debug_notify_callback),
NULL);
filename = gimp_personal_rc_file ("foorc");
gimp_config_serialize (G_OBJECT (config), filename);
gimp_config_deserialize (G_OBJECT (config), filename);
g_free (filename);
g_object_unref (config);
}
#if defined (HAVE_SHM_H) || defined (G_OS_WIN32)
use_shm = TRUE;
#endif
......
......@@ -91,7 +91,7 @@ esac
if test -z "$ACLOCAL_FLAGS"; then
acdir=`aclocal --print-ac-dir`
m4list="glib-2.0.m4 glib-gettext.m4 gtk-2.0.m4"
m4list="glib-2.0.m4 glib-gettext.m4 gtk-2.0.m4 pkg.m4"
for file in $m4list
do
......
dnl Process this file with autoconf to produce a configure script.
AC_INIT(etc/gimprc.in)
GLIB_REQUIRED_VERSION=1.3.11
GTK_REQUIRED_VERSION=$GLIB_REQUIRED_VERSION
PANGOFT2_REQUIRED_VERSION=0.22
GTKDOC_REQUIRED_VERSION=0.6
#
# Making releases:
# GIMP_MICRO_VERSION += 1;
......@@ -111,57 +117,15 @@ AM_GLIB_GNU_GETTEXT
AC_PATH_XTRA
dnl Find pkg-config
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
if test x$PKG_CONFIG = xno ; then
AC_MSG_ERROR([
*** pkg-config not found.
See the file 'INSTALL' for help.])
fi
AM_PATH_GLIB_2_0($GLIB_REQUIRED_VERSION,,
AC_MSG_ERROR(Test for GLIB failed. See the file 'INSTALL' for help.),
gobject)
if ! pkg-config --atleast-pkgconfig-version 0.7 ; then
AC_MSG_ERROR([
*** pkg-config too old; version 0.7 or better required.
See the file 'INSTALL' for help.])
fi
dnl Check for GTK+
AM_PATH_GTK_2_0(1.3.11,,
AM_PATH_GTK_2_0($GTK_REQUIRED_VERSION,,
AC_MSG_ERROR(Test for GTK failed. See the file 'INSTALL' for help.))
changequote(,)dnl
PKG_CHECK_MODULES(PANGOFT2, pangoft2 >= $PANGOFT2_REQUIRED_VERSION)
dnl Evil stuff to extract GLIB stuff from pkg-config output
dnl (we want to make sure it matches with the gtk we're using)
GTK_TEMP_CFLAGS=`echo $GTK_CFLAGS | sed 's/^\(-I[^ ]*\).*$/\1/'`
if echo $GTK_TEMP_CFLAGS | grep 'glib/include$' > /dev/null; then
GTK_TEMP_CFLAGS=$GTK_CFLAGS
else
GTK_TEMP_CFLAGS=`echo $GTK_CFLAGS | sed 's/^-I[^ ]* \(.*\)$/\1/'`
fi
GLIB_CFLAGS=`echo $GTK_TEMP_CFLAGS | sed 's/^\(-I[^ ]*glib[^ ]* *-I[^ ]*\).*/\1/'`
GLIB_LDFLAGS=`echo $GTK_LIBS | sed -e 's/^.*-lgdk[^ ]* *\(-L[^ ]*\).*$/\1/' -e 's/^.* -lgdk[^ ]* .*$//'`
if test -z "$GLIB_LDFLAGS" ; then
GLIB_LDFLAGS=`echo $GTK_LIBS | sed 's/^ *\(-L[^ ]*\) .*$/\1/'`
fi
GLIB_LIBS="$GLIB_LDFLAGS `echo $GTK_LIBS | sed 's/^.*\(-lglib[^ ]*\).*$/\1/'`"
changequote([,])dnl
dnl
dnl Check for PangoFT2
dnl
PANGOFT2_REQUIRED_VERSION=0.22
AC_MSG_CHECKING([for Freetype 2.0 font support for Pango])
if $PKG_CONFIG --atleast-version $PANGOFT2_REQUIRED_VERSION pangoft2; then
AC_MSG_RESULT(found)
PANGOFT2_CFLAGS=`$PKG_CONFIG --cflags pangoft2`
PANGOFT2_LIBS=`$PKG_CONFIG --libs pangoft2`
else
AC_MSG_ERROR([*** PangoFT2 $PANGOFT2_REQUIRED_VERSION or newer is required.])
fi
if eval "test x$GCC = xyes"; then
case " $CFLAGS " in
......@@ -625,8 +589,19 @@ AC_PATH_PROGS(EMACS, emacs xemacs, :)
dnl This is for the developers documentation.
AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
AC_SUBST(HAVE_GTK_DOC)
if $GTKDOC ; then
gtk_doc_version=`gtkdoc-mkdb --version`
AC_MSG_CHECKING([gtk-doc version ($gtk_doc_version) >= $GTKDOC_REQUIRED_VERSION])
if perl <<EOF ; then
exit (("$gtk_doc_version" =~ /^[[0-9]]+\.[[0-9]]+$/) &&
("$gtk_doc_version" >= "$GTKDOC_REQUIRED_VERSION") ? 0 : 1);
EOF
AC_MSG_RESULT(yes)
else
AC_MSG_RESULT(no)
GTKDOC=false
fi
fi
dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc, [ --enable-gtk-doc use gtk-doc to build documentation [default=auto]], enable_gtk_doc="$enableval", enable_gtk_doc=auto)
......@@ -643,11 +618,14 @@ AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)
AC_ARG_WITH(html-dir, [ --with-html-dir=PATH path to installed docs ])
if test "x$with_html_dir" = "x" ; then
HTML_DIR='${gimpdatadir}/devel-docs/html'
HTML_DIR='${datadir}/gtk-doc/html'
else
HTML_DIR=$with_html_dir
fi
AC_SUBST(HTML_DIR)
dnl This is for the mail plug-in
sendmail_path=":"
AC_ARG_ENABLE(sendmail_path, [ --with-sendmail=DIR set sendmail command location],
......@@ -770,9 +748,6 @@ AC_SUBST(LT_AGE)
AC_SUBST(X_LIBS)
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)
AC_SUBST(PANGOFT2_CFLAGS)
AC_SUBST(PANGOFT2_LIBS)
......
......@@ -64,7 +64,8 @@ static GTokenType gimp_config_deserialize_any (GValue *value,
gboolean
gimp_config_deserialize_properties (GObject *object,
GScanner *scanner)
GScanner *scanner,
gboolean store_unknown_tokens)
{
GObjectClass *klass;
GParamSpec **property_specs;
......@@ -102,11 +103,9 @@ gimp_config_deserialize_properties (GObject *object,
{
next = g_scanner_peek_next_token (scanner);
/* if we expected a symbol, but got an identifier,
try parsing it with gimp_config_deserialize_unknown */
if (next != token &&
! (token == G_TOKEN_SYMBOL && next == G_TOKEN_IDENTIFIER))
! (store_unknown_tokens &&
token == G_TOKEN_SYMBOL && next == G_TOKEN_IDENTIFIER))
{
break;
}
......@@ -165,8 +164,9 @@ gimp_config_deserialize_unknown (GObject *object,
g_scanner_get_next_token (scanner);
gimp_config_add_unknown_token (object,
key, g_strdup (scanner->value.v_string));
gimp_config_add_unknown_token (object, key, scanner->value.v_string);
g_free (key);
return G_TOKEN_RIGHT_PAREN;
}
......
......@@ -24,7 +24,8 @@
gboolean gimp_config_deserialize_properties (GObject *object,
GScanner *scanner);
GScanner *scanner,
gboolean store_unknown_tokens);
#endif /* __GIMP_CONFIG_DESERIALIZE_H__ */
......@@ -30,15 +30,18 @@
#include "gimpconfig-serialize.h"
#include "gimpconfig-deserialize.h"
#define GIMP_CONFIG_UNKNOWN_TOKENS "gimp-config-unknown-tokens"
/*
* The GimpConfig serialization and deserialization interface.
*/
static void gimp_config_iface_init (GimpConfigInterface *gimp_config_iface);
static void gimp_config_iface_serialize (GObject *object,
FILE *file);
static gboolean gimp_config_iface_deserialize (GObject *object,
GScanner *scanner);
GScanner *scanner,
gboolean store_unknown);
GType
......@@ -83,9 +86,12 @@ gimp_config_iface_serialize (GObject *object,
static gboolean
gimp_config_iface_deserialize (GObject *object,
GScanner *scanner)
GScanner *scanner,
gboolean store_unknown)
{
return gimp_config_deserialize_properties (object, scanner);
return gimp_config_deserialize_properties (object,
scanner,
store_unknown);
}
gboolean
......@@ -116,7 +122,8 @@ gimp_config_serialize (GObject *object,
gboolean
gimp_config_deserialize (GObject *object,
const gchar *filename)
const gchar *filename,
gboolean store_unknown)
{
GimpConfigInterface *gimp_config_iface;
gint fd;
......@@ -143,7 +150,7 @@ gimp_config_deserialize (GObject *object,
g_scanner_input_file (scanner, fd);
scanner->input_name = filename;
success = gimp_config_iface->deserialize (object, scanner);
success = gimp_config_iface->deserialize (object, scanner, store_unknown);
g_scanner_destroy (scanner);
close (fd);
......@@ -151,80 +158,135 @@ gimp_config_deserialize (GObject *object,
return success;
}
/*
* Code to store and lookup unknown tokens (string key/value pairs).
*/
#define GIMP_CONFIG_UNKNOWN_TOKENS "gimp-config-unknown-tokens"
typedef struct
{
gchar *key;
gchar *value;
} GimpConfigToken;
static void gimp_config_destroy_unknown_tokens (GSList *unknown_tokens);
void
gimp_config_add_unknown_token (GObject *object,
gchar *key,
gchar *value)
gimp_config_add_unknown_token (GObject *object,
const gchar *key,
const gchar *value)
{
GHashTable *unknown_tokens;
GimpConfigToken *token;
GSList *unknown_tokens;
GSList *last;
GSList *list;
g_return_if_fail (G_IS_OBJECT (object));
g_return_if_fail (key != NULL);
g_return_if_fail (value != NULL);
unknown_tokens =
(GHashTable *) g_object_get_data (object, GIMP_CONFIG_UNKNOWN_TOKENS);
unknown_tokens = (GSList *) g_object_get_data (object,
GIMP_CONFIG_UNKNOWN_TOKENS);
for (last = NULL, list = unknown_tokens;
list;
last = list, list = g_slist_next (list))
{
token = (GimpConfigToken *) list->data;
if (strcmp (token->key, key) == 0)
{
/* FIXME: should we emit a warning here ?? */
g_free (token->value);
token->value = g_strdup (value);
return;
}
}
if (!unknown_tokens)
token = g_new (GimpConfigToken, 1);
token->key = g_strdup (key);
token->value = g_strdup (value);
if (last)
{
g_slist_append (last, token);
}
else
{
unknown_tokens = g_hash_table_new_full (g_str_hash, g_str_equal,
g_free, g_free);
unknown_tokens = g_slist_append (NULL, token);
g_object_set_data_full (object, GIMP_CONFIG_UNKNOWN_TOKENS,
unknown_tokens,
(GDestroyNotify) g_hash_table_destroy);
(GDestroyNotify) gimp_config_destroy_unknown_tokens);
}
g_hash_table_replace (unknown_tokens, key, value);
}
const gchar *
gimp_config_lookup_unknown_token (GObject *object,
const gchar *key)
{
GHashTable *unknown_tokens;
GimpConfigToken *token;
GSList *unknown_tokens;
GSList *list;
g_return_val_if_fail (G_IS_OBJECT (object), NULL);
g_return_val_if_fail (key != NULL, NULL);
unknown_tokens =
(GHashTable *) g_object_get_data (object, GIMP_CONFIG_UNKNOWN_TOKENS);
unknown_tokens = (GSList *) g_object_get_data (object,
GIMP_CONFIG_UNKNOWN_TOKENS);
if (!unknown_tokens)
return NULL;
for (list = unknown_tokens; list; list = g_slist_next (list))
{
token = (GimpConfigToken *) list->data;
return (const gchar *) g_hash_table_lookup (unknown_tokens, key);
}
if (strcmp (token->key, key) == 0)
return token->value;
}
/* for debugging only */
return NULL;
}
void
gimp_config_debug_notify_callback (GObject *object,
GParamSpec *pspec)
gimp_config_foreach_unknown_token (GObject *object,