mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-20 19:02:23 +00:00
Make OSTYPE and ARCH user defineable.
The old implementation had two problems: * OSTYPE and ARCH are systemwide defines, overriding them may break the global libc headers. This is a theoretical problem, I've never seen it in praxis. * Not all system set ARCH correctly when building in a chroot env. For example on Linux ARCH is set to x86_64 when building in an i386 chroot. Now the user can do something like "make YQ2ARCH=i386" to get things right.
This commit is contained in:
parent
5d440bbb00
commit
aa897e3965
8 changed files with 33 additions and 31 deletions
|
@ -56,13 +56,15 @@ set(SERVER_SRC_DIR ${SOURCE_DIR}/server)
|
|||
set(CLIENT_SRC_DIR ${SOURCE_DIR}/client)
|
||||
|
||||
# Operating system
|
||||
add_definitions(-DOSTYPE="${CMAKE_SYSTEM_NAME}")
|
||||
set(YQ2OSTYPE "${CMAKE_SYSTEM_NAME}" CACHE STRING "Override operation system type")
|
||||
add_definitions(-DYQ2OSTYPE="${YQ2OSTYPE}")
|
||||
|
||||
# Architecture string
|
||||
string(REGEX REPLACE "amd64" "x86_64" ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
||||
set(YQ2ARCH "${CMAKE_SYSTEM_PROCESSOR}" CACHE STRING "Override CPU architecture")
|
||||
string(REGEX REPLACE "amd64" "x86_64" ARCH ${YQ2ARCH})
|
||||
string(REGEX REPLACE "i.86" "i386" ARCH ${ARCH})
|
||||
string(REGEX REPLACE "^arm.*" "arm" ARCH ${ARCH})
|
||||
add_definitions(-DARCH="${ARCH}")
|
||||
add_definitions(-DYQ2ARCH="${ARCH}")
|
||||
|
||||
# Systemwide installation of game assets
|
||||
if(${SYSTEMWIDE_SUPPORT})
|
||||
|
|
14
Makefile
14
Makefile
|
@ -100,28 +100,28 @@ endif
|
|||
|
||||
# Detect the OS
|
||||
ifdef SystemRoot
|
||||
OSTYPE := Windows
|
||||
YQ2OSTYPE ?= Windows
|
||||
else
|
||||
OSTYPE := $(shell uname -s)
|
||||
YQ2OSTYPE ?= $(shell uname -s)
|
||||
endif
|
||||
|
||||
# Special case for MinGW
|
||||
ifneq (,$(findstring MINGW,$(OSTYPE)))
|
||||
OSTYPE := Windows
|
||||
YQ2OSTYPE ?= Windows
|
||||
endif
|
||||
|
||||
# Detect the architecture
|
||||
ifeq ($(OSTYPE), Windows)
|
||||
ifdef PROCESSOR_ARCHITEW6432
|
||||
# 64 bit Windows
|
||||
ARCH := $(PROCESSOR_ARCHITEW6432)
|
||||
YQ2ARCH ?= $(PROCESSOR_ARCHITEW6432)
|
||||
else
|
||||
# 32 bit Windows
|
||||
ARCH := $(PROCESSOR_ARCHITECTURE)
|
||||
YQ2ARCH ?= $(PROCESSOR_ARCHITECTURE)
|
||||
endif
|
||||
else
|
||||
# Normalize some abiguous ARCH strings
|
||||
ARCH := $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
|
||||
YQ2ARCH ?= $(shell uname -m | sed -e 's/i.86/i386/' -e 's/amd64/x86_64/' -e 's/^arm.*/arm/')
|
||||
endif
|
||||
|
||||
# Disable CDA for SDL2
|
||||
|
@ -167,7 +167,7 @@ endif
|
|||
# ----------
|
||||
|
||||
# Defines the operating system and architecture
|
||||
CFLAGS += -DOSTYPE=\"$(OSTYPE)\" -DARCH=\"$(ARCH)\"
|
||||
CFLAGS += -DYQ2OSTYPE=\"$(YQ2OSTYPE)\" -DYQ2ARCH=\"$(YQ2ARCH)\"
|
||||
|
||||
# ----------
|
||||
|
||||
|
|
|
@ -110,8 +110,8 @@ main(int argc, char **argv)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
printf("Platform: %s\n", OSTYPE);
|
||||
printf("Architecture: %s\n", ARCH);
|
||||
printf("Platform: %s\n", YQ2OSTYPE);
|
||||
printf("Architecture: %s\n", YQ2ARCH);
|
||||
|
||||
/* Seed PRNG */
|
||||
randk_seed();
|
||||
|
|
|
@ -49,8 +49,8 @@ printBacktrace(int sig)
|
|||
|
||||
printf("Product: Yamagi Quake II\n");
|
||||
printf("Version: %s\n", YQ2VERSION);
|
||||
printf("Platform: %s\n", OSTYPE);
|
||||
printf("Architecture: %s\n", ARCH);
|
||||
printf("Platform: %s\n", YQ2OSTYPE);
|
||||
printf("Architecture: %s\n", YQ2ARCH);
|
||||
printf("Compiler: %s\n", __VERSION__);
|
||||
printf("Signal: %i\n", sig);
|
||||
printf("\nBacktrace:\n");
|
||||
|
@ -70,8 +70,8 @@ printBacktrace(int sig)
|
|||
{
|
||||
printf("Product: Yamagi Quake II\n");
|
||||
printf("Version: %s\n", YQ2VERSION);
|
||||
printf("Platform: %s\n", OSTYPE);
|
||||
printf("Architecture: %s\n", ARCH);
|
||||
printf("Platform: %s\n", YQ2OSTYPE);
|
||||
printf("Architecture: %s\n", YQ2ARCH);
|
||||
printf("Compiler: %s\n", __VERSION__);
|
||||
printf("Signal: %i\n", sig);
|
||||
printf("\nBacktrace:\n");
|
||||
|
|
|
@ -745,8 +745,8 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
|
|||
#endif
|
||||
#endif
|
||||
|
||||
printf("Platform: %s\n", OSTYPE);
|
||||
printf("Architecture: %s\n", ARCH);
|
||||
printf("Platform: %s\n", YQ2OSTYPE);
|
||||
printf("Architecture: %s\n", YQ2ARCH);
|
||||
|
||||
/* Seed PRNG */
|
||||
randk_seed();
|
||||
|
|
|
@ -36,12 +36,12 @@
|
|||
#define YQ2VERSION "6.00pre"
|
||||
#define BASEDIRNAME "baseq2"
|
||||
|
||||
#ifndef OSTYPE
|
||||
#error OSTYPE should be defined by the build system
|
||||
#ifndef YQ2OSTYPE
|
||||
#error YQ2OSTYPE should be defined by the build system
|
||||
#endif
|
||||
|
||||
#ifndef ARCH
|
||||
#error ARCH should be defined by the build system
|
||||
#ifndef YQ2ARCH
|
||||
#error YQ2RCH should be defined by the build system
|
||||
#endif
|
||||
|
||||
#ifndef BUILD_DATE
|
||||
|
|
|
@ -241,7 +241,7 @@ Qcommon_Init(int argc, char **argv)
|
|||
dedicated = Cvar_Get("dedicated", "0", CVAR_NOSET);
|
||||
#endif
|
||||
|
||||
s = va("%s %s %s %s", YQ2VERSION, ARCH, BUILD_DATE, OSTYPE);
|
||||
s = va("%s %s %s %s", YQ2VERSION, YQ2ARCH, BUILD_DATE, YQ2OSTYPE);
|
||||
Cvar_Get("version", s, CVAR_SERVERINFO | CVAR_NOSET);
|
||||
|
||||
if (dedicated->value)
|
||||
|
|
|
@ -82,12 +82,12 @@
|
|||
* created on other systems or architectures. This will
|
||||
* crash q2 in spectacular ways
|
||||
*/
|
||||
#ifndef OSTYPE
|
||||
#error OSTYPE should be defined by the build system
|
||||
#ifndef YQ2OSTYPE
|
||||
#error YQ2OSTYPE should be defined by the build system
|
||||
#endif
|
||||
|
||||
#ifndef ARCH
|
||||
#error ARCH should be defined by the build system
|
||||
#ifndef YQ2ARCH
|
||||
#error YQ2ARCH should be defined by the build system
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
@ -787,8 +787,8 @@ WriteGame(const char *filename, qboolean autosave)
|
|||
|
||||
Q_strlcpy(str_ver, SAVEGAMEVER, sizeof(str_ver));
|
||||
Q_strlcpy(str_game, GAMEVERSION, sizeof(str_game));
|
||||
Q_strlcpy(str_os, OSTYPE, sizeof(str_os));
|
||||
Q_strlcpy(str_arch, ARCH, sizeof(str_arch));
|
||||
Q_strlcpy(str_os, YQ2OSTYPE, sizeof(str_os));
|
||||
Q_strlcpy(str_arch, YQ2ARCH, sizeof(str_arch));
|
||||
|
||||
fwrite(str_ver, sizeof(str_ver), 1, f);
|
||||
fwrite(str_game, sizeof(str_game), 1, f);
|
||||
|
@ -844,12 +844,12 @@ ReadGame(const char *filename)
|
|||
fclose(f);
|
||||
gi.error("Savegame from another game.so.\n");
|
||||
}
|
||||
else if (strcmp(str_os, OSTYPE))
|
||||
else if (strcmp(str_os, YQ2OSTYPE))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from another os.\n");
|
||||
}
|
||||
else if (strcmp(str_arch, ARCH))
|
||||
else if (strcmp(str_arch, YQ2ARCH))
|
||||
{
|
||||
fclose(f);
|
||||
gi.error("Savegame from another architecture.\n");
|
||||
|
|
Loading…
Reference in a new issue