1 # SPDX-License-Identifier: GPL-2.0-only
2 # ===========================================================================
3 # OpenWrt configuration targets
8 rm -f
*.o lxdialog
/*.o
*.moc .
*.cmd
$(clean-files
)
10 # This clean-files definition is here to ensure that temporary files from the
11 # previous version are removed by make config-clean.
12 # It should be emptied after the end of support for OpenWrt 19.07.
13 clean-files
:= zconf.tab.c zconf.
lex.c zconf.hash.c .tmp_qtcheck
15 # ===========================================================================
16 # Variables needed by the upstream Makefile
18 # Avoids displaying 'UPD mconf-cfg' in an otherwise quiet make menuconfig
21 CONFIG_SHELL
:=$(SHELL
)
28 # some definitions taken from ../Kbuild.include
29 dot-target
= $(dir $@
).
$(notdir $@
)
31 escsq = $(subst $(squote),'\
$(squote
)',$1)
35 trap "rm -f $(dot-target).tmp" EXIT; \
36 { $(filechk_$(1)); } > $(dot-target).tmp; \
37 if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \
39 mv -f $(dot-target).tmp $@; \
42 cmd-check = $(if $(strip $(cmd_$@)),,1)
43 make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
44 newer-prereqs = $(filter-out $(PHONY),$?)
45 if_changed = $(if $(newer-prereqs)$(cmd-check), \
47 printf '%s
\n' 'cmd_
$@
:= $(make-cmd
)' > $(dot-target).cmd, @:)
49 ### Stripped down upstream Makefile follows:
50 # ===========================================================================
51 # object files used by all kconfig flavours
52 common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
53 preprocess.o symbol.o util.o
55 $(obj)/lexer.lex.o: $(obj)/parser.tab.h
56 HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
57 HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
59 # conf: Used for defconfig, oldconfig and related targets
61 conf-objs := conf.o $(common-objs)
63 # nconf: Used for the nconfig target based on ncurses
65 nconf-objs := nconf.o nconf.gui.o $(common-objs)
67 HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs)
68 HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
69 HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
71 $(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
73 # mconf: Used for the menuconfig target based on lxdialog
75 lxdialog := $(addprefix lxdialog/, \
76 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
77 mconf-objs := mconf.o $(lxdialog) $(common-objs)
79 HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
80 $(foreach f, mconf.o $(lxdialog), \
81 $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
83 $(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
85 # qconf: Used for the xconfig target based on Qt
87 qconf-cxxobjs := qconf.o qconf-moc.o
88 qconf-objs := images.o $(common-objs)
90 HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs)
91 HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
92 HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
94 $(obj)/qconf.o: $(obj)/qconf-cfg
96 quiet_cmd_moc = MOC $@
97 cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
99 $(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
100 $(call if_changed,moc)
102 targets += qconf-moc.cc
104 # check if necessary packages are available, and configure build flags
105 filechk_conf_cfg = $(CONFIG_SHELL) $<
107 $(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
108 $(call filechk,conf_cfg)
110 clean-files += *conf-cfg
112 # ===========================================================================
113 # OpenWrt rules and final adjustments that need to be made after reading the
114 # full upstream Makefile
116 clean-files += $(targets) $(hostprogs)
120 ifdef BUILD_SHIPPED_FILES
121 shipped-files := lexer.lex.c parser.tab.c parser.tab.h
122 clean-files += $(shipped-files)
124 .SECONDARY: $(shipped-files)
133 $(foreach f,$(conf-objs) $(filter-out $(common-objs),$(mconf-objs) \
136 $(eval $(obj)/$f: CFLAGS+=$$(HOSTCFLAGS_$f)))
138 $(foreach f,$(qconf-cxxobjs), \
139 $(eval $(obj)/$f: CXXFLAGS+=$$(HOSTCXXFLAGS_$f)))
141 $(obj)/conf: $(addprefix $(obj)/,$(conf-objs))
143 # The *conf-cfg file is used (then filtered out) as the first prerequisite to
144 # avoid sourcing it before the script is built, when trying to compute CFLAGS
145 # for the actual first prerequisite. This avoids errors like:
146 # '/bin
/sh
: .
/mconf-cfg
: No such file or directory
'
147 $(obj)/mconf: mconf-cfg $(addprefix $(obj)/,$(mconf-objs))
148 $(CC) -o $@ $(filter-out mconf-cfg,$^) $(HOSTLDLIBS_mconf)
150 $(obj)/nconf: nconf-cfg $(addprefix $(obj)/,$(nconf-objs))
151 $(CC) -o $@ $(filter-out nconf-cfg,$^) $(HOSTLDLIBS_nconf)
153 $(obj)/qconf: qconf-cfg $(addprefix $(obj)/,$(qconf-cxxobjs) $(qconf-objs))
154 $(CXX) -o $@ $(filter-out qconf-cfg,$^) $(HOSTLDLIBS_qconf)