nemysis - 2014-03-19

Hello I try to port to FreeBSD Speed Dreams

Have had same Problems with 2.0.0-r4687, 2.1.0-beta and trunk

In FreeBSD not exist LDL library, this have too added Upstream for Open Surge, when I have said to add this and later I have ported to FreeBSD this CMake Game

http://www.freshports.org/games/opensurge/

src/tools/nfsperf/CMakeLists.txt

cat files/patch-src__tools__nfsperf__CMakeLists.txt
--- ./src/tools/nfsperf/CMakeLists.txt.orig     2014-03-20 11:36:11.015268264 +0100
+++ ./src/tools/nfsperf/CMakeLists.txt  2014-03-20 11:37:28.565272734 +0100
@@ -17,7 +17,9 @@
 ADD_SDLIB_LIBRARY(${_TARGET_NAME} tgf txml)

 IF(UNIX)
+  IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD|DragonFly.*")
     TARGET_LINK_LIBRARIES(${_TARGET_NAME} dl)
+  ENDIF(NOT ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD|DragonFly.*")
 ENDIF(UNIX)

 IF(UNIX)

src/tools/xmlversion/CMakeLists.txt

cat files/patch-src__tools__xmlversion__CMakeLists.txt 
--- ./src/tools/xmlversion/CMakeLists.txt.orig  2014-03-20 11:36:11.025266532 +0100
+++ ./src/tools/xmlversion/CMakeLists.txt       2014-03-20 11:38:30.825283084 +0100
@@ -21,7 +21,10 @@
 ENDIF(CMAKE_SKIP_RPATH OR CMAKE_SKIP_BUILD_RPATH)

 IF(UNIX)
-  TARGET_LINK_LIBRARIES(xmlversion dl)
+  TARGET_LINK_LIBRARIES(xmlversion)
+  IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD|DragonFly.*")
+     TARGET_LINK_LIBRARIES(dl)
+  ENDIF(NOT ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD|DragonFly.*")
 ENDIF(UNIX)

 GET_TARGET_PROPERTY(XMLVERSION_BUILDLOC xmlversion LOCATION)

Bash is in FreeBSD in /usr/local/bin/bash

post-patch:
.for f in src/tools/robots/robotgen.sh src/modules/telemetry/telemetry.sh \
        data/tracks/road/ole-road-1/generate-src.sh
        @${REINPLACE_CMD} -e 's|/bin/bash|${LOCALBASE}/bin/bash|' \
                ${WRKSRC}/${f}
.endfor

or simpler

USES=shebangfix
SHEBANG_FILES=  src/tools/robots/robotgen.sh src/modules/telemetry/telemetry.sh \
                data/tracks/road/ole-road-1/generate-src.sh

But i must patch src/libs/tgf/linuxspec.cpp to be usable in FreeBSD ;(

Could you make too one bsdspec.cpp please which really works and not need patches?

I have fixed linuxspec.cpp to can build and install.

cat files/patch-src__libs__tgf__linuxspec.cpp
--- ./src/libs/tgf/linuxspec.cpp.orig   2012-02-05 11:21:33.000000000 +0100
+++ ./src/libs/tgf/linuxspec.cpp        2014-03-18 23:47:37.499419498 +0100
@@ -38,6 +38,7 @@
 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)
 #include <sys/param.h>
 #include <sys/sysctl.h>
+#include <sys/cpuset.h>
 #if defined(__APPLE__) 
 //#include <Carbon/Carbon.h> /* Carbon APIs for Multiprocessing (TODO) */
 #endif
@@ -632,7 +633,7 @@
 // MacOS X, FreeBSD, OpenBSD, NetBSD, etc ...
 #if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__NetBSD__)

-               nt mib[4];
+               int mib[4];
                size_t len; 

                // Set the mib for hw.ncpu
@@ -640,7 +641,7 @@
                // Get the number of CPUs from the system
                // 1) Try HW_AVAILCPU first.
                mib[0] = CTL_HW;
-               mib[1] = HW_AVAILCPU;  // alternatively, try HW_NCPU;
+               mib[1] = HW_NCPU; // alternatively, try HW_AVAILCPU;
                sysctl(mib, 2, &nCPUs, &len, NULL, 0);

                if (nCPUs < 1) 
@@ -690,7 +691,7 @@
 * Remarks
 *    
 */
-std::string cpuSet2String(const cpu_set_t* pCPUSet)
+std::string cpuSet2String(const cpuset_t* pCPUSet)
 {
        std::ostringstream ossCPUSet;
        for (int nCPUIndex = 0; nCPUIndex < CPU_SETSIZE; nCPUIndex++)
@@ -720,7 +721,7 @@
     pthread_t hCurrThread = pthread_self();

        // Determine the affinity mask to set for the current thread.
-       cpu_set_t nThreadAffinityMask;
+       cpuset_t nThreadAffinityMask;
        CPU_ZERO(&nThreadAffinityMask);
        if (nCPUId == GfAffinityAnyCPU)
        {

That compile in FreeBSD must change

cat files/patch-src__libs__tgf__tgf.hpp
--- ./src/libs/tgf/tgf.hpp.orig 2011-11-27 15:48:28.000000000 +0100
+++ ./src/libs/tgf/tgf.hpp      2014-03-19 04:08:10.139088016 +0100
@@ -84,7 +84,7 @@
        //! Get the asssociated shared library handle.
        void* getSharedLibHandle() const;

- protected:
+// protected:

        //! Unregister a module instance.
        static bool unregister(GfModule* pModule);
 

Last edit: nemysis 2014-03-20