summaryrefslogtreecommitdiff
path: root/Makefile.src.in
diff options
context:
space:
mode:
authorglx <glx@openttd.org>2019-01-15 02:26:54 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-01-16 19:27:06 +0000
commitee84f98f1e1c2063bb2a0c3405200c1a8ff9b970 (patch)
tree63da22a2139d0529d617ba6670a70fa9810af189 /Makefile.src.in
parent5a09337c2018a7ee371e2e96220ee0d06b1df753 (diff)
downloadopenttd-ee84f98f1e1c2063bb2a0c3405200c1a8ff9b970.tar.xz
Fix: deps calculation call could fail due to command line length
Diffstat (limited to 'Makefile.src.in')
-rw-r--r--Makefile.src.in22
1 files changed, 14 insertions, 8 deletions
diff --git a/Makefile.src.in b/Makefile.src.in
index 0589ba69a..c07015cfe 100644
--- a/Makefile.src.in
+++ b/Makefile.src.in
@@ -159,6 +159,19 @@ $(SRC_OBJS_DIR)/$(DEPEND): $(SRC_DIR)/depend/depend.cpp
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) -o $@ $<
endif
+# Macro for invoking a command on groups of 100 words at a time
+# (analogous to xargs(1)). The macro invokes itself recursively
+# until the list of words is depleted.
+#
+# Usage: $(call xargs,COMMAND,LIST)
+#
+# COMMAND should be a shell command to which the words will be
+# appended as arguments in groups of 100.
+define xargs
+$(1) $(wordlist 1,100,$(2))
+$(if $(word 101,$(2)),$(call xargs,$(1),$(wordlist 101,$(words $(2)),$(2))))
+endef
+
# Make sure that only 'make depend' ALWAYS triggers a recheck
ifeq ($(filter depend, $(MAKECMDGOALS)),)
Makefile.dep: $(FILE_DEP) $(SRCS:%=$(SRC_DIR)/%) $(CONFIG_CACHE_SOURCE) $(DEP)
@@ -170,14 +183,7 @@ endif
$(Q)touch Makefile.dep.tmp
# Calculate the deps via makedepend
- $(Q)$(MAKEDEPEND) -f$(SRC_OBJS_DIR)/Makefile.dep.tmp -o.o -Y -v -- $(CFLAGS_MAKEDEP) -- $(SRCS:%=$(SRC_DIR)/%) 2>/dev/null
-
-# Convert x:/... paths to /x/... for mingw
-ifeq ($(OS), MINGW)
- @cat Makefile.dep.tmp | sed 's@/\([a-zA-Z]\):\/@\/\1\/@g' > Makefile.dep.tmp.mingw
- @cp Makefile.dep.tmp.mingw Makefile.dep.tmp
- @rm -f Makefile.dep.tmp.mingw
-endif
+ $(call xargs,$(Q)$(MAKEDEPEND) -f$(SRC_OBJS_DIR)/Makefile.dep.tmp -o.o -Y -v -a -- $(CFLAGS_MAKEDEP) -- 2>/dev/null,$(SRCS:%=$(SRC_DIR)/%))
# Remove all comments and includes that don't start with $(SRC_DIR)
# Remove $(SRC_DIR) from object-file-name