Add -m32 and -x c to Makefile for 64-bit Snow Leopard.
authorphil@softsynth.com <phil@softsynth.com@b0a0988d-7f52-0410-8c73-4f6cdee1a2cf>
Thu, 8 Oct 2009 20:36:22 +0000 (20:36 +0000)
committerphil@softsynth.com <phil@softsynth.com@b0a0988d-7f52-0410-8c73-4f6cdee1a2cf>
Thu, 8 Oct 2009 20:36:22 +0000 (20:36 +0000)
build/unix/Makefile
csrc/pf_core.c
csrc/pf_main.c
fth/system.fth
fth/utils/dump_struct.fth
readme.txt
releases.txt

index 2408291..a7dbb5d 100644 (file)
@@ -2,7 +2,9 @@
 # Portable Forth written in 'C'
 # by Phil Burk
 # For more info visit http://www.softsynth.com/pforth/
 # 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
 .SUFFIXES: .c .o
 
 # Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
@@ -21,6 +23,9 @@ PFORTHAPP    = $(PFORTHDIR)/pforth_standalone
 OBJECTDIR    = $(PFORTHDIR)/objects
 TEMPOBJECTDIR = $(PFORTHDIR)/tempobjects
 
 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 \
 FULL_WARNINGS =  \
         -fsigned-char \
         -fno-builtin \
@@ -34,7 +39,8 @@ FULL_WARNINGS =  \
         -Wmissing-prototypes \
         -Wmissing-declarations
         
         -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
 
 IO_SOURCE = ${CSRCDIR}/posix/pf_io_posix.c
 #IO_SOURCE = ${CSRCDIR}/stdio/pf_io_stdio.c
@@ -80,21 +86,38 @@ ${OBJECTDIR}:
        mkdir -p ${OBJECTDIR}/posix
        mkdir -p ${OBJECTDIR}/stdio
 
        mkdir -p ${OBJECTDIR}/posix
        mkdir -p ${OBJECTDIR}/stdio
 
-# build pforth by compiling 'C' source
+# Build pforth by compiling 'C' source.
 $(PFDICAPP): $(PFINCLUDES) $(PFOBJS)
 $(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)
 
 $(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)"
        
        @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)
 clean:
        -rm -f $(PFOBJS) $(PFEMBOBJS)
        -rm $(PFORTHAPP)
index 497b7e0..740d942 100644 (file)
@@ -427,7 +427,7 @@ void pfMessage( const char *CString )
 }\r
 \r
 /**************************************************************************\r
 }\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
 */\r
 int32 pfDoForth( const char *DicFileName, const char *SourceName, int32 IfInit )\r
 {\r
@@ -435,7 +435,6 @@ int32 pfDoForth( const char *DicFileName, const char *SourceName, int32 IfInit )
        pfDictionary_t *dic = NULL;\r
        int32 Result = 0;\r
        ExecToken  EntryPoint = 0;\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
 \r
 #ifdef PF_USER_INIT\r
        Result = PF_USER_INIT;\r
index a779560..6b07f33 100644 (file)
 #define TRUE (1)\r
 #define FALSE (0)\r
 #endif\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
 \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
     pfMessage("\npForth Embedded\n");\r
     return pfDoForth( DicName, SourceName, IfInit);\r
 }\r
@@ -68,7 +76,14 @@ int main( int argc, char **argv )
        char *s;\r
        int32 i;\r
        int Result;\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
 /* For Metroworks on Mac */\r
 #ifdef __MWERKS__\r
        argc = ccommand(&argv);\r
index c83136d..01b779d 100644 (file)
@@ -17,6 +17,8 @@
 : \ ( <line> -- , comment out rest of line )\r
         EOL word drop\r
 ; immediate\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
 \r
 \ *********************************************************************\r
 \ This is another style of comment that is common in Forth.\r
@@ -809,7 +811,7 @@ auto.init
     THEN\r
 ;\r
 \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
 trace-include on\r
 trace-stack on\r
@@ -823,5 +825,6 @@ FREEZE    \ prevent forgetting below this point
 \r
 .( Dictionary compiled, save in "pforth.dic".) cr\r
 c" pforth.dic" save-forth\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
 SDAD\r
index b7fd173..39a32c0 100644 (file)
@@ -9,8 +9,9 @@
 \ 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
 \ 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
 \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
 include? task-c_struct c_struct.fth\r
 \r
 ANEW TASK-DUMP_STRUCT\r
@@ -84,11 +85,11 @@ VARIABLE DS-ADDR
 ; immediate\r
 \r
 : ADST ( absolute_address -- , dump structure )\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
 ; immediate\r
 \r
 \ For Testing Purposes\r
-false .IF\r
+false [IF]\r
 :STRUCT GOO\r
     LONG DATAPTR\r
     SHORT GOO_WIDTH\r
 :STRUCT GOO\r
     LONG DATAPTR\r
     SHORT GOO_WIDTH\r
@@ -105,11 +106,11 @@ false .IF
 \r
 FOO AFOO\r
 : AFOO.INIT\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
 ;\r
 afoo.init\r
 \r
@@ -117,4 +118,5 @@ afoo.init
     dst foo\r
 ;\r
 \r
     dst foo\r
 ;\r
 \r
-.THEN\r
+[THEN]\r
+\r
index b33c7d9..569a836 100644 (file)
@@ -3,14 +3,21 @@ README for pForth - a Portable ANS-like Forth written in ANSI 'C'
 by Phil Burk\r
 with Larry Polansky, David Rosenboom and Darren Gibbs.\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
 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
 \r
 -- LEGAL NOTICE -----------------------------------------\r
 \r
index f89773b..59e7752 100644 (file)
@@ -3,6 +3,8 @@ Release History for pForth - a Portable ANS-like Forth written in ANSI 'C'
 Documentation for pForth at http://www.softsynth.com/pforth/\r
 \r
 V?? \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
        - Allow space after -d command line option.\r
        - Restore normal tty mode if pForth dictionary loading fails.\r
         \r