From 9f6bc4ea37f9288a728941f3d7f49a1cdc35907e Mon Sep 17 00:00:00 2001 From: Alexandre Moine Date: Sat, 22 Aug 2015 13:43:16 +0200 Subject: [PATCH] Add cross-compile support --- Makefile.am | 17 +++++++ configure.ac | 47 ++++++++---------- .../LICENSE-ogg-vorbis.txt | 0 LICENSE-sdl.txt => dll/LICENSE-sdl.txt | 0 SDL.dll => dll/SDL.dll | Bin SDL_gfx.dll => dll/SDL_gfx.dll | Bin SDL_mixer.dll => dll/SDL_mixer.dll | Bin SDL_ttf.dll => dll/SDL_ttf.dll | Bin libogg-0.dll => dll/libogg-0.dll | Bin libvorbis-0.dll => dll/libvorbis-0.dll | Bin .../libvorbisfile-3.dll | Bin 11 files changed, 38 insertions(+), 26 deletions(-) rename LICENSE-ogg-vorbis.txt => dll/LICENSE-ogg-vorbis.txt (100%) rename LICENSE-sdl.txt => dll/LICENSE-sdl.txt (100%) rename SDL.dll => dll/SDL.dll (100%) rename SDL_gfx.dll => dll/SDL_gfx.dll (100%) rename SDL_mixer.dll => dll/SDL_mixer.dll (100%) rename SDL_ttf.dll => dll/SDL_ttf.dll (100%) rename libogg-0.dll => dll/libogg-0.dll (100%) rename libvorbis-0.dll => dll/libvorbis-0.dll (100%) rename libvorbisfile-3.dll => dll/libvorbisfile-3.dll (100%) diff --git a/Makefile.am b/Makefile.am index 459664e6..96a69ce9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,3 +27,20 @@ clean-local: # First target made BUILT_SOURCES = language-data.cpp graph.cpp +############################# +# Platform specific setup +############################# +windres_prefix="" +if MINGW +hyperrogue_SOURCES += hyper.res +hyperrogue_CPPFLAGS += ${wincppflags} +#hyperrogue_LDFLAGS = "-static-libgcc -static-libstdc++" +windres_prefix += "${host_cpu}-w64-mingw32-" + +endif MINGW + +############################# +# Arch specific setup +############################# +hyper.res: hyper.rc hr-icon.ico + ${windres_prefix}windres hyper.rc -O coff -o hyper.res diff --git a/configure.ac b/configure.ac index 7c7cce00..2dfe1c49 100644 --- a/configure.ac +++ b/configure.ac @@ -11,24 +11,35 @@ AC_CONFIG_SRCDIR([hyperpoint.cpp]) AC_PROG_CXX AC_PROG_CC +# Check for which host we are on and setup a few things +# specifically based on the host +AC_CANONICAL_HOST +AM_CONDITIONAL(DARWIN, test ["${host_os#*darwin}" != "$host_os"]) + +AM_CONDITIONAL(LINUX, test ["${host_os#*linux}" != "$host_os"]) + +AM_CONDITIONAL(MINGW, test ["${host_os#*mingw}" != "$host_os"]) +export wincppflags="" +AS_IF( test ["${host_os#*mingw}" != "$host_os"], [export EXEEXT=".exe"],[]) + # Checks for libraries. # FIXME: Replace `main' with a function in `-lGL': -AC_CHECK_LIB([GL], [main], [], [AC_MSG_ERROR([GL library was not found])]) +AC_CHECK_LIB([GL], [main], [], AC_MSG_ERROR([GL library was not found])) # FIXME: Replace `main' with a function in `-lSDL': -AC_CHECK_LIB([SDL], [main], [], [AC_MSG_ERROR([SDL library was not found])]) -# FIXME: Replace `main' with a function in `-lSDL_gfx': -AC_CHECK_LIB([SDL_gfx], [main], [], [AC_MSG_ERROR([SDL_gfx library was not found])]) +AC_CHECK_LIB([SDL], [main], [], AC_MSG_ERROR([SDL library was not found])) # FIXME: Replace `main' with a function in `-lSDL_mixer': -AC_CHECK_LIB([SDL_mixer], [main], [], [AC_MSG_ERROR([SDL_mixer library was not found])]) +AC_CHECK_LIB([SDL_mixer], [main], [], AC_MSG_ERROR([SDL_mixer library was not found])) +# FIXME: Replace `main' with a function in `-lSDL_gfx': +AC_CHECK_LIB([SDL_gfx], [main], [], [AS_IF( test ["${host_os#*mingw}" != "$host_os"], [export wincppflags=$wincppflags" dll/SDL_gfx.dll" && AC_MSG_RESULT([Building for windows, ignoring])] ,AC_MSG_ERROR([SDL_gfx library was not found]))]) # FIXME: Replace `main' with a function in `-lSDL_ttf': -AC_CHECK_LIB([SDL_ttf], [main], [], [AC_MSG_ERROR([SDL_ttf library was not found])]) +AC_CHECK_LIB([SDL_ttf], [main], [], [AS_IF( test ["${host_os#*mingw}" != "$host_os"], [export wincppflags=$wincppflags" dll/SDL_ttf.dll" && AC_MSG_RESULT([Building for windows, ignoring])] ,AC_MSG_ERROR([SDL_ttf library was not found]))]) # Checks for header files. AC_CHECK_HEADERS([stdlib.h unistd.h]) -AC_CHECK_HEADERS([SDL/SDL.h], [], [AC_MSG_ERROR([SDL/SDL.h header was not found])]) +AC_CHECK_HEADERS([SDL/SDL.h], [], AC_MSG_ERROR([SDL/SDL.h header was not found])) #AC_CHECK_HEADERS([SDL/SDL_gfx.h], [], [AC_MSG_ERROR([SDL/SDL_gfx.h header was not found])]) -AC_CHECK_HEADERS([SDL/SDL_mixer.h], [], [AC_MSG_ERROR([SDL/SDL_mixer.h header was not found])]) -AC_CHECK_HEADERS([SDL/SDL_ttf.h], [], [AC_MSG_ERROR([SDL/SDL_ttf.h header was not found])]) +AC_CHECK_HEADERS([SDL/SDL_mixer.h], [], AC_MSG_ERROR([SDL/SDL_mixer.h header was not found])) +AC_CHECK_HEADERS([SDL/SDL_ttf.h], [], AS_IF( test ["${host_os#*mingw}" != "$host_os"], [] ,AC_MSG_ERROR([SDL/SDL_ttf.h header was not found]))) # Checks for typedefs, structures, and compiler characteristics. AC_CHECK_HEADER_STDBOOL @@ -38,23 +49,7 @@ AC_TYPE_SIZE_T # Checks for library functions. AC_CHECK_FUNCS([memset sqrt strstr]) -############################# -# Platform specific setup -############################# -AC_CANONICAL_HOST -# Check for which host we are on and setup a few things -# specifically based on the host -case $host_os in - darwin* ) - SYSTEM=DARWIN - ;; - linux*) - SYSTEM=LINUX - ;; - *mingw*) - SYSTEM=MINGW - ;; -esac +AC_SUBST([wincppflags]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/LICENSE-ogg-vorbis.txt b/dll/LICENSE-ogg-vorbis.txt similarity index 100% rename from LICENSE-ogg-vorbis.txt rename to dll/LICENSE-ogg-vorbis.txt diff --git a/LICENSE-sdl.txt b/dll/LICENSE-sdl.txt similarity index 100% rename from LICENSE-sdl.txt rename to dll/LICENSE-sdl.txt diff --git a/SDL.dll b/dll/SDL.dll similarity index 100% rename from SDL.dll rename to dll/SDL.dll diff --git a/SDL_gfx.dll b/dll/SDL_gfx.dll similarity index 100% rename from SDL_gfx.dll rename to dll/SDL_gfx.dll diff --git a/SDL_mixer.dll b/dll/SDL_mixer.dll similarity index 100% rename from SDL_mixer.dll rename to dll/SDL_mixer.dll diff --git a/SDL_ttf.dll b/dll/SDL_ttf.dll similarity index 100% rename from SDL_ttf.dll rename to dll/SDL_ttf.dll diff --git a/libogg-0.dll b/dll/libogg-0.dll similarity index 100% rename from libogg-0.dll rename to dll/libogg-0.dll diff --git a/libvorbis-0.dll b/dll/libvorbis-0.dll similarity index 100% rename from libvorbis-0.dll rename to dll/libvorbis-0.dll diff --git a/libvorbisfile-3.dll b/dll/libvorbisfile-3.dll similarity index 100% rename from libvorbisfile-3.dll rename to dll/libvorbisfile-3.dll