#
# @(#)Makefile
#
# Copyright 1999-2001, Aaron Ardiri (mailto:aaron@ardiri.com)
# All rights reserved.
#
# The  source code outlines a number of basic Helio Computing Programming
# principles and you  should be able to take the core structure and write 
# a large complex program. It is distributed WITHOUT ANY WARRANTY; use it
# "AS IS" and at your own risk.
#
# The code presented is Copyright by Aaron Ardiri. It should be used  for 
# educational purposes only.  You shall not modify the Cube3D source code 
# in  any way and  re-distribute it as your own,  however you are free to
# use the code as a guide for developing programs on the Helio  Computing 
# Platform.
#

# compiler setup
PREFIX    = 
AS        = $(PREFIX)mips-vtos-as
CC        = $(PREFIX)mips-vtos-gcc
LD        = $(PREFIX)mips-vtos-ld

# source / outputs
LD_OBJS   = appstart.o gccfix.o syscall.o resource/gfx.a
OBJS      = helio.o device.o help.o cube3D.o resource.o
EXEC      = cube3D

# compiler flags 
ASFLAGS   = -O2
CCFLAGS   = -O2
LDFLAGS   = -T resource/link.cmd

# compile requirements
$(EXEC).app: main.obj
	chop main.obj main.out .head .text .data
	acompile /S:37 $(EXEC).app main.out images/mainicon.bmp "Cube 3D"
	cp $(EXEC).app ..
	make clean

main.obj: $(OBJS) $(LD_OBJS)
	$(LD) $(LDFLAGS) -o $@ $(OBJS) $(LD_OBJS)

resource.c: resource.rcp
	rcompile resource.rcp > tmp.out
	bin2hex resource.bin resource.c > tmp.out

# compile rules
%.o: %.s
	cp $< tmp.S; $(AS) -c $(ASFLAGS) tmp.S -o $@
%.o: %.c
	$(CC) -c $(CCFLAGS) $<

# clean-up funtions
clean:
	rm -f *.[oO] *.OBJ *.BIN c.txt resource.c *~ main.* tmp.* TMP.*

distclean:
	rm -f *.[oO] *.OBJ *.BIN c.txt resource.c *~ main.* *.app tmp.* TMP.*
