Extensive usage of Make
2009-03-15 11:49
218 查看
Many guys have used make utility with makefile to compile source code. The official introduction of gnu make also introduces it as "Make is a tool which controls the generation of executables and other non-source files of a program from the program's source files".
If we look inside how does make utility works, we'll find it can do much more than compiling code. It's so powerful to make our life much easier, and by our, i mean ordinary people, not just programmers.
The essential point is when combined with shell script, make can assist you doing a sequence of actions to perform automatically.
Typical scenario
Suppose we're writing a book "How to win lottery" which will surely be the best sell all around the world on amazon.com after it's available. Because everyone in different countries would like to have a copy of it, we also need to translate it into different languages.
And a generous, smart programmer provides us a super translation tool that is capable of translating all languages, at no cost.
The last thing is we need to share new chapters to our kind editor by placing documents at //ipaddress/book/(Sorry, I can't share the address with you since it's confidential). She will have some guys to proof reading them.
So, here is our typical working flow:
1. Write / update english version draft
2. Run the translation tool to generate a draft for a different language
3. Save the file according to its language
4. Upload the file to //ipaddress/book
5. Send a email to notify editor
A little bit boring, right ? We need to repeat this again and again when we have new chapter available or the editor asks us to correct errors. Can't we just focus on the writing the book itself ? We have two options, hire a guy to do steps two to five for us, or use make utility.
How to do?
We can define a makefile according to the steps above.
all: generateDraft translate upload sendMail
generateDraft:
draftGenerator.exe -o draft.pdf #this line generate a draft pdf file -o is the argument passed to draftGenerator
translate:
superTranslator.exe --lan $(lan) -o draft_$(lan).pdf #this line translate the draft to specified language and save it as a copy with language in filename
upload:
cp draft_$(lan).pdf //ipaddress/book
sendMail:
#send mail to editor
Then, each time after we update the draft, we can simply use "make lan=chinese"command to ask the compter do the rest for us.
The make utility is actually a parser that read the makefile and perform every actions defined there. So what we need to do is carefully design our makefile.
Summary
Well, to sum up, make utility if useful when we have:
A sequence of steps to perform
Frequent update
make will keep our working process consistent without forgetting to do several steps.
For example, we can define a make file to run all unit tests before comit new code to code respository.
References
Gnu make manual
Compile Apps Your Way With Custom Tasks For The Microsoft Build Engine
If we look inside how does make utility works, we'll find it can do much more than compiling code. It's so powerful to make our life much easier, and by our, i mean ordinary people, not just programmers.
The essential point is when combined with shell script, make can assist you doing a sequence of actions to perform automatically.
Typical scenario
Suppose we're writing a book "How to win lottery" which will surely be the best sell all around the world on amazon.com after it's available. Because everyone in different countries would like to have a copy of it, we also need to translate it into different languages.
And a generous, smart programmer provides us a super translation tool that is capable of translating all languages, at no cost.
The last thing is we need to share new chapters to our kind editor by placing documents at //ipaddress/book/(Sorry, I can't share the address with you since it's confidential). She will have some guys to proof reading them.
So, here is our typical working flow:
1. Write / update english version draft
2. Run the translation tool to generate a draft for a different language
3. Save the file according to its language
4. Upload the file to //ipaddress/book
5. Send a email to notify editor
A little bit boring, right ? We need to repeat this again and again when we have new chapter available or the editor asks us to correct errors. Can't we just focus on the writing the book itself ? We have two options, hire a guy to do steps two to five for us, or use make utility.
How to do?
We can define a makefile according to the steps above.
all: generateDraft translate upload sendMail
generateDraft:
draftGenerator.exe -o draft.pdf #this line generate a draft pdf file -o is the argument passed to draftGenerator
translate:
superTranslator.exe --lan $(lan) -o draft_$(lan).pdf #this line translate the draft to specified language and save it as a copy with language in filename
upload:
cp draft_$(lan).pdf //ipaddress/book
sendMail:
#send mail to editor
Then, each time after we update the draft, we can simply use "make lan=chinese"command to ask the compter do the rest for us.
The make utility is actually a parser that read the makefile and perform every actions defined there. So what we need to do is carefully design our makefile.
Summary
Well, to sum up, make utility if useful when we have:
A sequence of steps to perform
Frequent update
make will keep our working process consistent without forgetting to do several steps.
For example, we can define a make file to run all unit tests before comit new code to code respository.
References
Gnu make manual
Compile Apps Your Way With Custom Tasks For The Microsoft Build Engine
相关文章推荐
- Extensive usage of Make
- IL系列文章之二:Make Best Use of Our Tools
- C#: the sample usage of c# template
- Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "te
- Please make sure the TESSDATA_PREFIX environment variable is set to the parent directory of your "te
- Most Simple Usage Of Tensorboard
- 一些关于ARM驱动的问题 make menuconfig && implicit declaration of function
- simple usage of tcpdump
- map(映射)的使用方法 (The usage of map.)
- The Defining Decade-Why Your Twenties Matter--And How to Make the Most of Them Now
- the usage of tuple in python
- 10 Useful du (Disk Usage) Commands to Find Disk Usage of Files and Directories
- “API design is like sex: Make one mistake and support it for the rest of your life.”
- NDoc: How to Make Good Use of Your XML Comments?
- An Extensive Examination of LINQ: Querying and Searching XML Documents Using LINQ to XML
- [每日一题] 11gOCP 1z0-052 :2013-09-7 The usage of the SQL*LOAD utility...........................A38
- Usage of TKPROF
- Usage of AWR And ASH
- Python语言中对于json数据的编解码——Usage of json a Python standard library
- usage of c/c++ function