# Build runtime library for Dylan under X86 Linux

srcdir		= /usr/home/hannes/opendylan/sources/lib/run-time/pentium-freebsd
top_srcdir	= /usr/home/hannes/opendylan
top_builddir	= ../../../..

runtime_srcdir	= $(top_srcdir)/sources/lib/run-time

subdir		= sources/lib/run-time/pentium-freebsd

VPATH		= $(srcdir)

LIBDEST         = $(OPEN_DYLAN_USER_INSTALL)/lib
BINDEST         = $(OPEN_DYLAN_USER_INSTALL)/bin

MPS             = /usr/local/mps-kit-1.108.0
MPS_PLATFORM    = fri4gc
MPS_VARIANT     = hi
MPS_LIB         = $(MPS)/code/$(MPS_PLATFORM)/$(MPS_VARIANT)

AS = as -L
AR = ar -q

CFLAGS		= -D_REENTRANT=1 \
		  -O -g \
		  -I$(MPS)/code -I$(srcdir) -I$(runtime_srcdir)

OBJS		= x86-linux-collector.o \
		  x86-linux-threads-primitives.o \
		  linux-spy-interfaces.o \
		  linux-support.o

SRCOBJS		= $(srcdir)/runtime.o \
		  $(srcdir)/dylan-support.o \

RUNTIMELIBDEST	 = $(LIBDEST)/runtime/

all:	$(OBJS)

x86-linux-collector.o:       $(runtime_srcdir)/collector.c

x86-linux-threads-primitives.o:  $(runtime_srcdir)/linux-threads-primitives.c

linux-spy-interfaces.o: $(runtime_srcdir)/linux-spy-interfaces.c
	$(CC) $(CFLAGS) -c -o $@ $<

linux-support.o: $(runtime_srcdir)/linux-support.c
	$(CC) $(CFLAGS) -c -o $@ $<

#$(LIBDEST)/libgc.a: gc.a
#	cp -fp gc.a $(LIBDEST)/libgc.a
#
$(LIBDEST)/libmpsplan.a: $(MPS_LIB)/mpsplan.a
	cp -fp $(MPS_LIB)/mpsplan.a $(LIBDEST)/libmpsplan.a

$(LIBDEST)/libmmdw.a: $(MPS_LIB)/mmdw.a
	cp -fp $(MPS_LIB)/mmdw.a $(LIBDEST)/libmmdw.a

$(LIBDEST)/x86-freebsd-build.jam: $(srcdir)/x86-freebsd-build.jam
	cp -fp $(srcdir)/x86-freebsd-build.jam $(LIBDEST)

$(LIBDEST)/mini-jambase.jam: $(runtime_srcdir)/mini-jambase.jam
	cp -fp $(runtime_srcdir)/mini-jambase.jam $(LIBDEST)

$(LIBDEST)/dylan-elf-dll.script: $(srcdir)/dylan-elf-dll.script
	cp -fp $(srcdir)/dylan-elf-dll.script $(LIBDEST)

$(LIBDEST)/dylan-elf-exe.script: $(srcdir)/dylan-elf-exe.script
	cp -fp $(srcdir)/dylan-elf-exe.script $(LIBDEST)

install-build: $(LIBDEST)/libmmdw.a $(LIBDEST)/libmpsplan.a \
	       $(LIBDEST)/x86-freebsd-build.jam $(LIBDEST)/mini-jambase.jam \
               $(LIBDEST)/dylan-elf-dll.script $(LIBDEST)/dylan-elf-exe.script

install-runtime: $(OBJS) $(SRCOBJS)
	cp -fp $(OBJS) $(SRCOBJS) $(RUNTIMELIBDEST)

install: install-runtime install-build

clean:
	rm -f $(OBJS)

Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
	cd $(top_builddir) && ./config.status $(subdir)/Makefile
