shithub: scc

Download patch

ref: eb58c2c6c6dd1e5b066b52761641b680a526af15
parent: 3e2b9fc5817172876d54d82e4ddc7df78b051212
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Fri Aug 17 17:12:25 EDT 2018

Remove configure and config.mk.def

We don't need this complexity. We added a target in the Makefile
to configure.

--- a/.gitignore
+++ b/.gitignore
@@ -23,3 +23,4 @@
 as/target/*/*tbl.c
 *.out
 ld/ld
+config
--- a/Makefile
+++ b/Makefile
@@ -7,18 +7,37 @@
 
 DIRS  = inc cc1 cc2 driver lib as ar nm objdump ld
 
-all clean dep:
+all: $(DIRS)
+
+$(DIRS): config $(BINDIR) $(LIBEXEC) FORCE 
+	+@cd $@ && $(MAKE) all
+
+FORCE:
+
+$(BINDIR):
+	mkdir -p $@
+
+$(LIBEXEC):
+	mkdir -p $@
+
+clean dep:
 	$(FORALL)
 
-distclean:
-	touch config.mk    # we need config.mk for makes in $DIRS
-	find . -name makefile | xargs rm -f
+distclean: unconfig
 	$(FORALL)
+	rm -f config
 	rm -rf rootdir
-	rm -f config.mk
 
 tests: all
-	+cd tests && $(MAKE) -e all
+	+@cd tests && $(MAKE) -e all
+
+unconfig:
+	(echo '/^### Systems/,$$ v/^#/ s/^/#/' ; echo w) | ed -s config.mk
+	rm -f config
+
+config:
+	(echo '/^# '`uname`'/+;/^###$$/- s/^#//'; echo w) | ed -s config.mk
+	touch $@
 
 install: all
 	mkdir -p $(DESTDIR)$(PREFIX)/
--- /dev/null
+++ b/config.mk
@@ -1,0 +1,38 @@
+# scc version
+VERSION = 0.1
+
+## Customize below to fit your system
+DRIVER = posix
+
+# Can be c89 or c99
+STD = c99
+
+# paths
+PREFIX    = $(PWD)/$(PROJECTDIR)/rootdir
+MANPREFIX = $(PREFIX)/share/man
+
+# scc expects to be built by a C99 compiler
+# if your system is not at least POSIX 2004 compatible, adjust CC
+# CC = c99
+# AR = ar
+AS = as
+
+### Systems
+# 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
+###
--- a/config.mk.def
+++ /dev/null
@@ -1,18 +1,0 @@
-# scc version
-VERSION = 0.1
-
-## Customize below to fit your system
-DRIVER = posix
-
-# Can be c89 or c99
-STD = c99
-
-# paths
-PREFIX    = $(PWD)/$(PROJECTDIR)/rootdir
-MANPREFIX = $(PREFIX)/share/man
-
-# scc expects to be built by a C99 compiler
-# if your system is not at least POSIX 2004 compatible, adjust CC
-# CC = c99
-# AR = ar
-AS = as
--- a/configure
+++ /dev/null
@@ -1,22 +1,0 @@
-#!/bin/sh
-
-set -e
-
-echo Generating file tree...
-mkdir -p rootdir/libexec/scc
-mkdir -p rootdir/bin
-
-if test ! -e config.mk
-then
-	printf '%s\n' 'Generating config.mk from defaults...' \
-	              '(edit it for customization and then re-run this script)'
-	trap "rm -f $$.mk" 0 2 3
-	(cat config.mk.def
-	sed -n '/^# '`uname`'/,/^$/p' system.mk) > $$.mk &&
-	mv $$.mk config.mk
-fi
-
-echo Generating arch-dependant build files...
-cd inc && make config > /dev/null
-
-echo You can now install scc with \"make install\"
--- a/driver/posix/Makefile
+++ b/driver/posix/Makefile
@@ -10,6 +10,9 @@
 SYSLST  = amd64-sysv-linux-elf z80-scc-none-none \
           i386-sysv-linux-elf amd64-sysv-openbsd-elf
 
+SYSHDR  = $(INCDIR)/ldflags.h $(INCDIR)/syscrts.h \
+          $(INCDIR)/sysincludes.h $(INCDIR)/syslibs.h
+
 TARGETS = $(BINDIR)/scc $(BINDIR)/scpp
 
 all: $(TARGETS)
@@ -19,6 +22,9 @@
 
 $(BINDIR)/scpp: cpp
 	cp cpp $@
+
+$(SYSHDR):
+	+@cd $(INCDIR) && $(MAKE)
 
 scc: scc.o $(LIBSCC)/libscc.a
 	$(CC) $(SCC_LDFLAGS) scc.o -lscc -o $@
--- a/ld/Makefile
+++ b/ld/Makefile
@@ -14,6 +14,9 @@
 ld: $(OBJ) $(LIBSCC)/libscc.a
 	$(CC) $(SCC_LDFLAGS) $(OBJ) -lscc -o $@
 
+$(INCDIR)/syslibs.h:
+	+@cd $(INCDIR) && $(MAKE)
+
 dep:
 	$(PROJECTDIR)/mkdep.sh
 
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -6,5 +6,12 @@
 
 DIRS = scc
 
-all dep clean distclean:
+all: $(DIRS)
+
+FORCE:
+
+$(DIRS): FORCE
+	+@cd $@ && $(MAKE)
+
+dep clean distclean:
 	$(FORALL)