-
Notifications
You must be signed in to change notification settings - Fork 162
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·24 lines (18 loc) · 910 Bytes
/
Copy pathbuild.sh
File metadata and controls
executable file
·24 lines (18 loc) · 910 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env bash
# build.sh — local cross-compile helper
# Usage: ./build.sh [version]
# version defaults to the output of `git describe --tags --always`
set -e
VERSION="${1:-$(git describe --tags --always 2>/dev/null || echo 'dev')}"
LDFLAGS="-X github.com/boy-hack/ksubdomain/v2/pkg/core/conf.Version=${VERSION}"
echo "Building version: ${VERSION}"
# Linux amd64 (static libpcap required on the build host)
CGO_LDFLAGS="-Wl,-static -L/usr/lib/x86_64-linux-gnu/libpcap.a -lpcap -Wl,-Bdynamic -ldbus-1 -lsystemd" \
GOOS=linux GOARCH=amd64 \
go build -ldflags "${LDFLAGS}" -o ./ksubdomain_linux_amd64 ./cmd/ksubdomain/
echo " -> ksubdomain_linux_amd64"
# Windows amd64 (CGO disabled; npcap is linked at runtime)
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 \
go build -ldflags "${LDFLAGS}" -o ./ksubdomain_windows_amd64.exe ./cmd/ksubdomain/
echo " -> ksubdomain_windows_amd64.exe"
echo "Done."