# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# if you are cross-compiling, you need to point to the right executables
# and change the flags to ld and the build procedure for as
GCCDIR = ../xgccnew/
LDFLAGS = -T script -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)


# if you aren't cross-compiling:
#GCCDIR =
#LDFLAGS = -N -T 0
#ASFLAGS =
#CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld

CPP = $(GCCDIR)cpp
INCDIR =-I../userprog -I../threads
CFLAGS =   -G 0 -c $(INCDIR) -B$(GCCDIR)

all:  shell  

stdio.o: stdio.c stdio.h
	$(CC) $(CFLAGS) -c stdio.c
			



shell.o: shell.c
	$(CC) $(CFLAGS) -c shell.c
shell: shell.o start.o stdio.o
	$(LD) $(LDFLAGS) start.o stdio.o shell.o -o shell.coff
	../bin/coff2noff shell.coff shell
