Skip to content

Instantly share code, notes, and snippets.

@MaitreyaBuddha
Created March 9, 2015 21:21
Show Gist options
  • Select an option

  • Save MaitreyaBuddha/3de3afe7c6dfde72f8fb to your computer and use it in GitHub Desktop.

Select an option

Save MaitreyaBuddha/3de3afe7c6dfde72f8fb to your computer and use it in GitHub Desktop.
Example makefile with simplest usage for use with most jobs
##########################################################
#
# Example makefile
#
##########################################################
# The top item will run with just `make`, same as `make all`
# This will trigger dependencies, then run
all: silent dependency1 variable environment
echo Everything has been made # this line will be printed
# An @ sign at the beginning will not print the command
silent:
@echo ^^^ no command printed above me
# This shows linked dependencies
dependency1: dependency2
@echo executing number one
# Must run before dependency1
dependency2:
@echo executing dependency of number one
# This is how to use a variable. Run this on its own with `make variable`
VAR:=variable
C:=plane
variable:
@echo executing $(VAR) # You must wrap in () or make will just use the first letter
@echo This is not the right $CAR # like this
# This works for environment variables as well. `make environment`
environment:
echo $(PATH)
# Need to pass variables into a script? No problem, export them
NOTEXPORTED:=this is not blank
export EXPORTED:=exports
exported:
./export.sh
# This will fail out of make. Run with `make fail`, or add as a dependency somewhere
fail:
@echo this will fail
@exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment