Introduction to Makefile        Ray Song    February 25, 2012     Ray Song   Introduction to Makefile
Motivation      Small programs -> single file -> manual compilation      “not so small” programs             many files     ...
Motivation      Small programs -> single file -> manual compilation      “not so small” programs             many files     ...
Motivation      Small programs -> single file -> manual compilation      “not so small” programs             many files     ...
Motivation      Small programs -> single file -> manual compilation      “not so small” programs             many files     ...
Motivation      Small programs -> single file -> manual compilation      “not so small” programs             many files     ...
Motivation - cont.       Problems           harder to manage           every change require long compilation           div...
Motivation - cont.       Problems           harder to manage           every change require long compilation           div...
Motivation - cont.       Problems           harder to manage           every change require long compilation           div...
Motivation - cont.       Problems           harder to manage           every change require long compilation           div...
Motivation - cont.       Solution - Makefile                            Ray Song   Introduction to Makefile
Makefile     Makefile describes          project structure          instructions for files creation     A makefile consists of...
Makefile     Makefile describes          project structure          instructions for files creation     A makefile consists of...
Makefile     Makefile describes          project structure          instructions for files creation     A makefile consists of...
Makefile     Makefile describes          project structure          instructions for files creation     A makefile consists of...
Rule syntax      TARGETS: PREREQUISITES          RECIPE      In short, each rule describe instructions (RECIPE) to create ...
Rule syntax      TARGETS: PREREQUISITES          RECIPE      In short, each rule describe instructions (RECIPE) to create ...
Rule syntax      TARGETS: PREREQUISITES          RECIPE      In short, each rule describe instructions (RECIPE) to create ...
Makefile – cont.      TARGETS and PREREQUISITES are file names separated      by spaces.      Usually there is only one targ...
Makefile – cont.      TARGETS and PREREQUISITES are file names separated      by spaces.      Usually there is only one targ...
Makefile – cont.      TARGETS and PREREQUISITES are file names separated      by spaces.      Usually there is only one targ...
Makefile – cont.      TARGETS and PREREQUISITES are file names separated      by spaces.      Usually there is only one targ...
Makefile – cont.      TARGETS and PREREQUISITES are file names separated      by spaces.      Usually there is only one targ...
make’s mechanism     make command reads a makefile and records these rules into     its data base.     GNU Make defaults to...
make’s mechanism     make command reads a makefile and records these rules into     its data base.     GNU Make defaults to...
make’s mechanism     make command reads a makefile and records these rules into     its data base.     GNU Make defaults to...
make’s mechanism     make command reads a makefile and records these rules into     its data base.     GNU Make defaults to...
make’s mechanism     make command reads a makefile and records these rules into     its data base.     GNU Make defaults to...
make’s mechanism     make command reads a makefile and records these rules into     its data base.     GNU Make defaults to...
make’s mechanism - cont.      make virtually construct a dependency DAG (directed acyclic      graph).      make ensures m...
make’s mechanism - cont.      make virtually construct a dependency DAG (directed acyclic      graph).      make ensures m...
make’s mechanism - cont.      make virtually construct a dependency DAG (directed acyclic      graph).      make ensures m...
make’s mechanism - cont.      make virtually construct a dependency DAG (directed acyclic      graph).      make ensures m...
make’s mechanism - cont.      make virtually construct a dependency DAG (directed acyclic      graph).      make ensures m...
make’s mechanism - cont.      make virtually construct a dependency DAG (directed acyclic      graph).      make ensures m...
Automatic variables      $@      $ˆ      $<      others including $, $?, $+, $|, $%, $(%D), %(F), . . .                   ...
Automatic variables      $@      $ˆ      $<      others including $, $?, $+, $|, $%, $(%D), %(F), . . .                   ...
Automatic variables      $@      $ˆ      $<      others including $, $?, $+, $|, $%, $(%D), %(F), . . .                   ...
Automatic variables      $@      $ˆ      $<      others including $, $?, $+, $|, $%, $(%D), %(F), . . .                   ...
Example     convert: cmdline.o convert.o          g++ $ˆ -o $@     convert.o: convert.cpp convert.h          g++ -c $<    ...
Equivalent (implicit rules)       make can dedude appropriate recipes according to suffixes       convert: cmdline.o convert...
Equivalent (implicit rules) - cont.       convert: cmdline.o       convert.o: convert.h       cmdline.o: cmdline.h convert...
Another example      %.o: %.c          gcc -c $<                      Ray Song   Introduction to Makefile
Passing parameters      test: FORCE          echo $(VAR)      FORCE:      make VAR=hello      make VAR=world              ...
Passing parameters      test: FORCE          echo $(VAR)      FORCE:      make VAR=hello      make VAR=world              ...
Force targets       Targets without recipes or prerequisites                            Ray Song   Introduction to Makefile
Phony targets      They do not correspond to real file.      Provide some utility, e.g. cleaning intermediate files, archivi...
Phony targets      They do not correspond to real file.      Provide some utility, e.g. cleaning intermediate files, archivi...
Phony targets      They do not correspond to real file.      Provide some utility, e.g. cleaning intermediate files, archivi...
Example     all : prog1 prog2 prog3     .PHONY : all     prog1 : prog1.o utils.o          cc -o prog1 prog1.o utils.o     ...
Practical options of make      -n, print the commands to be run but do not execute them      -t, touch files instead of run...
Practical options of make      -n, print the commands to be run but do not execute them      -t, touch files instead of run...
Practical options of make      -n, print the commands to be run but do not execute them      -t, touch files instead of run...
Practical options of make      -n, print the commands to be run but do not execute them      -t, touch files instead of run...
Practical options of make      -n, print the commands to be run but do not execute them      -t, touch files instead of run...
Practical options of make      -n, print the commands to be run but do not execute them      -t, touch files instead of run...
Practical options of make      -n, print the commands to be run but do not execute them      -t, touch files instead of run...
Other usage      Makefile’s mechanism is not limited to programs          LaTeX sources          website deployment        ...
Other usage      Makefile’s mechanism is not limited to programs          LaTeX sources          website deployment        ...
Other usage      Makefile’s mechanism is not limited to programs          LaTeX sources          website deployment        ...
Other usage      Makefile’s mechanism is not limited to programs          LaTeX sources          website deployment        ...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Additional features       Variables (two flavors: simple and recursive, the latter is also       called macros)       Funct...
Acknowledgements      This slide incorporate some stuff from Roded Sharan’s      http://www.cs.tau.ac.il/~roded/courses/sof...
Acknowledgements      This slide incorporate some stuff from Roded Sharan’s      http://www.cs.tau.ac.il/~roded/courses/sof...
Acknowledgements      This slide incorporate some stuff from Roded Sharan’s      http://www.cs.tau.ac.il/~roded/courses/sof...
Acknowledgements      This slide incorporate some stuff from Roded Sharan’s      http://www.cs.tau.ac.il/~roded/courses/sof...
References      GNU Make Manual      http://www.gnu.org/software/make/manual/                      Ray Song   Introduction...
Upcoming SlideShare
Loading in …5
×

Introduction to makefile

1,545 views

Published on

http://maskray.me/blog/2012-02-25-introduction-to-makefile

Published in: Technology, Business
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,545
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
101
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to makefile

  1. 1. Introduction to Makefile Ray Song February 25, 2012 Ray Song Introduction to Makefile
  2. 2. Motivation Small programs -> single file -> manual compilation “not so small” programs many files multiple components more than one programmers Ray Song Introduction to Makefile
  3. 3. Motivation Small programs -> single file -> manual compilation “not so small” programs many files multiple components more than one programmers Ray Song Introduction to Makefile
  4. 4. Motivation Small programs -> single file -> manual compilation “not so small” programs many files multiple components more than one programmers Ray Song Introduction to Makefile
  5. 5. Motivation Small programs -> single file -> manual compilation “not so small” programs many files multiple components more than one programmers Ray Song Introduction to Makefile
  6. 6. Motivation Small programs -> single file -> manual compilation “not so small” programs many files multiple components more than one programmers Ray Song Introduction to Makefile
  7. 7. Motivation - cont. Problems harder to manage every change require long compilation division to components is desired Ray Song Introduction to Makefile
  8. 8. Motivation - cont. Problems harder to manage every change require long compilation division to components is desired Ray Song Introduction to Makefile
  9. 9. Motivation - cont. Problems harder to manage every change require long compilation division to components is desired Ray Song Introduction to Makefile
  10. 10. Motivation - cont. Problems harder to manage every change require long compilation division to components is desired Ray Song Introduction to Makefile
  11. 11. Motivation - cont. Solution - Makefile Ray Song Introduction to Makefile
  12. 12. Makefile Makefile describes project structure instructions for files creation A makefile consists of many rules. Ray Song Introduction to Makefile
  13. 13. Makefile Makefile describes project structure instructions for files creation A makefile consists of many rules. Ray Song Introduction to Makefile
  14. 14. Makefile Makefile describes project structure instructions for files creation A makefile consists of many rules. Ray Song Introduction to Makefile
  15. 15. Makefile Makefile describes project structure instructions for files creation A makefile consists of many rules. Ray Song Introduction to Makefile
  16. 16. Rule syntax TARGETS: PREREQUISITES RECIPE In short, each rule describe instructions (RECIPE) to create files (TARGETS) with PREREQUISITES. PREREQUISITES are targets must be created prior to TARGETS. A target is considered old if its modification timestamp is smaller than one of its dependencies’s. Ray Song Introduction to Makefile
  17. 17. Rule syntax TARGETS: PREREQUISITES RECIPE In short, each rule describe instructions (RECIPE) to create files (TARGETS) with PREREQUISITES. PREREQUISITES are targets must be created prior to TARGETS. A target is considered old if its modification timestamp is smaller than one of its dependencies’s. Ray Song Introduction to Makefile
  18. 18. Rule syntax TARGETS: PREREQUISITES RECIPE In short, each rule describe instructions (RECIPE) to create files (TARGETS) with PREREQUISITES. PREREQUISITES are targets must be created prior to TARGETS. A target is considered old if its modification timestamp is smaller than one of its dependencies’s. Ray Song Introduction to Makefile
  19. 19. Makefile – cont. TARGETS and PREREQUISITES are file names separated by spaces. Usually there is only one target per rule. TARGETS and PREREQUISITES may contain wildcards, e.g. %.c. Each line of RECIPE starts with a TAB. The first rule indicates the default target (not counting targets that contain wildcards). Ray Song Introduction to Makefile
  20. 20. Makefile – cont. TARGETS and PREREQUISITES are file names separated by spaces. Usually there is only one target per rule. TARGETS and PREREQUISITES may contain wildcards, e.g. %.c. Each line of RECIPE starts with a TAB. The first rule indicates the default target (not counting targets that contain wildcards). Ray Song Introduction to Makefile
  21. 21. Makefile – cont. TARGETS and PREREQUISITES are file names separated by spaces. Usually there is only one target per rule. TARGETS and PREREQUISITES may contain wildcards, e.g. %.c. Each line of RECIPE starts with a TAB. The first rule indicates the default target (not counting targets that contain wildcards). Ray Song Introduction to Makefile
  22. 22. Makefile – cont. TARGETS and PREREQUISITES are file names separated by spaces. Usually there is only one target per rule. TARGETS and PREREQUISITES may contain wildcards, e.g. %.c. Each line of RECIPE starts with a TAB. The first rule indicates the default target (not counting targets that contain wildcards). Ray Song Introduction to Makefile
  23. 23. Makefile – cont. TARGETS and PREREQUISITES are file names separated by spaces. Usually there is only one target per rule. TARGETS and PREREQUISITES may contain wildcards, e.g. %.c. Each line of RECIPE starts with a TAB. The first rule indicates the default target (not counting targets that contain wildcards). Ray Song Introduction to Makefile
  24. 24. make’s mechanism make command reads a makefile and records these rules into its data base. GNU Make defaults to search GNUmakefile, makefile, Makefile in order, use the first of these which exists. The first goal (terminology used to refer to the list of targets you specified on the command line) should be created. Prerequisites which appeared in the target must be processed first. This is a recursive process (depth first search). After updating the dependencies , make decides whether it is necessary to recreated the target. This is the case when it is older than one of its dependencies. In the case we recreate the target, execute the associated recipe. Ray Song Introduction to Makefile
  25. 25. make’s mechanism make command reads a makefile and records these rules into its data base. GNU Make defaults to search GNUmakefile, makefile, Makefile in order, use the first of these which exists. The first goal (terminology used to refer to the list of targets you specified on the command line) should be created. Prerequisites which appeared in the target must be processed first. This is a recursive process (depth first search). After updating the dependencies , make decides whether it is necessary to recreated the target. This is the case when it is older than one of its dependencies. In the case we recreate the target, execute the associated recipe. Ray Song Introduction to Makefile
  26. 26. make’s mechanism make command reads a makefile and records these rules into its data base. GNU Make defaults to search GNUmakefile, makefile, Makefile in order, use the first of these which exists. The first goal (terminology used to refer to the list of targets you specified on the command line) should be created. Prerequisites which appeared in the target must be processed first. This is a recursive process (depth first search). After updating the dependencies , make decides whether it is necessary to recreated the target. This is the case when it is older than one of its dependencies. In the case we recreate the target, execute the associated recipe. Ray Song Introduction to Makefile
  27. 27. make’s mechanism make command reads a makefile and records these rules into its data base. GNU Make defaults to search GNUmakefile, makefile, Makefile in order, use the first of these which exists. The first goal (terminology used to refer to the list of targets you specified on the command line) should be created. Prerequisites which appeared in the target must be processed first. This is a recursive process (depth first search). After updating the dependencies , make decides whether it is necessary to recreated the target. This is the case when it is older than one of its dependencies. In the case we recreate the target, execute the associated recipe. Ray Song Introduction to Makefile
  28. 28. make’s mechanism make command reads a makefile and records these rules into its data base. GNU Make defaults to search GNUmakefile, makefile, Makefile in order, use the first of these which exists. The first goal (terminology used to refer to the list of targets you specified on the command line) should be created. Prerequisites which appeared in the target must be processed first. This is a recursive process (depth first search). After updating the dependencies , make decides whether it is necessary to recreated the target. This is the case when it is older than one of its dependencies. In the case we recreate the target, execute the associated recipe. Ray Song Introduction to Makefile
  29. 29. make’s mechanism make command reads a makefile and records these rules into its data base. GNU Make defaults to search GNUmakefile, makefile, Makefile in order, use the first of these which exists. The first goal (terminology used to refer to the list of targets you specified on the command line) should be created. Prerequisites which appeared in the target must be processed first. This is a recursive process (depth first search). After updating the dependencies , make decides whether it is necessary to recreated the target. This is the case when it is older than one of its dependencies. In the case we recreate the target, execute the associated recipe. Ray Song Introduction to Makefile
  30. 30. make’s mechanism - cont. make virtually construct a dependency DAG (directed acyclic graph). make ensures minimum compilation as long as the project structure is written properly. Do not write something like: prog: main.c sum1.c sum2.c gcc –o prog main.c sum1.c sum2.c which requires compilation of all project when something is changed Ray Song Introduction to Makefile
  31. 31. make’s mechanism - cont. make virtually construct a dependency DAG (directed acyclic graph). make ensures minimum compilation as long as the project structure is written properly. Do not write something like: prog: main.c sum1.c sum2.c gcc –o prog main.c sum1.c sum2.c which requires compilation of all project when something is changed Ray Song Introduction to Makefile
  32. 32. make’s mechanism - cont. make virtually construct a dependency DAG (directed acyclic graph). make ensures minimum compilation as long as the project structure is written properly. Do not write something like: prog: main.c sum1.c sum2.c gcc –o prog main.c sum1.c sum2.c which requires compilation of all project when something is changed Ray Song Introduction to Makefile
  33. 33. make’s mechanism - cont. make virtually construct a dependency DAG (directed acyclic graph). make ensures minimum compilation as long as the project structure is written properly. Do not write something like: prog: main.c sum1.c sum2.c gcc –o prog main.c sum1.c sum2.c which requires compilation of all project when something is changed Ray Song Introduction to Makefile
  34. 34. make’s mechanism - cont. make virtually construct a dependency DAG (directed acyclic graph). make ensures minimum compilation as long as the project structure is written properly. Do not write something like: prog: main.c sum1.c sum2.c gcc –o prog main.c sum1.c sum2.c which requires compilation of all project when something is changed Ray Song Introduction to Makefile
  35. 35. make’s mechanism - cont. make virtually construct a dependency DAG (directed acyclic graph). make ensures minimum compilation as long as the project structure is written properly. Do not write something like: prog: main.c sum1.c sum2.c gcc –o prog main.c sum1.c sum2.c which requires compilation of all project when something is changed Ray Song Introduction to Makefile
  36. 36. Automatic variables $@ $ˆ $< others including $, $?, $+, $|, $%, $(%D), %(F), . . . Ray Song Introduction to Makefile
  37. 37. Automatic variables $@ $ˆ $< others including $, $?, $+, $|, $%, $(%D), %(F), . . . Ray Song Introduction to Makefile
  38. 38. Automatic variables $@ $ˆ $< others including $, $?, $+, $|, $%, $(%D), %(F), . . . Ray Song Introduction to Makefile
  39. 39. Automatic variables $@ $ˆ $< others including $, $?, $+, $|, $%, $(%D), %(F), . . . Ray Song Introduction to Makefile
  40. 40. Example convert: cmdline.o convert.o g++ $ˆ -o $@ convert.o: convert.cpp convert.h g++ -c $< cmdline.o: cmdline.cpp cmdline.h convert.h g++ -c $< Ray Song Introduction to Makefile
  41. 41. Equivalent (implicit rules) make can dedude appropriate recipes according to suffixes convert: cmdline.o convert.o convert.o: convert.cpp convert.h cmdline.o: cmdline.cpp cmdline.h convert.h Ray Song Introduction to Makefile
  42. 42. Equivalent (implicit rules) - cont. convert: cmdline.o convert.o: convert.h cmdline.o: cmdline.h convert.h Ray Song Introduction to Makefile
  43. 43. Another example %.o: %.c gcc -c $< Ray Song Introduction to Makefile
  44. 44. Passing parameters test: FORCE echo $(VAR) FORCE: make VAR=hello make VAR=world Ray Song Introduction to Makefile
  45. 45. Passing parameters test: FORCE echo $(VAR) FORCE: make VAR=hello make VAR=world Ray Song Introduction to Makefile
  46. 46. Force targets Targets without recipes or prerequisites Ray Song Introduction to Makefile
  47. 47. Phony targets They do not correspond to real file. Provide some utility, e.g. cleaning intermediate files, archiving the whole project, creating TAGS file for some editors Forced to run its recipe upon executing. Ray Song Introduction to Makefile
  48. 48. Phony targets They do not correspond to real file. Provide some utility, e.g. cleaning intermediate files, archiving the whole project, creating TAGS file for some editors Forced to run its recipe upon executing. Ray Song Introduction to Makefile
  49. 49. Phony targets They do not correspond to real file. Provide some utility, e.g. cleaning intermediate files, archiving the whole project, creating TAGS file for some editors Forced to run its recipe upon executing. Ray Song Introduction to Makefile
  50. 50. Example all : prog1 prog2 prog3 .PHONY : all prog1 : prog1.o utils.o cc -o prog1 prog1.o utils.o prog2 : prog2.o cc -o prog2 prog2.o prog3 : prog3.o sort.o utils.o cc -o prog3 prog3.o sort.o utils.o Ray Song Introduction to Makefile
  51. 51. Practical options of make -n, print the commands to be run but do not execute them -t, touch files instead of running the recipes -B, unconditionally make all targets (overide timestamps) -W file, pretend file has been just modified -p, print the data base that results from reading the makefiles -d, debug mode others, RTFM Ray Song Introduction to Makefile
  52. 52. Practical options of make -n, print the commands to be run but do not execute them -t, touch files instead of running the recipes -B, unconditionally make all targets (overide timestamps) -W file, pretend file has been just modified -p, print the data base that results from reading the makefiles -d, debug mode others, RTFM Ray Song Introduction to Makefile
  53. 53. Practical options of make -n, print the commands to be run but do not execute them -t, touch files instead of running the recipes -B, unconditionally make all targets (overide timestamps) -W file, pretend file has been just modified -p, print the data base that results from reading the makefiles -d, debug mode others, RTFM Ray Song Introduction to Makefile
  54. 54. Practical options of make -n, print the commands to be run but do not execute them -t, touch files instead of running the recipes -B, unconditionally make all targets (overide timestamps) -W file, pretend file has been just modified -p, print the data base that results from reading the makefiles -d, debug mode others, RTFM Ray Song Introduction to Makefile
  55. 55. Practical options of make -n, print the commands to be run but do not execute them -t, touch files instead of running the recipes -B, unconditionally make all targets (overide timestamps) -W file, pretend file has been just modified -p, print the data base that results from reading the makefiles -d, debug mode others, RTFM Ray Song Introduction to Makefile
  56. 56. Practical options of make -n, print the commands to be run but do not execute them -t, touch files instead of running the recipes -B, unconditionally make all targets (overide timestamps) -W file, pretend file has been just modified -p, print the data base that results from reading the makefiles -d, debug mode others, RTFM Ray Song Introduction to Makefile
  57. 57. Practical options of make -n, print the commands to be run but do not execute them -t, touch files instead of running the recipes -B, unconditionally make all targets (overide timestamps) -W file, pretend file has been just modified -p, print the data base that results from reading the makefiles -d, debug mode others, RTFM Ray Song Introduction to Makefile
  58. 58. Other usage Makefile’s mechanism is not limited to programs LaTeX sources website deployment describe any task where some files need updating as a result of changes of other files Ray Song Introduction to Makefile
  59. 59. Other usage Makefile’s mechanism is not limited to programs LaTeX sources website deployment describe any task where some files need updating as a result of changes of other files Ray Song Introduction to Makefile
  60. 60. Other usage Makefile’s mechanism is not limited to programs LaTeX sources website deployment describe any task where some files need updating as a result of changes of other files Ray Song Introduction to Makefile
  61. 61. Other usage Makefile’s mechanism is not limited to programs LaTeX sources website deployment describe any task where some files need updating as a result of changes of other files Ray Song Introduction to Makefile
  62. 62. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  63. 63. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  64. 64. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  65. 65. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  66. 66. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  67. 67. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  68. 68. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  69. 69. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  70. 70. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  71. 71. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  72. 72. Additional features Variables (two flavors: simple and recursive, the latter is also called macros) Functions including string substitution, file name manipulation, foreach, even the the root of evil – eval VPATH Ability to manipulate archives(.a) Including other makefiles Conditionals Secondary expansion Order-only prerequisites Static patterns Double-colon rules Target/pattern-specific variable values Ray Song Introduction to Makefile
  73. 73. Acknowledgements This slide incorporate some stuff from Roded Sharan’s http://www.cs.tau.ac.il/~roded/courses/softp-b06/ Makefile.ppt Markdown http://daringfireball.net/projects/markdown/ in which this slide source is written. Pandoc http://johnmacfarlane.net/pandoc/ by which this slide is generated. Haskell http://www.haskell.org/ in which Pandoc is implemented. Ray Song Introduction to Makefile
  74. 74. Acknowledgements This slide incorporate some stuff from Roded Sharan’s http://www.cs.tau.ac.il/~roded/courses/softp-b06/ Makefile.ppt Markdown http://daringfireball.net/projects/markdown/ in which this slide source is written. Pandoc http://johnmacfarlane.net/pandoc/ by which this slide is generated. Haskell http://www.haskell.org/ in which Pandoc is implemented. Ray Song Introduction to Makefile
  75. 75. Acknowledgements This slide incorporate some stuff from Roded Sharan’s http://www.cs.tau.ac.il/~roded/courses/softp-b06/ Makefile.ppt Markdown http://daringfireball.net/projects/markdown/ in which this slide source is written. Pandoc http://johnmacfarlane.net/pandoc/ by which this slide is generated. Haskell http://www.haskell.org/ in which Pandoc is implemented. Ray Song Introduction to Makefile
  76. 76. Acknowledgements This slide incorporate some stuff from Roded Sharan’s http://www.cs.tau.ac.il/~roded/courses/softp-b06/ Makefile.ppt Markdown http://daringfireball.net/projects/markdown/ in which this slide source is written. Pandoc http://johnmacfarlane.net/pandoc/ by which this slide is generated. Haskell http://www.haskell.org/ in which Pandoc is implemented. Ray Song Introduction to Makefile
  77. 77. References GNU Make Manual http://www.gnu.org/software/make/manual/ Ray Song Introduction to Makefile

×