diff --git a/build-scripts/v4l-utils.build b/build-scripts/v4l-utils.build index a4e0dea..7a54b7b 100644 --- a/build-scripts/v4l-utils.build +++ b/build-scripts/v4l-utils.build @@ -7,27 +7,39 @@ # $PKGS = Directory to store built packages # # DEPS -# Required: LLVM +# Required: LLVM argp-standalone # Recommended: alsa-lib, GLU, libjpeg-turbo, and Qt # Optional: Doxygen, SDL2 +# NOTE: version 1.24.1 will not compile, due to redefinitions +# in source + # If optimizing with GCC: export CFLAGS="-march=native -pipe " export CFLAGS+="-O3 -ffat-lto-objects -flto=4 " export CXXFLAGS=$CFLAGS export LDFLAGS="-flto=4 -Wl,-O2 -Wl,--as-needed " -#patch -Np1 -i ../patches/v4l-utils-alpine/getsubopt.patch -patch -Np1 -i ../patches/v4l-utils-alpine/types.patch -export CFLAGS="$CFLAGS -D__off_t=off_t" && +# Apply patch from Chimera Linux +patch -Np1 -i ../patches/v4l-utils-chimera/musl.patch + +# If using libc++ instead of GNU's libstdc++, apply this patch +# from Chimera Linux +patch -Np1 -i ../patches/v4l-utils-chimera/libcpp.patch + +autoreconf -vfi + +export CFLAGS="$CFLAGS -D__off_t=off_t -D__off64_t=off_t -fcommon" && export LIBS="-largp -lintl" && ./configure --prefix=/usr \ --sysconfdir=/etc \ --disable-static \ - --enable-libdvbv5 $BUILDTRUPLE && + --enable-libdvbv5 \ + --disable-qv4l2 \ + --with-udevdir=/usr/lib/udev $BUILDTRUPLE && read -p "Compile?" && make -j2 && -sudo -S make DESTDIR=$BUILD install && +sudo -S make DESTDIR=$BUILD install && unset CFLAGS LIBS && sudo -S mkdir -vp /BMAN/install && \ sudo -S mkdir -pv /BMAN/usr/share && \ @@ -56,7 +68,7 @@ v4l-utils: Homepage: http://linuxtv.org v4l-utils: EOF sudo -S mv -v /tmp/slack-desc install/ && -sudo -S makepkg -l y -c n $PKGS/v4l-utils-1.22.1-$(uname -m)-mlfs.txz && +sudo -S makepkg -l y -c n $PKGS/v4l-utils-1.22.1-$PSUFFIX && cd /BMAN cat > /tmp/slack-desc << "EOF" v4l-utils-doc: Manuals for v4l-utils (libraries and utilities for video4linux) @@ -72,6 +84,6 @@ v4l-utils-doc: http://linuxtv.org v4l-utils-doc: EOF sudo -S mv -v /tmp/slack-desc install/ && -sudo -S makepkg -l y -c n $PKGS/v4l-utils-doc-1.22.1-noarch-mlfs.txz +sudo -S makepkg -l y -c n $PKGS/v4l-utils-doc-1.22.1-$NOPSUFFIX sudo -S rm -rf /BMAN/* sudo -S rm -rf ${BUILD}/* diff --git a/patches/v4l-utils-alpine/getsubopt.patch b/patches/v4l-utils-alpine/getsubopt.patch deleted file mode 100644 index 8ac87a8..0000000 --- a/patches/v4l-utils-alpine/getsubopt.patch +++ /dev/null @@ -1,33 +0,0 @@ -POSIX says that behavior when subopts list is empty is undefined. -musl libs will set value to NULL which leads to crash. - -Simply avoid getsubopt, since we cannot rely on it. - ---- a/utils/v4l2-ctl/v4l2-ctl-common.cpp -+++ b/utils/v4l2-ctl/v4l2-ctl-common.cpp -@@ -782,15 +782,17 @@ - - static bool parse_next_subopt(char **subs, char **value) - { -- static char *const subopts[] = { -- NULL -- }; -- int opt = getsubopt(subs, subopts, value); -+ char *p = *subs; -+ *value = *subs; - -- if (opt < 0 || *value) -- return false; -- fprintf(stderr, "Missing suboption value\n"); -- return true; -+ while (*p && *p != ',') -+ p++; -+ -+ if (*p) -+ *p++ = '\0'; -+ -+ *subs = p; -+ return false; - } - - void common_cmd(const std::string &media_bus_info, int ch, char *optarg) diff --git a/patches/v4l-utils-alpine/types.patch b/patches/v4l-utils-alpine/types.patch deleted file mode 100644 index 340bb81..0000000 --- a/patches/v4l-utils-alpine/types.patch +++ /dev/null @@ -1,26 +0,0 @@ ---- a/utils/keytable/keymap.h -+++ b/utils/keytable/keymap.h -@@ -2,6 +2,10 @@ - #ifndef __KEYMAP_H - #define __KEYMAP_H - -+#include -+typedef uint32_t u_int32_t; -+typedef int error_t; -+ - struct keymap { - struct keymap *next; - char *name; ---- a/utils/ir-ctl/keymap.h -+++ b/utils/ir-ctl/keymap.h -@@ -2,6 +2,10 @@ - #ifndef __KEYMAP_H - #define __KEYMAP_H - -+#include -+typedef uint32_t u_int32_t; -+typedef int error_t; -+ - struct keymap { - struct keymap *next; - char *name; diff --git a/patches/v4l-utils-chimera/libcpp.patch b/patches/v4l-utils-chimera/libcpp.patch new file mode 100644 index 0000000..9dc9898 --- /dev/null +++ b/patches/v4l-utils-chimera/libcpp.patch @@ -0,0 +1,260 @@ +From 870abdc5c7dbb3327a926529ea6e0048237b2036 Mon Sep 17 00:00:00 2001 +From: Daniel Kolesa +Date: Tue, 7 Dec 2021 01:43:04 +0100 +Subject: [PATCH] fix a bunch of fallthrough bullshit + +this code conflicts with libc++ by defining fallthrough keyword +as macro and everything messes up +--- + include/compiler.h | 17 ----------------- + utils/cec-compliance/cec-test-audio.cpp | 2 ++ + utils/cec-ctl/cec-ctl.cpp | 2 ++ + utils/cec-follower/cec-follower.cpp | 2 ++ + utils/cec-follower/cec-processing.cpp | 2 ++ + utils/cec-follower/cec-tuner.cpp | 2 ++ + utils/common/v4l2-tpg-core.c | 2 ++ + utils/libcecutil/cec-log.cpp | 2 ++ + utils/qv4l2/v4l2-tpg-core.c | 2 ++ + utils/qvidcap/v4l2-tpg-core.c | 2 ++ + utils/v4l2-compliance/v4l2-test-colors.cpp | 2 ++ + utils/v4l2-compliance/v4l2-test-controls.cpp | 2 ++ + utils/v4l2-compliance/v4l2-test-formats.cpp | 2 ++ + utils/v4l2-ctl/v4l2-ctl-edid.cpp | 2 ++ + utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 2 ++ + utils/v4l2-ctl/v4l2-ctl-vbi.cpp | 2 ++ + utils/v4l2-ctl/v4l2-tpg-core.c | 2 ++ + 17 files changed, 32 insertions(+), 17 deletions(-) + +diff --git a/include/compiler.h b/include/compiler.h +index 5ad54f4..e69de29 100644 +--- a/include/compiler.h ++++ b/include/compiler.h +@@ -1,17 +0,0 @@ +-#ifdef _LIBCPP_VERSION +-#define fallthrough _LIBCPP_FALLTHROUGH() +-#else +- +-#if __cplusplus >= 201103L +- +-#ifdef __clang__ +-#define fallthrough [[clang::fallthrough]] +-#else +-#define fallthrough [[gnu::fallthrough]] +-#endif // __clang__ +- +-#else +-#define fallthrough ((void)0) +- +-#endif // __cplusplus +-#endif // _LIBCPP_VERSION +diff --git a/utils/cec-compliance/cec-test-audio.cpp b/utils/cec-compliance/cec-test-audio.cpp +index 611f600..7d9d042 100644 +--- a/utils/cec-compliance/cec-test-audio.cpp ++++ b/utils/cec-compliance/cec-test-audio.cpp +@@ -13,6 +13,8 @@ + #include "cec-compliance.h" + #include "compiler.h" + ++#define fallthrough [[clang::fallthrough]] ++ + static std::string audio_format_code2s(__u8 format_code) + { + switch (format_code) { +diff --git a/utils/cec-ctl/cec-ctl.cpp b/utils/cec-ctl/cec-ctl.cpp +index 4bed81a..0cd1f02 100644 +--- a/utils/cec-ctl/cec-ctl.cpp ++++ b/utils/cec-ctl/cec-ctl.cpp +@@ -34,6 +34,8 @@ + #include "cec-ctl.h" + #include "compiler.h" + ++#define fallthrough [[clang::fallthrough]] ++ + static struct timespec start_monotonic; + static struct timeval start_timeofday; + static bool ignore_la[16]; +diff --git a/utils/cec-follower/cec-follower.cpp b/utils/cec-follower/cec-follower.cpp +index 0adf6ce..30e6386 100644 +--- a/utils/cec-follower/cec-follower.cpp ++++ b/utils/cec-follower/cec-follower.cpp +@@ -14,6 +14,8 @@ + #include "cec-follower.h" + #include "compiler.h" + ++#define fallthrough [[clang::fallthrough]] ++ + /* Short option list + + Please keep in alphabetical order. +diff --git a/utils/cec-follower/cec-processing.cpp b/utils/cec-follower/cec-processing.cpp +index 661cbf4..a51b621 100644 +--- a/utils/cec-follower/cec-processing.cpp ++++ b/utils/cec-follower/cec-processing.cpp +@@ -13,6 +13,8 @@ + #include "cec-follower.h" + #include "compiler.h" + ++#define fallthrough [[clang::fallthrough]] ++ + #define VOLUME_MAX 0x64 + #define VOLUME_MIN 0 + +diff --git a/utils/cec-follower/cec-tuner.cpp b/utils/cec-follower/cec-tuner.cpp +index a2cb6ca..ae7fd6e 100644 +--- a/utils/cec-follower/cec-tuner.cpp ++++ b/utils/cec-follower/cec-tuner.cpp +@@ -11,6 +11,8 @@ + #include "cec-follower.h" + #include "compiler.h" + ++#define fallthrough [[clang::fallthrough]] ++ + #define NUM_ANALOG_FREQS 3 + #define NUM_DIGITAL_CHANS 3 + #define TOT_ANALOG_FREQS analog_freqs_khz[0][0].size() +diff --git a/utils/common/v4l2-tpg-core.c b/utils/common/v4l2-tpg-core.c +index f0090ed..ad43426 100644 +--- a/utils/common/v4l2-tpg-core.c ++++ b/utils/common/v4l2-tpg-core.c +@@ -11,6 +11,8 @@ + #include "compiler.h" + #include "v4l2-tpg-colors.h" + ++#define fallthrough [[clang::fallthrough]] ++ + /* Must remain in sync with enum tpg_pattern */ + const char * const tpg_pattern_strings[] = { + "75% Colorbar", +diff --git a/utils/libcecutil/cec-log.cpp b/utils/libcecutil/cec-log.cpp +index 0ee63de..3b176e2 100644 +--- a/utils/libcecutil/cec-log.cpp ++++ b/utils/libcecutil/cec-log.cpp +@@ -14,6 +14,8 @@ + #include "cec-log.h" + #include "compiler.h" + ++#define fallthrough [[clang::fallthrough]] ++ + static const struct cec_arg arg_u8 = { + CEC_ARG_TYPE_U8, + }; +diff --git a/utils/qv4l2/v4l2-tpg-core.c b/utils/qv4l2/v4l2-tpg-core.c +index f0090ed..ad43426 100644 +--- a/utils/qv4l2/v4l2-tpg-core.c ++++ b/utils/qv4l2/v4l2-tpg-core.c +@@ -11,6 +11,8 @@ + #include "compiler.h" + #include "v4l2-tpg-colors.h" + ++#define fallthrough [[clang::fallthrough]] ++ + /* Must remain in sync with enum tpg_pattern */ + const char * const tpg_pattern_strings[] = { + "75% Colorbar", +diff --git a/utils/qvidcap/v4l2-tpg-core.c b/utils/qvidcap/v4l2-tpg-core.c +index f0090ed..ad43426 100644 +--- a/utils/qvidcap/v4l2-tpg-core.c ++++ b/utils/qvidcap/v4l2-tpg-core.c +@@ -11,6 +11,8 @@ + #include "compiler.h" + #include "v4l2-tpg-colors.h" + ++#define fallthrough [[clang::fallthrough]] ++ + /* Must remain in sync with enum tpg_pattern */ + const char * const tpg_pattern_strings[] = { + "75% Colorbar", +diff --git a/utils/v4l2-compliance/v4l2-test-colors.cpp b/utils/v4l2-compliance/v4l2-test-colors.cpp +index 887b2fd..42ddb9a 100644 +--- a/utils/v4l2-compliance/v4l2-test-colors.cpp ++++ b/utils/v4l2-compliance/v4l2-test-colors.cpp +@@ -23,6 +23,8 @@ + #include "compiler.h" + #include "v4l2-compliance.h" + ++#define fallthrough [[clang::fallthrough]] ++ + static void setupPlanes(const cv4l_fmt &fmt, __u8 *planes[3]) + { + if (fmt.g_num_planes() > 1) +diff --git a/utils/v4l2-compliance/v4l2-test-controls.cpp b/utils/v4l2-compliance/v4l2-test-controls.cpp +index 22e8dec..e456cc3 100644 +--- a/utils/v4l2-compliance/v4l2-test-controls.cpp ++++ b/utils/v4l2-compliance/v4l2-test-controls.cpp +@@ -29,6 +29,8 @@ + #include "compiler.h" + #include "v4l2-compliance.h" + ++#define fallthrough [[clang::fallthrough]] ++ + static int checkQCtrl(struct node *node, struct test_query_ext_ctrl &qctrl) + { + struct v4l2_querymenu qmenu; +diff --git a/utils/v4l2-compliance/v4l2-test-formats.cpp b/utils/v4l2-compliance/v4l2-test-formats.cpp +index 3761b1f..de04136 100644 +--- a/utils/v4l2-compliance/v4l2-test-formats.cpp ++++ b/utils/v4l2-compliance/v4l2-test-formats.cpp +@@ -27,6 +27,8 @@ + #include "compiler.h" + #include "v4l2-compliance.h" + ++#define fallthrough [[clang::fallthrough]] ++ + static constexpr __u32 buftype2cap[] = { + 0, + V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_M2M, +diff --git a/utils/v4l2-ctl/v4l2-ctl-edid.cpp b/utils/v4l2-ctl/v4l2-ctl-edid.cpp +index c3a4a28..e7a5406 100644 +--- a/utils/v4l2-ctl/v4l2-ctl-edid.cpp ++++ b/utils/v4l2-ctl/v4l2-ctl-edid.cpp +@@ -6,6 +6,8 @@ + #include "compiler.h" + #include "v4l2-ctl.h" + ++#define fallthrough [[clang::fallthrough]] ++ + /* + * The 24-bit IEEE Registration Identifier for the HDMI-LLC Vendor + * Specific Data Block. +diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +index 7e24e0e..732412c 100644 +--- a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp ++++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp +@@ -14,6 +14,8 @@ extern "C" { + #include "v4l2-tpg.h" + } + ++#define fallthrough [[clang::fallthrough]] ++ + static unsigned stream_count; + static unsigned stream_skip; + static __u32 memory = V4L2_MEMORY_MMAP; +diff --git a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp +index dc7b428..4a49d52 100644 +--- a/utils/v4l2-ctl/v4l2-ctl-vbi.cpp ++++ b/utils/v4l2-ctl/v4l2-ctl-vbi.cpp +@@ -3,6 +3,8 @@ + #include "compiler.h" + #include "v4l2-ctl.h" + ++#define fallthrough [[clang::fallthrough]] ++ + static struct v4l2_format sliced_fmt; /* set_format/get_format for sliced VBI */ + static struct v4l2_format sliced_fmt_out; /* set_format/get_format for sliced VBI output */ + static struct v4l2_format raw_fmt; /* set_format/get_format for VBI */ +diff --git a/utils/v4l2-ctl/v4l2-tpg-core.c b/utils/v4l2-ctl/v4l2-tpg-core.c +index f0090ed..800032a 100644 +--- a/utils/v4l2-ctl/v4l2-tpg-core.c ++++ b/utils/v4l2-ctl/v4l2-tpg-core.c +@@ -11,6 +11,8 @@ + #include "compiler.h" + #include "v4l2-tpg-colors.h" + ++#define fallthrough ((void)0) ++ + /* Must remain in sync with enum tpg_pattern */ + const char * const tpg_pattern_strings[] = { + "75% Colorbar", +-- +2.34.1 + diff --git a/patches/v4l-utils-chimera/musl.patch b/patches/v4l-utils-chimera/musl.patch new file mode 100644 index 0000000..80702f8 --- /dev/null +++ b/patches/v4l-utils-chimera/musl.patch @@ -0,0 +1,46 @@ +--- a/utils/ir-ctl/ir-ctl.c 2017-01-25 17:27:44.373665101 +0000 ++++ b/utils/ir-ctl/ir-ctl.c 2017-01-25 17:27:51.052665445 +0000 +@@ -44,6 +44,24 @@ + + # define N_(string) string + ++#ifndef TEMP_FAILURE_RETRY ++#define TEMP_FAILURE_RETRY(expression) \ ++ (__extension__ \ ++ ({ long int __result; \ ++ do __result = (long int) (expression); \ ++ while (__result == -1L && errno == EINTR); \ ++ __result; })) ++#endif ++ ++#ifndef strndupa ++#define strndupa(s, n) \ ++ (__extension__ ({const char *__in = (s); \ ++ size_t __len = strnlen (__in, (n)) + 1; \ ++ char *__out = (char *) alloca (__len); \ ++ __out[__len-1] = '\0'; \ ++ (char *) memcpy (__out, __in, __len-1);})) ++#endif ++ + + /* See drivers/media/rc/ir-lirc-codec.c line 23 */ + #define LIRCBUF_SIZE 512 +--- a/lib/libdvbv5/dvb-dev-local.c ++++ b/lib/libdvbv5/dvb-dev-local.c +@@ -60,6 +60,16 @@ struct dvb_dev_local_priv { + void *user_priv; + }; + ++/* taken from glibc unistd.h and fixes musl */ ++#ifndef TEMP_FAILURE_RETRY ++#define TEMP_FAILURE_RETRY(expression) \ ++ (__extension__ \ ++ ({ long int __result; \ ++ do __result = (long int) (expression); \ ++ while (__result == -1L && errno == EINTR); \ ++ __result; })) ++#endif ++ + static int handle_device_change(struct dvb_device_priv *dvb, + struct udev_device *dev, + const char *syspath,