Last active
August 27, 2021 17:03
-
-
Save paytonrules/9faaa54e1497f5dad7be12d7ee772c25 to your computer and use it in GitHub Desktop.
A Cheat Sheet for a bunch of the stuff we did I my Makefile talk
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make # runs the first target in the makefile named Makefile | |
make -f MyMakefile # Runs the first target in the Makefile named MyMakefile | |
make -f MyMakefile app # Runs the target called app | |
make -f MyMakefile app --dry-run # Does a dry run of the target called app | |
make -f MyMakefile app --debug=v --dry-run # Turns on verbose debugging for a command | |
# Sending parameters at the end of a command | |
# In this case the parameter is not set with ?= in the Makefile | |
make <task-name> VAR_NAME=value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I haven't tried this bugt I don't want to lose thie idea, a self documenting Makefile | |
# https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html | |
# When I try it I'll update this, hopefully. | |
# Basic Syntax | |
target: dependency dependency2 ... | |
command1 | |
command2 | |
# Note that those must BE TABs | |
# Setting variables | |
variable_name = "blah" | |
# Expanding variables | |
target: $(variable_name) | |
# Remember in Make everything is just text | |
# Settting Variables that can be overridden at the command line | |
VARIABLE_NAME_2 ?= "blah blah" | |
# Overriding at the command line is then done by | |
# VARIABLE_NAME_2 = "not blah" make | |
# Finding files in a path with wildcard | |
files = $(wildcard path) | |
# Phony targets (ergo - tasks) | |
.PHONY: taskname | |
# Ignoring errors in commands | |
clean: | |
# Add a dash before each line | |
-rm filename | |
-rm filename | |
# Testing variable presence | |
check: | |
test -n $(VARNAME) | |
# To Add | |
# := vs = vs ?= | |
# recursive search (wildcard doesn't do it) | |
# The automatic variables | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
From Chris Wilson TIL:
Makefile recipe for checking that environment variables are present before attempting to run a rule. You can add additional variables to the check-env rule.