#
# $Id: Makefile,v 1.2 2002/09/09 05:44:23 halite Exp $
#

CLEAN_FILES = Image bootsect setup tools/build
SYSTEM = $(TOPDIR)/toykernel

.PHONY: Image clean

Image : bootsect setup $(SYSTEM) tools/build
	tmp=_tmp_$$$$; \
	rm -f $$tmp; \
	$(OBJCOPY) $(SYSTEM) $$tmp; \
	tools/build bootsect setup $$tmp > $@; \
	rm -f $$tmp

bootsect: bootsect.o
	$(LD) -Ttext 0x0 -s --oformat binary -o $@ $<

bootsect.o: bootsect.s
	$(AS) -o $@ $<

bootsect.s: bootsect.S
	$(CPP) $(CPPFLAGS) -traditional -o $@ $<

setup: setup.o
	$(LD) -Ttext 0x0 -s --oformat binary -o $@ $<

setup.o: setup.s
	$(AS) -o $@ $<

setup.s: setup.S
	$(CPP) $(CPPFLAGS) -D__ASSEMBLY__ -traditional -o $@ $<

tools/build: tools/build.c
	$(HOSTCC) $(HOSTCFLAGS) -o $@ $<

clean:
	rm -f $(CLEAN_FILES)

include $(TOPDIR)/Rules.make
