shithub: mc

Download patch

ref: 49b3d1b79ed5ac93301f2a9c2f69f03a4bd02b5b
parent: ce5bb49bd8b40a0cffc3de15660abe74582f0dbd
author: Ori Bernstein <ori@eigenstate.org>
date: Thu Mar 5 06:37:16 EST 2015

Speed up build.

    We get combinatorial explosions of tested patterns when using
    make matches. Use a script to fix this. (ugh).

--- a/libstd/Makefile
+++ b/libstd/Makefile
@@ -79,32 +79,35 @@
 
 all: lib$(STDLIB).a $(MYRBIN)
 
-%.myr: %+$(SYSCLASS)-$(ARCH).myr
-	cp $< $@
+# HACK HACK HACK.
+# Ideally we would have patterns for the
+# foo+arch-suffix.myr instead of a loop,
+# but that leads to a combinatorial explosion
+# of patterns that Make will try, leading to
+# millions of files getting statted. This
+# works around that.
+COPYTARG = for suff in $(SYSCLASS)-$(SYS)-$(ARCH) \
+		$(SYSCLASS)-$(SYS) \
+		$(SYSCLASS)-$(ARCH) \
+		$(SYSCLASS) \
+		$(SYS)-$(ARCH) \
+		$(SYS) \
+		$(ARCH); do \
+	    if [ -f $*+$$targ.$$ext ] ; then  \
+		echo $$targ; \
+		echo cp $*+$$targ.$$ext $@; \
+		cp $*+$$targ.$$ext $@; \
+		exit 0; \
+	    fi; \
+	done; \
 
-%.myr: %+$(SYSCLASS)-$(SYS).myr
-	cp $< $@
+%.myr: %+*.myr
+	@export ext=myr; \
+	$(COPYTARG)
 
-%.myr: %+$(SYSCLASS).myr
-	cp $< $@
-
-%.myr: %+$(SYS)-$(ARCH).myr
-	cp $< $@
-
-%.myr: %+$(SYS).myr
-	cp $< $@
-
-%.myr: %+$(ARCH).myr
-	cp $< $@
-
-%.s: %+$(SYSCLASS)-$(ARCH).s
-	cp $< $@
-
-%.s: %+$(SYS)-$(ARCH).s
-	cp $< $@
-
-%.s: %+$(ARCH).s
-	cp $< $@
+%.s: %+*.s
+	@export ext=s; \
+	$(COPYTARG)
 
 lib$(STDLIB).a: $(STDSRC) $(ASMSRC) lib$(SYSLIB).a ../6/6m
 	export MYR_MC=../6/6m && \