From b70d49349a7bec8e6ce539220b4b7ffb2e7e8bca Mon Sep 17 00:00:00 2001 From: Thomas Bernard Date: Tue, 6 Feb 2018 22:21:56 +0100 Subject: [PATCH] add CROSS_CC CROSS_PKGCONFIG CROSS_SDLCONFIG for Mingw32 Cross compilation --- doc/COMPILING.txt | 4 +++- src/Makefile | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/doc/COMPILING.txt b/doc/COMPILING.txt index d9d43eee..fa24cb23 100644 --- a/doc/COMPILING.txt +++ b/doc/COMPILING.txt @@ -96,8 +96,10 @@ This will only work on an UNIXsystem (Linux or FreeBSD). == Windows == It is also possible to compile from linux, with this command : - make WIN32CROSS=1 + $ make WIN32CROSS=1 You will need the mingw cross-compiler, and all the librairies listed above. +Variables CROSS_CC, CROSS_PKGCONFIG and CROSS_SDLCONFIG can be set : + $ CROSS_CC=mingw32-gcc CROSS_PKGCONFIG=mingw32-pkg-config CROSS_SDLCONFIG=/path/to/ming32/sdl-config WIN32CROSS=1 NOTTF=1 make Here is a list of the resources used to build the Windows version: diff --git a/src/Makefile b/src/Makefile index e3c205ac..8a223975 100644 --- a/src/Makefile +++ b/src/Makefile @@ -362,12 +362,19 @@ endif # These can only be used under linux and maybe freebsd. They allow to compile for the gp2x or to create a windows binary ifdef WIN32CROSS #cross compile a Win32 executable - CC = i686-w64-mingw32-gcc + CROSS_CC ?= $(shell which i686-w64-mingw32-gcc || which mingw32-gcc) + CROSS_PKGCONFIG ?= $(shell i686-w64-mingw32-pkg-config || mingw32-pkg-config) + CROSS_SDLCONFIG ?= /usr/local/cross-tools/i386-mingw32/bin/sdl-config + CC = $(CROSS_CC) BIN = ../bin/grafx2.exe - COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb -Dmain=SDL_main $(shell /usr/local/cross-tools/i386-mingw32/bin/sdl-config --cflags) $(TTFCOPT) - LOPT = -mwindows -lmingw32 -lSDLmain -lSDL -lshlwapi $(shell /usr/local/cross-tools/i386-mingw32/bin/sdl-config --libs) -lSDL_image $(TTFLOPT) - COPT += $(shell PKG_CONFIG_PATH=/usr/local/cross-tools/i386-mingw32/lib/pkgconfig i686-w64-mingw32-pkg-config --cflags libpng) - LOPT += $(shell PKG_CONFIG_PATH=/usr/local/cross-tools/i386-mingw32/lib/pkgconfig i686-w64-mingw32-pkg-config --libs libpng) + COPT = -W -Wall -Wdeclaration-after-statement -O$(OPTIM) -g -ggdb -Dmain=SDL_main $(shell $(CROSS_SDLCONFIG) --cflags) $(TTFCOPT) + LOPT = -mwindows -lmingw32 -lSDLmain -lSDL -lshlwapi $(shell $(CROSS_SDLCONFIG) --libs) -lSDL_image $(TTFLOPT) + ifeq (,$(CROSS_PKGCONFIG)) + COPT += -D__no_pnglib__ + else + COPT += $(shell PKG_CONFIG_PATH=/usr/local/cross-tools/i386-mingw32/lib/pkgconfig $(CROSS_PKGCONFIG) --cflags libpng) + LOPT += $(shell PKG_CONFIG_PATH=/usr/local/cross-tools/i386-mingw32/lib/pkgconfig $(CROSS_PKGCONGIF) --libs libpng) + endif OBJDIR = ../obj/win32 PLATFORM = win32 PLATFORMFILES = bin/SDL.dll bin/SDL_image.dll bin/libpng14-14.dll bin/zlib1.dll $(TTFLIBS)