1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

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.
This commit is contained in:
Marian Buschsieweke 2023-01-12 12:03:28 +01:00
parent 75c909b813
commit 8c055f0f3e
No known key found for this signature in database
GPG Key ID: CB8E3238CE715A94

View File

@ -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