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
@@ -6,3 +6,5 @@ all clean:
do \
(cd $$i && $(MAKE) $@) ;\
done
+
+.POSIX:
diff --git a/build.sh b/build.sh
index e280799..dea6489 100755
--- a/build.sh
+++ b/build.sh
@@ -1,11 +1,5 @@
#!/bin/sh
-case `uname` in
-Plan9)
- CFLAGS="-D_SUSV2_SOURCE -DNBOOL"
- export CFLAGS
- ;;
-esac
-
+source env.sh
make $@
diff --git a/cc1/Makefile b/cc1/Makefile
index ed8ac07..47e9c09 100644
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -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
@@ -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
@@ -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
@@ -3,6 +3,8 @@ OBJS = die.o xcalloc.o xmalloc.o xrealloc.o xstrdup.o
all: libcc.a
+.POSIX:
+
libcc.a: $(OBJS)
ar r $@ $?
--
2.1.4