From: Hannu Vuolasaho Date: Sat, 21 Feb 2015 01:44:05 +0000 (+0200) Subject: Sample crossbuild makefile X-Git-Url: http://git.subgeniuskitty.com/pforth/.git/commitdiff_plain/259625078859cb06e6cf02ddb5567c8a130d3821 Sample crossbuild makefile Crossbuild Makefile for building win32 without floating point support --- diff --git a/build/mingw-crossbuild-linux/Makefile b/build/mingw-crossbuild-linux/Makefile new file mode 100644 index 0000000..f6f8d68 --- /dev/null +++ b/build/mingw-crossbuild-linux/Makefile @@ -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) diff --git a/csrc/win32_console/pf_io_win32_console.c b/csrc/win32_console/pf_io_win32_console.c index d36a04c..a081812 100644 --- a/csrc/win32_console/pf_io_win32_console.c +++ b/csrc/win32_console/pf_io_win32_console.c @@ -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; @@ -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 ) @@ -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 ); } } @@ -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; } }