gEDA-dev: [PATCH] GAF: Compile libgeda even if libguile is missing
Bernd Jendrissek
bernd.jendrissek at gmail.com
Tue Jul 24 12:44:22 EDT 2007
I don't know if this is/was a (very?) bad idea, but here in Africa we
need racing ostriches to run our IP packets from village to village. I
hacked libgeda to build without guile-1.8.x since that was faster than
waiting until I had convenient net access again.
2007-07-24 Bernd Jendrissek <bernd.jendrissek at gmail.com>
* libgeda/include/prototype.h: Declare prototypes for Guile
interfaces only if libguile is present and recent enough.
* libgeda/src/s_menu.c, libgeda/src/s_clib.c,
libgeda/src/libgeda.c: Don't compile Guile-aware code if
libguile is missing or is too old.
* libgeda/configure.ac: AC_MSG_WARN() if libguile is missing or
is too old. Define automake conditional LIBGEDA_USE_GUILE.
Add -DLIBGEDA_USE_GUILE to LIBGEDA_CFLAGS if libguile is good.
* libgeda/src/Makefile.am: Link Guile-aware modules into
libgeda.la only if libguile is good.
-------------- next part --------------
Index: gaf.git/libgeda/include/prototype.h
diff -u -p -- gaf.git/libgeda/include/prototype.h.borig gaf.git/libgeda/include/prototype.h
--- gaf.git/libgeda/include/prototype.h
+++ gaf.git/libgeda/include/prototype.h 2007-07-24 01:29:52.000000000 +0200
@@ -32,6 +32,7 @@ int f_print_stream(TOPLEVEL *w_current,
void f_print_set_type(TOPLEVEL *w_current, int type);
int f_print_initialize_glyph_table(void);
+#ifdef LIBGEDA_USE_GUILE
/* g_basic.c */
int g_read_file(const gchar *filename);
@@ -91,6 +92,7 @@ void g_init_page_smob(void);
gboolean g_get_data_from_page_smob(SCM object_smob, TOPLEVEL **toplevel,
PAGE **object);
SCM g_get_page_filename(SCM page_smob);
+#endif /* LIBGEDA_USE_GUILE */
/* i_vars.c */
void i_vars_libgeda_set(TOPLEVEL *w_current);
@@ -506,8 +508,10 @@ const CLibSource *s_clib_add_directory (
const gchar *name);
const CLibSource *s_clib_add_command (const gchar *command,
const gchar *name);
+#ifdef LIBGEDA_USE_GUILE
const CLibSource *s_clib_add_scm (SCM listfunc, SCM getfunc,
const gchar *name);
+#endif /* LIBGEDA_USE_GUILE */
const gchar *s_clib_source_get_name (const CLibSource *source);
GList *s_clib_source_get_symbols (const CLibSource *source);
const gchar *s_clib_symbol_get_name (const CLibSymbol *symbol);
@@ -573,8 +577,10 @@ gchar *s_log_read (void);
/* s_menu.c */
int s_menu_return_num(void);
+#ifdef LIBGEDA_USE_GUILE
SCM s_menu_return_entry(int index, char **menu_name);
int s_menu_add_entry(char *new_menu, SCM menu_items);
+#endif /* LIBGEDA_USE_GUILE */
void s_menu_print(void);
void s_menu_free(void);
void s_menu_init(void);
Index: gaf.git/libgeda/src/s_menu.c
diff -u -p -- gaf.git/libgeda/src/s_menu.c.borig gaf.git/libgeda/src/s_menu.c
--- gaf.git/libgeda/src/s_menu.c
+++ gaf.git/libgeda/src/s_menu.c 2007-07-07 13:43:11.000000000 +0200
@@ -120,7 +120,9 @@ void s_menu_print()
for (i = 0; i < menu_index; i++) {
printf("Name; %s\n", menu[i].menu_name);
+#ifdef LIBGEDA_USE_GUILE
scm_display (menu[i].menu_items, scm_current_output_port ());
+#endif /* LIBGEDA_USE_GUILE */
printf("\n");
}
}
Index: gaf.git/libgeda/src/s_clib.c
diff -u -p -- gaf.git/libgeda/src/s_clib.c.borig gaf.git/libgeda/src/s_clib.c
--- gaf.git/libgeda/src/s_clib.c
+++ gaf.git/libgeda/src/s_clib.c 2007-07-07 13:43:11.000000000 +0200
@@ -144,7 +144,9 @@
#endif
#include <gtk/gtk.h>
+#ifdef LIBGEDA_USE_GUILE
#include <libguile.h>
+#endif
#include <sys/wait.h>
@@ -181,8 +183,10 @@ enum CLibSourceType {
CLIB_DIR,
/*! Command source */
CLIB_CMD,
+#ifdef LIBGEDA_USE_GUILE
/*! Guile function source */
CLIB_SCM,
+#endif /* LIBGEDA_USE_GUILE */
};
/*! Stores data about a particular component source */
@@ -196,10 +200,12 @@ struct _CLibSource {
/*! Available symbols (#CLibSymbol) */
GList *symbols;
+#ifdef LIBGEDA_USE_GUILE
/*! Scheme function for listing symbols */
SCM list_fn;
/*! Scheme function for retrieving symbol data */
SCM get_fn;
+#endif /* LIBGEDA_USE_GUILE */
};
/*! Stores data about a particular symbol */
@@ -288,10 +294,12 @@ static void free_source (gpointer data,
g_list_free (source->symbols);
source->symbols = NULL;
}
+#ifdef LIBGEDA_USE_GUILE
if (source->type == CLIB_SCM) {
scm_gc_unprotect_object (source->list_fn);
scm_gc_unprotect_object (source->get_fn);
}
+#endif /* LIBGEDA_USE_GUILE */
}
}
@@ -616,6 +624,7 @@ static void refresh_command (CLibSource
*/
static void refresh_scm (CLibSource *source)
{
+#ifdef LIBGEDA_USE_GUILE
SCM symlist;
SCM symname;
CLibSymbol *symbol;
@@ -658,6 +667,7 @@ static void refresh_scm (CLibSource *sou
/* Now sort the list of symbols by name. */
source->symbols = g_list_sort (source->symbols,
(GCompareFunc) compare_symbol_name);
+#endif /* LIBGEDA_USE_GUILE */
}
/*! \brief Rescan all available component libraries.
@@ -825,6 +835,7 @@ const CLibSource *s_clib_add_command (co
return source;
}
+#ifdef LIBGEDA_USE_GUILE
/*! \brief Add symbol-generating Scheme procedures to the library.
* \par Function Description
* Adds a source to the library based on Scheme procedures. See page
@@ -874,6 +885,7 @@ const CLibSource *s_clib_add_scm (SCM li
return source;
}
+#endif /* LIBGEDA_USE_GUILE */
/*! \brief Get the name of a source.
* \par Function Description
@@ -1018,6 +1030,7 @@ static gchar *get_data_command (const CL
return run_source_command ( argv );
}
+#ifdef LIBGEDA_USE_GUILE
/*! \brief Get symbol data from a Scheme-based component source.
* \par Function Description
* Get symbol data from a Scheme-based component source. The return
@@ -1046,6 +1059,7 @@ static gchar *get_data_scm (const CLibSy
return g_strdup (SCM_STRING_CHARS (symdata));
}
+#endif /* LIBGEDA_USE_GUILE */
/*! \brief Get symbol data.
* \par Function Description
@@ -1068,8 +1082,10 @@ gchar *s_clib_symbol_get_data (const CLi
return get_data_directory (symbol);
case CLIB_CMD:
return get_data_command (symbol);
+#ifdef LIBGEDA_USE_GUILE
case CLIB_SCM:
return get_data_scm (symbol);
+#endif /* LIBGEDA_USE_GUILE */
default:
g_assert_not_reached();
}
Index: gaf.git/libgeda/src/libgeda.c
diff -u -p -- gaf.git/libgeda/src/libgeda.c.borig gaf.git/libgeda/src/libgeda.c
--- gaf.git/libgeda/src/libgeda.c
+++ gaf.git/libgeda/src/libgeda.c 2007-07-07 13:43:11.000000000 +0200
@@ -73,8 +73,10 @@ void libgeda_init(void)
o_text_init();
+#ifdef LIBGEDA_USE_GUILE
g_register_libgeda_funcs();
g_register_libgeda_vars();
+#endif /* LIBGEDA_USE_GUILE */
}
Index: gaf.git/libgeda/configure.ac
diff -u -p -- gaf.git/libgeda/configure.ac.borig gaf.git/libgeda/configure.ac
--- gaf.git/libgeda/configure.ac
+++ gaf.git/libgeda/configure.ac 2007-07-24 00:36:09.000000000 +0200
@@ -89,9 +89,16 @@ AC_MSG_RESULT($GUILE_VERSION)
if test $guile_need_major -gt $guile_major \
|| test $guile_need_minor -gt $guile_minor; then
- AC_MSG_ERROR([Guile version >= $guile_need_version is required.])
+ AC_MSG_WARN([Guile version >= $guile_need_version is highly recommended.])
+ guile_whitelisted=no
+else
+ guile_whitelisted=yes
+ AC_DEFINE(LIBGEDA_USE_GUILE, 1,
+ [Define if you are using Guile as an extension language])
fi
+AM_CONDITIONAL(LIBGEDA_USE_GUILE, test x$guile_whitelisted = xyes)
+
#
# Check for guile end
############################################################################
@@ -372,10 +387,6 @@ AC_C_CONST
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(getcwd strstr vsnprintf snprintf chown)
-#
-# Checks for header files end
-#########################################################################
-
#########################################################################
#
@@ -467,7 +478,10 @@ AC_DEFINE_UNQUOTED(VERSION, "$VERSION",
# Finally create the final CFLAGS and LDFLAGS for use in the makefiles
LIBGEDA_CFLAGS="$MINGW_CFLAGS $GUILE_CFLAGS $GD_CFLAGS $GTK_CFLAGS $X_CFLAGS $GDK_PIXBUF_CFLAGS $GDK_CFLAGS"
LIBGEDA_LDFLAGS="$GUILE_LDFLAGS $GD_LIBS $GLIB_LIBS $MINGW_LIBS $DMALLOC_LIBS $GDK_PIXBUF_LIBS $GDK_LIBS"
+if test x$guile_whitelisted = xyes; then
+ LIBGEDA_CFLAGS="$LIBGEDA_CFLAGS -DLIBGEDA_USE_GUILE"
+fi
LIBTOOL_FLAGS="-version-info $SHARED_LIBRARY_VERSION"
# Makefile.in variable substitution
Index: gaf.git/libgeda/src/Makefile.am
diff -u -p -- gaf.git/libgeda/src/Makefile.am.borig gaf.git/libgeda/src/Makefile.am
--- gaf.git/libgeda/src/Makefile.am
+++ gaf.git/libgeda/src/Makefile.am 2007-07-08 03:12:31.000000000 +0200
@@ -12,18 +12,26 @@ endif
# Build a libtool library, libhello.la for installation in libdir.
lib_LTLIBRARIES = libgeda.la
+if LIBGEDA_USE_GUILE
+libgeda_scheme_CFILES = \
+ g_basic.c g_smob.c g_register.c g_rc.c
+else
+libgeda_scheme_CFILES =
+endif
+
libgeda_la_SOURCES = \
- a_basic.c f_basic.c f_print.c f_image.c g_basic.c m_basic.c \
+ a_basic.c f_basic.c f_print.c f_image.c m_basic.c \
o_arc_basic.c o_attrib.c o_basic.c o_box_basic.c \
o_circle_basic.c o_complex_basic.c o_line_basic.c o_list.c \
o_net_basic.c o_selection.c o_bus_basic.c o_text_basic.c \
o_pin_basic.c o_image.c o_embed.c \
u_basic.c s_attrib.c s_basic.c \
s_clib.c s_encoding.c s_hierarchy.c s_papersizes.c s_stretch.c \
s_log.c s_textbuffer.c \
s_page.c s_slib.c s_color.c s_undo.c s_conn.c \
- s_cue.c s_tile.c s_menu.c s_toplevel.c g_smob.c libgeda.c \
- g_register.c g_rc.c i_vars.c o_picture.c gdk-pixbuf-hacks.c
+ s_cue.c s_tile.c s_menu.c s_toplevel.c libgeda.c \
+ i_vars.c o_picture.c gdk-pixbuf-hacks.c \
+ $(libgeda_scheme_CFILES)
INCLUDES = -I$(top_srcdir)/include @LIBGEDA_CFLAGS@
libgeda_la_LDFLAGS = @LIBTOOL_FLAGS@ @LIBGEDA_LDFLAGS@
More information about the geda-dev
mailing list