@@ -186,63 +186,101 @@ in the right folder in the previous step.
186186
187187You can remove the general purge by remove the ``rm -rf * `` if everythings behaves as it should.
188188
189+ **build-llvm.sh **:
189190::
190191
191192 #!/bin/bash
192-
193+
193194 # Source the configuration script (sets LLVM_CMAKE_PREFIX_PATH)
194195 source ./config.sh
195-
196- # 1. AUTOMATICALLY EXTRACT MAJOR LLVM VERSION (FIXED)
196+
197+ # 1. AUTOMATICALLY EXTRACT MAJOR LLVM VERSION
197198 # Uses the known working '--version' output and cuts out the major number (e.g., '19').
198199 LLVM_MAJOR_VERSION=$(llvm-config --version | cut -d. -f1 2>/dev/null)
199-
200+
200201 if [ -z "$LLVM_MAJOR_VERSION" ]; then
201202 echo "Fatal Error: Could not determine LLVM major version. Please run 'llvm-config --version' manually to verify installation."
202203 exit 1
203204 fi
204-
205+
205206 echo "Detected LLVM Major Version: $LLVM_MAJOR_VERSION"
206-
207+
207208 # Navigate to the build directory and clean up. Safely.
208209 BUILD_DIR=~/AviSynthPlus/avisynth-build
209210 # Navigate
210211 cd "$BUILD_DIR"
211212 # Clean up (The shell expands the unquoted * to all visible contents)
212213 rm -rf "$BUILD_DIR"/*
213-
214+
214215 # 2. RUN CMAKE WITH VERSIONED COMPILERS
215216 # Compilers are now set to the specific version (e.g., clang-19, clang++-19).
216217 cmake ../ -G Ninja \
217218 -DCMAKE_BUILD_TYPE=Release \
218219 -DCMAKE_C_COMPILER="clang-$LLVM_MAJOR_VERSION" \
219220 -DCMAKE_CXX_COMPILER="clang++-$LLVM_MAJOR_VERSION" \
220221 -DCMAKE_PREFIX_PATH="$LLVM_CMAKE_PREFIX_PATH"
221-
222+
222223 # Check if CMake failed
223224 if [ $? -ne 0 ]; then
224225 echo "CMake configuration failed. Please check the output above."
225226 exit 1
226227 fi
227-
228- # 3. BUILD
228+
229+ # 2. Build the project
229230 ninja
230-
231+
231232 # Check if ninja build failed
232233 if [ $? -ne 0 ]; then
233234 echo "Ninja build failed. Please check the output above."
234235 exit 1
235236 fi
236-
237- # 4. INSTALL
238-
237+
238+ # 3. Prepare Package Version
239+
239240 # The generated avisynth.pc is in the build directory, inside the avs_core folder.
240241 AVS_VERSION=$(cat avs_core/avisynth.pc | grep Version: | cut -d " " -f2)
241242 CURRENT_DATE=$(date --rfc-3339=date | sed 's/-//g')
242243 PACKAGE_VERSION="$AVS_VERSION-$CURRENT_DATE-git"
243-
244+
244245 echo "Package Version: $PACKAGE_VERSION"
245-
246+
247+
248+ # 4.1 Ensure symlinks are (re)created during install so checkinstall includes them
249+ # Detect the SONAME from the freshly built real library (libavisynth.so.<version>)
250+ # and remove both the namelink (libavisynth.so) and the SONAME symlink (libavisynth.so.<SOVERSION>)
251+ # before running 'ninja install' under checkinstall. This guarantees they are recreated
252+ # during install and captured in the package payload.
253+ # Without this step, libavisynth.so may be missing after every second build, because
254+ # CMake reports existing symlinks as "Up-to-date", and checkinstall does not record
255+ # pre-existing filesystem items in the package payload.
256+
257+ LIBDIR=/usr/lib/aarch64-linux-gnu
258+
259+ # Find the real library we just built (e.g., libavisynth.so.3.7.5) in the target libdir
260+ REAL_LIB=$(ls -1 "$LIBDIR"/libavisynth.so.* 2>/dev/null | grep -E '\.so\.[0-9]+\.[0-9]+' | head -n1)
261+
262+ # If the real library is not yet present in the target libdir (first install on a clean system),
263+ # try to read it from the build tree so we can still get the SONAME safely.
264+ if [ -z "$REAL_LIB" ]; then
265+ # Search in the build directory output (adjust if your library lands elsewhere during build)
266+ REAL_LIB=$(ls -1 "$BUILD_DIR"/libavisynth.so.* 2>/dev/null | grep -E '\.so\.[0-9]+\.[0-9]+' | head -n1)
267+ fi
268+
269+ # If we managed to locate the real library, extract SONAME and remove symlinks safely.
270+ if [ -n "$REAL_LIB" ]; then
271+ SONAME=$(readelf -d "$REAL_LIB" 2>/dev/null | awk '/SONAME/ {print $5}' | tr -d '[]')
272+ if [ -n "$SONAME" ]; then
273+ echo "Detected SONAME: $SONAME (from $REAL_LIB)"
274+ # Remove namelink and SONAME symlink if present; leave the real file intact.
275+ sudo rm -f "$LIBDIR/libavisynth.so" "$LIBDIR/$SONAME"
276+ else
277+ echo "Warning: Could not detect SONAME via readelf; skipping pre-install symlink removal."
278+ fi
279+ else
280+ echo "Note: Real library not found before install; skipping pre-install symlink removal."
281+ fi
282+
283+ # 4.2 Install using checkinstall
246284 sudo checkinstall --pkgname=avisynth \
247285 --pkgversion="$PACKAGE_VERSION" \
248286 --backup=no \
@@ -255,62 +293,104 @@ You can remove the general purge by remove the ``rm -rf *`` if everythings behav
255293 --fstrans=no \
256294 --default \
257295 ninja install
258-
259- # Navigate to the target bin directory (assuming this is correct)
296+
297+ # 4.3 Refresh the dynamic linker cache
298+ sudo ldconfig
299+
300+
301+ # Navigate to the target bin directory
260302 cd ~/bin
261-
303+
304+ # 5. Success Message
262305 echo "AviSynth+ built and installed with LLVM version $LLVM_MAJOR_VERSION!"
263306
264307
265308
266309When you are happy with gcc, use this script:
267310
268- build-gcc.sh:
311+ ** build-gcc.sh ** :
269312::
270313
271314 #!/bin/bash
272-
315+
273316 # Navigate to the build directory and clean up. Safely.
274317 BUILD_DIR=~/AviSynthPlus/avisynth-build
275318 # Navigate
276319 cd "$BUILD_DIR"
277320 # Clean up (The shell expands the unquoted * to all visible contents)
278321 rm -rf "$BUILD_DIR"/*
279-
322+
280323 # --- Get GCC Major Version ---
281324 GXX_MAJOR_VERSION=$(g++ -dumpversion | cut -d. -f1 2>/dev/null)
282-
325+
283326 if [ -z "$GXX_MAJOR_VERSION" ]; then
284327 echo "Warning: Could not determine G++ major version. Using \"$GXX_MAJOR_VERSION\"."
285328 fi
286329 # -----------------------------------
287-
330+
288331 # 1. Configure the build using the default system compiler (gcc/g++)
289332 cmake ../ -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr
290-
333+
291334 # Check if CMake failed
292335 if [ $? -ne 0 ]; then
293- echo "CMake configuration failed."
336+ echo "CMake configuration failed. Please check the output above. "
294337 exit 1
295338 fi
296-
339+
297340 # 2. Build the project
298341 ninja
299-
342+
300343 # Check if ninja build failed
301344 if [ $? -ne 0 ]; then
302- echo "Ninja build failed."
345+ echo "Ninja build failed. Please check the output above. "
303346 exit 1
304347 fi
305-
348+
306349 # 3. Prepare Package Version
350+
351+ # The generated avisynth.pc is in the build directory, inside the avs_core folder.
307352 AVS_VERSION=$(cat avs_core/avisynth.pc | grep Version: | cut -d " " -f2)
308353 CURRENT_DATE=$(date --rfc-3339=date | sed 's/-//g')
309354 PACKAGE_VERSION="$AVS_VERSION-$CURRENT_DATE-git"
310-
355+
311356 echo "Package Version: $PACKAGE_VERSION"
312-
313- # 4. Install using checkinstall
357+
358+ # 4.1 Ensure symlinks are (re)created during install so checkinstall includes them
359+ # Detect the SONAME from the freshly built real library (libavisynth.so.<version>)
360+ # and remove both the namelink (libavisynth.so) and the SONAME symlink (libavisynth.so.<SOVERSION>)
361+ # before running 'ninja install' under checkinstall. This guarantees they are recreated
362+ # during install and captured in the package payload.
363+ # Without this step, libavisynth.so may be missing after every second build, because
364+ # CMake reports existing symlinks as "Up-to-date", and checkinstall does not record
365+ # pre-existing filesystem items in the package payload.
366+
367+ LIBDIR=/usr/lib/aarch64-linux-gnu
368+
369+ # Find the real library we just built (e.g., libavisynth.so.3.7.5) in the target libdir
370+ REAL_LIB=$(ls -1 "$LIBDIR"/libavisynth.so.* 2>/dev/null | grep -E '\.so\.[0-9]+\.[0-9]+' | head -n1)
371+
372+ # If the real library is not yet present in the target libdir (first install on a clean system),
373+ # try to read it from the build tree so we can still get the SONAME safely.
374+ if [ -z "$REAL_LIB" ]; then
375+ # Search in the build directory output (adjust if your library lands elsewhere during build)
376+ REAL_LIB=$(ls -1 "$BUILD_DIR"/libavisynth.so.* 2>/dev/null | grep -E '\.so\.[0-9]+\.[0-9]+' | head -n1)
377+ fi
378+
379+ # If we managed to locate the real library, extract SONAME and remove symlinks safely.
380+ if [ -n "$REAL_LIB" ]; then
381+ SONAME=$(readelf -d "$REAL_LIB" 2>/dev/null | awk '/SONAME/ {print $5}' | tr -d '[]')
382+ if [ -n "$SONAME" ]; then
383+ echo "Detected SONAME: $SONAME (from $REAL_LIB)"
384+ # Remove namelink and SONAME symlink if present; leave the real file intact.
385+ sudo rm -f "$LIBDIR/libavisynth.so" "$LIBDIR/$SONAME"
386+ else
387+ echo "Warning: Could not detect SONAME via readelf; skipping pre-install symlink removal."
388+ fi
389+ else
390+ echo "Note: Real library not found before install; skipping pre-install symlink removal."
391+ fi
392+
393+ # 4.2 Install using checkinstall
314394 sudo checkinstall --pkgname=avisynth \
315395 --pkgversion="$PACKAGE_VERSION" \
316396 --backup=no \
@@ -323,10 +403,13 @@ build-gcc.sh:
323403 --fstrans=no \
324404 --default \
325405 ninja install
326-
406+
407+ # 4.3 Refresh the dynamic linker cache
408+ sudo ldconfig
409+
327410 # Navigate to the target bin directory
328411 cd ~/bin
329-
412+
330413 # 5. Success Message
331414 echo "AviSynth+ built and installed using GCC/G++ version $GXX_MAJOR_VERSION!"
332415
@@ -604,8 +687,7 @@ Finally FFmpeg build with avisynth, here I set only x264 and avisynth, a rather
604687 --bindir="$HOME/bin" \
605688 --enable-gpl \
606689 --enable-libx264 \
607- --enable-avisynth \
608- --enable-nonfree && \
690+ --enable-avisynth && \
609691 PATH="$HOME/bin:$PATH" make -j4 && \
610692 make install && \
611693 hash -r
0 commit comments