#
# Makefile for RosettaMan
#   It's helpful to read the README-rman file first.
#   You should read over all parts of this file,
#      down to the "you shouldn't modify" line
#
# Tom Phelps (phelps@ACM.org)
#
# Mac version: Matthias Neeracher <neeri@iis.ee.ethz.ch>
#

BINDIR = "{{MPW}}LocalTools:"

version = 2.4
rman = rman-$(version)
srcs = rman.c getopt.c macish.c
defs = -d MANTITLEPRINTF='$(MANTITLEPRINTF)' -d MANREFPRINTF='$(MANREFPRINTF)' \
		 -d ROSETTAMANVERSION='"$(version)"'
libs = 
aux = README-rman Makefile rman.1 rman.html Copyright
distrib = $(srcs) $(libs) $(aux) contrib

COpt			=	$(defs) -d macintosh -w off -sym on
C68K			=	MWC68K ${COpt} -mc68020 -model far -mbg on
CPPC			=	MWCPPC ${COpt} -traceback
ROptions 	= 	-i :
Lib68K		=	MWLink68K -xm library -sym on
LibPPC		=	MWLinkPPC -xm library -sym on
LOpt			= 	-sym on -w -xm mpwtool
Link68K		=	MWLink68K ${LOpt} -model far
LinkPPC		=	MWLinkPPC ${LOpt} 

LibFiles68K	=			"{{MW68KLibraries}}GUSIDispatch.Lib.68K"				\
							"{{MW68KLibraries}}GUSIMPW.Lib.68K"						\
							"{{MW68KLibraries}}MPW_Runtime.o.lib"					\
							"{{MW68KLibraries}}new MPW ANSI (4i/8d) C.68K.Lib"	\
							"{{MW68KLibraries}}MathLib68K (4i/8d).Lib"			\
							"{{MW68KLibraries}}MacOS.Lib"								\
							"{{MW68KLibraries}}GUSI.Lib.68K"							\
							"{{MW68KLibraries}}CPlusPlus.lib"						\
							"{{MW68KLibraries}}ToolLibs.o"							\
							"{{MW68KLibraries}}PLStringFuncs.glue.lib"

LibFilesPPC	=			"{{MWPPCLibraries}}GUSIMPW.Lib.PPC"						\
							"{{MWPPCLibraries}}GUSI.Lib.PPC"							\
							"{{MWPPCLibraries}}MWStdCRuntime.Lib"					\
							"{{MWPPCLibraries}}InterfaceLib"							\
							"{{MWPPCLibraries}}ANSI (NL) C++.PPC.Lib"				\
							"{{MWPPCLibraries}}ANSI (NL) C.PPC.Lib"				\
							"{{MWPPCLibraries}}StdCLib"								\
							"{{MWPPCLibraries}}MathLib"								\
							"{{MWPPCLibraries}}PPCToolLibs.o"

# the printf strings used to set the <TITLE> and
# to set URL hyperlinks to referenced manual pages
# can be defined at runtime.  The defaults are defined below.
# The first %s parameter is the manual page name,
# the second the volume/section number.

MANTITLEPRINTF = "%s(%s) manual page"
MANREFPRINTF = "http://localhost/cgi-bin/man2html?%s?%s"
CP = Duplicate -y

OBJ68K		=	$(srcs:s/.c/.c.68K.o/)
OBJPPC		=	$(srcs:s/.c/.c.PPC.o/)

.SOURCE.o	:	":Obj:"

%.c.68K.o		:	%.c
	Set Echo 0
	Set Src68K "{{Src68K}} $<"
%.c.PPC.o		:	%.c
	Set Echo 0
	Set SrcPPC "{{SrcPPC}} $<"

all:  rman

install: all
	Begin
		Backup -a -to $(BINDIR) rman 
	End>"{{TempFolder}}"rman.run
	"{{TempFolder}}"rman.run

rman: rman.68K rman.PPC
	Duplicate -y rman.PPC rman
	Echo 'Include "rman.68K" '¶''CODE'¶'';Include "rman.68K" '¶''DATA'¶'';' ¶
		| Rez -a -c 'MPS ' -t MPST -o rman
rman.68K:	Objects68K
	${Link68K} -o rman.68K :Obj:{${OBJ68K}} ${LibFiles68K}
rman.PPC:	ObjectsPPC
	${LinkPPC} -o rman.PPC  :Obj:{${OBJPPC}} ${LibFilesPPC}

Objects68K	:	${OBJ68K}
	Set Echo 1
	If "{{Src68K}}" != "" 
		${C68K} -t -fatext {{Src68K}} -o :Obj:
	End
	echo > Objects68K
	
ObjectsPPC	:	${OBJPPC}	
	Set Echo 1
	If "{{SrcPPC}}" != "" 
		${CPPC} -t -fatext {{SrcPPC}} -o :Obj:
	End
	echo > ObjectsPPC
