From eb2f5614ca10aed240f2d7b310c6929874effc3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=3D=3FUTF-8=3Fq=3FHigor=3D20Eur=3DC3=3DADpedes=3F=3D?= Date: Sun, 26 Jul 2015 10:59:41 -0700 Subject: Fix mingw-w64 build and cross-compilation --- Makefile | 16 +++++++++------- config.c | 8 +++++++- mem_win.c | 2 +- util.c | 4 ++-- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 40ffb72..5b4fd5e 100644 --- a/Makefile +++ b/Makefile @@ -3,12 +3,18 @@ OS:=$(shell uname -s) endif ifeq ($(OS),Windows) +ifndef SDL2_PREFIX +SDL2_PREFIX:="C:/MinGW/usr" +endif +ifndef GLEW32S_LIB +GLEW32S_LIB=glew32s.lib +endif MEM:=mem_win.o BLASTEM:=blastem.exe CC:=wine gcc.exe -CFLAGS:=-O2 -std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"C:/MinGW/usr/include/SDL2" -DGLEW_STATIC -LDFLAGS:= -L"C:/MinGW/usr/lib" -lm -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lglu32 -mwindows +CFLAGS:=-O2 -std=gnu99 -Wreturn-type -Werror=return-type -Werror=implicit-function-declaration -I"$(SDL2_PREFIX)/include/SDL2" -DGLEW_STATIC +LDFLAGS:= $(GLEW32S_LIB) -L"$(SDL2_PREFIX)/lib" -lm -lmingw32 -lSDL2main -lSDL2 -lopengl32 -lglu32 -mwindows CPU:=i686 else @@ -117,11 +123,7 @@ else MAINOBJS+= $(Z80OBJS) endif -ifeq ($(OS),Windows) -MAINOBJS+= glew32s.lib -endif - -all : dis zdis stateview vgmplay blastem +all : dis zdis stateview vgmplay $(BLASTEM) $(BLASTEM) : $(MAINOBJS) $(CC) -o $(BLASTEM) $(MAINOBJS) $(LDFLAGS) diff --git a/config.c b/config.c index 6fd29b5..b34aec0 100644 --- a/config.c +++ b/config.c @@ -9,7 +9,13 @@ #include #include -#ifdef _WIN32 +#ifdef __MINGW64_VERSION_MAJOR +#define MINGW_W64_VERSION (__MINGW64_VERSION_MAJOR * 1000 + __MINGW64_VERSION_MINOR) +#else +#define MINGW_W64_VERSION 0 +#endif + +#if defined(_WIN32) && (MINGW_W64_VERSION < 3003) char * strtok_r(char * input, char * sep, char ** state) { if (input) { diff --git a/mem_win.c b/mem_win.c index 8a76712..4076afd 100644 --- a/mem_win.c +++ b/mem_win.c @@ -5,7 +5,7 @@ */ #include "mem.h" -#include +#include void * alloc_code(size_t *size) { diff --git a/util.c b/util.c index 2a59b08..9722d3e 100644 --- a/util.c +++ b/util.c @@ -87,8 +87,8 @@ void set_exe_str(char * str) } #ifdef _WIN32 -#include "Shlobj.h" -#include "Windows.h" +#include +#include char * get_home_dir() { -- cgit v1.2.3