github.com/erroneousboat/dot@v0.0.0-20170402193747-d2fd504d98ec/Makefile (about) 1 APP_NAME=dot 2 3 default: build 4 5 # -timeout timout in seconds 6 # -v verbose output 7 test: 8 go test -timeout=5s -v 9 10 # `CGO_ENABLED=0` 11 # Because of dynamically linked libraries, this will statically compile the 12 # app with all libraries built in. You won't be able to cross-compile if CGO 13 # is enabled. This is because Go binary is looking for libraries on the 14 # operating system it’s running in. We compiled our app, but it still is 15 # dynamically linked to the libraries it needs to run 16 # (i.e., all the C libraries it binds to). When using a minimal docker image 17 # the operating system doesn't have these libraries. 18 # 19 # `-a` 20 # Force rebuilding of package, all import will be rebuilt with cgo disabled, 21 # which means all the imports will be rebuilt with cgo disabled. 22 # 23 # `-installsuffix cgo` 24 # A suffix to use in the name of the package installation directory 25 # 26 # `-o` 27 # Output 28 # 29 # `./bin/[name-of-app]` 30 # Placement of the binary 31 # 32 # `.` 33 # Location of the source files 34 build: 35 CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/${APP_NAME} . 36 37 # Cross-compile 38 # http://dave.cheney.net/2015/08/22/cross-compilation-with-go-1-5 39 build-linux: 40 GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/${APP_NAME}-linux-amd64 . 41 42 build-mac: 43 GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -a -installsuffix cgo -o ./bin/${APP_NAME}-darwin-amd64 . 44 45 .PHONY: default test build build-linux build-mac