1 # SPDX-License-Identifier: GPL-2.0-only
2 # ===========================================================================
3 # OpenWrt configuration targets
8 rm -f
*.o lxdialog
/*.o
*.moc
$(clean-files
) conf mconf qconf nconf
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 removed or emptied when this Makefile get updated again.
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
)
27 dot-target
= $(dir $@
).
$(notdir $@
)
29 # taken from ../Kbuild.include
33 trap
"rm -f $(dot-target).tmp" EXIT
; \
34 { $(filechk_
$(1)); } > $(dot-target
).tmp
; \
35 if
[ ! -r
$@
] ||
! cmp
-s
$@
$(dot-target
).tmp
; then \
37 mv
-f
$(dot-target
).tmp
$@
; \
41 ### Stripped down upstream Makefile follows:
42 # ===========================================================================
43 # object files used by all kconfig flavours
44 common-objs
:= confdata.o expr.o lexer.
lex.o parser.tab.o preprocess.o \
47 $(obj
)/lexer.
lex.o
: $(obj
)/parser.tab.h
48 HOSTCFLAGS_lexer.
lex.o
:= -I
$(srctree
)/$(src
)
49 HOSTCFLAGS_parser.tab.o
:= -I
$(srctree
)/$(src
)
51 # conf: Used for defconfig, oldconfig and related targets
53 conf-objs
:= conf.o
$(common-objs
)
55 # nconf: Used for the nconfig target based on ncurses
57 nconf-objs
:= nconf.o nconf.gui.o
$(common-objs
)
59 HOSTLDLIBS_nconf
= $(shell .
$(obj
)/nconf-cfg
&& echo
$$libs)
60 HOSTCFLAGS_nconf.o
= $(shell .
$(obj
)/nconf-cfg
&& echo
$$cflags)
61 HOSTCFLAGS_nconf.gui.o
= $(shell .
$(obj
)/nconf-cfg
&& echo
$$cflags)
63 $(obj
)/nconf.o
$(obj
)/nconf.gui.o
: $(obj
)/nconf-cfg
65 # mconf: Used for the menuconfig target based on lxdialog
67 lxdialog
:= $(addprefix lxdialog
/, \
68 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
)
69 mconf-objs
:= mconf.o
$(lxdialog
) $(common-objs
)
71 HOSTLDLIBS_mconf
= $(shell .
$(obj
)/mconf-cfg
&& echo
$$libs)
72 $(foreach f
, mconf.o
$(lxdialog
), \
73 $(eval HOSTCFLAGS_
$f = $$(shell .
$(obj
)/mconf-cfg
&& echo
$$$$cflags)))
75 $(addprefix $(obj
)/, mconf.o
$(lxdialog
)): $(obj
)/mconf-cfg
77 # qconf: Used for the xconfig target based on Qt
79 qconf-cxxobjs
:= qconf.o
80 qconf-objs
:= images.o
$(common-objs
)
82 HOSTLDLIBS_qconf
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$libs)
83 HOSTCXXFLAGS_qconf.o
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$cflags)
85 $(obj
)/qconf.o
: $(obj
)/qconf-cfg
$(obj
)/qconf.moc
87 quiet_cmd_moc
= MOC
$@
88 cmd_moc
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$moc) -i
$< -o
$@
90 $(obj
)/%.moc
: $(src
)/%.h
$(obj
)/qconf-cfg
93 # check if necessary packages are available, and configure build flags
94 filechk_conf_cfg
= $(CONFIG_SHELL
) $<
96 $(obj
)/%conf-cfg
: $(src
)/%conf-cfg.sh FORCE
97 $(call filechk
,conf_cfg
)
99 clean-files
+= *conf-cfg
101 # ===========================================================================
102 # OpenWrt rules and final adjustments that need to be made after reading the
103 # full upstream Makefile
107 ifdef BUILD_SHIPPED_FILES
108 shipped-files
:= lexer.
lex.c parser.tab.c parser.tab.h
109 clean-files
+= $(shipped-files
)
111 .SECONDARY
: $(shipped-files
)
120 $(foreach f
, mconf.o
$(lxdialog
), \
121 $(eval
$f: CFLAGS
+=$$(HOSTCFLAGS_
$f)))
123 $(obj
)/lexer.
lex.o
: CFLAGS
+= $(HOSTCFLAGS_lexer.
lex.o
)
124 $(obj
)/parser.tab.o
: CFLAGS
+= $(HOSTCFLAGS_parser.tab.o
)
125 $(obj
)/qconf.o
: CXXFLAGS
+=$(HOSTCXXFLAGS_qconf.o
)
129 # The *conf-cfg file is used (then filtered out) as the first prerequisite to
130 # avoid sourcing it before the script is built, when trying to compute CFLAGS
131 # for the actual first prerequisite. This avoids errors like:
132 # '/bin/sh: ./mconf-cfg: No such file or directory'
133 mconf
: mconf-cfg
$(mconf-objs
)
134 $(CC
) -o
$@
$(filter-out mconf-cfg
,$^
) $(HOSTLDLIBS_mconf
)
136 nconf
: nconf-cfg
$(nconf-objs
)
137 $(CC
) -o
$@
$(filter-out nconf-cfg
,$^
) $(HOSTLDLIBS_nconf
)
139 qconf
: qconf-cfg
$(qconf-cxxobjs
) $(qconf-objs
)
140 $(CXX
) -o
$@
$(filter-out qconf-cfg
,$^
) $(HOSTLDLIBS_qconf
)