From 51f9d474523f31d867e3da447931ac3a012f308a Mon Sep 17 00:00:00 2001
From: Andrew Randrianasulu <randrianasulu@gmail.com>
Date: Wed, 13 Apr 2022 17:50:17 +0300
Subject: [PATCH 2/2] Try to guard against compilation on non-termux

---
 cinelerra-5.1/libbthread-master/Android.mk    | 49 ---------
 .../libbthread-master/CMakeLists.txt          | 32 ------
 cinelerra-5.1/libbthread-master/Makefile      |  4 +-
 .../{just-pt.c => just-pt.cc}                 | 99 ++-----------------
 4 files changed, 11 insertions(+), 173 deletions(-)
 delete mode 100644 cinelerra-5.1/libbthread-master/Android.mk
 delete mode 100644 cinelerra-5.1/libbthread-master/CMakeLists.txt
 rename cinelerra-5.1/libbthread-master/{just-pt.c => just-pt.cc} (52%)

diff --git a/cinelerra-5.1/libbthread-master/Android.mk b/cinelerra-5.1/libbthread-master/Android.mk
deleted file mode 100644
index 1acfcdb4..00000000
--- a/cinelerra-5.1/libbthread-master/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-# Copyright (C) 2002 Free Software Foundation, Inc.
-# This file is part of the GNU C Library.
-#
-# The GNU C Library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Library General Public License as
-# published by the Free Software Foundation; either version 2 of the
-# License, or (at your option) any later version.
-#
-# The GNU C Library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-# Library General Public License for more details.
-#
-# You should have received a copy of the GNU Library General Public
-# License along with the GNU C Library; see the file COPYING.LIB.  If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-# Boston, MA 02111-1307, USA.
-
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:=\
-	pt-cancel.c\
-	pt-docancel.c\
-	pt-setcancelstate.c\
-	pt-setcanceltype.c\
-	pt-testcancel.c\
-	pt-init.c
-
-LOCAL_C_INCLUDES:=libbthread/
-	
-LOCAL_CFLAGS:= -ffunction-sections -fdata-sections
-
-LOCAL_MODULE:= libbthread
-
-include $(BUILD_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES:=\
-	pt-test.c
-	
-LOCAL_C_INCLUDES:=libbthread/
-
-LOCAL_CFLAGS:= -ffunction-sections -fdata-sections
-
-LOCAL_MODULE:= bthread_test
-
-include $(BUILD_EXECUTABLE)
diff --git a/cinelerra-5.1/libbthread-master/CMakeLists.txt b/cinelerra-5.1/libbthread-master/CMakeLists.txt
deleted file mode 100644
index 4d8987ad..00000000
--- a/cinelerra-5.1/libbthread-master/CMakeLists.txt
+++ /dev/null
@@ -1,32 +0,0 @@
-# Disable in-source builds to prevent source tree corruption.
-if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
-  message(FATAL_ERROR "FATAL: In-source builds are not allowed.
-       You should create a separate directory for build files.")
-endif()
-
-# Set minimum cmake version + cmake settings
-cmake_minimum_required (VERSION 3.9)
-cmake_policy(SET CMP0048 OLD)
-
-# Specify the project, and set the use of c++ and c
-project(cancelthread LANGUAGES CXX C)
-
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -fPIC -rdynamic -Wall -O2")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -rdynamic -Wall -O2 -std=c++11 ")
-
-include_directories(${PROJECT_SOURCE_DIR})
-
-set(pt-cancel pt-cancel.c)
-set(pt-docancel pt-docancel.c)
-set(pt-init pt-init.c)
-set(pt-setcancelstate pt-setcancelstate.c)
-set(pt-setcanceltype pt-setcanceltype.c)
-set(pt-test pt-test.c)
-set(pt-testcancel pt-testcancel.c)
-
-
-# Build a static lib
-add_library(cancelthread STATIC ${pt-cancel} ${pt-docancel} ${pt-init} ${pt-setcancelstate} ${pt-setcanceltype} ${pt-test} ${pt-testcancel})
-
-
-target_link_libraries(cancelthread -lz -ldl -lm -lpthread)
diff --git a/cinelerra-5.1/libbthread-master/Makefile b/cinelerra-5.1/libbthread-master/Makefile
index a91f5279..87dadc0c 100644
--- a/cinelerra-5.1/libbthread-master/Makefile
+++ b/cinelerra-5.1/libbthread-master/Makefile
@@ -2,8 +2,8 @@ PLATFORM = $(uname -o)
 ifneq ($(PLATFORM),Android)
 all:
 #	mv pt-test.c pt-test
-	cat `ls *.c` > just-pt.c
-	g++ -c -o jpt.o just-pt.c -I.
+#	cat `ls *.c` > just-pt.c
+	g++ -c -o jpt.o just-pt.cc -I.
 	ar crs jpt.a jpt.o
 clean:
 	rm -f *.a *.o
diff --git a/cinelerra-5.1/libbthread-master/just-pt.c b/cinelerra-5.1/libbthread-master/just-pt.cc
similarity index 52%
rename from cinelerra-5.1/libbthread-master/just-pt.c
rename to cinelerra-5.1/libbthread-master/just-pt.cc
index 3f3a959c..e53d7c21 100644
--- a/cinelerra-5.1/libbthread-master/just-pt.c
+++ b/cinelerra-5.1/libbthread-master/just-pt.cc
@@ -16,6 +16,8 @@
    License along with the GNU C Library; see the file COPYING.LIB.  If not,
    write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    Boston, MA 02111-1307, USA.  */
+#include <stdio.h>
+#if defined(__TERMUX__)
 
 #include <pthread.h>
 
@@ -55,24 +57,8 @@ pthread_cancel (pthread_t t)
 	}
 
   return err;
-}/* Cancel a thread.
-   Copyright (C) 2002, 2007, 2008 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+}
+/* Cancel a thread. */
 
 #include <pthread.h>
 
@@ -97,24 +83,7 @@ __pthread_do_cancel (struct pthread_internal_t *p)
 
   return 0;
 }
-/* Init a thread.
-   Copyright (C) 2002 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+/* Init a thread. */
 
 #include <pthread.h>
 #include <bthread.h>
@@ -142,24 +111,7 @@ void pthread_init(void) {
 	
 	sigaction(SIGRTMIN, &sa, NULL);
 }
-/* Set the cancel state for the calling thread.
-   Copyright (C) 2002 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+/* Set the cancel state for the calling thread.  */
 
 #include <pthread.h>
 #include <bthread.h>
@@ -199,24 +151,7 @@ pthread_setcancelstate (int state, int *oldstate)
 	
   return 0;
 }
-/* Set the cancel type for the calling thread.
-   Copyright (C) 2002 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+/*   */
 
 #include <pthread.h>
 #include <bthread.h>
@@ -256,24 +191,7 @@ pthread_setcanceltype (int type, int *oldtype)
 	
   return 0;
 }
-/* Add an explicit cancelation point.
-   Copyright (C) 2002 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+/* Add an explicit cancelation point.  */
 
 #include <pthread.h>
 #include <bthread.h>
@@ -295,3 +213,4 @@ pthread_testcancel (void)
     pthread_exit (PTHREAD_CANCELED);
 		
 }
+#endif
\ No newline at end of file
-- 
2.35.2

