From 5b6ff8f27da4f149319fd8becef3a546d1d8f48e Mon Sep 17 00:00:00 2001 From: Robert Roland Date: Wed, 3 Jul 2019 22:10:06 -0700 Subject: [PATCH] Adding Atari TOS support Adding a simple Makefile based on the Amiga Makefile to use VBCC to compile for Atari TOS. In the Amiga and Atari Makefile, I made a small change to ensure the LDFLAGS (-lm) end up at the end of the link command, otherwise they will fail --- build/linux-crossbuild-amiga/Makefile | 3 +- build/linux-crossbuild-atari/Makefile | 152 ++++++++++++++++++++++++++ csrc/pf_types.h | 2 +- 3 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 build/linux-crossbuild-atari/Makefile diff --git a/build/linux-crossbuild-amiga/Makefile b/build/linux-crossbuild-amiga/Makefile index c37f5fe..55698f6 100644 --- a/build/linux-crossbuild-amiga/Makefile +++ b/build/linux-crossbuild-amiga/Makefile @@ -67,7 +67,6 @@ CFLAGS = $(CCOPTS) LDFLAGS = $(WIDTHOPT) -lm COMPILE = $(CC) $(CFLAGS) $(CPPFLAGS) -LINK = $(CC) $(LDFLAGS) # Cross compiler flags (for VBCC not gcc) XCFLAGS = -c99 -O3 @@ -106,7 +105,7 @@ pffiles: # Build pforth by compiling 'C' source. $(PFDICAPP): $(PFINCLUDES) $(PFOBJS) - $(LINK) -o $@ $(PFOBJS) $(LDADD) + $(CC) -o $@ $(PFOBJS) $(LDADD) $(LDFLAGS) # Build basic dictionary image by running newly built pforth and including "system.fth". $(PFORTHDIC): $(PFDICAPP) diff --git a/build/linux-crossbuild-atari/Makefile b/build/linux-crossbuild-atari/Makefile new file mode 100644 index 0000000..7327163 --- /dev/null +++ b/build/linux-crossbuild-atari/Makefile @@ -0,0 +1,152 @@ +# This Makefile can be used to cross-compile pForth on a Linux host to +# an Atari ST target. GCC is used as host-compiler and VBCC as +# cross-compiler. + +# makefile for pForth +# Portable Forth written in 'C' +# by Phil Burk +# For more info visit http://www.softsynth.com/pforth/ +# +# See "help" target below. + +# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG +# See "docs/pf_ref.htm" file for more info. + +# We are going to use VBCC as cross compiler. I've installed VBCC +# under /opt/vbcc. It's configured to generate Motorola 680x0 code. +VBCC := /opt/vbcc +PATH := $(VBCC)/bin:$(PATH) +XCC = vc # The VBCC compiler + +SRCDIR = ../.. +PFORTHDIR = $(SRCDIR) +CSRCDIR = $(PFORTHDIR)/csrc +FTHDIR = $(PFORTHDIR)/fth + +PFDICAPP = pforth +PFORTHDIC = pforth.dic +PFDICDAT = pfdicdat.h +PFORTHAPP = pforth.ttp + +# We need to create a 32-bit dictionary +WIDTHOPT= -m32 +DEBUGOPTS = -g +FULL_WARNINGS = \ + --std=c89 \ + -pedantic \ + -Wcast-qual \ + -Wall \ + -Wwrite-strings \ + -Winline \ + -Wmissing-prototypes \ + -Wmissing-declarations +CCOPTS = $(WIDTHOPT) -x c -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS) $(DEBUGOPTS) + +#IO_SOURCE = pf_io_posix.c +IO_SOURCE = pf_io_stdio.c pf_fileio_stdio.c +#IO_SOURCE = pf_io_win32_console.c + +EMBCCOPTS = -DPF_STATIC_DIC + +####################################### +PFINCLUDES = pf_all.h pf_cglue.h pf_clib.h pf_core.h pf_float.h \ + pf_guts.h pf_host.h pf_inc1.h pf_io.h pf_mem.h pf_save.h \ + pf_text.h pf_types.h pf_words.h pfcompfp.h \ + pfcompil.h pfdicdat_arm.h pfinnrfp.h pforth.h +PFBASESOURCE = pf_cglue.c pf_clib.c pf_core.c pf_inner.c \ + pf_io.c pf_io_none.c pf_main.c pf_mem.c pf_save.c \ + pf_text.c pf_words.c pfcompil.c pfcustom.c +PFSOURCE = $(PFBASESOURCE) $(IO_SOURCE) + +VPATH = .:$(CSRCDIR):$(CSRCDIR)/posix:$(CSRCDIR)/stdio + + +CPPFLAGS = -I. -DPF_BIG_ENDIAN_DIC -DPF_SUPPORT_FP +CFLAGS = $(CCOPTS) +LDFLAGS = $(WIDTHOPT) -lm + +COMPILE = $(CC) $(CFLAGS) $(CPPFLAGS) + +# Cross compiler flags (for VBCC not gcc) +XCFLAGS = +tos -c99 -O3 +#XCPPFLAGS = -DPF_SUPPORT_FP -DWIN32 +XCPPFLAGS = -I. -DATARI -DPF_SUPPORT_FP +XLDFLAGS = +tos -lm -lm881 + +XCOMPILE = $(XCC) $(XCFLAGS) $(XCPPFLAGS) +XLINK = $(XCC) $(XLDFLAGS) + +.SUFFIXES: .c .o .eo + +PFOBJS = $(PFSOURCE:.c=.o) +PFEMBOBJS = $(PFSOURCE:.c=.eo) + +.c.o: $(PFINCLUDES) + $(COMPILE) -c -o $@ $< + +.c.eo: $(PFINCLUDES) pfdicdat.h + $(XCOMPILE) $(EMBCCOPTS) -c -o $@ $< + +.PHONY: all clean test +.PHONY: help pffiles pfdicapp pfdicdat pforthapp + +all: $(PFORTHAPP) + +pffiles: + @echo "INCLUDE FILES -----------------" + @echo ${PFINCLUDES} + @echo "'C' FILES ---------------------" + @echo ${PFSOURCE} + @echo "OBJECT FILES ------------------" + @echo ${PFOBJS} + @echo "EMBEDDED OBJECT FILES ------------------" + @echo ${PFEMBOBJS} + +# Build pforth by compiling 'C' source. +$(PFDICAPP): $(PFINCLUDES) $(PFOBJS) + $(CC) -o $@ $(PFOBJS) $(LDADD) $(LDFLAGS) + +# Build basic dictionary image by running newly built pforth and including "system.fth". +$(PFORTHDIC): $(PFDICAPP) + wd=$$(pwd); (cd $(FTHDIR); $${wd}/$(PFDICAPP) -i system.fth) + (cd $(FTHDIR); cat pforth.dic; rm -f pforth.dic) > $@ + +$(PFDICDAT): $(PFORTHDIC) $(PFDICAPP) + echo 'include $(FTHDIR)/savedicd.fth SDAD'>load-dict-tmp.fth&& ./$(PFDICAPP) -d $(PFORTHDIC) load-dict-tmp.fth; rm -f load-dict-tmp.fth + +$(PFORTHAPP): $(PFDICDAT) $(PFEMBOBJS) + $(XLINK) -o $@ $(PFEMBOBJS) $(XLDADD) + @echo "" + @echo "Standalone pForth executable written to $(PFORTHAPP)" + + +# target aliases +pfdicapp: $(PFDICAPP) + +pfdicdat: $(PFDICDAT) + +pforthapp: $(PFORTHAPP) + +help: + @echo "Use 'make all' to build standalone pForth executable." + @echo "PForth can be built in several stages using these targets:" + @echo " pfdicapp = executable pForth with minimal dictionary. All from 'C'." + @echo " pfdicdat = image of full dictionary build by compiling Forth code." + @echo " pforthapp = executable with embedded dictionary image. DEFAULT 'all' target." + @echo "" + @echo " The file 'fth/pfdicdat.h' is generated by pForth. It contains a binary image of the Forth dictionary." + @echo " It allows pForth to work as a standalone image that does not need to load a dictionary file." + +test: $(PFORTHAPP) + wd=$$(pwd); (cd $(FTHDIR); $(WINE) $${wd}/$(PFORTHAPP) -q t_corex.fth) + wd=$$(pwd); (cd $(FTHDIR); $(WINE) $${wd}/$(PFORTHAPP) -q t_strings.fth) + wd=$$(pwd); (cd $(FTHDIR); $(WINE) $${wd}/$(PFORTHAPP) -q t_locals.fth) + wd=$$(pwd); (cd $(FTHDIR); $(WINE) $${wd}/$(PFORTHAPP) -q t_alloc.fth) + wd=$$(pwd); (cd $(FTHDIR); $(WINE) $${wd}/$(PFORTHAPP) -q t_floats.fth) + +clean: + rm -f $(PFOBJS) $(PFEMBOBJS) + rm -f $(PFORTHAPP) + rm -f $(PFDICDAT) $(FTHDIR)/$(PFDICDAT) + rm -f $(PFORTHDIC) $(FTHDIR)/$(PFORTHDIC) + rm -f $(PFDICAPP) diff --git a/csrc/pf_types.h b/csrc/pf_types.h index 619a2c0..6e0ea75 100644 --- a/csrc/pf_types.h +++ b/csrc/pf_types.h @@ -23,7 +23,7 @@ ** Type Declarations ***************************************************************/ -#ifndef AMIGA +#if !defined(AMIGA) && !defined(ATARI) #include #endif -- 2.20.1