Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge pull request #1 from philburk/fix-readme #2

Merged
merged 6 commits into from
Mar 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 149 additions & 0 deletions build/mingw-crossbuild-linux/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# makefile for pForth
# Portable Forth written in 'C'
# by Phil Burk
# For more info visit http://www.softsynth.com/pforth/
#
# See "help" target below.

.POSIX:

# Options include: PF_SUPPORT_FP PF_NO_MALLOC PF_NO_INIT PF_DEBUG
# See "docs/pf_ref.htm" file for more info.

CC = x86_64-w64-mingw32-gcc
WINE = wineconsole
SRCDIR = ../..
PFORTHDIR = $(SRCDIR)
CSRCDIR = $(PFORTHDIR)/csrc
FTHDIR = $(PFORTHDIR)/fth

PFDICAPP = pforth.exe
PFORTHDIC = pforth.dic
PFDICDAT = pfdicdat.h
PFORTHAPP = pforth_standalone.exe

# This is needed to get pForth to build on Snow Leopard and other 64 bit platforms.
WIDTHOPT=

FULL_WARNINGS = \
--std=c89 \
-fsigned-char \
-fno-builtin \
-fno-unroll-loops \
-fpeephole \
-fno-keep-inline-functions \
-pedantic \
-Wcast-qual \
-Wall \
-Wwrite-strings \
-Winline \
-Wmissing-prototypes \
-Wmissing-declarations

DEBUGOPTS = -g
CCOPTS = $(WIDTHOPT) -x c -O2 $(FULL_WARNINGS) $(EXTRA_CCOPTS) $(DEBUGOPTS)

#IO_SOURCE = pf_io_posix.c
#IO_SOURCE = pf_io_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_win32.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:$(CSRCDIR)/win32_console:$(CSRCDIR)/win32

XCFLAGS = $(CCOPTS)
#XCPPFLAGS = -DPF_SUPPORT_FP -DWIN32
XCPPFLAGS = -DWIN32
XLDFLAGS = $(WIDTHOPT)

CPPFLAGS = -I. $(XCPPFLAGS)
CFLAGS = $(XCFLAGS)
LDFLAGS = $(XLDFLAGS)

COMPILE = $(CC) $(CFLAGS) $(CPPFLAGS)
LINK = $(CC) $(LDFLAGS)

.SUFFIXES: .c .o .eo

PFOBJS = $(PFSOURCE:.c=.o)
PFEMBOBJS = $(PFSOURCE:.c=.eo)

.c.o: $(PFINCLUDES)
$(COMPILE) -c -o $@ $<

.c.eo: $(PFINCLUDES) pfdicdat.h
$(COMPILE) $(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)
$(LINK) -o $@ $(PFOBJS) $(LDADD) -lm

# Build basic dictionary image by running newly built pforth and including "system.fth".
$(PFORTHDIC): $(PFDICAPP)
wd=$$(pwd); (cd $(FTHDIR); $(WINE) $${wd}/$(PFDICAPP) -i system.fth)
(cd $(FTHDIR); cat pforth.dic; rm -f pforth.dic) > $@

$(PFDICDAT): $(PFORTHDIC) $(PFDICAPP)
echo 'include $(FTHDIR)/savedicd.fth SDAD BYE'>load-dict-tmp.fth&& $(WINE) ./$(PFDICAPP) -d $(PFORTHDIC) load-dict-tmp.fth; rm -f load-dict-tmp.fth

$(PFORTHAPP): $(PFDICDAT) $(PFEMBOBJS)
$(LINK) -o $@ $(PFEMBOBJS) $(LDADD) -lm
@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)
4 changes: 2 additions & 2 deletions build/unix/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PFORTHAPP = pforth_standalone
WIDTHOPT=

FULL_WARNINGS = \
-c89 \
--std=c89 \
-fsigned-char \
-fno-builtin \
-fno-unroll-loops \
Expand Down Expand Up @@ -59,7 +59,7 @@ PFSOURCE = $(PFBASESOURCE) $(IO_SOURCE)
VPATH = .:$(CSRCDIR):$(CSRCDIR)/posix:$(CSRCDIR)/stdio:$(CSRCDIR)/win32_console:$(CSRCDIR)/win32

XCFLAGS = $(CCOPTS)
XCPPFLAGS = -DPF_SUPPORT_FP
XCPPFLAGS = -DPF_SUPPORT_FP -D_DEFAULT_SOURCE
XLDFLAGS = $(WIDTHOPT)

CPPFLAGS = -I. $(XCPPFLAGS)
Expand Down
2 changes: 1 addition & 1 deletion csrc/pf_save.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ cell_t ffSaveForth( const char *FileName, ExecToken EntryPoint, cell_t NameSize,
#ifndef PF_NO_FILEIO

/***************************************************************/
static uint32_t Read32FromFile( FileStream *fid, uint32_t *ValPtr )
static int32_t Read32FromFile( FileStream *fid, uint32_t *ValPtr )
{
int32_t numr;
uint8_t pad[4];
Expand Down
12 changes: 6 additions & 6 deletions csrc/win32_console/pf_io_win32_console.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ typedef enum ConsoleState_e
{
SDCONSOLE_STATE_IDLE = 0,
SDCONSOLE_STATE_GOT_ESCAPE,
SDCONSOLE_STATE_GOT_BRACKET,
SDCONSOLE_STATE_GOT_BRACKET

} ConsoleState;

Expand All @@ -44,8 +44,8 @@ static CONSOLE_SCREEN_BUFFER_INFO sScreenInfo;
/******************************************************************/
static void sdConsoleEmit( char c )
{
// Write a WCHAR in case we have compiled with Unicode support.
// Otherwise we will see '?' printed.
/* Write a WCHAR in case we have compiled with Unicode support.
* Otherwise we will see '?' printed.*/
WCHAR wc = (WCHAR) c;
DWORD count;
if( sIsConsoleValid )
Expand All @@ -54,7 +54,7 @@ static void sdConsoleEmit( char c )
}
else
{
// This will get called if we are redirecting to a file.
/* This will get called if we are redirecting to a file.*/
WriteFile(sConsoleHandle, &c, 1, &count, NULL );
}
}
Expand Down Expand Up @@ -215,12 +215,12 @@ void sdTerminalInit( void )
sConsoleHandle = GetStdHandle( STD_OUTPUT_HANDLE );
if( GetConsoleMode( sConsoleHandle, &mode ) )
{
//printf("GetConsoleMode() mode is 0x%08X\n", mode );
/*printf("GetConsoleMode() mode is 0x%08X\n", mode );*/
sIsConsoleValid = TRUE;
}
else
{
//printf("GetConsoleMode() failed\n", mode );
/*printf("GetConsoleMode() failed\n", mode );*/
sIsConsoleValid = FALSE;
}
}
Expand Down