使用Shell脚本编译.c源文件

2549阅读 0评论2009-10-14 ericxlin
分类:

### function declaration: build .c source files
### user command pattern: gcc -Wall -g -o target_file_name source_file_name
### such as: gcc -Wall -g -o alarm alarm.c
### usage declaration: 1. ./build.sh alarm.c 2. ./alarm

#!/bin/sh
#echo $1
#echo ${1%.c}
if [[ "$#" != 1 || "${1%.c}" == "$1" ]]
then
 echo "build pattern: ./build.sh source_file_name(xxx.c)"
#elif [[ "${1%.c}" == "$1" ]]
#then
# echo "build pattern: ./build.sh source_file_name(xxx.c)"
else
 echo "gcc -Wall -g -o ${1%.c} $1"
 gcc -Wall -g -o ${1%.c} $1
fi
上一篇:install mpich2 in rhel4
下一篇:使用shell脚本删除当前目录下.c文件对应的可执行文件