chore(make): update go-build target

cross platform output (append extension)

Signed-off-by: Dwi Siswanto <git@dw1.io>
This commit is contained in:
Dwi Siswanto 2024-12-18 07:22:05 +07:00
parent 156b22687b
commit ee65a08747
No known key found for this signature in database
GPG Key ID: 3BB198907EF44CED

View File

@ -6,14 +6,16 @@ GOBUILD_PACKAGES :=
GOBUILD_ADDITIONAL_ARGS := GOBUILD_ADDITIONAL_ARGS :=
GOMOD := $(GOCMD) mod GOMOD := $(GOCMD) mod
GOTEST := $(GOCMD) test GOTEST := $(GOCMD) test
GOOS := $(shell ${GOCMD} env GOOS)
GOARCH := $(shell ${GOCMD} env GOARCH)
GOFLAGS := -v GOFLAGS := -v
# This should be disabled if the binary uses pprof # This should be disabled if the binary uses pprof
LDFLAGS := -s -w LDFLAGS := -s -w
ifneq ($(shell go env GOOS),darwin) ifneq ($(GOOS),darwin)
LDFLAGS = -extldflags "-static" LDFLAGS += -extldflags "-static"
endif endif
.PHONY: all build build-stats clean devtools-all devtools-bindgen devtools-scrapefuncs .PHONY: all build build-stats clean devtools-all devtools-bindgen devtools-scrapefuncs
.PHONY: devtools-tsgen docs docgen dsl-docs functional fuzzplayground go-build syntax-docs .PHONY: devtools-tsgen docs docgen dsl-docs functional fuzzplayground go-build syntax-docs
.PHONY: integration jsupdate-all jsupdate-bindgen jsupdate-tsgen memogen scan-charts test .PHONY: integration jsupdate-all jsupdate-bindgen jsupdate-tsgen memogen scan-charts test
@ -22,12 +24,17 @@ endif
all: build all: build
clean: clean:
rm -f '${GOBUILD_OUTPUT}' 2>/dev/null @echo "Removing ${FILE}"
@if [ ! -z "${FILE}" ]; then \
rm -f '${FILE}' 2>/dev/null; \
fi
go-build: clean
go-build: go-build:
$(GOBUILD) $(GOFLAGS) -ldflags '${LDFLAGS}' $(GOBUILD_ADDITIONAL_ARGS) \ @$(eval OUTPUT := ${GOBUILD_OUTPUT}$(if $(filter windows,${GOOS}),.exe,))
-o '${GOBUILD_OUTPUT}' $(GOBUILD_PACKAGES) @$(MAKE) clean FILE="${OUTPUT}"
@echo "Building ${OUTPUT} for ${GOOS}/${GOARCH}"
@$(GOBUILD) $(GOFLAGS) -ldflags '${LDFLAGS}' $(GOBUILD_ADDITIONAL_ARGS) \
-o '${OUTPUT}' $(GOBUILD_PACKAGES)
build: GOBUILD_OUTPUT = ./bin/nuclei build: GOBUILD_OUTPUT = ./bin/nuclei
build: GOBUILD_PACKAGES = cmd/nuclei/main.go build: GOBUILD_PACKAGES = cmd/nuclei/main.go