1 # SPDX-License-Identifier: GPL-2.0-only
2 # ===========================================================================
3 # OpenWrt configuration targets
8 rm -f
$(clean-files
) $(hostprogs
)
10 clean-files
:= *.o lxdialog
/*.o
*.moc qconf-moc.
cc \
11 *conf-cfg
# <- This should be removed after 23.05 is EOL
13 # ===========================================================================
14 # Variables needed by the upstream Makefile
16 export HOSTPKG_CONFIG
=pkg-config
17 CONFIG_SHELL
:=$(SHELL
)
21 quiet
:=$(if
$V,,_silent
)
22 include Kbuild.
include
24 ### Stripped down upstream Makefile follows:
25 # ===========================================================================
26 # object files used by all kconfig flavours
27 common-objs
:= confdata.o expr.o lexer.
lex.o menu.o parser.tab.o \
28 preprocess.o symbol.o util.o
30 $(obj
)/lexer.
lex.o
: $(obj
)/parser.tab.h
31 HOSTCFLAGS_lexer.
lex.o
:= -I
$(srctree
)/$(src
)
32 HOSTCFLAGS_parser.tab.o
:= -I
$(srctree
)/$(src
)
34 # conf: Used for defconfig, oldconfig and related targets
36 conf-objs
:= conf.o
$(common-objs
)
38 # nconf: Used for the nconfig target based on ncurses
40 nconf-objs
:= nconf.o nconf.gui.o
$(common-objs
)
42 HOSTLDLIBS_nconf
= $(call read-file
, $(obj
)/nconf-libs
)
43 HOSTCFLAGS_nconf.o
= $(call read-file
, $(obj
)/nconf-cflags
)
44 HOSTCFLAGS_nconf.gui.o
= $(call read-file
, $(obj
)/nconf-cflags
)
46 $(obj
)/nconf
: |
$(obj
)/nconf-libs
47 $(obj
)/nconf.o
$(obj
)/nconf.gui.o
: |
$(obj
)/nconf-cflags
49 # mconf: Used for the menuconfig target based on lxdialog
51 lxdialog
:= $(addprefix lxdialog
/, \
52 checklist.o inputbox.o menubox.o textbox.o util.o yesno.o
)
53 mconf-objs
:= mconf.o
$(lxdialog
) $(common-objs
)
55 HOSTLDLIBS_mconf
= $(call read-file
, $(obj
)/mconf-libs
)
56 $(foreach f
, mconf.o
$(lxdialog
), \
57 $(eval HOSTCFLAGS_
$f = $$(call read-file
, $(obj
)/mconf-cflags
)))
59 $(obj
)/mconf
: |
$(obj
)/mconf-libs
60 $(addprefix $(obj
)/, mconf.o
$(lxdialog
)): |
$(obj
)/mconf-cflags
62 # qconf: Used for the xconfig target based on Qt
64 qconf-cxxobjs
:= qconf.o qconf-moc.o
65 qconf-objs
:= images.o
$(common-objs
)
67 HOSTLDLIBS_qconf
= $(call read-file
, $(obj
)/qconf-libs
)
68 HOSTCXXFLAGS_qconf.o
= -std
=c
++11 -fPIC
$(call read-file
, $(obj
)/qconf-cflags
)
69 HOSTCXXFLAGS_qconf-moc.o
= -std
=c
++11 -fPIC
$(call read-file
, $(obj
)/qconf-cflags
)
70 $(obj
)/qconf
: |
$(obj
)/qconf-libs
71 $(obj
)/qconf.o
$(obj
)/qconf-moc.o
: |
$(obj
)/qconf-cflags
73 quiet_cmd_moc
= MOC
$@
74 cmd_moc
= $(call read-file
, $(obj
)/qconf-bin
)/moc
$< -o
$@
76 $(obj
)/qconf-moc.
cc: $(src
)/qconf.h FORCE |
$(obj
)/qconf-bin
77 $(call if_changed
,moc
)
79 targets
+= qconf-moc.
cc
81 # check if necessary packages are available, and configure build flags
82 cmd_conf_cfg
= $< $(addprefix $(obj
)/$*conf-
, cflags libs bin
); touch
$(obj
)/$*conf-bin
84 $(obj
)/%conf-cflags
$(obj
)/%conf-libs
$(obj
)/%conf-bin
: $(src
)/%conf-cfg.sh
87 clean-files
+= *conf-cflags
*conf-libs
*conf-bin
89 # ===========================================================================
90 # OpenWrt rules and final adjustments that need to be made after reading the
91 # full upstream Makefile
95 ifdef BUILD_SHIPPED_FILES
96 shipped-files
:= lexer.
lex.c parser.tab.c parser.tab.h
97 clean-files
+= $(shipped-files
)
99 .SECONDARY
: $(shipped-files
)
109 $(1): LDLIBS
+=$$(HOSTLDLIBS_
$(1))
110 $(1): $($(1)-objs
) $$($(1)-cxxobjs
)
111 $(if
$($(1)-cxxobjs
), $(CXX
) $$(LDFLAGS
) -o
$$@
$$^
$$(LDLIBS
))
112 all-objs
+= $($(1)-objs
)
113 all-cxxobjs
+= $($(1)-cxxobjs
)
118 $(foreach f
,$(hostprogs
),$(eval
$(call link_rule
,$f)))
121 $(foreach f
,$(sort $(all-objs
)), \
122 $(eval
$f: CFLAGS
+=$$(HOSTCFLAGS_
$f)))
124 $(foreach f
,$(sort $(all-cxxobjs
)), \
125 $(eval
$f: CXXFLAGS
+=$$(HOSTCXXFLAGS_
$f)))