Skip to content

Commit ca252f9

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 ca252f9

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Makefile

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

0 commit comments

Comments
 (0)