#!/bin/sh
mode=dynamic
debug=
iifiles=
ifiles=
soptions=
doptions=
liboptions=
ooptions=
output_file=
verbose=no
SYSTEM_DEVELOPER_DIR=/Developer
SYSTEM_DEVELOPER_EXECUTABLES_DIR="$SYSTEM_DEVELOPER_DIR/Executables"
gcc_vers=`$NEXT_ROOT/$SYSTEM_DEVELOPER_EXECUTABLES_DIR/gcc -v 2>&1 | fgrep version | sed -e 's/[^0-9]*\([^ ]*\) .*/\1/'`
static_libgen="/usr/ccs/bin/ar -r"
dynamic_libgen="$NEXT_ROOT/$SYSTEM_DEVELOPER_EXECUTABLES_DIR/gcc -nostdlib -G"
collect="$NEXT_ROOT/$SYSTEM_DEVELOPER_DIR/Libraries/gcc-lib/sparc-nextpdo-solaris2/$gcc_vers/collect2"
gcc_lib_dir="$NEXT_ROOT/$SYSTEM_DEVELOPER_DIR/Libraries/gcc-lib/sparc-nextpdo-solaris2/$gcc_vers/"
cc="$NEXT_ROOT/$SYSTEM_DEVELOPER_EXECUTABLES_DIR/gcc -c -fPIC"
bigo_libgen="$NEXT_ROOT/$SYSTEM_DEVELOPER_EXECUTABLES_DIR/gcc -nostdlib -r"
temp_file_base=/tmp/libtool$$
while [ $do
case $1 in
-static )
mode=static
shift
;;
-dynamic )
mode=dynamic
shift
;;
-o )
output_file="$2"
shift
shift
;;
-[sac] | -[sac][sac] | -[sac][sac][sac] )
echo "libtool: warning: -sac options ignored" 1>&2
shift
;;
-g )
doptions="$doptions -g"
debug="-g"
shift
;;
-def )
echo "libtool: warning: def file ignored" 1>&2
shift
shift
;;
-[lL]* )
liboptions="$liboptions $1"
shift
;;
-file[lL]ist )
if [ "$mode" = "dynamic" ]
then
ooptions="$ooptions -filelist $2"
else
file=`echo $2 | sed "s/,.*//g"`
if echo $2 | grep , > /dev/null
then
dir=`echo $2 | sed "s/.*,//g"`
else
dir=
fi
if [ ! -r "$file" ]
then
echo "libtool: error: filelist '$2' not found" 1>&2
exit 1
elif [ -n "$dir" ]
then
iifiles=`cat $file | sed "s@^@$dir/@" | tr -s '\012\015 ' ' '`
ifiles="$ifiles $iifiles"
else
ifiles="$ifiles `cat $file | tr -s '\012\015 ' ' '`"
fi
fi
shift
shift
;;
-install_name )
doptions="$doptions -h $2"
shift
shift
;;
-read_only_relocs )
echo "libtool: warning: -read_only_relocs ignored" 1>&2
shift
shift
;;
-compatibility_version )
echo "libtool: warning: -compatibility_version ignored" 1>&2
shift
shift
;;
-current_version )
echo "libtool: warning: -current_version ignored" 1>&2
shift
shift
;;
-v )
verbose=yes
shift
;;
-seg1addr | -undefined | -image_base )
echo "libtool: warning: option '$1 $2' suppressed" 1>&2
shift
shift
;;
-sectorder )
echo "libtool: warning: option '$1 $2 $3 $4' suppressed" 1>&2
shift
shift
shift
shift
;;
-sectorder_detail )
echo "libtool: warning: option '$1' suppressed" 1>&2
shift
;;
-t )
shift
;;
- )
shift
break
;;
-Xlinker )
doptions="$doptions $1 $2"
shift
shift
;;
*.so )
doptions="$doptions $1"
shift
;;
-framework )
doptions="$doptions -framework $2"
shift
shift
;;
-F* )
doptions="$doptions $1"
shift
;;
-arch* )
echo "libtool: warning: -arch option ignore" 1>&2
shift
shift
;;
-* )
soptions="$soptions $1"
doptions="$doptions $1"
shift
;;
* )
ifiles="$ifiles $1"
shift
;;
esac
done
if [ ! "$output_file" ]; then
echo "libtool: error: -o option is required" 1>&2
exit 1
fi
if [ "$mode" = "static" ]; then
cmd="$static_libgen $soptions $output_file $ifiles"
if [ "$verbose" = "yes" ]; then
echo $cmd
fi
$cmd
exit $?
elif [ "$mode" = "dynamic" ]; then
cmd="$bigo_libgen $ooptions -o $temp_file_base.tmp $ifiles"
if [ "$verbose" = "yes" ]; then
echo $cmd
fi
$cmd
cmd="$collect -o $temp_file_base.c $temp_file_base.tmp"
if [ "$verbose" = "yes" ]; then
echo $cmd
fi
$cmd
cmd="$cc $debug $temp_file_base.c -o $temp_file_base.o"
if [ "$verbose" = "yes" ]; then
echo $cmd
fi
$cmd
rm -f $temp_file_base.c
cmd="$dynamic_libgen -L$gcc_lib_dir $doptions -o $output_file $temp_file_base.tmp $temp_file_base.o $liboptions -lgcc"
if [ "$verbose" = "yes" ]; then
echo $cmd
fi
$cmd
rm -f $temp_file_base.o
rm -f $temp_file_base.tmp
else
echo "libtool: error: unknown mode $mode" 1>&2
exit 1
fi