Created
December 22, 2015 01:54
-
-
Save robbles/67baa3c755e2919e4a5d to your computer and use it in GitHub Desktop.
Simple Makefile example for reference
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
# Find all files matching "src/*.go" and replace "src/%.go" with "bin/%" | |
OUTPUTS := $(patsubst src/%.go,bin/%,$(wildcard src/*.go)) | |
# Reference all files to be built in a single rule | |
all: $(OUTPUTS) | |
# Rule for compiling a single output file in bin/ | |
bin/%: src/%.go | |
# $* is replaced with the value of the wildcard in the rule (%) | |
go build -o bin/$* src/$*.go | |
# Treat "all" rule as phony, meaning make will not look for a file named "all" when running it | |
.PHONY: all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment