From 2703fa7f6676d95db40bc225a4387855aa0c3edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Higor=20Eur=C3=ADpedes?= Date: Fri, 29 Aug 2014 16:35:56 -0300 Subject: [PATCH] Allow unix-like build under mingw --- Makefile | 56 ++++++++++++++++++++++++++++++++++++++++++--- compat/strl.h | 2 +- gfx/state_tracker.h | 2 +- qb/config.libs.sh | 32 ++++++++++++++++++++++---- 4 files changed, 83 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index fdf3e167ff..196482e778 100644 --- a/Makefile +++ b/Makefile @@ -139,6 +139,9 @@ endif ifeq ($(HAVE_NETPLAY), 1) OBJ += netplay.o + ifneq ($(findstring Win32,$(OS)),) + LIBS += -lws2_32 + endif endif ifeq ($(HAVE_COMMAND), 1) @@ -240,6 +243,34 @@ ifeq ($(HAVE_SDL2), 1) LIBS += $(SDL2_LIBS) endif +ifeq ($(HAVE_D3D9), 1) + OBJ += gfx/d3d9/d3d.o gfx/d3d9/render_chain.o gfx/fonts/d3d_font.o gfx/fonts/d3d_w32_font.o gfx/context/d3d_ctx.o + DEFINES += -DHAVE_WIN32_D3D9 + LIBS += -ld3d9 -ld3dx9 -ldxguid +endif + +ifeq ($(HAVE_WINXINPUT), 1) + OBJ += input/winxinput_joypad.o + JOYCONFIG_OBJ += input/winxinput_joypad.o +endif + +ifeq ($(HAVE_DINPUT), 1) + LIBS += -ldinput8 -ldxguid -lole32 + OBJ += input/dinput.o + JOYCONFIG_LIBS += -ldinput8 -ldxguid -lole32 + JOYCONFIG_OBJ += input/dinput.o +endif + +ifeq ($(HAVE_XAUDIO), 1) + OBJ += audio/xaudio.o audio/xaudio-c/xaudio-c.o + LIBS += -lole32 +endif + +ifeq ($(HAVE_DSOUND), 1) + OBJ += audio/dsound.o + LIBS += -ldxguid -ldsound +endif + ifeq ($(HAVE_OMAP), 1) OBJ += gfx/omap_gfx.o endif @@ -310,6 +341,9 @@ ifeq ($(HAVE_OPENGL), 1) OBJ += gfx/glsym/glsym_gl.o ifeq ($(OSX), 1) LIBS += -framework OpenGL + else ifneq ($(findstring Win32,$(OS)),) + LIBS += -lopengl32 -lgdi32 -lcomdlg32 + OBJ += gfx/context/wgl_ctx.o gfx/context/win32_common.o else LIBS += -lGL endif @@ -349,6 +383,9 @@ ifeq ($(HAVE_CG), 1) LIBS += -framework Cg else LIBS += -lCg -lCgGL + ifeq ($(HAVE_D3D9),1) + LIBS += -lcgD3D9 + endif endif endif @@ -437,11 +474,19 @@ ifeq ($(GL_DEBUG), 1) endif CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I. +CXXFLAGS = -std=c++0x -xc++ -D__STDC_CONSTANT_MACROS + ifeq ($(CXX_BUILD), 1) LINK = $(CXX) - CFLAGS += -std=c++0x -xc++ -D__STDC_CONSTANT_MACROS + CFLAGS += $(CXXFLAGS) else - LINK = $(CC) + ifeq ($(findstring Win32,$(OS)),) + LINK = $(CC) + else + # directx-related code is c++ + LINK = $(CXX) + endif + ifneq ($(GNU90_BUILD), 1) ifneq ($(findstring icc,$(CC)),) CFLAGS += -std=c99 -D_GNU_SOURCE @@ -460,7 +505,7 @@ endif GIT_VERSION := $(shell git rev-parse --short HEAD 2>/dev/null) ifneq ($(GIT_VERSION),) - DEFINES += -DHAVE_GIT_VERSION -DGIT_VERSION=\"$(GIT_VERSION)\" + DEFINES += -DHAVE_GIT_VERSION -DGIT_VERSION="\"$(GIT_VERSION)\"" OBJ += git_version.o endif @@ -497,6 +542,11 @@ $(OBJDIR)/%.o: %.c config.h config.mk @$(if $(Q), $(shell echo echo CC $<),) $(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $< +$(OBJDIR)/%.o: %.cpp + @mkdir -p $(dir $@) + @$(if $(Q), $(shell echo echo CXX $<),) + $(Q)$(CXX) $(CFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $< + .FORCE: $(OBJDIR)/git_version.o: git_version.c .FORCE diff --git a/compat/strl.h b/compat/strl.h index 02123da4ae..b55aa00f5e 100644 --- a/compat/strl.h +++ b/compat/strl.h @@ -20,7 +20,7 @@ #include #ifdef HAVE_CONFIG_H -#include "config.h" +#include "../config.h" #endif #ifndef HAVE_STRL diff --git a/gfx/state_tracker.h b/gfx/state_tracker.h index 08a6a68840..4022f9db06 100644 --- a/gfx/state_tracker.h +++ b/gfx/state_tracker.h @@ -24,7 +24,7 @@ extern "C" { #include "../boolean.h" #ifdef HAVE_CONFIG_H -#include "config.h" +#include "../config.h" #endif enum state_tracker_type diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 00b4ce6d72..5cd34e1e61 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -22,6 +22,9 @@ elif [ "$OS" = 'Haiku' ]; then CLIB=-lroot PTHREADLIB=-lroot SOCKETLIB=-lnetwork +elif [ "$OS" = 'Win32' ]; then + SOCKETLIB=-lws2_32 + DYLIB= fi add_define_make DYLIB_LIB "$DYLIB" @@ -113,8 +116,13 @@ else add_define_make MAN_DIR "${PREFIX}/share/man/man1" fi -check_lib THREADS "$PTHREADLIB" pthread_create -check_lib DYLIB "$DYLIB" dlopen +if [ "$OS" = 'Win32' ]; then + HAVE_THREADS=yes + HAVE_DYLIB=yes +else + check_lib THREADS "$PTHREADLIB" pthread_create + check_lib DYLIB "$DYLIB" dlopen +fi check_lib NETPLAY "$SOCKETLIB" socket if [ "$HAVE_NETPLAY" = 'yes' ]; then @@ -177,6 +185,18 @@ if [ "$HAVE_SDL2" = 'yes' ]; then fi fi +if [ "$OS" = 'Win32' ]; then + check_lib DINPUT -ldinput8 + check_lib D3D9 -ld3d9 + check_lib DSOUND -ldsound + + if [ "$HAVE_DINPUT" != 'no' ]; then + HAVE_WINXINPUT=yes + fi + + HAVE_XAUDIO=yes +fi + if [ "$HAVE_OPENGL" != 'no' ] && [ "$HAVE_GLES" != 'yes' ]; then if [ "$OS" = 'Darwin' ]; then check_lib CG "-framework Cg" cgCreateContext @@ -205,7 +225,9 @@ else HAVE_FFMPEG='no' fi -check_lib DYNAMIC "$DYLIB" dlopen +if [ "$OS" != 'Win32' ]; then + check_lib DYNAMIC "$DYLIB" dlopen +fi if [ "$HAVE_KMS" != "no" ]; then check_pkgconf GBM gbm 9.0 @@ -249,6 +271,8 @@ check_pkgconf V4L2 libv4l2 if [ "$OS" = 'Darwin' ]; then check_lib FBO "-framework OpenGL" glFramebufferTexture2D +elif [ "$OS" = 'Win32' ]; then + HAVE_FBO=yes else if [ "$HAVE_GLES" = "yes" ]; then [ $HAVE_FBO != "no" ] && HAVE_FBO=yes @@ -295,6 +319,6 @@ add_define_make OS "$OS" # Creates config.mk and config.h. add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR" -VARS="RGUI LAKKA ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL SDL2 OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT" +VARS="RGUI LAKKA ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL SDL2 D3D9 DINPUT WINXINPUT DSOUND XAUDIO OPENGL LIMA OMAP GLES GLES3 VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG LIBXML2 ZLIB DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL SWSCALE FREETYPE XKBCOMMON XVIDEO X11 XEXT XF86VM XINERAMA WAYLAND MALI_FBDEV VIVANTE_FBDEV NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL STRCASESTR MMAP PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 BSV_MOVIE VIDEOCORE NEON FLOATHARD FLOATSOFTFP UDEV V4L2 AV_CHANNEL_LAYOUT" create_config_make config.mk $VARS create_config_header config.h $VARS