#!/bin/bash
#------------------------------------------------------------------------------
#
# TITLE : Maketest.sh
# PURPOSE : compile some .c source files for test
#
#------------------------------------------------------------------------------
if [ $# = 0 ]
then
srcfile=main.c
else
srcfile=$1
fi
OS_type=`uname`
#dir_name=`dirname $1`
out_name=`basename $srcfile .c`
if [ $OS_type = SunOS ]
then
INCPATH=-I/usr/include
LIBPATH=-L/usr/lib
LINKLIB="-lsocket -lnsl"
else
INCPATH=-I/usr/include
LIBPATH=-L/usr/lib
LINKLIB=-ldl
fi
for src_unit in $*
do
obj_unit="`basename $src_unit .c`.o"
gcc -g -c -o ${obj_unit} ${INCPATH} ${src_unit} \
${LIBPATH} ${LINKLIB}
out_objs="$obj_unit $out_objs"
#echo $out_objs
done
gcc -g -o ${out_name} ${INCPATH} ${out_objs} \
${LIBPATH} ${LINKLIB}
rm $out_objs
######## END #########
阅读(667) | 评论(0) | 转发(0) |