Skip to content

Commit c624e43

Browse files
committed
makefile: add lean cross-compile build
Different platforms can now be cross-compiled wihtout packing all the source and vendor packages.
1 parent c52a6dd commit c624e43

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

Makefile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,22 @@ release-install:
145145
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lnd
146146
env CGO_ENABLED=0 $(GOINSTALL) -v -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" $(PKG)/cmd/lncli
147147

148+
#? cross-release-install: Build lnd and lncli release binaries for single/all supported platforms to /tmp (useful for checking cross compilation or priming release build cache).
149+
cross-release-install:
150+
@$(call print, "Cross compiling release lnd and lncli.")
151+
for sys in $(BUILD_SYSTEM); do \
152+
echo "Building lnd and lncli for $$sys"; \
153+
export CGO_ENABLED=0 GOOS=$$(echo $$sys | cut -d- -f1) GOARCH=$$(echo $$sys | cut -d- -f2); \
154+
if [ "$$GOARCH" = "armv6" ]; then \
155+
export GOARCH=arm; GOARM=6; \
156+
elif [ "$$GOARCH" = "armv7" ]; then \
157+
export GOARCH=arm; GOARM=7; \
158+
fi; \
159+
$(GOBUILD) -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" -o /tmp/lnd-$$sys $(PKG)/cmd/lnd; \
160+
$(GOBUILD) -trimpath -ldflags="$(RELEASE_LDFLAGS)" -tags="$(RELEASE_TAGS)" -o /tmp/lncli-$$sys $(PKG)/cmd/lncli; \
161+
echo; \
162+
done
163+
148164
#? release: Build the full set of reproducible release binaries for all supported platforms
149165
# Make sure the generated mobile RPC stubs don't influence our vendor package
150166
# by removing them first in the clean-mobile target.

0 commit comments

Comments
 (0)