#!/bin/sh -eux
"$RSTRIP_SH" "$@"

# we want to run it on all ELF files for the target, but not on other ELF files such as WiFi firmware.
# by looking for executables bit for executables and for .so* for libraries we should catch everything
find \
	"$@" \
	-type f \
	-not -name 'ld-linux*.so*' \
	'(' \
		-name '*.so*' \
		-or \
		-executable \
	')' \
	-exec file {} \; | grep -E ':.*ELF' | awk -F ': ' '{print $1}' | \
		xargs -rt -I {} "$PATCHELF" --no-default-lib --add-rpath '/${LIB}/broadcom:/usr/${LIB}/broadcom' '{}' || true