1 # SPDX-License-Identifier: GPL-2.0
2 # ===========================================================================
3 # OpenWrt configuration targets
8 rm -f
*.o lxdialog
/*.o
*.moc
$(clean-files
) conf mconf qconf
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 # mconf: Used for the menuconfig target based on lxdialog
57 lxdialog
:= $(addprefix lxdialog
/, \
58 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
)
59 mconf-objs
:= mconf.o
$(lxdialog
) $(common-objs
)
61 HOSTLDLIBS_mconf
= $(shell .
$(obj
)/mconf-cfg
&& echo
$$libs)
62 $(foreach f
, mconf.o
$(lxdialog
), \
63 $(eval HOSTCFLAGS_
$f = $$(shell .
$(obj
)/mconf-cfg
&& echo
$$$$cflags)))
65 $(addprefix $(obj
)/, mconf.o
$(lxdialog
)): $(obj
)/mconf-cfg
67 # qconf: Used for the xconfig target based on Qt
69 qconf-cxxobjs
:= qconf.o
70 qconf-objs
:= images.o
$(common-objs
)
72 HOSTLDLIBS_qconf
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$libs)
73 HOSTCXXFLAGS_qconf.o
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$cflags)
75 $(obj
)/qconf.o
: $(obj
)/qconf-cfg
$(obj
)/qconf.moc
77 quiet_cmd_moc
= MOC
$@
78 cmd_moc
= $(shell .
$(obj
)/qconf-cfg
&& echo
$$moc) -i
$< -o
$@
80 $(obj
)/%.moc
: $(src
)/%.h
$(obj
)/qconf-cfg
83 # check if necessary packages are available, and configure build flags
84 filechk_conf_cfg
= $(CONFIG_SHELL
) $<
86 $(obj
)/%conf-cfg
: $(src
)/%conf-cfg.sh FORCE
87 $(call filechk
,conf_cfg
)
89 clean-files
+= *conf-cfg
91 # ===========================================================================
92 # OpenWrt rules and final adjustments that need to be made after reading the
93 # full upstream Makefile
97 ifdef BUILD_SHIPPED_FILES
98 shipped-files
:= lexer.
lex.c parser.tab.c parser.tab.h
99 clean-files
+= $(shipped-files
)
101 .SECONDARY
: $(shipped-files
)
110 $(foreach f
, mconf.o
$(lxdialog
), \
111 $(eval
$f: CFLAGS
+=$$(HOSTCFLAGS_
$f)))
113 $(obj
)/lexer.
lex.o
: CFLAGS
+= $(HOSTCFLAGS_lexer.
lex.o
)
114 $(obj
)/parser.tab.o
: CFLAGS
+= $(HOSTCFLAGS_parser.tab.o
)
115 $(obj
)/qconf.o
: CXXFLAGS
+=$(HOSTCXXFLAGS_qconf.o
)
119 # The *conf-cfg file is used (then filtered out) as the first prerequisite to
120 # avoid sourcing it before the script is built, when trying to compute CFLAGS
121 # for the actual first prerequisite. This avoids errors like:
122 # '/bin/sh: ./mconf-cfg: No such file or directory'
123 mconf
: mconf-cfg
$(mconf-objs
)
124 $(CC
) -o
$@
$(filter-out mconf-cfg
,$^
) $(HOSTLDLIBS_mconf
)
126 qconf
: qconf-cfg
$(qconf-cxxobjs
) $(qconf-objs
)
127 $(CXX
) -o
$@
$(filter-out qconf-cfg
,$^
) $(HOSTLDLIBS_qconf
)