From 32fe084a178ac56eae2e543eba72d309185adba9 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 10 May 2011 18:18:19 +0000 Subject: Ported Ficl to NuttX apps/ git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3584 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 5 +- apps/interpreters/Makefile | 2 +- apps/interpreters/ficl/Makefile | 118 ++++++++++++++++++++++++++++++++++++ apps/interpreters/ficl/README.txt | 42 +++++++++++++ apps/interpreters/ficl/configure.sh | 47 ++++++++++++++ apps/interpreters/ficl/src/nuttx.c | 65 ++++++++++++++++++++ apps/interpreters/ficl/src/nuttx.h | 19 ++++++ nuttx/Documentation/NuttX.html | 2 + nuttx/Documentation/README.html | 6 +- nuttx/Makefile | 4 +- 10 files changed, 304 insertions(+), 6 deletions(-) create mode 100644 apps/interpreters/ficl/Makefile create mode 100755 apps/interpreters/ficl/README.txt create mode 100755 apps/interpreters/ficl/configure.sh create mode 100644 apps/interpreters/ficl/src/nuttx.c create mode 100644 apps/interpreters/ficl/src/nuttx.h diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index f78ae146b..9bdb87741 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -33,6 +33,7 @@ 6.3 2011-xx-xx Gregory Nutt - * apps/interpreter: Add a directory to hold interpreters. The Pascal add- + * apps/interpreter: Add a directory to hold interpreters. The Pascal add- on module now installs and builds under this directory. - + * apps/interpreter/ficl: Added logic to build Ficl (the "Forth Inspired + Command Language"). See http://ficl.sourceforge.net/. diff --git a/apps/interpreters/Makefile b/apps/interpreters/Makefile index bf27d79e8..1ef9c7439 100644 --- a/apps/interpreters/Makefile +++ b/apps/interpreters/Makefile @@ -37,7 +37,7 @@ # Sub-directories containing interpreter runtime -SUBDIRS = pcode +SUBDIRS = pcode ficl # Create the list of installed runtime modules (INSTALLED_DIRS) diff --git a/apps/interpreters/ficl/Makefile b/apps/interpreters/ficl/Makefile new file mode 100644 index 000000000..69cb4d504 --- /dev/null +++ b/apps/interpreters/ficl/Makefile @@ -0,0 +1,118 @@ +############################################################################ +# apps/interpreters/ficl/Makefile +# +# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +BUILDDIR := ${shell pwd | sed -e 's/ /\\ /g'} + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# Tools + +INCDIR = $(TOPDIR)/tools/incdir.sh + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Include paths + +CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(BUILDDIR)/$(FICL_SUBDIR) $(BUILDDIR)/src} + +# Source Files + +ASRCS = +CXXSRCS = +CSRCS = nuttx.c + +include Make.srcs + +ASRCS += $(FICL_ASRCS) +CXXSRCS += $(FICL_CXXSRCS) +CSRCS += $(FICL_CSRCS) + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOT_DEPPATH = --dep-path . +SRC_DEPPATH = --dep-path src + +VPATH = src:$(FICL_SUBDIR) + +all: .built +.PHONY: debug context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +debug: + @#echo "FICL: $(FICL_SUBDIR)" + @#echo "VPATH: $(VPATH)" + @#echo "CFLAGS: $(CFLAGS)" + +.built: debug $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +context: + +.depend: debug Makefile $(SRCS) + @$(MKDEP) $(ROOT_DEPPATH) $(SRC_DEPPATH) $(FICL_DEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/apps/interpreters/ficl/README.txt b/apps/interpreters/ficl/README.txt new file mode 100755 index 000000000..d775db1e8 --- /dev/null +++ b/apps/interpreters/ficl/README.txt @@ -0,0 +1,42 @@ +apps/interpreter/README.txt +=========================== + +Ficl is a programming language interpreter designed to be embedded into +other systems as a command, macro, and development prototyping language. +Ficl is an acronym for "Forth Inspired Command Language". See +http://ficl.sourceforge.net/ + +Build Instructions +------------------ + +Disclaimer: This installation steps have only been exercised using Ficl +4.1.0. With new versions you will likely have to make some adjustments +to this instructtions or to the files within this directory. This of this +information as "recommendations" -- not necessarily proven instructions. + +1. CD to apps/interpreters/ficl + +2. Download Ficl: http://sourceforge.net/projects/ficl/files/ + +3. Uznip the Ficl compressed file. + + For example, 'unzip ficl-4.1.0.zip' will leave the file + apps/interpreters/ficl/ficl-4.1.0 + +4. Configure to build Ficl in the apps/interpreters/ficl directory using + the configure.sh script. + + For example, './configure.sh ficl-4.1.0' will leave the Makefile + fragment 'Make.srcs' in the ficl build directory. + +5. Create your NuttX configuration. The appconfig file should include + (1) the path to your application code, and (2) the path to the Ficl + build directory. That latter would appear as the following line in + your appconfig file: + + CONFIGURED_APPS += interpreters/ficl + + 6. Configure and build NuttX. On successful completion, the Ficl objects + will be available in apps/libapps.a and that NuttX binary will be + linked against that file. Of course, Ficl will do nothing unless + you have written some application code that uses it! diff --git a/apps/interpreters/ficl/configure.sh b/apps/interpreters/ficl/configure.sh new file mode 100755 index 000000000..cadc1d48a --- /dev/null +++ b/apps/interpreters/ficl/configure.sh @@ -0,0 +1,47 @@ +#!/bin/bash + +USAGE="$0 " + +FICLDIR=$1 +if [ -z "${FICLDIR}" ]; then + echo "Missing command line argument" + echo $USAGE + exit 1 +fi + +if [ ! -d "${FICLDIR}" ]; then + echo "Sub-directory ${FICLDIR} does not exist" + echo $USAGE + exit 1 +fi + +if [ ! -r "${FICLDIR}/Makefile" ]; then + echo "Readable ${FICLDIR}/Makefile does not exist" + echo $USAGE + exit 1 +fi + +OBJECTS=`grep "^OBJECTS" ${FICLDIR}/Makefile` +if [ -z "${OBJECTS}" ]; then + echo "No OBJECTS found in ${FICLDIR}/Makefile" + echo $USAGE + exit 1 +fi + +OBJLIST=`echo ${OBJECTS} | cut -d'=' -f2 | sed -e "s/unix\.o//g"` + +rm -f Make.srcs +echo "# apps/interpreters/ficl/Make.obs" >> Make.srcs +echo "# Auto-generated file.. Do not edit" >> Make.srcs +echo "" >> Make.srcs +echo "FICL_SUBDIR = ${1}" >> Make.srcs +echo "FICL_DEPPATH = --dep-path ${1}" >> Make.srcs + +unset CSRCS +for OBJ in ${OBJLIST}; do + SRC=`echo ${OBJ} | sed -e "s/\.o/\.c/g"` + CSRCS=${CSRCS}" ${SRC}" +done +echo "FICL_ASRCS = " >> Make.srcs +echo "FICL_CXXSRCS = " >> Make.srcs +echo "FICL_CSRCS = ${CSRCS}" >> Make.srcs diff --git a/apps/interpreters/ficl/src/nuttx.c b/apps/interpreters/ficl/src/nuttx.c new file mode 100644 index 000000000..16b3fa1db --- /dev/null +++ b/apps/interpreters/ficl/src/nuttx.c @@ -0,0 +1,65 @@ +#include +#include + +#include +#include +#include + +#include "ficl.h" + +void *ficlMalloc(size_t size) +{ + return malloc(size); +} + +void *ficlRealloc(void *p, size_t size) +{ + return realloc(p, size); +} + +void ficlFree(void *p) +{ + free(p); +} + +void ficlCallbackDefaultTextOut(ficlCallback *callback, char *message) +{ + FICL_IGNORE(callback); + if (message != NULL) + fputs(message, stdout); + else + fflush(stdout); + return; +} + +int ficlFileStatus(char *filename, int *status) +{ + struct stat statbuf; + if (stat(filename, &statbuf) == 0) + { + *status = statbuf.st_mode; + return 0; + } + *status = ENOENT; + return -1; +} + +long ficlFileSize(ficlFile *ff) +{ + struct stat statbuf; + if (ff == NULL) + return -1; + + statbuf.st_size = -1; + if (fstat(fileno(ff->f), &statbuf) != 0) + return -1; + + return statbuf.st_size; +} + +void ficlSystemCompilePlatform(ficlSystem *system) +{ + return; +} + + diff --git a/apps/interpreters/ficl/src/nuttx.h b/apps/interpreters/ficl/src/nuttx.h new file mode 100644 index 000000000..e44031066 --- /dev/null +++ b/apps/interpreters/ficl/src/nuttx.h @@ -0,0 +1,19 @@ +#include + +typedef int8_t ficlInteger8; +typedef uint8_t ficlUnsigned8; +typedef int16_t ficlInteger16; +typedef uint16_t ficlUnsigned16; +typedef int32_t ficlInteger32; +typedef uint32_t ficlUnsigned32; + +typedef intptr_t ficlInteger; +typedef uintptr_t ficlUnsigned; +typedef float ficlFloat; + +#define FICL_PLATFORM_BASIC_TYPES (1) +#define FICL_PLATFORM_HAS_2INTEGER (0) +#define FICL_PLATFORM_HAS_FTRUNCATE (0) + +#define FICL_PLATFORM_OS "ansi" +#define FICL_PLATFORM_ARCHITECTURE "unknown" diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html index 391849996..57b0ccfde 100644 --- a/nuttx/Documentation/NuttX.html +++ b/nuttx/Documentation/NuttX.html @@ -2204,6 +2204,8 @@ apps-6.3 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> * apps/interpreter: Add a directory to hold interpreters. The Pascal add- on module now installs and builds under this directory. + * apps/interpreter/ficl: Added logic to build Ficl (the "Forth Inspired + Command Language"). See http://ficl.sourceforge.net/. pascal-3.0 2011-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr> diff --git a/nuttx/Documentation/README.html b/nuttx/Documentation/README.html index c753d654d..373f64192 100755 --- a/nuttx/Documentation/README.html +++ b/nuttx/Documentation/README.html @@ -8,7 +8,7 @@

NuttX README Files

-

Last Updated: May 9, 2010

+

Last Updated: May 10, 2010

@@ -184,11 +184,13 @@ | `- tools/ | `- README.txt `- apps/ + |- interpreters/ + | `- README.txt |- netutils/ | | |- telnetd/README.txt | `- README |- nshlib/ - | |- README.txt + | `- README.txt |- examples/ | |- pashello/README.txt | `- README.txt diff --git a/nuttx/Makefile b/nuttx/Makefile index b74f9e225..07c07ddec 100644 --- a/nuttx/Makefile +++ b/nuttx/Makefile @@ -268,7 +268,9 @@ include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig include/apps: Make.defs ifneq ($(APPDIR),) - @$(DIRLINK) $(TOPDIR)/$(APPDIR)/include include/apps + @if [ -d $(TOPDIR)/$(APPDIR)/include ]; then \ + $(DIRLINK) $(TOPDIR)/$(APPDIR)/include include/apps; \ + fi endif # Link the arch//include directory to include/arch -- cgit v1.2.3