Skip to content

Commit 2ef49ed

Browse files
committed
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. (cherry picked from commit 8c055f0)
1 parent b2e6ff6 commit 2ef49ed

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

makefiles/utils/strings.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ lowercase = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst
77
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))))))))))))))))))))))))))
88
uppercase_and_underscore = $(call uppercase,$(subst -,_,$1))
99

10-
# Padds $2 number to $1 digits
11-
_pad_number = $(shell printf '%0$1d' $2)
10+
# Padds number $2 to $1 digits. If $2 is empty, zero will be printed instead.
11+
_pad_number = $(shell printf '%0$1d' $(if $2,$2,0))
1212

1313
# Gets major, minor, patch from 'major.minor.patch', e.g.: 4.2.1 by index
1414
# $1: index

0 commit comments

Comments
 (0)