diff --git a/CMakeLists.txt b/CMakeLists.txt index 3c312452b5..2bb66d62e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,9 +80,27 @@ option(FORCE64 "Force native (x86-64) build. Do not use, for experimental purpos option(DISABLE_OPENGL "Disable OpenGL support.") option(DISABLE_RCT2 "WIP: Try building without using code and data segments from vanilla.") option(USE_MMAP "Use mmap to try loading rct2's data segment into memory.") +option(LAUNCHPAD_BUILD "Sets some build system options on launchpad.net") + +set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") + +# On mingw all code is already PIC, this will avoid compiler error on redefining this option +if(NOT MINGW) + set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -fPIC") +endif() + +if (LAUNCHPAD_BUILD) + # Launchpad turns on -Wdate-time for compilers that support it, this shouldn't break our build + set(COMMON_COMPILE_OPTIONS "${COMMON_COMPILE_OPTIONS} -Wno-error=date-time") +else() + if (FORCE64) + set(TARGET_M "-m64") + else () + set(TARGET_M "-m32") + endif() +endif() if (FORCE64) - set(TARGET_M "-m64") set(OBJ_FORMAT "elf64-x86-64") set(LINKER_SCRIPT "ld_script_x86_64.xc") if ((APPLE OR WIN32) AND NOT USE_MMAP) @@ -90,7 +108,6 @@ if (FORCE64) set(USE_MMAP ON) endif() else () - set(TARGET_M "-m32") set(OBJ_FORMAT "elf32-i386") set(LINKER_SCRIPT "ld_script_i386.xc") endif () @@ -203,10 +220,10 @@ if (APPLE) endif (APPLE) # set necessary flags to compile code as is -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 -fno-pie -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 -fno-pie -fstrict-aliasing -Werror -Wundef -Wmissing-declarations") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TARGET_M} -std=gnu99 ${COMMON_COMPILE_OPTIONS}") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TARGET_M} -std=gnu++11 ${COMMON_COMPILE_OPTIONS}") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${TARGET_M}") -set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS} -fpie") if (MINGW) set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++") diff --git a/debian/control b/debian/control index ee42fe1764..562e118de3 100644 --- a/debian/control +++ b/debian/control @@ -4,10 +4,10 @@ Section: misc Priority: optional Standards-Version: 3.9.2 Multi-Arch: same -Build-Depends: debhelper (>= 9), cmake, libsdl2-dev, libsdl2-ttf-dev, gcc, pkg-config, g++-multilib, gcc-multilib, libjansson4 (>= 2.7), libjansson-dev (>= 2.7), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev +Build-Depends: debhelper (>= 9), cmake, libsdl2-dev, libsdl2-ttf-dev, gcc, pkg-config, libjansson4 (>= 2.7), libjansson-dev (>= 2.7), libspeex-dev, libspeexdsp-dev, libcurl4-openssl-dev, libcrypto++-dev, libfontconfig1-dev, libfreetype6-dev, libpng-dev, libssl-dev Package: openrct2 -Architecture: i386 +Architecture: any Homepage: https://openrct2.website/ Vcs-Browser: https://github.com/OpenRCT2/OpenRCT2 Vcs-Git: https://github.com/OpenRCT2/OpenRCT2 diff --git a/debian/rules b/debian/rules index a3bada8c8f..de10dc205c 100755 --- a/debian/rules +++ b/debian/rules @@ -2,12 +2,10 @@ BUILDDIR=build_dir -build: - scripts/linux/install.sh - mkdir $(BUILDDIR) - cd $(BUILDDIR); cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo .. - make -C $(BUILDDIR) - touch build +extra_flags := $(if $(filter i386,$(DEB_HOST_ARCH)),-DLAUNCHPAD_BUILD=on,-DLAUNCHPAD_BUILD=on -DUSE_MMAP=on -DDISABLE_RCT2=on) + +override_dh_auto_configure: + dh_auto_configure -a -- $(extra_flags) %: dh $@ diff --git a/src/addresses.h b/src/addresses.h index 914f36a907..21cf8f82c5 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -24,7 +24,13 @@ #endif #ifdef USE_MMAP - #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x200000000) + #if defined(PLATFORM_64BIT) + #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x200000000) + #elif defined(PLATFORM_32BIT) + #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x09000000) + #else + #error "Unknown platform" + #endif #else #define GOOD_PLACE_FOR_DATA_SEGMENT ((uintptr_t)0x8a4000) #endif