Skip to content
Snippets Groups Projects
target-go-fetch-licenses.mk 1.16 KiB
Newer Older
#############################################################################################
#############################################################################################
##
## GET LICENSES
##
#############################################################################################
#############################################################################################

ifeq ($(GO),)
  $(error $(ERRORMARKER) Go is not defined, check your Makefile if go.mk is included)
endif

GO_MOD_FILE := $(SOURCE_PATH)go.mod

ifeq ($(shell test -e $(GO_MOD_FILE) && echo -n yes),yes)
  GO_CURRENT_MODULE := $(shell cat $(GO_MOD_FILE) | head -n1 | cut -d" " -f2)
  # go install github.com/google/go-licenses@latest
  EXECUTABLES = $(EXECUTABLES:-) go-licenses;    
endif

.PHONY: go-fetch-licenses
## Fetch licenses for all modules
go-fetch-licenses:
ifeq ($(GO_CURRENT_MODULE),)
	$(QUIET) $(ECHOERRORMARKER) "no go.mod file found, skipping fetching licenses"
else
	$(ECHOMARKER) "Fetch licenses"
	$(QUIET) cd $(SOURCE_PATH); $(GO_LICENSES_BIN) save $(GO_CURRENT_MODULE) $(GO_LICENSES_IGNORE_PACKAGES) --force --save_path $(DOCUMENTATION_PATH)licenses/ ; cd -
endif