# Gauntlet/Sigma0/Makefile
# Created by Adam Wiggins: 18/09/1999
# Last Modified by Adam Wiggins: 24/10/1999
# Makefile for Default Sigma0

include ../Makefile.conf
include ./Makefile.conf

BINARY=sigma0_$(PLATFORM).bin
SIGMA0=sigma0_$(PLATFORM).elf
SOURCES=crt0.S main.c
OBJECTS=$(patsubst %.S, %.o, $(patsubst %.c, %.o, $(SOURCES)))
LIBS=libcpu.a libplatform.a
SUBDIRS=$(CPU_DIR) $(PLATFORM_DIR)

#$(BINARY): $(SIGMA0)
#	$(OBJCOPY) -O binary -S $(SIGMA0) $(BINARY)

$(SIGMA0): $(OBJECTS) $(LIBS) sigma0.ld ./Makefile ./Makefile.conf \
	../Makefile.conf
	#$(LD) $(LDFLAGS) -o $@ $(OBJECTS) $(LIBS) -lgcc

libcpu.a: $(CPU_DIR)/* ./Makefile ./Makefile.conf ../Makefile.conf
	(cd $(CPU_DIR); $(MAKE))

libplatform.a: $(PLATFORM_DIR)/* ./Makefile ./Makefile.conf ../Makefile.conf
	(cd $(PLATFORM_DIR); $(MAKE))

.depend: $(SOURCES) ./Makefile ./Makefile.conf ../Makefile.conf
	$(CC) -M $(CPPFLAGS) $(SOURCES) > .depend

clean:
	rm -f *.elf *.bin *.o *.a *~
	@for i in $(SUBDIRS);\
	do \
	(cd $$i; $(MAKE) clean);\
	done

include .depend
