From 8c055f0f3e9019f32a57bc8724d4a16f66afdca3 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Thu, 12 Jan 2023 12:03:28 +0100 Subject: [PATCH] makefiles/utils/strings.mk: Fix version_is_greater_or_equal The Makefile function `version_is_greater_or_equal` is used to check if a version of GNU Make is at least the required one. However, it has the built-in assumption the version numbers have to format x.y.z, but Alpine Linux currently ships GNU Make 4.4. This results in `$(call _pad_number,3,)` which runs `printf '$03d' ''` in the shell, which is not valid. This fixes the issue by making `_pad_number` more robust by fall back to printing `0` with the given padding, if the number given to print is empty. --- makefiles/utils/strings.mk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefiles/utils/strings.mk b/makefiles/utils/strings.mk index 66467c2988..cbc280fcf0 100644 --- a/makefiles/utils/strings.mk +++ b/makefiles/utils/strings.mk @@ -7,8 +7,8 @@ lowercase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst uppercase = $(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1)))))))))))))))))))))))))) uppercase_and_underscore = $(call uppercase,$(subst -,_,$1)) -# Padds $2 number to $1 digits -_pad_number = $(shell printf '%0$1d' $2) +# Padds number $2 to $1 digits. If $2 is empty, zero will be printed instead. +_pad_number = $(shell printf '%0$1d' $(if $2,$2,0)) # Gets major, minor, patch from 'major.minor.patch', e.g.: 4.2.1 by index # $1: index