]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
build: Robust version checking helpers with `printf`
authorSimon Kuenzer <simon@unikraft.io>
Thu, 27 Jul 2023 07:46:00 +0000 (09:46 +0200)
committerUnikraft <monkey@unikraft.io>
Fri, 11 Aug 2023 10:21:30 +0000 (10:21 +0000)
This commit updates the compiler version checking helpers so that they also
work under environments like Darwin. It turns out that the behavior of
`echo` can be different in different environments, while `printf` seems to
be well defined.

Signed-off-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Alexander Jung <alex@unikraft.io>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #1034

support/build/Makefile.rules

index 1e368db4db5793097b708c52e8db5a45349f77c5..fe54b5fed7de60eeef3a3403a49e607539c5d112 100644 (file)
@@ -42,26 +42,26 @@ endef
 # test whether CC version is greater than or equal to the minimum requirement
 # cc_version_ge $cc_major,$cc_minor
 define cc_version_ge =
-$(shell if [ $(CC_VER_MAJOR) -gt $(1) ] || ([ $(CC_VER_MAJOR) -eq $(1) ] && [ $(CC_VER_MINOR) -ge $(2) ]) ; then echo -n y ; fi)
+$(shell if [ $(CC_VER_MAJOR) -gt $(1) ] || ([ $(CC_VER_MAJOR) -eq $(1) ] && [ $(CC_VER_MINOR) -ge $(2) ]) ; then printf 'y' ; fi)
 endef
 # test whether CC version is less than the supplied version
 # cc_version_lt $cc_major,$cc_minor
 define cc_version_lt =
-$(shell if [ $(CC_VER_MAJOR) -lt $(1) ] || ([ $(CC_VER_MAJOR) -eq $(1) ] && [ $(CC_VER_MINOR) -lt $(2) ]) ; then echo -n y ; fi)
+$(shell if [ $(CC_VER_MAJOR) -lt $(1) ] || ([ $(CC_VER_MAJOR) -eq $(1) ] && [ $(CC_VER_MINOR) -lt $(2) ]) ; then printf 'y' ; fi)
 endef
 
 define gcc_version_ge =
-$(shell if [ $(call have_gcc) = y ] ; then echo -n "$(call cc_version_ge,$(1),$(2))" ; fi)
+$(shell if [ $(call have_gcc) = y ] ; then printf "$(call cc_version_ge,$(1),$(2))" ; fi)
 endef
 define gcc_version_lt =
-$(shell if [ $(call have_gcc) = y ] ; then echo -n "$(call cc_version_lt,$(1),$(2))" ; fi)
+$(shell if [ $(call have_gcc) = y ] ; then printf "$(call cc_version_lt,$(1),$(2))" ; fi)
 endef
 
 define clang_version_ge =
-$(shell if [ $(call have_clang) = y ] ; then echo -n "$(call cc_version_ge,$(1),$(2))" ; fi)
+$(shell if [ $(call have_clang) = y ] ; then printf "$(call cc_version_ge,$(1),$(2))" ; fi)
 endef
 define clang_version_lt =
-$(shell if [ $(call have_clang) = y ] ; then echo -n "$(call cc_version_gt,$(1),$(2))" ; fi)
+$(shell if [ $(call have_clang) = y ] ; then printf "$(call cc_version_gt,$(1),$(2))" ; fi)
 endef
 
 # print error and stop build when GCC version doesn't meet the minimum requirement