пн, 10 июн. 2024 г., 22:30 Phyllis Smith <[email protected]>:
> What an interesting project! good luck, it sounds like a big challenge! > indeed! I tried to workaround raw data embedding using this stackoverflow answer: https://stackoverflow.com/questions/34641373/how-do-i-embed-the-contents-of-a-binary-file-in-an-executable-on-mac-os-x unfortunately while with attached haxkery main executable links it dies at startup with "-9" error nm -a bin/cin /opt/local/libexec/llvm-10/bin/llvm-nm: error: bin/cin truncated or malformed object (load command 21 LC_LOAD_DYLIB library name extends past the end of the load command) and of course plugin linking is broken .... > > On Mon, Jun 10, 2024 at 8:56 AM Andrew Randrianasulu < > [email protected]> wrote: > >> 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 05/11] 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 f001b65f3208991c7cfebd52615e73edf07d0ad4 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <[email protected]> Date: Mon, 10 Jun 2024 22:12:38 +0300 Subject: [PATCH 04/11] 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 2b169f2ce9f4e00f2bbcf3027cfbde9585eebfb0 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <[email protected]> Date: Wed, 19 Jun 2024 17:58:52 +0300 Subject: [PATCH 09/11] Hack: bchash.C for macosx --- cinelerra-5.1/guicast/bchash.C | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/cinelerra-5.1/guicast/bchash.C b/cinelerra-5.1/guicast/bchash.C index 341096be..8499c3fd 100644 --- a/cinelerra-5.1/guicast/bchash.C +++ b/cinelerra-5.1/guicast/bchash.C @@ -189,8 +189,70 @@ int BC_Hash::save_string(char *&bfr) fclose(fp); return ret; } +#else +#define BUFFER_LENGTH 4096 +int BC_Hash::save_string(char* &string) +{ + int alen; + char *bp; + + alen = BUFFER_LENGTH; + bp = string = new char[alen]; + + for(int i = 0; i < total; i++) + { + if(bp - string > alen - strlen(names[i]) - strlen(values[i]) - 5) + { + alen += BUFFER_LENGTH; + char *p = new char[alen]; + strcpy(p, string); + bp = &p[bp - string]; + delete [] string; + string = p; + } + bp += sprintf(bp, "%s %s\n", names[i], values[i]); + } + return 1; +} + +int BC_Hash::load_string(const char *string) +{ + char *p, *q, *r; +#if 0 + r = string; + while(*r) + { + for(q = p = r; *p; p++) + { + if(*p == ' ') + { + *p++ = 0; + q = p; + break; + } + } + if(q == r) + return 0; + + for(; *p; p++) + { + if(*p == '\n') + { + *p = 0; + break; + } + } + //cache->update(r, q); + r = ++p; + } #endif + return 1; +} + +#endif + + -- 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 02/11] 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 b275f83f4b6d4b5c70d4db50f3083fad739f1fe6 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <[email protected]> Date: Wed, 19 Jun 2024 17:55:57 +0300 Subject: [PATCH 07/11] fmemopen.C implementation --- cinelerra-5.1/guicast/fmemopen.C | 170 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 cinelerra-5.1/guicast/fmemopen.C diff --git a/cinelerra-5.1/guicast/fmemopen.C b/cinelerra-5.1/guicast/fmemopen.C new file mode 100644 index 00000000..bdb32dfe --- /dev/null +++ b/cinelerra-5.1/guicast/fmemopen.C @@ -0,0 +1,170 @@ +/* + * Copyright (c) 2017 Joachim Nilsson <[email protected]> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + + +extern "C" { + +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <stdio.h> + +#ifdef __APPLE__ +#include <stdlib.h> +#include <memory.h> + +struct ops { + char *buf; + size_t len, pos; +}; + +typedef struct ops ops_t; + +static int readfn(void *arg, char *buf, int len) +{ + int sz; + ops_t *ops = (ops_t *)arg; + + sz = (int)(ops->len - ops->pos); + if (sz < 0) + sz = 0; + if (len > sz) + len = sz; + + memcpy(buf, &ops->buf[ops->pos], len); + ops->pos += len; + + return len; +} + +static int writefn(void *arg, const char *buf, int len) +{ + int sz; + ops_t *ops = (ops_t *)arg; + + sz = (int)(ops->len - ops->pos); + if (sz < 0) + sz = 0; + if (len > sz) + len = sz; + + memcpy(&ops->buf[ops->pos], buf, len); + ops->pos += len; + + return len; +} + +static fpos_t seekfn(void *arg, fpos_t offset, int whence) +{ + fpos_t pos; + ops_t *ops = (ops_t *)arg; + + switch (whence) { + case SEEK_SET: + pos = offset; + break; + + case SEEK_END: + pos = ops->len + offset; + break; + + case SEEK_CUR: + pos = ops->pos + offset; + break; + + default: + return -1; + } + + if (pos < 0 || (size_t)pos > ops->len) { + ops->pos = 0; + return -1; + } + + return 0; +} + +static int closefn(void *arg) +{ + free(arg); + return 0; +} + +FILE *fmemopen(void *buf, size_t len, const char *type) +{ + ops_t *ops = (ops_t *)(malloc(sizeof(*ops))); + + if (!ops) + return NULL; + + memset(ops, 0, sizeof(*ops)); + ops->buf = (char *)(buf); + ops->len = len; + ops->pos = 0; + + return funopen(ops, readfn, writefn, seekfn, closefn); +} +#elif defined(HAVE_WINDOWS_H) +#include <io.h> +#include <fcntl.h> +#include <sys/stat.h> +#include <windows.h> + +FILE *fmemopen(void *buf, size_t len, const char *type) +{ + int fd; + FILE *fp; + char tp[MAX_PATH - 13]; + char fn[MAX_PATH + 1]; + + if (!GetTempPathA(sizeof(tp), tp)) + return NULL; + + if (!GetTempFileNameA(tp, "confuse", 0, fn)) + return NULL; + + fd = _open(fn, + _O_CREAT | _O_RDWR | _O_SHORT_LIVED | _O_TEMPORARY | _O_BINARY, + _S_IREAD | _S_IWRITE); + if (fd == -1) + return NULL; + + fp = _fdopen(fd, "w+"); + if (!fp) { + _close(fd); + return NULL; + } + + fwrite(buf, len, 1, fp); + rewind(fp); + + return fp; +} + +#else +#error Sorry, this platform currently has no fmemopen() replacement. +#endif + +} + + +/** + * Local Variables: + * indent-tabs-mode: t + * c-file-style: "linux" + * End: + */ -- 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 03/11] 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)
From b5f7abe8713852b5a4ee1391c74788e55a7aaf78 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <[email protected]> Date: Thu, 20 Jun 2024 00:31:54 +0300 Subject: [PATCH 11/11] more macosx hacks - links but killed at startup --- cinelerra-5.1/cinelerra/Makefile | 2 +- cinelerra-5.1/cinelerra/theme_data.S | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 cinelerra-5.1/cinelerra/theme_data.S diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile index 2e884b86..18020e15 100644 --- a/cinelerra-5.1/cinelerra/Makefile +++ b/cinelerra-5.1/cinelerra/Makefile @@ -411,7 +411,7 @@ endif GCC ?= gcc DCRAW := $(OBJDIR)/dcraw.o -THEME_DATA := $(OBJDIR)/theme_data.o +THEME_DATA := $(OBJDIR)/theme_data.S -I$(TOPDIR)/cinelerra/$(OBJDIR) OUTPUT = $(BINDIR)/$(WANT_CIN) OUTPUT_G = $(OBJDIR)/$(WANT_CIN).debuginfo diff --git a/cinelerra-5.1/cinelerra/theme_data.S b/cinelerra-5.1/cinelerra/theme_data.S new file mode 100644 index 00000000..ed98d647 --- /dev/null +++ b/cinelerra-5.1/cinelerra/theme_data.S @@ -0,0 +1,6 @@ + .global _binary_theme_data_start +_binary_theme_data_start: + .incbin "theme_data" + + .global _binary_theme_data_end +_binary_theme_data_end: -- 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 01/11] 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 09b0aa9e87f5f03e613650a943cde350631ce1f9 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <[email protected]> Date: Wed, 19 Jun 2024 18:15:35 +0300 Subject: [PATCH 10/11] Hack for macosx in theme.C not working yet --- cinelerra-5.1/cinelerra/theme.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cinelerra-5.1/cinelerra/theme.C b/cinelerra-5.1/cinelerra/theme.C index 8a667b5c..eb99b999 100644 --- a/cinelerra-5.1/cinelerra/theme.C +++ b/cinelerra-5.1/cinelerra/theme.C @@ -210,8 +210,8 @@ void Theme::initialize() message_error = RED; // Force to use local data for images - extern unsigned char _binary_theme_data_start[]; - set_data(_binary_theme_data_start); + extern unsigned char binary_theme_data_start[]; + set_data(binary_theme_data_start); // Set images which weren't set by subclass new_image("mode_normal", "mode_normal.png"); -- 2.13.5 (Apple Git-94)
From 47ac51ef3f5de4d07f8ddeb668f2b4467b968789 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <[email protected]> Date: Wed, 19 Jun 2024 14:53:08 +0300 Subject: [PATCH 06/11] More fixes for linking on macosx --- cinelerra-5.1/cinelerra/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cinelerra-5.1/cinelerra/Makefile b/cinelerra-5.1/cinelerra/Makefile index 093fb3ee..2e884b86 100644 --- a/cinelerra-5.1/cinelerra/Makefile +++ b/cinelerra-5.1/cinelerra/Makefile @@ -526,7 +526,7 @@ CFLAGS += -DUSE_ALPHA else ifeq ($(shell uname),Darwin) -LDFLAGS1 = -g +LDFLAGS1 = -g -Wl,-arch x86_64 -Wl,-allow_sub_type_mismatches -v -liconv -L/opt/local/libexec/ffmpeg6/lib else LDFLAGS1 = -Wl,-export-dynamic -g -Wl,-z,noexecstack endif -- 2.13.5 (Apple Git-94)
From 408bddf2d49bdb5392ec6c9d0a00c8b1e4666461 Mon Sep 17 00:00:00 2001 From: Andrew Randrianasulu <[email protected]> Date: Wed, 19 Jun 2024 17:57:59 +0300 Subject: [PATCH 08/11] Add fmemopen.C to guicast/Makefile --- cinelerra-5.1/guicast/Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cinelerra-5.1/guicast/Makefile b/cinelerra-5.1/guicast/Makefile index d7d18f6a..bf859e39 100644 --- a/cinelerra-5.1/guicast/Makefile +++ b/cinelerra-5.1/guicast/Makefile @@ -113,6 +113,11 @@ OBJS = \ $(OBJDIR)/vframe3d.o \ $(OBJDIR)/vicon.o \ $(OBJDIR)/workarounds.o + + +ifeq ($(shell uname), Darwin) +OBJS += $(OBJDIR)/fmemopen.o +endif OUTPUT = $(OBJDIR)/libguicast.a -- 2.13.5 (Apple Git-94)
-- Cin mailing list [email protected] https://lists.cinelerra-gg.org/mailman/listinfo/cin

