scc

Simple C99 Compiler
Log | Files | Refs | README | LICENSE

commit c7b52bd47910e2c14bc19422d14c432d20d92cce
parent ede7ba5d7698410287308633d191039d7e795092
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 16 Jul 2015 08:09:06 +0200

Add total compability to the Makefiles

With .POSIX target we get that the user
without environment will execute c99. If the user
has no c99, then it can source env.sh or execute
build.sh.

Diffstat:
Makefile | 2++
build.sh | 8+-------
cc1/Makefile | 3++-
cc2/Makefile | 2++
env.sh | 23+++++++++++++++++++++++
lib/Makefile | 2++
6 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/Makefile b/Makefile @@ -6,3 +6,5 @@ all clean: do \ (cd $$i && $(MAKE) $@) ;\ done + +.POSIX: diff --git 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 @@ -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 @@ -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 @@ -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 @@ -3,6 +3,8 @@ OBJS = die.o xcalloc.o xmalloc.o xrealloc.o xstrdup.o all: libcc.a +.POSIX: + libcc.a: $(OBJS) ar r $@ $?