From 970d32b553a44051cedd2caf34267b7b1cdbab78 Mon Sep 17 00:00:00 2001 From: "phil@softsynth.com" Date: Thu, 8 Oct 2009 20:36:22 +0000 Subject: [PATCH] Add -m32 and -x c to Makefile for 64-bit Snow Leopard. --- build/unix/Makefile | 41 ++++++++++++++++++++++++++++++--------- csrc/pf_core.c | 3 +-- csrc/pf_main.c | 19 ++++++++++++++++-- fth/system.fth | 7 +++++-- fth/utils/dump_struct.fth | 20 ++++++++++--------- readme.txt | 19 ++++++++++++------ releases.txt | 2 ++ 7 files changed, 81 insertions(+), 30 deletions(-) diff --git a/build/unix/Makefile b/build/unix/Makefile index 2408291..a7dbb5d 100644 --- a/build/unix/Makefile +++ b/build/unix/Makefile @@ -2,7 +2,9 @@ # Portable Forth written in 'C' # by Phil Burk # For more info visit http://www.softsynth.com/pforth/ - +# +# See "help" target below. + .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 +# This is needed to get pForth to build on Snow Leopard and other 64 bit platforms. +WIDTHOPT=-m32 + FULL_WARNINGS = \ -fsigned-char \ -fno-builtin \ @@ -34,7 +39,8 @@ FULL_WARNINGS = \ -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 @@ -80,21 +86,38 @@ ${OBJECTDIR}: 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) diff --git a/csrc/pf_core.c b/csrc/pf_core.c index 497b7e0..740d942 100644 --- a/csrc/pf_core.c +++ b/csrc/pf_core.c @@ -427,7 +427,7 @@ void pfMessage( const char *CString ) } /************************************************************************** -** Main entry point for pForth +** Main entry point for pForth. */ int32 pfDoForth( const char *DicFileName, const char *SourceName, int32 IfInit ) { @@ -435,7 +435,6 @@ int32 pfDoForth( const char *DicFileName, const char *SourceName, int32 IfInit ) pfDictionary_t *dic = NULL; int32 Result = 0; ExecToken EntryPoint = 0; - #ifdef PF_USER_INIT Result = PF_USER_INIT; diff --git a/csrc/pf_main.c b/csrc/pf_main.c index a779560..6b07f33 100644 --- a/csrc/pf_main.c +++ b/csrc/pf_main.c @@ -43,13 +43,21 @@ #define TRUE (1) #define FALSE (0) #endif + +static const char *gErrorMsg32Bit = "ERROR - A long is not 4 bytes. Are we running on a 64-bit machine?!\n"; #ifdef PF_EMBEDDED int main( void ) { char IfInit = 0; const char *DicName = NULL; - const char *SourceName = NULL; + const char *SourceName = NULL; + // Check to make sure we are running in 32-bit mode. + if( sizeof(long) != 4 ) + { + pfMessage(gErrorMsg32Bit); + return 1; + } pfMessage("\npForth Embedded\n"); return pfDoForth( DicName, SourceName, IfInit); } @@ -68,7 +76,14 @@ int main( int argc, char **argv ) char *s; int32 i; int Result; - + + // Check to make sure we are running in 32-bit mode. + if( sizeof(long) != 4 ) + { + ERR((gErrorMsg32Bit)); + return 1; + } + /* For Metroworks on Mac */ #ifdef __MWERKS__ argc = ccommand(&argv); diff --git a/fth/system.fth b/fth/system.fth index c83136d..01b779d 100644 --- a/fth/system.fth +++ b/fth/system.fth @@ -17,6 +17,8 @@ : \ ( -- , comment out rest of line ) EOL word drop ; immediate + +\ 1 echo ! \ Uncomment this line to echo Forth code while compiling. \ ********************************************************************* \ This is another style of comment that is common in Forth. @@ -809,7 +811,7 @@ auto.init THEN ; -\ load remainder of dictionary +\ Now that we can load from files, load remainder of dictionary. trace-include on trace-stack on @@ -823,5 +825,6 @@ FREEZE \ prevent forgetting below this point .( Dictionary compiled, save in "pforth.dic".) cr c" pforth.dic" save-forth - + +\ Save the dictionary in "pfdicdat.h" file so pForth can be compiled for standalone mode. SDAD diff --git a/fth/utils/dump_struct.fth b/fth/utils/dump_struct.fth index b7fd173..39a32c0 100644 --- a/fth/utils/dump_struct.fth +++ b/fth/utils/dump_struct.fth @@ -9,8 +9,9 @@ \ MOD: PLB 9/9/88 Print U/S , add ADST \ MOD: PLB 12/6/90 Modified to work with H4th \ 941109 PLB Converted to pforth. Added RP detection. +\ 090609 PLB Convert >rel to use->rel and ..! to s! -include? task-member member.fth +include? task-member.fth member.fth include? task-c_struct c_struct.fth ANEW TASK-DUMP_STRUCT @@ -84,11 +85,11 @@ VARIABLE DS-ADDR ; immediate : ADST ( absolute_address -- , dump structure ) - >rel [compile] dst + use->rel [compile] dst \ mod 090609 ; immediate \ For Testing Purposes -false .IF +false [IF] :STRUCT GOO LONG DATAPTR SHORT GOO_WIDTH @@ -105,11 +106,11 @@ false .IF FOO AFOO : AFOO.INIT - $ 12345678 afoo ..! along1 - $ -665 afoo ..! ashort1 - $ 21 afoo ..! abyte - $ 43 afoo ..! abyte2 - -234 afoo .. agoo ..! goo_height + $ 12345678 afoo s! along1 + $ -665 afoo s! ashort1 + $ 21 afoo s! abyte + $ 43 afoo s! abyte2 + -234 afoo .. agoo s! goo_height ; afoo.init @@ -117,4 +118,5 @@ afoo.init dst foo ; -.THEN +[THEN] + diff --git a/readme.txt b/readme.txt index b33c7d9..569a836 100644 --- a/readme.txt +++ b/readme.txt @@ -3,14 +3,21 @@ README for pForth - a Portable ANS-like Forth written in ANSI 'C' by Phil Burk with Larry Polansky, David Rosenboom and Darren Gibbs. -Last updated: July 20, 2008 V23 - -Documentation for pForth at http://www.softsynth.com/pforth/ - +Last updated: Feb 20, 2009 V24 + +Code for pForth is maintained on Google at: + http://code.google.com/p/pforth/ + +Documentation for pForth at: + http://www.softsynth.com/pforth/ + +For technical support please use the pForth forum at: + http://groups.google.com/group/pforthdev + The author is available for customization of pForth, porting to new platforms, or developing pForth applications on a contractual basis. - -If interested, contact Phil Burk at http://www.softsynth.com/contacts.php +If interested, contact Phil Burk at: + http://www.softsynth.com/contacts.php -- LEGAL NOTICE ----------------------------------------- diff --git a/releases.txt b/releases.txt index f89773b..59e7752 100644 --- a/releases.txt +++ b/releases.txt @@ -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/ V?? + - 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. - Restore normal tty mode if pForth dictionary loading fails. -- 2.20.1