MKLIBS_DIR="${FREETZ_BASE_DIR}/tools/build/bin" MKLIBS_SCRIPT="${MKLIBS_DIR}/mklibs" TARGET_TOOLCHAIN_STAGING_DIR="${FREETZ_BASE_DIR}/toolchain/target" GNU_TARGET_NAME=${FREETZ_TARGET_ARCH}-linux REAL_GNU_TARGET_NAME=${GNU_TARGET_NAME}-uclibc mklibs() { # TODO: replace the next 5 lines with code that replaces all # absolute sym links... to make mklibs happy local -a abs_symlinks=( \ /lib/libcapi20.so \ /lib/libcapi20.so.3 \ /lib/libfwsign.so.0 \ /lib/libled2.so.2.2 \ /lib/libled2.so.2 \ ) local -a rel_targets=( \ libcapi20.so.3.0.4 \ libcapi20.so.3.0.4 \ libfwsign.so \ libled2.so.2.2.0 \ libled2.so.2.2.0 \ ) for ((i=0; i<5; i++)); do [ -h "${FILESYSTEM_MOD_DIR}/${abs_symlinks[$i]}" ] && ln -sf "${rel_targets[i]}" "${FILESYSTEM_MOD_DIR}/${abs_symlinks[$i]}" done rm -rf ${MOD_DIR}/mklibs-progs ${MOD_DIR}/mklibs-out mkdir -p ${MOD_DIR}/mklibs-out # first find all programs and add them to the mklibs list find ${FILESYSTEM_MOD_DIR} -type f -perm +100 -exec \ file -r -N -F '' {} + | \ awk ' /executable.*dynamically/ { print $1 }' > ${MOD_DIR}/mklibs-progs # find all loadable objects that are not regular libraries and add them to the list as well find ${FILESYSTEM_MOD_DIR} -type f -name \*.so\* -exec \ file -r -N -F '' {} + | \ awk ' /shared object/ { print $1 }' >> ${MOD_DIR}/mklibs-progs # Run mklibs script, needs path to mklibs-readelf and objcopy PATH=${MKLIBS_DIR}:${TARGET_TOOLCHAIN_STAGING_DIR}/bin:$PATH \ ${MKLIBS_SCRIPT} -D -v \ -d ${MOD_DIR}/mklibs-out \ --sysroot ${FREETZ_BASE_DIR}/ \ -L toolchain/target/lib \ -L ${FILESYSTEM_MOD_DIR}/usr/lib/freetz \ -L ${FILESYSTEM_MOD_DIR}/lib \ --ldlib ${FILESYSTEM_MOD_DIR}/lib/ld-uClibc.so.0 \ --target ${REAL_GNU_TARGET_NAME} \ $(cat ${MOD_DIR}/mklibs-progs) \ > ${MOD_DIR}/mklibs.log 2>&1 local rv=$? # Copy stripped libs to their destination directory for lib in $(ls ${MOD_DIR}/mklibs-out/*.so.* 2>/dev/null); do \ LIB="${lib##*/}"; \ DEST="$(ls "${FILESYSTEM_MOD_DIR}/usr/lib/freetz/$LIB" 2>/dev/null)"; \ [ -n "$DEST" ] || DEST="$(ls "${FILESYSTEM_MOD_DIR}/lib/$LIB" 2>/dev/null)"; \ [ -n "$DEST" ] || continue; \ echo2 "$lib"; \ cp "$lib" "$DEST" || exit 1; \ done rm -rf ${MOD_DIR}/mklibs-progs ${MOD_DIR}/mklibs-out return $rv }