Merge: Docker, portability and crosscompiling tweaks
authorJean Privat <jean@pryen.org>
Mon, 20 Mar 2017 20:08:59 +0000 (16:08 -0400)
committerJean Privat <jean@pryen.org>
Mon, 20 Mar 2017 20:08:59 +0000 (16:08 -0400)
* Add the missing SDL2 package (since #2376) to the full DockerFile.
* Fix a warning raised by the C compiler when called by niti on 32 bits platforms.
* Clean up Makefile generation and enable using environment variables to override the default C compiler, C++ compiler, CFLAGS and whether or not to use libunwind. Making it possible to change the compiler for cross compilation and to skip linking with libunwind to create binaries compatible with more GNU/Linux systems.

Pull-Request: #2390
Reviewed-by: Romain Chanoir <romain.chanoir@viacesi.fr>

lib/core/kernel.nit
misc/docker/full/Dockerfile
src/compiler/abstract_compiler.nit

index fa7b6f4..a821006 100644 (file)
@@ -1063,7 +1063,7 @@ extern class Pointer
        fun free `{ free(self); `}
 
        # Use the address value
-       redef fun hash `{ return (long)self; `}
+       redef fun hash `{ return (long)(intptr_t)self; `}
 
        # Is equal to any instance pointing to the same address
        redef fun ==(o) do return o isa Pointer and native_equals(o)
index 2efb5d3..10bb9f6 100644 (file)
@@ -20,6 +20,7 @@ RUN dpkg --add-architecture i386 \
                libsdl-ttf2.0-dev \
                libsdl1.2-dev \
                libsdl2-dev \
+               libsdl2-image-dev \
                libsqlite3-dev \
                libx11-dev \
                libxdg-basedir-dev \
index 11ff040..4ce8024 100644 (file)
@@ -349,14 +349,21 @@ class MakefileToolchain
                end
                var debug = toolcontext.opt_debug.value
 
-               makefile.write("CC = ccache cc\nCXX = ccache c++\nCFLAGS = -g{ if not debug then " -O2 " else " "}-Wno-unused-value -Wno-switch -Wno-attributes -Wno-trigraphs\nCINCL =\nLDFLAGS ?= \nLDLIBS  ?= -lm {linker_options.join(" ")}\n\n")
+               makefile.write """
+CC ?= ccache cc
+CXX ?= ccache c++
+CFLAGS ?= -g {{{if not debug then "-O2" else ""}}} -Wno-unused-value -Wno-switch -Wno-attributes -Wno-trigraphs
+CINCL =
+LDFLAGS ?=
+LDLIBS  ?= -lm {{{linker_options.join(" ")}}}
+\n"""
 
                makefile.write "\n# SPECIAL CONFIGURATION FLAGS\n"
                if platform.supports_libunwind then
                        if toolcontext.opt_no_stacktrace.value then
-                               makefile.write "NO_STACKTRACE=True"
+                               makefile.write "NO_STACKTRACE ?= True"
                        else
-                               makefile.write "NO_STACKTRACE= # Set to `True` to enable"
+                               makefile.write "NO_STACKTRACE ?= # Set to `True` to enable"
                        end
                end