Enable backtrace printing on FreeBSD.

FreeBSD has supported printing backtraces for years. The API is the same
as on Linux, the only difference is that libexecinfo must be linked as a
seperate library. Since the last FreeBSD version with backtrace support
(FreeBSD 9.3) went out of support some time ago unconditionally enable
the printing.
This commit is contained in:
Yamagi Burmeister 2018-07-13 14:32:31 +02:00
parent 412dfe50b3
commit 176f95cc7c
3 changed files with 20 additions and 10 deletions

View file

@ -47,6 +47,7 @@ set(yquake2IncludeDirectories)
set(yquake2LinkerDirectories)
set(yquake2LinkerFlags)
set(yquake2ClientLinkerFlags)
set(yquake2ServerLinkerFlags)
set(yquake2OpenGLLinkerFlags)
set(yquake2SDLLinkerFlags)
set(yquake2ZLibLinkerFlags)
@ -95,6 +96,14 @@ find_package(OpenGL REQUIRED)
list(APPEND yquake2IncludeDirectories ${OPENGL_INCLUDE_DIR})
list(APPEND yquake2OpenGLLinkerFlags ${OPENGL_LIBRARIES})
if(${CMAKE_HOST_SYSTEM_NAME} STREQUAL "FreeBSD")
find_library(EXECINFO_LIBRARIES execinfo /usr/lib /usr/local/lib)
list(APPEND yquake2ClientLinkerFlags ${EXECINFO_LIBRARIES})
list(APPEND yquake2ServerLinkerFlags ${EXECINFO_LIBRARIES})
endif()
if(${ZIP_SUPPORT})
find_package(ZLIB REQUIRED)
list(APPEND yquake2IncludeDirectories ${ZLIB_INCLUDE_DIRS})
@ -576,7 +585,7 @@ set_target_properties(q2ded PROPERTIES
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
target_link_libraries(q2ded ${yquake2LinkerFlags} ${yquake2ZLibLinkerFlags} ws2_32 winmm)
else()
target_link_libraries(q2ded ${yquake2LinkerFlags} ${yquake2ZLibLinkerFlags})
target_link_libraries(q2ded ${yquake2LinkerFlags} ${yquake2ServerLinkerFlags} ${yquake2ZLibLinkerFlags})
endif()
# Build the game dynamic library

View file

@ -503,12 +503,8 @@ ifeq ($(WITH_SDL2),yes)
release/quake2 : CFLAGS += -DSDL2
endif
ifneq ($(YQ2_OSTYPE), Darwin)
release/ref_gl1.so : LDFLAGS += -lGL
endif
ifeq ($(YQ2_OSTYPE), FreeBSD)
release/quake2 : LDFLAGS += -Wl,-z,origin,-rpath='$$ORIGIN/lib'
release/quake2 : LDFLAGS += -Wl,-z,origin,-rpath='$$ORIGIN/lib' -lexecinfo
else ifeq ($(YQ2_OSTYPE), Linux)
release/quake2 : LDFLAGS += -Wl,-z,origin,-rpath='$$ORIGIN/lib'
endif
@ -568,6 +564,10 @@ ifeq ($(WITH_ZIP),yes)
release/q2ded : CFLAGS += $(ZIPCFLAGS) -DZIP -DNOUNCRYPT
release/q2ded : LDFLAGS += -lz
endif
ifeq ($(YQ2_OSTYPE), FreeBSD)
release/q2ded : LDFLAGS += -lexecinfo
endif
endif
# ----------
@ -611,7 +611,7 @@ ref_gl1:
release/ref_gl1.so : CFLAGS += -fPIC
release/ref_gl1.so : LDFLAGS += -shared
release/ref_gl1.so : LDFLAGS += -shared -lGL
ifeq ($(WITH_SDL2),yes)
release/ref_gl1.so : CFLAGS += -DSDL2

View file

@ -28,13 +28,14 @@
#include <signal.h>
#ifdef __linux__
#include <execinfo.h>
#if defined(__linux__) || defined(__FreeBSD__)
#endif
#include "../../common/header/common.h"
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__)
#include <execinfo.h>
void
printBacktrace(int sig)