diff options
Diffstat (limited to 'scripts/config/Makefile')
-rw-r--r-- | scripts/config/Makefile | 111 |
1 files changed, 41 insertions, 70 deletions
diff --git a/scripts/config/Makefile b/scripts/config/Makefile index 5976a91b9a..5e7dd9578e 100644 --- a/scripts/config/Makefile +++ b/scripts/config/Makefile @@ -5,46 +5,21 @@ .PHONY: clean all all: conf mconf clean: - rm -f *.o lxdialog/*.o *.moc .*.cmd $(clean-files) + rm -f $(clean-files) $(hostprogs) -# This clean-files definition is here to ensure that temporary files from the -# previous version are removed by make config-clean. -# It should be emptied after the end of support for OpenWrt 19.07. -clean-files := zconf.tab.c zconf.lex.c zconf.hash.c .tmp_qtcheck +clean-files := *.o lxdialog/*.o *.moc qconf-moc.cc \ + *conf-cfg # <- This should be removed after 23.05 is EOL # =========================================================================== # Variables needed by the upstream Makefile -# Avoids displaying 'UPD mconf-cfg' in an otherwise quiet make menuconfig -kecho:=true - +export HOSTPKG_CONFIG=pkg-config CONFIG_SHELL:=$(SHELL) -srctree:=. -src:=. +src:=$(CURDIR) obj:=. Q:=$(if $V,,@) -cmd = $(cmd_$(1)) - -# some definitions taken from ../Kbuild.include -dot-target = $(dir $@).$(notdir $@) -squote := ' -escsq = $(subst $(squote),'\$(squote)',$1) -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 -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, @:) +quiet:=$(if $V,,_silent) +include Kbuild.include ### Stripped down upstream Makefile follows: # =========================================================================== @@ -64,11 +39,12 @@ conf-objs := conf.o $(common-objs) hostprogs += nconf 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) +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) -$(obj)/nconf.o $(obj)/nconf.gui.o: $(obj)/nconf-cfg +$(obj)/nconf: | $(obj)/nconf-libs +$(obj)/nconf.o $(obj)/nconf.gui.o: | $(obj)/nconf-cflags # mconf: Used for the menuconfig target based on lxdialog hostprogs += mconf @@ -76,45 +52,44 @@ lxdialog := $(addprefix lxdialog/, \ checklist.o inputbox.o menubox.o textbox.o util.o yesno.o) mconf-objs := mconf.o $(lxdialog) $(common-objs) -HOSTLDLIBS_mconf = $(shell . $(obj)/mconf-cfg && echo $$libs) +HOSTLDLIBS_mconf = $(call read-file, $(obj)/mconf-libs) $(foreach f, mconf.o $(lxdialog), \ - $(eval HOSTCFLAGS_$f = $$(shell . $(obj)/mconf-cfg && echo $$$$cflags))) + $(eval HOSTCFLAGS_$f = $$(call read-file, $(obj)/mconf-cflags))) -$(addprefix $(obj)/, mconf.o $(lxdialog)): $(obj)/mconf-cfg +$(obj)/mconf: | $(obj)/mconf-libs +$(addprefix $(obj)/, mconf.o $(lxdialog)): | $(obj)/mconf-cflags # qconf: Used for the xconfig target based on Qt hostprogs += qconf qconf-cxxobjs := qconf.o qconf-moc.o qconf-objs := images.o $(common-objs) -HOSTLDLIBS_qconf = $(shell . $(obj)/qconf-cfg && echo $$libs) -HOSTCXXFLAGS_qconf.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) -HOSTCXXFLAGS_qconf-moc.o = $(shell . $(obj)/qconf-cfg && echo $$cflags) - -$(obj)/qconf.o: $(obj)/qconf-cfg +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 quiet_cmd_moc = MOC $@ - cmd_moc = $(shell . $(obj)/qconf-cfg && echo $$moc) $< -o $@ + cmd_moc = $(call read-file, $(obj)/qconf-bin)/moc $< -o $@ -$(obj)/qconf-moc.cc: $(src)/qconf.h $(obj)/qconf-cfg FORCE +$(obj)/qconf-moc.cc: $(src)/qconf.h FORCE | $(obj)/qconf-bin $(call if_changed,moc) targets += qconf-moc.cc # check if necessary packages are available, and configure build flags -filechk_conf_cfg = $(CONFIG_SHELL) $< +cmd_conf_cfg = $< $(addprefix $(obj)/$*conf-, cflags libs bin); touch $(obj)/$*conf-bin -$(obj)/%conf-cfg: $(src)/%conf-cfg.sh FORCE - $(call filechk,conf_cfg) +$(obj)/%conf-cflags $(obj)/%conf-libs $(obj)/%conf-bin: $(src)/%conf-cfg.sh + $(call cmd,conf_cfg) -clean-files += *conf-cfg +clean-files += *conf-cflags *conf-libs *conf-bin # =========================================================================== # OpenWrt rules and final adjustments that need to be made after reading the # full upstream Makefile -clean-files += $(targets) $(hostprogs) - FORCE: ifdef BUILD_SHIPPED_FILES @@ -130,25 +105,21 @@ clean-files += $(shipped-files) flex -L -o$@ $< endif -$(foreach f,$(conf-objs) $(filter-out $(common-objs),$(mconf-objs) \ - $(qconf-objs) \ - $(nconf-objs)), \ - $(eval $(obj)/$f: CFLAGS+=$$(HOSTCFLAGS_$f))) - -$(foreach f,$(qconf-cxxobjs), \ - $(eval $(obj)/$f: CXXFLAGS+=$$(HOSTCXXFLAGS_$f))) +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 -$(obj)/conf: $(addprefix $(obj)/,$(conf-objs)) +all-objs:= +all-cxxobjs:= +$(foreach f,$(hostprogs),$(eval $(call link_rule,$f))) -# 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' -$(obj)/mconf: mconf-cfg $(addprefix $(obj)/,$(mconf-objs)) - $(CC) -o $@ $(filter-out mconf-cfg,$^) $(HOSTLDLIBS_mconf) -$(obj)/nconf: nconf-cfg $(addprefix $(obj)/,$(nconf-objs)) - $(CC) -o $@ $(filter-out nconf-cfg,$^) $(HOSTLDLIBS_nconf) +$(foreach f,$(sort $(all-objs)), \ + $(eval $f: CFLAGS+=$$(HOSTCFLAGS_$f))) -$(obj)/qconf: qconf-cfg $(addprefix $(obj)/,$(qconf-cxxobjs) $(qconf-objs)) - $(CXX) -o $@ $(filter-out qconf-cfg,$^) $(HOSTLDLIBS_qconf) +$(foreach f,$(sort $(all-cxxobjs)), \ + $(eval $f: CXXFLAGS+=$$(HOSTCXXFLAGS_$f))) |