# Scheme 48 Makefile
# Part of Scheme 48 1.9.  See file COPYING for notices and license.

# Authors: Richard Kelsey, Jonathan Rees, Marcus Crestani,
# Robert Ransom, Michael Zabka, Harald Glab-Phlak, David Frese,
# Thorsten Alteholz.

# Documentation in files INSTALL and doc/install.txt

SHELL = /bin/sh

### Filled in by `configure' ###
srcdir = @srcdir@
VPATH = @srcdir@
CC = @CC@
LD = @LD@
DEFS = @DEFS@
LIBS = @LIBS@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@

LDFLAGS = @LDFLAGS@
LDFLAGS_VM = @LDFLAGS_VM@
LIBOBJS = @LIBOBJS@

GC_OBJS = @GC_OBJS@

ADDITIONAL_EXTERNALS = @ADDITIONAL_EXTERNALS@
ADDITIONAL_EXTERNAL_OBJS = @ADDITIONAL_EXTERNAL_OBJS@

ASM_OBJECTS = @ASM_OBJECTS@
ASM_STYLE = @ASM_STYLE@

HOST_ARCHITECTURE = @host@
BIT_SUFFIX = @BIT_SUFFIX@

prefix = @prefix@
exec_prefix = @exec_prefix@

bindir = @bindir@
libdir = @libdir@
incdir = @includedir@
manext = 1
mandir = @mandir@/man$(manext)
docdir = @docdir@
datarootdir = @datarootdir@
datadir = @datadir@

DYNAMIC_EXTERNALS_CFLAGS=@DYNAMIC_EXTERNALS_CFLAGS@
DYNAMIC_EXTERNALS_LDFLAGS=@DYNAMIC_EXTERNALS_LDFLAGS@
DYNAMIC_EXTERNALS_LDFLAGS_IN_PLACE=@DYNAMIC_EXTERNALS_LDFLAGS_IN_PLACE@
### End of `configure' section###

# HP 9000 series, if you don't have gcc
#   CC = cc
#   CFLAGS = -Aa -O +Obb1800
#   DEFS = -D_HPUX_SOURCE -Dhpux

# Ultrix
#   LDFLAGS = -N

COMPILING_ITSELF_DEFS = $(DEFS) -D__COMPILING_SCHEME48_ITSELF__ -DS48_HOST_ARCHITECTURE=\"$(HOST_ARCHITECTURE)\"

.c.o:
	$(CC) -c $(CPPFLAGS) $(COMPILING_ITSELF_DEFS) -I ./c -I$(srcdir)/c -I$(srcdir)/c/net -I$(srcdir)/c/bibop $(CFLAGS) -o $@ $<

# You might want to change RUNNABLE to "s48"
VERSION = 1.`cat $(srcdir)/build/minor-version-number`
RUNNABLE = scheme48
CONFIG_SCRIPT = scheme48-config
MANPAGE = $(RUNNABLE).$(manext)
LIB = $(libdir)/scheme48-$(VERSION)
SHARE = $(datadir)/scheme48-$(VERSION)

distdir = /tmp

# If make barfs on this include line, just comment it out.  It's only
# really needed if you want to build the linker or rebuild initial.image.
include $(srcdir)/build/filenames.make
#
#NetBSD make wants to see this instead:
#.include "$(srcdir)/build/filenames.make"


# Static linker:
#
# You only need the linker if you're going to make changes to the
# things that go into the initial.image, which in general means the
# files in rts/.  If you decide you need to use the linker, then you
# gots your choice; it can run in just about any version of Scheme 48
# or Pseudoscheme.  (It has also been made to run in Scheme->C.)  It
# doesn't matter a whole lot which Scheme you use as long as it's not
# broken or unavailable.  The two best choices are:
#
# 1. As below.
#    These settings requires you to already have a $(RUNNABLE)
#    command.  This is desirable if you are making changes to the
#    system that might break scheme48vm and/or scheme48.image.  But it
#    requires you to have squirreled away a previous working version
#    of scheme48.  The settings assume a Unicode version; if you want
#    to use an installed non-Unicode-capable Scheme 48 (1.4 or earlier),
#    you need to use this setting:
#    LINKER_WRITEBYTE = ,load scheme/alt/write-byte.scm
#
# 2. LINKER_VM = ./$(VM) $(BIG_HEAP)
#    LINKER_RUNNABLE = $(LINKER_VM) -i $(IMAGE)
#    LINKER_WRITEBYTE = ,open (subset i/o (write-byte)) (subset ports (set-port-crlf?!))
#    This builds the linker on the scheme48vm and scheme48.image
#    that are in the current directory.

BIG_HEAP = -h 8000000
LINKER_VM = $(RUNNABLE) $(BIG_HEAP)
LINKER_RUNNABLE = $(LINKER_VM)
LINKER_WRITEBYTE = ,open (subset i/o (write-byte)) (subset ports (set-port-crlf?!))
START_LINKER-32 = echo ',batch';				\
	       echo ',bench on';				\
	       echo ',open signals features code-quote';	\
	       echo ',open bitwise ascii code-vectors';		\
	       echo '$(LINKER_WRITEBYTE)';			\
	       echo ',config ,load scheme/platform-interfaces.scm'; \
	       echo ',config ,load scheme/rts-packages-32.scm'; \
	       echo ',open platform';	\
	       echo ',open cells record-types';	\
	       echo ',load scheme/alt/low-exception.scm';	\
	       echo ',load $(linker-files)';			\
	       echo ',load scheme/alt/init-defpackage.scm'

START_LINKER-64 = echo ',batch';				\
	       echo ',bench on';				\
	       echo ',open signals features code-quote';	\
	       echo ',open bitwise ascii code-vectors';		\
	       echo '$(LINKER_WRITEBYTE)';			\
	       echo ',config ,load scheme/platform-interfaces.scm'; \
	       echo ',config ,load scheme/rts-packages-64.scm'; \
	       echo ',open platform';	\
	       echo ',open cells record-types';	\
	       echo ',load scheme/alt/low-exception.scm';	\
	       echo ',load $(linker-files)';			\
	       echo ',load scheme/alt/init-defpackage.scm'

# --------------------
# You shouldn't have to change anything below this point.

# Targets:

IMAGE = scheme48.image
INITIAL = $(srcdir)/build/initial.image
VM = scheme48vm
LIBSCHEME48 = c/libscheme48.a
POSIX_EXTERNAL = c/posix.so
SRFI_27_EXTERNAL = c/srfi-27.so
FFI_TEST_EXTERNAL = c/ffi-test.so
R6RS_EXTERNAL = c/r6rs.so
EXTERNALS = $(POSIX_EXTERNAL) $(SRFI_27_EXTERNAL) $(FFI_TEST_EXTERNAL) $(ADDITIONAL_EXTERNALS) $(R6RS_EXTERNAL)
UNIX_OBJS = c/unix/misc.o c/unix/io.o c/unix/fd-io.o c/unix/event.o c/unix/time.o
OBJS =	c/scheme48vm-$(BIT_SUFFIX).o \
	c/extension.o c/free.o c/double_to_string.o c/bignum.o c/ffi.o \
	c/external.o c/external-lib.o c/external-init.o c/init.o

FAKEHS	= c/fake/dlfcn.h c/fake/sigact.h c/fake/strerror.h \
		c/fake/sys-select.h c/fake/langinfo.h

SCHEME48HS = c/scheme48.h c/scheme48arch.h c/scheme48write-barrier.h

# Sources:

CONFIG_FILES = scheme/interfaces.scm scheme/packages.scm \
	       scheme/vm/shared-interfaces.scm	\
	       scheme/low-packages.scm scheme/rts-packages.scm \
	       scheme/comp-packages.scm scheme/initial-packages.scm

# Rules:

.PHONY: enough all clean install man doc dist

# The following is the first rule and therefore the "make" command's
# default target.
enough: Makefile vm $(LIBSCHEME48) $(IMAGE) script-interpreter go
enough: $(EXTERNALS)

Makefile: ${srcdir}/Makefile.in config.status
	./config.status
	$(MAKE) clean
	$(MAKE)

# --------------------
# External code to include in the VM
# After changing any of these you should delete `scheme48vm' and remake it.

EXTERNAL_OBJECTS = c/net/socket.o c/net/address.o c/net/net.o c/unix/socket.o \
		   c/unix/dynlink.o \
		   c/unix/sysexits.o $(ASM_OBJECTS) \
		   $(ADDITIONAL_EXTERNAL_OBJS)

# POSIX rules; this could have its own Makefile, but I don't want to bother.

posix_dir = c/posix

CC_POSIX = $(CC) -c $(CPPFLAGS) $(DEFS) -I ./c -I$(srcdir)/c -I$(srcdir)/c/bibop $(CFLAGS) $(DYNAMIC_EXTERNALS_CFLAGS) -o $@ $<

$(posix_dir)/user.o: c/posix/user.c \
	$(SCHEME48HS) c/c-mods.h $(posix_dir)/posix.h
	$(CC_POSIX)

$(posix_dir)/regexp.o: c/posix/regexp.c \
	$(SCHEME48HS) c/c-mods.h $(posix_dir)/posix.h
	$(CC_POSIX)

$(posix_dir)/proc-env.o: c/posix/proc-env.c \
	$(SCHEME48HS) c/c-mods.h $(posix_dir)/posix.h
	$(CC_POSIX)

$(posix_dir)/io.o: c/posix/io.c \
	$(SCHEME48HS) c/c-mods.h $(posix_dir)/posix.h
	$(CC_POSIX)

$(posix_dir)/proc.o: c/posix/proc.c \
	$(SCHEME48HS) c/c-mods.h \
	c/event.h $(posix_dir)/posix.h $(posix_dir)/s48_signals.h
	$(CC_POSIX)

$(posix_dir)/errno.o: c/posix/errno.c \
	$(SCHEME48HS) c/c-mods.h \
	c/event.h $(posix_dir)/posix.h $(posix_dir)/s48_errno.h
	$(CC_POSIX)

$(posix_dir)/syslog.o: c/posix/syslog.c \
	$(SCHEME48HS)
	$(CC_POSIX)

$(posix_dir)/posix.o: c/posix/posix.c
	$(CC_POSIX)

$(posix_dir)/dir.o: c/posix/dir.c \
  $(SCHEME48HS) c/scheme48heap.h c/c-mods.h \
  c/event.h c/fd-io.h $(posix_dir)/posix.h
	$(CC_POSIX)

$(posix_dir)/time.o: c/posix/time.c \
	$(SCHEME48HS) c/c-mods.h $(posix_dir)/posix.h
	$(CC_POSIX)

POSIX_OBJECTS = $(posix_dir)/user.o     $(posix_dir)/regexp.o	\
                $(posix_dir)/proc-env.o $(posix_dir)/proc.o	\
                $(posix_dir)/io.o	$(posix_dir)/dir.o	\
		$(posix_dir)/posix.o	$(posix_dir)/time.o	\
		$(posix_dir)/errno.o	$(posix_dir)/syslog.o

$(POSIX_EXTERNAL) : $(POSIX_OBJECTS)
	$(LD) -o $@ $(POSIX_OBJECTS) $(DYNAMIC_EXTERNALS_LDFLAGS_IN_PLACE)


# End of POSIX rules

# R6RS native support

r6rs_dir = c/r6rs

$(r6rs_dir)/ieee_bytevect.o: c/r6rs/ieee_bytevect.c \
	$(SCHEME48HS)
	$(CC) -c $(CPPFLAGS) $(DEFS) -I ./c -I$(srcdir)/c -I$(srcdir)/c/bibop $(CFLAGS) $(DYNAMIC_EXTERNALS_CFLAGS) -o $@ $<

$(r6rs_dir)/r6rs_externals.o: c/r6rs/r6rs_externals.c \
	$(SCHEME48HS)
	$(CC) -c $(CPPFLAGS) $(DEFS) -I ./c -I$(srcdir)/c -I$(srcdir)/c/bibop $(CFLAGS) $(DYNAMIC_EXTERNALS_CFLAGS) -o $@ $<

R6RS_OBJECTS = $(r6rs_dir)/ieee_bytevect.o $(r6rs_dir)/r6rs_externals.o

$(R6RS_EXTERNAL) : $(R6RS_OBJECTS)
	$(LD) -o $@ $(R6RS_OBJECTS)  $(DYNAMIC_EXTERNALS_LDFLAGS_IN_PLACE) 


c/srfi-27.o: c/srfi-27.c $(SCHEME48HS)
	$(CC) -c $(CPPFLAGS) $(DEFS) -I ./c -I$(srcdir)/c -I$(srcdir)/c/bibop $(CFLAGS) $(DYNAMIC_EXTERNALS_CFLAGS) -o $@ $<

$(SRFI_27_EXTERNAL) : c/srfi-27.o
	$(LD) -o $@  c/srfi-27.o $(DYNAMIC_EXTERNALS_LDFLAGS_IN_PLACE)


c/ffi-test/ffi-test.o: c/ffi-test/ffi-test.c c/ffi-test/ffi-test.h $(SCHEME48HS)
	$(CC) -c $(CPPFLAGS) $(DEFS) -I ./c -I$(srcdir)/c -I$(srcdir)/c/bibop $(CFLAGS) $(DYNAMIC_EXTERNALS_CFLAGS) -o $@ $<

$(FFI_TEST_EXTERNAL) : c/ffi-test/ffi-test.o
	$(LD) -o $@ c/ffi-test/ffi-test.o $(DYNAMIC_EXTERNALS_LDFLAGS_IN_PLACE)


# Native-code glue rules

# Fake definitions if there is no support for native code
FAKE_ASM_OBJECTS = c/fake/glue.o

# Real definitions to be used when a. native code works and b. it is supported
# on the machine we're compiling on
# Does currently not work because of the new GC infrastructure
X86_ASM_OBJECTS = c/glue.o c/asm-glue.o

# Assumes s48-compiler/ in the working directory

c/glue.o: c/glue_$(ASM_STYLE).s
	gcc -c -o $@ $<

c/glue_$(ASM_STYLE).s: s48-compiler/assembler/x86/x86-glue.scm
	(echo ',batch';						\
	 echo ',open srfi-23';					\
	 echo ',load $<';					\
	 echo '(glue-code "$@" (quote $(ASM_STYLE)))';		\
	 echo ',exit'						\
	) | $(RUNNABLE)
# End of native-code glue rules

# Two-space copier objects

GC_TWOSPACE_OBJS = c/scheme48-twospace-heap-$(BIT_SUFFIX).o

c/scheme48-twospace-heap-$(BIT_SUFFIX).o: c/prescheme.h c/scheme48vm.h c/scheme48heap.h \
			c/scheme48vm-prelude.h c/c-mods.h \
			c/event.h c/io.h c/fd-io.h

# The BIBOP Garbage Collector
GC_BIBOP_OBJS =  c/scheme48-bibop-heap-$(BIT_SUFFIX).o \
	c/bibop/page_alloc.o c/bibop/memory_map.o c/bibop/areas.o \
	c/bibop/generation_gc.o c/bibop/find_all.o c/bibop/check_heap.o \
	c/bibop/utils.o c/bibop/area_roots.o c/bibop/remset.o

bibop: $(GC_BIBOP_OBJS)

c/scheme48-bibop-heap-$(BIT_SUFFIX).o: c/prescheme.h c/scheme48vm.h c/scheme48heap.h \
			c/scheme48vm-prelude.h \
			c/bibop/bibop.h \
			c/c-mods.h c/event.h c/io.h c/fd-io.h

c/bibop/page_alloc.o: c/bibop/page_alloc.h c/bibop/page_constants.h            \
	c/bibop/memory.h
c/bibop/memory_map.o: c/bibop/memory_map.h c/bibop/utils.h                     \
	c/bibop/page_constants.h
c/bibop/areas.o: c/bibop/areas.h c/bibop/page_constants.h c/bibop/utils.h      \
	c/bibop/memory_map.h c/bibop/area_roots.h c/bibop/gc_config.h          \
	c/bibop/remset.h
c/bibop/generation_gc.o: c/bibop/generation_gc.h c/bibop/page_constants.h      \
	c/bibop/areas.h c/bibop/memory.h c/bibop/data.h c/bibop/utils.h        \
	c/bibop/memory_map.h c/bibop/check_heap.h c/bibop/area_roots.h         \
	c/bibop/measure.h c/bibop/measure.ci 				       \
	c/bibop/gc_config.h c/bibop/remset.h				       \
	$(SCHEME48HS)
c/bibop/find_all.o: c/bibop/find_all.h c/bibop/generation_gc.h c/bibop/areas.h \
	c/bibop/data.h c/bibop/memory.h					       \
	$(SCHEME48HS)
c/bibop/check_heap.o: c/bibop/check_heap.h c/scheme48.h c/bibop/generation_gc.h\
	c/bibop/utils.h c/bibop/data.h c/bibop/memory.h c/bibop/memory_map.h   \
	$(SCHEME48HS)
c/bibop/area_roots.o: c/bibop/area_roots.h c/bibop/areas.h c/bibop/memory.h    \
	c/bibop/memory_map.h c/bibop/measure.h c/bibop/gc_config.h             \
	c/bibop/remset.h
c/bibop/remset.o: c/bibop/remset.h c/bibop/memory.h c/scheme48.h	       \
	c/bibop/utils.h c/bibop/data.h c/bibop/generation_gc.h 		       \
	c/bibop/gc_config.h						       \
	$(SCHEME48HS)


# End of BIBOP GC rules

$(VM): c/main.o $(LIBSCHEME48) c/scheme48.exp c/scheme48.def
	$(CC) $(LDFLAGS) $(LDFLAGS_VM) $(CFLAGS) $(CPPFLAGS) -o $@ c/main.o	$(LIBSCHEME48) $(LIBS)
	# Cygwin
	if test -x /usr/bin/dlltool; then \
		dlltool --dllname $(VM).exe --output-lib $(VM).a --def $(srcdir)/c/scheme48.def; \
	fi

$(LIBSCHEME48): $(OBJS) $(GC_OBJS) $(UNIX_OBJS) $(LIBOBJS) $(EXTERNAL_OBJECTS)
	rm -f $@;							\
	ar cq $@ $(OBJS) $(GC_OBJS) $(UNIX_OBJS) $(LIBOBJS) $(EXTERNAL_OBJECTS)
	ranlib $@

script-interpreter: c/script-interpreter.o
	$(CC) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) -o $@ c/script-interpreter.o

c/main.o: c/main.c c/scheme48vm.h c/scheme48heap.h
	$(CC) -c $(CFLAGS) -o $@ \
		-DDEFAULT_IMAGE_NAME=\"$(LIB)/$(IMAGE)\" \
		$(CPPFLAGS) $(COMPILING_ITSELF_DEFS) $(srcdir)/c/main.c

c/scheme48vm-$(BIT_SUFFIX).o: c/prescheme.h c/scheme48vm.h \
		c/scheme48heap.h \
		c/scheme48image.h c/bignum.h c/event.h \
		c/io.h c/fd-io.h \
		c/scheme48vm-prelude.h c/c-mods.h \
		$(SCHEME48HS)

c/bignum.o: c/bignum.h c/bignumint.h $(SCHEME48HS)
c/extension.o: c/sysdep.h $(FAKEHS) $(SCHEME48HS) c/scheme48vm.h
c/free.o: c/sysdep.h
c/ffi.o: c/ffi.h $(SCHEME48HS)
c/external.o: c/sysdep.h $(FAKEHS) $(SCHEME48HS) c/c-mods.h c/ffi.h
c/external-lib.o: $(SCHEME48HS)
c/unix/event.o: c/sysdep.h $(FAKEHS) c/c-mods.h \
			c/scheme48vm.h c/scheme48heap.h \
			c/event.h c/fd-io.h \
			c/c-mods.h
c/unix/fd-io.o: c/sysdep.h $(FAKEHS) c/c-mods.h \
			c/scheme48vm.h c/scheme48heap.h \
			c/event.h c/fd-io.h 
c/unix/misc.o: c/sysdep.h $(FAKEHS)
c/unix/io.o: c/io.h

c/net/address.o: $(SCHEME48HS) c/net/address.h
c/net/socket.o: $(SCHEME48HS) c/net/address.h c/net/socket.h
c/unix/socket.o: $(SCHEME48HS) c/net/address.h c/net/socket.h c/fd-io.h c/event.h
c/net/net.o: $(SCHEME48HS)
c/unix/dynlink.o: $(SCHEME48HS)

c/script-interpreter.o: c/sysdep.h $(FAKEHS) c/script-interpreter.c
	$(CC) -c $(CFLAGS) -o $@ \
		-DRUNNABLE=\"$(bindir)/$(RUNNABLE)\" \
		$(CPPFLAGS) $(DEFS) \
		-I ./c -I$(srcdir)/c \
		$(srcdir)/c/script-interpreter.c
c/fake/strerror.o: c/fake/strerror.h
c/fake/langinfo.o: c/fake/langinfo.h

# --------------------
# Make scheme48.image from initial.image and library .scm files.
#
# For bootstrap reasons, initial.image is *not* listed as a source,
# even though it really is.

$(IMAGE): $(VM) scheme/env/init-defpackage.scm scheme/more-interfaces.scm \
		scheme/link-packages.scm \
		scheme/env-packages.scm \
		scheme/more-packages.scm \
		scheme/sort/interfaces.scm scheme/sort/packages.scm \
		scheme/r6rs/packages.scm \
		scheme/cml/interfaces.scm scheme/cml/packages.scm \
		scheme/net/packages.scm	\
		scheme/posix/packages.scm scheme/srfi/packages.scm \
		$(usual-files) build/initial.debug build/build-usual-image
	$(srcdir)/build/build-usual-image $(srcdir) \
		"`(cd $(srcdir) && pwd)`/scheme" "`pwd`/c" '$(IMAGE)' './$(VM)' \
		'$(INITIAL)-$(BIT_SUFFIX)'

# --------------------
# Documentation

MANUAL_SRC = doc/src/manual.tex doc/src/bibliography.tex	      \
  doc/src/bibliography.tex					      \
  doc/src/code.tex doc/src/command.tex doc/src/external.tex	      \
  doc/src/hacks.tex doc/src/intro.tex				      \
  doc/src/module.tex doc/src/myindex.tex			      \
  doc/src/posix.tex doc/src/proto.tex				      \
  doc/src/thread.tex doc/src/unicode.tex doc/src/user-guide.tex	      \
  doc/src/utilities.tex doc/src/version-number.tex doc/src/matter.sty \

doc/manual.pdf: $(MANUAL_SRC)
	cd $(srcdir)/doc/src && pdflatex manual && \
	  makeindex manual && \
	  pdflatex manual && pdflatex manual
	mv $(srcdir)/doc/src/manual.pdf $(srcdir)/doc

doc/manual.ps: $(MANUAL_SRC)
	cd $(srcdir)/doc/src && latex manual && \
	  makeindex manual && \
	  latex manual && latex manual && \
	  dvips manual
	mv $(srcdir)/doc/src/manual.ps $(srcdir)/doc

doc/html/manual.html: doc/manual.pdf
	cd $(srcdir)/doc/src && tex2page manual && tex2page manual && tex2page manual

doc: doc/manual.pdf doc/manual.ps doc/html/manual.html

install: install-no-doc install-doc

install-no-doc: enough dirs
# install the VM
	$(INSTALL_PROGRAM) $(VM) $(DESTDIR)$(LIB)
	if test -e $(VM).a; then $(INSTALL_PROGRAM) $(VM).a $(DESTDIR)$(LIB); fi
# build and install the image
	rm -f '/tmp/$(IMAGE)'
	$(srcdir)/build/build-usual-image $(srcdir) "$(SHARE)" "$(LIB)" \
		"/tmp/$(IMAGE)" "./$(VM)" "$(INITIAL)-$(BIT_SUFFIX)"
	$(INSTALL_DATA) /tmp/$(IMAGE) $(DESTDIR)$(LIB)
	rm /tmp/$(IMAGE)
# install the man pages
	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
	sed 's=LBIN=$(bindir)=g' $(srcdir)/doc/scheme48.man |	   \
		sed "s=LLIB=$(LIB)=g" |				   \
		sed "s=LS48=$(RUNNABLE)=g" >$(MANPAGE)
	$(INSTALL_DATA) $(MANPAGE) $(DESTDIR)$(mandir)
	rm $(MANPAGE)
# install the include files
	$(INSTALL_DATA) $(srcdir)/c/scheme48.h $(DESTDIR)$(incdir)
	$(INSTALL_DATA) c/scheme48arch.h $(DESTDIR)$(incdir)
	$(INSTALL_DATA) $(srcdir)/c/scheme48write-barrier.h $(DESTDIR)$(incdir)
	$(INSTALL_DATA) $(srcdir)/c/scheme48.exp $(DESTDIR)$(incdir)
	$(INSTALL_DATA) $(srcdir)/c/scheme48.def $(DESTDIR)$(incdir)
	$(INSTALL_DATA) $(srcdir)/c/scheme48-external.exp $(DESTDIR)$(incdir)
# install Scheme source files
	for stub in env big sort opt misc link posix net cml srfi r6rs; do	\
		for f in $(srcdir)/scheme/$$stub/*.scm; do		\
			$(INSTALL_DATA) $$f $(DESTDIR)$(SHARE)/$$stub || exit 1;	\
		done;							\
	done
	for f in $(srcdir)/scheme/rts/*num.scm 				\
		 $(srcdir)/scheme/rts/jar-defrecord.scm; do		\
		$(INSTALL_DATA) $$f $(DESTDIR)$(SHARE)/rts || exit 1;	\
	done
# install the scheme48 script
	script=$(DESTDIR)$(bindir)/$(RUNNABLE) &&			\
	LIB=$(LIB) &&							\
	echo "#!/bin/sh"	>$$script &&				\
	echo			>>$$script &&				\
	echo "lib=$$LIB"	>>$$script &&				\
	echo 'exec $$lib/$(VM) -i $$lib/$(IMAGE) "$$@"'			\
				>>$$script &&				\
	chmod +x $$script
# install the script interpreter front end
	for dialect in r5rs srfi-7; do					\
		$(INSTALL_PROGRAM) script-interpreter			\
			$(DESTDIR)$(bindir)/scheme-$$dialect;		\
	done
# install the scheme48-config script
	config_script=$(DESTDIR)$(bindir)/$(CONFIG_SCRIPT) &&		\
	sed -e 's,@incdir\@,$(incdir),g'				\
	    -e 's,@libdir\@,$(libdir),g'				\
	    -e 's,@CC\@,$(CC),g'					\
	    -e 's,@LD\@,$(LD),g'					\
	    -e 's?@DYNAMIC_EXTERNALS_CFLAGS\@?$(DYNAMIC_EXTERNALS_CFLAGS)?g' \
	    -e 's?@DYNAMIC_EXTERNALS_LDFLAGS\@?$(DYNAMIC_EXTERNALS_LDFLAGS)?g' \
	< $(srcdir)/build/$(CONFIG_SCRIPT).in > $$config_script &&	\
	chmod +x $$config_script
# install the external modules
	$(INSTALL_PROGRAM) $(EXTERNALS) $(DESTDIR)$(LIB)/
# install the documentation
	$(srcdir)/mkinstalldirs $(DESTDIR)$(docdir)
	$(INSTALL_DATA) $(srcdir)/COPYING $(DESTDIR)$(docdir)

install-doc: dirs doc
	$(srcdir)/mkinstalldirs $(DESTDIR)$(docdir)
	$(INSTALL_DATA) $(srcdir)/COPYING $(DESTDIR)$(docdir)
	$(INSTALL_DATA) $(srcdir)/doc/manual.pdf $(DESTDIR)$(docdir)
	$(INSTALL_DATA) $(srcdir)/doc/manual.ps $(DESTDIR)$(docdir)
	for f in $(srcdir)/doc/html/*; do \
		$(INSTALL_DATA) $$f $(DESTDIR)$(docdir) || exit 1; \
	done

# Script to run scheme48 in this directory.
go:
	echo '#!/bin/sh'	>$@ &&					\
	echo			>>$@ &&					\
	echo "lib=\"`pwd`\""	>>$@ &&					\
	echo 'exec "$$lib"/$(VM) -i "$$lib"/$(IMAGE) "$$@"'		\
				>>$@ &&					\
	chmod +x $@

# Exports file for AIX and Cygwin

CAT_EXPORTS = cat $(srcdir)/c/scheme48.h $(srcdir)/c/fd-io.h $(srcdir)/c/event.h $(srcdir)/c/bibop/*.h | egrep '^S48_EXTERN' | sed 's,^S48_EXTERN.*\(s48_[a-zA-Z0-9_ ]*\)(.*$$,\1,' | sed 's,^S48_EXTERN.*\(ps_[a-zA-Z0-9_ ]*\)(.*$$,\1,' | sed 's,^S48_EXTERN.*\(s48_[a-zA-Z0-9_ ]*\).*$$,\1,'

c/scheme48.exp: c/scheme48.h c/fd-io.h c/event.h
	echo '#!..' > $(srcdir)/c/scheme48.exp &&			\
	$(CAT_EXPORTS) >> $(srcdir)/c/scheme48.exp

c/scheme48.def: c/scheme48.h c/fd-io.h c/event.h
	echo 'EXPORTS' > $(srcdir)/c/scheme48.def &&			\
	$(CAT_EXPORTS) >> $(srcdir)/c/scheme48.def

dirs:
	for dir in $(libdir) $(bindir) $(incdir) $(datadir); do		 \
		$(srcdir)/mkinstalldirs $(DESTDIR)$$dir || exit 1;	 \
	done
	$(srcdir)/mkinstalldirs $(DESTDIR)$(LIB)
	for dir in rts env big sort opt misc link posix net cml srfi r6rs; do   \
		$(srcdir)/mkinstalldirs $(DESTDIR)$(SHARE)/$$dir || exit 1; \
	done

configure: configure.in
	ACLOCAL="aclocal -I m4" autoreconf -v -i

clean:
	-rm -f $(VM) script-interpreter					\
		*.o c/unix/*.o c/posix/*.o c/net/*.o c/*.o 		\
		$(EXTERNALS)						\
		c/fake/*.o c/bibop/*.o					\
		c/*.a c/glue_gnu.s c/glue_darwin.s c/scheme48.exp 	\
		TAGS $(IMAGE)						\
		$(srcdir)/build/*.tmp $(srcdir)/$(MANPAGE) 		\
		$(srcdir)/scheme/debug/*.image 				\
		$(srcdir)/scheme/debug/*.debug 				\
		$(srcdir)/scheme/vm/scheme48vm-??.c 			\
		$(srcdir)/scheme/vm/scheme48*heap-??.c			\
		go $(distname)

distclean: clean
	rm -f Makefile config.log config.status config-cache \
		c/sysdep.h c/scheme48arch.h

check: $(EXTERNALS)
check: $(VM) $(IMAGE) scheme/debug/check.scm
	(								\
		echo ',batch';						\
		echo ',exec ,load =scheme48/debug/check.scm';		\
		echo ',config ,load =scheme48/test-packages.scm';	\
		echo ',open base-test';					\
		echo ',open big-test';					\
		echo ',open sockets-test';				\
		echo ',open os-time-test';				\
		echo ',open tconc-queue-test';				\
		echo ',open transport-link-cell-test';			\
		echo ',open tlc-table-test';				\
		echo ',open env-test';					\
		echo ',config ,load =scheme48/sort/test-packages.scm';	\
		echo ',open sort-test';					\
		echo ',config ,load =scheme48/misc/packages.scm';	\
		echo ',config ,load =scheme48/misc/test-packages.scm';	\
		echo ',open misc-test';					\
		echo ',config ,load =scheme48/r6rs/test-packages.scm';	\
		echo ',open r6rs-test';					\
		echo ',config ,load =scheme48/cml/test-packages.scm';	\
		echo ',open cml-test';					\
		echo ',config ,load =scheme48/srfi/test-packages.scm';	\
		echo ',open srfi-test';					\
		echo ',config ,load =scheme48/posix/test-packages.scm';	\
		echo ',open posix-test';				\
		echo ',config ,load =scheme48/ffi-test/test-packages.scm';	\
		echo ',open ffi-test';					\
		echo ',open test-suites';				\
		echo '(define-test-suite all-tests (compiler-tests base-tests big-tests tcp-sockets-tests tconc-queue-tests transport-link-cell-tests tlc-table-tests tlc-table-weak-tests tlc-table-string-tests os-time-tests sort-tests misc-tests env-tests r6rs-tests cml-tests srfi-tests posix-tests ffi-tests))'; \
		echo '(run-test-suite all-tests)'			\
	) | ./$(VM) -i $(IMAGE) $(BIG_HEAP)

# --------------------
# Rules from here on down are not essential for the basic installation
# procedure.

all: vm image $(LIBSCHEME48) script-interpreter go doc
libscheme48: $(LIBSCHEME48)
vm: $(VM)
image: $(INITIAL)-$(BIT_SUFFIX)
	$(MAKE) $(IMAGE)
test: check

tags:
	find . -name "*.scm" -o -name "*.c" -o -name "*.h" | etags -

# --------------------
# Distribution...

# DISTFILES should include all sources.
DISTFILES = README COPYING.rtf COPYING INSTALL WINDOWS.txt		\
		configure configure.in config.sub config.guess 		\
		Makefile.in 						\
		scheme48.sln scheme48.vcxproj				\
		srfi-27.vcxproj r6rs.vcxproj				\
		ffi-test.vcxproj					\
		mkinstalldirs install-sh				\
		doc/*.ps doc/*.pdf doc/*.txt 				\
		doc/html/*.html doc/html/*.css doc/html/*.gif 		\
		doc/src/*.tex doc/src/*.sty doc/src/*.scm		\
		doc/scheme48.man					\
		emacs/README 						\
		build/*.scm build/*-version-number build/*.exec		\
		build/*.lisp build/build-usual-image build/filenames.make \
		build/initial.debug 					\
		build/initial.image-32 build/initial.image-64		\
		build/*.bat build/*.sh build/*.rc			\
		build/UnicodeData.txt build/PropList.txt		\
		build/SpecialCasing.txt build/CaseFolding.txt		\
		build/CompositionExclusions.txt				\
		build/dummy build/*.wxs build/*.ico			\
		build/scheme48-config.in				\
		c/*.[ch] c/*/*.[ch] c/*/*.ci c/*.exp c/*.def		\
		c/scheme48.h.in						\
		c/scheme48write-barrier.h c/scheme48arch.h.in		\
		c/sysdep.h.in						\
		emacs/*.el gdbinit					\
		scheme/*.scm scheme/*/*.scm scheme/vm/*/*.scm		\
		ps-compiler/minor-version-number			\
		ps-compiler/doc/node.txt ps-compiler/doc/todo.txt	\
		ps-compiler/*.scm ps-compiler/*/*.scm			\
		ps-compiler/prescheme/primop/*.scm			\
		ps-compiler/prescheme/test/*.scm

distname = scheme48-$(VERSION)

dist: build/initial.image-32 build/initial.image-64 c/scheme48.h
	distname=$(distname) &&						\
	distfile=$(distdir)/$$distname.tgz &&				\
	if [ -d $(distdir) ] &&						\
	   [ -w $$distfile -o -w $(distdir) ]; then			\
		cd $(srcdir) &&						\
		rm -f $$distname &&					\
		ln -s . $$distname &&					\
		files='' &&						\
		for i in $(DISTFILES); do				\
			if [ "$$i" != "c/sysdep.h" -a "$$i" != "c/scheme48arch.h" ]; then \
				files="$$files $$distname/$$i";		\
			fi						\
		done &&							\
		tar -cf - $$files |					\
			gzip --best >$$distfile &&			\
		rm $$distname;						\
	else								\
		echo "Can't write $$distfile" >&2;			\
		exit 1;							\
	fi

# Increment the minor version number
inc:
	f=build/minor-version-number &&					\
	expr `cat $$f` + 1 >$$f.tmp &&					\
	mv $$f.tmp $$f &&						\
	cp $$f doc/src/version-number.tex &&				\
	echo '(define version-info "1.'`cat $$f`'")'			\
		>scheme/env/version-info.scm


# --------------------
# Generate build/filenames.make from *packages.scm
#
# This hack traces the module dependencies described in the
# various configuration files and converts them into dependency lists
# that "make" can use for its purposes.
#
# Since the distribution comes with a filenames.make, this rule
# shouldn't be invoked for simple installations.  But it will be used
# if you change any of the *-packages.scm files.
#
# You can actually run the forms in extract-filenames.scm in any Scheme
# implementation that has syntax-rules and explicit-renaming low-level
# macros (e.g., most versions of Scheme 48 and Pseudoscheme).
# If there are errors running this script, and you need to debug,
# don't use the initial.image, use something that has a reasonable
# environment.
#
# If this fails and you don't feel like debugging or fixing the problem,
# try "touch filenames.make" and hope for the best.

PACKAGES=scheme/packages.scm scheme/rts-packages.scm scheme/alt-packages.scm \
	 scheme/comp-packages.scm scheme/initial-packages.scm \
	 scheme/link-packages.scm \
	 scheme/env-packages.scm \
	 scheme/sort/packages.scm scheme/more-packages.scm \
	 scheme/cml/packages.scm scheme/r6rs/packages.scm

$(srcdir)/build/filenames.make: $(PACKAGES) build/extract-filenames.scm
# uncomment this if you activate the line below:
#	$(MAKE) $(VM) PACKAGES=
	cd $(srcdir) && \
	$(RUNNABLE) -a batch <build/extract-filenames.scm
# or:	./$(VM) -i $(srcdir)/$(INITIAL)-$(BIT_SUFFIX) -a batch <build/extract-filenames.scm


# --------------------
# Static linker
#
# The linker is capable of rebuilding an image from sources, even
# across an incompatible change in VM data representations.

# Bootstrap from Lucid Common Lisp: (last tested with
# Pseudoscheme 2.9 and Scheme 48 version 0.19)

PSEUDODIR = ../pseudo

link/linker-in-lucid: build/lucid-script.lisp $(linker-files) \
	    scheme/alt/pseudoscheme-features.scm \
	    scheme/alt/pseudoscheme-record.scm
	(echo \(defvar pseudoscheme-directory \"$(PSEUDODIR)/\"\); \
	 cat build/lucid-script.lisp; \
	 echo \(dump-linker\) \(lcl:quit\)) \
	| lisp

# --------------------
# Initial image
#
# The initial.image is built by the static linker.  The image contains
# Scheme, the byte-code compiler, and a minimal command processor, but
# no debugging environment to speak of.

$(INITIAL)-32: $(CONFIG_FILES) build/initial.scm \
	scheme/platform-interfaces.scm scheme/rts-packages-32.scm \
	scheme/alt/low-exception.scm \
	scheme/alt/init-defpackage.scm \
	$(initial-files) $(linker-files)
	cd $(srcdir) &&							\
	($(START_LINKER-32);						\
		echo '(load-configuration "scheme/platform-interfaces.scm")'; \
		echo '(load-configuration "scheme/rts-packages-32.scm")'; \
		echo '(load-configuration "scheme/interfaces.scm")';	\
		echo '(load-configuration "scheme/vm/shared-interfaces.scm")'; \
		echo '(load-configuration "scheme/packages.scm")';	\
		echo '(flatload initial-structures)';			\
		echo '(load "build/initial.scm")';			\
		echo '(link-initial-system)'				\
	) | $(LINKER_RUNNABLE)
	mv $(INITIAL) $@

$(INITIAL)-64: $(CONFIG_FILES) build/initial.scm \
	scheme/platform-interfaces.scm scheme/rts-packages-64.scm \
	scheme/alt/low-exception.scm \
	scheme/alt/init-defpackage.scm \
	$(initial-files) $(linker-files)
	cd $(srcdir) &&							\
	($(START_LINKER-64);						\
		echo '(load-configuration "scheme/platform-interfaces.scm")'; \
		echo '(load-configuration "scheme/rts-packages-64.scm")'; \
		echo '(load-configuration "scheme/interfaces.scm")';	\
		echo '(load-configuration "scheme/vm/shared-interfaces.scm")'; \
		echo '(load-configuration "scheme/packages.scm")';	\
		echo '(flatload initial-structures)';			\
		echo '(load "build/initial.scm")';			\
		echo '(link-initial-system)'				\
	) | $(LINKER_RUNNABLE)
	mv $(INITIAL) $@

# --------------------
# Various small images for debugging low-level changes

LOAD_DEBUG = \
	 $(START_LINKER-32); \
	 echo \(load-configuration \"scheme/interfaces.scm\"\); \
	 echo \(load-configuration \"scheme/packages.scm\"\); \
	 echo \(load-configuration \"scheme/vm/shared-interfaces.scm\"\); \
	 echo \(flatload debug-structures\)

scheme/debug/tiny.image: scheme/debug/tiny-packages.scm \
		  scheme/debug/tiny.scm
	cd $(srcdir) && \
	($(START_LINKER-32); \
	 echo \(load-configuration \"scheme/debug/tiny-packages.scm\"\); \
	 echo \(link-simple-system \'\(scheme/debug tiny\) \'start tiny-system\)) \
	| $(LINKER_RUNNABLE)

scheme/debug/low-test.image: scheme/debug/low-test-packages.scm \
		  scheme/debug/low-test.scm
	cd $(srcdir) && \
	($(START_LINKER-32); \
	 echo \(load-configuration \"scheme/debug/low-test-packages.scm\"\); \
	 echo \(link-simple-system \'\(scheme/debug low-test\) \'start low-test-system\)) \
	| $(LINKER_RUNNABLE)

scheme/debug/bignum-test.image: scheme/debug/low-test-packages.scm \
		  scheme/debug/bignum-test.scm
	cd $(srcdir) && \
	($(START_LINKER-32); \
	 echo \(load-configuration \"scheme/debug/low-test-packages.scm\"\); \
	 echo \(link-simple-system \'\(scheme/debug bignum-test\) \'start bignum-test-system\)) \
	| $(LINKER_RUNNABLE)

scheme/debug/little.image: $(CONFIG_FILES) scheme/debug-packages.scm
	cd $(srcdir) &&					\
	($(LOAD_DEBUG); echo \(link-little-system\))	\
	| $(LINKER_RUNNABLE)

scheme/debug/mini.image: $(CONFIG_FILES)
	cd $(srcdir) &&					\
	($(LOAD_DEBUG); echo \(link-mini-system\))	\
	| $(LINKER_RUNNABLE)

scheme/debug/medium.image: $(CONFIG_FILES)
	cd $(srcdir) &&						\
	($(LOAD_DEBUG); echo \(flatload compiler-structures\);	\
	 echo \(link-medium-system\)) \
	| $(LINKER_RUNNABLE)

# The following have not been updated for the new directory organization

c/smain.o: c/main.c
	$(CC) -c $(CPPFLAGS) $(DEFS) $(CFLAGS) -DSTATIC_AREAS -o $@ $(srcdir)/c/main.c

mini: mini-heap.o smain.o
	$(CC) $(LDFLAGS) $(CFLAGS) -o $@ c/smain.o mini-heap.o $(OBJS) $(LIBS)

mini-heap.o: mini-heap.c
	$(CC) -c $(CPPFLAGS) $(DEFS) $(CFLAGS) -o $@ $(srcdir)/mini-heap.c

mini-heap.c: scheme/debug/mini1.image
	(echo ,exec ,load misc/load-static.scm; \
	 echo \(do-it 150000 \"$(srcdir)/scheme/debug/mini1.image\" \"$@\"\)) \
	| $(RUNNABLE) -h 3000000 -a batch

scheme/debug/mini1.image: $(VM) scheme/debug/mini.image
	echo "(write-image \"scheme/debug/mini1.image\" \
			   (usual-resumer (lambda (args) \
					    (command-processor #f args))) \
			   \"foo\")" \
	| ./$(VM) -i scheme/debug/mini.image -a batch


# --------------------
# Generate unicode-info.scm, srfi-14-base-char-set.scm, and unicode-normalization-info
# from UnicodeData.txt
# Get fresh UnicodeData.txt from http://www.unicode.org.

scheme/rts/syntax-info.scm: build/UnicodeData.txt			\
	build/PropList.txt						\
	build/SpecialCasing.txt						\
	build/CaseFolding.txt						\
	build/CompositionExclusions.txt					\
	scheme/link/unicode-data.scm 					\
	scheme/env/unicode-category.scm					\
	scheme/big/compact-table.scm
	cd $(srcdir) &&							\
		(echo ',batch';							\
		echo ',config ,load scheme/link/unicode-data-packages.scm';	\
		echo ",in unicode-data (create-unicode-tables \"build/UnicodeData.txt\" \"build/PropList.txt\" \"build/SpecialCasing.txt\" \"build/CaseFolding.txt\" \"build/CompositionExclusions.txt\" \"scheme/env/unicode-info.scm\" \"scheme/rts/syntax-info.scm\" \"scheme/big/unicode-normalization-info.scm\" \"scheme/srfi/srfi-14-base-char-sets.scm\")"		\
	) | $(RUNNABLE) -h 6000000

# --------------------
# Generate scheme48.h from VM sources

c/scheme48.h: c/scheme48.h.in scheme/vm/interp/arch.scm 		\
		scheme/vm/data/data.scm scheme/link/generate-c-header.scm
	cd $(srcdir) &&							\
	(echo ',bench';							\
		echo ',batch';						\
		echo ',load-package big-scheme';			\
		echo ',open big-scheme';				\
		echo ',load scheme/link/generate-c-header.scm';		\
		echo "(make-c-header-file \"$@\"			\
			  \"c/scheme48.h.in\"				\
			  \"scheme/vm/interp/arch.scm\"			\
			  \"scheme/vm/data/data.scm\"			\
			  \"scheme/rts/record.scm\")"			\
	) | $(RUNNABLE)

# An old version of the above for legacy code.

c/old-scheme48.h: scheme/vm/interp/arch.scm scheme/vm/data/data.scm \
	    scheme/link/generate-old-c-header.scm
	(echo ',bench';							\
		echo ',batch';						\
		echo ',load-package big-scheme';			\
		echo ',open big-scheme';				\
		echo ',load scheme/link/generate-old-c-header.scm';	\
		echo "(make-c-header-file \"$@\"			\
			  \"$(srcdir)/scheme/vm/interp/arch.scm\"	\
			  \"$(srcdir)/scheme/vm/data/data.scm\")"   	\
	) | $(RUNNABLE)

# Generate VM and GC from VM sources.
# Never called automatically.  Do not use unless you are sure you
# know what you are doing.
# Afterwards, you should probably make c/scheme48.h.

i-know-what-i-am-doing: \
	compile-vm-32 compile-twospace-gc-32 compile-bibop-gc-32 \
	compile-vm-64 compile-twospace-gc-64 compile-bibop-gc-64

# compiles VM without GC

compile-vm-32:
	cd $(srcdir)/ps-compiler &&					     \
	(echo ',batch';							     \
		echo ',config ,load ../scheme/platform-interfaces.scm';	     \
		echo ',config ,load ../scheme/rts-packages-32.scm';          \
		echo ',config ,load ../scheme/prescheme/interface.scm';	     \
		echo ',config ,load ../scheme/prescheme/package-defs.scm';   \
		echo ',exec ,load load-ps-compiler.scm';		     \
		echo ',exec ,load compile-vm-no-gc-32.scm';		     \
		echo ',exit'						     \
	) | $(RUNNABLE) -h 12000000 &&					     \
		mv ../scheme/vm/scheme48vm-32.c ../c

compile-vm-64:
	cd $(srcdir)/ps-compiler &&					     \
	(echo ',batch';							     \
		echo ',config ,load ../scheme/platform-interfaces.scm';	     \
		echo ',config ,load ../scheme/rts-packages-64.scm';          \
		echo ',config ,load ../scheme/prescheme/interface.scm';	     \
		echo ',config ,load ../scheme/prescheme/package-defs.scm';   \
		echo ',exec ,load load-ps-compiler.scm';		     \
		echo ',exec ,load compile-vm-no-gc-64.scm';		     \
		echo ',exit'						     \
	) | $(RUNNABLE) -h 12000000 &&					     \
		mv ../scheme/vm/scheme48vm-64.c ../c

# compiles the two-space copier GC

compile-twospace-gc-32:
	cd $(srcdir)/ps-compiler &&					     \
	(echo ',batch';							     \
		echo ',config ,load ../scheme/platform-interfaces.scm';	     \
		echo ',config ,load ../scheme/rts-packages-32.scm';          \
		echo ',config ,load ../scheme/prescheme/interface.scm';	     \
		echo ',config ,load ../scheme/prescheme/package-defs.scm';   \
		echo ',exec ,load load-ps-compiler.scm';		     \
		echo ',exec ,load compile-twospace-gc-32.scm';		     \
		echo ',exit'						     \
	) | $(RUNNABLE) -h 8000000 &&					     \
		mv ../scheme/vm/scheme48-twospace-heap-32.c ../c

compile-twospace-gc-64:
	cd $(srcdir)/ps-compiler &&					     \
	(echo ',batch';							     \
		echo ',config ,load ../scheme/platform-interfaces.scm';	     \
		echo ',config ,load ../scheme/rts-packages-64.scm';          \
		echo ',config ,load ../scheme/prescheme/interface.scm';	     \
		echo ',config ,load ../scheme/prescheme/package-defs.scm';   \
		echo ',exec ,load load-ps-compiler.scm';		     \
		echo ',exec ,load compile-twospace-gc-64.scm';		     \
		echo ',exit'						     \
	) | $(RUNNABLE) -h 8000000 &&					     \
		mv ../scheme/vm/scheme48-twospace-heap-64.c ../c

# compiles the BIBOP GC

compile-bibop-gc-32:
	cd $(srcdir)/ps-compiler &&					     \
	(echo ',batch';							     \
		echo ',config ,load ../scheme/platform-interfaces.scm';	     \
		echo ',config ,load ../scheme/rts-packages-32.scm';          \
		echo ',config ,load ../scheme/prescheme/interface.scm';	     \
		echo ',config ,load ../scheme/prescheme/package-defs.scm';   \
		echo ',exec ,load load-ps-compiler.scm';		     \
		echo ',exec ,load compile-bibop-gc-32.scm';		     \
		echo ',exit'						     \
	) | $(RUNNABLE) -h 8000000 &&					     \
		mv ../scheme/vm/scheme48-bibop-heap-32.c ../c

compile-bibop-gc-64:
	cd $(srcdir)/ps-compiler &&					     \
	(echo ',batch';							     \
		echo ',config ,load ../scheme/platform-interfaces.scm';	     \
		echo ',config ,load ../scheme/rts-packages-64.scm';          \
		echo ',config ,load ../scheme/prescheme/interface.scm';	     \
		echo ',config ,load ../scheme/prescheme/package-defs.scm';   \
		echo ',exec ,load load-ps-compiler.scm';		     \
		echo ',exec ,load compile-bibop-gc-64.scm';		     \
		echo ',exit'						     \
	) | $(RUNNABLE) -h 8000000 &&					     \
		mv ../scheme/vm/scheme48-bibop-heap-64.c ../c
