2020-09-22 08:46:30 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
2006-04-20 20:17:34 +00:00
|
|
|
# ===========================================================================
|
2006-04-20 21:00:14 +00:00
|
|
|
# OpenWrt configuration targets
|
2020-04-19 23:12:50 +00:00
|
|
|
|
|
|
|
.PHONY: clean all
|
|
|
|
all: conf mconf
|
|
|
|
clean:
|
2024-02-16 17:32:07 +00:00
|
|
|
rm -f $(clean-files) $(hostprogs)
|
2020-04-19 23:12:50 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
clean-files := *.o lxdialog/*.o *.moc qconf-moc.cc \
|
|
|
|
*conf-cfg # <- This should be removed after 23.05 is EOL
|
2006-04-20 20:17:34 +00:00
|
|
|
|
|
|
|
# ===========================================================================
|
2020-04-19 23:12:50 +00:00
|
|
|
# Variables needed by the upstream Makefile
|
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
export HOSTPKG_CONFIG=pkg-config
|
2020-04-19 23:12:50 +00:00
|
|
|
CONFIG_SHELL:=$(SHELL)
|
2024-02-16 17:32:07 +00:00
|
|
|
src:=$(CURDIR)
|
2020-04-19 23:12:50 +00:00
|
|
|
obj:=.
|
|
|
|
Q:=$(if $V,,@)
|
2024-02-16 17:32:07 +00:00
|
|
|
quiet:=$(if $V,,_silent)
|
|
|
|
include Kbuild.include
|
2020-04-19 23:12:50 +00:00
|
|
|
|
|
|
|
### Stripped down upstream Makefile follows:
|
|
|
|
# ===========================================================================
|
2006-04-20 20:17:34 +00:00
|
|
|
# object files used by all kconfig flavours
|
2021-11-24 21:25:43 +00:00
|
|
|
common-objs := confdata.o expr.o lexer.lex.o menu.o parser.tab.o \
|
|
|
|
preprocess.o symbol.o util.o
|
2020-04-19 23:12:50 +00:00
|
|
|
|
|
|
|
$(obj)/lexer.lex.o: $(obj)/parser.tab.h
|
|
|
|
HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src)
|
|
|
|
HOSTCFLAGS_parser.tab.o := -I $(srctree)/$(src)
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
# conf: Used for defconfig, oldconfig and related targets
|
2021-11-24 21:25:43 +00:00
|
|
|
hostprogs += conf
|
2020-04-19 23:12:50 +00:00
|
|
|
conf-objs := conf.o $(common-objs)
|
2006-08-02 13:36:20 +00:00
|
|
|
|
2020-06-10 01:33:21 +00:00
|
|
|
# nconf: Used for the nconfig target based on ncurses
|
2021-11-24 21:25:43 +00:00
|
|
|
hostprogs += nconf
|
2020-06-10 01:33:21 +00:00
|
|
|
nconf-objs := nconf.o nconf.gui.o $(common-objs)
|
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
HOSTLDLIBS_nconf = $(call read-file, $(obj)/nconf-libs)
|
|
|
|
HOSTCFLAGS_nconf.o = $(call read-file, $(obj)/nconf-cflags)
|
|
|
|
HOSTCFLAGS_nconf.gui.o = $(call read-file, $(obj)/nconf-cflags)
|
2020-06-10 01:33:21 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
$(obj)/nconf: | $(obj)/nconf-libs
|
|
|
|
$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags
|
2020-06-10 01:33:21 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
# mconf: Used for the menuconfig target based on lxdialog
|
2021-11-24 21:25:43 +00:00
|
|
|
hostprogs += mconf
|
2020-04-19 23:12:50 +00:00
|
|
|
lxdialog := $(addprefix lxdialog/, \
|
|
|
|
checklist.o inputbox.o menubox.o textbox.o util.o yesno.o)
|
|
|
|
mconf-objs := mconf.o $(lxdialog) $(common-objs)
|
2013-04-18 12:05:16 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs)
|
2020-04-19 23:12:50 +00:00
|
|
|
$(foreach f, mconf.o $(lxdialog), \
|
2024-02-16 17:32:07 +00:00
|
|
|
$(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags)))
|
2006-08-02 13:36:20 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
$(obj)/mconf: | $(obj)/mconf-libs
|
|
|
|
$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags
|
2020-04-19 23:12:50 +00:00
|
|
|
|
|
|
|
# qconf: Used for the xconfig target based on Qt
|
2021-11-24 21:25:43 +00:00
|
|
|
hostprogs += qconf
|
|
|
|
qconf-cxxobjs := qconf.o qconf-moc.o
|
2020-04-19 23:12:50 +00:00
|
|
|
qconf-objs := images.o $(common-objs)
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
HOSTLDLIBS_qconf = $(call read-file, $(obj)/qconf-libs)
|
|
|
|
HOSTCXXFLAGS_qconf.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
|
|
|
|
HOSTCXXFLAGS_qconf-moc.o = -std=c++11 -fPIC $(call read-file, $(obj)/qconf-cflags)
|
|
|
|
$(obj)/qconf: | $(obj)/qconf-libs
|
|
|
|
$(obj)/qconf.o $(obj)/qconf-moc.o: | $(obj)/qconf-cflags
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
quiet_cmd_moc = MOC $@
|
2024-02-16 17:32:07 +00:00
|
|
|
cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@
|
2021-11-24 21:25:43 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin
|
2021-11-24 21:25:43 +00:00
|
|
|
$(call if_changed,moc)
|
2020-04-07 20:07:23 +00:00
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
targets += qconf-moc.cc
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
# check if necessary packages are available, and configure build flags
|
2024-02-16 17:32:07 +00:00
|
|
|
cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin); touch $(obj)/$*conf-bin
|
2020-04-19 23:12:50 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh
|
|
|
|
$(call cmd,conf_cfg)
|
2020-04-19 23:12:50 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
clean-files += *conf-cflags *conf-libs *conf-bin
|
2020-04-07 20:07:23 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
# ===========================================================================
|
|
|
|
# OpenWrt rules and final adjustments that need to be made after reading the
|
|
|
|
# full upstream Makefile
|
|
|
|
|
|
|
|
FORCE:
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
ifdef BUILD_SHIPPED_FILES
|
|
|
|
shipped-files := lexer.lex.c parser.tab.c parser.tab.h
|
|
|
|
clean-files += $(shipped-files)
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
.SECONDARY: $(shipped-files)
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
%.tab.c %.tab.h: %.y
|
|
|
|
bison -l -d -b $* $<
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2013-04-18 12:05:16 +00:00
|
|
|
%.lex.c: %.l
|
2020-04-19 23:12:50 +00:00
|
|
|
flex -L -o$@ $<
|
2017-07-23 03:08:17 +00:00
|
|
|
endif
|
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
define link_rule
|
|
|
|
$(1): LDLIBS+=$$(HOSTLDLIBS_$(1))
|
|
|
|
$(1): $($(1)-objs) $$($(1)-cxxobjs)
|
|
|
|
$(if $($(1)-cxxobjs), $(CXX) $$(LDFLAGS) -o $$@ $$^ $$(LDLIBS))
|
|
|
|
all-objs += $($(1)-objs)
|
|
|
|
all-cxxobjs += $($(1)-cxxobjs)
|
|
|
|
endef
|
2020-04-19 23:12:50 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
all-objs:=
|
|
|
|
all-cxxobjs:=
|
|
|
|
$(foreach f,$(hostprogs),$(eval $(call link_rule,$f)))
|
2017-07-23 03:08:17 +00:00
|
|
|
|
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
$(foreach f,$(sort $(all-objs)), \
|
|
|
|
$(eval $f: CFLAGS+=$$(HOSTCFLAGS_$f)))
|
2020-06-10 01:33:21 +00:00
|
|
|
|
2024-02-16 17:32:07 +00:00
|
|
|
$(foreach f,$(sort $(all-cxxobjs)), \
|
|
|
|
$(eval $f: CXXFLAGS+=$$(HOSTCXXFLAGS_$f)))
|