diff --git a/Makefile b/Makefile index 6b8106100..e9294f2c9 100644 --- a/Makefile +++ b/Makefile @@ -9,9 +9,9 @@ GNUMAKEFLAGS := --no-print-directory SUBMAKEFLAGS := CLOE_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) -CLOE_LAUNCH := PYTHONPATH="${CLOE_ROOT}/cli" python3 -m cloe_launch +CLOE_LAUNCH := PYTHONPATH="$(CLOE_ROOT)/cli" python3 -m cloe_launch -include ${CLOE_ROOT}/Makefile.help +include $(CLOE_ROOT)/Makefile.help # Set the clang-format command line to use: CLANG_FORMAT := $(shell command -v clang-format 2>/dev/null) @@ -31,7 +31,7 @@ CONAN_OPTIONS := # Lockfile for cloe-meta: META_LOCKFILE_SOURCE := meta/conanfile.py META_BUILD_LOCKFILE := meta/build/conan.lock -META_LOCKFILE_OPTION := --lockfile="${CLOE_ROOT}/${META_BUILD_LOCKFILE}" +META_LOCKFILE_OPTION := --lockfile="$(CLOE_ROOT)/$(META_BUILD_LOCKFILE)" .DEFAULT_GOAL := help .PHONY: help @@ -46,11 +46,11 @@ help:: # Setup targets --------------------------------------------------------------- include Makefile.setup -${META_BUILD_LOCKFILE}: - ${MAKE} -C meta LOCKFILE_SOURCE=conanfile.py lockfile +$(META_BUILD_LOCKFILE): + $(MAKE) -C meta LOCKFILE_SOURCE=conanfile.py lockfile .PHONY: lockfile -lockfile: ${META_BUILD_LOCKFILE} +lockfile: $(META_BUILD_LOCKFILE) # Workspace targets ----------------------------------------------------------- help:: @@ -61,60 +61,59 @@ help:: .PHONY: docs docs: $(call print_header, "Generating Doxygen documentation...") - ${MAKE} -C docs doxygen + $(MAKE) -C docs doxygen $(call print_header, "Generating Sphinx documentation...") - ${MAKE} -C docs html + $(MAKE) -C docs html help:: - $(call print_help_target, export-cli, "export ${_yel}cloe-launch-profile${_rst} Conan recipe") - $(call print_help_target, deploy-cli, "install ${_yel}cloe-launch${_rst} with ${_dim}${PIPX}${_rst}") + $(call print_help_target, export-cli, "export $(_yel)cloe-launch-profile$(_rst) Conan recipe") + $(call print_help_target, deploy-cli, "install $(_yel)cloe-launch$(_rst) with $(_dim)$(PIPX)$(_rst)") echo .PHONY: export-cli export-cli: - ${MAKE} -C cli export + $(MAKE) -C cli export .PHONY: deploy-cli deploy-cli: $(call print_header, "Deploying cloe-launch binary with pip...") - ${MAKE} -C cli install + $(MAKE) -C cli install help:: $(call print_help_target, lockfile, "create a lockfile for cloe-meta package") $(call print_help_target, status-all, "show status of each of the Conan packages") $(call print_help_target, export-all, "export all package sources to Conan cache") $(call print_help_target, build-all, "build individual packages locally in-source") - $(call print_help_target, deploy-all, "deploy Cloe to INSTALL_DIR [=${INSTALL_DIR}]") + $(call print_help_target, deploy-all, "deploy $(_yel)cloe$(_rst) to $(_grn)INSTALL_DIR$(_rst)=$(_dim)$(INSTALL_DIR)$(_rst)") $(call print_help_target, clean-all, "clean entire repository of temporary files") $(call print_help_target, purge-all, "remove all cloe packages (in any version) from Conan cache") echo .PHONY: build-all build-all: lockfile - ${MAKE} all-select UNSELECT_PKGS="meta" CONAN_OPTIONS="${CONAN_OPTIONS} ${META_LOCKFILE_OPTION}" + $(MAKE) all-select UNSELECT_PKGS="meta" CONAN_OPTIONS="$(CONAN_OPTIONS) $(META_LOCKFILE_OPTION)" .PHONY: status-all -status-all: ${META_BUILD_LOCKFILE} - @for pkg in ${ALL_PKGS}; do \ - [ -d $${pkg} ] || continue; \ - ${MAKE} LOCKFILE_SOURCE="" LOCKFILE_OPTION=${META_LOCKFILE_OPTION} -C $${pkg} status || true; \ +status-all: $(META_BUILD_LOCKFILE) + @for pkg in $(ALL_PKGS); do \ + $(MAKE) LOCKFILE_SOURCE="" LOCKFILE_OPTION=$(META_LOCKFILE_OPTION) -C $${pkg} status || true; \ done .PHONY: export-all export-all: $(call print_header, "Exporting all cloe Conan packages...") - ${MAKE} export-select export-cli export + $(MAKE) export-select export-cli export .PHONY: deploy-all deploy-all: - $(call print_header, "Deploying binaries to ${INSTALL_DIR}...") - conan install ${CONAN_OPTIONS} --install-folder ${BUILD_DIR}/deploy -g deploy . - mkdir -p ${INSTALL_DIR} - cp -r ${BUILD_DIR}/deploy/cloe-*/* ${INSTALL_DIR}/ + $(call print_header, "Deploying binaries to $(INSTALL_DIR)...") + conan install $(CONAN_OPTIONS) --install-folder $(BUILD_DIR)/deploy -g deploy . + mkdir -p $(INSTALL_DIR) + cp -r $(BUILD_DIR)/deploy/cloe-*/* $(INSTALL_DIR)/ .PHONY: clean-all clean-all: - ${MAKE} clean clean-select + $(MAKE) clean clean-select .PHONY: purge-all purge-all: @@ -137,19 +136,19 @@ format: # continues to work as expected. # # See: https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame - find . -type f -not -path '*/\.git/*' -and \( -name '*.cpp' -o -name '*.hpp' \) -exec ${CLANG_FORMAT} ${CLANG_FORMAT_ARGS} -i {} \; + find . -type f -not -path '*/\.git/*' -and \( -name '*.cpp' -o -name '*.hpp' \) -exec $(CLANG_FORMAT) $(CLANG_FORMAT_ARGS) -i {} \; .PHONY: todos todos: - ${AG} TODO - ${AG} FIXME - ${AG} XXX + $(AG) TODO + $(AG) FIXME + $(AG) XXX # Hidden development targets -------------------------------------------------- .PHONY: grep-uuids grep-uuids: - ${AG} "\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b" + $(AG) "\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b" .PHONY: find-missing-eol find-missing-eol: diff --git a/Makefile.all b/Makefile.all index 02668b3c4..e307c91af 100644 --- a/Makefile.all +++ b/Makefile.all @@ -37,12 +37,12 @@ SUBMAKEFLAGS := META_PKG := meta PLUGIN_PKGS := plugins/basic plugins/clothoid_fit plugins/esmini plugins/gndtruth_extractor plugins/minimator plugins/mocks plugins/noisy_sensor plugins/speedometer plugins/virtue -ALL_PKGS := fable runtime models osi oak engine ${PLUGIN_PKGS} ${META_PKG} +ALL_PKGS := fable runtime models osi oak engine $(PLUGIN_PKGS) $(META_PKG) WITHOUT_PKGS := -UNSELECT_PKGS := ${WITHOUT_PKGS} +UNSELECT_PKGS := $(WITHOUT_PKGS) WITH_PKGS := -SELECT_PKGS := $(call uniq, $(filter-out ${UNSELECT_PKGS}, ${ALL_PKGS}) ${WITH_PKGS}) -.PHONY: ${ALL_PKGS} +SELECT_PKGS := $(call uniq, $(filter-out $(UNSELECT_PKGS), $(ALL_PKGS)) $(WITH_PKGS)) +.PHONY: $(ALL_PKGS) ## VENDOR PACKAGE SELECTION ## @@ -50,10 +50,10 @@ SELECT_PKGS := $(call uniq, $(filter-out ${UNSELECT_PKGS}, ${ALL_PKGS}) ${WITH_P ## ALL_VENDOR := $(wildcard vendor/*) WITHOUT_VENDOR := -UNSELECT_VENDOR := ${WITHOUT_VENDOR} +UNSELECT_VENDOR := $(WITHOUT_VENDOR) WITH_VENDOR := -SELECT_VENDOR := $(call uniq, $(filter-out ${UNSELECT_VENDOR}, ${ALL_VENDOR}) ${WITH_VENDOR}) -.PHONY: ${ALL_VENDOR} +SELECT_VENDOR := $(call uniq, $(filter-out $(UNSELECT_VENDOR), $(ALL_VENDOR)) $(WITH_VENDOR)) +.PHONY: $(ALL_VENDOR) # Specify dependencies: fable: @@ -62,9 +62,9 @@ models: runtime osi: runtime models vendor/open-simulation-interface oak: runtime engine: models oak -${PLUGIN_PKGS}: runtime models +$(PLUGIN_PKGS): runtime models plugins/esmini: vendor/open-simulation-interface vendor/esmini -${META_PKG}: fable runtime models osi oak engine ${PLUGIN_PKGS} +$(META_PKG): fable runtime models osi oak engine $(PLUGIN_PKGS) vendor/esmini: vendor/open-simulation-interface vendor/esmini-data: @@ -99,36 +99,36 @@ CONAN_OPTIONS := # Usage: $(call _make_target_rule, TARGET-NAME, MAKE-TARGET, HELP-DESCRIPTION, MAKE-ARGUMENTS) define _make_target_rule -${1}: - $(call print_header, "Proceeding to $(call unquote, ${3})") - ${MAKE} ${SUBMAKEFLAGS} ${4} ${2} +$(1): + $(call print_header, "Proceeding to $(call unquote, $(3))") + $(MAKE) $(SUBMAKEFLAGS) $(4) $(2) endef # Usage: $(call _make_target_rules, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY, PACKAGE-DIRS) define _make_target_rules help:: - $(call print_help_target, ${1}, ${2}, ${3}) -$(call _make_target_rule,${1},${1}-each,${2},-f Makefile.all) -${1}-each: ${4} + $(call print_help_target, $(1), $(2), $(3)) +$(call _make_target_rule,$(1),$(1)-each,$(2),-f Makefile.all) +$(1)-each: $(4) endef REGEX_TARGET := 's/(-vendor|-select)?-each//' -${ALL_PKGS} ${ALL_VENDOR}: - ${MAKE} -C $@ $(shell echo ${MAKECMDGOALS} | sed -re ${REGEX_TARGET}) +$(ALL_PKGS) $(ALL_VENDOR): + $(MAKE) -C $@ $(shell echo $(MAKECMDGOALS) | sed -re $(REGEX_TARGET)) # Usage: $(call make_vendor_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) define make_vendor_target -$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_VENDOR})) +$(eval $(call _make_target_rules,$(1),$(2),$(3),$(SELECT_VENDOR))) endef # Usage: $(call make_every_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) define make_every_target -$(eval $(call _make_target_rules,${1},${2},${3},${ALL_PKGS})) +$(eval $(call _make_target_rules,$(1),$(2),$(3),$(ALL_PKGS))) endef # Usage: $(call make_select_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) define make_select_target -$(eval $(call _make_target_rules,${1},${2},${3},${SELECT_PKGS})) +$(eval $(call _make_target_rules,$(1),$(2),$(3),$(SELECT_PKGS))) endef # --------------------------------------------------------------------------- # @@ -139,7 +139,7 @@ endef help:: $(call print_help_section, "Available multi-package targets") -ifneq "${ALL_VENDOR}" "" +ifneq "$(ALL_VENDOR)" "" help:: $(call make_vendor_target, export-vendor, "export all vendor packages", "[conan-cache]") $(call make_vendor_target, package-vendor, "create all vendor packages", "[conan-cache]") @@ -174,19 +174,19 @@ $(call make_select_target, clean-select, "remove build artifacts", "[in-source]" help:: echo $(call print_help_subsection, "Options") -ifneq "${ALL_VENDOR}" "" - $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from ${_grn}UNSELECT_VENDOR${_rst}") +ifneq "$(ALL_VENDOR)" "" + $(call print_help_option, WITH_VENDOR, "", "include optional vendor packages from $(_grn)UNSELECT_VENDOR$(_rst)") endif - $(call print_help_option, WITH_PKGS, "", "include optional packages from ${_grn}UNSELECT_PKGS${_rst}") + $(call print_help_option, WITH_PKGS, "", "include optional packages from $(_grn)UNSELECT_PKGS$(_rst)") $(call print_help_option, LOCKFILE_SOURCE, "", "use specified conanfile as lockfile source for build") echo $(call print_help_subsection, "Defines") - $(call print_help_option, BUILD_POLICY, ${BUILD_POLICY}) - $(call print_help_define, CONAN_OPTIONS, ${CONAN_OPTIONS}) -ifneq "${ALL_VENDOR}" "" - $(call print_help_define_lines, UNSELECT_VENDOR, ${UNSELECT_VENDOR}) - $(call print_help_define_lines, SELECT_VENDOR, ${SELECT_VENDOR}) + $(call print_help_option, BUILD_POLICY, $(BUILD_POLICY)) + $(call print_help_define, CONAN_OPTIONS, $(CONAN_OPTIONS)) +ifneq "$(ALL_VENDOR)" "" + $(call print_help_define_lines, UNSELECT_VENDOR, $(UNSELECT_VENDOR)) + $(call print_help_define_lines, SELECT_VENDOR, $(SELECT_VENDOR)) endif - $(call print_help_define_lines, UNSELECT_PKGS, ${UNSELECT_PKGS}) - $(call print_help_define_lines, SELECT_PKGS, ${SELECT_PKGS}) + $(call print_help_define_lines, UNSELECT_PKGS, $(UNSELECT_PKGS)) + $(call print_help_define_lines, SELECT_PKGS, $(SELECT_PKGS)) echo diff --git a/Makefile.docker b/Makefile.docker index 69e41bef3..0576f9f78 100644 --- a/Makefile.docker +++ b/Makefile.docker @@ -2,61 +2,61 @@ # # This file defines all Docker targets. -PROJECT_ROOT := $(dir $(abspath $(lastword ${MAKEFILE_LIST}))) -PROJECT_VERSION := $(shell make --no-print-directory -C ${PROJECT_ROOT} -f Makefile.package info-version) +PROJECT_ROOT := $(dir $(abspath $(lastword $(MAKEFILE_LIST)))) +PROJECT_VERSION := $(shell make --no-print-directory -C $(PROJECT_ROOT) -f Makefile.package info-version) UBUNTU_NAME := ubuntu UBUNTU_VERSIONS := 18.04 20.04 22.04 DOCKER := DOCKER_BUILDKIT=1 docker DOCKER_IMAGE_NAME := cloe/cloe-engine -DOCKER_IMAGE_VERSION := ${PROJECT_VERSION} -DOCKER_IMAGE := ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_VERSION} -DOCKER_DEVIMAGE := ${DOCKER_IMAGE_NAME}-dev:${DOCKER_IMAGE_VERSION} -DOCKER_CONTEXT := ${PROJECT_ROOT} +DOCKER_IMAGE_VERSION := $(PROJECT_VERSION) +DOCKER_IMAGE := $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_VERSION) +DOCKER_DEVIMAGE := $(DOCKER_IMAGE_NAME)-dev:$(DOCKER_IMAGE_VERSION) +DOCKER_CONTEXT := $(PROJECT_ROOT) DOCKER_USER_ARGS += -DOCKER_BUILD_ARGS += --build-arg PROJECT_VERSION=${PROJECT_VERSION} +DOCKER_BUILD_ARGS += --build-arg PROJECT_VERSION=$(PROJECT_VERSION) DOCKER_RUN_ARGS += --rm -ifndef (${https_proxy},) +ifndef ($(https_proxy),) DOCKER_NETWORK := host DOCKER_BUILD_ARGS += --network=host \ - --build-arg https_proxy="${https_proxy}" \ - --build-arg http_proxy="${http_proxy}" \ - --build-arg no_proxy="${no_proxy}" + --build-arg https_proxy="$(https_proxy)" \ + --build-arg http_proxy="$(http_proxy)" \ + --build-arg no_proxy="$(no_proxy)" DOCKER_RUN_ARGS += --network=host \ - --env https_proxy="${https_proxy}" \ - --env http_proxy="${http_proxy}" \ - --env no_proxy="${no_proxy}" + --env https_proxy="$(https_proxy)" \ + --env http_proxy="$(http_proxy)" \ + --env no_proxy="$(no_proxy)" else DOCKER_NETWORK := internal endif -ifeq ($(shell [ -f ${PROJECT_ROOT}/setup.sh ] && echo "true"),true) -DOCKER_BUILD_ARGS += --secret id=setup,src=${PROJECT_ROOT}/setup.sh -DOCKER_RUN_ARGS += -v "${PROJECT_ROOT}/setup.sh:/root/setup.sh" +ifeq ($(shell [ -f $(PROJECT_ROOT)/setup.sh ] && echo "true"),true) +DOCKER_BUILD_ARGS += --secret id=setup,src=$(PROJECT_ROOT)/setup.sh +DOCKER_RUN_ARGS += -v "$(PROJECT_ROOT)/setup.sh:/root/setup.sh" endif -ifneq (${CONAN_PROFILE},) -DOCKER_BUILD_ARGS += --build-arg CONAN_PROFILE="${CONAN_PROFILE}" +ifneq ($(CONAN_PROFILE),) +DOCKER_BUILD_ARGS += --build-arg CONAN_PROFILE="$(CONAN_PROFILE)" endif -ifneq (${VENDOR_TARGET},) -DOCKER_BUILD_ARGS += --build-arg VENDOR_TARGET="${VENDOR_TARGET}" +ifneq ($(VENDOR_TARGET),) +DOCKER_BUILD_ARGS += --build-arg VENDOR_TARGET="$(VENDOR_TARGET)" endif -ifneq (${PACKAGE_TARGET},) -DOCKER_BUILD_ARGS += --build-arg PACKAGE_TARGET="${PACKAGE_TARGET}" +ifneq ($(PACKAGE_TARGET),) +DOCKER_BUILD_ARGS += --build-arg PACKAGE_TARGET="$(PACKAGE_TARGET)" endif -ifeq (${KEEP_SOURCES},1) +ifeq ($(KEEP_SOURCES),1) DOCKER_BUILD_ARGS += --build-arg KEEP_SOURCES=1 endif # ----------------------------------------------------------------------------- -include ${PROJECT_ROOT}/Makefile.help +include $(PROJECT_ROOT)/Makefile.help .PHONY: help .SILENT: help @@ -73,25 +73,25 @@ help:: $(call print_help_target, run-ubuntu-VERSION, "run the Ubuntu VERSION image") $(call print_help_target, release-all, "release all Ubuntu versions") $(call print_help_target, release-ubuntu-VERSION, "release the Ubuntu VERSION image") - $(call print_help_target, remove-current-images, "remove and prune all ${DOCKER_IMAGE} Docker images") - $(call print_help_target, remove-all-images, "remove and prune all ${DOCKER_IMAGE_NAME} Docker images") + $(call print_help_target, remove-current-images, "remove and prune all $(DOCKER_IMAGE) Docker images") + $(call print_help_target, remove-all-images, "remove and prune all $(DOCKER_IMAGE_NAME) Docker images") echo $(call print_help_section, "User configuration") - $(call print_help_define, CONAN_PROFILE, ${CONAN_PROFILE}) - $(call print_help_define, VENDOR_TARGET, ${VENDOR_TARGET}) - $(call print_help_define, PACKAGE_TARGET, ${PACKAGE_TARGET}) - $(call print_help_define, KEEP_SOURCES, ${KEEP_SOURCES}) - $(call print_help_args_lines, DOCKER_USER_ARGS, ${DOCKER_USER_ARGS}) + $(call print_help_define, CONAN_PROFILE, $(CONAN_PROFILE)) + $(call print_help_define, VENDOR_TARGET, $(VENDOR_TARGET)) + $(call print_help_define, PACKAGE_TARGET, $(PACKAGE_TARGET)) + $(call print_help_define, KEEP_SOURCES, $(KEEP_SOURCES)) + $(call print_help_args_lines, DOCKER_USER_ARGS, $(DOCKER_USER_ARGS)) echo $(call print_help_section, "Docker configuration") - $(call print_help_define, UBUNTU_NAME, "${UBUNTU_NAME}") - $(call print_help_define_lines, UBUNTU_VERSIONS, ${UBUNTU_VERSIONS}) - $(call print_help_define, DOCKER, "${DOCKER}") - $(call print_help_define, DOCKER_CONTEXT, "${DOCKER_CONTEXT}") - $(call print_help_define, DOCKER_NETWORK, "${DOCKER_NETWORK}") - $(call print_help_define, DOCKER_IMAGE, "${DOCKER_IMAGE}") - $(call print_help_args_lines, DOCKER_BUILD_ARGS, ${DOCKER_BUILD_ARGS}) - $(call print_help_args_lines, DOCKER_RUN_ARGS, ${DOCKER_RUN_ARGS}) + $(call print_help_define, UBUNTU_NAME, "$(UBUNTU_NAME)") + $(call print_help_define_lines, UBUNTU_VERSIONS, $(UBUNTU_VERSIONS)) + $(call print_help_define, DOCKER, "$(DOCKER)") + $(call print_help_define, DOCKER_CONTEXT, "$(DOCKER_CONTEXT)") + $(call print_help_define, DOCKER_NETWORK, "$(DOCKER_NETWORK)") + $(call print_help_define, DOCKER_IMAGE, "$(DOCKER_IMAGE)") + $(call print_help_args_lines, DOCKER_BUILD_ARGS, $(DOCKER_BUILD_ARGS)) + $(call print_help_args_lines, DOCKER_RUN_ARGS, $(DOCKER_RUN_ARGS)) echo .SILENT: FORCE @@ -101,61 +101,61 @@ FORCE: # prerequisites of every target with patterns. .PHONY: build-all -build-all: $(addprefix build-ubuntu-,${UBUNTU_VERSIONS}) +build-all: $(addprefix build-ubuntu-,$(UBUNTU_VERSIONS)) .PHONY: test-all -test-all: $(addprefix test-ubuntu-,${UBUNTU_VERSIONS}) +test-all: $(addprefix test-ubuntu-,$(UBUNTU_VERSIONS)) .PHONY: release-all -release-all: $(addprefix release-ubuntu-,${UBUNTU_VERSIONS}) +release-all: $(addprefix release-ubuntu-,$(UBUNTU_VERSIONS)) ubuntu-%: FORCE build-ubuntu-% test-ubuntu-% @echo - @echo "Completed building and testing: ${DOCKER_IMAGE}-$@" + @echo "Completed building and testing: $(DOCKER_IMAGE)-$@" .PHONY: all -all: $(addprefix ubuntu-,${UBUNTU_VERSIONS}) +all: $(addprefix ubuntu-,$(UBUNTU_VERSIONS)) build-devc-%: FORCE Dockerfile - ${DOCKER} build -f Dockerfile ${DOCKER_BUILD_ARGS} ${DOCKER_USER_ARGS} \ + $(DOCKER) build -f Dockerfile $(DOCKER_BUILD_ARGS) $(DOCKER_USER_ARGS) \ --build-arg UBUNTU_VERSION=$* \ --target stage-setup-system \ - -t ${DOCKER_DEVIMAGE}-ubuntu-$* \ - ${DOCKER_CONTEXT} + -t $(DOCKER_DEVIMAGE)-ubuntu-$* \ + $(DOCKER_CONTEXT) build-ubuntu-%: FORCE Dockerfile - ${DOCKER} build -f Dockerfile ${DOCKER_BUILD_ARGS} ${DOCKER_USER_ARGS} \ + $(DOCKER) build -f Dockerfile $(DOCKER_BUILD_ARGS) $(DOCKER_USER_ARGS) \ --build-arg UBUNTU_VERSION=$* \ - -t ${DOCKER_IMAGE}-ubuntu-$* \ - ${DOCKER_CONTEXT} + -t $(DOCKER_IMAGE)-ubuntu-$* \ + $(DOCKER_CONTEXT) test-ubuntu-%: FORCE - docker run ${DOCKER_RUN_ARGS} ${DOCKER_USER_ARGS} ${DOCKER_IMAGE}-ubuntu-$* \ + docker run $(DOCKER_RUN_ARGS) $(DOCKER_USER_ARGS) $(DOCKER_IMAGE)-ubuntu-$* \ bash -ec "[ -f /root/setup.sh ] && source /root/setup.sh; make smoketest" run-devc-%: FORCE - docker run -it ${DOCKER_RUN_ARGS} ${DOCKER_USER_ARGS} --mount type=bind,source=$$(pwd),destination=/cloe ${DOCKER_DEVIMAGE}-ubuntu-$* + docker run -it $(DOCKER_RUN_ARGS) $(DOCKER_USER_ARGS) --mount type=bind,source=$$(pwd),destination=/cloe $(DOCKER_DEVIMAGE)-ubuntu-$* run-ubuntu-%: FORCE - docker run -it ${DOCKER_RUN_ARGS} ${DOCKER_USER_ARGS} ${DOCKER_IMAGE}-ubuntu-$* + docker run -it $(DOCKER_RUN_ARGS) $(DOCKER_USER_ARGS) $(DOCKER_IMAGE)-ubuntu-$* release-ubuntu-%: FORCE @test -f setup.sh || echo 'Error: require setup.sh for user authentication' - ${DOCKER} run ${DOCKER_RUN_ARGS} ${DOCKER_USER_ARGS} ${DOCKER_IMAGE}-ubuntu-$* \ + $(DOCKER) run $(DOCKER_RUN_ARGS) $(DOCKER_USER_ARGS) $(DOCKER_IMAGE)-ubuntu-$* \ bash -ec 'source /root/setup.sh && upload_conan_packages' .PHONY: require-setup-sh require-setup-sh: - @if [ ! -f ${PROJECT_ROOT}/setup.sh ]; then \ - echo "ERROR: require ${PROJECT_ROOT}/setup.sh to proceed"; \ + @if [ ! -f $(PROJECT_ROOT)/setup.sh ]; then \ + echo "ERROR: require $(PROJECT_ROOT)/setup.sh to proceed"; \ exit 1; \ fi .PHONY: remove-current-images remove-current-images: - docker rmi $$(docker images --format '{{.Repository}}:{{.Tag}}' | grep '${DOCKER_IMAGE}') + docker rmi $$(docker images --format '{{.Repository}}:{{.Tag}}' | grep '$(DOCKER_IMAGE)') .PHONY: remove-all-images remove-all-images: - docker rmi $$(docker images --format '{{.Repository}}:{{.Tag}}' | grep '${DOCKER_IMAGE_NAME}:') + docker rmi $$(docker images --format '{{.Repository}}:{{.Tag}}' | grep '$(DOCKER_IMAGE_NAME):') diff --git a/Makefile.help b/Makefile.help index 84fdc9b0f..2a0bc50a8 100644 --- a/Makefile.help +++ b/Makefile.help @@ -21,10 +21,10 @@ # Usage: $(call assert_numeric_bool, VARIABLE-NAME) define assert_numeric_bool -$(if $(filter-out 0 1,${$1}), $(error Unexpected value for parameter $1, expect either 0 or 1)) +$(if $(filter-out 0 1,$($1)), $(error Unexpected value for parameter $1, expect either 0 or 1)) endef -# Usage: $(call uniq, ${LIST-OF-WORDS}) +# Usage: $(call uniq, $(LIST-OF-WORDS)) define uniq $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))) endef @@ -58,39 +58,39 @@ _dim := \e[2m define print_header @printf "________________________________________" @printf "________________________________________\n" - @printf ":: %s\n" ${1} + @printf ":: %s\n" $(1) endef # Usage: $(call print_help_section, SECTION-TITLE) define print_help_section - @printf "%s:\n" ${1} + @printf "%s:\n" $(1) endef # Usage: $(call print_help_subsection, SUBSECTION-TITLE) define print_help_subsection - @printf " %s:\n" ${1} + @printf " %s:\n" $(1) endef # Usage: $(call print_help_target, TARGET-NAME, HELP-DESCRIPTION, HELP-CATEGORY) define print_help_target - @printf " ${_blu}% -21s${_rst} % -45b ${_dim}%s${_rst}\n" ${1} ${2} ${3} + @printf " $(_blu)% -21s$(_rst) % -45b $(_dim)%s$(_rst)\n" $(1) $(2) $(3) endef # Usage: $(call print_help_option, VAR-NAME, VAR-DEFAULT, DESCRIPTION) define print_help_option - @printf " % -36s %b\n" $(shell printf "${_grn}%s${_rst}=${_dim}%s${_rst}" ${1} ${2}) ${3} + @printf " % -36s %b\n" $(shell printf "$(_grn)%s$(_rst)=$(_dim)%s$(_rst)" $(1) $(2)) $(3) endef -# Usage: $(call print_help_define, VAR-NAME, ${VAR-NAME}) +# Usage: $(call print_help_define, VAR-NAME, $(VAR-NAME)) define print_help_define - @printf " ${_grn}%s${_rst}=${_dim}%s${_rst}\n" ${1} ${2} + @printf " $(_grn)%s$(_rst)=$(_dim)%s$(_rst)\n" $(1) $(2) endef define print_help_define_align - @printf " ${_grn}%-16s${_rst}=${_dim} %s${_rst}\n" ${1} ${2} + @printf " $(_grn)%-16s$(_rst)=$(_dim) %s$(_rst)\n" $(1) $(2) endef -# Usage: $(call print_help_define_lines, VAR-NAME, ${VAR-NAME}) +# Usage: $(call print_help_define_lines, VAR-NAME, $(VAR-NAME)) # # For example, given a call with the following: # @@ -103,16 +103,16 @@ endef # 20.04 # 22.04 # -# If the contents of ${VAR-NAME} is empty or only contains whitespace, +# If the contents of $(VAR-NAME) is empty or only contains whitespace, # then no extra newline is printed, and it behaves as print_help_define. define print_help_define_lines - @printf " ${_grn}%s${_rst}=${_dim}" ${1} - @if [ -n "$(strip ${2})" ]; then printf "\\ \n"; fi - @printf "%s" "$$(echo " ${2}" | fmt -5)" - @printf "${_rst}\n" + @printf " $(_grn)%s$(_rst)=$(_dim)" $(1) + @if [ -n "$(strip $(2))" ]; then printf "\\ \n"; fi + @printf "%s" "$$(echo " $(2)" | fmt -5)" + @printf "$(_rst)\n" endef -# Usage: $(call print_help_args_lines, VAR-NAME, ${VAR-NAME}) +# Usage: $(call print_help_args_lines, VAR-NAME, $(VAR-NAME)) # # This function behaves as print_help_define_lines, except that # it doesn't split on words, but on arguments. Each argument (leading with -) @@ -129,12 +129,12 @@ endef # --rm # --network host # -# If the contents of ${VAR-NAME} is empty, same behavior as print_help_define. +# If the contents of $(VAR-NAME) is empty, same behavior as print_help_define. define print_help_args_lines - @printf " ${_grn}%s${_rst}=${_dim}" ${1} - @if [ -n "$(strip ${2})" ]; then printf "\\ \n"; fi - @printf "%s" "$$(echo " ${2}" | sed -r -e 's/\W--?[^-]/\n \0/g' -e 's/^\s*\n//')" - @printf "${_rst}\n" + @printf " $(_grn)%s$(_rst)=$(_dim)" $(1) + @if [ -n "$(strip $(2))" ]; then printf "\\ \n"; fi + @printf "%s" "$$(echo " $(2)" | sed -r -e 's/\W--?[^-]/\n \0/g' -e 's/^\s*\n//')" + @printf "$(_rst)\n" endef # Usage: $(call print_help_usage) @@ -142,5 +142,5 @@ endef # This should be called only once, before all other print_help_* calls, # so that the help message starts with a usage statement. define print_help_usage - @printf "Usage: make ${_blu}target${_rst}\n" + @printf "Usage: make $(_blu)target$(_rst)\n" endef diff --git a/Makefile.setup b/Makefile.setup index d9ac0cb74..626d308d3 100644 --- a/Makefile.setup +++ b/Makefile.setup @@ -13,9 +13,9 @@ SHELL := /bin/bash PROJECT_ROOT := $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) CONAN_DIR := $(shell conan config home 2>/dev/null || echo "$HOME/.conan") CONAN_PROFILE := default -CONAN_PROFILE_PATH := ${CONAN_DIR}/profiles/${CONAN_PROFILE} +CONAN_PROFILE_PATH := $(CONAN_DIR)/profiles/$(CONAN_PROFILE) -include ${PROJECT_ROOT}/Makefile.help +include $(PROJECT_ROOT)/Makefile.help APT := $(or \ $(shell command -v apt 2>/dev/null), \ @@ -28,7 +28,7 @@ PIP := $(or \ $(shell command -v pip3 2>/dev/null), \ $(shell command -v pip 2>/dev/null) \ ) -ifeq (${VIRTUAL_ENV}, ) +ifeq ($(VIRTUAL_ENV), ) PIP_INSTALL_ARGS := --user --upgrade else PIP_INSTALL_ARGS := --upgrade @@ -37,8 +37,8 @@ endif PIPX := $(shell command -v pipx 2>/dev/null) PIPX_INSTALL_ARGS := ifndef PIPX -PIPX := ${PIP} -PIPX_INSTALL_ARGS := ${PIP_INSTALL_ARGS} +PIPX := $(PIP) +PIPX_INSTALL_ARGS := $(PIP_INSTALL_ARGS) endif .DEFAULT_GOAL := help @@ -49,9 +49,9 @@ help:: $(call print_help_target, setup-git, "perform Git repository setup") $(call print_help_target, setup-conan, "install Conan profile") $(call print_help_target, install-system-deps, "install build (and development) system requirements") - $(call print_help_target, install-python-deps, "install Python runtime requirements with ${_dim}${PIP}${_rst}") - $(call print_help_target, install-sphinx-deps, "install Sphinx runtime requirements with ${_dim}${PIP}${_rst}") - $(call print_help_target, install-python-tools, "install Python development tools with ${_dim}${PIPX}${_rst}") + $(call print_help_target, install-python-deps, "install Python runtime requirements with $(_dim)$(PIP)$(_rst)") + $(call print_help_target, install-sphinx-deps, "install Sphinx runtime requirements with $(_dim)$(PIP)$(_rst)") + $(call print_help_target, install-python-tools, "install Python development tools with $(_dim)$(PIPX)$(_rst)") echo .PHONY: setup-git @@ -61,17 +61,17 @@ setup-git: .PHONY: setup-conan setup-conan: # Install Conan if it is not available. - if ! command -v conan >/dev/null 2>&1; then ${PIP} install --user --upgrade "conan<2"; fi + if ! command -v conan >/dev/null 2>&1; then $(PIP) install --user --upgrade "conan<2"; fi # Initialize Conan configuration if it doesn't already exist. # - # Since running any conan command, even conan --help creates ${CONAN_DIR} + # Since running any conan command, even conan --help creates $(CONAN_DIR) # and the default configuration, we rely on the existence of the default # profile as an indication that we have a "fresh" setup where we can # make our override. - if [ ! -f ${CONAN_PROFILE_PATH} ]; then \ + if [ ! -f $(CONAN_PROFILE_PATH) ]; then \ conan config init; \ - conan profile update settings.compiler.libcxx=libstdc++11 ${CONAN_PROFILE}; \ - conan profile update settings.build_type=Debug ${CONAN_PROFILE}; \ + conan profile update settings.compiler.libcxx=libstdc++11 $(CONAN_PROFILE); \ + conan profile update settings.build_type=Debug $(CONAN_PROFILE); \ fi if ! conan config get general.default_build_profile >/dev/null 2>&1; then \ conan config set general.default_build_profile=default; \ @@ -80,15 +80,15 @@ setup-conan: conan config set general.revisions_enabled=True; \ fi # Install cloe-{debug,normal,release} profiles. - for profile in "${PROJECT_ROOT}"/dist/conan/*.profile; do \ + for profile in "$(PROJECT_ROOT)"/dist/conan/*.profile; do \ export profile_name=$$(basename -s .profile $${profile}); \ - install -m 644 "$${profile}" "${CONAN_DIR}/profiles/$${profile_name}"; \ - sed -r -i "s/default/${CONAN_PROFILE}/" "${CONAN_DIR}/profiles/$${profile_name}"; \ + install -m 644 "$${profile}" "$(CONAN_DIR)/profiles/$${profile_name}"; \ + sed -r -i "s/default/$(CONAN_PROFILE)/" "$(CONAN_DIR)/profiles/$${profile_name}"; \ done # Ensure we have an up-to-date CMake configured. if [ $$(( cmake --version | head -1 | cut -f3 -d' '; echo "3.14.99" ) | sort -V | tail -1) = "3.14.99" ]; then \ - if ! grep "cmake/" ${CONAN_PROFILE_PATH} >/dev/null; then \ - echo -e "[tool_requires]\ncmake/[>=3.15.0]" >> ${CONAN_PROFILE_PATH}; \ + if ! grep "cmake/" $(CONAN_PROFILE_PATH) >/dev/null; then \ + echo -e "[tool_requires]\ncmake/[>=3.15.0]" >> $(CONAN_PROFILE_PATH); \ fi; \ fi @@ -102,8 +102,8 @@ endif .PHONY: install-ubuntu-deps install-ubuntu-deps:: - command -v ${APT} >/dev/null 2>&1 - ${APT} install ${APT_ARGS} \ + command -v $(APT) >/dev/null 2>&1 + $(APT) install $(APT_ARGS) \ bats \ build-essential \ clang-format \ @@ -129,8 +129,8 @@ install-ubuntu-deps:: ; # Require GCC and G++ version >= 8 - if [ "${UBUNTU_VERSION}" == "18.04" ]; then \ - ${APT} install ${APT_ARGS} gcc-8 g++-8; \ + if [ "$(UBUNTU_VERSION)" == "18.04" ]; then \ + $(APT) install $(APT_ARGS) gcc-8 g++-8; \ if [ $$(readlink /usr/bin/g++) == "g++-7" ]; then \ ln -sf /usr/bin/g++-8 /usr/bin/g++ && \ ln -sf /usr/bin/gcc-8 /usr/bin/gcc; \ @@ -140,8 +140,8 @@ install-ubuntu-deps:: # Python ---------------------------------------------------------------------- .PHONY: install-python-deps install-python-deps:: - command -v ${PIP} >/dev/null 2>&1 - ${PIP} install ${PIP_INSTALL_ARGS} \ + command -v $(PIP) >/dev/null 2>&1 + $(PIP) install $(PIP_INSTALL_ARGS) \ click \ "conan<2.0.0" \ libtmux \ @@ -151,12 +151,12 @@ install-python-deps:: .PHONY: install-sphinx-deps install-sphinx-deps: - command -v ${PIP} >/dev/null 2>&1 - ${PIP} install ${PIP_INSTALL_ARGS} -r docs/requirements.txt + command -v $(PIP) >/dev/null 2>&1 + $(PIP) install $(PIP_INSTALL_ARGS) -r docs/requirements.txt .PHONY: install-python-tools install-python-tools:: - command -v ${PIPX} >/dev/null 2>&1 + command -v $(PIPX) >/dev/null 2>&1 for pkg in \ black \ mypy \ @@ -166,5 +166,5 @@ install-python-tools:: yq \ ; \ do \ - ${PIPX} install ${PIPX_INSTALL_ARGS} $${pkg}; \ + $(PIPX) install $(PIPX_INSTALL_ARGS) $${pkg}; \ done