Commit Diff


commit - 292ece6080f3f3cfef48c47abff64dbd9034d4fd
commit + 2e0e3a8c58ebc3ff9261c83924a15c5f85627e6f
blob - 9c8cb7919a03db0a1a2897184202a943760c3947
blob + e3d225df6c2a825814bf23c083bb898efc5b1f91
--- tools/Makefile
+++ tools/Makefile
@@ -20,13 +20,14 @@ OKSH_VER = 7.5
 DESTRUCT_VER = 0.2
 RVFORTH_VER = 0.1
 MCU_VER = 1.2
+GFORTH_VER = 0.7.9_20240627
 
 GMAKE = $U/gmake
 SUDO =
 
 all: build
 
-extra: rvforth oksh mcu
+extra: rvforth oksh mcu # gforth (broken)
 
 build: ${STAMPS}/libgcc-install ${STAMPS}/destruct-install
 
@@ -39,8 +40,8 @@ clean:
 test:
 	${PREFIX}/bin/${TARGET}-gcc -o /dev/null $U/test.c
 
-download: src/binutils.tgz src/gcc.tgz src/musl.tgz src/linux.tgz src/gmp.tgz src/mpfr.tgz src/mpc.tgz src/oksh.tgz src/destruct.tgz src/rvforth.tgz src/mcu.tgz
-extract: ${STAMPS}/binutils-extract ${STAMPS}/gcc-extract ${STAMPS}/musl-extract ${STAMPS}/linux-extract ${STAMPS}/gmp ${STAMPS}/mpfr ${STAMPS}/mpc ${STAMPS}/oksh ${STAMPS}/destruct ${STAMPS}/rvforth ${STAMPS}/mcu
+download: src/binutils.tgz src/gcc.tgz src/musl.tgz src/linux.tgz src/gmp.tgz src/mpfr.tgz src/mpc.tgz src/oksh.tgz src/destruct.tgz src/rvforth.tgz src/mcu.tgz src/gforth.txz
+extract: ${STAMPS}/binutils-extract ${STAMPS}/gcc-extract ${STAMPS}/musl-extract ${STAMPS}/linux-extract ${STAMPS}/gmp ${STAMPS}/mpfr ${STAMPS}/mpc ${STAMPS}/oksh ${STAMPS}/destruct ${STAMPS}/rvforth ${STAMPS}/mcu ${STAMPS}/gforth
 
 headers: ${STAMPS}/linux-headers
 install-headers: ${STAMPS}/linux-hdrinst
@@ -93,6 +94,10 @@ src/mcu.tgz:
 	mkdir -p src
 	$U/download $@ https://github.com/riscygeek/microcoreutils/archive/refs/tags/v${MCU_VER}.tar.gz
 
+src/gforth.txz:
+	mkdir -p src
+	$U/download $@ https://www.complang.tuwien.ac.at/forth/gforth/Snapshots/${GFORTH_VER}/gforth-${GFORTH_VER}.tar.xz
+
 # EXTRACT
 
 ${STAMPS}/binutils-extract: src/binutils.tgz
@@ -168,6 +173,12 @@ ${STAMPS}/mcu: src/mcu.tgz
 	mv build/microcoreutils-* build/mcu
 	touch $@
 
+${STAMPS}/gforth: src/gforth.txz
+	mkdir -p ${STAMPS}
+	xzcat src/gforth.txz | tar -C build -xf -
+	mv build/gforth-* build/gforth
+	touch $@
+
 # KERNEL HEADERS
 
 ${STAMPS}/linux-headers: ${STAMPS}/linux-extract
@@ -323,6 +334,9 @@ ${TOP}/rootfs/bin/rvforth: ${STAMPS}/rvforth-build
 	mkdir -p ${TOP}/rootfs/bin
 	(cd ${TOOLS}/build/rvforth && ${MAKE} PREFIX=/ DESTDIR=${TOP}/rootfs install)
 
+clean-rvforth:
+	rm -f ${STAMPS}/rvforth*
+	rm -rf build/rvforth
 
 rvforth: ${TOP}/rootfs/bin/rvforth
 
@@ -350,3 +364,59 @@ ${TOP}/rootfs/mcu/bin/ls: ${STAMPS}/mcu-build
 	(cd ${TOOLS}/build/mcu && ${MAKE} DESTDIR=${TOP}/rootfs install)
 
 mcu: ${TOP}/rootfs/mcu/bin/ls
+
+# GFORTH
+
+${STAMPS}/gforth-fix: ${STAMPS}/gforth
+	(cd ${TOOLS}/build/gforth && sed '/^CHECKFLAGS=.*$$/d' configure > configure.new && chmod +x configure.new)
+	touch $@
+
+${STAMPS}/gforth-configure: ${STAMPS}/gforth-fix
+	cd ${TOOLS}/build/gforth &&				\
+	CC=${PREFIX}/bin/${TARGET}-gcc CFLAGS="-O2" ./configure.new	\
+		--prefix=/					\
+		--with-arch=riscv				\
+		--without-check					\
+		--host=${TARGET}				\
+		--enable-static					\
+		--disable-shared				\
+		--disable-version				\
+		--disable-lib					\
+		--without-pic					\
+		ac_cv_sizeof_void_p=8				\
+		ac_cv_sizeof_char_p=8				\
+		ac_cv_sizeof_char=1				\
+		ac_cv_sizeof_short=2				\
+		ac_cv_sizeof_int=4				\
+		ac_cv_sizeof_long=8				\
+		ac_cv_sizeof_long_long=8			\
+		ac_cv_sizeof_intptr_t=8				\
+		ac_cv_sizeof___int128_t=16			\
+		ac_cv_sizeof___uint128_t=16			\
+		ac_cv_sizeof_off_t=8				\
+		ac_cv_c_bigendian=no				\
+		ac_cv_func_memcmp_working=yes			\
+		ac_cv_func_memmove=yes				\
+		ac_cv_func_getpagesize=yes			\
+		ac_cv_func_wcwidth=yes				\
+		ac_cv_func_mcheck=no				\
+		ac_cv_func_dlopen=no				\
+		ac_cv_export_dynamic=no
+	(cd ${TOOLS}/build/gforth && \
+		sed 's@\(DITCENGINE\) = \(.*$$\)@\1 = ${TOP}/linurv \2@' Makefile > Makefile.new && \
+		mv Makefile.new Makefile)
+	touch $@
+
+${STAMPS}/gforth-build: ${STAMPS}/gforth-configure
+	(cd ${TOOLS}/build/gforth && ${GMAKE})
+	touch $@
+
+${TOP}/rootfs/bin/gforth: ${STAMPS}/gforth-build
+	(cd ${TOOLS}/build/gforth && ${GMAKE} DESTDIR=${TOP}/rootfs install)
+	touch $@
+
+clean-gforth:
+	rm -f ${STAMPS}/gforth*
+	rm -rf build/gforth
+
+gforth: ${TOP}/rootfs/bin/gforth