# Makefile for Toy OS projects
#
# COURSE V22.0202: Operating Systems
# Fall 2007
# Prof.Yap 
# 
############################################################

############################################################
# PLATFORM CUSTOMIZATION
############################################################

# choose your Platform
ifndef PF
	PF = unix
	PF = linux
	PF = mac
	PF = cyg
endif

############################################################
# VARIABLES
############################################################

# EXE should be .exe for cygwin, and blank for unix.
#

ifeq (${PF},cyg)
	AEXE=a.exe
	EXE=.exe
else 
ifeq (${PF},unix)
	AEXE=a.out
	EXE=
else
	AEXE=a.out
	EXE=
endif
endif

OS=tos

p=the
p=tos

############################################################
# TARGETS
############################################################

######################################### Testing Primes
t1 test1 primes: ${OS}${EXE} primes.stm
	@echo "Type any positive number n, and this program will compute"
	@echo "    all primes less than n.  E.g. n=7 will print 2, 3, 5."
	${OS}${EXE} primes.stm
	@echo "End of testing primes"

######################################### Testing Sort
t2 test2 sort: ${OS}${EXE} sort.stm
	@echo "Type any list of numbers (separated by white spaces or newlines)."
	@echo "    newlines).  End with -1." 
	@echo "    The list will be printed in sorted order."
	@echo "    E.g., typing 5 2 1 9 -1 will result in 1 2 5 9."
	${OS}${EXE} sort.stm
	@echo "End of testing sort"

######################################### Testing Sort
t3 test3 fraction: ${OS}${EXE} fraction.stm
	@echo "Type four number: N D B L "
	@echo "    (separated by white spaces or newlines)." 
	@echo "    The sort program will print L digits of the fraction N/D"
	@echo "    in base B.  E.g., typing 1 3 10 4 will result in 3 3 3 3."
	@echo "    (Since 1/3 in base 10 is 0.3333...).  Try 1 2 10 4."
	@echo "    Make sure that N < D."
	${OS}${EXE} fraction.stm
	@echo "End of testing fraction"

#########################################  Testing GCD
t4 test4 gcd: ${OS}${EXE} gcd.stm
	@echo "To see the GCD of integers m and n, type: m n "
	${OS}${EXE} gcd.stm
	@echo "End of testing gcd"

#########################################  Testing GCD_DETAIL
t5 test5 gcd_detail: ${OS}${EXE} gcd_detail.stm
	@echo "To see the GCD sequence of integers m and n, type: m n "
	${OS}${EXE} gcd_detail.stm
	@echo "End of testing gcd"

#########################################  Testing HELLO
t6 test6 hello: ${OS}${EXE} hello.stm
	@echo "String output test"
	${OS}${EXE} hello.stm

######################################### 
p:
	gcc -o ${p}${EXE} ${p}.c

######################################### 
the the.o: the.h the.c
	gcc -c the.c -o the.o 

######################################### 
os tos ${OS}${EXE}: tos.h tos.c the.o 
	gcc the.o ${OS}.c -o ${OS}${EXE}

############################################################
# House keeping
############################################################
clean:
	rm -f *.o

veryclean: clean
	rm -f *.exe
############################################################
# END
############################################################
