# Portable Forth written in 'C'
# by Phil Burk
# For more info visit http://www.softsynth.com/pforth/
-
+#
+# See "help" target below.
+\r
.SUFFIXES: .c .o
# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
OBJECTDIR = $(PFORTHDIR)/objects
TEMPOBJECTDIR = $(PFORTHDIR)/tempobjects
+# This is needed to get pForth to build on Snow Leopard and other 64 bit platforms.
+WIDTHOPT=-m32
+
FULL_WARNINGS = \
-fsigned-char \
-fno-builtin \
-Wmissing-prototypes \
-Wmissing-declarations
-CCOPTS = -DPF_SUPPORT_FP -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS)
+DEBUGOPTS = -g
+CCOPTS = $(WIDTHOPT) -x c -DPF_SUPPORT_FP -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS) $(DEBUGOPTS)
IO_SOURCE = ${CSRCDIR}/posix/pf_io_posix.c
#IO_SOURCE = ${CSRCDIR}/stdio/pf_io_stdio.c
mkdir -p ${OBJECTDIR}/posix
mkdir -p ${OBJECTDIR}/stdio
-# build pforth by compiling 'C' source
+# Build pforth by compiling 'C' source.
$(PFDICAPP): $(PFINCLUDES) $(PFOBJS)
- $(COMPILER) $(PFOBJS) -lm -o $(PFDICAPP)
-
-pfdicapp: $(PFDICAPP)
+ $(COMPILER) $(PFOBJS) $(WIDTHOPT) -lm -o $(PFDICAPP)
-# build basic dictionary by running newly built pforth and including system.fth
+# Build basic dictionary image by running newly built pforth and including "system.fth".
$(PFDICDAT): $(PFDICAPP)
cd $(FTHDIR); $(PFDICAPP) -i system.fth ; mv pfdicdat.h $(PFDICDAT)
-$(PFORTHAPP): ${TEMPOBJECTDIR} $(PFDICDAT) $(PFINCLUDES) $(PFEMBOBJS)
- $(COMPILER) $(PFEMBOBJS) -lm -o $(PFORTHAPP)
+$(PFORTHAPP): $(PFDICDAT) $(PFEMBOBJS)
+ $(COMPILER) $(PFEMBOBJS) $(WIDTHOPT) -lm -o $(PFORTHAPP)
@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."
+
+
clean:
-rm -f $(PFOBJS) $(PFEMBOBJS)
-rm $(PFORTHAPP)
}\r
\r
/**************************************************************************\r
-** Main entry point for pForth\r
+** Main entry point for pForth.
*/\r
int32 pfDoForth( const char *DicFileName, const char *SourceName, int32 IfInit )\r
{\r
pfDictionary_t *dic = NULL;\r
int32 Result = 0;\r
ExecToken EntryPoint = 0;\r
- \r
\r
#ifdef PF_USER_INIT\r
Result = PF_USER_INIT;\r
#define TRUE (1)\r
#define FALSE (0)\r
#endif\r
+
+static const char *gErrorMsg32Bit = "ERROR - A long is not 4 bytes. Are we running on a 64-bit machine?!\n";
\r
#ifdef PF_EMBEDDED\r
int main( void )\r
{\r
char IfInit = 0; \r
const char *DicName = NULL;\r
- const char *SourceName = NULL;\r
+ const char *SourceName = NULL;
+ // Check to make sure we are running in 32-bit mode.
+ if( sizeof(long) != 4 )
+ {
+ pfMessage(gErrorMsg32Bit);
+ return 1;
+ }\r
pfMessage("\npForth Embedded\n");\r
return pfDoForth( DicName, SourceName, IfInit);\r
}\r
char *s;\r
int32 i;\r
int Result;\r
-\r
+
+ // Check to make sure we are running in 32-bit mode.
+ if( sizeof(long) != 4 )
+ {
+ ERR((gErrorMsg32Bit));
+ return 1;
+ }
+ \r
/* For Metroworks on Mac */\r
#ifdef __MWERKS__\r
argc = ccommand(&argv);\r
: \ ( <line> -- , comment out rest of line )\r
EOL word drop\r
; immediate\r
+
+\ 1 echo ! \ Uncomment this line to echo Forth code while compiling.
\r
\ *********************************************************************\r
\ This is another style of comment that is common in Forth.\r
THEN\r
;\r
\r
-\ load remainder of dictionary\r
+\ Now that we can load from files, load remainder of dictionary.\r
\r
trace-include on\r
trace-stack on\r
\r
.( Dictionary compiled, save in "pforth.dic".) cr\r
c" pforth.dic" save-forth\r
-\r
+
+\ Save the dictionary in "pfdicdat.h" file so pForth can be compiled for standalone mode.\r
SDAD\r
\ MOD: PLB 9/9/88 Print U/S , add ADST\r
\ MOD: PLB 12/6/90 Modified to work with H4th\r
\ 941109 PLB Converted to pforth. Added RP detection.\r
+\ 090609 PLB Convert >rel to use->rel and ..! to s!\r
\r
-include? task-member member.fth\r
+include? task-member.fth member.fth\r
include? task-c_struct c_struct.fth\r
\r
ANEW TASK-DUMP_STRUCT\r
; immediate\r
\r
: ADST ( absolute_address -- , dump structure )\r
- >rel [compile] dst\r
+ use->rel [compile] dst \ mod 090609\r
; immediate\r
\r
\ For Testing Purposes\r
-false .IF\r
+false [IF]\r
:STRUCT GOO\r
LONG DATAPTR\r
SHORT GOO_WIDTH\r
\r
FOO AFOO\r
: AFOO.INIT\r
- $ 12345678 afoo ..! along1\r
- $ -665 afoo ..! ashort1\r
- $ 21 afoo ..! abyte\r
- $ 43 afoo ..! abyte2\r
- -234 afoo .. agoo ..! goo_height\r
+ $ 12345678 afoo s! along1\r
+ $ -665 afoo s! ashort1\r
+ $ 21 afoo s! abyte\r
+ $ 43 afoo s! abyte2\r
+ -234 afoo .. agoo s! goo_height\r
;\r
afoo.init\r
\r
dst foo\r
;\r
\r
-.THEN\r
+[THEN]\r
+\r
by Phil Burk\r
with Larry Polansky, David Rosenboom and Darren Gibbs.\r
\r
-Last updated: July 20, 2008 V23\r
-\r
-Documentation for pForth at http://www.softsynth.com/pforth/\r
-\r
+Last updated: Feb 20, 2009 V24\r
+
+Code for pForth is maintained on Google at:
+ http://code.google.com/p/pforth/
+ \r
+Documentation for pForth at:
+ http://www.softsynth.com/pforth/\r
+
+For technical support please use the pForth forum at:
+ http://groups.google.com/group/pforthdev
+ \r
The author is available for customization of pForth, porting to new\r
platforms, or developing pForth applications on a contractual basis.\r
-\r
-If interested, contact Phil Burk at http://www.softsynth.com/contacts.php\r
+If interested, contact Phil Burk at:
+ http://www.softsynth.com/contacts.php\r
\r
-- LEGAL NOTICE -----------------------------------------\r
\r
Documentation for pForth at http://www.softsynth.com/pforth/\r
\r
V?? \r
+ - Added -m32 to Makefile so we get 32 bit longs on Snow Leopard.
+ - Added "-x c" to Makefile CCOPTS to prevent confusion with C++
- Allow space after -d command line option.\r
- Restore normal tty mode if pForth dictionary loading fails.\r
\r