Compile on Freebsd (#1044)

* Compile on Freebsd

Small changes needed for compilation on Freebsd. Note that you'll have
to pass -DEQEMU_BUILD_ZLIB=OFF on the cmake command line. The bundled
zlib-ng does not build on Freebsd even though mainline zlib-ng does.

* Fix build errors: typo
This commit is contained in:
Jose123456 2020-05-09 12:40:33 -07:00 committed by GitHub
parent 7f3e4e3438
commit 914ea27406
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 2 deletions

View File

@ -328,7 +328,10 @@ IF(UNIX)
IF(NOT DARWIN) IF(NOT DARWIN)
SET(SERVER_LIBS ${SERVER_LIBS} "rt") SET(SERVER_LIBS ${SERVER_LIBS} "rt")
ENDIF() ENDIF()
SET(SERVER_LIBS ${SERVER_LIBS} "uuid") # Freebsd provides uuids in the C library
IF(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
SET(SERVER_LIBS ${SERVER_LIBS} "uuid")
ENDIF()
ENDIF() ENDIF()
IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED) IF(EQEMU_BUILD_LOGIN AND NOT TLS_LIBRARY_ENABLED)

View File

@ -118,6 +118,11 @@ void set_exception_handler() {
#include <unistd.h> #include <unistd.h>
#include <sys/fcntl.h> #include <sys/fcntl.h>
#ifdef __FreeBSD__
#include <signal.h>
#include <sys/stat.h>
#endif
void print_trace() void print_trace()
{ {
auto uid = geteuid(); auto uid = geteuid();

View File

@ -24,6 +24,10 @@
#include <vector> #include <vector>
#include <map> #include <map>
#ifdef __FreeBSD__
#include <unistd.h>
#endif
//I forced this object to become a singleton because it registers its //I forced this object to become a singleton because it registers its
//signal handler for UNIX //signal handler for UNIX
class ProcLauncher { class ProcLauncher {

View File

@ -14,6 +14,10 @@
#include <CoreFoundation/CFUUID.h> #include <CoreFoundation/CFUUID.h>
#endif #endif
#ifdef __FreeBSD__
#include <uuid.h>
#endif
unsigned char hexDigitToChar(char ch) unsigned char hexDigitToChar(char ch)
{ {
if (ch > 47 && ch < 58) if (ch > 47 && ch < 58)
@ -126,6 +130,15 @@ EQ::Util::UUID EQ::Util::UUID::Generate()
return buffer; return buffer;
#endif #endif
#ifdef __FreeBSD__
uuid_t l_id;
char l_uuid[37];
uint32_t l_ignored;
uuid_create(&l_id, &l_ignored);
uuid_to_string(&l_id, (char**) &l_uuid, &l_ignored);
return FromString(l_uuid);
#endif
} }
EQ::Util::UUID EQ::Util::UUID::FromString(const std::string &str) EQ::Util::UUID EQ::Util::UUID::FromString(const std::string &str)

View File

@ -92,6 +92,10 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/unix.h" #include "../common/unix.h"
#endif #endif
#ifdef __FreeBSD__
#include <pthread_np.h>
#endif
extern volatile bool is_zone_loaded; extern volatile bool is_zone_loaded;
EntityList entity_list; EntityList entity_list;
@ -431,8 +435,10 @@ int main(int argc, char** argv) {
EQStreamIdentifier stream_identifier; EQStreamIdentifier stream_identifier;
RegisterAllPatches(stream_identifier); RegisterAllPatches(stream_identifier);
#ifndef WIN32 #ifdef __linux__
LogDebug("Main thread running with thread id [{}]", pthread_self()); LogDebug("Main thread running with thread id [{}]", pthread_self());
#elif defined(__FreeBSD__)
LogDebug("Main thread running with thread id [{}]", pthread_getthreadid_np());
#endif #endif
bool worldwasconnected = worldserver.Connected(); bool worldwasconnected = worldserver.Connected();