more build tweaks for bsd
[goodguy/history.git] / cinelerra-5.1 / bsd.patch
index 1af225122f8f4115f85039dac18d501edfec34ee..f6841bdaf29a02c2c48f6144488c92abd8e6500a 100644 (file)
@@ -1,3 +1,16 @@
+diff --git a/cinelerra-5.1/Makefile.devel b/cinelerra-5.1/Makefile.devel
+index a12d8f2b..f892f648 100644
+--- a/cinelerra-5.1/Makefile.devel
++++ b/cinelerra-5.1/Makefile.devel
+@@ -4,7 +4,7 @@ TOPDIR := $(CURDIR)
+ CFLAGS ?= -ggdb
+ export CFLAGS_ := $(CFLAGS)
+-cpus:=$(shell grep -c "^proc" /proc/cpuinfo)
++cpus:=$(shell sysctl -n hw.ncpu)
+ jobs:=-j$(shell echo $$(($(cpus) + $(cpus)/2 +2)))
+ MAKEJ := $(MAKE) $(jobs)
 diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
 index 18590e3a..a60c71d1 100644
 --- a/cinelerra-5.1/cinelerra/Makefile
@@ -216,6 +229,15 @@ index 6fba32bb..ccdb683b 100644
  
  AC_DEFUN([CHECK_WITH], [
  AC_ARG_WITH([$1],
+@@ -126,7 +137,7 @@ AC_SUBST(MAK_INSTALLS)
+ AC_SUBST(MAK_UNINSTALLS)
+ if test "x$WANT_JOBS" = "xauto"; then
+-  CPUS=`grep -c "^proc" /proc/cpuinfo`
++  CPUS=`sysctl -n hw.ncpu`
+   WANT_JOBS=`expr $CPUS + $CPUS / 2 + 2`
+ fi
 diff --git a/cinelerra-5.1/db/tdb.h b/cinelerra-5.1/db/tdb.h
 index 8ee88002..9a17091e 100644
 --- a/cinelerra-5.1/db/tdb.h
@@ -259,10 +281,48 @@ index 40f5971f..73d47586 100644
        float* get_values();
  
 diff --git a/cinelerra-5.1/guicast/bcresources.C b/cinelerra-5.1/guicast/bcresources.C
-index e3400600..3cf616f8 100644
+index e3400600..b32d0a6f 100644
 --- a/cinelerra-5.1/guicast/bcresources.C
 +++ b/cinelerra-5.1/guicast/bcresources.C
-@@ -695,7 +695,7 @@ new_vframes(20,default_medium_7segment,
+@@ -38,6 +38,7 @@
+ #include <iconv.h>
+ #include <sys/ipc.h>
+ #include <sys/shm.h>
++#include <sys/sysctl.h>
+ #include <X11/extensions/XShm.h>
+ #include <fontconfig/fontconfig.h>
+ #include <fontconfig/fcfreetype.h>
+@@ -297,23 +298,12 @@ int BC_Resources::machine_cpus = 1;
+ int BC_Resources::get_machine_cpus()
+ {
+-      int cpus = 1;
+-      FILE *proc = fopen("/proc/cpuinfo", "r");
+-      if( proc ) {
+-              char string[BCTEXTLEN], *cp;
+-              while(!feof(proc) && fgets(string, sizeof(string), proc) ) {
+-                      if( !strncasecmp(string, "processor", 9) &&
+-                          (cp = strchr(string, ':')) != 0 ) {
+-                              int n = atol(cp+1) + 1;
+-                              if( n > cpus ) cpus = n;
+-                      }
+-                      else if( !strncasecmp(string, "cpus detected", 13) &&
+-                          (cp = strchr(string, ':')) != 0 )
+-                              cpus = atol(cp+1);
+-              }
+-              fclose(proc);
+-      }
+-      return cpus;
++      int mib[2], ncpu;
++      size_t len = sizeof(ncpu);
++      mib[0] = CTL_HW;
++      mib[1] = HW_NCPU;
++      if( sysctl(mib, 2, &ncpu, &len, 0, 0) ) ncpu = 1;
++      return ncpu;
+ }
+ void BC_Resources::new_vframes(int n, VFrame *vframes[], ...)
+@@ -695,7 +685,7 @@ new_vframes(20,default_medium_7segment,
        generic_button_margin = 15;
        draw_clock_background=1;
  
@@ -271,7 +331,7 @@ index e3400600..3cf616f8 100644
        shm_reply = 1;
  
  // Initialize
-@@ -1681,6 +1681,87 @@ BC_FontEntry *BC_Resources::find_fontentry(const char *displayname, int style,
+@@ -1681,6 +1671,87 @@ BC_FontEntry *BC_Resources::find_fontentry(const char *displayname, int style,
        return style_match;
  }
  
@@ -359,7 +419,7 @@ index e3400600..3cf616f8 100644
  size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
        char *input, int input_length, char *output, int output_length)
  {
-@@ -1688,10 +1769,12 @@ size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
+@@ -1688,10 +1759,12 @@ size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
        iconv_t cd;
        char *outbase = output;
  
@@ -374,7 +434,7 @@ index e3400600..3cf616f8 100644
                to_enc = "UTF-8";
  
        if(input_length < 0)
-@@ -1701,32 +1784,45 @@ size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
+@@ -1701,32 +1774,45 @@ size_t BC_Resources::encode(const char *from_enc, const char *to_enc,
  
        if(strcmp(from_enc, to_enc) && inbytes)
        {