commit 5ec804e4258967b8dda1fc1cea072e1620817411
parent a2be6ce9aeb1425066673636daa5867aef798b2c
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date: Sun, 19 Jan 2020 09:09:24 +0100
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.
Diffstat:
6 files changed, 73 insertions(+), 9 deletions(-)
diff --git a/Makefile b/Makefile
@@ -4,11 +4,20 @@ PROJECTDIR = .
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
diff --git a/README b/README
@@ -30,6 +30,7 @@ can be passed to the command line:
- amd64-dragonfly
- amd64-netbsd
- arm32-linux
+ - i386-linux
- TOOL: Specify the toolchain type to be used. Possible
supported values are:
@@ -39,6 +40,28 @@ can be passed to the command line:
- 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
===========================
This compiler aims to be fully compatible with the C99 standard, but
diff --git a/scripts/host b/scripts/host
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+case `uname` in
+*BSD)
+ echo bsd
+ ;;
+Plan9)
+ echo plan9
+ ;;
+*)
+ echo unix
+ ;;
+esac
diff --git a/scripts/libc-proto b/scripts/libc-proto
@@ -4,7 +4,10 @@ libexec/scc
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
diff --git 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
diff --git 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