shithub: cc65-plan9

Download patch

ref: 2e2e412d056d214d103bceec96186b35ea45acd1
parent: 7870bfc34bbd6c2cf918749490ee8fc8dd0177db
author: Tevo <estevan.cps@gmail.com>
date: Thu Sep 3 23:26:14 EDT 2020

libsrc WIP mkfiles

ape/diff: b/mkfiles/libsrc/defs/null: No such file or directory ape/diff: b/mkfiles/libsrc/null: No such file or directory
--- a/TODO	Thu Sep  3 22:19:23 2020
+++ b/TODO	Thu Sep  3 23:26:14 2020
@@ -1,6 +1,7 @@
 - Add git revision to BUILD_ID (mkfiles/src/common.mk)
 - Write mkfiles for libsrc, doc and samples
 - Cleanup mkfiles
+	- See mkfiles/libsrc/mkfile.target
 - 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	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/defs/apple2enh.mk	Thu Sep  3 23:26:14 2020
@@ -0,0 +1,3 @@
+SRCDIR=apple2
+OBJPFX=a2
+DRVPFX=a2e
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/defs/atari.mk	Thu Sep  3 23:26:14 2020
@@ -0,0 +1,40 @@
+# Mostly copy-pasted from atari/Makefile.inc, including comments
+# FIXME: It may be feasible to generate this file automatically
+
+# NUMDRVS        - number of supported drives (max. 16)
+#                  4 bytes for each device are statically allocated
+# LINEBUF        - support line buffered reads from E: (the number specifies
+#                  the length of the buffer)
+# UCASE_FILENAME - all filenames get uppercased
+# DEFAULT_DEVICE - if the string passed to the uppercase function doesn't
+#                  include a device (":" at position 2 or 3), provide "Dn:"
+#                  as a default disk device
+#                  n is the value of DEFAULT_DEVICE, unless DYNAMIC_DD is
+#                  also set, in which case it's overridden by a runtime
+#                  check (on SpartaDOS only)
+#                  needs UCASE_FILENAME to be defined, otherwise no effect
+# DYNAMIC_DD     - determine default disk device at runtime (SpartaDOS only)
+#                  needs DEFAULT_DEVICE to be defined, otherwise no effect
+
+CA65FLAGS=$CA65FLAGS -D NUMDRVS=4 -D LINEBUF=80 -D UCASE_FILENAME=1 -D DEFAULT_DEVICE=1 -D DYNAMIC_DD=1
+
+# The following defines are only used by the 'atarixl' target:
+#
+# CHARGEN_RELOC  - If defined, CHBAS and CHBASE are updated when
+#                  enabling or disabling the ROM.
+#                  If the ROM is enabled, $E0 is written to CHBAS
+#                  and CHBASE.
+#                  If the ROM is disabled, the upper byte of
+#                  __CHARGEN_START__ is written to CHBAS and CHBASE.
+# USEWSYNC       - If defined, the code waits for horizontal retrace
+#                  before switching the ROM and updating CHBAS and
+#                  CHBASE. This define only has effect if CHARGEN_RELOC
+#                  is also defined.
+
+# Disabled by default, you should enable it if the linker script relocates the
+# character generator (like atarixl-largehimem.cfg).
+#CA65FLAGS=$CA65_FLAGS -D CHARGEN_RELOC -D USEWSYNC
+
+# Disable if you don't want to use page 6 for mouse P/M data.
+# If disabled, top of the RAM is used for P/M data.
+CA65FLAGS=$CA65_FLAGS -D USE_PAGE6
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/defs/atarixl.mk	Thu Sep  3 23:26:14 2020
@@ -0,0 +1,3 @@
+SRCDIR=atari
+OBJPFX=atr
+DRVPFX=atrx
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/defs/common.mk	Thu Sep  3 23:26:14 2020
@@ -0,0 +1,3 @@
+SRCDIR=$TARGET
+OBJPFX=
+DRVPFX=
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/defs/geos-apple.mk	Thu Sep  3 23:26:14 2020
@@ -0,0 +1 @@
+CA65FLAGS=-Igeos-apple -Igeos-common
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/defs/geos-cbm.mk	Thu Sep  3 23:26:14 2020
@@ -0,0 +1 @@
+CA65FLAGS=-Igeos-cbm -Igeos-common
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/defs/sim65c02.mk	Thu Sep  3 23:26:14 2020
@@ -0,0 +1 @@
+SRCDIR=sim6502
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/mkfile	Thu Sep  3 23:26:14 2020
@@ -0,0 +1,63 @@
+
+CBMS=\
+	c128	\
+	c16		\
+	c64		\
+	cbm510	\
+	cbm610	\
+	cx16	\
+	pet		\
+	plus4	\
+	vic20
+
+GEOS=\
+	geos-apple	\
+	geos-cbm
+
+TARGETS=\
+	apple2		\
+	apple2enh	\
+	atari		\
+	atarixl		\
+	atari2600	\
+	atari5200	\
+	atmos		\
+	creativision\
+	$CBMS		\
+	$GEOS		\
+	gamate		\
+	lynx		\
+	nes			\
+	none		\
+	osic1p		\
+	pce			\
+	sim6502		\
+	sim65c02	\
+	supervision	\
+	telestrat
+
+DRVTYPES=\
+	emd	\
+	joy	\
+	mou	\
+	ser	\
+	tgi
+
+OUTPUTDIRS=\
+	lib		\
+	asminc	\
+	cfg		\
+	include	\
+	`{echo ../include/*			| sed 's@../@@g'}	\
+	`{echo ../target/*/drv/*	| sed 's@../@@g'}	\
+	`{echo ../target/*/util		| sed 's@../@@g'}
+
+datadir=/sys/lib/cc65
+
+all:V: $TARGETS
+
+$TARGETS:V:
+	for(TARGET in $target) # Can I get mk to call each target individually?
+		mk -f mkfile.target || status=''
+
+# TODO: clean, nuke, install
--- /dev/null	Thu Dec 31 12:39:09 2020
+++ b/mkfiles/libsrc/mkfile.target	Thu Sep  3 23:26:14 2020
@@ -0,0 +1,103 @@
+
+CA65FLAGS=
+CC65FLAGS=-Or -Werror
+
+# For native $O
+</$cputype/mkfile
+
+CC65_HOME=`{cleanname -d `{pwd} ..}
+
+AR65=../src/ar65/$O.out
+CA65=../src/ca65/$O.out
+CC65=../src/cc65/$O.out
+LD65=../src/cc65/$O.out
+
+../src/%/$O.out:
+	@{
+		cd ../src
+		objtype=$cputype mk $stem/$O.out
+	}
+
+EXTZP=\
+	cbm510	\
+	cbm610	\
+	lynx
+
+TARGETUTIL=\
+	apple2		\
+	apple2enh	\
+	atari		\
+	geos-apple
+
+GEOSDIRS=\
+	common		\
+	conio		\
+	disk		\
+	dlgbox		\
+	file		\
+	graph		\
+	memory		\
+	menuicon	\
+	mousesprite	\
+	process		\
+	runtime		\
+	system
+
+<defs/common.mk
+<`{test -r defs/$TARGET.mk && echo defs/$TARGET.mk || echo /dev/null} # It needs a include name
+
+SRCDIRS=\
+	$SRCDIR	\
+	`{~ $TARGET $CBMS && echo cbm}	\
+	`{~ $TARGET $GEOS && for(dir in $GEOSDIRS) {test -d $TARGET/$dir && echo $TARGET/$dir; echo geos-common/$dir}}	\
+	common		\
+	conio		\
+	dbg			\
+	em			\
+	joystick	\
+	mouse		\
+	runtime		\
+	serial		\
+	tgi			\
+	zlib
+
+SRC=`{walk $SRCDIRS | grep '\.[cs]$'}
+# Can we do this with a single namelist instead?
+OBJ=`{for(f in $SRC) echo $f | sed 's@\.[cs]$@.o@g'}
+
+DEPS=${OBJ:%.o=%.d}
+
+EXTRASRC=`{walk $SRCDIR | grep $SRCDIR/extra/^'.*\.s$'}
+EXTRAOBJ=${EXTRASRC:$SRCDIR/extra/%.s=../lib/$TARGET-%.o}
+
+DEPS=$DEPS ${EXTRAOBJ:../lib/%.o=$TARGET/%.d}
+
+# TODO: Target tools
+
+ZPOBJ=$TARGET/zeropage `{~ $TARGET $EXTZP && echo $TARGET/extzp.o}
+
+all:V: $TARGET
+
+# TODO: drvs
+
+# FIXME: Dump temporary assembly under ../libwrk, with .s extension
+
+%.o: %.s
+	$CA65 -t $TARGET $CA65FLAGS --create-dep `{echo $target | sed 's@\.o$@\.d@g'} \
+		-o $target $prereq
+
+%.o: %.c
+	$CC65 -t $TARGET $CC65FLAGS --create-dep `{echo $target | sed 's@\.o$@\.d@g'} \
+		--dep-target $target -o `{echo $target | sed 's@\.o$@\.asm@g'} $prereq
+	$CA65 -t $TARGET -o $target `{echo $target | sed 's@\.o$@\.asm@g'}
+
+../lib/$TARGET-%.o: $SRCDIR/extra/%.s
+	mkdir -p ../lib
+	$CA65 -t $TARGET $CA65FLAGS \
+		--create-dep `{echo $target | sed 's@^../lib/@'^$TARGET^'/@g;s@\.o$@.d@g'}
+
+# TODO: Maintain that as an archive
+../lib/$TARGET.lib: $OBJ
+	$AR65 a $target $prereq
+
+$TARGET:V: $EXTRAOBJ ../lib/$TARGET.lib