Extensive usage of Make
来源:互联网 发布:手机淘宝如何查看天猫积分 编辑:程序博客网 时间:2024/05/17 05:19
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:
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
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
- hdu 1035 (usage of sentinel, proper utilization of switch and goto to make code neat)
- Usage of Pseudocode
- Usage of MFC CRectTracker
- Usage of awk
- effective usage of strtok
- Usage of Protocol Buffer
- Usage of pmake
- Usage sample of SSL
- usage of >>>、>> and << operators
- Usage of Oracle Block
- Usage of TKPROF
- Usage of Ftp
- Usage of Func delegate
- Usage of Vmstat
- Usage Of TRCA
- Usage of #pragma
- The usage of finalize()
- Minimize Code Explosion of Generic Type
- GoAhead Web Server Hang
- Macro expansion and Assembly code
- Detect Stack Corruption
- Fix bugs with core dump
- Extensive usage of Make
- Enable SSL in goAhead web server
- Product quality issue
- Living in Huangpu river
- posting failed?
- 统计文件中出现的keyword的次数
- 如何选择白盒测试工具
- SSO跨域解决方案
- Linux 用户(user)和用户组(group)管理概述