# "../" below is included to simplify compilation for a
# different architecture sharing the same filing system.
SYSC = ../cintcode/sys

# Select the appropriate definition of CC, LIBS ans SYSM
# SYSM gives the location of machine specific code (eg cintasm.s)

# To build the system for freeBSD use the Linux option and possibly
# change dosys to _dosys in sys/LINUX/cintasm.s.  See the comment in
# that file.

# To build the system for Windows 95/98/NT/2000/XP using the 
# GNU Cygnus compiler edit the file cintcode\Makefile to select
# "forCYGWIN32" then use (under Windows) run the commands:
#        make clean
#        make

# This will generate a lot of output ending with something like:

#        BCPL Cintcode System (24 Sept 2003)
#        0> 

# At this prompt type:

#        0> c compall

# This will recompile all the standard commands.


# To build the system for Windows 95/98/NT using Borland C 4.0
# edit the file sys\BC4\makefile then use the command: make BC4
# ***** This version is out of date *****

# To build the system for Windows 95/98/NT using Microsoft Visual C
# edit the file sys\Win32\makefile then use the command: make Win32
# This version does not yet use cintasm.asm
# ***** This version is out of date *****

#CC = gcc -O9 -DforMAC
#CINTASM = cintasm.o
#ENDER = BIGENDER

#CC = gcc -O9 -DforMIPS
#SYSM = ../cintcode/sys/MIPS
#CINTASM = cintasm.o
#ENDER = LITENDER

#CC = gcc -O9 -DforSGI
#SYSM = ../cintcode/sys/SGI
#CINTASM = cintasm.o
#ENDER = BIGENDER

#CC = gcc -O2 -DforARM
#SYSM = ../cintcode/sys/ARM
#ENDER = LITENDER

CC = gcc -O9 -DforLINUX
SYSM = ../cintcode/sys/LINUX
CINTASM = cintasm.o
ENDER = LITENDER

#CC = gcc -O9 -DforCYGWIN32 -static
#SYSM = ../cintcode/sys/CYGWIN32
#CINTASM = cintasm.o
#ENDER = LITENDER

# The patched for a PowerMac G4 running Debian Linux was
# kindly provided by Chris Emerson
#CC = gcc -O9 -DforLINUXPPC
#SYSM = ../cintcode/sys/LINUXPPC
#CINTASM = cintasm.o
#ENDER = BIGENDER

#CC = gcc -O9 -DforSUN4
#SYSM = ../cintcode/sys/SUN4
#CINTASM = cintasm.o
#ENDER = BIGENDER

#CC = gcc -O9 -DforSPARC
#SYSM = ../cintcode/sys/SPARC
#CINTASM = cintasm.o
#ENDER = BIGENDER

#CC = gcc -O9 -DforALPHA
#SYSM = ../cintcode/sys/ALPHA
#CINTASM = cintasm.o
#ENDER = LITENDER

#CC = gcc -O9 -DforMSDOS
#SYSM = ../cintcode/sys/MSDOS
#CINTASM = cintasm.o
#ENDER = LITENDER

#CC = gcc -O9 -DforOS2
#SYSM = ../cintcode/sys/OS2
#CINTASM = cintasm.o
#ENDER = LITENDER

OBJ = cintmain.o cinterp.o kblib.o 
NRASTER = nrastlib.o
RASTER = rasterp.o rastlib.o
COM = com
BCOMS = $(COM)/abort.b $(COM)/bcpl.b $(COM)/bcplxref.b \
	$(COM)/c.b $(COM)/casech.b \
	$(COM)/checksum.b $(COM)/delete.b $(COM)/detab.b \
	$(COM)/echo.b $(COM)/edit.b \
	$(COM)/fail.b $(COM)/input.b $(COM)/interpreter.b \
	$(COM)/join.b $(COM)/lab.b \
	$(COM)/logout.b $(COM)/map.b $(COM)/nlconv.b \
	$(COM)/prefix.b $(COM)/preload.b \
	$(COM)/procode.b $(COM)/prompt.b $(COM)/quit.b \
	$(COM)/rast2ps.b $(COM)/raster.b \
	$(COM)/rename.b $(COM)/rem.b $(COM)/skip.b \
	$(COM)/stack.b $(COM)/stats.b $(COM)/type.b \
	$(COM)/typehex.b $(COM)/unpreload.b


run:	build $(ENDER)
	./cinterp

build:	cinterp $(BCOMS)
	echo "c compall; logout" | ./cinterp
	touch build

sane:	cinterp $(ENDER)
	stty sane
	./cinterp

rast:	rasterp $(ENDER)
	./rasterp

bc4:
	copy sys\cinterp.h
	E:\BC4\bin\make -f sys\BC4\makefile

Win32:
	copy sys\cinterp.h
	nmake /f sys\Win32\makefile

BIGENDER:
	cp ENDERBIG/SYSLIB .
	cp ENDERBIG/BOOT .
	cp ENDERBIG/BLIB .
	cp ENDERBIG/CLI .
	cp ENDERBIG/bcpl .
	cp ENDERBIG/c .
	cp ENDERBIG/bcb .
	cp ENDERBIG/bcl .
	cp ENDERBIG/bsb .
	cp ENDERBIG/bsb .
	touch BIGENDER

LITENDER:
	cp ENDERLIT/SYSLIB .
	cp ENDERLIT/BOOT .
	cp ENDERLIT/BLIB .
	cp ENDERLIT/CLI .
	cp ENDERLIT/bcpl .
	cp ENDERLIT/c .
	cp ENDERLIT/bcb .
	cp ENDERLIT/bcl .
	cp ENDERLIT/bsb .
	cp ENDERLIT/bsb .
	touch LITENDER

debug:	cinterp
	stty sane
	dbx ./cinterp

cintmain.o:	$(SYSC)/cintmain.c $(SYSC)/cinterp.h
	$(CC) -c $(SYSC)/cintmain.c

cinterp.o:	$(SYSC)/cinterp.c $(SYSC)/cinterp.h
	$(CC) -c $(SYSC)/cinterp.c

cintasm.o:	$(SYSM)/cintasm.s
	as -o cintasm.o $(SYSM)/cintasm.s

rasterp.o:	$(SYSC)/rasterp.c $(SYSC)/cinterp.h
	$(CC) -c $(SYSC)/rasterp.c

nrastlib.o:	$(SYSC)/nrastlib.c $(SYSC)/cinterp.h
	$(CC) -c $(SYSC)/nrastlib.c

rastlib.o:	$(SYSC)/rastlib.c $(SYSC)/cinterp.h
	$(CC) -c $(SYSC)/rastlib.c

cinterp:	$(OBJ) $(CINTASM) $(NRASTER)
	$(CC) -o cinterp $(OBJ) $(CINTASM) $(NRASTER) $(LIBS)

rasterp:	$(OBJ) $(RASTER)
	$(CC) -o rasterp $(OBJ) $(RASTER) $(LIBS)

kblib.o:	$(SYSC)/kblib.c $(SYSC)/cinterp.h
	$(CC) -c $(SYSC)/kblib.c

clean:
	rm -f OCODE MCODE COMFILE core
	rm -f SIAL MIAL MINTCODE
	rm -f *~ sys/*~ com/*~ doc/*~ sys/*/*~
	rm -f LITENDER BIGENDER
	rm -f *.cin
	rm -f *.obj *.o
	rm -f cinterp rasterp *.o junk* *.sial *.cial
	rm -f RASTER RASTER.ps STATS ANALYSIS PROFILE
	rm -f ANALYSIS*
	rm -f abort rast2ps raster stats
	rm -f casech checksum delete detab echo edit fail input
	rm -f interpreter join logout map nlconv prefix preload 
	rm -f procode prompt rename stack type typehex unpreload
	rm -f cinterp.h
