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:
|
2021-11-24 21:25:43 +00:00
|
|
|
rm -f *.o lxdialog/*.o *.moc .*.cmd $(clean-files)
|
2020-04-19 23:12:50 +00:00
|
|
|
|
2020-04-19 23:12:52 +00:00
|
|
|
# This clean-files definition is here to ensure that temporary files from the
|
|
|
|
# previous version are removed by make config-clean.
|
2021-11-24 21:25:43 +00:00
|
|
|
# It should be emptied after the end of support for OpenWrt 19.07.
|
2020-04-19 23:12:52 +00:00
|
|
|
clean-files := zconf.tab.c zconf.lex.c zconf.hash.c .tmp_qtcheck
|
2006-04-20 20:17:34 +00:00
|
|
|
|
|
|
|
# ===========================================================================
|
2020-04-19 23:12:50 +00:00
|
|
|
# Variables needed by the upstream Makefile
|
|
|
|
|
|
|
|
# Avoids displaying 'UPD mconf-cfg' in an otherwise quiet make menuconfig
|
|
|
|
kecho:=true
|
|
|
|
|
|
|
|
CONFIG_SHELL:=$(SHELL)
|
|
|
|
srctree:=.
|
|
|
|
src:=.
|
|
|
|
obj:=.
|
|
|
|
Q:=$(if $V,,@)
|
|
|
|
cmd = $(cmd_$(1))
|
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
# some definitions taken from ../Kbuild.include
|
|
|
|
dot-target = $(dir $@).$(notdir $@)
|
|
|
|
squote := '
|
|
|
|
escsq = $(subst $(squote),'\$(squote)',$1)
|
2020-04-19 23:12:50 +00:00
|
|
|
define filechk
|
|
|
|
$(Q)set -e; \
|
|
|
|
mkdir -p $(dir $@); \
|
|
|
|
trap "rm -f $(dot-target).tmp" EXIT; \
|
|
|
|
{ $(filechk_$(1)); } > $(dot-target).tmp; \
|
|
|
|
if [ ! -r $@ ] || ! cmp -s $@ $(dot-target).tmp; then \
|
|
|
|
$(kecho) ' UPD $@'; \
|
|
|
|
mv -f $(dot-target).tmp $@; \
|
|
|
|
fi
|
|
|
|
endef
|
2021-11-24 21:25:43 +00:00
|
|
|
cmd-check = $(if $(strip $(cmd_$@)),,1)
|
|
|
|
make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))))
|
|
|
|
newer-prereqs = $(filter-out $(PHONY),$?)
|
|
|
|
if_changed = $(if $(newer-prereqs)$(cmd-check), \
|
|
|
|
$(cmd); \
|
|
|
|
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)
|
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)
|
|
|
|
|
|
|
|
HOSTLDLIBS_nconf = $(shell . $(obj)/nconf-cfg && echo $$libs)
|
|
|
|
HOSTCFLAGS_nconf.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
|
|
|
|
HOSTCFLAGS_nconf.gui.o = $(shell . $(obj)/nconf-cfg && echo $$cflags)
|
|
|
|
|
|
|
|
$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg
|
|
|
|
|
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
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs)
|
|
|
|
$(foreach f, mconf.o $(lxdialog), \
|
|
|
|
$(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags)))
|
2006-08-02 13:36:20 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg
|
|
|
|
|
|
|
|
# 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
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs)
|
|
|
|
HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
|
2021-11-24 21:25:43 +00:00
|
|
|
HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags)
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
$(obj)/qconf.o: $(obj)/qconf-cfg
|
2006-04-20 20:17:34 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
quiet_cmd_moc = MOC $@
|
2021-11-24 21:25:43 +00:00
|
|
|
cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@
|
|
|
|
|
|
|
|
$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE
|
|
|
|
$(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
|
|
|
|
filechk_conf_cfg = $(CONFIG_SHELL) $<
|
|
|
|
|
|
|
|
$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE
|
|
|
|
$(call filechk,conf_cfg)
|
|
|
|
|
|
|
|
clean-files += *conf-cfg
|
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
|
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
clean-files += $(targets) $(hostprogs)
|
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
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
|
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
$(foreach f,$(conf-objs) $(filter-out $(common-objs),$(mconf-objs) \
|
|
|
|
$(qconf-objs) \
|
|
|
|
$(nconf-objs)), \
|
|
|
|
$(eval $(obj)/$f: CFLAGS+=$$(HOSTCFLAGS_$f)))
|
2017-07-23 03:08:17 +00:00
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
$(foreach f,$(qconf-cxxobjs), \
|
|
|
|
$(eval $(obj)/$f: CXXFLAGS+=$$(HOSTCXXFLAGS_$f)))
|
2020-04-19 23:12:50 +00:00
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
$(obj)/conf: $(addprefix $(obj)/,$(conf-objs))
|
2017-07-23 03:08:17 +00:00
|
|
|
|
2020-04-19 23:12:50 +00:00
|
|
|
# The *conf-cfg file is used (then filtered out) as the first prerequisite to
|
|
|
|
# avoid sourcing it before the script is built, when trying to compute CFLAGS
|
|
|
|
# for the actual first prerequisite. This avoids errors like:
|
|
|
|
# '/bin/sh: ./mconf-cfg: No such file or directory'
|
2021-11-24 21:25:43 +00:00
|
|
|
$(obj)/mconf: mconf-cfg $(addprefix $(obj)/,$(mconf-objs))
|
2020-04-19 23:12:50 +00:00
|
|
|
$(CC) -o $@ $(filter-out mconf-cfg,$^) $(HOSTLDLIBS_mconf)
|
2017-07-23 03:08:17 +00:00
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
$(obj)/nconf: nconf-cfg $(addprefix $(obj)/,$(nconf-objs))
|
2020-06-10 01:33:21 +00:00
|
|
|
$(CC) -o $@ $(filter-out nconf-cfg,$^) $(HOSTLDLIBS_nconf)
|
|
|
|
|
2021-11-24 21:25:43 +00:00
|
|
|
$(obj)/qconf: qconf-cfg $(addprefix $(obj)/,$(qconf-cxxobjs) $(qconf-objs))
|
2020-04-19 23:12:50 +00:00
|
|
|
$(CXX) -o $@ $(filter-out qconf-cfg,$^) $(HOSTLDLIBS_qconf)
|