github.com/Blockdaemon/celo-blockchain@v0.0.0-20200129231733-e667f6b08419/Makefile (about)

     1  # This Makefile is meant to be used by people that do not usually work
     2  # with Go source code. If you know what GOPATH is then you probably
     3  # don't need to bother with make.
     4  
     5  .PHONY: geth android ios geth-cross swarm evm all test clean
     6  .PHONY: geth-linux geth-linux-386 geth-linux-amd64 geth-linux-mips64 geth-linux-mips64le
     7  .PHONY: geth-linux-arm geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
     8  .PHONY: geth-darwin geth-darwin-386 geth-darwin-amd64
     9  .PHONY: geth-windows geth-windows-386 geth-windows-amd64
    10  
    11  GOBIN = $(shell pwd)/build/bin
    12  GO ?= latest
    13  
    14  CARGO_exists := $(shell command -v cargo 2> /dev/null)
    15  RUSTUP_exists := $(shell command -v rustup 2> /dev/null)
    16  CARGO_LIPO_exists := $(shell command -v cargo-lipo 2> /dev/null)
    17  LSB_exists := $(shell command -v lsb_release 2> /dev/null)
    18  
    19  ifdef CARGO_exists
    20  .PHONY: vendor/github.com/celo-org/bls-zexe/bls/target/release/libbls_zexe.a
    21  endif
    22  
    23  OS :=
    24  ifeq ("$(LSB_exists)","")
    25  	OS = darwin
    26  else
    27  	OS = linux
    28  endif
    29  
    30  # example NDK values
    31  export NDK_VERSION ?= android-ndk-r19c
    32  export ANDROID_NDK ?= $(PWD)/ndk_bundle/$(NDK_VERSION)
    33  
    34  geth: bls-zexe
    35  	build/env.sh go run build/ci.go install ./cmd/geth
    36  	@echo "Done building."
    37  	@echo "Run \"$(GOBIN)/geth\" to launch geth."
    38  
    39  bls-zexe: vendor/github.com/celo-org/bls-zexe/bls/target/release/libbls_zexe.a
    40  
    41  check_android_env:
    42  	@test $${ANDROID_NDK?Please set environment variable ANDROID_NDK}
    43  	@test $${ANDROID_HOME?Please set environment variable ANDROID_HOME}
    44  
    45  ndk_bundle: check_android_env
    46  ifeq ("$(wildcard $(ANDROID_NDK))","")
    47  	@test $${NDK_VERSION?Please set environment variable NDK_VERSION}
    48  	curl --silent --show-error --location --fail --retry 3 --output /tmp/$(NDK_VERSION).zip \
    49  		https://dl.google.com/android/repository/$(NDK_VERSION)-$(OS)-x86_64.zip && \
    50  		rm -rf $(ANDROID_NDK) && \
    51  		mkdir -p $(ANDROID_NDK) && \
    52  		unzip -q /tmp/$(NDK_VERSION).zip -d $(ANDROID_NDK)/.. && \
    53  		rm /tmp/$(NDK_VERSION).zip
    54  else
    55  ifeq ("$(wildcard $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64)","")
    56  	$(error "Android NDK is installed but doesn't contain an llvm cross-compilation toolchain. Delete your current NDK or modify the ANDROID_NDK environment variable to an empty directory download it automatically.")
    57  endif
    58  endif
    59  
    60  
    61  bls-zexe-android: check_android_env ndk_bundle
    62  ifeq ("$(RUSTUP_exists)","")
    63  	$(error "No rustup in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md to install Rust.")
    64  else
    65  	rustup target add aarch64-linux-android
    66  	rustup target add armv7-linux-androideabi
    67  	rustup target add i686-linux-android
    68  	rustup target add x86_64-linux-android
    69  	cd $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin && \
    70  		ln -s aarch64-linux-android21-clang aarch64-linux-android-clang; test aarch64-linux-android-clang && \
    71  		ln -s armv7a-linux-androideabi16-clang arm-linux-androideabi-clang; test arm-linux-androideabi-clang && \
    72  		ln -s i686-linux-android16-clang i686-linux-android-clang; test i686-linux-android-clang && \
    73  		ln -s x86_64-linux-android21-clang x86_64-linux-android-clang; test x86_64-linux-android-clang
    74  
    75  	cd $(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin && \
    76  		test -f aarch64-linux-android-clang && \
    77  		test -f arm-linux-androideabi-clang && \
    78  		test -f i686-linux-android-clang && \
    79  		test -f x86_64-linux-android-clang
    80  
    81  	PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/aarch64-linux-android-4.9/prebuilt/$(OS)-x86_64/bin" && \
    82  			 cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --release --target=aarch64-linux-android --lib
    83  
    84  	PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(OS)-x86_64/bin" && \
    85  			 cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --release --target=armv7-linux-androideabi --lib
    86  
    87  	PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/aarch64-linux-android-4.9/prebuilt/$(OS)-x86_64/bin" && \
    88  			 cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --release --target=i686-linux-android --lib
    89  
    90  	PATH="$$PATH:$(ANDROID_NDK)/toolchains/llvm/prebuilt/$(OS)-x86_64/bin:$(ANDROID_NDK)/toolchains/aarch64-linux-android-4.9/prebuilt/$(OS)-x86_64/bin" && \
    91  			 cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --release --target=x86_64-linux-android --lib
    92  endif
    93  
    94  bls-zexe-ios:
    95  ifeq ("$(RUSTUP_exists)","")
    96  	$(error "No rustup in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md")
    97  else 
    98  ifeq ("$(CARGO_LIPO_exists)","")
    99  	cargo install cargo-lipo
   100  endif
   101  	rustup target add aarch64-apple-ios armv7-apple-ios x86_64-apple-ios i386-apple-ios
   102  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo lipo --release --targets=aarch64-apple-ios,armv7-apple-ios,x86_64-apple-ios,i386-apple-ios
   103  endif
   104  
   105  vendor/github.com/celo-org/bls-zexe/bls/target/release/libbls_zexe.a:
   106  ifeq ("$(CARGO_exists)","")
   107  	$(error "No cargo in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md")
   108  else
   109  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --release && cargo build --release --example pop
   110  endif
   111  
   112  swarm:
   113  	build/env.sh go run build/ci.go install ./cmd/swarm
   114  	@echo "Done building."
   115  	@echo "Run \"$(GOBIN)/swarm\" to launch swarm."
   116  
   117  all: bls-zexe
   118  	build/env.sh go run build/ci.go install
   119  
   120  android: bls-zexe-android
   121  	ANDROID_NDK_HOME=$(ANDROID_NDK) build/env.sh go run build/ci.go aar --local
   122  	@echo "Done building."
   123  	@echo "Import \"$(GOBIN)/geth.aar\" to use the library."
   124  
   125  ios: bls-zexe-ios
   126  	build/env.sh go run build/ci.go xcode --local
   127  	pushd "$(GOBIN)"; rm -rf Geth.framework.zip; zip -r9y Geth.framework.zip Geth.framework; popd
   128  	@echo "Done building."
   129  	@echo "Import \"$(GOBIN)/Geth.framework\" to use the library."
   130  
   131  test: all
   132  	build/env.sh go run build/ci.go test
   133  
   134  lint: ## Run linters.
   135  	build/env.sh go run build/ci.go lint
   136  
   137  clean-geth:
   138  	./build/clean_go_build_cache.sh
   139  	rm -fr build/_workspace/pkg/ $(GOBIN)/*
   140  
   141  clean-bls-zexe:
   142  	rm -rf vendor/github.com/celo-org/bls-zexe/bls/target
   143  
   144  clean: clean-geth clean-bls-zexe
   145  
   146  
   147  # The devtools target installs tools required for 'go generate'.
   148  # You need to put $GOBIN (or $GOPATH/bin) in your PATH to use 'go generate'.
   149  
   150  devtools:
   151  	env GOBIN= go get -u golang.org/x/tools/cmd/stringer
   152  	env GOBIN= go get -u github.com/kevinburke/go-bindata/go-bindata
   153  	env GOBIN= go get -u github.com/fjl/gencodec
   154  	env GOBIN= go get -u github.com/golang/protobuf/protoc-gen-go
   155  	env GOBIN= go install ./cmd/abigen
   156  	@type "npm" 2> /dev/null || echo 'Please install node.js and npm'
   157  	@type "solc" 2> /dev/null || echo 'Please install solc'
   158  	@type "protoc" 2> /dev/null || echo 'Please install protoc'
   159  
   160  swarm-devtools:
   161  	env GOBIN= go install ./cmd/swarm/mimegen
   162  
   163  # Cross Compilation Targets (xgo)
   164  
   165  geth-cross: geth-linux geth-darwin geth-windows geth-android geth-ios
   166  	@echo "Full cross compilation done:"
   167  	@ls -ld $(GOBIN)/geth-*
   168  
   169  geth-linux: geth-linux-386 geth-linux-amd64 geth-linux-arm geth-linux-mips64 geth-linux-mips64le
   170  	@echo "Linux cross compilation done:"
   171  	@ls -ld $(GOBIN)/geth-linux-*
   172  
   173  geth-linux-386:
   174  	rustup target add i686-unknown-linux-gnu
   175  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=i686-unknown-linux-gnu --release
   176  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/386 -v ./cmd/geth
   177  	@echo "Linux 386 cross compilation done:"
   178  	@ls -ld $(GOBIN)/geth-linux-* | grep 386
   179  
   180  geth-linux-amd64:
   181  	rustup target add x86_64-unknown-linux-gnu
   182  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=x86_64-unknown-linux-gnu --release
   183  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/amd64 -v ./cmd/geth
   184  	@echo "Linux amd64 cross compilation done:"
   185  	@ls -ld $(GOBIN)/geth-linux-* | grep amd64
   186  
   187  geth-linux-arm: geth-linux-arm-5 geth-linux-arm-6 geth-linux-arm-7 geth-linux-arm64
   188  	@echo "Linux ARM cross compilation done:"
   189  	@ls -ld $(GOBIN)/geth-linux-* | grep arm
   190  
   191  geth-linux-arm-5:
   192  	# requires an arm compiler, on Ubuntu: sudo apt-get install gcc-arm-linux-gnueabi g++-arm-linux-gnueabi
   193  	rustup target add arm-unknown-linux-gnueabi
   194  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=arm-unknown-linux-gnueabi --release
   195  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-5 -v ./cmd/geth
   196  	@echo "Linux ARMv5 cross compilation done:"
   197  	@ls -ld $(GOBIN)/geth-linux-* | grep arm-5
   198  
   199  geth-linux-arm-6:
   200  	rustup target add arm-unknown-linux-gnueabi
   201  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=arm-unknown-linux-gnueabi --release
   202  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-6 -v ./cmd/geth
   203  	@echo "Linux ARMv6 cross compilation done:"
   204  	@ls -ld $(GOBIN)/geth-linux-* | grep arm-6
   205  
   206  geth-linux-arm-7:
   207  	# requires an arm compiler, on Ubuntu: sudo apt-get install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf
   208  	rustup target add arm-unknown-linux-gnueabihf
   209  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=arm-unknown-linux-gnueabihf --release
   210  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm-7 -v  --tags arm7 ./cmd/geth
   211  	@echo "Linux ARMv7 cross compilation done:"
   212  	@ls -ld $(GOBIN)/geth-linux-* | grep arm-7
   213  
   214  geth-linux-arm64:
   215  	# requires an arm64 compiler, on Ubuntu: sudo apt-get install gcc-aarch64-linux-gnu	g++-aarch64-linux-gnu
   216  	rustup target add aarch64-unknown-linux-gnu
   217  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=aarch64-unknown-linux-gnu --release
   218  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/arm64 -v ./cmd/geth
   219  	@echo "Linux ARM64 cross compilation done:"
   220  	@ls -ld $(GOBIN)/geth-linux-* | grep arm64
   221  
   222  geth-linux-mips:
   223  	# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mips-linux-gnu
   224  	rustup target add mips-unknown-linux-gnu
   225  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=mips-unknown-linux-gnu --release
   226  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips --ldflags '-extldflags "-static"' -v ./cmd/geth
   227  	@echo "Linux MIPS cross compilation done:"
   228  	@ls -ld $(GOBIN)/geth-linux-* | grep mips
   229  
   230  geth-linux-mipsle:
   231  	# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mipsel-linux-gnu
   232  	rustup target add mipsel-unknown-linux-gnu
   233  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=mipsel-unknown-linux-gnu --release
   234  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mipsle --ldflags '-extldflags "-static"' -v ./cmd/geth
   235  	@echo "Linux MIPSle cross compilation done:"
   236  	@ls -ld $(GOBIN)/geth-linux-* | grep mipsle
   237  
   238  geth-linux-mips64:
   239  	# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mips64-linux-gnuabi64
   240  	rustup target add mips64-unknown-linux-gnuabi64
   241  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=mips64-unknown-linux-gnuabi64 --release
   242  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64 --ldflags '-extldflags "-static"' -v ./cmd/geth
   243  	@echo "Linux MIPS64 cross compilation done:"
   244  	@ls -ld $(GOBIN)/geth-linux-* | grep mips64
   245  
   246  geth-linux-mips64le:
   247  	# requires a mips compiler, on Ubuntu: sudo apt-get install gcc-mips64el-linux-gnuabi64
   248  	rustup target add mips64el-unknown-linux-gnuabi64
   249  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=mips64el-unknown-linux-gnuabi64 --release
   250  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=linux/mips64le --ldflags '-extldflags "-static"' -v ./cmd/geth
   251  	@echo "Linux MIPS64le cross compilation done:"
   252  	@ls -ld $(GOBIN)/geth-linux-* | grep mips64le
   253  
   254  geth-darwin: geth-darwin-386 geth-darwin-amd64
   255  	@echo "Darwin cross compilation done:"
   256  	@ls -ld $(GOBIN)/geth-darwin-*
   257  
   258  geth-darwin-386:
   259  	# needs include files for asm errno, on Ubuntu: sudo apt-get install linux-libc-dev:i386
   260  	# currently doesn't compile on Ubuntu
   261  	rustup target add i686-apple-darwin
   262  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=i686-apple-darwin --release
   263  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/386 -v ./cmd/geth
   264  	@echo "Darwin 386 cross compilation done:"
   265  	@ls -ld $(GOBIN)/geth-darwin-* | grep 386
   266  
   267  geth-darwin-amd64:
   268  	# needs include files for asm errno, on Ubuntu: sudo apt-get install linux-libc-dev
   269  	# currently doesn't compile on Ubuntu
   270  	rustup target add x86_64-apple-darwin
   271  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=x86_64-apple-darwin --release
   272  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=darwin/amd64 -v ./cmd/geth
   273  	@echo "Darwin amd64 cross compilation done:"
   274  	@ls -ld $(GOBIN)/geth-darwin-* | grep amd64
   275  
   276  geth-windows: geth-windows-386 geth-windows-amd64
   277  	@echo "Windows cross compilation done:"
   278  	@ls -ld $(GOBIN)/geth-windows-*
   279  
   280  geth-windows-386:
   281  	# currently doesn't compile on Ubuntu, missing libunwind in xgo
   282  	rustup target add i686-pc-windows-msvc
   283  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=i686-pc-windows-msvc --release
   284  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/386 -v ./cmd/geth
   285  	@echo "Windows 386 cross compilation done:"
   286  	@ls -ld $(GOBIN)/geth-windows-* | grep 386
   287  
   288  geth-windows-amd64:
   289  	# currently doesn't compile on Ubuntu, missing libunwind in xgo
   290  	rustup target add x86_64-pc-windows-gnu
   291  	cd vendor/github.com/celo-org/bls-zexe/bls && cargo build --target=x86_64-pc-windows-gnu --release
   292  	build/env.sh go run build/ci.go xgo -- --go=$(GO) --targets=windows/amd64 -v ./cmd/geth
   293  	@echo "Windows amd64 cross compilation done:"
   294  	@ls -ld $(GOBIN)/geth-windows-* | grep amd64