History

kbuild: make cc-version available in kbuild files

Move $(CC) support functions to Kbuild.include so they are available in the kbuild files. In addition the following was done: o as-option documented in Documentation/kbuild/makefiles.txt o Moved documentation to new section to match new scope of functions o added cc-ifversion used to conditionally select a text string dependent on actual $(CC) version o documented cc-ifversion o change so Kbuild.include is read before the kbuild file

Sam Ravnborg committed 20 years ago

Commit 20a468b1 parent b39927c4 files · +136 −102Browse files

Showing the changes to scripts (2 of 4 files). Show all

Unified · Split

2 files
  1. scripts/Kbuild.include +37 −0
  2. scripts/Makefile.build +2 −1
scripts/Kbuild.include+37−0
@@ -44,6 +44,43 @@ define filechk · 43 unmodified lines
4444 fi
4545 endef
4646
47+######
48+# cc support functions to be used (only) in arch/$(ARCH)/Makefile
49+# See documentation in Documentation/kbuild/makefiles.txt
50+
51+# as-option
52+# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
53+
54+as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
55+ -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
56+ else echo "$(2)"; fi ;)
57+
58+# cc-option
59+# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
60+
61+cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
62+ > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
63+
64+# cc-option-yn
65+# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
66+cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
67+ > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
68+
69+# cc-option-align
70+# Prefix align with either -falign or -malign
71+cc-option-align = $(subst -functions=0,,\
72+ $(call cc-option,-falign-functions=0,-malign-functions=0))
73+
74+# cc-version
75+# Usage gcc-ver := $(call cc-version, $(CC))
76+cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
77+ $(if $(1), $(1), $(CC)))
78+
79+# cc-ifversion
80+# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
81+cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \
82+ echo $(3); fi;)
83+
4784 ###
4885 # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
4986 # Usage:
scripts/Makefile.build+2−1
@@ -10,11 +10,12 @@ __build: · 9 unmodified lines
1010 # Read .config if it exist, otherwise ignore
1111 -include .config
1212
13+include scripts/Kbuild.include
14+
1315 # The filename Kbuild has precedence over Makefile
1416 kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
1517 include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
1618
17−include scripts/Kbuild.include
1819 include scripts/Makefile.lib
1920
2021 ifdef host-progs

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t