aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog12
-rw-r--r--INSTALL50
-rw-r--r--Makefile.in53
-rw-r--r--Makefile.pamphlet70
-rw-r--r--TODO9
-rw-r--r--config/open-axiom.m418
-rw-r--r--config/openaxiom-c-macros.h.in3
-rw-r--r--config/setup-dep.mk12
-rw-r--r--config/var-def.mk9
-rwxr-xr-xconfigure179
-rw-r--r--configure.ac12
-rw-r--r--src/ChangeLog13
-rw-r--r--src/Makefile.in9
-rw-r--r--src/Makefile.pamphlet9
-rw-r--r--src/algebra/Makefile.in12
-rw-r--r--src/algebra/Makefile.pamphlet14
-rw-r--r--src/etc/Makefile.in2
-rw-r--r--src/graph/Makefile.in4
-rw-r--r--src/input/Makefile.in4
-rw-r--r--src/input/Makefile.pamphlet4
-rw-r--r--src/interp/Makefile.in4
-rw-r--r--src/interp/Makefile.pamphlet4
-rw-r--r--src/utils/Makefile.in77
-rw-r--r--src/utils/hammer.cc414
-rw-r--r--src/utils/storage.H87
-rw-r--r--src/utils/storage.cc175
26 files changed, 889 insertions, 370 deletions
diff --git a/ChangeLog b/ChangeLog
index 34b609ad..384da487 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2010-08-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ External tool noweb is no longer required.
+ * INSTALL: Update instructions.
+ * Makefile.pamphlet: Remove rules for building noweb.
+ (AXIOM_SRC_TARGETS): Include all-utils.
+ * config/open-axiom.m4 (OPENAXIOM_BUILD_TOOLS): Don't check for
+ notangle and noweave.
+ * config/setup-dep.mk: Remove rules for generating document.
+ * config/var-def.mk: Remove NOTANGLE and NOWEAVE variables.
+ * configure.ac: Instantiate Makefile for src/utils.
+
2010-08-18 Gabriel Dos Reis <gdr@cs.tamu.edu>
* config/open-axiom.m4 (OPENAXIOM_CPPFLAGS_FOR_VENDOR_LOCK_INS):
diff --git a/INSTALL b/INSTALL
index 7ab9d234..0b8b9815 100644
--- a/INSTALL
+++ b/INSTALL
@@ -5,32 +5,27 @@ OpenAxiom currenly requires a Lisp system for its runtime support.
OpenAxiom is known to build with the GNU Common Lisp (GCL versions 2.6.7
or 2.6.8), Steel Bank Common Lisp (SBCL version 1.0.22 or higher,
except 1.0.29), CLisp (version 2.44.x or higher), and ECL (version
-0.9l or higher). So, if you already have any of the above mentioned
-Lisp systems, your are good to go. Otherwise, you would need to
-download a dependency tarball from OpenAxiom's download web site. See
-instructions below.
+0.9l or higher), Clozure CL (version 1.3 or higher). So, if you
+already have any of the above mentioned Lisp systems, your are good to
+go. Otherwise, you would need to download a dependency tarball from
+OpenAxiom's download web site. See instructions below.
-OpenAxiom needs `noweb' for extracting its source codes. If you don't
-have running `noweb' utilities, you would need to either download the
-dependency tarball from OpenAxiom's download web site, or separately
-install them, and then proceed with configuration as detailed below.
+Note that a functional Lisp system (e.g. SBCL, GCL, CLisp, ECL, or
+Clozure CL) ir needed only to build OpenAxiom. They are not needed
+once the system is installed.
-Note that GCL or SBCL or CLisp, and `noweb' are needed only to build
-OpenAxiom. They are not needed once the system is installed.
-
-Finally, you would need a working GNU C compiler. It is also recommended
+Finally, you would need working C and C++ compilers -- you need
+compilers from GNU if you plan on using GCL. It is also recommended
that you install X11 development headers and libraries, especially
-Xpm. Windows (MingW/MSYS) users do not need X11 components. They
-still need a working GNU C compiler though.
+Xpm. Windows (MingW/MSYS) users do not need X11 components.
Ah, one more note: OpenAxiom requires GNU Make.
-1. Lisp and noweb prerequisites
- ----------------------------
+1. Lisp prerequisite
+ -----------------
-If any of GCL or noweb is missing from your build environment, then
-you need to either separately install them, or download the dependency
-tarball
+If you are missing a Lisp system, you need to get one, either
+separately install it, or download the dependency tarball
open-axiom-1.3.x-dep.tar.bz2
@@ -38,12 +33,7 @@ from the SourceForge download site
http://voxel.dl.sourceforge.net/sourceforge/open-axiom/open-axiom-1.3.x-dep.tar.bz2
-Please, notice that GCL and noweb are needed only to *build*
-OpenAxiom. If you plan to build OpenAxiom often, then it probably is
-a good idea to separately build and install those tools once for all.
-
-
-If you already have GCL and noweb installed, please go to step 2.
+If you already have a Lisp system installed, please go to step 2.
Note however that if you want to build OpenAxiom with the GCL from
the dependency tarball (assuming you have unpacked it as explained
in step 1.b.), and you have other Lisp systems available in the build
@@ -69,9 +59,9 @@ named open-axiom-1.3.x. Rename it to open-axiom-1.3.0, e.g.:
It is assumed you have already downloaded open-axiom source tarball,
e.g. open-axiom-1.3.0.tar.bz2.
-Note: If you don't have GCL or noweb in the build environment, please
+Note: If you don't have a Lisp system in the build environment, please
make sure that you have either followed the instructions in step 1.,
-or have separately installed them before proceeding.
+or have separately installed one before proceeding.
2.a. Decompress the OpenAxiom source tarball
@@ -175,10 +165,8 @@ OpenAxiom build system requires GNU Make. It might theoretically be
possible to cram the Makefiles so that they can work with a large set
of Make programs. However, doing so will not be cost effective. GNU
Make has been ported to virtually any system current OpenAxiom can build
-one. In particular, OpenAxiom uses GCL, which in turns requires GCC.
-GCC requires GNU Make. GCL too requires GNU Make. Consequently,
-the GNU Make requirement is not a stringent requirement. It just
-reflects reality.
+one. Consequently, the GNU Make requirement is not a stringent
+requirement. It just reflects reality.
So, if you're using a system where "make" is not GNU Make, then try
"gmake" instead.
diff --git a/Makefile.in b/Makefile.in
index bfa02570..1614c07d 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -16,7 +16,7 @@ build_srcdir = $(builddir)/src
AXIOM_SRC_TARGETS = all-algebra all-asq all-axiomsys all-boot all-share \
all-clef all-doc all-graph all-hyper all-input all-interpsys \
- all-lib all-lisp all-sman all-driver all-src all-databases
+ all-lib all-lisp all-sman all-driver all-src all-databases all-utils
.PHONY: all $(AXIOM_SRC_TARGETS)
all: all-ax
@@ -39,58 +39,10 @@ $(AXIOM_SRC_TARGETS):
all-algstrap:
cd src/algebra && $(MAKE) $@
-stamp-rootdirs: $(axiom_build_document)
- @mkdir -p "${TMP}"
+stamp-rootdirs:
@$(STAMP) stamp-rootdirs
-.PHONY: all-noweb
-all-noweb: $(axiom_build_bindir)/notangle
-
-.PHONY: maybe-cp-noweb-srcdir
-maybe-cp-noweb-srcdir: $(srcdir)/noweb
- ## Even though out-of-source build is what we recommend,
- ## noweb does not directly support that sort of build.
- ## So we copy the source to the build directory.
- ## We try to be nice to those who chose otherwise
- ## to build directly from the OpenAxiom source dir.
- if test "$(srcdir)" != "$(builddir)" -a ! -d noweb; then \
- cp -r "$(srcdir)"/noweb "$(builddir)"; \
- fi
-
-$(addprefix $(axiom_build_bindir)/, notangle noweave): maybe-cp-noweb-srcdir
- ## Noweb would like to install many things even if we
- ## are not interested in those. Prepare the ground.
- $(mkdir_p) "$(axiom_build_bindir)"
- $(mkdir_p) "$(axiom_build_libdir)"
- $(mkdir_p) "$(axiom_build_texdir)"
- $(mkdir_p) "$(axiom_build_mandir)"
- $(TOUCH) $(addprefix noweb/src/shell/, \
- noweave notangle noweb noroff toroff) \
- $(wildcard "$(builddir)"/noweb/src/c/*.h) \
- $(wildcard "$(builddir)"/noweb/src/c/*.c)
- ## noweb's Makefile needs editing before we can build to suit
- ## our needs. In particular, we must say when helper programs go,
- ## where the noweb style file goes, where the man pages go (even though
- ## in this specific context, they are not needed). Finally,
- ## noweb insists on running `texhash' after installation, which is
- ## of no practical value for us in ths specific context. We must
- ## convince it not to go there.
- cd noweb/src && \
- cat Makefile \
- | sed -e "s,^BIN=.*,BIN=$(axiom_abs_build_bindir)," \
- -e "s,^LIB=.*,LIB=$(axiom_abs_build_libdir)," \
- -e "s,^MAN=.*,MAN=$(axiom_abs_build_mandir)," \
- -e "s,^TEXINPUTS=.*,TEXINPUTS=$(axiom_abs_build_texdir)," \
- -e "s, make , $$\(MAKE\) ," \
- -e "s,c/nt,c/nt$(EXEEXT)," \
- -e "s,c/markup,c/markup$(EXEEXT)," \
- -e "s,c/mnt,c/mnt$(EXEEXT)," \
- -e "s,c/finduses,c/finduses$(EXEEXT)," \
- -e "s/-texhash.*/:/" \
- -e "s/ install-elisp//" \
- > Makefile.tmp && mv Makefile.tmp Makefile && \
- ./awkname $(AWK) && $(MAKE) all install
.PHONY: all-gcl
all-gcl: $(axiom_build_bindir)/gcl$(EXEEXT)
@@ -119,7 +71,6 @@ mostlyclean-local:
@-rm -f lastBuildDate
clean-local: mostlyclean-local
- @rm -fr "$(axiom_build_nowebdir)"
@ rm -f stamp-*
@ rm -rf int
diff --git a/Makefile.pamphlet b/Makefile.pamphlet
index 110dd3a5..bb839772 100644
--- a/Makefile.pamphlet
+++ b/Makefile.pamphlet
@@ -246,10 +246,6 @@ intricate to describe.
This description is STILL IN WORK IN PROGRESS. Therefore it is
incorrekt, incomplet, and iNconSiStenT.
-First of all \Tool{noweb} is needed to extract source codes from the
-documentation. Almost everything depends on \Tool{noweb} --- the exception
-being possible build of \Tool{GCL}.
-
Second, we need a Lisp runtime system. If one is available from
the build environment, we are done. In fact, currently we do insist that
the Lisp runtime system is \Tool{GCL}.
@@ -322,7 +318,7 @@ build_srcdir = $(builddir)/src
AXIOM_SRC_TARGETS = all-algebra all-asq all-axiomsys all-boot all-share \
all-clef all-doc all-graph all-hyper all-input all-interpsys \
- all-lib all-lisp all-sman all-driver all-src all-databases
+ all-lib all-lisp all-sman all-driver all-src all-databases all-utils
.PHONY: all $(AXIOM_SRC_TARGETS)
all: all-ax
@@ -347,7 +343,6 @@ all-algstrap:
<<rootdirs>>
-<<noweb>>
<<gcl>>
<<install>>
@@ -360,7 +355,6 @@ mostlyclean-local:
@-rm -f lastBuildDate
clean-local: mostlyclean-local
- @rm -fr "$(axiom_build_nowebdir)"
@ rm -f stamp-*
@ rm -rf int
@@ -459,8 +453,7 @@ Note that the -p (parent) option to mkdir will make all intermediate
directories as well if they don't exist.
<<rootdirs>>=
-stamp-rootdirs: $(axiom_build_document)
- @mkdir -p "${TMP}"
+stamp-rootdirs:
@$(STAMP) stamp-rootdirs
@
@@ -505,65 +498,6 @@ $(axiom_build_bindir)/gcl$(EXEEXT):
$(MAKE) && $(MAKE) install
@
-
-\subsection{\Tool{noweb}}
-
-When \Tool{noweb} is not available from the build environment
-and a \Tool{noweb} source files a present in a top level directory
-named \File{noweb}, we use those source file to build the executable
-necessary to extract codes and documentations.
-%
-<<noweb>>=
-.PHONY: all-noweb
-all-noweb: $(axiom_build_bindir)/notangle
-
-.PHONY: maybe-cp-noweb-srcdir
-maybe-cp-noweb-srcdir: $(srcdir)/noweb
- ## Even though out-of-source build is what we recommend,
- ## noweb does not directly support that sort of build.
- ## So we copy the source to the build directory.
- ## We try to be nice to those who chose otherwise
- ## to build directly from the OpenAxiom source dir.
- if test "$(srcdir)" != "$(builddir)" -a ! -d noweb; then \
- cp -r "$(srcdir)"/noweb "$(builddir)"; \
- fi
-
-$(addprefix $(axiom_build_bindir)/, notangle noweave): maybe-cp-noweb-srcdir
- ## Noweb would like to install many things even if we
- ## are not interested in those. Prepare the ground.
- $(mkdir_p) "$(axiom_build_bindir)"
- $(mkdir_p) "$(axiom_build_libdir)"
- $(mkdir_p) "$(axiom_build_texdir)"
- $(mkdir_p) "$(axiom_build_mandir)"
- $(TOUCH) $(addprefix noweb/src/shell/, \
- noweave notangle noweb noroff toroff) \
- $(wildcard "$(builddir)"/noweb/src/c/*.h) \
- $(wildcard "$(builddir)"/noweb/src/c/*.c)
- ## noweb's Makefile needs editing before we can build to suit
- ## our needs. In particular, we must say when helper programs go,
- ## where the noweb style file goes, where the man pages go (even though
- ## in this specific context, they are not needed). Finally,
- ## noweb insists on running `texhash' after installation, which is
- ## of no practical value for us in ths specific context. We must
- ## convince it not to go there.
- cd noweb/src && \
- cat Makefile \
- | sed -e "s,^BIN=.*,BIN=$(axiom_abs_build_bindir)," \
- -e "s,^LIB=.*,LIB=$(axiom_abs_build_libdir)," \
- -e "s,^MAN=.*,MAN=$(axiom_abs_build_mandir)," \
- -e "s,^TEXINPUTS=.*,TEXINPUTS=$(axiom_abs_build_texdir)," \
- -e "s, make , $$\(MAKE\) ," \
- -e "s,c/nt,c/nt$(EXEEXT)," \
- -e "s,c/markup,c/markup$(EXEEXT)," \
- -e "s,c/mnt,c/mnt$(EXEEXT)," \
- -e "s,c/finduses,c/finduses$(EXEEXT)," \
- -e "s/-texhash.*/:/" \
- -e "s/ install-elisp//" \
- > Makefile.tmp && mv Makefile.tmp Makefile && \
- ./awkname $(AWK) && $(MAKE) all install
-@
-
-
\subsection{install}
<<install>>=
.PHONY: install
diff --git a/TODO b/TODO
index 05e9f0b0..fd4145fb 100644
--- a/TODO
+++ b/TODO
@@ -21,8 +21,6 @@
* Better support on Windows platform (MinGW/MSYS)
* Modernize algebras
* Better documentations
-* Find better documentation tools and formats that do not get in
- the way of building the system on more platforms.
* Interfaces to mainstream programming languages
* Improve Boot, Spad
* Integrate to development environments
@@ -58,6 +56,13 @@
=== DONE ===
============
+* Remove dependency on noweb.
+
+* The installed system no longer requires AWK.
+
+* Find better documentation tools and formats that do not get in
+ the way of building the system on more platforms.
+
* FFI support for Spad
* Revisit the underlying definition of the types DFlo in foam
diff --git a/config/open-axiom.m4 b/config/open-axiom.m4
index e888c971..a2e26e8b 100644
--- a/config/open-axiom.m4
+++ b/config/open-axiom.m4
@@ -573,21 +573,6 @@ case $build in
fi
;;
esac
-
-## Make sure noweb executable is available
-AC_CHECK_PROGS([NOTANGLE], [notangle])
-AC_CHECK_PROGS([NOWEAVE], [noweave])
-## In case noweb is missing we need to build our own.
-if test -z "$NOTANGLE" -o -z "$NOWEAVE" ; then
- ## Yes, but do we have the source files to build from?
- if test ! -d ${srcdir}/noweb; then
- AC_MSG_NOTICE([OpenAxiom requires noweb utilties])
- AC_MSG_ERROR([Please get the tarball of dependencies and reconfigure])
- fi
- NOTANGLE='$(axiom_build_bindir)/notangle'
- NOWEAVE='$(axiom_build_bindir)/noweave'
- oa_all_prerequisites="$oa_all_prerequisites all-noweb"
-fi
])
dnl ---------------------------
@@ -992,7 +977,7 @@ dnl -- OPENAXIOM_CHECK_MM --
dnl ------------------------
dnl Check for host capability of memory mapping.
AC_DEFUN([OPENAXIOM_CHECK_MM],[
-AC_CHECK_HEADERS([sys/mman.h])
+AC_CHECK_HEADERS([sys/mman.h fcntl.h])
## We want annonymous mapping for memory allocation. Unfortunately,
## the flag for anonymous mapping is not standardized. Popular names
## are MAP_ANONYMOUS and MAP_ANON.
@@ -1032,6 +1017,7 @@ AC_DEFUN([OPENAXIOM_CHECK_MISC],[
case $GCC in
yes)
CFLAGS="$CFLAGS -O2 -Wall"
+ CXXFLAGS="$CXXFLAGS -O2 -Wall"
;;
esac
])
diff --git a/config/openaxiom-c-macros.h.in b/config/openaxiom-c-macros.h.in
index df10e836..c92cc8ac 100644
--- a/config/openaxiom-c-macros.h.in
+++ b/config/openaxiom-c-macros.h.in
@@ -51,6 +51,9 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
/* Define to 1 if the system has the type `intptr_t'. */
#undef HAVE_INTPTR_T
diff --git a/config/setup-dep.mk b/config/setup-dep.mk
index ab5913dc..a89e4ba5 100644
--- a/config/setup-dep.mk
+++ b/config/setup-dep.mk
@@ -97,16 +97,12 @@ $(axiom_target_docdir)/$(subdir)%.dvi: $(builddir)/%.dvi
export TEXINPUTS; \
BIBINPUTS=".:$(axiom_build_texdir):$${TEXINPUTS}"; \
export BIBINPUTS; \
- $(axiom_build_document) --latex $<
+ $(oa_hammer) --latex $<
%.tex: $(srcdir)/%.pamphlet
- $(axiom_build_document) --weave --output=$@ $<
+ $(oa_hammer) --weave --output=$@ $<
-$(axiom_build_texdir)/axiom.sty: $(axiom_src_docdir)/axiom.sty.pamphlet
- $(mkinstalldirs) $(axiom_build_texdir)/
- $(axiom_build_document) --tangle=axiom.sty --output=$@ $<
-
## Rules for regenerating configure.ac and configure from
## pamphlet files.
$(top_srcdir)/configure.ac: $(top_srcdir)/configure.ac.pamphlet
@@ -135,10 +131,6 @@ Makefile: $(srcdir)/Makefile.in $(top_srcdir)/config/var-def.mk \
$(abs_top_builddir)/config.status
cd $(abs_top_builddir) && $(SHELL) ./config.status $(subdir)$@
-$(axiom_build_document): $(axiom_src_srcdir)/scripts/document.in
- cd $(abs_top_builddir) && \
- $(SHELL) ./config.status build/scripts/document
-
$(top_builddir)/src/lisp/core.lisp: \
$(top_srcdir)/src/lisp/core.lisp.in \
$(top_builddir)/config.status
diff --git a/config/var-def.mk b/config/var-def.mk
index 3fee05b7..928b1e8c 100644
--- a/config/var-def.mk
+++ b/config/var-def.mk
@@ -235,14 +235,7 @@ oa_include_gcl = @oa_include_gcl@
## -------------------------------------------
## -- Files generated for the build machine --
## -------------------------------------------
-axiom_build_document = $(axiom_top_builddir)/scripts/document
-axiom_build_nowebdir = $(axiom_builddir)/noweb
-
-TANGLE = @NOTANGLE@
-WEAVE = @NOWEAVE@
-## We export TANGLE and WEAVE for use in subshells, such as document.
-export TANGLE
-export WEAVE
+oa_hammer = $(top_builddir)/src/utils/hammer$(EXEEXT)
AXIOM_LISP = @AXIOM_LISP@
# Extension of the output file name returned by compile-file
diff --git a/configure b/configure
index 1de37802..02574f0c 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.63 for OpenAxiom 1.4.0-2010-08-16.
+# Generated by GNU Autoconf 2.63 for OpenAxiom 1.4.0-2010-08-20.
#
# Report bugs to <open-axiom-bugs@lists.sf.net>.
#
@@ -745,8 +745,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='OpenAxiom'
PACKAGE_TARNAME='openaxiom'
-PACKAGE_VERSION='1.4.0-2010-08-16'
-PACKAGE_STRING='OpenAxiom 1.4.0-2010-08-16'
+PACKAGE_VERSION='1.4.0-2010-08-20'
+PACKAGE_STRING='OpenAxiom 1.4.0-2010-08-20'
PACKAGE_BUGREPORT='open-axiom-bugs@lists.sf.net'
ac_unique_file="src/Makefile.pamphlet"
@@ -822,8 +822,6 @@ axiom_fasl_type
oa_use_dynamic_lib
axiom_eval_flags
axiom_quiet_flags
-NOWEAVE
-NOTANGLE
MAKE
AWK
MKTEMP
@@ -1511,7 +1509,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures OpenAxiom 1.4.0-2010-08-16 to adapt to many kinds of systems.
+\`configure' configures OpenAxiom 1.4.0-2010-08-20 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1581,7 +1579,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of OpenAxiom 1.4.0-2010-08-16:";;
+ short | recursive ) echo "Configuration of OpenAxiom 1.4.0-2010-08-20:";;
esac
cat <<\_ACEOF
@@ -1689,7 +1687,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-OpenAxiom configure 1.4.0-2010-08-16
+OpenAxiom configure 1.4.0-2010-08-20
generated by GNU Autoconf 2.63
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1703,7 +1701,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by OpenAxiom $as_me 1.4.0-2010-08-16, which was
+It was created by OpenAxiom $as_me 1.4.0-2010-08-20, which was
generated by GNU Autoconf 2.63. Invocation command line was
$ $0 $@
@@ -2260,7 +2258,6 @@ axiom_build_sharedir=$axiom_builddir/share
## Accumulate list of utils needed for the build platform
-## It is vital that noweb is present in the build environement.
oa_all_prerequisites=
@@ -6984,13 +6981,13 @@ if test "${lt_cv_nm_interface+set}" = set; then
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
- (eval echo "\"\$as_me:6987: $ac_compile\"" >&5)
+ (eval echo "\"\$as_me:6984: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
- (eval echo "\"\$as_me:6990: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval echo "\"\$as_me:6987: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
- (eval echo "\"\$as_me:6993: output\"" >&5)
+ (eval echo "\"\$as_me:6990: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
@@ -8192,7 +8189,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
- echo '#line 8195 "configure"' > conftest.$ac_ext
+ echo '#line 8192 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@@ -10472,11 +10469,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10475: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10472: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:10479: \$? = $ac_status" >&5
+ echo "$as_me:10476: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -10811,11 +10808,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10814: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10811: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:10818: \$? = $ac_status" >&5
+ echo "$as_me:10815: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -10916,11 +10913,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10919: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10916: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:10923: \$? = $ac_status" >&5
+ echo "$as_me:10920: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -10971,11 +10968,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:10974: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:10971: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:10978: \$? = $ac_status" >&5
+ echo "$as_me:10975: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -13771,7 +13768,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 13774 "configure"
+#line 13771 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -13867,7 +13864,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 13870 "configure"
+#line 13867 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -15887,11 +15884,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15890: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15887: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
- echo "$as_me:15894: \$? = $ac_status" >&5
+ echo "$as_me:15891: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@@ -15986,11 +15983,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:15989: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:15986: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:15993: \$? = $ac_status" >&5
+ echo "$as_me:15990: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -16038,11 +16035,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
- (eval echo "\"\$as_me:16041: $lt_compile\"" >&5)
+ (eval echo "\"\$as_me:16038: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
- echo "$as_me:16045: \$? = $ac_status" >&5
+ echo "$as_me:16042: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@@ -17367,106 +17364,6 @@ $as_echo "$as_me: error: OpenAxiom build system needs GNU Make." >&2;}
;;
esac
-## Make sure noweb executable is available
-for ac_prog in notangle
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_NOTANGLE+set}" = set; then
- $as_echo_n "(cached) " >&6
-else
- if test -n "$NOTANGLE"; then
- ac_cv_prog_NOTANGLE="$NOTANGLE" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_NOTANGLE="$ac_prog"
- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-NOTANGLE=$ac_cv_prog_NOTANGLE
-if test -n "$NOTANGLE"; then
- { $as_echo "$as_me:$LINENO: result: $NOTANGLE" >&5
-$as_echo "$NOTANGLE" >&6; }
-else
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$NOTANGLE" && break
-done
-
-for ac_prog in noweave
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if test "${ac_cv_prog_NOWEAVE+set}" = set; then
- $as_echo_n "(cached) " >&6
-else
- if test -n "$NOWEAVE"; then
- ac_cv_prog_NOWEAVE="$NOWEAVE" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
- ac_cv_prog_NOWEAVE="$ac_prog"
- $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
-done
-IFS=$as_save_IFS
-
-fi
-fi
-NOWEAVE=$ac_cv_prog_NOWEAVE
-if test -n "$NOWEAVE"; then
- { $as_echo "$as_me:$LINENO: result: $NOWEAVE" >&5
-$as_echo "$NOWEAVE" >&6; }
-else
- { $as_echo "$as_me:$LINENO: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$NOWEAVE" && break
-done
-
-## In case noweb is missing we need to build our own.
-if test -z "$NOTANGLE" -o -z "$NOWEAVE" ; then
- ## Yes, but do we have the source files to build from?
- if test ! -d ${srcdir}/noweb; then
- { $as_echo "$as_me:$LINENO: OpenAxiom requires noweb utilties" >&5
-$as_echo "$as_me: OpenAxiom requires noweb utilties" >&6;}
- { { $as_echo "$as_me:$LINENO: error: Please get the tarball of dependencies and reconfigure" >&5
-$as_echo "$as_me: error: Please get the tarball of dependencies and reconfigure" >&2;}
- { (exit 1); exit 1; }; }
- fi
- NOTANGLE='$(axiom_build_bindir)/notangle'
- NOWEAVE='$(axiom_build_bindir)/noweave'
- oa_all_prerequisites="$oa_all_prerequisites all-noweb"
-fi
-
@@ -22085,7 +21982,8 @@ GCLOPTS="$oa_gcl_emacs $oa_gcl_bfd_option $oa_gcl_mm_option $oa_gcl_x_option"
-for ac_header in sys/mman.h
+
+for ac_header in sys/mman.h fcntl.h
do
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
@@ -22298,6 +22196,7 @@ fi
case $GCC in
yes)
CFLAGS="$CFLAGS -O2 -Wall"
+ CXXFLAGS="$CXXFLAGS -O2 -Wall"
;;
esac
@@ -22309,6 +22208,8 @@ ac_config_files="$ac_config_files src/Makefile:config/var-def.mk:src/Makefile.in
ac_config_files="$ac_config_files src/lib/Makefile:config/var-def.mk:src/lib/Makefile.in:config/setup-dep.mk"
+ac_config_files="$ac_config_files src/utils/Makefile:config/var-def.mk:src/utils/Makefile.in:config/setup-dep.mk"
+
ac_config_files="$ac_config_files src/hyper/Makefile:config/var-def.mk:src/hyper/Makefile.in:config/setup-dep.mk"
ac_config_files="$ac_config_files src/driver/Makefile:config/var-def.mk:src/driver/Makefile.in:config/setup-dep.mk"
@@ -22330,12 +22231,6 @@ ac_config_files="$ac_config_files src/etc/Makefile:config/var-def.mk:src/etc/Mak
ac_config_files="$ac_config_files src/doc/Makefile:config/var-def.mk:src/doc/Makefile.in:config/setup-dep.mk"
-## We now generate the "document" script and support files at configure time.
-## We put them in the build directory because they are intended to be
-## build support utils only.
-ac_config_files="$ac_config_files build/scripts/document:$srcdir/src/scripts/document.in"
-
-
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@@ -22756,7 +22651,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by OpenAxiom $as_me 1.4.0-2010-08-16, which was
+This file was extended by OpenAxiom $as_me 1.4.0-2010-08-20, which was
generated by GNU Autoconf 2.63. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -22819,7 +22714,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-OpenAxiom config.status 1.4.0-2010-08-16
+OpenAxiom config.status 1.4.0-2010-08-20
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
@@ -23305,6 +23200,7 @@ do
"Makefile") CONFIG_FILES="$CONFIG_FILES Makefile:config/var-def.mk:Makefile.in:config/setup-dep.mk" ;;
"src/Makefile") CONFIG_FILES="$CONFIG_FILES src/Makefile:config/var-def.mk:src/Makefile.in:config/setup-dep.mk" ;;
"src/lib/Makefile") CONFIG_FILES="$CONFIG_FILES src/lib/Makefile:config/var-def.mk:src/lib/Makefile.in:config/setup-dep.mk" ;;
+ "src/utils/Makefile") CONFIG_FILES="$CONFIG_FILES src/utils/Makefile:config/var-def.mk:src/utils/Makefile.in:config/setup-dep.mk" ;;
"src/hyper/Makefile") CONFIG_FILES="$CONFIG_FILES src/hyper/Makefile:config/var-def.mk:src/hyper/Makefile.in:config/setup-dep.mk" ;;
"src/driver/Makefile") CONFIG_FILES="$CONFIG_FILES src/driver/Makefile:config/var-def.mk:src/driver/Makefile.in:config/setup-dep.mk" ;;
"src/lisp/Makefile") CONFIG_FILES="$CONFIG_FILES src/lisp/Makefile:config/var-def.mk:src/lisp/Makefile.in:config/setup-dep.mk" ;;
@@ -23315,7 +23211,6 @@ do
"src/input/Makefile") CONFIG_FILES="$CONFIG_FILES src/input/Makefile:config/var-def.mk:src/input/Makefile.in:config/setup-dep.mk" ;;
"src/etc/Makefile") CONFIG_FILES="$CONFIG_FILES src/etc/Makefile:config/var-def.mk:src/etc/Makefile.in:config/setup-dep.mk" ;;
"src/doc/Makefile") CONFIG_FILES="$CONFIG_FILES src/doc/Makefile:config/var-def.mk:src/doc/Makefile.in:config/setup-dep.mk" ;;
- "build/scripts/document") CONFIG_FILES="$CONFIG_FILES build/scripts/document:$srcdir/src/scripts/document.in" ;;
*) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;}
@@ -24738,8 +24633,6 @@ compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
_LT_EOF
;;
- "build/scripts/document":F) \
- chmod +x build/scripts/document ;;
esac
done # for ac_tag
@@ -24792,7 +24685,7 @@ egrep '<<(category|domain|package) .*>>=' \
set $chunk_desc; spad_abbrev=$2
cat >> src/algebra/tmp-extract-spad.mk <<EOF
$spad_abbrev.spad: \$(srcdir)/`basename $spad_file` ; \
- @\$(axiom_build_document) --output=\$@.tmp --tangle="$chunk_desc" \$< && \
+ @\$(oa_hammer) --output=\$@.tmp --tangle="$chunk_desc" \$< && \
\$(top_confdir)/move-if-change \$@.tmp \$@
EOF
done
diff --git a/configure.ac b/configure.ac
index 495a01c2..b4fe9057 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,7 @@ dnl Most of the macros used in this configure.ac are defined in files
dnl located in the subdirectory config/
sinclude(config/open-axiom.m4)
sinclude(config/aclocal.m4)
-AC_INIT([OpenAxiom], [1.4.0-2010-08-16],
+AC_INIT([OpenAxiom], [1.4.0-2010-08-20],
[open-axiom-bugs@lists.sf.net])
AC_CONFIG_AUX_DIR(config)
@@ -79,7 +79,6 @@ axiom_build_sharedir=$axiom_builddir/share
## Accumulate list of utils needed for the build platform
-## It is vital that noweb is present in the build environement.
oa_all_prerequisites=
AC_SUBST(oa_all_prerequisites)
@@ -111,6 +110,7 @@ OPENAXIOM_CHECK_MISC
OPENAXIOM_MAKEFILE([Makefile])
OPENAXIOM_MAKEFILE([src/Makefile])
OPENAXIOM_MAKEFILE([src/lib/Makefile])
+OPENAXIOM_MAKEFILE([src/utils/Makefile])
OPENAXIOM_MAKEFILE([src/hyper/Makefile])
OPENAXIOM_MAKEFILE([src/driver/Makefile])
OPENAXIOM_MAKEFILE([src/lisp/Makefile])
@@ -122,12 +122,6 @@ OPENAXIOM_MAKEFILE([src/input/Makefile])
OPENAXIOM_MAKEFILE([src/etc/Makefile])
OPENAXIOM_MAKEFILE([src/doc/Makefile])
-## We now generate the "document" script and support files at configure time.
-## We put them in the build directory because they are intended to be
-## build support utils only.
-AC_CONFIG_FILES(build/scripts/document:$srcdir/src/scripts/document.in, \
- [chmod +x build/scripts/document])
-
AC_OUTPUT
## Generate rules to extrad SPAD type definitions from pamphlets.
@@ -140,7 +134,7 @@ egrep '<<(category|domain|package) .*>>=' \
set $chunk_desc; spad_abbrev=$2
cat >> src/algebra/tmp-extract-spad.mk <<EOF
$spad_abbrev.spad: \$(srcdir)/`basename $spad_file` ; \
- @\$(axiom_build_document) --output=\$@.tmp --tangle="$chunk_desc" \$< && \
+ @\$(oa_hammer) --output=\$@.tmp --tangle="$chunk_desc" \$< && \
\$(top_confdir)/move-if-change \$@.tmp \$@
EOF
done
diff --git a/src/ChangeLog b/src/ChangeLog
index a291b326..85445ae7 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,16 @@
+2010-08-20 Gabriel Dos Reis <gdr@cs.tamu.edu>
+
+ * Makefile.pamphlet (all-interpsys): Require all-utils.
+ (all-asq): Likewise.
+ (all-utils): New tule.
+ * algebra/Makefile.pamphlet: Replace $(axiom_build_document) with
+ $(oa_hammer).
+ * etc/Makefile.in: Likewise.
+ * graph/Makefile.in: Likewise.
+ * input/Makefile.pamphlet: Likewise.
+ * interp/Makefile.pamphlet: Likewise.
+ * utils/: New component.
+
2010-08-17 Gabriel Dos Reis <gdr@cs.tamu.edu>
* ChangeLog.jap: Merge into here. Remove
diff --git a/src/Makefile.in b/src/Makefile.in
index 420b1c8f..d6efda33 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -5,7 +5,7 @@ subdir = src/
SUBDIRS = @axiom_src_subdirs@
-.PHONY: all all-ax all-src all-clef all-sman all-driver
+.PHONY: all all-ax all-src all-clef all-sman all-driver all-utils
all: all-ax
@@ -19,6 +19,9 @@ stamp: @axiom_src_all@ all-driver
all-driver: all-lib
@cd driver && $(MAKE) $@
+all-utils:
+ @cd utils && $(MAKE) $@
+
all-clef: all-lib
@$(mkdir_p) "$(axiom_target_bindir)"
cd clef && $(MAKE) $@
@@ -41,7 +44,7 @@ all-lisp: all-lib
cd lisp && $(MAKE) all-lisp
all-boot: all-lisp
@cd boot && $(MAKE) $@
-all-interpsys: all-boot all-hyper-pre
+all-interpsys: all-boot all-hyper-pre all-utils
cd interp && ${MAKE} all-interpsys
all-axiomsys: all-asq
@@ -54,7 +57,7 @@ all-hyper-pre: all-lib
cd hyper && $(MAKE) all-hyper-pre
all-input: all-axiomsys all-doc
cd input && ${MAKE}
-all-asq: all-hyper-post
+all-asq: all-hyper-post all-utils
cd etc && $(MAKE) $@
.PHONY: all-databases
diff --git a/src/Makefile.pamphlet b/src/Makefile.pamphlet
index 806d8375..07989893 100644
--- a/src/Makefile.pamphlet
+++ b/src/Makefile.pamphlet
@@ -124,7 +124,7 @@ all-boot: all-lisp
Once \Tool{bootsys} exists we need to build
\Tool{interpsys}.
<<interpdir>>=
-all-interpsys: all-boot all-hyper-pre
+all-interpsys: all-boot all-hyper-pre all-utils
cd interp && ${MAKE} all-interpsys
all-axiomsys: all-asq
@@ -211,7 +211,7 @@ The \Tool{asq} \cite{2} command, contained in this directory, is useful
for finding detailed information about domains, packages, and
categories from the shell without running Axiom.
<<etcdir>>=
-all-asq: all-hyper-post
+all-asq: all-hyper-post all-utils
cd etc && $(MAKE) $@
.PHONY: all-databases
@@ -252,7 +252,7 @@ subdir = src/
SUBDIRS = @axiom_src_subdirs@
-.PHONY: all all-ax all-src all-clef all-sman all-driver
+.PHONY: all all-ax all-src all-clef all-sman all-driver all-utils
all: all-ax
@@ -266,6 +266,9 @@ stamp: @axiom_src_all@ all-driver
all-driver: all-lib
@cd driver && $(MAKE) $@
+all-utils:
+ @cd utils && $(MAKE) $@
+
<<clefdir>>
<<smandir>>
<<hyperdir>>
diff --git a/src/algebra/Makefile.in b/src/algebra/Makefile.in
index e2293479..0b47e87a 100644
--- a/src/algebra/Makefile.in
+++ b/src/algebra/Makefile.in
@@ -1131,7 +1131,7 @@ strap/%.$(FASLEXT): $(srcdir)/strap/%.lsp
$(OUTSRC)/%.spad: mk-target-src-algabra-dir
${OUTSRC}/%.spad: $(srcdir)/%.spad.pamphlet
- $(axiom_build_document) --tangle --output=$@ $<
+ $(oa_hammer) --tangle --output=$@ $<
.PHONY: mk-target-src-algabra-dir
mk-target-src-algabra-dir:
@@ -1153,10 +1153,10 @@ $(builddir)/%.dvi: $(axiom_build_texdir)/diagrams.tex \
$(axiom_build_texdir)/axiom.sty
$(builddir)/%.dvi: $(builddir)/%.tex
- $(axiom_build_document) --latex $<
+ $(oa_hammer) --latex $<
$(builddir)/%.tex: $(srcdir)/%.pamphlet
- $(axiom_build_document) --weave --output=$@ $<
+ $(oa_hammer) --weave --output=$@ $<
$(axiom_build_texdir)/diagrams.tex: $(axiom_src_docdir)/diagrams.tex
@cp -p $< $@
@@ -1170,13 +1170,13 @@ PARSER.NRLIB/code.$(FASLEXT): script-parser.spad
${INPUT}/TESTFR.input: $(srcdir)/fr.spad.pamphlet
- $(axiom_build_document) --tangle='TEST FR' --output=$@ $<
+ $(oa_hammer) --tangle='TEST FR' --output=$@ $<
${INPUT}/INTHEORY.input: $(srcdir)/numtheor.spad.pamphlet
- $(axiom_build_document) --tangle='TEST INTHEORY' --output=$@ $<
+ $(oa_hammer) --tangle='TEST INTHEORY' --output=$@ $<
${INPUT}/VIEW2D.input: $(srcdir)/view2D.spad.pamphlet
- $(axiom_build_document) --tangle='TEST VIEW2D' --output=$@ $<
+ $(oa_hammer) --tangle='TEST VIEW2D' --output=$@ $<
${DOC}/diagrams.tex: $(axiom_src_docdir)/diagrams.tex
diff --git a/src/algebra/Makefile.pamphlet b/src/algebra/Makefile.pamphlet
index 24d15915..210b5165 100644
--- a/src/algebra/Makefile.pamphlet
+++ b/src/algebra/Makefile.pamphlet
@@ -1418,13 +1418,13 @@ TESTS=${INPUT}/INTHEORY.input ${INPUT}/VIEW2D.input ${INPUT}/TESTFR.input
<<testrules>>=
${INPUT}/TESTFR.input: $(srcdir)/fr.spad.pamphlet
- $(axiom_build_document) --tangle='TEST FR' --output=$@ $<
+ $(oa_hammer) --tangle='TEST FR' --output=$@ $<
${INPUT}/INTHEORY.input: $(srcdir)/numtheor.spad.pamphlet
- $(axiom_build_document) --tangle='TEST INTHEORY' --output=$@ $<
+ $(oa_hammer) --tangle='TEST INTHEORY' --output=$@ $<
${INPUT}/VIEW2D.input: $(srcdir)/view2D.spad.pamphlet
- $(axiom_build_document) --tangle='TEST VIEW2D' --output=$@ $<
+ $(oa_hammer) --tangle='TEST VIEW2D' --output=$@ $<
@
@@ -1580,7 +1580,7 @@ strap/%.$(FASLEXT): $(srcdir)/strap/%.lsp
$(OUTSRC)/%.spad: mk-target-src-algabra-dir
${OUTSRC}/%.spad: $(srcdir)/%.spad.pamphlet
- $(axiom_build_document) --tangle --output=$@ $<
+ $(oa_hammer) --tangle --output=$@ $<
.PHONY: mk-target-src-algabra-dir
mk-target-src-algabra-dir:
@@ -1604,10 +1604,10 @@ $(builddir)/%.dvi: $(axiom_build_texdir)/diagrams.tex \
$(axiom_build_texdir)/axiom.sty
$(builddir)/%.dvi: $(builddir)/%.tex
- $(axiom_build_document) --latex $<
+ $(oa_hammer) --latex $<
$(builddir)/%.tex: $(srcdir)/%.pamphlet
- $(axiom_build_document) --weave --output=$@ $<
+ $(oa_hammer) --weave --output=$@ $<
$(axiom_build_texdir)/diagrams.tex: $(axiom_src_docdir)/diagrams.tex
@cp -p $< $@
@@ -1723,7 +1723,7 @@ the case above this would resolve to [[\${MID}/LEXTRIPK.spad]].
For the line given above it outputs the following:
\begin{verbatim}
${MID}/LEXTRIPK.spad: $(srcdir)/zerodim.spad.pamphlet
- $(axiom_build_document) --tangle='package LEXTRIPK LexTriangularPackage' --output=$@ $<
+ $(oa_hammer) --tangle='package LEXTRIPK LexTriangularPackage' --output=$@ $<
\end{verbatim}
diff --git a/src/etc/Makefile.in b/src/etc/Makefile.in
index b642bda1..c06c0437 100644
--- a/src/etc/Makefile.in
+++ b/src/etc/Makefile.in
@@ -109,7 +109,7 @@ asq$(EXEEXT): $(asq_objects)
asq.c: $(srcdir)/asq.c.pamphlet
- $(axiom_build_document) --tangle --output=$@ $<
+ $(oa_hammer) --tangle --output=$@ $<
$(axiom_target_libdir)/summary: $(srcdir)/summary
cp -p $< $@
diff --git a/src/graph/Makefile.in b/src/graph/Makefile.in
index 6ffecf3c..4368c446 100644
--- a/src/graph/Makefile.in
+++ b/src/graph/Makefile.in
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2009, Gabriel Dos Reis.
+# Copyright (C) 2007-2010, Gabriel Dos Reis.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -78,7 +78,7 @@ all-viewAlone: all-Gdraws
parabola/data parabola/graph0: $(srcdir)/fileformats.pamphlet
- $(axiom_build_document) --tangle=`basename $@` --output=$@ $<
+ $(oa_hammer) --tangle=`basename $@` --output=$@ $<
mostlyclean-local:
diff --git a/src/input/Makefile.in b/src/input/Makefile.in
index acfdd10a..a845deab 100644
--- a/src/input/Makefile.in
+++ b/src/input/Makefile.in
@@ -514,13 +514,13 @@ ${OUT}/%.input: %.input
.PRECIOUS: %.input
%.input: ${IN}/%.input.pamphlet
- @$(axiom_build_document) --output=$@ --tangle $<
+ @$(oa_hammer) --output=$@ --tangle $<
${OUT}/%.as: %.as
@cp -p $< $@
%.as: ${IN}/%.as.pamphlet
- @ $(axiom_build_document) --output=$@ --tangle $<
+ @ $(oa_hammer) --output=$@ --tangle $<
pamphlets = \
Makefile.pamphlet \
diff --git a/src/input/Makefile.pamphlet b/src/input/Makefile.pamphlet
index 5a320d1c..d9747262 100644
--- a/src/input/Makefile.pamphlet
+++ b/src/input/Makefile.pamphlet
@@ -57,13 +57,13 @@ ${OUT}/%.input: %.input
.PRECIOUS: %.input
%.input: ${IN}/%.input.pamphlet
- @$(axiom_build_document) --output=$@ --tangle $<
+ @$(oa_hammer) --output=$@ --tangle $<
${OUT}/%.as: %.as
@cp -p $< $@
%.as: ${IN}/%.as.pamphlet
- @ $(axiom_build_document) --output=$@ --tangle $<
+ @ $(oa_hammer) --output=$@ --tangle $<
pamphlets = \
Makefile.pamphlet \
diff --git a/src/interp/Makefile.in b/src/interp/Makefile.in
index bf46316f..6fbfdf3c 100644
--- a/src/interp/Makefile.in
+++ b/src/interp/Makefile.in
@@ -219,11 +219,9 @@ ${AXIOMSYS}: database.date \
--load-directory=. $(OBJS) makeint.$(LNKEXT)
@ echo 6a $@ created
exposed.lsp: $(axiom_src_algdir)/exposed.lsp.pamphlet
- @ echo 615 making exposed.lsp from $(axiom_src_algdir)/exposed.lsp.pamphlet
- $(axiom_build_document) --tangle --output=$@ $<
+ $(oa_hammer) --tangle --output=$@ $<
$(axiom_targetdir)/algebra/exposed.$(FASLEXT) : exposed.lsp boot-pkg.$(LNKEXT)
- @ echo 616 making $@ from exposed.lsp
$(mkdir_p) $(axiom_targetdir)/algebra
$(BOOTSYS) --compile --output=$@ --load-directory=. $<
diff --git a/src/interp/Makefile.pamphlet b/src/interp/Makefile.pamphlet
index c3714e72..a1579c1c 100644
--- a/src/interp/Makefile.pamphlet
+++ b/src/interp/Makefile.pamphlet
@@ -410,11 +410,9 @@ $(axiom_build_texdir)/diagrams.tex: $(axiom_src_docdir)/diagrams.tex
\end{verbatim}
<<databases>>=
exposed.lsp: $(axiom_src_algdir)/exposed.lsp.pamphlet
- @ echo 615 making exposed.lsp from $(axiom_src_algdir)/exposed.lsp.pamphlet
- $(axiom_build_document) --tangle --output=$@ $<
+ $(oa_hammer) --tangle --output=$@ $<
$(axiom_targetdir)/algebra/exposed.$(FASLEXT) : exposed.lsp boot-pkg.$(LNKEXT)
- @ echo 616 making $@ from exposed.lsp
$(mkdir_p) $(axiom_targetdir)/algebra
$(BOOTSYS) --compile --output=$@ --load-directory=. $<
diff --git a/src/utils/Makefile.in b/src/utils/Makefile.in
new file mode 100644
index 00000000..024af5dc
--- /dev/null
+++ b/src/utils/Makefile.in
@@ -0,0 +1,77 @@
+# Copyright (C) 2010, Gabriel Dos Reis.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are
+# met:
+#
+# - Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# - 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.
+#
+# - Neither the name of The Numerical Algorithms Group Ltd. 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.
+
+subdir = src/utils/
+
+bin_PROGRAMS = hammer$(EXEEXT)
+hammer_SOURCES = hammer.cc
+hammer_OBJECTS = $(hammer_SOURCES:.cc=.lo)
+hammer_LDADD = -L. -lOpenAxiom
+
+libOpenAxiom_HEADERS = storage.H
+libOpenAxiom_SOURCES = storage.cc
+libOpenAxiom_OBJECTS = $(libOpenAxiom_SOURCES:.cc=.lo)
+
+.PHONY: all all-ax all-utils
+.SUFFIXES:
+.SUFFIXES: .cc .H $(OBJEXT) $(LIBEXT)
+
+all: all-ax
+
+all-ax all-utils: stamp
+
+stamp: libOpenAxiom.$(LIBEXT) hammer$(EXEEXT)
+ -rm -f stamp
+ $(STAMP) stamp
+
+.SUFFIXES:
+.SUFFIXES: .c .h .lo .$(OBJEXT)
+.PRECIOUS: %.lo %.obj
+
+hammer$(EXEEXT): $(hammer_OBJECTS) libOpenAxiom.$(LIBEXT)
+ $(CXXLINK) -o $@ $(hammer_OBJECTS) $(hammer_LDADD) $(LDFLAGS)
+
+libOpenAxiom.$(LIBEXT): $(libOpenAxiom_OBJECTS)
+ $(CXXLINK) -o $@ $(libOpenAxiom_OBJECTS)
+
+%.lo: %.cc $(libOpenAxiom_HEADERS)
+ $(CXXCOMPILE) ${CXXFLAGS} -I. -I$(top_builddir)/config -o $@ $<
+
+
+mostlyclean-local:
+ @rm -rf .libs
+ @rm -f $(libOpenAxiom_OBJECTS)
+ @rm -f *~ core
+
+clean-local: mostlyclean-local
+
+distclean-local: clean-local
+
diff --git a/src/utils/hammer.cc b/src/utils/hammer.cc
new file mode 100644
index 00000000..17c5cc73
--- /dev/null
+++ b/src/utils/hammer.cc
@@ -0,0 +1,414 @@
+// Copyright (C) 2010, Gabriel Dos Reis.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// - Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// - 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.
+//
+// - Neither the name of The Numerical Algorithms Group Ltd. 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.
+
+#include <string.h>
+#include <stdlib.h>
+#include <utility>
+#include <string>
+#include <iostream>
+#include <fstream>
+#include <iterator>
+#include <list>
+#include <vector>
+#include <map>
+#include "storage.H"
+
+// -- This program implements basic functionalities for untangling
+// -- algebra source code from the pamphlets. The syntax is that
+// -- of `noweb'. A chunk definition starts with a pattern
+// -- <<name>>= on a line by itself, and ends with `@' by itself
+// -- on a line. A chunk can refer to another chunk through
+// -- a pattern of the form `<<name>>'.
+
+namespace OpenAxiom {
+ namespace Hammer {
+ // -------------
+ // -- Element --
+ // -------------
+ // Base class of document elements.
+ struct Element {
+ virtual ~Element() { }
+ };
+
+ // ---------------
+ // -- BasicText --
+ // ---------------
+ // Plain text, with no reference to any chunk.
+ struct BasicText : Element {
+ BasicText(const char* f, const char* l) : span(f, l) { }
+ // Pointer to the start of this basic text element
+ const char* begin() const { return span.first; }
+ // Oone-past-the-end of the this basic text element.
+ const char* end() const { return span.second; }
+ private:
+ std::pair<const char*, const char*> span;
+ };
+
+ // ---------------
+ // -- Reference --
+ // ---------------
+ // Reference to a a chunk by name.
+ struct Reference : Element {
+ explicit Reference(const std::string& s) : label(s) { }
+ // Naame of the chunk referenced.
+ const std::string& name() const { return label; }
+ private:
+ const std::string label;
+ };
+
+ // -------------------
+ // -- CompositeText --
+ // -------------------
+ // Sequence of basic elements and reference to chunks.
+ struct CompositeText: private std::vector<const Element*> {
+ typedef std::vector<const Element*> base;
+ using base::iterator;
+ using base::begin;
+ using base::end;
+ using base::size;
+ using base::operator[];
+
+ // Augment this chunk with a basic text in the open interval
+ // [f,l).
+ CompositeText& add_text(const char* f, const char* l) {
+ texts.push_back(BasicText(f, l));
+ push_back(&texts.back());
+ return *this;
+ }
+
+ // Augment this chunk with a reference to another chunk
+ // named `n'. Note that we don't attempt to check for
+ // possible circularities.
+ CompositeText reference_chunk(const char* f, const char* l) {
+ refs.push_back(Reference(std::string(f, l)));
+ push_back(&refs.back());
+ return *this;
+ }
+
+ private:
+ std::list<BasicText> texts;
+ std::list<Reference> refs;
+ };
+
+ // --------------
+ // -- Document --
+ // --------------
+ // A whole document; a sequence of chunks.
+ struct Document : std::list<CompositeText> {
+ Document(const Memory::FileMapping& file)
+ : active_chunk(&prose), text_start(file.begin()) {
+ parse(file);
+ }
+
+ // Return a pointer to a document chunk name `n'.
+ // Otherwise, return null.
+ CompositeText* lookup_chunk(const std::string& n) const {
+ ChunkTable::const_iterator i = defs.find(n);
+ return i == defs.end() ? 0 : i->second;
+ }
+
+ private:
+ typedef std::map<std::string, CompositeText*> ChunkTable;
+ CompositeText prose; // the prose around the chunks.
+ ChunkTable defs; // chunk definition table.
+ CompositeText* active_chunk; // chunk under construction.
+ const char* text_start; // begining of current basic text.
+
+ // Append basic text in the range `[text_start,last)'
+ // to the current chunk.
+ void finish_chunk(const char* last) {
+ if (text_start != last)
+ active_chunk->add_text(text_start, last);
+ active_chunk = &prose;
+ text_start = last;
+ }
+
+ // Start a new chunk or extend an existing chunk.
+ void begin_chunk(const std::string& name, const char* start) {
+ if (CompositeText* chunk = lookup_chunk(name))
+ active_chunk = chunk;
+ else {
+ push_back(CompositeText());
+ defs[name] = active_chunk = &back();
+ }
+ text_start = start;
+ }
+
+ // Parse a file mapping into this document.
+ void parse(const Memory::FileMapping&);
+ };
+
+ // Return true if the character `c' introduces a newline.
+ static inline bool
+ looking_at_newline(char c) {
+ return c == '\n' or c == '\r';
+ }
+
+ // Attempt to advance the cursor past newline marker.
+ // Return true on sucess.
+ static bool
+ saw_newline(const char*& cur, const char* end) {
+ if (*cur == '\n') {
+ ++cur;
+ return true;
+ }
+ else if (*cur == '\r') {
+ if (++cur < end and *cur == '\n')
+ ++cur;
+ return true;
+ }
+ return false;
+ }
+
+ // Move `cur' to end of line or `end', whichever comes first.
+ // Return true if the area swept consisted only of blank characters.
+ static inline bool
+ trailing_blank(const char*& cur, const char* end) {
+ bool result = true;
+ for (; cur < end and not saw_newline(cur, end); ++cur)
+ result = isspace(*cur);
+ return result;
+ }
+
+ // Attempt to advance `cur' past the double left angle brackets
+ // starting a chunk name. Returm true on success.
+ static bool
+ chunk_name_began(const char*& cur, const char* end) {
+ if (cur[0] == '<' and cur + 1 < end and cur[1] == '<') {
+ cur += 2;
+ return true;
+ }
+ return false;
+ }
+
+ // Attempt to move `cur' past the double right angle brackets
+ // terminating a chunk name. Returm true on success.
+ static bool
+ chunk_name_ended(const char*& cur, const char* end) {
+ if (cur[0] == '>' and cur + 1 < end and cur[1] == '>') {
+ cur += 2;
+ return true;
+ }
+ return false;
+ }
+
+ // We've just seen the start of a chunk reference; skip
+ // characters till we seen of the chunk's name.
+ static void
+ skip_to_end_of_chunk_name(const char*& cur, const char* end) {
+ while (cur < end) {
+ if (looking_at_newline(*cur)
+ or (cur + 1 < end and cur[0] == '>' and cur[1] == '>'))
+ return;
+ ++cur;
+ }
+ }
+
+ // Move the cursor until end of line.
+ static void
+ skip_to_end_of_line(const char*& cur, const char* end) {
+ while (cur < end) {
+ if (saw_newline(cur, end))
+ break;
+ ++cur;
+ }
+ }
+
+ void
+ Document::parse(const Memory::FileMapping& file) {
+ const char* cur = text_start;
+ const char* last = file.end();
+ // Process one line at a time.
+ while (cur < last) {
+ // 1. `@' ends previous chunk
+ if (*cur == '@') {
+ const char* p = cur;
+ if (trailing_blank(++cur, last))
+ finish_chunk(p);
+ }
+ // 2. `<<' introduces a chunk reference or a chunk definition.
+ else if (chunk_name_began(cur, last)) {
+ const char* label_start = cur;
+ skip_to_end_of_chunk_name(cur, last);
+ if (chunk_name_ended(cur, last)) {
+ const char* label_end = cur - 2;
+ if (cur < last and *cur == '=') {
+ if (trailing_blank(++cur, last)) {
+ // chunk definition or extension
+ finish_chunk(label_start - 2);
+ begin_chunk(std::string(label_start, label_end), cur);
+ }
+ }
+ else if (trailing_blank(cur, last)) {
+ // This is just a reference to a chunk.
+ active_chunk->add_text(text_start, label_start - 2);
+ active_chunk->reference_chunk(label_start, label_end);
+ text_start = cur;
+ }
+ else
+ skip_to_end_of_line(cur, last);
+ }
+ }
+ else
+ skip_to_end_of_line(cur, last);
+ }
+ finish_chunk(cur);
+ }
+
+ // Capture chunk resolution in a document.
+ struct resolve_chunk {
+ resolve_chunk(const std::string& s, const Document& f)
+ : name(s), doc(f) { }
+ const std::string name; // name of the chunk
+ const Document& doc; // document containing the chunk.
+ };
+
+ // Print the resolution of a chunk name onto an output stream.
+ std::ostream&
+ operator<<(std::ostream& os, const resolve_chunk& rc) {
+ // FIXME: no attempt at detecting circularities.
+ const CompositeText* doc = rc.doc.lookup_chunk(rc.name);
+ if (doc == 0) {
+ std::cerr << "chunk " << rc.name << " is undefined" << std::endl;
+ exit(1);
+ }
+ for (std::size_t i = 0; i < doc->size(); ++i) {
+ const Element* elt = (*doc)[i];
+ if (const BasicText* t = dynamic_cast<const BasicText*>(elt))
+ std::copy(t->begin(), t->end(),
+ std::ostream_iterator<char>(os));
+ else if (const Reference* r = dynamic_cast<const Reference*>(elt))
+ os << resolve_chunk(r->name(), rc.doc);
+ else {
+ std::cerr << "unknown document element" << std::endl;
+ exit(1);
+ }
+ }
+
+ return os;
+ }
+
+ // Return true if the `arg' is the option named`opt'.
+ static inline bool
+ is_option(const char* arg, const char* opt) {
+ return strcmp(arg, opt) == 0;
+ }
+
+ // `arg' is a argument on the command line. If `arg'
+ // does not match option name `opt', return null. Otherwise,
+ // return a pointer to the terminating NUL character if there
+ // is no specified value for that option, or a pointer to the
+ // start of the value.
+ static const char*
+ is_named_arg(const char* arg, const char* opt) {
+ const int n = strlen(opt);
+ int i = 0;
+ // Get out if argion name does not match.
+ // Note: Ideally, we could use strncmp(). However, that
+ // function is not available in C++98, so we cannot depend on it.
+ for (; i < n ; ++i)
+ if (arg[i] != opt[i])
+ return 0;
+
+ if (arg[i] == '\0')
+ return arg + i; // no value for the option.
+ return arg + n + 1; // being of the value.
+ }
+ }
+}
+
+
+int
+main(int argc, char* argv[]) {
+ using namespace OpenAxiom::Hammer;
+ int error_count = 0;
+ const char* chunk = 0; // chunck to tangle
+ const char* output_path = 0; // path to the output file
+ const char* input_path = 0; // path to the input file.
+ // 1. Process command line arguments.
+ for (int pos = 1; error_count == 0 and pos < argc; ++pos) {
+ if (const char* val = is_named_arg(argv[pos], "--tangle")) {
+ if (chunk != 0) {
+ std::cerr << "cannot tangle more than one chunk";
+ ++error_count;
+ }
+ else
+ chunk = *val == 0 ? "*" : val;
+ }
+ else if (const char* val = is_named_arg(argv[pos], "--output")) {
+ if (*val == 0) {
+ std::cerr << "missing output file name" << std::endl;
+ ++error_count;
+ }
+ else
+ output_path = val;
+ }
+ else if (argv[pos][0] == '-' and argv[pos][1] == '-') {
+ std::cerr << "unknown option " << argv[pos] << std::endl;
+ ++error_count;
+ }
+ else if (input_path != 0) {
+ std::cerr << "there must be exactly one input file" << std::endl;
+ ++error_count;
+ }
+ else
+ input_path = argv[pos];
+ }
+
+ // 2. Basic sanity check.
+ if (input_path == 0) {
+ std::cerr << "missing input file" << std::endl;
+ return 1;
+ }
+ if (output_path == 0) {
+ std::cerr << "missing output file" << std::endl;
+ return 1;
+ }
+ if (chunk == 0) {
+ std::cerr << "missing chunk name" << std::endl;
+ return 1;
+ }
+
+ if (error_count != 0)
+ return 1;
+
+ // 3. Attempt to extract the chunk.
+ try {
+ OpenAxiom::Memory::FileMapping file(input_path);
+ std::ofstream os(output_path);
+ os << resolve_chunk(chunk, Document(file));
+ }
+ catch(const OpenAxiom::SystemError& e) {
+ std::cerr << e.message() << std::endl;
+ exit(1);
+ }
+ return 0;
+}
diff --git a/src/utils/storage.H b/src/utils/storage.H
new file mode 100644
index 00000000..ba14ec97
--- /dev/null
+++ b/src/utils/storage.H
@@ -0,0 +1,87 @@
+// Copyright (C) 2010, Gabriel Dos Reis.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// - Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// - 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.
+//
+// - Neither the name of The Numerical Algorithms Group Ltd. 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.
+
+#include <stddef.h>
+#include <string>
+
+namespace OpenAxiom {
+ // -----------------
+ // -- SystemError --
+ // -----------------
+ // Objects of (type derived from) this type are used to report
+ // error orignating from the OpenAxiom core system.
+ struct SystemError {
+ explicit SystemError(std::string);
+ virtual ~SystemError();
+ // Return the text of the diagnostic message.
+ virtual const std::string& message() const;
+ protected:
+ const std::string text;
+ };
+
+ // Report a file system erro
+ void filesystem_error(std::string);
+
+ namespace Memory {
+ // Datatype for pointers to data.
+ typedef void* Pointer;
+
+ // Precision of the host OS storage page unit in byte count
+ size_t page_size();
+
+ // Acquire raw memory from the host OS in multiple
+ // of storage page nits.
+ Pointer os_acquire_raw_memory(size_t);
+
+ // Release raw storage to the hosting OS. The first operand must
+ // be a pointer value previous returned by `os_acquire_raw_memory'.
+ // Otherwise, the result is undefined.
+ void os_release_raw_memory(Pointer, size_t);
+
+ // -----------------
+ // -- FileMapping --
+ // -----------------
+ struct FileMapping {
+ explicit FileMapping(std::string);
+ ~FileMapping();
+ const char* begin() const { return static_cast<const char*>(start); }
+ const char* end() const { return begin() + extent; }
+ std::size_t size() const { return extent; }
+ protected:
+ Pointer start; // address at the mapped storage
+ size_t extent; // length (in bytes) of the storage
+ private:
+ FileMapping(const FileMapping&); // not implemented
+ FileMapping& operator=(const FileMapping&); // idem
+ };
+
+ }
+}
diff --git a/src/utils/storage.cc b/src/utils/storage.cc
new file mode 100644
index 00000000..4db7f302
--- /dev/null
+++ b/src/utils/storage.cc
@@ -0,0 +1,175 @@
+// Copyright (C) 2010, Gabriel Dos Reis.
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions are
+// met:
+//
+// - Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+//
+// - 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.
+//
+// - Neither the name of The Numerical Algorithms Group Ltd. 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.
+
+#include "openaxiom-c-macros.h"
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#include <sys/types.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_MMAN_H
+# include <sys/mman.h>
+#endif
+#ifdef OPENAXIOM_MS_WINDOWS_HOST
+# include <windows.h>
+#endif
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include "storage.H"
+
+namespace OpenAxiom {
+ // ----------------
+ // -- SystemError --
+ // ----------------
+ SystemError::SystemError(std::string s) : text(s) { }
+
+ SystemError::~SystemError() { }
+
+ const std::string&
+ SystemError::message() const {
+ return text;
+ }
+
+ void
+ filesystem_error(std::string s) {
+ throw SystemError(s);
+ }
+
+ namespace Memory {
+ // Return storage page allocation unit in byte count.
+ size_t page_size() {
+#if defined(OPENAXIOM_MS_WINDOWS_HOST)
+ SYSTEM_INFO si = { };
+ GetSystemInfo(&si);
+ return si.dwPageSize;
+#elif defined(HAVE_UNISTD_H)
+ return sysconf(_SC_PAGESIZE);
+#else
+ // Well, we have to return a number.
+ return 4096;
+#endif
+ }
+
+ // Subroutine of os_acquire_raw_memory. Attempt to acquire
+ // storage from the host OS. Return null on failure.
+ static inline Pointer
+ os_allocate_read_write_raw_memory(size_t nbytes) {
+#if defined(OPENAXIOM_MS_WINDOWS_HOST)
+ return VirtualAlloc(Pointer(), nbytes,
+ MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
+#elif defined(HAVE_SYS_MMAN_H)
+ Pointer p = mmap(Pointer(), nbytes, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | OPENAXIOM_MM_ANONYMOUS_MAP_FLAG,
+ -1, 0);
+ return p == MAP_FAILED ? Pointer() : p;
+#else
+ return malloc(byte_count);
+#endif
+ }
+
+ Pointer
+ os_acquire_raw_memory(size_t nbytes) {
+ Pointer p = os_allocate_read_write_raw_memory(nbytes);
+ if (p == 0)
+ throw SystemError("cannot acquire more memory");
+ return memset(p, nbytes, 0);
+ }
+
+ void
+ os_release_raw_memory(Pointer p, size_t n) {
+#if defined(OPENAXIOM_MS_WINDOWS_HOST)
+ VirtualFree(p, 0, MEM_RELEASE);
+#elif defined(HAVE_SYS_MMAN_H)
+ munmap(p, n);
+#else
+ free(p);
+#endif
+ }
+
+ // -----------------
+ // -- FileMapping --
+ // -----------------
+ FileMapping::FileMapping(std::string path)
+ : start(), extent() {
+#if defined(OPENAXIOM_MS_WINDOWS_HOST)
+ HANDLE file = CreateFile(path.c_str(), GENERIC_READ, 0, 0,
+ OPEN_EXISTING,
+ FILE_ATTRIBUTE_NORMAL, 0);
+ if (file == INVALID_HANDLE_VALUE)
+ filesystem_error("could not access file " + path);
+ HANDLE mapping = CreateFileMapping(file, 0, PAGE_READONLY, 0, 0, 0);
+ if (mapping == 0)
+ filesystem_error("could not map file " + path);
+ start = MapViewOfFile(mapping, FILE_MAP_READ, 0, 0, 0);
+ extent = GetFileSize(file, 0);
+ CloseHandle(mapping);
+ CloseHandle(file);
+#elif defined(HAVE_SYS_STAT_H) && defined(HAVE_SYS_MMAN_H) && defined(HAVE_FCNTL_H)
+ struct stat s;
+ errno = 0;
+ if (stat(path.c_str(), &s) < 0)
+ filesystem_error("could not access file " + path);
+ else if (!S_ISREG(s.st_mode))
+ filesystem_error(path + " is not a regular file");
+ int fd = open(path.c_str(), O_RDONLY);
+ if (fd < 0)
+ filesystem_error("could not open " + path);
+ start = mmap(Pointer(), s.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
+ close(fd);
+ if (start == MAP_FAILED)
+ filesystem_error("could not map file " + path);
+ extent = s.st_size;
+#else
+# error "Don't know how to map a file on this platform"
+#endif // OPENAXIOM_MS_WINDOWS_HOST
+ }
+
+ FileMapping::~FileMapping() {
+#if defined(OPENAXIOM_MS_WINDOWS_HOST)
+ UnmapViewOfFile(start);
+#elif defined(HAVE_SYS_MMAN_H)
+ munmap(start, extent);
+#else
+# error "Don't know how to unmap a file on this platform"
+#endif
+ }
+ }
+}