Skip to content

Commit 7075f62

Browse files
authored
build(linux): Add -system-libs flag for package manager compatibility
2 parents 1ff3457 + 170d769 commit 7075f62

File tree

2 files changed

+67
-1
lines changed

2 files changed

+67
-1
lines changed

docs/CHANGES.TXT

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
0.96.2 (2025-12-26)
2+
-------------------
23
- Rebundle Windows version to include required runtime files to process hardcoded subtitles
34
(hardcodex mode).
5+
- New: Add optional -system-libs flag to Linux build script for package manager compatibility
46

57
0.96.1 (2025-12-25)
68
-------------------

linux/build

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
RUST_LIB="rust/release/libccx_rust.a"
44
RUST_PROFILE="--release"
5+
USE_SYSTEM_LIBS=false
56
while [[ $# -gt 0 ]]; do
67
case $1 in
78
-debug)
@@ -23,14 +24,60 @@ while [[ $# -gt 0 ]]; do
2324
BLD_LINKER="$BLD_LINKER -lswscale -lavutil -pthread -lavformat -lavcodec -lavfilter -lxcb-shm -lxcb -lX11 -llzma -lswresample"
2425
shift
2526
;;
27+
-system-libs)
28+
USE_SYSTEM_LIBS=true
29+
shift
30+
;;
2631
-*)
2732
echo "Unknown option $1"
2833
exit 1
2934
;;
3035
esac
3136
done
3237

33-
BLD_FLAGS="$BLD_FLAGS -std=gnu99 -Wno-write-strings -Wno-pointer-sign -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -DFT2_BUILD_LIBRARY -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP"
38+
if [ "$USE_SYSTEM_LIBS" = true ]; then
39+
command -v pkg-config >/dev/null || {
40+
echo "Error: pkg-config is required for -system-libs mode"
41+
exit 1
42+
}
43+
44+
MISSING=""
45+
for lib in libpng zlib freetype2 libutf8proc; do
46+
if ! pkg-config --exists "$lib" 2>/dev/null; then
47+
MISSING="$MISSING $lib"
48+
fi
49+
done
50+
51+
if [ -n "$MISSING" ]; then
52+
echo "Error: Missing required system libraries:$MISSING"
53+
echo ""
54+
echo "On Debian/Ubuntu: sudo apt install libpng-dev zlib1g-dev libfreetype-dev libutf8proc-dev"
55+
exit 1
56+
fi
57+
58+
for hdr in leptonica/allheaders.h tesseract/capi.h; do
59+
if ! echo "#include <$hdr>" | gcc -E - >/dev/null 2>&1; then
60+
echo "Error: Missing headers for <$hdr>"
61+
echo "On Debian/Ubuntu: sudo apt install libleptonica-dev libtesseract-dev"
62+
exit 1
63+
fi
64+
done
65+
66+
PKG_CFLAGS="$(pkg-config --cflags libpng zlib freetype2 libutf8proc)"
67+
PKG_LIBS="$(pkg-config --libs libpng zlib freetype2 libutf8proc)"
68+
69+
UTF8PROC_COMPAT=""
70+
if [ ! -d /usr/include/utf8proc ] && [ -f /usr/include/utf8proc.h ]; then
71+
mkdir -p ./utf8proc_compat/utf8proc
72+
ln -sf /usr/include/utf8proc.h ./utf8proc_compat/utf8proc/utf8proc.h
73+
UTF8PROC_COMPAT="-I./utf8proc_compat"
74+
fi
75+
fi
76+
77+
BLD_FLAGS="$BLD_FLAGS -std=gnu99 -Wno-write-strings -Wno-pointer-sign -D_FILE_OFFSET_BITS=64 -DVERSION_FILE_PRESENT -DENABLE_OCR -DGPAC_DISABLE_VTT -DGPAC_DISABLE_OD_DUMP -DGPAC_DISABLE_REMOTERY -DNO_GZIP"
78+
if [ "$USE_SYSTEM_LIBS" != true ]; then
79+
BLD_FLAGS="$BLD_FLAGS -DFT2_BUILD_LIBRARY"
80+
fi
3481
bit_os=$(getconf LONG_BIT)
3582
if [ "$bit_os" == "64" ]
3683
then
@@ -87,6 +134,19 @@ SRC_FREETYPE="../src/thirdparty/freetype/autofit/autofit.c
87134
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_GPAC $SRC_ZLIB $SRC_LIBPNG $SRC_HASH $SRC_UTF8PROC $SRC_FREETYPE"
88135
BLD_LINKER="$BLD_LINKER -lm -zmuldefs -l tesseract -l leptonica -lpthread -ldl -lgpac"
89136

137+
if [ "$USE_SYSTEM_LIBS" = true ]; then
138+
LEPTONICA_CFLAGS="$(pkg-config --cflags --silence-errors lept)"
139+
TESSERACT_CFLAGS="$(pkg-config --cflags --silence-errors tesseract)"
140+
GPAC_CFLAGS="$(pkg-config --cflags --silence-errors gpac)"
141+
142+
BLD_INCLUDE="-I../src -I../src/lib_ccx -I../src/lib_ccx/zvbi -I../src/thirdparty/lib_hash \
143+
$UTF8PROC_COMPAT $PKG_CFLAGS $LEPTONICA_CFLAGS $TESSERACT_CFLAGS $GPAC_CFLAGS"
144+
145+
BLD_SOURCES="../src/ccextractor.c $SRC_CCX $SRC_HASH"
146+
BLD_LINKER="$PKG_LIBS -ltesseract -lleptonica -lgpac -lpthread -ldl -lm"
147+
fi
148+
149+
90150
echo "Running pre-build script..."
91151
./pre-build.sh
92152
echo "Trying to compile..."
@@ -149,3 +209,7 @@ if [[ "$out" != "" ]] ; then
149209
else
150210
echo "Compilation successful, no compiler messages."
151211
fi
212+
213+
if [ -d ./utf8proc_compat ]; then
214+
rm -rf ./utf8proc_compat
215+
fi

0 commit comments

Comments
 (0)