# This Makefile builds user progrmas listed under
# PROGS to run on the 15-410 kernel
# kernel/user
# Do not edit this file

include user_libs.mk
include user_tests/user_tests.mk
include 410_tests/410tests.mk

MAKE = make
CC = gcc
CFLAGS = -nostdinc -fno-strict-aliasing -fno-builtin -Wall -gstabs+ -Werror
LDFLAGS = -static --entry=_main -Ttext 1000000
LPATH = ./lib
INCLUDES = -I./ -I./inc -I./lib/inc
LIBS = -lthread -lmalloc -lstdio -lstdlib -lstring -lsyscall -lrand

PROGS = shell $(UPROGS) $(TPROGS)

.PHONY: all clean libs

all: ../user_apps.c

../user_apps.c: 410_tests.tgz user_tests.tgz
	rm -rf temp
	mkdir temp
	cd temp; tar -zxvf ../410_tests.tgz
	cd temp; tar -zxvf ../user_tests.tgz
	cd temp; ../exec2obj $(PROGS)
	mv temp/user_apps.c ..

libs:
	cd lib; $(MAKE)

410_tests.tgz: libs
	cd 410_tests; $(MAKE)

user_tests.tgz: libs
	cd user_tests; $(MAKE)

clean:
	rm -fr *.o *~ *.d *.a user_apps.c temp 410_tests.tgz user_tests.tgz
	cd lib; $(MAKE) clean
	cd user_tests; $(MAKE) clean
	cd 410_tests; $(MAKE) clean
