|
11 | 11 | SRCPATH := $(shell pwd)
|
12 | 12 | ARCH := $(shell ./scripts/archtype.sh)
|
13 | 13 | OS_TYPE := $(shell ./scripts/ostype.sh)
|
| 14 | +# overrides for cross-compiling platform-specific binaries |
| 15 | +ifdef CROSS_COMPILE_ARCH |
| 16 | + ARCH := $(CROSS_COMPILE_ARCH) |
| 17 | + GO_INSTALL := CGO_ENABLED=1 GOOS=$(OS_TYPE) GOARCH=$(ARCH) go build -o $(GOPATH1)/bin-$(OS_TYPE)-$(ARCH) |
| 18 | +else |
| 19 | + GO_INSTALL := go install |
| 20 | +endif |
14 | 21 | S3_RELEASE_BUCKET = $$S3_RELEASE_BUCKET
|
15 | 22 |
|
16 | 23 | GOLANG_VERSIONS := $(shell ./scripts/get_golang_version.sh all)
|
|
42 | 49 | export GOTESTCOMMAND=gotestsum --format pkgname --jsonfile testresults.json --
|
43 | 50 | endif
|
44 | 51 |
|
45 |
| -# M1 Mac--homebrew install location in /opt/homebrew |
46 | 52 | ifeq ($(OS_TYPE), darwin)
|
| 53 | +# For Xcode >= 15, set -no_warn_duplicate_libraries linker option |
| 54 | +CLANG_MAJOR_VERSION := $(shell clang --version | grep '^Apple clang version ' | awk '{print $$4}' | cut -d. -f1) |
| 55 | +ifeq ($(shell [ $(CLANG_MAJOR_VERSION) -ge 15 ] && echo true), true) |
| 56 | +EXTLDFLAGS := -Wl,-no_warn_duplicate_libraries |
| 57 | +endif |
| 58 | +# M1 Mac--homebrew install location in /opt/homebrew |
47 | 59 | ifeq ($(ARCH), arm64)
|
48 | 60 | export CPATH=/opt/homebrew/include
|
49 | 61 | export LIBRARY_PATH=/opt/homebrew/lib
|
@@ -102,6 +114,9 @@ fix: build
|
102 | 114 | lint: deps
|
103 | 115 | $(GOPATH1)/bin/golangci-lint run -c .golangci.yml
|
104 | 116 |
|
| 117 | +expectlint: |
| 118 | + cd test/e2e-go/cli/goal/expect && python3 expect_linter.py *.exp |
| 119 | + |
105 | 120 | check_go_version:
|
106 | 121 | @if [ $(CURRENT_GO_VERSION_MAJOR) != $(GOLANG_VERSION_BUILD_MAJOR) ]; then \
|
107 | 122 | echo "Wrong major version of Go installed ($(CURRENT_GO_VERSION_MAJOR)). Please use $(GOLANG_VERSION_BUILD_MAJOR)"; \
|
@@ -153,10 +168,40 @@ crypto/libs/$(OS_TYPE)/$(ARCH)/lib/libsodium.a:
|
153 | 168 | cp -R crypto/libsodium-fork/. crypto/copies/$(OS_TYPE)/$(ARCH)/libsodium-fork
|
154 | 169 | cd crypto/copies/$(OS_TYPE)/$(ARCH)/libsodium-fork && \
|
155 | 170 | ./autogen.sh --prefix $(SRCPATH)/crypto/libs/$(OS_TYPE)/$(ARCH) && \
|
156 |
| - ./configure --disable-shared --prefix="$(SRCPATH)/crypto/libs/$(OS_TYPE)/$(ARCH)" && \ |
| 171 | + ./configure --disable-shared --prefix="$(SRCPATH)/crypto/libs/$(OS_TYPE)/$(ARCH)" $(EXTRA_CONFIGURE_FLAGS) && \ |
157 | 172 | $(MAKE) && \
|
158 | 173 | $(MAKE) install
|
159 | 174 |
|
| 175 | +universal: |
| 176 | +ifeq ($(OS_TYPE),darwin) |
| 177 | + # build amd64 Mac binaries |
| 178 | + mkdir -p $(GOPATH1)/bin-darwin-amd64 |
| 179 | + CROSS_COMPILE_ARCH=amd64 GOBIN=$(GOPATH1)/bin-darwin-amd64 MACOSX_DEPLOYMENT_TARGET=12.0 EXTRA_CONFIGURE_FLAGS='CFLAGS="-arch x86_64 -mmacos-version-min=12.0" --host=x86_64-apple-darwin' $(MAKE) |
| 180 | + |
| 181 | + # build arm64 Mac binaries |
| 182 | + mkdir -p $(GOPATH1)/bin-darwin-arm64 |
| 183 | + CROSS_COMPILE_ARCH=arm64 GOBIN=$(GOPATH1)/bin-darwin-arm64 MACOSX_DEPLOYMENT_TARGET=12.0 EXTRA_CONFIGURE_FLAGS='CFLAGS="-arch arm64 -mmacos-version-min=12.0" --host=aarch64-apple-darwin' $(MAKE) |
| 184 | + |
| 185 | + # same for buildsrc-special |
| 186 | + cd tools/block-generator && \ |
| 187 | + CROSS_COMPILE_ARCH=amd64 GOBIN=$(GOPATH1)/bin-darwin-amd64 MACOSX_DEPLOYMENT_TARGET=12.0 EXTRA_CONFIGURE_FLAGS='CFLAGS="-arch x86_64 -mmacos-version-min=12.0" --host=x86_64-apple-darwin' $(MAKE) |
| 188 | + CROSS_COMPILE_ARCH=arm64 GOBIN=$(GOPATH1)/bin-darwin-arm64 MACOSX_DEPLOYMENT_TARGET=12.0 EXTRA_CONFIGURE_FLAGS='CFLAGS="-arch arm64 -mmacos-version-min=12.0" --host=aarch64-apple-darwin' $(MAKE) |
| 189 | + |
| 190 | + # lipo together |
| 191 | + mkdir -p $(GOPATH1)/bin |
| 192 | + for binary in $$(ls $(GOPATH1)/bin-darwin-arm64); do \ |
| 193 | + if [ -f $(GOPATH1)/bin-darwin-amd64/$$binary ]; then \ |
| 194 | + lipo -create -output $(GOPATH1)/bin/$$binary \ |
| 195 | + $(GOPATH1)/bin-darwin-arm64/$$binary \ |
| 196 | + $(GOPATH1)/bin-darwin-amd64/$$binary; \ |
| 197 | + else \ |
| 198 | + echo "Warning: Binary $$binary exists in arm64 but not in amd64"; \ |
| 199 | + fi \ |
| 200 | + done |
| 201 | +else |
| 202 | + echo "OS_TYPE must be darwin for universal builds, skipping" |
| 203 | +endif |
| 204 | + |
160 | 205 | deps:
|
161 | 206 | ./scripts/check_deps.sh
|
162 | 207 |
|
@@ -212,11 +257,11 @@ ${GOCACHE}/file.txt:
|
212 | 257 | touch "${GOCACHE}"/file.txt
|
213 | 258 |
|
214 | 259 | buildsrc: check-go-version crypto/libs/$(OS_TYPE)/$(ARCH)/lib/libsodium.a node_exporter NONGO_BIN ${GOCACHE}/file.txt
|
215 |
| - go install $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./... |
| 260 | + $(GO_INSTALL) $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./... |
216 | 261 |
|
217 | 262 | buildsrc-special:
|
218 | 263 | cd tools/block-generator && \
|
219 |
| - go install $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./... |
| 264 | + $(GO_INSTALL) $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./... |
220 | 265 |
|
221 | 266 | check-go-version:
|
222 | 267 | ./scripts/check_golang_version.sh build
|
@@ -331,7 +376,7 @@ dump: $(addprefix gen/,$(addsuffix /genesis.dump, $(NETWORKS)))
|
331 | 376 | install: build
|
332 | 377 | scripts/dev_install.sh -p $(GOPATH1)/bin
|
333 | 378 |
|
334 |
| -.PHONY: default fmt lint check_shell sanity cover prof deps build test fulltest shorttest clean cleango deploy node_exporter install %gen gen NONGO_BIN check-go-version rebuild_kmd_swagger |
| 379 | +.PHONY: default fmt lint check_shell sanity cover prof deps build test fulltest shorttest clean cleango deploy node_exporter install %gen gen NONGO_BIN check-go-version rebuild_kmd_swagger universal |
335 | 380 |
|
336 | 381 | ###### TARGETS FOR CICD PROCESS ######
|
337 | 382 | include ./scripts/release/mule/Makefile.mule
|
|
0 commit comments