1 # SPDX-License-Identifier: GPL-2.0
2 # ===========================================================================
3 # OpenWrt configuration targets
8 rm -f
*.o lxdialog
/*.o
*.moc
$(clean-files
) conf mconf qconf
12 # ===========================================================================
13 # Variables needed by the upstream Makefile
15 # Avoids displaying 'UPD mconf-cfg' in an otherwise quiet make menuconfig
18 CONFIG_SHELL
:=$(SHELL
)
24 dot-target
= $(dir $@
).
$(notdir $@
)
26 # taken from ../Kbuild.include
30 trap
"rm -f $(dot-target).tmp" EXIT
; \
31 { $(filechk_
$(1)); } > $(dot-target
).tmp
; \
32 if
[ ! -r
$@
] ||
! cmp
-s
$@
$(dot-target
).tmp
; then \
34 mv
-f
$(dot-target
).tmp
$@
; \
38 ### Stripped down upstream Makefile follows:
39 # ===========================================================================
40 # object files used by all kconfig flavours
41 common-objs
:= confdata.o expr.o lexer.
lex.o parser.tab.o preprocess.o \
44 $(obj
)/lexer.
lex.o
: $(obj
)/parser.tab.h
45 HOSTCFLAGS_lexer.
lex.o
:= -I
$(srctree
)/$(src
)
46 HOSTCFLAGS_parser.tab.o
:= -I
$(srctree
)/$(src
)
48 # conf: Used for defconfig, oldconfig and related targets
50 conf-objs
:= conf.o
$(common-objs
)
52 # mconf: Used for the menuconfig target based on lxdialog
54 lxdialog
:= $(addprefix lxdialog
/, \
55 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
)
56 mconf-objs
:= mconf.o
$(lxdialog
) $(common-objs
)
58 HOSTLDLIBS_mconf
= $(shell .
$(obj
)/mconf-cfg
&& echo
$$libs)
59 $(foreach f
, mconf.o
$(lxdialog
), \
60 $(eval HOSTCFLAGS_
$f = $$(shell .
$(obj
)/mconf-cfg
&& echo
$$$$cflags)))
62 $(addprefix $(obj
)/, mconf.o
$(lxdialog
)): $(obj
)/mconf-cfg
64 # qconf: Used for the xconfig target based on Qt
66 qconf-cxxobjs
:= qconf.o
67 qconf-objs
:= images.o
$(common-objs
)
69 HOSTLDLIBS_qconf
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$libs)
70 HOSTCXXFLAGS_qconf.o
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$cflags)
72 $(obj
)/qconf.o
: $(obj
)/qconf-cfg
$(obj
)/qconf.moc
74 quiet_cmd_moc
= MOC
$@
75 cmd_moc
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$moc) -i
$< -o
$@
77 $(obj
)/%.moc
: $(src
)/%.h
$(obj
)/qconf-cfg
80 # check if necessary packages are available, and configure build flags
81 filechk_conf_cfg
= $(CONFIG_SHELL
) $<
83 $(obj
)/%conf-cfg
: $(src
)/%conf-cfg.sh FORCE
84 $(call filechk
,conf_cfg
)
86 clean-files
+= *conf-cfg
88 # ===========================================================================
89 # OpenWrt rules and final adjustments that need to be made after reading the
90 # full upstream Makefile
94 ifdef BUILD_SHIPPED_FILES
95 shipped-files
:= lexer.
lex.c parser.tab.c parser.tab.h
96 clean-files
+= $(shipped-files
)
98 .SECONDARY
: $(shipped-files
)
107 $(foreach f
, mconf.o
$(lxdialog
), \
108 $(eval
$f: CFLAGS
+=$$(HOSTCFLAGS_
$f)))
110 $(obj
)/lexer.
lex.o
: CFLAGS
+= $(HOSTCFLAGS_lexer.
lex.o
)
111 $(obj
)/parser.tab.o
: CFLAGS
+= $(HOSTCFLAGS_parser.tab.o
)
112 $(obj
)/qconf.o
: CXXFLAGS
+=$(HOSTCXXFLAGS_qconf.o
)
116 # The *conf-cfg file is used (then filtered out) as the first prerequisite to
117 # avoid sourcing it before the script is built, when trying to compute CFLAGS
118 # for the actual first prerequisite. This avoids errors like:
119 # '/bin/sh: ./mconf-cfg: No such file or directory'
120 mconf
: mconf-cfg
$(mconf-objs
)
121 $(CC
) -o
$@
$(filter-out mconf-cfg
,$^
) $(HOSTLDLIBS_mconf
)
123 qconf
: qconf-cfg
$(qconf-cxxobjs
) $(qconf-objs
)
124 $(CXX
) -o
$@
$(filter-out qconf-cfg
,$^
) $(HOSTLDLIBS_qconf
)