tried to fix few of them via stackoverflow answers

DO NOT COMMIT as-is while I think edlexport.C change is harmless (just
extend netbsd/freebsd check for macosx).

sadly, linking still fails with

 ld: warning: unknown stabs type 0x71 in x86_64/theme_data.o

ld: warning: unknown stabs type 0x71 in x86_64/theme_data.o

 ld: warning: unknown stabs type 0x5F in x86_64/theme_data.o

ld: object file x86_64/theme_data.o was built for different x86_64 sub-type
(-2147483645) than link command line (3) file 'x86_64/theme_data.o' for
architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see
invocation)
make: ***
[/Users/andrewrandrianasulu/cinelerra/cinelerra-5.1/cinelerra/../bin/cin]
Error 1


so our fancy png in machine code object theme supports upsets  MacOSX's
clang ...?

also plugin linking completely fails ...

пн, 10 июн. 2024 г., 17:56 Andrew Randrianasulu <[email protected]>:

> You guess it - I tried to convince cingg to build on macos 10.12.6
>
> bchash.C:184:13: error: use of undeclared identifier 'open_memstream'
>
> seems to exist (reimplemented ) here
>
>
> https://android.googlesource.com/platform/system/core/+/cf63d5d00f5a631a2905da7812b5c029b5211cf6%5E!/
>
> fmemopen also used in bchash.C
>
> https://github.com/mprzybylski/darwin-fmemopen
>
>
> pthread_spinlock_t does not exist here ...
>
>
> https://stackoverflow.com/questions/8177031/does-mac-os-x-have-pthread-spinlock-t-type
>
> there is also bunch of  dirent64 vs dirent and this
>
>
> ffmpeg.C:4499:26: error: no member named 'st_mtim' in 'stat'
>                                          time_t t =
> (time_t)tst.st_mtim.tv_sec;
>                                 ~~~ ^
>                      ffmpeg.C:4502:20: error: no member named 'st_mtim' in
> 'stat'                                                       int64_t us =
> tst.st_mtim.tv_nsec / 1000;
>                         ~~~ ^
>                    20 warnings and 19 errors generated.
>
> ====
>
> I set build against wrong ffmpeg includes ....
>
From 6dfdb1da752ff4a74d21422a4074143ecb76e75f Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 10 Jun 2024 22:13:45 +0300
Subject: [PATCH 5/5] cinelerra Makefile hacks for macos WIP

---
 cinelerra-5.1/cinelerra/Makefile | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile
index 1cb58d50..093fb3ee 100644
--- a/cinelerra-5.1/cinelerra/Makefile
+++ b/cinelerra-5.1/cinelerra/Makefile
@@ -525,8 +525,11 @@ LINKER = ld -o $(OUTPUT)
 CFLAGS += -DUSE_ALPHA
 
 else
-
+ifeq ($(shell uname),Darwin)
+LDFLAGS1 =  -g
+else
 LDFLAGS1 = -Wl,-export-dynamic -g -Wl,-z,noexecstack
+endif
 LDFLAGS2 = $(LDFLAGS)
 LINKER = $(CXX) -o $(OUTPUT)
 
@@ -543,8 +546,8 @@ all:	$(OUTPUT) $(CUTADS) $(BDWRITE) $(LV2UI)
 # Also VFS only overrides the C library when dynamic linking is used.
 $(OUTPUT): $(OBJS) $(THEME_DATA) $(DCRAW) $(LIBRARIES)
 	$(LINKER) `cat $(OBJDIR)/objs`
-	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(OUTPUT) $(OUTPUT_G))
-	$(if $(findstring -g,$(CFLAGS)),objcopy --add-gnu-debuglink=$(OUTPUT_G) $(OUTPUT))
+	$(if $(findstring -g,$(CFLAGS)),gobjcopy --only-keep-debug $(OUTPUT) $(OUTPUT_G))
+	$(if $(findstring -g,$(CFLAGS)),gobjcopy --add-gnu-debuglink=$(OUTPUT_G) $(OUTPUT))
 	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(OUTPUT))
 	ln -f -s ../bin/$(WANT_CIN) ci
 
@@ -552,8 +555,8 @@ ifneq ($(WANT_COMMERCIAL),no)
 $(CUTADS):	$(CUTOBJS) $(CUTLIBS) $(LIBRARIES)
 	@echo $(CXX) -o $@ $(CUTOBJS)
 	@$(CXX) $(CFLAGS) -pthread -o $@ $(CUTOBJS) $(CUTLIBS) $(LIBS)
-	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(CUTADS) $(CUTADS).debuginfo)
-	$(if $(findstring -g,$(CFLAGS)),objcopy --add-gnu-debuglink=$(CUTADS).debuginfo $(CUTADS))
+	$(if $(findstring -g,$(CFLAGS)),gobjcopy --only-keep-debug $(CUTADS) $(CUTADS).debuginfo)
+	$(if $(findstring -g,$(CFLAGS)),gobjcopy --add-gnu-debuglink=$(CUTADS).debuginfo $(CUTADS))
 	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(CUTADS))
 
 install-cutads:
@@ -565,7 +568,7 @@ endif
 $(BDWRITE):	$(BDWOBJS) $(LIBRARIES)
 	@echo $(CXX) -o $@ $(BDWOBJS)
 	@$(CXX) $(CFLAGS) -pthread -o $@ $(BDWOBJS) $(LIBS)
-	$(if $(findstring -g,$(CFLAGS)),objcopy --only-keep-debug $(BDWRITE) $(BDWRITE).debuginfo)
+	$(if $(findstring -g,$(CFLAGS)),gobjcopy --only-keep-debug $(BDWRITE) $(BDWRITE).debuginfo)
 	$(if $(findstring -ggdb,$(CFLAGS)),,strip $(BDWRITE))
 
 install-bdwrite:
-- 
2.13.5 (Apple Git-94)

From a15c67f0219822c4951a3c4ce2d1c0599dbe6edb Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 10 Jun 2024 22:08:22 +0300
Subject: [PATCH 1/5] macos build files WIP

---
 cinelerra-5.1/blds/macos.bld                   | 20 +++++++++
 cinelerra-5.1/guicast/pthread_spin_lock_shim.h | 59 ++++++++++++++++++++++++++
 2 files changed, 79 insertions(+)
 create mode 100755 cinelerra-5.1/blds/macos.bld
 create mode 100644 cinelerra-5.1/guicast/pthread_spin_lock_shim.h

diff --git a/cinelerra-5.1/blds/macos.bld b/cinelerra-5.1/blds/macos.bld
new file mode 100755
index 00000000..408fbe1f
--- /dev/null
+++ b/cinelerra-5.1/blds/macos.bld
@@ -0,0 +1,20 @@
+#!/bin/bash
+#use: patch -p2 < bsd.patch
+export CONFIG_SHELL=/bin/bash
+export MAKE=gmake
+#export C_INCLUDE_PATH=-I/opt/local/include
+export CFLAGS="-I/opt/local/libexec/ffmpeg6/include -I/opt/local/include -I/opt/X11/include"
+export CPLUS_INCLUDE_PATH=/opt/local/include:/usr/local/include/OpenEXR:/usr/local/include/Imath
+export LIBRARY_PATH=/usr/local/lib:-I/opt/local/include
+alias make=gmake
+( ./autogen.sh
+  BSD=1 CC=clang CXX=clang++ CFLAGS="-g -O2 " \
+  ./configure --with-single-user \
+    --disable-static-build --without-libzmpeg --disable-lame --disable-twolame \
+    --without-oss --without-alsa --without-firewire --without-dv --without-dvb \
+    --without-video4linux2 --without-xxf86vm --without-ladspa-build \
+    --without-commercial --without-thirdparty \
+    --without-shuttle --without-libdpx --without-vdpau --without-vaapi --without-shuttle-usb \
+    --without-x10tv --without-filegif --without-lv2 --with-jobs=4 --without-wintv --with-clang
+   gmake
+   gmake install ) 2>&1 | tee log
diff --git a/cinelerra-5.1/guicast/pthread_spin_lock_shim.h b/cinelerra-5.1/guicast/pthread_spin_lock_shim.h
new file mode 100644
index 00000000..f9372e0c
--- /dev/null
+++ b/cinelerra-5.1/guicast/pthread_spin_lock_shim.h
@@ -0,0 +1,59 @@
+/*
+
+Required imports:
+#include <errno.h>
+
+*/
+
+#include <errno.h>
+#include <sched.h>
+
+#ifndef PTHREAD_SPIN_LOCK_SHIM
+#define PTHREAD_SPIN_LOCK_SHIM
+
+typedef int pthread_spinlock_t;
+
+#ifndef PTHREAD_PROCESS_SHARED
+# define PTHREAD_PROCESS_SHARED 1
+#endif
+#ifndef PTHREAD_PROCESS_PRIVATE
+# define PTHREAD_PROCESS_PRIVATE 2
+#endif
+
+static inline int pthread_spin_init(pthread_spinlock_t *lock, int pshared) {
+	__asm__ __volatile__ ("" ::: "memory");
+	*lock = 0;
+	return 0;
+}
+
+static inline int pthread_spin_destroy(pthread_spinlock_t *lock) {
+	return 0;
+}
+
+static inline int pthread_spin_lock(pthread_spinlock_t *lock) {
+	while (1) {
+		int i;
+		for (i=0; i < 10000; i++) {
+			if (__sync_bool_compare_and_swap(lock, 0, 1)) {
+				return 0;
+			}
+		}
+		sched_yield();
+	}
+}
+
+static inline int pthread_spin_trylock(pthread_spinlock_t *lock) {
+	if (__sync_bool_compare_and_swap(lock, 0, 1)) {
+		return 0;
+	}
+	return EBUSY;
+}
+
+static inline int pthread_spin_unlock(pthread_spinlock_t *lock) {
+	__asm__ __volatile__ ("" ::: "memory");
+	*lock = 0;
+	return 0;
+}
+
+#endif
+
-- 
2.13.5 (Apple Git-94)

From f001b65f3208991c7cfebd52615e73edf07d0ad4 Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 10 Jun 2024 22:12:38 +0300
Subject: [PATCH 4/5] macos configure.ac for macports WIP

---
 cinelerra-5.1/configure.ac | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
index 8159da8f..496c53c1 100644
--- a/cinelerra-5.1/configure.ac
+++ b/cinelerra-5.1/configure.ac
@@ -46,7 +46,7 @@ CFG_CFLAGS+=" -D__STDC_CONSTANT_MACROS"
 CFG_CFLAGS+=" -D__STDC_LIMIT_MACROS"
 CFG_CFLAGS+=" -DPNG_SKIP_SETJMP_CHECK=1"
 CFG_CFLAGS+=" -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64"
-CFG_CFLAGS+=" -I/usr/include -I/usr/local/include"
+CFG_CFLAGS+=" -I/usr/include -I/usr/local/include -I/opt/local/include"
 CFG_CFLAGS+=" -I/data/data/com.termux/files/usr/include/a52dec -I/usr/include/a52dec"
 CFG_CFLAGS+=" -I/usr/include/freetype2 -I/usr/local/include/freetype2"
 CFG_CFLAGS+=" -I/data/data/com.termux/files/usr/include/freetype2"
@@ -557,13 +557,15 @@ fi
 
 ## end arch dep tests
 
-REQUIRE_PROG(OBJCOPY, [objcopy])
+REQUIRE_PROG(OBJCOPY, [gobjcopy])
 if test "x$FATAL_ERROR" != "x"; then
  AC_MSG_ERROR("fatal eror.")
 fi
 CHECK_PROG(PACTL, [pactl])
 WANT_PACTL=$PROG_PACTL
 
+CFLAGS+="-I/opt/local/include/"
+LDFLAGS="-L/opt/local/lib/"
 AC_CHECK_DECL([X_HAVE_UTF8_STRING],,[no_utf=yes],[#include <X11/Xlib.h>])
 if test "$no_utf" = "yes"; then
   AC_MSG_ERROR([Cinelerra requires utf8 support in X Windows.])
@@ -1300,6 +1302,20 @@ echo "CFLAGS += -I/usr/pkg/include/uuid"
 
 fi
 
+if test [ "$(uname)"] = "Darwin" ; then
+echo "CFLAGS += -DNO_BTRACE"
+echo "CFLAGS += -DNO_CTX"
+echo "system_libs += -lpng16"
+echo "system_libs += -lintl"
+echo "CFLAGS += -I/opt/local/libexec/ffmpeg6/include/"
+echo "CFLAGS += -I/opt/local/include -std=c++11"
+echo "CFLAGS += $(pkg-config --cflags xft)"
+echo "CFLAGS += -I/usr/pkg/include"
+echo "CFLAGS += -I/usr/pkg/include/uuid"
+
+fi
+
+
 if test "x$WANT_X264_HIDEPTH" = "xyes" ; then
   X264_CFG_PARAMS="$X264_CFG_PARAMS --bit-depth=10"
 fi
-- 
2.13.5 (Apple Git-94)

From 4c7d7609d531b681c1a272978e8d5b880597f1db Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 10 Jun 2024 22:10:47 +0300
Subject: [PATCH 2/5] Guicast hacks for macos WIP

---
 cinelerra-5.1/guicast/Makefile     |  6 ++++-
 cinelerra-5.1/guicast/bchash.C     |  4 +++
 cinelerra-5.1/guicast/bchash.h     |  1 +
 cinelerra-5.1/guicast/bcsignals.C  |  3 +++
 cinelerra-5.1/guicast/bcsignals.h  |  1 +
 cinelerra-5.1/guicast/bctrace.h    |  1 +
 cinelerra-5.1/guicast/filesystem.C |  3 +++
 cinelerra-5.1/guicast/fmemopen.h   | 52 ++++++++++++++++++++++++++++++++++++++
 cinelerra-5.1/guicast/thread.C     |  4 +++
 9 files changed, 74 insertions(+), 1 deletion(-)
 create mode 100644 cinelerra-5.1/guicast/fmemopen.h

diff --git a/cinelerra-5.1/guicast/Makefile b/cinelerra-5.1/guicast/Makefile
index 49bd154c..d7d18f6a 100644
--- a/cinelerra-5.1/guicast/Makefile
+++ b/cinelerra-5.1/guicast/Makefile
@@ -10,7 +10,11 @@ BOOTSTRAPFLAGS := -DBOOTSTRAP="\"objcopy -B i386 -I binary -O elf32-i386\""
 endif
 
 ifeq ($(OBJDIR), x86_64)
-BOOTSTRAPFLAGS := -DBOOTSTRAP="\"objcopy -B i386 -I binary -O elf64-x86-64\""
+ifeq ($(shell uname), Darwin)
+BOOTSTRAPFLAGS := -DBOOTSTRAP="\"gobjcopy -B i386 -I binary -O mach-o-x86-64\""
+else
+BOOTSTRAPFLAGS := -DBOOTSTRAP="\"objcopy -B i386 -I binary -O elf64--x86-64\""
+endif
 endif
 ifeq ($(OBJDIR), amd64)
 BOOTSTRAPFLAGS := -DBOOTSTRAP="\"objcopy -B i386 -I binary -O elf64-x86-64\""
diff --git a/cinelerra-5.1/guicast/bchash.C b/cinelerra-5.1/guicast/bchash.C
index b38459ab..341096be 100644
--- a/cinelerra-5.1/guicast/bchash.C
+++ b/cinelerra-5.1/guicast/bchash.C
@@ -169,6 +169,7 @@ int BC_Hash::save()
 	return ret;
 }
 
+#if !defined (__APPLE__)
 int BC_Hash::load_string(const char *bfr)
 {
 	FILE *fp = fmemopen((void*)bfr, strlen(bfr), "r");
@@ -180,6 +181,7 @@ int BC_Hash::load_string(const char *bfr)
 
 int BC_Hash::save_string(char *&bfr)
 {
+
 	size_t bsz = 0;
 	FILE *fp = open_memstream(&bfr, &bsz);
 	if( !fp ) return 1;
@@ -188,6 +190,8 @@ int BC_Hash::save_string(char *&bfr)
 	return ret;
 }
 
+#endif
+
 
 
 int32_t BC_Hash::get(const char *name, int32_t default_)
diff --git a/cinelerra-5.1/guicast/bchash.h b/cinelerra-5.1/guicast/bchash.h
index 36c4a4a3..d3989088 100644
--- a/cinelerra-5.1/guicast/bchash.h
+++ b/cinelerra-5.1/guicast/bchash.h
@@ -30,6 +30,7 @@
 #include "bcwindowbase.inc"
 #include "bctextbox.inc"
 #include "units.h"
+//#include "fmemopen.h"
 
 
 class BC_Hash
diff --git a/cinelerra-5.1/guicast/bcsignals.C b/cinelerra-5.1/guicast/bcsignals.C
index 858ba409..c596d022 100644
--- a/cinelerra-5.1/guicast/bcsignals.C
+++ b/cinelerra-5.1/guicast/bcsignals.C
@@ -45,6 +45,9 @@
 #endif
 #include <sys/types.h>
 
+#define dirent64 dirent
+#define readdir64 readdir
+
 BC_Signals* BC_Signals::global_signals = 0;
 static int signal_done = 0;
 
diff --git a/cinelerra-5.1/guicast/bcsignals.h b/cinelerra-5.1/guicast/bcsignals.h
index 42fbebeb..ab4e0f9a 100644
--- a/cinelerra-5.1/guicast/bcsignals.h
+++ b/cinelerra-5.1/guicast/bcsignals.h
@@ -26,6 +26,7 @@
 
 #include "arraylist.h"
 #include "linklist.h"
+#include "pthread_spin_lock_shim.h"
 #include "bcsignals.inc"
 #include "bctrace.h"
 #include <stdio.h>
diff --git a/cinelerra-5.1/guicast/bctrace.h b/cinelerra-5.1/guicast/bctrace.h
index b2c4c359..4e47be07 100644
--- a/cinelerra-5.1/guicast/bctrace.h
+++ b/cinelerra-5.1/guicast/bctrace.h
@@ -24,6 +24,7 @@
 
 #include "arraylist.h"
 #include "linklist.h"
+#include "pthread_spin_lock_shim.h"
 #include "bctrace.inc"
 #include "bcwindowbase.inc"
 #include "cstrdup.h"
diff --git a/cinelerra-5.1/guicast/filesystem.C b/cinelerra-5.1/guicast/filesystem.C
index b1ace6fd..7c91d07e 100644
--- a/cinelerra-5.1/guicast/filesystem.C
+++ b/cinelerra-5.1/guicast/filesystem.C
@@ -36,6 +36,9 @@
 
 #include "filesystem.h"
 
+#define dirent64 dirent
+#define readdir64 readdir
+
 FileItem::FileItem()
 {
 	path = 0;
diff --git a/cinelerra-5.1/guicast/fmemopen.h b/cinelerra-5.1/guicast/fmemopen.h
new file mode 100644
index 00000000..ef52a26e
--- /dev/null
+++ b/cinelerra-5.1/guicast/fmemopen.h
@@ -0,0 +1,52 @@
+//
+// Copyright 2011-2014 NimbusKit
+// Originally ported from https://github.com/ingenuitas/python-tesseract/blob/master/fmemopen.c
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//    http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+#ifndef FMEMOPEN_H_
+#define FMEMOPEN_H_
+
+#if defined __cplusplus
+extern "C" {
+#endif
+
+/**
+ * A BSD port of the fmemopen Linux method using funopen.
+ *
+ * man docs for fmemopen:
+ * http://linux.die.net/man/3/fmemopen
+ *
+ * man docs for funopen:
+ * https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man3/funopen.3.html
+ *
+ * This method is ported from ingenuitas' python-tesseract project.
+ *
+ * You must call fclose on the returned file pointer or memory will be leaked.
+ *
+ * @param buf The data that will be used to back the FILE* methods. Must be at least
+ *            @c size bytes.
+ * @param size The size of the @c buf data.
+ * @param mode The permitted stream operation modes.
+ * @return A pointer that can be used in the fread/fwrite/fseek/fclose family of methods.
+ *         If a failure occurred NULL will be returned.
+ * @ingroup NimbusMemoryMappping
+ */
+FILE *fmemopen(void *buf, size_t size, const char *mode);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef FMEMOPEN_H_
diff --git a/cinelerra-5.1/guicast/thread.C b/cinelerra-5.1/guicast/thread.C
index edac1451..ae55aff4 100644
--- a/cinelerra-5.1/guicast/thread.C
+++ b/cinelerra-5.1/guicast/thread.C
@@ -238,9 +238,13 @@ int Thread::get_synchronous()
 
 bool Thread::calculate_realtime()
 {
+#if !defined (__APPLE__)
 //printf("Thread::calculate_realtime %d %d\n", getpid(), sched_getscheduler(0));
 	return (sched_getscheduler(0) == SCHED_RR ||
 		sched_getscheduler(0) == SCHED_FIFO);
+#endif
+return 0;
+
 }
 
 int Thread::get_realtime()
-- 
2.13.5 (Apple Git-94)

From 243da6453fc9ccad86e42e8a7d9ea4b9c66bf35a Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <[email protected]>
Date: Mon, 10 Jun 2024 22:11:46 +0300
Subject: [PATCH 3/5] Cinelerra macos hacks WIP

---
 cinelerra-5.1/cinelerra/bdcreate.C  |  4 ++--
 cinelerra-5.1/cinelerra/bdwrite.C   | 25 ++++++++++++++++++++++---
 cinelerra-5.1/cinelerra/dvdcreate.C |  4 ++--
 cinelerra-5.1/cinelerra/exportedl.C |  2 +-
 cinelerra-5.1/cinelerra/ffmpeg.C    |  8 ++++++++
 5 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/cinelerra-5.1/cinelerra/bdcreate.C b/cinelerra-5.1/cinelerra/bdcreate.C
index 7305d4e9..ae5fe2a7 100644
--- a/cinelerra-5.1/cinelerra/bdcreate.C
+++ b/cinelerra-5.1/cinelerra/bdcreate.C
@@ -46,7 +46,7 @@
 #include <errno.h>
 #if !defined(__FreeBSD__)
 #include <sys/stat.h>
-#if !defined(__NetBSD__)
+#if !defined(__NetBSD__) && !defined(__APPLE__)
 #include <sys/statfs.h>
 #endif
 #else
@@ -54,7 +54,7 @@
 #include <sys/mount.h>
 #endif
 
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined (__APPLE__)
 #include <sys/statvfs.h>
 #ifndef statfs
 #define statfs statvfs
diff --git a/cinelerra-5.1/cinelerra/bdwrite.C b/cinelerra-5.1/cinelerra/bdwrite.C
index 1f7f027e..4968a968 100644
--- a/cinelerra-5.1/cinelerra/bdwrite.C
+++ b/cinelerra-5.1/cinelerra/bdwrite.C
@@ -58,11 +58,30 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
-#if !defined (__FreeBSD__)
-#include <endian.h>
-#else
+#if defined (__FreeBSD__)
 #include <sys/endian.h>
 #endif
+#if defined (__APPLE__)
+#include <machine/endian.h>
+#include <libkern/OSByteOrder.h>
+
+#define htobe16(x) OSSwapHostToBigInt16(x)
+#define htole16(x) OSSwapHostToLittleInt16(x)
+#define be16toh(x) OSSwapBigToHostInt16(x)
+#define le16toh(x) OSSwapLittleToHostInt16(x)
+
+#define htobe32(x) OSSwapHostToBigInt32(x)
+#define htole32(x) OSSwapHostToLittleInt32(x)
+#define be32toh(x) OSSwapBigToHostInt32(x)
+#define le32toh(x) OSSwapLittleToHostInt32(x)
+
+#define htobe64(x) OSSwapHostToBigInt64(x)
+#define htole64(x) OSSwapHostToLittleInt64(x)
+#define be64toh(x) OSSwapBigToHostInt64(x)
+#define le64toh(x) OSSwapLittleToHostInt64(x)
+#else
+#include <endian.h>
+#endif
 #include <limits.h>
 #include <sys/stat.h>
 // work arounds (centos)
diff --git a/cinelerra-5.1/cinelerra/dvdcreate.C b/cinelerra-5.1/cinelerra/dvdcreate.C
index 390d2cbc..ee6877dd 100644
--- a/cinelerra-5.1/cinelerra/dvdcreate.C
+++ b/cinelerra-5.1/cinelerra/dvdcreate.C
@@ -47,7 +47,7 @@
 #include <errno.h>
 #if !defined(__FreeBSD__)
 #include <sys/stat.h>
-#if !defined(__NetBSD__)
+#if !defined(__NetBSD__) && !defined (__APPLE__)
 #include <sys/statfs.h>
 #endif
 #else
@@ -55,7 +55,7 @@
 #include <sys/mount.h>
 #endif
 
-#if defined(__NetBSD__)
+#if defined(__NetBSD__) || defined (__APPLE__)
 #include <sys/statvfs.h>
 #ifndef statfs
 #define statfs statvfs
diff --git a/cinelerra-5.1/cinelerra/exportedl.C b/cinelerra-5.1/cinelerra/exportedl.C
index 69174635..aca95d6b 100644
--- a/cinelerra-5.1/cinelerra/exportedl.C
+++ b/cinelerra-5.1/cinelerra/exportedl.C
@@ -39,7 +39,7 @@
 #include "exportedl.h"
 #include "tracks.h"
 #include "transition.h"
-#if defined (__FreeBSD__) || defined (__NetBSD__)
+#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__APPLE__)
 #include <libgen.h>
 #endif
 #include <ctype.h>
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index 9b8832dd..6f28778c 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -4496,10 +4496,18 @@ double FFMPEG::get_initial_timecode(int data_type, int channel, double frame_rat
 	}
 	struct stat tst;
 	if( stat(path, &tst) >= 0 ) {
+#if defined(__APPLE__)
+		time_t t = (time_t)tst.st_mtimespec.tv_sec;
+#else
 		time_t t = (time_t)tst.st_mtim.tv_sec;
+#endif
 		struct tm tm;
 		localtime_r(&t, &tm);
+#if defined (__APPLE__)
+		int64_t us = tst.st_mtimespec.tv_nsec / 1000;
+#else
 		int64_t us = tst.st_mtim.tv_nsec / 1000;
+#endif
 		int frm = us/1000000. * frame_rate;
 		sprintf(tcbuf,"%d:%02d:%02d:%02d", tm.tm_hour, tm.tm_min, tm.tm_sec, frm);
 		return ff_get_timecode(tcbuf, rate, 0);
-- 
2.13.5 (Apple Git-94)

-- 
Cin mailing list
[email protected]
https://lists.cinelerra-gg.org/mailman/listinfo/cin

Reply via email to