From 7ae44a055b2d723f5fcf1da2cd338c522b3fd051 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Fri, 3 Jan 2025 22:43:12 +0100 Subject: [PATCH] Linux: Default to builtin openssl, freetype, and zlib Fix support for cross-compilation, and fix handling of builtin libraries, which would still attempt to link system libs and use system headers. Also patch out GLU includes from GLEW, we don't need it, so that removes another mandatory dependency. (cherry picked from commit abf6a0919b5d18a82248bb460331f0f4ba25ec2b) --- .../glew-remove-glu-dependency.patch | 22 +++++++++++++ drivers/gl_context/glew.h | 5 +++ platform/server/detect.py | 22 +++++++++++-- platform/x11/detect.py | 31 ++++++++++--------- 4 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 drivers/gl_context/glew-remove-glu-dependency.patch diff --git a/drivers/gl_context/glew-remove-glu-dependency.patch b/drivers/gl_context/glew-remove-glu-dependency.patch new file mode 100644 index 00000000000..4ef9565a709 --- /dev/null +++ b/drivers/gl_context/glew-remove-glu-dependency.patch @@ -0,0 +1,22 @@ +diff --git a/drivers/gl_context/glew.h b/drivers/gl_context/glew.h +index 4eed47708f..5f937862bf 100644 +--- a/drivers/gl_context/glew.h ++++ b/drivers/gl_context/glew.h +@@ -1168,12 +1168,17 @@ GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei heigh + + /* ---------------------------------- GLU ---------------------------------- */ + ++// -- GODOT start -- ++// We don't use GLU, so remove a dependency. ++#if 0 + /* this is where we can safely include GLU */ + #if defined(__APPLE__) && defined(__MACH__) + #include + #else + #include + #endif ++#endif ++// -- GODOT end -- + + /* ----------------------------- GL_VERSION_1_2 ---------------------------- */ + diff --git a/drivers/gl_context/glew.h b/drivers/gl_context/glew.h index 4eed47708f4..5f937862bf3 100644 --- a/drivers/gl_context/glew.h +++ b/drivers/gl_context/glew.h @@ -1168,12 +1168,17 @@ GLAPI void GLAPIENTRY glViewport (GLint x, GLint y, GLsizei width, GLsizei heigh /* ---------------------------------- GLU ---------------------------------- */ +// -- GODOT start -- +// We don't use GLU, so remove a dependency. +#if 0 /* this is where we can safely include GLU */ #if defined(__APPLE__) && defined(__MACH__) #include #else #include #endif +#endif +// -- GODOT end -- /* ----------------------------- GL_VERSION_1_2 ---------------------------- */ diff --git a/platform/server/detect.py b/platform/server/detect.py index c43f0a716ef..53e091d020b 100644 --- a/platform/server/detect.py +++ b/platform/server/detect.py @@ -27,8 +27,10 @@ def get_opts(): def get_flags(): return [ - ('builtin_zlib', 'no'), - ('theora','no'), #use builtin openssl + ('builtin_zlib', 'yes'), + ('openssl', 'builtin'), + ("freetype", "builtin"), + ('theora','no'), ] @@ -71,8 +73,22 @@ def configure(env): env.Append(CCFLAGS=['-g2', '-DDEBUG_ENABLED','-DDEBUG_MEMORY_ENABLED']) + + if (env["openssl"]=="yes"): + env.ParseConfig('pkg-config openssl --cflags --libs') + + if (env["freetype"]!="no"): + env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + if (env["freetype"]=="builtin"): + env.Append(CPPPATH=['#tools/freetype']) + env.Append(CPPPATH=['#tools/freetype/freetype/include']) + else: + env.ParseConfig('pkg-config freetype2 --cflags --libs') + env.Append(CPPFLAGS=['-DSERVER_ENABLED','-DUNIX_ENABLED']) - env.Append(LIBS=['pthread','z']) #TODO detect linux/BSD! + env.Append(LIBS=['pthread']) #TODO detect linux/BSD! + if (env["builtin_zlib"]=="no"): + env.Append(LIBS=['z']) if (env["CXX"]=="clang++"): env.Append(CPPFLAGS=['-DTYPED_METHOD_BIND']) diff --git a/platform/x11/detect.py b/platform/x11/detect.py index 63389960551..9e5c5e162c9 100644 --- a/platform/x11/detect.py +++ b/platform/x11/detect.py @@ -29,11 +29,6 @@ def can_build(): print("X11 not found.. x11 disabled.") return False - ssl_error=os.system("pkg-config openssl --modversion > /dev/null ") - if (ssl_error): - print("OpenSSL not found.. x11 disabled.") - return False - x11_error=os.system("pkg-config xcursor --modversion > /dev/null ") if (x11_error): print("xcursor not found.. x11 disabled.") @@ -61,8 +56,9 @@ def get_opts(): def get_flags(): return [ - ('builtin_zlib', 'no'), - ("openssl", "yes"), + ('builtin_zlib', 'yes'), + ("openssl", "builtin"), + ("freetype", "builtin"), ("theora","no"), ] @@ -126,13 +122,18 @@ def configure(env): env.ParseConfig('pkg-config x11 --cflags --libs') env.ParseConfig('pkg-config xinerama --cflags --libs') env.ParseConfig('pkg-config xcursor --cflags --libs') - env.ParseConfig('pkg-config openssl --cflags --libs') + if (env["openssl"]=="yes"): + env.ParseConfig('pkg-config openssl --cflags --libs') - env.ParseConfig('pkg-config freetype2 --cflags --libs') - env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + if (env["freetype"]!="no"): + env.Append(CCFLAGS=['-DFREETYPE_ENABLED']) + if (env["freetype"]=="builtin"): + env.Append(CPPPATH=['#tools/freetype']) + env.Append(CPPPATH=['#tools/freetype/freetype/include']) + else: + env.ParseConfig('pkg-config freetype2 --cflags --libs') - env.Append(CPPFLAGS=['-DOPENGL_ENABLED','-DGLEW_ENABLED']) env.Append(CPPFLAGS=["-DALSA_ENABLED"]) @@ -145,17 +146,19 @@ def configure(env): print("PulseAudio development libraries not found, disabling driver") env.Append(CPPFLAGS=['-DX11_ENABLED','-DUNIX_ENABLED','-DGLES2_ENABLED','-DGLES_OVER_GL']) - env.Append(LIBS=['GL', 'GLU', 'pthread','asound','z']) #TODO detect linux/BSD! + env.Append(LIBS=['GL', 'pthread', 'asound']) #TODO detect linux/BSD! + if (env["builtin_zlib"]=="no"): + env.Append(LIBS=['z']) #env.Append(CPPFLAGS=['-DMPC_FIXED_POINT']) #host compiler is default.. if (is64 and env["bits"]=="32"): env.Append(CPPFLAGS=['-m32']) - env.Append(LINKFLAGS=['-m32','-L/usr/lib/i386-linux-gnu']) + env.Append(LINKFLAGS=['-m32']) elif (not is64 and env["bits"]=="64"): env.Append(CPPFLAGS=['-m64']) - env.Append(LINKFLAGS=['-m64','-L/usr/lib/i686-linux-gnu']) + env.Append(LINKFLAGS=['-m64']) import methods