[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 05/13] build: Add a makefile function to check GCC version



In this patch, we add a test_gcc_version function to test GCC
version and return a result. In this case, this function can
be used not only for processor flags check, but also can be
used in other places of Unikraft.

Signed-off-by: Wei Chen <Wei.Chen@xxxxxxx>
---
 Makefile                     | 4 ++++
 support/build/Makefile.rules | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/Makefile b/Makefile
index ca9b566..77659bd 100644
--- a/Makefile
+++ b/Makefile
@@ -426,6 +426,10 @@ LIFTOFF            := liftoff -e -s
 override ARFLAGS:= rcs
 CC_VERSION     := $(shell $(CC) --version | \
                   sed -n -r 's/^.* ([0-9]*)\.([0-9]*)\.([0-9]*)[ ]*.*/\1.\2/p')
+# Retrieve GCC major and minor number from CC_VERSION. They would be used
+# to select correct optimization parameters for target CPUs.
+CC_VER_MAJOR   := $(word 1,$(subst ., ,$(CC_VERSION)))
+CC_VER_MINOR   := $(word 2,$(subst ., ,$(CC_VERSION)))
 
 ASFLAGS                += -DCC_VERSION=$(CC_VERSION)
 CFLAGS         += -DCC_VERSION=$(CC_VERSION)
diff --git a/support/build/Makefile.rules b/support/build/Makefile.rules
index feb1455..cc9b522 100644
--- a/support/build/Makefile.rules
+++ b/support/build/Makefile.rules
@@ -29,6 +29,11 @@ lc = $(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst 
E,e,$(subst F,f,$(s
 # upper case
 uc = $(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)))))))))))))))))))))))))))
 
+# test whether GCC version meets the minimum requirement
+# test_gcc_version $gcc_major,$gcc_minor
+define test_gcc_version =
+$(shell echo 'if($(CC_VER_MAJOR).$(CC_VER_MINOR)>=$(1).$(2)) print "y"'| bc)
+endef
 
 
################################################################################
 #
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.