Remove an object from a static library
#!/bin/sh | |
# Remove an object from a static library. | |
LIB_SRC=${1} | |
OBJ=${2} | |
if [ -z ${OBJ} ]; then | |
echo "Usage: $0 source.a target.o" | |
exit 0 | |
fi | |
if [ ! -f ${LIB_SRC} ]; then | |
echo "File ${LIB_SRC} not found" | |
exit 1 | |
fi | |
EXTRACT_FAT(){ | |
SUBS="" | |
for ARCH in `echo $LIB_INFO | sed -n -e 's/Architectures in the fat file:.*are: \(.*\)/\1/p'`; do | |
SUB=${1}_${ARCH}.a | |
lipo -thin ${ARCH} ${1} -output ${SUB} | |
EXTRACT ${SUB} ${2} | |
SUBS="${SUBS} ${SUB}" | |
done | |
lipo -create ${SUBS} -output ${1} | |
rm ${SUBS} | |
} | |
EXTRACT(){ | |
ar -d ${1} ${2} | |
} | |
LIB_INFO=`lipo -info ${LIB_SRC}` | |
if [ `echo $LIB_INFO | grep -c "Architectures in the fat file" ` -gt 0 ]; then | |
EXTRACT_FAT ${LIB_SRC} ${OBJ} | |
else | |
EXTRACT ${LIB_SRC} ${OBJ} | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment