
# Initializations.
CFLAGS =
CLEANFILES =
lib_LTLIBRARIES =

LOCALPWD=$(shell pwd)
SETGWPPATH= "(set! %load-path (cons \"${LOCALPWD}/..\" %load-path))"

# FIXME: these targets need to be changed to be vars so we can handle
# optional building for various targets.

gwrappedmoduledir=@GUILEMODDIR@/g-wrapped
gwrappedmodule_DATA = gw-runtime-spec.scm gw-runtime.scm

EXTRA_DIST=$(gwrappedmodule_DATA) check-runtime check-runtime.scm
EXTRA_DIST += .cvsignore

#BEGIN TEMP JUNK ============================================================

CFLAGS += -O2 -Wall -g -I../libruntime-guile @CFLAGS@

#I believe libtool won't allow this yet.
#EXTRA_LTLIBRARIES=libruntime.la

lib_LTLIBRARIES += libgw-runtime.la
libgw_runtime_la_SOURCES = gw-runtime.c

# are we supposed to use -rpath here?  info pages suggest not.

libgw_runtime_la_LDFLAGS = -rpath $(libdir) -module -export-dynamic
#libgw_runtime_la_LIBADD = \
#  @GUILE_LIBS@ \
#  -L$(LOCALPWD)/../libruntime-guile/.libs -lg-wrap-runtime-guile

libgw_runtime_la_LIBADD = \
  @GUILE_LIBS@ \
  ../libruntime-guile/libg-wrap-runtime-guile.la


#END TEMP JUNK ===============================================================


# This must be built before we can build the examples...
$(LOCALPWD)/../libruntime-guile/.libs/libg-wrap-runtime-guile.so:
	(cd ../libruntime-guile && ${MAKE})

# include a dependency on g-wrap so we're sure we built everything.
gw-runtime.scm gw-runtime.c gw-runtime.h gw-runtime.html: gw-runtime-spec.scm
	guile -c \
          ${SETGWPPATH}"(use-modules (g-wrap)) \
                        (use-modules (g-wrapped gw-runtime-spec)) \
                        (gw:generate-module \"gw-runtime\")"

#(debug-enable 'backtrace) \
#	                (debug-enable 'debug) \
#	                (read-enable 'positions) \
#

CLEANFILES+=gw-runtime.scm
CLEANFILES+=gw-runtime.h
CLEANFILES+=gw-runtime.c
CLEANFILES+=gw-runtime.html

# We have to do this because otherwise automake insists on putting
# these files into the dist tarfile.  If there's a a better way,
# by all means, let us know...
dist-hook:
	rm ${distdir}/gw-runtime.c
