Chinaunix首页 | 论坛 | 博客
  • 博客访问: 571213
  • 博文数量: 79
  • 博客积分: 2513
  • 博客等级: 少校
  • 技术积分: 806
  • 用 户 组: 普通用户
  • 注册时间: 2006-10-04 18:46
文章分类

全部博文(79)

文章存档

2014年(1)

2010年(5)

2009年(8)

2008年(11)

2007年(41)

2006年(13)

我的朋友

分类: LINUX

2007-12-02 23:37:39

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

Makefile 如下:

main: null.out

null.out:

        ./compile.sh

clean:

        rm *.out


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

#!/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

阅读(1482) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~