#
# sdl/makefile.cfg for SRB2/SDL
#

#
#SDL...., *looks at Alam*, THIS IS A MESS!
#

ifdef UNIXCOMMON
include sdl/MakeNIX.cfg
endif

ifdef PANDORA
include sdl/SRB2Pandora/Makefile.cfg
endif #ifdef PANDORA

ifdef DC
include sdl/SRB2DC/Makefile.cfg
endif #ifdef DC

ifdef PS3N
include sdl/SRB2PS3/Makefile.cfg
endif #ifdef PS3N

ifdef PSP
include sdl/SRB2PSP/Makefile.cfg
endif #ifdef PSP

ifdef XBOX
include sdl/SRB2XBOX/Makefile.cfg
endif #ifdef XBOX

ifdef WINCE
include sdl/SRB2CE/Makefile.cfg
endif #ifef WINCE

ifdef CYGWIN32
include sdl/MakeCYG.cfg
endif #ifdef CYGWIN32

ifdef SDL_PKGCONFIG
SDL_CFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --cflags)
SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs)
else
ifdef PREFIX
	SDL_CONFIG?=$(PREFIX)-sdl-config
else
	SDL_CONFIG?=sdl-config
endif

ifdef STATIC
	SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
	SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --static-libs)
else
	SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags)
	SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --libs)
endif
endif


	#use the x86 asm code
ifndef CYGWIN32
ifndef NOASM
	USEASM=1
endif
endif

	OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o

	OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL

ifndef NOHW
	OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o
endif

ifndef NOHS
ifdef OPENAL
	OBJS+=$(OBJDIR)/s_openal.o
	OPTS+=-DSTATIC3DS
	STATICHS=1
else
ifdef FMOD
	OBJS+=$(OBJDIR)/s_fmod.o
	OPTS+=-DSTATIC3DS
	STATICHS=1
else
ifdef MINGW
ifdef DS3D
	OBJS+=$(OBJDIR)/s_ds3d.o
	OPTS+=-DSTATIC3DS
	STATICHS=1
endif
endif
endif
endif
endif

ifdef FILTERS
	OBJS+=$(OBJDIR)/filters.o $(OBJDIR)/hq2x.o $(OBJDIR)/lq2x.o
	OPTS+=-DHAVE_FILTER
endif

ifdef NOMIXER
	i_sound_o=$(OBJDIR)/sdl_sound.o
else
	i_sound_o=$(OBJDIR)/mixer_sound.o
	OPTS+=-DHAVE_MIXER
	SDL_LDFLAGS+=-lSDL_mixer
endif

ifdef SDL_TTF
	OPTS+=-DHAVE_TTF
	SDL_LDFLAGS+=-lSDL_ttf -lfreetype -lz
	OBJS+=$(OBJDIR)/i_ttf.o
endif

#ifdef SDL_IMAGE
#	OPTS+=-DHAVE_IMAGE
#	SDL_LDFLAGS+=-lSDL_image
#endif

ifdef SDL_NET
	OPTS+=-DHAVE_SDLNET
	SDL_LDFLAGS+=-lSDL_net
endif

ifdef SDLMAIN
	OPTS+=-DSDLMAIN
else
ifdef MINGW
	SDL_CFLAGS+=-Umain
	SDL_LDFLAGS+=-mconsole
endif
endif

ifndef NOHW
ifdef OPENAL
ifdef MINGW
	LIBS:=-lopenal32 $(LIBS)
else
	LIBS:=-lopenal $(LIBS)
endif
else
ifdef MINGW
ifdef DS3D
	LIBS:=-ldsound -luuid $(LIBS)
endif
endif
endif
endif

# FIXME: DevkitPPC and ready-compiled SDL Wii require these things to be in a silly order
ifdef WII
include sdl/SRB2WII/Makefile.cfg
endif #ifdef WII

CFLAGS+=$(SDL_CFLAGS)
LIBS:=$(SDL_LDFLAGS) $(LIBS)
ifndef WII
ifdef STATIC
	LIBS+=$(shell $(SDL_CONFIG) --static-libs)
endif
endif