shithub: cc65-plan9

Download patch

ref: 19535ffd6a03602cf0fcb4d78a2a89c4f494d859
author: Tevo <[email protected]>
date: Wed Sep 2 19:16:23 EDT 2020

Initial toolchain port

diff: cannot open b/mkfiles/src/common//null: file does not exist: 'b/mkfiles/src/common//null' diff: cannot open b/mkfiles/src//null: file does not exist: 'b/mkfiles/src//null' diff: cannot open b/mkfiles//null: file does not exist: 'b/mkfiles//null'
--- /dev/null
+++ b/TODO
@@ -1,0 +1,6 @@
+- Add git revision to BUILD_ID (mkfiles/src/common.mk)
+- Write mkfiles for libsrc, doc and samples
+- Cleanup mkfiles
+- Maybe write mkfiles to be installed somewhere like /sys/lib/cc65/$system/mkfile
+	- Can be imported for building projects for $system, in the same spirit
+	as /$objtype/mkfile
--- /dev/null
+++ b/mkfile
@@ -1,0 +1,19 @@
+
+UPSTREAM='https://github.com/cc65/cc65.git'
+
+all clean nuke install:V: upstream bind
+	@{
+		cd upstream && mk $target
+	}
+
+upstream:D: /bin/git/clone
+	git/clone $UPSTREAM upstream
+
+bind:V: upstream overlay
+	if(! test -e upstream/mkfile)
+		overlay mkfiles upstream
+	if not
+		status=''
+
+unbind:V: upstream overlay
+	overlay -u mkfiles upstream
--- /dev/null
+++ b/mkfiles/mkfile
@@ -1,0 +1,13 @@
+</$objtype/mkfile
+
+DIRS=\
+	src		\
+	libsrc	\
+	doc		\
+	samples
+
+all clean nuke install:V:
+	for(dir in $DIRS) @{
+		cd $dir
+		mk $target
+	}
--- /dev/null
+++ b/mkfiles/src/common.mk
@@ -1,0 +1,26 @@
+CC=pcc
+
+datadir=/sys/lib/cc65
+bindir=/$objtype/bin
+
+CA65_INC=$datadir/asminc
+CC65_INC=$datadir/include
+CL65_TGT=$datadir/target
+LD65_LIB=$datadir/lib
+LD65_OBJ=$datadir/lib
+LD65_CFG=$datadir/cfg
+
+# FIXME: Add git revision to build ID
+BUILD_ID='Plan 9'
+
+# I'm not sure if we should manually define __STDC_VERSION__ like that
+CFLAGS=\
+	-I../common	\
+	-D_POSIX_SOURCE -D__STDC_VERSION__=199901L \
+	-DCA65_INC=$CA65_INC	\
+	-DCC65_INC=$CC65_INC	\
+	-DCL65_TGT=$CL65_TGT	\
+	-DLD65_LIB=$LD65_LIB	\
+	-DLD65_OBJ=$LD65_OBJ	\
+	-DLD65_CFG=$LD65_CFG	\
+	-DBUILD_ID=$BUILD_ID
--- /dev/null
+++ b/mkfiles/src/common/mkfile
@@ -1,0 +1,18 @@
+</$objtype/mkfile
+
+LIB=common.$O.a
+
+SRC=`{walk | grep '\.c$'}
+OBJ=${SRC:%.c=%.$O}
+
+<../common.mk
+
+$LIB(%):N: %
+$LIB: ${OBJ:%=$LIB(%)}
+	ar rv $LIB `{membername $newprereq}
+
+clean:
+	rm -f *.[$OS].a *.[$OS]
+
+%.$O: %.c
+	$CC -c $CFLAGS $stem.c -o $target
--- /dev/null
+++ b/mkfiles/src/mkfile
@@ -1,0 +1,45 @@
+</$objtype/mkfile
+
+PROGS=\
+	ar65		\
+	ca65		\
+	cc65		\
+	chrcvt65	\
+	cl65		\
+	co65		\
+	da65		\
+	grc65		\
+	ld65		\
+	od65		\
+	sim65		\
+	sp65
+
+EXEC=${PROGS:%=%/$O.out}
+
+<common.mk
+
+all:V: $EXEC
+
+common/common.$O.a: common
+	cd common && mk
+
+%/$O.out: common/common.$O.a
+	cd $stem && mk -f ../mkfile.prog
+
+clean nuke:V:
+	@{ cd common && mk clean }
+	for(prog in $PROGS) @{
+		cd $prog
+		mk -f ../mkfile.prog $target
+	}
+
+$bindir/%: %/$O.out $bindir
+	cp $stem/$O.out $target
+
+install:V: ${PROGS:%=$bindir/%}
+
+uninstall:V:
+	for(prog in $PROGS) rm -f $bindir/$prog
+
+$datadir $bindir:
+	mkdir -p $target
--- /dev/null
+++ b/mkfiles/src/mkfile.prog
@@ -1,0 +1,18 @@
+</$objtype/mkfile
+
+LIBS=\
+	../common/common.$O.a
+
+SRC=`{walk | grep '\.c$'}
+OBJ=${SRC:%.c=%.$O}
+
+<../common.mk
+
+$O.out: $OBJ
+	$CC -o $target $OBJ $LIBS
+
+%.$O: %.c
+	$CC $CFLAGS $stem.c -c -o $target
+
+clean nuke:V:
+	rm -f [$OS].out *.[$OS]
--- /dev/null
+++ b/overlay
@@ -1,0 +1,45 @@
+#!/bin/rc
+
+fn usage {
+	echo usage: $0 [-u] source target >[1=2]
+	exit 'usage'
+}
+
+mode=bind
+
+while(~ $1 -*) {
+	switch($1) {
+	case -u
+		mode=unbind
+	case *
+		usage
+	}
+	shift
+}
+
+source=$1
+target=$2
+
+if(! test -d $source || ! test -d $target)
+	usage
+
+files=`{walk -f $source}
+mtpts=`{for(file in $files) basename -d $file | sed s@$source@$target@g}
+
+for(mtpt in $mtpts)
+	switch($mode) {
+	case bind
+		bind -cq $mtpt $mtpt || status=''
+	case unbind
+		unmount $mtpt >/dev/null >[2=1]  || status=''
+	}
+
+if(~ $mode bind)
+	for(file in $files) {
+		dest=`{echo $file | sed s@$source@$target@g}
+		aux/stub $dest
+		bind -c $file $dest
+	}
+if not
+	status=''
+