From f9b9077c7d37c3db28a1fea2a7d842bf37093684 Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Fri, 3 Nov 2023 08:41:39 +0100 Subject: [PATCH] Makefile simplify, add version target --- Makefile | 40 ++++++++++++++++------------------------ Makefile.config | 34 +++++++++++----------------------- 2 files changed, 27 insertions(+), 47 deletions(-) diff --git a/Makefile b/Makefile index ce83f9b1..5575dd51 100644 --- a/Makefile +++ b/Makefile @@ -4,45 +4,33 @@ include Makefile.config # load possible overrides or non-free definitions -include Makefile.local -#------------------------------------------------------------------------------ -# All, alliases -#------------------------------------------------------------------------------ -all: $(patsubst %, packer-%, $(DISTROS)) $(patsubst %, services-%, $(SERVICES)) - @: +# all, aliases +all: $(patsubst %, packer-%, $(DISTROS)) $(patsubst %, packer-%, $(SERVICES)) +distros: $(patsubst %, packer-%, $(DISTROS)) +services: $(patsubst %, packer-%, $(SERVICES)) # allow individual distribution targets (e.g., "make debian11") $(DISTROS): %: packer-% ; -$(SERVICES): %: services-% ; +$(SERVICES): %: packer-% ; -#------------------------------------------------------------------------------ -# Packer stage -# - run packer build for given distro -#------------------------------------------------------------------------------ -packer: $(patsubst %, packer-%, $(DISTROS)) - -packer-%: context-linux ${DIR_EXPORT}/%-${VERSION}-${RELEASE}.qcow2 +packer-%: context-linux ${DIR_EXPORT}/%.qcow2 @${INFO} "Packer ${*} done" -${DIR_EXPORT}/%-${VERSION}-${RELEASE}.qcow2: +# run packer build for given distro or service +${DIR_EXPORT}/%.qcow2: $(eval DISTRO_NAME := $(shell echo ${*} | sed 's/[0-9].*//')) $(eval DISTRO_VER := $(shell echo ${*} | sed 's/[a-z]*//')) packer/build.sh ${DISTRO_NAME} ${DISTRO_VER} ${@} -clean: - -rm -rf ${DIR_EXPORT}/* - -#------------------------------------------------------------------------------ -# context-linux -#------------------------------------------------------------------------------ context-linux: $(patsubst %, context-linux/out/%, $(LINUX_CONTEXT_PACKAGES)) @${INFO} "Generate context-linux done" context-linux/out/%: cd context-linux; ./generate-all.sh -#------------------------------------------------------------------------------ -# help -#------------------------------------------------------------------------------ +clean: + -rm -rf ${DIR_EXPORT}/* + help: @echo 'Available distros:' @echo ' $(DISTROS)' @@ -51,9 +39,13 @@ help: @echo ' $(SERVICES)' @echo @echo 'Usage examples:' - @echo ' make -- build all distros' + @echo ' make -- build all distros and services' + @echo ' make distros -- build all distros' + @echo ' make services -- build all services' @echo @echo ' make -- build just one distro' @echo ' make context-linux -- build context linux packages' @echo ' make context-windows -- TODO' +version: + @echo $(VERSION)-$(RELEASE) diff --git a/Makefile.config b/Makefile.config index 8130145a..103b9d00 100644 --- a/Makefile.config +++ b/Makefile.config @@ -1,11 +1,11 @@ # context version definition -VERSION ?= 6.6.1 -RELEASE ?= 1 +VERSION := 6.6.1 +RELEASE := 1 # log -VERBOSE ?= 1 -PACKER_LOG ?= 0 -PACKER_HEADLESS ?= true +VERBOSE := 1 +PACKER_LOG := 0 +PACKER_HEADLESS := true DISTROS := alma8 alma9 \ alpine316 alpine317 \ @@ -22,17 +22,16 @@ DISTROS := alma8 alma9 \ SERVICES := service_OneKE service_wordpress # default directories -DIR_BUILD ?= build -DIR_PACKER ?= $(DIR_BUILD)/packer -DIR_EXPORT ?= export +DIR_BUILD := build +DIR_EXPORT := export # create them if not present -$(shell mkdir -p ${DIR_BUILD} ${DIR_PACKER} ${DIR_EXPORT}) +$(shell mkdir -p ${DIR_BUILD} ${DIR_EXPORT}) -# Don't delete exported -.SECONDARY: $(patsubst %, $(DIR_EXPORT)/%-$(VERSION)-$(RELEASE).qcow2, $(DISTROS)) +# don't delete exported +.SECONDARY: $(patsubst %, $(DIR_EXPORT)/%.qcow2, $(DISTROS)) $(patsubst %, $(DIR_EXPORT)/%.qcow2, $(SERVICES)) -.PHONY: context-linux packer help +.PHONY: context-linux help # this needs to match context-linux/generate-all.sh products LINUX_CONTEXT_PACKAGES := one-context_${VERSION}-${RELEASE}.deb \ @@ -49,17 +48,6 @@ LINUX_CONTEXT_PACKAGES := one-context_${VERSION}-${RELEASE}.deb \ LINUX_CONTEXT_PACKAGES_FULL := $(patsubst %, context-linux/out/%, $(LINUX_CONTEXT_PACKAGES)) -# discover some binaries -QEMU_BINARY ?= $(shell \ - for _qb in /usr/bin/qemu-system-x86_64 \ - /usr/libexec/qemu-kvm \ - /usr/bin/qemu-kvm; do \ - \ - if [ -e "$$_qb" ]; then \ - echo $$_qb && exit; \ - fi; \ - done ) - # logging func INFO=sh -c 'if [ $(VERBOSE) = 1 ]; then echo [INFO] $$1; fi' INFO