scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit f1bcf404decd303a4905dbc12bbbd4736b7ca1b4
parent f46933b11d1f0f91c0898fd180facd09b1899301
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri,  9 Dec 2016 19:05:34 +0100

Merge remote-tracking branch 'origin/master'

Diffstat:
MMakefile | 7+++----
Mcc1/Makefile | 10+++++-----
Mcc2/Makefile | 6+++---
Mdriver/posix/scc.c | 10++++++----
4 files changed, 17 insertions(+), 16 deletions(-)

diff --git a/Makefile b/Makefile @@ -17,14 +17,13 @@ driver/$(DRIVER)/scc: bin ln -f driver/$(DRIVER)/scc bin/scc $(ARCHS): bin - mkdir -p bin for i in cc1 cc2; \ do \ (cd $$i; \ - ARCH=$@ $(MAKE) -e $$i || exit); \ + ARCH=$@ $(MAKE) -e $$i-$@ || exit); \ done - ln -f cc1/cc1 bin/cc1-$@ - ln -f cc2/cc2 bin/cc2-$@ + ln -f cc1/cc1-$@ bin/ + ln -f cc2/cc2-$@ bin/ bin: mkdir -p bin diff --git a/cc1/Makefile b/cc1/Makefile @@ -6,7 +6,7 @@ include ../config.mk OBJS = types.o decl.o lex.o error.o symbol.o main.o expr.o \ code.o stmt.o cpp.o fold.o init.o arch/$(ARCH)/arch.o -all: cc1 +all: cc1-$(ARCH) cpp.o: stallman.msg $(OBJS): cc1.h ../inc/cc.h ../inc/sizes.h @@ -17,15 +17,15 @@ $(OBJS): cc1.h ../inc/cc.h ../inc/sizes.h ../lib/libcc.a: cd ../lib && $(MAKE) -e -cc1: $(OBJS) ../lib/libcc.a +cc1-$(ARCH): $(OBJS) ../lib/libcc.a $(CC) $(SCC_LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ -cpp: cc1 - ln -f cc1 cpp +cpp: cc1-$(ARCH) + ln -f $< cpp test: cd tests && ./chktest.sh *.c clean: rm -f $(OBJS) - rm -f cc1 cpp + rm -f cc1-* cpp diff --git a/cc2/Makefile b/cc2/Makefile @@ -7,7 +7,7 @@ OBJS = main.o parser.o peep.o symbol.o node.o code.o optm.o\ arch/$(ARCH)/code.o arch/$(ARCH)/cgen.o \ arch/$(ARCH)/types.o arch/$(ARCH)/optm.o -all: cc2 +all: cc2-$(ARCH) main.o: error.h $(OBJS): cc2.h ../inc/sizes.h ../inc/cc.h @@ -24,9 +24,9 @@ error.h: cc2.h ../inc/sizes.h: cp ../inc/sizes_$(STD).h $@ -cc2: $(OBJS) ../lib/libcc.a +cc2-$(ARCH): $(OBJS) ../lib/libcc.a $(CC) $(SCC_LDFLAGS) $(OBJS) ../lib/libcc.a -o $@ clean: rm -f $(OBJS) - rm -f cc2 error.h + rm -f cc2-* error.h diff --git a/driver/posix/scc.c b/driver/posix/scc.c @@ -163,10 +163,12 @@ outfname(char *path, char *type) n = snprintf(new, newsz, "%.*s%c%s", (int)pathln, path, sep, type); if (n < 0 || n >= newsz) die("scc: wrong output filename"); - if ((tmpfd = mkstemp(new)) < 0 && errno != EINVAL) - die("scc: could not create output file '%s': %s", - new, strerror(errno)); - close(tmpfd); + if (sep == '/') { + if ((tmpfd = mkstemp(new)) < 0) + die("scc: could not create output file '%s': %s", + new, strerror(errno)); + close(tmpfd); + } return new; }