[Freeciv-Dev] guile buindings
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Here is some preliminary patch to add guile scripting. Actually
I was able to configure and compile system correctly and run
guile-core at end of turn, but otherwise it is not working. This
was just quick hack, and I don't have nowadays to desing and
make it complete. I hope someone finds this patch usefull. And I
also hope it has all parts in it.
What I really want:
- autoconfigure guile properly
- guile hooks at every event, changeable without restarting the
game, that way I can code hookhandlers during the game run
- menu to add my own menus made by guile-gtk, and way to alter
them even when game is running, (aka recode and export, the
way scwm does it), it is very fast to change ui if you don't
have to recompile or even restart game
- guile bindings to freeciv (client) internals, ie way to change
stuff automatically from guile-script
- if you don't want to build agains guile, you don't have to and
you don't get any extra burden to handle
- general scripting where other like python and perl (whatever)
can have all the above too, dunno if it is possible
Index: configure.in
===================================================================
RCS file: /home/freeciv/CVS/freeciv/configure.in,v
retrieving revision 1.50
diff -u -r1.50 configure.in
--- configure.in 1999/05/22 04:40:01 1.50
+++ configure.in 1999/09/17 21:27:37
@@ -4,6 +4,7 @@
dnl Initialize with some random file to ensure the source is here.
AC_INIT(common/game.c)
AM_CONFIG_HEADER(config.h)
+AM_ACLOCAL_INCLUDE(macros)
dnl May not be quite correct, but autoconf version 2.9 is reported
dnl not to work, and version 2.12 is known to work:
@@ -106,7 +107,7 @@
AC_PROG_CC
AC_PROG_CPP
AC_PROG_LN_S
-AC_PROG_RANLIB
+AM_PROG_LIBTOOL
AC_ARG_PROGRAM
@@ -191,6 +192,14 @@
AM_CONDITIONAL(CLIENT_GUI_GTK, test "$gui_sources" = "gui-gtk")
AM_CONDITIONAL(CLIENT_INCLUDE_DIST, test "x" = "y")
+AC_ARG_WITH(guile,[ --with-guile Include Guile
support],[GNOME_CHECK_GUILE])
+if test x$ac_cv_guile_found = xyes; then
+FC_CHECK_GUILE_GTK
+if test x$ac_cv_guile_gtk_found = xno; then
+ AC_MSG_ERROR(need guile-gtk, check README.guile)
+fi
+fi
+
dnl Checks for non-X libraries:
if test x$server = xtrue; then
dnl For the client, these libs (if required) should already be present
@@ -248,4 +257,4 @@
FC_EXPAND_DIR(FREECIV_DATADIR, "$datadir/freeciv")
AC_DEFINE_UNQUOTED(FREECIV_DATADIR, "$FREECIV_DATADIR")
-AC_OUTPUT(Makefile data/Makefile data/default/Makefile data/civ1/Makefile
data/classic/Makefile common/Makefile ai/Makefile client/Makefile
client/include/Makefile client/gui-gtk/Makefile client/gui-xaw/Makefile
server/Makefile undep.sh, [ chmod +x undep.sh ; ./undep.sh ])
+AC_OUTPUT(Makefile data/Makefile data/default/Makefile data/civ1/Makefile
data/classic/Makefile common/Makefile ai/Makefile client/Makefile
client/include/Makefile client/gui-gtk/Makefile client/gui-xaw/Makefile
client/guile/Makefile server/Makefile undep.sh, [ chmod +x undep.sh ;
./undep.sh ])
Index: client/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/Makefile.am,v
retrieving revision 1.17
diff -u -r1.17 Makefile.am
--- Makefile.am 1999/05/13 20:02:39 1.17
+++ Makefile.am 1999/09/17 21:27:37
@@ -18,11 +18,17 @@
CLI_INCLUDE =
endif
-SUBDIRS = $(GUI_SUBDIR) $(CLI_INCLUDE)
+if GUILE
+GUILE_SUBDIR = guile
+else
+GUILE_SUBDIR =
+endif
+SUBDIRS = $(GUI_SUBDIR) $(CLI_INCLUDE) $(GUILE_SUBDIR)
+
bin_PROGRAMS = civclient
-INCLUDES = -I$(srcdir)/include -I$(top_srcdir)/common
-I$(srcdir)/@gui_sources@ @CLIENT_CFLAGS@
+INCLUDES = -I$(srcdir)/include -I$(top_srcdir)/common
-I$(srcdir)/@gui_sources@ @CLIENT_CFLAGS@ @GUILE_INCS@ @GUILE_GTK_INCS@
civclient_SOURCES = \
civclient.c \
@@ -31,4 +37,4 @@
options.c
civclient_DEPENDENCIES = @gui_sources@/libguiclient.a ../common/libcivcommon.a
-civclient_LDADD = @gui_sources@/libguiclient.a ../common/libcivcommon.a
@CLIENT_LIBS@
+civclient_LDADD = @gui_sources@/libguiclient.a ../common/libcivcommon.a
@CLIENT_LIBS@ @GUILE_LIBS@ @GUILE_GTK_LIBS@
Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.35
diff -u -r1.35 civclient.c
--- civclient.c 1999/05/03 12:37:02 1.35
+++ civclient.c 1999/09/17 21:27:37
@@ -10,6 +10,10 @@
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
***********************************************************************/
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -41,6 +45,8 @@
#include <helpdlg.h>
#include <options.h>
+#include <guile_macros.h>
+
char server_host[512];
char name[512];
int server_port;
@@ -78,7 +84,20 @@
...
**************************************************************************/
+#ifdef HAVE_GUILE
+int inner_main(int argc, char *argv[]);
+
+int
+main (int argc, char **argv)
+{
+ scm_boot_guile (argc, argv, inner_main, 0);
+ return 0; /* never reached */
+}
+
+int inner_main(int argc, char *argv[])
+#else
int main(int argc, char *argv[])
+#endif
{
if(argc>1 && strstr(argv[1],"-help")) {
fprintf(stderr, "This is the Freeciv client\n");
@@ -99,6 +118,13 @@
fprintf(stderr, "%s\n", FREECIV_NAME_VERSION);
exit(0);
}
+
+#ifdef HAVE_GUILE
+ sgtk_init();
+ gh_eval_file(FREECIV_DATADIR "/guile/freeciv_startup.scm");
+ GUILE_MAKE_HOOK("end_turn_hook");
+ gh_eval_str("(fc-user-init)");
+#endif
/* audio_init(); */
init_messages_where();
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.12
diff -u -r1.12 gui_main.c
--- gui_main.c 1999/05/24 17:26:55 1.12
+++ gui_main.c 1999/09/17 21:27:37
@@ -47,6 +47,8 @@
#include <spaceshipdlg.h>
#include <options.h>
+#include <guile_macros.h>
+
#define NOTIFY_DIALOG_FONT
"-b&h-lucidatypewriter-bold-r-normal-*-12-*-*-*-*-*-*-*"
/*void file_quit_cmd_callback( GtkWidget *widget, gpointer data )*/
@@ -847,6 +849,7 @@
{
gtk_widget_set_sensitive(turn_done_button, FALSE);
user_ended_turn();
+ GUILE_RUN_HOOK("end_turn_hook");
}
Index: client/gui-gtk/menu.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/menu.c,v
retrieving revision 1.5
diff -u -r1.5 menu.c
--- menu.c 1999/05/23 18:50:50 1.5
+++ menu.c 1999/09/17 21:27:38
@@ -37,6 +37,7 @@
#include <options.h>
#include <capability.h>
+#include <guile_macros.h>
GtkItemFactory *item_factory=NULL;
@@ -102,6 +103,10 @@
MENU_REPORT_WOW,
MENU_REPORT_SPACESHIP,
+#ifdef HAVE_GUILE
+ MENU_GUILE,
+#endif
+
MENU_HELP_CONTROLS,
MENU_HELP_PLAYING,
MENU_HELP_IMPROVEMENTS,
@@ -117,6 +122,7 @@
MENU_HELP_COPYING,
MENU_HELP_ABOUT,
MENU_HELP_CONNECTING
+
};
@@ -343,9 +349,24 @@
}
+#ifdef HAVE_GUILE
/****************************************************************
...
*****************************************************************/
+void guile_menu_callback(gpointer callback_data, guint callback_action,
+ GtkWidget *widget)
+{
+ switch(callback_action) {
+ case MENU_GUILE:
+ popup_guile_dialog(0);
+ break;
+ }
+}
+#endif
+
+/****************************************************************
+...
+*****************************************************************/
void help_menu_callback(gpointer callback_data, guint callback_action,
GtkWidget *widget)
{
@@ -494,7 +515,7 @@
{ "/Orders/Build Irrigation", "i",
orders_menu_callback,
MENU_ORDER_IRRIGATE
},
{ "/Orders/Transform Terrain", "o", orders_menu_callback,
- MENU_ORDER_TRANSFORM
},
+ MENU_ORDER_TRANSFORM },
{ "/Orders/Build Mine", "m", orders_menu_callback,
MENU_ORDER_MINE },
{ "/Orders/sep1", NULL, NULL,
@@ -561,7 +582,16 @@
{ "/Reports/Demographics", "F11", reports_menu_callback,
MENU_REPORT_DEMOGRAPHIC },
{ "/Reports/Spaceship", "F12", reports_menu_callback,
- MENU_REPORT_SPACESHIP
},
+ MENU_REPORT_SPACESHIP },
+
+#ifdef HAVE_GUILE
+ { "/Guile", NULL, NULL,
+ 0, "<Branch>" },
+ { "/Guile/tearoff1", NULL, NULL,
+ 0, "<Tearoff>" },
+ { "/Guile/Actions", NULL, guile_menu_callback,
+ MENU_GUILE },
+#endif
{ "/_Help", NULL, NULL,
0, "<LastBranch>" },
Index: client/include/Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/include/Makefile.am,v
retrieving revision 1.1
diff -u -r1.1 Makefile.am
--- Makefile.am 1999/05/13 22:39:03 1.1
+++ Makefile.am 1999/09/17 21:27:38
@@ -1,6 +1,7 @@
## Process this file with automake to produce Makefile.in
EXTRA_DIST = \
+ guile_macros.h \
cityicon.ico \
freeciv.ico \
goto_cursor.xbm \
Index: ChangeLog
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ChangeLog,v
retrieving revision 1.20
diff -u -r1.20 ChangeLog
--- ChangeLog 1999/04/02 05:35:43 1.20
+++ ChangeLog 1999/09/17 21:27:34
@@ -1,3 +1,50 @@
+1999-05-26 Markus Linnala <maage@xxxxxxxxx>
+
+ * client/gui-gtk/menu.c: include guile_macros
+ (guile_menu_callback): add guile menu
+ (menu_items): add entries at menufactory
+
+ * Makefile.am (EXTRA_DIST): add files from macros directory
+
+ * acconfig.h: add HAVE_GUILE and HAVE_GUILE_GTK
+
+ * configure.in: use am_aclocal_include
+ - use libtool instead of ranlib
+ - check for guile
+ - update new Makefile's too
+
+ * macros/guile-gtk-checks.m4: new file, check guile-gtk
+
+ * macros/gnome-guile-checks.m4: new file, check guile (ripped from
+ gnome)
+
+ * macros/aclocal-include.m4: new file, to properly handle aclocal
+ macros
+
+ * client/include/Makefile.am (EXTRA_DIST): add guile_macros.h
+
+ * client/guile/freeciv_startup.scm : new file
+
+ * client/guile/Makefile.am: new file
+
+ * client/include/guile_macros.h: new file
+
+ * client/Makefile.am (GUILE_SUBDIR): maybe add guile specific
+ stuff too
+ (civclient_LDADD): maybe link against guile libs
+
+ * client/gui-gtk/gui_main.c: include guile_macros.h
+ (end_turn_callback): add hook for guile
+
+ * client/civclient.c: use config.h
+ - include guile_macros.h
+ (main): when using guile:
+ - wrap main
+ - boot guile
+ - boot guile-gtk
+ - init hooks
+ - run startup scripts
+
Fri Apr 2 05:26:57 1999 David Pfitzner <dwp@xxxxxxxxxxxxxx>:
* common/shared.h: Changed capability string to "+1.8".
Index: Makefile.am
===================================================================
RCS file: /home/freeciv/CVS/freeciv/Makefile.am,v
retrieving revision 1.9
diff -u -r1.9 Makefile.am
--- Makefile.am 1999/01/30 03:41:10 1.9
+++ Makefile.am 1999/09/17 21:27:35
@@ -25,4 +25,7 @@
NEWS README README.AI README.rulesets \
acconfig.h config.h.in configure configure.in \
acinclude.m4 install-sh mkinstalldirs \
- civ ser freeciv_hackers_guide.txt
+ civ ser freeciv_hackers_guide.txt \
+ macros/gnome-guile-checks.m4 \
+ macros/guile-gtk-checks.m4 \
+ macros/aclocal-incluce.m4
\ No newline at end of file
Index: acconfig.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/acconfig.h,v
retrieving revision 1.8
diff -u -r1.8 acconfig.h
--- acconfig.h 1999/03/14 00:17:26 1.8
+++ acconfig.h 1999/09/17 21:27:35
@@ -30,6 +30,8 @@
#undef HAVE_LIBXMU
#undef HAVE_LIBXPM
#undef HAVE_LIBXT
+#undef HAVE_GUILE
+#undef HAVE_GUILE_GTK
@BOTTOM@
diff -u --recursive --new-file --exclude-from=.diffignore
freeciv-cvs/macros/aclocal-include.m4 freeciv-guile/macros/aclocal-include.m4
--- freeciv-cvs/macros/aclocal-include.m4 Thu Jan 1 02:00:00 1970
+++ freeciv-guile/macros/aclocal-include.m4 Wed May 26 02:00:51 1999
@@ -0,0 +1,16 @@
+# aclocal-include.m4
+#
+# This macro adds the name macrodir to the set of directories
+# that `aclocal' searches for macros.
+
+# serial 1
+
+dnl AM_ACLOCAL_INCLUDE(macrodir)
+AC_DEFUN([AM_ACLOCAL_INCLUDE],
+[
+ AM_CONDITIONAL(INSIDE_GNOME_COMMON, test x = y)
+
+ test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
+
+ for k in $1 ; do ACLOCAL="$ACLOCAL -I $k" ; done
+])
diff -u --recursive --new-file --exclude-from=.diffignore
freeciv-cvs/macros/gnome-guile-checks.m4
freeciv-guile/macros/gnome-guile-checks.m4
--- freeciv-cvs/macros/gnome-guile-checks.m4 Thu Jan 1 02:00:00 1970
+++ freeciv-guile/macros/gnome-guile-checks.m4 Wed May 26 01:10:20 1999
@@ -0,0 +1,126 @@
+dnl
+dnl GNOME_CHECK_GUILE (failflag)
+dnl
+dnl if failflag is "fail" then GNOME_CHECK_GUILE will abort if guile is not
found.
+dnl
+dnl Ripped from GNOME
+
+AC_SUBST(QTTHREADS_LIB)
+AC_SUBST(TERMCAP_LIB)
+AC_SUBST(READLINE_LIB)
+AC_SUBST(GUILE_LIBS)
+AC_SUBST(GUILE_INCS)
+
+AC_DEFUN([GNOME_CHECK_GUILE],
+[
+ saved_ldflags="$LDFLAGS"
+ saved_cppflags="$CPPFLAGS"
+ LDFLAGS="$LDFLAGS"
+
+ AC_CHECK_LIB(qthreads,main,[
+ QTTHREADS_LIB="-lqthreads"
+ ],[
+ AC_CHECK_LIB(qt, qt_null, QTTHREADS_LIB="-lqt")
+ ],$LIBS)
+ AC_SUBST(QTTHREADS_LIB)
+
+ AC_CHECK_LIB(termcap,main,TERMCAP_LIB="-ltermcap")
+ AC_CHECK_LIB(readline,main,READLINE_LIB="-lreadline",,$TERMCAP_LIB)
+
+ AC_SUBST(TERMCAP_LIB)
+ AC_SUBST(READLINE_LIB)
+
+ if test "x$cross_compiling" = "xyes" ; then
+ name_build_guile="$target_alias-guile-config"
+ else
+ name_build_guile="guile-config"
+ fi
+
+ AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
+
+ if test "x$BUILD_GUILE" = "xyes"; then
+ AC_MSG_CHECKING(whether $name_build_guile works)
+ if test x`$name_build_guile --version >/dev/null 2>&1 || \
+ echo no` = xno; then
+ BUILD_GUILE=no
+ fi
+ AC_MSG_RESULT($BUILD_GUILE)
+ else
+
+ if test "x$cross_compiling" = "xyes" ; then
+ name_build_guile="$target_alias-build-guile"
+ else
+ name_build_guile="build-guile"
+ fi
+
+ AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
+
+ if test "x$BUILD_GUILE" = "xyes"; then
+ AC_MSG_CHECKING(whether $name_build_guile works)
+ if test x`$name_build_guile --version >/dev/null 2>&1 || \
+ echo no` = xno; then
+ BUILD_GUILE=no
+ fi
+ AC_MSG_RESULT($BUILD_GUILE)
+ fi
+ fi
+
+ AC_CHECK_LIB(m, sin)
+
+ if test "x$BUILD_GUILE" = "xyes"; then
+ AC_MSG_CHECKING(for guile libraries)
+ GUILE_LIBS="`$name_build_guile link`"
+ AC_MSG_RESULT($GUILE_LIBS)
+ AC_MSG_CHECKING(for guile headers)
+ GUILE_INCS="`$name_build_guile compile`"
+ AC_MSG_RESULT($GUILE_INCS)
+ else
+ GUILE_LIBS=""
+ GUILE_INCS=""
+ AC_CHECK_LIB(rx, main, GUILE_LIBS="-lrx $GUILE_LIBS")
+ AC_CHECK_LIB(qt, main, GUILE_LIBS="-lqt $GUILE_LIBS")
+ AC_CHECK_LIB(dl, dlopen, GUILE_LIBS="-ldl $GUILE_LIBS")
+ AC_CHECK_LIB(nsl, t_accept, GUILE_LIBS="$GUILE_LIBS -lnsl")
+ AC_CHECK_LIB(socket, socket, GUILE_LIBS="$GUILE_LIBS -lsocket")
+ GUILE_LIBS="-lguile $GUILE_LIBS $QTTHREADS_LIB $READLINE_LIB
$TERMCAP_LIB"
+ fi
+
+ AC_SUBST(GUILE_LIBS)
+ AC_SUBST(GUILE_INCS)
+
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $GUILE_LIBS"
+ CPPFLAGS="$saved_cppflags $GUILE_INCS"
+
+ AC_MSG_CHECKING(whether guile works)
+ AC_TRY_LINK([
+ #include <libguile.h>
+ #include <guile/gh.h>
+ ],[
+ gh_eval_str("(newline)");
+ scm_boot_guile(0,NULL,NULL,NULL);
+ ],[
+ ac_cv_guile_found=yes
+ AC_DEFINE(HAVE_GUILE)
+ ],[
+ ac_cv_guile_found=no
+ ])
+ AC_MSG_RESULT($ac_cv_guile_found)
+
+ if test x$ac_cv_guile_found = xno ; then
+ if test x$1 = xfail ; then
+ AC_MSG_ERROR(Can not find Guile on this system)
+ else
+ AC_MSG_WARN(Can not find Guile on this system)
+ fi
+ ac_cv_guile_found=no
+ GUILE_LIBS= GUILE_INCS=
+ fi
+
+ LIBS="$saved_LIBS"
+ LDFLAGS="$saved_ldflags"
+ CPPFLAGS="$saved_cppflags"
+
+ AC_SUBST(GUILE_LIBS)
+ AM_CONDITIONAL(GUILE, test x$ac_cv_guile_found = xyes)
+])
diff -u --recursive --new-file --exclude-from=.diffignore
freeciv-cvs/macros/guile-gtk-checks.m4 freeciv-guile/macros/guile-gtk-checks.m4
--- freeciv-cvs/macros/guile-gtk-checks.m4 Thu Jan 1 02:00:00 1970
+++ freeciv-guile/macros/guile-gtk-checks.m4 Mon May 24 17:49:54 1999
@@ -0,0 +1,81 @@
+AC_DEFUN([FC_CHECK_GUILE_GTK],
+[
+AC_ARG_WITH(guile-gtk-prefix,[ --with-guile-gtk-prefix=PFX Prefix where
guile-gtk is installed (optional)],
+ guile_gtk_config_prefix="$withval", guile_gtk_config_prefix="")
+
+ saved_ldflags="$LDFLAGS"
+ saved_cppflags="$CPPFLAGS"
+ LDFLAGS="$LDFLAGS"
+
+ name_build_guile_gtk="build-guile-gtk"
+ if test "x$cross_compiling" = "xyes" ; then
+ name_build_guile_gtk="${target_alias}-$name_build_guile_gtk"
+ fi
+
+ if test "x$guile_gtk_config_prefix" != "x"; then
+ if test x${BUILD_GUILE_GTK+set} != xset ; then
+
name_build_guile_gtk="$guile_gtk_config_prefix/bin/$name_build_guile_gtk"
+ fi
+ fi
+
+ AC_PATH_PROG(BUILD_GUILE_GTK, $name_build_guile_gtk, yes, no)
+
+ if test "x$BUILD_GUILE_GTK" = "xyes"; then
+ AC_MSG_CHECKING(whether $name_build_guile_gtk works)
+ if test x`$name_build_guile_gtk cflags >/dev/null 2>&1 || \
+ echo no` = xno; then
+ BUILD_GUILE_GTK=no
+ fi
+ AC_MSG_RESULT($BUILD_GUILE_GTK)
+ fi
+
+ if test "x$BUILD_GUILE_GTK" = "xyes"; then
+ AC_MSG_CHECKING(for guile-gtk libraries)
+ GUILE_GTK_INCS="`$name_build_guile_gtk cflags`"
+ GUILE_GTK_LIBS="`$name_build_guile_gtk libs`"
+ AC_MSG_RESULT($GUILE_GTK_LIBS)
+ else
+ GUILE_GTK_LIBS=""
+ GUILE_GTK_INCS=""
+ GUILE_GTK_LIBS="-lguilegtk"
+ fi
+
+ AC_SUBST(GUILE_GTK_LIBS)
+ AC_SUBST(GUILE_GTK_INCS)
+
+ saved_LIBS="$LIBS"
+ LIBS="$LIBS $GUILE_GTK_LIBS"
+ CPPFLAGS="$saved_cppflags $GUILE_GTK_INCS"
+
+ AC_MSG_CHECKING(whether guile-gtk works)
+ AC_TRY_LINK([
+ #include <libguile.h>
+ #include <guile-gtk.h>
+ ],[
+ sgtk_init();
+ return(0);
+ ],[
+ ac_cv_guile_gtk_found=yes
+ AC_DEFINE(HAVE_GUILE_GTK)
+ ],[
+ ac_cv_guile_gtk_found=no
+ ])
+ AC_MSG_RESULT($ac_cv_guile_gtk_found)
+
+ if test x$ac_cv_guile_gtk_found = xno ; then
+ if test x$1 = xfail ; then
+ AC_MSG_ERROR(Can not find guile-gtk on this system)
+ else
+ AC_MSG_WARN(Can not find guile-gtk on this system)
+ fi
+ ac_cv_guile_gtk_found=no
+ GUILE_GTK_LIBS= GUILE_GTK_INCS=
+ fi
+
+ LIBS="$saved_LIBS"
+ LDFLAGS="$saved_ldflags"
+ CPPFLAGS="$saved_cppflags"
+
+ AC_SUBST(GUILE_GTK_LIBS)
+ AM_CONDITIONAL(GUILE_GTK, test x$ac_cv_guile_gtk_found = xyes)
+])
diff -u --recursive --new-file --exclude-from=.diffignore
freeciv-cvs/client/guile/hooks.scm freeciv-guile/client/guile/hooks.scm
--- freeciv-cvs/client/guile/hooks.scm Thu Jan 1 02:00:00 1970
+++ freeciv-guile/client/guile/hooks.scm Wed May 26 01:00:38 1999
@@ -0,0 +1,33 @@
+
+(define (fc-run-hook hook)
+ ((hook 'run)))
+
+(define (fc-add-hook hook def)
+ ((hook 'add) def))
+
+(define (fc-print-hook hook)
+ ((hook 'print)))
+
+(define (fc-make-hook)
+ (define hooks '())
+ (define (add def)
+ (set! hooks (append hooks (list def))))
+ (define (run)
+ (for-each
+ (lambda (x)
+ (eval x))
+ hooks))
+ (define (print)
+ (display hooks) (newline))
+ (define (dispatch m)
+ (cond ((eq? m 'run) run)
+ ((eq? m 'print) print)
+ ((eq? m 'add) add)))
+ dispatch)
+
+;; (define foo-hook (fc-make-hook))
+;; (fc-add-hook foo-hook '(display "Hei!\n"))
+;; (fc-add-hook foo-hook '(display "Hei2!\n"))
+
+;; (fc-run-hook foo-hook)
+;; (fc-print-hook foo-hook)
diff -u --recursive --new-file --exclude-from=.diffignore
freeciv-cvs/client/guile/Makefile.am freeciv-guile/client/guile/Makefile.am
--- freeciv-cvs/client/guile/Makefile.am Thu Jan 1 02:00:00 1970
+++ freeciv-guile/client/guile/Makefile.am Wed May 26 03:36:13 1999
@@ -0,0 +1,8 @@
+## Process this file with automake to produce Makefile.in
+
+Guilescriptsdir = $(datadir)/freeciv/guile
+
+Guilescripts_DATA = freeciv_startup.scm unit_production.scm
+
+EXTRA_DIST = $(Guilescripts_DATA)
+
diff -u --recursive --new-file --exclude-from=.diffignore
freeciv-cvs/client/include/guile_macros.h
freeciv-guile/client/include/guile_macros.h
--- freeciv-cvs/client/include/guile_macros.h Thu Jan 1 02:00:00 1970
+++ freeciv-guile/client/include/guile_macros.h Wed May 26 01:52:16 1999
@@ -0,0 +1,24 @@
+#ifndef FC__GUILE_MACROS_H
+#define FC__GUILE_MACROS_H 1
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_GUILE
+
+#include <libguile.h>
+#include <guile/gh.h>
+#include <guile-gtk.h>
+
+#define GUILE_MAKE_HOOK(hook) gh_eval_str("(define " hook "
(fc-make-hook))");+#define GUILE_RUN_HOOK(hook) gh_eval_str("(fc-run-hook "
hook ")");
+
+#else /* ! HAVE_GUILE */
+
+#define GUILE_RUN_HOOK(hook)
+#define GUILE_MAKE_HOOK(hook)
+
+#endif /* ! HAVE_GUILE */
+
+#endif /* FC__GUILE_MACROS_H */
--
//Markus
- [Freeciv-Dev] guile buindings,
Markus Linnala <=
|
|