
AR = ar
AR_FLAGS = cru
RANLIB = ranlib

INC=-I. -Iinclude -DHAVE_CONFIG_H -DDREAMCAST
OPT= -O3 -fstrict-aliasing -fexpensive-optimizations -foptimize-register-move  -freduce-all-givs -frename-registers -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns -fno-sched-interblock -fsched-spec-load -fsingle-precision-constant -fstrength-reduce -fstrict-aliasing -ffast-math -fno-common -fno-builtin -fno-exceptions -fargument-noalias-global -Wall -g -fomit-frame-pointer

OPT2 = -O9 -fomit-frame-pointer -fno-ident -freorder-blocks -funsigned-char -funsigned-char -funroll-all-loops -frerun-loop-opt  -falign-loops -fstrict-aliasing

OPT3 = -Os -mbigtable -mnomacsave -fschedule-insns2 -fexpensive-optimizations -fomit-frame-pointer -fstrict-aliasing -ffast-math

#KOS_CFLAGS += $(INC) -I$(KOS_BASE)/../kos-ports/include/zlib -I$(KOS_BASE)/../kos-ports/libpng -I$(KOS_BASE)/../kos-ports/include/SDL -I$(KOS_BASE)/../kos-ports/SDL/SDL_mixer/mikmod 
KOS_CFLAGS += $(INC) -ml -m4-single-only -D_arch_dreamcast -D_arch_sub_pristine  \
$(OPT3) \
-I$(KOS_BASE)/../../sh-elf/sh-elf/include -I$(KOS_BASE)/../kos-ports/include -I$(KOS_BASE)/include -I$(KOS_BASE)/kernel/arch/dreamcast/include -I$(KOS_BASE)/addons/include-I$(KOS_BASE)/include -I$(KOS_BASE)/addons/include -I$(KOS_BASE)/../kos-ports/include  -I$(KOS_BASE)/../kos-ports/include/zlib -I$(KOS_BASE)/../kos-ports/libpng -I$(KOS_BASE)/../kos-ports/include/SDL -I$(KOS_BASE)/../kos-ports/SDL/SDL_mixer/mikmod 

KOS_CPPFLAGS+= ${KOS_CFLAGS} $(INC)


TARGET = Cdogs.elf

.PHONY: all all-before all-after clean clean-custom

all: all-before $(TARGET) all-after

include dreamcast.mak
 
OBJS = romdisk.o 	cdogs.o draw.o pics.o actors.o map.o sounds.o defs.o objs.o gamedata.o ai.o triggers.o input.o prep.o hiscores.o automap.o mission.o game.o mainmenu.o password.o files.o menu.o joystick.o sprcomp.o grafx.o blit.o text.o keyboard.o events.o utils.o drawtools.o
include $(KOS_BASE)/Makefile.rules

clean:
	-rm -f $(TARGET) $(OBJS) cdogs.bin romdisk.*

rm-elf:
	-rm -f $(TARGET) romdisk.*

$(TARGET): $(OBJS) $(PROBJS) 
	$(KOS_CC) $(KOS_CFLAGS) $(KOS_LDFLAGS) -o $(TARGET) $(KOS_START) \
		$(OBJS)  $(PROBJS)   $(OBJEXTRA) -L$(KOS_BASE)/lib -lgcc -lSDL_129 -lSDL_image_124 -lSDL_mixer_126 -lSDL_ttf -lfreetype -lpng_128 -ljpeg -lz_123 -lm -lSDL_129 $(KOS_LIBS)
