octeontx: drop target
[openwrt/openwrt.git] / scripts / config / Makefile
1 # SPDX-License-Identifier: GPL-2.0-only
2 # ===========================================================================
3 # OpenWrt configuration targets
4
5 .PHONY: clean all
6 all: conf mconf
7 clean:
8 rm -f $(clean-files) $(hostprogs)
9
10 clean-files := *.o lxdialog/*.o *.moc qconf-moc.cc \
11 *conf-cfg # <- This should be removed after 23.05 is EOL
12
13 # ===========================================================================
14 # Variables needed by the upstream Makefile
15
16 export HOSTPKG_CONFIG=pkg-config
17 CONFIG_SHELL:=$(SHELL)
18 src:=$(CURDIR)
19 obj:=.
20 Q:=$(if $V,,@)
21 quiet:=$(if $V,,_silent)
22 include Kbuild.include
23
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
29
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)
33
34 # conf: Used for defconfig, oldconfig and related targets
35 hostprogs += conf
36 conf-objs := conf.o $(common-objs)
37
38 # nconf: Used for the nconfig target based on ncurses
39 hostprogs += nconf
40 nconf-objs := nconf.o nconf.gui.o $(common-objs)
41
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)
45
46 $(obj)/nconf: | $(obj)/nconf-libs
47 $(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags
48
49 # mconf: Used for the menuconfig target based on lxdialog
50 hostprogs += mconf
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)
54
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)))
58
59 $(obj)/mconf: | $(obj)/mconf-libs
60 $(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags
61
62 # qconf: Used for the xconfig target based on Qt
63 hostprogs += qconf
64 qconf-cxxobjs := qconf.o qconf-moc.o
65 qconf-objs := images.o $(common-objs)
66
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
72
73 quiet_cmd_moc = MOC $@
74 cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@
75
76 $(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin
77 $(call if_changed,moc)
78
79 targets += qconf-moc.cc
80
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
83
84 $(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
85 $(call cmd,conf_cfg)
86
87 clean-files += *conf-cflags *conf-libs *conf-bin
88
89 # ===========================================================================
90 # OpenWrt rules and final adjustments that need to be made after reading the
91 # full upstream Makefile
92
93 FORCE:
94
95 ifdef BUILD_SHIPPED_FILES
96 shipped-files := lexer.lex.c parser.tab.c parser.tab.h
97 clean-files += $(shipped-files)
98
99 .SECONDARY: $(shipped-files)
100
101 %.tab.c %.tab.h: %.y
102 bison -l -d -b $* $<
103
104 %.lex.c: %.l
105 flex -L -o$@ $<
106 endif
107
108 define link_rule
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)
114 endef
115
116 all-objs:=
117 all-cxxobjs:=
118 $(foreach f,$(hostprogs),$(eval $(call link_rule,$f)))
119
120
121 $(foreach f,$(sort $(all-objs)), \
122 $(eval $f: CFLAGS+=$$(HOSTCFLAGS_$f)))
123
124 $(foreach f,$(sort $(all-cxxobjs)), \
125 $(eval $f: CXXFLAGS+=$$(HOSTCXXFLAGS_$f)))