Enable build for FreeBSD (part 1/2)
authorRobin Gareus <robin@gareus.org>
Sun, 26 Jun 2016 14:43:07 +0000 (16:43 +0200)
committerRobin Gareus <robin@gareus.org>
Sun, 26 Jun 2016 14:43:07 +0000 (16:43 +0200)
Adopted from Michael Beer -- GH pull-request #232 with minor changes:

*   rebased on master,
*   removed trailing whitespace,
*   don't explicitly change saved configuration defaults (wscript)
*   moved sys/wait (WNOHANG) to header include
*   separate changes in GUI and lib

libs/ardour/route_group.cc
libs/ardour/session.cc
libs/ardour/session_state.cc
libs/midi++2/midi++/ipmidi_port.h
libs/pbd/cpus.cc
libs/pbd/pbd/floating.h
libs/pbd/pbd/system_exec.h
libs/ptformat/ptfformat.cc
tools/gccabicheck/wscript
wscript

index f258e9f14d2d379aaec05f937e3b09467d77e704..91303af07ec00f0308f706659ff6cc0b85252f6c 100644 (file)
@@ -32,6 +32,7 @@
 #include "ardour/route.h"
 #include "ardour/route_group.h"
 #include "ardour/session.h"
+#include "ardour/debug.h"
 
 #include "i18n.h"
 
index 00055844031fa5c60e1cda4142029ff3e0e73853..6ef78eacb63231ddd755f1f04e3b4b88291e49c4 100644 (file)
@@ -3459,7 +3459,7 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
                        }
                }
 
-#ifndef __APPLE__
+#if !defined(__APPLE__) && !defined(__FreeBSD__)
                /* clang complains: 'operator<<' should be declared prior to the call site or in an associated namespace of one of its
                 * arguments std::ostream& operator<<(std::ostream& o, ARDOUR::PresentationInfo const& rid)"
                 */
index a9d7828d8b9cee6dc80a984cc7aa6bb756fdaa41..0075799a16e2bc813b28650fb9b4f5befaee8de4 100644 (file)
@@ -39,7 +39,7 @@
 #include <sys/vfs.h>
 #endif
 
-#ifdef __APPLE__
+#if defined(__APPLE__) || defined(__FreeBSD__)
 #include <sys/param.h>
 #include <sys/mount.h>
 #endif
@@ -2262,7 +2262,7 @@ Session::save_template (string template_name, bool replace_existing)
 void
 Session::refresh_disk_space ()
 {
-#if __APPLE__ || (HAVE_SYS_VFS_H && HAVE_SYS_STATVFS_H)
+#if __APPLE__ || __FreeBSD__ || (HAVE_SYS_VFS_H && HAVE_SYS_STATVFS_H)
 
        Glib::Threads::Mutex::Lock lm (space_lock);
 
index 313208892f34c048c9be335d5cc336e05678abae..d870c79ef090d782d88addb3fc5babb5595488a3 100644 (file)
@@ -23,7 +23,7 @@
 #include <iostream>
 #if defined(PLATFORM_WINDOWS)
 #include <winsock.h>
-#elif defined(__FREE_BSD__)
+#elif defined(__FreeBSD__)
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <sys/_sockaddr_storage.h>
index fb94b475de69735c8990f1f85dc50c619b8929d0..69421e5e9275e57543473baa60dbf37f30a3b1a8 100644 (file)
@@ -43,10 +43,14 @@ hardware_concurrency()
 {
 #if defined(PTW32_VERSION) || defined(__hpux)
         return pthread_num_processors_np();
-#elif defined(__APPLE__) || defined(__FreeBSD__)
+#elif defined(__APPLE__)
         int count;
         size_t size=sizeof(count);
         return sysctlbyname("hw.physicalcpu",&count,&size,NULL,0)?0:count;
+#elif defined(__FreeBSD__)
+        int count;
+        size_t size=sizeof(count);
+        return sysctlbyname("hw.ncpu",&count,&size,NULL,0)?0:count;
 #elif defined(HAVE_UNISTD) && defined(_SC_NPROCESSORS_ONLN)
         int const count=sysconf(_SC_NPROCESSORS_ONLN);
         return (count>0)?count:0;
index 86ab4a68f037bf7ed838a7ac8da019ad7c18df6c..d7d6349a3478557fc6768c3bd8f89d053a683be4 100644 (file)
@@ -28,6 +28,7 @@
 
 #include <stdint.h>
 
+#include <cstdlib> // abs(int)
 #include <cmath>
 
 #include "pbd/libpbd_visibility.h"
index d5b14c827384d527ed8eff91a3bece3a975eb51c..a8a30ba18dc0b6af05faac7aacc5f68cd4f1b76b 100644 (file)
@@ -37,6 +37,9 @@
 #undef interface // VKamyshniy: to avoid "include/giomm-2.4/giomm/dbusmessage.h:270:94: error: expected ',' or '...' before 'struct'"
 #endif
 
+#else // posix
+#include <sys/types.h>
+#include <sys/wait.h> /* WNOHANG is part of the exposed API */
 #endif
 
 #include <string>
index caf2c2f42a668a883d24d7c9e27419e60637fb77..3d66ec025ec8a0ea0dfa867849932cb83b04cc05 100644 (file)
@@ -15,6 +15,7 @@
 */
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string>
 #include <string.h>
 #include <assert.h>
index ecef5c6aa7ab9b4278c655d874ca2fe282c66ac1..afdb99f506816685ed5b7b54cfed0003a320d011 100644 (file)
@@ -2,6 +2,8 @@
 from waflib.extras import autowaf as autowaf
 from waflib import Options
 import os
+import re
+import sys
 
 # Mandatory variables
 top = '.'
@@ -19,5 +21,6 @@ def build(bld):
     obj.source = [ 'abicheck.c' ]
     obj.target = 'gcc-glibmm-abi-check'
     obj.name = 'gcc-glibmm-abi-check'
-    obj.lib = 'dl'
+    if re.search ("freebsd", sys.platform) == None:
+        obj.lib = 'dl'
     obj.install_path = None
diff --git a/wscript b/wscript
index 352c9cda2c2e00de9d418e478ef7fc8c4fe28170..f23a987b3cb290a5641875b28f139e6101ae13a0 100644 (file)
--- a/wscript
+++ b/wscript
@@ -568,6 +568,9 @@ int main() { return 0; }''',
     if opt.stl_debug:
         cxx_flags.append("-D_GLIBCXX_DEBUG")
 
+    if re.search ("freebsd", sys.platform) != None:
+        linker_flags.append('-lexecinfo')
+
     if conf.env['DEBUG_RT_ALLOC']:
         compiler_flags.append('-DDEBUG_RT_ALLOC')
         linker_flags.append('-ldl')
@@ -940,7 +943,10 @@ def configure(conf):
     # executing a test program is n/a when cross-compiling
     if Options.options.dist_target != 'mingw':
         if Options.options.dist_target != 'msvc':
-            conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL')
+            if re.search ("freebsd", sys.platform) != None:
+                conf.check_cc(function_name='dlopen', header_name='dlfcn.h', uselib_store='DL')
+            else:
+                conf.check_cc(function_name='dlopen', header_name='dlfcn.h', lib='dl', uselib_store='DL')
         conf.check_cxx(fragment = "#include <boost/version.hpp>\nint main(void) { return (BOOST_VERSION >= 103900 ? 0 : 1); }\n",
                   execute = "1",
                   mandatory = True,