# EPOS-- Boot Makefile

include $(EPOS)/makedefs

TARGET := $(if $(shell find $(MACH)*), $(MACH)_install)

all: 		$(TARGET)

pc_boot:        pc_boot.o
		ld86 -0 -s -T $(BOOT_ADDR) -o $@ $<

pc_boot.o:      pc_boot.s
		as86 -0 -o $@ $<

pc_install:	pc_boot
		$(DD) if=$< of=$<.tmp ibs=32 skip=1 obs=512
		$(INSTALL) $(MACH)_boot.tmp $(IMG)/$(MACH)_boot
		$(CLEAN) $(MACH)_boot.tmp


atmega16_install:
atmega128_install:


ml310_boot:	ml310_boot.o
		$(LD) $(LDFLAGS) -L$(CCLIB) --omagic \
		--section-start $(MACH_CODE_NAME)=$(BOOT_ADDR) \
		--entry=_start \
		-o $@ $< -l$(LUTIL) -l$(LSYS) -l$(LINIT) -lgcc -lc -lgcc

ml310_install:	ml310_boot
		$(OBJCPY) -O binary $< $<.tmp
		$(INSTALL) $(MACH)_boot.tmp $(IMG)/$(MACH)_boot
		$(CLEAN) $(MACH)_boot.tmp

test:

clean:
		$(CLEAN) *.s *.o *_boot *.tmp

