# Given a list of files, look for .a archives and unpack them.
# Return the original list of files minus the .a files plus the unpacked files.
expand_archives() {
+ DIR=$1
+ shift
FILES=$@
NEWFILES=""
+ ORIG_DIR=`pwd`
+ mkdir -p "$DIR"
+ cd "$DIR"
for FILE in $FILES ; do
case $FILE in
*.a)
# extract the .o files from this .a archive
+ case $FILE in
+ /*) ;;
+ *) FILE="$ORIG_DIR/$FILE" ;;
+ esac
MEMBERS=`ar t $FILE`
ar x $FILE
- NEWFILES="$NEWFILES $MEMBERS"
+ for MEMBER in $MEMBERS ; do
+ NEWFILES="$NEWFILES $DIR/$MEMBER"
+ done
;;
*)
# other file type, just add to list
;;
esac
done
+ cd "$ORIG_DIR"
echo $NEWFILES
}
fi
# expand .a into .o files
- NEW_OBJECTS=`expand_archives $OBJECTS`
+ NEW_OBJECTS=`expand_archives ${LIBNAME}.obj $OBJECTS`
# make static lib
FINAL_LIBS=`make_ar_static_lib ${OPTS} 1 ${LIBNAME} ${NEW_OBJECTS}`
# remove temporary extracted .o files
- rm -f `contents_of_archives $OBJECTS`
+ rm -rf ${LIBNAME}.obj
else
# make dynamic library
LIBNAME="lib${LIBNAME}" # prefix with "lib"
echo "mklib: Making FreeBSD static library: " ${STLIB}
# expand .a into .o files
- NEW_OBJECTS=`expand_archives $OBJECTS`
+ NEW_OBJECTS=`expand_archives ${STLIB}.obj $OBJECTS`
FINAL_LIBS=`make_ar_static_lib cq 1 ${STLIB} ${NEW_OBJECTS}`
# remove temporary extracted .o files
- rm -f `contents_of_archives $OBJECTS`
+ rm -rf ${STLIB}.obj
else
# make dynamic library
SHLIB="lib${LIBNAME}.so.${MAJOR}"