#
# win32/Makefile.cfg for SRB2/Minwgw
#

#
#Mingw, if you don't know, that's Win32/Win64
#

ifdef MINGW64
	NOASM=1
	NONX86=1
	SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main
	SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDL2_mixer/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
else
	HAVE_LIBGME=1
	LIBGME_CFLAGS=-I../libs/gme/include
	LIBGME_LDFLAGS=-L../libs/gme/win32 -lgme
	SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main
	SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDL2_mixer/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows
endif

ifndef NOASM
	USEASM=1
endif

	HAVE_MINIUPNPC=1

	OPTS=-DSTDC_HEADERS

ifndef GCC44
	#OPTS+=-mms-bitfields
endif

ifndef MINGW64
	OPTS+=-gdwarf-2
endif

ifndef SDL
	OPTS+=-D_WINDOWS
endif
	OPTS+=-D__USE_MINGW_ANSI_STDIO=0

ifndef SDL
	LIBS+=-lmingw32 -mwindows -ldinput -ldxguid -lgdi32 -lwinmm
endif

	LIBS+=-ladvapi32 -lkernel32 -lmsvcrt -luser32
ifdef MINGW64
	LIBS+=-lws2_32
else
ifdef NO_IPV6
	LIBS+=-lwsock32
else
	LIBS+=-lws2_32
endif
endif

	# name of the exefile
ifdef SDL
	EXENAME?=srb2win.exe
else
	EXENAME?=srb2dd.exe
endif

ifdef SDL
	i_system_o+=$(OBJDIR)/SRB2.res
	i_main_o+=$(OBJDIR)/win_dbg.o
ifndef NOHW
	OPTS+=-DUSE_WGL_SWAP
endif
else
	D_FILES+=$(D_DIR)/fmodex.dll
	CFLAGS+=-I../libs/fmodex/inc
	LDFLAGS+=-L../libs/fmodex/lib
ifdef MINGW64
	LIBS+=-lfmodex64_vc
else
	LIBS+=-lfmodex_vc
endif
	i_cdmus_o=$(OBJDIR)/win_cd.o
	i_net_o=$(OBJDIR)/win_net.o
	i_system_o=$(OBJDIR)/win_sys.o $(OBJDIR)/SRB2.res
	i_sound_o=$(OBJDIR)/win_snd.o
	i_main_o=$(OBJDIR)/win_dbg.o $(OBJDIR)/win_main.o
	OBJS=$(OBJDIR)/dx_error.o $(OBJDIR)/fabdxlib.o $(OBJDIR)/win_vid.o $(OBJDIR)/win_dll.o
endif


ZLIB_CFLAGS?=-I../libs/zlib
ifdef MINGW64
ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz64
else
ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz32
endif

ifndef NOPNG
ifndef PNG_CONFIG
	PNG_CFLAGS?=-I../libs/libpng-src
ifdef MINGW64
	PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng64
else
	PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng32
endif #MINGW64
endif #PNG_CONFIG
endif #NOPNG

ifdef GETTEXT
ifndef CCBS
	MSGFMT?=../libs/gettext/bin32/msgfmt.exe
endif
ifdef MINGW64
	CPPFLAGS+=-I../libs/gettext/include64
	LDFLAGS+=-L../libs/gettext/lib64
	LIBS+=-lmingwex
else
	CPPFLAGS+=-I../libs/gettext/include32
	LDFLAGS+=-L../libs/gettext/lib32
	STATIC_GETTEXT=1
endif #MINGW64
ifdef STATIC_GETTEXT
	LIBS+=-lasprintf -lintl
else
	LIBS+=-lintl.dll
endif #STATIC_GETTEXT
endif #GETTEXT

ifdef HAVE_MINIUPNPC
	CPPFLAGS+=-I../libs/ -DSTATIC_MINIUPNPC
ifdef MINGW64
	LDFLAGS+=-L../libs/miniupnpc/mingw64
else
	LDFLAGS+=-L../libs/miniupnpc/mingw32
endif #MINGW64
endif
