Build and configuration scripts should use portable path handling techniques to ensure they work correctly across different environments and installations.
Key practices:
# Correct - captures all version suffixes
cp ${VULKAN_ROOT}/libvulkan.so* "${BUILD_DIR}/bin/"
# Incorrect - only copies the base library file
cp "${VULKAN_ROOT}/libvulkan.so" "${BUILD_DIR}/bin/"
# Better approach - allows overriding with environment variables
if [ -z "${VULKAN_ROOT}" ]; then
# Default only used if not explicitly set
VULKAN_ROOT=/usr/lib/
fi
$ORIGIN
for runtime library paths instead of absolute paths that assume specific installation locations:
# Better - uses relative paths from binary location
EXTRA_LIBS="-Wl,-rpath,'$ORIGIN'"
# Avoid - assumes specific installation location
EXTRA_LIBS="-Wl,-rpath,/opt/intel/oneapi/compiler/latest/lib"
# Correct - no space after equals
DNF_COMPATIBILITY_FMT="addrepo --from-repofile="
# Incorrect - space will cause command parsing issues
DNF_COMPATIBILITY_FMT="addrepo --from-repofile= "
Following these practices ensures build scripts and configurations work reliably across different environments, making software more portable and easier to install for end users.
Enter the URL of a public GitHub repository