Makefile 1.77 KB
Newer Older
1
# SPDX-License-Identifier: GPL-2.0
Linus Torvalds's avatar
Linus Torvalds committed
2 3 4 5
#
# Makefile for the linux kernel.
#

6 7
ccflags-y := -fno-function-sections -fno-data-sections

8 9 10 11 12 13
obj-y                          := main.o version.o mounts.o
ifneq ($(CONFIG_BLK_DEV_INITRD),y)
obj-y                          += noinitramfs.o
else
obj-$(CONFIG_BLK_DEV_INITRD)   += initramfs.o
endif
Linus Torvalds's avatar
Linus Torvalds committed
14
obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
15 16

obj-y                          += init_task.o
Linus Torvalds's avatar
Linus Torvalds committed
17 18 19 20 21

mounts-y			:= do_mounts.o
mounts-$(CONFIG_BLK_DEV_RAM)	+= do_mounts_rd.o
mounts-$(CONFIG_BLK_DEV_INITRD)	+= do_mounts_initrd.o

22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
#
# UTS_VERSION
#

smp-flag-$(CONFIG_SMP)			:= SMP
preempt-flag-$(CONFIG_PREEMPT_BUILD)	:= PREEMPT
preempt-flag-$(CONFIG_PREEMPT_DYNAMIC)	:= PREEMPT_DYNAMIC
preempt-flag-$(CONFIG_PREEMPT_RT)	:= PREEMPT_RT

build-version = $(or $(KBUILD_BUILD_VERSION), $(build-version-auto))
build-timestamp = $(or $(KBUILD_BUILD_TIMESTAMP), $(build-timestamp-auto))

# Maximum length of UTS_VERSION is 64 chars
filechk_uts_version = \
	utsver=$$(echo '$(pound)'"$(build-version)" $(smp-flag-y) $(preempt-flag-y) "$(build-timestamp)" | cut -b -64); \
	echo '$(pound)'define UTS_VERSION \""$${utsver}"\"

#
# Build version.c with temporary UTS_VERSION
#
Linus Torvalds's avatar
Linus Torvalds committed
42

43 44
$(obj)/utsversion-tmp.h: FORCE
	$(call filechk,uts_version)
45

46 47
clean-files += utsversion-tmp.h

48
$(obj)/version.o: $(obj)/utsversion-tmp.h
49 50 51 52 53 54 55 56 57 58 59 60 61
CFLAGS_version.o := -include $(obj)/utsversion-tmp.h

#
# Build version-timestamp.c with final UTS_VERSION
#

include/generated/utsversion.h: build-version-auto = $(shell $(srctree)/$(src)/build-version)
include/generated/utsversion.h: build-timestamp-auto = $(shell LC_ALL=C date)
include/generated/utsversion.h: FORCE
	$(call filechk,uts_version)

$(obj)/version-timestamp.o: include/generated/utsversion.h
CFLAGS_version-timestamp.o := -include include/generated/utsversion.h