1 # SPDX-License-Identifier: GPL-2.0-or-later
3 # Early coreboot specific configuration
4 KBUILD_KCONFIG ?
= src
/Kconfig
11 # Include original Makefile, with just enough edits to work for us
12 $(objk
)/Makefile.real
: $(dir $(lastword
$(MAKEFILE_LIST
)))Makefile
15 -e
"s,\$$(obj),\$$(objk),g" \
16 -e
"s,\$$(src),\$$(srck),g" \
17 -e
"s,^help:,help_kconfig help::," \
18 -e
"s,^%.config:,__disable__&," \
19 -e
"s,^savedefconfig:,__disable__&," \
20 -e
"s,\$$(srctree)/arch/\$$(SRCARCH)/configs/\$$(KBUILD_DEFCONFIG),\$$(KBUILD_DEFCONFIG)," \
21 -e
"s,--defconfig=arch/\$$(SRCARCH)/configs/\$$(KBUILD_DEFCONFIG),--defconfig=\$$(KBUILD_DEFCONFIG)," \
22 -e
"/^unexport CONFIG_$$/d" \
29 cmd_conf_cfg
= $< $(addprefix $(obj
)/$*conf-
, cflags libs bin
); touch
$(obj
)/$*conf-bin
32 # Read a file, replacing newlines with spaces
34 # Make 4.2 or later can read a file by using its builtin function.
36 # Imported from Linux upstream:
37 # commit 6768fa4bcb6c1618248f135d04b9287ba2724ae0
38 # Author: Masahiro Yamada <masahiroy@kernel.org>
39 ifneq ($(filter-out 3.
% 4.0 4.1, $(MAKE_VERSION
)),)
40 read-file
= $(subst $(newline
),$(space
),$(file
< $1))
42 read-file
= $(shell cat
$1 2>/dev
/null
)
45 -include $(objk
)/Makefile.real
46 unexport KCONFIG_DEFCONFIG_LIST
48 # Fill in Linux kconfig build rules to work
50 savedefconfig
: $(objk
)/conf
51 cp
$(DOTCONFIG
) $(DEFCONFIG
)
53 $< --savedefconfig
=$(DEFCONFIG
) $(KBUILD_KCONFIG
)
59 $(objk
)/%.o
: $(srck
)/%.c
60 $(HOSTCC
) -I
$(srck
) -I
$(objk
) -c
$(HOSTCFLAGS_
$(notdir $@
)) -o
$@
$<
62 $(objk
)/%.o
: $(srck
)/%.
cc
63 $(HOSTCXX
) -I
$(srck
) -I
$(objk
) -c
$(HOSTCXXFLAGS_
$(notdir $@
)) -o
$@
$<
65 $(objk
)/%.o
: $(objk
)/%.c
66 $(HOSTCC
) -I
$(srck
) -I
$(objk
) -c
-o
$@
$<
68 $(objk
)/%.moc
: $(srck
)/%.h |
$(objk
)/qconf-cfg
71 define hostprogs_template
72 # $1 entry in hostprogs
73 $(objk
)/$(1): $$(foreach _o
,$$($(1)-objs
) $$($(1)-cxxobjs
),$(objk
)/$$(_o
)) |
$(wildcard $(objk
)/$(1)-cfg
)
74 $$(HOSTCXX
) -o
$$@
$$^
$$(HOSTLDLIBS_
$(1))
77 $(foreach prog
,$(hostprogs
),$(eval
$(call hostprogs_template
,$(prog
))))
79 # This might be a bit of a chicken & egg problem, using a kconfig flag when
80 # building kconfig, but if you're messing with the parser you probably know
81 # what you're doing: make CONFIG_UTIL_GENPARSER=y
82 ifeq ($(CONFIG_UTIL_GENPARSER
),y
)
83 $(objk
)/%.tab.c
$(objk
)/%.tab.h
: $(srck
)/%.y
84 bison
-t
-l
--defines
-b
$(objk
)/$* $<
86 $(objk
)/%.
lex.c
: $(srck
)/%.l
89 else # !CONFIG_UTIL_GENPARSER
91 $(objk
)/parser.tab.c
: |
$(objk
)/parser.tab.h
93 $(objk
)/%: $(srck
)/%_shipped
98 # Support mingw by shipping our own regex implementation
99 _OS
=$(shell uname
-s |cut
-c-7
)
101 ifeq ($(_OS
),MINGW32
)
104 $(objk
)/regex.o
: $(srck
)/regex.c
105 $(HOSTCC
) $(HOSTCFLAGS
) $(HOST_EXTRACFLAGS
) -DHAVE_STRING_H
-c
-o
$@
$<
107 conf-objs
+= $(regex-objs
)
108 mconf-objs
+= $(regex-objs
)
110 # Provide tool to convert kconfig output into Ada format
111 $(objk
)/toada
: $(objk
)/toada.o
112 $(HOSTCC
) $(HOSTCFLAGS
) $(HOST_EXTRACFLAGS
) -o
$@
$^
113 $(objk
)/toada.o
: $(srck
)/toada.c
114 $(HOSTCC
) $(HOSTCFLAGS
) $(HOST_EXTRACFLAGS
) -c
-o
$@
$<