# eCos makefile

# This is a generated file - do not edit

export REPOSITORY := /ecos/ecos-2.0/packages
export PREFIX := /ecos/ecos-2.0/tools/bin/RDC_redboot_install
export COMMAND_PREFIX := i386-elf-
export CC := $(COMMAND_PREFIX)gcc
export OBJCOPY := $(COMMAND_PREFIX)objcopy
export HOST := UNIX
export AR := $(COMMAND_PREFIX)ar

PACKAGE := hal/i386/pc/v2_0
OBJECT_PREFIX := hal_i386_pc
CFLAGS := -Wall -Wpointer-arith -Wstrict-prototypes -Winline -Wundef -Woverloaded-virtual -g -O2 -ffunction-sections -fdata-sections -fno-rtti -fno-exceptions -fvtable-gc -finit-priority
LDFLAGS := -g -nostdlib -Wl,--gc-sections -Wl,-static
VPATH := $(REPOSITORY)/$(PACKAGE)
INCLUDE_PATH := $(INCLUDE_PATH) -I$(PREFIX)/include $(foreach dir,$(VPATH),-I$(dir) -I$(dir)/src -I$(dir)/tests) -I.
MLT := $(wildcard $(REPOSITORY)/$(PACKAGE)/include/pkgconf/mlt*.ldi $(REPOSITORY)/$(PACKAGE)/include/pkgconf/mlt*.h)
TESTS := 

build: headers libtarget.a.stamp

LIBRARY := libtarget.a
COMPILE := src/hal_diag.c src/plf_misc.c src/plf_stub.c
OBJECTS := $(COMPILE:.cxx=.o.d)
OBJECTS := $(OBJECTS:.c=.o.d)
OBJECTS := $(OBJECTS:.S=.o.d)

$(LIBRARY).stamp: $(OBJECTS)
	$(AR) rcs $(PREFIX)/lib/$(@:.stamp=) $(foreach obj,$?,$(dir $(obj))$(OBJECT_PREFIX)_$(notdir $(obj:.o.d=.o)))
	@cat $^ > $(@:.stamp=.deps)
	@touch $@

$(PREFIX)/lib/romboot.ld: $(wildcard $(REPOSITORY)/$(PACKAGE)/src/romboot.ld)
	cp $< $@
	

$(PREFIX)/bin/romboot.elf: $(wildcard $(REPOSITORY)/$(PACKAGE)/src/romboot.S)
	@sh -c "mkdir -p $(dir $@)"
	$(CC) -Wp,-MD,romboot.tmp $(INCLUDE_PATH) -nostdlib -Wl,-static -T$(PREFIX)/lib/romboot.ld -o $@ $<
	@echo $@ ": \\" > $(notdir $@).deps
	@tail +2 romboot.tmp >> $(notdir $@).deps
	@echo >> $(notdir $@).deps
	@rm romboot.tmp
	

$(PREFIX)/bin/redboot.bin: $(wildcard $(PREFIX)/bin/redboot.elf)
	$(OBJCOPY) -O binary $< $(@:.bin=.img)
	$(OBJCOPY) -O binary $(PREFIX)/bin/romboot.elf $(PREFIX)/bin/romboot.img
	dd if=/dev/zero of=$@ bs=1024 count=64 conv=sync
	dd if=$(@:.bin=.img) of=$@ bs=512 conv=notrunc,sync
	dd if=$(PREFIX)/bin/romboot.img of=$@ bs=256 count=5 seek=507 conv=notrunc
	

headers: mlt_headers $(PREFIX)/include/cyg/hal/hal_diag.h $(PREFIX)/include/cyg/hal/platform.inc $(PREFIX)/include/cyg/hal/plf_arch.h $(PREFIX)/include/cyg/hal/plf_intr.h $(PREFIX)/include/cyg/hal/plf_io.h $(PREFIX)/include/cyg/hal/plf_misc.h $(PREFIX)/include/cyg/hal/plf_stub.h

$(PREFIX)/include/cyg/hal/hal_diag.h: $(REPOSITORY)/$(PACKAGE)/include/hal_diag.h
	@mkdir -p $(dir $@)
	@cp $< $@
	@chmod u+w $@

$(PREFIX)/include/cyg/hal/platform.inc: $(REPOSITORY)/$(PACKAGE)/include/platform.inc
	@mkdir -p $(dir $@)
	@cp $< $@
	@chmod u+w $@

$(PREFIX)/include/cyg/hal/plf_arch.h: $(REPOSITORY)/$(PACKAGE)/include/plf_arch.h
	@mkdir -p $(dir $@)
	@cp $< $@
	@chmod u+w $@

$(PREFIX)/include/cyg/hal/plf_intr.h: $(REPOSITORY)/$(PACKAGE)/include/plf_intr.h
	@mkdir -p $(dir $@)
	@cp $< $@
	@chmod u+w $@

$(PREFIX)/include/cyg/hal/plf_io.h: $(REPOSITORY)/$(PACKAGE)/include/plf_io.h
	@mkdir -p $(dir $@)
	@cp $< $@
	@chmod u+w $@

$(PREFIX)/include/cyg/hal/plf_misc.h: $(REPOSITORY)/$(PACKAGE)/include/plf_misc.h
	@mkdir -p $(dir $@)
	@cp $< $@
	@chmod u+w $@

$(PREFIX)/include/cyg/hal/plf_stub.h: $(REPOSITORY)/$(PACKAGE)/include/plf_stub.h
	@mkdir -p $(dir $@)
	@cp $< $@
	@chmod u+w $@

include $(REPOSITORY)/pkgconf/rules.mak

