# KallistiOS 0.6
#
# Root Makefile
# (c)2000 Dan Potter
#   
# $Id: Makefile,v 1.3 2000/11/12 01:22:50 bard Exp $

include Makefile.globals

all: subdirs build-libkallisti build-userland build-kernel
SUBDIRS	= mm stdlib hardware startup process fs

include Makefile.rules

clean: clean_subdirs
	-rm -f libkallisti.a
	-rm -f build/*
	-rm -f test test.o test.srec
	$(MAKE) -C kernel clean
	$(MAKE) -C userland clean

build-kernel:
	-rm -f kallistios.elf kernel/kallistios.elf
	$(MAKE) -C kernel
	-cp kernel/kallistios.elf .
	$(OBJCOPY) -O binary kallistios.elf kallistios.bin

build-userland:
	$(MAKE) -C userland

build-libkallisti:
	-rm -f libkallisti.a
	(cd build; $(AR) rcs ../libkallisti.a *.o)

test: all test.c
	$(CC) $(CFLAGS) -c test.c -Iinclude
	$(CC) $(CFLAGS) -Wl,-Ttext,0x8c010000 -nostartfiles -nostdlib -o test startup/startup.o test.o -L. -lkallisti -lgcc
	$(OBJCOPY) -O srec test test.srec

run:
	$(MAKE) -C kernel run


reset:
	dc-tool -n -x ../programs/reboot.bin

