Add a static build target to Makefile
This allows us to build a static binary for all three binaries, from the make file using ``make static``. Signed-off-by: Ken Cochrane <KenCochrane@gmail.com>
This commit is contained in:
		
							
								
								
									
										17
									
								
								Makefile
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								Makefile
									
									
									
									
									
								
							| @@ -2,7 +2,7 @@ BUILDTAGS= | |||||||
|  |  | ||||||
| GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true) | GIT_COMMIT := $(shell git rev-parse HEAD 2> /dev/null || true) | ||||||
|  |  | ||||||
| LDFLAGS := "-X github.com/docker/containerd.GitCommit=${GIT_COMMIT} ${LDFLAGS}" | LDFLAGS := -X github.com/docker/containerd.GitCommit=${GIT_COMMIT} ${LDFLAGS} | ||||||
|  |  | ||||||
| # if this session isn't interactive, then we don't want to allocate a | # if this session isn't interactive, then we don't want to allocate a | ||||||
| # TTY, which would fail, but if it is interactive, we do want to attach | # TTY, which would fail, but if it is interactive, we do want to attach | ||||||
| @@ -19,6 +19,8 @@ export GOPATH:=$(CURDIR)/vendor:$(GOPATH) | |||||||
|  |  | ||||||
| all: client daemon shim | all: client daemon shim | ||||||
|  |  | ||||||
|  | static: client-static daemon-static shim-static | ||||||
|  |  | ||||||
| bin: | bin: | ||||||
| 	mkdir -p bin/ | 	mkdir -p bin/ | ||||||
|  |  | ||||||
| @@ -26,14 +28,23 @@ clean: | |||||||
| 	rm -rf bin | 	rm -rf bin | ||||||
|  |  | ||||||
| client: bin | client: bin | ||||||
| 	cd ctr && go build -ldflags ${LDFLAGS} -o ../bin/ctr | 	cd ctr && go build -ldflags "${LDFLAGS}" -o ../bin/ctr | ||||||
|  |  | ||||||
|  | client-static: | ||||||
|  | 	cd ctr && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/ctr | ||||||
|  |  | ||||||
| daemon: bin | daemon: bin | ||||||
| 	cd containerd && go build -ldflags ${LDFLAGS}  -tags "$(BUILDTAGS)" -o ../bin/containerd | 	cd containerd && go build -ldflags "${LDFLAGS}"  -tags "$(BUILDTAGS)" -o ../bin/containerd | ||||||
|  |  | ||||||
|  | daemon-static: | ||||||
|  | 	cd containerd && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd | ||||||
|  |  | ||||||
| shim: bin | shim: bin | ||||||
| 	cd containerd-shim && go build -tags "$(BUILDTAGS)" -o ../bin/containerd-shim | 	cd containerd-shim && go build -tags "$(BUILDTAGS)" -o ../bin/containerd-shim | ||||||
|  |  | ||||||
|  | shim-static: | ||||||
|  | 	cd containerd-shim && go build -ldflags "-w -extldflags -static ${LDFLAGS}" -tags "$(BUILDTAGS)" -o ../bin/containerd-shim | ||||||
|  |  | ||||||
| dbuild: | dbuild: | ||||||
| 	@docker build --rm --force-rm -t "$(DOCKER_IMAGE)" . | 	@docker build --rm --force-rm -t "$(DOCKER_IMAGE)" . | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ken Cochrane
					Ken Cochrane