meta data for this page
  •  

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
programming:makefile [2024/03/22 09:29] niziakprogramming:makefile [2025/04/16 13:31] (current) niziak
Line 3: Line 3:
 Quick reference [[https://www.gnu.org/software/make/manual/html_node/Quick-Reference.html]] Quick reference [[https://www.gnu.org/software/make/manual/html_node/Quick-Reference.html]]
  
-[[http://aegis.sourceforge.net/auug97.pdf|Recursive Make Considered Harmfull]] +Recursive Make Considered Harmful: 
- +  * [[http://aegis.sourceforge.net/auug97.pdf|Recursive Make Considered Harmfull]] 
-[[http://make.mad-scientist.net/papers/rules-of-makefiles/]]+  * [[https://accu.org/journals/overload/14/71/miller_2004/|Recursive Make Considered Harmful]] 
 +  * [[https://news.ycombinator.com/item?id=20014348]] 
 +  [[http://make.mad-scientist.net/papers/rules-of-makefiles/]]
  
  
 === one shell === === one shell ===
  
 +NOTE: read carefully issues introduced with "one shell":
 [[https://www.gnu.org/software/make/manual/html_node/One-Shell.html|5.3.1 Using One Shell]] [[https://www.gnu.org/software/make/manual/html_node/One-Shell.html|5.3.1 Using One Shell]]
 +
 <code make> <code make>
 .ONESHELL: .ONESHELL:
Line 16: Line 20:
         cd $(<D)         cd $(<D)
         gobble $(<F) > ../$@         gobble $(<F) > ../$@
 +</code>
 +
 +alternatives w/o ''.ONESHELL''
 +
 +<code make>
 +target:
 + $(Q)( \
 + set -eo pipefail ; \
 + if [ -x "/opt/SEGGER/JLink/JLinkExe" ]; then \
 + echo "Skipping JLINK intallation (reason: already installed)."; \
 + exit 0; \
 + fi; \
 + \
 + wget -c -P /tmp --post-data "accept_license_agreement=accepted" --progress=dot:giga \
 + "https://www.segger.com/downloads/jlink/$(JLINK_VERSION).deb"; \
 + \
 + $(SUDO) apt-get update; \
 + $(SUDO) apt-get -y --fix-broken install "/tmp/$(JLINK_VERSION).deb"; \
 + \
 + rm "/tmp/${JLINK_VERSION}.deb"; \
 + make .jlink-workaround; \
 + make jlink-notice; \
 + )
 +
 </code> </code>
  
Line 37: Line 65:
  
 Special pipe "|" character is used.  Special pipe "|" character is used. 
-If any //$(objects)// has to be build, then //obj// has to be build first. +If any ''$(objects)'' has to be build, then ''obj'' has to be build first. 
-But if //obj// is out of date or missing, this doesn't force //$(objects)// to built.+But if ''obj'' is out of date or missing, this doesn't force ''$(objects)'' to built.
  
  
Line 45: Line 73:
  
 obj: obj:
-  @mkdir -p $@''+  @mkdir -p $@
 </code> </code>
  
Line 81: Line 109:
     * if no prereq, command is always executed     * if no prereq, command is always executed
   * Order of execution is not guaranteed   * Order of execution is not guaranteed
- 
-=== macros === 
- 
-  * *$(dir /path/to/file.txt)* get path part only 
-  * *$(basename src/foo.c src-1.0/bar hacks)* - produces the result ‘src/foo src-1.0/bar hacks’.  
-  * *$(notdir src/foo.c hacks)* - result ‘foo.c hacks’.  
- 
  
 ====== Parallel make ====== ====== Parallel make ======