## Powder 117 - A Roguelike designed for the Gameboy Advance and Nintendo DS.
## This is free software under the GPL

# Put the filename of the output binary here
TARGET = powder.elf

# List all of your C files here, but change the extension to ".o"
# Include "romdisk.o" if you want a rom disk.
OBJS = 	dcmain.o \
	 hamfake.o \
	 ../../action.o \
	 ../../assert.o \
	 ../../ai.o \
	 ../../artifact.o \
	 ../../bmp.o \
	 ../../build.o \
	 ../../buf.o \
	 ../../control.o \
	 ../../creature.o \
	 ../../dpdf_table.o \
	 ../../encyc_support.o \
	 ../../gfxengine.o \
	 ../../grammar.o \
	 ../../hiscore.o \
	 ../../input.o \
	 ../../intrinsic.o \
	 ../../item.o \
	 ../../map.o \
	 ../../mobref.o \
	 ../../msg.o \
	 ../../name.o \
	 ../../piety.o \
	 ../../rand.o \
	 ../../signpost.o \
	 ../../smokestack.o \
	 ../../speed.o \
	 ../../sramstream.o \
	 ../../stylus.o \
	 ../../victory.o \
	 ../../encyclopedia.o \
	 ../../glbdef.o \
	 ../../credits.o \
	 ../../license.o \
	 ../../gfx/all_bitmaps.o \
	 ../../rooms/allrooms.o
	 
PREMAKE = ../../support/map2c/map2c \
	  ../../support/tile2c/tile2c \
	  ../../support/bmp2c/bmp2c \
	  ../../support/encyclopedia2c/encyclopedia2c \
	  ../../support/enummaker/enummaker \
	  ../../support/txt2c/txt2c

# If you define this, the Makefile.rules will create a romdisk.o for you
# from the named dir.
#KOS_ROMDISK_DIR = romdisk

# The rm-elf step is to remove the target before building, to force the
# re-creation of the rom disk.
all: rm-elf $(TARGET)

# Chui DREAMCAST SDL
INCLUDES = -I. -I$(KOS_BASE)/addons/include/SDL -I$(KOS_BASE)/addons/include

# FLAGS
KOS_CPPFLAGS += $(INCLUDES) -DDREAMCAST 

include $(KOS_BASE)/Makefile.rules

clean:
	-rm -f $(TARGET) $(OBJS)
	@for s in $$( echo "$(PREMAKE)" | tr -s '' '\n'); do \
		$(MAKE) clean -C `dirname $$s`; \
	done;

rm-elf:
	-rm -f $(TARGET)

# Create the static version :)
$(TARGET): premake $(OBJS)
	$(KOS_CCPLUS) $(KOS_CPPFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
		$(OBJS) $(OBJEXTRA) -L$(KOS_BASE)/lib -lgcc -lSDL_1213 -lm -lz -lstdc++ $(KOS_LIBS)

$(PREMAKE):
	$(MAKE) -C `dirname $@`

premake: $(PREMAKE)
	cd ../../rooms ; ./buildrooms.bash
	cd ../../gfx ; ./rebuild.sh
	cd ../.. ; support/enummaker/enummaker source.txt
	cd ../.. ; support/txt2c/txt2c LICENSE.TXT license.cpp
	cd ../.. ; support/txt2c/txt2c CREDITS.TXT credits.cpp
	cd ../.. ; support/encyclopedia2c/encyclopedia2c encyclopedia.txt
	
bin:
	$(KOS_OBJCOPY) -O binary -R .stack $(TARGET) powder.bin
