README LOCAL README
NAME
README - installation information for the Fth package
INTRODUCTION
Fth is a software package which includes the interpreter fth and the
library libfth. You can write Forth scripts and interpret them with the
interpreter fth or you can link libfth into an application to use Fth as
extension language.
The core language of Fth is John Sadler's Forth-inspired command language
Ficl. Fth has some object type extensions, for example array, hash,
string, regexp, bignum, ratio etc.
WHERE IS FTH LOCATED?
You can get the latest archive from http://www.sf.net/projects/fth/. If
you prefer svn, you can get the source code from
svn.code.sf.net/p/fth/code/. Check out the source tree with
% svn co svn://svn.code.sf.net/p/fth/code/trunk fth
and update later with
% svn up
in the new fth directory.
REQUIREMENTS
Tecla
The interactive Fth interpreter supports tcsh-like command-line editing
and history manipulation with the tecla(7) library from
http://www.astro.caltech.edu/~mcs/tecla/libtecla-1.6.3.tar.gz. But you
may configure Fth without tecla(7), see CONFIGURE AND BUILD FTH WITH
SCONS.
64-Bit-NetBSD and Tecla
The libtecla package on NetBSD provides a static library libtecla.a. On
64-bit machines this package should be compiled with:
% cd /usr/pkgsrc/devel/libtecla
% env CFLAGS=-fPIC make install clean
CONFIGURE AND BUILD FTH WITH SCONS
If you have the python(1) package scons(1), you can config, build and
install Fth with Scons:
% scons install
or
% scons test install
You can set additional variables on the command line, see below for the
full set of variables:
% scons CC=clang CFLAGS='-fno-strict-aliasing' install
The Scons scripts in the Fth directory have the following extra command
line options. For full list, try:
% scons -h
--prefix=path
Installation prefix.
--build=path
Build path, default is ./build.
--tecla-prefix=path
Searches for tecla(7) in path/{include,lib}.
--program-prefix=string
--program-suffix=string
Prepends or appends string to the installed program and library
name. More than one version of fth may be installed at the same
time. You can have different names, for example:
% scons --prefix=/usr/local --program-suffix=-1.4 test
install
installs the interpreter as fth-1.4, the library as
libfth-1.4.so, creates a library path /usr/local/lib/fth-1.4 for
local dynamic libs and installs the header files in
/usr/local/include/fth-1.4:
/usr/local/bin/fth-1.4
/usr/local/lib/libfth-1.4.so
/usr/local/lib/fth-1.4/
/usr/local/include/fth-1.4/
--enable-warnings
Enables extra C compiler warning flags, default disabled.
--disable-shared
Disables shared library support, default enabled.
--verbose
Shows some statistics after configuring as well as after testing,
default disabled.
--without-tecla
Disables support for the tecla(7) command-line editing library,
default enabled.
Scons has the following targets:
install
Installs the Fth package.
test Tests the Fth package.
uninstall
Uninstalls all installed files.
% scons -c
is similar to `make clean'.
Scons handles command line variables. They can be mixed with command
line options as well:
% scons --prefix=/usr/opt CC=clang warnings=yes install
These variables can also be set in ${HOME}/.scons/fth.py as normal Python
variables. Strings have to be enclosed in single or double quotes
corresponding to Python's requirements.
% cat ~/.scons/fth.py
CC = 'clang'
CFLAGS = '-fno-strict-aliasing'
LDFLAGS = '-fuse-ld=lld -Wl,--no-rosegment -Wl,-znorelro -Wl,-L/usr/lib'
Here is the full list of variables:
CC=string
C Compiler, default is cc.
CFLAGS=string
Additional CFLAGS, default is empty.
LDFLAGS=string
Additional LDFLAGS, default is empty.
build=path
Build path, default is ./build.
prefix=path
Installation prefix.
program_prefix=string
program_suffix=string
Prepends or appends string to the fth program and library. See
above at --program-{prefix,suffix} for an example.
tecla_prefix=path
Searches for tecla(7) in path/{include,lib}.
libtecla={yes,no}
Enables or disables support for the tecla(7) command-line editing
library, default yes (enabled).
shared={yes,no}
Enables or disables shared library support, default yes
(enabled).
verbose={yes,no}
If yes, shows some statistics after configuration as well as
after testing, default no.
warnings={yes,no}
Enables or disables extra C compiler warning flags, default no.
CONFIGURE AND BUILD FTH THE OLD WAY
You may also configure and install Fth this way:
% ./configure
% make
% make test # optional
% make install
There are a few additional configure options which may be of interest.
See CONFIGURE AND BUILD FTH WITH SCONS for an explanations of them. For
more, try:
% ./configure -h
--prefix path
--with-tecla-prefix path
--program-prefix string
--program-suffix string
--enable-warnings
--enable-maintainer-mode
--disable-shared
--without-tecla
The following make targets are provided:
all
clean
distclean
fth-shared
fth-static
install
install-shared
install-static
install-strip
maintainer-clean
test
uninstall
Testing with
% make test
checks two environment variables:
FTH_TEST_IO
FTH_TEST_FILE
If set, the IO and File tests will be executed. These two tests may have
problems on some systems so they are disabled by default.
AUTOCONF MACRO FTH_CHECK_LIB
An application using the Fth package as extension language can detect
program and library using the autoconf(1) macro FTH_CHECK_LIB which is
located in fth.m4. This macro tests if the interpreter fth can be found
in PATH. If so, it tests if libfth contains complex and rational
numbers. Eventually it substitutes six variables for configure.ac.
After including FTH_CHECK_LIB in configure.ac call:
% aclocal && autoconf
to update aclocal.m4.
FTH Set to full path of the interpreter or no.
FTH_VERSION
Set to version number of the Fth package or no.
FTH_CFLAGS
Set to include path or no.
FTH_LIBS
Set to library path and library or no.
FTH_HAVE_COMPLEX
Set to yes or no.
FTH_HAVE_RATIO
Set to yes or no.
Short configure.ac Example
AC_ARG_WITH([forth],
[AS_HELP_STRING([--with-forth],
[use Forth as the extension language])],
[if test "$withval" = yes ; then
FTH_CHECK_LIB([AC_DEFINE([HAVE_FORTH])])
fi])
Long configure.ac Example
AC_ARG_WITH([forth],
[AS_HELP_STRING([--with-forth],
[use Forth as the extension language])],
[if test "$withval" = yes ; then
FTH_CHECK_LIB([AC_DEFINE([HAVE_FORTH])
AC_DEFINE([HAVE_EXTENSION_LANGUAGE])
if test "$FTH_HAVE_COMPLEX" = yes ; then
AC_DEFINE([HAVE_COMPLEX_TRIG])
AC_DEFINE([HAVE_MAKE_COMPLEX])
AC_DEFINE([HAVE_MAKE_RECTANGULAR])
fi
if test "$FTH_HAVE_RATIO" = yes ; then
AC_DEFINE([HAVE_MAKE_RATIO])
fi
AC_SUBST(XEN_CFLAGS, $FTH_CFLAGS)
AC_SUBST(XEN_LIBS, $FTH_LIBS)
LOCAL_LANGUAGE="Forth"
ac_snd_have_extension_language=yes])
fi])