162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci#
362306a36Sopenharmony_ci# Makefile for the linux kernel.
462306a36Sopenharmony_ci#
562306a36Sopenharmony_ci
662306a36Sopenharmony_ciccflags-y := -fno-function-sections -fno-data-sections
762306a36Sopenharmony_ci
862306a36Sopenharmony_ciobj-y                          := main.o version.o mounts.o
962306a36Sopenharmony_ciifneq ($(CONFIG_BLK_DEV_INITRD),y)
1062306a36Sopenharmony_ciobj-y                          += noinitramfs.o
1162306a36Sopenharmony_cielse
1262306a36Sopenharmony_ciobj-$(CONFIG_BLK_DEV_INITRD)   += initramfs.o
1362306a36Sopenharmony_ciendif
1462306a36Sopenharmony_ciobj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciobj-y                          += init_task.o
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_cimounts-y			:= do_mounts.o
1962306a36Sopenharmony_cimounts-$(CONFIG_BLK_DEV_RAM)	+= do_mounts_rd.o
2062306a36Sopenharmony_cimounts-$(CONFIG_BLK_DEV_INITRD)	+= do_mounts_initrd.o
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ci#
2362306a36Sopenharmony_ci# UTS_VERSION
2462306a36Sopenharmony_ci#
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_cismp-flag-$(CONFIG_SMP)			:= SMP
2762306a36Sopenharmony_cipreempt-flag-$(CONFIG_PREEMPT_BUILD)	:= PREEMPT
2862306a36Sopenharmony_cipreempt-flag-$(CONFIG_PREEMPT_DYNAMIC)	:= PREEMPT_DYNAMIC
2962306a36Sopenharmony_cipreempt-flag-$(CONFIG_PREEMPT_RT)	:= PREEMPT_RT
3062306a36Sopenharmony_ci
3162306a36Sopenharmony_cibuild-version = $(or $(KBUILD_BUILD_VERSION), $(build-version-auto))
3262306a36Sopenharmony_cibuild-timestamp = $(or $(KBUILD_BUILD_TIMESTAMP), $(build-timestamp-auto))
3362306a36Sopenharmony_ci
3462306a36Sopenharmony_ci# Maximum length of UTS_VERSION is 64 chars
3562306a36Sopenharmony_cifilechk_uts_version = \
3662306a36Sopenharmony_ci	utsver=$$(echo '$(pound)'"$(build-version)" $(smp-flag-y) $(preempt-flag-y) "$(build-timestamp)" | cut -b -64); \
3762306a36Sopenharmony_ci	echo '$(pound)'define UTS_VERSION \""$${utsver}"\"
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ci#
4062306a36Sopenharmony_ci# Build version.c with temporary UTS_VERSION
4162306a36Sopenharmony_ci#
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci$(obj)/utsversion-tmp.h: FORCE
4462306a36Sopenharmony_ci	$(call filechk,uts_version)
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciclean-files += utsversion-tmp.h
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci$(obj)/version.o: $(obj)/utsversion-tmp.h
4962306a36Sopenharmony_ciCFLAGS_version.o := -include $(obj)/utsversion-tmp.h
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci#
5262306a36Sopenharmony_ci# Build version-timestamp.c with final UTS_VERSION
5362306a36Sopenharmony_ci#
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ciinclude/generated/utsversion.h: build-version-auto = $(shell $(srctree)/$(src)/build-version)
5662306a36Sopenharmony_ciinclude/generated/utsversion.h: build-timestamp-auto = $(shell LC_ALL=C date)
5762306a36Sopenharmony_ciinclude/generated/utsversion.h: FORCE
5862306a36Sopenharmony_ci	$(call filechk,uts_version)
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci$(obj)/version-timestamp.o: include/generated/utsversion.h
6162306a36Sopenharmony_ciCFLAGS_version-timestamp.o := -include include/generated/utsversion.h
6262306a36Sopenharmony_ciKASAN_SANITIZE_version-timestamp.o := n
6362306a36Sopenharmony_ciKCSAN_SANITIZE_version-timestamp.o := n
6462306a36Sopenharmony_ciGCOV_PROFILE_version-timestamp.o := n
65