From 64db97e226ec993b7336fe8ede0a00c938afdc61 Mon Sep 17 00:00:00 2001 From: Armin Weatherwax Date: Sun, 13 Nov 2011 14:31:42 +0100 Subject: Linux: allow cross compiling the 32bit viewer on a x86_64 platform to do so: (have anything for crosscompiling installed), export WORD_SIZE='32' before configuring and/or building. Be aware: Mixing several platforms in one root directory probably wont work (didn't try though). Cross compiling the 64bit viewer on a i686 platform isn't tested, but probably will work using export WORD_SIZE='64' --- linden/indra/cmake/00-Common.cmake | 9 +++++++++ linden/indra/cmake/Variables.cmake | 26 ++++++++++++++++++++++++-- linden/indra/develop.py | 20 ++++++++++++++++---- linden/scripts/install.py | 7 +++++-- 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/linden/indra/cmake/00-Common.cmake b/linden/indra/cmake/00-Common.cmake index d92aa0f..81bfbdf 100644 --- a/linden/indra/cmake/00-Common.cmake +++ b/linden/indra/cmake/00-Common.cmake @@ -233,6 +233,15 @@ if (LINUX OR DARWIN) set(CMAKE_C_FLAGS "${GCC_WARNINGS} ${CMAKE_C_FLAGS}") set(CMAKE_CXX_FLAGS "${GCC_CXX_WARNINGS} ${CMAKE_CXX_FLAGS}") + + if (WORD_SIZE EQUAL 32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + elseif (WORD_SIZE EQUAL 64) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") + endif (WORD_SIZE EQUAL 32) + endif (LINUX OR DARWIN) diff --git a/linden/indra/cmake/Variables.cmake b/linden/indra/cmake/Variables.cmake index eb9c004..6b7ded3 100644 --- a/linden/indra/cmake/Variables.cmake +++ b/linden/indra/cmake/Variables.cmake @@ -50,8 +50,30 @@ endif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(LINUX ON BOOl FORCE) - execute_process(COMMAND uname -m COMMAND sed s/i.86/i686/ - OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) + + # If someone has specified a word size, use that to determine the + # architecture. Otherwise, let the architecture specify the word size. + + if ("$ENV{WORD_SIZE}" MATCHES "32") + set(WORD_SIZE 32) + elseif ("$ENV{WORD_SIZE}" MATCHES "64") + set(WORD_SIZE 64) + endif () + + if (WORD_SIZE EQUAL 32) + set(ARCH i686) + elseif (WORD_SIZE EQUAL 64) + set(ARCH x86_64) + else (WORD_SIZE EQUAL 32) + execute_process(COMMAND uname -m COMMAND sed s/i.86/i686/ + OUTPUT_VARIABLE ARCH OUTPUT_STRIP_TRAILING_WHITESPACE) + if (ARCH STREQUAL x86_64) + set(WORD_SIZE 64) + else (ARCH STREQUAL x86_64) + set(WORD_SIZE 32) + endif (ARCH STREQUAL x86_64) + endif (WORD_SIZE EQUAL 32) + set(LL_ARCH ${ARCH}_linux) set(LL_ARCH_DIR ${ARCH}-linux) endif (${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/linden/indra/develop.py b/linden/indra/develop.py index 8b23b1d..2f07e9e 100755 --- a/linden/indra/develop.py +++ b/linden/indra/develop.py @@ -223,14 +223,26 @@ class UnixSetup(PlatformSetup): def arch(self): cpu = os.uname()[-1] + word_size = os.environ.get('WORD_SIZE') if cpu.endswith('386'): cpu = 'i386' + if word_size == '64': + cpu = 'x86_64' elif cpu.endswith('86'): - cpu = 'i686' + if word_size == '64': + cpu = 'x86_64' + else: + cpu = 'i686' elif cpu in ('x86_64'): - cpu = 'x86_64' - elif cpu in ('athlon',): - cpu = 'i686' + if word_size == '32': + cpu = 'i686' + else: + cpu = 'x86_64' + elif cpu in ('athlon',): + if word_size == '64': + cpu = 'x86_64' + else: + cpu = 'i686' elif cpu == 'Power Macintosh': cpu = 'ppc' return cpu diff --git a/linden/scripts/install.py b/linden/scripts/install.py index f09fc48..c69644b 100755 --- a/linden/scripts/install.py +++ b/linden/scripts/install.py @@ -805,11 +805,14 @@ def _get_platform(): } this_platform = platform_map[sys.platform] if this_platform == 'linux': - if platform.architecture()[0] == '64bit': + word_size = os.environ.get('WORD_SIZE') + if platform.architecture()[0] == '64bit' or word_size == '64': # TODO -- someday when install.py accepts a platform of the form # os/arch/compiler/compiler_version then we can replace the # 'linux64' platform with 'linux/x86_64/gcc/4.1' - this_platform = 'linux64' + if not word_size == '32': + this_platform = 'linux64' + return this_platform def _getuser(): -- cgit v1.1