Managing Projects with GNU make 3rd Edition(1)

第1个例子需要一点flex和bison的知识,可以参考书籍flex and bison by Jobn Levine,第1个例子大概的思路就是使用lexerwg命令将lexer.l文件编译成C语言文件,qd然后使用make来编译。

先介绍不用makefile运行此例子的步骤。

文件lexer.l的内容为:

int fee_count = 0;
	int fie_count = 0;
	int foe_count = 0;
	int fum_count = 0;
%%
fee	fee_count++;
fie	fie_count++;
foe	foe_count++;
fum	fum_count++;

若不使用makefile,直接使用命令flex -t flexer.l > flexer.c可以生成flex.c文件。

使用命令gcc -c -o count_words.o count_words.c 编译count_words.c生成count_words.o文件。
使用命令gcc -c -o lexer.o lexer.c编译lexer.c生成lexer.o文件。
使用命令gcc count_words.o lexer.o -lfl -o count_words链接生成可执行文件count_words。

若使用makefile编译这些文件,makefile文件内容为:

count_words: count_words.o lexer.o -lfl
	gcc count_words.o lexer.o -lfl -ocount_words

count_words.o: count_words.c
	gcc -c count_words.c

lexer.o: lexer.c
	gcc -c lexer.c

lexer.c: lexer.l
	flex -t lexer.l > lexer.c

直接使用make即可编译这些文件。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
make是unix和其他操作系统上最持久的工具之一。自1970年问世以来,make至今仍旧是大多数程序开发项目的核心工具,它甚至被用来编译linux内核。阅读本书,读者将可以了解,尽管出现了许多新兴的竞争者为何make仍旧是开发项目中编译软件的首选工具。. 简单就是make欲达成的目标:在你变更源代码文件之后,想要重编译你的程序或其他输出文件之际,make会检查时间戳,找出被变更的文件并进行必要的重编译动作,因此不会浪费时间去重编译其他文件。为了达到这个目标,make提供了许多选项让你能够操作多个目录、为不同的平台编译不同版本的程序以及自定义编译方法。.. 本书第三版的重点是gnu make,这个版本的make已经成为行业标准。本书将会探索gnu make所提供的强大扩充功能。gnu make之所以广受欢迎是因为它是一个自由软件,并且几乎可以在包括微软windows(作为cygwin项目的一部分)的每个平台上使用 *************************************************************** 请注意: 下载完,评论的同时,请点击评论框上方的五角星(共5个五角星),这样你的被扣的积分就可以返还了。 如果只评论,不点击小五角星,积分不会返还。 一定要先下载完,再评论。如果先评论后下载,或者在下载的过程中评论,积分同样不会返还。 *************************************************************** 更多linux、ARM和C语言资源请参考: http://blog.csdn.net/arkofnoach/archive/2010/10/23/5960560.aspx
The utility simply known as make is one of the most enduring features of both Unix and other operating systems. First invented in the 1970s, make still turns up to this day as the central engine in most programming projects; it even builds the Linux kernel. In the third edition of the classic Managing Projects with GNU make, readers will learn why this utility continues to hold its top position in project build software, despite many younger competitors.The premise behind make is simple: after you change source files and want to rebuild your program or other output files, make checks timestamps to see what has changed and rebuilds just what you need, without wasting time rebuilding other files. But on top of this simple principle, make layers a rich collection of options that lets you manipulate multiple directories, build different versions of programs for different platforms, and customize your builds in other ways.This edition focuses on the GNU version of make, which has deservedly become the industry standard. GNU make contains powerful extensions that are explored in this book. It is also popular because it is free software and provides a version for almost every platform, including a version for Microsoft Windows as part of the free Cygwin project. Managing Projects with GNU make, 3rd Edition provides guidelines on meeting the needs of large, modern projects. Also added are a number of interesting advanced topics such as portability, parallelism, and use with Java.Robert Mecklenburg, author of the third edition, has used make for decades with a variety of platforms and languages. In this book he zealously lays forth how to get your builds to be as efficient as possible, reduce maintenance, avoid errors, and thoroughly understand what make is doing. Chapters on C++ and Java provide makefile entries optimized for projects in those languages. The author even includes a discussion of the makefile used to build the book.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值