diff --git a/Makefile b/Makefile index 0ea26956dff..c9dc4546399 100644 --- a/Makefile +++ b/Makefile @@ -78,11 +78,14 @@ PROTOS = $(shell git ls-files *.proto | grep -v vendor) MSP_SAMPLECONFIG = $(shell git ls-files msp/sampleconfig/*) PROJECT_FILES = $(shell git ls-files) IMAGES = peer orderer ccenv javaenv buildenv testenv zookeeper kafka couchdb +RELEASE_PLATFORMS = windows-amd64 darwin-amd64 linux-amd64 linux-ppc64le linux-s390x +RELEASE_PKGS = configtxgen cryptogen pkgmap.configtxgen := $(PKGNAME)/common/configtx/tool/configtxgen pkgmap.peer := $(PKGNAME)/peer pkgmap.orderer := $(PKGNAME)/orderer pkgmap.block-listener := $(PKGNAME)/examples/events/block-listener +pkgmap.cryptogen := $(PKGNAME)/common/tools/cryptogen include docker-env.mk @@ -266,6 +269,49 @@ build/%.tar.bz2: @echo "Creating $@" @tar -jc $^ > $@ +# builds release packages for the host platform +release: $(patsubst %,release/%, $(shell go env GOOS)-$(shell go env GOARCH)) + +# builds release packages for all target platforms +release-all: $(patsubst %,release/%, $(RELEASE_PLATFORMS)) + +release/windows-amd64: GOOS=windows +release/windows-amd64: GOARCH=amd64 +release/windows-amd64: GO_TAGS+= nopkcs11 +release/windows-amd64: $(patsubst %,release/windows-amd64/%, $(RELEASE_PKGS)) + +release/darwin-amd64: GOOS=darwin +release/darwin-amd64: GOARCH=amd64 +release/darwin-amd64: GO_TAGS+= nopkcs11 +release/darwin-amd64: $(patsubst %,release/darwin-amd64/%, $(RELEASE_PKGS)) + +release/linux-amd64: GOOS=linux +release/linux-amd64: GOARCH=amd64 +release/linux-amd64: GO_TAGS+= nopkcs11 +release/linux-amd64: $(patsubst %,release/linux-amd64/%, $(RELEASE_PKGS)) + +release/linux-ppc64le: GOOS=linux +release/linux-ppc64le: GOARCH=ppc64le +release/linux-ppc64le: GO_TAGS+= nopkcs11 +release/linux-ppc64le: $(patsubst %,release/linux-ppc64le/%, $(RELEASE_PKGS)) + +release/linux-s390x: GOOS=linux +release/linux-s390x: GOARCH=s390x +release/linux-s390x: GO_TAGS+= nopkcs11 +release/linux-s390x: $(patsubst %,release/linux-s390x/%, $(RELEASE_PKGS)) + +release/%/configtxgen: $(PROJECT_FILES) + @echo "Building $@ for $(GOOS)-$(GOARCH)" + mkdir -p $(@D) + $(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F)) + @touch $@ + +release/%/cryptogen: $(PROJECT_FILES) + @echo "Building $@ for $(GOOS)-$(GOARCH)" + mkdir -p $(@D) + $(CGO_FLAGS) GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o $(abspath $@) -tags "$(GO_TAGS)" -ldflags "$(GO_LDFLAGS)" $(pkgmap.$(@F)) + @touch $@ + .PHONY: protos protos: buildenv @$(DRUN) $(DOCKER_NS)/fabric-buildenv:$(DOCKER_TAG) ./scripts/compile_protos.sh @@ -285,6 +331,10 @@ clean: docker-clean unit-test-clean dist-clean: clean gotools-clean -@rm -rf /var/hyperledger/* ||: +.PHONY: release-clean +release-clean: + -@rm -rf release + .PHONY: unit-test-clean unit-test-clean: cd unit-test && docker-compose down