Skip to content

Instantly share code, notes, and snippets.

@Bassem-Ramzy
Last active February 7, 2022 09:22
Show Gist options
  • Save Bassem-Ramzy/1854811c5146613676b334aa9e2b73cf to your computer and use it in GitHub Desktop.
Save Bassem-Ramzy/1854811c5146613676b334aa9e2b73cf to your computer and use it in GitHub Desktop.
check_linux_kernel_version_make
# In Makefile, check if the current kernel version is < 5.6,
# it sets `ADD_CCFLAGS_Y=-DOLD_KERNEL_FOR_PIN`
# Kernel Version
KVER := $(shell uname -r)
KMAJ := $(shell echo $(KVER) | \
sed -e 's/^\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*.*/\1/')
KMIN := $(shell echo $(KVER) | \
sed -e 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*.*/\1/')
# No Indentation Tabs/Spaces in the following ifeq lines please
ifeq ($(shell if [ 5 -gt $(KMAJ) ] ; then echo $$? ; fi ;),0)
$(eval ADD_CCFLAGS_Y=-DOLD_KERNEL_FOR_PIN)
endif
ifeq ($(shell if [ $(KMAJ) -eq 5 ] && [ 6 -ge $(KMIN) ] ; then echo $$? ; fi ;),0)
$(eval ADD_CCFLAGS_Y=-DOLD_KERNEL_FOR_PIN)
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment