[hackers] [scc] [PATCH] Fix MAKEFLAGS use

From: Lucas Gabriel Vuotto <l.vuotto92_AT_gmail.com>
Date: Wed, 15 Jun 2016 13:09:35 -0300

POSIX says that MAKEFLAGS can have flags in both 'ers' and '-e -r -s' format, so
the previous approach might not work if the second format is used, or if
MAKEFLAGS is empty.

Signed-off-by: Lucas Gabriel Vuotto <l.vuotto92_AT_gmail.com>
---
 Makefile              | 10 +++++-----
 cc1/Makefile          |  2 +-
 cc2/Makefile          |  2 +-
 driver/posix/Makefile |  2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/Makefile b/Makefile
index 48b5282..c0163bb 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -10,7 +10,7 @@ ARCHS = z80 i386-sysv amd64-sysv qbe
 all:
 	for i in $(DIRS); \
 	do \
-		(cd $$i && $(MAKE) -e -$(MAKEFLAGS)); \
+		(cd $$i && MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) -e); \
 	done
 	cp -f cc1/cc1 bin/cc1
 	cp -f cc2/cc2 bin/cc2
_AT_@ -19,14 +19,14 @@ all:
 multi:
 	for i in $(ARCHS); \
 	do \
-		$(MAKE) -$(MAKEFLAGS) $$i || exit; \
+		MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) $$i || exit; \
 	done
 
 $(ARCHS):
 	for i in cc1 cc2; \
 	do \
 		(cd $$i; \
-		ARCH=$_AT_ $(MAKE) -e -$(MAKEFLAGS) clean; \
+		ARCH=$_AT_ MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) -e clean; \
 		ARCH=$_AT_ $(MAKE) -e $$i || exit); \
 	done
 	ln -f cc1/cc1 bin/cc1-$_AT_
_AT_@ -49,13 +49,13 @@ uninstall:
 clean:
 	for i in $(DIRS); \
 	do \
-		(cd $$i && $(MAKE) -$(MAKEFLAGS) $_AT_ || exit); \
+		(cd $$i && MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) $_AT_ || exit); \
 	done
 
 multi-clean:
 	for i in $(ARCHS); \
 	do \
-		ARCH=$$i $(MAKE) -e -$(MAKEFLAGS) clean || exit; \
+		ARCH=$$i MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) -e clean || exit; \
 	done
 
 distclean: multi-clean
diff --git a/cc1/Makefile b/cc1/Makefile
index 1cfc5c3..c31382c 100644
--- a/cc1/Makefile
+++ b/cc1/Makefile
_AT_@ -14,7 +14,7 @@ all: cc1
 $(OBJS): cc1.h ../inc/cc.h ../inc/sizes.h arch/$(ARCH)/arch.h
 
 ../lib/libcc.a:
-	cd ../lib && $(MAKE) -e -$(MAKEFLAGS)
+	cd ../lib && MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) -e
 
 cc1: $(OBJS) ../lib/libcc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJS) ../lib/libcc.a -o $_AT_
diff --git a/cc2/Makefile b/cc2/Makefile
index 62e58d0..394f4a2 100644
--- a/cc2/Makefile
+++ b/cc2/Makefile
_AT_@ -21,7 +21,7 @@ main.o: error.h
 $(OBJS): cc2.h ../inc/sizes.h
 
 ../lib/libcc.a:
-	cd ../lib && $(MAKE) -e -$(MAKEFLAGS)
+	cd ../lib && MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) -e
 
 cc2: $(OBJS) ../lib/libcc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJS) ../lib/libcc.a -o $_AT_
diff --git a/driver/posix/Makefile b/driver/posix/Makefile
index 5012890..05b4ff2 100644
--- a/driver/posix/Makefile
+++ b/driver/posix/Makefile
_AT_@ -10,7 +10,7 @@ all: scc
 $(OBJS): ../../inc/cc.h
 
 ../../lib/libcc.a:
-	cd ../../lib && $(MAKE) -e -$(MAKEFLAGS)
+	cd ../../lib && MAKEFLAGS="$(MAKEFLAGS)" $(MAKE) -e
 
 scc: $(OBJS) ../../lib/libcc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJS) ../../lib/libcc.a -o $_AT_
-- 
2.7.3
Received on Wed Jun 15 2016 - 18:09:35 CEST

This archive was generated by hypermail 2.3.0 : Wed Jun 15 2016 - 18:12:15 CEST