[hackers] [st][PATCH] Add total compability to the Makefiles

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Thu, 16 Jul 2015 08:33:03 +0200

With .POSIX target we get that the user
without environment will execute c99. If the user
has no c99, then he can source env.sh or execute
build.sh.
---
 Makefile     |  2 ++
 build.sh     |  8 +-------
 cc1/Makefile |  3 ++-
 cc2/Makefile |  2 ++
 env.sh       | 23 +++++++++++++++++++++++
 lib/Makefile |  2 ++
 6 files changed, 32 insertions(+), 8 deletions(-)
 create mode 100755 env.sh
diff --git a/Makefile b/Makefile
index 76176de..cfdf573 100644
--- a/Makefile
+++ b/Makefile
_AT_@ -6,3 +6,5 @@ all clean:
 	do \
 		(cd $$i && $(MAKE) $_AT_) ;\
 	done
+
+.POSIX:
diff --git a/build.sh b/build.sh
index e280799..dea6489 100755
--- a/build.sh
+++ b/build.sh
_AT_@ -1,11 +1,5 @@
 #!/bin/sh
 
-case `uname` in
-Plan9)
-	CFLAGS="-D_SUSV2_SOURCE -DNBOOL"
-	export CFLAGS
-	;;
-esac
-
+source env.sh
 make $_AT_
 
diff --git a/cc1/Makefile b/cc1/Makefile
index ed8ac07..47e9c09 100644
--- a/cc1/Makefile
+++ b/cc1/Makefile
_AT_@ -1,9 +1,10 @@
-CFLAGS = -ansi
 OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \
 	code.o stmt.o cpp.o
 
 all: cc1
 
+.POSIX:
+
 $(OBJS) : cc1.h ../inc/cc.h ../inc/sizes.h
 
 cc1: $(OBJS) ../lib/libcc.a
diff --git a/cc2/Makefile b/cc2/Makefile
index 2e364fa..1324c82 100644
--- a/cc2/Makefile
+++ b/cc2/Makefile
_AT_@ -5,6 +5,8 @@ LIBS = -lcc
 
 all: cc2
 
+.POSIX:
+
 $(OBJS): ../inc/cc.h ../inc/sizes.h cc2.h
 main.o: error.h
 
diff --git a/env.sh b/env.sh
new file mode 100755
index 0000000..30f3b88
--- /dev/null
+++ b/env.sh
_AT_@ -0,0 +1,23 @@
+#!/bin/sh
+
+case `uname` in
+Plan9)
+	CFLAGS="-D_SUSV2_SOURCE -DNBOOL"
+	export CFLAGS
+	;;
+*)
+	case x$CC in
+	xc99)
+		;;
+	x|xgcc)
+		CC=gcc
+		CFLAGS=-std=c99
+		export CFLAGS CC
+		;;
+	*)
+		echo You need a c99 compiler for this program 2>&1
+		exit
+		;;
+	esac
+	;;
+esac
diff --git a/lib/Makefile b/lib/Makefile
index 586c8b9..3e3a0c0 100644
--- a/lib/Makefile
+++ b/lib/Makefile
_AT_@ -3,6 +3,8 @@ OBJS = die.o xcalloc.o xmalloc.o xrealloc.o xstrdup.o
 
 all: libcc.a
 
+.POSIX:
+
 libcc.a: $(OBJS)
 	ar r $_AT_ $?
 
-- 
2.1.4
Received on Thu Jul 16 2015 - 08:33:03 CEST

This archive was generated by hypermail 2.3.0 : Thu Jul 16 2015 - 08:36:10 CEST