1# *** 2# WARNING: Do not EDIT or MERGE this file, it is generated by packagespec. 3# *** 4# packagespec.mk should be included at the end of your main Makefile, 5# it provides hooks into packagespec targets, so you can run them 6# from the root of your product repository. 7# 8# All packagespec-generated make targets assume they are invoked by 9# targets in this file, which provides the necessary context for those 10# other targets. Therefore, this file is not just for conveninence but 11# is currently necessary to the correct functioning of Packagespec. 12 13# Since this file is included in other Makefiles, which may or may not want 14# to use bash with these options, we explicitly set the shell for specific 15# targets, in this file, rather than setting the global SHELL variable. 16PACKAGESPEC_SHELL := /usr/bin/env bash -euo pipefail -c 17 18# The RUN macro is used in place of the shell builtin in this file, so that 19# we can use the PACKAGESPEC_SHELL rather than the default from the Makefile 20# that includes this one. 21RUN = $(shell $(PACKAGESPEC_SHELL) '$1') 22 23# This can be overridden by the calling Makefile to write config to a different path. 24PACKAGESPEC_CIRCLECI_CONFIG ?= .circleci/config.yml 25PACKAGESPEC_HOOK_POST_CI_CONFIG ?= echo > /dev/null 26 27SPEC_FILE_PATTERN := packages*.yml 28# SPEC is the human-managed description of which packages we are able to build. 29SPEC := $(call RUN,find . -mindepth 1 -maxdepth 1 -name '$(SPEC_FILE_PATTERN)') 30ifneq ($(words $(SPEC)),1) 31$(error Found $(words $(SPEC)) $(SPEC_FILE_PATTERN) files, need exactly 1: $(SPEC)) 32endif 33SPEC_FILENAME := $(notdir $(SPEC)) 34SPEC_MODIFIER := $(SPEC_FILENAME:packages%.yml=%) 35# LOCKDIR contains the lockfile and layer files. 36LOCKDIR := packages$(SPEC_MODIFIER).lock 37LOCKFILE := $(LOCKDIR)/pkgs.yml 38 39export PACKAGE_SPEC_ID LAYER_SPEC_ID PRODUCT_REVISION PRODUCT_VERSION 40 41# PASSTHROUGH_TARGETS are convenience aliases for targets defined in $(LOCKDIR)/Makefile 42PASSTHROUGH_TARGETS := \ 43 build package-contents copy-package-contents build-all \ 44 aliases meta package package-meta package-meta-all \ 45 build-ci watch-ci \ 46 stage-config stage custom-build custom-build-config\ 47 bundle \ 48 orchestrator stop-orchestrator \ 49 list-custom-builds \ 50 list-staged-builds \ 51 list-promoted-builds \ 52 publish-config publish \ 53 workflow 54 55.PHONY: $(PASSTHROUGH_TARGETS) 56 57LOCAL_TARGETS := packages packagespec-circleci-config $(PACKAGESPEC_CIRCLECI_CONFIG) 58 59# Set the shell for all packagespec targets. 60$(PASSTHROUGH_TARGETS) $(LOCAL_TARGETS): SHELL := $(PACKAGESPEC_SHELL) 61 62$(PASSTHROUGH_TARGETS): 63 @PRODUCT_REPO_ROOT="$(call RUN,git rev-parse --show-toplevel)" $(MAKE) -C $(LOCKDIR) $@ 64 65# packages regenerates build and CI config using packagespec. This is only for 66# internal HashiCorp use, as it has dependencies not available externally. 67.PHONY: packages 68packages: 69 @command -v packagespec > /dev/null 2>&1 || { \ 70 echo "Please install packagespec."; \ 71 echo "Note: packagespec is only available to HashiCorp employees at present."; \ 72 exit 1; \ 73 } 74 @packagespec lock -circleciconfig="$(PACKAGESPEC_CIRCLECI_CONFIG)" 75 @$(MAKE) packagespec-circleci-config 76 77packagespec-circleci-config: 78 @$(PACKAGESPEC_HOOK_POST_CI_CONFIG) 79