Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 35 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,55 @@
include Makefile.bootfiles

GO:=go
GO_FLAGS:=-ldflags "-s -w" # strip Go binaries
CGO_ENABLED:=0
GOMODVENDOR:=
# C settings

# enable loading kernel modules in init
KMOD:=0

CFLAGS:=-O2 -Wall
LDFLAGS:=-static -s #strip C binaries
LDLIBS:=
PREPROCESSORFLAGS:=
ifeq "$(KMOD)" "1"
LDFLAGS:= -s
LDLIBS:= -lkmod
LDFLAGS:=-s
LDLIBS:=-lkmod
PREPROCESSORFLAGS:=-DMODULES=1
endif

# Go settings

# if Go is from the Microsoft Go fork
MSGO:=0
# explicitly use vendored modules when building
GOMODVENDOR:=
# Go tags to enable
GO_BUILD_TAGS:=
# additional Go build flags
GO_FLAGS_EXTRA:=
# use CGO
CGO_ENABLED:=0

GO:=go
GO_FLAGS:=-ldflags "-s -w" # strip Go binaries
ifeq "$(GOMODVENDOR)" "1"
GO_FLAGS_EXTRA += -mod=vendor
GO_FLAGS+=-mod=vendor
endif
GO_BUILD_TAGS:=
ifneq ($(strip $(GO_BUILD_TAGS)),)
GO_FLAGS_EXTRA += -tags="$(GO_BUILD_TAGS)"
GO_FLAGS+=-tags="$(GO_BUILD_TAGS)"
endif
GO_BUILD_ENV:=CGO_ENABLED=$(CGO_ENABLED)
# starting with ms-go1.25, systemcrypto (for FIPS compliance) is enabled by default, which
# requires CGo.
# disable it for non-CGo builds.
#
# https://github.com/microsoft/go/blob/microsoft/main/eng/doc/MigrationGuide.md#cgo-is-not-enabled
# https://github.com/microsoft/go/blob/microsoft/main/eng/doc/MigrationGuide.md#disabling-systemcrypto
ifeq "$(MSGO)" "1"
ifneq "$(CGO_ENABLED)" "1"
# MS_GO_NOSYSTEMCRYPTO only works for >=ms-go1.25.2
GO_BUILD_ENV+=MS_GO_NOSYSTEMCRYPTO=1 GOEXPERIMENT=nosystemcrypto
endif
endif
GO_BUILD:=CGO_ENABLED=$(CGO_ENABLED) $(GO) build $(GO_FLAGS) $(GO_FLAGS_EXTRA)
GO_BUILD:= $(GO_BUILD_ENV) $(GO) build $(GO_FLAGS) $(GO_FLAGS_EXTRA)

SRCROOT=$(dir $(abspath $(firstword $(MAKEFILE_LIST))))
# additional directories to search for rule prerequisites and targets
Expand Down