Skip to content

Commit 9ab7596

Browse files
committed
[build] new version of makemore
1 parent 2fa9290 commit 9ab7596

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

scripts.mk

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ endif
254254
# objects recipes generation
255255
##
256256
$(foreach t,$(slib-y) $(lib-y) $(bin-y) $(sbin-y) $(modules-y), $(eval $(t)_SOURCES+=$(patsubst %.hpp,%.moc.cpp,$($(t)_QTHEADERS) $($(t)_QTHEADERS-y))))
257-
$(foreach t,$(slib-y) $(lib-y) $(bin-y) $(sbin-y) $(modules-y), $(if $(findstring .cpp, $(notdir $($(t)_SOURCES))), $(eval $(t)_LIBRARY+=stdc++)))
257+
$(foreach t,$(slib-y) $(lib-y) $(bin-y) $(sbin-y) $(modules-y), $(if $(findstring .cpp, $(notdir $($(t)_SOURCES))), $(eval $(t)_LIBS+=stdc++)))
258258

259259
$(foreach t,$(slib-y) $(lib-y) $(bin-y) $(sbin-y) $(modules-y), $(eval $(t)-objs+=$(patsubst %.s,%.o,$(patsubst %.S,%.o,$(patsubst %.cpp,%.o,$(patsubst %.c,%.o,$($(t)_SOURCES) $($(t)_SOURCES-y)))))))
260260
target-objs:=$(foreach t, $(slib-y) $(lib-y) $(bin-y) $(sbin-y) $(modules-y), $(if $($(t)-objs), $(addprefix $(obj),$($(t)-objs)), $(obj)$(t).o))
@@ -293,7 +293,7 @@ gcov-target:=$(target-objs:%.o=%.gcov)
293293
$(foreach t,$(slib-y) $(lib-y),$(eval include-y+=$($(t)_HEADERS)))
294294

295295
define cmd_pkgconfig
296-
$(shell $(PKGCONFIG) --silence-errors $(2) $(1) || $(PKGCONFIG) --silence-errors $(2) lib$(1))
296+
$(shell $(PKGCONFIG) --silence-errors $(2) $(1))
297297
endef
298298
# LIBRARY may contain libraries name to check
299299
# The name may terminate with {<version>} informations like LIBRARY+=usb{1.0}
@@ -325,7 +325,7 @@ $(foreach t,$(bin-y) $(sbin-y),$(if $(findstring dl, $($(t)_LIBS) $(LIBS)),$(eva
325325
# targets recipes generation
326326
##
327327

328-
lib-check-target:=$(LIBRARY) $(sort $(foreach t,$(slib-y) $(lib-y) $(bin-y) $(sbin-y) $(modules-y),$($(t)_LIBRARY)))
328+
lib-check-target:=$(sort $(LIBRARY:%=check_%) $(sort $(foreach t,$(slib-y) $(lib-y) $(bin-y) $(sbin-y) $(modules-y),$($(t)_LIBRARY:%=check_%))))
329329

330330
ifeq (STATIC,y)
331331
lib-static-target:=$(addprefix $(obj),$(addsuffix $(slib-ext:%=.%),$(addprefix $(library_prefix),$(slib-y) $(lib-y))))
@@ -626,26 +626,22 @@ quiet_cmd_check_lib=CHECK $*
626626
define cmd_check_lib
627627
$(RM) $(TMPDIR)/$(TESTFILE:%=%.c) $(TMPDIR)/$(TESTFILE)
628628
echo "int main(){}" > $(TMPDIR)/$(TESTFILE:%=%.c)
629-
$(eval CFLAGS:=$(if $(strip $(call cmd_pkgconfig,$(2),--exists --print-errors --errors-to-stdout)),,$(call cmd_pkgconfig,$(2),--cflags)))
630-
$(eval LDFLAGS:=$(if $(strip $(call cmd_pkgconfig,$(2),--exists --print-errors --errors-to-stdout)),$(2:%=-l%),$(call cmd_pkgconfig,$(2),--libs)))
631-
$(TARGETCC) -c -o $(TMPDIR)/$(TESTFILE:%=%.o) $(TMPDIR)/$(TESTFILE:%=%.c) $(INTERN_CFLAGS) $(CFLAGS) > /dev/null 2>&1
632-
$(TARGETLD) -o $(TMPDIR)/$(TESTFILE) $(TMPDIR)/$(TESTFILE:%=%.o) $(INTERN_LDFLAGS) $(LDFLAGS) $(call cmd_pkgconfig,$(2),--libs) > /dev/null 2>&1
629+
$(eval CHECKLIB=$(firstword $(subst {, ,$(subst },,$2))))
630+
$(eval CHECKVERSION=$(if $(findstring {, $(2)),$(subst -, - ,$(lastword $(subst {, ,$(subst },,$2))))))
631+
$(eval CHECKOPTIONS=$(if $(CHECKVERSION),$(if $(findstring -,$(firstword $(CHECKVERSION))),--atleast-version=$(word 2,$(CHECKVERSION)))))
632+
$(eval CHECKOPTIONS+=$(if $(CHECKVERSION),$(if $(findstring -,$(lastword $(CHECKVERSION))),--max-version=$(word 1,$(CHECKVERSION)))))
633+
$(eval CHECKOPTIONS+=$(if $(CHECKVERSION),$(if $(findstring -,$(CHECKVERSION)),,--exact-version=$(CHECKVERSION))))
634+
$(PKGCONFIG) --exists --print-errors $(CHECKOPTIONS) $(CHECKLIB)
635+
$(eval CHECKCFLAGS:=$(call cmd_pkgconfig,$(CHECKLIB),--cflags))
636+
$(eval CHECKLDFLAGS:=$(call cmd_pkgconfig,$(CHECKLIB),--libs))
637+
$(TARGETCC) -c -o $(TMPDIR)/$(TESTFILE:%=%.o) $(TMPDIR)/$(TESTFILE:%=%.c) $(INTERN_CFLAGS) $(CHECKCFLAGS) > /dev/null 2>&1
638+
$(TARGETLD) -o $(TMPDIR)/$(TESTFILE) $(TMPDIR)/$(TESTFILE:%=%.o) $(INTERN_LDFLAGS) $(CHECKLDFLAGS) > /dev/null 2>&1
633639
endef
634640

635-
checkoption:=--exact-version
636-
prepare_check=$(if $(filter %-, $2),$(eval checkoption:=--atleast-version),$(if $(filter -%, $2),$(eval checkoption:=--max-version)))
637-
cmd_check2_lib=$(if $(findstring $(3:%-=%), $3),$(if $(findstring $(3:-%=%), $3),,$(eval checkoption:=--atleast-version),$(eval checkoption:=--max-version))) \
638-
$(call cmd_pkgconfig,$(2),--print-errors $(checkoption))
639-
640-
$(lib-check-target): %:
641+
$(lib-check-target): check_%:
641642
$(Q)$(RM) $(TMPDIR)/$(TESTFILE:%=%.c) $(TMPDIR)/$(TESTFILE)
642643
$(Q)echo "int main(){}" > $(TMPDIR)/$(TESTFILE:%=%.c)
643-
$(eval CHECKLIB=$(firstword $(subst {, ,$(subst },,$@))))
644-
$(eval CHECKVERSION=$(if $(findstring {,$@),$(lastword $(subst {, ,$(subst },,$@)))))
645-
$(Q)$(call cmd,check_lib,$(CHECKLIB))
646-
$(Q)$(call prepare_check,$(CHECKVERSION))
647-
$(Q)$(if $(strip $(CHECKVERSION)),echo COUCOU $(CHECKVERSION))
648-
$(Q)$(if $(strip $(CHECKVERSION)),$(call cmd,check2_lib,$(CHECKLIB),$(CHECKVERSION)))
644+
$(Q)$(call cmd,check_lib,$*)
649645

650646
###############################################################################
651647
# Commands for install

0 commit comments

Comments
 (0)