shithub: scc

Download patch

ref: 77f337174f231d989fdd4a7de1bd3d8ed366bd08
parent: e4fb950f7f36da741e55025fd564a31a37ee4b06
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Aug 19 04:46:15 EDT 2018

[lib/coff32] Introduce new library coff32

This library is intended to be used in the different tools
that use coff file format.

--- a/Makefile
+++ b/Makefile
@@ -12,8 +12,6 @@
 $(DIRS): config $(BINDIR) $(LIBEXEC) FORCE 
 	+@cd $@ && $(MAKE) all
 
-FORCE:
-
 $(BINDIR):
 	mkdir -p $@
 
--- a/ar/Makefile
+++ b/ar/Makefile
@@ -5,7 +5,7 @@
 include $(LIBSCC)/libdep.mk
 
 OBJ       = main.o $(DRIVER)/driver.o
-MOREFLAGS = -I$(DRIVER)
+MORECFLAGS = -I$(DRIVER)
 
 all: $(BINDIR)/ar
 
--- a/as/Makefile
+++ b/as/Makefile
@@ -5,7 +5,7 @@
 include $(LIBSCC)/libdep.mk
 
 OBJ = main.o symbol.o ins.o parser.o expr.o myro.o
-MOREFLAGS = -I$(INCDIR)/$(STD) $(AS_CFLAGS)
+MORECFLAGS = -I$(INCDIR)/$(STD) $(STDCFLAGS)
 TARGETS = $(LIBEXEC)/as-amd64 $(LIBEXEC)/as-i386 \
           $(LIBEXEC)/as-i286 $(LIBEXEC)/as-z80
 
--- a/cc1/Makefile
+++ b/cc1/Makefile
@@ -5,7 +5,7 @@
 include $(PROJECTDIR)/rules.mk
 include $(LIBSCC)/libdep.mk
 
-MOREFLAGS = -I$(INCDIR)/$(STD) $(CC1_CFLAGS)
+MORECFLAGS = -I$(INCDIR)/$(STD) $(STDCFLAGS)
 
 OBJ = types.o decl.o lex.o error.o symbol.o main.o expr.o \
       code.o stmt.o cpp.o fold.o init.o builtin.o
--- a/cc2/Makefile
+++ b/cc2/Makefile
@@ -4,7 +4,7 @@
 include $(PROJECTDIR)/rules.mk
 include $(LIBSCC)/libdep.mk
 
-MOREFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(CC2_CFLAGS)
+MORECFLAGS = -I$(PROJECTDIR)/inc/$(STD) $(STDCFLAGS)
 
 OBJ = main.o parser.o peep.o symbol.o node.o code.o optm.o
 
--- a/config.mk
+++ b/config.mk
@@ -20,19 +20,17 @@
 ### Systems
 # Plan9
 #SYSCFLAGS = -D_SUSV2_SOURCE
+#STDCFLAGS =
 ###
 # NetBSD
-#CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-#CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-#AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
+#SYSCFLAGS =
+#STDCFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
 ###
 # OpenBSD
-#CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-#CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-#AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
+#SYSCFLAGS =
+#STDCFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
 ###
 # FreeBSD
-#CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-#CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-#AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
+#SYSCFLAGS =
+#STDCFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
 ###
--- a/inc/coff32/aouthdr.h
+++ b/inc/coff32/aouthdr.h
@@ -12,7 +12,7 @@
 	long data_start;    /* base of data segment */
 };
 
-typedef struct aouthdr AOUTHDR;
+#define AOUTHDR struct aouthdr 
 #define AOUTSZ sizeof(AOUTHDR)
 
 #define QMAGIC      0314
--- /dev/null
+++ b/inc/coff32/coff32.h
@@ -1,0 +1,22 @@
+
+typedef int (*packfun)(unsigned char *, char *, ...);
+
+#ifdef AOUTHDR
+extern void coff32_pack_aout(packfun fun, unsigned char *buff, AOUTHDR *aout);
+extern void coff32_unpack_aout(packfun fun, unsigned char *buff, AOUTHDR *ent);
+#endif
+
+#ifdef SYMENT
+extern void coff32_pack_ent(packfun fun, unsigned char *buff, SYMENT *ent);
+extern void coff32_unpack_ent(packfun fun, unsigned char *buff, SYMENT *ent);
+#endif
+
+#ifdef FILHDR
+extern void coff32_pack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr);
+extern void coff32_unpack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr);
+#endif
+
+#ifdef SCNHDR
+extern void coff32_pack_scn(packfun fun, unsigned char *buff, SCNHDR *scn);
+extern void coff32_unpack_scn(packfun fun, unsigned char *buff, SCNHDR *scn);
+#endif
--- /dev/null
+++ b/inc/incdep.mk
@@ -1,0 +1,7 @@
+include $(INCDIR)/inclst.mk
+
+debug:
+	echo $(SYSHDR)
+
+$(SYSHDR):
+	+@cd $(INCDIR) && $(MAKE)
--- /dev/null
+++ b/inc/inclst.mk
@@ -1,0 +1,4 @@
+SYSHDR = $(INCDIR)/ldflags.h\
+         $(INCDIR)/syscrts.h\
+         $(INCDIR)/sysincludes.h\
+         $(INCDIR)/syslibs.h
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -6,6 +6,8 @@
 include $(LIBCOFF32)/libdep.mk
 
 OBJ = main.o coff32.o obj.o
+LIB = $(LIBSCC)/libscc.a $(LIBCOFF32)/libcoff32.a
+MORELFLAGS = -L$(LIBCOFF32)
 
 all: $(BINDIR)/ld
 
@@ -12,11 +14,8 @@
 $(BINDIR)/ld: ld
 	cp ld $@
 
-ld: $(OBJ) $(LIBSCC)/libscc.a
-	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
-
-$(INCDIR)/syslibs.h:
-	+@cd $(INCDIR) && $(MAKE)
+ld: $(OBJ) $(LIB)
+	$(CC) $(SCC_LDFLAGS) $(OBJ) -lcoff32 -lscc -o $@
 
 dep:
 	$(PROJECTDIR)/mkdep.sh
--- a/ld/coff32.c
+++ b/ld/coff32.c
@@ -13,6 +13,7 @@
 #include "../inc/coff32/filehdr.h"
 #include "../inc/coff32/scnhdr.h"
 #include "../inc/coff32/syms.h"
+#include "../inc/coff32/coff32.h"
 #include "../inc/scc.h"
 #include "ld.h"
 
@@ -19,104 +20,8 @@
 #define NUMSCN_MAX 65536
 #define NUMENT_MAX 2147483648
 
-typedef int (*packfun)(unsigned char *, char *, ...);
 static long textpc = 0x1000;
 
-static void
-pack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr)
-{
-	int n;
-
-	n = (*fun)(buff,
-	           "sslllss",
-	           hdr->f_magic,
-	           hdr->f_nscns,
-	           hdr->f_timdat,
-	           hdr->f_symptr,
-	           hdr->f_nsyms,
-	           hdr->f_opthdr,
-	           hdr->f_flags);
-	assert(n == FILHSZ);
-}
-
-static void
-unpack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr)
-{
-	int n;
-
-	n = (*fun)(buff,
-	           "sslllss",
-	           &hdr->f_magic,
-	           &hdr->f_nscns,
-	           &hdr->f_timdat,
-	           &hdr->f_symptr,
-	           &hdr->f_nsyms,
-	           &hdr->f_opthdr,
-	           &hdr->f_flags);
-	assert(n == FILHSZ);
-}
-
-static void
-pack_scn(packfun fun, unsigned char *buff, SCNHDR *scn)
-{
-	int n;
-
-	n = (*fun)(buff,
-                  "'8llllllssl",
-	          scn->s_name,
-	          scn->s_paddr,
-	          scn->s_vaddr,
-	          scn->s_size,
-	          scn->s_scnptr,
-	          scn->s_relptr,
-	          scn->s_lnnoptr,
-	          scn->s_nrelloc,
-	          scn->s_nlnno,
-	          scn->s_flags);
-	assert(n == SCNHSZ);
-}
-
-static void
-unpack_scn(packfun fun, unsigned char *buff, SCNHDR *scn)
-{
-	int n;
-
-	n = (*fun)(buff,
-                  "'8llllllssl",
-	          scn->s_name,
-	          &scn->s_paddr,
-	          &scn->s_vaddr,
-	          &scn->s_size,
-	          &scn->s_scnptr,
-	          &scn->s_relptr,
-	          &scn->s_lnnoptr,
-	          &scn->s_nrelloc,
-	          &scn->s_nlnno,
-	          &scn->s_flags);
-	assert(n == SCNHSZ);
-}
-
-static void
-pack_aout(packfun fun, unsigned char *buff, AOUTHDR *aout)
-{
-}
-
-static void
-unpack_ent(packfun fun, unsigned char *buff, SYMENT *ent)
-{
-	int n;
-
-	n = (*fun)(buff,
-		   "'8lsscc",
-		   &ent->n_name,
-		   &ent->n_value,
-		   &ent->n_scnum,
-		   &ent->n_type,
-		   &ent->n_sclass,
-		   &ent->n_numaux);
-	assert(n == SYMESZ);
-}
-
 /*
  * check overflow in: off + ptr + nitem*size
  */
@@ -200,7 +105,7 @@
 		p = &scns[i];
 		if (fread(buff, SCNHSZ, 1, obj->fp) != 1)
 			return -1;
-		unpack_scn(obj->unpack, buff, p);
+		coff32_unpack_scn(obj->unpack, buff, p);
 		sp = slookup(p->s_name);
 		p->s_vaddr = sp->base + sp->size;
 		sp->size += p->s_size;
@@ -237,7 +142,7 @@
 	for (ent = ents; ent < &ents[nsyms]; ++ent) {
 		if (fread(buff, SYMESZ, 1, obj->fp) != 1)
 			return -1;
-		unpack_ent(obj->unpack, buff, ent);
+		coff32_unpack_ent(obj->unpack, buff, ent);
 		s = ent->n_name;
 		if (!s[0] && !s[1] && !s[2] && !s[3])
 			(*obj->unpack)(buff, "ll", &ent->n_zeroes, &ent->n_offset);
@@ -319,7 +224,7 @@
 
 	if ((hdr = malloc(sizeof(*hdr))) == NULL)
 		outmem();
-	unpack_hdr(obj->unpack, buff, hdr);
+	coff32_unpack_hdr(obj->unpack, buff, hdr);
 	obj->filhdr = hdr;
 
 	stroff = fileptr(pos, hdr->f_symptr, hdr->f_nsyms, SYMESZ);
@@ -420,7 +325,7 @@
 		hdr.f_nsyms = numsymbols;
 	}
 
-	pack_hdr(lpack, buff, &hdr);
+	coff32_pack_hdr(lpack, buff, &hdr);
 	fwrite(buff, FILHSZ, 1, fp);
 }
 
@@ -450,7 +355,7 @@
 	aout.text_start = textpc;
 	aout.data_start = textpc + dsize;
 
-	pack_aout(lpack, buff, &aout);
+	coff32_pack_aout(lpack, buff, &aout);
 	fwrite(buff, AOUTSZ, 1, fp);
 }
 
@@ -471,7 +376,7 @@
 	scn.s_nlnno = 0;
 	scn.s_flags = 0; /* TODO: Add flags */
 
-	pack_scn(lpack, buff, &scn);
+	coff32_pack_scn(lpack, buff, &scn);
 	fwrite(buff, SCNHSZ, 1, fp);
 }
 
--- a/ld/deps.mk
+++ b/ld/deps.mk
@@ -1,6 +1,7 @@
 
 #deps
 coff32.o: ../inc/coff32/aouthdr.h
+coff32.o: ../inc/coff32/coff32.h
 coff32.o: ../inc/coff32/filehdr.h
 coff32.o: ../inc/coff32/scnhdr.h
 coff32.o: ../inc/coff32/syms.h
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -8,8 +8,6 @@
 
 all: $(DIRS)
 
-FORCE:
-
 $(DIRS): FORCE
 	+@cd $@ && $(MAKE)
 
--- /dev/null
+++ b/lib/coff32/Makefile
@@ -1,0 +1,22 @@
+.POSIX:
+
+PROJECTDIR = ../..
+LIBCOFF32 = .
+include $(PROJECTDIR)/rules.mk
+include objlst.mk
+
+MORECFLAGS = $(STDCFLAGS)
+
+all: libcoff32.a
+
+libcoff32.a: $(LIBCOFF32-OBJ)
+	$(AR) $(ARFLAGS) $@ $?
+	ranlib $@
+
+dep:
+	$(PROJECTDIR)/mkdep.sh
+
+clean:
+	rm -f *.o *.a
+
+include deps.mk
--- /dev/null
+++ b/lib/coff32/coff32_pack_aout.c
@@ -1,0 +1,10 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/aouthdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_aout(packfun fun, unsigned char *buff, AOUTHDR *aout)
+{
+}
--- /dev/null
+++ b/lib/coff32/coff32_pack_ent.c
@@ -1,0 +1,21 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/syms.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_ent(packfun fun, unsigned char *buff, SYMENT *ent)
+{
+	int n;
+
+	n = (*fun)(buff,
+		   "'8lsscc",
+		   &ent->n_name,
+		   &ent->n_value,
+		   &ent->n_scnum,
+		   &ent->n_type,
+		   &ent->n_sclass,
+		   &ent->n_numaux);
+	assert(n == SYMESZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_pack_hdr.c
@@ -1,0 +1,22 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/filehdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr)
+{
+	int n;
+
+	n = (*fun)(buff,
+	           "sslllss",
+	           hdr->f_magic,
+	           hdr->f_nscns,
+	           hdr->f_timdat,
+	           hdr->f_symptr,
+	           hdr->f_nsyms,
+	           hdr->f_opthdr,
+	           hdr->f_flags);
+	assert(n == FILHSZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_pack_scn.c
@@ -1,0 +1,25 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/scnhdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_pack_scn(packfun fun, unsigned char *buff, SCNHDR *scn)
+{
+	int n;
+
+	n = (*fun)(buff,
+                  "'8llllllssl",
+	          scn->s_name,
+	          scn->s_paddr,
+	          scn->s_vaddr,
+	          scn->s_size,
+	          scn->s_scnptr,
+	          scn->s_relptr,
+	          scn->s_lnnoptr,
+	          scn->s_nrelloc,
+	          scn->s_nlnno,
+	          scn->s_flags);
+	assert(n == SCNHSZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_unpack_aout.c
@@ -1,0 +1,10 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/aouthdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_aout(packfun fun, unsigned char *buff, AOUTHDR *ent)
+{
+}
--- /dev/null
+++ b/lib/coff32/coff32_unpack_ent.c
@@ -1,0 +1,21 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/syms.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_ent(packfun fun, unsigned char *buff, SYMENT *ent)
+{
+	int n;
+
+	n = (*fun)(buff,
+		   "'8lsscc",
+		   &ent->n_name,
+		   &ent->n_value,
+		   &ent->n_scnum,
+		   &ent->n_type,
+		   &ent->n_sclass,
+		   &ent->n_numaux);
+	assert(n == SYMESZ);
+}
--- /dev/null
+++ b/lib/coff32/coff32_unpack_hdr.c
@@ -1,0 +1,23 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/filehdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_hdr(packfun fun, unsigned char *buff, FILHDR *hdr)
+{
+	int n;
+
+	n = (*fun)(buff,
+	           "sslllss",
+	           &hdr->f_magic,
+	           &hdr->f_nscns,
+	           &hdr->f_timdat,
+	           &hdr->f_symptr,
+	           &hdr->f_nsyms,
+	           &hdr->f_opthdr,
+	           &hdr->f_flags);
+	assert(n == FILHSZ);
+}
+
--- /dev/null
+++ b/lib/coff32/coff32_unpack_scn.c
@@ -1,0 +1,25 @@
+
+#include <assert.h>
+
+#include "../../inc/coff32/scnhdr.h"
+#include "../../inc/coff32/coff32.h"
+
+void
+coff32_unpack_scn(packfun fun, unsigned char *buff, SCNHDR *scn)
+{
+	int n;
+
+	n = (*fun)(buff,
+                  "'8llllllssl",
+	          scn->s_name,
+	          &scn->s_paddr,
+	          &scn->s_vaddr,
+	          &scn->s_size,
+	          &scn->s_scnptr,
+	          &scn->s_relptr,
+	          &scn->s_lnnoptr,
+	          &scn->s_nrelloc,
+	          &scn->s_nlnno,
+	          &scn->s_flags);
+	assert(n == SCNHSZ);
+}
--- a/lib/coff32/deps.mk
+++ b/lib/coff32/deps.mk
@@ -1,18 +1,17 @@
 #deps
-packaout.o: ./../../../inc/coff32/aouthdr.h
-packaout.o: ./coff32.h
-packent.o: ./../../../inc/coff32/syms.h
-packent.o: ./coff32.h
-packhdr.o: ./../../../inc/coff32/filehdr.h
-packhdr.o: ./coff32.h
-packscn.o: ./../../../inc/coff32/filehdr.h
-packscn.o: ./../../../inc/coff32/scnhdr.h
-packscn.o: ./coff32.h
-unpackaout.o: ./../../../inc/coff32/aouthdr.h
-unpackaout.o: ./coff32.h
-unpackent.o: ./../../../inc/coff32/syms.h
-unpackent.o: ./coff32.h
-unpackhdr.o: ./../../../inc/coff32/filehdr.h
-unpackhdr.o: ./coff32.h
-unpackscn.o: ./../../../inc/coff32/scnhdr.h
-unpackscn.o: ./coff32.h
+coff32_pack_aout.o: ../../inc/coff32/aouthdr.h
+coff32_pack_aout.o: ../../inc/coff32/coff32.h
+coff32_pack_ent.o: ../../inc/coff32/coff32.h
+coff32_pack_ent.o: ../../inc/coff32/syms.h
+coff32_pack_hdr.o: ../../inc/coff32/coff32.h
+coff32_pack_hdr.o: ../../inc/coff32/filehdr.h
+coff32_pack_scn.o: ../../inc/coff32/coff32.h
+coff32_pack_scn.o: ../../inc/coff32/scnhdr.h
+coff32_unpack_aout.o: ../../inc/coff32/aouthdr.h
+coff32_unpack_aout.o: ../../inc/coff32/coff32.h
+coff32_unpack_ent.o: ../../inc/coff32/coff32.h
+coff32_unpack_ent.o: ../../inc/coff32/syms.h
+coff32_unpack_hdr.o: ../../inc/coff32/coff32.h
+coff32_unpack_hdr.o: ../../inc/coff32/filehdr.h
+coff32_unpack_scn.o: ../../inc/coff32/coff32.h
+coff32_unpack_scn.o: ../../inc/coff32/scnhdr.h
--- /dev/null
+++ b/lib/coff32/libdep.mk
@@ -1,0 +1,4 @@
+include $(LIBCOFF32)/objlst.mk
+
+$(LIBCOFF32)/libcoff32.a: $(LIBCOFF32-OBJ)
+	+cd $(LIBCOFF32) && $(MAKE)
--- /dev/null
+++ b/lib/coff32/objlst.mk
@@ -1,0 +1,9 @@
+
+LIBCOFF32-OBJ = $(LIBCOFF32)/coff32_pack_hdr.o	\
+                $(LIBCOFF32)/coff32_unpack_hdr.o \
+                $(LIBCOFF32)/coff32_pack_scn.o	\
+                $(LIBCOFF32)/coff32_unpack_scn.o \
+                $(LIBCOFF32)/coff32_pack_aout.o	\
+                $(LIBCOFF32)/coff32_unpack_aout.o \
+                $(LIBCOFF32)/coff32_pack_ent.o	\
+                $(LIBCOFF32)/coff32_unpack_ent.o
--- a/lib/crt/Makefile
+++ b/lib/crt/Makefile
@@ -10,7 +10,7 @@
 	./gendep.sh $(TARGETS)
 
 clean:
-	rm -f */crt.o
+	rm -f ./*/crt.o
 
 distclean: clean
 	rm -f makefile
--- a/lib/scc/Makefile
+++ b/lib/scc/Makefile
@@ -4,6 +4,8 @@
 include $(PROJECTDIR)/rules.mk
 include objlst.mk
 
+MORECFLAGS = $(STDCFLAGS)
+
 all: libscc.a
 
 libscc.a: $(LIBSCC-OBJ)
--- a/lib/scc/deps.mk
+++ b/lib/scc/deps.mk
@@ -1,3 +1,4 @@
+#deps
 alloc.o: ../../inc/scc.h
 bpack.o: ../../inc/scc.h
 bunpack.o: ../../inc/scc.h
--- a/nm/Makefile
+++ b/nm/Makefile
@@ -4,6 +4,8 @@
 include $(PROJECTDIR)/rules.mk
 include $(LIBSCC)/libdep.mk
 
+MORECFLAGS = $(STDCFLAGS)
+
 OBJ       = main.o coff32.o formats.o
 
 all: $(BINDIR)/nm
--- a/objdump/Makefile
+++ b/objdump/Makefile
@@ -5,6 +5,7 @@
 include $(LIBSCC)/libdep.mk
 
 OBJ       = main.o 
+MORECFLAGS = $(STDCFLAGS)
 
 all: $(BINDIR)/objdump
 
--- a/rules.mk
+++ b/rules.mk
@@ -1,16 +1,14 @@
 include $(PROJECTDIR)/config.mk
 
-BINDIR  = $(PROJECTDIR)/rootdir/bin
-INCDIR  = $(PROJECTDIR)/inc
-LIBEXEC = $(PROJECTDIR)/rootdir/libexec/scc
-LIBSCC  = $(PROJECTDIR)/lib/scc
+BINDIR     = $(PROJECTDIR)/rootdir/bin
+INCDIR     = $(PROJECTDIR)/inc
+LIBEXEC    = $(PROJECTDIR)/rootdir/libexec/scc
+LIBSCC     = $(PROJECTDIR)/lib/scc
+LIBCOFF32  = $(PROJECTDIR)/lib/coff32
 
-SCC_CFLAGS = $(MOREFLAGS) \
-             $(SYSCFLAGS) \
-             -g \
-             $(CFLAGS)
+SCC_CFLAGS = $(MORECFLAGS) $(SYSCFLAGS) -g $(CFLAGS)
 
-SCC_LDFLAGS = -L$(LIBSCC) -g $(LDFLAGS)
+SCC_LDFLAGS = $(MORELFLAGS) -L$(LIBSCC) -g $(LDFLAGS)
 
 # helper macro to run over all the directories
 FORALL = +@set -e ;\
@@ -28,10 +26,8 @@
 .c.o:
 	$(CC) $(SCC_CFLAGS) -o $@ -c $<
 
-.c:
-	$(CC) $(SCC_CFLAGS) $(SCC_LDFLAGS) -o $@ $<
-
 all:
 dep:
 clean:
 distclean: clean
+FORCE:
--- a/system.mk
+++ /dev/null
@@ -1,18 +1,0 @@
-# Plan9
-SYSCFLAGS = -D_SUSV2_SOURCE
-
-# NetBSD
-CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-
-# OpenBSD
-CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-
-# FreeBSD
-CC1_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-CC2_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-AS_CFLAGS = -D_ISOC99_SOURCE -D_ANSI_SOURCE
-