# Build runtime library for Dylan under MPW

#
# Building the C runtime is a bit tricky as it must be linked against the import stubs for the Dylan library
# which, of course, must be linked against the C runtime!  Here's what you need to do:
#   1) Checkout and claim DylanRuntimeLib.exp so that it's writable.
#   2) Delete DylanRuntimeLib.exp as you'll want to regenerate it.
#   3) If you already have a usable DylanLib stub library, proceed to step #6.
#   4) Build the runtime as a static library by using the 'install-static' target.
#   5) Build the Dylan library normally using the 'install' target.
#   6) Build the runtime as a shared library by using the 'install-shared' (or 'install') target.
#

OPEN_DYLAN_RELEASE_BIN     = {OPEN_DYLAN_RELEASE_INSTALL}Bin:
OPEN_DYLAN_RELEASE_INCLUDE = {OPEN_DYLAN_RELEASE_INSTALL}Include:
OPEN_DYLAN_RELEASE_LIB     = {OPEN_DYLAN_RELEASE_INSTALL}Lib:
OPEN_DYLAN_USER_BIN     = {OPEN_DYLAN_USER_INSTALL}Bin:
OPEN_DYLAN_USER_INCLUDE = {OPEN_DYLAN_USER_INSTALL}Include:
OPEN_DYLAN_USER_LIB     = {OPEN_DYLAN_USER_INSTALL}Lib:

INSTALLOBJ = Echo
INSTALLLIB = Duplicate -y
UNINSTALL = Delete -c -ac -i
MKDIR = NewFolder
CREATE = Echo >

#
# ---*** NOTE: There's a bug in MWLinkPPC that causes it to reverse the file type and creator settings!
#

LINKLIB   = MWLinkPPC -xm library -sym fullpath -o
LINKSTUB  = MWLinkPPC -xm stublibrary -c ' SPM' -t 'buts' -fragname DylanRuntime -@export DylanRuntimeLib.exp -L"{OPEN_DYLAN_USER_LIB}" -L"{OPEN_DYLAN_RELEASE_LIB}" -L"{MWPPCLibraries}" -L"{SharedLibraries}" -warn -o
LINKSHLIB = MWLinkPPC -xm sharedlibrary -c 'lyDH' -t 'blhs' -fragname DylanRuntime -@export DylanRuntimeLib.exp -L"{OPEN_DYLAN_USER_LIB}" -L"{OPEN_DYLAN_RELEASE_LIB}" -L"{MWPPCLibraries}" -L"{SharedLibraries}" -sym fullpath -warn -o

CC = MWCPPC
CFLAGS = -sym full -I"{OPEN_DYLAN_RELEASE_INCLUDE}" -w nounusedarg,noimplicitconv,noemptydecl -nomapcr {OPEN_DYLAN_C_FLAGS}
RC = Rez
RFLAGS = 

OBJS	= run-time.o debug-print.o dummy-threads.o
LIBFILE	= DylanRuntimeLib

RTLIBS  = -ldylanLib -lBoehmGCLib -l"MSL C.PPC.DLL" -l"MSL ShLibRuntime.Lib" -l"MSL RuntimePPC.DLL" -lInterfaceLib -lMathLib

.o Ä .c
	{CC} {CFLAGS} {DepDir}{Default}.c -o {TargDir}{Default}.o

install-basics Ä
	if `Exists "{OPEN_DYLAN_USER_LIB}{LIBFILE}"`
		SetFile -a l "{OPEN_DYLAN_USER_LIB}{LIBFILE}"
	end
	{INSTALLLIB} {LIBFILE}.stub "{OPEN_DYLAN_USER_LIB}{LIBFILE}"
	if `Exists "{OPEN_DYLAN_USER_INCLUDE}run-time.h"`
		SetFile -a l "{OPEN_DYLAN_USER_INCLUDE}run-time.h"
	end
	{INSTALLLIB} run-time.h "{OPEN_DYLAN_USER_INCLUDE}"
	# if `Exists "{OPEN_DYLAN_USER_BIN}ccl-linker.script"`
	#	SetFile -a l "{OPEN_DYLAN_USER_BIN}ccl-linker.script"
	# end
	# {INSTALLLIB} mpw-ccl-linker.script "{OPEN_DYLAN_USER_BIN}"ccl-linker.script

static Ä {OBJS}
	{LINKLIB} {LIBFILE}.stub {OBJS}

install-static Ä static install-basics

shared Ä {OBJS}
	{LINKSTUB}  {LIBFILE}.stub {OBJS} {RTLIBS}
	StreamEdit -e '/¥__ptmf_null°/||/¥__vec_longjmp°/||/¥longjmp°/||/¥__terminate°/||/¥__initialize°/delete' -o {LIBFILE}.exp {LIBFILE}.exp
	{LINKSTUB}  {LIBFILE}.stub {OBJS} {RTLIBS}
	{LINKSHLIB} {LIBFILE} {OBJS} {RTLIBS}

install-shared Ä shared install-basics
	if `Exists "{OPEN_DYLAN_USER_BIN}{LIBFILE}"`
		SetFile -a l "{OPEN_DYLAN_USER_BIN}{LIBFILE}"
	end
	{INSTALLLIB} {LIBFILE} "{OPEN_DYLAN_USER_BIN}"
	if `Exists "{OPEN_DYLAN_USER_BIN}{LIBFILE}.xSYM"`
		SetFile -a l "{OPEN_DYLAN_USER_BIN}{LIBFILE}.xSYM"
	end
	{INSTALLLIB} {LIBFILE}.xSYM "{OPEN_DYLAN_USER_BIN}"

install Ä install-shared

clean Ä
	{UNINSTALL} {OBJS} {LIBFILE} {LIBFILE}.exp {LIBFILE}.stub


syntax highlighted by Code2HTML, v. 0.9.1