diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5a8d22f4b..f8c507922 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -279,6 +279,11 @@ if("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin") target_compile_definitions(BLANKART PRIVATE -DMACOSX) endif() +if("${CMAKE_SYSTEM_NAME}" MATCHES "FreeBSD") + target_compile_definitions(BLANKART PRIVATE -DFREEBSD) + target_link_libraries(BLANKART PRIVATE execinfo) +endif() + if("${SRB2_CONFIG_USE_GME}") target_link_libraries(BLANKART PRIVATE gme) target_compile_definitions(BLANKART PRIVATE -DHAVE_GME) diff --git a/src/sdl/al_sound.c b/src/sdl/al_sound.c index e68ac7ebb..67ad764f6 100644 --- a/src/sdl/al_sound.c +++ b/src/sdl/al_sound.c @@ -1792,6 +1792,8 @@ boolean I_SetSongTrack(INT32 track) return false; } +#endif +#ifdef HAVE_GME } #endif diff --git a/src/sdl/i_system.cpp b/src/sdl/i_system.cpp index ad18d841f..e11be53f0 100644 --- a/src/sdl/i_system.cpp +++ b/src/sdl/i_system.cpp @@ -88,7 +88,7 @@ typedef LPVOID (WINAPI *p_MapViewOfFile) (HANDLE, DWORD, DWORD, DWORD, SIZE_T); #include #endif #include -#include +#include #endif #endif @@ -2080,40 +2080,17 @@ static long get_entry(const char* name, const char* buf) UINT32 I_GetFreeMem(UINT32 *total) { #ifdef FREEBSD - struct vmmeter sum; - kvm_t *kd; - struct nlist namelist[] = - { -#define X_SUM 0 - {"_cnt"}, - {NULL} - }; - if ((kd = kvm_open(NULL, NULL, NULL, O_RDONLY, "kvm_open")) == NULL) - { - if (total) - *total = 0L; - return 0; - } - if (kvm_nlist(kd, namelist) != 0) - { - kvm_close (kd); - if (total) - *total = 0L; - return 0; - } - if (kvm_read(kd, namelist[X_SUM].n_value, &sum, - sizeof (sum)) != sizeof (sum)) - { - kvm_close(kd); - if (total) - *total = 0L; - return 0; - } - kvm_close(kd); + u_int v_free_count, v_page_size, v_page_count; + size_t size = sizeof(v_free_count); + sysctlbyname("vm.stats.vm.v_free_count", &v_free_count, &size, NULL, 0); + size = sizeof(v_page_size); + sysctlbyname("vm.stats.vm.v_page_size", &v_page_size, &size, NULL, 0); + size = sizeof(v_page_count); + sysctlbyname("vm.stats.vm.v_page_count", &v_page_count, &size, NULL, 0); if (total) - *total = sum.v_page_count * sum.v_page_size; - return sum.v_free_count * sum.v_page_size; + *total = v_page_count * v_page_size; + return v_free_count * v_page_size; #elif defined (SOLARIS) /* Just guess */ if (total) diff --git a/src/stun.c b/src/stun.c index e2433c3f4..900b9cd79 100644 --- a/src/stun.c +++ b/src/stun.c @@ -11,7 +11,7 @@ /* https://tools.ietf.org/html/rfc5389 */ -#if defined (__linux__) +#if defined (__linux__) || defined (__FreeBSD__) #include #elif defined (_WIN32) #define _CRT_RAND_S diff --git a/thirdparty/CMakeLists.txt b/thirdparty/CMakeLists.txt index c4b7cc010..3d8d6932a 100644 --- a/thirdparty/CMakeLists.txt +++ b/thirdparty/CMakeLists.txt @@ -34,5 +34,7 @@ if(SRB2_CONFIG_UPNP) set(UPNPC_BUILD_SHARED ${SRB2_CONFIG_SHARED_INTERNAL_LIBRARIES}) set(UPNPC_BUILD_TESTS FALSE) set(UPNPC_BUILD_SAMPLE FALSE) - add_subdirectory("miniupnp/miniupnpc" EXCLUDE_FROM_ALL) + if(NOT "${SRB2_CONFIG_SYSTEM_LIBRARIES}") + add_subdirectory("miniupnp/miniupnpc" EXCLUDE_FROM_ALL) + endif() endif()