Created
September 6, 2018 09:51
-
-
Save yowcow/9b8ebc7ac7051a5a1271a571373a0480 to your computer and use it in GitHub Desktop.
Statically/dynamically cross-compile with CGO enabled/disabled
This file contains hidden or 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
STATIC := static-app | |
DYNAMIC := dynamic-app | |
all: $(STATIC) $(DYNAMIC) | |
$(MAKE) -f build.mk check FILE=$(STATIC) | |
$(MAKE) -f build.mk check FILE=$(DYNAMIC) | |
$(STATIC): | |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build --ldflags '-extldflags "-static"' -o $@ | |
$(DYNAMIC): | |
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -o $@ | |
check: | |
file $(FILE) || true | |
ldd $(FILE) || true | |
clean: | |
rm -f $(STATIC) $(DYNAMIC) | |
.PHONY: all check clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment