最简单的makefile和最简单的shell程序

不知如何编写shell程序,makefile也是很糟糕,于是查找资料,自己编写一个最入门的例子。

程序文件为helloword.c

makefile也很简单

test为shell程序

这三个文件放在/home/scs/helloword目录下

代码如下所示:

makefile

[plain]  view plain copy
  1. a.out:helloword.c  
  2.     cc helloword.c  
  3. clean:  
  4.     rm a.out  

 

 

helloword.c

 

[cpp]  view plain copy
  1. #include <stdio.h>  
  2. void main(void){  
  3. printf("\nhello world !\n");  
  4. }  

 

test 

 

[plain]  view plain copy
  1. #! /bin/sh   
  2. cd /home/scs/helloword  
  3. /usr/bin/make  
  4. echo "lalalalalala"  
  5. exit  



 

下面讲解具体步骤:

1. 建立helloword.c ,这个不用说了,地球人都知道

2. 建立makefile文件,内容如上所示,

    (注释:执行make时,生成a.out,

   执行make clean时,删除a.out)

3. 建立test文件,敲入对应代码

(  注释:

#!/bin/sh 指明用默认shell

 exit为退出shell

中间的命令和linux shell下敲入的命令完全一样)

4.使test编程可执行文件

    命令:chmod 555 test

5  执行test

   命令:  ./test

  哈哈发现shell程序调用make了吧??

转载于:https://www.cnblogs.com/yazhouren/archive/2012/04/12/2443843.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值