[Cin] Compiling Cingg on termux (Linux userspace for Android devices)

Andrew Randrianasulu randrianasulu at gmail.com
Thu May 6 02:12:45 CEST 2021


Hello all!
So,  because I only have this tablet:

$ termux-info Packages CPU architecture: arm
 Subscribed repositories: # sources.list deb https://ipfs.io/ipns/
k51qzi5uqu5dg9vawh923wejqffxiu9bhqlze5f508msk0h7ylpac27fdgaskx stable main
 # science-repo (sources.list.d/science.list) deb
https://grimler.se/science-packages-24 science stable
 # game-repo (sources.list.d/game.list) deb https://grimler.se/game-
packages-24 games stable
 # x11-repo (sources.list.d/x11.list) deb https://termux.com/x11-
packages-bin x11 main
 Updatable packages: All packages up to date
 Android version: 10
 Kernel build information: Linux localhost 4.14.141+ #1 SMP PREEMPT Mon Mar
29 18:09:45 CST 2021 armv8l
Android Device manufacturer: HUAWEI
 Device model: KOB2-L09

I tried to do my best and compile Cingg on *that*
Of course my attempt failed So far, but at least buildsystem  unpack
sources correctly and start to build them.

I installed termux from so-called AppGallery (but termux actually exist for
F-droid, libre/oss repo independent from Google play), and updated it,
after installing few utilites and editing source list (it uses apt, like
debian, while you can call it as 'pkg search blah, pkg install meh')
because since mid-2020 they changed their way Of hosting binaries

More about termux :

https://github.com/termux/termux-app
Works on Android 7+, provides  X via Xsdl or vnc
Does not require root priviledges on device

In theory you can try to install more compatible arm distro but this Will
eat more space So I tried Hard way!

Packages with development files have '-static' added to their name.
So, I tried to call configure in Cingg source tree with suitable argument.

generated by GNU Autoconf 2.71. Invocation command line was

 $ ./configure --with-single-user --with-thirdparty --enable-static-build
--without-vaapi --without-vdpau --without-shuttle_usb --without-libzmpeg
--without-lv2 --with-clang

device uses clang-12 currently (!)

I tried to update configure.ac based on result of 'autoscan' invokation, it
makes configure phase longer but more verbose.

But main show breaker was difference between /bin/sh and bin/bash (with
long termux path)
Default was sh and it was barking at += statements in configure.ac like
those

CFG_CFLAGS+=" -pthread -Wall"
# misguided pedantic warnings
# this is extra work, not a gain...
CFG_CFLAGS+=" -Wno-unknown-warning-option"
CFG_CFLAGS+=" -Wno-attributes"
CFG_CFLAGS+=" -Wno-unused-result"
CFG_CFLAGS+=" -Wno-stringop-overflow"
CFG_CFLAGS+=" -Wno-format-truncation"
CFG_CFLAGS+=" -Wno-format-overflow"
CFG_CFLAGS+=" -Wno-parentheses"
CFG_CFLAGS+=" -Wno-stringop-truncation"
CFG_CFLAGS+=" -D__STDC_CONSTANT_MACROS"
CFG_CFLAGS+=" -D__STDC_LIMIT_MACROS"

And as result configure was half-broken, failed to make thirdparty.. :/

But by changing configure's first line manually to

#! /data/data/com.termux/files/usr/bin/bash

I overcome this error!

Of course with less than 700 mb free out of 16 gb flash 'disk' (I have few
huge navigator apps and Android was weighting 9 gb from very start!) build
in thirdparty failed, and guicast/cinelerra dirs had their own problems
related to missing shared mem support (!) and other problems  but at least
it started

See my hacks attached

Be aware about limited number of write cycles when it comes to flash
memory! Big compiles can degrade internal storage prety quickly, I am afraid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20210506/8d9ac9c3/attachment.htm>
-------------- next part --------------
diff --git a/cinelerra-5.1/cinelerra/ffmpeg.C b/cinelerra-5.1/cinelerra/ffmpeg.C
index df39763c..786ca723 100644
--- a/cinelerra-5.1/cinelerra/ffmpeg.C
+++ b/cinelerra-5.1/cinelerra/ffmpeg.C
@@ -404,7 +404,7 @@ int FFStream::decode_activate()
 		}
 		while( ret >= 0 && st != 0 && !reading ) {
 			AVCodecID codec_id = st->codecpar->codec_id;
-			AVCodec *decoder = 0;
+			const AVCodec *decoder = 0;
 			if( is_video() ) {
 				if( ffmpeg->opt_video_decoder )
 					decoder = avcodec_find_decoder_by_name(ffmpeg->opt_video_decoder);
@@ -1243,6 +1243,7 @@ int FFVideoStream::probe(int64_t pos)
 		ret = -1;
 
 	ret = ret > 0 ? 1 : ret < 0 ? -1 : 0;
+	av_frame_free(&frame);
 	return ret;
 }
 
@@ -2089,7 +2090,7 @@ void FFMPEG::scan_audio_options(Asset *asset, EDL *edl)
 		cin_fmt = (int)av_get_sample_fmt(cin_sample_fmt);
 	if( cin_fmt < 0 ) {
 		char audio_codec[BCSTRLEN]; audio_codec[0] = 0;
-		AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", asset->acodec) ?
+		const AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", asset->acodec) ?
 			avcodec_find_encoder_by_name(audio_codec) : 0;
 		if( av_codec && av_codec->sample_fmts )
 			cin_fmt = find_best_sample_fmt_of_list(av_codec->sample_fmts, AV_SAMPLE_FMT_FLT);
@@ -2125,7 +2126,7 @@ void FFMPEG::scan_video_options(Asset *asset, EDL *edl)
 			cin_fmt = (int)av_get_pix_fmt(cin_pix_fmt);
 	if( cin_fmt < 0 ) {
 		char video_codec[BCSTRLEN];  video_codec[0] = 0;
-		AVCodec *av_codec = !get_codec(video_codec, "video", asset->vcodec) ?
+		const AVCodec *av_codec = !get_codec(video_codec, "video", asset->vcodec) ?
 			avcodec_find_encoder_by_name(video_codec) : 0;
 		if( av_codec && av_codec->pix_fmts ) {
 			if( 0 && edl ) { // frequently picks a bad answer
@@ -2322,7 +2323,7 @@ int FFCodecRemaps::add(const char *val)
 
 int FFCodecRemaps::update(AVCodecID &codec_id, AVCodec *&decoder)
 {
-	AVCodec *codec = avcodec_find_decoder(codec_id);
+	const AVCodec *codec = avcodec_find_decoder(codec_id);
 	if( !codec ) return -1;
 	const char *name = codec->name;
 	FFCodecRemaps &map = *this;
@@ -2542,7 +2543,7 @@ int FFMPEG::init_decoder(const char *filename)
 	char *sp = strrchr(bp, '.');
 	if( !sp ) sp = bp + strlen(bp);
 	FILE *fp = 0;
-	AVInputFormat *ifmt = 0;
+	const AVInputFormat *ifmt = 0;
 	if( sp ) {
 		strcpy(sp, ".opts");
 		fp = fopen(file_opts, "r");
@@ -2759,7 +2760,7 @@ int FFMPEG::open_encoder(const char *type, const char *spec)
 	AVCodecContext *ctx = 0;
 
 	const AVCodecDescriptor *codec_desc = 0;
-	AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
+	const AVCodec *codec = avcodec_find_encoder_by_name(codec_name);
 	if( !codec ) {
 		eprintf(_("cant find codec %s:%s\n"), codec_name, filename);
 		ret = 1;
@@ -3651,7 +3652,7 @@ Preferences *FFMPEG::ff_prefs()
 double FFVideoStream::get_rotation_angle()
 {
 	int size = 0;
-	int *matrix = (int*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, &size);
+	uint32_t  *matrix = (uint32_t*)av_stream_get_side_data(st, AV_PKT_DATA_DISPLAYMATRIX, &size);
 	int len = size/sizeof(*matrix);
 	if( !matrix || len < 5 ) return 0;
 	const double s = 1/65536.;
@@ -3875,7 +3876,7 @@ AVCodecContext *FFMPEG::activate_decoder(AVStream *st)
 	AVDictionary *copts = 0;
 	av_dict_copy(&copts, opts, 0);
 	AVCodecID codec_id = st->codecpar->codec_id;
-	AVCodec *decoder = 0;
+	const AVCodec *decoder = 0;
 	switch( st->codecpar->codec_type ) {
 	case AVMEDIA_TYPE_VIDEO:
 		if( opt_video_decoder )
diff --git a/cinelerra-5.1/cinelerra/fileffmpeg.C b/cinelerra-5.1/cinelerra/fileffmpeg.C
index a71d692a..853e5839 100644
--- a/cinelerra-5.1/cinelerra/fileffmpeg.C
+++ b/cinelerra-5.1/cinelerra/fileffmpeg.C
@@ -159,7 +159,7 @@ void FFMpegPixelFormat::update_formats()
 	pixfmts.remove_all_objects();
 	char video_codec[BCSTRLEN]; video_codec[0] = 0;
 	const char *vcodec = vid_config->asset->vcodec;
-	AVCodec *av_codec = !FFMPEG::get_codec(video_codec, "video", vcodec) ?
+	const AVCodec *av_codec = !FFMPEG::get_codec(video_codec, "video", vcodec) ?
 		avcodec_find_encoder_by_name(video_codec) : 0;
 	const AVPixelFormat *pix_fmts = av_codec ? av_codec->pix_fmts : 0;
 	if( pix_fmts ) {
@@ -190,7 +190,7 @@ void FFMpegSampleFormat::update_formats()
 	samplefmts.remove_all_objects();
 	char audio_codec[BCSTRLEN]; audio_codec[0] = 0;
 	const char *acodec = aud_config->asset->acodec;
-	AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", acodec) ?
+	const AVCodec *av_codec = !FFMPEG::get_codec(audio_codec, "audio", acodec) ?
 		avcodec_find_encoder_by_name(audio_codec) : 0;
 	const AVSampleFormat *sample_fmts = av_codec ? av_codec->sample_fmts : 0;
 	if( sample_fmts ) {
@@ -345,7 +345,7 @@ int FileFFMPEG::open_file(int rd, int wr)
 				asset->aspect_ratio = ff->ff_aspect_ratio(0);
 				if (!asset->interlace_mode) asset->interlace_mode = ff->ff_interlace(0);
 				if ( ff->ff_video_frames(0) > 1 ) {
-//				ff->video_probe(1);
+				ff->video_probe(1);
 				 if (!asset->interlace_mode && (ff->interlace_from_codec) ) asset->interlace_mode = ff->video_probe(1); 
 				}
 				if( !asset->layers ) asset->layers = video_layers;
@@ -1844,7 +1844,7 @@ int FFOptionsViewAudio::handle_event()
 	const char *name = asset->acodec;
 	char audio_format[BCSTRLEN];  audio_format[0] = 0;
 	char audio_codec[BCSTRLEN];   audio_codec[0] = 0;
-	AVCodec *codec = !ret &&
+	const AVCodec *codec = !ret &&
 	    !FFMPEG::get_format(audio_format, "audio", name) &&
 	    !FFMPEG::get_codec(audio_codec, "audio", name) ?
 		avcodec_find_encoder_by_name(audio_codec) : 0;
@@ -1882,7 +1882,7 @@ int FFOptionsViewVideo::handle_event()
 	const char *name = asset->vcodec;
 	char video_format[BCSTRLEN];  video_format[0] = 0;
 	char video_codec[BCSTRLEN];   video_codec[0] = 0;
-	AVCodec *codec = !ret &&
+	const AVCodec *codec = !ret &&
 	    !FFMPEG::get_format(video_format, "video", name) &&
 	    !FFMPEG::get_codec(video_codec, "video", name) ?
 		avcodec_find_encoder_by_name(video_codec) : 0;
diff --git a/cinelerra-5.1/configure.ac b/cinelerra-5.1/configure.ac
index ceddac2a..9404d2fb 100644
--- a/cinelerra-5.1/configure.ac
+++ b/cinelerra-5.1/configure.ac
@@ -1,11 +1,11 @@
 
-AC_PREREQ([2.69])
-AC_INIT([cinelerra], [5.1], [mail at lists.cinelerra-gg.org])
+AC_PREREQ([2.71])
+AC_INIT([cinelerra],[5.1],[mail at lists.cinelerra-gg.org])
 AM_INIT_AUTOMAKE([foreign])
 
 AM_PROG_AS
-AC_LANG_CPLUSPLUS
-AC_LANG_C
+AC_LANG([C++])
+AC_LANG([C])
 AC_PROG_CXX
 
 CFG_CFLAGS+=" -fno-omit-frame-pointer -fno-math-errno -fno-signed-zeros"
@@ -24,14 +24,15 @@ 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"
+CFG_CFLAGS+=" -I/data/data/com.termux/files/usr/include/freetype2"
 CFG_CFLAGS+=" -I/usr/include/freetype2 -I/usr/local/include/freetype2"
 CFG_CFLAGS+=" -I/usr/include/uuid -I/usr/local/include/uuid"
 CFG_CFLAGS+=" -I/usr/include/mjpegtools -I/usr/local/include/mjpegtools"
 
 AC_DEFUN([CHECK_WITH], [
 AC_ARG_WITH([$1],
-  AC_HELP_STRING([--with-[$1]], [$2 ($4)]),
+  AS_HELP_STRING([--with-[$1]],[$2 ($4)]),
   [WANT_$3=$withval], [WANT_$3='$4'])
 AC_SUBST([WANT_$3])
 ])
@@ -64,6 +65,45 @@ CHECK_WITH([nv],[nvenc/nvdec ffnvcodec api],[NV],[yes])
 CHECK_WITH([cuda],[nv cuda plugins],[CUDA],[auto])
 CHECK_WITH([clang],[use clang instead of gcc/g++],[CLANG],[no])
 
+# Checks for header files.
+AC_PATH_X
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h fenv.h inttypes.h libintl.h malloc.h mntent.h netdb.h netinet/in.h stdint.h strings.h sys/file.h sys/ioctl.h sys/socket.h sys/statfs.h sys/time.h unistd.h utime.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_CHECK_HEADER_STDBOOL
+AC_C_INLINE
+AC_TYPE_INT16_T
+AC_TYPE_INT32_T
+AC_TYPE_INT64_T
+AC_TYPE_INT8_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_SSIZE_T
+AC_CHECK_MEMBERS([struct stat.st_blksize])
+AC_STRUCT_ST_BLOCKS
+AC_CHECK_MEMBERS([struct stat.st_rdev])
+AC_TYPE_UINT16_T
+AC_TYPE_UINT32_T
+AC_TYPE_UINT64_T
+AC_TYPE_UINT8_T
+
+# Checks for library functions.
+AC_FUNC_ALLOCA
+AC_FUNC_ERROR_AT_LINE
+AC_FUNC_FORK
+AC_FUNC_FSEEKO
+AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
+AC_FUNC_MALLOC
+AC_FUNC_MKTIME
+AC_FUNC_MMAP
+AC_FUNC_REALLOC
+AC_FUNC_STRERROR_R
+AC_FUNC_STRNLEN
+AC_FUNC_STRTOD
+AC_CHECK_FUNCS([atexit bzero dup2 endpwent floor ftruncate getcwd gethostbyname gettimeofday inet_ntoa localtime_r memmove memset mkdir mkfifo modf munmap nl_langinfo pow putenv realpath rint rmdir select setenv setlocale socket sqrt strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol strtoul tzset uname utime])
+
+
 if test "x$WANT_LV2" != "xno"; then
   GTK2_LIBS=`pkg-config --libs gtk+-2.0`
   AC_CHECK_LIB([m], [gtk_init], [HAVE_gtk=yes], [HAVE_gtk=no], [$GTK2_LIBS])
@@ -153,7 +193,7 @@ inc_$1="$4"
 
 AC_DEFUN([PKG_3RD],[
 AC_ARG_ENABLE([$1],
-  AC_HELP_STRING([--enable-$1],[build $1 ($2)]),
+  AS_HELP_STRING([--enable-$1],[build $1 ($2)]),
   [PKG_$1=$enableval], [PKG_$1=$2])
 PKG_DEF([$1],[$3],[$4],[$5])
 ])
@@ -432,7 +472,7 @@ AC_SUBST(STATIC_PKGS)
 
 AC_DEFUN([CHECK_ENABLE], [
 AC_ARG_ENABLE([$1],
-  AC_HELP_STRING([--enable-[$1]], [$3 ([$4])]),
+  AS_HELP_STRING([--enable-[$1]],[$3 ([$4])]),
   [WANT_$2=$enableval], [WANT_$2=[$4]])
 ])
 
@@ -615,7 +655,7 @@ AC_DEFUN([CHECK_WANT], [
 RESULT=yes
 # WANT_$1
 AC_ARG_WITH(m4_tolower([$1]),
- AC_HELP_STRING([m4_join([-],[--with],m4_tolower([$1]))], [$3] (auto)),
+ AS_HELP_STRING([m4_join([-],[--with],m4_tolower([$1]))],[$3 (auto)]),
   [WANT_$1=$withval],[WANT_$1=$2])
  m4_quote($4)
  if test "x$WANT_$1" = "xauto" ; then
@@ -821,14 +861,14 @@ HAVE_ilmbase=no \
 OBJDIR=`uname -m`
 AC_SUBST(OBJDIR)
 
-echo "AC_HELP_STRING([Reason],[Package])"
-echo "AC_HELP_STRING([------],[-------])"
+echo "AS_HELP_STRING([Reason],[Package])"
+echo "AS_HELP_STRING([------],[-------])"
 
 AC_DEFUN([PKG_DISABLED],[
  PKG_$1="no"
  BUILD_$1=0
  AC_SUBST(BUILD_$1)
- echo "AC_HELP_STRING([disabled],[$1])"
+ echo "AS_HELP_STRING([disabled],[$1])"
 ])
 AC_DEFUN([PKG_SHARED],[
  PKG_$1="shared"
@@ -843,7 +883,7 @@ AC_DEFUN([PKG_STATIC],[
   BUILD_$1=1
   AC_SUBST(BUILD_$1)
   STATIC_BLDS+=" [$1]"
-  echo "AC_HELP_STRING([$2],[$1])"
+  echo "AS_HELP_STRING([$2],[$1])"
  fi
 ])
 
@@ -937,11 +977,11 @@ fi
 
 AC_SUBST(STATIC_BLDS)
 for f in $SHARED_LIBS; do
-  echo "AC_HELP_STRING([shared],[$f])"
+  echo "AS_HELP_STRING([shared],[$f])"
 done
 AC_SUBST(SHARED_LIBS)
 for f in $SYSTEM_LIBS; do
-  echo "AC_HELP_STRING([system],[$f])"
+  echo "AS_HELP_STRING([system],[$f])"
 done
 AC_SUBST(SYSTEM_LIBS)
 
@@ -955,7 +995,7 @@ for v in GL XFT XXF86VM OSS ALSA FIREWIRE OGG DV DVB LADSPA \
 	 VAAPI VDPAU CUDA NV WINTV X10TV; do
   eval vv="\$WANT_$v"
   if test "x$vv" != "xno"; then
-    CFG_CFLAGS+=" -DHAVE_$v"
+    echo "CFG_CFLAGS+="-DHAVE_$v""
     vv=with
   else
     vv=without
diff --git a/cinelerra-5.1/guicast/bcresources.h b/cinelerra-5.1/guicast/bcresources.h
index 2b305f80..c3f85a35 100644
--- a/cinelerra-5.1/guicast/bcresources.h
+++ b/cinelerra-5.1/guicast/bcresources.h
@@ -39,6 +39,8 @@
 #include "vframe.inc"
 
 #include <X11/Xlib.h>
+#include <freetype/freetype.h>
+#include <fontconfig/fontconfig.h>
 
 typedef struct
 {
diff --git a/cinelerra-5.1/guicast/bcwindowbase.h b/cinelerra-5.1/guicast/bcwindowbase.h
index e4eb8ba4..8a034acd 100644
--- a/cinelerra-5.1/guicast/bcwindowbase.h
+++ b/cinelerra-5.1/guicast/bcwindowbase.h
@@ -97,6 +97,10 @@
 #include <GL/glx.h>
 #endif
 
+#include <freetype/freetype.h>
+#include <fontconfig/fontconfig.h>
+#include <X11/Xft/Xft.h>
+
 // scaled x,y unit
 #define xS(v) (BC_WindowBase::get_resources()->x_scale*(v))
 #define yS(v) (BC_WindowBase::get_resources()->y_scale*(v))
diff --git a/cinelerra-5.1/guicast/thread.h b/cinelerra-5.1/guicast/thread.h
index 79f3e713..bec2509d 100644
--- a/cinelerra-5.1/guicast/thread.h
+++ b/cinelerra-5.1/guicast/thread.h
@@ -29,13 +29,15 @@
 #ifndef NO_TID
 #include <sys/syscall.h>
 
+#if defined(__GLIBC__)
 // glibc >= 2.30 provides gettid() in unistd
 #if !defined(__GLIBC_PREREQ) || !__GLIBC_PREREQ(2, 30)
 static inline int gettid() { return syscall(SYS_gettid, 0, 0, 0); }
 #endif
 #else
-static inline long gettid() { return (long)pthread_self(); }
+//static inline long gettid() { return (long)pthread_self(); }
 #endif
+#endif // GLIBC
 
 // The thread does not autodelete by default.
 // If autodelete is 1 the thread autodeletes.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cingg_CFG
Type: application/octet-stream
Size: 450 bytes
Desc: not available
URL: <https://lists.cinelerra-gg.org/pipermail/cin/attachments/20210506/8d9ac9c3/attachment.obj>


More information about the Cin mailing list