BACKPORT: Documentation/llvm: add documentation on building w/ Clang/LLVM
[GitHub/LineageOS/G12/android_kernel_amlogic_linux-4.9.git] / Makefile
index 0722aa762d821429f9f72de8777ea5b6021c55b9..6f9ab01e0cc94d976b2b07a526d7015bc24deae0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 VERSION = 4
 PATCHLEVEL = 9
-SUBLEVEL = 299
+SUBLEVEL = 337
 EXTRAVERSION =
 NAME = Roaring Lionus
 
@@ -389,7 +389,10 @@ KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common -fshort-wchar \
                   -Werror-implicit-function-declaration \
                   -Wno-format-security \
-                  -std=gnu89
+                  -Werror      \
+                  -std=gnu89 $(call cc-option,-fno-PIE)
+
+
 KBUILD_CPPFLAGS := -D__KERNEL__
 KBUILD_AFLAGS_KERNEL :=
 KBUILD_CFLAGS_KERNEL :=
@@ -401,6 +404,7 @@ CLANG_FLAGS :=
 
 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
+KERNELRELEASE_FULL = $(shell cat include/config/kernel.release_full 2> /dev/null)
 KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(SUBLEVEL)))$(EXTRAVERSION)
 
 export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
@@ -438,6 +442,11 @@ PHONY += scripts_basic
 scripts_basic:
        $(Q)$(MAKE) $(build)=scripts/basic
        $(Q)rm -f .tmp_quiet_recordmcount
+       $(Q)if [ -d $(srctree)/.git/hooks ]; then \
+               cp $(srctree)/scripts/amlogic/pre-commit $(srctree)/.git/hooks/; \
+               chmod +x $(srctree)/.git/hooks/pre-commit; \
+       fi
+#$(Q)mkdir -p $(srctree)/.git/hooks
 
 # To avoid any implicit rule to kick in, define an empty command.
 scripts/basic/%: scripts_basic ;
@@ -634,7 +643,9 @@ all: vmlinux
 
 KBUILD_CFLAGS  += $(call cc-option,-fno-PIE)
 KBUILD_AFLAGS  += $(call cc-option,-fno-PIE)
-CFLAGS_GCOV    := -fprofile-arcs -ftest-coverage -fno-tree-loop-im $(call cc-disable-warning,maybe-uninitialized,)
+CFLAGS_GCOV    := -fprofile-arcs -ftest-coverage \
+       $(call cc-option,-fno-tree-loop-im) \
+       $(call cc-disable-warning,maybe-uninitialized,)
 CFLAGS_KCOV    := $(call cc-option,-fsanitize-coverage=trace-pc,)
 export CFLAGS_GCOV CFLAGS_KCOV
 
@@ -693,7 +704,7 @@ export LDFINAL_vmlinux LDFLAGS_FINAL_vmlinux
 endif
 
 ifdef CONFIG_CFI_CLANG
-cfi-clang-flags        += -fsanitize=cfi
+cfi-clang-flags        += -fsanitize=cfi $(call cc-option, -fsplit-lto-unit)
 DISABLE_CFI_CLANG := -fno-sanitize=cfi
 ifdef CONFIG_MODULES
 cfi-clang-flags        += -fsanitize-cfi-cross-dso
@@ -758,7 +769,7 @@ ifdef CONFIG_CC_STACKPROTECTOR_REGULAR
   stackp-flag := -fstack-protector
   stackp-name := REGULAR
 else
-ifdef CONFIG_CC_STACKPROTECTOR_STRONG
+ifdef CONFIG_CC_STACKPROTECTOR_STRONG_AMLOGIC
   stackp-flag := -fstack-protector-strong
   stackp-name := STRONG
 else
@@ -1103,13 +1114,21 @@ $(vmlinux-dirs): prepare scripts
        $(Q)$(MAKE) $(build)=$@
 
 define filechk_kernel.release
+       echo "$(KERNELVERSION)"
+endef
+
+define filechk_kernel.release_full
        echo "$(KERNELVERSION)$$($(CONFIG_SHELL) $(srctree)/scripts/setlocalversion $(srctree))"
 endef
 
+
 # Store (new) KERNELRELEASE string in include/config/kernel.release
 include/config/kernel.release: include/config/auto.conf FORCE
        $(call filechk,kernel.release)
 
+include/config/kernel.release_full: include/config/auto.conf FORCE
+       $(call filechk,kernel.release_full)
+
 
 # Things we need to do before we recursively start building the kernel
 # or the modules are listed in "prepare".
@@ -1123,7 +1142,7 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
 # prepare3 is used to check if we are building in a separate output directory,
 # and if so do:
 # 1) Check that make has not been executed in the kernel src $(srctree)
-prepare3: include/config/kernel.release
+prepare3: include/config/kernel.release include/config/kernel.release_full
 ifneq ($(KBUILD_SRC),)
        @$(kecho) '  Using $(srctree) as source for kernel'
        $(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
@@ -1229,7 +1248,7 @@ define filechk_utsrelease.h
          echo '"$(UTS_RELEASE)" exceeds $(uts_len) characters' >&2;    \
          exit 1;                                                       \
        fi;                                                             \
-       (echo \#define UTS_RELEASE \"$(UTS_RELEASE)\";)
+       (echo \#define UTS_RELEASE \"$(KERNELRELEASE)\"; echo \#define UTS_RELEASE_FULL \"$(KERNELRELEASE_FULL)\";)
 endef
 
 define filechk_version.h
@@ -1242,7 +1261,7 @@ $(version_h): $(srctree)/Makefile FORCE
        $(call filechk,version.h)
        $(Q)rm -f $(old_version_h)
 
-include/generated/utsrelease.h: include/config/kernel.release FORCE
+include/generated/utsrelease.h: include/config/kernel.release include/config/kernel.release_full FORCE
        $(call filechk,utsrelease.h)
 
 PHONY += headerdep