export SHELLOPTS := igncr


OBJECTS := crt0 blubber task funcasm sieve mix ovdemo


GCC    := ppc-eabi-gcc
GCOPT  := -gdwarf-2 -Wall -mcpu=powerpc -mno-eabi -mno-sdata -fshort-enums
GOBJ   := $(addsuffix .gnu.o, $(OBJECTS))

DCC    := dcc
DCOPT  := -g2 -Xdebug-dwarf2 -Xlint=0x88 -tPPCFS:simple -Xsmall-data=0 -Xsmall-const=0 -Xenum-is-best -Xconst-in-data
DOBJ   := $(addsuffix .diab.o, $(OBJECTS))


.PHONY : all
all: gnu


.PHONY : gnu
gnu : ovdemo.gnu.elf

%.gnu.o: %.gnu.s makefile
	$(GCC) $(GCOPT) -xassembler-with-cpp -c -o $@ $< 

%.gnu.o: %.c makefile
	$(GCC) $(GCOPT) -c -o $@ $< 

ovdemo.gnu.elf: $(GOBJ) ovdemo.gnu.ld makefile
	$(GCC) -nostdlib -Wl,--emit-relocs -Tovdemo.gnu.ld -o $@ $(GOBJ)
	ppc-eabi-readelf ovdemo.gnu.elf -s -S -l > info.gnu.txt
# Note: The linker option "--emit-relocs" is mandatory, to debug code overlays. 


.PHONY : diab
diab : ovdemo.diab.elf

%.diab.o: %.diab.s makefile
	$(DCC) $(DAOPT) -Xpreprocess-assembly -c -o $@ $< 

%.diab.o: %.c makefile
	$(DCC) $(DCOPT) -c -o $@ $< 

ovdemo.diab.elf: $(DOBJ) ovdemo.diab.ld makefile
	$(DCC) -Ws -r2 -W l,-Xgenerate-paddr,-Xassociate-headers -o $@ $(DOBJ) ovdemo.diab.ld
	 ppc-eabi-readelf ovdemo.diab.elf -s -S -l > info.diab.txt
# Note: The linker option "-r2" is mandatory, to debug code overlays. 


.PHONY : clean
clean:
	rm -fv *.o 
	rm -fv *.elf 

