shithub: scc

Download patch

ref: 30486c0e4349deef16a130294033825dfddae4ec
parent: 9e7b8848343bdb7e2a44c5273dd7766353fdac2e
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Sun Jan 19 04:09:24 EST 2020

build: Automatize build

Setting HOST manually was prone to errors and confuse for
new people. Compiling only amd64-linux linux was prone to
errors because other libc versions of the library where not
compiled.

--- a/Makefile
+++ b/Makefile
@@ -4,11 +4,20 @@
 include $(PROJECTDIR)/scripts/rules.mk
 
 PREFIX= /usr/local
-DIRS  = src include/scc/scc tests
+DIRS  = src src/libc include/scc/scc tests
 
-all: src
+all:
+	+@$(MAKE) HOST=`$(SCRIPTDIR)/host` toolchain
+	+@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-linux libc
+	+@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-openbsd libc
+	+@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-netbsd libc
+	+@$(MAKE) HOST=`$(SCRIPTDIR)/host` CONF=amd64-dragonfly libc
 
-src: dirs include/scc/scc
+toolchain: dirs src
+
+libc: dirs src/libc
+
+src: include/scc/scc
 
 dirs: $(SCRIPTDIR)/libc-proto
 	xargs mkdir -p < $(SCRIPTDIR)/libc-proto
--- a/README
+++ b/README
@@ -30,6 +30,7 @@
 		- amd64-dragonfly
 		- amd64-netbsd
 		- arm32-linux
+		- i386-linux
 
 	- TOOL: Specify the toolchain type to be used.  Possible
 	  supported values are:
@@ -38,6 +39,28 @@
 		- gnu
 		- gnu-darwin
 		- clang
+
+The main targets of the Makefile are:
+
+	- all:
+	  Compile the toolchain and all the amd64-posix libc. It automatically
+	  determines what is the best value for HOST.
+
+	- toolchain
+	  Compile the toolchain.
+
+	- libc:
+	  Compile the libc for the target specified in CONF.
+
+	- install:
+	  Installs scc in PREFIX.
+	
+	- clean:
+	  Remoe all the generated files except the one supposed to be edited
+	  by the user.
+
+	- distclean
+	  Remove all the generated files. 
 
 Deviations from standard C
 ===========================
--- /dev/null
+++ b/scripts/host
@@ -1,0 +1,13 @@
+#!/bin/sh
+
+case `uname` in
+*BSD)
+	echo bsd
+	;;
+Plan9)
+	echo plan9
+	;;
+*)
+	echo unix
+	;;
+esac
--- a/scripts/libc-proto
+++ b/scripts/libc-proto
@@ -4,7 +4,10 @@
 lib
 lib/scc
 lib/scc/i386-linux
+lib/scc/arm32-linux
+lib/scc/arm64-linux
 lib/scc/amd64-netbsd
 lib/scc/amd64-linux
 lib/scc/amd64-openbsd
-lib/scc/i386-openbsd
+lib/scc/amd64-dragonfly
+lib/scc/amd64-darwin
--- a/scripts/proto
+++ b/scripts/proto
@@ -1,15 +1,31 @@
 d 755 lib
 d 755 lib/scc
 f 644 lib/scc/libmach.a
-d 755 lib/scc/amd64-netbsd
+f 644 lib/scc/libscc.a
 d 755 lib/scc/i386-linux
-d 755 lib/scc/i386-openbsd
+f 644 lib/scc/i386-linux/libc.a
+f 644 lib/scc/i386-linux/crt.o
+f 644 lib/scc/i386-linux/libcrt.a
+d 755 lib/scc/amd64-dragonfly
+f 644 lib/scc/amd64-dragonfly/libc.a
+f 644 lib/scc/amd64-dragonfly/crt.o
+f 644 lib/scc/amd64-dragonfly/libcrt.a
+d 755 lib/scc/amd64-darwin
+f 644 lib/scc/amd64-darwin/libc.a
+f 644 lib/scc/amd64-darwin/crt.o
+f 644 lib/scc/amd64-darwin/libcrt.a
+d 755 lib/scc/amd64-openbsd
+f 644 lib/scc/amd64-openbsd/libc.a
+f 644 lib/scc/amd64-openbsd/crt.o
+f 644 lib/scc/amd64-openbsd/libcrt.a
+d 755 lib/scc/amd64-netbsd
+f 644 lib/scc/amd64-netbsd/libc.a
+f 644 lib/scc/amd64-netbsd/crt.o
+f 644 lib/scc/amd64-netbsd/libcrt.a
 d 755 lib/scc/amd64-linux
 f 644 lib/scc/amd64-linux/libc.a
 f 644 lib/scc/amd64-linux/crt.o
 f 644 lib/scc/amd64-linux/libcrt.a
-f 644 lib/scc/libscc.a
-d 755 lib/scc/amd64-openbsd
 d 755 bin
 f 755 bin/ld
 f 755 bin/cpp
--- a/src/Makefile
+++ b/src/Makefile
@@ -3,7 +3,7 @@
 PROJECTDIR = ..
 include $(PROJECTDIR)/scripts/rules.mk
 
-LIBS  = libcrt libscc libc libmach
+LIBS  = libcrt libscc libmach
 DIRS  = cmd $(LIBS)
 
 all: cmd