龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 操作系统 > LINUX系统 >

Bash的另类shell Makefile

时间:2011-03-20 22:37来源:未知 作者:admin 点击:
分享到:

  无赖对 Makefile 不太熟悉,为了编译数量不断增加的独立的 .cpp 文件,只有想个另类的办法了。考虑了好几种方法,最后以 Makefile为壳,用 bash 暗渡陈仓。

 

  Makefile 如下:

QUOTE:

main: null.out

null.out:

./compile.sh

clean:

rm *.out

compile.sh 就是实际执行 make 命令的了:

 

  QUOTE:

#!/bin/bash

for cpp in *.cpp

do

out="${cpp%.cpp}.out"

if test ${cpp} -nt ${out}

then

printf "g++ -o %s %s\n" "${out}" "${cpp}"

g++ -o ${out} ${cpp}

fi

done

 

精彩图集

赞助商链接