Squashed 'third_party/ctemplate/' content from commit 6742f62
Change-Id: I828e4e4c906f13ba19944d78a8a78652b62949af
git-subtree-dir: third_party/ctemplate
git-subtree-split: 6742f6233db12f545e90baa8f34f5c29c4eb396a
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..044c44e
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+google-ctemplate@googlegroups.com
+
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..e4956cf
--- /dev/null
+++ b/COPYING
@@ -0,0 +1,28 @@
+Copyright (c) 2005, Google Inc.
+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 Google Inc. 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.
diff --git a/ChangeLog b/ChangeLog
new file mode 100644
index 0000000..0b20f2f
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,287 @@
+Wed Mar 19 20:02:51 2014 Olaf van der Spek <olafvdspek@gmail.com>
+
+ * ctemplate: version 2.3 release
+ * Fixed some more C++11 issues.
+ * Removed deprecated Template::SetEscapedValueAndShowSection()
+ * and Template::ReloadIfChanged().
+
+Wed Apr 18 23:36:08 2012 Olaf van der Spek <olafvdspek@gmail.com>
+
+ * ctemplate: version 2.2 release
+ * Fixed several issues reported by G++ 4.7
+
+Thu Mar 22 00:29:09 2012 Olaf van der Spek <olafvdspek@gmail.com>
+
+ * ctemplate: version 2.1 release
+ * Added operator[] to TemplateDictionary
+ * Added begin(), end(), data() and size() to TemplateString
+ * Refactored code
+
+Tue Jan 24 16:00:51 2012 Google Inc. <google-ctemplate@googlegroups.com>
+
+ * ctemplate: version 2.0 release
+ * Changed the 'official' ctemplate email in setup.py/etc
+ * Rewrote docs to refer to Ctemplate, not Google Template
+ * Renamed google-ctemplate.sln to ctemplate.sln
+ * Changed copyright text to reflect Google's relinquished ownership
+
+Thu Dec 22 14:03:27 2011 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 1.1 release
+ * Make reloads always prefer files earlier on the search patch (ssas)
+ * PORTING: Add a default BSWAP32, needed for AIX (csilvers)
+ * Die at configure-time when g++ isn't installed
+
+Fri Aug 26 13:10:46 2011 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 1.0 release
+ * No changes since 1.0rc2
+
+Fri Jul 29 12:19:50 2011 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 1.0rc2 release
+ * BUGFIX: removed #includes of non-installed headers from installed ones
+ * BUGFIX: Make compile-test test against an install
+
+Fri Jul 22 15:31:05 2011 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 1.0rc1 release
+ * BUGFIX: Dumpers were ignoring a tpl-string 'length' (csilvers)
+ * BUGFIX: Add a needed $(top_srcdir) to Makefile.am
+ * Replace 0x00-0x1F with space in xml_escape (alexvod)
+ * Fix xml encoding to handle form-feed properly (ghurley)
+ * DOCUMENTATION: Wer missing some docs in the tarball (csilvers)
+ * BUILD: Update acx_pthread.m4 for nostdlib (Kacper)
+ * BUGFIX: Make CreateSectionIterator check tpl-globals (williasr)
+ * PORTING: Fix solaris build by getting rid of PATH_MAX (csilvers)
+
+Mon Jan 24 15:38:31 2011 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.99 release
+ * Accept . as part of tag/attr names when autoescaping (falmeida)
+ * Optimize javascript template escaping (blount)
+ * Allow <span dir=...> inside :H=snippet modifiers (jdtang)
+ * make_tpl_varnames can write multiple tpls to one file (jad)
+ * Add a few escaping modifier equivalences (jad)
+ * BUGFIX: Fix ReloadAllIfChanged() with path (panicker)
+ * PORTING: Relace tr with more portable sed, in tests (csilvers)
+ * Updated from autoconf 2.64 to autoconf 2.65
+
+Fri Sep 24 11:38:27 2010 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.98 release
+ * Add new image URL modifier: :I=html, :I=css, etc (jshneier, dougy)
+ * Allow lowercase words in pragma contexts (csilvers)
+ * Enable full-word matching for tpl filenames (aneeshnaman)
+ * Performance improvements for small_map (wonchun)
+ * Avoid some compiler warnings (mac)
+ * Fix a c++ conformance bug involving const (chandlerc)
+ * BUGFIX: never reload string templates (panicker)
+ * BUGFIX: Fix refcounting to avoid accessing freed memory (panicker)
+ * PORTING: Avoid SIBGUS on sparc by aligning memory more (csilvers)
+ * PORTING: Use isascii_is*() to avoid langtype issues (csilvers)
+ * PORTING: Fix 'class not properly dll-epxorted' warnings (csilvers)
+ * PORTING: Rename README.windows to README_windows.txt (csilvers)
+ * Made NEWS file non-empty.
+ * Added ctemplate.pc + ctemplate_nothreads.pc for pkg-config (csilvers)
+
+Mon Apr 19 15:55:23 2010 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.97 release
+ * Major API revamp: +TemplateCache, -Template (panicker, csilvers)
+ * Major documentation revamp: howto -> guide + reference (csilvers)
+ * Protect auto-generated #include files with header guard (dnovillo)
+ * Allow ftp:// in ValidateUrl modifier (martone)
+ * Speed up template modifiers (turnidge)
+ * BUGFIX: Fix a dnagling pointer in template-modifiers (csilvers)
+ * PORTING: cygwin/mingw now compile (due to autoconf macros) (csilvers)
+ * PORTING: improve generate_fs_test on windows (csilvers)
+
+Mon Oct 19 11:42:57 2009 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.96 release
+ * Support multiple template root directories (williasr)
+ * Remove TemplateContext from TemplateToString (jad)
+ * Remove programmatic auto-escape code (jad)
+ * Speedup: use linker to detect immutable TemplateStrings (csilvers)
+ * Implement ShowTemplateGlobalSection (williasr)
+ * Change SetIntValue to accept longs (omoikane)
+ * Allow TemplateDictionary c'tor to take a TemplateString (csilvers)
+ * Make Mutex safer to run during global destructors (csilvers)
+ * BUILD: don't set TMPDIR when building; ar reads it (csilvers)
+ * BUILD: fix compiling of C (as opposed to C++) test file (csilvers)
+ * BUILD: remove bash-specific 'test x == y' from configure.ac (csilvers)
+ * BUGFIX: use AllocAligned when allocating non-char objects (csilvers)
+ * PORTING: remove obsolete MSVC Detect64BitPortabilityProblems (csilvers)
+ * Updated from autoconf 2.61 to 2.62
+
+Fri Jun 12 08:13:35 2009 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.95 release
+ * Change default namespace from google to ctemplate
+ * Rename include directory from google to ctemplate
+ * Remove deprecated code: template_from_string.{h,cc}
+ * Remove deprecated code: modifiers in TemplateDictionary class
+ * Remove last arg from StringToTemplate; use autoescape pragma instead
+ * Remove template_modifiers namespace
+ * Provide a script to help convert namespaces and #includes
+ * TemplateDictionary constructor takes TemplateString, not string
+
+Thu May 7 11:27:28 2009 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.94 release
+ * Use arena for all memory allocations: 3-4% speedup (csilvers)
+ * Add the ability to hook the annotation system (ryoji)
+ * Expose Expand(ExpandEmitter*,...) to allow custom emitters (csilvers)
+ * Add RemoveStringFromTemplateCache (csilvers)
+ * Add new :url_escape_with_arg=css modifier for urls in CSS (jad)
+ * Support tr1's unordered_map in preference to hash_map (csilvers)
+ * Use Murmurhash for all string hashing, rather than hash<> (csilvers)
+ * Better parsing of meta tags and dangling < for auto-escape (falmeida)
+ * Add AddXssSafeModifier (jad)
+ * Allow disabling auto-escape for 'trusted' vars (jad)
+ * BUGFIX: resolve possible memory-leaks in CopyDictionary (csilvers)
+ * BUGFIX: fix bug when reloading with AUTOESCAPE pragma (jad)
+ * Updated autoconf version to 2.61 and libtool version to 1.5.26
+
+Mon Feb 2 13:51:33 2009 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.93 release
+ * New AUTOESCAPE pragma: alternative to GetTemplateWithAutoescaping (jad)
+ * Improve autoescape for CSS template and more (jad)
+ * Replace RegisterStringAsTemplate with TemplateToString (csilvers)
+ * Speed up template code by hashing and cacheing template strings (jcrim)
+ * Add StaticTemplateString to make hashing/cacheing even faster
+ * Autogenerate parser files from .config files (falmeida)
+ * TESTING: new compile_test to test end-to-end compilation (csilvers)
+ * Fix Mutex class to allow expanding template before main() (csilvers)
+
+Wed Nov 12 11:24:33 2008 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.92 release
+ * BUG FIX: affecting an included string-template with autoescaping (jad)
+ * BUG FIX: long-name cmdline flag in diff_tpl_auto_escape (jad)
+ * Do include-template indenting after applying modifiers (jad)
+ * Add human-readable error messages to the html parser (falmeida)
+ * Create an abstract base class for TemplateDictionary (williasr)
+ * PORTING: Be more careful about Windows #defines and types (csilvers)
+ * PORTING: Make unittest scripts more sh-compatible (falmeida)
+ * Show missing includes in annotated output (ribrdb)
+ * Improvements to javascript escaping (escape \f) (jad)
+ * Improvements to json escaping (escape <>&) (jad)
+ * Avoid raciness by preferring cached to new template-strings (csilvers)
+
+Tue Aug 19 16:20:27 2008 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.91 release
+ * NEW FEATURE: "separator" sections (csilvers)
+ * NEW FEATURE: changing the markup separator via {{=XXX YYY=}} (csilvers)
+ * NEW FEATURE: Add an Expand modifier to template dictionary (turnidge)
+ * TemplateAsString class -> Template::RegisterStringAsTemplate (edwardcu)
+ * TemplateModifier class -> PerExpandData class (csilvers)
+ * Store more data in the arena, shrinking TemplateDictionary (csilvers)
+ * Use TemplateString more widely internally; small speedup (adamk)
+ * Lazily initialize hash-maps, saving time and space (csilvers)
+ * Make template annotations more efficient (turnidge)
+ * PORTABILITY: Fixed a testing script to run on solaris x86 (csilvers)
+ * Fix namespaces to start with :: (csilvers)
+ * Improve html parser in various ways (falmeida)
+
+Sun Apr 27 15:06:15 2008 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.90 release
+ * MAJOR NEW FEATURE: New "auto-escape" mode (jad, falmeida, mughda)
+ * New tool, diff_tpl_auto_escape, to convert templates to auto-escaping
+ * Fixed make install to install test datafiles (csilvers)
+ * Add a new modifier: javascript_escape_with_arg=number (jad)
+ * Javascript modifier now escapes all js newlines (msamuel)
+
+Thu Jan 24 16:09:43 2008 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.9 release
+ * Bugfix: now we honor "preserve newlines in javacript" (ktl)
+ * Fix indentation of included templates (csilvers)
+ * Deprecate the SetEscaped* methods in favor of modifiers (csilvers)
+ * Revamp the way template modifiers are registered (csilvers)
+ * Change the psuedo-name of main section from __MAIN__ to __{{MAIN}}__
+ * Fix types to quiet windows compiler (csilvers)
+ * Allow infile and outfile for template-converter (ambrose)
+ * Some doc fixes
+
+Thu Aug 16 21:42:55 2007 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.8 release
+ * Add the ability to dynamically add modifiers (ribrdb)
+ * Support per-Expand() data for template modifiers (ribrdb)
+ * New commandline flag -f for make_tpl_varnames_h (herbertc)
+ * Windows: give debug dll and release dll different names (csilvers)
+ * A few fixups of Windows includes, based on user reports (csilvers)
+
+Tue Jul 3 12:46:59 2007 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.7 release
+ * Bugfix: another lock hygiene fix, for recursive includes (csilvers)
+ * Minor type-hygiene improvements: size_t for int, etc. (csilvers)
+ * Porting improvements: tests pass on OS X, FreeBSD, Solaris (csilvers)
+ * Windows port! -- VS solution provided for all unittests (csilvers)
+
+Thu Jun 21 14:02:32 2007 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.6.1 release
+ * Bugfix: data corruption bug with >2 template modifiers (jmacgill)
+ * Bugfix: syntax error in template-namelist: configure-bug (csilvers)
+ * Bugfix: improve lock hygiene to avoid potential deadlock (csilvers)
+
+Sat Jun 9 22:34:52 2007 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.6 release
+ * Use computed includes for hash_map/set: easier config (csilvers)
+ * Added all used .m4 templates to the distribution (csilvers)
+ * Beefed-up and revamped modifier code (csilvers)
+ * New modifiers for url-escaping, attribute-cleansing, etc (ribrdb)
+ * Annotations now include modifier information (csilvers)
+ * Support embedded NULs in template names and values (csilvers)
+
+Mon May 14 17:27:10 2007 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.5 release
+ * Add new MakeCopy() method to copy template dictionaries (csilvers)
+ * Add JSON-escaping (mikepurvis)
+ * Internal change that should ease thread-handling a bit (csilvers)
+ * Fix url_query_escape to avoid stack overflow (csilvers)
+
+Mon Jan 15 14:10:42 2007 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.4 release
+ * Improve html-escaping by adding single-quote (bdangelo)
+ * Improve javascript-escaping by adding more characters too (smknappy)
+ * Add url-escaping, for url query parameters (dcoker)
+ * Add support for "pre" escaping, which preserves whitespace (dboswell)
+ * Typo fixes in documentation (csilvers)
+ * Expand() returns false if a template file failed to load (jmittleman)
+
+Mon Aug 21 17:44:32 2006 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.3 release
+ * New contrib/ directory entry: vi syntax highlighting (patlac)
+ * New contrib/ directory entry: emacs syntax highlighting (tonyg)
+ * Allow escape-modifiers to affect includes, not just vars (csilvers)
+ separating logic from presentation.
+ * Add JSON escape-functor (majewski)
+
+Wed Jun 14 14:56:04 2006 Google Inc. <opensource@google.com>
+
+ * ctemplate: version 0.2 release
+ * API CHANGE: new typedefs (and types) for namelist functions (csilvers)
+ * carry annotation status through to child templates/sections (ehamon)
+ * Support registering templates after global construct time (njain)
+ * Add pthread-rwlock support for darwin (csilvers)
+ * SetTemplateGlobalValue(): new variable type with new scoping (ehamon)
+ * Export a nothreads version of the ctemplate library (csilvers)
+ * Got rid of scandir call, which should improve portability (csilvers)
+
+Mon Mar 13 22:20:46 2006 Google Inc. <opensource@google.com>
+
+ * ctemplate: initial release:
+ The ctemplate package contains a library implementing a simple
+ but powerful template language for C++. It emphasizes
diff --git a/INSTALL b/INSTALL
new file mode 100644
index 0000000..d3c5b40
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,237 @@
+Installation Instructions
+*************************
+
+Copyright (C) 1994, 1995, 1996, 1999, 2000, 2001, 2002, 2004, 2005,
+2006, 2007 Free Software Foundation, Inc.
+
+This file is free documentation; the Free Software Foundation gives
+unlimited permission to copy, distribute and modify it.
+
+Basic Installation
+==================
+
+Briefly, the shell commands `./configure; make; make install' should
+configure, build, and install this package. The following
+more-detailed instructions are generic; see the `README' file for
+instructions specific to this package.
+
+ The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation. It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions. Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, and a
+file `config.log' containing compiler output (useful mainly for
+debugging `configure').
+
+ It can also use an optional file (typically called `config.cache'
+and enabled with `--cache-file=config.cache' or simply `-C') that saves
+the results of its tests to speed up reconfiguring. Caching is
+disabled by default to prevent problems with accidental use of stale
+cache files.
+
+ If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release. If you are using the cache, and at
+some point `config.cache' contains results you don't want to keep, you
+may remove or edit it.
+
+ The file `configure.ac' (or `configure.in') is used to create
+`configure' by a program called `autoconf'. You need `configure.ac' if
+you want to change it or regenerate `configure' using a newer version
+of `autoconf'.
+
+The simplest way to compile this package is:
+
+ 1. `cd' to the directory containing the package's source code and type
+ `./configure' to configure the package for your system.
+
+ Running `configure' might take a while. While running, it prints
+ some messages telling which features it is checking for.
+
+ 2. Type `make' to compile the package.
+
+ 3. Optionally, type `make check' to run any self-tests that come with
+ the package.
+
+ 4. Type `make install' to install the programs and any data files and
+ documentation.
+
+ 5. You can remove the program binaries and object files from the
+ source code directory by typing `make clean'. To also remove the
+ files that `configure' created (so you can compile the package for
+ a different kind of computer), type `make distclean'. There is
+ also a `make maintainer-clean' target, but that is intended mainly
+ for the package's developers. If you use it, you may have to get
+ all sorts of other programs in order to regenerate files that came
+ with the distribution.
+
+ 6. Often, you can also type `make uninstall' to remove the installed
+ files again.
+
+Compilers and Options
+=====================
+
+Some systems require unusual options for compilation or linking that the
+`configure' script does not know about. Run `./configure --help' for
+details on some of the pertinent environment variables.
+
+ You can give `configure' initial values for configuration parameters
+by setting variables in the command line or in the environment. Here
+is an example:
+
+ ./configure CC=c99 CFLAGS=-g LIBS=-lposix
+
+ *Note Defining Variables::, for more details.
+
+Compiling For Multiple Architectures
+====================================
+
+You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory. To do this, you can use GNU `make'. `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script. `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+ With a non-GNU `make', it is safer to compile the package for one
+architecture at a time in the source code directory. After you have
+installed the package for one architecture, use `make distclean' before
+reconfiguring for another architecture.
+
+Installation Names
+==================
+
+By default, `make install' installs the package's commands under
+`/usr/local/bin', include files under `/usr/local/include', etc. You
+can specify an installation prefix other than `/usr/local' by giving
+`configure' the option `--prefix=PREFIX'.
+
+ You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files. If you
+pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+PREFIX as the prefix for installing programs and libraries.
+Documentation and other data files still use the regular prefix.
+
+ In addition, if you use an unusual directory layout you can give
+options like `--bindir=DIR' to specify different values for particular
+kinds of files. Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+ If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System). The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+ For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+There may be some features `configure' cannot figure out automatically,
+but needs to determine by the type of machine the package will run on.
+Usually, assuming the package is built to be run on the _same_
+architectures, `configure' can figure that out, but if it prints a
+message saying it cannot guess the machine type, give it the
+`--build=TYPE' option. TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name which has the form:
+
+ CPU-COMPANY-SYSTEM
+
+where SYSTEM can have one of these forms:
+
+ OS KERNEL-OS
+
+ See the file `config.sub' for the possible values of each field. If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the machine type.
+
+ If you are _building_ compiler tools for cross-compiling, you should
+use the option `--target=TYPE' to select the type of system they will
+produce code for.
+
+ If you want to _use_ a cross compiler, that generates code for a
+platform different from the build platform, you should specify the
+"host" platform (i.e., that on which the generated programs will
+eventually be run) with `--host=TYPE'.
+
+Sharing Defaults
+================
+
+If you want to set default values for `configure' scripts to share, you
+can create a site shell script called `config.site' that gives default
+values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists. Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Defining Variables
+==================
+
+Variables not defined in a site shell script can be set in the
+environment passed to `configure'. However, some packages may run
+configure again during the build, and the customized values of these
+variables may be lost. In order to avoid this problem, you should set
+them in the `configure' command line, using `VAR=value'. For example:
+
+ ./configure CC=/usr/local2/bin/gcc
+
+causes the specified `gcc' to be used as the C compiler (unless it is
+overridden in the site shell script).
+
+Unfortunately, this technique does not work for `CONFIG_SHELL' due to
+an Autoconf bug. Until the bug is fixed you can use this workaround:
+
+ CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash
+
+`configure' Invocation
+======================
+
+`configure' recognizes the following options to control how it operates.
+
+`--help'
+`-h'
+ Print a summary of the options to `configure', and exit.
+
+`--version'
+`-V'
+ Print the version of Autoconf used to generate the `configure'
+ script, and exit.
+
+`--cache-file=FILE'
+ Enable the cache: use and save the results of the tests in FILE,
+ traditionally `config.cache'. FILE defaults to `/dev/null' to
+ disable caching.
+
+`--config-cache'
+`-C'
+ Alias for `--cache-file=config.cache'.
+
+`--quiet'
+`--silent'
+`-q'
+ Do not print messages saying which checks are being made. To
+ suppress all normal output, redirect it to `/dev/null' (any error
+ messages will still be shown).
+
+`--srcdir=DIR'
+ Look for the package's source code in directory DIR. Usually
+ `configure' can determine that directory automatically.
+
+`configure' also accepts some other, not widely useful, options. Run
+`configure --help' for more details.
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..31040cc
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,513 @@
+## Process this file with automake to produce Makefile.in
+
+# Make sure that when we re-make ./configure, we get the macros we need
+ACLOCAL_AMFLAGS = -I m4
+
+# This is so we can #include <ctemplate/foo>
+AM_CPPFLAGS = -I$(top_srcdir)/src
+
+# These are good warnings to turn on by default
+if GCC
+AM_CXXFLAGS = -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
+endif
+
+# mingw does weird directory munging on /tmp, which causes some of our
+# tests to fail, so use a different tmpdir there.
+if MINGW
+TMPDIR = ./
+else
+TMPDIR = /tmp
+endif
+
+ctemplateincludedir = $(includedir)/ctemplate
+## The .h files you want to install (that is, .h files that people
+## who install this package can include in their own applications.)
+## We have to include both the .h and .h.in forms. The latter we
+## put in noinst_HEADERS.
+## NOTE: If you add a file here, also add it to the end of configure.ac
+nodist_ctemplateinclude_HEADERS = \
+ src/ctemplate/template.h \
+ src/ctemplate/template_cache.h \
+ src/ctemplate/template_string.h \
+ src/ctemplate/template_enums.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_dictionary_interface.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_namelist.h \
+ src/ctemplate/per_expand_data.h \
+ src/ctemplate/str_ref.h
+noinst_HEADERS = \
+ src/ctemplate/template.h.in \
+ src/ctemplate/template_cache.h.in \
+ src/ctemplate/template_string.h.in \
+ src/ctemplate/template_enums.h.in \
+ src/ctemplate/template_pathops.h.in \
+ src/ctemplate/template_modifiers.h.in \
+ src/ctemplate/template_dictionary.h.in \
+ src/ctemplate/template_dictionary_interface.h.in \
+ src/ctemplate/template_annotator.h.in \
+ src/ctemplate/template_emitter.h.in \
+ src/ctemplate/template_namelist.h.in \
+ src/ctemplate/per_expand_data.h.in \
+ src/ctemplate/str_ref.h.in
+
+docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
+## This is for HTML and other documentation you want to install.
+## Add your documentation files (in doc/) in addition to these
+## top-level boilerplate files. Also add a TODO file if you have one.
+dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README_windows.txt \
+ doc/designstyle.css doc/index.html \
+ doc/howto.html doc/guide.html doc/reference.html \
+ doc/tips.html doc/example.html doc/auto_escape.html \
+ doc/xss_resources.html
+
+## The libraries (.so's) you want to install
+lib_LTLIBRARIES =
+## Libraries that we want to use only internally (for our unittest binaries)
+noinst_LTLIBRARIES =
+## The binaries you want to install
+bin_PROGRAMS =
+bin_SCRIPTS =
+## The location of the windows project file for each binary we make
+WINDOWS_PROJECTS = ctemplate.sln
+
+
+## unittests you want to run when people type 'make check'.
+## TESTS is for binary unittests, check_SCRIPTS for script-based unittests.
+## TESTS_ENVIRONMENT sets environment variables for when you run unittest,
+## but it only seems to take effect for *binary* unittests (argh!)
+TESTS =
+check_SCRIPTS =
+TESTS_ENVIRONMENT = TEMPLATE_ROOTDIR=$(top_srcdir)
+# Every time you add a unittest to check_SCRIPTS, add it here too
+noinst_SCRIPTS =
+# Add to this for tests that use data
+TESTDATA =
+
+## vvvv RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
+
+# These files are auto-generated via generate_fsm.py. Since we don't want
+# to require python to build ctemplate, we include these in the dist
+src/htmlparser/htmlparser_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/htmlparser/htmlparser_fsm.config
+ $(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/htmlparser/htmlparser_fsm.config > $@
+
+src/htmlparser/jsparser_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/htmlparser/jsparser_fsm.config
+ $(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/htmlparser/jsparser_fsm.config > $@
+
+src/tests/statemachine_test_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/tests/statemachine_test_fsm.config
+ $(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/tests/statemachine_test_fsm.config > $@
+
+# This is a required hack for auto-generated .h files: cf the automake info pages
+# NOTE: since we put these .h files in BUILT_SOURCES, we don't need to put
+# them in as deps for the binaries that use them. In fact, it's important
+# that we don't; instead we put them in EXTRA_DIST. This mean, in practice,
+# they'll go at the end of the distribution tarfile, which means they'll
+# have a later timestamp than the .config files that generate them, which
+# means users won't try to rebuild them. Ah, the joys of automake.
+BUILT_SOURCES = src/htmlparser/htmlparser_fsm.h \
+ src/htmlparser/jsparser_fsm.h \
+ src/tests/statemachine_test_fsm.h
+
+
+# These are the symbols (classes, mostly) we want to export from our library.
+# Note this regexp applies to the *mangled* name, which is why we have to
+# be careful where we want to assert [^A-Za-z]. (Particularly bad on Darwin.)
+# template_modifiers and BaseArena and UnsafeArena perhaps shouldn't be
+# exported, but they're needed -- at least -- for some unittests.
+CTEMPLATE_SYMBOLS = '(ctemplate|template_modifiers|BaseArena|UnsafeArena|[^A-Za-z]Template[^A-Za-z]|TemplateDictionary|TemplateNamelist|TemplateFromString|TemplateString|TemplateState|[^A-Za-z]Strip[^A-Za-z])'
+
+lib_LTLIBRARIES += libctemplate.la
+WINDOWS_PROJECTS += vsprojects/libctemplate/libctemplate.vcproj
+libctemplate_la_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/base/arena-inl.h \
+ src/base/arena.cc \
+ src/base/arena.h \
+ src/base/fileutil.h \
+ src/base/macros.h \
+ src/base/manual_constructor.h \
+ src/base/mutex.h \
+ src/base/small_map.h \
+ src/base/thread_annotations.h \
+ src/base/util.h \
+ src/indented_writer.h \
+ src/per_expand_data.cc \
+ src/template.cc \
+ src/template_annotator.cc \
+ src/template_cache.cc \
+ src/template_dictionary.cc \
+ src/template_modifiers.cc \
+ src/template_modifiers_internal.h \
+ src/template_namelist.cc \
+ src/template_pathops.cc \
+ src/template_string.cc \
+ src/htmlparser/htmlparser.cc \
+ src/htmlparser/htmlparser.h \
+ src/htmlparser/htmlparser_cpp.h \
+ src/htmlparser/jsparser.cc \
+ src/htmlparser/jsparser.h \
+ src/htmlparser/statemachine.cc \
+ src/htmlparser/statemachine.h
+libctemplate_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS)
+# -version-info gets passed to libtool
+libctemplate_la_LDFLAGS = $(PTHREAD_CFLAGS) \
+ -export-symbols-regex $(CTEMPLATE_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+libctemplate_la_LIBADD = $(PTHREAD_LIBS)
+
+# For MinGW, we need to bring in the windows port files
+if MINGW
+libctemplate_la_SOURCES += src/windows/port.h src/windows/port.cc
+endif MINGW
+
+# automake will make different .o files for this library, which is good,
+# because we use an extra compiler flag.
+lib_LTLIBRARIES += libctemplate_nothreads.la
+libctemplate_nothreads_la_SOURCES = $(libctemplate_la_SOURCES)
+libctemplate_nothreads_la_DEPENDENCIES = $(libctemplate_la_DEPENDENCIES)
+libctemplate_nothreads_la_CXXFLAGS = -DNDEBUG -DNO_THREADS $(AM_CXXFLAGS)
+libctemplate_nothreads_la_LDFLAGS = -export-symbols-regex $(CTEMPLATE_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+
+# For our tests, we want versions of these libraries that include asserts.
+noinst_LTLIBRARIES += libctemplate_debug.la
+libctemplate_debug_la_SOURCES = $(libctemplate_la_SOURCES)
+libctemplate_debug_la_DEPENDENCIES = $(libctemplate_la_DEPENDENCIES)
+libctemplate_debug_la_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+libctemplate_debug_la_LDFLAGS = $(libctemplate_la_LDFLAGS)
+libctemplate_debug_la_LIBADD = $(libctemplate_la_LIBADD)
+noinst_LTLIBRARIES += libctemplate_nothreads_debug.la
+libctemplate_nothreads_debug_la_SOURCES = $(libctemplate_nothreads_la_SOURCES)
+libctemplate_nothreads_debug_la_DEPENDENCIES = $(libctemplate_nothreads_la_DEPENDENCIES)
+libctemplate_nothreads_debug_la_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+libctemplate_nothreads_debug_la_LDFLAGS = $(libctemplate_nothreads_la_LDFLAGS)
+
+# We could also make a library that has the TemplateDictionaryPeer
+# class. This class is useful for testing (it provides introspection
+# on the TemplateDictionary hierarchy that's easier to use than the
+# default debugging method, TemplateDictionary::Dump()) but by the
+# same token also violates abstraction in ways that might be fragile.
+# We don't expose the library for now, until the demonstrated need
+# outweighs the costs. If you'd like to use this library, please send
+# mail to google-ctemplate@googlegroups.com!
+##lib_LTLIBRARIES += libctemplate_testing.la
+noinst_LTLIBRARIES += libctemplate_testing.la libctemplate_testing_nothreads.la
+libctemplate_testing_la_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/tests/template_test_util.h \
+ src/tests/template_test_util.cc
+libctemplate_testing_la_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+CTEMPLATE_TESTING_SYMBOLS = 'TemporaryRegisterTemplate|TemplateDictionaryPeer'
+libctemplate_testing_la_LDFLAGS = $(PTHREAD_CFLAGS) \
+ -export-symbols-regex $(CTEMPLATE_TESTING_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+libctemplate_testing_la_LIBADD = $(PTHREAD_LIBS)
+libctemplate_testing_nothreads_la_SOURCES = $(libctemplate_testing_la_SOURCES)
+libctemplate_testing_nothreads_la_CXXFLAGS = $(AM_CXXFLAGS) -DNO_THREADS
+libctemplate_testing_nothreads_la_LDFLAGS = -export-symbols-regex $(CTEMPLATE_TESTING_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+
+# This library depends on libctemplate, but it can use either libctemplate
+# or libctemplate_nothreads. Rather than have two versions of this
+# library, I just leave out the deps entirely: you must be sure to specify
+# one of the two whenever you link this library into your code.
+#libctemplate_testing_la_LIBADD = libctemplate.la # or libctemplate_nothreads.la
+
+
+# Helper apps
+bin_PROGRAMS += make_tpl_varnames_h
+WINDOWS_PROJECTS += vsprojects/make_tpl_varname_h/make_tpl_varname_h.vcproj
+make_tpl_varnames_h_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/make_tpl_varnames_h.cc
+make_tpl_varnames_h_LDADD = libctemplate_nothreads.la
+
+bin_PROGRAMS += diff_tpl_auto_escape
+WINDOWS_PROJECTS += vsprojects/diff_tpl_auto_escape/diff_tpl_auto_escape.vcproj
+diff_tpl_auto_escape_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/diff_tpl_auto_escape.cc
+diff_tpl_auto_escape_LDADD = libctemplate_nothreads.la
+
+bin_SCRIPTS += src/template-converter
+
+# For each of the tests, we test with and without threads
+
+TESTS += compile_test compile_nothreads_test
+WINDOWS_PROJECTS += vsprojects/compile_test/compile_test.vcproj
+compile_test_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/tests/compile_test.cc
+compile_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+compile_test_LDFLAGS = $(PTHREAD_CFLAGS)
+compile_test_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
+compile_nothreads_test_SOURCES = $(compile_test_SOURCES)
+compile_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+compile_nothreads_test_LDADD = libctemplate_nothreads_debug.la
+
+# With compile_test, we are making sure that the code compiles without
+# needing config.h/etc. The best test is to make sure we can compile
+# with just the installed header files. The best way to do this is at
+# installcheck time. When this rule is run (via 'make distcheck'),
+# 'includedir' is the installed include-dir.
+installcheck-local:
+ $(CXX) -I $(includedir) -c $(top_srcdir)/src/tests/compile_test.cc \
+ -o installcheck_compile_test.o
+
+TESTS += template_test_util_test template_test_util_nothreads_test
+WINDOWS_PROJECTS += vsprojects/template_test_util_test/template_test_util_test.vcproj
+template_test_util_test_SOURCES = src/tests/config_for_unittests.h \
+ src/template_dictionary.cc \
+ src/tests/template_test_util_test.cc
+template_test_util_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_test_util_test_LDFLAGS = $(PTHREAD_CFLAGS)
+template_test_util_test_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+template_test_util_nothreads_test_SOURCES = $(template_test_util_test_SOURCES)
+template_test_util_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_test_util_nothreads_test_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+TESTS += template_dictionary_unittest template_dictionary_nothreads_unittest
+WINDOWS_PROJECTS += vsprojects/template_dictionary_unittest/template_dictionary_unittest.vcproj
+template_dictionary_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/base/arena.h \
+ src/tests/template_dictionary_unittest.cc
+template_dictionary_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_dictionary_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_dictionary_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+template_dictionary_nothreads_unittest_SOURCES = $(template_dictionary_unittest_SOURCES)
+template_dictionary_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_dictionary_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+TESTS += template_modifiers_unittest template_modifiers_nothreads_unittest
+WINDOWS_PROJECTS += vsprojects/template_modifiers_unittest/template_modifiers_unittest.vcproj
+template_modifiers_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/tests/template_modifiers_unittest.cc
+template_modifiers_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_modifiers_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_modifiers_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+template_modifiers_nothreads_unittest_SOURCES = $(template_modifiers_unittest_SOURCES)
+template_modifiers_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_modifiers_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+TESTS += template_setglobals_unittest template_setglobals_nothreads_unittest
+WINDOWS_PROJECTS += vsprojects/template_setglobals_unittest/template_setglobals_unittest.vcproj
+template_setglobals_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/tests/template_setglobals_unittest.cc
+template_setglobals_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_setglobals_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_setglobals_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+template_setglobals_nothreads_unittest_SOURCES = $(template_setglobals_unittest_SOURCES)
+template_setglobals_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_setglobals_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+TESTS += template_cache_test template_cache_nothreads_test
+WINDOWS_PROJECTS += vsprojects/template_cache_test/template_cache_test.vcproj
+template_cache_test_SOURCES = src/tests/config_for_unittests.h \
+ src/template_modifiers_internal.h \
+ src/tests/template_cache_test.cc
+template_cache_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_cache_test_LDFLAGS = $(PTHREAD_CFLAGS)
+template_cache_test_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+template_cache_nothreads_test_SOURCES = $(template_cache_test_SOURCES)
+template_cache_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_cache_nothreads_test_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+TESTS += template_unittest template_nothreads_unittest
+WINDOWS_PROJECTS += vsprojects/template_unittest/template_unittest.vcproj
+WINDOWS_PROJECTS += vsprojects/template_unittest_static/template_unittest_static.vcproj
+template_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/template_modifiers_internal.h \
+ src/tests/template_unittest.cc
+template_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+template_nothreads_unittest_SOURCES = $(template_unittest_SOURCES)
+template_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+TESTS += template_regtest template_nothreads_regtest
+WINDOWS_PROJECTS += vsprojects/template_regtest/template_regtest.vcproj
+template_regtest_SOURCES = src/tests/template_regtest.cc
+template_regtest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_regtest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_regtest_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
+template_nothreads_regtest_SOURCES = $(template_regtest_SOURCES)
+template_nothreads_regtest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_nothreads_regtest_LDADD = libctemplate_nothreads_debug.la
+TESTDATA += \
+ src/tests/template_unittest_test_footer.in \
+ src/tests/template_unittest_test_html.in \
+ src/tests/template_unittest_test_invalid1.in \
+ src/tests/template_unittest_test_invalid2.in \
+ src/tests/template_unittest_test_markerdelim.in \
+ src/tests/template_unittest_test_modifiers.in \
+ src/tests/template_unittest_test_nul.in \
+ src/tests/template_unittest_test_selective_css.in \
+ src/tests/template_unittest_test_selective_html.in \
+ src/tests/template_unittest_test_selective_js.in \
+ src/tests/template_unittest_test_simple.in \
+ src/tests/template_unittest_test_valid1.in \
+ src/tests/template_unittest_test_footer_dict01.out \
+ src/tests/template_unittest_test_footer_dict02.out \
+ src/tests/template_unittest_test_html_dict01.out \
+ src/tests/template_unittest_test_html_dict02.out \
+ src/tests/template_unittest_test_markerdelim_dict01.out \
+ src/tests/template_unittest_test_markerdelim_dict02.out \
+ src/tests/template_unittest_test_modifiers_dict01.out \
+ src/tests/template_unittest_test_nul_dict01.out \
+ src/tests/template_unittest_test_selective_css_dict01.out \
+ src/tests/template_unittest_test_selective_css_dict02.out \
+ src/tests/template_unittest_test_selective_html_dict01.out \
+ src/tests/template_unittest_test_selective_html_dict02.out \
+ src/tests/template_unittest_test_selective_js_dict01.out \
+ src/tests/template_unittest_test_selective_js_dict02.out \
+ src/tests/template_unittest_test_simple_dict01.out \
+ src/tests/template_unittest_test_simple_dict02.out \
+ src/tests/template_unittest_test_simple_dict03.out \
+ src/tests/template_unittest_test_valid1_dict01.out
+
+TESTS += htmlparser_test htmlparser_nothreads_test
+WINDOWS_PROJECTS += vsprojects/htmlparser_test/htmlparser_test.vcproj
+htmlparser_test_SOURCES = src/tests/htmlparser_cpp_test.cc
+htmlparser_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+htmlparser_test_LDFLAGS = $(PTHREAD_CFLAGS)
+htmlparser_test_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
+htmlparser_nothreads_test_SOURCES = $(htmlparser_test_SOURCES)
+htmlparser_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+htmlparser_nothreads_test_LDADD = libctemplate_nothreads_debug.la
+TESTDATA += \
+ src/tests/htmlparser_testdata/cdata.html \
+ src/tests/htmlparser_testdata/comments.html \
+ src/tests/htmlparser_testdata/context.html \
+ src/tests/htmlparser_testdata/google.html \
+ src/tests/htmlparser_testdata/javascript_attribute.html \
+ src/tests/htmlparser_testdata/javascript_block.html \
+ src/tests/htmlparser_testdata/javascript_regexp.html \
+ src/tests/htmlparser_testdata/position.html \
+ src/tests/htmlparser_testdata/reset.html \
+ src/tests/htmlparser_testdata/simple.html \
+ src/tests/htmlparser_testdata/tags.html
+
+# We want to compile statemachine.cc as a c file as well as a c++ file
+
+statemachine.c: src/htmlparser/statemachine.cc
+ $(LN_S) src/htmlparser/statemachine.cc $@
+
+BUILT_SOURCES += statemachine.c
+CLEANFILES = statemachine.c
+
+TESTS += statemachine_test
+WINDOWS_PROJECTS += vsprojects/statemachine_test/statemachine_test.vcproj
+statemachine_test_SOURCES = src/tests/statemachine_test.c \
+ statemachine.c
+statemachine_test_CFLAGS = -I$(top_srcdir)/src/htmlparser
+
+TESTS += generate_fsm_c_test
+WINDOWS_PROJECTS += vsprojects/generate_fsm_c_test/generate_fsm_c_test.vcproj
+generate_fsm_c_test_SOURCES = src/tests/generate_fsm_c_test.c
+generate_fsm_c_test_DEPENDENCIES = src/tests/htmlparser_testdata/sample_fsm.c
+
+# This is something only maintainers need (since they're the only ones
+# who generate .h or .c files from .config files).
+check_SCRIPTS += generate_fsm_test_sh
+noinst_SCRIPTS += src/tests/generate_fsm_test.sh
+generate_fsm_test_sh: src/tests/generate_fsm_test.sh \
+ src/tests/htmlparser_testdata/sample_fsm.config \
+ src/tests/htmlparser_testdata/sample_fsm.c \
+ src/htmlparser/generate_fsm.py
+ sh $(top_srcdir)/src/tests/generate_fsm_test.sh $(top_srcdir)
+TESTDATA += \
+ src/tests/htmlparser_testdata/sample_fsm.config \
+ src/tests/htmlparser_testdata/sample_fsm.c
+
+check_SCRIPTS += make_tpl_varnames_h_unittest_sh
+noinst_SCRIPTS += src/tests/make_tpl_varnames_h_unittest.sh
+make_tpl_varnames_h_unittest_sh: src/tests/make_tpl_varnames_h_unittest.sh \
+ make_tpl_varnames_h
+ sh $(top_srcdir)/src/tests/make_tpl_varnames_h_unittest.sh \
+ $(top_builddir)/make_tpl_varnames_h $(TMPDIR)/$@_dir
+
+check_SCRIPTS += diff_tpl_auto_escape_unittest_sh
+noinst_SCRIPTS += src/tests/diff_tpl_auto_escape_unittest.sh
+diff_tpl_auto_escape_unittest_sh: src/tests/diff_tpl_auto_escape_unittest.sh \
+ diff_tpl_auto_escape
+ sh $(top_srcdir)/src/tests/diff_tpl_auto_escape_unittest.sh \
+ $(top_builddir)/diff_tpl_auto_escape $(TMPDIR)/$@_dir
+
+## ^^^^ END OF RULES TO MAKE THE LIBRARIES, BINARIES, AND UNITTESTS
+
+## This should always include $(TESTS), but may also include other
+## binaries that you compile but don't want automatically installed.
+noinst_PROGRAMS = $(TESTS)
+
+rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
+ @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
+
+deb: dist-gzip packages/deb.sh packages/deb/*
+ @cd packages && ./deb.sh ${PACKAGE} ${VERSION}
+
+# http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = lib${PACKAGE}.pc lib${PACKAGE}_nothreads.pc
+CLEANFILES += $(pkgconfig_DATA)
+
+# I get the description and URL lines from the rpm spec. I use sed to
+# try to rewrite exec_prefix, libdir, and includedir in terms of
+# prefix, if possible.
+lib${PACKAGE}.pc: Makefile packages/rpm/rpm.spec
+ echo 'prefix=$(prefix)' > "$@".tmp
+ echo 'exec_prefix='`echo '$(exec_prefix)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
+ echo 'libdir='`echo '$(libdir)' | sed 's@^$(exec_prefix)@$${exec_prefix}@'` >> "$@".tmp
+ echo 'includedir='`echo '$(includedir)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
+ echo '' >> "$@".tmp
+ echo 'Name: $(PACKAGE)' >> "$@".tmp
+ echo 'Version: $(VERSION)' >> "$@".tmp
+ -grep '^Summary:' $(top_srcdir)/packages/rpm/rpm.spec | sed s/^Summary:/Description:/ | head -n1 >> "$@".tmp
+ -grep '^URL: ' $(top_srcdir)/packages/rpm/rpm.spec >> "$@".tmp
+ echo 'Requires:' >> "$@".tmp
+ echo 'Libs: -L$${libdir} -l$(PACKAGE)' >> "$@".tmp
+ echo 'Libs.private: $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)' >> "$@".tmp
+ echo 'Cflags: -I$${includedir}' >> "$@".tmp
+ mv -f "$@".tmp "$@"
+
+# The nothreads version is mostly the same
+lib${PACKAGE}_nothreads.pc: lib${PACKAGE}.pc
+ grep -v Libs.private lib${PACKAGE}.pc | sed s/-l$(PACKAGE)/-l$(PACKAGE)_nothreads/ > "$@"
+
+# Windows wants write permission to .vcproj files and maybe even sln files.
+dist-hook:
+ test -e "$(distdir)/vsprojects" \
+ && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
+
+## If you're using libtool, add 'libtool' here. Also add this rule:
+libtool: $(LIBTOOL_DEPS)
+ $(SHELL) ./config.status --recheck
+
+# In addition to the normal stuff, we include all the windows-specific
+# code, and also the code used to generate the html-parser fsm files.
+# NOTE: BUILT_SOURCES should come after the .config files, so they
+# come later (and thus end up with a later timestamp) when we tar/untar.
+EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
+ $(SCRIPTS) $(TESTDATA) libtool autogen.sh \
+ src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py \
+ src/tests/statemachine_test_fsm.config \
+ src/htmlparser/htmlparser_fsm.config \
+ src/htmlparser/jsparser_fsm.config \
+ $(BUILT_SOURCES) \
+ src/windows/config.h src/windows/preprocess.sh \
+ src/windows/ctemplate $(WINDOWS_PROJECTS) \
+ src/solaris/libstdc++.la contrib
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..56330fd
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,3683 @@
+# Makefile.in generated by automake 1.14.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994-2013 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+
+
+VPATH = @srcdir@
+am__is_gnu_make = test -n '$(MAKEFILE_LIST)' && test -n '$(MAKELEVEL)'
+am__make_running_with_option = \
+ case $${target_option-} in \
+ ?) ;; \
+ *) echo "am__make_running_with_option: internal error: invalid" \
+ "target option '$${target_option-}' specified" >&2; \
+ exit 1;; \
+ esac; \
+ has_opt=no; \
+ sane_makeflags=$$MAKEFLAGS; \
+ if $(am__is_gnu_make); then \
+ sane_makeflags=$$MFLAGS; \
+ else \
+ case $$MAKEFLAGS in \
+ *\\[\ \ ]*) \
+ bs=\\; \
+ sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+ | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \
+ esac; \
+ fi; \
+ skip_next=no; \
+ strip_trailopt () \
+ { \
+ flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+ }; \
+ for flg in $$sane_makeflags; do \
+ test $$skip_next = yes && { skip_next=no; continue; }; \
+ case $$flg in \
+ *=*|--*) continue;; \
+ -*I) strip_trailopt 'I'; skip_next=yes;; \
+ -*I?*) strip_trailopt 'I';; \
+ -*O) strip_trailopt 'O'; skip_next=yes;; \
+ -*O?*) strip_trailopt 'O';; \
+ -*l) strip_trailopt 'l'; skip_next=yes;; \
+ -*l?*) strip_trailopt 'l';; \
+ -[dEDm]) skip_next=yes;; \
+ -[JT]) skip_next=yes;; \
+ esac; \
+ case $$flg in \
+ *$$target_option*) has_opt=yes; break;; \
+ esac; \
+ done; \
+ test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = make_tpl_varnames_h$(EXEEXT) \
+ diff_tpl_auto_escape$(EXEEXT)
+TESTS = compile_test$(EXEEXT) compile_nothreads_test$(EXEEXT) \
+ template_test_util_test$(EXEEXT) \
+ template_test_util_nothreads_test$(EXEEXT) \
+ template_dictionary_unittest$(EXEEXT) \
+ template_dictionary_nothreads_unittest$(EXEEXT) \
+ template_modifiers_unittest$(EXEEXT) \
+ template_modifiers_nothreads_unittest$(EXEEXT) \
+ template_setglobals_unittest$(EXEEXT) \
+ template_setglobals_nothreads_unittest$(EXEEXT) \
+ template_cache_test$(EXEEXT) \
+ template_cache_nothreads_test$(EXEEXT) \
+ template_unittest$(EXEEXT) \
+ template_nothreads_unittest$(EXEEXT) template_regtest$(EXEEXT) \
+ template_nothreads_regtest$(EXEEXT) htmlparser_test$(EXEEXT) \
+ htmlparser_nothreads_test$(EXEEXT) statemachine_test$(EXEEXT) \
+ generate_fsm_c_test$(EXEEXT)
+
+# For MinGW, we need to bring in the windows port files
+@MINGW_TRUE@am__append_1 = src/windows/port.h src/windows/port.cc
+noinst_PROGRAMS = $(am__EXEEXT_1)
+subdir = .
+DIST_COMMON = INSTALL NEWS README AUTHORS ChangeLog \
+ $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
+ $(top_srcdir)/configure $(am__configure_deps) \
+ $(top_srcdir)/src/config.h.in \
+ $(top_srcdir)/src/ctemplate/template_string.h.in \
+ $(top_srcdir)/src/ctemplate/template_enums.h.in \
+ $(top_srcdir)/src/ctemplate/template.h.in \
+ $(top_srcdir)/src/ctemplate/template_cache.h.in \
+ $(top_srcdir)/src/ctemplate/template_modifiers.h.in \
+ $(top_srcdir)/src/ctemplate/template_emitter.h.in \
+ $(top_srcdir)/src/ctemplate/template_annotator.h.in \
+ $(top_srcdir)/src/ctemplate/template_dictionary.h.in \
+ $(top_srcdir)/src/ctemplate/template_pathops.h.in \
+ $(top_srcdir)/src/ctemplate/template_namelist.h.in \
+ $(top_srcdir)/src/ctemplate/find_ptr.h.in \
+ $(top_srcdir)/src/ctemplate/per_expand_data.h.in \
+ $(top_srcdir)/src/ctemplate/str_ref.h.in \
+ $(top_srcdir)/src/ctemplate/template_dictionary_interface.h.in \
+ depcomp $(dist_doc_DATA) $(noinst_HEADERS) test-driver COPYING \
+ compile config.guess config.sub install-sh missing ltmain.sh
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_have_attribute.m4 \
+ $(top_srcdir)/m4/ac_interlocked_exchange.m4 \
+ $(top_srcdir)/m4/ac_rwlock.m4 $(top_srcdir)/m4/acx_pthread.m4 \
+ $(top_srcdir)/m4/compiler_characteristics.m4 \
+ $(top_srcdir)/m4/google_namespace.m4 \
+ $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \
+ $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \
+ $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/namespaces.m4 \
+ $(top_srcdir)/m4/stl_hash.m4 $(top_srcdir)/m4/stl_namespace.m4 \
+ $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/src/config.h
+CONFIG_CLEAN_FILES = src/ctemplate/template_string.h \
+ src/ctemplate/template_enums.h src/ctemplate/template.h \
+ src/ctemplate/template_cache.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_namelist.h src/ctemplate/find_ptr.h \
+ src/ctemplate/per_expand_data.h src/ctemplate/str_ref.h \
+ src/ctemplate/template_dictionary_interface.h
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+ test -z "$$files" \
+ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+ $(am__cd) "$$dir" && rm -f $$files; }; \
+ }
+am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" \
+ "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" \
+ "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(ctemplateincludedir)"
+LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libctemplate_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am__libctemplate_la_SOURCES_DIST = src/ctemplate/template.h \
+ src/ctemplate/template_cache.h src/ctemplate/template_string.h \
+ src/ctemplate/template_enums.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_dictionary_interface.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_namelist.h \
+ src/ctemplate/per_expand_data.h src/ctemplate/str_ref.h \
+ src/base/arena-inl.h src/base/arena.cc src/base/arena.h \
+ src/base/fileutil.h src/base/macros.h \
+ src/base/manual_constructor.h src/base/mutex.h \
+ src/base/small_map.h src/base/thread_annotations.h \
+ src/base/util.h src/indented_writer.h src/per_expand_data.cc \
+ src/template.cc src/template_annotator.cc \
+ src/template_cache.cc src/template_dictionary.cc \
+ src/template_modifiers.cc src/template_modifiers_internal.h \
+ src/template_namelist.cc src/template_pathops.cc \
+ src/template_string.cc src/htmlparser/htmlparser.cc \
+ src/htmlparser/htmlparser.h src/htmlparser/htmlparser_cpp.h \
+ src/htmlparser/jsparser.cc src/htmlparser/jsparser.h \
+ src/htmlparser/statemachine.cc src/htmlparser/statemachine.h \
+ src/windows/port.h src/windows/port.cc
+am__objects_1 =
+am__dirstamp = $(am__leading_dot)dirstamp
+@MINGW_TRUE@am__objects_2 = src/windows/libctemplate_la-port.lo
+am_libctemplate_la_OBJECTS = $(am__objects_1) \
+ src/base/libctemplate_la-arena.lo \
+ src/libctemplate_la-per_expand_data.lo \
+ src/libctemplate_la-template.lo \
+ src/libctemplate_la-template_annotator.lo \
+ src/libctemplate_la-template_cache.lo \
+ src/libctemplate_la-template_dictionary.lo \
+ src/libctemplate_la-template_modifiers.lo \
+ src/libctemplate_la-template_namelist.lo \
+ src/libctemplate_la-template_pathops.lo \
+ src/libctemplate_la-template_string.lo \
+ src/htmlparser/libctemplate_la-htmlparser.lo \
+ src/htmlparser/libctemplate_la-jsparser.lo \
+ src/htmlparser/libctemplate_la-statemachine.lo \
+ $(am__objects_2)
+libctemplate_la_OBJECTS = $(am_libctemplate_la_OBJECTS)
+AM_V_lt = $(am__v_lt_@AM_V@)
+am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@)
+am__v_lt_0 = --silent
+am__v_lt_1 =
+libctemplate_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) \
+ $(libctemplate_la_LDFLAGS) $(LDFLAGS) -o $@
+am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
+am__libctemplate_debug_la_SOURCES_DIST = src/ctemplate/template.h \
+ src/ctemplate/template_cache.h src/ctemplate/template_string.h \
+ src/ctemplate/template_enums.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_dictionary_interface.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_namelist.h \
+ src/ctemplate/per_expand_data.h src/ctemplate/str_ref.h \
+ src/base/arena-inl.h src/base/arena.cc src/base/arena.h \
+ src/base/fileutil.h src/base/macros.h \
+ src/base/manual_constructor.h src/base/mutex.h \
+ src/base/small_map.h src/base/thread_annotations.h \
+ src/base/util.h src/indented_writer.h src/per_expand_data.cc \
+ src/template.cc src/template_annotator.cc \
+ src/template_cache.cc src/template_dictionary.cc \
+ src/template_modifiers.cc src/template_modifiers_internal.h \
+ src/template_namelist.cc src/template_pathops.cc \
+ src/template_string.cc src/htmlparser/htmlparser.cc \
+ src/htmlparser/htmlparser.h src/htmlparser/htmlparser_cpp.h \
+ src/htmlparser/jsparser.cc src/htmlparser/jsparser.h \
+ src/htmlparser/statemachine.cc src/htmlparser/statemachine.h \
+ src/windows/port.h src/windows/port.cc
+@MINGW_TRUE@am__objects_3 = src/windows/libctemplate_debug_la-port.lo
+am__objects_4 = $(am__objects_1) \
+ src/base/libctemplate_debug_la-arena.lo \
+ src/libctemplate_debug_la-per_expand_data.lo \
+ src/libctemplate_debug_la-template.lo \
+ src/libctemplate_debug_la-template_annotator.lo \
+ src/libctemplate_debug_la-template_cache.lo \
+ src/libctemplate_debug_la-template_dictionary.lo \
+ src/libctemplate_debug_la-template_modifiers.lo \
+ src/libctemplate_debug_la-template_namelist.lo \
+ src/libctemplate_debug_la-template_pathops.lo \
+ src/libctemplate_debug_la-template_string.lo \
+ src/htmlparser/libctemplate_debug_la-htmlparser.lo \
+ src/htmlparser/libctemplate_debug_la-jsparser.lo \
+ src/htmlparser/libctemplate_debug_la-statemachine.lo \
+ $(am__objects_3)
+am_libctemplate_debug_la_OBJECTS = $(am__objects_4)
+libctemplate_debug_la_OBJECTS = $(am_libctemplate_debug_la_OBJECTS)
+libctemplate_debug_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) \
+ $(libctemplate_debug_la_LDFLAGS) $(LDFLAGS) -o $@
+libctemplate_nothreads_la_LIBADD =
+am__libctemplate_nothreads_la_SOURCES_DIST = src/ctemplate/template.h \
+ src/ctemplate/template_cache.h src/ctemplate/template_string.h \
+ src/ctemplate/template_enums.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_dictionary_interface.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_namelist.h \
+ src/ctemplate/per_expand_data.h src/ctemplate/str_ref.h \
+ src/base/arena-inl.h src/base/arena.cc src/base/arena.h \
+ src/base/fileutil.h src/base/macros.h \
+ src/base/manual_constructor.h src/base/mutex.h \
+ src/base/small_map.h src/base/thread_annotations.h \
+ src/base/util.h src/indented_writer.h src/per_expand_data.cc \
+ src/template.cc src/template_annotator.cc \
+ src/template_cache.cc src/template_dictionary.cc \
+ src/template_modifiers.cc src/template_modifiers_internal.h \
+ src/template_namelist.cc src/template_pathops.cc \
+ src/template_string.cc src/htmlparser/htmlparser.cc \
+ src/htmlparser/htmlparser.h src/htmlparser/htmlparser_cpp.h \
+ src/htmlparser/jsparser.cc src/htmlparser/jsparser.h \
+ src/htmlparser/statemachine.cc src/htmlparser/statemachine.h \
+ src/windows/port.h src/windows/port.cc
+@MINGW_TRUE@am__objects_5 = \
+@MINGW_TRUE@ src/windows/libctemplate_nothreads_la-port.lo
+am__objects_6 = $(am__objects_1) \
+ src/base/libctemplate_nothreads_la-arena.lo \
+ src/libctemplate_nothreads_la-per_expand_data.lo \
+ src/libctemplate_nothreads_la-template.lo \
+ src/libctemplate_nothreads_la-template_annotator.lo \
+ src/libctemplate_nothreads_la-template_cache.lo \
+ src/libctemplate_nothreads_la-template_dictionary.lo \
+ src/libctemplate_nothreads_la-template_modifiers.lo \
+ src/libctemplate_nothreads_la-template_namelist.lo \
+ src/libctemplate_nothreads_la-template_pathops.lo \
+ src/libctemplate_nothreads_la-template_string.lo \
+ src/htmlparser/libctemplate_nothreads_la-htmlparser.lo \
+ src/htmlparser/libctemplate_nothreads_la-jsparser.lo \
+ src/htmlparser/libctemplate_nothreads_la-statemachine.lo \
+ $(am__objects_5)
+am_libctemplate_nothreads_la_OBJECTS = $(am__objects_6)
+libctemplate_nothreads_la_OBJECTS = \
+ $(am_libctemplate_nothreads_la_OBJECTS)
+libctemplate_nothreads_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) \
+ $(libctemplate_nothreads_la_LDFLAGS) $(LDFLAGS) -o $@
+libctemplate_nothreads_debug_la_LIBADD =
+am__libctemplate_nothreads_debug_la_SOURCES_DIST = \
+ src/ctemplate/template.h src/ctemplate/template_cache.h \
+ src/ctemplate/template_string.h src/ctemplate/template_enums.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_dictionary_interface.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_namelist.h \
+ src/ctemplate/per_expand_data.h src/ctemplate/str_ref.h \
+ src/base/arena-inl.h src/base/arena.cc src/base/arena.h \
+ src/base/fileutil.h src/base/macros.h \
+ src/base/manual_constructor.h src/base/mutex.h \
+ src/base/small_map.h src/base/thread_annotations.h \
+ src/base/util.h src/indented_writer.h src/per_expand_data.cc \
+ src/template.cc src/template_annotator.cc \
+ src/template_cache.cc src/template_dictionary.cc \
+ src/template_modifiers.cc src/template_modifiers_internal.h \
+ src/template_namelist.cc src/template_pathops.cc \
+ src/template_string.cc src/htmlparser/htmlparser.cc \
+ src/htmlparser/htmlparser.h src/htmlparser/htmlparser_cpp.h \
+ src/htmlparser/jsparser.cc src/htmlparser/jsparser.h \
+ src/htmlparser/statemachine.cc src/htmlparser/statemachine.h \
+ src/windows/port.h src/windows/port.cc
+@MINGW_TRUE@am__objects_7 = src/windows/libctemplate_nothreads_debug_la-port.lo
+am__objects_8 = $(am__objects_1) \
+ src/base/libctemplate_nothreads_debug_la-arena.lo \
+ src/libctemplate_nothreads_debug_la-per_expand_data.lo \
+ src/libctemplate_nothreads_debug_la-template.lo \
+ src/libctemplate_nothreads_debug_la-template_annotator.lo \
+ src/libctemplate_nothreads_debug_la-template_cache.lo \
+ src/libctemplate_nothreads_debug_la-template_dictionary.lo \
+ src/libctemplate_nothreads_debug_la-template_modifiers.lo \
+ src/libctemplate_nothreads_debug_la-template_namelist.lo \
+ src/libctemplate_nothreads_debug_la-template_pathops.lo \
+ src/libctemplate_nothreads_debug_la-template_string.lo \
+ src/htmlparser/libctemplate_nothreads_debug_la-htmlparser.lo \
+ src/htmlparser/libctemplate_nothreads_debug_la-jsparser.lo \
+ src/htmlparser/libctemplate_nothreads_debug_la-statemachine.lo \
+ $(am__objects_7)
+am__objects_9 = $(am__objects_8)
+am_libctemplate_nothreads_debug_la_OBJECTS = $(am__objects_9)
+libctemplate_nothreads_debug_la_OBJECTS = \
+ $(am_libctemplate_nothreads_debug_la_OBJECTS)
+libctemplate_nothreads_debug_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) \
+ $(libctemplate_nothreads_debug_la_LDFLAGS) $(LDFLAGS) -o $@
+libctemplate_testing_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
+am_libctemplate_testing_la_OBJECTS = $(am__objects_1) \
+ src/tests/libctemplate_testing_la-template_test_util.lo
+libctemplate_testing_la_OBJECTS = \
+ $(am_libctemplate_testing_la_OBJECTS)
+libctemplate_testing_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(libctemplate_testing_la_CXXFLAGS) $(CXXFLAGS) \
+ $(libctemplate_testing_la_LDFLAGS) $(LDFLAGS) -o $@
+libctemplate_testing_nothreads_la_LIBADD =
+am__objects_10 = $(am__objects_1) \
+ src/tests/libctemplate_testing_nothreads_la-template_test_util.lo
+am_libctemplate_testing_nothreads_la_OBJECTS = $(am__objects_10)
+libctemplate_testing_nothreads_la_OBJECTS = \
+ $(am_libctemplate_testing_nothreads_la_OBJECTS)
+libctemplate_testing_nothreads_la_LINK = $(LIBTOOL) $(AM_V_lt) \
+ --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+ $(CXXLD) $(libctemplate_testing_nothreads_la_CXXFLAGS) \
+ $(CXXFLAGS) $(libctemplate_testing_nothreads_la_LDFLAGS) \
+ $(LDFLAGS) -o $@
+am__EXEEXT_1 = compile_test$(EXEEXT) compile_nothreads_test$(EXEEXT) \
+ template_test_util_test$(EXEEXT) \
+ template_test_util_nothreads_test$(EXEEXT) \
+ template_dictionary_unittest$(EXEEXT) \
+ template_dictionary_nothreads_unittest$(EXEEXT) \
+ template_modifiers_unittest$(EXEEXT) \
+ template_modifiers_nothreads_unittest$(EXEEXT) \
+ template_setglobals_unittest$(EXEEXT) \
+ template_setglobals_nothreads_unittest$(EXEEXT) \
+ template_cache_test$(EXEEXT) \
+ template_cache_nothreads_test$(EXEEXT) \
+ template_unittest$(EXEEXT) \
+ template_nothreads_unittest$(EXEEXT) template_regtest$(EXEEXT) \
+ template_nothreads_regtest$(EXEEXT) htmlparser_test$(EXEEXT) \
+ htmlparser_nothreads_test$(EXEEXT) statemachine_test$(EXEEXT) \
+ generate_fsm_c_test$(EXEEXT)
+PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
+am__objects_11 = $(am__objects_1) \
+ src/tests/compile_nothreads_test-compile_test.$(OBJEXT)
+am_compile_nothreads_test_OBJECTS = $(am__objects_11)
+compile_nothreads_test_OBJECTS = $(am_compile_nothreads_test_OBJECTS)
+compile_nothreads_test_DEPENDENCIES = libctemplate_nothreads_debug.la
+compile_nothreads_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(compile_nothreads_test_CXXFLAGS) $(CXXFLAGS) $(AM_LDFLAGS) \
+ $(LDFLAGS) -o $@
+am_compile_test_OBJECTS = $(am__objects_1) \
+ src/tests/compile_test-compile_test.$(OBJEXT)
+compile_test_OBJECTS = $(am_compile_test_OBJECTS)
+compile_test_DEPENDENCIES = libctemplate_debug.la \
+ $(am__DEPENDENCIES_1)
+compile_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(compile_test_CXXFLAGS) \
+ $(CXXFLAGS) $(compile_test_LDFLAGS) $(LDFLAGS) -o $@
+am_diff_tpl_auto_escape_OBJECTS = $(am__objects_1) \
+ src/diff_tpl_auto_escape.$(OBJEXT)
+diff_tpl_auto_escape_OBJECTS = $(am_diff_tpl_auto_escape_OBJECTS)
+diff_tpl_auto_escape_DEPENDENCIES = libctemplate_nothreads.la
+am_generate_fsm_c_test_OBJECTS = \
+ src/tests/generate_fsm_c_test.$(OBJEXT)
+generate_fsm_c_test_OBJECTS = $(am_generate_fsm_c_test_OBJECTS)
+generate_fsm_c_test_LDADD = $(LDADD)
+am__objects_12 = src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.$(OBJEXT)
+am_htmlparser_nothreads_test_OBJECTS = $(am__objects_12)
+htmlparser_nothreads_test_OBJECTS = \
+ $(am_htmlparser_nothreads_test_OBJECTS)
+htmlparser_nothreads_test_DEPENDENCIES = \
+ libctemplate_nothreads_debug.la
+htmlparser_nothreads_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(htmlparser_nothreads_test_CXXFLAGS) $(CXXFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_htmlparser_test_OBJECTS = \
+ src/tests/htmlparser_test-htmlparser_cpp_test.$(OBJEXT)
+htmlparser_test_OBJECTS = $(am_htmlparser_test_OBJECTS)
+htmlparser_test_DEPENDENCIES = libctemplate_debug.la \
+ $(am__DEPENDENCIES_1)
+htmlparser_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(htmlparser_test_CXXFLAGS) $(CXXFLAGS) \
+ $(htmlparser_test_LDFLAGS) $(LDFLAGS) -o $@
+am_make_tpl_varnames_h_OBJECTS = $(am__objects_1) \
+ src/make_tpl_varnames_h.$(OBJEXT)
+make_tpl_varnames_h_OBJECTS = $(am_make_tpl_varnames_h_OBJECTS)
+make_tpl_varnames_h_DEPENDENCIES = libctemplate_nothreads.la
+am_statemachine_test_OBJECTS = \
+ src/tests/statemachine_test-statemachine_test.$(OBJEXT) \
+ statemachine_test-statemachine.$(OBJEXT)
+statemachine_test_OBJECTS = $(am_statemachine_test_OBJECTS)
+statemachine_test_LDADD = $(LDADD)
+statemachine_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
+ $(statemachine_test_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) \
+ -o $@
+am__objects_13 = src/tests/template_cache_nothreads_test-template_cache_test.$(OBJEXT)
+am_template_cache_nothreads_test_OBJECTS = $(am__objects_13)
+template_cache_nothreads_test_OBJECTS = \
+ $(am_template_cache_nothreads_test_OBJECTS)
+template_cache_nothreads_test_DEPENDENCIES = \
+ libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+template_cache_nothreads_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_cache_nothreads_test_CXXFLAGS) $(CXXFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_template_cache_test_OBJECTS = \
+ src/tests/template_cache_test-template_cache_test.$(OBJEXT)
+template_cache_test_OBJECTS = $(am_template_cache_test_OBJECTS)
+template_cache_test_DEPENDENCIES = libctemplate_testing.la \
+ libctemplate_debug.la $(am__DEPENDENCIES_1)
+template_cache_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_cache_test_CXXFLAGS) $(CXXFLAGS) \
+ $(template_cache_test_LDFLAGS) $(LDFLAGS) -o $@
+am__objects_14 = src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.$(OBJEXT)
+am_template_dictionary_nothreads_unittest_OBJECTS = $(am__objects_14)
+template_dictionary_nothreads_unittest_OBJECTS = \
+ $(am_template_dictionary_nothreads_unittest_OBJECTS)
+template_dictionary_nothreads_unittest_DEPENDENCIES = \
+ libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+template_dictionary_nothreads_unittest_LINK = $(LIBTOOL) $(AM_V_lt) \
+ --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+ $(CXXLD) $(template_dictionary_nothreads_unittest_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_template_dictionary_unittest_OBJECTS = src/tests/template_dictionary_unittest-template_dictionary_unittest.$(OBJEXT)
+template_dictionary_unittest_OBJECTS = \
+ $(am_template_dictionary_unittest_OBJECTS)
+template_dictionary_unittest_DEPENDENCIES = libctemplate_testing.la \
+ libctemplate_debug.la $(am__DEPENDENCIES_1)
+template_dictionary_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_dictionary_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(template_dictionary_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am__objects_15 = src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.$(OBJEXT)
+am_template_modifiers_nothreads_unittest_OBJECTS = $(am__objects_15)
+template_modifiers_nothreads_unittest_OBJECTS = \
+ $(am_template_modifiers_nothreads_unittest_OBJECTS)
+template_modifiers_nothreads_unittest_DEPENDENCIES = \
+ libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+template_modifiers_nothreads_unittest_LINK = $(LIBTOOL) $(AM_V_lt) \
+ --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+ $(CXXLD) $(template_modifiers_nothreads_unittest_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_template_modifiers_unittest_OBJECTS = src/tests/template_modifiers_unittest-template_modifiers_unittest.$(OBJEXT)
+template_modifiers_unittest_OBJECTS = \
+ $(am_template_modifiers_unittest_OBJECTS)
+template_modifiers_unittest_DEPENDENCIES = libctemplate_testing.la \
+ libctemplate_debug.la $(am__DEPENDENCIES_1)
+template_modifiers_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_modifiers_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(template_modifiers_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am__objects_16 = src/tests/template_nothreads_regtest-template_regtest.$(OBJEXT)
+am_template_nothreads_regtest_OBJECTS = $(am__objects_16)
+template_nothreads_regtest_OBJECTS = \
+ $(am_template_nothreads_regtest_OBJECTS)
+template_nothreads_regtest_DEPENDENCIES = \
+ libctemplate_nothreads_debug.la
+template_nothreads_regtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_nothreads_regtest_CXXFLAGS) $(CXXFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am__objects_17 = src/tests/template_nothreads_unittest-template_unittest.$(OBJEXT)
+am_template_nothreads_unittest_OBJECTS = $(am__objects_17)
+template_nothreads_unittest_OBJECTS = \
+ $(am_template_nothreads_unittest_OBJECTS)
+template_nothreads_unittest_DEPENDENCIES = \
+ libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+template_nothreads_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_template_regtest_OBJECTS = \
+ src/tests/template_regtest-template_regtest.$(OBJEXT)
+template_regtest_OBJECTS = $(am_template_regtest_OBJECTS)
+template_regtest_DEPENDENCIES = libctemplate_debug.la \
+ $(am__DEPENDENCIES_1)
+template_regtest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_regtest_CXXFLAGS) $(CXXFLAGS) \
+ $(template_regtest_LDFLAGS) $(LDFLAGS) -o $@
+am__objects_18 = src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.$(OBJEXT)
+am_template_setglobals_nothreads_unittest_OBJECTS = $(am__objects_18)
+template_setglobals_nothreads_unittest_OBJECTS = \
+ $(am_template_setglobals_nothreads_unittest_OBJECTS)
+template_setglobals_nothreads_unittest_DEPENDENCIES = \
+ libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+template_setglobals_nothreads_unittest_LINK = $(LIBTOOL) $(AM_V_lt) \
+ --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+ $(CXXLD) $(template_setglobals_nothreads_unittest_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_template_setglobals_unittest_OBJECTS = src/tests/template_setglobals_unittest-template_setglobals_unittest.$(OBJEXT)
+template_setglobals_unittest_OBJECTS = \
+ $(am_template_setglobals_unittest_OBJECTS)
+template_setglobals_unittest_DEPENDENCIES = libctemplate_testing.la \
+ libctemplate_debug.la $(am__DEPENDENCIES_1)
+template_setglobals_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_setglobals_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(template_setglobals_unittest_LDFLAGS) $(LDFLAGS) -o $@
+am__objects_19 = src/template_test_util_nothreads_test-template_dictionary.$(OBJEXT) \
+ src/tests/template_test_util_nothreads_test-template_test_util_test.$(OBJEXT)
+am_template_test_util_nothreads_test_OBJECTS = $(am__objects_19)
+template_test_util_nothreads_test_OBJECTS = \
+ $(am_template_test_util_nothreads_test_OBJECTS)
+template_test_util_nothreads_test_DEPENDENCIES = \
+ libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+template_test_util_nothreads_test_LINK = $(LIBTOOL) $(AM_V_lt) \
+ --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
+ $(CXXLD) $(template_test_util_nothreads_test_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+am_template_test_util_test_OBJECTS = \
+ src/template_test_util_test-template_dictionary.$(OBJEXT) \
+ src/tests/template_test_util_test-template_test_util_test.$(OBJEXT)
+template_test_util_test_OBJECTS = \
+ $(am_template_test_util_test_OBJECTS)
+template_test_util_test_DEPENDENCIES = libctemplate_testing.la \
+ libctemplate_debug.la $(am__DEPENDENCIES_1)
+template_test_util_test_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) \
+ $(template_test_util_test_LDFLAGS) $(LDFLAGS) -o $@
+am_template_unittest_OBJECTS = \
+ src/tests/template_unittest-template_unittest.$(OBJEXT)
+template_unittest_OBJECTS = $(am_template_unittest_OBJECTS)
+template_unittest_DEPENDENCIES = libctemplate_testing.la \
+ libctemplate_debug.la $(am__DEPENDENCIES_1)
+template_unittest_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(template_unittest_CXXFLAGS) $(CXXFLAGS) \
+ $(template_unittest_LDFLAGS) $(LDFLAGS) -o $@
+SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS)
+AM_V_P = $(am__v_P_@AM_V@)
+am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_@AM_V@)
+am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@)
+am__v_GEN_0 = @echo " GEN " $@;
+am__v_GEN_1 =
+AM_V_at = $(am__v_at_@AM_V@)
+am__v_at_ = $(am__v_at_@AM_DEFAULT_V@)
+am__v_at_0 = @
+am__v_at_1 =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_@AM_V@)
+am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@)
+am__v_CC_0 = @echo " CC " $@;
+am__v_CC_1 =
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_@AM_V@)
+am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@)
+am__v_CCLD_0 = @echo " CCLD " $@;
+am__v_CCLD_1 =
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_@AM_V@)
+am__v_CXX_ = $(am__v_CXX_@AM_DEFAULT_V@)
+am__v_CXX_0 = @echo " CXX " $@;
+am__v_CXX_1 =
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_@AM_V@)
+am__v_CXXLD_ = $(am__v_CXXLD_@AM_DEFAULT_V@)
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+am__v_CXXLD_1 =
+SOURCES = $(libctemplate_la_SOURCES) $(libctemplate_debug_la_SOURCES) \
+ $(libctemplate_nothreads_la_SOURCES) \
+ $(libctemplate_nothreads_debug_la_SOURCES) \
+ $(libctemplate_testing_la_SOURCES) \
+ $(libctemplate_testing_nothreads_la_SOURCES) \
+ $(compile_nothreads_test_SOURCES) $(compile_test_SOURCES) \
+ $(diff_tpl_auto_escape_SOURCES) $(generate_fsm_c_test_SOURCES) \
+ $(htmlparser_nothreads_test_SOURCES) \
+ $(htmlparser_test_SOURCES) $(make_tpl_varnames_h_SOURCES) \
+ $(statemachine_test_SOURCES) \
+ $(template_cache_nothreads_test_SOURCES) \
+ $(template_cache_test_SOURCES) \
+ $(template_dictionary_nothreads_unittest_SOURCES) \
+ $(template_dictionary_unittest_SOURCES) \
+ $(template_modifiers_nothreads_unittest_SOURCES) \
+ $(template_modifiers_unittest_SOURCES) \
+ $(template_nothreads_regtest_SOURCES) \
+ $(template_nothreads_unittest_SOURCES) \
+ $(template_regtest_SOURCES) \
+ $(template_setglobals_nothreads_unittest_SOURCES) \
+ $(template_setglobals_unittest_SOURCES) \
+ $(template_test_util_nothreads_test_SOURCES) \
+ $(template_test_util_test_SOURCES) \
+ $(template_unittest_SOURCES)
+DIST_SOURCES = $(am__libctemplate_la_SOURCES_DIST) \
+ $(am__libctemplate_debug_la_SOURCES_DIST) \
+ $(am__libctemplate_nothreads_la_SOURCES_DIST) \
+ $(am__libctemplate_nothreads_debug_la_SOURCES_DIST) \
+ $(libctemplate_testing_la_SOURCES) \
+ $(libctemplate_testing_nothreads_la_SOURCES) \
+ $(compile_nothreads_test_SOURCES) $(compile_test_SOURCES) \
+ $(diff_tpl_auto_escape_SOURCES) $(generate_fsm_c_test_SOURCES) \
+ $(htmlparser_nothreads_test_SOURCES) \
+ $(htmlparser_test_SOURCES) $(make_tpl_varnames_h_SOURCES) \
+ $(statemachine_test_SOURCES) \
+ $(template_cache_nothreads_test_SOURCES) \
+ $(template_cache_test_SOURCES) \
+ $(template_dictionary_nothreads_unittest_SOURCES) \
+ $(template_dictionary_unittest_SOURCES) \
+ $(template_modifiers_nothreads_unittest_SOURCES) \
+ $(template_modifiers_unittest_SOURCES) \
+ $(template_nothreads_regtest_SOURCES) \
+ $(template_nothreads_unittest_SOURCES) \
+ $(template_regtest_SOURCES) \
+ $(template_setglobals_nothreads_unittest_SOURCES) \
+ $(template_setglobals_unittest_SOURCES) \
+ $(template_test_util_nothreads_test_SOURCES) \
+ $(template_test_util_test_SOURCES) \
+ $(template_unittest_SOURCES)
+am__can_run_installinfo = \
+ case $$AM_UPDATE_INFO_DIR in \
+ n|no|NO) false;; \
+ *) (install-info --version) >/dev/null 2>&1;; \
+ esac
+DATA = $(dist_doc_DATA) $(pkgconfig_DATA)
+HEADERS = $(nodist_ctemplateinclude_HEADERS) $(noinst_HEADERS)
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates. Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+ BEGIN { nonempty = 0; } \
+ { items[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique. This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+ list='$(am__tagged_files)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+AM_RECURSIVE_TARGETS = cscope check recheck
+am__tty_colors_dummy = \
+ mgn= red= grn= lgn= blu= brg= std=; \
+ am__color_tests=no
+am__tty_colors = { \
+ $(am__tty_colors_dummy); \
+ if test "X$(AM_COLOR_TESTS)" = Xno; then \
+ am__color_tests=no; \
+ elif test "X$(AM_COLOR_TESTS)" = Xalways; then \
+ am__color_tests=yes; \
+ elif test "X$$TERM" != Xdumb && { test -t 1; } 2>/dev/null; then \
+ am__color_tests=yes; \
+ fi; \
+ if test $$am__color_tests = yes; then \
+ red='[0;31m'; \
+ grn='[0;32m'; \
+ lgn='[1;32m'; \
+ blu='[1;34m'; \
+ mgn='[0;35m'; \
+ brg='[1m'; \
+ std='[m'; \
+ fi; \
+}
+am__recheck_rx = ^[ ]*:recheck:[ ]*
+am__global_test_result_rx = ^[ ]*:global-test-result:[ ]*
+am__copy_in_global_log_rx = ^[ ]*:copy-in-global-log:[ ]*
+# A command that, given a newline-separated list of test names on the
+# standard input, print the name of the tests that are to be re-run
+# upon "make recheck".
+am__list_recheck_tests = $(AWK) '{ \
+ recheck = 1; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ { \
+ if ((getline line2 < ($$0 ".log")) < 0) \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[nN][Oo]/) \
+ { \
+ recheck = 0; \
+ break; \
+ } \
+ else if (line ~ /$(am__recheck_rx)[yY][eE][sS]/) \
+ { \
+ break; \
+ } \
+ }; \
+ if (recheck) \
+ print $$0; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# A command that, given a newline-separated list of test names on the
+# standard input, create the global log from their .trs and .log files.
+am__create_global_log = $(AWK) ' \
+function fatal(msg) \
+{ \
+ print "fatal: making $@: " msg | "cat >&2"; \
+ exit 1; \
+} \
+function rst_section(header) \
+{ \
+ print header; \
+ len = length(header); \
+ for (i = 1; i <= len; i = i + 1) \
+ printf "="; \
+ printf "\n\n"; \
+} \
+{ \
+ copy_in_global_log = 1; \
+ global_test_result = "RUN"; \
+ while ((rc = (getline line < ($$0 ".trs"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".trs"); \
+ if (line ~ /$(am__global_test_result_rx)/) \
+ { \
+ sub("$(am__global_test_result_rx)", "", line); \
+ sub("[ ]*$$", "", line); \
+ global_test_result = line; \
+ } \
+ else if (line ~ /$(am__copy_in_global_log_rx)[nN][oO]/) \
+ copy_in_global_log = 0; \
+ }; \
+ if (copy_in_global_log) \
+ { \
+ rst_section(global_test_result ": " $$0); \
+ while ((rc = (getline line < ($$0 ".log"))) != 0) \
+ { \
+ if (rc < 0) \
+ fatal("failed to read from " $$0 ".log"); \
+ print line; \
+ }; \
+ printf "\n"; \
+ }; \
+ close ($$0 ".trs"); \
+ close ($$0 ".log"); \
+}'
+# Restructured Text title.
+am__rst_title = { sed 's/.*/ & /;h;s/./=/g;p;x;s/ *$$//;p;g' && echo; }
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL), and POSIX 2008 even requires this. Work around it
+# by disabling -e (using the XSI extension "set +e") if it's set.
+am__sh_e_setup = case $$- in *e*) set +e;; esac
+# Default flags passed to test drivers.
+am__common_driver_flags = \
+ --color-tests "$$am__color_tests" \
+ --enable-hard-errors "$$am__enable_hard_errors" \
+ --expect-failure "$$am__expect_failure"
+# To be inserted before the command running the test. Creates the
+# directory for the log if needed. Stores in $dir the directory
+# containing $f, in $tst the test, in $log the log. Executes the
+# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
+# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
+# will run the test scripts (or their associated LOG_COMPILER, if
+# thy have one).
+am__check_pre = \
+$(am__sh_e_setup); \
+$(am__vpath_adj_setup) $(am__vpath_adj) \
+$(am__tty_colors); \
+srcdir=$(srcdir); export srcdir; \
+case "$@" in \
+ */*) am__odir=`echo "./$@" | sed 's|/[^/]*$$||'`;; \
+ *) am__odir=.;; \
+esac; \
+test "x$$am__odir" = x"." || test -d "$$am__odir" \
+ || $(MKDIR_P) "$$am__odir" || exit $$?; \
+if test -f "./$$f"; then dir=./; \
+elif test -f "$$f"; then dir=; \
+else dir="$(srcdir)/"; fi; \
+tst=$$dir$$f; log='$@'; \
+if test -n '$(DISABLE_HARD_ERRORS)'; then \
+ am__enable_hard_errors=no; \
+else \
+ am__enable_hard_errors=yes; \
+fi; \
+case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$f[\ \ ]* | *[\ \ ]$$dir$$f[\ \ ]*) \
+ am__expect_failure=yes;; \
+ *) \
+ am__expect_failure=no;; \
+esac; \
+$(AM_TESTS_ENVIRONMENT) $(TESTS_ENVIRONMENT)
+# A shell command to get the names of the tests scripts with any registered
+# extension removed (i.e., equivalently, the names of the test logs, with
+# the '.log' extension removed). The result is saved in the shell variable
+# '$bases'. This honors runtime overriding of TESTS and TEST_LOGS. Sadly,
+# we cannot use something simpler, involving e.g., "$(TEST_LOGS:.log=)",
+# since that might cause problem with VPATH rewrites for suffix-less tests.
+# See also 'test-harness-vpath-rewrite.sh' and 'test-trs-basic.sh'.
+am__set_TESTS_bases = \
+ bases='$(TEST_LOGS)'; \
+ bases=`for i in $$bases; do echo $$i; done | sed 's/\.log$$//'`; \
+ bases=`echo $$bases`
+RECHECK_LOGS = $(TEST_LOGS)
+TEST_SUITE_LOG = test-suite.log
+TEST_EXTENSIONS = @EXEEXT@ .test
+LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+LOG_COMPILE = $(LOG_COMPILER) $(AM_LOG_FLAGS) $(LOG_FLAGS)
+am__set_b = \
+ case '$@' in \
+ */*) \
+ case '$*' in \
+ */*) b='$*';; \
+ *) b=`echo '$@' | sed 's/\.log$$//'`; \
+ esac;; \
+ *) \
+ b='$*';; \
+ esac
+am__test_logs1 = $(TESTS:=.log)
+am__test_logs2 = $(am__test_logs1:@EXEEXT@.log=.log)
+TEST_LOGS = $(am__test_logs2:.test.log=.log)
+TEST_LOG_DRIVER = $(SHELL) $(top_srcdir)/test-driver
+TEST_LOG_COMPILE = $(TEST_LOG_COMPILER) $(AM_TEST_LOG_FLAGS) \
+ $(TEST_LOG_FLAGS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+ if test -d "$(distdir)"; then \
+ find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+ && rm -rf "$(distdir)" \
+ || { sleep 5 && rm -rf "$(distdir)"; }; \
+ else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
+DIST_ARCHIVES = $(distdir).tar.gz $(distdir).zip
+GZIP_ENV = --best
+DIST_TARGETS = dist-gzip dist-zip
+distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+ | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FGREP = @FGREP@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBTOOL_DEPS = @LIBTOOL_DEPS@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+RANLIB = @RANLIB@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+SO_VERSION = @SO_VERSION@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+ac_cv_cxx_hash_map = @ac_cv_cxx_hash_map@
+ac_cv_cxx_hash_map_class = @ac_cv_cxx_hash_map_class@
+ac_cv_cxx_hash_set = @ac_cv_cxx_hash_set@
+ac_cv_cxx_hash_set_class = @ac_cv_cxx_hash_set_class@
+ac_cv_have_inttypes_h = @ac_cv_have_inttypes_h@
+ac_cv_have_stdint_h = @ac_cv_have_stdint_h@
+ac_cv_uint64 = @ac_cv_uint64@
+ac_google_attribute = @ac_google_attribute@
+ac_google_end_namespace = @ac_google_end_namespace@
+ac_google_namespace = @ac_google_namespace@
+ac_google_start_namespace = @ac_google_start_namespace@
+ac_have_attribute_weak = @ac_have_attribute_weak@
+ac_htmlparser_namespace = @ac_htmlparser_namespace@
+ac_windows_dllexport = @ac_windows_dllexport@
+ac_windows_dllexport_defines = @ac_windows_dllexport_defines@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = $(prefix)/share/doc/$(PACKAGE)-$(VERSION)
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+# Make sure that when we re-make ./configure, we get the macros we need
+ACLOCAL_AMFLAGS = -I m4
+
+# This is so we can #include <ctemplate/foo>
+AM_CPPFLAGS = -I$(top_srcdir)/src
+
+# These are good warnings to turn on by default
+@GCC_TRUE@AM_CXXFLAGS = -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
+@MINGW_FALSE@TMPDIR = /tmp
+
+# mingw does weird directory munging on /tmp, which causes some of our
+# tests to fail, so use a different tmpdir there.
+@MINGW_TRUE@TMPDIR = ./
+ctemplateincludedir = $(includedir)/ctemplate
+nodist_ctemplateinclude_HEADERS = \
+ src/ctemplate/template.h \
+ src/ctemplate/template_cache.h \
+ src/ctemplate/template_string.h \
+ src/ctemplate/template_enums.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_dictionary_interface.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_namelist.h \
+ src/ctemplate/per_expand_data.h \
+ src/ctemplate/str_ref.h
+
+noinst_HEADERS = \
+ src/ctemplate/template.h.in \
+ src/ctemplate/template_cache.h.in \
+ src/ctemplate/template_string.h.in \
+ src/ctemplate/template_enums.h.in \
+ src/ctemplate/template_pathops.h.in \
+ src/ctemplate/template_modifiers.h.in \
+ src/ctemplate/template_dictionary.h.in \
+ src/ctemplate/template_dictionary_interface.h.in \
+ src/ctemplate/template_annotator.h.in \
+ src/ctemplate/template_emitter.h.in \
+ src/ctemplate/template_namelist.h.in \
+ src/ctemplate/per_expand_data.h.in \
+ src/ctemplate/str_ref.h.in
+
+dist_doc_DATA = AUTHORS COPYING ChangeLog INSTALL NEWS README README_windows.txt \
+ doc/designstyle.css doc/index.html \
+ doc/howto.html doc/guide.html doc/reference.html \
+ doc/tips.html doc/example.html doc/auto_escape.html \
+ doc/xss_resources.html
+
+
+# automake will make different .o files for this library, which is good,
+# because we use an extra compiler flag.
+lib_LTLIBRARIES = libctemplate.la libctemplate_nothreads.la
+
+# For our tests, we want versions of these libraries that include asserts.
+
+# We could also make a library that has the TemplateDictionaryPeer
+# class. This class is useful for testing (it provides introspection
+# on the TemplateDictionary hierarchy that's easier to use than the
+# default debugging method, TemplateDictionary::Dump()) but by the
+# same token also violates abstraction in ways that might be fragile.
+# We don't expose the library for now, until the demonstrated need
+# outweighs the costs. If you'd like to use this library, please send
+# mail to google-ctemplate@googlegroups.com!
+noinst_LTLIBRARIES = libctemplate_debug.la \
+ libctemplate_nothreads_debug.la libctemplate_testing.la \
+ libctemplate_testing_nothreads.la
+bin_SCRIPTS = src/template-converter
+WINDOWS_PROJECTS = ctemplate.sln \
+ vsprojects/libctemplate/libctemplate.vcproj \
+ vsprojects/make_tpl_varname_h/make_tpl_varname_h.vcproj \
+ vsprojects/diff_tpl_auto_escape/diff_tpl_auto_escape.vcproj \
+ vsprojects/compile_test/compile_test.vcproj \
+ vsprojects/template_test_util_test/template_test_util_test.vcproj \
+ vsprojects/template_dictionary_unittest/template_dictionary_unittest.vcproj \
+ vsprojects/template_modifiers_unittest/template_modifiers_unittest.vcproj \
+ vsprojects/template_setglobals_unittest/template_setglobals_unittest.vcproj \
+ vsprojects/template_cache_test/template_cache_test.vcproj \
+ vsprojects/template_unittest/template_unittest.vcproj \
+ vsprojects/template_unittest_static/template_unittest_static.vcproj \
+ vsprojects/template_regtest/template_regtest.vcproj \
+ vsprojects/htmlparser_test/htmlparser_test.vcproj \
+ vsprojects/statemachine_test/statemachine_test.vcproj \
+ vsprojects/generate_fsm_c_test/generate_fsm_c_test.vcproj
+
+# This is something only maintainers need (since they're the only ones
+# who generate .h or .c files from .config files).
+check_SCRIPTS = generate_fsm_test_sh make_tpl_varnames_h_unittest_sh \
+ diff_tpl_auto_escape_unittest_sh
+TESTS_ENVIRONMENT = TEMPLATE_ROOTDIR=$(top_srcdir)
+# Every time you add a unittest to check_SCRIPTS, add it here too
+noinst_SCRIPTS = src/tests/generate_fsm_test.sh \
+ src/tests/make_tpl_varnames_h_unittest.sh \
+ src/tests/diff_tpl_auto_escape_unittest.sh
+# Add to this for tests that use data
+TESTDATA = src/tests/template_unittest_test_footer.in \
+ src/tests/template_unittest_test_html.in \
+ src/tests/template_unittest_test_invalid1.in \
+ src/tests/template_unittest_test_invalid2.in \
+ src/tests/template_unittest_test_markerdelim.in \
+ src/tests/template_unittest_test_modifiers.in \
+ src/tests/template_unittest_test_nul.in \
+ src/tests/template_unittest_test_selective_css.in \
+ src/tests/template_unittest_test_selective_html.in \
+ src/tests/template_unittest_test_selective_js.in \
+ src/tests/template_unittest_test_simple.in \
+ src/tests/template_unittest_test_valid1.in \
+ src/tests/template_unittest_test_footer_dict01.out \
+ src/tests/template_unittest_test_footer_dict02.out \
+ src/tests/template_unittest_test_html_dict01.out \
+ src/tests/template_unittest_test_html_dict02.out \
+ src/tests/template_unittest_test_markerdelim_dict01.out \
+ src/tests/template_unittest_test_markerdelim_dict02.out \
+ src/tests/template_unittest_test_modifiers_dict01.out \
+ src/tests/template_unittest_test_nul_dict01.out \
+ src/tests/template_unittest_test_selective_css_dict01.out \
+ src/tests/template_unittest_test_selective_css_dict02.out \
+ src/tests/template_unittest_test_selective_html_dict01.out \
+ src/tests/template_unittest_test_selective_html_dict02.out \
+ src/tests/template_unittest_test_selective_js_dict01.out \
+ src/tests/template_unittest_test_selective_js_dict02.out \
+ src/tests/template_unittest_test_simple_dict01.out \
+ src/tests/template_unittest_test_simple_dict02.out \
+ src/tests/template_unittest_test_simple_dict03.out \
+ src/tests/template_unittest_test_valid1_dict01.out \
+ src/tests/htmlparser_testdata/cdata.html \
+ src/tests/htmlparser_testdata/comments.html \
+ src/tests/htmlparser_testdata/context.html \
+ src/tests/htmlparser_testdata/google.html \
+ src/tests/htmlparser_testdata/javascript_attribute.html \
+ src/tests/htmlparser_testdata/javascript_block.html \
+ src/tests/htmlparser_testdata/javascript_regexp.html \
+ src/tests/htmlparser_testdata/position.html \
+ src/tests/htmlparser_testdata/reset.html \
+ src/tests/htmlparser_testdata/simple.html \
+ src/tests/htmlparser_testdata/tags.html \
+ src/tests/htmlparser_testdata/sample_fsm.config \
+ src/tests/htmlparser_testdata/sample_fsm.c
+
+# This is a required hack for auto-generated .h files: cf the automake info pages
+# NOTE: since we put these .h files in BUILT_SOURCES, we don't need to put
+# them in as deps for the binaries that use them. In fact, it's important
+# that we don't; instead we put them in EXTRA_DIST. This mean, in practice,
+# they'll go at the end of the distribution tarfile, which means they'll
+# have a later timestamp than the .config files that generate them, which
+# means users won't try to rebuild them. Ah, the joys of automake.
+BUILT_SOURCES = src/htmlparser/htmlparser_fsm.h \
+ src/htmlparser/jsparser_fsm.h \
+ src/tests/statemachine_test_fsm.h statemachine.c
+
+# These are the symbols (classes, mostly) we want to export from our library.
+# Note this regexp applies to the *mangled* name, which is why we have to
+# be careful where we want to assert [^A-Za-z]. (Particularly bad on Darwin.)
+# template_modifiers and BaseArena and UnsafeArena perhaps shouldn't be
+# exported, but they're needed -- at least -- for some unittests.
+CTEMPLATE_SYMBOLS = '(ctemplate|template_modifiers|BaseArena|UnsafeArena|[^A-Za-z]Template[^A-Za-z]|TemplateDictionary|TemplateNamelist|TemplateFromString|TemplateString|TemplateState|[^A-Za-z]Strip[^A-Za-z])'
+libctemplate_la_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/base/arena-inl.h src/base/arena.cc src/base/arena.h \
+ src/base/fileutil.h src/base/macros.h \
+ src/base/manual_constructor.h src/base/mutex.h \
+ src/base/small_map.h src/base/thread_annotations.h \
+ src/base/util.h src/indented_writer.h src/per_expand_data.cc \
+ src/template.cc src/template_annotator.cc \
+ src/template_cache.cc src/template_dictionary.cc \
+ src/template_modifiers.cc src/template_modifiers_internal.h \
+ src/template_namelist.cc src/template_pathops.cc \
+ src/template_string.cc src/htmlparser/htmlparser.cc \
+ src/htmlparser/htmlparser.h src/htmlparser/htmlparser_cpp.h \
+ src/htmlparser/jsparser.cc src/htmlparser/jsparser.h \
+ src/htmlparser/statemachine.cc src/htmlparser/statemachine.h \
+ $(am__append_1)
+libctemplate_la_CXXFLAGS = $(PTHREAD_CFLAGS) -DNDEBUG $(AM_CXXFLAGS)
+# -version-info gets passed to libtool
+libctemplate_la_LDFLAGS = $(PTHREAD_CFLAGS) \
+ -export-symbols-regex $(CTEMPLATE_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+
+libctemplate_la_LIBADD = $(PTHREAD_LIBS)
+libctemplate_nothreads_la_SOURCES = $(libctemplate_la_SOURCES)
+libctemplate_nothreads_la_DEPENDENCIES = $(libctemplate_la_DEPENDENCIES)
+libctemplate_nothreads_la_CXXFLAGS = -DNDEBUG -DNO_THREADS $(AM_CXXFLAGS)
+libctemplate_nothreads_la_LDFLAGS = -export-symbols-regex $(CTEMPLATE_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+
+libctemplate_debug_la_SOURCES = $(libctemplate_la_SOURCES)
+libctemplate_debug_la_DEPENDENCIES = $(libctemplate_la_DEPENDENCIES)
+libctemplate_debug_la_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+libctemplate_debug_la_LDFLAGS = $(libctemplate_la_LDFLAGS)
+libctemplate_debug_la_LIBADD = $(libctemplate_la_LIBADD)
+libctemplate_nothreads_debug_la_SOURCES = $(libctemplate_nothreads_la_SOURCES)
+libctemplate_nothreads_debug_la_DEPENDENCIES = $(libctemplate_nothreads_la_DEPENDENCIES)
+libctemplate_nothreads_debug_la_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+libctemplate_nothreads_debug_la_LDFLAGS = $(libctemplate_nothreads_la_LDFLAGS)
+libctemplate_testing_la_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/tests/template_test_util.h \
+ src/tests/template_test_util.cc
+
+libctemplate_testing_la_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+CTEMPLATE_TESTING_SYMBOLS = 'TemporaryRegisterTemplate|TemplateDictionaryPeer'
+libctemplate_testing_la_LDFLAGS = $(PTHREAD_CFLAGS) \
+ -export-symbols-regex $(CTEMPLATE_TESTING_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+
+libctemplate_testing_la_LIBADD = $(PTHREAD_LIBS)
+libctemplate_testing_nothreads_la_SOURCES = $(libctemplate_testing_la_SOURCES)
+libctemplate_testing_nothreads_la_CXXFLAGS = $(AM_CXXFLAGS) -DNO_THREADS
+libctemplate_testing_nothreads_la_LDFLAGS = -export-symbols-regex $(CTEMPLATE_TESTING_SYMBOLS) \
+ -no-undefined \
+ -version-info @SO_VERSION@
+
+make_tpl_varnames_h_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/make_tpl_varnames_h.cc
+
+make_tpl_varnames_h_LDADD = libctemplate_nothreads.la
+diff_tpl_auto_escape_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/diff_tpl_auto_escape.cc
+
+diff_tpl_auto_escape_LDADD = libctemplate_nothreads.la
+compile_test_SOURCES = $(nodist_ctemplateinclude_HEADERS) \
+ src/tests/compile_test.cc
+
+compile_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+compile_test_LDFLAGS = $(PTHREAD_CFLAGS)
+compile_test_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
+compile_nothreads_test_SOURCES = $(compile_test_SOURCES)
+compile_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+compile_nothreads_test_LDADD = libctemplate_nothreads_debug.la
+template_test_util_test_SOURCES = src/tests/config_for_unittests.h \
+ src/template_dictionary.cc \
+ src/tests/template_test_util_test.cc
+
+template_test_util_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_test_util_test_LDFLAGS = $(PTHREAD_CFLAGS)
+template_test_util_test_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+
+template_test_util_nothreads_test_SOURCES = $(template_test_util_test_SOURCES)
+template_test_util_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_test_util_nothreads_test_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+template_dictionary_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/base/arena.h \
+ src/tests/template_dictionary_unittest.cc
+
+template_dictionary_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_dictionary_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_dictionary_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+
+template_dictionary_nothreads_unittest_SOURCES = $(template_dictionary_unittest_SOURCES)
+template_dictionary_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_dictionary_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+template_modifiers_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/tests/template_modifiers_unittest.cc
+
+template_modifiers_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_modifiers_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_modifiers_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+
+template_modifiers_nothreads_unittest_SOURCES = $(template_modifiers_unittest_SOURCES)
+template_modifiers_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_modifiers_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+template_setglobals_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/tests/template_setglobals_unittest.cc
+
+template_setglobals_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_setglobals_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_setglobals_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+
+template_setglobals_nothreads_unittest_SOURCES = $(template_setglobals_unittest_SOURCES)
+template_setglobals_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_setglobals_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+template_cache_test_SOURCES = src/tests/config_for_unittests.h \
+ src/template_modifiers_internal.h \
+ src/tests/template_cache_test.cc
+
+template_cache_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_cache_test_LDFLAGS = $(PTHREAD_CFLAGS)
+template_cache_test_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+
+template_cache_nothreads_test_SOURCES = $(template_cache_test_SOURCES)
+template_cache_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_cache_nothreads_test_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+template_unittest_SOURCES = src/tests/config_for_unittests.h \
+ src/template_modifiers_internal.h \
+ src/tests/template_unittest.cc
+
+template_unittest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_unittest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_unittest_LDADD = libctemplate_testing.la libctemplate_debug.la \
+ $(PTHREAD_LIBS)
+
+template_nothreads_unittest_SOURCES = $(template_unittest_SOURCES)
+template_nothreads_unittest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_nothreads_unittest_LDADD = libctemplate_testing_nothreads.la \
+ libctemplate_nothreads_debug.la
+
+template_regtest_SOURCES = src/tests/template_regtest.cc
+template_regtest_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+template_regtest_LDFLAGS = $(PTHREAD_CFLAGS)
+template_regtest_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
+template_nothreads_regtest_SOURCES = $(template_regtest_SOURCES)
+template_nothreads_regtest_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+template_nothreads_regtest_LDADD = libctemplate_nothreads_debug.la
+htmlparser_test_SOURCES = src/tests/htmlparser_cpp_test.cc
+htmlparser_test_CXXFLAGS = $(PTHREAD_CFLAGS) $(AM_CXXFLAGS)
+htmlparser_test_LDFLAGS = $(PTHREAD_CFLAGS)
+htmlparser_test_LDADD = libctemplate_debug.la $(PTHREAD_LIBS)
+htmlparser_nothreads_test_SOURCES = $(htmlparser_test_SOURCES)
+htmlparser_nothreads_test_CXXFLAGS = -DNO_THREADS $(AM_CXXFLAGS)
+htmlparser_nothreads_test_LDADD = libctemplate_nothreads_debug.la
+CLEANFILES = statemachine.c $(pkgconfig_DATA)
+statemachine_test_SOURCES = src/tests/statemachine_test.c \
+ statemachine.c
+
+statemachine_test_CFLAGS = -I$(top_srcdir)/src/htmlparser
+generate_fsm_c_test_SOURCES = src/tests/generate_fsm_c_test.c
+generate_fsm_c_test_DEPENDENCIES = src/tests/htmlparser_testdata/sample_fsm.c
+
+# http://linux.die.net/man/1/pkg-config, http://pkg-config.freedesktop.org/wiki
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = lib${PACKAGE}.pc lib${PACKAGE}_nothreads.pc
+
+# In addition to the normal stuff, we include all the windows-specific
+# code, and also the code used to generate the html-parser fsm files.
+# NOTE: BUILT_SOURCES should come after the .config files, so they
+# come later (and thus end up with a later timestamp) when we tar/untar.
+EXTRA_DIST = packages/rpm.sh packages/rpm/rpm.spec packages/deb.sh packages/deb \
+ $(SCRIPTS) $(TESTDATA) libtool autogen.sh \
+ src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py \
+ src/tests/statemachine_test_fsm.config \
+ src/htmlparser/htmlparser_fsm.config \
+ src/htmlparser/jsparser_fsm.config \
+ $(BUILT_SOURCES) \
+ src/windows/config.h src/windows/preprocess.sh \
+ src/windows/ctemplate $(WINDOWS_PROJECTS) \
+ src/solaris/libstdc++.la contrib
+
+all: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .cc .lo .log .o .obj .test .test$(EXEEXT) .trs
+am--refresh: Makefile
+ @:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
+ $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
+ && exit 0; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --gnu Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ echo ' $(SHELL) ./config.status'; \
+ $(SHELL) ./config.status;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+src/config.h: src/stamp-h1
+ @test -f $@ || rm -f src/stamp-h1
+ @test -f $@ || $(MAKE) $(AM_MAKEFLAGS) src/stamp-h1
+
+src/stamp-h1: $(top_srcdir)/src/config.h.in $(top_builddir)/config.status
+ @rm -f src/stamp-h1
+ cd $(top_builddir) && $(SHELL) ./config.status src/config.h
+$(top_srcdir)/src/config.h.in: $(am__configure_deps)
+ ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+ rm -f src/stamp-h1
+ touch $@
+
+distclean-hdr:
+ -rm -f src/config.h src/stamp-h1
+src/ctemplate/template_string.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_string.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_enums.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_enums.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_cache.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_cache.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_modifiers.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_modifiers.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_emitter.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_emitter.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_annotator.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_annotator.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_dictionary.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_dictionary.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_pathops.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_pathops.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_namelist.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_namelist.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/find_ptr.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/find_ptr.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/per_expand_data.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/per_expand_data.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/str_ref.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/str_ref.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+src/ctemplate/template_dictionary_interface.h: $(top_builddir)/config.status $(top_srcdir)/src/ctemplate/template_dictionary_interface.h.in
+ cd $(top_builddir) && $(SHELL) ./config.status $@
+
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(MKDIR_P) '$(DESTDIR)$(libdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(libdir)" || exit 1; \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+ }
+
+uninstall-libLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+ done
+
+clean-libLTLIBRARIES:
+ -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+ @list='$(lib_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; \
+ locs=`for p in $$list; do echo $$p; done | \
+ sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \
+ sort -u`; \
+ test -z "$$locs" || { \
+ echo rm -f $${locs}; \
+ rm -f $${locs}; \
+ }
+src/base/$(am__dirstamp):
+ @$(MKDIR_P) src/base
+ @: > src/base/$(am__dirstamp)
+src/base/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/base/$(DEPDIR)
+ @: > src/base/$(DEPDIR)/$(am__dirstamp)
+src/base/libctemplate_la-arena.lo: src/base/$(am__dirstamp) \
+ src/base/$(DEPDIR)/$(am__dirstamp)
+src/$(am__dirstamp):
+ @$(MKDIR_P) src
+ @: > src/$(am__dirstamp)
+src/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/$(DEPDIR)
+ @: > src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-per_expand_data.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template_annotator.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template_cache.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template_dictionary.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template_modifiers.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template_namelist.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template_pathops.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_la-template_string.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/$(am__dirstamp):
+ @$(MKDIR_P) src/htmlparser
+ @: > src/htmlparser/$(am__dirstamp)
+src/htmlparser/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/htmlparser/$(DEPDIR)
+ @: > src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_la-htmlparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_la-jsparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_la-statemachine.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/windows/$(am__dirstamp):
+ @$(MKDIR_P) src/windows
+ @: > src/windows/$(am__dirstamp)
+src/windows/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/windows/$(DEPDIR)
+ @: > src/windows/$(DEPDIR)/$(am__dirstamp)
+src/windows/libctemplate_la-port.lo: src/windows/$(am__dirstamp) \
+ src/windows/$(DEPDIR)/$(am__dirstamp)
+
+libctemplate.la: $(libctemplate_la_OBJECTS) $(libctemplate_la_DEPENDENCIES) $(EXTRA_libctemplate_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(libctemplate_la_LINK) -rpath $(libdir) $(libctemplate_la_OBJECTS) $(libctemplate_la_LIBADD) $(LIBS)
+src/base/libctemplate_debug_la-arena.lo: src/base/$(am__dirstamp) \
+ src/base/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-per_expand_data.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template_annotator.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template_cache.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template_dictionary.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template_modifiers.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template_namelist.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template_pathops.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_debug_la-template_string.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_debug_la-htmlparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_debug_la-jsparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_debug_la-statemachine.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/windows/libctemplate_debug_la-port.lo: \
+ src/windows/$(am__dirstamp) \
+ src/windows/$(DEPDIR)/$(am__dirstamp)
+
+libctemplate_debug.la: $(libctemplate_debug_la_OBJECTS) $(libctemplate_debug_la_DEPENDENCIES) $(EXTRA_libctemplate_debug_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(libctemplate_debug_la_LINK) $(libctemplate_debug_la_OBJECTS) $(libctemplate_debug_la_LIBADD) $(LIBS)
+src/base/libctemplate_nothreads_la-arena.lo: src/base/$(am__dirstamp) \
+ src/base/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-per_expand_data.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template_annotator.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template_cache.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template_dictionary.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template_modifiers.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template_namelist.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template_pathops.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_la-template_string.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_nothreads_la-htmlparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_nothreads_la-jsparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_nothreads_la-statemachine.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/windows/libctemplate_nothreads_la-port.lo: \
+ src/windows/$(am__dirstamp) \
+ src/windows/$(DEPDIR)/$(am__dirstamp)
+
+libctemplate_nothreads.la: $(libctemplate_nothreads_la_OBJECTS) $(libctemplate_nothreads_la_DEPENDENCIES) $(EXTRA_libctemplate_nothreads_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(libctemplate_nothreads_la_LINK) -rpath $(libdir) $(libctemplate_nothreads_la_OBJECTS) $(libctemplate_nothreads_la_LIBADD) $(LIBS)
+src/base/libctemplate_nothreads_debug_la-arena.lo: \
+ src/base/$(am__dirstamp) src/base/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-per_expand_data.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template.lo: src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template_annotator.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template_cache.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template_dictionary.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template_modifiers.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template_namelist.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template_pathops.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/libctemplate_nothreads_debug_la-template_string.lo: \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_nothreads_debug_la-htmlparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_nothreads_debug_la-jsparser.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/htmlparser/libctemplate_nothreads_debug_la-statemachine.lo: \
+ src/htmlparser/$(am__dirstamp) \
+ src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+src/windows/libctemplate_nothreads_debug_la-port.lo: \
+ src/windows/$(am__dirstamp) \
+ src/windows/$(DEPDIR)/$(am__dirstamp)
+
+libctemplate_nothreads_debug.la: $(libctemplate_nothreads_debug_la_OBJECTS) $(libctemplate_nothreads_debug_la_DEPENDENCIES) $(EXTRA_libctemplate_nothreads_debug_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(libctemplate_nothreads_debug_la_LINK) $(libctemplate_nothreads_debug_la_OBJECTS) $(libctemplate_nothreads_debug_la_LIBADD) $(LIBS)
+src/tests/$(am__dirstamp):
+ @$(MKDIR_P) src/tests
+ @: > src/tests/$(am__dirstamp)
+src/tests/$(DEPDIR)/$(am__dirstamp):
+ @$(MKDIR_P) src/tests/$(DEPDIR)
+ @: > src/tests/$(DEPDIR)/$(am__dirstamp)
+src/tests/libctemplate_testing_la-template_test_util.lo: \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+libctemplate_testing.la: $(libctemplate_testing_la_OBJECTS) $(libctemplate_testing_la_DEPENDENCIES) $(EXTRA_libctemplate_testing_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(libctemplate_testing_la_LINK) $(libctemplate_testing_la_OBJECTS) $(libctemplate_testing_la_LIBADD) $(LIBS)
+src/tests/libctemplate_testing_nothreads_la-template_test_util.lo: \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+libctemplate_testing_nothreads.la: $(libctemplate_testing_nothreads_la_OBJECTS) $(libctemplate_testing_nothreads_la_DEPENDENCIES) $(EXTRA_libctemplate_testing_nothreads_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(libctemplate_testing_nothreads_la_LINK) $(libctemplate_testing_nothreads_la_OBJECTS) $(libctemplate_testing_nothreads_la_LIBADD) $(LIBS)
+install-binPROGRAMS: $(bin_PROGRAMS)
+ @$(NORMAL_INSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed 's/$(EXEEXT)$$//' | \
+ while read p p1; do if test -f $$p \
+ || test -f $$p1 \
+ ; then echo "$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n;h' \
+ -e 's|.*|.|' \
+ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+ sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) files[d] = files[d] " " $$1; \
+ else { print "f", $$3 "/" $$4, $$1; } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binPROGRAMS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+ -e 's/$$/$(EXEEXT)/' \
+ `; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+ @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+src/tests/compile_nothreads_test-compile_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+compile_nothreads_test$(EXEEXT): $(compile_nothreads_test_OBJECTS) $(compile_nothreads_test_DEPENDENCIES) $(EXTRA_compile_nothreads_test_DEPENDENCIES)
+ @rm -f compile_nothreads_test$(EXEEXT)
+ $(AM_V_CXXLD)$(compile_nothreads_test_LINK) $(compile_nothreads_test_OBJECTS) $(compile_nothreads_test_LDADD) $(LIBS)
+src/tests/compile_test-compile_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+compile_test$(EXEEXT): $(compile_test_OBJECTS) $(compile_test_DEPENDENCIES) $(EXTRA_compile_test_DEPENDENCIES)
+ @rm -f compile_test$(EXEEXT)
+ $(AM_V_CXXLD)$(compile_test_LINK) $(compile_test_OBJECTS) $(compile_test_LDADD) $(LIBS)
+src/diff_tpl_auto_escape.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+
+diff_tpl_auto_escape$(EXEEXT): $(diff_tpl_auto_escape_OBJECTS) $(diff_tpl_auto_escape_DEPENDENCIES) $(EXTRA_diff_tpl_auto_escape_DEPENDENCIES)
+ @rm -f diff_tpl_auto_escape$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(diff_tpl_auto_escape_OBJECTS) $(diff_tpl_auto_escape_LDADD) $(LIBS)
+src/tests/generate_fsm_c_test.$(OBJEXT): src/tests/$(am__dirstamp) \
+ src/tests/$(DEPDIR)/$(am__dirstamp)
+
+generate_fsm_c_test$(EXEEXT): $(generate_fsm_c_test_OBJECTS) $(generate_fsm_c_test_DEPENDENCIES) $(EXTRA_generate_fsm_c_test_DEPENDENCIES)
+ @rm -f generate_fsm_c_test$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(generate_fsm_c_test_OBJECTS) $(generate_fsm_c_test_LDADD) $(LIBS)
+src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+htmlparser_nothreads_test$(EXEEXT): $(htmlparser_nothreads_test_OBJECTS) $(htmlparser_nothreads_test_DEPENDENCIES) $(EXTRA_htmlparser_nothreads_test_DEPENDENCIES)
+ @rm -f htmlparser_nothreads_test$(EXEEXT)
+ $(AM_V_CXXLD)$(htmlparser_nothreads_test_LINK) $(htmlparser_nothreads_test_OBJECTS) $(htmlparser_nothreads_test_LDADD) $(LIBS)
+src/tests/htmlparser_test-htmlparser_cpp_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+htmlparser_test$(EXEEXT): $(htmlparser_test_OBJECTS) $(htmlparser_test_DEPENDENCIES) $(EXTRA_htmlparser_test_DEPENDENCIES)
+ @rm -f htmlparser_test$(EXEEXT)
+ $(AM_V_CXXLD)$(htmlparser_test_LINK) $(htmlparser_test_OBJECTS) $(htmlparser_test_LDADD) $(LIBS)
+src/make_tpl_varnames_h.$(OBJEXT): src/$(am__dirstamp) \
+ src/$(DEPDIR)/$(am__dirstamp)
+
+make_tpl_varnames_h$(EXEEXT): $(make_tpl_varnames_h_OBJECTS) $(make_tpl_varnames_h_DEPENDENCIES) $(EXTRA_make_tpl_varnames_h_DEPENDENCIES)
+ @rm -f make_tpl_varnames_h$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(make_tpl_varnames_h_OBJECTS) $(make_tpl_varnames_h_LDADD) $(LIBS)
+src/tests/statemachine_test-statemachine_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+statemachine_test$(EXEEXT): $(statemachine_test_OBJECTS) $(statemachine_test_DEPENDENCIES) $(EXTRA_statemachine_test_DEPENDENCIES)
+ @rm -f statemachine_test$(EXEEXT)
+ $(AM_V_CCLD)$(statemachine_test_LINK) $(statemachine_test_OBJECTS) $(statemachine_test_LDADD) $(LIBS)
+src/tests/template_cache_nothreads_test-template_cache_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_cache_nothreads_test$(EXEEXT): $(template_cache_nothreads_test_OBJECTS) $(template_cache_nothreads_test_DEPENDENCIES) $(EXTRA_template_cache_nothreads_test_DEPENDENCIES)
+ @rm -f template_cache_nothreads_test$(EXEEXT)
+ $(AM_V_CXXLD)$(template_cache_nothreads_test_LINK) $(template_cache_nothreads_test_OBJECTS) $(template_cache_nothreads_test_LDADD) $(LIBS)
+src/tests/template_cache_test-template_cache_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_cache_test$(EXEEXT): $(template_cache_test_OBJECTS) $(template_cache_test_DEPENDENCIES) $(EXTRA_template_cache_test_DEPENDENCIES)
+ @rm -f template_cache_test$(EXEEXT)
+ $(AM_V_CXXLD)$(template_cache_test_LINK) $(template_cache_test_OBJECTS) $(template_cache_test_LDADD) $(LIBS)
+src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_dictionary_nothreads_unittest$(EXEEXT): $(template_dictionary_nothreads_unittest_OBJECTS) $(template_dictionary_nothreads_unittest_DEPENDENCIES) $(EXTRA_template_dictionary_nothreads_unittest_DEPENDENCIES)
+ @rm -f template_dictionary_nothreads_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_dictionary_nothreads_unittest_LINK) $(template_dictionary_nothreads_unittest_OBJECTS) $(template_dictionary_nothreads_unittest_LDADD) $(LIBS)
+src/tests/template_dictionary_unittest-template_dictionary_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_dictionary_unittest$(EXEEXT): $(template_dictionary_unittest_OBJECTS) $(template_dictionary_unittest_DEPENDENCIES) $(EXTRA_template_dictionary_unittest_DEPENDENCIES)
+ @rm -f template_dictionary_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_dictionary_unittest_LINK) $(template_dictionary_unittest_OBJECTS) $(template_dictionary_unittest_LDADD) $(LIBS)
+src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_modifiers_nothreads_unittest$(EXEEXT): $(template_modifiers_nothreads_unittest_OBJECTS) $(template_modifiers_nothreads_unittest_DEPENDENCIES) $(EXTRA_template_modifiers_nothreads_unittest_DEPENDENCIES)
+ @rm -f template_modifiers_nothreads_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_modifiers_nothreads_unittest_LINK) $(template_modifiers_nothreads_unittest_OBJECTS) $(template_modifiers_nothreads_unittest_LDADD) $(LIBS)
+src/tests/template_modifiers_unittest-template_modifiers_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_modifiers_unittest$(EXEEXT): $(template_modifiers_unittest_OBJECTS) $(template_modifiers_unittest_DEPENDENCIES) $(EXTRA_template_modifiers_unittest_DEPENDENCIES)
+ @rm -f template_modifiers_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_modifiers_unittest_LINK) $(template_modifiers_unittest_OBJECTS) $(template_modifiers_unittest_LDADD) $(LIBS)
+src/tests/template_nothreads_regtest-template_regtest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_nothreads_regtest$(EXEEXT): $(template_nothreads_regtest_OBJECTS) $(template_nothreads_regtest_DEPENDENCIES) $(EXTRA_template_nothreads_regtest_DEPENDENCIES)
+ @rm -f template_nothreads_regtest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_nothreads_regtest_LINK) $(template_nothreads_regtest_OBJECTS) $(template_nothreads_regtest_LDADD) $(LIBS)
+src/tests/template_nothreads_unittest-template_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_nothreads_unittest$(EXEEXT): $(template_nothreads_unittest_OBJECTS) $(template_nothreads_unittest_DEPENDENCIES) $(EXTRA_template_nothreads_unittest_DEPENDENCIES)
+ @rm -f template_nothreads_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_nothreads_unittest_LINK) $(template_nothreads_unittest_OBJECTS) $(template_nothreads_unittest_LDADD) $(LIBS)
+src/tests/template_regtest-template_regtest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_regtest$(EXEEXT): $(template_regtest_OBJECTS) $(template_regtest_DEPENDENCIES) $(EXTRA_template_regtest_DEPENDENCIES)
+ @rm -f template_regtest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_regtest_LINK) $(template_regtest_OBJECTS) $(template_regtest_LDADD) $(LIBS)
+src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_setglobals_nothreads_unittest$(EXEEXT): $(template_setglobals_nothreads_unittest_OBJECTS) $(template_setglobals_nothreads_unittest_DEPENDENCIES) $(EXTRA_template_setglobals_nothreads_unittest_DEPENDENCIES)
+ @rm -f template_setglobals_nothreads_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_setglobals_nothreads_unittest_LINK) $(template_setglobals_nothreads_unittest_OBJECTS) $(template_setglobals_nothreads_unittest_LDADD) $(LIBS)
+src/tests/template_setglobals_unittest-template_setglobals_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_setglobals_unittest$(EXEEXT): $(template_setglobals_unittest_OBJECTS) $(template_setglobals_unittest_DEPENDENCIES) $(EXTRA_template_setglobals_unittest_DEPENDENCIES)
+ @rm -f template_setglobals_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_setglobals_unittest_LINK) $(template_setglobals_unittest_OBJECTS) $(template_setglobals_unittest_LDADD) $(LIBS)
+src/template_test_util_nothreads_test-template_dictionary.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/tests/template_test_util_nothreads_test-template_test_util_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_test_util_nothreads_test$(EXEEXT): $(template_test_util_nothreads_test_OBJECTS) $(template_test_util_nothreads_test_DEPENDENCIES) $(EXTRA_template_test_util_nothreads_test_DEPENDENCIES)
+ @rm -f template_test_util_nothreads_test$(EXEEXT)
+ $(AM_V_CXXLD)$(template_test_util_nothreads_test_LINK) $(template_test_util_nothreads_test_OBJECTS) $(template_test_util_nothreads_test_LDADD) $(LIBS)
+src/template_test_util_test-template_dictionary.$(OBJEXT): \
+ src/$(am__dirstamp) src/$(DEPDIR)/$(am__dirstamp)
+src/tests/template_test_util_test-template_test_util_test.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_test_util_test$(EXEEXT): $(template_test_util_test_OBJECTS) $(template_test_util_test_DEPENDENCIES) $(EXTRA_template_test_util_test_DEPENDENCIES)
+ @rm -f template_test_util_test$(EXEEXT)
+ $(AM_V_CXXLD)$(template_test_util_test_LINK) $(template_test_util_test_OBJECTS) $(template_test_util_test_LDADD) $(LIBS)
+src/tests/template_unittest-template_unittest.$(OBJEXT): \
+ src/tests/$(am__dirstamp) src/tests/$(DEPDIR)/$(am__dirstamp)
+
+template_unittest$(EXEEXT): $(template_unittest_OBJECTS) $(template_unittest_DEPENDENCIES) $(EXTRA_template_unittest_DEPENDENCIES)
+ @rm -f template_unittest$(EXEEXT)
+ $(AM_V_CXXLD)$(template_unittest_LINK) $(template_unittest_OBJECTS) $(template_unittest_LDADD) $(LIBS)
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ dir='$(DESTDIR)$(bindir)'; $(am__uninstall_files_from_dir)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+ -rm -f src/*.$(OBJEXT)
+ -rm -f src/*.lo
+ -rm -f src/base/*.$(OBJEXT)
+ -rm -f src/base/*.lo
+ -rm -f src/htmlparser/*.$(OBJEXT)
+ -rm -f src/htmlparser/*.lo
+ -rm -f src/tests/*.$(OBJEXT)
+ -rm -f src/tests/*.lo
+ -rm -f src/windows/*.$(OBJEXT)
+ -rm -f src/windows/*.lo
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/statemachine_test-statemachine.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/diff_tpl_auto_escape.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-per_expand_data.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template_annotator.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template_cache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template_dictionary.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template_modifiers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template_namelist.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template_pathops.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_debug_la-template_string.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-per_expand_data.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template_annotator.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template_cache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template_dictionary.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template_modifiers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template_namelist.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template_pathops.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_la-template_string.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-per_expand_data.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_annotator.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_cache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_dictionary.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_modifiers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_namelist.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_pathops.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_string.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-per_expand_data.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template_annotator.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template_cache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template_dictionary.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template_modifiers.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template_namelist.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template_pathops.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/libctemplate_nothreads_la-template_string.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/make_tpl_varnames_h.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/template_test_util_nothreads_test-template_dictionary.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/$(DEPDIR)/template_test_util_test-template_dictionary.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/base/$(DEPDIR)/libctemplate_debug_la-arena.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/base/$(DEPDIR)/libctemplate_la-arena.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/base/$(DEPDIR)/libctemplate_nothreads_debug_la-arena.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/base/$(DEPDIR)/libctemplate_nothreads_la-arena.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_debug_la-htmlparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_debug_la-jsparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_debug_la-statemachine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_la-htmlparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_la-jsparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_la-statemachine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-htmlparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-jsparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-statemachine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-htmlparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-jsparser.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-statemachine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/compile_nothreads_test-compile_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/compile_test-compile_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/generate_fsm_c_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/htmlparser_nothreads_test-htmlparser_cpp_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/htmlparser_test-htmlparser_cpp_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/libctemplate_testing_la-template_test_util.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/libctemplate_testing_nothreads_la-template_test_util.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/statemachine_test-statemachine_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_cache_nothreads_test-template_cache_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_cache_test-template_cache_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_dictionary_nothreads_unittest-template_dictionary_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_dictionary_unittest-template_dictionary_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_modifiers_nothreads_unittest-template_modifiers_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_modifiers_unittest-template_modifiers_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_nothreads_regtest-template_regtest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_nothreads_unittest-template_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_regtest-template_regtest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_setglobals_nothreads_unittest-template_setglobals_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_setglobals_unittest-template_setglobals_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_test_util_nothreads_test-template_test_util_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_test_util_test-template_test_util_test.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/tests/$(DEPDIR)/template_unittest-template_unittest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/windows/$(DEPDIR)/libctemplate_debug_la-port.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/windows/$(DEPDIR)/libctemplate_la-port.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/windows/$(DEPDIR)/libctemplate_nothreads_debug_la-port.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@src/windows/$(DEPDIR)/libctemplate_nothreads_la-port.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCC_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LTCOMPILE) -c -o $@ $<
+
+src/tests/statemachine_test-statemachine_test.o: src/tests/statemachine_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -MT src/tests/statemachine_test-statemachine_test.o -MD -MP -MF src/tests/$(DEPDIR)/statemachine_test-statemachine_test.Tpo -c -o src/tests/statemachine_test-statemachine_test.o `test -f 'src/tests/statemachine_test.c' || echo '$(srcdir)/'`src/tests/statemachine_test.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/statemachine_test-statemachine_test.Tpo src/tests/$(DEPDIR)/statemachine_test-statemachine_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tests/statemachine_test.c' object='src/tests/statemachine_test-statemachine_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -c -o src/tests/statemachine_test-statemachine_test.o `test -f 'src/tests/statemachine_test.c' || echo '$(srcdir)/'`src/tests/statemachine_test.c
+
+src/tests/statemachine_test-statemachine_test.obj: src/tests/statemachine_test.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -MT src/tests/statemachine_test-statemachine_test.obj -MD -MP -MF src/tests/$(DEPDIR)/statemachine_test-statemachine_test.Tpo -c -o src/tests/statemachine_test-statemachine_test.obj `if test -f 'src/tests/statemachine_test.c'; then $(CYGPATH_W) 'src/tests/statemachine_test.c'; else $(CYGPATH_W) '$(srcdir)/src/tests/statemachine_test.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/statemachine_test-statemachine_test.Tpo src/tests/$(DEPDIR)/statemachine_test-statemachine_test.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='src/tests/statemachine_test.c' object='src/tests/statemachine_test-statemachine_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -c -o src/tests/statemachine_test-statemachine_test.obj `if test -f 'src/tests/statemachine_test.c'; then $(CYGPATH_W) 'src/tests/statemachine_test.c'; else $(CYGPATH_W) '$(srcdir)/src/tests/statemachine_test.c'; fi`
+
+statemachine_test-statemachine.o: statemachine.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -MT statemachine_test-statemachine.o -MD -MP -MF $(DEPDIR)/statemachine_test-statemachine.Tpo -c -o statemachine_test-statemachine.o `test -f 'statemachine.c' || echo '$(srcdir)/'`statemachine.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/statemachine_test-statemachine.Tpo $(DEPDIR)/statemachine_test-statemachine.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='statemachine.c' object='statemachine_test-statemachine.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -c -o statemachine_test-statemachine.o `test -f 'statemachine.c' || echo '$(srcdir)/'`statemachine.c
+
+statemachine_test-statemachine.obj: statemachine.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -MT statemachine_test-statemachine.obj -MD -MP -MF $(DEPDIR)/statemachine_test-statemachine.Tpo -c -o statemachine_test-statemachine.obj `if test -f 'statemachine.c'; then $(CYGPATH_W) 'statemachine.c'; else $(CYGPATH_W) '$(srcdir)/statemachine.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/statemachine_test-statemachine.Tpo $(DEPDIR)/statemachine_test-statemachine.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='statemachine.c' object='statemachine_test-statemachine.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(statemachine_test_CFLAGS) $(CFLAGS) -c -o statemachine_test-statemachine.obj `if test -f 'statemachine.c'; then $(CYGPATH_W) 'statemachine.c'; else $(CYGPATH_W) '$(srcdir)/statemachine.c'; fi`
+
+.cc.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ $<
+
+.cc.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.obj$$||'`;\
+@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ `$(CYGPATH_W) '$<'` &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cc.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.lo$$||'`;\
+@am__fastdepCXX_TRUE@ $(LTCXXCOMPILE) -MT $@ -MD -MP -MF $$depbase.Tpo -c -o $@ $< &&\
+@am__fastdepCXX_TRUE@ $(am__mv) $$depbase.Tpo $$depbase.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LTCXXCOMPILE) -c -o $@ $<
+
+src/base/libctemplate_la-arena.lo: src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/base/libctemplate_la-arena.lo -MD -MP -MF src/base/$(DEPDIR)/libctemplate_la-arena.Tpo -c -o src/base/libctemplate_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/base/$(DEPDIR)/libctemplate_la-arena.Tpo src/base/$(DEPDIR)/libctemplate_la-arena.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/base/arena.cc' object='src/base/libctemplate_la-arena.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/base/libctemplate_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+
+src/libctemplate_la-per_expand_data.lo: src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-per_expand_data.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-per_expand_data.Tpo -c -o src/libctemplate_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-per_expand_data.Tpo src/$(DEPDIR)/libctemplate_la-per_expand_data.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/per_expand_data.cc' object='src/libctemplate_la-per_expand_data.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+
+src/libctemplate_la-template.lo: src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template.Tpo -c -o src/libctemplate_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template.Tpo src/$(DEPDIR)/libctemplate_la-template.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template.cc' object='src/libctemplate_la-template.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+
+src/libctemplate_la-template_annotator.lo: src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template_annotator.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template_annotator.Tpo -c -o src/libctemplate_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template_annotator.Tpo src/$(DEPDIR)/libctemplate_la-template_annotator.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_annotator.cc' object='src/libctemplate_la-template_annotator.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+
+src/libctemplate_la-template_cache.lo: src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template_cache.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template_cache.Tpo -c -o src/libctemplate_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template_cache.Tpo src/$(DEPDIR)/libctemplate_la-template_cache.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_cache.cc' object='src/libctemplate_la-template_cache.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+
+src/libctemplate_la-template_dictionary.lo: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template_dictionary.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template_dictionary.Tpo -c -o src/libctemplate_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template_dictionary.Tpo src/$(DEPDIR)/libctemplate_la-template_dictionary.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/libctemplate_la-template_dictionary.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+
+src/libctemplate_la-template_modifiers.lo: src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template_modifiers.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template_modifiers.Tpo -c -o src/libctemplate_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template_modifiers.Tpo src/$(DEPDIR)/libctemplate_la-template_modifiers.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_modifiers.cc' object='src/libctemplate_la-template_modifiers.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+
+src/libctemplate_la-template_namelist.lo: src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template_namelist.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template_namelist.Tpo -c -o src/libctemplate_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template_namelist.Tpo src/$(DEPDIR)/libctemplate_la-template_namelist.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_namelist.cc' object='src/libctemplate_la-template_namelist.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+
+src/libctemplate_la-template_pathops.lo: src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template_pathops.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template_pathops.Tpo -c -o src/libctemplate_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template_pathops.Tpo src/$(DEPDIR)/libctemplate_la-template_pathops.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_pathops.cc' object='src/libctemplate_la-template_pathops.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+
+src/libctemplate_la-template_string.lo: src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_la-template_string.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_la-template_string.Tpo -c -o src/libctemplate_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_la-template_string.Tpo src/$(DEPDIR)/libctemplate_la-template_string.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_string.cc' object='src/libctemplate_la-template_string.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+
+src/htmlparser/libctemplate_la-htmlparser.lo: src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_la-htmlparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_la-htmlparser.Tpo -c -o src/htmlparser/libctemplate_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_la-htmlparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_la-htmlparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/htmlparser.cc' object='src/htmlparser/libctemplate_la-htmlparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+
+src/htmlparser/libctemplate_la-jsparser.lo: src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_la-jsparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_la-jsparser.Tpo -c -o src/htmlparser/libctemplate_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_la-jsparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_la-jsparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/jsparser.cc' object='src/htmlparser/libctemplate_la-jsparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+
+src/htmlparser/libctemplate_la-statemachine.lo: src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_la-statemachine.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_la-statemachine.Tpo -c -o src/htmlparser/libctemplate_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_la-statemachine.Tpo src/htmlparser/$(DEPDIR)/libctemplate_la-statemachine.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/statemachine.cc' object='src/htmlparser/libctemplate_la-statemachine.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+
+src/windows/libctemplate_la-port.lo: src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -MT src/windows/libctemplate_la-port.lo -MD -MP -MF src/windows/$(DEPDIR)/libctemplate_la-port.Tpo -c -o src/windows/libctemplate_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/windows/$(DEPDIR)/libctemplate_la-port.Tpo src/windows/$(DEPDIR)/libctemplate_la-port.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/windows/port.cc' object='src/windows/libctemplate_la-port.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_la_CXXFLAGS) $(CXXFLAGS) -c -o src/windows/libctemplate_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+
+src/base/libctemplate_debug_la-arena.lo: src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/base/libctemplate_debug_la-arena.lo -MD -MP -MF src/base/$(DEPDIR)/libctemplate_debug_la-arena.Tpo -c -o src/base/libctemplate_debug_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/base/$(DEPDIR)/libctemplate_debug_la-arena.Tpo src/base/$(DEPDIR)/libctemplate_debug_la-arena.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/base/arena.cc' object='src/base/libctemplate_debug_la-arena.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/base/libctemplate_debug_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+
+src/libctemplate_debug_la-per_expand_data.lo: src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-per_expand_data.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-per_expand_data.Tpo -c -o src/libctemplate_debug_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-per_expand_data.Tpo src/$(DEPDIR)/libctemplate_debug_la-per_expand_data.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/per_expand_data.cc' object='src/libctemplate_debug_la-per_expand_data.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+
+src/libctemplate_debug_la-template.lo: src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template.Tpo -c -o src/libctemplate_debug_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template.Tpo src/$(DEPDIR)/libctemplate_debug_la-template.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template.cc' object='src/libctemplate_debug_la-template.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+
+src/libctemplate_debug_la-template_annotator.lo: src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template_annotator.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template_annotator.Tpo -c -o src/libctemplate_debug_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template_annotator.Tpo src/$(DEPDIR)/libctemplate_debug_la-template_annotator.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_annotator.cc' object='src/libctemplate_debug_la-template_annotator.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+
+src/libctemplate_debug_la-template_cache.lo: src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template_cache.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template_cache.Tpo -c -o src/libctemplate_debug_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template_cache.Tpo src/$(DEPDIR)/libctemplate_debug_la-template_cache.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_cache.cc' object='src/libctemplate_debug_la-template_cache.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+
+src/libctemplate_debug_la-template_dictionary.lo: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template_dictionary.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template_dictionary.Tpo -c -o src/libctemplate_debug_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template_dictionary.Tpo src/$(DEPDIR)/libctemplate_debug_la-template_dictionary.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/libctemplate_debug_la-template_dictionary.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+
+src/libctemplate_debug_la-template_modifiers.lo: src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template_modifiers.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template_modifiers.Tpo -c -o src/libctemplate_debug_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template_modifiers.Tpo src/$(DEPDIR)/libctemplate_debug_la-template_modifiers.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_modifiers.cc' object='src/libctemplate_debug_la-template_modifiers.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+
+src/libctemplate_debug_la-template_namelist.lo: src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template_namelist.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template_namelist.Tpo -c -o src/libctemplate_debug_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template_namelist.Tpo src/$(DEPDIR)/libctemplate_debug_la-template_namelist.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_namelist.cc' object='src/libctemplate_debug_la-template_namelist.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+
+src/libctemplate_debug_la-template_pathops.lo: src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template_pathops.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template_pathops.Tpo -c -o src/libctemplate_debug_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template_pathops.Tpo src/$(DEPDIR)/libctemplate_debug_la-template_pathops.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_pathops.cc' object='src/libctemplate_debug_la-template_pathops.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+
+src/libctemplate_debug_la-template_string.lo: src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_debug_la-template_string.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_debug_la-template_string.Tpo -c -o src/libctemplate_debug_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_debug_la-template_string.Tpo src/$(DEPDIR)/libctemplate_debug_la-template_string.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_string.cc' object='src/libctemplate_debug_la-template_string.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_debug_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+
+src/htmlparser/libctemplate_debug_la-htmlparser.lo: src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_debug_la-htmlparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_debug_la-htmlparser.Tpo -c -o src/htmlparser/libctemplate_debug_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_debug_la-htmlparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_debug_la-htmlparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/htmlparser.cc' object='src/htmlparser/libctemplate_debug_la-htmlparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_debug_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+
+src/htmlparser/libctemplate_debug_la-jsparser.lo: src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_debug_la-jsparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_debug_la-jsparser.Tpo -c -o src/htmlparser/libctemplate_debug_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_debug_la-jsparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_debug_la-jsparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/jsparser.cc' object='src/htmlparser/libctemplate_debug_la-jsparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_debug_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+
+src/htmlparser/libctemplate_debug_la-statemachine.lo: src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_debug_la-statemachine.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_debug_la-statemachine.Tpo -c -o src/htmlparser/libctemplate_debug_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_debug_la-statemachine.Tpo src/htmlparser/$(DEPDIR)/libctemplate_debug_la-statemachine.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/statemachine.cc' object='src/htmlparser/libctemplate_debug_la-statemachine.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_debug_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+
+src/windows/libctemplate_debug_la-port.lo: src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/windows/libctemplate_debug_la-port.lo -MD -MP -MF src/windows/$(DEPDIR)/libctemplate_debug_la-port.Tpo -c -o src/windows/libctemplate_debug_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/windows/$(DEPDIR)/libctemplate_debug_la-port.Tpo src/windows/$(DEPDIR)/libctemplate_debug_la-port.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/windows/port.cc' object='src/windows/libctemplate_debug_la-port.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/windows/libctemplate_debug_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+
+src/base/libctemplate_nothreads_la-arena.lo: src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/base/libctemplate_nothreads_la-arena.lo -MD -MP -MF src/base/$(DEPDIR)/libctemplate_nothreads_la-arena.Tpo -c -o src/base/libctemplate_nothreads_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/base/$(DEPDIR)/libctemplate_nothreads_la-arena.Tpo src/base/$(DEPDIR)/libctemplate_nothreads_la-arena.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/base/arena.cc' object='src/base/libctemplate_nothreads_la-arena.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/base/libctemplate_nothreads_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+
+src/libctemplate_nothreads_la-per_expand_data.lo: src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-per_expand_data.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-per_expand_data.Tpo -c -o src/libctemplate_nothreads_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-per_expand_data.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-per_expand_data.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/per_expand_data.cc' object='src/libctemplate_nothreads_la-per_expand_data.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+
+src/libctemplate_nothreads_la-template.lo: src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template.Tpo -c -o src/libctemplate_nothreads_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template.cc' object='src/libctemplate_nothreads_la-template.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+
+src/libctemplate_nothreads_la-template_annotator.lo: src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template_annotator.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template_annotator.Tpo -c -o src/libctemplate_nothreads_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template_annotator.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template_annotator.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_annotator.cc' object='src/libctemplate_nothreads_la-template_annotator.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+
+src/libctemplate_nothreads_la-template_cache.lo: src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template_cache.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template_cache.Tpo -c -o src/libctemplate_nothreads_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template_cache.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template_cache.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_cache.cc' object='src/libctemplate_nothreads_la-template_cache.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+
+src/libctemplate_nothreads_la-template_dictionary.lo: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template_dictionary.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template_dictionary.Tpo -c -o src/libctemplate_nothreads_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template_dictionary.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template_dictionary.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/libctemplate_nothreads_la-template_dictionary.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+
+src/libctemplate_nothreads_la-template_modifiers.lo: src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template_modifiers.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template_modifiers.Tpo -c -o src/libctemplate_nothreads_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template_modifiers.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template_modifiers.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_modifiers.cc' object='src/libctemplate_nothreads_la-template_modifiers.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+
+src/libctemplate_nothreads_la-template_namelist.lo: src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template_namelist.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template_namelist.Tpo -c -o src/libctemplate_nothreads_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template_namelist.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template_namelist.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_namelist.cc' object='src/libctemplate_nothreads_la-template_namelist.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+
+src/libctemplate_nothreads_la-template_pathops.lo: src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template_pathops.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template_pathops.Tpo -c -o src/libctemplate_nothreads_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template_pathops.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template_pathops.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_pathops.cc' object='src/libctemplate_nothreads_la-template_pathops.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+
+src/libctemplate_nothreads_la-template_string.lo: src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_la-template_string.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_la-template_string.Tpo -c -o src/libctemplate_nothreads_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_la-template_string.Tpo src/$(DEPDIR)/libctemplate_nothreads_la-template_string.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_string.cc' object='src/libctemplate_nothreads_la-template_string.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+
+src/htmlparser/libctemplate_nothreads_la-htmlparser.lo: src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_nothreads_la-htmlparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-htmlparser.Tpo -c -o src/htmlparser/libctemplate_nothreads_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-htmlparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-htmlparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/htmlparser.cc' object='src/htmlparser/libctemplate_nothreads_la-htmlparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_nothreads_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+
+src/htmlparser/libctemplate_nothreads_la-jsparser.lo: src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_nothreads_la-jsparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-jsparser.Tpo -c -o src/htmlparser/libctemplate_nothreads_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-jsparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-jsparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/jsparser.cc' object='src/htmlparser/libctemplate_nothreads_la-jsparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_nothreads_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+
+src/htmlparser/libctemplate_nothreads_la-statemachine.lo: src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_nothreads_la-statemachine.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-statemachine.Tpo -c -o src/htmlparser/libctemplate_nothreads_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-statemachine.Tpo src/htmlparser/$(DEPDIR)/libctemplate_nothreads_la-statemachine.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/statemachine.cc' object='src/htmlparser/libctemplate_nothreads_la-statemachine.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_nothreads_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+
+src/windows/libctemplate_nothreads_la-port.lo: src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/windows/libctemplate_nothreads_la-port.lo -MD -MP -MF src/windows/$(DEPDIR)/libctemplate_nothreads_la-port.Tpo -c -o src/windows/libctemplate_nothreads_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/windows/$(DEPDIR)/libctemplate_nothreads_la-port.Tpo src/windows/$(DEPDIR)/libctemplate_nothreads_la-port.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/windows/port.cc' object='src/windows/libctemplate_nothreads_la-port.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/windows/libctemplate_nothreads_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+
+src/base/libctemplate_nothreads_debug_la-arena.lo: src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/base/libctemplate_nothreads_debug_la-arena.lo -MD -MP -MF src/base/$(DEPDIR)/libctemplate_nothreads_debug_la-arena.Tpo -c -o src/base/libctemplate_nothreads_debug_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/base/$(DEPDIR)/libctemplate_nothreads_debug_la-arena.Tpo src/base/$(DEPDIR)/libctemplate_nothreads_debug_la-arena.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/base/arena.cc' object='src/base/libctemplate_nothreads_debug_la-arena.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/base/libctemplate_nothreads_debug_la-arena.lo `test -f 'src/base/arena.cc' || echo '$(srcdir)/'`src/base/arena.cc
+
+src/libctemplate_nothreads_debug_la-per_expand_data.lo: src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-per_expand_data.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-per_expand_data.Tpo -c -o src/libctemplate_nothreads_debug_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-per_expand_data.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-per_expand_data.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/per_expand_data.cc' object='src/libctemplate_nothreads_debug_la-per_expand_data.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-per_expand_data.lo `test -f 'src/per_expand_data.cc' || echo '$(srcdir)/'`src/per_expand_data.cc
+
+src/libctemplate_nothreads_debug_la-template.lo: src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template.Tpo -c -o src/libctemplate_nothreads_debug_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template.cc' object='src/libctemplate_nothreads_debug_la-template.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template.lo `test -f 'src/template.cc' || echo '$(srcdir)/'`src/template.cc
+
+src/libctemplate_nothreads_debug_la-template_annotator.lo: src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template_annotator.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_annotator.Tpo -c -o src/libctemplate_nothreads_debug_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_annotator.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_annotator.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_annotator.cc' object='src/libctemplate_nothreads_debug_la-template_annotator.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template_annotator.lo `test -f 'src/template_annotator.cc' || echo '$(srcdir)/'`src/template_annotator.cc
+
+src/libctemplate_nothreads_debug_la-template_cache.lo: src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template_cache.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_cache.Tpo -c -o src/libctemplate_nothreads_debug_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_cache.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_cache.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_cache.cc' object='src/libctemplate_nothreads_debug_la-template_cache.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template_cache.lo `test -f 'src/template_cache.cc' || echo '$(srcdir)/'`src/template_cache.cc
+
+src/libctemplate_nothreads_debug_la-template_dictionary.lo: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template_dictionary.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_dictionary.Tpo -c -o src/libctemplate_nothreads_debug_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_dictionary.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_dictionary.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/libctemplate_nothreads_debug_la-template_dictionary.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template_dictionary.lo `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+
+src/libctemplate_nothreads_debug_la-template_modifiers.lo: src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template_modifiers.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_modifiers.Tpo -c -o src/libctemplate_nothreads_debug_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_modifiers.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_modifiers.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_modifiers.cc' object='src/libctemplate_nothreads_debug_la-template_modifiers.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template_modifiers.lo `test -f 'src/template_modifiers.cc' || echo '$(srcdir)/'`src/template_modifiers.cc
+
+src/libctemplate_nothreads_debug_la-template_namelist.lo: src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template_namelist.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_namelist.Tpo -c -o src/libctemplate_nothreads_debug_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_namelist.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_namelist.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_namelist.cc' object='src/libctemplate_nothreads_debug_la-template_namelist.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template_namelist.lo `test -f 'src/template_namelist.cc' || echo '$(srcdir)/'`src/template_namelist.cc
+
+src/libctemplate_nothreads_debug_la-template_pathops.lo: src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template_pathops.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_pathops.Tpo -c -o src/libctemplate_nothreads_debug_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_pathops.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_pathops.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_pathops.cc' object='src/libctemplate_nothreads_debug_la-template_pathops.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template_pathops.lo `test -f 'src/template_pathops.cc' || echo '$(srcdir)/'`src/template_pathops.cc
+
+src/libctemplate_nothreads_debug_la-template_string.lo: src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/libctemplate_nothreads_debug_la-template_string.lo -MD -MP -MF src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_string.Tpo -c -o src/libctemplate_nothreads_debug_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_string.Tpo src/$(DEPDIR)/libctemplate_nothreads_debug_la-template_string.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_string.cc' object='src/libctemplate_nothreads_debug_la-template_string.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/libctemplate_nothreads_debug_la-template_string.lo `test -f 'src/template_string.cc' || echo '$(srcdir)/'`src/template_string.cc
+
+src/htmlparser/libctemplate_nothreads_debug_la-htmlparser.lo: src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_nothreads_debug_la-htmlparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-htmlparser.Tpo -c -o src/htmlparser/libctemplate_nothreads_debug_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-htmlparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-htmlparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/htmlparser.cc' object='src/htmlparser/libctemplate_nothreads_debug_la-htmlparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_nothreads_debug_la-htmlparser.lo `test -f 'src/htmlparser/htmlparser.cc' || echo '$(srcdir)/'`src/htmlparser/htmlparser.cc
+
+src/htmlparser/libctemplate_nothreads_debug_la-jsparser.lo: src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_nothreads_debug_la-jsparser.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-jsparser.Tpo -c -o src/htmlparser/libctemplate_nothreads_debug_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-jsparser.Tpo src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-jsparser.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/jsparser.cc' object='src/htmlparser/libctemplate_nothreads_debug_la-jsparser.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_nothreads_debug_la-jsparser.lo `test -f 'src/htmlparser/jsparser.cc' || echo '$(srcdir)/'`src/htmlparser/jsparser.cc
+
+src/htmlparser/libctemplate_nothreads_debug_la-statemachine.lo: src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/htmlparser/libctemplate_nothreads_debug_la-statemachine.lo -MD -MP -MF src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-statemachine.Tpo -c -o src/htmlparser/libctemplate_nothreads_debug_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-statemachine.Tpo src/htmlparser/$(DEPDIR)/libctemplate_nothreads_debug_la-statemachine.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/htmlparser/statemachine.cc' object='src/htmlparser/libctemplate_nothreads_debug_la-statemachine.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/htmlparser/libctemplate_nothreads_debug_la-statemachine.lo `test -f 'src/htmlparser/statemachine.cc' || echo '$(srcdir)/'`src/htmlparser/statemachine.cc
+
+src/windows/libctemplate_nothreads_debug_la-port.lo: src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -MT src/windows/libctemplate_nothreads_debug_la-port.lo -MD -MP -MF src/windows/$(DEPDIR)/libctemplate_nothreads_debug_la-port.Tpo -c -o src/windows/libctemplate_nothreads_debug_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/windows/$(DEPDIR)/libctemplate_nothreads_debug_la-port.Tpo src/windows/$(DEPDIR)/libctemplate_nothreads_debug_la-port.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/windows/port.cc' object='src/windows/libctemplate_nothreads_debug_la-port.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_nothreads_debug_la_CXXFLAGS) $(CXXFLAGS) -c -o src/windows/libctemplate_nothreads_debug_la-port.lo `test -f 'src/windows/port.cc' || echo '$(srcdir)/'`src/windows/port.cc
+
+src/tests/libctemplate_testing_la-template_test_util.lo: src/tests/template_test_util.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_testing_la_CXXFLAGS) $(CXXFLAGS) -MT src/tests/libctemplate_testing_la-template_test_util.lo -MD -MP -MF src/tests/$(DEPDIR)/libctemplate_testing_la-template_test_util.Tpo -c -o src/tests/libctemplate_testing_la-template_test_util.lo `test -f 'src/tests/template_test_util.cc' || echo '$(srcdir)/'`src/tests/template_test_util.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/libctemplate_testing_la-template_test_util.Tpo src/tests/$(DEPDIR)/libctemplate_testing_la-template_test_util.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_test_util.cc' object='src/tests/libctemplate_testing_la-template_test_util.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_testing_la_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/libctemplate_testing_la-template_test_util.lo `test -f 'src/tests/template_test_util.cc' || echo '$(srcdir)/'`src/tests/template_test_util.cc
+
+src/tests/libctemplate_testing_nothreads_la-template_test_util.lo: src/tests/template_test_util.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_testing_nothreads_la_CXXFLAGS) $(CXXFLAGS) -MT src/tests/libctemplate_testing_nothreads_la-template_test_util.lo -MD -MP -MF src/tests/$(DEPDIR)/libctemplate_testing_nothreads_la-template_test_util.Tpo -c -o src/tests/libctemplate_testing_nothreads_la-template_test_util.lo `test -f 'src/tests/template_test_util.cc' || echo '$(srcdir)/'`src/tests/template_test_util.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/libctemplate_testing_nothreads_la-template_test_util.Tpo src/tests/$(DEPDIR)/libctemplate_testing_nothreads_la-template_test_util.Plo
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_test_util.cc' object='src/tests/libctemplate_testing_nothreads_la-template_test_util.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libctemplate_testing_nothreads_la_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/libctemplate_testing_nothreads_la-template_test_util.lo `test -f 'src/tests/template_test_util.cc' || echo '$(srcdir)/'`src/tests/template_test_util.cc
+
+src/tests/compile_nothreads_test-compile_test.o: src/tests/compile_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/compile_nothreads_test-compile_test.o -MD -MP -MF src/tests/$(DEPDIR)/compile_nothreads_test-compile_test.Tpo -c -o src/tests/compile_nothreads_test-compile_test.o `test -f 'src/tests/compile_test.cc' || echo '$(srcdir)/'`src/tests/compile_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/compile_nothreads_test-compile_test.Tpo src/tests/$(DEPDIR)/compile_nothreads_test-compile_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/compile_test.cc' object='src/tests/compile_nothreads_test-compile_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/compile_nothreads_test-compile_test.o `test -f 'src/tests/compile_test.cc' || echo '$(srcdir)/'`src/tests/compile_test.cc
+
+src/tests/compile_nothreads_test-compile_test.obj: src/tests/compile_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/compile_nothreads_test-compile_test.obj -MD -MP -MF src/tests/$(DEPDIR)/compile_nothreads_test-compile_test.Tpo -c -o src/tests/compile_nothreads_test-compile_test.obj `if test -f 'src/tests/compile_test.cc'; then $(CYGPATH_W) 'src/tests/compile_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/compile_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/compile_nothreads_test-compile_test.Tpo src/tests/$(DEPDIR)/compile_nothreads_test-compile_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/compile_test.cc' object='src/tests/compile_nothreads_test-compile_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/compile_nothreads_test-compile_test.obj `if test -f 'src/tests/compile_test.cc'; then $(CYGPATH_W) 'src/tests/compile_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/compile_test.cc'; fi`
+
+src/tests/compile_test-compile_test.o: src/tests/compile_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/compile_test-compile_test.o -MD -MP -MF src/tests/$(DEPDIR)/compile_test-compile_test.Tpo -c -o src/tests/compile_test-compile_test.o `test -f 'src/tests/compile_test.cc' || echo '$(srcdir)/'`src/tests/compile_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/compile_test-compile_test.Tpo src/tests/$(DEPDIR)/compile_test-compile_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/compile_test.cc' object='src/tests/compile_test-compile_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/compile_test-compile_test.o `test -f 'src/tests/compile_test.cc' || echo '$(srcdir)/'`src/tests/compile_test.cc
+
+src/tests/compile_test-compile_test.obj: src/tests/compile_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/compile_test-compile_test.obj -MD -MP -MF src/tests/$(DEPDIR)/compile_test-compile_test.Tpo -c -o src/tests/compile_test-compile_test.obj `if test -f 'src/tests/compile_test.cc'; then $(CYGPATH_W) 'src/tests/compile_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/compile_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/compile_test-compile_test.Tpo src/tests/$(DEPDIR)/compile_test-compile_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/compile_test.cc' object='src/tests/compile_test-compile_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(compile_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/compile_test-compile_test.obj `if test -f 'src/tests/compile_test.cc'; then $(CYGPATH_W) 'src/tests/compile_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/compile_test.cc'; fi`
+
+src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.o: src/tests/htmlparser_cpp_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.o -MD -MP -MF src/tests/$(DEPDIR)/htmlparser_nothreads_test-htmlparser_cpp_test.Tpo -c -o src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.o `test -f 'src/tests/htmlparser_cpp_test.cc' || echo '$(srcdir)/'`src/tests/htmlparser_cpp_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/htmlparser_nothreads_test-htmlparser_cpp_test.Tpo src/tests/$(DEPDIR)/htmlparser_nothreads_test-htmlparser_cpp_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/htmlparser_cpp_test.cc' object='src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.o `test -f 'src/tests/htmlparser_cpp_test.cc' || echo '$(srcdir)/'`src/tests/htmlparser_cpp_test.cc
+
+src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.obj: src/tests/htmlparser_cpp_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.obj -MD -MP -MF src/tests/$(DEPDIR)/htmlparser_nothreads_test-htmlparser_cpp_test.Tpo -c -o src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.obj `if test -f 'src/tests/htmlparser_cpp_test.cc'; then $(CYGPATH_W) 'src/tests/htmlparser_cpp_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/htmlparser_cpp_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/htmlparser_nothreads_test-htmlparser_cpp_test.Tpo src/tests/$(DEPDIR)/htmlparser_nothreads_test-htmlparser_cpp_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/htmlparser_cpp_test.cc' object='src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/htmlparser_nothreads_test-htmlparser_cpp_test.obj `if test -f 'src/tests/htmlparser_cpp_test.cc'; then $(CYGPATH_W) 'src/tests/htmlparser_cpp_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/htmlparser_cpp_test.cc'; fi`
+
+src/tests/htmlparser_test-htmlparser_cpp_test.o: src/tests/htmlparser_cpp_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/htmlparser_test-htmlparser_cpp_test.o -MD -MP -MF src/tests/$(DEPDIR)/htmlparser_test-htmlparser_cpp_test.Tpo -c -o src/tests/htmlparser_test-htmlparser_cpp_test.o `test -f 'src/tests/htmlparser_cpp_test.cc' || echo '$(srcdir)/'`src/tests/htmlparser_cpp_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/htmlparser_test-htmlparser_cpp_test.Tpo src/tests/$(DEPDIR)/htmlparser_test-htmlparser_cpp_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/htmlparser_cpp_test.cc' object='src/tests/htmlparser_test-htmlparser_cpp_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/htmlparser_test-htmlparser_cpp_test.o `test -f 'src/tests/htmlparser_cpp_test.cc' || echo '$(srcdir)/'`src/tests/htmlparser_cpp_test.cc
+
+src/tests/htmlparser_test-htmlparser_cpp_test.obj: src/tests/htmlparser_cpp_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/htmlparser_test-htmlparser_cpp_test.obj -MD -MP -MF src/tests/$(DEPDIR)/htmlparser_test-htmlparser_cpp_test.Tpo -c -o src/tests/htmlparser_test-htmlparser_cpp_test.obj `if test -f 'src/tests/htmlparser_cpp_test.cc'; then $(CYGPATH_W) 'src/tests/htmlparser_cpp_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/htmlparser_cpp_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/htmlparser_test-htmlparser_cpp_test.Tpo src/tests/$(DEPDIR)/htmlparser_test-htmlparser_cpp_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/htmlparser_cpp_test.cc' object='src/tests/htmlparser_test-htmlparser_cpp_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(htmlparser_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/htmlparser_test-htmlparser_cpp_test.obj `if test -f 'src/tests/htmlparser_cpp_test.cc'; then $(CYGPATH_W) 'src/tests/htmlparser_cpp_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/htmlparser_cpp_test.cc'; fi`
+
+src/tests/template_cache_nothreads_test-template_cache_test.o: src/tests/template_cache_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_cache_nothreads_test-template_cache_test.o -MD -MP -MF src/tests/$(DEPDIR)/template_cache_nothreads_test-template_cache_test.Tpo -c -o src/tests/template_cache_nothreads_test-template_cache_test.o `test -f 'src/tests/template_cache_test.cc' || echo '$(srcdir)/'`src/tests/template_cache_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_cache_nothreads_test-template_cache_test.Tpo src/tests/$(DEPDIR)/template_cache_nothreads_test-template_cache_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_cache_test.cc' object='src/tests/template_cache_nothreads_test-template_cache_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_cache_nothreads_test-template_cache_test.o `test -f 'src/tests/template_cache_test.cc' || echo '$(srcdir)/'`src/tests/template_cache_test.cc
+
+src/tests/template_cache_nothreads_test-template_cache_test.obj: src/tests/template_cache_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_cache_nothreads_test-template_cache_test.obj -MD -MP -MF src/tests/$(DEPDIR)/template_cache_nothreads_test-template_cache_test.Tpo -c -o src/tests/template_cache_nothreads_test-template_cache_test.obj `if test -f 'src/tests/template_cache_test.cc'; then $(CYGPATH_W) 'src/tests/template_cache_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_cache_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_cache_nothreads_test-template_cache_test.Tpo src/tests/$(DEPDIR)/template_cache_nothreads_test-template_cache_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_cache_test.cc' object='src/tests/template_cache_nothreads_test-template_cache_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_cache_nothreads_test-template_cache_test.obj `if test -f 'src/tests/template_cache_test.cc'; then $(CYGPATH_W) 'src/tests/template_cache_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_cache_test.cc'; fi`
+
+src/tests/template_cache_test-template_cache_test.o: src/tests/template_cache_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_cache_test-template_cache_test.o -MD -MP -MF src/tests/$(DEPDIR)/template_cache_test-template_cache_test.Tpo -c -o src/tests/template_cache_test-template_cache_test.o `test -f 'src/tests/template_cache_test.cc' || echo '$(srcdir)/'`src/tests/template_cache_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_cache_test-template_cache_test.Tpo src/tests/$(DEPDIR)/template_cache_test-template_cache_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_cache_test.cc' object='src/tests/template_cache_test-template_cache_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_cache_test-template_cache_test.o `test -f 'src/tests/template_cache_test.cc' || echo '$(srcdir)/'`src/tests/template_cache_test.cc
+
+src/tests/template_cache_test-template_cache_test.obj: src/tests/template_cache_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_cache_test-template_cache_test.obj -MD -MP -MF src/tests/$(DEPDIR)/template_cache_test-template_cache_test.Tpo -c -o src/tests/template_cache_test-template_cache_test.obj `if test -f 'src/tests/template_cache_test.cc'; then $(CYGPATH_W) 'src/tests/template_cache_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_cache_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_cache_test-template_cache_test.Tpo src/tests/$(DEPDIR)/template_cache_test-template_cache_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_cache_test.cc' object='src/tests/template_cache_test-template_cache_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_cache_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_cache_test-template_cache_test.obj `if test -f 'src/tests/template_cache_test.cc'; then $(CYGPATH_W) 'src/tests/template_cache_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_cache_test.cc'; fi`
+
+src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.o: src/tests/template_dictionary_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_dictionary_nothreads_unittest-template_dictionary_unittest.Tpo -c -o src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.o `test -f 'src/tests/template_dictionary_unittest.cc' || echo '$(srcdir)/'`src/tests/template_dictionary_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_dictionary_nothreads_unittest-template_dictionary_unittest.Tpo src/tests/$(DEPDIR)/template_dictionary_nothreads_unittest-template_dictionary_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_dictionary_unittest.cc' object='src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.o `test -f 'src/tests/template_dictionary_unittest.cc' || echo '$(srcdir)/'`src/tests/template_dictionary_unittest.cc
+
+src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.obj: src/tests/template_dictionary_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_dictionary_nothreads_unittest-template_dictionary_unittest.Tpo -c -o src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.obj `if test -f 'src/tests/template_dictionary_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_dictionary_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_dictionary_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_dictionary_nothreads_unittest-template_dictionary_unittest.Tpo src/tests/$(DEPDIR)/template_dictionary_nothreads_unittest-template_dictionary_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_dictionary_unittest.cc' object='src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_dictionary_nothreads_unittest-template_dictionary_unittest.obj `if test -f 'src/tests/template_dictionary_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_dictionary_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_dictionary_unittest.cc'; fi`
+
+src/tests/template_dictionary_unittest-template_dictionary_unittest.o: src/tests/template_dictionary_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_dictionary_unittest-template_dictionary_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_dictionary_unittest-template_dictionary_unittest.Tpo -c -o src/tests/template_dictionary_unittest-template_dictionary_unittest.o `test -f 'src/tests/template_dictionary_unittest.cc' || echo '$(srcdir)/'`src/tests/template_dictionary_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_dictionary_unittest-template_dictionary_unittest.Tpo src/tests/$(DEPDIR)/template_dictionary_unittest-template_dictionary_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_dictionary_unittest.cc' object='src/tests/template_dictionary_unittest-template_dictionary_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_dictionary_unittest-template_dictionary_unittest.o `test -f 'src/tests/template_dictionary_unittest.cc' || echo '$(srcdir)/'`src/tests/template_dictionary_unittest.cc
+
+src/tests/template_dictionary_unittest-template_dictionary_unittest.obj: src/tests/template_dictionary_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_dictionary_unittest-template_dictionary_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_dictionary_unittest-template_dictionary_unittest.Tpo -c -o src/tests/template_dictionary_unittest-template_dictionary_unittest.obj `if test -f 'src/tests/template_dictionary_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_dictionary_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_dictionary_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_dictionary_unittest-template_dictionary_unittest.Tpo src/tests/$(DEPDIR)/template_dictionary_unittest-template_dictionary_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_dictionary_unittest.cc' object='src/tests/template_dictionary_unittest-template_dictionary_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_dictionary_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_dictionary_unittest-template_dictionary_unittest.obj `if test -f 'src/tests/template_dictionary_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_dictionary_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_dictionary_unittest.cc'; fi`
+
+src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.o: src/tests/template_modifiers_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_modifiers_nothreads_unittest-template_modifiers_unittest.Tpo -c -o src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.o `test -f 'src/tests/template_modifiers_unittest.cc' || echo '$(srcdir)/'`src/tests/template_modifiers_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_modifiers_nothreads_unittest-template_modifiers_unittest.Tpo src/tests/$(DEPDIR)/template_modifiers_nothreads_unittest-template_modifiers_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_modifiers_unittest.cc' object='src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.o `test -f 'src/tests/template_modifiers_unittest.cc' || echo '$(srcdir)/'`src/tests/template_modifiers_unittest.cc
+
+src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.obj: src/tests/template_modifiers_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_modifiers_nothreads_unittest-template_modifiers_unittest.Tpo -c -o src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.obj `if test -f 'src/tests/template_modifiers_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_modifiers_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_modifiers_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_modifiers_nothreads_unittest-template_modifiers_unittest.Tpo src/tests/$(DEPDIR)/template_modifiers_nothreads_unittest-template_modifiers_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_modifiers_unittest.cc' object='src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_modifiers_nothreads_unittest-template_modifiers_unittest.obj `if test -f 'src/tests/template_modifiers_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_modifiers_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_modifiers_unittest.cc'; fi`
+
+src/tests/template_modifiers_unittest-template_modifiers_unittest.o: src/tests/template_modifiers_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_modifiers_unittest-template_modifiers_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_modifiers_unittest-template_modifiers_unittest.Tpo -c -o src/tests/template_modifiers_unittest-template_modifiers_unittest.o `test -f 'src/tests/template_modifiers_unittest.cc' || echo '$(srcdir)/'`src/tests/template_modifiers_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_modifiers_unittest-template_modifiers_unittest.Tpo src/tests/$(DEPDIR)/template_modifiers_unittest-template_modifiers_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_modifiers_unittest.cc' object='src/tests/template_modifiers_unittest-template_modifiers_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_modifiers_unittest-template_modifiers_unittest.o `test -f 'src/tests/template_modifiers_unittest.cc' || echo '$(srcdir)/'`src/tests/template_modifiers_unittest.cc
+
+src/tests/template_modifiers_unittest-template_modifiers_unittest.obj: src/tests/template_modifiers_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_modifiers_unittest-template_modifiers_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_modifiers_unittest-template_modifiers_unittest.Tpo -c -o src/tests/template_modifiers_unittest-template_modifiers_unittest.obj `if test -f 'src/tests/template_modifiers_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_modifiers_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_modifiers_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_modifiers_unittest-template_modifiers_unittest.Tpo src/tests/$(DEPDIR)/template_modifiers_unittest-template_modifiers_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_modifiers_unittest.cc' object='src/tests/template_modifiers_unittest-template_modifiers_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_modifiers_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_modifiers_unittest-template_modifiers_unittest.obj `if test -f 'src/tests/template_modifiers_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_modifiers_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_modifiers_unittest.cc'; fi`
+
+src/tests/template_nothreads_regtest-template_regtest.o: src/tests/template_regtest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_regtest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_nothreads_regtest-template_regtest.o -MD -MP -MF src/tests/$(DEPDIR)/template_nothreads_regtest-template_regtest.Tpo -c -o src/tests/template_nothreads_regtest-template_regtest.o `test -f 'src/tests/template_regtest.cc' || echo '$(srcdir)/'`src/tests/template_regtest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_nothreads_regtest-template_regtest.Tpo src/tests/$(DEPDIR)/template_nothreads_regtest-template_regtest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_regtest.cc' object='src/tests/template_nothreads_regtest-template_regtest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_regtest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_nothreads_regtest-template_regtest.o `test -f 'src/tests/template_regtest.cc' || echo '$(srcdir)/'`src/tests/template_regtest.cc
+
+src/tests/template_nothreads_regtest-template_regtest.obj: src/tests/template_regtest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_regtest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_nothreads_regtest-template_regtest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_nothreads_regtest-template_regtest.Tpo -c -o src/tests/template_nothreads_regtest-template_regtest.obj `if test -f 'src/tests/template_regtest.cc'; then $(CYGPATH_W) 'src/tests/template_regtest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_regtest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_nothreads_regtest-template_regtest.Tpo src/tests/$(DEPDIR)/template_nothreads_regtest-template_regtest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_regtest.cc' object='src/tests/template_nothreads_regtest-template_regtest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_regtest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_nothreads_regtest-template_regtest.obj `if test -f 'src/tests/template_regtest.cc'; then $(CYGPATH_W) 'src/tests/template_regtest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_regtest.cc'; fi`
+
+src/tests/template_nothreads_unittest-template_unittest.o: src/tests/template_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_nothreads_unittest-template_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_nothreads_unittest-template_unittest.Tpo -c -o src/tests/template_nothreads_unittest-template_unittest.o `test -f 'src/tests/template_unittest.cc' || echo '$(srcdir)/'`src/tests/template_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_nothreads_unittest-template_unittest.Tpo src/tests/$(DEPDIR)/template_nothreads_unittest-template_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_unittest.cc' object='src/tests/template_nothreads_unittest-template_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_nothreads_unittest-template_unittest.o `test -f 'src/tests/template_unittest.cc' || echo '$(srcdir)/'`src/tests/template_unittest.cc
+
+src/tests/template_nothreads_unittest-template_unittest.obj: src/tests/template_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_nothreads_unittest-template_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_nothreads_unittest-template_unittest.Tpo -c -o src/tests/template_nothreads_unittest-template_unittest.obj `if test -f 'src/tests/template_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_nothreads_unittest-template_unittest.Tpo src/tests/$(DEPDIR)/template_nothreads_unittest-template_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_unittest.cc' object='src/tests/template_nothreads_unittest-template_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_nothreads_unittest-template_unittest.obj `if test -f 'src/tests/template_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_unittest.cc'; fi`
+
+src/tests/template_regtest-template_regtest.o: src/tests/template_regtest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_regtest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_regtest-template_regtest.o -MD -MP -MF src/tests/$(DEPDIR)/template_regtest-template_regtest.Tpo -c -o src/tests/template_regtest-template_regtest.o `test -f 'src/tests/template_regtest.cc' || echo '$(srcdir)/'`src/tests/template_regtest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_regtest-template_regtest.Tpo src/tests/$(DEPDIR)/template_regtest-template_regtest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_regtest.cc' object='src/tests/template_regtest-template_regtest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_regtest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_regtest-template_regtest.o `test -f 'src/tests/template_regtest.cc' || echo '$(srcdir)/'`src/tests/template_regtest.cc
+
+src/tests/template_regtest-template_regtest.obj: src/tests/template_regtest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_regtest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_regtest-template_regtest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_regtest-template_regtest.Tpo -c -o src/tests/template_regtest-template_regtest.obj `if test -f 'src/tests/template_regtest.cc'; then $(CYGPATH_W) 'src/tests/template_regtest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_regtest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_regtest-template_regtest.Tpo src/tests/$(DEPDIR)/template_regtest-template_regtest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_regtest.cc' object='src/tests/template_regtest-template_regtest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_regtest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_regtest-template_regtest.obj `if test -f 'src/tests/template_regtest.cc'; then $(CYGPATH_W) 'src/tests/template_regtest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_regtest.cc'; fi`
+
+src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.o: src/tests/template_setglobals_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_setglobals_nothreads_unittest-template_setglobals_unittest.Tpo -c -o src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.o `test -f 'src/tests/template_setglobals_unittest.cc' || echo '$(srcdir)/'`src/tests/template_setglobals_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_setglobals_nothreads_unittest-template_setglobals_unittest.Tpo src/tests/$(DEPDIR)/template_setglobals_nothreads_unittest-template_setglobals_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_setglobals_unittest.cc' object='src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.o `test -f 'src/tests/template_setglobals_unittest.cc' || echo '$(srcdir)/'`src/tests/template_setglobals_unittest.cc
+
+src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.obj: src/tests/template_setglobals_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_setglobals_nothreads_unittest-template_setglobals_unittest.Tpo -c -o src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.obj `if test -f 'src/tests/template_setglobals_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_setglobals_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_setglobals_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_setglobals_nothreads_unittest-template_setglobals_unittest.Tpo src/tests/$(DEPDIR)/template_setglobals_nothreads_unittest-template_setglobals_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_setglobals_unittest.cc' object='src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_nothreads_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_setglobals_nothreads_unittest-template_setglobals_unittest.obj `if test -f 'src/tests/template_setglobals_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_setglobals_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_setglobals_unittest.cc'; fi`
+
+src/tests/template_setglobals_unittest-template_setglobals_unittest.o: src/tests/template_setglobals_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_setglobals_unittest-template_setglobals_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_setglobals_unittest-template_setglobals_unittest.Tpo -c -o src/tests/template_setglobals_unittest-template_setglobals_unittest.o `test -f 'src/tests/template_setglobals_unittest.cc' || echo '$(srcdir)/'`src/tests/template_setglobals_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_setglobals_unittest-template_setglobals_unittest.Tpo src/tests/$(DEPDIR)/template_setglobals_unittest-template_setglobals_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_setglobals_unittest.cc' object='src/tests/template_setglobals_unittest-template_setglobals_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_setglobals_unittest-template_setglobals_unittest.o `test -f 'src/tests/template_setglobals_unittest.cc' || echo '$(srcdir)/'`src/tests/template_setglobals_unittest.cc
+
+src/tests/template_setglobals_unittest-template_setglobals_unittest.obj: src/tests/template_setglobals_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_setglobals_unittest-template_setglobals_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_setglobals_unittest-template_setglobals_unittest.Tpo -c -o src/tests/template_setglobals_unittest-template_setglobals_unittest.obj `if test -f 'src/tests/template_setglobals_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_setglobals_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_setglobals_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_setglobals_unittest-template_setglobals_unittest.Tpo src/tests/$(DEPDIR)/template_setglobals_unittest-template_setglobals_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_setglobals_unittest.cc' object='src/tests/template_setglobals_unittest-template_setglobals_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_setglobals_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_setglobals_unittest-template_setglobals_unittest.obj `if test -f 'src/tests/template_setglobals_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_setglobals_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_setglobals_unittest.cc'; fi`
+
+src/template_test_util_nothreads_test-template_dictionary.o: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/template_test_util_nothreads_test-template_dictionary.o -MD -MP -MF src/$(DEPDIR)/template_test_util_nothreads_test-template_dictionary.Tpo -c -o src/template_test_util_nothreads_test-template_dictionary.o `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/template_test_util_nothreads_test-template_dictionary.Tpo src/$(DEPDIR)/template_test_util_nothreads_test-template_dictionary.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/template_test_util_nothreads_test-template_dictionary.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/template_test_util_nothreads_test-template_dictionary.o `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+
+src/template_test_util_nothreads_test-template_dictionary.obj: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/template_test_util_nothreads_test-template_dictionary.obj -MD -MP -MF src/$(DEPDIR)/template_test_util_nothreads_test-template_dictionary.Tpo -c -o src/template_test_util_nothreads_test-template_dictionary.obj `if test -f 'src/template_dictionary.cc'; then $(CYGPATH_W) 'src/template_dictionary.cc'; else $(CYGPATH_W) '$(srcdir)/src/template_dictionary.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/template_test_util_nothreads_test-template_dictionary.Tpo src/$(DEPDIR)/template_test_util_nothreads_test-template_dictionary.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/template_test_util_nothreads_test-template_dictionary.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/template_test_util_nothreads_test-template_dictionary.obj `if test -f 'src/template_dictionary.cc'; then $(CYGPATH_W) 'src/template_dictionary.cc'; else $(CYGPATH_W) '$(srcdir)/src/template_dictionary.cc'; fi`
+
+src/tests/template_test_util_nothreads_test-template_test_util_test.o: src/tests/template_test_util_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_test_util_nothreads_test-template_test_util_test.o -MD -MP -MF src/tests/$(DEPDIR)/template_test_util_nothreads_test-template_test_util_test.Tpo -c -o src/tests/template_test_util_nothreads_test-template_test_util_test.o `test -f 'src/tests/template_test_util_test.cc' || echo '$(srcdir)/'`src/tests/template_test_util_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_test_util_nothreads_test-template_test_util_test.Tpo src/tests/$(DEPDIR)/template_test_util_nothreads_test-template_test_util_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_test_util_test.cc' object='src/tests/template_test_util_nothreads_test-template_test_util_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_test_util_nothreads_test-template_test_util_test.o `test -f 'src/tests/template_test_util_test.cc' || echo '$(srcdir)/'`src/tests/template_test_util_test.cc
+
+src/tests/template_test_util_nothreads_test-template_test_util_test.obj: src/tests/template_test_util_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_test_util_nothreads_test-template_test_util_test.obj -MD -MP -MF src/tests/$(DEPDIR)/template_test_util_nothreads_test-template_test_util_test.Tpo -c -o src/tests/template_test_util_nothreads_test-template_test_util_test.obj `if test -f 'src/tests/template_test_util_test.cc'; then $(CYGPATH_W) 'src/tests/template_test_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_test_util_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_test_util_nothreads_test-template_test_util_test.Tpo src/tests/$(DEPDIR)/template_test_util_nothreads_test-template_test_util_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_test_util_test.cc' object='src/tests/template_test_util_nothreads_test-template_test_util_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_nothreads_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_test_util_nothreads_test-template_test_util_test.obj `if test -f 'src/tests/template_test_util_test.cc'; then $(CYGPATH_W) 'src/tests/template_test_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_test_util_test.cc'; fi`
+
+src/template_test_util_test-template_dictionary.o: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -MT src/template_test_util_test-template_dictionary.o -MD -MP -MF src/$(DEPDIR)/template_test_util_test-template_dictionary.Tpo -c -o src/template_test_util_test-template_dictionary.o `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/template_test_util_test-template_dictionary.Tpo src/$(DEPDIR)/template_test_util_test-template_dictionary.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/template_test_util_test-template_dictionary.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -c -o src/template_test_util_test-template_dictionary.o `test -f 'src/template_dictionary.cc' || echo '$(srcdir)/'`src/template_dictionary.cc
+
+src/template_test_util_test-template_dictionary.obj: src/template_dictionary.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -MT src/template_test_util_test-template_dictionary.obj -MD -MP -MF src/$(DEPDIR)/template_test_util_test-template_dictionary.Tpo -c -o src/template_test_util_test-template_dictionary.obj `if test -f 'src/template_dictionary.cc'; then $(CYGPATH_W) 'src/template_dictionary.cc'; else $(CYGPATH_W) '$(srcdir)/src/template_dictionary.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/$(DEPDIR)/template_test_util_test-template_dictionary.Tpo src/$(DEPDIR)/template_test_util_test-template_dictionary.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/template_dictionary.cc' object='src/template_test_util_test-template_dictionary.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -c -o src/template_test_util_test-template_dictionary.obj `if test -f 'src/template_dictionary.cc'; then $(CYGPATH_W) 'src/template_dictionary.cc'; else $(CYGPATH_W) '$(srcdir)/src/template_dictionary.cc'; fi`
+
+src/tests/template_test_util_test-template_test_util_test.o: src/tests/template_test_util_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_test_util_test-template_test_util_test.o -MD -MP -MF src/tests/$(DEPDIR)/template_test_util_test-template_test_util_test.Tpo -c -o src/tests/template_test_util_test-template_test_util_test.o `test -f 'src/tests/template_test_util_test.cc' || echo '$(srcdir)/'`src/tests/template_test_util_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_test_util_test-template_test_util_test.Tpo src/tests/$(DEPDIR)/template_test_util_test-template_test_util_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_test_util_test.cc' object='src/tests/template_test_util_test-template_test_util_test.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_test_util_test-template_test_util_test.o `test -f 'src/tests/template_test_util_test.cc' || echo '$(srcdir)/'`src/tests/template_test_util_test.cc
+
+src/tests/template_test_util_test-template_test_util_test.obj: src/tests/template_test_util_test.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_test_util_test-template_test_util_test.obj -MD -MP -MF src/tests/$(DEPDIR)/template_test_util_test-template_test_util_test.Tpo -c -o src/tests/template_test_util_test-template_test_util_test.obj `if test -f 'src/tests/template_test_util_test.cc'; then $(CYGPATH_W) 'src/tests/template_test_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_test_util_test.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_test_util_test-template_test_util_test.Tpo src/tests/$(DEPDIR)/template_test_util_test-template_test_util_test.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_test_util_test.cc' object='src/tests/template_test_util_test-template_test_util_test.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_test_util_test_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_test_util_test-template_test_util_test.obj `if test -f 'src/tests/template_test_util_test.cc'; then $(CYGPATH_W) 'src/tests/template_test_util_test.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_test_util_test.cc'; fi`
+
+src/tests/template_unittest-template_unittest.o: src/tests/template_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_unittest-template_unittest.o -MD -MP -MF src/tests/$(DEPDIR)/template_unittest-template_unittest.Tpo -c -o src/tests/template_unittest-template_unittest.o `test -f 'src/tests/template_unittest.cc' || echo '$(srcdir)/'`src/tests/template_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_unittest-template_unittest.Tpo src/tests/$(DEPDIR)/template_unittest-template_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_unittest.cc' object='src/tests/template_unittest-template_unittest.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_unittest-template_unittest.o `test -f 'src/tests/template_unittest.cc' || echo '$(srcdir)/'`src/tests/template_unittest.cc
+
+src/tests/template_unittest-template_unittest.obj: src/tests/template_unittest.cc
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_unittest_CXXFLAGS) $(CXXFLAGS) -MT src/tests/template_unittest-template_unittest.obj -MD -MP -MF src/tests/$(DEPDIR)/template_unittest-template_unittest.Tpo -c -o src/tests/template_unittest-template_unittest.obj `if test -f 'src/tests/template_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_unittest.cc'; fi`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) src/tests/$(DEPDIR)/template_unittest-template_unittest.Tpo src/tests/$(DEPDIR)/template_unittest-template_unittest.Po
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='src/tests/template_unittest.cc' object='src/tests/template_unittest-template_unittest.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(template_unittest_CXXFLAGS) $(CXXFLAGS) -c -o src/tests/template_unittest-template_unittest.obj `if test -f 'src/tests/template_unittest.cc'; then $(CYGPATH_W) 'src/tests/template_unittest.cc'; else $(CYGPATH_W) '$(srcdir)/src/tests/template_unittest.cc'; fi`
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+ -rm -rf src/.libs src/_libs
+ -rm -rf src/base/.libs src/base/_libs
+ -rm -rf src/htmlparser/.libs src/htmlparser/_libs
+ -rm -rf src/tests/.libs src/tests/_libs
+ -rm -rf src/windows/.libs src/windows/_libs
+
+distclean-libtool:
+ -rm -f libtool config.lt
+install-dist_docDATA: $(dist_doc_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(docdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(docdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(docdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(docdir)" || exit $$?; \
+ done
+
+uninstall-dist_docDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_doc_DATA)'; test -n "$(docdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(docdir)'; $(am__uninstall_files_from_dir)
+install-pkgconfigDATA: $(pkgconfig_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(pkgconfigdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
+ done
+
+uninstall-pkgconfigDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(pkgconfigdir)'; $(am__uninstall_files_from_dir)
+install-nodist_ctemplateincludeHEADERS: $(nodist_ctemplateinclude_HEADERS)
+ @$(NORMAL_INSTALL)
+ @list='$(nodist_ctemplateinclude_HEADERS)'; test -n "$(ctemplateincludedir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(ctemplateincludedir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(ctemplateincludedir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_HEADER) $$files '$(DESTDIR)$(ctemplateincludedir)'"; \
+ $(INSTALL_HEADER) $$files "$(DESTDIR)$(ctemplateincludedir)" || exit $$?; \
+ done
+
+uninstall-nodist_ctemplateincludeHEADERS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(nodist_ctemplateinclude_HEADERS)'; test -n "$(ctemplateincludedir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(ctemplateincludedir)'; $(am__uninstall_files_from_dir)
+
+ID: $(am__tagged_files)
+ $(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-am
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ set x; \
+ here=`pwd`; \
+ $(am__define_uniq_tagged_files); \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: ctags-am
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+ $(am__define_uniq_tagged_files); \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+ test ! -s cscope.files \
+ || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+ -rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-am
+
+cscopelist-am: $(am__tagged_files)
+ list='$(am__tagged_files)'; \
+ case "$(srcdir)" in \
+ [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+ *) sdir=$(subdir)/$(srcdir) ;; \
+ esac; \
+ for i in $$list; do \
+ if test -f "$$i"; then \
+ echo "$(subdir)/$$i"; \
+ else \
+ echo "$$sdir/$$i"; \
+ fi; \
+ done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+ -rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+# Recover from deleted '.trs' file; this should ensure that
+# "rm -f foo.log; make foo.trs" re-run 'foo.test', and re-create
+# both 'foo.log' and 'foo.trs'. Break the recipe in two subshells
+# to avoid problems with "make -n".
+.log.trs:
+ rm -f $< $@
+ $(MAKE) $(AM_MAKEFLAGS) $<
+
+# Leading 'am--fnord' is there to ensure the list of targets does not
+# expand to empty, as could happen e.g. with make check TESTS=''.
+am--fnord $(TEST_LOGS) $(TEST_LOGS:.log=.trs): $(am__force_recheck)
+am--force-recheck:
+ @:
+
+$(TEST_SUITE_LOG): $(TEST_LOGS)
+ @$(am__set_TESTS_bases); \
+ am__f_ok () { test -f "$$1" && test -r "$$1"; }; \
+ redo_bases=`for i in $$bases; do \
+ am__f_ok $$i.trs && am__f_ok $$i.log || echo $$i; \
+ done`; \
+ if test -n "$$redo_bases"; then \
+ redo_logs=`for i in $$redo_bases; do echo $$i.log; done`; \
+ redo_results=`for i in $$redo_bases; do echo $$i.trs; done`; \
+ if $(am__make_dryrun); then :; else \
+ rm -f $$redo_logs && rm -f $$redo_results || exit 1; \
+ fi; \
+ fi; \
+ if test -n "$$am__remaking_logs"; then \
+ echo "fatal: making $(TEST_SUITE_LOG): possible infinite" \
+ "recursion detected" >&2; \
+ else \
+ am__remaking_logs=yes $(MAKE) $(AM_MAKEFLAGS) $$redo_logs; \
+ fi; \
+ if $(am__make_dryrun); then :; else \
+ st=0; \
+ errmsg="fatal: making $(TEST_SUITE_LOG): failed to create"; \
+ for i in $$redo_bases; do \
+ test -f $$i.trs && test -r $$i.trs \
+ || { echo "$$errmsg $$i.trs" >&2; st=1; }; \
+ test -f $$i.log && test -r $$i.log \
+ || { echo "$$errmsg $$i.log" >&2; st=1; }; \
+ done; \
+ test $$st -eq 0 || exit 1; \
+ fi
+ @$(am__sh_e_setup); $(am__tty_colors); $(am__set_TESTS_bases); \
+ ws='[ ]'; \
+ results=`for b in $$bases; do echo $$b.trs; done`; \
+ test -n "$$results" || results=/dev/null; \
+ all=` grep "^$$ws*:test-result:" $$results | wc -l`; \
+ pass=` grep "^$$ws*:test-result:$$ws*PASS" $$results | wc -l`; \
+ fail=` grep "^$$ws*:test-result:$$ws*FAIL" $$results | wc -l`; \
+ skip=` grep "^$$ws*:test-result:$$ws*SKIP" $$results | wc -l`; \
+ xfail=`grep "^$$ws*:test-result:$$ws*XFAIL" $$results | wc -l`; \
+ xpass=`grep "^$$ws*:test-result:$$ws*XPASS" $$results | wc -l`; \
+ error=`grep "^$$ws*:test-result:$$ws*ERROR" $$results | wc -l`; \
+ if test `expr $$fail + $$xpass + $$error` -eq 0; then \
+ success=true; \
+ else \
+ success=false; \
+ fi; \
+ br='==================='; br=$$br$$br$$br$$br; \
+ result_count () \
+ { \
+ if test x"$$1" = x"--maybe-color"; then \
+ maybe_colorize=yes; \
+ elif test x"$$1" = x"--no-color"; then \
+ maybe_colorize=no; \
+ else \
+ echo "$@: invalid 'result_count' usage" >&2; exit 4; \
+ fi; \
+ shift; \
+ desc=$$1 count=$$2; \
+ if test $$maybe_colorize = yes && test $$count -gt 0; then \
+ color_start=$$3 color_end=$$std; \
+ else \
+ color_start= color_end=; \
+ fi; \
+ echo "$${color_start}# $$desc $$count$${color_end}"; \
+ }; \
+ create_testsuite_report () \
+ { \
+ result_count $$1 "TOTAL:" $$all "$$brg"; \
+ result_count $$1 "PASS: " $$pass "$$grn"; \
+ result_count $$1 "SKIP: " $$skip "$$blu"; \
+ result_count $$1 "XFAIL:" $$xfail "$$lgn"; \
+ result_count $$1 "FAIL: " $$fail "$$red"; \
+ result_count $$1 "XPASS:" $$xpass "$$red"; \
+ result_count $$1 "ERROR:" $$error "$$mgn"; \
+ }; \
+ { \
+ echo "$(PACKAGE_STRING): $(subdir)/$(TEST_SUITE_LOG)" | \
+ $(am__rst_title); \
+ create_testsuite_report --no-color; \
+ echo; \
+ echo ".. contents:: :depth: 2"; \
+ echo; \
+ for b in $$bases; do echo $$b; done \
+ | $(am__create_global_log); \
+ } >$(TEST_SUITE_LOG).tmp || exit 1; \
+ mv $(TEST_SUITE_LOG).tmp $(TEST_SUITE_LOG); \
+ if $$success; then \
+ col="$$grn"; \
+ else \
+ col="$$red"; \
+ test x"$$VERBOSE" = x || cat $(TEST_SUITE_LOG); \
+ fi; \
+ echo "$${col}$$br$${std}"; \
+ echo "$${col}Testsuite summary for $(PACKAGE_STRING)$${std}"; \
+ echo "$${col}$$br$${std}"; \
+ create_testsuite_report --maybe-color; \
+ echo "$$col$$br$$std"; \
+ if $$success; then :; else \
+ echo "$${col}See $(subdir)/$(TEST_SUITE_LOG)$${std}"; \
+ if test -n "$(PACKAGE_BUGREPORT)"; then \
+ echo "$${col}Please report to $(PACKAGE_BUGREPORT)$${std}"; \
+ fi; \
+ echo "$$col$$br$$std"; \
+ fi; \
+ $$success || exit 1
+
+check-TESTS:
+ @list='$(RECHECK_LOGS)'; test -z "$$list" || rm -f $$list
+ @list='$(RECHECK_LOGS:.log=.trs)'; test -z "$$list" || rm -f $$list
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ trs_list=`for i in $$bases; do echo $$i.trs; done`; \
+ log_list=`echo $$log_list`; trs_list=`echo $$trs_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) TEST_LOGS="$$log_list"; \
+ exit $$?;
+recheck: all $(check_SCRIPTS)
+ @test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+ @set +e; $(am__set_TESTS_bases); \
+ bases=`for i in $$bases; do echo $$i; done \
+ | $(am__list_recheck_tests)` || exit 1; \
+ log_list=`for i in $$bases; do echo $$i.log; done`; \
+ log_list=`echo $$log_list`; \
+ $(MAKE) $(AM_MAKEFLAGS) $(TEST_SUITE_LOG) \
+ am__force_recheck=am--force-recheck \
+ TEST_LOGS="$$log_list"; \
+ exit $$?
+compile_test.log: compile_test$(EXEEXT)
+ @p='compile_test$(EXEEXT)'; \
+ b='compile_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+compile_nothreads_test.log: compile_nothreads_test$(EXEEXT)
+ @p='compile_nothreads_test$(EXEEXT)'; \
+ b='compile_nothreads_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_test_util_test.log: template_test_util_test$(EXEEXT)
+ @p='template_test_util_test$(EXEEXT)'; \
+ b='template_test_util_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_test_util_nothreads_test.log: template_test_util_nothreads_test$(EXEEXT)
+ @p='template_test_util_nothreads_test$(EXEEXT)'; \
+ b='template_test_util_nothreads_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_dictionary_unittest.log: template_dictionary_unittest$(EXEEXT)
+ @p='template_dictionary_unittest$(EXEEXT)'; \
+ b='template_dictionary_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_dictionary_nothreads_unittest.log: template_dictionary_nothreads_unittest$(EXEEXT)
+ @p='template_dictionary_nothreads_unittest$(EXEEXT)'; \
+ b='template_dictionary_nothreads_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_modifiers_unittest.log: template_modifiers_unittest$(EXEEXT)
+ @p='template_modifiers_unittest$(EXEEXT)'; \
+ b='template_modifiers_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_modifiers_nothreads_unittest.log: template_modifiers_nothreads_unittest$(EXEEXT)
+ @p='template_modifiers_nothreads_unittest$(EXEEXT)'; \
+ b='template_modifiers_nothreads_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_setglobals_unittest.log: template_setglobals_unittest$(EXEEXT)
+ @p='template_setglobals_unittest$(EXEEXT)'; \
+ b='template_setglobals_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_setglobals_nothreads_unittest.log: template_setglobals_nothreads_unittest$(EXEEXT)
+ @p='template_setglobals_nothreads_unittest$(EXEEXT)'; \
+ b='template_setglobals_nothreads_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_cache_test.log: template_cache_test$(EXEEXT)
+ @p='template_cache_test$(EXEEXT)'; \
+ b='template_cache_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_cache_nothreads_test.log: template_cache_nothreads_test$(EXEEXT)
+ @p='template_cache_nothreads_test$(EXEEXT)'; \
+ b='template_cache_nothreads_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_unittest.log: template_unittest$(EXEEXT)
+ @p='template_unittest$(EXEEXT)'; \
+ b='template_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_nothreads_unittest.log: template_nothreads_unittest$(EXEEXT)
+ @p='template_nothreads_unittest$(EXEEXT)'; \
+ b='template_nothreads_unittest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_regtest.log: template_regtest$(EXEEXT)
+ @p='template_regtest$(EXEEXT)'; \
+ b='template_regtest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+template_nothreads_regtest.log: template_nothreads_regtest$(EXEEXT)
+ @p='template_nothreads_regtest$(EXEEXT)'; \
+ b='template_nothreads_regtest'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+htmlparser_test.log: htmlparser_test$(EXEEXT)
+ @p='htmlparser_test$(EXEEXT)'; \
+ b='htmlparser_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+htmlparser_nothreads_test.log: htmlparser_nothreads_test$(EXEEXT)
+ @p='htmlparser_nothreads_test$(EXEEXT)'; \
+ b='htmlparser_nothreads_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+statemachine_test.log: statemachine_test$(EXEEXT)
+ @p='statemachine_test$(EXEEXT)'; \
+ b='statemachine_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+generate_fsm_c_test.log: generate_fsm_c_test$(EXEEXT)
+ @p='generate_fsm_c_test$(EXEEXT)'; \
+ b='generate_fsm_c_test'; \
+ $(am__check_pre) $(LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_LOG_DRIVER_FLAGS) $(LOG_DRIVER_FLAGS) -- $(LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+.test.log:
+ @p='$<'; \
+ $(am__set_b); \
+ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+ --log-file $$b.log --trs-file $$b.trs \
+ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+ "$$tst" $(AM_TESTS_FD_REDIRECT)
+@am__EXEEXT_TRUE@.test$(EXEEXT).log:
+@am__EXEEXT_TRUE@ @p='$<'; \
+@am__EXEEXT_TRUE@ $(am__set_b); \
+@am__EXEEXT_TRUE@ $(am__check_pre) $(TEST_LOG_DRIVER) --test-name "$$f" \
+@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
+@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
+@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
+
+distdir: $(DISTFILES)
+ $(am__remove_distdir)
+ test -d "$(distdir)" || mkdir "$(distdir)"
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$(top_distdir)" distdir="$(distdir)" \
+ dist-hook
+ -test -n "$(am__skip_mode_fix)" \
+ || find "$(distdir)" -type d ! -perm -755 \
+ -exec chmod u+rwx,go+rx {} \; -o \
+ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+ ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+ || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+ tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+ $(am__post_remove_distdir)
+
+dist-bzip2: distdir
+ tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+ $(am__post_remove_distdir)
+
+dist-lzip: distdir
+ tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+ $(am__post_remove_distdir)
+
+dist-xz: distdir
+ tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+ $(am__post_remove_distdir)
+
+dist-tarZ: distdir
+ @echo WARNING: "Support for shar distribution archives is" \
+ "deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+ $(am__post_remove_distdir)
+
+dist-shar: distdir
+ @echo WARNING: "Support for distribution archives compressed with" \
+ "legacy program 'compress' is deprecated." >&2
+ @echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+ shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+ $(am__post_remove_distdir)
+dist-zip: distdir
+ -rm -f $(distdir).zip
+ zip -rq $(distdir).zip $(distdir)
+ $(am__post_remove_distdir)
+
+dist dist-all:
+ $(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+ $(am__post_remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration. Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+ case '$(DIST_ARCHIVES)' in \
+ *.tar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
+ *.tar.bz2*) \
+ bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+ *.tar.lz*) \
+ lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+ *.tar.xz*) \
+ xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+ *.tar.Z*) \
+ uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+ *.shar.gz*) \
+ GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\
+ *.zip*) \
+ unzip $(distdir).zip ;;\
+ esac
+ chmod -R a-w $(distdir)
+ chmod u+w $(distdir)
+ mkdir $(distdir)/_build $(distdir)/_inst
+ chmod a-w $(distdir)
+ test -d $(distdir)/_build || exit 0; \
+ dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+ && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+ && am__cwd=`pwd` \
+ && $(am__cd) $(distdir)/_build \
+ && ../configure \
+ $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+ $(DISTCHECK_CONFIGURE_FLAGS) \
+ --srcdir=.. --prefix="$$dc_install_base" \
+ && $(MAKE) $(AM_MAKEFLAGS) \
+ && $(MAKE) $(AM_MAKEFLAGS) dvi \
+ && $(MAKE) $(AM_MAKEFLAGS) check \
+ && $(MAKE) $(AM_MAKEFLAGS) install \
+ && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+ && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+ distuninstallcheck \
+ && chmod -R a-w "$$dc_install_base" \
+ && ({ \
+ (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+ && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+ distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+ } || { rm -rf "$$dc_destdir"; exit 1; }) \
+ && rm -rf "$$dc_destdir" \
+ && $(MAKE) $(AM_MAKEFLAGS) dist \
+ && rm -rf $(DIST_ARCHIVES) \
+ && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+ && cd "$$am__cwd" \
+ || exit 1
+ $(am__post_remove_distdir)
+ @(echo "$(distdir) archives ready for distribution: "; \
+ list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+ sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+ @test -n '$(distuninstallcheck_dir)' || { \
+ echo 'ERROR: trying to run $@ with an empty' \
+ '$$(distuninstallcheck_dir)' >&2; \
+ exit 1; \
+ }; \
+ $(am__cd) '$(distuninstallcheck_dir)' || { \
+ echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+ exit 1; \
+ }; \
+ test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left after uninstall:" ; \
+ if test -n "$(DESTDIR)"; then \
+ echo " (check DESTDIR support)"; \
+ fi ; \
+ $(distuninstallcheck_listfiles) ; \
+ exit 1; } >&2
+distcleancheck: distclean
+ @if test '$(srcdir)' = . ; then \
+ echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+ exit 1 ; \
+ fi
+ @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+ || { echo "ERROR: files left in build directory after distclean:" ; \
+ $(distcleancheck_listfiles) ; \
+ exit 1; } >&2
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) $(check_SCRIPTS)
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(SCRIPTS) $(DATA) \
+ $(HEADERS)
+install-binPROGRAMS: install-libLTLIBRARIES
+
+installdirs:
+ for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" "$(DESTDIR)$(docdir)" "$(DESTDIR)$(pkgconfigdir)" "$(DESTDIR)$(ctemplateincludedir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ if test -z '$(STRIP)'; then \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ install; \
+ else \
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+ fi
+mostlyclean-generic:
+ -test -z "$(TEST_LOGS)" || rm -f $(TEST_LOGS)
+ -test -z "$(TEST_LOGS:.log=.trs)" || rm -f $(TEST_LOGS:.log=.trs)
+ -test -z "$(TEST_SUITE_LOG)" || rm -f $(TEST_SUITE_LOG)
+
+clean-generic:
+ -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+ -rm -f src/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/$(am__dirstamp)
+ -rm -f src/base/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/base/$(am__dirstamp)
+ -rm -f src/htmlparser/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/htmlparser/$(am__dirstamp)
+ -rm -f src/tests/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/tests/$(am__dirstamp)
+ -rm -f src/windows/$(DEPDIR)/$(am__dirstamp)
+ -rm -f src/windows/$(am__dirstamp)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+ -test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libLTLIBRARIES \
+ clean-libtool clean-noinstLTLIBRARIES clean-noinstPROGRAMS \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf ./$(DEPDIR) src/$(DEPDIR) src/base/$(DEPDIR) src/htmlparser/$(DEPDIR) src/tests/$(DEPDIR) src/windows/$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-hdr distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-dist_docDATA \
+ install-nodist_ctemplateincludeHEADERS install-pkgconfigDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS install-binSCRIPTS \
+ install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am: installcheck-local
+
+maintainer-clean: maintainer-clean-am
+ -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+ -rm -rf $(top_srcdir)/autom4te.cache
+ -rm -rf ./$(DEPDIR) src/$(DEPDIR) src/base/$(DEPDIR) src/htmlparser/$(DEPDIR) src/tests/$(DEPDIR) src/windows/$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-binSCRIPTS \
+ uninstall-dist_docDATA uninstall-libLTLIBRARIES \
+ uninstall-nodist_ctemplateincludeHEADERS \
+ uninstall-pkgconfigDATA
+
+.MAKE: all check check-am install install-am install-strip
+
+.PHONY: CTAGS GTAGS TAGS all all-am am--refresh check check-TESTS \
+ check-am clean clean-binPROGRAMS clean-cscope clean-generic \
+ clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS cscope cscopelist-am ctags ctags-am dist \
+ dist-all dist-bzip2 dist-gzip dist-hook dist-lzip dist-shar \
+ dist-tarZ dist-xz dist-zip distcheck distclean \
+ distclean-compile distclean-generic distclean-hdr \
+ distclean-libtool distclean-tags distcleancheck distdir \
+ distuninstallcheck dvi dvi-am html html-am info info-am \
+ install install-am install-binPROGRAMS install-binSCRIPTS \
+ install-data install-data-am install-dist_docDATA install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am \
+ install-libLTLIBRARIES install-man \
+ install-nodist_ctemplateincludeHEADERS install-pdf \
+ install-pdf-am install-pkgconfigDATA install-ps install-ps-am \
+ install-strip installcheck installcheck-am installcheck-local \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am recheck tags tags-am \
+ uninstall uninstall-am uninstall-binPROGRAMS \
+ uninstall-binSCRIPTS uninstall-dist_docDATA \
+ uninstall-libLTLIBRARIES \
+ uninstall-nodist_ctemplateincludeHEADERS \
+ uninstall-pkgconfigDATA
+
+
+# These files are auto-generated via generate_fsm.py. Since we don't want
+# to require python to build ctemplate, we include these in the dist
+src/htmlparser/htmlparser_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/htmlparser/htmlparser_fsm.config
+ $(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/htmlparser/htmlparser_fsm.config > $@
+
+src/htmlparser/jsparser_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/htmlparser/jsparser_fsm.config
+ $(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/htmlparser/jsparser_fsm.config > $@
+
+src/tests/statemachine_test_fsm.h: src/htmlparser/generate_fsm.py src/htmlparser/fsm_config.py src/tests/statemachine_test_fsm.config
+ $(top_srcdir)/src/htmlparser/generate_fsm.py $(top_srcdir)/src/tests/statemachine_test_fsm.config > $@
+
+# With compile_test, we are making sure that the code compiles without
+# needing config.h/etc. The best test is to make sure we can compile
+# with just the installed header files. The best way to do this is at
+# installcheck time. When this rule is run (via 'make distcheck'),
+# 'includedir' is the installed include-dir.
+installcheck-local:
+ $(CXX) -I $(includedir) -c $(top_srcdir)/src/tests/compile_test.cc \
+ -o installcheck_compile_test.o
+
+# We want to compile statemachine.cc as a c file as well as a c++ file
+
+statemachine.c: src/htmlparser/statemachine.cc
+ $(LN_S) src/htmlparser/statemachine.cc $@
+generate_fsm_test_sh: src/tests/generate_fsm_test.sh \
+ src/tests/htmlparser_testdata/sample_fsm.config \
+ src/tests/htmlparser_testdata/sample_fsm.c \
+ src/htmlparser/generate_fsm.py
+ sh $(top_srcdir)/src/tests/generate_fsm_test.sh $(top_srcdir)
+make_tpl_varnames_h_unittest_sh: src/tests/make_tpl_varnames_h_unittest.sh \
+ make_tpl_varnames_h
+ sh $(top_srcdir)/src/tests/make_tpl_varnames_h_unittest.sh \
+ $(top_builddir)/make_tpl_varnames_h $(TMPDIR)/$@_dir
+diff_tpl_auto_escape_unittest_sh: src/tests/diff_tpl_auto_escape_unittest.sh \
+ diff_tpl_auto_escape
+ sh $(top_srcdir)/src/tests/diff_tpl_auto_escape_unittest.sh \
+ $(top_builddir)/diff_tpl_auto_escape $(TMPDIR)/$@_dir
+
+rpm: dist-gzip packages/rpm.sh packages/rpm/rpm.spec
+ @cd packages && ./rpm.sh ${PACKAGE} ${VERSION}
+
+deb: dist-gzip packages/deb.sh packages/deb/*
+ @cd packages && ./deb.sh ${PACKAGE} ${VERSION}
+
+# I get the description and URL lines from the rpm spec. I use sed to
+# try to rewrite exec_prefix, libdir, and includedir in terms of
+# prefix, if possible.
+lib${PACKAGE}.pc: Makefile packages/rpm/rpm.spec
+ echo 'prefix=$(prefix)' > "$@".tmp
+ echo 'exec_prefix='`echo '$(exec_prefix)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
+ echo 'libdir='`echo '$(libdir)' | sed 's@^$(exec_prefix)@$${exec_prefix}@'` >> "$@".tmp
+ echo 'includedir='`echo '$(includedir)' | sed 's@^$(prefix)@$${prefix}@'` >> "$@".tmp
+ echo '' >> "$@".tmp
+ echo 'Name: $(PACKAGE)' >> "$@".tmp
+ echo 'Version: $(VERSION)' >> "$@".tmp
+ -grep '^Summary:' $(top_srcdir)/packages/rpm/rpm.spec | sed s/^Summary:/Description:/ | head -n1 >> "$@".tmp
+ -grep '^URL: ' $(top_srcdir)/packages/rpm/rpm.spec >> "$@".tmp
+ echo 'Requires:' >> "$@".tmp
+ echo 'Libs: -L$${libdir} -l$(PACKAGE)' >> "$@".tmp
+ echo 'Libs.private: $(PTHREAD_CFLAGS) $(PTHREAD_LIBS)' >> "$@".tmp
+ echo 'Cflags: -I$${includedir}' >> "$@".tmp
+ mv -f "$@".tmp "$@"
+
+# The nothreads version is mostly the same
+lib${PACKAGE}_nothreads.pc: lib${PACKAGE}.pc
+ grep -v Libs.private lib${PACKAGE}.pc | sed s/-l$(PACKAGE)/-l$(PACKAGE)_nothreads/ > "$@"
+
+# Windows wants write permission to .vcproj files and maybe even sln files.
+dist-hook:
+ test -e "$(distdir)/vsprojects" \
+ && chmod -R u+w $(distdir)/*.sln $(distdir)/vsprojects/
+
+libtool: $(LIBTOOL_DEPS)
+ $(SHELL) ./config.status --recheck
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/NEWS b/NEWS
new file mode 100644
index 0000000..0c80b51
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,263 @@
+== 19 March 2014 ==
+
+Ctemplate 2.3 has been released. Fixed some more C++11 issues.
+Removed deprecated Template::SetEscapedValueAndShowSection() and Template::ReloadIfChanged().
+
+== 18 April 2012 ==
+
+Ctemplate 2.2 has been released. Several issues reported by G++ 4.7 have been fixed.
+
+== 22 March 2012 ==
+
+2.1 has been released. operator[] has been added to TemplateDictionary.
+
+== 24 January 2012 ==
+
+I've just released ctemplate 2.0. It has no functional changes from
+ctemplate 1.2.
+
+The `google-ctemplate` project has been renamed to `ctemplate`. I
+(csilvers) am stepping down as maintainer, to be replaced by Olaf van
+der Spek. Welcome to the team, Olaf! I've been impressed by your
+contributions to the project discussions and code to date, and look
+forward to having you on the team.
+
+I bumped the major version number up to 2 to reflect the new community
+ownership of the project. All the
+[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-2.0/ChangeLog changes]
+are related to the renaming.
+
+
+=== 18 January 2011 ===
+
+The `google-ctemplate` Google Code page has been renamed to
+`ctemplate`, in preparation for the project being renamed to
+`ctemplate`. In the coming weeks, I'll be stepping down as
+maintainer for the ctemplate project, and as part of that Google is
+relinquishing ownership of the project; it will now be entirely
+community run. The name change reflects that shift.
+
+=== 22 December 2011 ===
+
+I've just released ctemplate 1.1. The only functionality change is
+obscure: when a reload is done (via, say, `ReloadAllIfChanged`), and a
+new file has been created since the last reload that both a) has the
+same filename as a template file that had been loaded in the past, and
+b) is earlier on the template search-path than the previously loaded
+file, *and* c) the previously loaded file hasn't changed since the
+last reload, then at reload-time we now load the new file into the
+template, replacing the old file. Before we would only load the new
+file if the old file had changed on disk, and would otherwise leave
+the template alone. Even more minor changes are in the
+[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-1.1/ChangeLog ChangeLog].
+
+=== 26 August 2011 ===
+
+I've just released ctemplate 1.0! (I've decided 4 weeks is well
+within the definition of "the next week or so"...)
+
+A bit anti-climactic: there are no changes from ctemplate 1.0rc2.
+
+=== 29 July 2011 ===
+
+I've just released ctemplate 1.0rc2. This fixes a serious bug where I
+had added #includes in installed header files, that tried to include
+non-installed header files. This means it was impossible to use
+installed ctemplate; it only worked if you were using it from the
+tarball directory.
+
+I also fixed the unittest that was supposed to catch this, but didn't
+(it was also building in the tarball directory).
+
+If no further problems are found in the next week or so, I will
+release ctemplate 1.0.
+
+=== 22 July 2011 ===
+
+I've just released ctemplate 1.0rc1. If no problems are found in the
+next week or two, I will release ctemplate 1.0.
+
+ctemplate 1.0rc1 has relatively few changes from ctemplate 0.99.
+xml-escaping has been improved a bit. A couple of bugs have been
+fixed, including one where we were ignoring template-global sections
+(a relatively new feature) in some places. A full list of changes is
+available in the
+[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-1.0rc1/ChangeLog ChangeLog].
+
+I've also changed the internal tools used to integrate
+Google-supplied patches to ctemplate into the opensource release.
+These new tools should result in more frequent updates with better
+change descriptions. They will also result in future ChangeLog
+entries being much more verbose (for better or for worse).
+
+=== 24 January 2011 ===
+
+I've just released ctemplate 0.99. I expect this to be the last
+release before ctemplate 1.0. Code has settled down; the big change
+here is some efficiency improvements to javascript template escaping.
+There is also a bugfix for an obscure case where ReloadAllIfChanged()
+is used with multiple ctemplate search paths, where files are deleted
+in one part of the search path between reloads. Unless you need
+either of the above, there's no particular reason to upgrade.
+
+A full list of changes is available in the
+[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-0.99/ChangeLog ChangeLog].
+
+=== 23 September 2010 ===
+
+I've just released ctemplate 0.98. The changes are settling down as
+we approach ctemplate 1.0 -- a few new default modifiers, a few
+performance tweaks, a few portability improvements, but nothing
+disruptive.
+
+In my testing for this release, I noticed that the template regression
+test (but not other template tests) would segfault on gcc 4.1.1 when
+compiled with -O2. This seems pretty clearly to be a compiler bug; if
+you need to use gcc 4.1.1 to compile ctemplate, you may wish to build
+via `./configure CXXFLAGS="-O1 -g"` just to be safe.
+
+=== 20 April 2010 ===
+
+I've just released ctemplate 0.97. This change consists primarily of
+a significant change to the API: the addition of the `TemplateCache`
+class, combined with deprecation of the `Template` class.
+
+`TemplateCache` is a class that holds a collection of templates; this
+concept always existed in ctemplate, but was not previously exposed.
+Many static methods of the `Template` class, such as
+`ReloadAllIfChanged()`, have become methods on `TemplateCache` instead
+(the `Template` methods have been retained for backwards
+compatibility.) Other methods, such as `Expand()`, have become free
+functions. In fact, the entire `Template` class has been deprecated.
+
+The deprecation of `Template` calls for changes in all clients of the
+template code -- you can see in the example at the top of this page
+how the code has changed from `Template* tpl =
+ctemplate::Template::GetTemplate("example.tpl",
+ctemplate::DO_NOT_STRIP); tpl->Expand(&output, &dict);` to
+`ctemplate::ExpandTemplate("example.tpl", ctemplate::DO_NOT_STRIP,
+&dict, &output);`. These changes will make the code simpler and more
+thread-safe.
+
+Old code should continue to work -- the `Template` class remains --
+but new code should use the new API, and old code should transition as
+convenient. One old API method is intrinsically thread-unsafe, and
+should be prioritized to change: `tpl->ReloadIfChanged` should change
+to `ctemplate::Template::ReloadAllIfChanged()`. Note this is a
+semantic change: all templates are now reloaded, rather than just one.
+However, since templates are reloaded lazily, and only if they've
+changed on disk, I'm hopeful it will always be a reasonable change to
+make.
+
+To go along with these changes, the documentation has been almost
+entirely revamped and made more accessible. Obscure ctemplate
+features have been excised from the user's guide and moved into a
+separate reference document. The new API is fully documented,
+including new flexibility around reloading templates, made available
+by the introduction of `TemplateCache`.
+
+There are some more minor changes as well, such as the addition of
+#include guards in the auto-generated .tpl.h files, to make it safe to
+multiply-include them. I've also been continuing the portability
+work: ctemplate should now work under Cygwin and MinGW. A full list
+of changes is available in the
+[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-0.97/ChangeLog ChangeLog].
+
+I know I've said this before, but I don't expect major API changes
+before the 1.0 release. The most significant changes I expect to see
+are the potential removal of some of the 'forwarding' methods in the
+(deprecated) `Template` class.
+
+=== 12 June 2009 ===
+
+I've just released ctemplate 0.95. This is entirely an API cleanup
+release. Actually, relatively little of the API proper has changed:
+`StringToTemplate` no longer takes an autoescape-context arg (instead
+you specify this as part of the template-string, using the
+`AUTOESCAPE` pragma). A few obsolete constructs have gone away, such
+as the `TemplateFromString` class and
+`TemplateDictionary::html_escape` and friends (just use the top-level
+`html_escape`). See the
+[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-0.95/ChangeLog
+ChangeLog] for a full list of these changes.
+
+The biggest change is a renaming: the default namespace is now
+`ctemplate` rather than `google`, and the include directory is
+`ctemplate` rather than `google`. Other namespaces, such as
+`template_modifiers`, have gone away.
+
+All these changes will require you to modify your old code to get it
+working with ctemplate 0.95. I've written a
+[http://google-ctemplate.googlecode.com/svn/trunk/contrib/convert_to_95.pl
+script] to help you do that. Please open an
+[http://code.google.com/p/google-ctemplate/issues/list issue] if you
+see a problem with the script. I've tested it, but not as widely as
+I'd like. Also note the script will not be perfect for more complex
+constructs, which you will have to clean up by hand.
+
+I hope (expect) the API is now stable, and we won't see any more such
+changes before ctemplate 1.0. I tried to isolate them all in this
+release; except for the API changes, this release should behave
+identically to ctemplate 0.94.
+
+=== 7 May 2009 ===
+
+I've just released ctemplate 0.94. A few new features have been
+added, such as the ability to expand a template into your own custom
+`ExpandEmitter` instance, and the ability to hook the annotation
+system (typically used for debugging). You can now remove strings
+from the template cache in addition to adding them. Also, there
+continues to be a trickle of new modifiers, in this case a modifier
+for URL's in a CSS context.
+
+However, the most invasive changes were made for speed reasons. The
+biggest is that (almost) all `TemplateDictionary` allocations are now
+done on the arena -- this includes allocations by the STL classes
+inside the dictionary. This allows us to free all the memory at once,
+rather than item by item, and has yielded a 3-4% speed improvement in
+our tests. I've combined this with a `small_map` class that stores
+items in a vector instead of a hash-map until we get to 3 or 4 items;
+this gives another speed increase in the (common) case a template has
+only a few sections or includes.
+
+I also changed the hashing code to use
+[http://murmurhash.googlepages.com/ MurmurHash] everywhere, rather
+than the string hash function built into the STL library. This should
+be faster.
+
+All these changes should not be outwardly visible, but they do use
+more advanced features of C++ than ctemplate has to date. This may
+result in some problems compiling, or conceivably when running. If
+you see any, please file an
+[http://code.google.com/p/google-ctemplate/issues/list issue report].
+
+You can see a full list of changes on the
+[http://google-ctemplate.googlecode.com/svn/tags/ctemplate-0.94/ChangeLog
+ChangeLog].
+
+=== 20 August 2008 ===
+
+ctemplate 0.91 introduces the beginning of some API changes, as I look
+to clean up the API in preparation for ctemplate 1.0. After 1.0, the
+API will remain backwards compatible, but until that time, the API may
+change. Please take a look at the
+[http://google-ctemplate.googlecode.com/svn/trunk/ChangeLog ChangeLog]
+to see if any of these changes affect you.
+
+One change is the introduction of a new `PerExpandData` class, which
+holds some state that was formerly in the `TemplateDictionary` class.
+I'm still not sure if this class is a good idea, if it should be
+separate from `TemplateDictionary` or a member, or what functionality
+should move there (for instance, should `SetTemplateGlobal` move
+there, since template-global variables are really, in some sense,
+per-expand variables?) If you have any feedback, ideally based on
+your own experience using the current API, feel free to post it at
+`google-ctemplate@googlegroups.com`.
+
+ctemplate also has several new features, including the addition of
+"separator" sections, and the ability to change the markup character
+(from `{{`). See the
+[http://google-ctemplate.googlecode.com/svn/trunk/ChangeLog ChangeLog]
+for a complete list, and the
+[http://google-ctemplate.googlecode.com/svn/trunk/doc/howto.html howto
+documentation] for more details on these new features.
diff --git a/README b/README
new file mode 100644
index 0000000..8959c40
--- /dev/null
+++ b/README
@@ -0,0 +1,37 @@
+See the documentation in the doc/ directory for information about how
+to use the ctemplate library.
+
+COMPILING
+---------
+To compile test applications with these classes, run ./configure
+followed by make. To install these header files on your system, run
+'make install'. (On Windows, the instructions are different; see
+README.windows.) See INSTALL for more details.
+
+This code should work on any modern C++ system. It has been tested on
+Linux (Ubuntu, Fedora, RedHat), Solaris 10 x86, FreeBSD 6.0, OS X 10.3
+and 10.4, and Windows under both VC++7 and VC++8.
+
+There are a few Windows-specific details; see README.windows for more
+information.
+
+CTEMPLATE AND THREADS
+---------------------
+The ctemplate library has thread support, so it works properly in a
+threaded environment. For this to work, if you link libraries with
+-lctemplate you may find you also need to add -pthread (or, on some
+systems, -pthreads, and on others, -lpthread) to get the library to
+compile. If you leave out the -pthread, you'll see errors like this:
+
+ symbol lookup error: /usr/local/lib/libctemplate.so.0: undefined symbol: pthread_rwlock_init
+
+If your code isn't multi-threaded, you can instead use the
+ctemplate_nothread library:
+ -lctemplate_nothreads
+
+To summarize, there are two ways to link in ctemlpate in non-threaded
+applications. For instance:
+ 1) gcc -o my_app my_app.o -lctemplate -pthread
+ 2) gcc -o my_app my_app.o -lctemplate_nothreads
+
+If your application uses threads, you should use form (1).
diff --git a/README_windows.txt b/README_windows.txt
new file mode 100644
index 0000000..2a89f75
--- /dev/null
+++ b/README_windows.txt
@@ -0,0 +1,43 @@
+This project has been ported to Windows. A working solution file
+exists in this directory:
+ ctemplate.sln
+
+You can load this solution file into either VC++ 7.1 (Visual Studio
+2003) or VC++ 8.0 (Visual Studio 2005) -- in the latter case, it will
+automatically convert the files to the latest format for you.
+
+When you build the solution, it will create libctemplate.dll, the main
+library for this project, plus a number of unittests, which you can
+run by hand (or, more easily, under the Visual Studio debugger) to
+make sure everything is working properly on your system. The binaries
+will end up in a directory called "debug" or "release" in the
+top-level directory (next to the .sln file).
+
+I don't know very much about how to install DLLs on Windows, so you'll
+have to figure out that part for yourself. If you choose to just
+re-use the existing .sln, make sure you set the IncludeDir's
+appropriately! Look at the properties for libctemplate.dll.
+
+If you wish to link to ctemplate statically instead of using the .dll,
+you can; see the example project template_unittest_static. For this
+to work, you'll need to add "/D CTEMPLATE_DLL_DECL=" to the compile
+line of every ctemplate .cc file.
+
+Note that these systems are set to build in Debug mode by default.
+You may want to change them to Release mode.
+
+Currently, Template::StringToTemplate returns a Template object that
+you, the caller, must free. We've heard reports that Windows can have
+trouble allocating memory in a .dll that is meant to be freed in the
+application. Thus, we suggest you not use StringToTemplate from
+Windows. Instead, you can use Template::StringToTemplateCache()
+followed by Template::GetTemplate().
+
+I have little experience with Windows programming, so there may be
+better ways to set this up than I've done! If you run across any
+problems, please post to the google-ctemplate Google Group, or report
+them on the ctemplate Google Code site:
+ http://groups.google.com/group/google-ctemplate
+ http://code.google.com/p/ctemplate/issues/list
+
+-- craig
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644
index 0000000..e944066
--- /dev/null
+++ b/aclocal.m4
@@ -0,0 +1,1192 @@
+# generated automatically by aclocal 1.14.1 -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
+m4_ifndef([AC_AUTOCONF_VERSION],
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],,
+[m4_warning([this file was generated for autoconf 2.69.
+You have another version of autoconf. It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically 'autoreconf'.])])
+
+# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.14'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version. Point them to the right macro.
+m4_if([$1], [1.14.1], [],
+ [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too. Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.14.1])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to
+# '$srcdir', '$srcdir/..', or '$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory. The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run. This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+# fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+# fails if $ac_aux_dir is absolute,
+# fails when called from a subdirectory in a VPATH build with
+# a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir. In an in-source build this is usually
+# harmless because $srcdir is '.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
+# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+# MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH. The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
+])
+
+# AM_CONDITIONAL -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ([2.52])dnl
+ m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
+ [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+ $1_TRUE=
+ $1_FALSE='#'
+else
+ $1_TRUE='#'
+ $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+ AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery. Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+m4_if([$1], [CC], [depcc="$CC" am_compiler_list=],
+ [$1], [CXX], [depcc="$CXX" am_compiler_list=],
+ [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+ [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'],
+ [$1], [UPC], [depcc="$UPC" am_compiler_list=],
+ [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
+ [depcc="$$1" am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+ [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_$1_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+ fi
+ am__universal=false
+ m4_case([$1], [CC],
+ [case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac],
+ [CXX],
+ [case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac])
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_$1_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES.
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE([dependency-tracking], [dnl
+AS_HELP_STRING(
+ [--enable-dependency-tracking],
+ [do not reject slow dependency extractors])
+AS_HELP_STRING(
+ [--disable-dependency-tracking],
+ [speeds up one-time build])])
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+ am__nodep='_no'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+AC_SUBST([am__nodep])dnl
+_AM_SUBST_NOTMAKE([am__nodep])dnl
+])
+
+# Generate code to set up dependency tracking. -*- Autoconf -*-
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+ # Older Autoconf quotes --file arguments for eval, but not when files
+ # are listed without --file. Let's play safe and only enable the eval
+ # if we detect the quoting.
+ case $CONFIG_FILES in
+ *\'*) eval set x "$CONFIG_FILES" ;;
+ *) set x $CONFIG_FILES ;;
+ esac
+ shift
+ for mf
+ do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named 'Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # Grep'ing the whole file is not good either: AIX grep has a line
+ # limit of 2048, but all sed's we know have understand at least 4000.
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+ dirpart=`AS_DIRNAME("$mf")`
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running 'make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "$am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`AS_DIRNAME(["$file"])`
+ AS_MKDIR_P([$dirpart/$fdir])
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+ done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled. FIXME. This creates each '.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+ [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+ [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake. -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This macro actually does too much. Some checks are only needed if
+# your package does certain things. But this isn't really a big deal.
+
+dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O.
+m4_define([AC_PROG_CC],
+m4_defn([AC_PROG_CC])
+[_AM_PROG_CC_C_O
+])
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out. PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition. After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.65])dnl
+dnl Autoconf wants to disallow AM_ names. We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[AC_DIAGNOSE([obsolete],
+ [$0: two- and three-arguments forms are deprecated.])
+m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(
+ m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]),
+ [ok:ok],,
+ [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package])
+ AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}])
+AM_MISSING_PROG([AUTOCONF], [autoconf])
+AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}])
+AM_MISSING_PROG([AUTOHEADER], [autoheader])
+AM_MISSING_PROG([MAKEINFO], [makeinfo])
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+# For better backward compatibility. To be removed once Automake 1.9.x
+# dies out for good. For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+AC_SUBST([mkdir_p], ['$(MKDIR_P)'])
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+ [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+ [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+ [_AM_DEPENDENCIES([CC])],
+ [m4_define([AC_PROG_CC],
+ m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [_AM_DEPENDENCIES([CXX])],
+ [m4_define([AC_PROG_CXX],
+ m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+ [_AM_DEPENDENCIES([OBJC])],
+ [m4_define([AC_PROG_OBJC],
+ m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJCXX],
+ [_AM_DEPENDENCIES([OBJCXX])],
+ [m4_define([AC_PROG_OBJCXX],
+ m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl
+])
+AC_REQUIRE([AM_SILENT_RULES])dnl
+dnl The testsuite driver may need to know about EXEEXT, so add the
+dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This
+dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+ [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ AC_MSG_ERROR([Your 'rm' program is bad, sorry.])
+ fi
+fi
+])
+
+dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated. The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+ *)
+ install_sh="\${SHELL} $am_aux_dir/install-sh"
+ esac
+fi
+AC_SUBST([install_sh])])
+
+# Copyright (C) 2003-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot. For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes. -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+ am__include=include
+ am__quote=
+ _am_result=GNU
+ ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ case `$am_make -s -f confmf 2> /dev/null` in #(
+ *the\ am__doit\ target*)
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ ;;
+ esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
+
+# Copyright (C) 1997-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it is modern enough.
+# If it is, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+ *)
+ MISSING="\${SHELL} $am_aux_dir/missing" ;;
+ esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+ am_missing_run="$MISSING "
+else
+ am_missing_run=
+ AC_MSG_WARN(['missing' script is too old or missing])
+fi
+])
+
+# -*- Autoconf -*-
+# Obsolete and "removed" macros, that must however still report explicit
+# error messages when used, to smooth transition.
+#
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([AM_CONFIG_HEADER],
+[AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should use the 'AC][_CONFIG_HEADERS' macro instead.])dnl
+AC_CONFIG_HEADERS($@)])
+
+AC_DEFUN([AM_PROG_CC_STDC],
+[AC_PROG_CC
+am_cv_prog_cc_stdc=$ac_cv_prog_cc_stdc
+AC_DIAGNOSE([obsolete],
+['$0': this macro is obsolete.
+You should simply use the 'AC][_PROG_CC' macro instead.
+Also, your code should no longer depend upon 'am_cv_prog_cc_stdc',
+but upon 'ac_cv_prog_cc_stdc'.])])
+
+AC_DEFUN([AM_C_PROTOTYPES],
+ [AC_FATAL([automatic de-ANSI-fication support has been removed])])
+AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
+
+# Helper functions for option handling. -*- Autoconf -*-
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# --------------------
+# Set option NAME. Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), [1])])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Copyright (C) 1999-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_CC_C_O
+# ---------------
+# Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC
+# to automatically call this.
+AC_DEFUN([_AM_PROG_CC_C_O],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+AC_LANG_PUSH([C])dnl
+AC_CACHE_CHECK(
+ [whether $CC understands -c and -o together],
+ [am_cv_prog_cc_c_o],
+ [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])])
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i])
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+AC_LANG_POP([C])])
+
+# For backward compatibility.
+AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_RUN_LOG(COMMAND)
+# -------------------
+# Run COMMAND, save the exit status in ac_status, and log it.
+# (This has been adapted from Autoconf's _AC_RUN_LOG macro.)
+AC_DEFUN([AM_RUN_LOG],
+[{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD
+ ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ (exit $ac_status); }])
+
+# Check to make sure that the build environment is sane. -*- Autoconf -*-
+
+# Copyright (C) 1996-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name. Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+ *[[\\\"\#\$\&\'\`$am_lf]]*)
+ AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+ *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
+ AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ am_has_slept=no
+ for am_try in 1 2; do
+ echo "timestamp, slept: $am_has_slept" > conftest.file
+ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+ if test "$[*]" = "X"; then
+ # -L didn't work.
+ set X `ls -t "$srcdir/configure" conftest.file`
+ fi
+ if test "$[*]" != "X $srcdir/configure conftest.file" \
+ && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
+ alias in your environment])
+ fi
+ if test "$[2]" = conftest.file || test $am_try -eq 2; then
+ break
+ fi
+ # Just in case.
+ sleep 1
+ am_has_slept=yes
+ done
+ test "$[2]" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT([yes])
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+ ( sleep 1 ) &
+ am_sleep_pid=$!
+fi
+AC_CONFIG_COMMANDS_PRE(
+ [AC_MSG_CHECKING([that generated files are newer than configure])
+ if test -n "$am_sleep_pid"; then
+ # Hide warnings about reused PIDs.
+ wait $am_sleep_pid 2>/dev/null
+ fi
+ AC_MSG_RESULT([done])])
+rm -f conftest.file
+])
+
+# Copyright (C) 2009-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_SILENT_RULES([DEFAULT])
+# --------------------------
+# Enable less verbose build rules; with the default set to DEFAULT
+# ("yes" being less verbose, "no" or empty being verbose).
+AC_DEFUN([AM_SILENT_RULES],
+[AC_ARG_ENABLE([silent-rules], [dnl
+AS_HELP_STRING(
+ [--enable-silent-rules],
+ [less verbose build output (undo: "make V=1")])
+AS_HELP_STRING(
+ [--disable-silent-rules],
+ [verbose build output (undo: "make V=0")])dnl
+])
+case $enable_silent_rules in @%:@ (((
+ yes) AM_DEFAULT_VERBOSITY=0;;
+ no) AM_DEFAULT_VERBOSITY=1;;
+ *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);;
+esac
+dnl
+dnl A few 'make' implementations (e.g., NonStop OS and NextStep)
+dnl do not support nested variable expansions.
+dnl See automake bug#9928 and bug#10237.
+am_make=${MAKE-make}
+AC_CACHE_CHECK([whether $am_make supports nested variables],
+ [am_cv_make_support_nested_variables],
+ [if AS_ECHO([['TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+ @$(TRUE)
+.PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then
+ am_cv_make_support_nested_variables=yes
+else
+ am_cv_make_support_nested_variables=no
+fi])
+if test $am_cv_make_support_nested_variables = yes; then
+ dnl Using '$V' instead of '$(V)' breaks IRIX make.
+ AM_V='$(V)'
+ AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+ AM_V=$AM_DEFAULT_VERBOSITY
+ AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AC_SUBST([AM_V])dnl
+AM_SUBST_NOTMAKE([AM_V])dnl
+AC_SUBST([AM_DEFAULT_V])dnl
+AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl
+AC_SUBST([AM_DEFAULT_VERBOSITY])dnl
+AM_BACKSLASH='\'
+AC_SUBST([AM_BACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl
+])
+
+# Copyright (C) 2001-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor 'install' (even GNU) is that you can't
+# specify the program used to strip binaries. This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in "make install-strip", and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip". However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be 'maybe'.
+if test "$cross_compiling" != no; then
+ AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# --------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball. -*- Autoconf -*-
+
+# Copyright (C) 2004-2013 Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of 'v7', 'ustar', or 'pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+# tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+# $(am__untar) < result.tar
+#
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility. Yes, it's still used
+# in the wild :-( We should find a proper way to deprecate it ...
+AC_SUBST([AMTAR], ['$${TAR-tar}'])
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+
+m4_if([$1], [v7],
+ [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'],
+
+ [m4_case([$1],
+ [ustar],
+ [# The POSIX 1988 'ustar' format is defined with fixed-size fields.
+ # There is notably a 21 bits limit for the UID and the GID. In fact,
+ # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
+ # and bug#13588).
+ am_max_uid=2097151 # 2^21 - 1
+ am_max_gid=$am_max_uid
+ # The $UID and $GID variables are not portable, so we need to resort
+ # to the POSIX-mandated id(1) utility. Errors in the 'id' calls
+ # below are definitely unexpected, so allow the users to see them
+ # (that is, avoid stderr redirection).
+ am_uid=`id -u || echo unknown`
+ am_gid=`id -g || echo unknown`
+ AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format])
+ if test $am_uid -le $am_max_uid; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ _am_tools=none
+ fi
+ AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format])
+ if test $am_gid -le $am_max_gid; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ _am_tools=none
+ fi],
+
+ [pax],
+ [],
+
+ [m4_fatal([Unknown tar format])])
+
+ AC_MSG_CHECKING([how to create a $1 tar archive])
+
+ # Go ahead even if we have the value already cached. We do so because we
+ # need to set the values for the 'am__tar' and 'am__untar' variables.
+ _am_tools=${am_cv_prog_tar_$1-$_am_tools}
+
+ for _am_tool in $_am_tools; do
+ case $_am_tool in
+ gnutar)
+ for _am_tar in tar gnutar gtar; do
+ AM_RUN_LOG([$_am_tar --version]) && break
+ done
+ am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+ am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+ am__untar="$_am_tar -xf -"
+ ;;
+ plaintar)
+ # Must skip GNU tar: if it does not support --format= it doesn't create
+ # ustar tarball either.
+ (tar --version) >/dev/null 2>&1 && continue
+ am__tar='tar chf - "$$tardir"'
+ am__tar_='tar chf - "$tardir"'
+ am__untar='tar xf -'
+ ;;
+ pax)
+ am__tar='pax -L -x $1 -w "$$tardir"'
+ am__tar_='pax -L -x $1 -w "$tardir"'
+ am__untar='pax -r'
+ ;;
+ cpio)
+ am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+ am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+ am__untar='cpio -i -H $1 -d'
+ ;;
+ none)
+ am__tar=false
+ am__tar_=false
+ am__untar=false
+ ;;
+ esac
+
+ # If the value was cached, stop now. We just wanted to have am__tar
+ # and am__untar set.
+ test -n "${am_cv_prog_tar_$1}" && break
+
+ # tar/untar a dummy directory, and stop if the command works.
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ echo GrepMe > conftest.dir/file
+ AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+ rm -rf conftest.dir
+ if test -s conftest.tar; then
+ AM_RUN_LOG([$am__untar <conftest.tar])
+ AM_RUN_LOG([cat conftest.dir/file])
+ grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+ fi
+ done
+ rm -rf conftest.dir
+
+ AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+ AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([m4/ac_have_attribute.m4])
+m4_include([m4/ac_interlocked_exchange.m4])
+m4_include([m4/ac_rwlock.m4])
+m4_include([m4/acx_pthread.m4])
+m4_include([m4/compiler_characteristics.m4])
+m4_include([m4/google_namespace.m4])
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
+m4_include([m4/namespaces.m4])
+m4_include([m4/stl_hash.m4])
+m4_include([m4/stl_namespace.m4])
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..3268bc9
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+# Before using, you should figure out all the .m4 macros that your
+# configure.m4 script needs and make sure they exist in the m4/
+# directory.
+#
+# These are the files that this script might edit:
+# aclocal.m4 configure Makefile.in src/config.h.in \
+# depcomp config.guess config.sub install-sh missing mkinstalldirs \
+#
+# Here's a command you can run to see what files aclocal will import:
+# aclocal -I ../autoconf --output=- | sed -n 's/^m4_include..\([^]]*\).*/\1/p'
+
+# Because libtoolize isn't in the hermetic build, autogen doesn't run it.
+# However, it should be run manually periodically to update these files:
+# in .: ltmain.sh
+# in m4: libtool.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 lt~obsolete.m4
+
+set -ex
+rm -rf autom4te.cache
+
+aclocal --force -I m4
+#grep -q LIBTOOL configure.ac && libtoolize -c -f
+autoconf -f -W all,no-obsolete
+autoheader -f -W all
+automake -a -c -f -W all
+
+rm -rf autom4te.cache
+exit 0
diff --git a/compile b/compile
new file mode 100755
index 0000000..1b1d232
--- /dev/null
+++ b/compile
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "compile $scriptversion"
+ exit $?
+ ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+ if test -n "$eat"; then
+ eat=
+ else
+ case $1 in
+ -o)
+ # configure might choose to run compile as `compile cc -o foo foo.c'.
+ # So we strip `-o arg' only if arg is an object.
+ eat=1
+ case $2 in
+ *.o | *.obj)
+ ofile=$2
+ ;;
+ *)
+ set x "$@" -o "$2"
+ shift
+ ;;
+ esac
+ ;;
+ *.c)
+ cfile=$1
+ set x "$@" "$1"
+ shift
+ ;;
+ *)
+ set x "$@" "$1"
+ shift
+ ;;
+ esac
+ fi
+ shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+ # If no `-o' option was seen then we might have been invoked from a
+ # pattern rule where we don't need one. That is ok -- this is a
+ # normal compilation that the losing compiler can handle. If no
+ # `.c' file was seen then we are probably linking. That is also
+ # ok.
+ exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use `[/.-]' here to ensure that we don't use the same name
+# that we are using for the .o file. Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+while true; do
+ if mkdir "$lockdir" >/dev/null 2>&1; then
+ break
+ fi
+ sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+ mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+ mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/config.guess b/config.guess
new file mode 100755
index 0000000..ca2a03c
--- /dev/null
+++ b/config.guess
@@ -0,0 +1,1526 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+
+timestamp='2008-01-08'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub. If it succeeds, it prints the system name on stdout, and
+# exits with 0. Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help" >&2
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,) echo "int x;" > $dummy.c ;
+ for c in cc gcc c89 c99 ; do
+ if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+ CC_FOR_BUILD="$c"; break ;
+ fi ;
+ done ;
+ if test x"$CC_FOR_BUILD" = x ; then
+ CC_FOR_BUILD=no_compiler_found ;
+ fi
+ ;;
+ ,,*) CC_FOR_BUILD=$CC ;;
+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+ PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # NetBSD (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ #
+ # Note: NetBSD doesn't particularly care about the vendor
+ # portion of the name. We always set it to "unknown".
+ sysctl="sysctl -n hw.machine_arch"
+ UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+ /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+ case "${UNAME_MACHINE_ARCH}" in
+ armeb) machine=armeb-unknown ;;
+ arm*) machine=arm-unknown ;;
+ sh3el) machine=shl-unknown ;;
+ sh3eb) machine=sh-unknown ;;
+ sh5el) machine=sh5le-unknown ;;
+ *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+ esac
+ # The Operating System including object format, if it has switched
+ # to ELF recently, or will in the future.
+ case "${UNAME_MACHINE_ARCH}" in
+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+ eval $set_cc_for_build
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ ;;
+ *)
+ os=netbsd
+ ;;
+ esac
+ # The OS release
+ # Debian GNU/NetBSD machines have a different userland, and
+ # thus, need a distinct triplet. However, they do not need
+ # kernel version information, so it can be replaced with a
+ # suitable tag, in the style of linux-gnu.
+ case "${UNAME_VERSION}" in
+ Debian*)
+ release='-gnu'
+ ;;
+ *)
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ ;;
+ esac
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit ;;
+ *:OpenBSD:*:*)
+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+ echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+ exit ;;
+ *:ekkoBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+ exit ;;
+ *:SolidBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+ exit ;;
+ macppc:MirBSD:*:*)
+ echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ *:MirBSD:*:*)
+ echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+ exit ;;
+ alpha:OSF1:*:*)
+ case $UNAME_RELEASE in
+ *4.0)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+ ;;
+ *5.*)
+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+ ;;
+ esac
+ # According to Compaq, /usr/sbin/psrinfo has been available on
+ # OSF/1 and Tru64 systems produced since 1995. I hope that
+ # covers most systems running today. This code pipes the CPU
+ # types through head -n 1, so we only detect the type of CPU 0.
+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+ case "$ALPHA_CPU_TYPE" in
+ "EV4 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "EV4.5 (21064)")
+ UNAME_MACHINE="alpha" ;;
+ "LCA4 (21066/21068)")
+ UNAME_MACHINE="alpha" ;;
+ "EV5 (21164)")
+ UNAME_MACHINE="alphaev5" ;;
+ "EV5.6 (21164A)")
+ UNAME_MACHINE="alphaev56" ;;
+ "EV5.6 (21164PC)")
+ UNAME_MACHINE="alphapca56" ;;
+ "EV5.7 (21164PC)")
+ UNAME_MACHINE="alphapca57" ;;
+ "EV6 (21264)")
+ UNAME_MACHINE="alphaev6" ;;
+ "EV6.7 (21264A)")
+ UNAME_MACHINE="alphaev67" ;;
+ "EV6.8CB (21264C)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8AL (21264B)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.8CX (21264D)")
+ UNAME_MACHINE="alphaev68" ;;
+ "EV6.9A (21264/EV69A)")
+ UNAME_MACHINE="alphaev69" ;;
+ "EV7 (21364)")
+ UNAME_MACHINE="alphaev7" ;;
+ "EV7.9 (21364A)")
+ UNAME_MACHINE="alphaev79" ;;
+ esac
+ # A Pn.n version is a patched version.
+ # A Vn.n version is a released version.
+ # A Tn.n version is a released field test version.
+ # A Xn.n version is an unreleased experimental baselevel.
+ # 1.2 uses "1.2" for uname -r.
+ echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ exit ;;
+ Alpha\ *:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # Should we change UNAME_MACHINE based on the output of uname instead
+ # of the specific Alpha model?
+ echo alpha-pc-interix
+ exit ;;
+ 21064:Windows_NT:50:3)
+ echo alpha-dec-winnt3.5
+ exit ;;
+ Amiga*:UNIX_System_V:4.0:*)
+ echo m68k-unknown-sysv4
+ exit ;;
+ *:[Aa]miga[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-amigaos
+ exit ;;
+ *:[Mm]orph[Oo][Ss]:*:*)
+ echo ${UNAME_MACHINE}-unknown-morphos
+ exit ;;
+ *:OS/390:*:*)
+ echo i370-ibm-openedition
+ exit ;;
+ *:z/VM:*:*)
+ echo s390-ibm-zvmoe
+ exit ;;
+ *:OS400:*:*)
+ echo powerpc-ibm-os400
+ exit ;;
+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+ echo arm-acorn-riscix${UNAME_RELEASE}
+ exit ;;
+ arm:riscos:*:*|arm:RISCOS:*:*)
+ echo arm-unknown-riscos
+ exit ;;
+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+ echo hppa1.1-hitachi-hiuxmpp
+ exit ;;
+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+ if test "`(/bin/universe) 2>/dev/null`" = att ; then
+ echo pyramid-pyramid-sysv3
+ else
+ echo pyramid-pyramid-bsd
+ fi
+ exit ;;
+ NILE*:*:*:dcosx)
+ echo pyramid-pyramid-svr4
+ exit ;;
+ DRS?6000:unix:4.0:6*)
+ echo sparc-icl-nx6
+ exit ;;
+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+ case `/usr/bin/uname -p` in
+ sparc) echo sparc-icl-nx7; exit ;;
+ esac ;;
+ sun4H:SunOS:5.*:*)
+ echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+ echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:6*:*)
+ # According to config.sub, this is the proper way to canonicalize
+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but
+ # it's likely to be more like Solaris than SunOS4.
+ echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ sun4*:SunOS:*:*)
+ case "`/usr/bin/arch -k`" in
+ Series*|S4*)
+ UNAME_RELEASE=`uname -v`
+ ;;
+ esac
+ # Japanese Language versions have a version number like `4.1.3-JL'.
+ echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+ exit ;;
+ sun3*:SunOS:*:*)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ exit ;;
+ sun*:*:4.2BSD:*)
+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+ test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+ case "`/bin/arch`" in
+ sun3)
+ echo m68k-sun-sunos${UNAME_RELEASE}
+ ;;
+ sun4)
+ echo sparc-sun-sunos${UNAME_RELEASE}
+ ;;
+ esac
+ exit ;;
+ aushp:SunOS:*:*)
+ echo sparc-auspex-sunos${UNAME_RELEASE}
+ exit ;;
+ # The situation for MiNT is a little confusing. The machine name
+ # can be virtually everything (everything which is not
+ # "atarist" or "atariste" at least should have a processor
+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"
+ # to the lowercase version "mint" (or "freemint"). Finally
+ # the system name "TOS" denotes a system which is actually not
+ # MiNT. But MiNT is downward compatible to TOS, so this should
+ # be no problem.
+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+ echo m68k-atari-mint${UNAME_RELEASE}
+ exit ;;
+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+ echo m68k-milan-mint${UNAME_RELEASE}
+ exit ;;
+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+ echo m68k-hades-mint${UNAME_RELEASE}
+ exit ;;
+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+ echo m68k-unknown-mint${UNAME_RELEASE}
+ exit ;;
+ m68k:machten:*:*)
+ echo m68k-apple-machten${UNAME_RELEASE}
+ exit ;;
+ powerpc:machten:*:*)
+ echo powerpc-apple-machten${UNAME_RELEASE}
+ exit ;;
+ RISC*:Mach:*:*)
+ echo mips-dec-mach_bsd4.3
+ exit ;;
+ RISC*:ULTRIX:*:*)
+ echo mips-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ VAX*:ULTRIX*:*:*)
+ echo vax-dec-ultrix${UNAME_RELEASE}
+ exit ;;
+ 2020:CLIX:*:* | 2430:CLIX:*:*)
+ echo clipper-intergraph-clix${UNAME_RELEASE}
+ exit ;;
+ mips:*:*:UMIPS | mips:*:*:RISCos)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
+ int main (int argc, char *argv[]) {
+#else
+ int main (argc, argv) int argc; char *argv[]; {
+#endif
+ #if defined (host_mips) && defined (MIPSEB)
+ #if defined (SYSTYPE_SYSV)
+ printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_SVR4)
+ printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+ #endif
+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+ printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+ #endif
+ #endif
+ exit (-1);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c &&
+ dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+ SYSTEM_NAME=`$dummy $dummyarg` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo mips-mips-riscos${UNAME_RELEASE}
+ exit ;;
+ Motorola:PowerMAX_OS:*:*)
+ echo powerpc-motorola-powermax
+ exit ;;
+ Motorola:*:4.3:PL8-*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+ echo powerpc-harris-powermax
+ exit ;;
+ Night_Hawk:Power_UNIX:*:*)
+ echo powerpc-harris-powerunix
+ exit ;;
+ m88k:CX/UX:7*:*)
+ echo m88k-harris-cxux7
+ exit ;;
+ m88k:*:4*:R4*)
+ echo m88k-motorola-sysv4
+ exit ;;
+ m88k:*:3*:R3*)
+ echo m88k-motorola-sysv3
+ exit ;;
+ AViiON:dgux:*:*)
+ # DG/UX returns AViiON for all architectures
+ UNAME_PROCESSOR=`/usr/bin/uname -p`
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+ then
+ if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+ [ ${TARGET_BINARY_INTERFACE}x = x ]
+ then
+ echo m88k-dg-dgux${UNAME_RELEASE}
+ else
+ echo m88k-dg-dguxbcs${UNAME_RELEASE}
+ fi
+ else
+ echo i586-dg-dgux${UNAME_RELEASE}
+ fi
+ exit ;;
+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)
+ echo m88k-dolphin-sysv3
+ exit ;;
+ M88*:*:R3*:*)
+ # Delta 88k system running SVR3
+ echo m88k-motorola-sysv3
+ exit ;;
+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+ echo m88k-tektronix-sysv3
+ exit ;;
+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+ echo m68k-tektronix-bsd
+ exit ;;
+ *:IRIX*:*:*)
+ echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+ exit ;;
+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+ echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id
+ exit ;; # Note that: echo "'`uname -s`'" gives 'AIX '
+ i*86:AIX:*:*)
+ echo i386-ibm-aix
+ exit ;;
+ ia64:AIX:*:*)
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:2:3)
+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <sys/systemcfg.h>
+
+ main()
+ {
+ if (!__power_pc())
+ exit(1);
+ puts("powerpc-ibm-aix3.2.5");
+ exit(0);
+ }
+EOF
+ if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+ then
+ echo "$SYSTEM_NAME"
+ else
+ echo rs6000-ibm-aix3.2.5
+ fi
+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+ echo rs6000-ibm-aix3.2.4
+ else
+ echo rs6000-ibm-aix3.2
+ fi
+ exit ;;
+ *:AIX:*:[456])
+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+ if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+ IBM_ARCH=rs6000
+ else
+ IBM_ARCH=powerpc
+ fi
+ if [ -x /usr/bin/oslevel ] ; then
+ IBM_REV=`/usr/bin/oslevel`
+ else
+ IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+ fi
+ echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+ exit ;;
+ *:AIX:*:*)
+ echo rs6000-ibm-aix
+ exit ;;
+ ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+ echo romp-ibm-bsd4.4
+ exit ;;
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
+ echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
+ exit ;; # report: romp-ibm BSD 4.3
+ *:BOSX:*:*)
+ echo rs6000-bull-bosx
+ exit ;;
+ DPX/2?00:B.O.S.:*:*)
+ echo m68k-bull-sysv3
+ exit ;;
+ 9000/[34]??:4.3bsd:1.*:*)
+ echo m68k-hp-bsd
+ exit ;;
+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+ echo m68k-hp-bsd4.4
+ exit ;;
+ 9000/[34678]??:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ case "${UNAME_MACHINE}" in
+ 9000/31? ) HP_ARCH=m68000 ;;
+ 9000/[34]?? ) HP_ARCH=m68k ;;
+ 9000/[678][0-9][0-9])
+ if [ -x /usr/bin/getconf ]; then
+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+ case "${sc_cpu_version}" in
+ 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+ 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+ 532) # CPU_PA_RISC2_0
+ case "${sc_kernel_bits}" in
+ 32) HP_ARCH="hppa2.0n" ;;
+ 64) HP_ARCH="hppa2.0w" ;;
+ '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20
+ esac ;;
+ esac
+ fi
+ if [ "${HP_ARCH}" = "" ]; then
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
+ #include <stdlib.h>
+ #include <unistd.h>
+
+ int main ()
+ {
+ #if defined(_SC_KERNEL_BITS)
+ long bits = sysconf(_SC_KERNEL_BITS);
+ #endif
+ long cpu = sysconf (_SC_CPU_VERSION);
+
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+ case CPU_PA_RISC2_0:
+ #if defined(_SC_KERNEL_BITS)
+ switch (bits)
+ {
+ case 64: puts ("hppa2.0w"); break;
+ case 32: puts ("hppa2.0n"); break;
+ default: puts ("hppa2.0"); break;
+ } break;
+ #else /* !defined(_SC_KERNEL_BITS) */
+ puts ("hppa2.0"); break;
+ #endif
+ default: puts ("hppa1.0"); break;
+ }
+ exit (0);
+ }
+EOF
+ (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+ test -z "$HP_ARCH" && HP_ARCH=hppa
+ fi ;;
+ esac
+ if [ ${HP_ARCH} = "hppa2.0w" ]
+ then
+ eval $set_cc_for_build
+
+ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler
+ # generating 64-bit code. GNU and HP use different nomenclature:
+ #
+ # $ CC_FOR_BUILD=cc ./config.guess
+ # => hppa2.0w-hp-hpux11.23
+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+ # => hppa64-hp-hpux11.23
+
+ if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+ grep __LP64__ >/dev/null
+ then
+ HP_ARCH="hppa2.0w"
+ else
+ HP_ARCH="hppa64"
+ fi
+ fi
+ echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+ exit ;;
+ ia64:HP-UX:*:*)
+ HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+ echo ia64-hp-hpux${HPUX_REV}
+ exit ;;
+ 3050*:HI-UX:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <unistd.h>
+ int
+ main ()
+ {
+ long cpu = sysconf (_SC_CPU_VERSION);
+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct
+ results, however. */
+ if (CPU_IS_PA_RISC (cpu))
+ {
+ switch (cpu)
+ {
+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+ default: puts ("hppa-hitachi-hiuxwe2"); break;
+ }
+ }
+ else if (CPU_IS_HP_MC68K (cpu))
+ puts ("m68k-hitachi-hiuxwe2");
+ else puts ("unknown-hitachi-hiuxwe2");
+ exit (0);
+ }
+EOF
+ $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+ echo unknown-hitachi-hiuxwe2
+ exit ;;
+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+ echo hppa1.1-hp-bsd
+ exit ;;
+ 9000/8??:4.3bsd:*:*)
+ echo hppa1.0-hp-bsd
+ exit ;;
+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+ echo hppa1.0-hp-mpeix
+ exit ;;
+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+ echo hppa1.1-hp-osf
+ exit ;;
+ hp8??:OSF1:*:*)
+ echo hppa1.0-hp-osf
+ exit ;;
+ i*86:OSF1:*:*)
+ if [ -x /usr/sbin/sysversion ] ; then
+ echo ${UNAME_MACHINE}-unknown-osf1mk
+ else
+ echo ${UNAME_MACHINE}-unknown-osf1
+ fi
+ exit ;;
+ parisc*:Lites*:*:*)
+ echo hppa1.1-hp-lites
+ exit ;;
+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+ echo c1-convex-bsd
+ exit ;;
+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+ echo c34-convex-bsd
+ exit ;;
+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+ echo c38-convex-bsd
+ exit ;;
+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+ echo c4-convex-bsd
+ exit ;;
+ CRAY*Y-MP:*:*:*)
+ echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*[A-Z]90:*:*:*)
+ echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+ -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*TS:*:*:*)
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*T3E:*:*:*)
+ echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ *:UNICOS/mp:*:*)
+ echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit ;;
+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+ FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+ echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ 5000:UNIX_System_V:4.*:*)
+ FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+ FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+ echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+ exit ;;
+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+ echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+ exit ;;
+ sparc*:BSD/OS:*:*)
+ echo sparc-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:BSD/OS:*:*)
+ echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+ exit ;;
+ *:FreeBSD:*:*)
+ case ${UNAME_MACHINE} in
+ pc98)
+ echo i386-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ amd64)
+ echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ *)
+ echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+ esac
+ exit ;;
+ i*:CYGWIN*:*)
+ echo ${UNAME_MACHINE}-pc-cygwin
+ exit ;;
+ *:MINGW*:*)
+ echo ${UNAME_MACHINE}-pc-mingw32
+ exit ;;
+ i*:windows32*:*)
+ # uname -m includes "-pc" on this system.
+ echo ${UNAME_MACHINE}-mingw32
+ exit ;;
+ i*:PW*:*)
+ echo ${UNAME_MACHINE}-pc-pw32
+ exit ;;
+ *:Interix*:[3456]*)
+ case ${UNAME_MACHINE} in
+ x86)
+ echo i586-pc-interix${UNAME_RELEASE}
+ exit ;;
+ EM64T | authenticamd)
+ echo x86_64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ IA64)
+ echo ia64-unknown-interix${UNAME_RELEASE}
+ exit ;;
+ esac ;;
+ [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+ echo i${UNAME_MACHINE}-pc-mks
+ exit ;;
+ i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+ # How do we know it's Interix rather than the generic POSIX subsystem?
+ # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+ # UNAME_MACHINE based on the output of uname instead of i386?
+ echo i586-pc-interix
+ exit ;;
+ i*:UWIN*:*)
+ echo ${UNAME_MACHINE}-pc-uwin
+ exit ;;
+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
+ echo x86_64-unknown-cygwin
+ exit ;;
+ p*:CYGWIN*:*)
+ echo powerpcle-unknown-cygwin
+ exit ;;
+ prep*:SunOS:5.*:*)
+ echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+ exit ;;
+ *:GNU:*:*)
+ # the GNU system
+ echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+ exit ;;
+ *:GNU/*:*:*)
+ # other systems with GNU libc and userland
+ echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+ exit ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit ;;
+ arm*:Linux:*:*)
+ eval $set_cc_for_build
+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep -q __ARM_EABI__
+ then
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ else
+ echo ${UNAME_MACHINE}-unknown-linux-gnueabi
+ fi
+ exit ;;
+ avr32*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ cris:Linux:*:*)
+ echo cris-axis-linux-gnu
+ exit ;;
+ crisv32:Linux:*:*)
+ echo crisv32-axis-linux-gnu
+ exit ;;
+ frv:Linux:*:*)
+ echo frv-unknown-linux-gnu
+ exit ;;
+ ia64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m32r*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ m68*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ mips:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips
+ #undef mipsel
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mipsel
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ mips64:Linux:*:*)
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #undef CPU
+ #undef mips64
+ #undef mips64el
+ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+ CPU=mips64el
+ #else
+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+ CPU=mips64
+ #else
+ CPU=
+ #endif
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^CPU/{
+ s: ::g
+ p
+ }'`"
+ test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+ ;;
+ or32:Linux:*:*)
+ echo or32-unknown-linux-gnu
+ exit ;;
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
+ exit ;;
+ ppc64:Linux:*:*)
+ echo powerpc64-unknown-linux-gnu
+ exit ;;
+ alpha:Linux:*:*)
+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+ EV5) UNAME_MACHINE=alphaev5 ;;
+ EV56) UNAME_MACHINE=alphaev56 ;;
+ PCA56) UNAME_MACHINE=alphapca56 ;;
+ PCA57) UNAME_MACHINE=alphapca56 ;;
+ EV6) UNAME_MACHINE=alphaev6 ;;
+ EV67) UNAME_MACHINE=alphaev67 ;;
+ EV68*) UNAME_MACHINE=alphaev68 ;;
+ esac
+ objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+ if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+ echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+ exit ;;
+ parisc:Linux:*:* | hppa:Linux:*:*)
+ # Look for CPU level
+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+ PA7*) echo hppa1.1-unknown-linux-gnu ;;
+ PA8*) echo hppa2.0-unknown-linux-gnu ;;
+ *) echo hppa-unknown-linux-gnu ;;
+ esac
+ exit ;;
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
+ exit ;;
+ s390:Linux:*:* | s390x:Linux:*:*)
+ echo ${UNAME_MACHINE}-ibm-linux
+ exit ;;
+ sh64*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sh*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ sparc:Linux:*:* | sparc64:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ vax:Linux:*:*)
+ echo ${UNAME_MACHINE}-dec-linux-gnu
+ exit ;;
+ x86_64:Linux:*:*)
+ echo x86_64-unknown-linux-gnu
+ exit ;;
+ xtensa*:Linux:*:*)
+ echo ${UNAME_MACHINE}-unknown-linux-gnu
+ exit ;;
+ i*86:Linux:*:*)
+ # The BFD linker knows what the default object file format is, so
+ # first see if it will tell us. cd to the root directory to prevent
+ # problems with other programs or directories called `ld' in the path.
+ # Set LC_ALL=C to ensure ld outputs messages in English.
+ ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+ | sed -ne '/supported targets:/!d
+ s/[ ][ ]*/ /g
+ s/.*supported targets: *//
+ s/ .*//
+ p'`
+ case "$ld_supported_targets" in
+ elf32-i386)
+ TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+ ;;
+ a.out-i386-linux)
+ echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+ exit ;;
+ coff-i386)
+ echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+ exit ;;
+ "")
+ # Either a pre-BFD a.out linker (linux-gnuoldld) or
+ # one that does not give us useful --help.
+ echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+ exit ;;
+ esac
+ # Determine whether the default compiler is a.out or elf
+ eval $set_cc_for_build
+ sed 's/^ //' << EOF >$dummy.c
+ #include <features.h>
+ #ifdef __ELF__
+ # ifdef __GLIBC__
+ # if __GLIBC__ >= 2
+ LIBC=gnu
+ # else
+ LIBC=gnulibc1
+ # endif
+ # else
+ LIBC=gnulibc1
+ # endif
+ #else
+ #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC)
+ LIBC=gnu
+ #else
+ LIBC=gnuaout
+ #endif
+ #endif
+ #ifdef __dietlibc__
+ LIBC=dietlibc
+ #endif
+EOF
+ eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
+ /^LIBC/{
+ s: ::g
+ p
+ }'`"
+ test x"${LIBC}" != x && {
+ echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+ exit
+ }
+ test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+ ;;
+ i*86:DYNIX/ptx:4*:*)
+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+ # earlier versions are messed up and put the nodename in both
+ # sysname and nodename.
+ echo i386-sequent-sysv4
+ exit ;;
+ i*86:UNIX_SV:4.2MP:2.*)
+ # Unixware is an offshoot of SVR4, but it has its own version
+ # number series starting with 2...
+ # I am not positive that other SVR4 systems won't match this,
+ # I just have to hope. -- rms.
+ # Use sysv4.2uw... so that sysv4* matches it.
+ echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+ exit ;;
+ i*86:OS/2:*:*)
+ # If we were able to find `uname', then EMX Unix compatibility
+ # is probably installed.
+ echo ${UNAME_MACHINE}-pc-os2-emx
+ exit ;;
+ i*86:XTS-300:*:STOP)
+ echo ${UNAME_MACHINE}-unknown-stop
+ exit ;;
+ i*86:atheos:*:*)
+ echo ${UNAME_MACHINE}-unknown-atheos
+ exit ;;
+ i*86:syllable:*:*)
+ echo ${UNAME_MACHINE}-pc-syllable
+ exit ;;
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+ echo i386-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ i*86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit ;;
+ i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+ UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+ echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+ else
+ echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+ fi
+ exit ;;
+ i*86:*:5:[678]*)
+ # UnixWare 7.x, OpenUNIX and OpenServer 6.
+ case `/bin/uname -X | grep "^Machine"` in
+ *486*) UNAME_MACHINE=i486 ;;
+ *Pentium) UNAME_MACHINE=i586 ;;
+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+ esac
+ echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+ exit ;;
+ i*86:*:3.2:*)
+ if test -f /usr/options/cb.name; then
+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+ echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+ elif /bin/uname -X 2>/dev/null >/dev/null ; then
+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+ && UNAME_MACHINE=i586
+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+ && UNAME_MACHINE=i686
+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+ && UNAME_MACHINE=i686
+ echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+ else
+ echo ${UNAME_MACHINE}-pc-sysv32
+ fi
+ exit ;;
+ pc:*:*:*)
+ # Left here for compatibility:
+ # uname -m prints for DJGPP always 'pc', but it prints nothing about
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
+ exit ;;
+ Intel:Mach:3*:*)
+ echo i386-pc-mach3
+ exit ;;
+ paragon:*:*:*)
+ echo i860-intel-osf1
+ exit ;;
+ i860:*:4.*:*) # i860-SVR4
+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+ echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+ else # Add other i860-SVR4 vendors below as they are discovered.
+ echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4
+ fi
+ exit ;;
+ mini*:CTIX:SYS*5:*)
+ # "miniframe"
+ echo m68010-convergent-sysv
+ exit ;;
+ mc68k:UNIX:SYSTEM5:3.51m)
+ echo m68k-convergent-sysv
+ exit ;;
+ M680?0:D-NIX:5.3:*)
+ echo m68k-diab-dnix
+ exit ;;
+ M68*:*:R3V[5678]*:*)
+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+ OS_REL=''
+ test -r /etc/.relid \
+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+ && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+ && { echo i486-ncr-sysv4; exit; } ;;
+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+ echo m68k-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ mc68030:UNIX_System_V:4.*:*)
+ echo m68k-atari-sysv4
+ exit ;;
+ TSUNAMI:LynxOS:2.*:*)
+ echo sparc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ rs6000:LynxOS:2.*:*)
+ echo rs6000-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+ echo powerpc-unknown-lynxos${UNAME_RELEASE}
+ exit ;;
+ SM[BE]S:UNIX_SV:*:*)
+ echo mips-dde-sysv${UNAME_RELEASE}
+ exit ;;
+ RM*:ReliantUNIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ RM*:SINIX-*:*:*)
+ echo mips-sni-sysv4
+ exit ;;
+ *:SINIX-*:*:*)
+ if uname -p 2>/dev/null >/dev/null ; then
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ echo ${UNAME_MACHINE}-sni-sysv4
+ else
+ echo ns32k-sni-sysv
+ fi
+ exit ;;
+ PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+ # says <Richard.M.Bartel@ccMail.Census.GOV>
+ echo i586-unisys-sysv4
+ exit ;;
+ *:UNIX_System_V:4*:FTX*)
+ # From Gerald Hewes <hewes@openmarket.com>.
+ # How about differentiating between stratus architectures? -djm
+ echo hppa1.1-stratus-sysv4
+ exit ;;
+ *:*:*:FTX*)
+ # From seanf@swdc.stratus.com.
+ echo i860-stratus-sysv4
+ exit ;;
+ i*86:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo ${UNAME_MACHINE}-stratus-vos
+ exit ;;
+ *:VOS:*:*)
+ # From Paul.Green@stratus.com.
+ echo hppa1.1-stratus-vos
+ exit ;;
+ mc68*:A/UX:*:*)
+ echo m68k-apple-aux${UNAME_RELEASE}
+ exit ;;
+ news*:NEWS-OS:6*:*)
+ echo mips-sony-newsos6
+ exit ;;
+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+ if [ -d /usr/nec ]; then
+ echo mips-nec-sysv${UNAME_RELEASE}
+ else
+ echo mips-unknown-sysv${UNAME_RELEASE}
+ fi
+ exit ;;
+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
+ echo powerpc-be-beos
+ exit ;;
+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
+ echo powerpc-apple-beos
+ exit ;;
+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.
+ echo i586-pc-beos
+ exit ;;
+ SX-4:SUPER-UX:*:*)
+ echo sx4-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-5:SUPER-UX:*:*)
+ echo sx5-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-6:SUPER-UX:*:*)
+ echo sx6-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-7:SUPER-UX:*:*)
+ echo sx7-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8:SUPER-UX:*:*)
+ echo sx8-nec-superux${UNAME_RELEASE}
+ exit ;;
+ SX-8R:SUPER-UX:*:*)
+ echo sx8r-nec-superux${UNAME_RELEASE}
+ exit ;;
+ Power*:Rhapsody:*:*)
+ echo powerpc-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Rhapsody:*:*)
+ echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+ exit ;;
+ *:Darwin:*:*)
+ UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+ case $UNAME_PROCESSOR in
+ unknown) UNAME_PROCESSOR=powerpc ;;
+ esac
+ echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+ exit ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ UNAME_PROCESSOR=`uname -p`
+ if test "$UNAME_PROCESSOR" = "x86"; then
+ UNAME_PROCESSOR=i386
+ UNAME_MACHINE=pc
+ fi
+ echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+ exit ;;
+ *:QNX:*:4*)
+ echo i386-pc-qnx
+ exit ;;
+ NSE-?:NONSTOP_KERNEL:*:*)
+ echo nse-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ NSR-?:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit ;;
+ *:NonStop-UX:*:*)
+ echo mips-compaq-nonstopux
+ exit ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit ;;
+ *:Plan9:*:*)
+ # "uname -m" is not consistent, so use $cputype instead. 386
+ # is converted to i386 for consistency with other x86
+ # operating systems.
+ if test "$cputype" = "386"; then
+ UNAME_MACHINE=i386
+ else
+ UNAME_MACHINE="$cputype"
+ fi
+ echo ${UNAME_MACHINE}-unknown-plan9
+ exit ;;
+ *:TOPS-10:*:*)
+ echo pdp10-unknown-tops10
+ exit ;;
+ *:TENEX:*:*)
+ echo pdp10-unknown-tenex
+ exit ;;
+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+ echo pdp10-dec-tops20
+ exit ;;
+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+ echo pdp10-xkl-tops20
+ exit ;;
+ *:TOPS-20:*:*)
+ echo pdp10-unknown-tops20
+ exit ;;
+ *:ITS:*:*)
+ echo pdp10-unknown-its
+ exit ;;
+ SEI:*:*:SEIUX)
+ echo mips-sei-seiux${UNAME_RELEASE}
+ exit ;;
+ *:DragonFly:*:*)
+ echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+ exit ;;
+ *:*VMS:*:*)
+ UNAME_MACHINE=`(uname -p) 2>/dev/null`
+ case "${UNAME_MACHINE}" in
+ A*) echo alpha-dec-vms ; exit ;;
+ I*) echo ia64-dec-vms ; exit ;;
+ V*) echo vax-dec-vms ; exit ;;
+ esac ;;
+ *:XENIX:*:SysV)
+ echo i386-pc-xenix
+ exit ;;
+ i*86:skyos:*:*)
+ echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+ exit ;;
+ i*86:rdos:*:*)
+ echo ${UNAME_MACHINE}-pc-rdos
+ exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,
+ I don't know.... */
+ printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+ printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+ "4"
+#else
+ ""
+#endif
+ ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+ printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+ printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+ int version;
+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+ if (version < 4)
+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+ else
+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+ exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+ printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+ printf ("ns32k-encore-mach\n"); exit (0);
+#else
+ printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+ printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+ printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+ printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+ struct utsname un;
+
+ uname(&un);
+
+ if (strncmp(un.version, "V2", 2) == 0) {
+ printf ("i386-sequent-ptx2\n"); exit (0);
+ }
+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+ printf ("i386-sequent-ptx1\n"); exit (0);
+ }
+ printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+# include <sys/param.h>
+# if defined (BSD)
+# if BSD == 43
+ printf ("vax-dec-bsd4.3\n"); exit (0);
+# else
+# if BSD == 199006
+ printf ("vax-dec-bsd4.3reno\n"); exit (0);
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# endif
+# else
+ printf ("vax-dec-bsd\n"); exit (0);
+# endif
+# else
+ printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+ printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+ exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+ { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+ case `getsysinfo -f cpu_type` in
+ c1*)
+ echo c1-convex-bsd
+ exit ;;
+ c2*)
+ if getsysinfo -f scalar_acc
+ then echo c32-convex-bsd
+ else echo c2-convex-bsd
+ fi
+ exit ;;
+ c34*)
+ echo c34-convex-bsd
+ exit ;;
+ c38*)
+ echo c38-convex-bsd
+ exit ;;
+ c4*)
+ echo c4-convex-bsd
+ exit ;;
+ esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+ http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.sub b/config.sub
new file mode 100755
index 0000000..6759825
--- /dev/null
+++ b/config.sub
@@ -0,0 +1,1658 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Free Software Foundation, Inc.
+
+timestamp='2008-01-16'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine. It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>. Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support. The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -t, --time-stamp print date of last modification, then exit
+ -v, --version print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions. There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case $1 in
+ --time-stamp | --time* | -t )
+ echo "$timestamp" ; exit ;;
+ --version | -v )
+ echo "$version" ; exit ;;
+ --help | --h* | -h )
+ echo "$usage"; exit ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ echo "$me: invalid option $1$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit ;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
+ storm-chaos* | os2-emx* | rtmk-nova*)
+ os=-$maybe_os
+ basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+ ;;
+ *)
+ basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+ if [ $basic_machine != $1 ]
+ then os=`echo $1 | sed 's/.*-/-/'`
+ else os=; fi
+ ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work. We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+ -sun*os*)
+ # Prevent following clause from handling this invalid input.
+ ;;
+ -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+ -apple | -axis | -knuth | -cray)
+ os=
+ basic_machine=$1
+ ;;
+ -sim | -cisco | -oki | -wec | -winbond)
+ os=
+ basic_machine=$1
+ ;;
+ -scout)
+ ;;
+ -wrs)
+ os=-vxworks
+ basic_machine=$1
+ ;;
+ -chorusos*)
+ os=-chorusos
+ basic_machine=$1
+ ;;
+ -chorusrdb)
+ os=-chorusrdb
+ basic_machine=$1
+ ;;
+ -hiux*)
+ os=-hiuxwe2
+ ;;
+ -sco6)
+ os=-sco5v6
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5)
+ os=-sco3.2v5
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco4)
+ os=-sco3.2v4
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2.[4-9]*)
+ os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco3.2v[4-9]*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco5v6*)
+ # Don't forget version if it is 3.2v4 or newer.
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -sco*)
+ os=-sco3.2v2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -udk*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -isc)
+ os=-isc2.2
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -clix*)
+ basic_machine=clipper-intergraph
+ ;;
+ -isc*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+ ;;
+ -lynx*)
+ os=-lynxos
+ ;;
+ -ptx*)
+ basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+ ;;
+ -windowsnt*)
+ os=`echo $os | sed -e 's/windowsnt/winnt/'`
+ ;;
+ -psos*)
+ os=-psos
+ ;;
+ -mint | -mint[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+ # Recognize the basic CPU types without company name.
+ # Some are omitted here because they have special meanings below.
+ 1750a | 580 \
+ | a29k \
+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+ | am33_2.0 \
+ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
+ | bfin \
+ | c4x | clipper \
+ | d10v | d30v | dlx | dsp16xx \
+ | fido | fr30 | frv \
+ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+ | i370 | i860 | i960 | ia64 \
+ | ip2k | iq2000 \
+ | m32c | m32r | m32rle | m68000 | m68k | m88k \
+ | maxq | mb | microblaze | mcore | mep \
+ | mips | mipsbe | mipseb | mipsel | mipsle \
+ | mips16 \
+ | mips64 | mips64el \
+ | mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
+ | mips64vr4100 | mips64vr4100el \
+ | mips64vr4300 | mips64vr4300el \
+ | mips64vr5000 | mips64vr5000el \
+ | mips64vr5900 | mips64vr5900el \
+ | mipsisa32 | mipsisa32el \
+ | mipsisa32r2 | mipsisa32r2el \
+ | mipsisa64 | mipsisa64el \
+ | mipsisa64r2 | mipsisa64r2el \
+ | mipsisa64sb1 | mipsisa64sb1el \
+ | mipsisa64sr71k | mipsisa64sr71kel \
+ | mipstx39 | mipstx39el \
+ | mn10200 | mn10300 \
+ | mt \
+ | msp430 \
+ | nios | nios2 \
+ | ns16k | ns32k \
+ | or32 \
+ | pdp10 | pdp11 | pj | pjl \
+ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+ | pyramid \
+ | score \
+ | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh64 | sh64le \
+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
+ | spu | strongarm \
+ | tahoe | thumb | tic4x | tic80 | tron \
+ | v850 | v850e \
+ | we32k \
+ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
+ | z8k)
+ basic_machine=$basic_machine-unknown
+ ;;
+ m6811 | m68hc11 | m6812 | m68hc12)
+ # Motorola 68HC11/12.
+ basic_machine=$basic_machine-unknown
+ os=-none
+ ;;
+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+ ;;
+ ms1)
+ basic_machine=mt-unknown
+ ;;
+
+ # We use `pc' rather than `unknown'
+ # because (1) that's what they normally are, and
+ # (2) the word "unknown" tends to confuse beginning users.
+ i*86 | x86_64)
+ basic_machine=$basic_machine-pc
+ ;;
+ # Object if more than one company name word.
+ *-*-*)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+ # Recognize the basic CPU types with company name.
+ 580-* \
+ | a29k-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
+ | avr-* | avr32-* \
+ | bfin-* | bs2000-* \
+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+ | clipper-* | craynv-* | cydra-* \
+ | d10v-* | d30v-* | dlx-* \
+ | elxsi-* \
+ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
+ | h8300-* | h8500-* \
+ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+ | i*86-* | i860-* | i960-* | ia64-* \
+ | ip2k-* | iq2000-* \
+ | m32c-* | m32r-* | m32rle-* \
+ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
+ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+ | mips16-* \
+ | mips64-* | mips64el-* \
+ | mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
+ | mips64vr4100-* | mips64vr4100el-* \
+ | mips64vr4300-* | mips64vr4300el-* \
+ | mips64vr5000-* | mips64vr5000el-* \
+ | mips64vr5900-* | mips64vr5900el-* \
+ | mipsisa32-* | mipsisa32el-* \
+ | mipsisa32r2-* | mipsisa32r2el-* \
+ | mipsisa64-* | mipsisa64el-* \
+ | mipsisa64r2-* | mipsisa64r2el-* \
+ | mipsisa64sb1-* | mipsisa64sb1el-* \
+ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+ | mipstx39-* | mipstx39el-* \
+ | mmix-* \
+ | mt-* \
+ | msp430-* \
+ | nios-* | nios2-* \
+ | none-* | np1-* | ns16k-* | ns32k-* \
+ | orion-* \
+ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+ | pyramid-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
+ | sparclite-* \
+ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
+ | tahoe-* | thumb-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+ | tron-* \
+ | v850-* | v850e-* | vax-* \
+ | we32k-* \
+ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
+ | xstormy16-* | xtensa*-* \
+ | ymp-* \
+ | z8k-*)
+ ;;
+ # Recognize the basic CPU types without company name, with glob match.
+ xtensa*)
+ basic_machine=$basic_machine-unknown
+ ;;
+ # Recognize the various machine names and aliases which stand
+ # for a CPU type and a company and sometimes even an OS.
+ 386bsd)
+ basic_machine=i386-unknown
+ os=-bsd
+ ;;
+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+ basic_machine=m68000-att
+ ;;
+ 3b*)
+ basic_machine=we32k-att
+ ;;
+ a29khif)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ abacus)
+ basic_machine=abacus-unknown
+ ;;
+ adobe68k)
+ basic_machine=m68010-adobe
+ os=-scout
+ ;;
+ alliant | fx80)
+ basic_machine=fx80-alliant
+ ;;
+ altos | altos3068)
+ basic_machine=m68k-altos
+ ;;
+ am29k)
+ basic_machine=a29k-none
+ os=-bsd
+ ;;
+ amd64)
+ basic_machine=x86_64-pc
+ ;;
+ amd64-*)
+ basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ amdahl)
+ basic_machine=580-amdahl
+ os=-sysv
+ ;;
+ amiga | amiga-*)
+ basic_machine=m68k-unknown
+ ;;
+ amigaos | amigados)
+ basic_machine=m68k-unknown
+ os=-amigaos
+ ;;
+ amigaunix | amix)
+ basic_machine=m68k-unknown
+ os=-sysv4
+ ;;
+ apollo68)
+ basic_machine=m68k-apollo
+ os=-sysv
+ ;;
+ apollo68bsd)
+ basic_machine=m68k-apollo
+ os=-bsd
+ ;;
+ aux)
+ basic_machine=m68k-apple
+ os=-aux
+ ;;
+ balance)
+ basic_machine=ns32k-sequent
+ os=-dynix
+ ;;
+ blackfin)
+ basic_machine=bfin-unknown
+ os=-linux
+ ;;
+ blackfin-*)
+ basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ c90)
+ basic_machine=c90-cray
+ os=-unicos
+ ;;
+ convex-c1)
+ basic_machine=c1-convex
+ os=-bsd
+ ;;
+ convex-c2)
+ basic_machine=c2-convex
+ os=-bsd
+ ;;
+ convex-c32)
+ basic_machine=c32-convex
+ os=-bsd
+ ;;
+ convex-c34)
+ basic_machine=c34-convex
+ os=-bsd
+ ;;
+ convex-c38)
+ basic_machine=c38-convex
+ os=-bsd
+ ;;
+ cray | j90)
+ basic_machine=j90-cray
+ os=-unicos
+ ;;
+ craynv)
+ basic_machine=craynv-cray
+ os=-unicosmp
+ ;;
+ cr16)
+ basic_machine=cr16-unknown
+ os=-elf
+ ;;
+ crds | unos)
+ basic_machine=m68k-crds
+ ;;
+ crisv32 | crisv32-* | etraxfs*)
+ basic_machine=crisv32-axis
+ ;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
+ crx)
+ basic_machine=crx-unknown
+ os=-elf
+ ;;
+ da30 | da30-*)
+ basic_machine=m68k-da30
+ ;;
+ decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+ basic_machine=mips-dec
+ ;;
+ decsystem10* | dec10*)
+ basic_machine=pdp10-dec
+ os=-tops10
+ ;;
+ decsystem20* | dec20*)
+ basic_machine=pdp10-dec
+ os=-tops20
+ ;;
+ delta | 3300 | motorola-3300 | motorola-delta \
+ | 3300-motorola | delta-motorola)
+ basic_machine=m68k-motorola
+ ;;
+ delta88)
+ basic_machine=m88k-motorola
+ os=-sysv3
+ ;;
+ djgpp)
+ basic_machine=i586-pc
+ os=-msdosdjgpp
+ ;;
+ dpx20 | dpx20-*)
+ basic_machine=rs6000-bull
+ os=-bosx
+ ;;
+ dpx2* | dpx2*-bull)
+ basic_machine=m68k-bull
+ os=-sysv3
+ ;;
+ ebmon29k)
+ basic_machine=a29k-amd
+ os=-ebmon
+ ;;
+ elxsi)
+ basic_machine=elxsi-elxsi
+ os=-bsd
+ ;;
+ encore | umax | mmax)
+ basic_machine=ns32k-encore
+ ;;
+ es1800 | OSE68k | ose68k | ose | OSE)
+ basic_machine=m68k-ericsson
+ os=-ose
+ ;;
+ fx2800)
+ basic_machine=i860-alliant
+ ;;
+ genix)
+ basic_machine=ns32k-ns
+ ;;
+ gmicro)
+ basic_machine=tron-gmicro
+ os=-sysv
+ ;;
+ go32)
+ basic_machine=i386-pc
+ os=-go32
+ ;;
+ h3050r* | hiux*)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ h8300hms)
+ basic_machine=h8300-hitachi
+ os=-hms
+ ;;
+ h8300xray)
+ basic_machine=h8300-hitachi
+ os=-xray
+ ;;
+ h8500hms)
+ basic_machine=h8500-hitachi
+ os=-hms
+ ;;
+ harris)
+ basic_machine=m88k-harris
+ os=-sysv3
+ ;;
+ hp300-*)
+ basic_machine=m68k-hp
+ ;;
+ hp300bsd)
+ basic_machine=m68k-hp
+ os=-bsd
+ ;;
+ hp300hpux)
+ basic_machine=m68k-hp
+ os=-hpux
+ ;;
+ hp3k9[0-9][0-9] | hp9[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k2[0-9][0-9] | hp9k31[0-9])
+ basic_machine=m68000-hp
+ ;;
+ hp9k3[2-9][0-9])
+ basic_machine=m68k-hp
+ ;;
+ hp9k6[0-9][0-9] | hp6[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hp9k7[0-79][0-9] | hp7[0-79][0-9])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k78[0-9] | hp78[0-9])
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+ # FIXME: really hppa2.0-hp
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][13679] | hp8[0-9][13679])
+ basic_machine=hppa1.1-hp
+ ;;
+ hp9k8[0-9][0-9] | hp8[0-9][0-9])
+ basic_machine=hppa1.0-hp
+ ;;
+ hppa-next)
+ os=-nextstep3
+ ;;
+ hppaosf)
+ basic_machine=hppa1.1-hp
+ os=-osf
+ ;;
+ hppro)
+ basic_machine=hppa1.1-hp
+ os=-proelf
+ ;;
+ i370-ibm* | ibm*)
+ basic_machine=i370-ibm
+ ;;
+# I'm not sure what "Sysv32" means. Should this be sysv3.2?
+ i*86v32)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv32
+ ;;
+ i*86v4*)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv4
+ ;;
+ i*86v)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-sysv
+ ;;
+ i*86sol2)
+ basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+ os=-solaris2
+ ;;
+ i386mach)
+ basic_machine=i386-mach
+ os=-mach
+ ;;
+ i386-vsta | vsta)
+ basic_machine=i386-unknown
+ os=-vsta
+ ;;
+ iris | iris4d)
+ basic_machine=mips-sgi
+ case $os in
+ -irix*)
+ ;;
+ *)
+ os=-irix4
+ ;;
+ esac
+ ;;
+ isi68 | isi)
+ basic_machine=m68k-isi
+ os=-sysv
+ ;;
+ m68knommu)
+ basic_machine=m68k-unknown
+ os=-linux
+ ;;
+ m68knommu-*)
+ basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ m88k-omron*)
+ basic_machine=m88k-omron
+ ;;
+ magnum | m3230)
+ basic_machine=mips-mips
+ os=-sysv
+ ;;
+ merlin)
+ basic_machine=ns32k-utek
+ os=-sysv
+ ;;
+ mingw32)
+ basic_machine=i386-pc
+ os=-mingw32
+ ;;
+ mingw32ce)
+ basic_machine=arm-unknown
+ os=-mingw32ce
+ ;;
+ miniframe)
+ basic_machine=m68000-convergent
+ ;;
+ *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+ basic_machine=m68k-atari
+ os=-mint
+ ;;
+ mips3*-*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+ ;;
+ mips3*)
+ basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+ ;;
+ monitor)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ morphos)
+ basic_machine=powerpc-unknown
+ os=-morphos
+ ;;
+ msdos)
+ basic_machine=i386-pc
+ os=-msdos
+ ;;
+ ms1-*)
+ basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
+ ;;
+ mvs)
+ basic_machine=i370-ibm
+ os=-mvs
+ ;;
+ ncr3000)
+ basic_machine=i486-ncr
+ os=-sysv4
+ ;;
+ netbsd386)
+ basic_machine=i386-unknown
+ os=-netbsd
+ ;;
+ netwinder)
+ basic_machine=armv4l-rebel
+ os=-linux
+ ;;
+ news | news700 | news800 | news900)
+ basic_machine=m68k-sony
+ os=-newsos
+ ;;
+ news1000)
+ basic_machine=m68030-sony
+ os=-newsos
+ ;;
+ news-3600 | risc-news)
+ basic_machine=mips-sony
+ os=-newsos
+ ;;
+ necv70)
+ basic_machine=v70-nec
+ os=-sysv
+ ;;
+ next | m*-next )
+ basic_machine=m68k-next
+ case $os in
+ -nextstep* )
+ ;;
+ -ns2*)
+ os=-nextstep2
+ ;;
+ *)
+ os=-nextstep3
+ ;;
+ esac
+ ;;
+ nh3000)
+ basic_machine=m68k-harris
+ os=-cxux
+ ;;
+ nh[45]000)
+ basic_machine=m88k-harris
+ os=-cxux
+ ;;
+ nindy960)
+ basic_machine=i960-intel
+ os=-nindy
+ ;;
+ mon960)
+ basic_machine=i960-intel
+ os=-mon960
+ ;;
+ nonstopux)
+ basic_machine=mips-compaq
+ os=-nonstopux
+ ;;
+ np1)
+ basic_machine=np1-gould
+ ;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
+ op50n-* | op60c-*)
+ basic_machine=hppa1.1-oki
+ os=-proelf
+ ;;
+ openrisc | openrisc-*)
+ basic_machine=or32-unknown
+ ;;
+ os400)
+ basic_machine=powerpc-ibm
+ os=-os400
+ ;;
+ OSE68000 | ose68000)
+ basic_machine=m68000-ericsson
+ os=-ose
+ ;;
+ os68k)
+ basic_machine=m68k-none
+ os=-os68k
+ ;;
+ pa-hitachi)
+ basic_machine=hppa1.1-hitachi
+ os=-hiuxwe2
+ ;;
+ paragon)
+ basic_machine=i860-intel
+ os=-osf
+ ;;
+ parisc)
+ basic_machine=hppa-unknown
+ os=-linux
+ ;;
+ parisc-*)
+ basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
+ os=-linux
+ ;;
+ pbd)
+ basic_machine=sparc-tti
+ ;;
+ pbb)
+ basic_machine=m68k-tti
+ ;;
+ pc532 | pc532-*)
+ basic_machine=ns32k-pc532
+ ;;
+ pc98)
+ basic_machine=i386-pc
+ ;;
+ pc98-*)
+ basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium | p5 | k5 | k6 | nexgen | viac3)
+ basic_machine=i586-pc
+ ;;
+ pentiumpro | p6 | 6x86 | athlon | athlon_*)
+ basic_machine=i686-pc
+ ;;
+ pentiumii | pentium2 | pentiumiii | pentium3)
+ basic_machine=i686-pc
+ ;;
+ pentium4)
+ basic_machine=i786-pc
+ ;;
+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+ basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+ basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pentium4-*)
+ basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ pn)
+ basic_machine=pn-gould
+ ;;
+ power) basic_machine=power-ibm
+ ;;
+ ppc) basic_machine=powerpc-unknown
+ ;;
+ ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppcle | powerpclittle | ppc-le | powerpc-little)
+ basic_machine=powerpcle-unknown
+ ;;
+ ppcle-* | powerpclittle-*)
+ basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64) basic_machine=powerpc64-unknown
+ ;;
+ ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+ basic_machine=powerpc64le-unknown
+ ;;
+ ppc64le-* | powerpc64little-*)
+ basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+ ;;
+ ps2)
+ basic_machine=i386-ibm
+ ;;
+ pw32)
+ basic_machine=i586-unknown
+ os=-pw32
+ ;;
+ rdos)
+ basic_machine=i386-pc
+ os=-rdos
+ ;;
+ rom68k)
+ basic_machine=m68k-rom68k
+ os=-coff
+ ;;
+ rm[46]00)
+ basic_machine=mips-siemens
+ ;;
+ rtpc | rtpc-*)
+ basic_machine=romp-ibm
+ ;;
+ s390 | s390-*)
+ basic_machine=s390-ibm
+ ;;
+ s390x | s390x-*)
+ basic_machine=s390x-ibm
+ ;;
+ sa29200)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ sb1)
+ basic_machine=mipsisa64sb1-unknown
+ ;;
+ sb1el)
+ basic_machine=mipsisa64sb1el-unknown
+ ;;
+ sde)
+ basic_machine=mipsisa32-sde
+ os=-elf
+ ;;
+ sei)
+ basic_machine=mips-sei
+ os=-seiux
+ ;;
+ sequent)
+ basic_machine=i386-sequent
+ ;;
+ sh)
+ basic_machine=sh-hitachi
+ os=-hms
+ ;;
+ sh5el)
+ basic_machine=sh5le-unknown
+ ;;
+ sh64)
+ basic_machine=sh64-unknown
+ ;;
+ sparclite-wrs | simso-wrs)
+ basic_machine=sparclite-wrs
+ os=-vxworks
+ ;;
+ sps7)
+ basic_machine=m68k-bull
+ os=-sysv2
+ ;;
+ spur)
+ basic_machine=spur-unknown
+ ;;
+ st2000)
+ basic_machine=m68k-tandem
+ ;;
+ stratus)
+ basic_machine=i860-stratus
+ os=-sysv4
+ ;;
+ sun2)
+ basic_machine=m68000-sun
+ ;;
+ sun2os3)
+ basic_machine=m68000-sun
+ os=-sunos3
+ ;;
+ sun2os4)
+ basic_machine=m68000-sun
+ os=-sunos4
+ ;;
+ sun3os3)
+ basic_machine=m68k-sun
+ os=-sunos3
+ ;;
+ sun3os4)
+ basic_machine=m68k-sun
+ os=-sunos4
+ ;;
+ sun4os3)
+ basic_machine=sparc-sun
+ os=-sunos3
+ ;;
+ sun4os4)
+ basic_machine=sparc-sun
+ os=-sunos4
+ ;;
+ sun4sol2)
+ basic_machine=sparc-sun
+ os=-solaris2
+ ;;
+ sun3 | sun3-*)
+ basic_machine=m68k-sun
+ ;;
+ sun4)
+ basic_machine=sparc-sun
+ ;;
+ sun386 | sun386i | roadrunner)
+ basic_machine=i386-sun
+ ;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
+ symmetry)
+ basic_machine=i386-sequent
+ os=-dynix
+ ;;
+ t3e)
+ basic_machine=alphaev5-cray
+ os=-unicos
+ ;;
+ t90)
+ basic_machine=t90-cray
+ os=-unicos
+ ;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
+ tic55x | c55x*)
+ basic_machine=tic55x-unknown
+ os=-coff
+ ;;
+ tic6x | c6x*)
+ basic_machine=tic6x-unknown
+ os=-coff
+ ;;
+ tile*)
+ basic_machine=tile-unknown
+ os=-linux-gnu
+ ;;
+ tx39)
+ basic_machine=mipstx39-unknown
+ ;;
+ tx39el)
+ basic_machine=mipstx39el-unknown
+ ;;
+ toad1)
+ basic_machine=pdp10-xkl
+ os=-tops20
+ ;;
+ tower | tower-32)
+ basic_machine=m68k-ncr
+ ;;
+ tpf)
+ basic_machine=s390x-ibm
+ os=-tpf
+ ;;
+ udi29k)
+ basic_machine=a29k-amd
+ os=-udi
+ ;;
+ ultra3)
+ basic_machine=a29k-nyu
+ os=-sym1
+ ;;
+ v810 | necv810)
+ basic_machine=v810-nec
+ os=-none
+ ;;
+ vaxv)
+ basic_machine=vax-dec
+ os=-sysv
+ ;;
+ vms)
+ basic_machine=vax-dec
+ os=-vms
+ ;;
+ vpp*|vx|vx-*)
+ basic_machine=f301-fujitsu
+ ;;
+ vxworks960)
+ basic_machine=i960-wrs
+ os=-vxworks
+ ;;
+ vxworks68)
+ basic_machine=m68k-wrs
+ os=-vxworks
+ ;;
+ vxworks29k)
+ basic_machine=a29k-wrs
+ os=-vxworks
+ ;;
+ w65*)
+ basic_machine=w65-wdc
+ os=-none
+ ;;
+ w89k-*)
+ basic_machine=hppa1.1-winbond
+ os=-proelf
+ ;;
+ xbox)
+ basic_machine=i686-pc
+ os=-mingw32
+ ;;
+ xps | xps100)
+ basic_machine=xps100-honeywell
+ ;;
+ ymp)
+ basic_machine=ymp-cray
+ os=-unicos
+ ;;
+ z8k-*-coff)
+ basic_machine=z8k-unknown
+ os=-sim
+ ;;
+ none)
+ basic_machine=none-none
+ os=-none
+ ;;
+
+# Here we handle the default manufacturer of certain CPU types. It is in
+# some cases the only manufacturer, in others, it is the most popular.
+ w89k)
+ basic_machine=hppa1.1-winbond
+ ;;
+ op50n)
+ basic_machine=hppa1.1-oki
+ ;;
+ op60c)
+ basic_machine=hppa1.1-oki
+ ;;
+ romp)
+ basic_machine=romp-ibm
+ ;;
+ mmix)
+ basic_machine=mmix-knuth
+ ;;
+ rs6000)
+ basic_machine=rs6000-ibm
+ ;;
+ vax)
+ basic_machine=vax-dec
+ ;;
+ pdp10)
+ # there are many clones, so DEC is not a safe bet
+ basic_machine=pdp10-unknown
+ ;;
+ pdp11)
+ basic_machine=pdp11-dec
+ ;;
+ we32k)
+ basic_machine=we32k-att
+ ;;
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+ basic_machine=sh-unknown
+ ;;
+ sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
+ basic_machine=sparc-sun
+ ;;
+ cydra)
+ basic_machine=cydra-cydrome
+ ;;
+ orion)
+ basic_machine=orion-highlevel
+ ;;
+ orion105)
+ basic_machine=clipper-highlevel
+ ;;
+ mac | mpw | mac-mpw)
+ basic_machine=m68k-apple
+ ;;
+ pmac | pmac-mpw)
+ basic_machine=powerpc-apple
+ ;;
+ *-unknown)
+ # Make sure to match an already-canonicalized machine name.
+ ;;
+ *)
+ echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+ *-digital*)
+ basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+ ;;
+ *-commodore*)
+ basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+ ;;
+ *)
+ ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+ # First match some system type aliases
+ # that might get confused with valid system types.
+ # -solaris* is a basic system type, with this one exception.
+ -solaris1 | -solaris1.*)
+ os=`echo $os | sed -e 's|solaris1|sunos4|'`
+ ;;
+ -solaris)
+ os=-solaris2
+ ;;
+ -svr4*)
+ os=-sysv4
+ ;;
+ -unixware*)
+ os=-sysv4.2uw
+ ;;
+ -gnu/linux*)
+ os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+ ;;
+ # First accept the basic system types.
+ # The portable systems comes first.
+ # Each alternative MUST END IN A *, to match a version number.
+ # -sysv* is not here because it comes later, after sysvr4.
+ -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+ | -aos* \
+ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
+ | -openbsd* | -solidbsd* \
+ | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+ | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+ | -chorusos* | -chorusrdb* \
+ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
+ | -uxpv* | -beos* | -mpeix* | -udk* \
+ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
+ # Remember, each alternative MUST END IN *, to match a version number.
+ ;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i*86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto-qnx*)
+ ;;
+ -nto*)
+ os=`echo $os | sed -e 's|nto|nto-qnx|'`
+ ;;
+ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+ ;;
+ -mac*)
+ os=`echo $os | sed -e 's|mac|macos|'`
+ ;;
+ -linux-dietlibc)
+ os=-linux-dietlibc
+ ;;
+ -linux*)
+ os=`echo $os | sed -e 's|linux|linux-gnu|'`
+ ;;
+ -sunos5*)
+ os=`echo $os | sed -e 's|sunos5|solaris2|'`
+ ;;
+ -sunos6*)
+ os=`echo $os | sed -e 's|sunos6|solaris3|'`
+ ;;
+ -opened*)
+ os=-openedition
+ ;;
+ -os400*)
+ os=-os400
+ ;;
+ -wince*)
+ os=-wince
+ ;;
+ -osfrose*)
+ os=-osfrose
+ ;;
+ -osf*)
+ os=-osf
+ ;;
+ -utek*)
+ os=-bsd
+ ;;
+ -dynix*)
+ os=-bsd
+ ;;
+ -acis*)
+ os=-aos
+ ;;
+ -atheos*)
+ os=-atheos
+ ;;
+ -syllable*)
+ os=-syllable
+ ;;
+ -386bsd)
+ os=-bsd
+ ;;
+ -ctix* | -uts*)
+ os=-sysv
+ ;;
+ -nova*)
+ os=-rtmk-nova
+ ;;
+ -ns2 )
+ os=-nextstep2
+ ;;
+ -nsk*)
+ os=-nsk
+ ;;
+ # Preserve the version number of sinix5.
+ -sinix5.*)
+ os=`echo $os | sed -e 's|sinix|sysv|'`
+ ;;
+ -sinix*)
+ os=-sysv4
+ ;;
+ -tpf*)
+ os=-tpf
+ ;;
+ -triton*)
+ os=-sysv3
+ ;;
+ -oss*)
+ os=-sysv3
+ ;;
+ -svr4)
+ os=-sysv4
+ ;;
+ -svr3)
+ os=-sysv3
+ ;;
+ -sysvr4)
+ os=-sysv4
+ ;;
+ # This must come after -sysvr4.
+ -sysv*)
+ ;;
+ -ose*)
+ os=-ose
+ ;;
+ -es1800*)
+ os=-ose
+ ;;
+ -xenix)
+ os=-xenix
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ os=-mint
+ ;;
+ -aros*)
+ os=-aros
+ ;;
+ -kaos*)
+ os=-kaos
+ ;;
+ -zvmoe)
+ os=-zvmoe
+ ;;
+ -none)
+ ;;
+ *)
+ # Get rid of the `-' at the beginning of $os.
+ os=`echo $os | sed 's/[^-]*-//'`
+ echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+ exit 1
+ ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system. Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+ score-*)
+ os=-elf
+ ;;
+ spu-*)
+ os=-elf
+ ;;
+ *-acorn)
+ os=-riscix1.2
+ ;;
+ arm*-rebel)
+ os=-linux
+ ;;
+ arm*-semi)
+ os=-aout
+ ;;
+ c4x-* | tic4x-*)
+ os=-coff
+ ;;
+ # This must come before the *-dec entry.
+ pdp10-*)
+ os=-tops20
+ ;;
+ pdp11-*)
+ os=-none
+ ;;
+ *-dec | vax-*)
+ os=-ultrix4.2
+ ;;
+ m68*-apollo)
+ os=-domain
+ ;;
+ i386-sun)
+ os=-sunos4.0.2
+ ;;
+ m68000-sun)
+ os=-sunos3
+ # This also exists in the configure program, but was not the
+ # default.
+ # os=-sunos4
+ ;;
+ m68*-cisco)
+ os=-aout
+ ;;
+ mep-*)
+ os=-elf
+ ;;
+ mips*-cisco)
+ os=-elf
+ ;;
+ mips*-*)
+ os=-elf
+ ;;
+ or32-*)
+ os=-coff
+ ;;
+ *-tti) # must be before sparc entry or we get the wrong os.
+ os=-sysv3
+ ;;
+ sparc-* | *-sun)
+ os=-sunos4.1.1
+ ;;
+ *-be)
+ os=-beos
+ ;;
+ *-haiku)
+ os=-haiku
+ ;;
+ *-ibm)
+ os=-aix
+ ;;
+ *-knuth)
+ os=-mmixware
+ ;;
+ *-wec)
+ os=-proelf
+ ;;
+ *-winbond)
+ os=-proelf
+ ;;
+ *-oki)
+ os=-proelf
+ ;;
+ *-hp)
+ os=-hpux
+ ;;
+ *-hitachi)
+ os=-hiux
+ ;;
+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+ os=-sysv
+ ;;
+ *-cbm)
+ os=-amigaos
+ ;;
+ *-dg)
+ os=-dgux
+ ;;
+ *-dolphin)
+ os=-sysv3
+ ;;
+ m68k-ccur)
+ os=-rtu
+ ;;
+ m88k-omron*)
+ os=-luna
+ ;;
+ *-next )
+ os=-nextstep
+ ;;
+ *-sequent)
+ os=-ptx
+ ;;
+ *-crds)
+ os=-unos
+ ;;
+ *-ns)
+ os=-genix
+ ;;
+ i370-*)
+ os=-mvs
+ ;;
+ *-next)
+ os=-nextstep3
+ ;;
+ *-gould)
+ os=-sysv
+ ;;
+ *-highlevel)
+ os=-bsd
+ ;;
+ *-encore)
+ os=-bsd
+ ;;
+ *-sgi)
+ os=-irix
+ ;;
+ *-siemens)
+ os=-sysv4
+ ;;
+ *-masscomp)
+ os=-rtu
+ ;;
+ f30[01]-fujitsu | f700-fujitsu)
+ os=-uxpv
+ ;;
+ *-rom68k)
+ os=-coff
+ ;;
+ *-*bug)
+ os=-coff
+ ;;
+ *-apple)
+ os=-macos
+ ;;
+ *-atari*)
+ os=-mint
+ ;;
+ *)
+ os=-none
+ ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer. We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+ *-unknown)
+ case $os in
+ -riscix*)
+ vendor=acorn
+ ;;
+ -sunos*)
+ vendor=sun
+ ;;
+ -aix*)
+ vendor=ibm
+ ;;
+ -beos*)
+ vendor=be
+ ;;
+ -hpux*)
+ vendor=hp
+ ;;
+ -mpeix*)
+ vendor=hp
+ ;;
+ -hiux*)
+ vendor=hitachi
+ ;;
+ -unos*)
+ vendor=crds
+ ;;
+ -dgux*)
+ vendor=dg
+ ;;
+ -luna*)
+ vendor=omron
+ ;;
+ -genix*)
+ vendor=ns
+ ;;
+ -mvs* | -opened*)
+ vendor=ibm
+ ;;
+ -os400*)
+ vendor=ibm
+ ;;
+ -ptx*)
+ vendor=sequent
+ ;;
+ -tpf*)
+ vendor=ibm
+ ;;
+ -vxsim* | -vxworks* | -windiss*)
+ vendor=wrs
+ ;;
+ -aux*)
+ vendor=apple
+ ;;
+ -hms*)
+ vendor=hitachi
+ ;;
+ -mpw* | -macos*)
+ vendor=apple
+ ;;
+ -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+ vendor=atari
+ ;;
+ -vos*)
+ vendor=stratus
+ ;;
+ esac
+ basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+ ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755
index 0000000..a7f08c4
--- /dev/null
+++ b/configure
@@ -0,0 +1,18969 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.69 for ctemplate 2.3.
+#
+# Report bugs to <google-ctemplate@googlegroups.com>.
+#
+#
+# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Use a proper internal environment variable to ensure we don't fall
+ # into an infinite loop, continuously re-executing ourselves.
+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then
+ _as_can_reexec=no; export _as_can_reexec;
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+as_fn_exit 255
+ fi
+ # We don't want this to propagate to other subprocesses.
+ { _as_can_reexec=; unset _as_can_reexec;}
+if test "x$CONFIG_SHELL" = x; then
+ as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+"
+ as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+ exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1
+test -x / || exit 1"
+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+ if (eval "$as_required") 2>/dev/null; then :
+ as_have_required=yes
+else
+ as_have_required=no
+fi
+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ as_found=:
+ case $as_dir in #(
+ /*)
+ for as_base in sh bash ksh sh5; do
+ # Try only shells that exist, to save several forks.
+ as_shell=$as_dir/$as_base
+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ CONFIG_SHELL=$as_shell as_have_required=yes
+ if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+ break 2
+fi
+fi
+ done;;
+ esac
+ as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+ { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+ CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+ if test "x$CONFIG_SHELL" != x; then :
+ export CONFIG_SHELL
+ # We cannot yet assume a decent shell, so we have to provide a
+# neutralization value for shells without unset; and this also
+# works around shells that cannot unset nonexistent variables.
+# Preserve -v and -x to the replacement shell.
+BASH_ENV=/dev/null
+ENV=/dev/null
+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+case $- in # ((((
+ *v*x* | *x*v* ) as_opts=-vx ;;
+ *v* ) as_opts=-v ;;
+ *x* ) as_opts=-x ;;
+ * ) as_opts= ;;
+esac
+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}
+# Admittedly, this is quite paranoid, since all the known shells bail
+# out after a failed `exec'.
+$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2
+exit 255
+fi
+
+ if test x$as_have_required = xno; then :
+ $as_echo "$0: This script requires a shell more modern than all"
+ $as_echo "$0: the shells that I found on your system."
+ if test x${ZSH_VERSION+set} = xset ; then
+ $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+ $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+ else
+ $as_echo "$0: Please tell bug-autoconf@gnu.org and
+$0: google-ctemplate@googlegroups.com about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+ fi
+ exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+ as_lineno_1=$LINENO as_lineno_1a=$LINENO
+ as_lineno_2=$LINENO as_lineno_2a=$LINENO
+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)
+ sed -n '
+ p
+ /[$]LINENO/=
+ ' <$as_myself |
+ sed '
+ s/[$]LINENO.*/&-/
+ t lineno
+ b
+ :lineno
+ N
+ :loop
+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+ t loop
+ s/-\n.*//
+ ' >$as_me.lineno &&
+ chmod +x "$as_me.lineno" ||
+ { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have
+ # already done that, so ensure we don't try to do so again and fall
+ # in an infinite loop. This has already happened in practice.
+ _as_can_reexec=no; export _as_can_reexec
+ # Don't try to exec as it changes $[0], causing all sort of problems
+ # (the dirname of $[0] is not the place where we might find the
+ # original and so on. Autoconf is especially sensitive to this).
+ . "./$as_me.lineno"
+ # Exit status is that of the last command.
+ exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\$\\$0,'$0','`
+ ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+ # Yippee, $ECHO works!
+ :
+else
+ # Restart under the correct shell.
+ exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<_LT_EOF
+$*
+_LT_EOF
+ exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+ if test "X${echo_test_string+set}" != Xset; then
+ # find a string as large as possible, as long as the shell can cope with it
+ for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+ then
+ break
+ fi
+ done
+ fi
+
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ :
+ else
+ # The Solaris, AIX, and Digital Unix default echo programs unquote
+ # backslashes. This makes it impossible to quote backslashes using
+ # echo "$something" | sed 's/\\/\\\\/g'
+ #
+ # So, first we look for a working echo in the user's PATH.
+
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for dir in $PATH /usr/ucb; do
+ IFS="$lt_save_ifs"
+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$dir/echo"
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ if test "X$ECHO" = Xecho; then
+ # We didn't find a better echo, so look for alternatives.
+ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # This shell has a builtin print -r that does the trick.
+ ECHO='print -r'
+ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+ test "X$CONFIG_SHELL" != X/bin/ksh; then
+ # If we have ksh, try running configure again with it.
+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ export ORIGINAL_CONFIG_SHELL
+ CONFIG_SHELL=/bin/ksh
+ export CONFIG_SHELL
+ exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+ else
+ # Try using printf.
+ ECHO='printf %s\n'
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # Cool, printf works
+ :
+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+ export CONFIG_SHELL
+ SHELL="$CONFIG_SHELL"
+ export SHELL
+ ECHO="$CONFIG_SHELL $0 --fallback-echo"
+ elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$CONFIG_SHELL $0 --fallback-echo"
+ else
+ # maybe with a smaller string...
+ prev=:
+
+ for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+ then
+ break
+ fi
+ prev="$cmd"
+ done
+
+ if test "$prev" != 'sed 50q "$0"'; then
+ echo_test_string=`eval $prev`
+ export echo_test_string
+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+ else
+ # Oops. We lost completely, so just stick with echo.
+ ECHO=echo
+ fi
+ fi
+ fi
+ fi
+ fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+ lt_ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='ctemplate'
+PACKAGE_TARNAME='ctemplate'
+PACKAGE_VERSION='2.3'
+PACKAGE_STRING='ctemplate 2.3'
+PACKAGE_BUGREPORT='google-ctemplate@googlegroups.com'
+PACKAGE_URL=''
+
+ac_unique_file="README"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+ac_htmlparser_namespace
+ac_windows_dllexport
+ac_windows_dllexport_defines
+ac_have_attribute_weak
+ac_cv_have_inttypes_h
+ac_cv_have_stdint_h
+ac_cv_uint64
+ac_google_attribute
+ac_cv_cxx_hash_set_class
+ac_cv_cxx_hash_map_class
+ac_cv_cxx_hash_set
+ac_cv_cxx_hash_map
+ac_google_end_namespace
+ac_google_start_namespace
+ac_google_namespace
+PTHREAD_CFLAGS
+PTHREAD_LIBS
+PTHREAD_CC
+acx_pthread_config
+SO_VERSION
+LIBTOOL_DEPS
+CXXCPP
+OTOOL64
+OTOOL
+LIPO
+NMEDIT
+DSYMUTIL
+lt_ECHO
+RANLIB
+AR
+OBJDUMP
+LN_S
+NM
+ac_ct_DUMPBIN
+DUMPBIN
+LD
+FGREP
+EGREP
+GREP
+SED
+LIBTOOL
+MINGW_FALSE
+MINGW_TRUE
+GCC_FALSE
+GCC_TRUE
+CPP
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+ac_ct_CC
+CFLAGS
+CC
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+am__nodep
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CXX
+CPPFLAGS
+LDFLAGS
+CXXFLAGS
+CXX
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+AM_BACKSLASH
+AM_DEFAULT_VERBOSITY
+AM_DEFAULT_V
+AM_V
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_silent_rules
+enable_dependency_tracking
+enable_fast_install
+enable_shared
+enable_static
+with_pic
+with_gnu_ld
+enable_libtool_lock
+enable_namespace
+'
+ ac_precious_vars='build_alias
+host_alias
+target_alias
+CXX
+CXXFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CCC
+CC
+CFLAGS
+CPP
+CXXCPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+ # If the previous option needs an argument, assign it.
+ if test -n "$ac_prev"; then
+ eval $ac_prev=\$ac_option
+ ac_prev=
+ continue
+ fi
+
+ case $ac_option in
+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+ *=) ac_optarg= ;;
+ *) ac_optarg=yes ;;
+ esac
+
+ # Accept the important Cygnus configure options, so we can diagnose typos.
+
+ case $ac_dashdash$ac_option in
+ --)
+ ac_dashdash=yes ;;
+
+ -bindir | --bindir | --bindi | --bind | --bin | --bi)
+ ac_prev=bindir ;;
+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+ bindir=$ac_optarg ;;
+
+ -build | --build | --buil | --bui | --bu)
+ ac_prev=build_alias ;;
+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+ build_alias=$ac_optarg ;;
+
+ -cache-file | --cache-file | --cache-fil | --cache-fi \
+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+ ac_prev=cache_file ;;
+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+ cache_file=$ac_optarg ;;
+
+ --config-cache | -C)
+ cache_file=config.cache ;;
+
+ -datadir | --datadir | --datadi | --datad)
+ ac_prev=datadir ;;
+ -datadir=* | --datadir=* | --datadi=* | --datad=*)
+ datadir=$ac_optarg ;;
+
+ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+ | --dataroo | --dataro | --datar)
+ ac_prev=datarootdir ;;
+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+ datarootdir=$ac_optarg ;;
+
+ -disable-* | --disable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=no ;;
+
+ -docdir | --docdir | --docdi | --doc | --do)
+ ac_prev=docdir ;;
+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+ docdir=$ac_optarg ;;
+
+ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+ ac_prev=dvidir ;;
+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+ dvidir=$ac_optarg ;;
+
+ -enable-* | --enable-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid feature name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"enable_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval enable_$ac_useropt=\$ac_optarg ;;
+
+ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+ | --exec | --exe | --ex)
+ ac_prev=exec_prefix ;;
+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+ | --exec=* | --exe=* | --ex=*)
+ exec_prefix=$ac_optarg ;;
+
+ -gas | --gas | --ga | --g)
+ # Obsolete; use --with-gas.
+ with_gas=yes ;;
+
+ -help | --help | --hel | --he | -h)
+ ac_init_help=long ;;
+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+ ac_init_help=recursive ;;
+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+ ac_init_help=short ;;
+
+ -host | --host | --hos | --ho)
+ ac_prev=host_alias ;;
+ -host=* | --host=* | --hos=* | --ho=*)
+ host_alias=$ac_optarg ;;
+
+ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+ ac_prev=htmldir ;;
+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+ | --ht=*)
+ htmldir=$ac_optarg ;;
+
+ -includedir | --includedir | --includedi | --included | --include \
+ | --includ | --inclu | --incl | --inc)
+ ac_prev=includedir ;;
+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+ | --includ=* | --inclu=* | --incl=* | --inc=*)
+ includedir=$ac_optarg ;;
+
+ -infodir | --infodir | --infodi | --infod | --info | --inf)
+ ac_prev=infodir ;;
+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+ infodir=$ac_optarg ;;
+
+ -libdir | --libdir | --libdi | --libd)
+ ac_prev=libdir ;;
+ -libdir=* | --libdir=* | --libdi=* | --libd=*)
+ libdir=$ac_optarg ;;
+
+ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+ | --libexe | --libex | --libe)
+ ac_prev=libexecdir ;;
+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+ | --libexe=* | --libex=* | --libe=*)
+ libexecdir=$ac_optarg ;;
+
+ -localedir | --localedir | --localedi | --localed | --locale)
+ ac_prev=localedir ;;
+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+ localedir=$ac_optarg ;;
+
+ -localstatedir | --localstatedir | --localstatedi | --localstated \
+ | --localstate | --localstat | --localsta | --localst | --locals)
+ ac_prev=localstatedir ;;
+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+ localstatedir=$ac_optarg ;;
+
+ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+ ac_prev=mandir ;;
+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+ mandir=$ac_optarg ;;
+
+ -nfp | --nfp | --nf)
+ # Obsolete; use --without-fp.
+ with_fp=no ;;
+
+ -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+ | --no-cr | --no-c | -n)
+ no_create=yes ;;
+
+ -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+ no_recursion=yes ;;
+
+ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+ | --oldin | --oldi | --old | --ol | --o)
+ ac_prev=oldincludedir ;;
+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+ oldincludedir=$ac_optarg ;;
+
+ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+ ac_prev=prefix ;;
+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+ prefix=$ac_optarg ;;
+
+ -program-prefix | --program-prefix | --program-prefi | --program-pref \
+ | --program-pre | --program-pr | --program-p)
+ ac_prev=program_prefix ;;
+ -program-prefix=* | --program-prefix=* | --program-prefi=* \
+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+ program_prefix=$ac_optarg ;;
+
+ -program-suffix | --program-suffix | --program-suffi | --program-suff \
+ | --program-suf | --program-su | --program-s)
+ ac_prev=program_suffix ;;
+ -program-suffix=* | --program-suffix=* | --program-suffi=* \
+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+ program_suffix=$ac_optarg ;;
+
+ -program-transform-name | --program-transform-name \
+ | --program-transform-nam | --program-transform-na \
+ | --program-transform-n | --program-transform- \
+ | --program-transform | --program-transfor \
+ | --program-transfo | --program-transf \
+ | --program-trans | --program-tran \
+ | --progr-tra | --program-tr | --program-t)
+ ac_prev=program_transform_name ;;
+ -program-transform-name=* | --program-transform-name=* \
+ | --program-transform-nam=* | --program-transform-na=* \
+ | --program-transform-n=* | --program-transform-=* \
+ | --program-transform=* | --program-transfor=* \
+ | --program-transfo=* | --program-transf=* \
+ | --program-trans=* | --program-tran=* \
+ | --progr-tra=* | --program-tr=* | --program-t=*)
+ program_transform_name=$ac_optarg ;;
+
+ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+ ac_prev=pdfdir ;;
+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+ pdfdir=$ac_optarg ;;
+
+ -psdir | --psdir | --psdi | --psd | --ps)
+ ac_prev=psdir ;;
+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+ psdir=$ac_optarg ;;
+
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ silent=yes ;;
+
+ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+ ac_prev=sbindir ;;
+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+ | --sbi=* | --sb=*)
+ sbindir=$ac_optarg ;;
+
+ -sharedstatedir | --sharedstatedir | --sharedstatedi \
+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+ | --sharedst | --shareds | --shared | --share | --shar \
+ | --sha | --sh)
+ ac_prev=sharedstatedir ;;
+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+ | --sha=* | --sh=*)
+ sharedstatedir=$ac_optarg ;;
+
+ -site | --site | --sit)
+ ac_prev=site ;;
+ -site=* | --site=* | --sit=*)
+ site=$ac_optarg ;;
+
+ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+ ac_prev=srcdir ;;
+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+ srcdir=$ac_optarg ;;
+
+ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+ | --syscon | --sysco | --sysc | --sys | --sy)
+ ac_prev=sysconfdir ;;
+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+ sysconfdir=$ac_optarg ;;
+
+ -target | --target | --targe | --targ | --tar | --ta | --t)
+ ac_prev=target_alias ;;
+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+ target_alias=$ac_optarg ;;
+
+ -v | -verbose | --verbose | --verbos | --verbo | --verb)
+ verbose=yes ;;
+
+ -version | --version | --versio | --versi | --vers | -V)
+ ac_init_version=: ;;
+
+ -with-* | --with-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=\$ac_optarg ;;
+
+ -without-* | --without-*)
+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+ # Reject names that are not valid shell variable names.
+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+ as_fn_error $? "invalid package name: $ac_useropt"
+ ac_useropt_orig=$ac_useropt
+ ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+ case $ac_user_opts in
+ *"
+"with_$ac_useropt"
+"*) ;;
+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+ ac_unrecognized_sep=', ';;
+ esac
+ eval with_$ac_useropt=no ;;
+
+ --x)
+ # Obsolete; use --with-x.
+ with_x=yes ;;
+
+ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+ | --x-incl | --x-inc | --x-in | --x-i)
+ ac_prev=x_includes ;;
+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+ x_includes=$ac_optarg ;;
+
+ -x-libraries | --x-libraries | --x-librarie | --x-librari \
+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+ ac_prev=x_libraries ;;
+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+ x_libraries=$ac_optarg ;;
+
+ -*) as_fn_error $? "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information"
+ ;;
+
+ *=*)
+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+ # Reject names that are not valid shell variable names.
+ case $ac_envvar in #(
+ '' | [0-9]* | *[!_$as_cr_alnum]* )
+ as_fn_error $? "invalid variable name: \`$ac_envvar'" ;;
+ esac
+ eval $ac_envvar=\$ac_optarg
+ export $ac_envvar ;;
+
+ *)
+ # FIXME: should be removed in autoconf 3.0.
+ $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+ $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"
+ ;;
+
+ esac
+done
+
+if test -n "$ac_prev"; then
+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+ as_fn_error $? "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+ case $enable_option_checking in
+ no) ;;
+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;
+ *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+ esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \
+ datadir sysconfdir sharedstatedir localstatedir includedir \
+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+ libdir localedir mandir
+do
+ eval ac_val=\$$ac_var
+ # Remove trailing slashes.
+ case $ac_val in
+ */ )
+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+ eval $ac_var=\$ac_val;;
+ esac
+ # Be sure to have absolute directory names.
+ case $ac_val in
+ [\\/$]* | ?:[\\/]* ) continue;;
+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+ esac
+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+ if test "x$build_alias" = x; then
+ cross_compiling=maybe
+ elif test "x$build_alias" != "x$host_alias"; then
+ cross_compiling=yes
+ fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+ as_fn_error $? "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+ as_fn_error $? "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+ ac_srcdir_defaulted=yes
+ # Try the directory containing this script, then the parent directory.
+ ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_myself" : 'X\(//\)[^/]' \| \
+ X"$as_myself" : 'X\(//\)$' \| \
+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ srcdir=$ac_confdir
+ if test ! -r "$srcdir/$ac_unique_file"; then
+ srcdir=..
+ fi
+else
+ ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"
+ pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+ srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+ eval ac_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_env_${ac_var}_value=\$${ac_var}
+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+ eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+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 ctemplate 2.3 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE. See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+ -h, --help display this help and exit
+ --help=short display options specific to this package
+ --help=recursive display the short help of all the included packages
+ -V, --version display version information and exit
+ -q, --quiet, --silent do not print \`checking ...' messages
+ --cache-file=FILE cache test results in FILE [disabled]
+ -C, --config-cache alias for \`--cache-file=config.cache'
+ -n, --no-create do not create output files
+ --srcdir=DIR find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+ --prefix=PREFIX install architecture-independent files in PREFIX
+ [$ac_default_prefix]
+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
+ [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+ --bindir=DIR user executables [EPREFIX/bin]
+ --sbindir=DIR system admin executables [EPREFIX/sbin]
+ --libexecdir=DIR program executables [EPREFIX/libexec]
+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]
+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]
+ --libdir=DIR object code libraries [EPREFIX/lib]
+ --includedir=DIR C header files [PREFIX/include]
+ --oldincludedir=DIR C header files for non-gcc [/usr/include]
+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]
+ --infodir=DIR info documentation [DATAROOTDIR/info]
+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]
+ --mandir=DIR man documentation [DATAROOTDIR/man]
+ --docdir=DIR documentation root [DATAROOTDIR/doc/ctemplate]
+ --htmldir=DIR html documentation [DOCDIR]
+ --dvidir=DIR dvi documentation [DOCDIR]
+ --pdfdir=DIR pdf documentation [DOCDIR]
+ --psdir=DIR ps documentation [DOCDIR]
+_ACEOF
+
+ cat <<\_ACEOF
+
+Program names:
+ --program-prefix=PREFIX prepend PREFIX to installed program names
+ --program-suffix=SUFFIX append SUFFIX to installed program names
+ --program-transform-name=PROGRAM run sed PROGRAM on installed program names
+
+System types:
+ --build=BUILD configure for building on BUILD [guessed]
+ --host=HOST cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+ case $ac_init_help in
+ short | recursive ) echo "Configuration of ctemplate 2.3:";;
+ esac
+ cat <<\_ACEOF
+
+Optional Features:
+ --disable-option-checking ignore unrecognized --enable/--with options
+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+ --enable-silent-rules less verbose build output (undo: "make V=1")
+ --disable-silent-rules verbose build output (undo: "make V=0")
+ --enable-dependency-tracking
+ do not reject slow dependency extractors
+ --disable-dependency-tracking
+ speeds up one-time build
+ --enable-fast-install[=PKGS]
+ optimize for fast installation [default=no]
+ --enable-shared[=PKGS] build shared libraries [default=yes]
+ --enable-static[=PKGS] build static libraries [default=yes]
+ --disable-libtool-lock avoid locking (might break parallel builds)
+ --enable-namespace=FOO to define these Google
+ classes in the FOO namespace. --disable-namespace
+ to define them in the global namespace. Default
+ is to define them in namespace ctemplate.
+
+Optional Packages:
+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
+ --with-pic try to use only PIC/non-PIC objects [default=use
+ both]
+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]
+
+Some influential environment variables:
+ CXX C++ compiler command
+ CXXFLAGS C++ compiler flags
+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+ nonstandard directory <lib dir>
+ LIBS libraries to pass to the linker, e.g. -l<library>
+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+ you have headers in a nonstandard directory <include dir>
+ CC C compiler command
+ CFLAGS C compiler flags
+ CPP C preprocessor
+ CXXCPP C++ preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to <google-ctemplate@googlegroups.com>.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+ # If there are subdirs, report their specific --help.
+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+ test -d "$ac_dir" ||
+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+ continue
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+ cd "$ac_dir" || { ac_status=$?; continue; }
+ # Check for guested configure.
+ if test -f "$ac_srcdir/configure.gnu"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+ elif test -f "$ac_srcdir/configure"; then
+ echo &&
+ $SHELL "$ac_srcdir/configure" --help=recursive
+ else
+ $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+ fi || ac_status=$?
+ cd "$ac_pwd" || { ac_status=$?; break; }
+ done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+ cat <<\_ACEOF
+ctemplate configure 2.3
+generated by GNU Autoconf 2.69
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+ exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext
+ if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest.$ac_objext; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_c_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: program exited with status $ac_status" >&5
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=$ac_status
+fi
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+ For example, HP-UX 11i <limits.h> declares gettimeofday. */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char $2 (); below.
+ Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ <limits.h> exists even on freestanding compilers. */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ eval "$3=yes"
+else
+ eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_func
+
+# ac_fn_cxx_try_cpp LINENO
+# ------------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_cpp ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } > conftest.i && {
+ test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_cpp
+
+# ac_fn_cxx_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_link ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ grep -v '^ *+' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ mv -f conftest.er1 conftest.err
+ fi
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && {
+ test -z "$ac_cxx_werror_flag" ||
+ test ! -s conftest.err
+ } && test -s conftest$ac_exeext && {
+ test "$cross_compiling" = yes ||
+ test -x conftest$ac_exeext
+ }; then :
+ ac_retval=0
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+ ac_retval=1
+fi
+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+ # interfere with the next link command; also delete a directory that is
+ # left behind by Apple's compiler. We do this before executing the actions.
+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+ as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_link
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ if eval \${$3+:} false; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+ # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_header_compiler=yes
+else
+ ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ ac_header_preproc=yes
+else
+ ac_header_preproc=no
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So? What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+ yes:no: )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+ ;;
+ no:yes:* )
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+( $as_echo "## ------------------------------------------------ ##
+## Report this to google-ctemplate@googlegroups.com ##
+## ------------------------------------------------ ##"
+ ) | sed "s/^/$as_me: WARNING: /" >&2
+ ;;
+esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if eval \${$3+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ eval "$3=no"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+
+} # ac_fn_c_check_type
+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 ctemplate $as_me 2.3, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`
+
+/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`
+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`
+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ $as_echo "PATH: $as_dir"
+ done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+ for ac_arg
+ do
+ case $ac_arg in
+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil)
+ continue ;;
+ *\'*)
+ ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ case $ac_pass in
+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+ 2)
+ as_fn_append ac_configure_args1 " '$ac_arg'"
+ if test $ac_must_keep_next = true; then
+ ac_must_keep_next=false # Got value, back to normal.
+ else
+ case $ac_arg in
+ *=* | --config-cache | -C | -disable-* | --disable-* \
+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+ | -with-* | --with-* | -without-* | --without-* | --x)
+ case "$ac_configure_args0 " in
+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+ esac
+ ;;
+ -* ) ac_must_keep_next=true ;;
+ esac
+ fi
+ as_fn_append ac_configure_args " '$ac_arg'"
+ ;;
+ esac
+ done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log. We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+ # Save into config.log some information that might help in debugging.
+ {
+ echo
+
+ $as_echo "## ---------------- ##
+## Cache variables. ##
+## ---------------- ##"
+ echo
+ # The following way of writing the cache mishandles newlines in values,
+(
+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+ (set) 2>&1 |
+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ sed -n \
+ "s/'\''/'\''\\\\'\'''\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+ ;; #(
+ *)
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+)
+ echo
+
+ $as_echo "## ----------------- ##
+## Output variables. ##
+## ----------------- ##"
+ echo
+ for ac_var in $ac_subst_vars
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+
+ if test -n "$ac_subst_files"; then
+ $as_echo "## ------------------- ##
+## File substitutions. ##
+## ------------------- ##"
+ echo
+ for ac_var in $ac_subst_files
+ do
+ eval ac_val=\$$ac_var
+ case $ac_val in
+ *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+ esac
+ $as_echo "$ac_var='\''$ac_val'\''"
+ done | sort
+ echo
+ fi
+
+ if test -s confdefs.h; then
+ $as_echo "## ----------- ##
+## confdefs.h. ##
+## ----------- ##"
+ echo
+ cat confdefs.h
+ echo
+ fi
+ test "$ac_signal" != 0 &&
+ $as_echo "$as_me: caught signal $ac_signal"
+ $as_echo "$as_me: exit $exit_status"
+ } >&5
+ rm -f core *.core core.conftest.* &&
+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+ exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+ # We do not want a PATH search for config.site.
+ case $CONFIG_SITE in #((
+ -*) ac_site_file1=./$CONFIG_SITE;;
+ */*) ac_site_file1=$CONFIG_SITE;;
+ *) ac_site_file1=./$CONFIG_SITE;;
+ esac
+elif test "x$prefix" != xNONE; then
+ ac_site_file1=$prefix/share/config.site
+ ac_site_file2=$prefix/etc/config.site
+else
+ ac_site_file1=$ac_default_prefix/share/config.site
+ ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+ test "x$ac_site_file" = xNONE && continue
+ if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+ sed 's/^/| /' "$ac_site_file" >&5
+ . "$ac_site_file" \
+ || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "failed to load site script $ac_site_file
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+done
+
+if test -r "$cache_file"; then
+ # Some versions of bash will fail to source /dev/null (special files
+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.
+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+ case $cache_file in
+ [\\/]* | ?:[\\/]* ) . "$cache_file";;
+ *) . "./$cache_file";;
+ esac
+ fi
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+ >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+ eval ac_old_set=\$ac_cv_env_${ac_var}_set
+ eval ac_new_set=\$ac_env_${ac_var}_set
+ eval ac_old_val=\$ac_cv_env_${ac_var}_value
+ eval ac_new_val=\$ac_env_${ac_var}_value
+ case $ac_old_set,$ac_new_set in
+ set,)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,set)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+ ac_cache_corrupted=: ;;
+ ,);;
+ *)
+ if test "x$ac_old_val" != "x$ac_new_val"; then
+ # differences in whitespace do not lead to failure.
+ ac_old_val_w=`echo x $ac_old_val`
+ ac_new_val_w=`echo x $ac_new_val`
+ if test "$ac_old_val_w" != "$ac_new_val_w"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+ ac_cache_corrupted=:
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+ eval $ac_var=\$ac_old_val
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5
+$as_echo "$as_me: former value: \`$ac_old_val'" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5
+$as_echo "$as_me: current value: \`$ac_new_val'" >&2;}
+ fi;;
+ esac
+ # Pass precious variables to config.status.
+ if test "$ac_new_set" = set; then
+ case $ac_new_val in
+ *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+ *) ac_arg=$ac_var=$ac_new_val ;;
+ esac
+ case " $ac_configure_args " in
+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.
+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+ esac
+ fi
+done
+if $ac_cache_corrupted; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+ as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Check whether --enable-silent-rules was given.
+if test "${enable_silent_rules+set}" = set; then :
+ enableval=$enable_silent_rules;
+fi
+
+case $enable_silent_rules in # (((
+ yes) AM_DEFAULT_VERBOSITY=0;;
+ no) AM_DEFAULT_VERBOSITY=1;;
+ *) AM_DEFAULT_VERBOSITY=0;;
+esac
+am_make=${MAKE-make}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $am_make supports nested variables" >&5
+$as_echo_n "checking whether $am_make supports nested variables... " >&6; }
+if ${am_cv_make_support_nested_variables+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if $as_echo 'TRUE=$(BAR$(V))
+BAR0=false
+BAR1=true
+V=1
+am__doit:
+ @$(TRUE)
+.PHONY: am__doit' | $am_make -f - >/dev/null 2>&1; then
+ am_cv_make_support_nested_variables=yes
+else
+ am_cv_make_support_nested_variables=no
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_make_support_nested_variables" >&5
+$as_echo "$am_cv_make_support_nested_variables" >&6; }
+if test $am_cv_make_support_nested_variables = yes; then
+ AM_V='$(V)'
+ AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)'
+else
+ AM_V=$AM_DEFAULT_VERBOSITY
+ AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY
+fi
+AM_BACKSLASH='\'
+
+
+# Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+SO_VERSION=3:0:0
+
+# The argument here is just something that should be in the current directory
+# (for sanity checking)
+
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+ if test -f "$ac_dir/install-sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install-sh -c"
+ break
+ elif test -f "$ac_dir/install.sh"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/install.sh -c"
+ break
+ elif test -f "$ac_dir/shtool"; then
+ ac_aux_dir=$ac_dir
+ ac_install_sh="$ac_aux_dir/shtool install -c"
+ break
+ fi
+done
+if test -z "$ac_aux_dir"; then
+ as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+ as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if ${ac_cv_build+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+ ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if ${ac_cv_host+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "x$host_alias" = x; then
+ ac_cv_host=$ac_cv_build
+else
+ ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+ as_fn_error $? "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+am__api_version='1.14'
+
+# Find a good install program. We prefer a C program (faster),
+# so one script is as good as another. But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if ${ac_cv_path_install+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+ ./ | .// | /[cC]/* | \
+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+ /usr/ucb/* ) ;;
+ *)
+ # OSF1 and SCO ODT 3.0 have their own names for install.
+ # Don't use installbsd from OSF since it installs stuff as root
+ # by default.
+ for ac_prog in ginstall scoinst install; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then
+ if test $ac_prog = install &&
+ grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # AIX install. It has an incompatible calling convention.
+ :
+ elif test $ac_prog = install &&
+ grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+ # program-specific install script used by HP pwplus--don't use.
+ :
+ else
+ rm -rf conftest.one conftest.two conftest.dir
+ echo one > conftest.one
+ echo two > conftest.two
+ mkdir conftest.dir
+ if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+ test -s conftest.one && test -s conftest.two &&
+ test -s conftest.dir/conftest.one &&
+ test -s conftest.dir/conftest.two
+ then
+ ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+ break 3
+ fi
+ fi
+ fi
+ done
+ done
+ ;;
+esac
+
+ done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+ if test "${ac_cv_path_install+set}" = set; then
+ INSTALL=$ac_cv_path_install
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for INSTALL within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ INSTALL=$ac_install_sh
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name. Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+ *[\\\"\#\$\&\'\`$am_lf]*)
+ as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+ *[\\\"\#\$\&\'\`$am_lf\ \ ]*)
+ as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
+esac
+
+# Do 'set' in a subshell so we don't clobber the current shell's
+# arguments. Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+ am_has_slept=no
+ for am_try in 1 2; do
+ echo "timestamp, slept: $am_has_slept" > conftest.file
+ set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+ if test "$*" = "X"; then
+ # -L didn't work.
+ set X `ls -t "$srcdir/configure" conftest.file`
+ fi
+ if test "$*" != "X $srcdir/configure conftest.file" \
+ && test "$*" != "X conftest.file $srcdir/configure"; then
+
+ # If neither matched, then we have a broken ls. This can happen
+ # if, for instance, CONFIG_SHELL is bash and it inherits a
+ # broken ls alias from the environment. This has actually
+ # happened. Such a system could not be considered "sane".
+ as_fn_error $? "ls -t appears to fail. Make sure there is not a broken
+ alias in your environment" "$LINENO" 5
+ fi
+ if test "$2" = conftest.file || test $am_try -eq 2; then
+ break
+ fi
+ # Just in case.
+ sleep 1
+ am_has_slept=yes
+ done
+ test "$2" = conftest.file
+ )
+then
+ # Ok.
+ :
+else
+ as_fn_error $? "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+# If we didn't sleep, we still need to ensure time stamps of config.status and
+# generated files are strictly newer.
+am_sleep_pid=
+if grep 'slept: no' conftest.file >/dev/null 2>&1; then
+ ( sleep 1 ) &
+ am_sleep_pid=$!
+fi
+
+rm -f conftest.file
+
+test "$program_prefix" != NONE &&
+ program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+ program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# Expand $ac_aux_dir to an absolute path.
+am_aux_dir=`cd "$ac_aux_dir" && pwd`
+
+if test x"${MISSING+set}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+ *)
+ MISSING="\${SHELL} $am_aux_dir/missing" ;;
+ esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --is-lightweight"; then
+ am_missing_run="$MISSING "
+else
+ am_missing_run=
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: 'missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: 'missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+ case $am_aux_dir in
+ *\ * | *\ *)
+ install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+ *)
+ install_sh="\${SHELL} $am_aux_dir/install-sh"
+ esac
+fi
+
+# Installed binaries are usually stripped using 'strip' when the user
+# run "make install-strip". However 'strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the 'STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_STRIP" = x; then
+ STRIP=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ STRIP=$ac_ct_STRIP
+ fi
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+ if ${ac_cv_path_mkdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in mkdir gmkdir; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext" || continue
+ case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+ 'mkdir (GNU coreutils) '* | \
+ 'mkdir (coreutils) '* | \
+ 'mkdir (fileutils) '4.1*)
+ ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+ break 3;;
+ esac
+ done
+ done
+ done
+IFS=$as_save_IFS
+
+fi
+
+ test -d ./--version && rmdir ./--version
+ if test "${ac_cv_path_mkdir+set}" = set; then
+ MKDIR_P="$ac_cv_path_mkdir -p"
+ else
+ # As a last resort, use the slow shell script. Don't cache a
+ # value for MKDIR_P within a source directory, because that will
+ # break other packages using the cache if that directory is
+ # removed, or if the value is a relative name.
+ MKDIR_P="$ac_install_sh -d"
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+for ac_prog in gawk mawk nawk awk
+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:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AWK+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AWK"; then
+ ac_cv_prog_AWK="$AWK" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AWK="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+ @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+ *@@@%%%=?*=@@@%%%*)
+ eval ac_cv_prog_make_${ac_make}_set=yes;;
+ *)
+ eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ SET_MAKE=
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+ am__leading_dot=.
+else
+ am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+ # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+ # is not polluted with repeated "-I."
+ am__isrc=' -I$(srcdir)'
+ # test to see if srcdir already configured
+ if test -f $srcdir/config.status; then
+ as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+ fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+ if (cygpath --version) >/dev/null 2>/dev/null; then
+ CYGPATH_W='cygpath -w'
+ else
+ CYGPATH_W=echo
+ fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='ctemplate'
+ VERSION='2.3'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# For better backward compatibility. To be removed once Automake 1.9.x
+# dies out for good. For more background, see:
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00001.html>
+# <http://lists.gnu.org/archive/html/automake/2012-07/msg00014.html>
+mkdir_p='$(MKDIR_P)'
+
+# We need awk for the "check" target. The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility. Yes, it's still used
+# in the wild :-( We should find a proper way to deprecate it ...
+AMTAR='$${TAR-tar}'
+
+
+# We'll loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar pax cpio none'
+
+am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
+
+
+
+
+
+
+# POSIX will say in a future version that running "rm -f" with no argument
+# is OK; and we want to be able to make that assumption in our Makefile
+# recipes. So use an aggressive probe to check that the usage we want is
+# actually supported "in the wild" to an acceptable degree.
+# See automake bug#10828.
+# To make any issue more visible, cause the running configure to be aborted
+# by default if the 'rm' program in use doesn't match our expectations; the
+# user can still override this though.
+if rm -f && rm -fr && rm -rf; then : OK; else
+ cat >&2 <<'END'
+Oops!
+
+Your 'rm' program seems unable to run without file operands specified
+on the command line, even when the '-f' option is present. This is contrary
+to the behaviour of most rm programs out there, and not conforming with
+the upcoming POSIX standard: <http://austingroupbugs.net/view.php?id=542>
+
+Please tell bug-automake@gnu.org about your system, including the value
+of your $PATH and any error possibly output before this message. This
+can help us improve future automake versions.
+
+END
+ if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then
+ echo 'Configuration will proceed anyway, since you have set the' >&2
+ echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2
+ echo >&2
+ else
+ cat >&2 <<'END'
+Aborting the configuration process, to ensure you take notice of the issue.
+
+You can download and install GNU coreutils to get an 'rm' implementation
+that behaves properly: <http://www.gnu.org/software/coreutils/>.
+
+If you want to complete the configuration process using your problematic
+'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM
+to "yes", and re-run configure.
+
+END
+ as_fn_error $? "Your 'rm' program is bad, sorry." "$LINENO" 5
+ fi
+fi
+
+ac_config_headers="$ac_config_headers src/config.h"
+
+
+# Checks for programs.
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+ if test -n "$CCC"; then
+ CXX=$CCC
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CXX" && break
+ done
+fi
+if test -z "$CXX"; then
+ ac_ct_CXX=$CXX
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+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:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CXX"; then
+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CXX" && break
+done
+
+ if test "x$ac_ct_CXX" = x; then
+ CXX="g++"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CXX=$ac_ct_CXX
+ fi
+fi
+
+ fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C++ compiler works" >&5
+$as_echo_n "checking whether the C++ compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+ esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link_default") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile. We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+ ;;
+ [ab].out )
+ # We found the default executable, but exeext='' is most
+ # certainly right.
+ break;;
+ *.* )
+ if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+ then :; else
+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ fi
+ # We set ac_cv_exeext here because the later test for it is not
+ # safe: cross compilers may not add the suffix if given an `-o'
+ # argument, so we may need to know it at that point already.
+ # Even if this section looks crufty: it has the advantage of
+ # actually working.
+ break;;
+ * )
+ break;;
+ esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+ ac_file=''
+fi
+if test -z "$ac_file"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error 77 "C++ compiler cannot create executables
+See \`config.log' for more details" "$LINENO" 5; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler default output file name" >&5
+$as_echo_n "checking for C++ compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+ test -f "$ac_file" || continue
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+ break;;
+ * ) break;;
+ esac
+done
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+ ;
+ return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run. If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+ { { ac_try="$ac_link"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_link") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ if { ac_try='./conftest$ac_cv_exeext'
+ { { case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_try") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; }; then
+ cross_compiling=no
+ else
+ if test "$cross_compiling" = maybe; then
+ cross_compiling=yes
+ else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot run C++ compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details" "$LINENO" 5; }
+ fi
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if ${ac_cv_objext+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compile") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then :
+ for ac_file in conftest.o conftest.obj conftest.*; do
+ test -f "$ac_file" || continue;
+ case $ac_file in
+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+ break;;
+ esac
+done
+else
+ $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GXX=yes
+else
+ GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ ac_cxx_werror_flag=yes
+ ac_cv_prog_cxx_g=no
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+else
+ CXXFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+ @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from 'make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+ am__include=include
+ am__quote=
+ _am_result=GNU
+ ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+ echo '.include "confinc"' > confmf
+ case `$am_make -s -f confmf 2> /dev/null` in #(
+ *the\ am__doit\ target*)
+ am__include=.include
+ am__quote="\""
+ _am_result=BSD
+ ;;
+ esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+ enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+ am_depcomp="$ac_aux_dir/depcomp"
+ AMDEPBACKSLASH='\'
+ am__nodep='_no'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+ AMDEP_TRUE=
+ AMDEP_FALSE='#'
+else
+ AMDEP_TRUE='#'
+ AMDEP_FALSE=
+fi
+
+
+
+depcc="$CXX" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CXX_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+ case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CXX_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+ am__fastdepCXX_TRUE=
+ am__fastdepCXX_FALSE='#'
+else
+ am__fastdepCXX_TRUE='#'
+ am__fastdepCXX_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+ ac_ct_CC=$CC
+ # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="gcc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+else
+ CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="${ac_tool_prefix}cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ fi
+fi
+if test -z "$CC"; then
+ # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+ ac_prog_rejected=no
+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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+ ac_prog_rejected=yes
+ continue
+ fi
+ ac_cv_prog_CC="cc"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+ # We found a bogon in the path, so make sure we never use it.
+ set dummy $ac_cv_prog_CC
+ shift
+ if test $# != 0; then
+ # We chose a different compiler from the bogus one.
+ # However, it has the same basename, so the bogon will be chosen
+ # first if we set CC to just the basename; use the full file name.
+ shift
+ ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+ fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in cl.exe
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CC"; then
+ ac_cv_prog_CC="$CC" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CC" && break
+ done
+fi
+if test -z "$CC"; then
+ ac_ct_CC=$CC
+ for ac_prog in cl.exe
+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:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CC"; then
+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CC" && break
+done
+
+ if test "x$ac_ct_CC" = x; then
+ CC=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CC=$ac_ct_CC
+ fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "no acceptable C compiler found in \$PATH
+See \`config.log' for more details" "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if ${ac_cv_c_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GCC=yes
+else
+ GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if ${ac_cv_prog_cc_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_c_werror_flag=$ac_c_werror_flag
+ ac_c_werror_flag=yes
+ ac_cv_prog_cc_g=no
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+else
+ CFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+ ac_c_werror_flag=$ac_save_c_werror_flag
+ CFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+ CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+ if test "$GCC" = yes; then
+ CFLAGS="-g -O2"
+ else
+ CFLAGS="-g"
+ fi
+else
+ if test "$GCC" = yes; then
+ CFLAGS="-O2"
+ else
+ CFLAGS=
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if ${ac_cv_prog_cc_c89+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdarg.h>
+#include <stdio.h>
+struct stat;
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+ char **p;
+ int i;
+{
+ return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+ char *s;
+ va_list v;
+ va_start (v,p);
+ s = g (p, va_arg (v,int));
+ va_end (v);
+ return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has
+ function prototypes and stuff, but not '\xHH' hex character constants.
+ These don't provoke an error unfortunately, instead are silently treated
+ as 'x'. The following induces an error, until -std is added to get
+ proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an
+ array size at least. It's necessary to write '\x00'==0 to get something
+ that's true only with -std. */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+ inside strings and character constants. */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
+ ;
+ return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+ CC="$ac_save_CC $ac_arg"
+ if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+ test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+ x)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+ xno)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+ *)
+ CC="$CC $ac_cv_prog_cc_c89"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC understands -c and -o together" >&5
+$as_echo_n "checking whether $CC understands -c and -o together... " >&6; }
+if ${am_cv_prog_cc_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+ # Make sure it works both with $CC and with simple cc.
+ # Following AC_PROG_CC_C_O, we do the test twice because some
+ # compilers refuse to overwrite an existing .o file with -o,
+ # though they will create one.
+ am_cv_prog_cc_c_o=yes
+ for am_i in 1 2; do
+ if { echo "$as_me:$LINENO: $CC -c conftest.$ac_ext -o conftest2.$ac_objext" >&5
+ ($CC -c conftest.$ac_ext -o conftest2.$ac_objext) >&5 2>&5
+ ac_status=$?
+ echo "$as_me:$LINENO: \$? = $ac_status" >&5
+ (exit $ac_status); } \
+ && test -f conftest2.$ac_objext; then
+ : OK
+ else
+ am_cv_prog_cc_c_o=no
+ break
+ fi
+ done
+ rm -f core conftest*
+ unset am_i
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_cc_c_o" >&5
+$as_echo "$am_cv_prog_cc_c_o" >&6; }
+if test "$am_cv_prog_cc_c_o" != yes; then
+ # Losing compiler, so override with the script.
+ # FIXME: It is wrong to rewrite CC.
+ # But if we don't then we get into trouble of one sort or another.
+ # A longer-term fix would be to have automake use am__CC in this case,
+ # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+ CC="$am_aux_dir/compile $CC"
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+depcc="$CC" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CC_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CC_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+ case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CC_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+ am__fastdepCC_TRUE=
+ am__fastdepCC_FALSE='#'
+else
+ am__fastdepCC_TRUE='#'
+ am__fastdepCC_FALSE=
+fi
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+ if ${ac_cv_prog_CPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CPP needs to be expanded
+ for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CPP=$CPP
+
+fi
+ CPP=$ac_cv_prog_CPP
+else
+ ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ if test "$GCC" = yes; then
+ GCC_TRUE=
+ GCC_FALSE='#'
+else
+ GCC_TRUE='#'
+ GCC_FALSE=
+fi
+ # let the Makefile know if we're gcc
+
+# MinGW uses autoconf, but also needs the windows shim routines
+# (since it doesn't have its own support for, say, pthreads).
+# This requires us to #include a special header file, and also to
+# link in some windows versions of .o's instead of the unix versions.
+
+case $host_os in
+ *mingw*)
+ # Disabling fast install keeps libtool from creating wrapper scripts
+ # around the executables it builds. Such scripts have caused failures on
+ # MinGW. Using this option means an extra link step is executed during
+ # "make install".
+ # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+ enableval=$enable_fast_install; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_fast_install=no
+fi
+
+
+
+
+
+
+
+
+
+ ;;
+ *)
+ # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+ enableval=$enable_fast_install; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_fast_install=yes
+fi
+
+
+
+
+
+
+ ;;
+esac
+ if expr $host : '.*-mingw' >/dev/null 2>&1; then
+ MINGW_TRUE=
+ MINGW_FALSE='#'
+else
+ MINGW_TRUE='#'
+ MINGW_FALSE=
+fi
+
+
+# Uncomment this if you'll be exporting libraries (.so's)
+case `pwd` in
+ *\ * | *\ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
+
+
+
+macro_version='2.2.6b'
+macro_revision='1.3017'
+
+
+
+
+
+
+
+
+
+
+
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+ for ac_i in 1 2 3 4 5 6 7; do
+ ac_script="$ac_script$as_nl$ac_script"
+ done
+ echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+ { ac_script=; unset ac_script;}
+ if test -z "$SED"; then
+ ac_path_SED_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ 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_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_SED" || continue
+# Check for GNU ac_path_SED and select it if it is found.
+ # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+ ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo '' >> "conftest.nl"
+ "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_SED_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_SED="$ac_path_SED"
+ ac_path_SED_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_SED_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_SED"; then
+ as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+ fi
+else
+ ac_cv_path_SED=$SED
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+ rm -f conftest.sed
+
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$GREP"; then
+ ac_path_GREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in grep ggrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_GREP" || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+ # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'GREP' >> "conftest.nl"
+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_GREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_GREP="$ac_path_GREP"
+ ac_path_GREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_GREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_GREP"; then
+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+ then ac_cv_path_EGREP="$GREP -E"
+ else
+ if test -z "$EGREP"; then
+ ac_path_EGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in egrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_EGREP" || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+ # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'EGREP' >> "conftest.nl"
+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_EGREP="$ac_path_EGREP"
+ ac_path_EGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_EGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_EGREP"; then
+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_EGREP=$EGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if ${ac_cv_path_FGREP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+ then ac_cv_path_FGREP="$GREP -F"
+ else
+ if test -z "$FGREP"; then
+ ac_path_FGREP_found=false
+ # Loop through the user's path and test for each of PROGNAME-LIST
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_prog in fgrep; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+ as_fn_executable_p "$ac_path_FGREP" || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+ # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+ ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+ ac_count=0
+ $as_echo_n 0123456789 >"conftest.in"
+ while :
+ do
+ cat "conftest.in" "conftest.in" >"conftest.tmp"
+ mv "conftest.tmp" "conftest.in"
+ cp "conftest.in" "conftest.nl"
+ $as_echo 'FGREP' >> "conftest.nl"
+ "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+ as_fn_arith $ac_count + 1 && ac_count=$as_val
+ if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+ # Best one so far, save it but keep looking for a better one
+ ac_cv_path_FGREP="$ac_path_FGREP"
+ ac_path_FGREP_max=$ac_count
+ fi
+ # 10*(2^10) chars as input seems more than enough
+ test $ac_count -gt 10 && break
+ done
+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+ $ac_path_FGREP_found && break 3
+ done
+ done
+ done
+IFS=$as_save_IFS
+ if test -z "$ac_cv_path_FGREP"; then
+ as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+ fi
+else
+ ac_cv_path_FGREP=$FGREP
+fi
+
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
+
+
+test -z "$GREP" && GREP=grep
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if ${lt_cv_path_NM+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DUMPBIN"; then
+ ac_cv_prog_DUMPBIN="$DUMPBIN" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$DUMPBIN" && break
+ done
+fi
+if test -z "$DUMPBIN"; then
+ ac_ct_DUMPBIN=$DUMPBIN
+ for ac_prog in "dumpbin -symbols" "link -dump -symbols"
+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:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DUMPBIN"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_DUMPBIN" && break
+done
+
+ if test "x$ac_ct_DUMPBIN" = x; then
+ DUMPBIN=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DUMPBIN=$ac_ct_DUMPBIN
+ fi
+fi
+
+
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if ${lt_cv_nm_interface+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:5514: $ac_compile\"" >&5)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:5517: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&5
+ (eval echo "\"\$as_me:5520: output\"" >&5)
+ cat conftest.out >&5
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if ${lt_cv_sys_max_cmd_len+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw* | cegcc*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+ if test -n "$lt_cv_sys_max_cmd_len"; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`$SHELL $0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+
+
+
+
+
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
+
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+
+
+
+
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if ${lt_cv_ld_reload_flag+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OBJDUMP"; then
+ ac_cv_prog_OBJDUMP="$OBJDUMP" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OBJDUMP"; then
+ ac_ct_OBJDUMP=$OBJDUMP
+ # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OBJDUMP"; then
+ ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OBJDUMP="objdump"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OBJDUMP" = x; then
+ OBJDUMP="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OBJDUMP=$ac_ct_OBJDUMP
+ fi
+else
+ OBJDUMP="$ac_cv_prog_OBJDUMP"
+fi
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if ${lt_cv_deplibs_check_method+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[4-9]*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi[45]*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ if ( file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
+ ;;
+
+cegcc)
+ # use the weaker test based on 'objdump'. See mingw*.
+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case $host_cpu in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+interix[3-9]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+rdos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.3*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$AR"; then
+ ac_cv_prog_AR="$AR" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_AR="${ac_tool_prefix}ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+ ac_ct_AR=$AR
+ # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_AR"; then
+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_AR="ar"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_AR" = x; then
+ AR="false"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ AR=$ac_ct_AR
+ fi
+else
+ AR="$ac_cv_prog_AR"
+fi
+
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$STRIP"; then
+ ac_cv_prog_STRIP="$STRIP" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+ ac_ct_STRIP=$STRIP
+ # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_STRIP"; then
+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_STRIP="strip"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_STRIP" = x; then
+ STRIP=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ STRIP=$ac_ct_STRIP
+ fi
+else
+ STRIP="$ac_cv_prog_STRIP"
+fi
+
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$RANLIB"; then
+ ac_cv_prog_RANLIB="$RANLIB" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+ ac_ct_RANLIB=$RANLIB
+ # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_RANLIB"; then
+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_RANLIB="ranlib"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_RANLIB" = x; then
+ RANLIB=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ RANLIB=$ac_ct_RANLIB
+ fi
+else
+ RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+test -z "$RANLIB" && RANLIB=:
+
+
+
+
+
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[BCDT]'
+ ;;
+cygwin* | mingw* | pw32* | cegcc*)
+ symcode='[ABCDGISTW]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[ABCDEGRST]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[BCDEGRST]'
+ ;;
+osf*)
+ symcode='[BCDEGQRST]'
+ ;;
+solaris*)
+ symcode='[BDRT]'
+ ;;
+sco3.2v5*)
+ symcode='[DT]'
+ ;;
+sysv4.2uw2*)
+ symcode='[DT]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[ABDT]'
+ ;;
+sysv4)
+ symcode='[DFNSTU]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK '"\
+" {last_section=section; section=\$ 3};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5
+ (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_save_LIBS="$LIBS"
+ lt_save_CFLAGS="$CFLAGS"
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS="$lt_save_LIBS"
+ CFLAGS="$lt_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&5
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&5
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+ fi
+ else
+ echo "$progname: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ fi
+ rm -rf conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+ enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '#line 6726 "configure"' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if ${lt_cv_cc_needs_belf+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_cc_needs_belf=yes
+else
+ lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+sparc*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*) LD="${LD-ld} -m elf64_sparc" ;;
+ *)
+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+ LD="${LD-ld} -64"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+ case $host_os in
+ rhapsody* | darwin*)
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$DSYMUTIL"; then
+ ac_cv_prog_DSYMUTIL="$DSYMUTIL" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+ ac_ct_DSYMUTIL=$DSYMUTIL
+ # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_DSYMUTIL"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_DSYMUTIL" = x; then
+ DSYMUTIL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ DSYMUTIL=$ac_ct_DSYMUTIL
+ fi
+else
+ DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$NMEDIT"; then
+ ac_cv_prog_NMEDIT="$NMEDIT" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+ ac_ct_NMEDIT=$NMEDIT
+ # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_NMEDIT"; then
+ ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_NMEDIT="nmedit"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_NMEDIT" = x; then
+ NMEDIT=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ NMEDIT=$ac_ct_NMEDIT
+ fi
+else
+ NMEDIT="$ac_cv_prog_NMEDIT"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$LIPO"; then
+ ac_cv_prog_LIPO="$LIPO" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+ ac_ct_LIPO=$LIPO
+ # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_LIPO"; then
+ ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_LIPO="lipo"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_LIPO" = x; then
+ LIPO=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ LIPO=$ac_ct_LIPO
+ fi
+else
+ LIPO="$ac_cv_prog_LIPO"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL"; then
+ ac_cv_prog_OTOOL="$OTOOL" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+ ac_ct_OTOOL=$OTOOL
+ # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL"; then
+ ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL="otool"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL" = x; then
+ OTOOL=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OTOOL=$ac_ct_OTOOL
+ fi
+else
+ OTOOL="$ac_cv_prog_OTOOL"
+fi
+
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$OTOOL64"; then
+ ac_cv_prog_OTOOL64="$OTOOL64" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+ ac_ct_OTOOL64=$OTOOL64
+ # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_OTOOL64"; then
+ ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_OTOOL64="otool64"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_ct_OTOOL64" = x; then
+ OTOOL64=":"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ OTOOL64=$ac_ct_OTOOL64
+ fi
+else
+ OTOOL64="$ac_cv_prog_OTOOL64"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if ${lt_cv_apple_cc_single_mod+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi_module to the
+ # link flags.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&5
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if ${lt_cv_ld_exported_symbols_list+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ lt_cv_ld_exported_symbols_list=yes
+else
+ lt_cv_ld_exported_symbols_list=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
+ case $host_os in
+ rhapsody* | darwin1.[012])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # if running on 10.5 or later, the deployment target defaults
+ # to the OS version, if on x86, and 10.4, the deployment
+ # target defaults to 10.4. Don't you love it?
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+ 10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ 10.[012]*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ 10.*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ esac
+ ;;
+ esac
+ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ _lt_dar_single_mod='$single_module'
+ fi
+ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ else
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ if test "$DSYMUTIL" != ":"; then
+ _lt_dsymutil='~$DSYMUTIL $lib || :'
+ else
+ _lt_dsymutil=
+ fi
+ ;;
+ esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+ inttypes.h stdint.h unistd.h
+do :
+ as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in dlfcn.h
+do :
+ ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+ if test -n "$CCC"; then
+ CXX=$CCC
+ else
+ if test -n "$ac_tool_prefix"; then
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+ do
+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$CXX"; then
+ ac_cv_prog_CXX="$CXX" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$CXX" && break
+ done
+fi
+if test -z "$CXX"; then
+ ac_ct_CXX=$CXX
+ for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+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:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$ac_ct_CXX"; then
+ ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_ac_ct_CXX="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$ac_ct_CXX" && break
+done
+
+ if test "x$ac_ct_CXX" = x; then
+ CXX="g++"
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ CXX=$ac_ct_CXX
+ fi
+fi
+
+ fi
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+ { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+ *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+ ac_status=$?
+ if test -s conftest.err; then
+ sed '10a\
+... rest of stderr output deleted ...
+ 10q' conftest.err >conftest.er1
+ cat conftest.er1 >&5
+ fi
+ rm -f conftest.er1 conftest.err
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+#ifndef __GNUC__
+ choke me
+#endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_compiler_gnu=yes
+else
+ ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+ GXX=yes
+else
+ GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+ ac_cxx_werror_flag=yes
+ ac_cv_prog_cxx_g=no
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+else
+ CXXFLAGS=""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+
+else
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+ CXXFLAGS="-g"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_prog_cxx_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+ CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+ if test "$GXX" = yes; then
+ CXXFLAGS="-g -O2"
+ else
+ CXXFLAGS="-g"
+ fi
+else
+ if test "$GXX" = yes; then
+ CXXFLAGS="-O2"
+ else
+ CXXFLAGS=
+ fi
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CXX" am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+ # We make a subdir and do the tests there. Otherwise we can end up
+ # making bogus files that we don't know about and never remove. For
+ # instance it was reported that on HP-UX the gcc test will end up
+ # making a dummy file named 'D' -- because '-MD' means "put the output
+ # in D".
+ rm -rf conftest.dir
+ mkdir conftest.dir
+ # Copy depcomp to subdir because otherwise we won't find it if we're
+ # using a relative directory.
+ cp "$am_depcomp" conftest.dir
+ cd conftest.dir
+ # We will build objects and dependencies in a subdirectory because
+ # it helps to detect inapplicable dependency modes. For instance
+ # both Tru64's cc and ICC support -MD to output dependencies as a
+ # side effect of compilation, but ICC will put the dependencies in
+ # the current directory while Tru64 will put them in the object
+ # directory.
+ mkdir sub
+
+ am_cv_CXX_dependencies_compiler_type=none
+ if test "$am_compiler_list" = ""; then
+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+ fi
+ am__universal=false
+ case " $depcc " in #(
+ *\ -arch\ *\ -arch\ *) am__universal=true ;;
+ esac
+
+ for depmode in $am_compiler_list; do
+ # Setup a source with many dependencies, because some compilers
+ # like to wrap large dependency lists on column 80 (with \), and
+ # we should not choose a depcomp mode which is confused by this.
+ #
+ # We need to recreate these files for each test, as the compiler may
+ # overwrite some of them when testing with obscure command lines.
+ # This happens at least with the AIX C compiler.
+ : > sub/conftest.c
+ for i in 1 2 3 4 5 6; do
+ echo '#include "conftst'$i'.h"' >> sub/conftest.c
+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+ # Solaris 10 /bin/sh.
+ echo '/* dummy */' > sub/conftst$i.h
+ done
+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+ # We check with '-c' and '-o' for the sake of the "dashmstdout"
+ # mode. It turns out that the SunPro C++ compiler does not properly
+ # handle '-M -o', and we need to detect this. Also, some Intel
+ # versions had trouble with output in subdirs.
+ am__obj=sub/conftest.${OBJEXT-o}
+ am__minus_obj="-o $am__obj"
+ case $depmode in
+ gcc)
+ # This depmode causes a compiler race in universal mode.
+ test "$am__universal" = false || continue
+ ;;
+ nosideeffect)
+ # After this tag, mechanisms are not by side-effect, so they'll
+ # only be used when explicitly requested.
+ if test "x$enable_dependency_tracking" = xyes; then
+ continue
+ else
+ break
+ fi
+ ;;
+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+ # This compiler won't grok '-c -o', but also, the minuso test has
+ # not run yet. These depmodes are late enough in the game, and
+ # so weak that their functioning should not be impacted.
+ am__obj=conftest.${OBJEXT-o}
+ am__minus_obj=
+ ;;
+ none) break ;;
+ esac
+ if depmode=$depmode \
+ source=sub/conftest.c object=$am__obj \
+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+ >/dev/null 2>conftest.err &&
+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+ # icc doesn't choke on unknown options, it will just issue warnings
+ # or remarks (even with -Werror). So we grep stderr for any message
+ # that says an option was ignored or not supported.
+ # When given -MP, icc 7.0 and 7.1 complain thusly:
+ # icc: Command line warning: ignoring option '-M'; no argument required
+ # The diagnosis changed in icc 8.0:
+ # icc: Command line remark: option '-MP' not supported
+ if (grep 'ignoring option' conftest.err ||
+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+ am_cv_CXX_dependencies_compiler_type=$depmode
+ break
+ fi
+ fi
+ done
+
+ cd ..
+ rm -rf conftest.dir
+else
+ am_cv_CXX_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+ test "x$enable_dependency_tracking" != xno \
+ && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+ am__fastdepCXX_TRUE=
+ am__fastdepCXX_FALSE='#'
+else
+ am__fastdepCXX_TRUE='#'
+ am__fastdepCXX_FALSE=
+fi
+
+
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+ (test "X$CXX" != "Xg++"))) ; then
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
+$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
+if test -z "$CXXCPP"; then
+ if ${ac_cv_prog_CXXCPP+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # Double quotes because CXXCPP needs to be expanded
+ for CXXCPP in "$CXX -E" "/lib/cpp"
+ do
+ ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+ break
+fi
+
+ done
+ ac_cv_prog_CXXCPP=$CXXCPP
+
+fi
+ CXXCPP=$ac_cv_prog_CXXCPP
+else
+ ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
+$as_echo "$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+ # Use a header file that comes with gcc, so configuring glibc
+ # with a fresh cross-compiler works.
+ # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+ # <limits.h> exists even on freestanding compilers.
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp. "Syntax error" is here to catch this case.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+ Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+
+else
+ # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+ # OK, works on sane cases. Now check whether nonexistent headers
+ # can be detected and how.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+ # Broken: success on invalid input.
+continue
+else
+ # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+_lt_caught_CXX_error=yes; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+else
+ _lt_caught_CXX_error=yes
+fi
+
+
+
+
+
+# Set options
+
+
+
+ enable_dlopen=no
+
+
+ enable_win32_dll=no
+
+
+ # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+ enableval=$enable_shared; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_shared=yes
+fi
+
+
+
+
+
+
+
+
+
+ # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+ enableval=$enable_static; p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac
+else
+ enable_static=yes
+fi
+
+
+
+
+
+
+
+
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+ withval=$with_pic; pic_mode="$withval"
+else
+ pic_mode=default
+fi
+
+
+test -z "$pic_mode" && pic_mode=default
+
+
+
+
+
+
+
+
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if ${lt_cv_objdir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/${ac_tool_prefix}file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $MAGIC_CMD in
+[\\/*] | ?:[\\/]*)
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/file; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/file"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ else
+ MAGIC_CMD=:
+ fi
+fi
+
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+ lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_rtti_exceptions=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="-fno-rtti -fno-exceptions"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:8617: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:8621: \$? = $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.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_rtti_exceptions=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+ :
+fi
+
+fi
+
+
+
+
+
+
+ lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+ if test "$GCC" = yes; then
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_static='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic='-fno-common'
+ ;;
+
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ lt_prog_compiler_can_build_shared=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ lt_prog_compiler_pic='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ lt_prog_compiler_wl='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static='-Bstatic'
+ else
+ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ lt_prog_compiler_pic='-DDLL_EXPORT'
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ lt_prog_compiler_static='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ lt_prog_compiler_wl='-Wl,'
+ # PIC (with -KPIC) is the default.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ # old Intel for x86_64 which still supported -KPIC.
+ ecc*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ # icc used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ icc* | ifort*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fPIC'
+ lt_prog_compiler_static='-static'
+ ;;
+ # Lahey Fortran 8.1.
+ lf95*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='--shared'
+ lt_prog_compiler_static='--static'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-fpic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+ ccc*)
+ lt_prog_compiler_wl='-Wl,'
+ # All Alpha code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+ xl*)
+ # IBM XL C 8.0/Fortran 10.1 on PPC
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-qpic'
+ lt_prog_compiler_static='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C 5.9
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl='-Wl,'
+ ;;
+ *Sun\ F*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ lt_prog_compiler_wl=''
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ lt_prog_compiler_wl='-Wl,'
+ # All OSF/1 code is PIC.
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ rdos*)
+ lt_prog_compiler_static='-non_shared'
+ ;;
+
+ solaris*)
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95*)
+ lt_prog_compiler_wl='-Qoption ld ';;
+ *)
+ lt_prog_compiler_wl='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ lt_prog_compiler_wl='-Qoption ld '
+ lt_prog_compiler_pic='-PIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ lt_prog_compiler_pic='-Kconform_pic'
+ lt_prog_compiler_static='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_pic='-KPIC'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ unicos*)
+ lt_prog_compiler_wl='-Wl,'
+ lt_prog_compiler_can_build_shared=no
+ ;;
+
+ uts4*)
+ lt_prog_compiler_pic='-pic'
+ lt_prog_compiler_static='-Bstatic'
+ ;;
+
+ *)
+ lt_prog_compiler_can_build_shared=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic=
+ ;;
+ *)
+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5
+$as_echo "$lt_prog_compiler_pic" >&6; }
+
+
+
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_works=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:8956: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:8960: \$? = $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.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_pic_works=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+ case $lt_prog_compiler_pic in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+ esac
+else
+ lt_prog_compiler_pic=
+ lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_static_works=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_static_works=yes
+ fi
+ else
+ lt_cv_prog_compiler_static_works=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+ :
+else
+ lt_prog_compiler_static=
+fi
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:9061: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:9065: \$? = $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
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:9116: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:9120: \$? = $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
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+ if test "$hard_links" = no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+ runpath_var=
+ allow_undefined_flag=
+ always_export_symbols=no
+ archive_cmds=
+ archive_expsym_cmds=
+ compiler_needs_object=no
+ enable_shared_with_static_runtimes=no
+ export_dynamic_flag_spec=
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ hardcode_automatic=no
+ hardcode_direct=no
+ hardcode_direct_absolute=no
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_flag_spec_ld=
+ hardcode_libdir_separator=
+ hardcode_minus_L=no
+ hardcode_shlibpath_var=unsupported
+ inherit_rpath=no
+ link_all_deplibs=unknown
+ module_cmds=
+ module_expsym_cmds=
+ old_archive_from_new_cmds=
+ old_archive_from_expsyms_cmds=
+ thread_safe_flag_spec=
+ whole_archive_flag_spec=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ include_expsyms=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ # Exclude shared library initialization/finalization symbols.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ linux* | k*bsd*-gnu)
+ link_all_deplibs=no
+ ;;
+ esac
+
+ ld_shlibs=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *GNU\ gold*) supports_anon_versioning=yes ;;
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[3-9]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec='-L$libdir'
+ allow_undefined_flag=unsupported
+ always_export_symbols=no
+ enable_shared_with_static_runtimes=yes
+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=
+ tmp_sharedflag='-shared'
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+ whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ lf95*) # Lahey Fortran 8.1
+ whole_archive_flag_spec=
+ tmp_sharedflag='--shared' ;;
+ xl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ tmp_sharedflag='-qmkshrobj'
+ tmp_addflag= ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+
+ case $cc_basename in
+ xlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+ hardcode_libdir_flag_spec=
+ hardcode_libdir_flag_spec_ld='-rpath $libdir'
+ archive_cmds='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+ ld_shlibs=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ ld_shlibs=no
+ fi
+ ;;
+ esac
+
+ if test "$ld_shlibs" = no; then
+ runpath_var=
+ hardcode_libdir_flag_spec=
+ export_dynamic_flag_spec=
+ whole_archive_flag_spec=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ allow_undefined_flag=unsupported
+ always_export_symbols=yes
+ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ hardcode_minus_L=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ hardcode_direct=unsupported
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds=''
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ file_list_spec='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L=yes
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_libdir_separator=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ link_all_deplibs=no
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ export_dynamic_flag_spec='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ always_export_symbols=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag="-z nodefs"
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag=' ${wl}-bernotok'
+ allow_undefined_flag=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec='$convenience'
+ archive_cmds_need_lc=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds=''
+ ;;
+ m68k)
+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[45]*)
+ export_dynamic_flag_spec=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ hardcode_libdir_flag_spec=' '
+ allow_undefined_flag=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ archive_cmds='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ old_archive_from_new_cmds='true'
+ # FIXME: Should let the user specify the lib program.
+ old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ fix_srcfile_path='`cygpath -w "$srcfile"`'
+ enable_shared_with_static_runtimes=yes
+ ;;
+
+ darwin* | rhapsody*)
+
+
+ archive_cmds_need_lc=no
+ hardcode_direct=no
+ hardcode_automatic=yes
+ hardcode_shlibpath_var=unsupported
+ whole_archive_flag_spec=''
+ link_all_deplibs=yes
+ allow_undefined_flag="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=echo
+ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+
+ else
+ ld_shlibs=no
+ fi
+
+ ;;
+
+ dgux*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ freebsd1*)
+ ld_shlibs=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ archive_cmds='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ export_dynamic_flag_spec='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_flag_spec_ld='+b $libdir'
+ hardcode_libdir_separator=:
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct=no
+ hardcode_shlibpath_var=no
+ ;;
+ *)
+ hardcode_direct=yes
+ hardcode_direct_absolute=yes
+ export_dynamic_flag_spec='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ hardcode_minus_L=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+int foo(void) {}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS="$save_LDFLAGS"
+ else
+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ inherit_rpath=yes
+ link_all_deplibs=yes
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ newsos6)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ hardcode_shlibpath_var=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct=yes
+ hardcode_shlibpath_var=no
+ hardcode_direct_absolute=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec='${wl}-E'
+ else
+ case $host_os in
+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-R$libdir'
+ ;;
+ *)
+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ ld_shlibs=no
+ fi
+ ;;
+
+ os2*)
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_minus_L=yes
+ allow_undefined_flag=unsupported
+ archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+ else
+ allow_undefined_flag=' -expect_unresolved \*'
+ archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ hardcode_libdir_flag_spec='-rpath $libdir'
+ fi
+ archive_cmds_need_lc='no'
+ hardcode_libdir_separator=:
+ ;;
+
+ solaris*)
+ no_undefined_flag=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ archive_cmds='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ hardcode_libdir_flag_spec='-R$libdir'
+ hardcode_shlibpath_var=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ link_all_deplibs=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_direct=yes
+ hardcode_minus_L=yes
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ reload_cmds='$CC -r -o $output$reload_objs'
+ hardcode_direct=no
+ ;;
+ motorola)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ hardcode_shlibpath_var=no
+ ;;
+
+ sysv4.3*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ export_dynamic_flag_spec='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_shlibpath_var=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ ld_shlibs=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag='${wl}-z,text'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag='${wl}-z,text'
+ allow_undefined_flag='${wl}-z,nodefs'
+ archive_cmds_need_lc=no
+ hardcode_shlibpath_var=no
+ hardcode_libdir_flag_spec='${wl}-R,$libdir'
+ hardcode_libdir_separator=':'
+ link_all_deplibs=yes
+ export_dynamic_flag_spec='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ hardcode_libdir_flag_spec='-L$libdir'
+ hardcode_shlibpath_var=no
+ ;;
+
+ *)
+ ld_shlibs=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ export_dynamic_flag_spec='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+with_gnu_ld=$with_gnu_ld
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl
+ pic_flag=$lt_prog_compiler_pic
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag
+ allow_undefined_flag=
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+ (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ then
+ archive_cmds_need_lc=no
+ else
+ archive_cmds_need_lc=yes
+ fi
+ allow_undefined_flag=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5
+$as_echo "$archive_cmds_need_lc" >&6; }
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+if test "$GCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[lt_foo]++; }
+ if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[123]*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+interix[3-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+ shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+ test -n "$runpath_var" ||
+ test "X$hardcode_automatic" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+ test "$hardcode_minus_L" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink ||
+ test "$inherit_rpath" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+
+
+
+
+
+ if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32* | cegcc*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dl_dlopen=yes
+else
+ ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+
+fi
+
+ ;;
+
+ *)
+ ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if ${ac_cv_lib_dld_shl_load+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dld_shl_load=yes
+else
+ ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+ lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+ ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dl_dlopen=yes
+else
+ ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if ${ac_cv_lib_svld_dlopen+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_svld_dlopen=yes
+else
+ ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
+ lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if ${ac_cv_lib_dld_dld_link+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_lib_dld_dld_link=yes
+else
+ ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
+ lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line 11500 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}
+_LT_EOF
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self_static+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test "$cross_compiling" = yes; then :
+ lt_cv_dlopen_self_static=cross
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+#line 11596 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}
+_LT_EOF
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+ (eval $ac_link) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&5 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+ x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
+ esac
+ else :
+ # compilation failed
+ lt_cv_dlopen_self_static=no
+ fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ ;;
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ ;;
+ esac
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+ # Report which library types will actually be built
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[4-9]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+
+
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+compiler_needs_object_CXX=no
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_direct_absolute_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_flag_spec_ld_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+inherit_rpath_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="int some_variable = 0;"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+ # save warnings/boilerplate of simple test code
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+ ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_LD=$LD
+ lt_save_GCC=$GCC
+ GCC=$GXX
+ lt_save_with_gnu_ld=$with_gnu_ld
+ lt_save_path_LD=$lt_cv_path_LD
+ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+ else
+ $as_unset lt_cv_prog_gnu_ld
+ fi
+ if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+ else
+ $as_unset lt_cv_path_LD
+ fi
+ test -z "${LDCXX+set}" || LD=$LDCXX
+ CC=${CXX-"c++"}
+ compiler=$CC
+ compiler_CXX=$CC
+ for cc_temp in $compiler""; do
+ case $cc_temp in
+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+ else
+ lt_prog_compiler_no_builtin_flag_CXX=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+ with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [\\/]* | ?:[\\/]*)
+ re_direlt='/[^/][^/]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+
+
+
+
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+ $GREP 'no-whole-archive' > /dev/null; then
+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ whole_archive_flag_spec_CXX=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+ else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+ fi
+
+ # PORTME: fill in a description of your system's C++ link characteristics
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+ ld_shlibs_CXX=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aix[4-9]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ archive_cmds_CXX=''
+ hardcode_direct_CXX=yes
+ hardcode_direct_absolute_CXX=yes
+ hardcode_libdir_separator_CXX=':'
+ link_all_deplibs_CXX=yes
+ file_list_spec_CXX='${wl}-f,'
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[012]|aix4.[012].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ hardcode_direct_CXX=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ hardcode_minus_L_CXX=yes
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ hardcode_libdir_separator_CXX=
+ fi
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ export_dynamic_flag_spec_CXX='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to
+ # export.
+ always_export_symbols_CXX=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ allow_undefined_flag_CXX='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+ allow_undefined_flag_CXX="-z nodefs"
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ no_undefined_flag_CXX=' ${wl}-bernotok'
+ allow_undefined_flag_CXX=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ whole_archive_flag_spec_CXX='$convenience'
+ archive_cmds_need_lc_CXX=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ allow_undefined_flag_CXX=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+ # as there is no search path for DLLs.
+ hardcode_libdir_flag_spec_CXX='-L$libdir'
+ allow_undefined_flag_CXX=unsupported
+ always_export_symbols_CXX=no
+ enable_shared_with_static_runtimes_CXX=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ darwin* | rhapsody*)
+
+
+ archive_cmds_need_lc_CXX=no
+ hardcode_direct_CXX=no
+ hardcode_automatic_CXX=yes
+ hardcode_shlibpath_var_CXX=unsupported
+ whole_archive_flag_spec_CXX=''
+ link_all_deplibs_CXX=yes
+ allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=echo
+ archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+ archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+ fi
+
+ else
+ ld_shlibs_CXX=no
+ fi
+
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ freebsd[12]*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ ld_shlibs_CXX=no
+ ;;
+
+ freebsd-elf*)
+ archive_cmds_need_lc_CXX=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ ld_shlibs_CXX=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ hpux9*)
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ hardcode_direct_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC*)
+ archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ ;;
+ *)
+ hardcode_direct_CXX=yes
+ hardcode_direct_absolute_CXX=yes
+ hardcode_minus_L_CXX=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[3-9]*)
+ hardcode_direct_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC*)
+ # SGI C++
+ archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+ fi
+ fi
+ link_all_deplibs_CXX=yes
+ ;;
+ esac
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+ inherit_rpath_CXX=yes
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ with_gnu_ld=yes
+ # version 8.0 and above of icpc choke on multiply defined symbols
+ # if we add $predep_objects and $postdep_objects, however 7.1 and
+ # earlier do not add the objects themselves.
+ case `$CC -V 2>&1` in
+ *"Version 7."*)
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ *) # Version 8.0 or newer
+ tmp_idyn=
+ case $host_cpu in
+ ia64*) tmp_idyn=' -i_dynamic';;
+ esac
+ archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ esac
+ archive_cmds_need_lc_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [1-5]* | *pgcpp\ [1-5]*)
+ prelink_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+ old_archive_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+ $RANLIB $oldlib'
+ archive_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ archive_expsym_cmds_CXX='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 will use weak symbols
+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+
+ hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ ;;
+ cxx*)
+ # Compaq C++
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ xl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+ archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ no_undefined_flag_CXX=' -zdefs'
+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ compiler_needs_object_CXX=yes
+
+ # Not sure whether something based on
+ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+ # would be better.
+ output_verbose_link_cmd='echo'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ archive_cmds_CXX='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_direct_CXX=yes
+ hardcode_shlibpath_var_CXX=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+
+ *nto* | *qnx*)
+ ld_shlibs_CXX=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ ld_shlibs_CXX=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ hardcode_direct_CXX=yes
+ hardcode_shlibpath_var_CXX=no
+ hardcode_direct_absolute_CXX=yes
+ archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+ export_dynamic_flag_spec_CXX='${wl}-E'
+ whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=echo
+ else
+ ld_shlibs_CXX=no
+ fi
+ ;;
+
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ allow_undefined_flag_CXX=' -expect_unresolved \*'
+ archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+ ;;
+ esac
+
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+ hardcode_libdir_separator_CXX=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ archive_cmds_need_lc_CXX=yes
+ no_undefined_flag_CXX=' -zdefs'
+ archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ hardcode_libdir_flag_spec_CXX='-R$libdir'
+ hardcode_shlibpath_var_CXX=no
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ link_all_deplibs_CXX=yes
+
+ output_verbose_link_cmd='echo'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ archive_cmds_CXX='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ fi
+
+ hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[0-5] | solaris2.[0-5].*) ;;
+ *)
+ whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+ no_undefined_flag_CXX='${wl}-z,text'
+ archive_cmds_need_lc_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ no_undefined_flag_CXX='${wl}-z,text'
+ allow_undefined_flag_CXX='${wl}-z,nodefs'
+ archive_cmds_need_lc_CXX=no
+ hardcode_shlibpath_var_CXX=no
+ hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+ hardcode_libdir_separator_CXX=':'
+ link_all_deplibs_CXX=yes
+ export_dynamic_flag_spec_CXX='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ ld_shlibs_CXX=no
+ ;;
+ esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+ test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+ GCC_CXX="$GXX"
+ LD_CXX="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ # Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
+
+cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+
+if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ for p in `eval "$output_verbose_link_cmd"`; do
+ case $p in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ else
+ prev=
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ case $p in
+ -L* | -R*)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$compiler_lib_search_path_CXX"; then
+ compiler_lib_search_path_CXX="${prev}${p}"
+ else
+ compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$postdeps_CXX"; then
+ postdeps_CXX="${prev}${p}"
+ else
+ postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+ fi
+ fi
+ ;;
+
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$predep_objects_CXX"; then
+ predep_objects_CXX="$p"
+ else
+ predep_objects_CXX="$predep_objects_CXX $p"
+ fi
+ else
+ if test -z "$postdep_objects_CXX"; then
+ postdep_objects_CXX="$p"
+ else
+ postdep_objects_CXX="$postdep_objects_CXX $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling CXX test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+ # Interix 3.5 installs completely hosed .la files for C++, so rather than
+ # hack all around it, let's just trust "g++" to DTRT.
+ predep_objects_CXX=
+ postdep_objects_CXX=
+ postdeps_CXX=
+ ;;
+
+linux*)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ if test "$solaris_use_stlport4" != yes; then
+ postdeps_CXX='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+
+solaris*)
+ case $cc_basename in
+ CC*)
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ # Adding this requires a known-good setup of shared libraries for
+ # Sun compiler versions before 5.6, else PIC objects from an old
+ # archive will be linked into the output, leading to subtle bugs.
+ if test "$solaris_use_stlport4" != yes; then
+ postdeps_CXX='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+ compiler_lib_search_dirs_CXX=
+if test -n "${compiler_lib_search_path_CXX}"; then
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ lt_prog_compiler_pic_CXX='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ lt_prog_compiler_pic_CXX=
+ ;;
+ interix[3-9]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ lt_prog_compiler_pic_CXX=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_CXX='-fPIC -shared'
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix[4-9]*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ lt_prog_compiler_static_CXX='-Bstatic'
+ else
+ lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ lt_prog_compiler_pic_CXX='+Z'
+ fi
+ ;;
+ aCC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ interix*)
+ # This is c89, which is MS Visual C++ (no shared libs)
+ # Anyone wants to do a port?
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_static_CXX='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # KAI C++ Compiler
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ lt_prog_compiler_pic_CXX='-fPIC'
+ ;;
+ ecpc* )
+ # old Intel C++ for x86_64 which still supported -KPIC.
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-static'
+ ;;
+ icpc* )
+ # Intel C++, used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-fPIC'
+ lt_prog_compiler_static_CXX='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-fpic'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ cxx*)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ xlc* | xlC*)
+ # IBM XL 8.0 on PPC
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-qpic'
+ lt_prog_compiler_static_CXX='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ lt_prog_compiler_wl_CXX='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ lt_prog_compiler_pic_CXX='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd* | netbsdelf*-gnu)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ lt_prog_compiler_pic_CXX='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ lt_prog_compiler_wl_CXX='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ lt_prog_compiler_wl_CXX='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_static_CXX='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ lt_prog_compiler_wl_CXX='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ lt_prog_compiler_pic_CXX='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ lt_prog_compiler_pic_CXX='-pic'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ lt_prog_compiler_pic_CXX='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ lt_prog_compiler_wl_CXX='-Wl,'
+ lt_prog_compiler_pic_CXX='-KPIC'
+ lt_prog_compiler_static_CXX='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ lt_prog_compiler_pic_CXX='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ lt_prog_compiler_can_build_shared_CXX=no
+ ;;
+ esac
+ fi
+
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ lt_prog_compiler_pic_CXX=
+ ;;
+ *)
+ lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_CXX" >&5
+$as_echo "$lt_prog_compiler_pic_CXX" >&6; }
+
+
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_pic_works_CXX=no
+ ac_outfile=conftest.$ac_objext
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:13552: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&5
+ echo "$as_me:13556: \$? = $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.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_pic_works_CXX=yes
+ fi
+ fi
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+ case $lt_prog_compiler_pic_CXX in
+ "" | " "*) ;;
+ *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+ esac
+else
+ lt_prog_compiler_pic_CXX=
+ lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_static_works_CXX=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&5
+ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_static_works_CXX=yes
+ fi
+ else
+ lt_cv_prog_compiler_static_works_CXX=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+ :
+else
+ lt_prog_compiler_static_CXX=
+fi
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o_CXX=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:13651: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:13655: \$? = $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
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_CXX=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ lt_cv_prog_compiler_c_o_CXX=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:13703: $lt_compile\"" >&5)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&5
+ echo "$as_me:13707: \$? = $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
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ lt_cv_prog_compiler_c_o_CXX=yes
+ fi
+ fi
+ chmod u+w . 2>&5
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+ if test "$hard_links" = no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ case $host_os in
+ aix[4-9]*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ export_symbols_cmds_CXX="$ltdll_cmds"
+ ;;
+ cygwin* | mingw* | cegcc*)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;/^.*[ ]__nm__/s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ linux* | k*bsd*-gnu)
+ link_all_deplibs_CXX=no
+ ;;
+ *)
+ export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+ exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+with_gnu_ld_CXX=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+ # Assume -lc should be added
+ archive_cmds_need_lc_CXX=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $archive_cmds_CXX in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+ (eval $ac_compile) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; } 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$lt_prog_compiler_wl_CXX
+ pic_flag=$lt_prog_compiler_pic_CXX
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+ allow_undefined_flag_CXX=
+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+ (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }
+ then
+ archive_cmds_need_lc_CXX=no
+ else
+ archive_cmds_need_lc_CXX=yes
+ fi
+ allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc_CXX" >&5
+$as_echo "$archive_cmds_need_lc_CXX" >&6; }
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[4-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[01] | aix4.[01].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[45]*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[123]*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[01]* | freebsdelf3.[01]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+interix[3-9]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+ shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[89] | openbsd2.[89].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" ||
+ test -n "$runpath_var_CXX" ||
+ test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$hardcode_direct_CXX" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+ test "$hardcode_minus_L_CXX" != no; then
+ # Linking always hardcodes the temporary library directory.
+ hardcode_action_CXX=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ hardcode_action_CXX=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ hardcode_action_CXX=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
+$as_echo "$hardcode_action_CXX" >&6; }
+
+if test "$hardcode_action_CXX" = relink ||
+ test "$inherit_rpath_CXX" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ with_gnu_ld=$lt_save_with_gnu_ld
+ lt_cv_path_LDCXX=$lt_cv_path_LD
+ lt_cv_path_LD=$lt_save_path_LD
+ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5
+$as_echo_n "checking for __attribute__... " >&6; }
+ if ${ac_cv___attribute__+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+ static void foo(void) __attribute__ ((unused));
+ void foo(void) { exit(1); }
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv___attribute__=yes
+else
+ ac_cv___attribute__=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+
+ if test "$ac_cv___attribute__" = "yes"; then
+
+$as_echo "#define HAVE___ATTRIBUTE__ 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv___attribute__" >&5
+$as_echo "$ac_cv___attribute__" >&6; }
+
+
+# Check whether some low-level functions/files are available
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_header_stdc=yes
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+ # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+ $EGREP "free" >/dev/null 2>&1; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+ # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+ if test "$cross_compiling" = yes; then :
+ :
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+ (('a' <= (c) && (c) <= 'i') \
+ || ('j' <= (c) && (c) <= 'r') \
+ || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+ int i;
+ for (i = 0; i < 256; i++)
+ if (XOR (islower (i), ISLOWER (i))
+ || toupper (i) != TOUPPER (i))
+ return 2;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+ ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+ conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+
+# Defines PRIuS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking printf format code for printing a size_t and ssize_t" >&5
+$as_echo_n "checking printf format code for printing a size_t and ssize_t... " >&6; }
+if ${ac_cv_formatting_prius_prefix+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stddef.h>
+int
+main ()
+{
+unsigned int v1 = 0; size_t v2 = 0; return (&v1 - &v2)
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_formatting_prius_prefix=; ac_cv_prius_defined=1
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stddef.h>
+int
+main ()
+{
+unsigned long v1 = 0; size_t v2 = 0; return (&v1 - &v2)
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_formatting_prius_prefix=l; ac_cv_prius_defined=1
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <stddef.h>
+int
+main ()
+{
+unsigned long long v1 = 0; size_t v2 = 0; return (&v1 - &v2)
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_formatting_prius_prefix=ll; ac_cv_prius_defined=1
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_formatting_prius_prefix" >&5
+$as_echo "$ac_cv_formatting_prius_prefix" >&6; }
+ if test -z "$ac_cv_prius_defined"; then
+ ac_cv_formatting_prius_prefix=z;
+ fi
+
+cat >>confdefs.h <<_ACEOF
+#define PRIuS "${ac_cv_formatting_prius_prefix}u"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PRIxS "${ac_cv_formatting_prius_prefix}x"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define PRIdS "${ac_cv_formatting_prius_prefix}d"
+_ACEOF
+
+
+
+# Here are some examples of how to check for the existence of a fn or file
+for ac_func in getopt_long getopt
+do :
+ as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+for ac_header in getopt.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default"
+if test "x$ac_cv_header_getopt_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_GETOPT_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in utime.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "utime.h" "ac_cv_header_utime_h" "$ac_includes_default"
+if test "x$ac_cv_header_utime_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_UTIME_H 1
+_ACEOF
+
+fi
+
+done
+ # used by unittests to mock file-times
+
+# These are the types I need. We look for them in either stdint.h,
+# sys/types.h, or inttypes.h, all of which are part of the default-includes.
+ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint32_t" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT32_T 1
+_ACEOF
+
+
+fi
+
+ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "$ac_includes_default"
+if test "x$ac_cv_type_u_int32_t" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_U_INT32_T 1
+_ACEOF
+
+
+fi
+
+ac_fn_c_check_type "$LINENO" "__int32" "ac_cv_type___int32" "$ac_includes_default"
+if test "x$ac_cv_type___int32" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE___INT32 1
+_ACEOF
+
+
+fi
+
+ac_fn_c_check_type "$LINENO" "uint64_t" "ac_cv_type_uint64_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint64_t" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT64_T 1
+_ACEOF
+
+
+fi
+
+ac_fn_c_check_type "$LINENO" "u_int64_t" "ac_cv_type_u_int64_t" "$ac_includes_default"
+if test "x$ac_cv_type_u_int64_t" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_U_INT64_T 1
+_ACEOF
+
+
+fi
+
+ac_fn_c_check_type "$LINENO" "__int64" "ac_cv_type___int64" "$ac_includes_default"
+if test "x$ac_cv_type___int64" = xyes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE___INT64 1
+_ACEOF
+
+
+fi
+
+
+ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+ as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if eval \${$as_ac_Header+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ eval "$as_ac_Header=yes"
+else
+ eval "$as_ac_Header=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_ac_Header
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+ cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if ${ac_cv_search_opendir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_opendir+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_opendir+:} false; then :
+
+else
+ ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if ${ac_cv_search_opendir+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+ ;
+ return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+ if test -z "$ac_lib"; then
+ ac_res="none required"
+ else
+ ac_res=-l$ac_lib
+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"
+ fi
+ if ac_fn_c_try_link "$LINENO"; then :
+ ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext
+ if ${ac_cv_search_opendir+:} false; then :
+ break
+fi
+done
+if ${ac_cv_search_opendir+:} false; then :
+
+else
+ ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+ # for template_unittest.cc, template_regtest.cc
+
+# We need to do byte-swapping efficiently to hash efficiently in
+# template_string.cc. Different architectures do this differently.
+for ac_header in byteswap.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "byteswap.h" "ac_cv_header_byteswap_h" "$ac_includes_default"
+if test "x$ac_cv_header_byteswap_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_BYTESWAP_H 1
+_ACEOF
+
+fi
+
+done
+ # Linux (GNU in general)
+for ac_header in libkern/OSByteOrder.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "libkern/OSByteOrder.h" "ac_cv_header_libkern_OSByteOrder_h" "$ac_includes_default"
+if test "x$ac_cv_header_libkern_OSByteOrder_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBKERN_OSBYTEORDER_H 1
+_ACEOF
+
+fi
+
+done
+ # OS X
+for ac_header in sys/byteorder.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/byteorder.h" "ac_cv_header_sys_byteorder_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_byteorder_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_BYTEORDER_H 1
+_ACEOF
+
+fi
+
+done
+ # Solaris 10
+for ac_header in endian.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "endian.h" "ac_cv_header_endian_h" "$ac_includes_default"
+if test "x$ac_cv_header_endian_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_ENDIAN_H 1
+_ACEOF
+
+fi
+
+done
+ # Linux
+for ac_header in machine/endian.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "machine/endian.h" "ac_cv_header_machine_endian_h" "$ac_includes_default"
+if test "x$ac_cv_header_machine_endian_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_MACHINE_ENDIAN_H 1
+_ACEOF
+
+fi
+
+done
+ # OS X
+for ac_header in sys/endian.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/endian.h" "ac_cv_header_sys_endian_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_endian_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_ENDIAN_H 1
+_ACEOF
+
+fi
+
+done
+ # FreeBSD
+for ac_header in sys/isa_defs.h
+do :
+ ac_fn_c_check_header_mongrel "$LINENO" "sys/isa_defs.h" "ac_cv_header_sys_isa_defs_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_isa_defs_h" = xyes; then :
+ cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_ISA_DEFS_H 1
+_ACEOF
+
+fi
+
+done
+ # Solaris 10
+
+# A lot of the code in this directory depends on pthreads
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS" >&5
+$as_echo_n "checking for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+/* Override any GCC internal prototype to avoid an error.
+ Use char because int might match the return type of a GCC
+ builtin and then its argument prototype would still apply. */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pthread_join ();
+int
+main ()
+{
+return pthread_join ();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ acx_pthread_ok=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
+$as_echo "$acx_pthread_ok" >&6; }
+ if test x"$acx_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+ *solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+ case $flag in
+ none)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5
+$as_echo_n "checking whether pthreads work without any flags... " >&6; }
+ ;;
+
+ -*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $flag" >&5
+$as_echo_n "checking whether pthreads work with $flag... " >&6; }
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ # Extract the first word of "pthread-config", so it can be a program name with args.
+set dummy pthread-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_acx_pthread_config+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$acx_pthread_config"; then
+ ac_cv_prog_acx_pthread_config="$acx_pthread_config" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_acx_pthread_config="yes"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ test -z "$ac_cv_prog_acx_pthread_config" && ac_cv_prog_acx_pthread_config="no"
+fi
+fi
+acx_pthread_config=$ac_cv_prog_acx_pthread_config
+if test -n "$acx_pthread_config"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_config" >&5
+$as_echo "$acx_pthread_config" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test x"$acx_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$flag" >&5
+$as_echo_n "checking for the pthreads library -l$flag... " >&6; }
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ acx_pthread_ok=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_pthread_ok" >&5
+$as_echo "$acx_pthread_ok" >&6; }
+ if test "x$acx_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5
+$as_echo_n "checking for joinable pthread attribute... " >&6; }
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+int attr=$attr; return attr;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ attr_name=$attr; break
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+ done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $attr_name" >&5
+$as_echo "$attr_name" >&6; }
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+
+cat >>confdefs.h <<_ACEOF
+#define PTHREAD_CREATE_JOINABLE $attr_name
+_ACEOF
+
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if more special flags are required for pthreads" >&5
+$as_echo_n "checking if more special flags are required for pthreads... " >&6; }
+ flag=no
+ case "${host_cpu}-${host_os}" in
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ esac
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${flag}" >&5
+$as_echo "${flag}" >&6; }
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+ # More AIX lossage: must compile with xlc_r or cc_r
+ if test x"$GCC" != xyes; then
+ for ac_prog in xlc_r cc_r
+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:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_PTHREAD_CC+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ if test -n "$PTHREAD_CC"; then
+ ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # 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 as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_prog_PTHREAD_CC="$ac_prog"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+fi
+fi
+PTHREAD_CC=$ac_cv_prog_PTHREAD_CC
+if test -n "$PTHREAD_CC"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5
+$as_echo "$PTHREAD_CC" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$PTHREAD_CC" && break
+done
+test -n "$PTHREAD_CC" || PTHREAD_CC="${CC}"
+
+ else
+ PTHREAD_CC=$CC
+ fi
+
+ # The next part tries to detect GCC inconsistency with -shared on some
+ # architectures and systems. The problem is that in certain
+ # configurations, when -shared is specified, GCC "forgets" to
+ # internally use various flags which are still necessary.
+
+ #
+ # Prepare the flags
+ #
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_CC="$CC"
+
+ # Try with the flags determined by the earlier checks.
+ #
+ # -Wl,-z,defs forces link-time symbol resolution, so that the
+ # linking checks with -shared actually have any value
+ #
+ # FIXME: -fPIC is required for -shared on many architectures,
+ # so we specify it here, but the right way would probably be to
+ # properly detect whether it is actually required.
+ CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CC="$PTHREAD_CC"
+
+ # In order not to create several levels of indentation, we test
+ # the value of "$done" until we find the cure or run out of ideas.
+ done="no"
+
+ # First, make sure the CFLAGS we added are actually accepted by our
+ # compiler. If not (and OS X's ld, for instance, does not accept -z),
+ # then we can't do this test.
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to check for GCC pthread/shared inconsistencies" >&5
+$as_echo_n "checking whether to check for GCC pthread/shared inconsistencies... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+else
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes ; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ fi
+ fi
+
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -pthread is sufficient with -shared" >&5
+$as_echo_n "checking whether -pthread is sufficient with -shared... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+
+ #
+ # Linux gcc on some architectures such as mips/mipsel forgets
+ # about -lpthread
+ #
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lpthread fixes that" >&5
+$as_echo_n "checking whether -lpthread fixes that... " >&6; }
+ LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+ #
+ # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
+ #
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc_r fixes that" >&5
+$as_echo_n "checking whether -lc_r fixes that... " >&6; }
+ LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+ if test x"$done" = xno; then
+ # OK, we have run out of ideas
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Impossible to determine how to use pthreads with shared libraries" >&5
+$as_echo "$as_me: WARNING: Impossible to determine how to use pthreads with shared libraries" >&2;}
+
+ # so it's not safe to assume that we may use pthreads
+ acx_pthread_ok=no
+ fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether what we have so far is sufficient with -nostdlib" >&5
+$as_echo_n "checking whether what we have so far is sufficient with -nostdlib... " >&6; }
+ CFLAGS="-nostdlib $CFLAGS"
+ # we need c with nostdlib
+ LIBS="$LIBS -lc"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+else
+ done=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+
+ if test x"$done" = xno; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lpthread saves the day" >&5
+$as_echo_n "checking whether -lpthread saves the day... " >&6; }
+ LIBS="-lpthread $LIBS"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <pthread.h>
+int
+main ()
+{
+pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+ done=yes
+else
+ done=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+ if test "x$done" = xyes; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Impossible to determine how to use pthreads with shared libraries and -nostdlib" >&5
+$as_echo "$as_me: WARNING: Impossible to determine how to use pthreads with shared libraries and -nostdlib" >&2;}
+ fi
+ fi
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ CC="$save_CC"
+else
+ PTHREAD_CC="$CC"
+fi
+
+
+
+
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+
+$as_echo "#define HAVE_PTHREAD 1" >>confdefs.h
+
+ :
+else
+ acx_pthread_ok=no
+
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+# We'd like to use read/write locks in several places in the code.
+# See if our pthreads support extends to that. Note: for linux, it
+# does as long as you define _XOPEN_SOURCE appropriately.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking support for pthread_rwlock_* functions" >&5
+$as_echo_n "checking support for pthread_rwlock_* functions... " >&6; }
+if ${ac_cv_rwlock+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#define _XOPEN_SOURCE 500
+ #include <pthread.h>
+ #ifdef __CYGWIN32__
+ # error Cygwin has a bug in pthread_rwlock; disabling
+ #endif
+int
+main ()
+{
+pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
+ pthread_rwlock_rdlock(&l);
+ return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ ac_cv_rwlock=yes
+else
+ ac_cv_rwlock=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_rwlock" >&5
+$as_echo "$ac_cv_rwlock" >&6; }
+if test "$ac_cv_rwlock" = yes; then
+
+$as_echo "#define HAVE_RWLOCK 1" >>confdefs.h
+
+fi
+
+
+# For mingw/cygwin, figure out if the mutex code needs to use
+# 'volatile' in some places. They differ from MSVC, and the API is
+# unclear, so it's best just to check.
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether first argument to InterlockedExchange omits volatile" >&5
+$as_echo_n "checking whether first argument to InterlockedExchange omits volatile... " >&6; }
+if ${ac_cv_interlocked_exchange_nonvolatile+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <windows.h>
+int
+main ()
+{
+volatile LONG once; InterlockedExchange(&once, 1);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_interlocked_exchange_nonvolatile="no"
+else
+ ac_cv_interlocked_exchange_nonvolatile="yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+fi
+
+if test "$ac_cv_interlocked_exchange_nonvolatile" = "yes"; then
+
+$as_echo "#define INTERLOCKED_EXCHANGE_NONVOLATILE 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_interlocked_exchange_nonvolatile" >&5
+$as_echo "$ac_cv_interlocked_exchange_nonvolatile" >&6; }
+
+
+# Find out what namespace 'normal' STL code lives in, and also what namespace
+# the user wants our classes to be defined in
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler implements namespaces" >&5
+$as_echo_n "checking whether the compiler implements namespaces... " >&6; }
+if ${ac_cv_cxx_namespaces+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+namespace Outer {
+ namespace Inner { int i = 0; }}
+int
+main ()
+{
+using namespace Outer::Inner; return i;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_namespaces=yes
+else
+ ac_cv_cxx_namespaces=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_namespaces" >&5
+$as_echo "$ac_cv_cxx_namespaces" >&6; }
+ if test "$ac_cv_cxx_namespaces" = yes; then
+
+$as_echo "#define HAVE_NAMESPACES 1" >>confdefs.h
+
+ fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking what namespace STL code is in" >&5
+$as_echo_n "checking what namespace STL code is in... " >&6; }
+if ${ac_cv_cxx_stl_namespace+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <vector>
+int
+main ()
+{
+vector<int> t; return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_stl_namespace=none
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <vector>
+int
+main ()
+{
+std::vector<int> t; return 0;
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_stl_namespace=std
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_stl_namespace" >&5
+$as_echo "$ac_cv_cxx_stl_namespace" >&6; }
+ if test "$ac_cv_cxx_stl_namespace" = none; then
+
+$as_echo "#define STL_NAMESPACE /**/" >>confdefs.h
+
+ fi
+ if test "$ac_cv_cxx_stl_namespace" = std; then
+
+$as_echo "#define STL_NAMESPACE std" >>confdefs.h
+
+ fi
+
+google_namespace_default=ctemplate
+ # Check whether --enable-namespace was given.
+if test "${enable_namespace+set}" = set; then :
+ enableval=$enable_namespace; case "$enableval" in
+ yes) google_namespace="$google_namespace_default" ;;
+ no) google_namespace="" ;;
+ *) google_namespace="$enableval" ;;
+ esac
+else
+ google_namespace="$google_namespace_default"
+fi
+
+ if test -n "$google_namespace"; then
+ ac_google_namespace="::$google_namespace"
+ ac_google_start_namespace="namespace $google_namespace {"
+ ac_google_end_namespace="}"
+ else
+ ac_google_namespace=""
+ ac_google_start_namespace=""
+ ac_google_end_namespace=""
+ fi
+
+cat >>confdefs.h <<_ACEOF
+#define GOOGLE_NAMESPACE $ac_google_namespace
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define _START_GOOGLE_NAMESPACE_ $ac_google_start_namespace
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define _END_GOOGLE_NAMESPACE_ $ac_google_end_namespace
+_ACEOF
+
+
+
+# Figures out where hash_map and hash_set live, and what namespace they use
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking the location of hash_map" >&5
+$as_echo_n "checking the location of hash_map... " >&6; }
+
+ ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+
+ ac_cv_cxx_hash_map=""
+ # First try unordered_map, but not on gcc's before 4.2 -- I've
+ # seen unexplainable unordered_map bugs with -O2 on older gcc's.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
+ # error GCC too old for unordered_map
+ #endif
+
+int
+main ()
+{
+/* no program body necessary */
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ stl_hash_old_gcc=no
+else
+ stl_hash_old_gcc=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ for location in unordered_map tr1/unordered_map; do
+ for namespace in std std::tr1; do
+ if test -z "$ac_cv_cxx_hash_map" -a "$stl_hash_old_gcc" != yes; then
+ # Some older gcc's have a buggy tr1, so test a bit of code.
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$location>
+int
+main ()
+{
+const ${namespace}::unordered_map<int, int> t;
+ return t.find(5) == t.end();
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_hash_map="<$location>";
+ ac_cv_cxx_hash_namespace="$namespace";
+ ac_cv_cxx_have_unordered_map="yes";
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ done
+ done
+ # Now try hash_map
+ for location in ext/hash_map hash_map; do
+ for namespace in __gnu_cxx "" std stdext; do
+ if test -z "$ac_cv_cxx_hash_map"; then
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include <$location>
+int
+main ()
+{
+${namespace}::hash_map<int, int> t
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ ac_cv_cxx_hash_map="<$location>";
+ ac_cv_cxx_hash_namespace="$namespace";
+ ac_cv_cxx_have_unordered_map="no";
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
+ done
+ done
+ ac_cv_cxx_hash_set=`echo "$ac_cv_cxx_hash_map" | sed s/map/set/`;
+ if test -n "$ac_cv_cxx_hash_map"; then
+
+$as_echo "#define HAVE_HASH_MAP 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_HASH_SET 1" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define HASH_MAP_H $ac_cv_cxx_hash_map
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define HASH_SET_H $ac_cv_cxx_hash_set
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define HASH_NAMESPACE $ac_cv_cxx_hash_namespace
+_ACEOF
+
+ if test "$ac_cv_cxx_have_unordered_map" = yes; then
+
+$as_echo "#define HAVE_UNORDERED_MAP 1" >>confdefs.h
+
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_hash_map" >&5
+$as_echo "$ac_cv_cxx_hash_map" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: " >&5
+$as_echo "" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: could not find an STL hash_map" >&5
+$as_echo "$as_me: WARNING: could not find an STL hash_map" >&2;}
+ fi
+
+
+# If we found tr1/unordered_map, prefer unordered_map/unordered_set to
+# hash_map/hash_set.
+if test "$ac_cv_cxx_have_unordered_map" = yes; then
+ ac_cv_cxx_hash_map_class="$ac_cv_cxx_hash_namespace::unordered_map"
+ ac_cv_cxx_hash_set_class="$ac_cv_cxx_hash_namespace::unordered_set"
+else
+ ac_cv_cxx_hash_map_class="$ac_cv_cxx_hash_namespace::hash_map"
+ ac_cv_cxx_hash_set_class="$ac_cv_cxx_hash_namespace::hash_set"
+fi
+
+
+
+
+
+
+
+
+if test "$ac_cv___attribute__" = "yes"; then
+ ac_google_attribute=1
+
+else
+ ac_google_attribute=0
+
+fi
+if test "$ac_cv_type_u_int64_t" = "yes"; then
+ ac_cv_uint64=u_int64_t
+
+elif test "$ac_cv_type_uint64_t" = "yes"; then
+ ac_cv_uint64=uint64_t
+
+elif test "$ac_cv_type___int64" = "yes"; then
+ ac_cv_uint64=unsigned __int64
+
+else
+ ac_cv_uint64=unsigned long long
+ # best we can do
+fi
+# These are used by template_string.h.in
+if test "$ac_cv_header_stdint_h" = "yes"; then
+ ac_cv_have_stdint_h=1
+
+else
+ ac_cv_have_stdint_h=0
+
+fi
+if test "$ac_cv_header_inttypes_h" = "yes"; then
+ ac_cv_have_inttypes_h=1
+
+else
+ ac_cv_have_inttypes_h=0
+
+fi
+
+
+# One some systems (eg gnu/linux), the linker defines _start and
+# data_start to indicate the extent of the .text section. We can use
+# this to know strings are immutable. In the code, we make the
+# variables weak, just in case, but for this check, we only want to
+# say "yes" if the linker supports the vars, *and* the compiler supports
+# attribute-weak.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+ extern char _start[];
+ extern char data_start[];
+ extern char dummy[] __attribute__((weak));
+ return (_start && data_start && dummy);
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
+ ac_have_attribute_weak=1
+else
+ ac_have_attribute_weak=0
+fi
+rm -f core conftest.err conftest.$ac_objext \
+ conftest$ac_exeext conftest.$ac_ext
+
+
+# In unix (that is, using this script), this dll-export stuff will always
+# be the empty string. In windows, we'll replace it with windows-specific
+# text.
+ac_windows_dllexport_defines=
+ac_windows_dllexport=
+
+
+
+# This will (should) never change, but we put it here so if we do need
+# to change it, to avoid naming conflicts or something, it's easy to
+# do in one place.
+ac_htmlparser_namespace=ctemplate_htmlparser
+
+
+cat >>confdefs.h <<_ACEOF
+#define HTMLPARSER_NAMESPACE $ac_htmlparser_namespace
+_ACEOF
+
+
+# Write generated configuration file, and also .h files
+ac_config_files="$ac_config_files Makefile src/ctemplate/template_string.h src/ctemplate/template_enums.h src/ctemplate/template.h src/ctemplate/template_cache.h src/ctemplate/template_modifiers.h src/ctemplate/template_emitter.h src/ctemplate/template_annotator.h src/ctemplate/template_dictionary.h src/ctemplate/template_pathops.h src/ctemplate/template_namelist.h src/ctemplate/find_ptr.h src/ctemplate/per_expand_data.h src/ctemplate/str_ref.h src/ctemplate/template_dictionary_interface.h"
+
+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
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems. If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+ eval ac_val=\$$ac_var
+ case $ac_val in #(
+ *${as_nl}*)
+ case $ac_var in #(
+ *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+ esac
+ case $ac_var in #(
+ _ | IFS | as_nl) ;; #(
+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+ *) { eval $ac_var=; unset $ac_var;} ;;
+ esac ;;
+ esac
+ done
+
+ (set) 2>&1 |
+ case $as_nl`(ac_space=' '; set) 2>&1` in #(
+ *${as_nl}ac_space=\ *)
+ # `set' does not quote correctly, so add quotes: double-quote
+ # substitution turns \\\\ into \\, and sed turns \\ into \.
+ sed -n \
+ "s/'/'\\\\''/g;
+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+ ;; #(
+ *)
+ # `set' quotes correctly as required by POSIX, so do not add quotes.
+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+ ;;
+ esac |
+ sort
+) |
+ sed '
+ /^ac_cv_env_/b end
+ t clear
+ :clear
+ s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+ t end
+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+ :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+ if test -w "$cache_file"; then
+ if test "x$cache_file" != "x/dev/null"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+ if test ! -f "$cache_file" || test -h "$cache_file"; then
+ cat confcache >"$cache_file"
+ else
+ case $cache_file in #(
+ */* | ?:*)
+ mv -f confcache "$cache_file"$$ &&
+ mv -f "$cache_file"$$ "$cache_file" ;; #(
+ *)
+ mv -f confcache "$cache_file" ;;
+ esac
+ fi
+ fi
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+ fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+ # 1. Remove the extension, and $U if already installed.
+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+ ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR
+ # will be set to the directory where LIBOBJS objects are built.
+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking that generated files are newer than configure" >&5
+$as_echo_n "checking that generated files are newer than configure... " >&6; }
+ if test -n "$am_sleep_pid"; then
+ # Hide warnings about reused PIDs.
+ wait $am_sleep_pid 2>/dev/null
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: done" >&5
+$as_echo "done" >&6; }
+ if test -n "$EXEEXT"; then
+ am__EXEEXT_TRUE=
+ am__EXEEXT_FALSE='#'
+else
+ am__EXEEXT_TRUE='#'
+ am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+ as_fn_error $? "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${GCC_TRUE}" && test -z "${GCC_FALSE}"; then
+ as_fn_error $? "conditional \"GCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${MINGW_TRUE}" && test -z "${MINGW_FALSE}"; then
+ as_fn_error $? "conditional \"MINGW\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCXX_TRUE}" && test -z "${am__fastdepCXX_FALSE}"; then
+ as_fn_error $? "conditional \"am__fastdepCXX\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: "${CONFIG_STATUS=./config.status}"
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+ emulate sh
+ NULLCMD=:
+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in #(
+ *posix*) :
+ set -o posix ;; #(
+ *) :
+ ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+ && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='print -r --'
+ as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+ as_echo='printf %s\n'
+ as_echo_n='printf %s'
+else
+ if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+ as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+ as_echo_n='/usr/ucb/echo -n'
+ else
+ as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+ as_echo_n_body='eval
+ arg=$1;
+ case $arg in #(
+ *"$as_nl"*)
+ expr "X$arg" : "X\\(.*\\)$as_nl";
+ arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+ esac;
+ expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+ '
+ export as_echo_n_body
+ as_echo_n='sh -c $as_echo_n_body as_echo'
+ fi
+ export as_echo_body
+ as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+ PATH_SEPARATOR=:
+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+ PATH_SEPARATOR=';'
+ }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order. Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" "" $as_nl"
+
+# Find who we are. Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+ *[\\/]* ) as_myself=$0 ;;
+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+ as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+ $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+ exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there. '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+ as_status=$1; test $as_status -eq 0 && as_status=1
+ if test "$4"; then
+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+ $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+ fi
+ $as_echo "$as_me: error: $2" >&2
+ as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+ return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+ set +e
+ as_fn_set_status $1
+ exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+ { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+ eval 'as_fn_append ()
+ {
+ eval $1+=\$2
+ }'
+else
+ as_fn_append ()
+ {
+ eval $1=\$$1\$2
+ }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+ eval 'as_fn_arith ()
+ {
+ as_val=$(( $* ))
+ }'
+else
+ as_fn_arith ()
+ {
+ as_val=`expr "$@" || test $? -eq 1`
+ }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+ test "X`expr 00001 : '.*\(...\)'`" = X001; then
+ as_expr=expr
+else
+ as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+ as_basename=basename
+else
+ as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+ as_dirname=dirname
+else
+ as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+ X"$0" : 'X\(//\)$' \| \
+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+ sed '/^.*\/\([^/][^/]*\)\/*$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\/\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+ case `echo 'xy\c'` in
+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.
+ xy) ECHO_C='\c';;
+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null
+ ECHO_T=' ';;
+ esac;;
+*)
+ ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+ rm -f conf$$.dir/conf$$.file
+else
+ rm -f conf$$.dir
+ mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+ if ln -s conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s='ln -s'
+ # ... but there are two gotchas:
+ # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+ # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+ # In both cases, we have to default to `cp -pR'.
+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+ as_ln_s='cp -pR'
+ elif ln conf$$.file conf$$ 2>/dev/null; then
+ as_ln_s=ln
+ else
+ as_ln_s='cp -pR'
+ fi
+else
+ as_ln_s='cp -pR'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+ case $as_dir in #(
+ -*) as_dir=./$as_dir;;
+ esac
+ test -d "$as_dir" || eval $as_mkdir_p || {
+ as_dirs=
+ while :; do
+ case $as_dir in #(
+ *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+ *) as_qdir=$as_dir;;
+ esac
+ as_dirs="'$as_qdir' $as_dirs"
+ as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$as_dir" : 'X\(//\)[^/]' \| \
+ X"$as_dir" : 'X\(//\)$' \| \
+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ test -d "$as_dir" && break
+ done
+ test -z "$as_dirs" || eval "mkdir $as_dirs"
+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+ as_mkdir_p='mkdir -p "$as_dir"'
+else
+ test -d ./-p && rmdir ./-p
+ as_mkdir_p=false
+fi
+
+
+# as_fn_executable_p FILE
+# -----------------------
+# Test if FILE is an executable regular file.
+as_fn_executable_p ()
+{
+ test -f "$1" && test -x "$1"
+} # as_fn_executable_p
+as_test_x='test -x'
+as_executable_p=as_fn_executable_p
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by ctemplate $as_me 2.3, which was
+generated by GNU Autoconf 2.69. Invocation command line was
+
+ CONFIG_FILES = $CONFIG_FILES
+ CONFIG_HEADERS = $CONFIG_HEADERS
+ CONFIG_LINKS = $CONFIG_LINKS
+ CONFIG_COMMANDS = $CONFIG_COMMANDS
+ $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration. Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+ -h, --help print this help, then exit
+ -V, --version print version number and configuration settings, then exit
+ --config print configuration, then exit
+ -q, --quiet, --silent
+ do not print progress messages
+ -d, --debug don't remove temporary files
+ --recheck update $as_me by reconfiguring in the same conditions
+ --file=FILE[:TEMPLATE]
+ instantiate the configuration file FILE
+ --header=FILE[:TEMPLATE]
+ instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to <google-ctemplate@googlegroups.com>."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+ctemplate config.status 2.3
+configured by $0, generated by GNU Autoconf 2.69,
+ with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2012 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+ case $1 in
+ --*=?*)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+ ac_shift=:
+ ;;
+ --*=)
+ ac_option=`expr "X$1" : 'X\([^=]*\)='`
+ ac_optarg=
+ ac_shift=:
+ ;;
+ *)
+ ac_option=$1
+ ac_optarg=$2
+ ac_shift=shift
+ ;;
+ esac
+
+ case $ac_option in
+ # Handling of the options.
+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+ ac_cs_recheck=: ;;
+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+ $as_echo "$ac_cs_version"; exit ;;
+ --config | --confi | --conf | --con | --co | --c )
+ $as_echo "$ac_cs_config"; exit ;;
+ --debug | --debu | --deb | --de | --d | -d )
+ debug=: ;;
+ --file | --fil | --fi | --f )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ '') as_fn_error $? "missing file argument" ;;
+ esac
+ as_fn_append CONFIG_FILES " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --header | --heade | --head | --hea )
+ $ac_shift
+ case $ac_optarg in
+ *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+ esac
+ as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+ ac_need_defaults=false;;
+ --he | --h)
+ # Conflict between --help and --header
+ as_fn_error $? "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+ --help | --hel | -h )
+ $as_echo "$ac_cs_usage"; exit ;;
+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+ | -silent | --silent | --silen | --sile | --sil | --si | --s)
+ ac_cs_silent=: ;;
+
+ # This is an error.
+ -*) as_fn_error $? "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+ *) as_fn_append ac_config_targets " $1"
+ ac_need_defaults=false ;;
+
+ esac
+ shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+ exec 6>/dev/null
+ ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+ shift
+ \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+ CONFIG_SHELL='$SHELL'
+ export CONFIG_SHELL
+ exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+ echo
+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+ $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+enable_fast_install='`$ECHO "X$enable_fast_install" | $Xsed -e "$delay_single_quote_subst"`'
+macro_version='`$ECHO "X$macro_version" | $Xsed -e "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "X$macro_revision" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "X$enable_shared" | $Xsed -e "$delay_single_quote_subst"`'
+enable_static='`$ECHO "X$enable_static" | $Xsed -e "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "X$pic_mode" | $Xsed -e "$delay_single_quote_subst"`'
+host_alias='`$ECHO "X$host_alias" | $Xsed -e "$delay_single_quote_subst"`'
+host='`$ECHO "X$host" | $Xsed -e "$delay_single_quote_subst"`'
+host_os='`$ECHO "X$host_os" | $Xsed -e "$delay_single_quote_subst"`'
+build_alias='`$ECHO "X$build_alias" | $Xsed -e "$delay_single_quote_subst"`'
+build='`$ECHO "X$build" | $Xsed -e "$delay_single_quote_subst"`'
+build_os='`$ECHO "X$build_os" | $Xsed -e "$delay_single_quote_subst"`'
+SED='`$ECHO "X$SED" | $Xsed -e "$delay_single_quote_subst"`'
+Xsed='`$ECHO "X$Xsed" | $Xsed -e "$delay_single_quote_subst"`'
+GREP='`$ECHO "X$GREP" | $Xsed -e "$delay_single_quote_subst"`'
+EGREP='`$ECHO "X$EGREP" | $Xsed -e "$delay_single_quote_subst"`'
+FGREP='`$ECHO "X$FGREP" | $Xsed -e "$delay_single_quote_subst"`'
+LD='`$ECHO "X$LD" | $Xsed -e "$delay_single_quote_subst"`'
+NM='`$ECHO "X$NM" | $Xsed -e "$delay_single_quote_subst"`'
+LN_S='`$ECHO "X$LN_S" | $Xsed -e "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "X$max_cmd_len" | $Xsed -e "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "X$ac_objext" | $Xsed -e "$delay_single_quote_subst"`'
+exeext='`$ECHO "X$exeext" | $Xsed -e "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "X$lt_unset" | $Xsed -e "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "X$lt_SP2NL" | $Xsed -e "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "X$lt_NL2SP" | $Xsed -e "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "X$reload_flag" | $Xsed -e "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "X$reload_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "X$OBJDUMP" | $Xsed -e "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "X$deplibs_check_method" | $Xsed -e "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "X$file_magic_cmd" | $Xsed -e "$delay_single_quote_subst"`'
+AR='`$ECHO "X$AR" | $Xsed -e "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "X$AR_FLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+STRIP='`$ECHO "X$STRIP" | $Xsed -e "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "X$RANLIB" | $Xsed -e "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "X$old_postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "X$old_postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "X$old_archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+CC='`$ECHO "X$CC" | $Xsed -e "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "X$CFLAGS" | $Xsed -e "$delay_single_quote_subst"`'
+compiler='`$ECHO "X$compiler" | $Xsed -e "$delay_single_quote_subst"`'
+GCC='`$ECHO "X$GCC" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "X$lt_cv_sys_global_symbol_pipe" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "X$lt_cv_sys_global_symbol_to_cdecl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "X$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+objdir='`$ECHO "X$objdir" | $Xsed -e "$delay_single_quote_subst"`'
+SHELL='`$ECHO "X$SHELL" | $Xsed -e "$delay_single_quote_subst"`'
+ECHO='`$ECHO "X$ECHO" | $Xsed -e "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "X$MAGIC_CMD" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "X$lt_prog_compiler_no_builtin_flag" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "X$lt_prog_compiler_wl" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "X$lt_prog_compiler_pic" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "X$lt_prog_compiler_static" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "X$lt_cv_prog_compiler_c_o" | $Xsed -e "$delay_single_quote_subst"`'
+need_locks='`$ECHO "X$need_locks" | $Xsed -e "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "X$DSYMUTIL" | $Xsed -e "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "X$NMEDIT" | $Xsed -e "$delay_single_quote_subst"`'
+LIPO='`$ECHO "X$LIPO" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "X$OTOOL" | $Xsed -e "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "X$OTOOL64" | $Xsed -e "$delay_single_quote_subst"`'
+libext='`$ECHO "X$libext" | $Xsed -e "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "X$shrext_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "X$extract_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "X$archive_cmds_need_lc" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "X$enable_shared_with_static_runtimes" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "X$export_dynamic_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "X$whole_archive_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "X$compiler_needs_object" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "X$old_archive_from_new_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "X$old_archive_from_expsyms_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "X$archive_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "X$archive_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "X$module_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "X$module_expsym_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "X$with_gnu_ld" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "X$allow_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "X$no_undefined_flag" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "X$hardcode_libdir_flag_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld='`$ECHO "X$hardcode_libdir_flag_spec_ld" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "X$hardcode_libdir_separator" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "X$hardcode_direct" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "X$hardcode_direct_absolute" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "X$hardcode_minus_L" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "X$hardcode_shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "X$hardcode_automatic" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "X$inherit_rpath" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "X$link_all_deplibs" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path='`$ECHO "X$fix_srcfile_path" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "X$always_export_symbols" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "X$export_symbols_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "X$exclude_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "X$include_expsyms" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "X$prelink_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "X$file_list_spec" | $Xsed -e "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "X$variables_saved_for_relink" | $Xsed -e "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "X$need_lib_prefix" | $Xsed -e "$delay_single_quote_subst"`'
+need_version='`$ECHO "X$need_version" | $Xsed -e "$delay_single_quote_subst"`'
+version_type='`$ECHO "X$version_type" | $Xsed -e "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "X$runpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "X$shlibpath_var" | $Xsed -e "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "X$shlibpath_overrides_runpath" | $Xsed -e "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "X$libname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "X$library_names_spec" | $Xsed -e "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "X$soname_spec" | $Xsed -e "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "X$postinstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "X$postuninstall_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "X$finish_cmds" | $Xsed -e "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "X$finish_eval" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "X$hardcode_into_libs" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "X$sys_lib_search_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "X$sys_lib_dlsearch_path_spec" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "X$hardcode_action" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "X$enable_dlopen" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "X$enable_dlopen_self" | $Xsed -e "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "X$enable_dlopen_self_static" | $Xsed -e "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "X$old_striplib" | $Xsed -e "$delay_single_quote_subst"`'
+striplib='`$ECHO "X$striplib" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "X$compiler_lib_search_dirs" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "X$predep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "X$postdep_objects" | $Xsed -e "$delay_single_quote_subst"`'
+predeps='`$ECHO "X$predeps" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps='`$ECHO "X$postdeps" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "X$compiler_lib_search_path" | $Xsed -e "$delay_single_quote_subst"`'
+LD_CXX='`$ECHO "X$LD_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_cmds_CXX='`$ECHO "X$old_archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_CXX='`$ECHO "X$compiler_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+GCC_CXX='`$ECHO "X$GCC_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "X$lt_prog_compiler_no_builtin_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_CXX='`$ECHO "X$lt_prog_compiler_wl_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_CXX='`$ECHO "X$lt_prog_compiler_pic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_prog_compiler_static_CXX='`$ECHO "X$lt_prog_compiler_static_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_CXX='`$ECHO "X$lt_cv_prog_compiler_c_o_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_need_lc_CXX='`$ECHO "X$archive_cmds_need_lc_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_CXX='`$ECHO "X$enable_shared_with_static_runtimes_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_CXX='`$ECHO "X$export_dynamic_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+whole_archive_flag_spec_CXX='`$ECHO "X$whole_archive_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_needs_object_CXX='`$ECHO "X$compiler_needs_object_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_CXX='`$ECHO "X$old_archive_from_new_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_CXX='`$ECHO "X$old_archive_from_expsyms_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_cmds_CXX='`$ECHO "X$archive_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+archive_expsym_cmds_CXX='`$ECHO "X$archive_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+module_cmds_CXX='`$ECHO "X$module_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+module_expsym_cmds_CXX='`$ECHO "X$module_expsym_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+with_gnu_ld_CXX='`$ECHO "X$with_gnu_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+allow_undefined_flag_CXX='`$ECHO "X$allow_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+no_undefined_flag_CXX='`$ECHO "X$no_undefined_flag_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_CXX='`$ECHO "X$hardcode_libdir_flag_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_ld_CXX='`$ECHO "X$hardcode_libdir_flag_spec_ld_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_libdir_separator_CXX='`$ECHO "X$hardcode_libdir_separator_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_CXX='`$ECHO "X$hardcode_direct_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_direct_absolute_CXX='`$ECHO "X$hardcode_direct_absolute_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_minus_L_CXX='`$ECHO "X$hardcode_minus_L_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_CXX='`$ECHO "X$hardcode_shlibpath_var_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_automatic_CXX='`$ECHO "X$hardcode_automatic_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+inherit_rpath_CXX='`$ECHO "X$inherit_rpath_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+link_all_deplibs_CXX='`$ECHO "X$link_all_deplibs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+fix_srcfile_path_CXX='`$ECHO "X$fix_srcfile_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+always_export_symbols_CXX='`$ECHO "X$always_export_symbols_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+export_symbols_cmds_CXX='`$ECHO "X$export_symbols_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+exclude_expsyms_CXX='`$ECHO "X$exclude_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+include_expsyms_CXX='`$ECHO "X$include_expsyms_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+prelink_cmds_CXX='`$ECHO "X$prelink_cmds_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+file_list_spec_CXX='`$ECHO "X$file_list_spec_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+hardcode_action_CXX='`$ECHO "X$hardcode_action_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_CXX='`$ECHO "X$compiler_lib_search_dirs_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+predep_objects_CXX='`$ECHO "X$predep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+postdep_objects_CXX='`$ECHO "X$postdep_objects_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+predeps_CXX='`$ECHO "X$predeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+postdeps_CXX='`$ECHO "X$postdeps_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+compiler_lib_search_path_CXX='`$ECHO "X$compiler_lib_search_path_CXX" | $Xsed -e "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+OBJDUMP \
+deplibs_check_method \
+file_magic_cmd \
+AR \
+AR_FLAGS \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+SHELL \
+ECHO \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_wl \
+lt_prog_compiler_pic \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_flag_spec_ld \
+hardcode_libdir_separator \
+fix_srcfile_path \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_CXX \
+compiler_CXX \
+lt_prog_compiler_no_builtin_flag_CXX \
+lt_prog_compiler_wl_CXX \
+lt_prog_compiler_pic_CXX \
+lt_prog_compiler_static_CXX \
+lt_cv_prog_compiler_c_o_CXX \
+export_dynamic_flag_spec_CXX \
+whole_archive_flag_spec_CXX \
+compiler_needs_object_CXX \
+with_gnu_ld_CXX \
+allow_undefined_flag_CXX \
+no_undefined_flag_CXX \
+hardcode_libdir_flag_spec_CXX \
+hardcode_libdir_flag_spec_ld_CXX \
+hardcode_libdir_separator_CXX \
+fix_srcfile_path_CXX \
+exclude_expsyms_CXX \
+include_expsyms_CXX \
+file_list_spec_CXX \
+compiler_lib_search_dirs_CXX \
+predep_objects_CXX \
+postdep_objects_CXX \
+predeps_CXX \
+postdeps_CXX \
+compiler_lib_search_path_CXX; do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+old_archive_cmds_CXX \
+old_archive_from_new_cmds_CXX \
+old_archive_from_expsyms_cmds_CXX \
+archive_cmds_CXX \
+archive_expsym_cmds_CXX \
+module_cmds_CXX \
+module_expsym_cmds_CXX \
+export_symbols_cmds_CXX \
+prelink_cmds_CXX; do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[\\\\\\\`\\"\\\$]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\$0 --fallback-echo"') lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\$0 --fallback-echo"\$/\$0 --fallback-echo"/'\`
+ ;;
+esac
+
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'
+
+
+
+
+
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+ case $ac_config_target in
+ "src/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/config.h" ;;
+ "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+ "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;
+ "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+ "src/ctemplate/template_string.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_string.h" ;;
+ "src/ctemplate/template_enums.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_enums.h" ;;
+ "src/ctemplate/template.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template.h" ;;
+ "src/ctemplate/template_cache.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_cache.h" ;;
+ "src/ctemplate/template_modifiers.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_modifiers.h" ;;
+ "src/ctemplate/template_emitter.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_emitter.h" ;;
+ "src/ctemplate/template_annotator.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_annotator.h" ;;
+ "src/ctemplate/template_dictionary.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_dictionary.h" ;;
+ "src/ctemplate/template_pathops.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_pathops.h" ;;
+ "src/ctemplate/template_namelist.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_namelist.h" ;;
+ "src/ctemplate/find_ptr.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/find_ptr.h" ;;
+ "src/ctemplate/per_expand_data.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/per_expand_data.h" ;;
+ "src/ctemplate/str_ref.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/str_ref.h" ;;
+ "src/ctemplate/template_dictionary_interface.h") CONFIG_FILES="$CONFIG_FILES src/ctemplate/template_dictionary_interface.h" ;;
+
+ *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+ esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used. Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+ test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+ test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+ test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience. Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+ tmp= ac_tmp=
+ trap 'exit_status=$?
+ : "${ac_tmp:=$tmp}"
+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status
+' 0
+ trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+ test -d "$tmp"
+} ||
+{
+ tmp=./conf$$-$RANDOM
+ (umask 077 && mkdir "$tmp")
+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5
+ac_tmp=$tmp
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+ eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+ ac_cs_awk_cr='\\r'
+else
+ ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$ac_tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+ echo "cat >conf$$subs.awk <<_ACEOF" &&
+ echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+ echo "_ACEOF"
+} >conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+ . ./conf$$subs.sh ||
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+
+ ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+ if test $ac_delim_n = $ac_delim_num; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+ N
+ s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$ac_tmp/subs1.awk" <<_ACAWK &&
+ for (key in S) S_is_set[key] = 1
+ FS = ""
+
+}
+{
+ line = $ 0
+ nfields = split(line, field, "@")
+ substed = 0
+ len = length(field[1])
+ for (i = 2; i < nfields; i++) {
+ key = field[i]
+ keylen = length(key)
+ if (S_is_set[key]) {
+ value = S[key]
+ line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+ len += length(value) + length(field[++i])
+ substed = 1
+ } else
+ len += 1 + keylen
+ }
+
+ print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+ sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+ cat
+fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \
+ || as_fn_error $? "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove sole $(srcdir),
+# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+ ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{
+h
+s///
+s/^/:/
+s/[ ]*$/:/
+s/:\$(srcdir):/:/g
+s/:\${srcdir}:/:/g
+s/:@srcdir@:/:/g
+s/^:*//
+s/:*$//
+x
+s/\(=[ ]*\).*/\1/
+G
+s/\n//
+s/^[^=]*=[ ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`
+ if test -z "$ac_tt"; then
+ break
+ elif $ac_last_try; then
+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5
+ else
+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+ fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any. Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[ ]*#[ ]*define[ ][ ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ for (key in D) D_is_set[key] = 1
+ FS = ""
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+ line = \$ 0
+ split(line, arg, " ")
+ if (arg[1] == "#") {
+ defundef = arg[2]
+ mac1 = arg[3]
+ } else {
+ defundef = substr(arg[1], 2)
+ mac1 = arg[2]
+ }
+ split(mac1, mac2, "(") #)
+ macro = mac2[1]
+ prefix = substr(line, 1, index(line, defundef) - 1)
+ if (D_is_set[macro]) {
+ # Preserve the white space surrounding the "#".
+ print prefix "define", macro P[macro] D[macro]
+ next
+ } else {
+ # Replace #undef with comments. This is necessary, for example,
+ # in the case of _POSIX_SOURCE, which is predefined and required
+ # on some systems where configure will not decide to define it.
+ if (defundef == "undef") {
+ print "/*", prefix defundef, macro, "*/"
+ next
+ }
+ }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+ case $ac_tag in
+ :[FHLC]) ac_mode=$ac_tag; continue;;
+ esac
+ case $ac_mode$ac_tag in
+ :[FHL]*:*);;
+ :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;;
+ :[FH]-) ac_tag=-:-;;
+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+ esac
+ ac_save_IFS=$IFS
+ IFS=:
+ set x $ac_tag
+ IFS=$ac_save_IFS
+ shift
+ ac_file=$1
+ shift
+
+ case $ac_mode in
+ :L) ac_source=$1;;
+ :[FH])
+ ac_file_inputs=
+ for ac_f
+ do
+ case $ac_f in
+ -) ac_f="$ac_tmp/stdin";;
+ *) # Look for the file first in the build tree, then in the source tree
+ # (if the path is not absolute). The absolute path cannot be DOS-style,
+ # because $ac_f cannot contain `:'.
+ test -f "$ac_f" ||
+ case $ac_f in
+ [\\/$]*) false;;
+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+ esac ||
+ as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+ esac
+ case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+ as_fn_append ac_file_inputs " '$ac_f'"
+ done
+
+ # Let's still pretend it is `configure' which instantiates (i.e., don't
+ # use $as_me), people would be surprised to read:
+ # /* config.h. Generated by config.status. */
+ configure_input='Generated from '`
+ $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+ `' by configure.'
+ if test x"$ac_file" != x-; then
+ configure_input="$ac_file. $configure_input"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+ fi
+ # Neutralize special characters interpreted by sed in replacement strings.
+ case $configure_input in #(
+ *\&* | *\|* | *\\* )
+ ac_sed_conf_input=`$as_echo "$configure_input" |
+ sed 's/[\\\\&|]/\\\\&/g'`;; #(
+ *) ac_sed_conf_input=$configure_input;;
+ esac
+
+ case $ac_tag in
+ *:-:* | *:-) cat >"$ac_tmp/stdin" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;
+ esac
+ ;;
+ esac
+
+ ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$ac_file" : 'X\(//\)[^/]' \| \
+ X"$ac_file" : 'X\(//\)$' \| \
+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir="$ac_dir"; as_fn_mkdir_p
+ ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+ ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+ # A ".." for each directory in $ac_dir_suffix.
+ ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+ case $ac_top_builddir_sub in
+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+ esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+ .) # We are building in place.
+ ac_srcdir=.
+ ac_top_srcdir=$ac_top_builddir_sub
+ ac_abs_top_srcdir=$ac_pwd ;;
+ [\\/]* | ?:[\\/]* ) # Absolute name.
+ ac_srcdir=$srcdir$ac_dir_suffix;
+ ac_top_srcdir=$srcdir
+ ac_abs_top_srcdir=$srcdir ;;
+ *) # Relative name.
+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+ ac_top_srcdir=$ac_top_build_prefix$srcdir
+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+ case $ac_mode in
+ :F)
+ #
+ # CONFIG_FILE
+ #
+
+ case $INSTALL in
+ [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+ *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+ esac
+ ac_MKDIR_P=$MKDIR_P
+ case $MKDIR_P in
+ [\\/$]* | ?:[\\/]* ) ;;
+ */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+ esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+ p
+ q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ ac_datarootdir_hack='
+ s&@datadir@&$datadir&g
+ s&@docdir@&$docdir&g
+ s&@infodir@&$infodir&g
+ s&@localedir@&$localedir&g
+ s&@mandir@&$mandir&g
+ s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \
+ >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+ { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } &&
+ { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \
+ "$ac_tmp/out"`; test -z "$ac_out"; } &&
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined. Please make sure it is defined" >&2;}
+
+ rm -f "$ac_tmp/stdin"
+ case $ac_file in
+ -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";;
+ *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";;
+ esac \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ ;;
+ :H)
+ #
+ # CONFIG_HEADER
+ #
+ if test x"$ac_file" != x-; then
+ {
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"
+ } >"$ac_tmp/config.h" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+ else
+ rm -f "$ac_file"
+ mv "$ac_tmp/config.h" "$ac_file" \
+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5
+ fi
+ else
+ $as_echo "/* $configure_input */" \
+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \
+ || as_fn_error $? "could not create -" "$LINENO" 5
+ fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+ case $_am_header in
+ $_am_arg | $_am_arg:* )
+ break ;;
+ * )
+ _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+ esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$_am_arg" : 'X\(//\)[^/]' \| \
+ X"$_am_arg" : 'X\(//\)$' \| \
+ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+ :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+ esac
+
+
+ case $ac_file$ac_mode in
+ "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+ # Older Autoconf quotes --file arguments for eval, but not when files
+ # are listed without --file. Let's play safe and only enable the eval
+ # if we detect the quoting.
+ case $CONFIG_FILES in
+ *\'*) eval set x "$CONFIG_FILES" ;;
+ *) set x $CONFIG_FILES ;;
+ esac
+ shift
+ for mf
+ do
+ # Strip MF so we end up with the name of the file.
+ mf=`echo "$mf" | sed -e 's/:.*$//'`
+ # Check whether this is an Automake generated Makefile or not.
+ # We used to match only the files named 'Makefile.in', but
+ # some people rename them; so instead we look at the file content.
+ # Grep'ing the first line is not enough: some people post-process
+ # each Makefile.in and add a new line on top of each file to say so.
+ # Grep'ing the whole file is not good either: AIX grep has a line
+ # limit of 2048, but all sed's we know have understand at least 4000.
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+ dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$mf" : 'X\(//\)[^/]' \| \
+ X"$mf" : 'X\(//\)$' \| \
+ X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ else
+ continue
+ fi
+ # Extract the definition of DEPDIR, am__include, and am__quote
+ # from the Makefile without running 'make'.
+ DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+ test -z "$DEPDIR" && continue
+ am__include=`sed -n 's/^am__include = //p' < "$mf"`
+ test -z "$am__include" && continue
+ am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+ # Find all dependency output files, they are included files with
+ # $(DEPDIR) in their names. We invoke sed twice because it is the
+ # simplest approach to changing $(DEPDIR) to its actual value in the
+ # expansion.
+ for file in `sed -n "
+ s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do
+ # Make sure the directory exists.
+ test -f "$dirpart/$file" && continue
+ fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$file" : 'X\(//\)[^/]' \| \
+ X"$file" : 'X\(//\)$' \| \
+ X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'`
+ as_dir=$dirpart/$fdir; as_fn_mkdir_p
+ # echo "creating $dirpart/$file"
+ echo '# dummy' > "$dirpart/$file"
+ done
+ done
+}
+ ;;
+ "libtool":C)
+
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+
+# The names of the tagged configurations supported by this script.
+available_tags="CXX "
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# What type of objects to build.
+pic_mode=$pic_mode
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
+
+# A grep program that handles long lines.
+GREP=$lt_GREP
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# A literal string matcher.
+FGREP=$lt_FGREP
+
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
+
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
+
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
+
+# Object file suffix (normally "o").
+objext=$ac_objext
+
+# Executable file suffix (normally "").
+exeext=$exeext
+
+# whether the shell understands "unset".
+lt_unset=$lt_unset
+
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
+
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# An object symbol dumper.
+OBJDUMP=$lt_OBJDUMP
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# An echo program that does not interpret backslashes.
+ECHO=$lt_ECHO
+
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
+
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
+
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
+
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
+
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
+
+# Old archive suffix (normally "a").
+libext=$libext
+
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
+
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Library versioning type.
+version_type=$version_type
+
+# Shared library runtime path variable.
+runpath_var=$runpath_var
+
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names. First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
+
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
+
+# A language specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking. This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+
+ltmain="$ac_aux_dir/ltmain.sh"
+
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ case $xsi_shell in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+ func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=${1%%=*}
+ func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=$(( $* ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=${#1}
+}
+
+_LT_EOF
+ ;;
+ *) # Bourne compatible functions.
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+ esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[^=]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[^=]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[^.]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=`expr "$@"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$1+=\$2"
+}
+_LT_EOF
+ ;;
+ *)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$1=\$$1\$2"
+}
+
+_LT_EOF
+ ;;
+ esac
+
+
+ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+
+
+ cat <<_LT_EOF >> "$ofile"
+
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
+
+# The linker used to build libraries.
+LD=$lt_LD_CXX
+
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_CXX
+
+# A language specific compiler.
+CC=$lt_compiler_CXX
+
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_CXX
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
+
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_CXX
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
+
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_CXX
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
+
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+
+# If ld is used when linking, flag to hardcode \$libdir into a binary
+# during linking. This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_CXX
+
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_CXX
+
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
+
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
+
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_CXX
+
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_CXX
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path=$lt_fix_srcfile_path_CXX
+
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
+
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_CXX
+
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_CXX
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
+
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+
+# ### END LIBTOOL TAG CONFIG: CXX
+_LT_EOF
+
+ ;;
+
+ esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded. So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status. When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+ ac_cs_success=:
+ ac_config_status_args=
+ test "$silent" = yes &&
+ ac_config_status_args="$ac_config_status_args --quiet"
+ exec 5>/dev/null
+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+ exec 5>>config.log
+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+ # would make configure fail if this is the last instruction.
+ $ac_cs_success || as_fn_exit 1
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..8365989
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,204 @@
+## Process this file with autoconf to produce configure.
+## In general, the safest way to proceed is to run ./autogen.sh
+
+# make sure we're interpreted by some minimal autoconf
+AC_PREREQ(2.57)
+
+AC_INIT(ctemplate, 2.3, google-ctemplate@googlegroups.com)
+AM_SILENT_RULES([yes])
+
+# Update this value for every release! (A:B:C will map to foo.so.(A-C).C.B)
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+SO_VERSION=3:0:0
+
+# The argument here is just something that should be in the current directory
+# (for sanity checking)
+AC_CONFIG_SRCDIR(README)
+AC_CONFIG_MACRO_DIR([m4])
+AC_CANONICAL_HOST
+AM_INIT_AUTOMAKE([subdir-objects dist-zip])
+AM_CONFIG_HEADER(src/config.h)
+
+# Checks for programs.
+AC_PROG_CXX
+AC_PROG_CC
+AM_PROG_CC_C_O
+AC_PROG_CPP
+AM_CONDITIONAL(GCC, test "$GCC" = yes) # let the Makefile know if we're gcc
+
+# MinGW uses autoconf, but also needs the windows shim routines
+# (since it doesn't have its own support for, say, pthreads).
+# This requires us to #include a special header file, and also to
+# link in some windows versions of .o's instead of the unix versions.
+AH_BOTTOM([
+#if defined( __MINGW32__) || defined(__MINGW64__)
+#include "windows/port.h"
+#endif
+])
+case $host_os in
+ *mingw*)
+ # Disabling fast install keeps libtool from creating wrapper scripts
+ # around the executables it builds. Such scripts have caused failures on
+ # MinGW. Using this option means an extra link step is executed during
+ # "make install".
+ AC_DISABLE_FAST_INSTALL
+ ;;
+ *)
+ AC_ENABLE_FAST_INSTALL
+ ;;
+esac
+AM_CONDITIONAL(MINGW, expr $host : '.*-mingw' >/dev/null 2>&1)
+
+# Uncomment this if you'll be exporting libraries (.so's)
+AC_PROG_LIBTOOL
+AC_SUBST(LIBTOOL_DEPS)
+AC_SUBST(SO_VERSION)
+
+AC_PROG_LN_S
+
+AX_C___ATTRIBUTE__
+
+# Check whether some low-level functions/files are available
+AC_HEADER_STDC
+
+# Defines PRIuS
+AC_COMPILER_CHARACTERISTICS
+
+# Here are some examples of how to check for the existence of a fn or file
+AC_CHECK_FUNCS([getopt_long getopt])
+AC_CHECK_HEADERS([getopt.h])
+AC_CHECK_HEADERS([utime.h]) # used by unittests to mock file-times
+
+# These are the types I need. We look for them in either stdint.h,
+# sys/types.h, or inttypes.h, all of which are part of the default-includes.
+AC_CHECK_TYPES([uint32_t])
+AC_CHECK_TYPES([u_int32_t])
+AC_CHECK_TYPES([__int32])
+AC_CHECK_TYPES([uint64_t])
+AC_CHECK_TYPES([u_int64_t])
+AC_CHECK_TYPES([__int64])
+
+AC_HEADER_DIRENT # for template_unittest.cc, template_regtest.cc
+
+# We need to do byte-swapping efficiently to hash efficiently in
+# template_string.cc. Different architectures do this differently.
+AC_CHECK_HEADERS(byteswap.h) # Linux (GNU in general)
+AC_CHECK_HEADERS(libkern/OSByteOrder.h) # OS X
+AC_CHECK_HEADERS(sys/byteorder.h) # Solaris 10
+AC_CHECK_HEADERS(endian.h) # Linux
+AC_CHECK_HEADERS(machine/endian.h) # OS X
+AC_CHECK_HEADERS(sys/endian.h) # FreeBSD
+AC_CHECK_HEADERS(sys/isa_defs.h) # Solaris 10
+
+# A lot of the code in this directory depends on pthreads
+ACX_PTHREAD
+
+# We'd like to use read/write locks in several places in the code.
+# See if our pthreads support extends to that. Note: for linux, it
+# does as long as you define _XOPEN_SOURCE appropriately.
+AC_RWLOCK
+
+# For mingw/cygwin, figure out if the mutex code needs to use
+# 'volatile' in some places. They differ from MSVC, and the API is
+# unclear, so it's best just to check.
+AC_INTERLOCKED_EXCHANGE_NONVOLATILE
+
+# Find out what namespace 'normal' STL code lives in, and also what namespace
+# the user wants our classes to be defined in
+AC_CXX_STL_NAMESPACE
+AC_DEFINE_GOOGLE_NAMESPACE(ctemplate)
+
+# Figures out where hash_map and hash_set live, and what namespace they use
+AC_CXX_STL_HASH
+
+# If we found tr1/unordered_map, prefer unordered_map/unordered_set to
+# hash_map/hash_set.
+if test "$ac_cv_cxx_have_unordered_map" = yes; then
+ ac_cv_cxx_hash_map_class="$ac_cv_cxx_hash_namespace::unordered_map"
+ ac_cv_cxx_hash_set_class="$ac_cv_cxx_hash_namespace::unordered_set"
+else
+ ac_cv_cxx_hash_map_class="$ac_cv_cxx_hash_namespace::hash_map"
+ ac_cv_cxx_hash_set_class="$ac_cv_cxx_hash_namespace::hash_set"
+fi
+
+AC_SUBST(ac_google_namespace)
+AC_SUBST(ac_google_start_namespace)
+AC_SUBST(ac_google_end_namespace)
+AC_SUBST(ac_cv_cxx_hash_map)
+AC_SUBST(ac_cv_cxx_hash_set)
+AC_SUBST(ac_cv_cxx_hash_map_class)
+AC_SUBST(ac_cv_cxx_hash_set_class)
+if test "$ac_cv___attribute__" = "yes"; then
+ AC_SUBST(ac_google_attribute, 1)
+else
+ AC_SUBST(ac_google_attribute, 0)
+fi
+if test "$ac_cv_type_u_int64_t" = "yes"; then
+ AC_SUBST(ac_cv_uint64, u_int64_t)
+elif test "$ac_cv_type_uint64_t" = "yes"; then
+ AC_SUBST(ac_cv_uint64, uint64_t)
+elif test "$ac_cv_type___int64" = "yes"; then
+ AC_SUBST(ac_cv_uint64, unsigned __int64)
+else
+ AC_SUBST(ac_cv_uint64, unsigned long long) # best we can do
+fi
+# These are used by template_string.h.in
+if test "$ac_cv_header_stdint_h" = "yes"; then
+ AC_SUBST(ac_cv_have_stdint_h, 1)
+else
+ AC_SUBST(ac_cv_have_stdint_h, 0)
+fi
+if test "$ac_cv_header_inttypes_h" = "yes"; then
+ AC_SUBST(ac_cv_have_inttypes_h, 1)
+else
+ AC_SUBST(ac_cv_have_inttypes_h, 0)
+fi
+
+
+# One some systems (eg gnu/linux), the linker defines _start and
+# data_start to indicate the extent of the .text section. We can use
+# this to know strings are immutable. In the code, we make the
+# variables weak, just in case, but for this check, we only want to
+# say "yes" if the linker supports the vars, *and* the compiler supports
+# attribute-weak.
+AC_TRY_LINK([], [ extern char _start[];
+ extern char data_start[];
+ extern char dummy[] __attribute__((weak));
+ return (_start && data_start && dummy); ],
+ [ ac_have_attribute_weak=1 ], [ ac_have_attribute_weak=0 ])
+AC_SUBST(ac_have_attribute_weak)
+
+# In unix (that is, using this script), this dll-export stuff will always
+# be the empty string. In windows, we'll replace it with windows-specific
+# text.
+ac_windows_dllexport_defines=
+ac_windows_dllexport=
+AC_SUBST(ac_windows_dllexport_defines)
+AC_SUBST(ac_windows_dllexport)
+
+# This will (should) never change, but we put it here so if we do need
+# to change it, to avoid naming conflicts or something, it's easy to
+# do in one place.
+ac_htmlparser_namespace=ctemplate_htmlparser
+AC_SUBST(ac_htmlparser_namespace)
+AC_DEFINE_UNQUOTED(HTMLPARSER_NAMESPACE, $ac_htmlparser_namespace,
+ [The namespace to put the htmlparser code.])
+
+# Write generated configuration file, and also .h files
+AC_CONFIG_FILES([Makefile \
+ src/ctemplate/template_string.h \
+ src/ctemplate/template_enums.h \
+ src/ctemplate/template.h \
+ src/ctemplate/template_cache.h \
+ src/ctemplate/template_modifiers.h \
+ src/ctemplate/template_emitter.h \
+ src/ctemplate/template_annotator.h \
+ src/ctemplate/template_dictionary.h \
+ src/ctemplate/template_pathops.h \
+ src/ctemplate/template_namelist.h \
+ src/ctemplate/find_ptr.h \
+ src/ctemplate/per_expand_data.h \
+ src/ctemplate/str_ref.h \
+ src/ctemplate/template_dictionary_interface.h \
+ ])
+AC_OUTPUT
diff --git a/contrib/README.contrib b/contrib/README.contrib
new file mode 100644
index 0000000..861ba7c
--- /dev/null
+++ b/contrib/README.contrib
@@ -0,0 +1,13 @@
+All files under this contrib directory are UNSUPPORTED; use at your
+own risk. They were provided by users of ctemplate and were not
+tested by the authors of ctemplate. These files are not owned by
+Google. Please contact the authors of the contributions for help
+about these, not the ctemplate authors. Thanks!, and enjoy.
+
+highlighting.vim by Patrick Lacasse <patlac@borabora.crchul.ulaval.ca>
+ How to set up syntax highlighting (colorization) for ctemplate .tpl
+ files, using vim. A shar file; see top-of-file for how to extract.
+
+tpl-mode.el by Tony Gentilcore
+ Elisp file for syntax highlighting (colorization) for ctemplate
+ .tpl files, using emacs. See top-of-file for how to use.
diff --git a/contrib/convert_to_95.pl b/contrib/convert_to_95.pl
new file mode 100755
index 0000000..1b70e1c
--- /dev/null
+++ b/contrib/convert_to_95.pl
@@ -0,0 +1,117 @@
+#!/usr/bin/perl -pli.bak
+
+# Copyright (c) 2006, Google Inc.
+# 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 Google Inc. 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.
+#
+# ---
+# Author: Craig Silverstein
+
+# This is a perl script for editing your source files that were
+# written with ctemplate <0.95, to use the new #include paths,
+# namespace names, and function locations in ctemplate 0.95.
+#
+# This script will modify your files in place. It is safe to
+# call it multiple times. To call it, do something like:
+# find <root of my project tree> -print0 | xargs -0 ./convert_to_95.pl
+#
+# Issues:
+# TemplateFromString logic is tricky. Best to check up by hand.
+# Can't always tell when 1st arg to TemplateFromString is empty string.
+# If it might be for your app, change the logic to use StringToTemplate.
+# Fails if TemplateFromString or StringToTemplate span multiple lines.
+
+# Change all the #include lines
+s@google/template.h@ctemplate/template.h@g;
+s@google/per_expand_data.h@ctemplate/per_expand_data.h@g;
+s@google/template.h@ctemplate/template.h@g;
+s@google/template_annotator.h@ctemplate/template_annotator.h@g;
+s@google/template_dictionary.h@ctemplate/template_dictionary.h@g;
+s@google/template_dictionary_interface.h@ctemplate/template_dictionary_interface.h@g;
+s@google/template_emitter.h@ctemplate/template_emitter.h@g;
+s@google/template_enums.h@ctemplate/template_enums.h@g;
+s@google/template_from_string.h@ctemplate/template_from_string.h@g;
+s@google/template_modifiers.h@ctemplate/template_modifiers.h@g;
+s@google/template_namelist.h@ctemplate/template_namelist.h@g;
+s@google/template_pathops.h@ctemplate/template_pathops.h@g;
+s@google/template_string.h@ctemplate/template_string.h@g;
+
+# Change all the namespace uses
+s@namespace\s+google@namespace ctemplate@g; # brought into google namespace
+s@\bgoogle::@ctemplate::@g;
+s@namespace\s+template_modifiers\s*{@@ && ($in_tm = 1);
+$in_tm && s@}@@ && ($in_tm = 0);
+s@\btemplate_modifiers::@@g;
+
+# Change TemplateFromString::GetTemplate to
+# Template::StringToTemplateCache(cache_key, template_text);
+# return Template::GetTemplate(cache_key, strip);
+# unless cache_key is the empty string, in which case it should be
+# return Template::StringToTemplate(template_text, strip, TC_MANUAL);
+# We have to be tricky, to do this in one command.
+# Better would be to just do Template::StringToTemplate(), but then we
+# have to free the memory when we're done, which is too hard to do here.
+s@TemplateFromString::GetTemplate\s*\(""\s*,([^,]+),([^,]+)\)@Template::StringToTemplate($1, $2, ctemplate::TC_MANUAL)@;
+s@TemplateFromString::GetTemplate\s*\(([^,]+),([^,]+),([^,]+)\)@Template::GetTemplate((ctemplate::Template::StringToTemplateCache($1, $2), $1), $3)@;
+
+if (m@TemplateFromString::GetTemplate\s*\([^)]*$@) {
+ warn("$ARGV:$.: TemplateFromString spans mutiple lines. You will need " .
+ "to clean it up by hand. See comments in $0.");
+}
+
+# Get rid of the 4th arg to Template::TemplateToString. If it's
+# TC_MANUAL, that's fine. If it's not, we need to tell the user to
+# fix this up manually by adding an {{%PRAGMA AUTOESCAPE}} to the
+# beginning of their string.
+if (s@(\bStringToTemplate\s*\([^)]*),\s*TC_([A-Z_]*)@$1@g) {
+ if ($2 ne "MANUAL") { # TC_MANUAL is the new default
+ warn("WARNING: $ARGV:$.: You will need to manually fix up the " .
+ "StringToTemplate change to add an AUTOESCAPE {{\%pragma}} to " .
+ "the beginning of the input string, to set the context to TC_$2\n");
+ }
+}
+if (m@\bStringToTemplate\s*\([^)]*$@) {
+ warn("$ARGV:$.: StringToTemplate spans mutiple lines. You will need " .
+ "to clean it up by hand: get rid of the TC_foo arg. If it's not " .
+ "TC_MANUAL, you will need to add an AUTOESCAPE pragma. " .
+ "See comments in $0.");
+}
+
+# Change all the TemplateDictionary escapes. Now they are globals in
+# the ctemplate namespace.
+s@TemplateDictionary::html_escape@html_escape@g;
+s@TemplateDictionary::pre_escape@pre_escape@g;
+s@TemplateDictionary::xml_escape@xml_escape@g;
+s@TemplateDictionary::javascript_escape@javascript_escape@g;
+s@TemplateDictionary::url_query_escape@url_query_escape@g;
+s@TemplateDictionary::json_escape@json_escape@g;
+
+# This cleans up anything messy we left behind.
+s@\bctemplate::ctemplate::@ctemplate::@g; # get rid of redundant specifier
+
+close ARGV if eof; # to reset $. for each file
diff --git a/contrib/highlighting.vim b/contrib/highlighting.vim
new file mode 100644
index 0000000..67d534d
--- /dev/null
+++ b/contrib/highlighting.vim
@@ -0,0 +1,212 @@
+#!/bin/sh
+# This is a shell archive (produced by GNU sharutils 4.2.1).
+# To extract the files from this archive, save it to some FILE, remove
+# everything before the `!/bin/sh' line above, then type `sh FILE'.
+#
+# Made on 2006-08-08 13:38 PDT by <patlac@borabora.crchul.ulaval.ca>.
+# Commandline: shar -T .vim
+#
+# Existing files will *not* be overwritten unless `-c' is specified.
+#
+# This shar contains:
+# length mode name
+# ------ ---------- ------------------------------------------
+# 1477 -rw-r--r-- .vim/syntax/tpl.vim
+# 56 -rw-r--r-- .vim/ftdetect/tpl.vim
+#
+echo >/dev/null <<_NOTES_EOF
+From: Patrick Lacasse <patlac@borabora.crchul.ulaval.ca>
+Subject: vim color for google-ctemplate howto
+To: google-ctemplate@googlegroups.com
+Date: Fri, 4 Aug 2006 11:38:39 -0400
+
+Hi group,
+
+ I'm now using google-ctemplate. My text editor is vim. Here is a little gift
+for other people like me.
+
+Howto have google-ctemplate colored by vim :
+
+In your home directory, run 'sh $0'.
+
+Now restart vim.
+
+This will autodetects file with tpl extension and colors them. You can change
+the color by changing the HiLink lines ( try changing String by
+Identifier ) .
+
+I'm not sure exactly about what are the legal marker names. Feel free to
+change the regexes.
+
+I only tryed this with vim 6.4 , I just cut and past the things about version
+checking.
+
+For more information about syntax higlithning in vim, try
+:help syntax
+
+Amusez-vous bien,
+
+Patrick Lacasse
+patlac@borabora.crchul.ulaval.ca
+_NOTES_EOF
+
+save_IFS="${IFS}"
+IFS="${IFS}:"
+gettext_dir=FAILED
+locale_dir=FAILED
+first_param="$1"
+for dir in $PATH
+do
+ if test "$gettext_dir" = FAILED && test -f $dir/gettext \
+ && ($dir/gettext --version >/dev/null 2>&1)
+ then
+ set `$dir/gettext --version 2>&1`
+ if test "$3" = GNU
+ then
+ gettext_dir=$dir
+ fi
+ fi
+ if test "$locale_dir" = FAILED && test -f $dir/shar \
+ && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
+ then
+ locale_dir=`$dir/shar --print-text-domain-dir`
+ fi
+done
+IFS="$save_IFS"
+if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
+then
+ echo=echo
+else
+ TEXTDOMAINDIR=$locale_dir
+ export TEXTDOMAINDIR
+ TEXTDOMAIN=sharutils
+ export TEXTDOMAIN
+ echo="$gettext_dir/gettext -s"
+fi
+if touch -am -t 200112312359.59 $$.touch >/dev/null 2>&1 && test ! -f 200112312359.59 -a -f $$.touch; then
+ shar_touch='touch -am -t $1$2$3$4$5$6.$7 "$8"'
+elif touch -am 123123592001.59 $$.touch >/dev/null 2>&1 && test ! -f 123123592001.59 -a ! -f 123123592001.5 -a -f $$.touch; then
+ shar_touch='touch -am $3$4$5$6$1$2.$7 "$8"'
+elif touch -am 1231235901 $$.touch >/dev/null 2>&1 && test ! -f 1231235901 -a -f $$.touch; then
+ shar_touch='touch -am $3$4$5$6$2 "$8"'
+else
+ shar_touch=:
+ echo
+ $echo 'WARNING: not restoring timestamps. Consider getting and'
+ $echo "installing GNU \`touch', distributed in GNU File Utilities..."
+ echo
+fi
+rm -f 200112312359.59 123123592001.59 123123592001.5 1231235901 $$.touch
+#
+if mkdir _sh09814; then
+ $echo 'x -' 'creating lock directory'
+else
+ $echo 'failed to create lock directory'
+ exit 1
+fi
+# ============= .vim/syntax/tpl.vim ==============
+if test ! -d '.vim'; then
+ $echo 'x -' 'creating directory' '.vim'
+ mkdir '.vim'
+fi
+if test ! -d '.vim/syntax'; then
+ $echo 'x -' 'creating directory' '.vim/syntax'
+ mkdir '.vim/syntax'
+fi
+if test -f '.vim/syntax/tpl.vim' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING '.vim/syntax/tpl.vim' '(file already exists)'
+else
+ $echo 'x -' extracting '.vim/syntax/tpl.vim' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > '.vim/syntax/tpl.vim' &&
+" Vim syntax file
+" Language: google-ctemplate
+" Maintainer: Patrick Lacasse <patlac@borabora.crchul.ulaval.ca>
+" Last Change: 2006 Août 03
+"
+" For information about google-ctemplate see
+" http://goog-ctemplate.sourceforge.net/
+"
+" This vim syntax file works on vim 5.6, 5.7, 5.8 and 6.x.
+" It implements Bram Moolenaar's April 25, 2001 recommendations to make
+" the syntax file maximally portable across different versions of vim.
+X
+" For version 5.x: Clear all syntax items
+" For version 6.x: Quit when a syntax file was already loaded
+if version < 600
+X syntax clear
+elseif exists("b:current_syntax")
+X finish
+endif
+X
+syntax match tplMarkerError "{{}\?\([^}]\+}\?\)*}}"
+syntax match tplSectionMarker "{{[#/][A-Za-z_]\+}}"
+syntax match tplInclude "{{>[A-Za-z_]\+}}"
+syntax match tplComment "{{![A-Za-z_]\+}}"
+syntax match tplVariableMarker "{{[_A-Za-z]\+}}"
+X
+" Define the default highlighting.
+" For version 5.7 and earlier: only when not done already
+" For version 5.8 and later: only when an item doesn't have highlighting yet
+if version >= 508 || !exists("did_tpl_syn_inits")
+X if version < 508
+X let did_tpl_syn_inits = 1
+X command -nargs=+ HiLink hi link <args>
+X else
+X command -nargs=+ HiLink hi def link <args>
+X endif
+X
+X HiLink tplSectionMarker Repeat
+X HiLink tplInclude Include
+X HiLink tplComment Comment
+X HiLink tplVariableMarker String
+X HiLink tplMarkerError Error
+X
+X delcommand HiLink
+endif
+X
+let b:current_syntax = "tpl"
+SHAR_EOF
+ (set 20 06 08 08 13 34 11 '.vim/syntax/tpl.vim'; eval "$shar_touch") &&
+ chmod 0644 '.vim/syntax/tpl.vim' ||
+ $echo 'restore of' '.vim/syntax/tpl.vim' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo '.vim/syntax/tpl.vim:' 'MD5 check failed'
+536faef79eff0597e642c5db04c1f79d .vim/syntax/tpl.vim
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.vim/syntax/tpl.vim'`"
+ test 1477 -eq "$shar_count" ||
+ $echo '.vim/syntax/tpl.vim:' 'original size' '1477,' 'current size' "$shar_count!"
+ fi
+fi
+# ============= .vim/ftdetect/tpl.vim ==============
+if test ! -d '.vim/ftdetect'; then
+ $echo 'x -' 'creating directory' '.vim/ftdetect'
+ mkdir '.vim/ftdetect'
+fi
+if test -f '.vim/ftdetect/tpl.vim' && test "$first_param" != -c; then
+ $echo 'x -' SKIPPING '.vim/ftdetect/tpl.vim' '(file already exists)'
+else
+ $echo 'x -' extracting '.vim/ftdetect/tpl.vim' '(text)'
+ sed 's/^X//' << 'SHAR_EOF' > '.vim/ftdetect/tpl.vim' &&
+au BufRead,BufNewFile *.tpl set filetype=tpl
+SHAR_EOF
+ (set 20 06 08 08 13 34 20 '.vim/ftdetect/tpl.vim'; eval "$shar_touch") &&
+ chmod 0644 '.vim/ftdetect/tpl.vim' ||
+ $echo 'restore of' '.vim/ftdetect/tpl.vim' 'failed'
+ if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
+ && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
+ md5sum -c << SHAR_EOF >/dev/null 2>&1 \
+ || $echo '.vim/ftdetect/tpl.vim:' 'MD5 check failed'
+774fd4a092b77400ef6e74a7256ff8ef .vim/ftdetect/tpl.vim
+SHAR_EOF
+ else
+ shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < '.vim/ftdetect/tpl.vim'`"
+ test 56 -eq "$shar_count" ||
+ $echo '.vim/ftdetect/tpl.vim:' 'original size' '56,' 'current size' "$shar_count!"
+ fi
+fi
+rm -fr _sh09814
+exit 0
diff --git a/contrib/tpl-mode.el b/contrib/tpl-mode.el
new file mode 100644
index 0000000..ff1afd4
--- /dev/null
+++ b/contrib/tpl-mode.el
@@ -0,0 +1,262 @@
+;;; tpl-mode.el -- a major mode for editing Google CTemplate files.
+;;; By Tony Gentilcore, July 2006
+;;;
+;;; TO USE:
+;;; 1) Copy this file somewhere you in emacs load-path. To see what
+;;; your load-path is, run inside emacs: C-h v load-path<RET>
+;;; 2) Add the following two lines to your .emacs file:
+;;; (setq auto-mode-alist (cons '("\\.tpl$" . tpl-mode) auto-mode-alist))
+;;; (autoload 'tpl-mode "tpl-mode" "Major mode for editing CTemplate files." t)
+;;; 3) Optionally (but recommended), add this third line as well:
+;;; (add-hook 'tpl-mode-hook '(lambda () (font-lock-mode 1)))
+;;; ---
+;;;
+;;; While the CTemplate language can be used for any types of text,
+;;; this mode is intended for using CTemplate to write HTML.
+;;;
+;;; The indentation still has minor bugs due to the fact that
+;;; templates do not require valid HTML.
+;;;
+;;; It would be nice to be able to highlight attributes of HTML tags,
+;;; however this is difficult due to the presence of CTemplate symbols
+;;; embedded within attributes.
+
+(eval-when-compile
+ (require 'font-lock))
+
+(defgroup tpl-mode nil
+ "Major mode for editing CTemplate files"
+ :group 'languages)
+
+(defvar tpl-mode-version "1.0"
+ "Version of `tpl-mode.el'.")
+
+(defvar tpl-mode-abbrev-table nil
+ "Abbrev table for use in tpl-mode buffers.")
+
+(define-abbrev-table 'tpl-mode-abbrev-table ())
+
+(defcustom tpl-mode-hook nil
+ "*Hook that runs upon entering tpl-mode."
+ :type 'hook
+ )
+
+(defvar tpl-mode-map nil
+ "Keymap for tpl-mode major mode")
+
+(if tpl-mode-map
+ nil
+ (setq tpl-mode-map (make-sparse-keymap))
+ )
+
+(define-key tpl-mode-map "\t" 'tpl-indent-command)
+(define-key tpl-mode-map "\C-m" 'newline-and-indent)
+
+
+(defvar tpl-mode-syntax-table nil
+ "Syntax table in use in tpl-mode buffers.")
+
+;; Syntax table.
+(if tpl-mode-syntax-table
+ nil
+ (setq tpl-mode-syntax-table (make-syntax-table text-mode-syntax-table))
+ (modify-syntax-entry ?< "(> " tpl-mode-syntax-table)
+ (modify-syntax-entry ?> ")< " tpl-mode-syntax-table)
+ (modify-syntax-entry ?\" ". " tpl-mode-syntax-table)
+ (modify-syntax-entry ?\\ ". " tpl-mode-syntax-table)
+ (modify-syntax-entry ?' "w " tpl-mode-syntax-table)
+ )
+
+(defvar tpl-basic-offset 2
+ "The basic indentation offset.")
+
+;; Constant regular expressions to identify template elements.
+(defconst tpl-mode-tpl-token "[a-zA-Z][a-zA-Z0-9_:=\-]*?")
+(defconst tpl-mode-section (concat "\\({{[#/]"
+ tpl-mode-tpl-token
+ "}}\\)"))
+(defconst tpl-mode-open-section (concat "\\({{#"
+ tpl-mode-tpl-token
+ "}}\\)"))
+(defconst tpl-mode-close-section (concat "{{/\\("
+ tpl-mode-tpl-token
+ "\\)}}"))
+(defconst tpl-mode-comment "\\({{![^}]+?}}\\)")
+(defconst tpl-mode-include (concat "\\({{>"
+ tpl-mode-tpl-token
+ "}}\\)"))
+(defconst tpl-mode-variable (concat "\\({{"
+ tpl-mode-tpl-token
+ "}}\\)"))
+(defconst tpl-mode-builtins
+ (concat
+ "\\({{\\<"
+ (regexp-opt
+ '("BI_NEWLINE" "BI_SPACE")
+ t)
+ "\\>}}\\)"))
+(defconst tpl-mode-close-section-at-start (concat "^[ \t]*?"
+ tpl-mode-close-section))
+
+;; Constant regular expressions to identify html tags.
+;; Taken from HTML 4.01 / XHTML 1.0 Reference found at:
+;; http://www.w3schools.com/tags/default.asp.
+(defconst tpl-mode-html-constant "\\(&#?[a-z0-9]\\{2,5\\};\\)")
+(defconst tpl-mode-pair-tag
+ (concat
+ "\\<"
+ (regexp-opt
+ '("a" "abbr" "acronym" "address" "applet" "area" "b" "bdo"
+ "big" "blockquote" "body" "button" "caption" "center" "cite"
+ "code" "col" "colgroup" "dd" "del" "dfn" "dif" "div" "dl"
+ "dt" "em" "fieldset" "font" "form" "frame" "frameset" "h1"
+ "h2" "h3" "h4" "h5" "h6" "head" "html" "i" "iframe" "ins"
+ "kbd" "label" "legend" "li" "link" "map" "menu" "noframes"
+ "noscript" "object" "ol" "optgroup" "option" "p" "pre" "q"
+ "s" "samp" "script" "select" "small" "span" "strike"
+ "strong" "style" "sub" "sup" "table" "tbody" "td" "textarea"
+ "tfoot" "th" "thead" "title" "tr" "tt" "u" "ul" "var")
+ t)
+ "\\>"))
+(defconst tpl-mode-standalone-tag
+ (concat
+ "\\<"
+ (regexp-opt
+ '("base" "br" "hr" "img" "input" "meta" "param")
+ t)
+ "\\>"))
+(defconst tpl-mode-open-tag (concat "<\\("
+ tpl-mode-pair-tag
+ "\\)"))
+(defconst tpl-mode-close-tag (concat "</\\("
+ tpl-mode-pair-tag
+ "\\)>"))
+(defconst tpl-mode-close-tag-at-start (concat "^[ \t]*?"
+ tpl-mode-close-tag))
+
+(defconst tpl-mode-blank-line "^[ \t]*?$")
+(defconst tpl-mode-dangling-open (concat "\\("
+ tpl-mode-open-section
+ "\\)\\|\\("
+ tpl-mode-open-tag
+ "\\)[^/]*$"))
+
+(defun tpl-indent-command ()
+ "Command for indenting text. Just calls tpl-indent."
+ (interactive)
+ (tpl-indent))
+
+;; Function to control indenting.
+(defun tpl-indent ()
+ "Indent current line"
+ ;; Set the point to beginning of line.
+ (beginning-of-line)
+ ;; If we are at the beginning of the file, indent to 0.
+ (if (bobp)
+ (indent-line-to 0)
+ (let ((tag-stack 1) (close-tag "") (cur-indent 0) (old-pnt (point-marker))
+ (close-at-start) (open-token) (dangling-open))
+ (progn
+ ;; Determine if this is a template line or an html line.
+ (if (looking-at "^[ \t]*?{{")
+ (setq close-at-start tpl-mode-close-section-at-start
+ open-token "{{#")
+ (setq close-at-start tpl-mode-close-tag-at-start
+ open-token "<")
+ )
+ ;; If there is a closing tag at the start of the line, search back
+ ;; for its opener and indent to that level.
+ (if (looking-at close-at-start)
+ (progn
+ (save-excursion
+ (setq close-tag (match-string 1))
+ ;; Keep searching for a match for the close tag until
+ ;; the tag-stack is 0.
+ (while (and (not (bobp))
+ (> tag-stack 0)
+ (re-search-backward (concat open-token
+ "\\(/?\\)"
+ close-tag) nil t))
+ (if (string-equal (match-string 1) "/")
+ ;; We found another close tag, so increment tag-stack.
+ (setq tag-stack (+ tag-stack 1))
+ ;; We found an open tag, so decrement tag-stack.
+ (setq tag-stack (- tag-stack 1))
+ )
+ (setq cur-indent (current-indentation))
+ )
+ )
+ (if (> tag-stack 0)
+ (save-excursion
+ (forward-line -1)
+ (setq cur-indent (current-indentation))
+ )
+ )
+ )
+ ;; This was not a closing tag, so we check if the previous line
+ ;; was an opening tag.
+ (save-excursion
+ ;; Keep moving back until we find a line that is not blank
+ (while (progn
+ (forward-line -1)
+ (and (not (bobp)) (looking-at tpl-mode-blank-line))
+ )
+ )
+ (setq cur-indent (current-indentation))
+ (if (re-search-forward tpl-mode-dangling-open old-pnt t)
+ (setq cur-indent (+ cur-indent tpl-basic-offset))
+ )
+ )
+ )
+ ;; Finally, we execute the actual indentation.
+ (if (> cur-indent 0)
+ (indent-line-to cur-indent)
+ (indent-line-to 0)
+ )
+ )
+ )
+ )
+ )
+
+;; controls highlighting
+(defconst tpl-mode-font-lock-keywords
+ (list
+ (list tpl-mode-section
+ '(1 font-lock-keyword-face))
+ (list tpl-mode-comment
+ '(1 font-lock-comment-face))
+ (list tpl-mode-include
+ '(1 font-lock-builtin-face))
+ (list tpl-mode-builtins
+ '(1 font-lock-variable-name-face))
+ (list tpl-mode-variable
+ '(1 font-lock-reference-face))
+ (list (concat "</?\\(" tpl-mode-pair-tag "\\)")
+ '(1 font-lock-function-name-face))
+ (list (concat "<\\(" tpl-mode-standalone-tag "\\)")
+ '(1 font-lock-function-name-face))
+ (list tpl-mode-html-constant
+ '(1 font-lock-variable-name-face))
+ ))
+
+(put 'tpl-mode 'font-lock-defaults '(tpl-font-lock-keywords nil t))
+
+(defun tpl-mode ()
+ "Major mode for editing CTemplate file."
+ (interactive)
+ (kill-all-local-variables)
+ (use-local-map tpl-mode-map)
+ (setq major-mode 'tpl-mode)
+ (setq mode-name "tpl-mode")
+ (setq local-abbrev-table tpl-mode-abbrev-table)
+ (setq indent-tabs-mode nil)
+ (set-syntax-table tpl-mode-syntax-table)
+ ; show trailing whitespace, but only when the user can fix it
+ (setq show-trailing-whitespace (not buffer-read-only))
+ (make-local-variable 'indent-line-function)
+ (setq indent-line-function 'tpl-indent)
+ (setq font-lock-defaults '(tpl-mode-font-lock-keywords))
+ (run-hooks 'tpl-mode-hook)
+)
+
+(provide 'tpl-mode)
diff --git a/ctemplate.sln b/ctemplate.sln
new file mode 100755
index 0000000..bf64336
--- /dev/null
+++ b/ctemplate.sln
@@ -0,0 +1,146 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libctemplate", "vsprojects\libctemplate\libctemplate.vcproj", "{FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "compile_test", "vsprojects\compile_test\compile_test.vcproj", "{4B263748-5F0F-468C-8C5C-ED2682BB6BE3}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_dictionary_unittest", "vsprojects\template_dictionary_unittest\template_dictionary_unittest.vcproj", "{9160CC7F-3BC6-49F1-A158-70DF579376CA}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_modifiers_unittest", "vsprojects\template_modifiers_unittest\template_modifiers_unittest.vcproj", "{D9E45FD2-07AC-4EE8-9DA4-26E0427D619E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_regtest", "vsprojects\template_regtest\template_regtest.vcproj", "{0072B37E-DCDA-4128-BC12-7C0A7EF59016}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_setglobals_unittest", "vsprojects\template_setglobals_unittest\template_setglobals_unittest.vcproj", "{686099C0-A778-4D27-80B5-A7E051658D2F}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_cache_test", "vsprojects\template_cache_test\template_cache_test.vcproj", "{5105C0FF-C28A-480B-8298-A66AB4F1F0C0}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_unittest", "vsprojects\template_unittest\template_unittest.vcproj", "{5105C0FF-C28A-480B-8298-A66AB4F1F0CD}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_unittest_static", "vsprojects\template_unittest_static\template_unittest_static.vcproj", "{ED69C82B-F593-418A-8D17-C64CBB11E603}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "make_tpl_varname_h", "vsprojects\make_tpl_varname_h\make_tpl_varname_h.vcproj", "{CFD560F2-1B16-4CEE-985D-B19FDE74513F}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "diff_tpl_auto_escape", "vsprojects\diff_tpl_auto_escape\diff_tpl_auto_escape.vcproj", "{72CD1C2A-56F6-4DDA-957B-BCF181BB558E}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "template_test_util_test", "vsprojects\template_test_util_test\template_test_util_test.vcproj", "{87132061-D584-4388-A80B-D8560F8D0895}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "statemachine_test", "vsprojects\statemachine_test\statemachine_test.vcproj", "{A105C0FF-C28A-480B-8298-A66AB4F1F0CD}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "htmlparser_test", "vsprojects\htmlparser_test\htmlparser_test.vcproj", "{B105C0FF-C28A-480B-8298-A66AB4F1F0CD}"
+ ProjectSection(ProjectDependencies) = postProject
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC} = {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}
+ EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "generate_fsm_c_test", "vsprojects\generate_fsm_c_test\generate_fsm_c_test.vcproj", "{8FB1935F-FC23-465D-8C18-C1466A99D08D}"
+ ProjectSection(ProjectDependencies) = postProject
+ EndProjectSection
+EndProject
+Global
+ GlobalSection(SolutionConfiguration) = preSolution
+ Debug = Debug
+ Release = Release
+ EndGlobalSection
+ GlobalSection(ProjectDependencies) = postSolution
+ EndGlobalSection
+ GlobalSection(ProjectConfiguration) = postSolution
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Debug.ActiveCfg = Debug|Win32
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Debug.Build.0 = Debug|Win32
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Release.ActiveCfg = Release|Win32
+ {FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}.Release.Build.0 = Release|Win32
+ {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Debug.ActiveCfg = Debug|Win32
+ {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Debug.Build.0 = Debug|Win32
+ {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Release.ActiveCfg = Release|Win32
+ {4B263748-5F0F-468C-8C5C-ED2682BB6BE3}.Release.Build.0 = Release|Win32
+ {9160CC7F-3BC6-49F1-A158-70DF579376CA}.Debug.ActiveCfg = Debug|Win32
+ {9160CC7F-3BC6-49F1-A158-70DF579376CA}.Debug.Build.0 = Debug|Win32
+ {9160CC7F-3BC6-49F1-A158-70DF579376CA}.Release.ActiveCfg = Release|Win32
+ {9160CC7F-3BC6-49F1-A158-70DF579376CA}.Release.Build.0 = Release|Win32
+ {D9E45FD2-07AC-4EE8-9DA4-26E0427D619E}.Debug.ActiveCfg = Debug|Win32
+ {D9E45FD2-07AC-4EE8-9DA4-26E0427D619E}.Debug.Build.0 = Debug|Win32
+ {D9E45FD2-07AC-4EE8-9DA4-26E0427D619E}.Release.ActiveCfg = Release|Win32
+ {D9E45FD2-07AC-4EE8-9DA4-26E0427D619E}.Release.Build.0 = Release|Win32
+ {0072B37E-DCDA-4128-BC12-7C0A7EF59016}.Debug.ActiveCfg = Debug|Win32
+ {0072B37E-DCDA-4128-BC12-7C0A7EF59016}.Debug.Build.0 = Debug|Win32
+ {0072B37E-DCDA-4128-BC12-7C0A7EF59016}.Release.ActiveCfg = Release|Win32
+ {0072B37E-DCDA-4128-BC12-7C0A7EF59016}.Release.Build.0 = Release|Win32
+ {686099C0-A778-4D27-80B5-A7E051658D2F}.Debug.ActiveCfg = Debug|Win32
+ {686099C0-A778-4D27-80B5-A7E051658D2F}.Debug.Build.0 = Debug|Win32
+ {686099C0-A778-4D27-80B5-A7E051658D2F}.Release.ActiveCfg = Release|Win32
+ {686099C0-A778-4D27-80B5-A7E051658D2F}.Release.Build.0 = Release|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Debug.ActiveCfg = Debug|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Debug.Build.0 = Debug|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Release.ActiveCfg = Release|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Release.Build.0 = Release|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0C0}.Debug.ActiveCfg = Debug|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0C0}.Debug.Build.0 = Debug|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0C0}.Release.ActiveCfg = Release|Win32
+ {5105C0FF-C28A-480B-8298-A66AB4F1F0C0}.Release.Build.0 = Release|Win32
+ {ED69C82B-F593-418A-8D17-C64CBB11E603}.Debug.ActiveCfg = Debug|Win32
+ {ED69C82B-F593-418A-8D17-C64CBB11E603}.Debug.Build.0 = Debug|Win32
+ {ED69C82B-F593-418A-8D17-C64CBB11E603}.Release.ActiveCfg = Release|Win32
+ {ED69C82B-F593-418A-8D17-C64CBB11E603}.Release.Build.0 = Release|Win32
+ {CFD560F2-1B16-4CEE-985D-B19FDE74513F}.Debug.ActiveCfg = Debug|Win32
+ {CFD560F2-1B16-4CEE-985D-B19FDE74513F}.Debug.Build.0 = Debug|Win32
+ {CFD560F2-1B16-4CEE-985D-B19FDE74513F}.Release.ActiveCfg = Release|Win32
+ {CFD560F2-1B16-4CEE-985D-B19FDE74513F}.Release.Build.0 = Release|Win32
+ {72CD1C2A-56F6-4DDA-957B-BCF181BB558E}.Debug.ActiveCfg = Debug|Win32
+ {72CD1C2A-56F6-4DDA-957B-BCF181BB558E}.Debug.Build.0 = Debug|Win32
+ {72CD1C2A-56F6-4DDA-957B-BCF181BB558E}.Release.ActiveCfg = Release|Win32
+ {72CD1C2A-56F6-4DDA-957B-BCF181BB558E}.Release.Build.0 = Release|Win32
+ {87132061-D584-4388-A80B-D8560F8D0895}.Debug.ActiveCfg = Debug|Win32
+ {87132061-D584-4388-A80B-D8560F8D0895}.Debug.Build.0 = Debug|Win32
+ {87132061-D584-4388-A80B-D8560F8D0895}.Release.ActiveCfg = Release|Win32
+ {87132061-D584-4388-A80B-D8560F8D0895}.Release.Build.0 = Release|Win32
+ {A105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Debug.ActiveCfg = Debug|Win32
+ {A105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Debug.Build.0 = Debug|Win32
+ {A105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Release.ActiveCfg = Release|Win32
+ {A105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Release.Build.0 = Release|Win32
+ {B105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Debug.ActiveCfg = Debug|Win32
+ {B105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Debug.Build.0 = Debug|Win32
+ {B105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Release.ActiveCfg = Release|Win32
+ {B105C0FF-C28A-480B-8298-A66AB4F1F0CD}.Release.Build.0 = Release|Win32
+ {8FB1935F-FC23-465D-8C18-C1466A99D08D}.Debug.ActiveCfg = Debug|Win32
+ {8FB1935F-FC23-465D-8C18-C1466A99D08D}.Debug.Build.0 = Debug|Win32
+ {8FB1935F-FC23-465D-8C18-C1466A99D08D}.Release.ActiveCfg = Release|Win32
+ {8FB1935F-FC23-465D-8C18-C1466A99D08D}.Release.Build.0 = Release|Win32
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ EndGlobalSection
+ GlobalSection(ExtensibilityAddIns) = postSolution
+ EndGlobalSection
+EndGlobal
diff --git a/depcomp b/depcomp
new file mode 100755
index 0000000..e5f9736
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,589 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2007-03-29.01
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007 Free Software
+# Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+ '')
+ echo "$0: No command. Try \`$0 --help' for more information." 1>&2
+ exit 1;
+ ;;
+ -h | --h*)
+ cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+ depmode Dependency tracking mode.
+ source Source file read by `PROGRAMS ARGS'.
+ object Object file output by `PROGRAMS ARGS'.
+ DEPDIR directory where to store dependencies.
+ depfile Dependency file to output.
+ tmpdepfile Temporary file to use when outputing dependencies.
+ libtool Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+ exit $?
+ ;;
+ -v | --v*)
+ echo "depcomp $scriptversion"
+ exit $?
+ ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+ echo "depcomp: Variables source, object and depmode must be set" 1>&2
+ exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+ sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags. We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write. Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+ # HP compiler uses -M and no extra arg.
+ gccflag=-M
+ depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+ # This is just like dashmstdout with a different argument.
+ dashmflag=-xM
+ depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want. Yay! Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff. Hmm.
+## Unfortunately, FreeBSD c89 acceptance of flags depends upon
+## the command line argument order; so add the flags where they
+## appear in depend2.am. Note that the slowdown incurred here
+## affects only configure: in makefiles, %FASTDEP% shortcuts this.
+ for arg
+ do
+ case $arg in
+ -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
+ *) set fnord "$@" "$arg" ;;
+ esac
+ shift # fnord
+ shift # $arg
+ done
+ "$@"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ mv "$tmpdepfile" "$depfile"
+ ;;
+
+gcc)
+## There are various ways to get dependency output from gcc. Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+## up in a subdir. Having to rename by hand is ugly.
+## (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+## -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+## than renaming).
+ if test -z "$gccflag"; then
+ gccflag=-MD,
+ fi
+ "$@" -Wp,"$gccflag$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+ sed -e 's/^[^:]*: / /' \
+ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header). We avoid this by adding
+## dummy dependencies for each header file. Too bad gcc doesn't do
+## this for us directly.
+ tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'. On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp)
+ # This case exists only to let depend.m4 do its work. It works by
+ # looking at the text of this script. This case will never be run,
+ # since it is checked for above.
+ exit 1
+ ;;
+
+sgi)
+ if test "$libtool" = yes; then
+ "$@" "-Wp,-MDupdate,$tmpdepfile"
+ else
+ "$@" -MDupdate "$tmpdepfile"
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+
+ if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
+ echo "$object : \\" > "$depfile"
+
+ # Clip off the initial element (the dependent). Don't try to be
+ # clever and replace this with sed code, as IRIX sed won't handle
+ # lines with more than a fixed number of characters (4096 in
+ # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
+ # the IRIX cc adds comments like `#:fec' to the end of the
+ # dependency line.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+ tr '
+' ' ' >> $depfile
+ echo >> $depfile
+
+ # The second pass generates a dummy entry for each header file.
+ tr ' ' '
+' < "$tmpdepfile" \
+ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+ >> $depfile
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+aix)
+ # The C for AIX Compiler uses -M and outputs the dependencies
+ # in a .u file. In older versions, this file always lives in the
+ # current directory. Also, the AIX compiler puts `$object:' at the
+ # start of each line; $object doesn't have directory information.
+ # Version 6 uses the directory in both cases.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$base.u
+ tmpdepfile3=$dir.libs/$base.u
+ "$@" -Wc,-M
+ else
+ tmpdepfile1=$dir$base.u
+ tmpdepfile2=$dir$base.u
+ tmpdepfile3=$dir$base.u
+ "$@" -M
+ fi
+ stat=$?
+
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ # Each line is of the form `foo.o: dependent.h'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ # The sourcefile does not contain any dependencies, so just
+ # store a dummy comment line, to avoid errors with the Makefile
+ # "include basename.Plo" scheme.
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+icc)
+ # Intel's C compiler understands `-MD -MF file'. However on
+ # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+ # ICC 7.0 will fill foo.d with something like
+ # foo.o: sub/foo.c
+ # foo.o: sub/foo.h
+ # which is wrong. We want:
+ # sub/foo.o: sub/foo.c
+ # sub/foo.o: sub/foo.h
+ # sub/foo.c:
+ # sub/foo.h:
+ # ICC 7.1 will output
+ # foo.o: sub/foo.c sub/foo.h
+ # and will wrap long lines using \ :
+ # foo.o: sub/foo.c ... \
+ # sub/foo.h ... \
+ # ...
+
+ "$@" -MD -MF "$tmpdepfile"
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile"
+ exit $stat
+ fi
+ rm -f "$depfile"
+ # Each line is of the form `foo.o: dependent.h',
+ # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+ # Do two passes, one to just change these to
+ # `$object: dependent.h' and one to simply `dependent.h:'.
+ sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+ # Some versions of the HPUX 10.20 sed can't process this invocation
+ # correctly. Breaking it into two sed invocations is a workaround.
+ sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+ sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+hp2)
+ # The "hp" stanza above does not work with aCC (C++) and HP's ia64
+ # compilers, which have integrated preprocessors. The correct option
+ # to use with these is +Maked; it writes dependencies to a file named
+ # 'foo.d', which lands next to the object file, wherever that
+ # happens to be.
+ # Much of this is similar to the tru64 case; see comments there.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+ if test "$libtool" = yes; then
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir.libs/$base.d
+ "$@" -Wc,+Maked
+ else
+ tmpdepfile1=$dir$base.d
+ tmpdepfile2=$dir$base.d
+ "$@" +Maked
+ fi
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile"
+ # Add `dependent.h:' lines.
+ sed -ne '2,${; s/^ *//; s/ \\*$//; s/$/:/; p;}' "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile" "$tmpdepfile2"
+ ;;
+
+tru64)
+ # The Tru64 compiler uses -MD to generate dependencies as a side
+ # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+ # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+ # dependencies in `foo.d' instead, so we check for that too.
+ # Subdirectories are respected.
+ dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+ test "x$dir" = "x$object" && dir=
+ base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+ if test "$libtool" = yes; then
+ # With Tru64 cc, shared objects can also be used to make a
+ # static library. This mechanism is used in libtool 1.4 series to
+ # handle both shared and static libraries in a single compilation.
+ # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+ #
+ # With libtool 1.5 this exception was removed, and libtool now
+ # generates 2 separate objects for the 2 libraries. These two
+ # compilations output dependencies in $dir.libs/$base.o.d and
+ # in $dir$base.o.d. We have to check for both files, because
+ # one of the two compilations can be disabled. We should prefer
+ # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+ # automatically cleaned when .libs/ is deleted, while ignoring
+ # the former would cause a distcleancheck panic.
+ tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
+ tmpdepfile2=$dir$base.o.d # libtool 1.5
+ tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
+ tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
+ "$@" -Wc,-MD
+ else
+ tmpdepfile1=$dir$base.o.d
+ tmpdepfile2=$dir$base.d
+ tmpdepfile3=$dir$base.d
+ tmpdepfile4=$dir$base.d
+ "$@" -MD
+ fi
+
+ stat=$?
+ if test $stat -eq 0; then :
+ else
+ rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ exit $stat
+ fi
+
+ for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+ do
+ test -f "$tmpdepfile" && break
+ done
+ if test -f "$tmpdepfile"; then
+ sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+ # That's a tab and a space in the [].
+ sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+ else
+ echo "#dummy" > "$depfile"
+ fi
+ rm -f "$tmpdepfile"
+ ;;
+
+#nosideeffect)
+ # This comment above is used by automake to tell side-effect
+ # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ test -z "$dashmflag" && dashmflag=-M
+ # Require at least two characters before searching for `:'
+ # in the target name. This is to cope with DOS-style filenames:
+ # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+ "$@" $dashmflag |
+ sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+dashXmstdout)
+ # This case only exists to satisfy depend.m4. It is never actually
+ # run, as this mode is specially recognized in the preamble.
+ exit 1
+ ;;
+
+makedepend)
+ "$@" || exit $?
+ # Remove any Libtool call
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+ # X makedepend
+ shift
+ cleared=no
+ for arg in "$@"; do
+ case $cleared in
+ no)
+ set ""; shift
+ cleared=yes ;;
+ esac
+ case "$arg" in
+ -D*|-I*)
+ set fnord "$@" "$arg"; shift ;;
+ # Strip any option that makedepend may not understand. Remove
+ # the object too, otherwise makedepend will parse it as a source file.
+ -*|$object)
+ ;;
+ *)
+ set fnord "$@" "$arg"; shift ;;
+ esac
+ done
+ obj_suffix="`echo $object | sed 's/^.*\././'`"
+ touch "$tmpdepfile"
+ ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+ rm -f "$depfile"
+ cat < "$tmpdepfile" > "$depfile"
+ sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly. Breaking it into two sed invocations is a workaround.
+ sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile" "$tmpdepfile".bak
+ ;;
+
+cpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout.
+ "$@" || exit $?
+
+ # Remove the call to Libtool.
+ if test "$libtool" = yes; then
+ while test $1 != '--mode=compile'; do
+ shift
+ done
+ shift
+ fi
+
+ # Remove `-o $object'.
+ IFS=" "
+ for arg
+ do
+ case $arg in
+ -o)
+ shift
+ ;;
+ $object)
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift # fnord
+ shift # $arg
+ ;;
+ esac
+ done
+
+ "$@" -E |
+ sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+ sed '$ s: \\$::' > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ cat < "$tmpdepfile" >> "$depfile"
+ sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+msvisualcpp)
+ # Important note: in order to support this mode, a compiler *must*
+ # always write the preprocessed file to stdout, regardless of -o,
+ # because we must use -o when running libtool.
+ "$@" || exit $?
+ IFS=" "
+ for arg
+ do
+ case "$arg" in
+ "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+ set fnord "$@"
+ shift
+ shift
+ ;;
+ *)
+ set fnord "$@" "$arg"
+ shift
+ shift
+ ;;
+ esac
+ done
+ "$@" -E |
+ sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+ rm -f "$depfile"
+ echo "$object : \\" > "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
+ echo " " >> "$depfile"
+ . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+ rm -f "$tmpdepfile"
+ ;;
+
+none)
+ exec "$@"
+ ;;
+
+*)
+ echo "Unknown depmode $depmode" 1>&2
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/doc/auto_escape.html b/doc/auto_escape.html
new file mode 100644
index 0000000..2b5dd12
--- /dev/null
+++ b/doc/auto_escape.html
@@ -0,0 +1,424 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <title>Guide to using Auto Escape</title>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link href="designstyle.css" type="text/css" rel="stylesheet">
+ <style type="text/css">
+ ol.bluelist li {
+ color: #3366ff;
+ font-family: sans-serif;
+ }
+ ol.bluelist li p {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ ul.blacklist li {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ </style>
+</head>
+<body>
+
+<h1><a name="Guide_Auto_Escape"></a>Guide to using Auto Escape</h1>
+
+<h2>Introduction</h2>
+
+<p>Auto Escape is an optional mode of execution in the Template System
+developed to provide a better defense against cross-site scripting (XSS)
+in web applications. In this mode, the Template System assumes
+responsibility for applying the proper escaping modifiers for each
+variable in your template (and templates it may include). As such, the
+template developer no longer needs to manually apply escaping modifiers
+to each variable, a process which is repetitive and error-prone
+particularly in larger and more complex applications.</p>
+
+<p>In order for the Template System to properly determine the escaping
+modifiers to apply to variables, it activates a built-in HTML-aware
+parser during template initialization. The parser scans the template
+to determines the context in which each variable is being emitted.
+The scanning is performed at initialization-time only hence does not
+contribute to processing costs at template expansion time.</p>
+
+<p>Refer to <a href="guide.html#security">Security Considerations</a>
+for additional security information on escaping directives and their
+use according to the context in which content is being expanded.</p>
+
+<h2>Current Status</h2>
+
+<p>Auto Escape currently supports well <code>HTML</code> and
+<code>Javascript</code> templates. It also provides very basic support
+for <code>CSS</code>, <code>JSON</code> and <code>XML</code> templates
+where it applies the corresponding escaping modifier but without
+utilizing a parser. We may in the future provide parsers specific
+to these contexts and modifiers for them that are finer-grained.</p>
+
+<h2>Overview</h2>
+
+This section provides more background on Auto Escape.
+Refer to <a href="guide.html#auto_escape">How to Auto Escape</a>
+for information on how to leverage this mode in your application.
+
+<h3>Using template modifiers</h3>
+
+<p>In the simplest case, where you only want to use template-modifiers
+to achieve html-safety (that is, you only use
+<code>html_escape</code>, <code>url_query_escape</code>, and so
+forth), you can stop specifying template-modifiers in your template at
+all. The Auto Escape mode will generate the modifiers on its own and
+perform the correct escaping.</p>
+
+<p>If you need other types of modifiers, including your own custom
+modifiers, you can still specify them in your template and they will
+continue to work just the same. The Auto Escape mode will simply apply
+the appropriate escaping modifiers after your own.</p>
+
+<p>Other reasons for manually specifying variable modifiers include:</p>
+<ol>
+ <li> To indicate a variable is safe. You may add the
+ <code>:none</code> modifier as the last modifier for a given
+ variable, in which case the Auto Escape mode will leave it
+ untouched and not apply escaping directives to it. Use only
+ when you are sure the variable is trusted to be safe from XSS.
+ </li>
+
+ <li> To select a different escaping modifier from a list of
+ equivalent modifiers. Certain modifiers are equivalent from
+ an escaping point of view in that they would all ensure given
+ content is safe when escaped in a specific context. The
+ Auto Escape mode choses the most common escaping modifier for
+ that use but allows you to indicate a different choice as shown
+ below:
+
+ <table border="1" cellpadding="3" summary="Alternatives to modifiers">
+ <tr><th>TemplateContext</th><th>Primary Modifier</th>
+ <th>Accepted alternatives</th></tr>
+
+ <tr>
+ <td><code>TC_HTML</code></td>
+ <td><code>:html_escape</code></td>
+ <td><ul>
+ <li><code>:pre_escape</code></li>
+ <li><code>:html_escape_with_arg=snippet</code></li>
+ <li><code>:html_escape_with_arg=attribute</code></li>
+ <li><code>:html_escape_with_arg=url</code></li>
+ <li><code>:url_query_escape</code></li>
+ <li><code>:url_escape_with_arg=html</code></li>
+ <li><code>:img_src_url_escape_with_arg=html</code></li>
+ </ul></td>
+ </tr>
+
+ <tr>
+ <td><code>TC_HTML</code> and <code>TC_CSS</code></td>
+ <td><code>:cleanse_css</code></td>
+ <td><ul>
+ <li><code>:url_escape_with_arg=css</code></li>
+ <li><code>:img_src_url_escape_with_arg=css</code></li>
+ </ul></td>
+ </tr>
+
+ <tr>
+ <td><code>TC_XML</code></td>
+ <td><code>:xml_escape</code></td>
+ <td><ul>
+ <li><code>:html_escape</code></li>
+ <li><code>:html_escape_with_arg=attribute</code></li>
+ </ul></td>
+ </tr>
+
+ <tr>
+ <td><code>TC_JS</code></td>
+ <td><code>:javascript_escape</code></td>
+ <td><ul>
+ <li><code>:url_escape_with_arg=javascript</code></li>
+ <li><code>:img_src_url_escape_with_arg=javascript</code></li>
+ </ul></td>
+ </tr>
+
+ <tr>
+ <td><code>TC_JSON</code></td>
+ <td><code>:javascript_escape</code></td>
+ <td><ul>
+ <li><code>:json_escape</code></li>
+ </ul></td>
+ </tr>
+
+ </table></li>
+
+ <li> To add additional escaping modifiers. The Template System will
+ never remove escaping directives you explicitly specify. </li>
+</ol>
+
+<h3><A name="EscapeContext">Escaping Contexts</A>
+</h3>
+
+
+<p>The table belows indicates which modifier Auto-Escape selects to
+escape a given variable, based on the context of the variable being
+inserted and, possibly, on more specific information such as whether
+the variable is inside quotation marks. The table only applies for
+the well-supported TemplateContext values (currently
+<code>TC_HTML</code> and <code>TC_JS</code>).</p>
+
+<p>In a few cases, we do not have
+a modifier that is both safe against XSS and respecting of
+the semantics of the variable therefore we fail the template
+initialization. An error is logged indicating the cause of
+the failure.</p>
+
+<table border="1" cellpadding="3" summary="Contexts for using modifiers">
+<tr bgcolor="#4169E1">
+ <th>Context</th><th>HTML Quoted?</th>
+ <th>Examples</th><th>Action Performed</th>
+</tr>
+
+<tr bgcolor="#F0F8FF">
+ <td>Regular HTML Body and HTML comments</td><td>Any</td>
+ <td><pre><p>Hello {{USER}}</p>
+ </pre></td>
+ <td>Escape <code>USER</code> using
+ <code>:html_escape</code></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In URL attribute: Starts at pos 0</td><td>Yes</td>
+ <td><pre><a href="{{URL}}">;</pre></td>
+ <td>Escape <code>URL</code> using
+ <code>:url_escape_with_arg=html</code></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In URL attribute: Other</td><td>Yes</td>
+ <td><pre><a href="/foo?q={{QUERY}}"></pre></td>
+ <td>Escape <code>QUERY</code> using
+ <code>:html_escape</code></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In URL attribute: Starting at pos 0</td><td>No</td>
+ <td><pre><form action={{URL}}></pre></td>
+ <td><em>Fail template initialization</em></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In URL attribute: Other</td><td>No</td>
+ <td><pre><a href=/foo?q={{QUERY}}>My Link</a></pre></td>
+ <td>Escape <code>QUERY</code> using
+ <code>:url_query_escape</code></td>
+</tr>
+
+<tr bgcolor="#F0F8FF">
+ <td>In STYLE attribute</td><td>Yes</td>
+ <td><pre><div style="color:{{COLOR}};"></pre></td>
+ <td>Escape <code>COLOR</code> using
+ <code>:cleanse_css</code></td>
+</tr>
+
+<tr bgcolor="#F0F8FF">
+ <td>In STYLE attribute</td><td>No</td>
+ <td><pre><div style=color:{{COLOR}};></pre></td>
+ <td><em>Fail template initialization</em></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In Javascript attribute: String literal</td><td>Yes</td>
+ <td><pre><a href="url" onclick="doFoo('{{ARG}}');"></pre></td>
+ <td>Escape <code>ARG</code> using
+ <code>:javascript_escape</code></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In Javascript attribute: Non-string literal</td><td>Yes</td>
+ <td><pre><a href="url" onclick="doFoo({{ARG}});"></pre></td>
+ <td>Escape <code>ARG</code> using
+ <code>:javascript_escape_with_arg=number</code></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In Javascript attribute: Any</td><td>No</td>
+ <td><pre><a href="url" onclick=doFoo('{{ARG}}');></pre></td>
+ <td><em>Fail template initialization.</em></td>
+</tr>
+
+<tr bgcolor="#F0F8FF">
+ <td>In all other attributes</td><td>Yes</td>
+ <td><pre><b class="{{CLASS}}"></pre></td>
+ <td>Escape <code>CLASS</code> using
+ <code>:html_escape</code></td>
+</tr>
+
+<tr bgcolor="#F0F8FF">
+ <td>In all other attributes</td><td>No</td>
+ <td><pre><table border={{BORDER}}></pre></td>
+ <td>Escape <code>BORDER</code> using
+ <code>:html_escape_with_arg=attribute</code></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In Javascript code: In a string literal</td><td>Any</td>
+ <td><pre><script>var a = '{{VALUE}}';</script></pre></td>
+ <td>Escape <code>VALUE</code> using
+ <code>:javascript_escape</code></td>
+</tr>
+
+<tr bgcolor="#FAEBD7">
+ <td>In Javascript code: Non-string literal</td><td>Any</td>
+ <td><pre><script>var a = {{VALUE}};</script></pre></td>
+ <td>Escape <code>VALUE</code> using
+ <code>:javascript_escape_with_arg=number</code></td>
+</tr>
+
+<tr bgcolor="#F0F8FF">
+ <td>In a <style> tag</td><td>Any</td>
+ <td><pre><style>font-size={{FONTSIZE}};</style></pre></td>
+ <td>Escape <code>FONTSIZE</code> using
+ <code>:cleanse_css</code></td>
+</tr>
+
+</table>
+
+<h4>Comments:</h4>
+<ul>
+ <li>For values of URL-accepting attributes, we apply a different
+ modifier if the variable is at the beginning of the attribute
+ value or not because in the former case we consider the
+ variable to represent a complete URL and hence also check
+ that its scheme is safe (<code>HTTP</code> or
+ <code>HTTPS</code>).</li>
+ <li>We recommend that you enclose attribute values in quotes
+ in particular:
+ <ol>
+ <li>Under some conditions outlined in the table above, when
+ variables are present in attribute values that are not
+ enclosed in quotes, we may fail template initialization
+ because we do not have escaping modifiers that are safe to
+ use.</li>
+ <li>Also the determination of which escaping modifier
+ to apply for unquoted attribute values specifically
+ is likely to change in the future.</li>
+ </ol>
+</ul>
+
+<p>The Auto Escape mode is designed to be simple to use and to produce
+correct correct escaping with minimal input. It does however come with
+restrictions governing the use of this template system.</p>
+
+<h3><a name="Limitations">Limitations</a></h3>
+
+<ul>
+ <li> <p>Templates may only be included in regular HTML
+ text. Including a template within HTML comments or inside an
+ HTML tag is currently not supported. In the example below,
+ <code>HEADER</code> and <code>FOOTER</code> are properly
+ included but <code>TAG</code> and <code>COMMENT</code> are
+ not.</p>
+ <pre>
+ <html><head>{{>HEADER}}</head><body>
+ <{{>TAG}}>
+ <p>
+ <!-- {{>COMMENT}} -->
+ <p>{{>FOOTER}}
+ </body></html>
+ </pre>
+ <p>If the template system detects that you are including a
+ template in another HTML context, it will log a warning.</p></li>
+
+ <li> <p>Included templates may not cross HTML boundaries. They
+ cannot start with one <code>TemplateContext</code> and end in
+ another. For example, the template below crosses boundaries --
+ it starts in HTML and ends in Javascript -- and is therefore
+ not a valid included template for auto-escaping.</p>
+ <pre>
+ <html>
+ <head>
+ </head>
+ <body>
+ Hello USER.
+ <script>
+ var a = 'not a nice template';
+ </pre>
+ <p>To rectify this violation, continue the template by
+ completing the javascript code and terminating it with a
+ <code></script></code> tag.</p> </li>
+
+ <li> <p>Error reporting. We currently report errors by logging
+ a warning or an error during initial template
+ initialization and parsing if we suspect something is
+ incorrect. Please check for them, as they indicate an error
+ that may cause auto-escaping to work improperly.</p> </li>
+
+ <li> <p>Beware of double escaping. When you use the Auto Escape mode,
+ you surrender all variable escaping to the template system.
+ If you also perform your own escaping in your source code, you may
+ face situations where content was escaped multiple times.</p>
+ <p>In particular, do not use any of the legacy methods below or
+ others that perform variable escaping.</p>
+ <ul>
+ <li> <code>SetEscapedValue</code> </li>
+ <li> <code>SetEscapedFormatttedValue</code> </li>
+ <li> <code>SetEscapedValueAndShowSection</code> </li>
+ </ul>
+ </li>
+
+ <li> <p>Supported HTML contexts. HTML (<code>TC_HTML</code>) and
+ Javascript (<code>TC_JS</code>) templates are well supported.
+ Other template contexts have only basic support.
+ For these contexts, variables are escaped as follows:</p>
+ <table border="1" cellpadding="3" summary="HTML contexts for modifiers">
+ <tr><th>TemplateContext</th><th>Escaping Applied</th></tr>
+ <tr><td>TC_JSON</td>
+ <td><code>:javascript_escape</code></td></tr>
+ <tr><td>TC_XML</td>
+ <td><code>:xml_escape</code></td></tr>
+ <tr><td>TC_CSS</td>
+ <td><code>:cleanse_css</code></td></tr>
+ </table></li>
+
+ <li> <p>New restrictions on the use of <code>BI_SPACE</code> and
+ <code>BI_NEWLINE</code>. These system variables may not be
+ re-assigned to a semantically different value via
+ <code>dict->SetValue</code> or related methods, and they may
+ not have modifiers attached to them in templates. For
+ instance: it's ok to redefine <code>BI_NEWLINE</code> from
+ <code>\n</code> to <code>\r\n</code>, since html treats them
+ identically. But changing it to <code>hello, world!</code> is
+ not allowed.</p> </li>
+</ul>
+
+<h4> A new filename convention </h4>
+
+<p>The Auto Escape feature codifies simple conventions
+of template filenames: </p>
+<ol>
+ <li> CSS templates optionally include, in their filename, the
+ keywords <code>style</code> or <code>stylesheet</code> or
+ <code>css</code>. </li>
+ <li> Javascript templates optionally include, in their filename, the
+ keywords <code>js</code> or <code>javascript</code>. </li>
+</ol>
+
+<p>If we find one of these keywords in the filename but
+it does not match the template type given, we log a warning.</p>
+
+<hr>
+<ul>
+ <li> <A HREF="guide.html">User's Guide</A> </li>
+ <li> <A HREF="reference.html">Reference Manual</A> </li>
+<!--
+ <li> <A HREF="auto_escape.html">Auto Escape</A> </li>
+-->
+ <li> <A HREF="tips.html">Tips</A> </li>
+ <li> <A HREF="example.html">Example</A> </li>
+</ul>
+
+
+
+<hr>
+<address>
+Jad Boutros<br>
+</address>
+
+</body>
+</html>
diff --git a/doc/designstyle.css b/doc/designstyle.css
new file mode 100644
index 0000000..29299af
--- /dev/null
+++ b/doc/designstyle.css
@@ -0,0 +1,109 @@
+body {
+ background-color: #ffffff;
+ color: black;
+ margin-right: 1in;
+ margin-left: 1in;
+}
+
+
+h1, h2, h3, h4, h5, h6 {
+ color: #3366ff;
+ font-family: sans-serif;
+}
+@media print {
+ /* Darker version for printing */
+ h1, h2, h3, h4, h5, h6 {
+ color: #000080;
+ font-family: helvetica, sans-serif;
+ }
+}
+
+h1 {
+ text-align: center;
+ font-size: 18pt;
+}
+h2 {
+ margin-left: -0.5in;
+}
+h3 {
+ margin-left: -0.25in;
+}
+h4 {
+ margin-left: -0.125in;
+}
+hr {
+ margin-left: -1in;
+}
+
+/* Definition lists: definition term bold */
+dt {
+ font-weight: bold;
+}
+
+address {
+ text-align: right;
+}
+/* Use the <code> tag for bits of code and <var> for variables and objects. */
+code,pre,samp,var {
+ color: #006000;
+}
+/* Use the <file> tag for file and directory paths and names. */
+file {
+ color: #905050;
+ font-family: monospace;
+}
+/* Use the <kbd> tag for stuff the user should type. */
+kbd {
+ color: #600000;
+}
+div.note p {
+ float: right;
+ width: 3in;
+ margin-right: 0%;
+ padding: 1px;
+ border: 2px solid #6060a0;
+ background-color: #fffff0;
+}
+
+UL.nobullets {
+ list-style-type: none;
+ list-style-image: none;
+ margin-left: -1em;
+}
+
+/* pretty printing styles. See prettify.js */
+.str { color: #080; }
+.kwd { color: #008; }
+.com { color: #800; }
+.typ { color: #606; }
+.lit { color: #066; }
+.pun { color: #660; }
+.pln { color: #000; }
+.tag { color: #008; }
+.atn { color: #606; }
+.atv { color: #080; }
+pre.prettyprint { padding: 2px; border: 1px solid #888; }
+
+.embsrc { background: #eee; }
+
+@media print {
+ .str { color: #060; }
+ .kwd { color: #006; font-weight: bold; }
+ .com { color: #600; font-style: italic; }
+ .typ { color: #404; font-weight: bold; }
+ .lit { color: #044; }
+ .pun { color: #440; }
+ .pln { color: #000; }
+ .tag { color: #006; font-weight: bold; }
+ .atn { color: #404; }
+ .atv { color: #060; }
+}
+
+/* Table Column Headers */
+.hdr {
+ color: #006;
+ font-weight: bold;
+ background-color: #dddddd; }
+.hdr2 {
+ color: #006;
+ background-color: #eeeeee; }
\ No newline at end of file
diff --git a/doc/example.html b/doc/example.html
new file mode 100644
index 0000000..91464c5
--- /dev/null
+++ b/doc/example.html
@@ -0,0 +1,345 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>Template Examples</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link href="designstyle.css" type="text/css" rel="stylesheet">
+<style type="text/css">
+ ol.bluelist li {
+ color: #3366ff;
+ font-family: sans-serif;
+ }
+ ol.bluelist li p {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ ul.blacklist li {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+</style>
+</head>
+
+<body>
+
+<h1>Template Examples</h1>
+
+
+<h2> Simple Example </h2>
+
+<p>One reason this example is so simple is that it doesn't even
+require a separate template file, but instead uses
+<code>StringToTemplateCache()</code>. It also doesn't use sections or
+template-includes.</p>
+
+<pre class=example>
+
+int main() {
+ static const char template_text[] =
+ "ERROR: {{FUNCTION}}({{ARGS}}) returned {{ERROR_CODE}}: {{ERROR_MESSAGE}}\n";
+ ctemplate::StringToTemplateCache("mytpl", template_text, ctemplate::DO_NOT_STRIP);
+ FILE* fp = fopen(argv[1], "r");
+ if (fp == NULL) {
+ int err_no = errno; // squirrel this away
+ ctemplate::TemplateDictionary dict("error_msg: fopen()");
+ dict.SetValue("FUNCTION", "fopen");
+ dict.SetValue("ARGS", argv[1]);
+ dict.SetIntValue("ERROR_CODE", err_no);
+ dict.SetValue("ERROR_MESSAGE", strerror(err_no));
+
+ string error_text;
+ ctemplate::ExpandTemplate("mytpl", ctemplate::DO_NOT_STRIP, &dict, &error_text);
+ puts(error_text.c_str());
+ }
+}
+
+</pre>
+
+Note: If this template was intended to run in a web application, you can
+leverage the functionality provided by the auto-escape mode. Simply add
+the AUTOESCAPE pragma directive at the top of the template text and your
+variables will be automatically escaped for the context you specify.
+
+For example, if your template is returned in an HTML context,
+change the <code>template_text</code> declaration as follows:
+
+<pre class=example>
+ static const char template_text[] =
+ "{{%AUTOESCAPE context=\"HTML\"}}"
+ "ERROR: {{FUNCTION}}({{ARGS}}) returned {{ERROR_CODE}}: {{ERROR_MESSAGE}}\n";
+</pre>
+
+<p>This example is only slightly more complicated: we only print the
+": <error message>" part when the error message isn't the empty
+string.</p>
+
+<pre class=example>
+
+int main() {
+ static const char template_text[] =
+ "ERROR: {{FUNCTION}}({{ARGS}}) returned {{ERROR_CODE}}"
+ "{{#MSG_SECTION}}: {{ERROR_MESSAGE}}{{/MSG_SECTION}}\n";
+ ctemplate::StringToTemplateCache("mytpl", template_text, ctemplate::DO_NOT_STRIP);
+ FILE* fp = fopen(argv[1], "r");
+ if (fp == NULL) {
+ int err_no = errno; // squirrel this away
+ ctemplate::TemplateDictionary dict("file_error_message");
+ dict.SetValue("FUNCTION", "fopen");
+ dict.SetValue("ARGS", argv[1]);
+ dict.SetIntValue("ERROR_CODE", err_no);
+ if (err_no > 0)
+ dict.SetValueAndShowSection("ERROR_MESSAGE", strerror(err_no),
+ "MSG_SECTION");
+
+ string error_text;
+ ctemplate::ExpandTemplate("mytpl", ctemplate::DO_NOT_STRIP, &dict, &error_text);
+ puts(error_text.c_str());
+ }
+ delete tpl;
+}
+
+</pre>
+
+<p>This maybe-show-text functionality is one way the template
+machinery is more powerful than just using <code>printf</code>.
+Another nice property of templates is you can reuse the same variable
+multiple times in your template string. You can also define the
+variable values in any order.</p>
+
+
+<h2> Search Results Page </h2>
+
+<p>Here is an example template that could be used to format a Google
+search results page:</p>
+
+<pre class=example>
+
+{{>HEADER}}
+<body bgcolor=white>
+
+{{>PAGE_HEADING}}{{!The following div must be on the same line}}<div>
+
+{{!The ONE_RESULT section displays a single search item}}
+{{#ONE_RESULT}}
+ {{! Note: there are two SUBITEM_SECTIONs. They both show or hide together}}
+ {{#SUBITEM_SECTION}}<blockquote>{{/SUBITEM_SECTION}}
+ {{! LEAD_LINE is received HTML-escaped from the backend.}}
+ <p><a href="{{JUMP_TO_URL:html_escape}}" target=nw>{{LEAD_LINE}}</a><font size=-1>
+
+ {{! SNIPPET1, SNIPPET2 are HTML-escaped in the snippet generator.}}
+ {{#SNIPPET1_SECTION}}
+ <br>{{SNIPPET1}}
+ {{/SNIPPET1_SECTION}}
+
+ {{#SNIPPET2_SECTION}}
+ <br>{{SNIPPET2}}
+ {{/SNIPPET2_SECTION}}
+
+ {{#DESCRIPTION_SECTION}}
+ {{! DESC is received HTML-escaped from the backend.}}
+ <br><span class=f>Description:</span> {{DESC}}
+ {{/DESCRIPTION_SECTION}}
+
+ {{#CATEGORY_SECTION}}
+ <br><span class=f>Category:</span> <a href="{{CAT_URL:html_escape}}" class=f>
+ {{CATEGORY:html_escape}}</a>
+ {{/CATEGORY_SECTION}}
+
+ {{#LASTLINE_SECTION}}
+ <br><font color="{{ALT_TEXT_COLOR:h}}">{{URL:h}}
+ {{#KS_SECTION}}} - {{KSIZE:h}}{{/KS_SECTION}}}
+ {{#CACHE_SECTION}}} - <a href="{{CACHE_URL:h}}" class=f>Cached</A>
+ {{/CACHE_SECTION}}}
+ {{#SIM_SECTION}}} - <a href="{{SIM_PAGES_URL:h}}" class=f>Similar pages</A>
+ {{/SIM_SECTION}}}
+
+ {{#STOCK_SECTION}}
+ - <a href="{{STOCK_URL:h}}" class=f>Stock quotes: {{STOCK_SYMBOL:h}}</a>
+ {{/STOCK_SECTION}}
+ </font>
+ {{/LASTLINE_SECTION}}
+
+ {{#MORE_SECTION}}
+ <br>[ <a href="{{MORE_URL:h}}" class=f>More results from {{MORE_LABEL:h}}</a> ]
+ {{/MORE_SECTION}}
+
+ </font><br>
+ {{! Note: there are two SUBITEM_SECTIONs. They both show or hide together}}
+ {{#SUBITEM_SECTION}}</blockquote>{{/SUBITEM_SECTION}}
+{{/ONE_RESULT}}
+</div> {{! this /div closes the div at the top of this file}}
+{{>PAGE_FOOTING}}
+
+</pre>
+
+<p> Here is a sample procedure that could populate a dictionary for
+expanding that template. The "one procedure" entry point is
+<code>fill_search_results_dictionary</code>. The
+<code>SetTemplateValues</code> function is a separate entry point for
+initializing each top-level template with some standard values.</p>
+
+<pre class=example>
+#include "template.h"
+
+RegisterTemplateFilename(SEARCH_RESULTS_FN, "search_results.tpl");
+#include "search_results.tpl.varnames.h" // defines ksr_HEADER, etc.
+
+using ctemplate::TemplateDictionary;
+using ctemplate::ExpandTemplate;
+using ctemplate::STRIP_WHITESPACE;
+
+// IsEmpty
+// A simple utility function
+static bool IsEmpty(const string &str) {
+ return str.empty();
+}
+
+// SetTemplateValues
+// Use the TemplateDictionary object to set template-wide values that
+// may be used in the top-level template and all its sub-sections
+// and included templates. The template-wide values are all
+// colors from the Palette object
+void SetTemplateValues(TemplateDictionary *dictionary, const Palette* colors) {
+ // better would be to use ksr_LINK_COLOR, etc, assuming those are
+ // defined in search_results.tpl.varnames.h. But using literal
+ // text, as here, is legal as well.
+ dictionary->SetValue("LINK_COLOR", colors->link_color);
+ dictionary->SetValue("BAR_TEXT_COLOR", colors->bar_text_color);
+ dictionary->SetValue("TEXT_COLOR", colors->text_color);
+ dictionary->SetValue("FAINT_COLOR", colors->faint_color);
+ dictionary->SetValue("IMPORTANT_COLOR", colors->important_color);
+ dictionary->SetValue("BAR_COLOR", colors->bar_color);
+ dictionary->SetValue("ALT_TEXT_COLOR", colors->alt_text_color);
+ dictionary->SetValue("ALINK_COLOR", colors->alink_color);
+ dictionary->SetValue("VLINK_COLOR", colors->vlink_color);
+}
+
+// fill_search_results_dictionary
+// Iterates through all the QueryResults contained in the Query object.
+// For each one, it sets corresponding template dictionary values
+// (or hides sections containing their variables, if appropriate) in
+// a sub-dictionary and then adds that dictionary to the parent
+void fill_search_results_dictionary(TemplateDictionary *dictionary,
+ const Query *query) {
+ dictionary->SetFilename(SEARCH_RESULTS_FN);
+
+ // These two functions are defined elsewhere
+ fill_header_dictionary(dictionary->AddIncludeDictionary(ksr_HEADER));
+ fill_page_heading_dictionary(dictionary->AddIncludeDictionary(ksr_PAGE_HEADING),
+ query);
+
+ ResultsList *results = query->GetResults();
+ int resCount = 0;
+
+ for (ResultsList::const_iterator iter = results->begin();
+ iter != results->end();
+ ++iter) {
+ QueryResult *qr = (*iter);
+
+ // Create a new sub-dictionary named "Result Dict <n>" for this entry
+
+ ++resCount;
+
+ TemplateDictionary *result_dictionary =
+ dictionary->AddSectionDictionary(ksr_ONE_RESULT);
+
+ result_dictionary->SetValue(ksr_JUMP_TO_URL, qr->GetUrl());
+
+ if (qr->IsSubItem()) {
+ result_dictionary->ShowSection(ksr_SUBITEM_SECTION);
+ }
+
+ result_dictionary->SetValue(ksr_LEAD_LINE, qr->GetLeadLine());
+
+ result_dictionary->SetValueAndShowSection(ksr_SNIPPET1, qr->GetSnippet1(),
+ ksr_SNIPPET1_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_SNIPPET2, qr->GetSnippet2(),
+ ksr_SNIPPET2_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_DESC, qr->GetDescription(),
+ ksr_DESCRIPTION_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_CAT_URL, qr->GetCategoryUrl(),
+ ksr_CATEGORY_SECTION);
+
+ result_dictionary->SetValueAndShowSection("CATEGORY", qr->GetCategoryName(),
+ "CATEGORY_SECTION");
+
+
+ if (IsEmpty(qr->GetDisplayUrl()) &&
+ IsEmpty(qr->GetPageSize()) &&
+ IsEmpty(qr->GetCachedUrl()) &&
+ IsEmpty(qr->GetSimilarPagesUrl()) &&
+ (IsEmpty(qr->GetStockUrl()) ||
+ IsEmpty(qr->GetStockSymbol())) ) {
+ // there is nothing on the last line, so hide it altogether
+ } else {
+ result_dictionary->ShowSection("LASTLINE_SECTION");
+
+ result_dictionary->SetValue(ksr_URL, qr->GetDisplayUrl());
+
+ result_dictionary->SetValueAndShowSection(ksr_KSIZE, qr->GetPageSize(),
+ ksr_KS_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_CACHE_URL, qr->GetCachedUrl(),
+ ksr_CACHE_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_SIM_PAGES_URL,
+ qr->GetSimilarPagesUrl(),
+ ksr_SIM_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_STOCK_URL, qr->GetStockUrl(),
+ ksr_STOCK_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_STOCK_SYMBOL,
+ qr->GetStockSymbol(),
+ ksr_STOCK_SECTION);
+ }
+
+ result_dictionary->SetValueAndShowSection(ksr_MORE_URL, qr->GetMoreUrl(),
+ ksr_MORE_SECTION);
+
+ result_dictionary->SetValueAndShowSection(ksr_MORE_LABEL, qr->GetMoreLabel(),
+ ksr_MORE_SECTION);
+
+ }
+
+ fill_page_footing_dictionary(dictionary->AddIncludeDictionary(ksr_PAGE_FOOTING),
+ query);
+}
+
+void output_page(const Query* query) {
+ TemplateDictionary dict("search-results dict");
+ string output;
+ fill_search_results_dictionary(&dict, query);
+ ctemplate::ExpandTemplate(SEARCH_RESULTS_FN, STRIP_WHITESPACE, &dict, &output);
+ // output now holds the expanded template
+}
+
+</pre>
+
+
+<hr>
+<ul>
+ <li> <A HREF="guide.html">User's Guide</A> </li>
+ <li> <A HREF="reference.html">Reference Manual</A> </li>
+ <li> <A HREF="auto_escape.html">Auto Escape</A> </li>
+ <li> <A HREF="tips.html">Tips</A> </li>
+<!--
+ <li> <A HREF="example.html">Example</A> </li>
+-->
+</ul>
+
+<hr>
+<address>
+Craig Silverstein<br>
+<script type=text/javascript>
+ var lm = new Date(document.lastModified);
+ document.write(lm.toDateString());
+</script>
+</address>
+
+</body>
+</html>
diff --git a/doc/guide.html b/doc/guide.html
new file mode 100644
index 0000000..f60f94a
--- /dev/null
+++ b/doc/guide.html
@@ -0,0 +1,1080 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+<title>How To Use the Ctemplate (formerly Google Template) System</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link href="designstyle.css" type="text/css" rel="stylesheet">
+<style type="text/css">
+ ol.bluelist li {
+ color: #3366ff;
+ font-family: sans-serif;
+ }
+ ol.bluelist li p {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ ul.blacklist li {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+</style>
+</head>
+
+<body>
+
+<h1>How To Use the Ctemplate (formerly Google Template) System</h1>
+<small>(as of
+<script type=text/javascript>
+ var lm = new Date(document.lastModified);
+ document.write(lm.toDateString());
+</script>)
+</small>
+<br>
+
+
+<h2> Motivation </h2>
+
+<p>A template system can be used to separate output formatting
+specifications, which govern the appearance and location of output
+text and data elements, from the executable logic which prepares the
+data and makes decisions about what appears in the output.</p>
+
+<p>Template systems lie along a continuum of power versus separation.
+"Powerful" constructs like variable assignment or conditional
+statements make it easy to modify the look of an application within
+the template system exclusively, without having to modify any of the
+underlying "application logic". They do so, however, at the cost of
+separation, turning the templates themselves into part of the
+application logic.</p>
+
+<p>This template system leans strongly towards preserving the
+separation of logic and presentation. It is intentionally constrained
+in the features it supports and, as a result, applications tend to
+require quite a bit of code to instantiate a template. This may not
+be to everybody's tastes. However, while this design limits the power
+of the template <i>language</i>, it does not limit the power or
+flexibility of the template <i>system</i>. This system supports
+arbitrarily complex text formatting. Many Google applications,
+including the "main" Google web search, use this system
+for formatting output.</p>
+
+<p>Finally, this system is designed with an eye towards efficiency.
+Template instantiation is very quick, with an eye towards minimizing
+both memory use and memory fragmentation.</p>
+
+
+<h2> Overview </h2>
+
+<p>There are two main parts to the Ctemplate System:</p>
+
+<ul>
+ <li> Templates
+ <li> Data dictionaries
+</ul>
+
+<p>The templates are text files that contain the format specification
+for the formatted output, i.e, the template language. The data
+dictionaries contain the mappings from the template elements (markers)
+embedded in the templates to the data that they will format. Here's
+a simple template:</p>
+<pre>
+ <html><head><title>{{TITLE}}</title>{{META_TAGS}}</head>
+ <body>{{BODY}}</body></html>
+</pre>
+
+<p>Here's a dictionary that one could use to instantiate the template:</p>
+<pre>
+ {"TITLE": "Template example",
+ "BODY": "This is a simple template example.\nIt's boring",
+ "DATE": "11/20/2005"}
+</pre>
+
+<p>If we instantiated the template with this dictionary (a process we
+call "expanding"), here's the output we would get:</p>
+<pre>
+ <html><head><title>Template example</title></head>
+ <body>This is a simple template example.
+It's boring</body></html>
+</pre>
+
+<p><code>{{TITLE}}</code> and <code>{{BODY}}</code> are <b>template
+elements</b>, also called <b>markers</b>. In the dictionary,
+<code>TITLE</code>, <code>BODY</code>, and <code>DATE</code> are
+<b>dictionary names</b>, and the values associated with each one, such
+as <code>11/20/2005</code>, are <b>dictionary values</b>.</p>
+
+<p>A few points are clear even from this simple example:</p>
+<ol>
+ <li> Dictionary keys and values are strings; the Ctemplate
+ system is not typed. </li>
+ <li> Dictionary values come already formatted. It was up to the
+ application code to decide how to format the value for
+ <code>DATE</code>, and to insert the date into the dictionary
+ already formatted. </li>
+ <li> Not all dictionary values must be used by a template.
+ <code>DATE</code> is entirely ignored. </li>
+ <li> Not all template elements may exist in the dictionary. In this
+ example, <code>{{META_TAGS}}</code> is not found in the
+ dictionary. This is perfectly legal; missing dictionary names
+ evaluate to the empty string. </li>
+</ol>
+
+
+<h3> Templates </h3>
+
+<p> The template language has four major types of markers (the full
+list of marker types is described in the <A
+HREF="reference.html#template">reference guide</A>):</p>
+<ol>
+ <li> <b>Variable</b> markers, which are replaced by text based on
+ dictionary values. All markers in the above example are
+ variable markers. Variable markers look like this:
+ <code>{{FOO}}</code></li>
+
+ <li> <b>Start section</b> and <b>end section</b> markers, which delimit
+ sections which may appear zero, one, or N times in
+ the output. The number of times a section appears is
+ determined by the data dictionaries, as explained below.
+ Each time a section is expanded, it uses a different
+ dictionary, so that the output values may be different from one
+ iteration of a section expansion to another. Note that the
+ specification of how sections expand is entirely dependent on
+ the dictionary, as set up by the application; there is no way
+ to specify a repeat count in the template language itself.
+ Section markers look like this:
+ <code>{{#FOO}}...{{/FOO}}</code></li>
+
+ <li> <b>Template-include</b> markers, which designate other templates to be
+ expanded and inserted at the location where the marker appears.
+ These are treated much like sections -- one may think of them
+ as sections whose content is specified in a
+ different file instead of inline -- and just like sections, can
+ be expanded zero, one or N times in the output, each with a
+ different dictionary and even a different include-file.
+ Template-include markers look like this:
+ <code>{{>FOO}}</code></li>
+
+ <li> <b>Comment</b> markers, which may annotate the template
+ structure but drop completely out of the expanded
+ output. Comment markers look like this:
+ <code>{{! comment lives here -- cool, no?}}</code></li>
+</ol>
+
+<p>These marker types each have their own namespace. For readability,
+however, it is best to not overuse a single name.</p>
+
+<p>Anything found in a template of the form <code>{{...}}</code> is
+interpreted as a template marker. All other text is considered
+formatting text and is output verbatim at template expansion time.
+Formatting text may consist of HTML tags, XML tags, linefeeds and
+other spacing characters, constant text, etc.</p>
+
+
+<h3> Data Dictionaries </h3>
+
+<p>A data dictionary is a map from keys to values. The keys are
+always strings, each string representing either a variable, a section,
+or a template-include file. (Comments are not stored in the data
+dictionary!) These values correspond to the name of the associated
+template marker: a section <code>{{#FOO}}</code> in the template text
+is matched to the key <code>"FOO"</code> in the dictionary, if it
+exists. Note the case must match as well.</p>
+
+<p>The value associated with a key differs according to key type. The
+value associated with a <i>variable</i> is simple: it's the value for
+that variable. Both keys and values can be any 8-bit
+character-string, and may include internal NULs (\0).</p>
+
+<p>The value associated with a <i>section</i> is more complicated, and
+somewhat recursive: it's a list of data dictionaries. Come
+template-expansion time, the section is expanded once for each
+dictionary in the list, so if there are two dictionaries in the list,
+then the section text will occur in the output twice. The first time,
+all variables/etc. in the section will be evaluated taking into
+account the first dictionary. The second time, all
+variables/etc. will be evaluated taking into account the second
+dictionary. (See <A HREF="#inheritance">below</A> for a definition of
+"taking into account.")</p>
+
+<p>A <i>template-include</i> is a special type of section, so the
+associated value is the same: a list of dictionaries.
+Template-includes also have one other, mandatory associated piece of
+information: the filename of the template to include.</p>
+
+<p>The application program is responsible for building this data
+dictionary, including all nesting. It then applies this dictionary to
+a single template to produce formatted output.</p>
+
+
+<h3>Expanding a Template</h3>
+
+<p>A program using Ctemplate typically reads in templates at
+load time. During the course of program execution, the program will
+repeatedly perform the following two steps: first, instantiate a data
+dictionary, and second, apply the dictionary to the template to
+produce output.</p>
+
+<p>The template system applies a dictionary to a template by finding
+all template markers in the template, and replacing them with the
+appropriate dictionary values. It matches template markers to
+dictionary keys in the obvious way. For instance, a template marker
+<code>{{FOO}}</code> matches the dictionary key <code>FOO</code>. The
+marker <code>{{#BAR}}</code> matches the dictionary key
+<code>BAR</code>, as does the marker <code>{{/BAR}}</code>. The
+marker <code>{{>BAZ}}</code> matches the dictionary key
+<code>BAZ</code>. (And of course, the marker <code>{{!
+comment}}</code> doesn't match any dictionary key at all.)</p>
+
+<p>If no dictionary key is found for a given template marker, then the
+template marker is ignored: if a variable, it expands to the empty
+string; if a section or include-template, the section or
+include-template is expanded zero times.</p>
+
+<p>All names are case sensitive. Names -- that is, variable keys and,
+as a result, template markers -- must be made of (7-bit ascii)
+alphanumeric characters and the underscore. The comment marker,
+which does not map to dictionary keys, may contain any characters
+whatsoever except <code>}</code>, the close-curly brace. It's a
+syntax error for any template marker to violate this rule.</p>
+
+<p>Outside of the template markers, templates may contain any text
+whatsoever, including (single) curly braces and NUL characters.</p>
+
+
+<h3> <A NAME="auto_escape">Auto Escape Mode</A> </h3>
+
+<p>The Auto Escape mode helps protect against cross-site scripting
+(XSS) attacks in web-applications by automatically escaping variables
+in your template. The <a href="auto_escape.html">Guide to using Auto
+Escape</a> has an overview of Auto Escape as well as discussion of its
+limitations.</p>
+
+<p>Auto Escape is enabled on a template-by-template basis. Simply add
+the AUTOESCAPE pragma to the desired template. That template will then
+be automatically escaped, independently of the templates it may
+include or it may be included from. The AUTOESCAPE pragma must be
+placed at the top of the template. It takes a 'context' argument
+saying what context the template is used in: html, javascript, css,
+xml, etc. (There's also a <code>state=IN_TAG</code> argument that is
+used when the template is just a snippet of html intended for use in a
+tag.) See the <A HREF="reference.html#auto_escaping">reference
+guide</A> for a full description of autoescape arguments.</p>
+
+<p>The table below shows four small sample templates along with their
+corresponding AUTOESCAPE pragma. The two most common contexts are
+<code>HTML</code> and <code>JAVASCRIPT</code>. We also show a sample
+template for the <code>CSS</code> context as well as a sample template
+for the <code>IN_TAG</code> state of <code>HTML</code>
+(although it is expected to be rarely used).</p>
+
+<p>
+<table id="AutoescapePragmaEx" border=1 cellpadding=3>
+ <tr>
+ <th>HTML</th>
+ <th>JAVASCRIPT</th>
+ <th>CSS</th>
+ <th>HTML IN_TAG (uncommon)</th>
+ </tr>
+ <tr valign="top">
+ <td>
+ <pre>
+ {{%AUTOESCAPE context="HTML"}}
+
+ <body>
+ <p>Hello {{USER}}</p>
+ <p><a href="{{URL}}">Your Account</a></p>
+ </body>
+ </pre>
+ </td>
+ <td>
+ <pre>
+ {{%AUTOESCAPE context="JAVASCRIPT"}}
+
+ function showMessage(user, msg) {
+ alert("Hello: " + user + " Message: " + msg);
+ }
+
+ var user = '{{USER}}';
+ var msg = '{{MSG}}';
+ showMessage(user, msg);
+ </pre>
+ </td>
+ <td>
+ <pre>
+ {{%AUTOESCAPE context="CSS"}}
+
+ P.abstract {
+ text-align:{{EDGE}};
+ font-size:{{FONT_SIZE_PC}};
+ }
+ .italic {font-style:{{ITALIC}}}
+ </pre>
+ </td>
+ <td>
+ <pre>
+ {{%AUTOESCAPE context="HTML" state="IN_TAG"}}
+
+ class="{{CLASS}}" id="{{ID}}"
+ </pre>
+ </td>
+ </tr>
+</table>
+</p>
+
+<p>Auto-escaping works by automatically applying <i>modifiers</i> to
+every variable in the template. You can manually apply modifiers as
+well, and even define your own. See the <A
+HREF="reference.html#template_modifier">reference guide</A> for a full
+discussion of modifiers and how to use them.</p>
+
+
+<h3> <A NAME="inheritance">Details on Dictionary Lookup</A> </h3>
+
+<p>The dictionary structure is a tree: there's a 'main' dictionary,
+and then a list of sub-dictionaries for each section or
+include-template. Even with all this complexity, the lookup rules are
+mostly straightforward: when looking up a marker -- be it a variable,
+section, or include-template marker -- the system looks in the
+currently applicable dictionary. If it's found there, great. If not,
+and the parent dictionary is not an include-template, it continues the
+look in the parent dictionary, and possibly the grandparent, etc.
+That is, lookup has <i>static scoping</i>: you look in your dictionary
+and any parent dictionary that is associated with the same
+template-file. As soon as continuing the lookup would require you to
+jump to a new template-file (which is what include-template would do),
+we stop the lookup.</p>
+
+<p>For instance, for a template that says
+<code>{{#RESULTS}}{{RESULTNUM}}. {{>ONE_RESULT}}{{/RESULTS}}</code>,
+<code>"ONE_RESULT"</code> is looked for in the "RESULTS" dictionary,
+and if not found there, is looked for in the main, top-level
+dictionary. Likewise, the variable <code>"RESULTNUM"</code> is looked
+for first in the "RESULTS" dictionary, then in the main dictionary if
+necessary. However, "ONE_RESULT" will not do equivalent cascading
+lookups. In fact, it will have no parent dictionaries at all, because
+it's a different template file and thus in a different scope.</p>
+
+<p>Because of these scoping rules, it's perfectly reasonable to set
+all variables that are needed in a given template file, in the
+top-level dictionary for that template. In fact, the <code><A
+HREF="#sections">ShowSection()</A></code> function is provided to
+support just this idiom. To avoid confusion in such a usage mode,
+it's strongly encouraged that you give unique names to all sections
+and include-templates in a single template file. (It's no problem,
+given the template scoping rules, for a single section or
+include-template name to be repeated across different template
+files.)</p>
+
+<p>There's a single special case: the <b>global variable
+dictionary</b>. Every dictionary inherits its initial set of values
+from the global dictionary. Clients can <A HREF="#variables">set
+variables in the global dictionary</A> just like they can in normal
+template dictionaries they create.</p>
+
+<p>The system initializes the global dictionary with a few useful
+values for your convenience. All system variables are prefixed with
+<code>BI</code>, to emphasize they are "built in" variables.</p>
+<ul>
+ <li> <code>BI_SPACE</code>, which has the value
+ <code><space></code>. It is used to force a space
+ at the beginning or end of a line in the template,
+ where it would normally be suppressed. (See below.) </li>
+
+ <li><code>BI_NEWLINE</code>, which has the value
+ <code><newline></code> It is used to force a
+ newline at the end of a line, where it would normally
+ be suppressed. (See below.) </li>
+</ul>
+
+<p>As is usual for inheritance, if a user explicitly assigns a value
+to these variable-names in its own dictionary, this overrides the
+inherited value. So, <code>dict->SetValue("BI_SPACE",
+"&nbsp;")</code> causes <code>BI_SPACE</code> to have the value
+<code>&nbsp;</code>, rather than <code><space></code>, when
+expanding <code>dict</code>.</p>
+
+<p>Note that only variables can be inherited from the global
+dictionary, not section dictionaries or include-file dictionaries.</p>
+
+<p>A couple of small implementation notes: global inheritance is "last
+chance", so if a section's parent dictionary redefined
+<code>BI_SPACE</code>, say, the section dictionary inherits the
+parent-dict value, not the global-dict value. Second, variable
+inheritance happens at expand time, not at dictionary-create time. So
+if you create a section dictionary, and then afterwards set a variable
+in its parent dictionary (or in the global dictionary), the section
+<i>will</i> inherit that variable value, if it doesn't define the
+value itself.</p>
+
+
+<h2> Writing Application Code To Use Templates </h2>
+
+<p>Most application code concerns filling a template dictionary, but
+there is also code for expanding templates given a dictionary. A
+final category of code lets you inspect and control the template
+system.</p>
+
+
+<h3> Creating A Template Dictionary </h3>
+
+<p>The class <code>TemplateDictionary</code> is used for all template
+dictionary operations. <code>new ctemplate::TemplateDictionary(name)</code> is
+used to create a new top-level dictionary.
+<code>dict->AddSectionDictionary(name)</code> and
+<code>dict->AddIncludeDictionary(name)</code> are used to create
+sub-dictionaries for sections or include-files. After
+creating a dictionary, the application should call one or more
+functions for each marker in the template. As an example, consider
+the following template:
+<pre>
+<html><body> {{! This page has no head section.}}
+{{#CHANGE_USER}}
+<A HREF="/login">Click here</A> if you are not {{USERNAME}}<br>
+{{/CHANGE_USER}}
+
+Last five searches:<ol>
+{{#PREV_SEARCHES}
+<li> {{PREV_SEARCH}}
+{{/PREV_SEARCHES}}
+</ol>
+
+{{>RESULT_TEMPLATE}}
+
+{{FOOTER}}
+</body></html>
+</pre>
+
+<p>To instantiate the template, the user should call a function to set
+up <code>FOOTER</code>, and a function to say what to do for the
+sections <code>CHANGE_USER</code> and <code>PREV_SEARCHES</code>, and
+for the include-template <code>RESULT_TEMPLATE</code>. Quite likely,
+the application will also want to create a sub-dictionary for
+<code>CHANGE_USER</code>, and in that sub-dictionary call a function
+to set up <code>USERNAME</code>. There will also be sub-dictionaries
+for <code>PREV_SEARCHES</code>, each of which will need to set
+<code>PREV_SEARCH</code>. Only when this is all set up will the
+application be able to apply the dictionary to the template to get
+output.</p>
+
+<p>The appropriate function to call for a given template marker
+depends on its type.</p>
+
+<h4> <A NAME="variables">Variables</A> </h4>
+
+<p>For variables, the only interesting action is to set the variable's
+value. For most variables, the right method to call is
+<code>dict->SetValue(name, value)</code>. (The name and value
+can be specified as strings in a variety of ways: C++ strings, char
+*'s, or char *'s plus length.)</p>
+
+<p>There are two other ways to set a variable's value as well, each
+with a different scoping rule. You can call
+<code>ctemplate::TemplateDictionary::SetGlobalValue(name, value)</code>
+-- no <code>TemplateDictionary</code> instance needed here -- to set a
+variable that can be used by all templates in an application. This
+is quite rare.</p>
+
+<p>You can also call <code>dict->SetTemplateGlobalValue(name,
+value)</code>. This sets a variable that is seen by all child
+dictionaries of this dictionary: sub-sections you create via
+<code>AddSectionDictionary</code>, and included templates you create
+via <code>AddIncludeDictionary</code> (both described below). This
+differs from <code>SetValue()</code>, because <code>SetValue()</code>
+values are never inherited across template-includes. Almost always,
+<code>SetValue</code> is what you want;
+<code>SetTemplateGlobalValue</code> is intended for variables that are
+"global" to a particular template tree not all template trees, such as
+a color scheme to use, a language code, etc.</p>
+
+<p>To make it easier to use <code>SetValue()</code>, there are a few
+helper routines to help setting values of a few special forms.</p>
+
+<ul>
+ <li> <code>SetIntValue(name, int)</code>: takes an int as the value. </li>
+ <li> <code>SetFormattedValue(name, fmt, ...)</code>: the
+ <code>fmt</code> and <code>...</code> work just like in
+ <code>printf</code>: <code>SetFormattedValue("HOMEPAGE",
+ "http://%s/", hostname)</code>. </li>
+</ul>
+
+<p>Example:</p>
+<pre>
+ ctemplate::TemplateDictionary* dict = new ctemplate::TemplateDictionary("var example");
+ dict->SetValue("FOOTER", "Aren't these great results?");
+</pre>
+
+<h4> <A NAME="sections">Sections</A> </h4>
+
+<p>Sections are used in two ways in templates. One is to expand some
+text multiple times. This is how <code>PREV_SEARCHES</code> is used
+in the example above. In this case we'll have one small
+sub-dictionary for each of the five previous searches the user did.
+To do this, call <code>AddSectionDictionary(section_name)</code>
+to create the sub-dictionary. It returns a
+<code>TemplateDictionary*</code> that you can use to fill the
+sub-dictionary.
+
+<p>The other use of sections is to conditionally show or hide a block
+of text at template-expand time. This is how <code>CHANGE_USER</code>
+is used in the example template: if the user is logged in, we show the
+section with the user's username, otherwise we choose not to show the
+section.</p>
+
+<p>This second case is a special case of the first, and the "standard"
+way to show a section is to expand it exactly one time, by calling
+<code>AddSectionDictionary()</code> once, and then setting
+<code>USERNAME</code> in the sub-dictionary.</p>
+
+<p>However, the hide/show idiom is so common there are a few
+convenience methods to make it simpler. The first takes advantage of
+the fact sections inherit variables from their parent: you set
+<code>USERNAME</code> in the parent dictionary, rather than a section
+sub-dictionary, and then call <code>ShowSection()</code>, which adds a
+single, empty dictionary for that section. This causes the section to
+be shown once, and to inherit <i>all</i> its variable values from its
+parent.</p>
+
+<p>A second convenience method is written for the particular case we
+have with <code>USERNAME</code>: if the user's username is non-empty,
+we wish to
+show the section with <code>USERNAME</code> set to the username,
+otherwise we wish to hide the section and show neither
+<code>USERNAME</code> nor the text around it. The method
+<code>SetValueAndShowSection(name, value, section_name)</code> does
+exactly that: if value is non-empty, add a single dictionary to
+<code>section_name</code> and call <code>section_dict->AddValue(name,
+value)</code>.</p>
+
+<p>Example:</p>
+<pre>
+ ctemplate::TemplateDictionary* dict = new ctemplate::TemplateDictionary("section example");
+ const char* username = GetUsername(); // returns "" for no user
+ if (username[0] != '\0') {
+ ctemplate::TemplateDictionary* sub_dict = dict->AddSectionDictionary("CHANGE_USER");
+ sub_dict->SetValue("USERNAME", username);
+ } else {
+ // don't need to do anything; we want a hidden section, which is the default
+ }
+
+ // Instead of the above 'if' statement, we could have done this:
+ if (username[0] != '\0') {
+ dict->ShowSection("CHANGE_USER"); // adds a single, empty dictionary
+ dict->SetValue("USERNAME", username); // take advantage of inheritance
+ } else {
+ // don't need to do anything; we want a hidden section, which is the default
+ }
+
+ // Or we could have done this:
+ dict->SetValueAndShowSection("USERNAME", username, "CHANGE_USER");
+
+ // Moving on...
+ GetPrevSearches(prev_searches, &num_prev_searches);
+ if (num_prev_searches > 0) {
+ for (int i = 0; i < num_prev_searches; ++i) {
+ TemplateDictionary* sub_dict = dict->AddSectionDictionary("PREV_SEARCHES");
+ sub_dict->SetValue("PREV_SEARCH", prev_searches[i]);
+ }
+ }
+</pre>
+
+<h4> Template-includes </h4>
+
+<p>Template-include markers are much like section markers, so
+<code>AddIncludeDictionary(name)</code> acts, not surprisingly,
+exactly like <code>AddSectionDictionary(name)</code>. However, since
+variable inheritance doesn't work across include boundaries, there is
+no template-include equivalent to <code>ShowSection()</code> or
+<code>SetValueAndShowSection()</code>.</p>
+
+<p>One difference between template-includes and sections is that for a
+sub-dictionary that you create via
+<code>AddIncludeDictionary()</code>, you <i>must</i> call
+<code>subdict->SetFilename()</code> to indicate the name of the
+template to include. If you do not set this, the sub-dictionary will
+be ignored. The filename may be absolute, or relative, in which case
+it's relative to some entry in the <A
+HREF="reference.html#template_cache">template search path</A>.</p>
+
+<p>Example:</p>
+<pre>
+ using ctemplate::TemplateDictionary;
+ TemplateDictionary* dict = new TemplateDictionary("include example");
+ GetResults(results, &num_results);
+ for (int i = 0; i < num_results; ++i) {
+ TemplateDictionary* sub_dict = dict->AddIncludeDictionary("RESULT_TEMPLATE");
+ sub_dict->SetFilename("results.tpl");
+ FillResultsTemplate(sub_dict, results[i]);
+ }
+</pre>
+
+<p>In practice, it's much more likely that
+<code>FillResultsTemplate()</code> will be the one to call
+<code>SetFilename()</code>. Note that it's not an error to call
+<code>SetFilename()</code> on a dictionary even if the dictionary is
+not being used for a template-include; in that case, the function is a
+no-op, but is perhaps still useful as self-documenting code.</p>
+
+<p>Another property of template-includes is that they set the indentation level
+for the included template, that is, every line in the included template is
+indented by the same amount as the template-includes line itself. For
+instance, if you have a template <code>PRINT_STUFF</code> like this:</p>
+<pre>
+print "Hello!"
+print "You are the 10th caller!"
+print "Congratulations!"
+</pre>
+
+<p>and you include it in the template:</p>
+
+<pre>
+ if ShouldPrintStuff():
+ {{>PRINT_STUFF}}
+ else:
+ pass
+</pre>
+
+<p>then when it is expanded, all three print lines will be indented,
+not just the first one:</p>
+
+<pre>
+ if ShouldPrintStuff():
+ print "Hello!"
+ print "You are the 10th caller!"
+ print "Congratulations!"
+ else:
+ pass
+</pre>
+
+<p>Note that this behavior is immaterial when using <A
+HREF="#expand"><code>STRIP_WHITESPACE</code></A>, since in that case
+all leading whitespace is stripped.</p>
+
+
+<h3> <A name="expand">Expanding a Template</A> </h3>
+
+<p>Once you have a template dictionary, it's simplicity itself to
+expand the template with those dictionary values, putting the output
+in a string:</p>
+<pre>
+ ctemplate::TemplateDictionary dict("debug-name");
+ FillDictionary(&dict, ...);
+ string output;
+ bool error_free = <font color=red>ctemplate::ExpandTemplate(<filename>, ctemplate::STRIP_WHITESPACE, &dict, &output);</font>
+ // output now holds the expanded template.
+ // ExpandTemplate returns false if the system cannot load-and-parse
+ // <filename> or any of the template files referenced by the
+ // TemplateDictionary.
+</pre>
+
+<p>The first argument to <code>ExpandTemplate</code> is the filename
+holding the template to expand (though there are ways to use <A
+HREF="#string">non-file-based templates</A> as well). The second argument
+is the "strip" mode, which specifies how to treat whitespace in the
+template. It can take the following values:</p>
+<ul>
+ <li> <code>ctemplate::DO_NOT_STRIP</code>: do nothing. This expands
+ the template file verbatim.
+
+ <li> <code>ctemplate::STRIP_BLANK_LINES</code>: remove all blank
+ lines. This ignores any blank lines found in the template file
+ when parsing it. When the template is html, this reduces the
+ size of the output text without requiring a sacrifice of
+ readability for the input file.
+
+ <li> <code>ctemplate::STRIP_WHITESPACE</code>: remove not only blank
+ lines when parsing, but also whitespace at the beginning and
+ end of each line. It also removes any linefeed (possibly
+ following whitespace) that follows a closing <code>}}</code> of
+ any kind of template marker <i>except</i> a template variable.
+ (This means a linefeed may be removed anywhere by simply
+ placing a comment marker as the last element on the line.)
+ When the template is html, this reduces the size of the output
+ html without changing the way it renders (except in a few
+ special cases.) When using this flag, the built-in template
+ variables <code>BI_NEWLINE</code> and <code>BI_SPACE</code> can
+ be useful to force a space or newline in a particular
+ situation.
+</ul>
+
+<p>The expanded template is written to the string <code>output</code>.
+If <code>output</code> was not empty before calling
+<code>Expand()</code>, the expanded template is appended to the end of
+<code>output</code>.
+
+<p>There is also a "power user" version of
+<code>ExpandTemplate()</code>, called <code>ExpandWithData()</code>,
+that allows you to pass in per-expand data. Another "power user"
+version allows you to expand the template into a custom output
+container, rather than a string. See the <A
+HREF="reference.html#per_expand_data">reference guide</A> for more
+information about these advanced methods.</p>
+
+
+<h3> <A name="string">Getting a Template From a String Rather Than a File</A> </h3>
+
+<p>The first argument to <code>ExpandTemplate</code> is named
+"filename", suggesting that the template has to be read from an
+on-disk file. But in reality, the "filename" argument is just a key
+into an internal cache. (By default, the template system looks on
+disk to satisfy a cache miss, hence the "filename" to describe this
+variable.) If you have a template specified in a string rather than a
+file, you can manually insert it into the cache via
+<code>ctemplate::StringToTemplateCache()</code>.</p>
+
+<p><code>StringToTemplateCache()</code> parses the string you pass in
+as if it were a template file, and inserts it into the global cache
+with the key and strip-mode that you provide. You can then use this
+key and strip-mode as the first two arguments to
+<code>ExpandTemplate</code>. You can also use the key as the argument
+to <code>ctemplate::TemplateDictionary::SetFilename()</code>.</p>
+
+<p>Prefer file-based to string-based templates where possible.
+Updating a file-based template requires merely a data push, rather
+than pushing the new executable, and it also makes it easier for
+non-programmers to modify the template. One reason to use
+string-based templates is if you are in an environment where having
+data files could be dangerous—for instance, you work on a disk
+that is usually full, or need the template to work even in the face of
+disk I/O errors.</p>
+
+<p>This package comes with a script, <A
+HREF="reference.html#template_converter">template-converter</A>, that
+takes a template file as input and emits a C++ code snippet (an .h
+file) that defines a string with those template contents. This makes
+it easy to start by using a normal, file-based template, and then
+switch to <code>StringToTemplateCache()</code> later if you so
+desire.</p>
+
+
+<h3> Copying a Template Dictionary </h3>
+
+<p>You can use the <code>MakeCopy()</code> method on a template
+dictionary to make a "deep" copy of the template. This can be useful
+for situations like the following: you want to fill a template several
+times, each time with 90% of the values the same, but the last 10%
+different. Computing the values is slow. Here's how you can use
+<code>MakeCopy()</code> to do it:</p>
+<ol>
+ <li> fill dict with 90%
+ <li> <code>newdict1 = dict->MakeCopy();</code>
+ <li> fill newdict1 with last 10%
+ <li> <code>newdict2 = dict->MakeCopy();</code>
+ <li> fill newdict2 with last 10%
+ <li> etc.
+</ol>
+
+
+<h3> The Template Cache </h3>
+
+<p>When templates are loaded from disk, they are stored in an internal
+template cache, which is used by <code>ExpandTemplate()</code> and
+(most obviously) <code>StringToTemplateCache()</code>. You can define
+your own template cache with the <code>TemplateCache</code> class.</p>
+
+<p>This is an advanced technique used when you want to support having
+several versions of a template file in memory at the same time (for
+instance, a webserver might want to keep an old version of a template
+file around until all old requests using that template are done being
+serviced). It also supports advanced operations like removing a
+template from the cache, and reloading templates from disk if they
+have changed.</p>
+
+<p>See the <A HREF="reference.html#template_cache">reference
+manual</A> for more details about the template cache.</p>
+
+
+<h3> Template and Threads </h3>
+
+<p>All expansion functions and static <code>TemplateDictionary</code>
+methods are threadsafe: you can safely call
+<code>ctemplate::TemplateDictionary::SetGlobalValue()</code>
+without needing to worry about locking.</p>
+
+<p>Non-static <code>TemplateDictionary</code> methods are not
+thread-safe. It is not safe for two threads to assign values to the
+same template-dictionary without doing their own locking. Note that
+this is expected to be quite rare: usually only one thread will care
+about a given template-dictionary.</p>
+
+
+<h2> <a name="testing_templates">Testing Templates</a> </h2>
+
+<p>Templates have the advantage that they separate the presentation of
+your data from the application logic that generates the data.
+Naturally, you want to do the same for testing: you would like to test
+the application's <i>logic</i> in a way that is robust to changes in
+the <i>presentation</i>.</p>
+
+<p>The easiest way to test this logic is with unit tests that exercise
+the functions in your code that fill template dictionaries. The class
+<code>ctemplate::TemplateDictionaryPeer</code> in
+<code>template_test_util.h</code> is designed to help you do exactly
+that.</p>
+
+<p>Here's a sample test using <code>TemplateDictionaryPeer</code>:</p>
+<pre>
+ void MyTestMethod() {
+ // Create and populate the dictionary as your app normally would.
+ // In this case, we create a dict with data like this:
+ // { color:blue,
+ // shape_section: [
+ // { size:big, num_sides:7 },
+ // { size:big, num_sides:7 },
+ // { size:big, num_sides:7 }
+ // ]
+ // }
+ MyObject obj;
+ ctemplate::TemplateDictionary dict;
+ obj.FillDictionary(&dict);
+ // Create a TemplateDictionaryPeer to gain access to the dict contents.
+ ctemplate::TemplateDictionaryPeer peer(&dict);
+ // Expect color:blue at the top level of this dictionary.
+ EXPECT_STREQ("blue", peer.GetSectionValue("color"));
+ // Fetch sub-dictionaries from the dict.
+ vector<const ctemplate::TemplateDictionary*> shape_dicts;
+ peer.GetSectionDictionaries("shape_section", &shape_dicts);
+ EXPECT_EQ(3, shape_dicts.size());
+ for (int i = 0; i < 3; ++i) {
+ // Create another peer for each sub-dict, and assert that each sub-dict
+ // contains the expected data.
+ ctemplate::TemplateDictionaryPeer shape_peer(dicts[i]);
+ EXPECT_STREQ("big", shape_peer.GetSectionValue("size"));
+ EXPECT_STREQ("7", shape_peer.GetSectionValue("num_sides"));
+ }
+ }
+</pre>
+
+<p>Note that by using <code>TemplateDictionaryPeer</code>, you can
+unit test the code for filling a <code>TemplateDictionary</code>
+independent of the consuming <code>Template</code>.</p>
+
+<p>The above tests your dictionary filling functions, but doesn't
+touch the template expansion. Naturally, you may also want to test
+the template itself. In this case, you will want to avoid using your
+program's dictionary filling functions, and will instead provide a
+custom dictionary in your test. There are a variety of properties you
+might want to test about the template, but here are a few sample
+tests:</p>
+
+<pre>
+ void TestTemplateHTMLEscapesColor() {
+ // Populate a dictionary that lets us exercise the condition we're testing.
+ // In this case, that the 'color' tag will be HTML escaped.
+ ctemplate::TemplateDictionary dict("t1");
+ dict.SetValue("color", "<blue>");
+ // Expand the template with this dictionary.
+ string result;
+ ctemplate::ExpandTemplate(FLAGS_test_srcdir + "templates/my_template.html",
+ ctemplate::STRIP_WHITESPACE, &dict, &result);
+ // Assert that the expansion has the appropriate text in it.
+ EXPECT_THAT(result, HasSubstr("&lt;blue&gt;"));
+ }
+
+ void TestColorAppearsBeforeShape() {
+ // This time, the condition under test is that the "color" element of
+ // the dictionary appears before the "shape" element.
+ // Create an appropriate dictionary.
+ ctemplate::TemplateDictionary dict("t2"); // Note: use sufficiently unique
+ dict.SetValue("color", "white_asdf"); // strings that they won't occur
+ dict.SetValue("shape", "square_asdf"); // "bare" in the template.
+
+ string result;
+ ctemplate::ExpandTemplate(FLAGS_test_srcdir + "templates/my_template.html",
+ ctemplate::STRIP_WHITESPACE, &dict, &result);
+ // Assert that color comes before shape.
+ EXPECT_THAT(result, ContainsRegex("white_asdf.*square_asdf"));
+ }
+</pre>
+
+
+<h2> <A NAME="security">Security Considerations</A> </h2>
+
+<p>Like all web applications, programs that use the Ctemplate
+System to create HTML documents can be vulnerable to
+Cross-Site-Scripting (XSS) attacks unless data inserted into a
+template is appropriately sanitized and/or escaped. Which specific
+form of escaping or sanitization is required depends on the context in
+which the template variable appears within a HTML document (such as,
+regular "inner text", within a <code><script></code> tag, or
+within an <code>onClick</code> handler).
+
+<p>If you are concerned with XSS, your are strongly encouraged to
+leverage the <a href="auto_escape.html">Auto Escape</a> mode developed
+specifically to better defend your application against XSS. The Auto
+Escape mode follows the guidelines outlined below. Do note however
+that regardless of whether you use Auto Escape or not, escaping alone
+while generally required, is often not enough! You also may need to
+sanitize or validate the input, as for instance with URL attributes.
+For further information, refer to additional <a
+href="xss_resources.html">resources</a> on Cross-Site-Scripting
+issues.</p>
+
+The remainder of this section provides a brief summary of techniques
+to prevent XSS vulnerabilities due to template variables in various
+HTML contexts.
+
+<ol class=bluelist>
+<li> Regular text (outside of tags and other special situations).
+
+ <p>Use the auto-escape pragma to html-escape the variable.</p>
+</li>
+
+<li> HTML tag attributes.
+
+ <p>In addition to the auto-escape pragma, ensure that the
+ attribute is enclosed in double quotes in the template.</p>
+</li>
+
+<li> URL attributes (eg., href/src).
+
+ <p>In addition to the auto-escape pragma, ensure that the
+ attribute is enclosed in double quotes in the template.</p>
+</li>
+
+<li> Beware of inserting variables containing data from untrusted
+ sources into the context of a <code>style</code> tag or
+ attribute.
+
+ <p>Certain CSS style-sheet constructs can result in the
+ invocation of javascript. To prevent XSS, the variable must be
+ carefully validated and sanitized.</p>
+</li>
+
+<li> Populating javascript variables.
+
+ <p>In addition to the auto-escape pragma, ensure that the
+ literal is enclosed in quotes in the template:</p>
+ <pre>
+ <script>
+ var msg_text = '{{MESSAGE}}';
+ </script>
+ </pre>
+
+ <p>Literals of non-string types cannot be quoted and escaped.
+ Instead, ensure that the variable's value is set such that it is
+ guaranteed that the resulting string corresponds to a javascript
+ literal of the expected type. For example, use</p>
+ <pre>
+ dict->SetValueInt("NUM_ITEMS", num_items);
+ </pre>
+ <p>to populate an integer javascript variable in the template
+ fragment</p>
+ <pre>
+ <script>
+ var num_items = {{NUM_ITEMS}};
+ </script>
+ </pre>
+
+</li>
+
+<li> Populating javascript variables within event handlers such as
+ <code>onClick</code>.
+
+ <p>Tag attributes whose values are evaluated as a javascript
+ expression (such as <code>on{Click,Load,etc}</code> handlers)
+ generally require HTML-Escape in addition to Javascript-Escape,
+ since the attribute's value is HTML-unescaped by the browser
+ before it is passed to the javascript interpreter.</p>
+
+ <p>However, the javascript-escaping provided by auto-escape
+ makes a subsequent HTML-Escape unnecessary. As such you can
+ apply the same rules for variables within event handlers
+ as you would for javascript variables in string literals:</p>
+ <pre>
+ <button ...
+ onclick='GotoUrl("{{TARGET_URL}}");'>
+ </pre>
+</li>
+
+<li> Consider potential non-template sources of XSS.
+
+ <p>There are a number of scenarios in which XSS can arise that
+ are unrelated to the insertion of values into HTML templates,
+ including,</p>
+
+ <ul class=blacklist>
+ <li> injection into HTTP headers such as <code>Location</code>,</li>
+ <li> incorrect browser-side guess of the content-encoding of a HTML
+ document without explicitly specified <code>charset</code>,</li>
+ <li> incorrect browser-side guess of a non-HTML document's
+ content-type that overrides the document's specified
+ <code>Content-Type</code>,</li>
+ <li> browser-side handling of documents served for download-to-disk
+ (<code>Content-Disposition: attachment</code>).</li>
+ </ul>
+
+ <p>Please consult additional <a
+ href="xss_resources.html">documentation</a> on
+ Cross-Site-Scripting for more detailed discussion of such
+ issues.</p>
+</li>
+
+</ol>
+
+
+<h2> Working Effectively with Templates </h2>
+
+<h3> <A name="register">Registering Template Strings</A> </h3>
+
+<p>Both dictionary keys and template filenames are strings. Instead
+of using raw strings, we encourage you to use a bit of machinery to
+help protect against various types of errors.</p>
+
+<p>For dictionary keys, you can use the <A
+HREF="reference.html#make_tpl_varnames_h">make_tpl_varnames_h</A> tool
+to create static string variables to use instead of a string constant.
+This will protect against typos, as the <A
+HREF="reference.html#make_tpl_varnames_h">make_tpl_varnames_h</A>
+documentation describes. It also yields slightly more efficient
+code.</p>
+
+<p>For template filenames that a program uses -- including
+sub-templates -- we suggest the following idiom:</p>
+
+<pre>
+ #include "example.tpl.varnames.h" // defines 1 string per dictionary key
+ RegisterTemplateFilename(EXAMPLE_FN, "example.tpl"); // defines template
+ ...
+ include_dict->SetFilename(EXAMPLE_FN);
+ ...
+ ctemplate::ExpandTemplate(EXAMPLE_FN, ctemplate::DO_NOT_STRIP, ...);
+ ...
+</pre>
+
+<p>By registering the filename, you can <A
+HREF="reference.html#template_namelist">query</A> the template system
+to detect syntax errors, reload-status, and so forth.</p>
+
+
+<h3> <A NAME="managing">Managing Templates</A> </h3>
+
+<p>There are methods to change the global state of the template
+system, to examine templates, and to examine template dictionaries.
+See the <A HREF="reference.html">reference guide</A> for more
+information.</p>
+
+
+<hr>
+<ul>
+<!--
+ <li> <A HREF="guide.html">User's Guide</A> </li>
+-->
+ <li> <A HREF="reference.html">Reference Manual</A> </li>
+ <li> <A HREF="auto_escape.html">Auto Escape</A> </li>
+ <li> <A HREF="tips.html">Tips</A> </li>
+ <li> <A HREF="example.html">Example</A> </li>
+</ul>
+
+<hr>
+<address>
+Craig Silverstein<br>
+<script type=text/javascript>
+ var lm = new Date(document.lastModified);
+ document.write(lm.toDateString());
+</script>
+</address>
+
+</body>
+</html>
diff --git a/doc/howto.html b/doc/howto.html
new file mode 100644
index 0000000..2a55381
--- /dev/null
+++ b/doc/howto.html
@@ -0,0 +1,31 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+<title>How To Use the Ctemplate (formerly Google Template) System</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link href="designstyle.css" type="text/css" rel="stylesheet">
+</head>
+
+<body>
+
+<p>This document has split into two parts: a user's guide and a
+reference guide. Use the links below to see these, and other
+documents about the template system.<p>
+
+<ul>
+ <li> <A HREF="guide.html">User's Guide</A> </li>
+ <li> <A HREF="reference.html">Reference Manual</A> </li>
+ <li> <A HREF="auto_escape.html">Auto Escape</A> </li>
+ <li> <A HREF="tips.html">Tips</A> </li>
+ <li> <A HREF="example.html">Example</A> </li>
+</ul>
+
+<hr>
+<address>
+Craig Silverstein<br>
+</address>
+
+</body>
+</html>
diff --git a/doc/index.html b/doc/index.html
new file mode 100644
index 0000000..13da75e
--- /dev/null
+++ b/doc/index.html
@@ -0,0 +1,111 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <title>Ctemplate (formerly Google Template) System</title>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link href="designstyle.css" type="text/css" rel="stylesheet">
+ <style type="text/css">
+ ol.bluelist li {
+ color: #3366ff;
+ font-family: sans-serif;
+ }
+ ol.bluelist li p {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ ul.blacklist li {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ </style>
+</head>
+<body>
+
+<h1> <a name="Ctemplate_System"></a>Ctemplate System </h1>
+<center><strong>Status: Current</strong>
+<small>(as of 25 April 2008)</small></center>
+<br>
+
+<p>Welcome to the C++ CTemplate system! (This project was originally
+called Google Templates, due to its origin as the template system used
+for Google search result pages, but now has a more general name
+matching its community-owned nature.)</p>
+
+<p>As a quick start, here's a small but complete program that uses this
+template library. For more details see, the links below.</p>
+
+<h3>Template file <code>example.tpl</code></h3>
+<pre>
+ Hello {{NAME}},
+ You have just won ${{VALUE}}!
+ {{#IN_CA}}Well, ${{TAXED_VALUE}}, after taxes.{{/IN_CA}}
+</pre>
+
+<h3>C++ program <code>example.cc</code></h3>
+<pre>
+ #include <stdlib.h>
+ #include <string>
+ #include <iostream>
+ #include <ctemplate/template.h>
+ int main(int argc, char** argv) {
+ ctemplate::TemplateDictionary dict("example");
+ dict.SetValue("NAME", "John Smith");
+ int winnings = rand() % 100000;
+ dict.SetIntValue("VALUE", winnings);
+ dict.SetFormattedValue("TAXED_VALUE", "%.2f", winnings * 0.83);
+ // For now, assume everyone lives in CA.
+ // (Try running the program with a 0 here instead!)
+ if (1) {
+ dict.ShowSection("IN_CA");
+ }
+ std::string output;
+ ctemplate::ExpandTemplate("example.tpl", ctemplate::DO_NOT_STRIP, &dict, &output);
+ std::cout << output;
+ return 0;
+ }
+</pre>
+
+<h3>Compiling and linking (using gcc)</h3>
+<pre>
+ gcc -o example example.cc -lctemplate_nothreads
+</pre>
+
+<p>I can use the "nothreads" library because <code>example.cc</code>
+doesn't use threads. If <code>example.cc</code> were threaded, I
+would do something like this instead:</p>
+<pre>
+ gcc -o example example.cc -lctemplate -pthread
+</pre>
+
+<p>See the README for more details about the two different ctemplate
+libraries.</p>
+
+
+<h2>In-depth Documentation</h2>
+
+<ol>
+ <li> <A HREF="howto.html">Howto</A>: Introduction to the
+ Ctemplate system, and a tutorial for using it. </li>
+
+ <li> <A HREF="auto_escape.html">Auto Escape</A>: Guide to using
+ the optional Auto Escape mode to protect your web application
+ better against XSS.</li>
+
+ <li> <A HREF="tips.html">Tips</A>: Advice, tips, and recommendations
+ for best practices with templates, to make them easier to write
+ and maintain, and to avoid common template mistakes. </li>
+
+ <li> <A HREF="example.html">Examples</A>: Some example templates and
+ application code that uses them. These are taken from actual
+ Google applications. </li>
+</ol>
+
+<hr>
+<address>
+Craig Silverstein<br>
+Last modified: Mon Feb 22 10:59:03 PST 2010
+</address>
+
+</body>
+</html>
diff --git a/doc/reference.html b/doc/reference.html
new file mode 100644
index 0000000..09eab1a
--- /dev/null
+++ b/doc/reference.html
@@ -0,0 +1,1707 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+<head>
+<title>Ctemplate System Reference Guide</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link href="designstyle.css" type="text/css" rel="stylesheet">
+<style type="text/css">
+ ol.bluelist li {
+ color: #3366ff;
+ font-family: sans-serif;
+ }
+ ol.bluelist li p {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ ul.blacklist li {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+</style>
+</head>
+
+<body>
+
+<h1>Ctemplate System Reference Guide</h1>
+<small>(as of
+<script type=text/javascript>
+ var lm = new Date(document.lastModified);
+ document.write(lm.toDateString());
+</script>)
+</small>
+<br>
+
+
+<h2> Overview </h2>
+
+<p>The main class used by the template system is
+<code>TemplateDictionary</code>, which is used to expand a template
+file. It is used by the main functions for expanding a template,
+found in <code>template.h</code>.</p>
+
+<p><code>TemplateCache</code> is used to hold a collection of
+<code>Template</code> objects. <code>TemplateNamelist</code> provides
+various introspection routines on collections of <code>Template</code>
+objects.</p>
+
+<p><code>TemplateModifier</code> and <code>PerExpandData</code> are
+used to modify the values of a <code>TemplateDictionary</code> at
+expand time. <code>TemplateAnnotator</code> does too, but is intended
+for debugging purposes. <code>TemplateDictionaryPeer</code> is used
+for testing template code.</p>
+
+<p><code>ExpandEmitter</code> provides the ability to emit an expanded
+template to an arbitrary output store.</p>
+
+<p><code>TemplateString</code> is a string-like class that is built to
+be very efficient when used with the template system. For instance,
+tools are available to hash constant <code>TemplateString</code>
+objects at compile-time, speeding up their use at run-time.</p>
+
+<p>The rest of this document describes these classes and functions in
+more detail, as well as build tools and other mechanisms for handling
+templates.</p>
+
+<p>(Note: the code snippets below all assume the default configuration
+option is set, which puts template code in namespace
+<code>ctemplate</code>.)</p>
+
+<h2> <A NAME="template">Expanding Templates</A> </h2>
+
+
+<h3> The Template Language </h3>
+
+<p>Templates are strings that contain special formatting code called
+<em>template markers</em>. In the Ctemplate System, template
+strings are usually read from a file.</p>
+
+<p>Anything found in a template of the form {{...}} is
+interpreted as a template marker. All other text is considered
+formatting text and is output verbatim at template expansion time.
+Outside of the template markers, templates may contain any text
+whatsoever, including (single) curly braces and NUL characters.</p>
+
+<p>The template language has six types of markers:</p>
+<ol>
+ <li> <b>Variable</b> markers, which are replaced by text based on
+ dictionary values. Variable markers look like this:
+ {{FOO}}</li>
+
+ <li> <b>Start section</b> and <b>end section</b> markers, which
+ delimit sections which may appear zero, one, or N times in
+ the output. Section markers look like this:
+ <code>{{#FOO}}...{{/FOO}}</code></li>
+
+ <li> <b>Template-include</b> markers, which designate other
+ templates to be expanded and inserted at the location where the
+ marker appears. These are treated much like sections -- one
+ may think of them as sections whose content is specified in a
+ different file instead of inline -- and just like sections, can
+ be expanded zero, one or N times in the output, each with a
+ different dictionary. Template-include markers look like this:
+ <code>{{>FOO}}</code></li>
+
+ <li> <b>Comment</b> markers, which may annotate the template
+ structure but drop completely out of the expanded
+ output. Comment markers look like this:
+ <code>{{! comment lives here -- cool, no?}}</code></li>
+
+ <li> <b>Set-delimiter</b> markers, which change the marker
+ delimiters from <code>{{</code> and <code>}}</code> to custom
+ strings. (The only requirement is that these strings not
+ contain whitespace or the equals sign.) This is useful for
+ languages like TeX, where double-braces may occur in the text
+ and are awkward to use for markup. Set-delimiter markers look
+ like this: <code>{{=< >=}} <! Now markers are
+ delimited by braces > <=| |=> |! And now markers are
+ delimited by bars! | </code></li>
+
+ <li> <b>Pragma</b> markers, which invoke additional built-in template
+ features when processing the template. Pragma markers look like
+ this: <code>{{%PRAGMA [name="value"...]}}</code>. Currently,
+ AUTOESCAPE is the only pragma defined.</li>
+</ol>
+
+<p>These marker types each have their own namespace. For readability,
+however, it is best to not overuse a single name.</p>
+
+
+<h3> Modifiers </h3>
+
+<p>A variable and include-template can have one or more <A
+HREF="#template_modifier">modifiers</A> attached to them, like so:</p>
+<pre>
+ {{MYVAR:mod1:mod2:mod3=value:mod4=value with spaces:mod5}}
+</pre>
+
+<p>A modifier is a filter that's
+applied at template-expand time, that munges the value of the variable
+before it's output. See the <A
+HREF="#template_modifier"><code>TemplateModifier</code></A> class for
+more details.</p>
+
+<p>When expanding a variable (or template-include) with a modifier,
+the modifiers are applied in order, left to right. For a
+template-include, first the entire sub-template is expanded, as a
+single string, and then the modifiers are applied to that string.</p>
+
+<p>In general, using explicit modifiers does not turn off <A
+HREF="#auto_escape">auto-escaping</A> on a variable. The explicit
+modifier <code>:none</code> does suppress auto-escaping.</p>
+
+
+<h3> <A NAME="special_markers">Special Markers</A> </h3>
+
+<p>Some marker names may have a special meaning in the template
+system. Right now, there's one such name.</p>
+
+<h4><A NAME="separator">Separator Sections</A></h4>
+
+<p>If you have a section named FOO, you can define inside
+of it a section named FOO_separator, and the template
+system will automatically expand that section every time
+<code>FOO</code> is expanded, <i>except for the last</i>. Thus, the
+contents of <code>FOO_separator</code> can be used to separate
+repeated values of a section.</p>
+
+<p>Here's an example:</p>
+<pre>
+ Here are the meeting attendees:
+ {{#ATTENDEES}}
+ {{NAME}}
+ {{#ATTENDEES_separator}}, {{/ATTENDEES_separator}}
+ {{/ATTENDEES}}
+ .
+</pre>
+
+<p>Here is a more convoluted example, to show the date:</p>
+<pre>
+ {{#DATE}}{{DATE_COMPONENT}}{{#DATE_separator}}{{DATE_SEP}}{{/DATE_separator}}{{/DATE}}
+</pre>
+
+<p>You'd set up a template dictionary to repeat <code>DATE</code>
+three times, with <code>DATE_COMPONENT</code> set to the month, day,
+and year (or day, month, and year, depending on your locale...), and
+<code>DATE_SEP</code> set to <code>/</code> or <code>-</code> or
+whatever date-separator is called for.</p>
+
+<p><code>SEP_separator</code> is always evaluated with the current
+dictionary. Thus, in the date example, if you wanted a different
+separator each time, you could do so by setting <code>DATE_SEP</code>
+to a different value for each repetition of <code>DATE</code>.</p>
+
+<p>While <code>SEP_separator</code> is automatically expanded by the
+template system, it is otherwise a perfectly normal section. You can
+even instantiate it yourself by calling
+<code>AddSectionDictionary("SEP_separator")</code>. In that case, the
+section will be expanded both via the automatic expansion as a
+separator, and as a normal section via the section dictionary you
+added. This is more confusing than helpful, and you should probably
+never do it.</p>
+
+<p>There can be at most one "separator" sub-section per section. If
+there are more, only the last is automatically expanded.</p>
+
+
+<h3> <A NAME="strip">Specifying a template</A> </h3>
+
+<p>In the template system -- in functions like
+<code>ExpandTemplate()</code> -- a template is specified by a pair:
+filename + strip-mode. The filename specifies the name of the
+template file on disk (but see below for string templates). The strip
+mode specifies how this file should be parsed as it's read from disk,
+in particular, how whitespace should be handled. It can take the
+following values:</p>
+
+<ul>
+ <li> <code>ctemplate::DO_NOT_STRIP</code>: do nothing. This expands
+ the template file verbatim.
+
+ <li> <code>ctemplate::STRIP_BLANK_LINES</code>: remove all blank
+ lines. This ignores any blank lines found in the template file
+ when parsing it. When the template is html, this reduces the
+ size of the output text without requiring a sacrifice of
+ readability for the input file.
+
+ <li> <code>ctemplate::STRIP_WHITESPACE</code>: remove not only blank
+ lines when parsing, but also whitespace at the beginning and
+ end of each line. It also removes any linefeed (possibly
+ following whitespace) that follows a closing <code>}}</code> of
+ any kind of template marker <i>except</i> a template variable.
+ (This means a linefeed may be removed anywhere by simply
+ placing a comment marker as the last element on the line.)
+ When the template is html, this reduces the size of the output
+ html without changing the way it renders (except in a few
+ special cases.) When using this flag, the built-in template
+ variables <code>BI_NEWLINE</code> and <code>BI_SPACE</code> can
+ be useful to force a space or newline in a particular
+ situation.
+</ul>
+
+<p>The filename is where the template file lives on disk. It can be
+either an absolute filename, or relative to a directory in the
+<A HREF="#search_path">template search path</A>.</p>
+
+<p>In addition to reading a template from disk, it is possible to read
+a template from a string, using <code>StringToTemplateCache()</code>.
+The first argument of <code>StringToTemplateCache()</code> is a "key"
+to use to refer to this string-based template. This key takes the
+place of the filename, for any routine that asks for a
+filename + strip.</p>
+
+
+<h3> <A NAME="expand_template">ExpandTemplate()</A> </h3>
+
+<p>This is the main workhorse function of the template system. It
+takes the filename of a template, a <A
+HREF="#template_dictionary">template dictionary</A>, and a string to
+emit to, and emits an "expanded" version of the template using the
+given template dictionary to fill in the template markers.</p>
+
+<p>If the template specified by the given filename is already found in
+an internal cache, the cached version of the template is used,
+otherwise the template is loaded from disk, parsed, and stored in the
+cache before expansion is performed. As always, the "filename" can
+also be a <A HREF="#strip">key</A> to a string-based template,
+inserted directly into the cache via
+<code>StringToTemplateCache()</code>.</p>
+
+<p>There is an overloaded version of <code>Expand()</code> that takes
+an <A HREF="#expand_emitter"><code>ExpandEmitter</code></A> rather
+than a string, as the source to expand the template into.</p>
+
+<p>This function returns true if the template was successfully
+expanded into the output parameter. It returns false if expansion
+failed or was only partially successful. It might fail because the
+template file cannot be found on disk, or because the template has
+syntax errors and cannot be parsed, or because the template
+sub-includes another template, and that sub-template has errors. To
+minimize the risk of errors at expand-time, you can call
+<code>LoadTemplate()</code> (below) first to load and parse the
+template into the cache. This will catch all errors except for errors
+involving sub-templates.</p>
+
+<p>In the case of partial failures -- typically, failures resulting in
+an error in a sub-inclued template -- there may be partial data
+emitted to the output before the error was detected. If
+<code>ExpandTemplate()</code> returns false, you should be careful to
+check for and remove this partial data, if desired.</p>
+
+
+<h3> <A NAME="expand_with_data">ExpandWithData()</A> </h3>
+
+<p><code>ExpandWithData()</code> is like
+<code>ExpandTemplate()</code>, with the addition that it allows you to
+pass in <A HREF="#per_expand_data">per-expand data</A>. It's called
+like this:</p>
+<pre>
+ ctemplate::TemplateDictionary dict(...);
+ ctemplate::PerExpandData per_expand_data;
+ string output;
+ ctemplate::ExpandWithData(filename, strip_mode, &output, &dict,
+ &per_expand_data);
+</pre>
+
+<p>Per-expand data is applied to all templates that are seen while
+expanding: not only the template you called <code>Expand()</code> on,
+but also sub-templates that are brought in via template-includes
+(<code>{{>INCLUDE}}</code>). See the description of the <A
+HREF="#per_expand_data"><code>PerExpandData</code></A> class for more
+details about how expansion can be modified by per-expand data.</p>
+
+<p>The return value has the same meaning as for
+<code>ExpandTemplate()</code> In fact, if you pass in
+<code>NULL</code> as the <code>per_expand_data</code> argument, this
+function is exactly equivalent to <code>ExpandTemplate()</code>.</p>
+
+
+<h3> <A NAME="load_template">LoadTemplate()</A> </h3>
+
+<p>This function takes a filename and a strip-mode, and loads the file
+into the default template cache. Future calls to
+<code>ExpandTemplate()</code> or <code>ExpandWithData()</code> will
+get the parsed template from the cache, without needing to go to
+disk.</p>
+
+<p>This function returns true if the template was successfully read
+from disk, parsed, and inserted into the cache. It will also return
+true if the template is already in the cache (even if the file has
+changed on disk since the template was inserted into the cache). It
+will return false if the file cannot be found on disk, or cannot be
+successfully parsed. (Note that <code>LoadTemplate()</code> cannot
+detect errors in sub-included templates, since the identity of
+sub-included templates is specified in a
+<code>TemplateDictionary</code>, not in the template itself.)</p>
+
+
+<h3> <A NAME="string_to_template_cache">StringToTemplateCache()</A> </h3>
+
+<p>In addition to reading a template file from disk, it is also
+possible to read a template file from a string, using
+<code>StringToTemplateCache()</code>. It takes the content
+as a string. It also takes in a key and a <A HREF="#strip">strip</A>
+mode. The given key and strip mode can be used as the filename/strip
+pair in calls to <code>ExpandTemplate()</code> and similar
+functions. The key can also be used as the "filename" in calls to
+<code>ctemplate::TemplateDictionary::SetFilename()</code>, allowing
+this template to be included inside other templates.</p>
+
+<p><code>StringToTemplateCache()</code> returns true if the string is
+successfully inserted into the cache. It returns false otherwise,
+probably because there is already a string or filename in the cache
+with the same key.</p>
+
+
+<h3> default_template_cache() and mutable_default_template_cache() </h3>
+
+<p>All the above routines -- <code>ExpandTemplate()</code>,
+<code>LoadTemplate()</code>, and the like -- read and write parsed
+templates to the default template cache. This is just a static
+instance of the <A
+HREF="#template_cache"><code>TemplateCache</code></A> class. It can
+be accessed via these two functions:
+<code>default_template_cache()</code> and, if you need a non-const
+version of the cache, <code>mutable_default_template_cache()</code>.
+These can be useful if you need the advanced features of template
+caches, such as <code>ReloadAllIfChanged()</code> or
+<code>ClearCache()</code>.</p>
+
+
+<h2> <A NAME="template_dictionary">The <code>TemplateDictionary</code>
+ Class</A> </h2>
+
+<p>The class <code>TemplateDictionary</code> is used for all template
+dictionary operations. In general, an application will need to call a
+<code>TemplateDictionary</code> method for every marker in the
+associated template (the major exception: markers that evaluate to the
+empty string can be ignored).</p>
+
+<p>The appropriate function to call for a given template marker
+depends on its type.</p>
+
+
+<h3> Data Dictionaries </h3>
+
+<p>A data dictionary is a map from keys to values. The keys are
+always strings, corresponding to the name of the associated template
+marker, so a section <code>{{#FOO}}</code> in the template text is
+matched to the key <code>FOO</code> in the dictionary, if it exists.
+Note the case must match as well.</p>
+
+<p>The value associated with a key differs according to key type. The
+value associated with a <i>variable</i> is simple: it's the value for
+that variable. Both keys and values can be any 8-bit
+character-string, and may include internal NULs (<code>\0</code>).</p>
+
+<p>The value associated with a <i>section</i> is a list of data
+dictionaries. At template-expansion time, the section is expanded
+once for each dictionary in the list. The first time, all
+variables/etc. in the section will be evaluated taking into account
+the first dictionary. The second time, all variables/etc. will be
+evaluated taking into account the second dictionary. (See <A
+HREF="#inheritance">below</A> for a definition of "taking into
+account.")</p>
+
+<p>The value associated with a <i>template-include</i> is also a list
+of data dictionaries. Each data dictionary in this list must also
+have one other, mandatory associated piece of associated information:
+the filename of the template to include. At expand-time, that
+filename is passed as-is to <code>ctemplate::ExpandTemplate()</code>
+(or, more exactly, the equivalent of <code>ExpandTemplate()</code> in
+the same <code>TemplateCache</code> that the parent template comes
+from).</p>
+
+
+<h3> <A NAME="inheritance">Details on Dictionary Lookup</A> </h3>
+
+<p>The dictionary structure is a tree: there's a 'main' dictionary,
+and then a list of sub-dictionaries for each section or
+include-template. When looking up a marker -- be it a variable,
+section, or include-template marker -- the system looks in the
+currently applicable dictionary. If it's found there, that value is
+used. If not, and the parent dictionary is not an include-template,
+it continues the look in the parent dictionary, and possibly the
+grandparent, etc. That is, lookup has <i>static scoping</i>: you look
+in your dictionary and any parent dictionary that is associated with
+the same template-file. As soon as continuing the lookup would
+require you to jump to a new template-file (which is what
+include-template would do), we stop the lookup.</p>
+
+<p>If lookup fails in all dictionaries, the template system does a
+final lookup in the <b>global variable dictionary</b>.</p>
+
+<p>The system initializes the global dictionary with a few useful
+values for your convenience (the user can add more). All system
+variables are prefixed with <code>BI</code>, to emphasize they are
+"built in" variables.</p>
+<ul>
+ <li> <code>BI_SPACE</code>, which has the value
+ <code><space></code>. It is used to force a space
+ at the beginning or end of a line in the template,
+ where it would normally be suppressed. (See below.) </li>
+
+ <li><code>BI_NEWLINE</code>, which has the value
+ <code><newline></code> It is used to force a
+ newline at the end of a line, where it would normally
+ be suppressed. (See below.) </li>
+</ul>
+
+<p>Variable inheritance happens at expand time, not at
+dictionary-create time. So if you create a section dictionary, and
+then afterwards set a variable in its parent dictionary (or in the
+global dictionary), the section <i>will</i> inherit that variable
+value, if it doesn't define the value itself.</p>
+
+
+<h3> SetValue() and variants </h3>
+
+<p>SetValue() is used to set the value for a variable
+marker in a dictionary. It takes a string as input -- nominally a <A
+HREF="#template_string"><code>TemplateString</code></A>, though a C++
+string or C char* will be auto-converted -- for the variable name and
+its value. The name is the same string as is used for the variable's
+template-marker inside the template this dictionary will be expanded
+with: if the template reads <code>Hello {{NAME}}</code> then the
+first argument to <code>SetValue()</code> must be <code>NAME</code>.
+Case matters.</p>
+
+<p><code>SetIntValue()</code> takes an integer as the value, rather
+than a string. On all platforms, the integer may be up to 64
+bits.</p>
+
+<p><code>SetFormattedValue()</code> is a convenience routine.
+<code>SetFormattedValue(key, arg1, arg2, ...)</code> is logically
+equivalent to</p>
+<pre>
+ char buffer[A_BIG_ENOUGH_NUMBER];
+ sprintf(buffer, arg1, arg2, ...);
+ SetValue(key, buffer);
+</pre>
+<p>without having to worry about the size of <code>buffer</code>, or
+about stack overflow.</p>
+
+<p><code>SetValueWithoutCopy()</code> is provided to give an extra bit
+of efficiency when needed. <code>SetValue()</code> will copy the key
+and value into an internal data structure used by the
+<code>TemplateDictionary</code>; this avoids dangling pointers if the
+arguments to <code>SetValue()</code> are temporaries, or otherwise
+have shorter lifetime than the <code>TemplateDictionary</code>. But
+if you know that both the key and value strings have lifetime longer
+than the <code>TemplateDictionary</code> -- perhaps because they are
+global (static duration) <code>char*</code>'s -- you can call
+<code>SetValueWIthoutCopy()</code> to avoid the copy. This yields a
+small time savings at the cost of significant code fragility, so
+should only be used when absolutely necessary.</p>
+
+
+<h3> SetGlobalValue() and SetTemplateGlobalValue() </h3>
+
+<p><code>SetGlobalValue()</code> is like <code>SetValue()</code> but
+works on the global dictionary. Since the global dictionary is shared
+across all template dictionaries, this is a static method on
+<code>TemplateDictionary</code>. It is thread-safe. It is also
+relatively slow.</p>
+
+<p><code>SetTemplateGlobalValue()</code> is like
+<code>SetValue()</code>, but the values are preserved across
+template-includes.</p>
+
+<p>This example shows all three forms:</p>
+<pre>
+A.tpl:
+ {{NAME}} has won {{>PRIZE}}. It is worth {{AMOUNT}}.
+B.tpl:
+ {{AMOUNT}} dollars! And it's all yours, {{NAME}}
+C.tpl:
+ To: {{NAME}}. Amount: {{AMOUNT}}.
+code:
+ ctemplate::TemplateDictionary dict("set_value_demo");
+ ctemplate::TemplateDictionary* subdict = dict.AddIncludeDictionary("PRIZE");
+ subdict->SetFilename("B.tpl");
+ dict->SetValue("NAME", "Jane McJane");
+ dict->SetTemplateGlobalValue("AMOUNT", "One Million");
+ ctemplate::TemplateDictionary::SetGlobalValue("NAME", "John Doe");
+ ctemplate::TemplateDictionary dict_c("set_value_demo, part 2");
+
+ ctemplate::ExpandTemplate("A.tpl", ..., &dict);
+ ctemplate::ExpandTemplate("C.tpl", ..., &dict_c);
+</pre>
+
+<p>The first expand yields this:</p>
+<pre>
+ Jane McJane has won One Million dollars! And it's all yours, John Doe. It is worth One Million.
+</pre>
+
+<p>The second expand yields this:</p>
+<pre>
+ To: John Doe. Amount: .
+</pre>
+
+<p><code>NAME</code> was set via <code>SetValue()</code>, so its
+value was not propagated across the include-dict boundary; instead,
+the subdict (B.tpl) got its value for <code>NAME</code> from the
+global dictionary. <code>AMOUNT</code>, on the other hand, was set
+via <code>SetTemplateGlobalValue()</code>, so its value was propagated
+across the boundary, and the subdict saw it. However, the totally
+unrelated template, C.tpl, did not see either value, and only sees the
+values in the global dictionary. (Of course, had we filled
+<code>dict_c</code> with some values, C.tpl would have had access to
+those.)</p>
+
+
+<h3> AddSectionDictionary(), ShowSection(),
+ and SetValueAndShowSection() </h3>
+
+<p><code>AddSectionDictionary(section_name)</code> returns a
+sub-dictionary associated with the given section_name (for instance,
+<code>dict.AddSectionDictionary("MYSECT")</code> for a template like
+<code>{{#MYSECT}}...{{/MYSECT}}</code>). If called multiple times, it
+will return a new dictionary each time. During <code>Expand()</code>,
+the section will be expanded once for each time
+<code>AddSectionDictionary()</code> was called; that is, the text
+inside the section delimiters will be repeated once for each
+<code>AddSectionDictionary()</code> call, and within a single
+repetition, the dictionary returned by
+<code>AddSectionDictionary()</code> will be used to populate the text
+inside the section delimiters. (With the current dictionary as that
+dictionary's parent, for inheritance purposes.)</p>
+
+<p>This suggests that if <code>AddSectionDictionary()</code> is never
+called on a section, the text inside the section will be omitted
+entirely by <code>Expand()</code>.</p>
+
+<p><code>ShowSection()</code> is a convenience method used to show the
+text inside the section exactly once. It is equivalent to calling
+<code>AddSectionDictionary()</code> once, and ignoring the returned
+sub-dictionary. All variables in the section will depend on
+dictionary inheritence to get their values.</p>
+
+<p><code>SetValueAndShowSection()</code> is another convenience
+method,, used to show a section if and only if a related variable is
+set to a non-empty value. <code>SetValueAndShowSection(name, value,
+section_name)</code> is equivalent to this: if value is empty do
+nothing, otherwise add a single dictionary to
+<code>section_name</code> and call <code>section_dict->AddValue(name,
+value)</code>.</p>
+
+<p>Example:</p>
+<pre>
+ ctemplate::TemplateDictionary* dict = new ctemplate::TemplateDictionary("section example");
+ const char* username = GetUsername(); // returns "" for no user
+ if (username[0] != '\0') {
+ ctemplate::TemplateDictionary* sub_dict = dict->AddSectionDictionary("CHANGE_USER");
+ sub_dict->SetValue("USERNAME", username);
+ } else {
+ // don't need to do anything; we want a hidden section, which is the default
+ }
+
+ // Instead of the above 'if' statement, we could have done this:
+ if (username[0] != '\0') {
+ dict->ShowSection("CHANGE_USER"); // adds a single, empty dictionary
+ dict->SetValue("USERNAME", username); // take advantage of inheritance
+ } else {
+ // don't need to do anything; we want a hidden section, which is the default
+ }
+
+ // Or we could have done this:
+ dict->SetValueAndShowSection("USERNAME", username, "CHANGE_USER");
+
+ // Moving on...
+ GetPrevSearches(prev_searches, &num_prev_searches);
+ if (num_prev_searches > 0) {
+ for (int i = 0; i < num_prev_searches; ++i) {
+ TemplateDictionary* sub_dict = dict->AddSectionDictionary("PREV_SEARCHES");
+ sub_dict->SetValue("PREV_SEARCH", prev_searches[i]);
+ }
+ }
+</pre>
+
+
+<h3> AddIncludeDictionary() and SetFilename() </h3>
+
+<p><code>AddIncludeDictionary(section_name)</code> returns a
+sub-dictionary associated with the given include_name (for instance,
+<code>dict.AddIncludeDictionary("MYTPL")</code> for a template like
+<code>{{>MYTPL}}</code>). If called multiple times, it
+will return a new dictionary each time. It is the responsibility of
+the caller to then call <code>SetFilename()</code> on the
+sub-dictionary returned.</p>
+
+<p>During <code>Expand()</code>,
+each dictionary returned by <code>AddIncludeDictionary</code> will be
+examined in turn. For each dictionary for which
+<code>SetFilename()</code> is called, that filename will be read as a
+template (via <code>LoadTemplate()</code>, with the same
+"strip" value as the current template), and expanded using the
+dictionary. (Note that the dictionary will not inherit
+<code>SetValue()</code> values from the parent dictionary, though it
+will inherit <code>SetTemplateGlobalValue()</code> values.) This
+expanded template will then be emitted to the output.</p>
+
+<p>Note that if <code>AddIncludeDictionary()</code> is never called,
+the template-include will be a no-op during <code>Expand()</code>.
+Likewise, if it is called but <code>SetFilename()</code> is never
+called on the resulting sub-dictionary, the template-include will be a
+no-op. On the other hand, if it is called multiple times, multiple
+templates -- possibly all from the same file, possibly not -- will be
+inserted at the point of the template-include.</p>
+
+<p>If a user has called <code>StringToTemplateCache(key, ...)</code>,
+then the user can call <code>SetFilename(key)</code> to include the
+contents of the string as the sub-template.</p>
+
+
+<h3> Dump() and DumpToString() </h3>
+
+<p>These routines dump the contents of a dictionary and its
+sub-dictionaries. <code>Dump()</code> dumps to stdout,
+<code>DumpToString()</code> to a string. They are intended for
+debugging.</p>
+
+
+<h2> <A NAME="template_cache">The <code>TemplateCache</code> Class</A> </h2>
+
+<p>This class holds a collection of templates. It can be used to give
+you a coherent view of the template system: you load all the templates
+you are going to use into the cache, and then reload them from disk in
+one atomic operation. You can have multiple
+<code>TemplateCache</code> objects in your executable, perhaps one for
+each service you provide, or perhaps one per thread (so as to avoid
+thread contention when loading templates).</p>
+
+<p>One intended use of the template cache is to make it safe to reload
+template files while serving user requests from a webserver. The idea
+is that every user request, as it's created, is associated with the
+current template cache. When you wish to reload, you
+<code>Clone()</code> the current cache, and then reload inside the
+cloned copy. New requests will get the cloned cache, while old
+requests will continue to render using the old cache.
+<code>TemplateCache</code> is written to make this use-case efficient:
+templates are shared between caches when appropriate, with
+reference-counting to keep memory management easy.</p>
+
+
+<h3> The default template cache </h3>
+
+<p>The template system creates a default template cache, which is
+available via the functions <code>default_template_cache()</code> and
+<code>mutable_default_template_cache()</code>.</p>
+
+<p>For simple uses of the template system, using the default cache,
+via <code>ExpandTemplate()</code> and the like, may be perfectly
+adequate. If you want more sophisticated features, such as the
+ability to have different versions of the same template file active at
+one time, or to change the template root-directory, you will have to
+use an explicit <code>TemplateCache</code>.</p>
+
+
+<h3> LoadTemplate() and StringToTemplateCache() </h3>
+
+<p>These two routines are how you explicitly insert data into the
+cache. <code>LoadTemplate()</code> reads a template from disk, while
+<code>StringToTemplateCache()</code> takes the data from a
+user-specified string. These work exactly the same as the global <A
+HREF="#load_template"><code>LoadTemplate()</code></A> and <A
+HREF="#string_to_template_cache"><code>StringToTemplateCache()</code></A>,
+except they insert into the given <code>TemplateCache</code>, rather
+than the global cache.</p>
+
+<p><code>LoadTemplate()</code> is not strictly necessary: if the cache
+cannot find a template it needs at <code>Expand*()</code> time, it will
+automatically try to fetch it from disk. It is intended mostly for
+use with <A HREF="#freeze"><code>Freeze()</code></A>, which disables
+this auto-fetch behavior.</p>
+
+<p>Both of these routines take a <A HREF="#strip">strip</A> mode
+specifying how the template system should treat whitespace while
+parsing.</p>
+
+<p>If the template-cache is <A HREF="#freeze">frozen</A>,
+<code>LoadTemplate()</code> will only return true if the template is
+already stored in the cache, and will return false in every other
+case. For a frozen cache, <code>StringToTemplateCache()</code> will
+always return false.</p>
+
+
+<h3> ExpandWithData() and ExpandFrozen() </h3>
+
+<p>These routines takes a string that represents either a template
+filename (for disk-based templates), or a key used in
+<code>StringToTemplateCache()</code> (for string-based templates), a <A
+HREF="#strip">strip</A> mode saying how to parse the template's
+whitespace, and <A HREF="#per_expand_data">per-expand data</A> (which
+can be NULL). Overloads are provided to output the expanded template
+to either a string or to an arbitrary <A
+HREF="#expand_emitter"><code>ExpandEmitter</code></A>.</p>
+
+<p>Expand uses the filename + strip pair to fetch the template from
+the cache, if it's there. If not, <code>ExpandWithData()</code> will
+fetch the template from disk and insert it into the cache.
+<code>ExpandFrozen()</code>, on the other hand, will just fail to
+expand, and return false. This is the only difference in behavior
+between the two routines. To reinforce this behavior,
+<code>ExpandFrozen()</code> will return false immediately if <A
+HREF="#freeze"><code>Freeze()</code></A> has not been called on the
+cache.
+
+<p>While expanding, the template system may come across template
+sub-includes (<code>{{>SUB_TEMPLATE}}</code>). It will attempt to
+fetch these templates from the cache as well; failing that, it will
+try to load the template from disk (for <code>ExpandWithData()</code>)
+or else fail the expand and return false (for
+<code>ExpandFrozen()</code>).</p>
+
+<p>Because <code>ExpandFrozen()</code> never updates the cache, it is
+a const method, unlike <code>ExpandWithData()</code>.</p>
+
+<p>Note that <code>TemplateCache</code> does not provide the
+convenience <code>ExpandTemplate()</code> routine, as the analogue of
+the global <A
+HREF="#expand_template"><code>ExpandTemplate()</code></A>. If you are
+not interested in the per-expand data, just call
+<code>ExpandWithData()</code> with the per-expand data set to NULL.</p>
+
+
+<h3> ReloadAllIfChanged() </h3>
+
+<p>For every file-based template in the cache (this method ignores
+string-based templates), <code>ReloadAllIfChanged()</code> checks the
+filesystem to see if the file has changed since it was loaded into the
+cache. If so, the cache loads a new version of the file into the
+cache. Note that at this point both the old and new versions of the
+file exist in the cache! Only the new version is accessible via new
+calls to <code>Expand()</code>, but any expansions currently in flight
+during the <code>ReloadAllIfChanged()</code> call will continue to use
+the old version.</p>
+
+<p>NOTE: <code>ReloadAllIfChanged()</code> never modifies existing
+items in the cache in any way. It only loads new entries into the
+cache.</p>
+
+<p><code>ReloadAllIfChanged()</code> comes in two flavors, controlled
+by the passed-in enum. In "immediate" mode, it synchronously iterates
+through the cache and reloads all files that need it. In "lazy" mode,
+it waits to reload a given template file until the next time it's
+actually used (in a call to <code>Expand*()</code>). "Immediate" mode
+is safer in the case where templates depend on each other and the
+files change a lot, since all files are reloaded at about the same
+time. "Lazy" mode avoids the latency spike of "immediate" mode, and
+is preferable in the (common) case that files on disk change only
+rarely.</p>
+
+
+<h3> <A NAME="search_path"> SetTemplateRootDirectory(),
+ AddAlternateTemplateRootDirectory(), and
+ template_root_directory() </A> </h3>
+
+<p>By default, filenames passed in to <code>Expand*()</code> are taken
+to be relative to the current working directory. These functions
+change that behavior. <code>SetTemplateRootDirectory()</code> resets
+the search path to be the single path passed in to this function.
+Every time <code>AddAlternateTemplateRootDirectory()</code> is called,
+it adds another directory to the end of the search path. The template
+system will follow the search path, in order, when looking for a
+filename.</p>
+
+<p>Note that the template search path is only meaningful when the
+filename passed to <code>Expand*()</code> (or specified for a
+sub-include) is a relative filename. If the filename is an absolute
+filename, starting with <code>/</code>, the search path is
+ignored.</p>
+
+<p><code>template_root_directory()</code> returns the first entry in
+the search path. There is currently no way to access other entries in
+the search path.</p>
+
+
+<h3> FindTemplateFilename() </h3>
+
+<p><code>FindTemplateFilename()</code> does the work of finding a
+template file in the filesystem, using the current template search
+path. It takes a relative pathname as input, and returns an absolute
+pathname as output, indicating where the template file lives on the
+filesystem. If the template file is not found, this method returns
+the empty string.</p>
+
+
+<h3> <A NAME="freeze">Freeze()</A> </h3>
+
+<p><code>Freeze()</code> marks the template cache as immutable. After
+this method is called, the cache can no longer be modified by loading
+new templates or reloading existing templates. During expansion only
+cached included templates will be used; they won't be loaded
+on-demand.</p>
+
+<p>Before calling <code>Freeze()</code>, you should make sure your
+cache has all the templates it might need, using
+<code>LoadTemplate()</code> and <code>StringToTemplateCache()</code>.
+Otherwise, <code>ExpandWithData()</code> and
+<code>ExpandFrozen()</code> may fail.</p>
+
+<p>Once the cache is frozen, calls to
+<code>SetTemplateRootDirectory()</code>,
+<code>AddAlternateTemplateRootDirectory()</code>,
+<code>Delete()</code>, and <code>ReloadAllIfChanged()</code> will
+fail.</p>
+
+<p>After the cache is frozen, the <code>TemplateCache</code> object is
+effectively const.</p>
+
+
+<h3> Delete() </h3>
+
+<p>This method deletes an entry from the cache. If the entry is in
+the cache multiple times (each with a different "strip" mode), this
+method deletes all of them.</p>
+
+
+<h3> ClearCache() </h3>
+
+<p>This method deletes all entries from the cache. It can be called
+even on a frozen cache.</p>
+
+<p>Note: this method is not typically necessary unless you are testing
+for memory leaks. It is intended to be called just before exiting the
+program, and after all template expansions are completed. Using it in
+that way may prevent unnecessary reporting by the leak checker.</p>
+
+
+<h3> Clone() </h3>
+
+<p><code>Clone()</code> makes a shallow copy of the given
+<code>TemplateCache</code> object, and returns the copy. The new copy
+and the old share the same template objects; since it's a shallow
+copy, they actually share pointers to the exact same object. (Since
+the template cache never changes a template object once it's loaded
+into the cache, sharing the pointer isn't a risk.)</p>
+
+<p>The intended use of <code>Clone()</code>, as described above, is to
+allow fine control over "epochal" changes in templates. One
+<code>TemplateCache</code> can hold all versions of the template files
+before the big update; after the update is done, you can clone the old
+cache and then call <code>ReloadAllIfChanged()</code> on the clone.
+This is a low-cost operation, since the two copies share most
+resources. Smart pointers take care of most memory management
+issues.</p>
+
+<p>The caller is responsible for calling <code>delete</code> on the
+returned <code>TemplateCache</code> object.</p>
+
+
+
+<h2> <A NAME="template_namelist">The <code>TemplateNamelist</code> Class</A> </h2>
+
+<p>This class provides information about <A
+HREF="guide.html#register">registered</A> templates. Or more
+precisely, all templates corresponding to registered filenames.</p>
+
+<p>All methods in this class are static.</p>
+
+
+<h3> RegisterTemplate() and
+ RegisterTemplateFilename() </h3>
+
+<p><code>TemplateNamelist::RegisterTemplate()</code> takes a filename
+and adds it to the static namelist used by
+<code>TemplateNamelist</code>. All other methods of
+<code>TemplateNamelist</code> work only on registered filenames.</p>
+
+<p>It's fairly rare to call this method directly. Instead, the more
+common use is to use the macro <code>RegisterTemplateFilename</code>
+somewhere in the global scope, like so:</p>
+<pre>
+RegisterTemplateFilename(EXAMPLE_FN, "example.tpl");
+</pre>
+
+<p>The reason to prefer the macro is it defines a global variable that
+you can use instead of the hard-coded template name. This helps catch
+typos. The <code>RegisterTemplateFilename()</code> example is
+functionally equivalent to:</p>
+<pre>
+#define EXAMPLE_FN "example.tpl"
+</pre>
+
+<p>It can be used like this:</p>
+<pre>
+ ctemplate::ExpandTemplate(EXAMPLE_FN, ctemplate::DO_NOT_STRIP, ...);
+</pre>
+
+
+<h3> GetMissingList() </h3>
+
+<p><code>TemplateNamelist::GetMissingList()</code> returns a list of
+all registered templates (or rather, all filenames) where the file
+could not be found on disk.</p>
+
+
+<h3> AllDoExist() </h3>
+
+<p>Returns true if and only if the missing-list is empty.</p>
+
+
+<h3> GetBadSyntax() </h3>
+
+<p>Returns a list of all registered templates where the template
+contains a syntax error, and thus cannot be used.</p>
+
+
+<h3> IsAllSyntaxOkay() </h3>
+
+<p>True if and only if the bad-syntax list is empty.</p>
+
+
+<h3> GetLastmodTime() </h3>
+
+<p>Returns the latest last-modified time for any registered
+template-file.</p>
+
+
+<h2> <A NAME="template_modifier">The TemplateModifier Class</A>
+ and Associated Functions</h2>
+
+<p>A modifier is a filter that's applied at template-expand time, that
+munges the value of the variable before it's output. For instance,
+<code><html><body>{{NAME:html_escape}}</body></html></code>
+asks the template system to apply the built-in
+<code>html_escape</code> modifier when expanding
+<code>{{NAME}}</code>. If you set <code>NAME</code> in your
+dictionary to be <code>Jim & Bob</code>, what will actually be
+emitted in the template is <code>Jim &amp; Bob</code>.</p>
+
+<p>You can chain modifiers together. This template first html-escapes
+<code>NAME</code>, and then javascript-escapes that result:</p>
+<pre>
+ <html><body>{{NAME:html_escape:javascript_escape}}</body></html>
+</pre>
+
+<p>Modifiers typically have a long, descriptive name and also a
+one-letter abbreviation. So this example is equivalent to the
+previous one:</p>
+<pre>
+ <html><body>{{NAME:h:j}}</body></html>
+</pre>
+
+<p>Some modifiers take an argument, specified after an equals
+sign:</p>
+<pre>
+ <html><body>{{NAME:html_escape_with_arg=pre}}</body></html>
+</pre>
+
+
+<h3> Built-in Modifiers </h3>
+
+<p>Here are the modifiers that are built in to the template system.
+They are all defined in template_modifiers.cc:</p>
+
+<table border="1" cellpadding="3" summary="List of built-in modifiers">
+<tr><th>long name</th><th>short name</th><th>description</th></tr>
+
+<tr><td><code>:cleanse_css</code></td><td><code>:c</code></td>
+ <td>Removes characters not safe for a CSS value. Safe characters
+ are alphanumeric, space, underscore, period, coma, exclamation
+ mark, pound, percent, and dash.</td>
+</tr>
+
+<tr><td><code>:html_escape</code></td><td><code>:h</code></td>
+ <td>html-escapes the variable before output
+ (eg <code>&</code> -> <code>&amp;</code>)</td>
+</tr>
+
+<tr><td><code>:html_escape_with_arg</code></td><td><code>:H</code></td>
+ <td>special purpose html escaping. See
+ <a href="#html_escape_args">:H Arguments</a>
+ below for details.</td>
+</tr>
+
+<tr><td><code>:img_src_url_escape_with_arg</code></td><td><code>:I</code></td>
+ <td>special purpose image url escaping. See
+ <a href="#url_escape_args">:I and :U Arguments</a>
+ below for details.</td>
+</tr>
+
+<tr><td><code>:javascript_escape</code></td><td><code>:j</code></td>
+ <td>javascript-escapes the variable before output (eg
+ <code>"</code> -> <code>\x27</code> and
+ <code>&</code> -> <code>\x26</code>)</td>
+</tr>
+
+<tr><td><code>:javascript_escape_with_arg</code></td><td><code>:J</code>
+ </td>
+ <td>special purpose javascript escaping. See
+ <a href="#javascript_escape_args">:J Arguments</a>
+ below for details.</td>
+</tr>
+
+<tr><td><code>:json_escape</code></td><td><code>:o</code></td>
+ <td>json-escapes a variable before output as a string in json;
+ HTML characters are escaped using Unicode escape sequences
+ (e.g <code>&</code> -> <code>\u0026</code>) to comply with
+ <a href="http://www.ietf.org/rfc/rfc4627.txt">RFC 4627</a>.
+ </td>
+</tr>
+
+<tr><td><code>:none</code></td><td></td>
+ <td>leaves the variable as is (used to disable <A
+ HREF="#auto_escape">auto-escaping</A>)</td>
+</tr>
+
+<tr><td><code>:pre_escape</code></td><td><code>:p</code></td>
+ <td>pre-escapes the variable before output (same as html_escape but
+ whitespace is preserved; useful for <pre>...</pre>)</td>
+</tr>
+
+<tr><td><code>:url_escape_with_arg</code></td><td><code>:U</code></td>
+ <td>special purpose url escaping. See
+ <a href="#url_escape_args">:I and :U Arguments</a>
+ below for details.</td>
+</tr>
+
+<tr><td><code>:url_query_escape</code></td><td><code>:u</code></td>
+ <td>performs URL escaping on the variable before output.
+ space is turned into +, and everything other than [0-9a-zA-Z.,_:*/~!()-], is
+ transformed into %-style escapes. Use this when you are building
+ URLs with variables as parameters:
+ <pre><a href="http://google.com/search?q={{QUERY:u}}">{{QUERY:h}}</a></pre>
+ </td>
+</tr>
+
+<tr><td><code>:xml_escape</code></td><td></td>
+ <td>xml-escapes the variable before output
+ (the five characters <code><>&"'</code> become
+ <code>&lt&gt;&amp;&quot;&#39;</code>)
+ suitable for content returned in raw XML. It is not intended
+ for escaping content within CDATA blocks.</td>
+</tr>
+
+</table>
+
+<p>The <code>*_with_arg</code> modifiers require an argument to
+specify the type of escaping to use. The following sections list
+the supported arguments for each of these modifiers.
+
+<h4 id="html_escape_args">:H Arguments</h4>
+<p>Here are the values that are supported by
+the <code>html_escape_with_arg</code> modifier:</p>
+<table border="1" cellpadding="3" summary="Arguments for :H modifier">
+<tr><th>value</th><th>description</th></tr>
+
+<tr><td><code>=snippet</code></td>
+ <td>like <code>html_escape</code>, but allows HTML entities and
+ some tags to pass through unchanged. The allowed tags
+ are <code><br></code>, <code><wbr></code>, <code><b></code>,
+ and <code></b></code>.</td>
+</tr>
+
+<tr><td><code>=pre</code></td>
+ <td>same as <code>pre_escape</code></td>
+</tr>
+
+<tr><td><code>=url</code></td>
+ <td>same as <code>:U=html</code> below. For backwards compatibility.</td>
+</tr>
+
+<tr><td><code>=attribute</code></td>
+ <td>replaces characters not safe for an use in an unquoted
+ attribute with underscore. Safe characters are alphanumeric,
+ underscore, dash, period, and colon.</td>
+</tr>
+
+</table>
+
+<h4 id="url_escape_args">:I and :U Arguments</h4>
+<p>Here are the values that are supported by
+the <code>img_src_url_escape_with_arg</code> and
+<code>url_escape_with_arg</code> modifiers:</p>
+<table border="1" cellpadding="3" summary="Arguments for :I and :U modifiers">
+<tr><th>value</th><th>description</th></tr>
+
+<tr><td><code>=html</code></td>
+ <td>Ensures that a variable contains a safe URL. Safe means that
+ it is either a http or https URL, or else it has no protocol
+ specified.
+ <ul>
+ <li>If the URL is safe, the modifier HTML-escapes the URL.
+ <li>Otherwise, the modifier replaces the unsafe URL with one of the
+ following values:
+ <ul>
+ <li><code>/images/cleardot.gif</code> (the <code>:I</code>
+ modifier)
+ <li><code>#</code> (the <code>:U</code> modifier)
+ </ul>
+ </li>
+ </ul>
+ <b>Do not use <code>:U</code> for image URLs.</b> Use <code>:I</code>
+ instead. <code>#</code> is not a safe replacement for an image URL.
+ <code><img src=#></code> can cause each browser to request the
+ entire page again.
+ </td>
+</tr>
+
+<tr><td><code>=javascript</code></td>
+ <td>Same as <code>=html</code>, but using javascript escaping
+ instead of html escaping.</td>
+</tr>
+
+<tr><td><code>=css</code></td>
+ <td>Same as <code>=html</code> but using CSS escaping instead
+ of html escaping so that the variable can be safely inserted
+ within a CSS <code>@import</code> statement or a CSS property.
+ The characters in [\r\n()'"<>*\] are transformed
+ into %-style escapes.</td>
+</tr>
+
+<tr><td><code>=query</code></td>
+ <td>(Supported for <code>:U</code> only) Same as
+ <code>url_query_escape</code>.</td>
+</tr>
+
+</table>
+
+<h4 id="javascript_escape_args">:J Arguments</h4>
+<p>Here are the values that are supported by
+the <code>javascript_escape_with_arg</code> modifier:</p>
+<table border="1" cellpadding="3" summary="Arguments for :J modifier">
+<tr><th>value</th><th>description</th></tr>
+
+<tr><td><code>=number</code></td>
+ <td>Ensures that the variable is a valid number or boolean
+ javascript literal. This includes booleans
+ <code>true</code> and <code>false</code>, decimal
+ numbers (e.g. <code>4.10</code> or <code>-5.01e+10</code>)
+ as well as hex numbers (e.g. <code>0x5FF</code>). This modifier
+ is intended to ensure the variable not enclosed in
+ quotes cannot contain javascript code that may execute. It does
+ not guarantee that the variable is syntactically well-formed.
+ If the variable is safe, it is returned
+ as-is, otherwise it is replaced with <code>null</code>.
+ In the future we may add more logic to support objects and
+ arrays.</td>
+</tr>
+</table>
+
+<h3> Custom Modifiers </h3>
+
+<p>In addition to the built-in modifiers, you can write your own
+modifier. Custom modifiers must have a name starting with "x-", and
+the name can contain alphanumeric characters plus dashes and
+underscores. Custom modifiers can also accept values with any
+character except for : and <code>}</code>. For example
+this template could be a valid use of a custom modifier:</p>
+
+<pre>
+{{VAR:x-my_modifier:value1,value2,value3 has spaces,etc}}
+</pre>
+
+<p>See <code><template_modifiers.h></code> for details on how to
+write a modifier and how to register it. In short, you write a
+modifier by subclassing <code>ctemplate::TemplateModifier</code> and
+overriding the <code>Modify</code> method, and you register it by
+calling <code>ctemplate::AddModifier()</code> Here is an example of
+the code for a custom modifier:</p>
+<pre>
+ class StarEscape : public ctemplate::TemplateModifier {
+ void Modify(const char* in, size_t inlen,
+ const ctemplate::PerExpandData* per_expand_data,
+ ctemplate::ExpandEmitter* outbuf, const string& arg) const {
+ outbuf->Emit(string("*") + string(in, inlen) + string("*"));
+ }
+ };
+</pre>
+
+
+<h3> Subclassing TemplateModifier </h3>
+
+<p>The minimum work to create a custom modifier is to subclass
+<code>TemplateModifier</code> and override the <code>Modify()</code>
+method. <code>Modify()</code> takes as input the value of the text to
+be modified, as well as the <A HREF="#per_expand_data">per expand
+data</A> associated with this <code>Expand()</code> call. The method
+may use this input, plus any other data it may have, to generate
+output, which it should write into the given
+<code>ExpandEmitter</code>.</p>
+
+<p>The subclass can also override <code>MightModify()</code>. This is
+useful for modifiers that are typically a no-op (in which case the
+modifier is just doing busy-work, copying its input to the output
+<code>ExpandEmitter</code>). If <code>MightModify()</code> returns
+false, the template system will avoid calling <code>Modify()</code> at
+all on that variable, avoiding the busy-work copy.</p>
+
+
+<h3> AddModifier() </h3>
+
+<p> AddModifier() is used to register a custom modifier,
+so the modifier can be used in templates. The name of the modifier
+must start with <code>x-</code>. </p>
+
+
+<h3> AddXssSafeModifier() </h3>
+
+<p> <code>AddXssSafeModifier()</code> is used to register a custom
+modifier that can work well with the <A
+HREF="auto_escape.html">auto-escape system</A>. It is used when the
+modifier produces output that is "safe" from cross-site scripting
+attacks in all contexts in which it might be used. For instance, a
+modifier that only emits numbers is xss-safe if it's only used in html
+or javascript contexts.</p>
+
+
+<h3> <A NAME="auto_escape">Auto-escaping and Manual Escaping</A> </h3>
+
+<p>If the <A HREF="auto_escape.html">auto-escape pragma</A> is used
+in a document, then all variables will be auto-escaped, even if
+explicit modifiers are used on the variable. The rules are a little
+complicated:</p>
+
+<ul>
+ <li> If the explicit modifier is a built-in modifier, and that
+ modifier is "compatible" with the modifier that auto-escape
+ would perform ("compatible" means it safely escapes in at least
+ as many contexts as the auto-escape modifier), then only the
+ explicit modifier is applied, and no further auto-escaping is
+ done. </li>
+
+ <li> If the explicit modifier is a custom modifier registered using
+ AddXssSafeModifier(), no further auto-escaping is
+ done. </li>
+
+ <li> If the explicit modifier is the :none modifier, no
+ further auto-escaping is done. This is the mechanism for
+ manually turning off auto-escaping. </li>
+
+ <li> In all other situations, auto-escaping will be performed after
+ the explicit modifiers have all run. </li>
+</ul>
+
+
+<h2> <A NAME="per_expand_data">The <code>PerExpandData</code> Class</A> </h2>
+
+<p><code>ExpandWithData()</code> and
+<code>TemplateModifier::Modify()</code> both take a
+<code>PerExpandData</code> object. Per-expand data is applied to all
+templates that are seen while expanding: not only the template you
+called <code>ExpandWithData()</code> on, but also sub-templates that
+are brought in via template-includes (<code>{{>INCLUDE}}</code>).
+
+<p>There are several types of per-expand data you can set, by calling
+the appropriate method on a <code>PerExpandData</code> object.</p>
+
+
+<h3> SetAnnotateOutput() </h3>
+
+<p>This is a debugging function. When expanding this template, it adds
+marker-strings to the output to indicate what template-substitutions
+the system made. This takes a string argument which can be used to
+shorten the filenames printed in the annotations: if the filename
+contains the string you give, everything before that string is elided
+from the filename before printing. (It's safe to just always pass in
+the empty string.)</p>
+
+
+<h3> SetAnnotator() </h3>
+
+<p>This overrides the default text-based annotation used by
+<code>SetAnnotateOutput()</code>. If this is set and
+<code>SetAnnotateOutput()</code> is called, the per-expand data will
+use this <A
+HREF="#template_annotator"><code>TemplateAnnotator</code></A> instance
+to do the annotation, rather than the default instance.</p>
+
+
+<h3> InsertForModifiers() and LookupForModifiers() </h3>
+
+<p><code>InsertForModifiers()</code> stores an arbitrary key/value
+pair in the <code>PerExpandData</code> structure. This is used with
+<A HREF="#template_modifier">template modifiers</A>: the
+<code>PerExpandData</code> object passed to
+<code>ExpandWithData()</code> is made available to every template
+modifier that is called during expand time (including any custom
+modifiers). The intended use of this functionality is to allow a
+modifier to work one way when expanding a template with dictionary A,
+and another way when expanding a template with dictionary B. For
+instance, a modifier might encrypt part of a webpage using a user's
+secret-key, which is of course different for every expansion of the
+webpage.</p>
+
+<p><code>LookupForModifiers()</code> can be used by a
+template-modifier to read the key/value pair inserted by
+<code>InsertForModifiers()</code>.
+<code>LookupForModifiersAsString()</code> is the same, but returns the
+value as a char* rather than a void*, for convenience.</p>
+
+
+<h3> SetTemplateExpansionModifier() </h3>
+
+<p>This is an advanced feature for those who need a custom hook into
+template expansion. It will not be used by most programmers. It
+takes a template-modifier as its argument, but this template modifier
+is treated specially: instead of applying when an appropriate magic
+string appears in the text of a template, it applies every time a
+template is expanded during a call to <code>ExpandWithData()</code>.
+Note this means that it's called not only after the top-level
+template, that <code>ExpandWithData()</code> is called on, is
+expanded, but also on every sub-template that is expanded due to a
+template-include.</p>
+
+<p>This unusual functionality has a few unusual properties. Since the
+template expansion modifier is not called in normal fashion, the
+normal <code>arg</code> argument to the template modifier does not
+make sense. Instead, the <code>arg</code> is set to the path of the
+template which is being expanded. Also, template expansion modifiers
+can be expensive, since they are applied pretty indiscriminately, so
+it can be worth implementing the <code>MightModifiy()</code> predicate
+for the passed-in <code>TemplateModifier</code> to avoid unnecessary
+work.</p>
+
+
+<h2> <A NAME="template_annotator">The <code>TemplateAnnotator</code>
+ Class</A> </h2>
+
+<p>The <code>TemplateAnnotator</code> class is used to pass in to <A
+HREF="#per_expand_data"><code>PerExpandData::SetAnnotator()</code></A>,
+to control how expand-time annotation is done. This is meant to be
+used as a debugging routine.</p>
+
+<p>This class is an abstract base class; <code>SetAnnotator()</code>
+takes a subclass that implements the various methods of the base
+class. These methods control the action taken when various template
+markers are seen during template expansion.</p>
+
+<p><code>template_annotator.h</code> defines the abstract base class,
+and also a concrete subclass that is used by default for annotation if
+<code>SetAnnotator()</code> is not called.</p>
+
+
+<h2> <A NAME="template_dictionary_peer">The
+ <code>TemplateDictionaryPeer</code> Class</A> </h2>
+
+<p>By design, it is not possible to view the contents of a
+<code>TemplateDictionary</code>; we want to make sure the interface
+between the logic layer of the application and the presentation layer
+of the template goes in only one direction. While generally this
+keeps programs as clean as possible, it presents problems in testing
+code, which may want to verify that a given
+<code>TemplateDictionary</code> has been filled properly. The
+<code>TemplateDictionaryPeer</code> addresses this need. It lives in
+<code>template_test_util.h</code>.</p>
+
+<p>Some of the methods of <code>TemplateDictionaryPeer</code> are
+useful for internal tests only. Below are some of the methods that
+are most useful for user-level tests.</p>
+
+
+<h3> STS_INIT_FOR_TEST </h3>
+
+<p>This macro allows use of <code>STS_INIT</code> for testing, even
+when the input pointer is not guaranteed to be allocated for the
+entire length of the test (it must, of course, be allocated for the
+entire lifetime of the template being tested). Since normally
+<code>STS_INIT</code> requires inputs to have static duration, this
+allows for more flexibility in tests, at the cost of worse memory
+management and decreased code safety (in that it's possible to
+accidentally violate the lifetime requirements).</p>
+
+
+<h3> GetSectionValue() </h3>
+
+<p>This returns the value for the named variable. It uses normal
+template scoping rules to resolve the name.</p>
+
+
+<h3> IsHiddenSection() and IsHiddenTemplate() </h3>
+
+<p>Checks if a section or sub-template is "hidden" (that is, won't be
+displayed at all).</p>
+
+
+<h3> GetSectionDictionaries() and GetIncludeDictionaries() </h3>
+
+<p>Returns all the sub-dictionaries for a given section or
+template-include, in a vector.</>
+
+
+<h3> Other Testing Functions </h3>
+
+<p>template_test_util.h has other useful routines for
+testing, such as ExpandIs(), which tests whether a
+template + dictionary pair expands into an expected string. See the
+header file for details.</p>
+
+
+<h2> <A NAME="expand_emitter">The <code>ExpandEmitter</code> Class</A> </h2>
+
+<p>There are two overloads of <A
+HREF="#expand_template"><code>ExpandTemplate()</code></A>: the first
+emits the expanded template to a C++ string, and the second emits to
+an <code>ExpandEmitter</code>: an abstract base class that serves as a
+data source. It supports just one overloaded method,
+<code>Emit()</code>, that can take a char, a char*, or a C++ string as
+input.</p>
+
+<p>Using this class requires subclassing <code>ExpandEmitter</code>
+and providing the various definitions for <code>Emit()</code>. For
+instance, a subclass might provide definitions of <code>Emit()</code>
+that send the input bytes out to a network socket.</p>
+
+<p>In addition to defining the abstract base class,
+<code>template_emitter.h</code> provides a sample concrete subclass
+implementation, for emitting to a string.</p>
+
+
+<h2> <A NAME="template_string">The <code>TemplateString</code> and
+ <code>StaticTemplateString</code> Classes</A> </h2>
+
+<p><code>TemplateString</code> is a string-like implementation.
+Ctemplate uses <code>TemplateString</code> almost exclusively,
+internally. Many of the public API methods, such as
+<code>TemplateDictionary::SetValue()</code>, also take
+<code>TemplateString</code> as input. <code>TemplateString</code>
+has implicit constructors for both C++ strings and char*'s, so every
+method that takes a <code>TemplateString</code> will also work if
+given a C++ string or a char*. If you have a char* and know its
+length, you can save a bit of work by explicitly constructing a
+<code>TemplateString</code> with a char* + length, for instance:</p>
+<pre>
+ dict->SetValue(ctemplate::TemplateString("MYVAR", 5), value);
+</pre>
+
+<p>Some compile-time tools work with <code>TemplateString</code> to
+offload computation from runtime to compile-time. This is possible
+because the Ctemplate code often stores a hash of a string
+rather than a string directly. For static, immutable strings,
+<code>TemplateString</code> can store a pre-computed hash value. This
+functionality is used by <A
+HREF="#make_tpl_varnames_h"><code>make_tpl_varnames_h</code></A>. Thus,
+using this tool to create constants to use for <code>SetValue()</code>
+keys provides not only protection against typos, but a speed
+improvement as well.</p>
+
+<p>For immutable strings in your code, you can create efficient
+compile-time template-string objects of your own -- in this case of
+type <code>StaticTemplateString</code> -- by using the
+<code>STS_INIT</code> macro, like so:</p>
+<pre>
+static const StaticTemplateString kSectName =
+ STS_INIT(kSectName, "test_SetAddSectionDictionary");
+</pre>
+
+<p>The string variable's name, <code>kSectName</code> is repeated
+twice. The variable's value is specified inside the macro. Note that
+this macro should be used at the top level of a file, not inside
+functions (even when the variables are made static), and you should
+define the <code>StaticTemplateString</code> exactly as above:
+<code>static const StaticTemplateString</code>. Otherwise, the
+undefined constructor/destructor order of C++ may result in surprising
+behavior, wherein the <code>StaticTemplateString</code> is not
+initialized when it ought to be.</p>
+
+
+<h2> The <code>Template</code> Class </h2>
+
+<p>In older version of ctemplate, the <code>Template</code> class,
+which holds parsed templates, was a major part of the template
+workflow: the common template use-case would be:</p>
+<pre>
+ Template* tpl = Template::GetTemplate(filename, strip_mode);
+ TemplateDictionary dict(name);
+ tpl->Expand(&dict, &outstring);
+</pre>
+
+<p>In current use, this model is deprecated in favor of the single
+<code>ExpandTemplate()</code> call; support for <code>Template</code>
+methods may be removed entirely in future versions of ctemplate.
+However, you may still find older code using this old formulation.</p>
+
+
+<h2> <A NAME="auto_escaping">Auto-Escaping</A> </h2>
+
+<p>The <a href="auto_escape.html">Guide to using Auto Escape</a> has
+an overview of Auto Escape as well as discussion of its limitations.
+<!-- TODO(csilvers): move that information here? -->
+To use it, put the following text at the top of the template:</p>
+<pre>
+ {{%AUTOESCAPE context="CONTEXT" [state="STATE"]}}
+</pre>
+
+<p>Description of the arguments:</p>
+<ul>
+ <li> The context attribute is one of <code>HTML</code>,
+ <code>JAVASCRIPT</code>, <code>CSS</code>,
+ <code>JSON</code> or <code>XML</code>. It must correspond
+ to the context in which the browser will interpret this
+ template. <b>Warning:</b> Setting the wrong context will
+ result in wrong escaping applied to all variables in
+ the given template. In particular, if the template starts with
+ a <code><script></code> tag, its context is
+ <code>HTML</code> and not <code>JAVASCRIPT</code>. Auto-Escape
+ will recognize the <code><script></code> tag and hence
+ properly Javascript-escape the variables within it. Similarly,
+ if the template starts with a <code><style></code> tag,
+ its context is <code>HTML</code> and not <code>CSS</code>.
+</li>
+ <li> The state attribute is commonly omitted. It accepts the
+ value <code>IN_TAG</code> in the <code>HTML</code> context
+ to indicate that the template only contains (one or more)
+ HTML attribute name and value pairs that are part of an
+ HTML tag formed in a parent template.
+</ul>
+
+<p>This will auto-escape every variable in the template. To turn off
+auto-escaping for a particular variable, you can apply the
+<code>none</code> modifier, like so: <code>{{MYVAR:none}}</code>.
+Here is an example of an autoescaped document:</p>
+
+<pre>
+ {{%AUTOESCAPE context="HTML"}}
+
+ <body>
+ <p>Hello {{USER}}</p>
+ <p><a href="{{URL}}">Your Account</a></p>
+ <p>Your identifier: {{ID:none}}{{! This is dangerous! }}</p>
+ </body>
+</pre>
+
+
+<h2> Development Tools </h2>
+
+<p>This package includes several tools to make it easier to use write
+and use templates.</p>
+
+
+<h3> <A name="make_tpl_varnames_h">make_tpl_varnames_h:
+ Template Syntax Checker and Header File Generator</A> </h3>
+
+<p><code>make_tpl_varnames_h</code> is a "lint" style syntax checker
+and header file generator. It takes the names of template files as
+command line arguments and loads each file into a Template object by
+retrieving the file via the Template factory method. The loading of
+the file does pure syntax checking and reports such errors as
+mis-matched section start/end markers, mis-matched open/close
+double-curly braces, such as <code>"{{VAR}"</code>, or invalid
+characters in template variables/names/comments.</p>
+
+<p>If the template passes the syntax check, by default the utility
+then creates a header file for use in the executable code that fills
+the dictionary for the template. If the developer includes this
+header file, then constants in the header file may be referenced in
+the dictionary building function, rather than hard-coding strings as
+variable and section names. By using these constants, the compiler
+can notify the developer of spelling errors and mismatched names.
+Here's an example of how this is used, and how it helps prevent
+errors:</p>
+
+<pre>
+ const char * const kosr_RESULT_NUMBER = "RESULT_NUMBER"; // script output
+ dict.SetValue("RESSULT_NUMBER", "4"); // typo is silently missed
+ dict.SetValue(kosr_RESSULT_NUMBER, "4"); // compiler catches typo
+</pre>
+
+<p>Each constant is named as follows:</p>
+
+<ul>
+ <li> The initial letter 'k', indicating a defined constant. </li>
+
+ <li> One or more prefix letters which are derived from the
+ template file name. These prefix letters consist of the first
+ letter of the file name, followed by the first letter following
+ each underscore in the name, with the exception of the letter
+ 'p' when it is followed by the letters "ost", as is a <A
+ HREF="tips.html#versioning">recommended convention</A> for
+ template versioning. For example, the prefix letters for the
+ file <code>one_search_result_post20020815.tpl</code> are
+ <code>osr</code>. </li>
+
+ <li> An underscore. </li>
+
+ <li> The variable or section name itself, same casing. </li>
+</ul>
+
+<p>As an example, the section name "RESULT_NUMBER" in the file
+one_search_result_post20020815.tpl would be given the constant name
+<code>kosr_RESULT_NUMBER</code> and would appear in the header file as
+<code>const char * const kosr_RESULT_NUMBER = "RESULT_NUMBER";</code>
+-- as in the example above. (The variable is actually a
+<code>StaticTemplateString</code>, not a char*, but the basic idea
+holds.)</p>
+
+<p>
+An alternate output directory may be specified by the command line
+flag <code>--header_dir</code>.
+</p>
+
+<p>The name of the generated header file is the same as the name of
+the template file with an extension added to the name. By default,
+that extension is <code>.varnames.h</code>. In the above example, the
+header file containing the constant declarations would be named
+<code>one_search_result_post20020815.tpl.varnames.h</code>. An
+alternate extension may be provided via the command line flag
+<code>--outputfile_suffix</code>.</p>
+
+<p>Important command line flags:</p>
+
+<ul>
+ <li> <code>--noheader</code> -- Indicates that a header file
+ should not be generated; only syntax checking should be done. </li>
+
+ <li> <code>--header_dir</code> -- sets the directory where the header
+ is written. Default: "./" </li>
+
+ <li> <code>--template_dir</code> -- sets the template root
+ directory. Default: <code>./</code> which is the correct
+ specification when it is run from the directory where the templates
+ are located. This is only used if the input template filenames
+ are specified as relative paths rather than absolute
+ paths. </li>
+
+ <li> <code>--outputfile_suffix</code> -- the extension added to the
+ name of the template file to create the name of the generated
+ header file. Default: <code>.varnames.h</code>.
+</ul>
+
+<p>For a full list of command line flags, run
+<code>make_tpl_varnames_h --help</code>.</p>
+
+
+<h3> <A name="template_converter">template-converter: convert a
+ template to a C++ string</A> </h3>
+
+<p><code>StringToTemplateCache()</code> lets you load a template
+from a string instead of a file. Applications may prefer this option
+to reduce the dependencies of the executable, or use it in
+environments where data files are not practical. In such cases,
+<code>template-converter</code> can be used as a template "compiler",
+letting the developer write a template file as a data file in the
+normal way, and then "compiling" it to a C++ string to be included in
+the executable.</p>
+
+<p>Usage is <code>template-converter <template filename></code>.
+C++ code is output is to stdout; it can be stored in a .h file or
+included directly into a C++ file. Perl must be installed to use this
+script.</p>
+
+
+<hr>
+<ul>
+ <li> <A HREF="guide.html">User's Guide</A> </li>
+<!--
+ <li> <A HREF="reference.html">Reference Manual</A> </li>
+-->
+ <li> <A HREF="auto_escape.html">Auto Escape</A> </li>
+ <li> <A HREF="tips.html">Tips</A> </li>
+ <li> <A HREF="example.html">Example</A> </li>
+</ul>
+
+<hr>
+<address>
+Craig Silverstein<br>
+<script type=text/javascript>
+ var lm = new Date(document.lastModified);
+ document.write(lm.toDateString());
+</script>
+</address>
+
+</body>
+</html>
+
diff --git a/doc/tips.html b/doc/tips.html
new file mode 100644
index 0000000..723065b
--- /dev/null
+++ b/doc/tips.html
@@ -0,0 +1,474 @@
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+<title>Tips and Guidelines for Using the Ctemplate System</title>
+
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+<link href="designstyle.css" type="text/css" rel="stylesheet">
+<style type="text/css">
+ ol.bluelist li {
+ color: #3366ff;
+ font-family: sans-serif;
+ }
+ ol.bluelist li p {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ ul.blacklist li {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+</style>
+</head>
+
+<body>
+
+<h1>Tips and Guidelines for Using the Ctemplate System</h1>
+<small>(as of 10 March 2010)</small>
+
+<br>
+
+<p>The <A HREF="guide.html">basic rules</A> of the template system are
+enough to use it, but over time, we at Google have developed some
+tips, guidelines, and best practices that make it easier to use
+templates effectively, and to avoid common template errors.</p>
+
+
+<h2> Program Design Considerations </h2>
+
+<h3> <a name=versioning>Template naming and versioning</a> </h3>
+
+<p> Early in Google's use of templates, we noticed a problem: if a
+binary that uses a template and its corresponding template were both
+modified, particularly if the change were such that the old binary
+could not work with the new template or the new binary could not work
+with the old template, then somehow they both had to be deployed at
+the same instant to not present errors to our users. This was hard to
+do. The solution was to adopt a template naming and versioning
+convention. The procedure to use it follows:</p>
+
+<ul>
+ <li> Each template name ends with <code>_postYYYYMMDD.tpl</code>,
+ where YYYMMDD is the date of this version's initial
+ creation. </li>
+
+ <li> Before making (non-backward-compatible) modifications to a
+ template, copy the template to a new name, incorporating a
+ later date than the original one being copied. </li>
+
+ <li> Edit the new file, and push it to the production server. </li>
+
+ <li> Finally, update the code to refer to the new template-name
+ (ideally, using the <A
+ HREF="guide.html#register"><code>RegisterTemplateFilename</code>
+ idiom</A>), and push the new executable to the production
+ server. </li>
+</ul>
+
+<p>When this convention is followed, the new template file does not
+overwrite the old one when it is deployed, because it is a new file
+with a new name. The old template file is still there to be used as
+long as the old binary is still in production and the new template
+file just sits there being ignored. Then when the new binary finally
+gets deployed, it immediately starts using the new template file,
+because it is coded (in <code>RegisterTemplateFilename</code>) to do
+so. After that, it is the old template file that continues to sit
+there ignored.</p>
+
+<p>The <A
+HREF="reference.html#make_tpl_varnames_h"><code>make_tpl_varnames_h</code>
+utility</A> knows about the "_postYYYYMMDD" naming convention, so it
+is important that you use that convention exactly if you use the
+<code>make_tpl_varnames_h</code>.</p>
+
+
+<h3> Processing Phases </h3>
+
+<p>Typically a program using the Ctemplate System will
+perform the following phases, usually in this order:</p>
+
+<ol>
+ <li> Retrieve and prepare the data used to fill a dictionary. </li>
+
+ <li> Build the data dictionary, including all its
+ sub-dictionaries, that will supply the values to the
+ designated template object, its sections, and its
+ included templates. </li>
+
+ <li> Retrieve the top-level template object required to
+ format the data. (This may or may
+ not involve reading and parsing a template file,
+ depending on whether the requested file has already
+ been read and parsed by the running program or
+ whether that file has been marked "reload if changed"
+ and was in fact changed.) </li>
+
+ <li> Expand the template object into an output buffer
+ using the completed data dictionary. </li>
+
+ <li> Output the buffer. </li>
+
+ <li> Clean up: Destroy the top-level data dictionary
+ whenever it is no longer needed. </li>
+
+ <li> Optionally, clear the cache at the end of program
+ execution. </li>
+</ol>
+
+
+<h3> <A NAME="oneone">One template / One procedure call</A> </h3>
+
+<p> Most of the code of the program will be in Phases 1 and
+2. Clearly, Phase 1 is outside the scope of the template system. But
+in designing the code for Phase 2 (building the data dictionary), it
+is wise to have the structure of the program reflect the structure of
+the templates being used. Specifically, there should be a single
+procedure call to build the dictionary for a single template. That
+procedure call should take parameters that include all the data
+required to populate the data dictionary for that template and all the
+templates it includes. Following this "one template/one procedure
+call" guideline further, for each included template, another procedure
+should be called to populate the (or <i>each</i>) data dictionary for
+that included template. This maintains the "one template/one procedure
+call" principle in a nested fashion that reflects the nesting of the
+templates.</p>
+
+<p> This is not to imply that the "one procedure call" for a template
+should not be modularized into sub-procedures for readability and
+maintainability, or that it should not call other auxilliary
+procedures for such things as formatting the data and converting it to
+the appropriate strings, etc. But it does mean that there should be
+one entry point for building the dictionary tree for one template and
+that entry point should show the data dependencies of that template
+through its parameter list. This code for populating the data
+dictionary should <i>NOT</i> be intermingled with data gathering code
+that should have been done in Phase 1.</p>
+
+<p>(Inside Google, the convention has been used to name the dictionary
+building procedure using the pattern <code>fill_..._dictionary</code>
+where the dots are related to the name of the template the data is
+being prepared for. For instance, the data for the template named
+one_search_result.tpl might be placed in a dictionary via a function
+named <code>fill_one_search_result_dictionary</code>.)
+
+
+<h2> <A name=tips>Tips, Idioms, and Conventions</a> </h2>
+
+<ol class=bluelist>
+
+<li> Choose template names to create unique constant prefixes.
+
+ <p>Template names should contain <em>at least two words</em>
+ to avoid constant prefix clashes (e.g. <code>kxy_</code>
+ instead of <code>kx_</code> ) The name of a new template
+ should be checked against the existing names before
+ proceeding. If your new template name produces a prefix that
+ conflicts with an already existing template, you should change
+ the name of your new template, even though it may be the only
+ perfect name you can come up with. You'll have to use a less
+ than perfect name in that case. (See "Template Syntax Checker
+ and Header File Generator" below for more explanation about
+ constant prefixes.)</p> </li>
+
+<li> <a name="tip_setformattedvalue"></a>Use SetFormattedValue
+ discriminately.
+
+ <p> This method should never be used to sneak HTML into the
+ executable as in</p>
+
+ <pre>
+ dictionary->SetFormattedValue(kxy_VAR,
+ "<b>%s</b>",
+ some_const_char_string);
+ </pre>
+
+ <p>In that case, the <code><b></code> and
+ <code></b></code> should be moved into the template.</p>
+
+<li> Never have a section encompass an entire template.
+
+ <p>If the first line of a template is a start section marker
+ and the last line is its matching end section marker, then
+ those markers are unnecessary in almost all cases. They are
+ usually put there to allow the entire template to be hidden or
+ iterated, but since it encompasses the entire file, the
+ section may be hidden by not expanding the file (or by hiding
+ the template-include section that includes the file) and it
+ may be iterated by iterating the template-include marker of
+ the including template. (The only exception might be if the
+ entire page is to be iterated, but this seems a bit of a
+ stretch.)</p> </li>
+
+<li> An included template is just a section whose contents are
+ located in a separate file. You may iterate over it just
+ like you do sections.
+
+ <p>For example, if your template has the following
+ template-include marker:</p>
+ <pre>
+ {{>MY_INCLUDED_TEMPLATE}}
+ </pre>
+ <p>you may call</p>
+ <pre>
+ ctemplate::TemplateDictionary *child_dict =
+ dictionary->AddIncludeDictionary(kxy_MY_INCLUDED_TEMPLATE);
+ </pre>
+ <p>to iterate that section. (Note: Make sure you call
+ <code>child_dict->SetFilename()</code>! If your included
+ template is not showing in the output, this is the first thing
+ you should check.)</p> </li>
+
+<li> The recommended idiom to fill an include-template dictionary is
+ like this:
+ <pre>
+ fill_include_template_dictionary(dict->AddIncludeDictionary(name), ...);
+ </pre>
+
+ <p>But what do you do if you decide, in
+ <code>fill_include_template_dictionary</code>, that you don't
+ want to display anything for this include-template after all? It
+ seems like it's too late: you've already created the
+ sub-dictionary. The solution is simple: just be sure that
+ <code>fill_include_template_dictionary()</code> doesn't call
+ <code>SetFilename()</code> in that case.</p>
+
+<li> Never have a section which only contains another section.
+ <p>For example, don't do this:</p>
+ <pre>
+ {{#OUTER_SECTION}}
+ {{#INNER_SECTION}}
+ section contents here
+ {{/INNER_SECTION}}
+ {{/OUTER_SECTION}}
+ </pre>
+ <p>or this equivalent template code (see the previous item):</p>
+ <pre>
+ {{#OUTER_SECTION}}
+ {{>INCLUDED_SECTION}}
+ {{/OUTER_SECTION}}
+ </pre>
+
+ <p>This is usually done because the developer thinks the outer
+ section must be used to hide the section when the inner
+ section, intended for iteration, has no iterations. In both
+ cases, you should only have one section (either
+ <code>INNER_SECTION</code> or <code>INCLUDED_SECTION</code> in
+ the examples) and iterate that section either 0 times or more
+ than 0 times. It's the wonder of the dual use of sections,
+ i.e. that they may be conditional or iterative or, in this case,
+ both.</p>
+
+ <p>A related suggestion: Do not have a section whose entire
+ contents is one variable marker with nothing else, unless you
+ need to iterate over that section with multiple values of that
+ variable. You don't need the surrounding section just to hide
+ the marker. A variable marker that is not set, does not
+ produce output. By convention, we set such variables to the
+ empty string. But in neither case do you need to hide it by
+ hiding a surrounding section that contains nothing else.</p>
+
+<li> Use this hide/show idiom for <code>if-else</code> blocks.
+
+ <p>Since sections are hidden by default, you can use represent
+ if-else logic in your code via <code>ShowSection</code>. For
+ example:</p>
+
+ <pre>
+ if ( my_test ) {
+ dict->ShowSection(kxyz_TRUE_BLOCK);
+ [ more code to fill the values for that section]
+ } else {
+ dict->ShowSection(kxyz_FALSE_BLOCK);
+ [ more code to fill the values for that section]
+ }
+ </pre>
+
+<li> <code>Write...</code> vs. <code>Fill...Dictionary</code> methods
+ - Observe the proper division of labor, don't mix them.
+
+ <p>The output (or write) function should create the top level
+ template dictionary, call one or more fill-dictionary routines
+ with it, then get the template and expand it. It should not call
+ dictionary modifying methods, like <code>ShowSection</code>
+ and <code>SetValue</code>. By keeping these separated into
+ their own fill-dictionary routine, the code is more modular and
+ lends itself to template re-use. If you maintain the proper
+ division of labor, the template you are filling and outputting
+ may be filled and included in a larger template by someone
+ else.</p> </li>
+
+<li> Use <code>AddSectionDictionary</code> only when you want to
+ iterate over a section or, secondarily, if you need to avoid name
+ conflicts.
+
+ <p>Sometimes developers get the idea that every section requires
+ its own child dictionary created by an
+ <code>AddSectionDictionary</code> call. Because of variable
+ inheritence, this isn't usually so. The intended purpose of
+ <code>AddSectionDictionary</code> is to enable iteration over a
+ section. Secondarily, if the section contains generic names that
+ may conflict with the same name in other parts of the template,
+ it may be safer to call <code>AddSectionDictionary</code> to
+ create a separate namespace. In any case, do not assume you must
+ call <code>AddSectionDictionary</code> just because you are
+ working within a section. The main dictionary can be used for all
+ levels of conditional sections as long as you avoid name
+ conflicts by keeping the marker names unique.</p> </li>
+
+<li> Do not place <code>RegisterTemplateFilename</code>
+ statements in header (<code>.h</code>) files.
+
+ <p><code>RegisterTemplateFilename</code> is a macro that
+ instantiates a <code>TemplateNamelist</code> object. If you place
+ it in a header file, a different object will get created each time
+ it is included in another <code>.cc</code> file.
+
+ <p>The <code>RegisterTemplateFilename</code> statement and its
+ associated <code>#include</code> of the <code>varnames.h</code>
+ file should occur only in the <code>.cc</code> file that
+ implements the fill-dictionary routine for that template. You
+ should never have more than one
+ <code>RegisterTemplateFilename</code> for a single template and
+ you should try hard not to copy the <code>#include</code> file to
+ other files as well. The template versioning makes this more
+ important because a developer may not know that the template name
+ with included version number needs to be updated in more than one
+ file when versioning occurs. [Also see above for more information
+ about what routine uses the filename declared by the
+ <code>RegisterTemplateFilename</code> statement.]</p> </li>
+
+<li> Never reference more than one template in a
+ fill...dictionary method.
+
+ <p>Each template should have its own fill-dictionary
+ routine. That routine should only reference marker names defined
+ in that template. If this convention is followed, then all the
+ prefixes in a fill-dictionary routine will be the same. [Note
+ that an implication of this convention is that if the template
+ includes another template, via a template-include marker, then
+ containing template's fill-dictionary routine should call the
+ included template's fill-dictionary routine (being careful to
+ observe the convention described above). But
+ then, this is merely a restatement of <A HREF="#oneone">"One
+ template / One procedure call"</A>.]</p> </li>
+
+<li> Have fill...dictionary call <code>SetFilename</code> even if the
+ dictionary is never used for a template-include.
+
+ <p>SetFilename() is required when a dictionary is created via
+ <code>AddIncludeDictionary()</code>. However, it's safe to set
+ all the time. By setting it always, you make the code work
+ properly if this dictionary ever changes to be template-included
+ after all. Even if not, by saying what template file the
+ dictionary is intended to go with, you are self-documenting your
+ code.</p> </li>
+
+<li> Do not call <code>c_str()</code> on strings to pass them to
+ <code>TemplateDictionary</code> methods.
+
+ <p>Note that all the TemplateDictionary methods are defined to
+ take <code>TemplateString</code> objects. These are created
+ automatically from both strings and char*'s (and can be created
+ manually if you have a char* and a length). So if you have a
+ string, it's safe and efficient to just pass it in directly; you
+ do not need to extract the const char * from your string object
+ to pass it to these methods. For some reason, this is a common
+ error of novice template coders.</p>
+
+ <p>The one exception to this rule is when using the method
+ <code>SetFormattedValue</code>. When calling that
+ method, you must call <code>c_str()</code> on strings that are to
+ be inserted
+ into the format string, just as you would when providing data for
+ any other printf format string.</p> </li>
+
+<li> Do not use <code>SetGlobalValue</code> when you could use
+ <code>SetValue</code> or <code>SetTemplateGlobalValue</code>.
+
+ <p><code>SetGlobalValue</code> should be used quite rarely, for
+ constants that really are consistent across all your templates.
+ It's slower to look up a value in the global dictionary than it
+ is in the template-specific dictionary.</p> </li>
+
+<li> Do not use <code>StringToTemplateCache</code> unless you have
+ a specific need for its non-file-based attributes.
+
+ <p><code>ctemplate::StringToTemplateCache</code> was created for
+ use in highly constrained cases where file I/O may be impaired or
+ undesirable, for instance to produce a server error message
+ where there may be disk problems or to produce formatted
+ output where there are processes that do not have a facility
+ for updating data files dynamically. It is not recommended for
+ ordinary use since it cannot be updated dynamically via a
+ data-push; changes always require a binary push.</p>
+ </ul>
+ </li>
+
+<li> Use <A HREF="auto_escape.html">auto-escaping</A> to prevent
+ Cross-Site-Scripting security vulnerabilities.
+
+ <p>Use <code>{{%AUTOESCAPE}}</code> consistently. Use the
+ <code>:none</code> modifier to override autoesacping only in
+ those (usually rare) cases where there is a specific reason the
+ template variable should not be escaped, for example:
+ <ul class=blacklist>
+ <li>The template variable contains HTML markup that should be
+ interpreted by the browser. In this case you must be very careful to
+ ensure that the variable can in no case contain "harmful" HTML. Also,
+ keep in mind the <a href="#tip_setformattedvalue">above
+ recommendation</a> on the use of <code>SetFormattedValue</code> and
+ consider moving the HTML markup into the template.</li>
+
+ <li>The variable is known to be already escaped at the point it
+ is inserted into the template (for example, the value might be
+ kept in escaped form in a storage backend). Here, escaping again
+ via a variable-modifier would result in "double escaping". You
+ must ensure that the variable comes escaped in the appropriate
+ context (that is, if you're inserting the variable into an html
+ document, it's html-escaped and not java-escaped).</li>
+ </ul>
+ </li>
+
+<li> Do not leave an extra space when using <code>{{BI_SPACE}}</code>
+
+ <p>The built-in template variable <code>BI_SPACE</code> is itself
+ replaced by a single space. It is used where you need to make
+ sure a space is preserved at the end of a line. It is a common
+ mistake to leave an extra space before this marker, which results
+ in not one, but two, spaces created in the document.</p>
+
+ <p>Incorrect:</p><pre>
+<table border=0 {{BI_SPACE}}
+ align=center></pre>
+
+ <p>Correct:</p><pre>
+<table border=0{{BI_SPACE}}
+ align=center></pre>
+
+ </li>
+
+</ol>
+
+<hr>
+<ul>
+ <li> <A HREF="guide.html">User's Guide</A> </li>
+ <li> <A HREF="reference.html">Reference Manual</A> </li>
+ <li> <A HREF="auto_escape.html">Auto Escape</A> </li>
+<!--
+ <li> <A HREF="tips.html">Tips</A> </li>
+-->
+ <li> <A HREF="example.html">Example</A> </li>
+</ul>
+
+<hr>
+<address>
+Craig Silverstein<br>
+<script type=text/javascript>
+ var lm = new Date(document.lastModified);
+ document.write(lm.toDateString());
+</script>
+</address>
+
+</body>
+</html>
diff --git a/doc/xss_resources.html b/doc/xss_resources.html
new file mode 100644
index 0000000..96038e1
--- /dev/null
+++ b/doc/xss_resources.html
@@ -0,0 +1,71 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<html>
+<head>
+ <title>Cross-Site Scripting Resources</title>
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ <link href="designstyle.css" type="text/css" rel="stylesheet">
+ <style type="text/css">
+ <!--
+ ol.bluelist li {
+ color: #3366ff;
+ font-family: sans-serif;
+ }
+ ol.bluelist li p {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ ul.blacklist li {
+ color: #000;
+ font-family: "Times Roman", times, serif;
+ }
+ //-->
+ </style>
+</head>
+<body>
+
+<h1> <a name="XSS_Resources"></a>Cross-Site Scripting Resources</h1>
+<center><strong>Status: Current</strong>
+<small>(as of 17 August 2006)</small></center>
+<br>
+
+<p>Cross-Site Scripting (commonly abbreviated as XSS) is a security
+issue that arises when an attacker can cause client-side script (such as
+JavaScript) of his or her choosing to execute within another user's
+browser in the context of a given web-site or web-application. This may
+allow the attacker to steal that user's session cookies for the
+web-application in question, or otherwise manipulate that user's session
+context.
+
+<p>XSS vulnerabilities most often arise if a web-application renders
+data that originated from an untrusted source (such as a query
+parameter) in a HTML document without carefully validating or escaping
+that data.
+
+<p>The following online resources provide further information on XSS
+vulnerabilities and how to avoid them:
+
+<ul>
+ <li>The Open Web Application Security Project (OWASP) has an
+ <a
+ href="http://www.owasp.org/index.php/Cross_Site_Scripting">introductory
+ article</a> on XSS.
+ </li>
+
+ <li>In addition, the OWASP's <a
+ href="http://www.owasp.org/index.php/Category:OWASP_Guide_Project">Guide to Building Secure Web
+ Applications and Web Services</a> and the <a
+ href="http://www.owasp.org/index.php/Category:OWASP_Top_Ten_Project">"Top
+ Ten" Vulnerabilities</a> include sections on XSS.
+ </li>
+
+ <li>The CERT Coordination Center published <a
+ href="http://www.cert.org/tech_tips/malicious_code_mitigation.html">Understanding
+ Malicious Content Mitigation for Web Developers</a> and <a
+ href="http://www.cert.org/advisories/CA-2000-02.html">Advisory
+ CA-2000-02 Malicious HTML Tags Embedded in Client Web Requests</a>.
+
+ </li>
+</ul>
+</body>
+</html>
diff --git a/install-sh b/install-sh
new file mode 100755
index 0000000..a5897de
--- /dev/null
+++ b/install-sh
@@ -0,0 +1,519 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2006-12-25.00
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.
+
+nl='
+'
+IFS=" "" $nl"
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit=${DOITPROG-}
+if test -z "$doit"; then
+ doit_exec=exec
+else
+ doit_exec=$doit
+fi
+
+# Put in absolute file names if you don't have them in your path;
+# or use environment vars.
+
+chgrpprog=${CHGRPPROG-chgrp}
+chmodprog=${CHMODPROG-chmod}
+chownprog=${CHOWNPROG-chown}
+cmpprog=${CMPPROG-cmp}
+cpprog=${CPPROG-cp}
+mkdirprog=${MKDIRPROG-mkdir}
+mvprog=${MVPROG-mv}
+rmprog=${RMPROG-rm}
+stripprog=${STRIPPROG-strip}
+
+posix_glob='?'
+initialize_posix_glob='
+ test "$posix_glob" != "?" || {
+ if (set -f) 2>/dev/null; then
+ posix_glob=
+ else
+ posix_glob=:
+ fi
+ }
+'
+
+posix_mkdir=
+
+# Desired mode of installed file.
+mode=0755
+
+chgrpcmd=
+chmodcmd=$chmodprog
+chowncmd=
+mvcmd=$mvprog
+rmcmd="$rmprog -f"
+stripcmd=
+
+src=
+dst=
+dir_arg=
+dst_arg=
+
+copy_on_change=false
+no_target_directory=
+
+usage="\
+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+ or: $0 [OPTION]... SRCFILES... DIRECTORY
+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+ or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+ --help display this help and exit.
+ --version display version info and exit.
+
+ -c (ignored)
+ -C install only if different (preserve the last data modification time)
+ -d create directories instead of installing files.
+ -g GROUP $chgrpprog installed files to GROUP.
+ -m MODE $chmodprog installed files to MODE.
+ -o USER $chownprog installed files to USER.
+ -s $stripprog installed files.
+ -t DIRECTORY install into DIRECTORY.
+ -T report an error if DSTFILE is a directory.
+
+Environment variables override the default commands:
+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG
+ RMPROG STRIPPROG
+"
+
+while test $# -ne 0; do
+ case $1 in
+ -c) ;;
+
+ -C) copy_on_change=true;;
+
+ -d) dir_arg=true;;
+
+ -g) chgrpcmd="$chgrpprog $2"
+ shift;;
+
+ --help) echo "$usage"; exit $?;;
+
+ -m) mode=$2
+ case $mode in
+ *' '* | *' '* | *'
+'* | *'*'* | *'?'* | *'['*)
+ echo "$0: invalid mode: $mode" >&2
+ exit 1;;
+ esac
+ shift;;
+
+ -o) chowncmd="$chownprog $2"
+ shift;;
+
+ -s) stripcmd=$stripprog;;
+
+ -t) dst_arg=$2
+ shift;;
+
+ -T) no_target_directory=true;;
+
+ --version) echo "$0 $scriptversion"; exit $?;;
+
+ --) shift
+ break;;
+
+ -*) echo "$0: invalid option: $1" >&2
+ exit 1;;
+
+ *) break;;
+ esac
+ shift
+done
+
+if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then
+ # When -d is used, all remaining arguments are directories to create.
+ # When -t is used, the destination is already specified.
+ # Otherwise, the last argument is the destination. Remove it from $@.
+ for arg
+ do
+ if test -n "$dst_arg"; then
+ # $@ is not empty: it contains at least $arg.
+ set fnord "$@" "$dst_arg"
+ shift # fnord
+ fi
+ shift # arg
+ dst_arg=$arg
+ done
+fi
+
+if test $# -eq 0; then
+ if test -z "$dir_arg"; then
+ echo "$0: no input file specified." >&2
+ exit 1
+ fi
+ # It's OK to call `install-sh -d' without argument.
+ # This can happen when creating conditional directories.
+ exit 0
+fi
+
+if test -z "$dir_arg"; then
+ trap '(exit $?); exit' 1 2 13 15
+
+ # Set umask so as not to create temps with too-generous modes.
+ # However, 'strip' requires both read and write access to temps.
+ case $mode in
+ # Optimize common cases.
+ *644) cp_umask=133;;
+ *755) cp_umask=22;;
+
+ *[0-7])
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw='% 200'
+ fi
+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;
+ *)
+ if test -z "$stripcmd"; then
+ u_plus_rw=
+ else
+ u_plus_rw=,u+rw
+ fi
+ cp_umask=$mode$u_plus_rw;;
+ esac
+fi
+
+for src
+do
+ # Protect names starting with `-'.
+ case $src in
+ -*) src=./$src;;
+ esac
+
+ if test -n "$dir_arg"; then
+ dst=$src
+ dstdir=$dst
+ test -d "$dstdir"
+ dstdir_status=$?
+ else
+
+ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+ # might cause directories to be created, which would be especially bad
+ # if $src (and thus $dsttmp) contains '*'.
+ if test ! -f "$src" && test ! -d "$src"; then
+ echo "$0: $src does not exist." >&2
+ exit 1
+ fi
+
+ if test -z "$dst_arg"; then
+ echo "$0: no destination specified." >&2
+ exit 1
+ fi
+
+ dst=$dst_arg
+ # Protect names starting with `-'.
+ case $dst in
+ -*) dst=./$dst;;
+ esac
+
+ # If destination is a directory, append the input filename; won't work
+ # if double slashes aren't ignored.
+ if test -d "$dst"; then
+ if test -n "$no_target_directory"; then
+ echo "$0: $dst_arg: Is a directory" >&2
+ exit 1
+ fi
+ dstdir=$dst
+ dst=$dstdir/`basename "$src"`
+ dstdir_status=0
+ else
+ # Prefer dirname, but fall back on a substitute if dirname fails.
+ dstdir=`
+ (dirname "$dst") 2>/dev/null ||
+ expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+ X"$dst" : 'X\(//\)[^/]' \| \
+ X"$dst" : 'X\(//\)$' \| \
+ X"$dst" : 'X\(/\)' \| . 2>/dev/null ||
+ echo X"$dst" |
+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)[^/].*/{
+ s//\1/
+ q
+ }
+ /^X\(\/\/\)$/{
+ s//\1/
+ q
+ }
+ /^X\(\/\).*/{
+ s//\1/
+ q
+ }
+ s/.*/./; q'
+ `
+
+ test -d "$dstdir"
+ dstdir_status=$?
+ fi
+ fi
+
+ obsolete_mkdir_used=false
+
+ if test $dstdir_status != 0; then
+ case $posix_mkdir in
+ '')
+ # Create intermediate dirs using mode 755 as modified by the umask.
+ # This is like FreeBSD 'install' as of 1997-10-28.
+ umask=`umask`
+ case $stripcmd.$umask in
+ # Optimize common cases.
+ *[2367][2367]) mkdir_umask=$umask;;
+ .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;;
+
+ *[0-7])
+ mkdir_umask=`expr $umask + 22 \
+ - $umask % 100 % 40 + $umask % 20 \
+ - $umask % 10 % 4 + $umask % 2
+ `;;
+ *) mkdir_umask=$umask,go-w;;
+ esac
+
+ # With -d, create the new directory with the user-specified mode.
+ # Otherwise, rely on $mkdir_umask.
+ if test -n "$dir_arg"; then
+ mkdir_mode=-m$mode
+ else
+ mkdir_mode=
+ fi
+
+ posix_mkdir=false
+ case $umask in
+ *[123567][0-7][0-7])
+ # POSIX mkdir -p sets u+wx bits regardless of umask, which
+ # is incompatible with FreeBSD 'install' when (umask & 300) != 0.
+ ;;
+ *)
+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$
+ trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
+
+ if (umask $mkdir_umask &&
+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+ then
+ if test -z "$dir_arg" || {
+ # Check for POSIX incompatibilities with -m.
+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+ # other-writeable bit of parent directory when it shouldn't.
+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+ ls_ld_tmpdir=`ls -ld "$tmpdir"`
+ case $ls_ld_tmpdir in
+ d????-?r-*) different_mode=700;;
+ d????-?--*) different_mode=755;;
+ *) false;;
+ esac &&
+ $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+ ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+ }
+ }
+ then posix_mkdir=:
+ fi
+ rmdir "$tmpdir/d" "$tmpdir"
+ else
+ # Remove any dirs left behind by ancient mkdir implementations.
+ rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null
+ fi
+ trap '' 0;;
+ esac;;
+ esac
+
+ if
+ $posix_mkdir && (
+ umask $mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"
+ )
+ then :
+ else
+
+ # The umask is ridiculous, or mkdir does not conform to POSIX,
+ # or it failed possibly due to a race condition. Create the
+ # directory the slow way, step by step, checking for races as we go.
+
+ case $dstdir in
+ /*) prefix='/';;
+ -*) prefix='./';;
+ *) prefix='';;
+ esac
+
+ eval "$initialize_posix_glob"
+
+ oIFS=$IFS
+ IFS=/
+ $posix_glob set -f
+ set fnord $dstdir
+ shift
+ $posix_glob set +f
+ IFS=$oIFS
+
+ prefixes=
+
+ for d
+ do
+ test -z "$d" && continue
+
+ prefix=$prefix$d
+ if test -d "$prefix"; then
+ prefixes=
+ else
+ if $posix_mkdir; then
+ (umask=$mkdir_umask &&
+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break
+ # Don't fail if two instances are running concurrently.
+ test -d "$prefix" || exit 1
+ else
+ case $prefix in
+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;
+ *) qprefix=$prefix;;
+ esac
+ prefixes="$prefixes '$qprefix'"
+ fi
+ fi
+ prefix=$prefix/
+ done
+
+ if test -n "$prefixes"; then
+ # Don't fail if two instances are running concurrently.
+ (umask $mkdir_umask &&
+ eval "\$doit_exec \$mkdirprog $prefixes") ||
+ test -d "$dstdir" || exit 1
+ obsolete_mkdir_used=true
+ fi
+ fi
+ fi
+
+ if test -n "$dir_arg"; then
+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&
+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||
+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1
+ else
+
+ # Make a couple of temp file names in the proper directory.
+ dsttmp=$dstdir/_inst.$$_
+ rmtmp=$dstdir/_rm.$$_
+
+ # Trap to clean up those temp files at exit.
+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+
+ # Copy the file name to the temp name.
+ (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") &&
+
+ # and set any options; do chmod last to preserve setuid bits.
+ #
+ # If any of these fail, we abort the whole thing. If we want to
+ # ignore errors from any of these, just make sure not to ignore
+ # errors from the above "$doit $cpprog $src $dsttmp" command.
+ #
+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&
+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&
+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&
+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&
+
+ # If -C, don't bother to copy if it wouldn't change the file.
+ if $copy_on_change &&
+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&
+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&
+
+ eval "$initialize_posix_glob" &&
+ $posix_glob set -f &&
+ set X $old && old=:$2:$4:$5:$6 &&
+ set X $new && new=:$2:$4:$5:$6 &&
+ $posix_glob set +f &&
+
+ test "$old" = "$new" &&
+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1
+ then
+ rm -f "$dsttmp"
+ else
+ # Rename the file to the real destination.
+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||
+
+ # The rename failed, perhaps because mv can't rename something else
+ # to itself, or perhaps because mv is so ancient that it does not
+ # support -f.
+ {
+ # Now remove or move aside any old file at destination location.
+ # We try this two ways since rm can't unlink itself on some
+ # systems and the destination file might be busy for other
+ # reasons. In this case, the final cleanup might fail but the new
+ # file should still install successfully.
+ {
+ test ! -f "$dst" ||
+ $doit $rmcmd -f "$dst" 2>/dev/null ||
+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&
+ { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; }
+ } ||
+ { echo "$0: cannot unlink or rename $dst" >&2
+ (exit 1); exit 1
+ }
+ } &&
+
+ # Now rename the file to the real destination.
+ $doit $mvcmd "$dsttmp" "$dst"
+ }
+ fi || exit 1
+
+ trap '' 0
+ fi
+done
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/ltmain.sh b/ltmain.sh
new file mode 100644
index 0000000..7ed280b
--- /dev/null
+++ b/ltmain.sh
@@ -0,0 +1,8413 @@
+# Generated from ltmain.m4sh.
+
+# ltmain.sh (GNU libtool) 2.2.6b
+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
+# This is free software; see the source for copying conditions. There is NO
+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+# GNU Libtool is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# Usage: $progname [OPTION]... [MODE-ARG]...
+#
+# Provide generalized library-building support services.
+#
+# --config show all configuration variables
+# --debug enable verbose shell tracing
+# -n, --dry-run display commands without modifying any files
+# --features display basic configuration information and exit
+# --mode=MODE use operation mode MODE
+# --preserve-dup-deps don't remove duplicate dependency libraries
+# --quiet, --silent don't print informational messages
+# --tag=TAG use configuration variables from tag TAG
+# -v, --verbose print informational messages (default)
+# --version print version information
+# -h, --help print short or long help message
+#
+# MODE must be one of the following:
+#
+# clean remove files from the build directory
+# compile compile a source file into a libtool object
+# execute automatically set library path, then run a program
+# finish complete the installation of libtool libraries
+# install install libraries or executables
+# link create a library or an executable
+# uninstall remove libraries from an installed directory
+#
+# MODE-ARGS vary depending on the MODE.
+# Try `$progname --help --mode=MODE' for a more detailed description of MODE.
+#
+# When reporting a bug, please describe a test case to reproduce it and
+# include the following information:
+#
+# host-triplet: $host
+# shell: $SHELL
+# compiler: $LTCC
+# compiler flags: $LTCFLAGS
+# linker: $LD (gnu? $with_gnu_ld)
+# $progname: (GNU libtool) 2.2.6b Debian-2.2.6b-2ubuntu1
+# automake: $automake_version
+# autoconf: $autoconf_version
+#
+# Report bugs to <bug-libtool@gnu.org>.
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION="2.2.6b Debian-2.2.6b-2ubuntu1"
+TIMESTAMP=""
+package_revision=1.3017
+
+# Be Bourne compatible
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '${1+"$@"}'='"$@"'
+ setopt NO_GLOB_SUBST
+else
+ case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# NLS nuisances: We save the old values to restore during execute mode.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+lt_user_locale=
+lt_safe_locale=
+for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+do
+ eval "if test \"\${$lt_var+set}\" = set; then
+ save_$lt_var=\$$lt_var
+ $lt_var=C
+ export $lt_var
+ lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
+ lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
+ fi"
+done
+
+$lt_unset CDPATH
+
+
+
+
+
+: ${CP="cp -f"}
+: ${ECHO="echo"}
+: ${EGREP="/bin/grep -E"}
+: ${FGREP="/bin/grep -F"}
+: ${GREP="/bin/grep"}
+: ${LN_S="ln -s"}
+: ${MAKE="make"}
+: ${MKDIR="mkdir"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+: ${SED="/bin/sed"}
+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}
+: ${Xsed="$SED -e 1s/^X//"}
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
+EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
+
+exit_status=$EXIT_SUCCESS
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS=" $lt_nl"
+
+dirname="s,/[^/]*$,,"
+basename="s,^.*/,,"
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+# Generated shell functions inserted here.
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+# In the unlikely event $progname began with a '-', it would play havoc with
+# func_echo (imagine progname=-n), so we prepend ./ in that case:
+func_dirname_and_basename "$progpath"
+progname=$func_basename_result
+case $progname in
+ -*) progname=./$progname ;;
+esac
+
+# Make sure we have an absolute path for reexecution:
+case $progpath in
+ [\\/]*|[A-Za-z]:\\*) ;;
+ *[\\/]*)
+ progdir=$func_dirname_result
+ progdir=`cd "$progdir" && pwd`
+ progpath="$progdir/$progname"
+ ;;
+ *)
+ save_IFS="$IFS"
+ IFS=:
+ for progdir in $PATH; do
+ IFS="$save_IFS"
+ test -x "$progdir/$progname" && break
+ done
+ IFS="$save_IFS"
+ test -n "$progdir" || progdir=`pwd`
+ progpath="$progdir/$progname"
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
+
+# Re-`\' parameter expansions in output of double_quote_subst that were
+# `\'-ed in input to the same. If an odd number of `\' preceded a '$'
+# in input to double_quote_subst, that '$' was protected from expansion.
+# Since each input `\' is now two `\'s, look for any number of runs of
+# four `\'s followed by two `\'s and then a '$'. `\' that '$'.
+bs='\\'
+bs2='\\\\'
+bs4='\\\\\\\\'
+dollar='\$'
+sed_double_backslash="\
+ s/$bs4/&\\
+/g
+ s/^$bs2$dollar/$bs&/
+ s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
+ s/\n//g"
+
+# Standard options:
+opt_dry_run=false
+opt_help=false
+opt_quiet=false
+opt_verbose=false
+opt_warning=:
+
+# func_echo arg...
+# Echo program name prefixed message, along with the current mode
+# name if it has been set yet.
+func_echo ()
+{
+ $ECHO "$progname${mode+: }$mode: $*"
+}
+
+# func_verbose arg...
+# Echo program name prefixed message in verbose mode only.
+func_verbose ()
+{
+ $opt_verbose && func_echo ${1+"$@"}
+
+ # A bug in bash halts the script if the last line of a function
+ # fails when set -e is in force, so we need another command to
+ # work around that:
+ :
+}
+
+# func_error arg...
+# Echo program name prefixed message to standard error.
+func_error ()
+{
+ $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
+}
+
+# func_warning arg...
+# Echo program name prefixed warning message to standard error.
+func_warning ()
+{
+ $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
+
+ # bash bug again:
+ :
+}
+
+# func_fatal_error arg...
+# Echo program name prefixed message to standard error, and exit.
+func_fatal_error ()
+{
+ func_error ${1+"$@"}
+ exit $EXIT_FAILURE
+}
+
+# func_fatal_help arg...
+# Echo program name prefixed message to standard error, followed by
+# a help hint, and exit.
+func_fatal_help ()
+{
+ func_error ${1+"$@"}
+ func_fatal_error "$help"
+}
+help="Try \`$progname --help' for more information." ## default
+
+
+# func_grep expression filename
+# Check whether EXPRESSION matches any line of FILENAME, without output.
+func_grep ()
+{
+ $GREP "$1" "$2" >/dev/null 2>&1
+}
+
+
+# func_mkdir_p directory-path
+# Make sure the entire path to DIRECTORY-PATH is available.
+func_mkdir_p ()
+{
+ my_directory_path="$1"
+ my_dir_list=
+
+ if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
+
+ # Protect directory names starting with `-'
+ case $my_directory_path in
+ -*) my_directory_path="./$my_directory_path" ;;
+ esac
+
+ # While some portion of DIR does not yet exist...
+ while test ! -d "$my_directory_path"; do
+ # ...make a list in topmost first order. Use a colon delimited
+ # list incase some portion of path contains whitespace.
+ my_dir_list="$my_directory_path:$my_dir_list"
+
+ # If the last portion added has no slash in it, the list is done
+ case $my_directory_path in */*) ;; *) break ;; esac
+
+ # ...otherwise throw away the child directory and loop
+ my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
+ done
+ my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
+
+ save_mkdir_p_IFS="$IFS"; IFS=':'
+ for my_dir in $my_dir_list; do
+ IFS="$save_mkdir_p_IFS"
+ # mkdir can fail with a `File exist' error if two processes
+ # try to create one of the directories concurrently. Don't
+ # stop in that case!
+ $MKDIR "$my_dir" 2>/dev/null || :
+ done
+ IFS="$save_mkdir_p_IFS"
+
+ # Bail out if we (or some other process) failed to create a directory.
+ test -d "$my_directory_path" || \
+ func_fatal_error "Failed to create \`$1'"
+ fi
+}
+
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible. If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+ my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+ if test "$opt_dry_run" = ":"; then
+ # Return a directory name, but don't create it in dry-run mode
+ my_tmpdir="${my_template}-$$"
+ else
+
+ # If mktemp works, use that first and foremost
+ my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+ if test ! -d "$my_tmpdir"; then
+ # Failing that, at least try and use $RANDOM to avoid a race
+ my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+ save_mktempdir_umask=`umask`
+ umask 0077
+ $MKDIR "$my_tmpdir"
+ umask $save_mktempdir_umask
+ fi
+
+ # If we're not in dry-run mode, bomb out on failure
+ test -d "$my_tmpdir" || \
+ func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
+ fi
+
+ $ECHO "X$my_tmpdir" | $Xsed
+}
+
+
+# func_quote_for_eval arg
+# Aesthetically quote ARG to be evaled later.
+# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
+# is double-quoted, suitable for a subsequent eval, whereas
+# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
+# which are still active within double quotes backslashified.
+func_quote_for_eval ()
+{
+ case $1 in
+ *[\\\`\"\$]*)
+ func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
+ *)
+ func_quote_for_eval_unquoted_result="$1" ;;
+ esac
+
+ case $func_quote_for_eval_unquoted_result in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting, command substitution and and variable
+ # expansion for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
+ ;;
+ *)
+ func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
+ esac
+}
+
+
+# func_quote_for_expand arg
+# Aesthetically quote ARG to be evaled later; same as above,
+# but do not quote variable references.
+func_quote_for_expand ()
+{
+ case $1 in
+ *[\\\`\"]*)
+ my_arg=`$ECHO "X$1" | $Xsed \
+ -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
+ *)
+ my_arg="$1" ;;
+ esac
+
+ case $my_arg in
+ # Double-quote args containing shell metacharacters to delay
+ # word splitting and command substitution for a subsequent eval.
+ # Many Bourne shells cannot handle close brackets correctly
+ # in scan sets, so we specify it separately.
+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+ my_arg="\"$my_arg\""
+ ;;
+ esac
+
+ func_quote_for_expand_result="$my_arg"
+}
+
+
+# func_show_eval cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it.
+func_show_eval ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$my_cmd"
+ my_status=$?
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+
+# func_show_eval_locale cmd [fail_exp]
+# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
+# is given, then evaluate it. Use the saved locale for evaluation.
+func_show_eval_locale ()
+{
+ my_cmd="$1"
+ my_fail_exp="${2-:}"
+
+ ${opt_silent-false} || {
+ func_quote_for_expand "$my_cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+
+ if ${opt_dry_run-false}; then :; else
+ eval "$lt_user_locale
+ $my_cmd"
+ my_status=$?
+ eval "$lt_safe_locale"
+ if test "$my_status" -eq 0; then :; else
+ eval "(exit $my_status); $my_fail_exp"
+ fi
+ fi
+}
+
+
+
+
+
+# func_version
+# Echo version message to standard output and exit.
+func_version ()
+{
+ $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
+ s/^# //
+ s/^# *$//
+ s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
+ p
+ }' < "$progpath"
+ exit $?
+}
+
+# func_usage
+# Echo short help message to standard output and exit.
+func_usage ()
+{
+ $SED -n '/^# Usage:/,/# -h/ {
+ s/^# //
+ s/^# *$//
+ s/\$progname/'$progname'/
+ p
+ }' < "$progpath"
+ $ECHO
+ $ECHO "run \`$progname --help | more' for full usage"
+ exit $?
+}
+
+# func_help
+# Echo long help message to standard output and exit.
+func_help ()
+{
+ $SED -n '/^# Usage:/,/# Report bugs to/ {
+ s/^# //
+ s/^# *$//
+ s*\$progname*'$progname'*
+ s*\$host*'"$host"'*
+ s*\$SHELL*'"$SHELL"'*
+ s*\$LTCC*'"$LTCC"'*
+ s*\$LTCFLAGS*'"$LTCFLAGS"'*
+ s*\$LD*'"$LD"'*
+ s/\$with_gnu_ld/'"$with_gnu_ld"'/
+ s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
+ s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
+ p
+ }' < "$progpath"
+ exit $?
+}
+
+# func_missing_arg argname
+# Echo program name prefixed message to standard error and set global
+# exit_cmd.
+func_missing_arg ()
+{
+ func_error "missing argument for $1"
+ exit_cmd=exit
+}
+
+exit_cmd=:
+
+
+
+
+
+# Check that we have a working $ECHO.
+if test "X$1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X$1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
+ # Yippee, $ECHO works!
+ :
+else
+ # Restart under the correct shell, and then maybe $ECHO will work.
+ exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<EOF
+$*
+EOF
+ exit $EXIT_SUCCESS
+fi
+
+magic="%%%MAGIC variable%%%"
+magic_exe="%%%MAGIC EXE variable%%%"
+
+# Global variables.
+# $mode is unset
+nonopt=
+execute_dlfiles=
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+extracted_archives=
+extracted_serial=0
+
+opt_dry_run=false
+opt_duplicate_deps=false
+opt_silent=false
+opt_debug=:
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end. This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+# func_fatal_configuration arg...
+# Echo program name prefixed message to standard error, followed by
+# a configuration failure hint, and exit.
+func_fatal_configuration ()
+{
+ func_error ${1+"$@"}
+ func_error "See the $PACKAGE documentation for more information."
+ func_fatal_error "Fatal configuration error."
+}
+
+
+# func_config
+# Display the configuration for all the tags in this script.
+func_config ()
+{
+ re_begincf='^# ### BEGIN LIBTOOL'
+ re_endcf='^# ### END LIBTOOL'
+
+ # Default configuration.
+ $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
+
+ # Now print the configurations for the tags.
+ for tagname in $taglist; do
+ $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
+ done
+
+ exit $?
+}
+
+# func_features
+# Display the features supported by this script.
+func_features ()
+{
+ $ECHO "host: $host"
+ if test "$build_libtool_libs" = yes; then
+ $ECHO "enable shared libraries"
+ else
+ $ECHO "disable shared libraries"
+ fi
+ if test "$build_old_libs" = yes; then
+ $ECHO "enable static libraries"
+ else
+ $ECHO "disable static libraries"
+ fi
+
+ exit $?
+}
+
+# func_enable_tag tagname
+# Verify that TAGNAME is valid, and either flag an error and exit, or
+# enable the TAGNAME tag. We also add TAGNAME to the global $taglist
+# variable here.
+func_enable_tag ()
+{
+ # Global variable:
+ tagname="$1"
+
+ re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
+ re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
+ sed_extractcf="/$re_begincf/,/$re_endcf/p"
+
+ # Validate tagname.
+ case $tagname in
+ *[!-_A-Za-z0-9,/]*)
+ func_fatal_error "invalid tag name: $tagname"
+ ;;
+ esac
+
+ # Don't test for the "default" C tag, as we know it's
+ # there but not specially marked.
+ case $tagname in
+ CC) ;;
+ *)
+ if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
+ taglist="$taglist $tagname"
+
+ # Evaluate the configuration. Be careful to quote the path
+ # and the sed script, to avoid splitting on whitespace, but
+ # also don't use non-portable quotes within backquotes within
+ # quotes we have to do it in 2 steps:
+ extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
+ eval "$extractedcf"
+ else
+ func_error "ignoring unknown tag $tagname"
+ fi
+ ;;
+ esac
+}
+
+# Parse options once, thoroughly. This comes as soon as possible in
+# the script to make things like `libtool --version' happen quickly.
+{
+
+ # Shorthand for --mode=foo, only valid as the first argument
+ case $1 in
+ clean|clea|cle|cl)
+ shift; set dummy --mode clean ${1+"$@"}; shift
+ ;;
+ compile|compil|compi|comp|com|co|c)
+ shift; set dummy --mode compile ${1+"$@"}; shift
+ ;;
+ execute|execut|execu|exec|exe|ex|e)
+ shift; set dummy --mode execute ${1+"$@"}; shift
+ ;;
+ finish|finis|fini|fin|fi|f)
+ shift; set dummy --mode finish ${1+"$@"}; shift
+ ;;
+ install|instal|insta|inst|ins|in|i)
+ shift; set dummy --mode install ${1+"$@"}; shift
+ ;;
+ link|lin|li|l)
+ shift; set dummy --mode link ${1+"$@"}; shift
+ ;;
+ uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
+ shift; set dummy --mode uninstall ${1+"$@"}; shift
+ ;;
+ esac
+
+ # Parse non-mode specific arguments:
+ while test "$#" -gt 0; do
+ opt="$1"
+ shift
+
+ case $opt in
+ --config) func_config ;;
+
+ --debug) preserve_args="$preserve_args $opt"
+ func_echo "enabling shell trace mode"
+ opt_debug='set -x'
+ $opt_debug
+ ;;
+
+ -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
+ execute_dlfiles="$execute_dlfiles $1"
+ shift
+ ;;
+
+ --dry-run | -n) opt_dry_run=: ;;
+ --features) func_features ;;
+ --finish) mode="finish" ;;
+
+ --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
+ case $1 in
+ # Valid mode arguments:
+ clean) ;;
+ compile) ;;
+ execute) ;;
+ finish) ;;
+ install) ;;
+ link) ;;
+ relink) ;;
+ uninstall) ;;
+
+ # Catch anything else as an error
+ *) func_error "invalid argument for $opt"
+ exit_cmd=exit
+ break
+ ;;
+ esac
+
+ mode="$1"
+ shift
+ ;;
+
+ --preserve-dup-deps)
+ opt_duplicate_deps=: ;;
+
+ --quiet|--silent) preserve_args="$preserve_args $opt"
+ opt_silent=:
+ ;;
+
+ --verbose| -v) preserve_args="$preserve_args $opt"
+ opt_silent=false
+ ;;
+
+ --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
+ preserve_args="$preserve_args $opt $1"
+ func_enable_tag "$1" # tagname is set here
+ shift
+ ;;
+
+ # Separate optargs to long options:
+ -dlopen=*|--mode=*|--tag=*)
+ func_opt_split "$opt"
+ set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
+ shift
+ ;;
+
+ -\?|-h) func_usage ;;
+ --help) opt_help=: ;;
+ --version) func_version ;;
+
+ -*) func_fatal_help "unrecognized option \`$opt'" ;;
+
+ *) nonopt="$opt"
+ break
+ ;;
+ esac
+ done
+
+
+ case $host in
+ *cygwin* | *mingw* | *pw32* | *cegcc*)
+ # don't eliminate duplications in $postdeps and $predeps
+ opt_duplicate_compiler_generated_deps=:
+ ;;
+ *)
+ opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
+ ;;
+ esac
+
+ # Having warned about all mis-specified options, bail out if
+ # anything was wrong.
+ $exit_cmd $EXIT_FAILURE
+}
+
+# func_check_version_match
+# Ensure that we are using m4 macros, and libtool script from the same
+# release of libtool.
+func_check_version_match ()
+{
+ if test "$package_revision" != "$macro_revision"; then
+ if test "$VERSION" != "$macro_version"; then
+ if test -z "$macro_version"; then
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from an older release.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the
+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
+$progname: and run autoconf again.
+_LT_EOF
+ fi
+ else
+ cat >&2 <<_LT_EOF
+$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
+$progname: but the definition of this LT_INIT comes from revision $macro_revision.
+$progname: You should recreate aclocal.m4 with macros from revision $package_revision
+$progname: of $PACKAGE $VERSION and run autoconf again.
+_LT_EOF
+ fi
+
+ exit $EXIT_MISMATCH
+ fi
+}
+
+
+## ----------- ##
+## Main. ##
+## ----------- ##
+
+$opt_help || {
+ # Sanity checks first:
+ func_check_version_match
+
+ if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+ func_fatal_configuration "not configured to build any kind of library"
+ fi
+
+ test -z "$mode" && func_fatal_error "error: you must specify a MODE."
+
+
+ # Darwin sucks
+ eval std_shrext=\"$shrext_cmds\"
+
+
+ # Only execute mode is allowed to have -dlopen flags.
+ if test -n "$execute_dlfiles" && test "$mode" != execute; then
+ func_error "unrecognized option \`-dlopen'"
+ $ECHO "$help" 1>&2
+ exit $EXIT_FAILURE
+ fi
+
+ # Change the help message to a mode-specific one.
+ generic_help="$help"
+ help="Try \`$progname --help --mode=$mode' for more information."
+}
+
+
+# func_lalib_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_lalib_p ()
+{
+ test -f "$1" &&
+ $SED -e 4q "$1" 2>/dev/null \
+ | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
+}
+
+# func_lalib_unsafe_p file
+# True iff FILE is a libtool `.la' library or `.lo' object file.
+# This function implements the same check as func_lalib_p without
+# resorting to external programs. To this end, it redirects stdin and
+# closes it afterwards, without saving the original file descriptor.
+# As a safety measure, use it only where a negative result would be
+# fatal anyway. Works if `file' does not exist.
+func_lalib_unsafe_p ()
+{
+ lalib_p=no
+ if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
+ for lalib_p_l in 1 2 3 4
+ do
+ read lalib_p_line
+ case "$lalib_p_line" in
+ \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
+ esac
+ done
+ exec 0<&5 5<&-
+ fi
+ test "$lalib_p" = yes
+}
+
+# func_ltwrapper_script_p file
+# True iff FILE is a libtool wrapper script
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_script_p ()
+{
+ func_lalib_p "$1"
+}
+
+# func_ltwrapper_executable_p file
+# True iff FILE is a libtool wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_executable_p ()
+{
+ func_ltwrapper_exec_suffix=
+ case $1 in
+ *.exe) ;;
+ *) func_ltwrapper_exec_suffix=.exe ;;
+ esac
+ $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
+}
+
+# func_ltwrapper_scriptname file
+# Assumes file is an ltwrapper_executable
+# uses $file to determine the appropriate filename for a
+# temporary ltwrapper_script.
+func_ltwrapper_scriptname ()
+{
+ func_ltwrapper_scriptname_result=""
+ if func_ltwrapper_executable_p "$1"; then
+ func_dirname_and_basename "$1" "" "."
+ func_stripname '' '.exe' "$func_basename_result"
+ func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
+ fi
+}
+
+# func_ltwrapper_p file
+# True iff FILE is a libtool wrapper script or wrapper executable
+# This function is only a basic sanity check; it will hardly flush out
+# determined imposters.
+func_ltwrapper_p ()
+{
+ func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
+}
+
+
+# func_execute_cmds commands fail_cmd
+# Execute tilde-delimited COMMANDS.
+# If FAIL_CMD is given, eval that upon failure.
+# FAIL_CMD may read-access the current command in variable CMD!
+func_execute_cmds ()
+{
+ $opt_debug
+ save_ifs=$IFS; IFS='~'
+ for cmd in $1; do
+ IFS=$save_ifs
+ eval cmd=\"$cmd\"
+ func_show_eval "$cmd" "${2-:}"
+ done
+ IFS=$save_ifs
+}
+
+
+# func_source file
+# Source FILE, adding directory component if necessary.
+# Note that it is not necessary on cygwin/mingw to append a dot to
+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe
+# behavior happens only for exec(3), not for open(2)! Also, sourcing
+# `FILE.' does not work on cygwin managed mounts.
+func_source ()
+{
+ $opt_debug
+ case $1 in
+ */* | *\\*) . "$1" ;;
+ *) . "./$1" ;;
+ esac
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+ $opt_debug
+ if test -n "$available_tags" && test -z "$tagname"; then
+ CC_quoted=
+ for arg in $CC; do
+ func_quote_for_eval "$arg"
+ CC_quoted="$CC_quoted $func_quote_for_eval_result"
+ done
+ case $@ in
+ # Blanks in the command may have been stripped by the calling shell,
+ # but not from the CC environment variable when configure was run.
+ " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
+ # Blanks at the start of $base_compile will cause this to fail
+ # if we don't check for them as well.
+ *)
+ for z in $available_tags; do
+ if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+ # Evaluate the configuration.
+ eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+ CC_quoted=
+ for arg in $CC; do
+ # Double-quote args containing other shell metacharacters.
+ func_quote_for_eval "$arg"
+ CC_quoted="$CC_quoted $func_quote_for_eval_result"
+ done
+ case "$@ " in
+ " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
+ # The compiler in the base compile command matches
+ # the one in the tagged configuration.
+ # Assume this is the tagged configuration we want.
+ tagname=$z
+ break
+ ;;
+ esac
+ fi
+ done
+ # If $tagname still isn't set, then no tagged configuration
+ # was found and let the user know that the "--tag" command
+ # line option must be used.
+ if test -z "$tagname"; then
+ func_echo "unable to infer tagged configuration"
+ func_fatal_error "specify a tag with \`--tag'"
+# else
+# func_verbose "using $tagname tagged configuration"
+ fi
+ ;;
+ esac
+ fi
+}
+
+
+
+# func_write_libtool_object output_name pic_name nonpic_name
+# Create a libtool object file (analogous to a ".la" file),
+# but don't create it if we're doing a dry run.
+func_write_libtool_object ()
+{
+ write_libobj=${1}
+ if test "$build_libtool_libs" = yes; then
+ write_lobj=\'${2}\'
+ else
+ write_lobj=none
+ fi
+
+ if test "$build_old_libs" = yes; then
+ write_oldobj=\'${3}\'
+ else
+ write_oldobj=none
+ fi
+
+ $opt_dry_run || {
+ cat >${write_libobj}T <<EOF
+# $write_libobj - a libtool object file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+pic_object=$write_lobj
+
+# Name of the non-PIC object
+non_pic_object=$write_oldobj
+
+EOF
+ $MV "${write_libobj}T" "${write_libobj}"
+ }
+}
+
+# func_mode_compile arg...
+func_mode_compile ()
+{
+ $opt_debug
+ # Get the compilation command and the source file.
+ base_compile=
+ srcfile="$nonopt" # always keep a non-empty value in "srcfile"
+ suppress_opt=yes
+ suppress_output=
+ arg_mode=normal
+ libobj=
+ later=
+ pie_flag=
+
+ for arg
+ do
+ case $arg_mode in
+ arg )
+ # do not "continue". Instead, add this to base_compile
+ lastarg="$arg"
+ arg_mode=normal
+ ;;
+
+ target )
+ libobj="$arg"
+ arg_mode=normal
+ continue
+ ;;
+
+ normal )
+ # Accept any command-line options.
+ case $arg in
+ -o)
+ test -n "$libobj" && \
+ func_fatal_error "you cannot specify \`-o' more than once"
+ arg_mode=target
+ continue
+ ;;
+
+ -pie | -fpie | -fPIE)
+ pie_flag="$pie_flag $arg"
+ continue
+ ;;
+
+ -shared | -static | -prefer-pic | -prefer-non-pic)
+ later="$later $arg"
+ continue
+ ;;
+
+ -no-suppress)
+ suppress_opt=no
+ continue
+ ;;
+
+ -Xcompiler)
+ arg_mode=arg # the next one goes into the "base_compile" arg list
+ continue # The current "srcfile" will either be retained or
+ ;; # replaced later. I would guess that would be a bug.
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ lastarg=
+ save_ifs="$IFS"; IFS=','
+ for arg in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$arg"
+ lastarg="$lastarg $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$lastarg"
+ lastarg=$func_stripname_result
+
+ # Add the arguments to base_compile.
+ base_compile="$base_compile $lastarg"
+ continue
+ ;;
+
+ *)
+ # Accept the current argument as the source file.
+ # The previous "srcfile" becomes the current argument.
+ #
+ lastarg="$srcfile"
+ srcfile="$arg"
+ ;;
+ esac # case $arg
+ ;;
+ esac # case $arg_mode
+
+ # Aesthetically quote the previous argument.
+ func_quote_for_eval "$lastarg"
+ base_compile="$base_compile $func_quote_for_eval_result"
+ done # for arg
+
+ case $arg_mode in
+ arg)
+ func_fatal_error "you must specify an argument for -Xcompile"
+ ;;
+ target)
+ func_fatal_error "you must specify a target with \`-o'"
+ ;;
+ *)
+ # Get the name of the library object.
+ test -z "$libobj" && {
+ func_basename "$srcfile"
+ libobj="$func_basename_result"
+ }
+ ;;
+ esac
+
+ # Recognize several different file suffixes.
+ # If the user specifies -o file.o, it is replaced with file.lo
+ case $libobj in
+ *.[cCFSifmso] | \
+ *.ada | *.adb | *.ads | *.asm | \
+ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
+ *.[fF][09]? | *.for | *.java | *.obj | *.sx)
+ func_xform "$libobj"
+ libobj=$func_xform_result
+ ;;
+ esac
+
+ case $libobj in
+ *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
+ *)
+ func_fatal_error "cannot determine name of library object from \`$libobj'"
+ ;;
+ esac
+
+ func_infer_tag $base_compile
+
+ for arg in $later; do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ continue
+ ;;
+
+ -static)
+ build_libtool_libs=no
+ build_old_libs=yes
+ continue
+ ;;
+
+ -prefer-pic)
+ pic_mode=yes
+ continue
+ ;;
+
+ -prefer-non-pic)
+ pic_mode=no
+ continue
+ ;;
+ esac
+ done
+
+ func_quote_for_eval "$libobj"
+ test "X$libobj" != "X$func_quote_for_eval_result" \
+ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
+ && func_warning "libobj name \`$libobj' may not contain shell special characters."
+ func_dirname_and_basename "$obj" "/" ""
+ objname="$func_basename_result"
+ xdir="$func_dirname_result"
+ lobj=${xdir}$objdir/$objname
+
+ test -z "$base_compile" && \
+ func_fatal_help "you must specify a compilation command"
+
+ # Delete any leftover library objects.
+ if test "$build_old_libs" = yes; then
+ removelist="$obj $lobj $libobj ${libobj}T"
+ else
+ removelist="$lobj $libobj ${libobj}T"
+ fi
+
+ # On Cygwin there's no "real" PIC flag so we must build both object types
+ case $host_os in
+ cygwin* | mingw* | pw32* | os2* | cegcc*)
+ pic_mode=default
+ ;;
+ esac
+ if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+ # non-PIC code in shared libraries is not supported
+ pic_mode=default
+ fi
+
+ # Calculate the filename of the output object if compiler does
+ # not support -o with -c
+ if test "$compiler_c_o" = no; then
+ output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+ lockfile="$output_obj.lock"
+ else
+ output_obj=
+ need_locks=no
+ lockfile=
+ fi
+
+ # Lock this critical section if it is needed
+ # We use this script file to make the link, it avoids creating a new file
+ if test "$need_locks" = yes; then
+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
+ func_echo "Waiting for $lockfile to be removed"
+ sleep 2
+ done
+ elif test "$need_locks" = warn; then
+ if test -f "$lockfile"; then
+ $ECHO "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+ removelist="$removelist $output_obj"
+ $ECHO "$srcfile" > "$lockfile"
+ fi
+
+ $opt_dry_run || $RM $removelist
+ removelist="$removelist $lockfile"
+ trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
+
+ if test -n "$fix_srcfile_path"; then
+ eval srcfile=\"$fix_srcfile_path\"
+ fi
+ func_quote_for_eval "$srcfile"
+ qsrcfile=$func_quote_for_eval_result
+
+ # Only build a PIC object if we are building libtool libraries.
+ if test "$build_libtool_libs" = yes; then
+ # Without this assignment, base_compile gets emptied.
+ fbsd_hideous_sh_bug=$base_compile
+
+ if test "$pic_mode" != no; then
+ command="$base_compile $qsrcfile $pic_flag"
+ else
+ # Don't build PIC code
+ command="$base_compile $qsrcfile"
+ fi
+
+ func_mkdir_p "$xdir$objdir"
+
+ if test -z "$output_obj"; then
+ # Place PIC objects in $objdir
+ command="$command -o $lobj"
+ fi
+
+ func_show_eval_locale "$command" \
+ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed, then go on to compile the next one
+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+ func_show_eval '$MV "$output_obj" "$lobj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+
+ # Allow error messages only from the first compilation.
+ if test "$suppress_opt" = yes; then
+ suppress_output=' >/dev/null 2>&1'
+ fi
+ fi
+
+ # Only build a position-dependent object if we build old libraries.
+ if test "$build_old_libs" = yes; then
+ if test "$pic_mode" != yes; then
+ # Don't build PIC code
+ command="$base_compile $qsrcfile$pie_flag"
+ else
+ command="$base_compile $qsrcfile $pic_flag"
+ fi
+ if test "$compiler_c_o" = yes; then
+ command="$command -o $obj"
+ fi
+
+ # Suppress compiler output if we already did a PIC compilation.
+ command="$command$suppress_output"
+ func_show_eval_locale "$command" \
+ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
+
+ if test "$need_locks" = warn &&
+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+ $ECHO "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together. If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+ $opt_dry_run || $RM $removelist
+ exit $EXIT_FAILURE
+ fi
+
+ # Just move the object if needed
+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+ func_show_eval '$MV "$output_obj" "$obj"' \
+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
+ fi
+ fi
+
+ $opt_dry_run || {
+ func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
+
+ # Unlock the critical section if it was locked
+ if test "$need_locks" != no; then
+ removelist=$lockfile
+ $RM "$lockfile"
+ fi
+ }
+
+ exit $EXIT_SUCCESS
+}
+
+$opt_help || {
+test "$mode" = compile && func_mode_compile ${1+"$@"}
+}
+
+func_mode_help ()
+{
+ # We need to display help for each of the modes.
+ case $mode in
+ "")
+ # Generic help is extracted from the usage comments
+ # at the start of this file.
+ func_help
+ ;;
+
+ clean)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ compile)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+ -o OUTPUT-FILE set the output file name to OUTPUT-FILE
+ -no-suppress do not suppress compiler output for multiple passes
+ -prefer-pic try to building PIC objects only
+ -prefer-non-pic try to building non-PIC objects only
+ -shared do not build a \`.o' file suitable for static linking
+ -static only build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+ ;;
+
+ execute)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+ -dlopen FILE add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+ ;;
+
+ finish)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges. Use
+the \`--dry-run' option if you just want to see what would be executed."
+ ;;
+
+ install)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command. The first component should be
+either the \`install' or \`cp' program.
+
+The following components of INSTALL-COMMAND are treated specially:
+
+ -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+ ;;
+
+ link)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+ -all-static do not do any dynamic linking at all
+ -avoid-version do not add a version suffix if possible
+ -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+ -export-symbols SYMFILE
+ try to export only the symbols listed in SYMFILE
+ -export-symbols-regex REGEX
+ try to export only the symbols matching REGEX
+ -LLIBDIR search LIBDIR for required installed libraries
+ -lNAME OUTPUT-FILE requires the installed library libNAME
+ -module build a library that can dlopened
+ -no-fast-install disable the fast-install mode
+ -no-install link a not-installable executable
+ -no-undefined declare that a library does not refer to external symbols
+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
+ -objectlist FILE Use a list of object files found in FILE to specify objects
+ -precious-files-regex REGEX
+ don't remove output files matching REGEX
+ -release RELEASE specify package release information
+ -rpath LIBDIR the created library will eventually be installed in LIBDIR
+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
+ -shared only do dynamic linking of libtool libraries
+ -shrext SUFFIX override the standard shared library file extension
+ -static do not do any dynamic linking of uninstalled libtool libraries
+ -static-libtool-libs
+ do not do any dynamic linking of libtool libraries
+ -version-info CURRENT[:REVISION[:AGE]]
+ specify library version info [each variable defaults to 0]
+ -weak LIBNAME declare that the target provides the LIBNAME interface
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename. Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+ ;;
+
+ uninstall)
+ $ECHO \
+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+ ;;
+
+ *)
+ func_fatal_help "invalid operation mode \`$mode'"
+ ;;
+ esac
+
+ $ECHO
+ $ECHO "Try \`$progname --help' for more information about other modes."
+
+ exit $?
+}
+
+ # Now that we've collected a possible --mode arg, show help if necessary
+ $opt_help && func_mode_help
+
+
+# func_mode_execute arg...
+func_mode_execute ()
+{
+ $opt_debug
+ # The first argument is the command name.
+ cmd="$nonopt"
+ test -z "$cmd" && \
+ func_fatal_help "you must specify a COMMAND"
+
+ # Handle -dlopen flags immediately.
+ for file in $execute_dlfiles; do
+ test -f "$file" \
+ || func_fatal_help "\`$file' is not a file"
+
+ dir=
+ case $file in
+ *.la)
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$lib' is not a valid libtool archive"
+
+ # Read the libtool library.
+ dlname=
+ library_names=
+ func_source "$file"
+
+ # Skip this library if it cannot be dlopened.
+ if test -z "$dlname"; then
+ # Warn if it was a shared library.
+ test -n "$library_names" && \
+ func_warning "\`$file' was not linked with \`-export-dynamic'"
+ continue
+ fi
+
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+
+ if test -f "$dir/$objdir/$dlname"; then
+ dir="$dir/$objdir"
+ else
+ if test ! -f "$dir/$dlname"; then
+ func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
+ fi
+ fi
+ ;;
+
+ *.lo)
+ # Just add the directory containing the .lo file.
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ ;;
+
+ *)
+ func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
+ continue
+ ;;
+ esac
+
+ # Get the absolute pathname.
+ absdir=`cd "$dir" && pwd`
+ test -n "$absdir" && dir="$absdir"
+
+ # Now add the directory to shlibpath_var.
+ if eval "test -z \"\$$shlibpath_var\""; then
+ eval "$shlibpath_var=\"\$dir\""
+ else
+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+ fi
+ done
+
+ # This variable tells wrapper scripts just to set shlibpath_var
+ # rather than running their programs.
+ libtool_execute_magic="$magic"
+
+ # Check if any of the arguments is a wrapper script.
+ args=
+ for file
+ do
+ case $file in
+ -*) ;;
+ *)
+ # Do a test to see if this is really a libtool program.
+ if func_ltwrapper_script_p "$file"; then
+ func_source "$file"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ elif func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ func_source "$func_ltwrapper_scriptname_result"
+ # Transform arg to wrapped name.
+ file="$progdir/$program"
+ fi
+ ;;
+ esac
+ # Quote arguments (to preserve shell metacharacters).
+ func_quote_for_eval "$file"
+ args="$args $func_quote_for_eval_result"
+ done
+
+ if test "X$opt_dry_run" = Xfalse; then
+ if test -n "$shlibpath_var"; then
+ # Export the shlibpath_var.
+ eval "export $shlibpath_var"
+ fi
+
+ # Restore saved environment variables
+ for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
+ do
+ eval "if test \"\${save_$lt_var+set}\" = set; then
+ $lt_var=\$save_$lt_var; export $lt_var
+ else
+ $lt_unset $lt_var
+ fi"
+ done
+
+ # Now prepare to actually exec the command.
+ exec_cmd="\$cmd$args"
+ else
+ # Display what would be done.
+ if test -n "$shlibpath_var"; then
+ eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
+ $ECHO "export $shlibpath_var"
+ fi
+ $ECHO "$cmd$args"
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$mode" = execute && func_mode_execute ${1+"$@"}
+
+
+# func_mode_finish arg...
+func_mode_finish ()
+{
+ $opt_debug
+ libdirs="$nonopt"
+ admincmds=
+
+ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+ for dir
+ do
+ libdirs="$libdirs $dir"
+ done
+
+ for libdir in $libdirs; do
+ if test -n "$finish_cmds"; then
+ # Do each command in the finish commands.
+ func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
+'"$cmd"'"'
+ fi
+ if test -n "$finish_eval"; then
+ # Do the single finish_eval.
+ eval cmds=\"$finish_eval\"
+ $opt_dry_run || eval "$cmds" || admincmds="$admincmds
+ $cmds"
+ fi
+ done
+ fi
+
+ # Exit here if they wanted silent mode.
+ $opt_silent && exit $EXIT_SUCCESS
+
+ $ECHO "X----------------------------------------------------------------------" | $Xsed
+ $ECHO "Libraries have been installed in:"
+ for libdir in $libdirs; do
+ $ECHO " $libdir"
+ done
+ $ECHO
+ $ECHO "If you ever happen to want to link against installed libraries"
+ $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
+ $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
+ $ECHO "flag during linking and do at least one of the following:"
+ if test -n "$shlibpath_var"; then
+ $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
+ $ECHO " during execution"
+ fi
+ if test -n "$runpath_var"; then
+ $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
+ $ECHO " during linking"
+ fi
+ if test -n "$hardcode_libdir_flag_spec"; then
+ libdir=LIBDIR
+ eval flag=\"$hardcode_libdir_flag_spec\"
+
+ $ECHO " - use the \`$flag' linker flag"
+ fi
+ if test -n "$admincmds"; then
+ $ECHO " - have your system administrator run these commands:$admincmds"
+ fi
+ if test -f /etc/ld.so.conf; then
+ $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+ fi
+ $ECHO
+
+ $ECHO "See any operating system documentation about shared libraries for"
+ case $host in
+ solaris2.[6789]|solaris2.1[0-9])
+ $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
+ $ECHO "pages."
+ ;;
+ *)
+ $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
+ ;;
+ esac
+ $ECHO "X----------------------------------------------------------------------" | $Xsed
+ exit $EXIT_SUCCESS
+}
+
+test "$mode" = finish && func_mode_finish ${1+"$@"}
+
+
+# func_mode_install arg...
+func_mode_install ()
+{
+ $opt_debug
+ # There may be an optional sh(1) argument at the beginning of
+ # install_prog (especially on Windows NT).
+ if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+ # Allow the use of GNU shtool's install command.
+ $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
+ # Aesthetically quote it.
+ func_quote_for_eval "$nonopt"
+ install_prog="$func_quote_for_eval_result "
+ arg=$1
+ shift
+ else
+ install_prog=
+ arg=$nonopt
+ fi
+
+ # The real first argument should be the name of the installation program.
+ # Aesthetically quote it.
+ func_quote_for_eval "$arg"
+ install_prog="$install_prog$func_quote_for_eval_result"
+
+ # We need to accept at least all the BSD install flags.
+ dest=
+ files=
+ opts=
+ prev=
+ install_type=
+ isdir=no
+ stripme=
+ for arg
+ do
+ if test -n "$dest"; then
+ files="$files $dest"
+ dest=$arg
+ continue
+ fi
+
+ case $arg in
+ -d) isdir=yes ;;
+ -f)
+ case " $install_prog " in
+ *[\\\ /]cp\ *) ;;
+ *) prev=$arg ;;
+ esac
+ ;;
+ -g | -m | -o)
+ prev=$arg
+ ;;
+ -s)
+ stripme=" -s"
+ continue
+ ;;
+ -*)
+ ;;
+ *)
+ # If the previous option needed an argument, then skip it.
+ if test -n "$prev"; then
+ prev=
+ else
+ dest=$arg
+ continue
+ fi
+ ;;
+ esac
+
+ # Aesthetically quote the argument.
+ func_quote_for_eval "$arg"
+ install_prog="$install_prog $func_quote_for_eval_result"
+ done
+
+ test -z "$install_prog" && \
+ func_fatal_help "you must specify an install program"
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prev' option requires an argument"
+
+ if test -z "$files"; then
+ if test -z "$dest"; then
+ func_fatal_help "no file or destination specified"
+ else
+ func_fatal_help "you must specify a destination"
+ fi
+ fi
+
+ # Strip any trailing slash from the destination.
+ func_stripname '' '/' "$dest"
+ dest=$func_stripname_result
+
+ # Check to see that the destination is a directory.
+ test -d "$dest" && isdir=yes
+ if test "$isdir" = yes; then
+ destdir="$dest"
+ destname=
+ else
+ func_dirname_and_basename "$dest" "" "."
+ destdir="$func_dirname_result"
+ destname="$func_basename_result"
+
+ # Not a directory, so check to see that there is only one file specified.
+ set dummy $files; shift
+ test "$#" -gt 1 && \
+ func_fatal_help "\`$dest' is not a directory"
+ fi
+ case $destdir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ for file in $files; do
+ case $file in
+ *.lo) ;;
+ *)
+ func_fatal_help "\`$destdir' must be an absolute directory name"
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ staticlibs=
+ future_libdirs=
+ current_libdirs=
+ for file in $files; do
+
+ # Do each installation.
+ case $file in
+ *.$libext)
+ # Do the static libraries later.
+ staticlibs="$staticlibs $file"
+ ;;
+
+ *.la)
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$file" \
+ || func_fatal_help "\`$file' is not a valid libtool archive"
+
+ library_names=
+ old_library=
+ relink_command=
+ func_source "$file"
+
+ # Add the libdir to current_libdirs if it is the destination.
+ if test "X$destdir" = "X$libdir"; then
+ case "$current_libdirs " in
+ *" $libdir "*) ;;
+ *) current_libdirs="$current_libdirs $libdir" ;;
+ esac
+ else
+ # Note the libdir as a future libdir.
+ case "$future_libdirs " in
+ *" $libdir "*) ;;
+ *) future_libdirs="$future_libdirs $libdir" ;;
+ esac
+ fi
+
+ func_dirname "$file" "/" ""
+ dir="$func_dirname_result"
+ dir="$dir$objdir"
+
+ if test -n "$relink_command"; then
+ # Determine the prefix the user has applied to our future dir.
+ inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
+
+ # Don't allow the user to place us outside of our expected
+ # location b/c this prevents finding dependent libraries that
+ # are installed to the same prefix.
+ # At present, this check doesn't affect windows .dll's that
+ # are installed into $libdir/../bin (currently, that works fine)
+ # but it's something to keep an eye on.
+ test "$inst_prefix_dir" = "$destdir" && \
+ func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
+
+ if test -n "$inst_prefix_dir"; then
+ # Stick the inst_prefix_dir data into the link command.
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+ else
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
+ fi
+
+ func_warning "relinking \`$file'"
+ func_show_eval "$relink_command" \
+ 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
+ fi
+
+ # See the names of the shared library.
+ set dummy $library_names; shift
+ if test -n "$1"; then
+ realname="$1"
+ shift
+
+ srcname="$realname"
+ test -n "$relink_command" && srcname="$realname"T
+
+ # Install the shared library and build the symlinks.
+ func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
+ 'exit $?'
+ tstripme="$stripme"
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ case $realname in
+ *.dll.a)
+ tstripme=""
+ ;;
+ esac
+ ;;
+ esac
+ if test -n "$tstripme" && test -n "$striplib"; then
+ func_show_eval "$striplib $destdir/$realname" 'exit $?'
+ fi
+
+ if test "$#" -gt 0; then
+ # Delete the old symlinks, and create new ones.
+ # Try `ln -sf' first, because the `ln' binary might depend on
+ # the symlink we replace! Solaris /bin/ln does not understand -f,
+ # so we also need to try rm && ln -s.
+ for linkname
+ do
+ test "$linkname" != "$realname" \
+ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
+ done
+ fi
+
+ # Do each command in the postinstall commands.
+ lib="$destdir/$realname"
+ func_execute_cmds "$postinstall_cmds" 'exit $?'
+ fi
+
+ # Install the pseudo-library for information purposes.
+ func_basename "$file"
+ name="$func_basename_result"
+ instname="$dir/$name"i
+ func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
+
+ # Maybe install the static library, too.
+ test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+ ;;
+
+ *.lo)
+ # Install (i.e. copy) a libtool object.
+
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # Deduce the name of the destination old-style object file.
+ case $destfile in
+ *.lo)
+ func_lo2o "$destfile"
+ staticdest=$func_lo2o_result
+ ;;
+ *.$objext)
+ staticdest="$destfile"
+ destfile=
+ ;;
+ *)
+ func_fatal_help "cannot copy a libtool object to \`$destfile'"
+ ;;
+ esac
+
+ # Install the libtool object if requested.
+ test -n "$destfile" && \
+ func_show_eval "$install_prog $file $destfile" 'exit $?'
+
+ # Install the old object if enabled.
+ if test "$build_old_libs" = yes; then
+ # Deduce the name of the old-style object file.
+ func_lo2o "$file"
+ staticobj=$func_lo2o_result
+ func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
+ fi
+ exit $EXIT_SUCCESS
+ ;;
+
+ *)
+ # Figure out destination file name, if it wasn't already specified.
+ if test -n "$destname"; then
+ destfile="$destdir/$destname"
+ else
+ func_basename "$file"
+ destfile="$func_basename_result"
+ destfile="$destdir/$destfile"
+ fi
+
+ # If the file is missing, and there is a .exe on the end, strip it
+ # because it is most likely a libtool script we actually want to
+ # install
+ stripped_ext=""
+ case $file in
+ *.exe)
+ if test ! -f "$file"; then
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ stripped_ext=".exe"
+ fi
+ ;;
+ esac
+
+ # Do a test to see if this is really a libtool program.
+ case $host in
+ *cygwin* | *mingw*)
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ wrapper=$func_ltwrapper_scriptname_result
+ else
+ func_stripname '' '.exe' "$file"
+ wrapper=$func_stripname_result
+ fi
+ ;;
+ *)
+ wrapper=$file
+ ;;
+ esac
+ if func_ltwrapper_script_p "$wrapper"; then
+ notinst_deplibs=
+ relink_command=
+
+ func_source "$wrapper"
+
+ # Check the variables that should have been set.
+ test -z "$generated_by_libtool_version" && \
+ func_fatal_error "invalid libtool wrapper script \`$wrapper'"
+
+ finalize=yes
+ for lib in $notinst_deplibs; do
+ # Check to see that each library is installed.
+ libdir=
+ if test -f "$lib"; then
+ func_source "$lib"
+ fi
+ libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+ if test -n "$libdir" && test ! -f "$libfile"; then
+ func_warning "\`$lib' has not been installed in \`$libdir'"
+ finalize=no
+ fi
+ done
+
+ relink_command=
+ func_source "$wrapper"
+
+ outputname=
+ if test "$fast_install" = no && test -n "$relink_command"; then
+ $opt_dry_run || {
+ if test "$finalize" = yes; then
+ tmpdir=`func_mktempdir`
+ func_basename "$file$stripped_ext"
+ file="$func_basename_result"
+ outputname="$tmpdir/$file"
+ # Replace the output file specification.
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+ $opt_silent || {
+ func_quote_for_expand "$relink_command"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ if eval "$relink_command"; then :
+ else
+ func_error "error: relink \`$file' with the above command before installing it"
+ $opt_dry_run || ${RM}r "$tmpdir"
+ continue
+ fi
+ file="$outputname"
+ else
+ func_warning "cannot relink \`$file'"
+ fi
+ }
+ else
+ # Install the binary that we compiled earlier.
+ file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+ fi
+ fi
+
+ # remove .exe since cygwin /usr/bin/install will append another
+ # one anyway
+ case $install_prog,$host in
+ */usr/bin/install*,*cygwin*)
+ case $file:$destfile in
+ *.exe:*.exe)
+ # this is ok
+ ;;
+ *.exe:*)
+ destfile=$destfile.exe
+ ;;
+ *:*.exe)
+ func_stripname '' '.exe' "$destfile"
+ destfile=$func_stripname_result
+ ;;
+ esac
+ ;;
+ esac
+ func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
+ $opt_dry_run || if test -n "$outputname"; then
+ ${RM}r "$tmpdir"
+ fi
+ ;;
+ esac
+ done
+
+ for file in $staticlibs; do
+ func_basename "$file"
+ name="$func_basename_result"
+
+ # Set up the ranlib parameters.
+ oldlib="$destdir/$name"
+
+ func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
+
+ if test -n "$stripme" && test -n "$old_striplib"; then
+ func_show_eval "$old_striplib $oldlib" 'exit $?'
+ fi
+
+ # Do each command in the postinstall commands.
+ func_execute_cmds "$old_postinstall_cmds" 'exit $?'
+ done
+
+ test -n "$future_libdirs" && \
+ func_warning "remember to run \`$progname --finish$future_libdirs'"
+
+ if test -n "$current_libdirs"; then
+ # Maybe just do a dry run.
+ $opt_dry_run && current_libdirs=" -n$current_libdirs"
+ exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+ else
+ exit $EXIT_SUCCESS
+ fi
+}
+
+test "$mode" = install && func_mode_install ${1+"$@"}
+
+
+# func_generate_dlsyms outputname originator pic_p
+# Extract symbols from dlprefiles and create ${outputname}S.o with
+# a dlpreopen symbol table.
+func_generate_dlsyms ()
+{
+ $opt_debug
+ my_outputname="$1"
+ my_originator="$2"
+ my_pic_p="${3-no}"
+ my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
+ my_dlsyms=
+
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ if test -n "$NM" && test -n "$global_symbol_pipe"; then
+ my_dlsyms="${my_outputname}S.c"
+ else
+ func_error "not configured to extract global symbols from dlpreopened files"
+ fi
+ fi
+
+ if test -n "$my_dlsyms"; then
+ case $my_dlsyms in
+ "") ;;
+ *.c)
+ # Discover the nlist of each of the dlfiles.
+ nlist="$output_objdir/${my_outputname}.nm"
+
+ func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
+
+ # Parse the name list into a source file.
+ func_verbose "creating $output_objdir/$my_dlsyms"
+
+ $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
+/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
+/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* External symbol declarations for the compiler. */\
+"
+
+ if test "$dlself" = yes; then
+ func_verbose "generating symbol list for \`$output'"
+
+ $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
+
+ # Add our own program objects to the symbol list.
+ progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ for progfile in $progfiles; do
+ func_verbose "extracting global C symbols from \`$progfile'"
+ $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
+ done
+
+ if test -n "$exclude_expsyms"; then
+ $opt_dry_run || {
+ eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ if test -n "$export_symbols_regex"; then
+ $opt_dry_run || {
+ eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ }
+ fi
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ export_symbols="$output_objdir/$outputname.exp"
+ $opt_dry_run || {
+ $RM $export_symbols
+ eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ else
+ $opt_dry_run || {
+ eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+ eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+ eval '$MV "$nlist"T "$nlist"'
+ case $host in
+ *cygwin | *mingw* | *cegcc* )
+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+ eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+ ;;
+ esac
+ }
+ fi
+ fi
+
+ for dlprefile in $dlprefiles; do
+ func_verbose "extracting global C symbols from \`$dlprefile'"
+ func_basename "$dlprefile"
+ name="$func_basename_result"
+ $opt_dry_run || {
+ eval '$ECHO ": $name " >> "$nlist"'
+ eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
+ }
+ done
+
+ $opt_dry_run || {
+ # Make sure we have at least an empty file.
+ test -f "$nlist" || : > "$nlist"
+
+ if test -n "$exclude_expsyms"; then
+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+ $MV "$nlist"T "$nlist"
+ fi
+
+ # Try sorting and uniquifying the output.
+ if $GREP -v "^: " < "$nlist" |
+ if sort -k 3 </dev/null >/dev/null 2>&1; then
+ sort -k 3
+ else
+ sort +2
+ fi |
+ uniq > "$nlist"S; then
+ :
+ else
+ $GREP -v "^: " < "$nlist" > "$nlist"S
+ fi
+
+ if test -f "$nlist"S; then
+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
+ else
+ $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
+ fi
+
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+
+/* The mapping between symbol names and symbols. */
+typedef struct {
+ const char *name;
+ void *address;
+} lt_dlsymlist;
+"
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+/* DATA imports from DLLs on WIN32 con't be const, because
+ runtime relocations are performed -- see ld's documentation
+ on pseudo-relocs. */"
+ lt_dlsym_const= ;;
+ *osf5*)
+ echo >> "$output_objdir/$my_dlsyms" "\
+/* This system does not cope well with relocations in const data */"
+ lt_dlsym_const= ;;
+ *)
+ lt_dlsym_const=const ;;
+ esac
+
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+extern $lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[];
+$lt_dlsym_const lt_dlsymlist
+lt_${my_prefix}_LTX_preloaded_symbols[] =
+{\
+ { \"$my_originator\", (void *) 0 },"
+
+ case $need_lib_prefix in
+ no)
+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ *)
+ eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
+ ;;
+ esac
+ $ECHO >> "$output_objdir/$my_dlsyms" "\
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt_${my_prefix}_LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+ } # !$opt_dry_run
+
+ pic_flag_for_symtable=
+ case "$compile_command " in
+ *" -static "*) ;;
+ *)
+ case $host in
+ # compiling the symbol table file with pic_flag works around
+ # a FreeBSD bug that causes programs to crash when -lm is
+ # linked before any other PIC object. But we must not use
+ # pic_flag when linking with -static. The problem exists in
+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+ *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+ pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
+ *-*-hpux*)
+ pic_flag_for_symtable=" $pic_flag" ;;
+ *)
+ if test "X$my_pic_p" != Xno; then
+ pic_flag_for_symtable=" $pic_flag"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ symtab_cflags=
+ for arg in $LTCFLAGS; do
+ case $arg in
+ -pie | -fpie | -fPIE) ;;
+ *) symtab_cflags="$symtab_cflags $arg" ;;
+ esac
+ done
+
+ # Now compile the dynamic symbol file.
+ func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
+
+ # Clean up the generated files.
+ func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
+
+ # Transform the symbol file into the correct name.
+ symfileobj="$output_objdir/${my_outputname}S.$objext"
+ case $host in
+ *cygwin* | *mingw* | *cegcc* )
+ if test -f "$output_objdir/$my_outputname.def"; then
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
+ else
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ fi
+ ;;
+ *)
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
+ ;;
+ esac
+ ;;
+ *)
+ func_fatal_error "unknown suffix for \`$my_dlsyms'"
+ ;;
+ esac
+ else
+ # We keep going just in case the user didn't refer to
+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
+ # really was required.
+
+ # Nullify the symbol file.
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+ finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+ fi
+}
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+ $opt_debug
+ win32_libid_type="unknown"
+ win32_fileres=`file -L $1 2>/dev/null`
+ case $win32_fileres in
+ *ar\ archive\ import\ library*) # definitely import
+ win32_libid_type="x86 archive import"
+ ;;
+ *ar\ archive*) # could be an import, or static
+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
+ $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+ win32_nmres=`eval $NM -f posix -A $1 |
+ $SED -n -e '
+ 1,100{
+ / I /{
+ s,.*,import,
+ p
+ q
+ }
+ }'`
+ case $win32_nmres in
+ import*) win32_libid_type="x86 archive import";;
+ *) win32_libid_type="x86 archive static";;
+ esac
+ fi
+ ;;
+ *DLL*)
+ win32_libid_type="x86 DLL"
+ ;;
+ *executable*) # but shell scripts are "executable" too...
+ case $win32_fileres in
+ *MS\ Windows\ PE\ Intel*)
+ win32_libid_type="x86 DLL"
+ ;;
+ esac
+ ;;
+ esac
+ $ECHO "$win32_libid_type"
+}
+
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+ $opt_debug
+ f_ex_an_ar_dir="$1"; shift
+ f_ex_an_ar_oldlib="$1"
+ func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
+ if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
+ fi
+}
+
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+ $opt_debug
+ my_gentop="$1"; shift
+ my_oldlibs=${1+"$@"}
+ my_oldobjs=""
+ my_xlib=""
+ my_xabs=""
+ my_xdir=""
+
+ for my_xlib in $my_oldlibs; do
+ # Extract the objects.
+ case $my_xlib in
+ [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+ *) my_xabs=`pwd`"/$my_xlib" ;;
+ esac
+ func_basename "$my_xlib"
+ my_xlib="$func_basename_result"
+ my_xlib_u=$my_xlib
+ while :; do
+ case " $extracted_archives " in
+ *" $my_xlib_u "*)
+ func_arith $extracted_serial + 1
+ extracted_serial=$func_arith_result
+ my_xlib_u=lt$extracted_serial-$my_xlib ;;
+ *) break ;;
+ esac
+ done
+ extracted_archives="$extracted_archives $my_xlib_u"
+ my_xdir="$my_gentop/$my_xlib_u"
+
+ func_mkdir_p "$my_xdir"
+
+ case $host in
+ *-darwin*)
+ func_verbose "Extracting $my_xabs"
+ # Do not bother doing anything if just a dry run
+ $opt_dry_run || {
+ darwin_orig_dir=`pwd`
+ cd $my_xdir || exit $?
+ darwin_archive=$my_xabs
+ darwin_curdir=`pwd`
+ darwin_base_archive=`basename "$darwin_archive"`
+ darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
+ if test -n "$darwin_arches"; then
+ darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
+ darwin_arch=
+ func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
+ for darwin_arch in $darwin_arches ; do
+ func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+ cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+ func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+ cd "$darwin_curdir"
+ $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+ done # $darwin_arches
+ ## Okay now we've a bunch of thin objects, gotta fatten them up :)
+ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
+ darwin_file=
+ darwin_files=
+ for darwin_file in $darwin_filelist; do
+ darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+ $LIPO -create -output "$darwin_file" $darwin_files
+ done # $darwin_filelist
+ $RM -rf unfat-$$
+ cd "$darwin_orig_dir"
+ else
+ cd $darwin_orig_dir
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ fi # $darwin_arches
+ } # !$opt_dry_run
+ ;;
+ *)
+ func_extract_an_archive "$my_xdir" "$my_xabs"
+ ;;
+ esac
+ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+ done
+
+ func_extract_archives_result="$my_oldobjs"
+}
+
+
+
+# func_emit_wrapper_part1 [arg=no]
+#
+# Emit the first part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part1 ()
+{
+ func_emit_wrapper_part1_arg1=no
+ if test -n "$1" ; then
+ func_emit_wrapper_part1_arg1=$1
+ fi
+
+ $ECHO "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# Be Bourne compatible
+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
+ emulate sh
+ NULLCMD=:
+ # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
+ # is contrary to our usage. Disable this feature.
+ alias -g '\${1+\"\$@\"}'='\"\$@\"'
+ setopt NO_GLOB_SUBST
+else
+ case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
+fi
+BIN_SH=xpg4; export BIN_SH # for Tru64
+DUALCASE=1; export DUALCASE # for MKS sh
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+ # install mode needs the following variables:
+ generated_by_libtool_version='$macro_version'
+ notinst_deplibs='$notinst_deplibs'
+else
+ # When we are sourced in execute mode, \$file and \$ECHO are already set.
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ ECHO=\"$qecho\"
+ file=\"\$0\"
+ # Make sure echo works.
+ if test \"X\$1\" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+ elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
+ # Yippee, \$ECHO works!
+ :
+ else
+ # Restart under the correct shell, and then maybe \$ECHO will work.
+ exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+ fi
+ fi\
+"
+ $ECHO "\
+
+ # Find the directory that this script lives in.
+ thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+ # Follow symbolic links until we get to the real thisdir.
+ file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+ while test -n \"\$file\"; do
+ destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+ # If there was a directory component, then change thisdir.
+ if test \"x\$destdir\" != \"x\$file\"; then
+ case \"\$destdir\" in
+ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+ *) thisdir=\"\$thisdir/\$destdir\" ;;
+ esac
+ fi
+
+ file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+ file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+ done
+"
+}
+# end: func_emit_wrapper_part1
+
+# func_emit_wrapper_part2 [arg=no]
+#
+# Emit the second part of a libtool wrapper script on stdout.
+# For more information, see the description associated with
+# func_emit_wrapper(), below.
+func_emit_wrapper_part2 ()
+{
+ func_emit_wrapper_part2_arg1=no
+ if test -n "$1" ; then
+ func_emit_wrapper_part2_arg1=$1
+ fi
+
+ $ECHO "\
+
+ # Usually 'no', except on cygwin/mingw when embedded into
+ # the cwrapper.
+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
+ if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
+ # special case for '.'
+ if test \"\$thisdir\" = \".\"; then
+ thisdir=\`pwd\`
+ fi
+ # remove .libs from thisdir
+ case \"\$thisdir\" in
+ *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
+ $objdir ) thisdir=. ;;
+ esac
+ fi
+
+ # Try to get the absolute directory name.
+ absdir=\`cd \"\$thisdir\" && pwd\`
+ test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+ if test "$fast_install" = yes; then
+ $ECHO "\
+ program=lt-'$outputname'$exeext
+ progdir=\"\$thisdir/$objdir\"
+
+ if test ! -f \"\$progdir/\$program\" ||
+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+ file=\"\$\$-\$program\"
+
+ if test ! -d \"\$progdir\"; then
+ $MKDIR \"\$progdir\"
+ else
+ $RM \"\$progdir/\$file\"
+ fi"
+
+ $ECHO "\
+
+ # relink executable if necessary
+ if test -n \"\$relink_command\"; then
+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+ else
+ $ECHO \"\$relink_command_output\" >&2
+ $RM \"\$progdir/\$file\"
+ exit 1
+ fi
+ fi
+
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+ { $RM \"\$progdir/\$program\";
+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+ $RM \"\$progdir/\$file\"
+ fi"
+ else
+ $ECHO "\
+ program='$outputname'
+ progdir=\"\$thisdir/$objdir\"
+"
+ fi
+
+ $ECHO "\
+
+ if test -f \"\$progdir/\$program\"; then"
+
+ # Export our shlibpath_var if we have one.
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ $ECHO "\
+ # Add our own library path to $shlibpath_var
+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+ # Some systems cannot cope with colon-terminated $shlibpath_var
+ # The second colon is a workaround for a bug in BeOS R4 sed
+ $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+ export $shlibpath_var
+"
+ fi
+
+ # fixup the dll searchpath if we need to.
+ if test -n "$dllsearchpath"; then
+ $ECHO "\
+ # Add the dll search path components to the executable PATH
+ PATH=$dllsearchpath:\$PATH
+"
+ fi
+
+ $ECHO "\
+ if test \"\$libtool_execute_magic\" != \"$magic\"; then
+ # Run the actual program with our arguments.
+"
+ case $host in
+ # Backslashes separate directories on plain windows
+ *-*-mingw | *-*-os2* | *-cegcc*)
+ $ECHO "\
+ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+ ;;
+
+ *)
+ $ECHO "\
+ exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+ ;;
+ esac
+ $ECHO "\
+ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
+ exit 1
+ fi
+ else
+ # The program doesn't exist.
+ \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+ \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
+ $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
+ exit 1
+ fi
+fi\
+"
+}
+# end: func_emit_wrapper_part2
+
+
+# func_emit_wrapper [arg=no]
+#
+# Emit a libtool wrapper script on stdout.
+# Don't directly open a file because we may want to
+# incorporate the script contents within a cygwin/mingw
+# wrapper executable. Must ONLY be called from within
+# func_mode_link because it depends on a number of variables
+# set therein.
+#
+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
+# variable will take. If 'yes', then the emitted script
+# will assume that the directory in which it is stored is
+# the $objdir directory. This is a cygwin/mingw-specific
+# behavior.
+func_emit_wrapper ()
+{
+ func_emit_wrapper_arg1=no
+ if test -n "$1" ; then
+ func_emit_wrapper_arg1=$1
+ fi
+
+ # split this up so that func_emit_cwrapperexe_src
+ # can call each part independently.
+ func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
+ func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
+}
+
+
+# func_to_host_path arg
+#
+# Convert paths to host format when used with build tools.
+# Intended for use with "native" mingw (where libtool itself
+# is running under the msys shell), or in the following cross-
+# build environments:
+# $build $host
+# mingw (msys) mingw [e.g. native]
+# cygwin mingw
+# *nix + wine mingw
+# where wine is equipped with the `winepath' executable.
+# In the native mingw case, the (msys) shell automatically
+# converts paths for any non-msys applications it launches,
+# but that facility isn't available from inside the cwrapper.
+# Similar accommodations are necessary for $host mingw and
+# $build cygwin. Calling this function does no harm for other
+# $host/$build combinations not listed above.
+#
+# ARG is the path (on $build) that should be converted to
+# the proper representation for $host. The result is stored
+# in $func_to_host_path_result.
+func_to_host_path ()
+{
+ func_to_host_path_result="$1"
+ if test -n "$1" ; then
+ case $host in
+ *mingw* )
+ lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+ case $build in
+ *mingw* ) # actually, msys
+ # awkward: cmd appends spaces to result
+ lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+ func_to_host_path_tmp1=`( cmd //c echo "$1" |\
+ $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+ func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+ $SED -e "$lt_sed_naive_backslashify"`
+ ;;
+ *cygwin* )
+ func_to_host_path_tmp1=`cygpath -w "$1"`
+ func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+ $SED -e "$lt_sed_naive_backslashify"`
+ ;;
+ * )
+ # Unfortunately, winepath does not exit with a non-zero
+ # error code, so we are forced to check the contents of
+ # stdout. On the other hand, if the command is not
+ # found, the shell will set an exit code of 127 and print
+ # *an error message* to stdout. So we must check for both
+ # error code of zero AND non-empty stdout, which explains
+ # the odd construction:
+ func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
+ if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
+ func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
+ $SED -e "$lt_sed_naive_backslashify"`
+ else
+ # Allow warning below.
+ func_to_host_path_result=""
+ fi
+ ;;
+ esac
+ if test -z "$func_to_host_path_result" ; then
+ func_error "Could not determine host path corresponding to"
+ func_error " '$1'"
+ func_error "Continuing, but uninstalled executables may not work."
+ # Fallback:
+ func_to_host_path_result="$1"
+ fi
+ ;;
+ esac
+ fi
+}
+# end: func_to_host_path
+
+# func_to_host_pathlist arg
+#
+# Convert pathlists to host format when used with build tools.
+# See func_to_host_path(), above. This function supports the
+# following $build/$host combinations (but does no harm for
+# combinations not listed here):
+# $build $host
+# mingw (msys) mingw [e.g. native]
+# cygwin mingw
+# *nix + wine mingw
+#
+# Path separators are also converted from $build format to
+# $host format. If ARG begins or ends with a path separator
+# character, it is preserved (but converted to $host format)
+# on output.
+#
+# ARG is a pathlist (on $build) that should be converted to
+# the proper representation on $host. The result is stored
+# in $func_to_host_pathlist_result.
+func_to_host_pathlist ()
+{
+ func_to_host_pathlist_result="$1"
+ if test -n "$1" ; then
+ case $host in
+ *mingw* )
+ lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
+ # Remove leading and trailing path separator characters from
+ # ARG. msys behavior is inconsistent here, cygpath turns them
+ # into '.;' and ';.', and winepath ignores them completely.
+ func_to_host_pathlist_tmp2="$1"
+ # Once set for this call, this variable should not be
+ # reassigned. It is used in tha fallback case.
+ func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
+ $SED -e 's|^:*||' -e 's|:*$||'`
+ case $build in
+ *mingw* ) # Actually, msys.
+ # Awkward: cmd appends spaces to result.
+ lt_sed_strip_trailing_spaces="s/[ ]*\$//"
+ func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
+ $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
+ func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+ $SED -e "$lt_sed_naive_backslashify"`
+ ;;
+ *cygwin* )
+ func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
+ func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
+ $SED -e "$lt_sed_naive_backslashify"`
+ ;;
+ * )
+ # unfortunately, winepath doesn't convert pathlists
+ func_to_host_pathlist_result=""
+ func_to_host_pathlist_oldIFS=$IFS
+ IFS=:
+ for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
+ IFS=$func_to_host_pathlist_oldIFS
+ if test -n "$func_to_host_pathlist_f" ; then
+ func_to_host_path "$func_to_host_pathlist_f"
+ if test -n "$func_to_host_path_result" ; then
+ if test -z "$func_to_host_pathlist_result" ; then
+ func_to_host_pathlist_result="$func_to_host_path_result"
+ else
+ func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
+ fi
+ fi
+ fi
+ IFS=:
+ done
+ IFS=$func_to_host_pathlist_oldIFS
+ ;;
+ esac
+ if test -z "$func_to_host_pathlist_result" ; then
+ func_error "Could not determine the host path(s) corresponding to"
+ func_error " '$1'"
+ func_error "Continuing, but uninstalled executables may not work."
+ # Fallback. This may break if $1 contains DOS-style drive
+ # specifications. The fix is not to complicate the expression
+ # below, but for the user to provide a working wine installation
+ # with winepath so that path translation in the cross-to-mingw
+ # case works properly.
+ lt_replace_pathsep_nix_to_dos="s|:|;|g"
+ func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
+ $SED -e "$lt_replace_pathsep_nix_to_dos"`
+ fi
+ # Now, add the leading and trailing path separators back
+ case "$1" in
+ :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
+ ;;
+ esac
+ case "$1" in
+ *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+}
+# end: func_to_host_pathlist
+
+# func_emit_cwrapperexe_src
+# emit the source code for a wrapper executable on stdout
+# Must ONLY be called from within func_mode_link because
+# it depends on a number of variable set therein.
+func_emit_cwrapperexe_src ()
+{
+ cat <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+ Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+
+ The $output program cannot be directly executed until all the libtool
+ libraries that it depends on are installed.
+
+ This wrapper executable should never be moved out of the build directory.
+ If it is, it will not operate correctly.
+
+ Currently, it simply execs the wrapper *script* "$SHELL $output",
+ but could eventually absorb all of the scripts functionality and
+ exec $objdir/$outputname directly.
+*/
+EOF
+ cat <<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef _MSC_VER
+# include <direct.h>
+# include <process.h>
+# include <io.h>
+# define setmode _setmode
+#else
+# include <unistd.h>
+# include <stdint.h>
+# ifdef __CYGWIN__
+# include <io.h>
+# define HAVE_SETENV
+# ifdef __STRICT_ANSI__
+char *realpath (const char *, char *);
+int putenv (char *);
+int setenv (const char *, const char *, int);
+# endif
+# endif
+#endif
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef S_IXOTH
+# define S_IXOTH 0
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP 0
+#endif
+
+#ifdef _MSC_VER
+# define S_IXUSR _S_IEXEC
+# define stat _stat
+# ifndef _INTPTR_T_DEFINED
+# define intptr_t int
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+ defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# define FOPEN_WB "wb"
+# ifndef DIR_SEPARATOR_2
+# define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+# define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#ifdef __CYGWIN__
+# define FOPEN_WB "wb"
+#endif
+
+#ifndef FOPEN_WB
+# define FOPEN_WB "w"
+#endif
+#ifndef _O_BINARY
+# define _O_BINARY 0
+#endif
+
+#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+ if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+#undef LTWRAPPER_DEBUGPRINTF
+#if defined DEBUGWRAPPER
+# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
+static void
+ltwrapper_debugprintf (const char *fmt, ...)
+{
+ va_list args;
+ va_start (args, fmt);
+ (void) vfprintf (stderr, fmt, args);
+ va_end (args);
+}
+#else
+# define LTWRAPPER_DEBUGPRINTF(args)
+#endif
+
+const char *program_name = NULL;
+
+void *xmalloc (size_t num);
+char *xstrdup (const char *string);
+const char *base_name (const char *name);
+char *find_executable (const char *wrapper);
+char *chase_symlinks (const char *pathspec);
+int make_executable (const char *path);
+int check_executable (const char *path);
+char *strendzap (char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+void lt_setenv (const char *name, const char *value);
+char *lt_extend_str (const char *orig_value, const char *add, int to_end);
+void lt_opt_process_env_set (const char *arg);
+void lt_opt_process_env_prepend (const char *arg);
+void lt_opt_process_env_append (const char *arg);
+int lt_split_name_value (const char *arg, char** name, char** value);
+void lt_update_exe_path (const char *name, const char *value);
+void lt_update_lib_path (const char *name, const char *value);
+
+static const char *script_text_part1 =
+EOF
+
+ func_emit_wrapper_part1 yes |
+ $SED -e 's/\([\\"]\)/\\\1/g' \
+ -e 's/^/ "/' -e 's/$/\\n"/'
+ echo ";"
+ cat <<EOF
+
+static const char *script_text_part2 =
+EOF
+ func_emit_wrapper_part2 yes |
+ $SED -e 's/\([\\"]\)/\\\1/g' \
+ -e 's/^/ "/' -e 's/$/\\n"/'
+ echo ";"
+
+ cat <<EOF
+const char * MAGIC_EXE = "$magic_exe";
+const char * LIB_PATH_VARNAME = "$shlibpath_var";
+EOF
+
+ if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+ func_to_host_pathlist "$temp_rpath"
+ cat <<EOF
+const char * LIB_PATH_VALUE = "$func_to_host_pathlist_result";
+EOF
+ else
+ cat <<"EOF"
+const char * LIB_PATH_VALUE = "";
+EOF
+ fi
+
+ if test -n "$dllsearchpath"; then
+ func_to_host_pathlist "$dllsearchpath:"
+ cat <<EOF
+const char * EXE_PATH_VARNAME = "PATH";
+const char * EXE_PATH_VALUE = "$func_to_host_pathlist_result";
+EOF
+ else
+ cat <<"EOF"
+const char * EXE_PATH_VARNAME = "";
+const char * EXE_PATH_VALUE = "";
+EOF
+ fi
+
+ if test "$fast_install" = yes; then
+ cat <<EOF
+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
+EOF
+ else
+ cat <<EOF
+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
+EOF
+ fi
+
+
+ cat <<"EOF"
+
+#define LTWRAPPER_OPTION_PREFIX "--lt-"
+#define LTWRAPPER_OPTION_PREFIX_LENGTH 5
+
+static const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH;
+static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
+
+static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
+
+static const size_t env_set_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
+static const char *env_set_opt = LTWRAPPER_OPTION_PREFIX "env-set";
+ /* argument is putenv-style "foo=bar", value of foo is set to bar */
+
+static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
+static const char *env_prepend_opt = LTWRAPPER_OPTION_PREFIX "env-prepend";
+ /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
+
+static const size_t env_append_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
+static const char *env_append_opt = LTWRAPPER_OPTION_PREFIX "env-append";
+ /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
+
+int
+main (int argc, char *argv[])
+{
+ char **newargz;
+ int newargc;
+ char *tmp_pathspec;
+ char *actual_cwrapper_path;
+ char *actual_cwrapper_name;
+ char *target_name;
+ char *lt_argv_zero;
+ intptr_t rval = 127;
+
+ int i;
+
+ program_name = (char *) xstrdup (base_name (argv[0]));
+ LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
+ LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
+
+ /* very simple arg parsing; don't want to rely on getopt */
+ for (i = 1; i < argc; i++)
+ {
+ if (strcmp (argv[i], dumpscript_opt) == 0)
+ {
+EOF
+ case "$host" in
+ *mingw* | *cygwin* )
+ # make stdout use "unix" line endings
+ echo " setmode(1,_O_BINARY);"
+ ;;
+ esac
+
+ cat <<"EOF"
+ printf ("%s", script_text_part1);
+ printf ("%s", script_text_part2);
+ return 0;
+ }
+ }
+
+ newargz = XMALLOC (char *, argc + 1);
+ tmp_pathspec = find_executable (argv[0]);
+ if (tmp_pathspec == NULL)
+ lt_fatal ("Couldn't find %s", argv[0]);
+ LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
+ tmp_pathspec));
+
+ actual_cwrapper_path = chase_symlinks (tmp_pathspec);
+ LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
+ actual_cwrapper_path));
+ XFREE (tmp_pathspec);
+
+ actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
+ strendzap (actual_cwrapper_path, actual_cwrapper_name);
+
+ /* wrapper name transforms */
+ strendzap (actual_cwrapper_name, ".exe");
+ tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
+ XFREE (actual_cwrapper_name);
+ actual_cwrapper_name = tmp_pathspec;
+ tmp_pathspec = 0;
+
+ /* target_name transforms -- use actual target program name; might have lt- prefix */
+ target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
+ strendzap (target_name, ".exe");
+ tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
+ XFREE (target_name);
+ target_name = tmp_pathspec;
+ tmp_pathspec = 0;
+
+ LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
+ target_name));
+EOF
+
+ cat <<EOF
+ newargz[0] =
+ XMALLOC (char, (strlen (actual_cwrapper_path) +
+ strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
+ strcpy (newargz[0], actual_cwrapper_path);
+ strcat (newargz[0], "$objdir");
+ strcat (newargz[0], "/");
+EOF
+
+ cat <<"EOF"
+ /* stop here, and copy so we don't have to do this twice */
+ tmp_pathspec = xstrdup (newargz[0]);
+
+ /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
+ strcat (newargz[0], actual_cwrapper_name);
+
+ /* DO want the lt- prefix here if it exists, so use target_name */
+ lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
+ XFREE (tmp_pathspec);
+ tmp_pathspec = NULL;
+EOF
+
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+ {
+ char* p;
+ while ((p = strchr (newargz[0], '\\')) != NULL)
+ {
+ *p = '/';
+ }
+ while ((p = strchr (lt_argv_zero, '\\')) != NULL)
+ {
+ *p = '/';
+ }
+ }
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+ XFREE (target_name);
+ XFREE (actual_cwrapper_path);
+ XFREE (actual_cwrapper_name);
+
+ lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
+ lt_setenv ("DUALCASE", "1"); /* for MSK sh */
+ lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
+ lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
+
+ newargc=0;
+ for (i = 1; i < argc; i++)
+ {
+ if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
+ {
+ if (argv[i][env_set_opt_len] == '=')
+ {
+ const char *p = argv[i] + env_set_opt_len + 1;
+ lt_opt_process_env_set (p);
+ }
+ else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
+ {
+ lt_opt_process_env_set (argv[++i]); /* don't copy */
+ }
+ else
+ lt_fatal ("%s missing required argument", env_set_opt);
+ continue;
+ }
+ if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
+ {
+ if (argv[i][env_prepend_opt_len] == '=')
+ {
+ const char *p = argv[i] + env_prepend_opt_len + 1;
+ lt_opt_process_env_prepend (p);
+ }
+ else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
+ {
+ lt_opt_process_env_prepend (argv[++i]); /* don't copy */
+ }
+ else
+ lt_fatal ("%s missing required argument", env_prepend_opt);
+ continue;
+ }
+ if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
+ {
+ if (argv[i][env_append_opt_len] == '=')
+ {
+ const char *p = argv[i] + env_append_opt_len + 1;
+ lt_opt_process_env_append (p);
+ }
+ else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
+ {
+ lt_opt_process_env_append (argv[++i]); /* don't copy */
+ }
+ else
+ lt_fatal ("%s missing required argument", env_append_opt);
+ continue;
+ }
+ if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
+ {
+ /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
+ namespace, but it is not one of the ones we know about and
+ have already dealt with, above (inluding dump-script), then
+ report an error. Otherwise, targets might begin to believe
+ they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
+ namespace. The first time any user complains about this, we'll
+ need to make LTWRAPPER_OPTION_PREFIX a configure-time option
+ or a configure.ac-settable value.
+ */
+ lt_fatal ("Unrecognized option in %s namespace: '%s'",
+ ltwrapper_option_prefix, argv[i]);
+ }
+ /* otherwise ... */
+ newargz[++newargc] = xstrdup (argv[i]);
+ }
+ newargz[++newargc] = NULL;
+
+ LTWRAPPER_DEBUGPRINTF (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
+ for (i = 0; i < newargc; i++)
+ {
+ LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
+ }
+
+EOF
+
+ case $host_os in
+ mingw*)
+ cat <<"EOF"
+ /* execv doesn't actually work on mingw as expected on unix */
+ rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
+ if (rval == -1)
+ {
+ /* failed to start process */
+ LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
+ return 127;
+ }
+ return rval;
+EOF
+ ;;
+ *)
+ cat <<"EOF"
+ execv (lt_argv_zero, newargz);
+ return rval; /* =127, but avoids unused variable warning */
+EOF
+ ;;
+ esac
+
+ cat <<"EOF"
+}
+
+void *
+xmalloc (size_t num)
+{
+ void *p = (void *) malloc (num);
+ if (!p)
+ lt_fatal ("Memory exhausted");
+
+ return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
+ string) : NULL;
+}
+
+const char *
+base_name (const char *name)
+{
+ const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ /* Skip over the disk name in MSDOS pathnames. */
+ if (isalpha ((unsigned char) name[0]) && name[1] == ':')
+ name += 2;
+#endif
+
+ for (base = name; *name; name++)
+ if (IS_DIR_SEPARATOR (*name))
+ base = name + 1;
+ return base;
+}
+
+int
+check_executable (const char *path)
+{
+ struct stat st;
+
+ LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
+ path ? (*path ? path : "EMPTY!") : "NULL!"));
+ if ((!path) || (!*path))
+ return 0;
+
+ if ((stat (path, &st) >= 0)
+ && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ return 1;
+ else
+ return 0;
+}
+
+int
+make_executable (const char *path)
+{
+ int rval = 0;
+ struct stat st;
+
+ LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
+ path ? (*path ? path : "EMPTY!") : "NULL!"));
+ if ((!path) || (!*path))
+ return 0;
+
+ if (stat (path, &st) >= 0)
+ {
+ rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
+ }
+ return rval;
+}
+
+/* Searches for the full path of the wrapper. Returns
+ newly allocated full path name if found, NULL otherwise
+ Does not chase symlinks, even on platforms that support them.
+*/
+char *
+find_executable (const char *wrapper)
+{
+ int has_slash = 0;
+ const char *p;
+ const char *p_next;
+ /* static buffer for getcwd */
+ char tmp[LT_PATHMAX + 1];
+ int tmp_len;
+ char *concat_name;
+
+ LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
+ wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
+
+ if ((wrapper == NULL) || (*wrapper == '\0'))
+ return NULL;
+
+ /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ else
+ {
+#endif
+ if (IS_DIR_SEPARATOR (wrapper[0]))
+ {
+ concat_name = xstrdup (wrapper);
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+ }
+#endif
+
+ for (p = wrapper; *p; p++)
+ if (*p == '/')
+ {
+ has_slash = 1;
+ break;
+ }
+ if (!has_slash)
+ {
+ /* no slashes; search PATH */
+ const char *path = getenv ("PATH");
+ if (path != NULL)
+ {
+ for (p = path; *p; p = p_next)
+ {
+ const char *q;
+ size_t p_len;
+ for (q = p; *q; q++)
+ if (IS_PATH_SEPARATOR (*q))
+ break;
+ p_len = q - p;
+ p_next = (*q == '\0' ? q : q + 1);
+ if (p_len == 0)
+ {
+ /* empty path: current directory */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal ("getcwd failed");
+ tmp_len = strlen (tmp);
+ concat_name =
+ XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+ }
+ else
+ {
+ concat_name =
+ XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, p, p_len);
+ concat_name[p_len] = '/';
+ strcpy (concat_name + p_len + 1, wrapper);
+ }
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ }
+ }
+ /* not found in PATH; assume curdir */
+ }
+ /* Relative path | not found in path: prepend cwd */
+ if (getcwd (tmp, LT_PATHMAX) == NULL)
+ lt_fatal ("getcwd failed");
+ tmp_len = strlen (tmp);
+ concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
+ memcpy (concat_name, tmp, tmp_len);
+ concat_name[tmp_len] = '/';
+ strcpy (concat_name + tmp_len + 1, wrapper);
+
+ if (check_executable (concat_name))
+ return concat_name;
+ XFREE (concat_name);
+ return NULL;
+}
+
+char *
+chase_symlinks (const char *pathspec)
+{
+#ifndef S_ISLNK
+ return xstrdup (pathspec);
+#else
+ char buf[LT_PATHMAX];
+ struct stat s;
+ char *tmp_pathspec = xstrdup (pathspec);
+ char *p;
+ int has_symlinks = 0;
+ while (strlen (tmp_pathspec) && !has_symlinks)
+ {
+ LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
+ tmp_pathspec));
+ if (lstat (tmp_pathspec, &s) == 0)
+ {
+ if (S_ISLNK (s.st_mode) != 0)
+ {
+ has_symlinks = 1;
+ break;
+ }
+
+ /* search backwards for last DIR_SEPARATOR */
+ p = tmp_pathspec + strlen (tmp_pathspec) - 1;
+ while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ p--;
+ if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
+ {
+ /* no more DIR_SEPARATORS left */
+ break;
+ }
+ *p = '\0';
+ }
+ else
+ {
+ char *errstr = strerror (errno);
+ lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
+ }
+ }
+ XFREE (tmp_pathspec);
+
+ if (!has_symlinks)
+ {
+ return xstrdup (pathspec);
+ }
+
+ tmp_pathspec = realpath (pathspec, buf);
+ if (tmp_pathspec == 0)
+ {
+ lt_fatal ("Could not follow symlinks for %s", pathspec);
+ }
+ return xstrdup (tmp_pathspec);
+#endif
+}
+
+char *
+strendzap (char *str, const char *pat)
+{
+ size_t len, patlen;
+
+ assert (str != NULL);
+ assert (pat != NULL);
+
+ len = strlen (str);
+ patlen = strlen (pat);
+
+ if (patlen <= len)
+ {
+ str += len - patlen;
+ if (strcmp (str, pat) == 0)
+ *str = '\0';
+ }
+ return str;
+}
+
+static void
+lt_error_core (int exit_status, const char *mode,
+ const char *message, va_list ap)
+{
+ fprintf (stderr, "%s: %s: ", program_name, mode);
+ vfprintf (stderr, message, ap);
+ fprintf (stderr, ".\n");
+
+ if (exit_status >= 0)
+ exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+ va_list ap;
+ va_start (ap, message);
+ lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+ va_end (ap);
+}
+
+void
+lt_setenv (const char *name, const char *value)
+{
+ LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
+ (name ? name : "<NULL>"),
+ (value ? value : "<NULL>")));
+ {
+#ifdef HAVE_SETENV
+ /* always make a copy, for consistency with !HAVE_SETENV */
+ char *str = xstrdup (value);
+ setenv (name, str, 1);
+#else
+ int len = strlen (name) + 1 + strlen (value) + 1;
+ char *str = XMALLOC (char, len);
+ sprintf (str, "%s=%s", name, value);
+ if (putenv (str) != EXIT_SUCCESS)
+ {
+ XFREE (str);
+ }
+#endif
+ }
+}
+
+char *
+lt_extend_str (const char *orig_value, const char *add, int to_end)
+{
+ char *new_value;
+ if (orig_value && *orig_value)
+ {
+ int orig_value_len = strlen (orig_value);
+ int add_len = strlen (add);
+ new_value = XMALLOC (char, add_len + orig_value_len + 1);
+ if (to_end)
+ {
+ strcpy (new_value, orig_value);
+ strcpy (new_value + orig_value_len, add);
+ }
+ else
+ {
+ strcpy (new_value, add);
+ strcpy (new_value + add_len, orig_value);
+ }
+ }
+ else
+ {
+ new_value = xstrdup (add);
+ }
+ return new_value;
+}
+
+int
+lt_split_name_value (const char *arg, char** name, char** value)
+{
+ const char *p;
+ int len;
+ if (!arg || !*arg)
+ return 1;
+
+ p = strchr (arg, (int)'=');
+
+ if (!p)
+ return 1;
+
+ *value = xstrdup (++p);
+
+ len = strlen (arg) - strlen (*value);
+ *name = XMALLOC (char, len);
+ strncpy (*name, arg, len-1);
+ (*name)[len - 1] = '\0';
+
+ return 0;
+}
+
+void
+lt_opt_process_env_set (const char *arg)
+{
+ char *name = NULL;
+ char *value = NULL;
+
+ if (lt_split_name_value (arg, &name, &value) != 0)
+ {
+ XFREE (name);
+ XFREE (value);
+ lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
+ }
+
+ lt_setenv (name, value);
+ XFREE (name);
+ XFREE (value);
+}
+
+void
+lt_opt_process_env_prepend (const char *arg)
+{
+ char *name = NULL;
+ char *value = NULL;
+ char *new_value = NULL;
+
+ if (lt_split_name_value (arg, &name, &value) != 0)
+ {
+ XFREE (name);
+ XFREE (value);
+ lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
+ }
+
+ new_value = lt_extend_str (getenv (name), value, 0);
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ XFREE (name);
+ XFREE (value);
+}
+
+void
+lt_opt_process_env_append (const char *arg)
+{
+ char *name = NULL;
+ char *value = NULL;
+ char *new_value = NULL;
+
+ if (lt_split_name_value (arg, &name, &value) != 0)
+ {
+ XFREE (name);
+ XFREE (value);
+ lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
+ }
+
+ new_value = lt_extend_str (getenv (name), value, 1);
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ XFREE (name);
+ XFREE (value);
+}
+
+void
+lt_update_exe_path (const char *name, const char *value)
+{
+ LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
+ (name ? name : "<NULL>"),
+ (value ? value : "<NULL>")));
+
+ if (name && *name && value && *value)
+ {
+ char *new_value = lt_extend_str (getenv (name), value, 0);
+ /* some systems can't cope with a ':'-terminated path #' */
+ int len = strlen (new_value);
+ while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
+ {
+ new_value[len-1] = '\0';
+ }
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ }
+}
+
+void
+lt_update_lib_path (const char *name, const char *value)
+{
+ LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
+ (name ? name : "<NULL>"),
+ (value ? value : "<NULL>")));
+
+ if (name && *name && value && *value)
+ {
+ char *new_value = lt_extend_str (getenv (name), value, 0);
+ lt_setenv (name, new_value);
+ XFREE (new_value);
+ }
+}
+
+
+EOF
+}
+# end: func_emit_cwrapperexe_src
+
+# func_mode_link arg...
+func_mode_link ()
+{
+ $opt_debug
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ # It is impossible to link a dll without this setting, and
+ # we shouldn't force the makefile maintainer to figure out
+ # which system we are compiling for in order to pass an extra
+ # flag for every libtool invocation.
+ # allow_undefined=no
+
+ # FIXME: Unfortunately, there are problems with the above when trying
+ # to make a dll which has undefined symbols, in which case not
+ # even a static library is built. For now, we need to specify
+ # -no-undefined on the libtool link line when we can be certain
+ # that all symbols are satisfied, otherwise we get a static library.
+ allow_undefined=yes
+ ;;
+ *)
+ allow_undefined=yes
+ ;;
+ esac
+ libtool_args=$nonopt
+ base_compile="$nonopt $@"
+ compile_command=$nonopt
+ finalize_command=$nonopt
+
+ compile_rpath=
+ finalize_rpath=
+ compile_shlibpath=
+ finalize_shlibpath=
+ convenience=
+ old_convenience=
+ deplibs=
+ old_deplibs=
+ compiler_flags=
+ linker_flags=
+ dllsearchpath=
+ lib_search_path=`pwd`
+ inst_prefix_dir=
+ new_inherited_linker_flags=
+
+ avoid_version=no
+ dlfiles=
+ dlprefiles=
+ dlself=no
+ export_dynamic=no
+ export_symbols=
+ export_symbols_regex=
+ generated=
+ libobjs=
+ ltlibs=
+ module=no
+ no_install=no
+ objs=
+ non_pic_objects=
+ precious_files_regex=
+ prefer_static_libs=no
+ preload=no
+ prev=
+ prevarg=
+ release=
+ rpath=
+ xrpath=
+ perm_rpath=
+ temp_rpath=
+ thread_safe=no
+ vinfo=
+ vinfo_number=no
+ weak_libs=
+ single_module="${wl}-single_module"
+ func_infer_tag $base_compile
+
+ # We need to know -static, to get the right output filenames.
+ for arg
+ do
+ case $arg in
+ -shared)
+ test "$build_libtool_libs" != yes && \
+ func_fatal_configuration "can not build a shared library"
+ build_old_libs=no
+ break
+ ;;
+ -all-static | -static | -static-libtool-libs)
+ case $arg in
+ -all-static)
+ if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+ func_warning "complete static linking is impossible in this configuration"
+ fi
+ if test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ -static)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=built
+ ;;
+ -static-libtool-libs)
+ if test -z "$pic_flag" && test -n "$link_static_flag"; then
+ dlopen_self=$dlopen_self_static
+ fi
+ prefer_static_libs=yes
+ ;;
+ esac
+ build_libtool_libs=no
+ build_old_libs=yes
+ break
+ ;;
+ esac
+ done
+
+ # See if our shared archives depend on static archives.
+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+ # Go through the arguments, transforming them on the way.
+ while test "$#" -gt 0; do
+ arg="$1"
+ shift
+ func_quote_for_eval "$arg"
+ qarg=$func_quote_for_eval_unquoted_result
+ func_append libtool_args " $func_quote_for_eval_result"
+
+ # If the previous option needs an argument, assign it.
+ if test -n "$prev"; then
+ case $prev in
+ output)
+ func_append compile_command " @OUTPUT@"
+ func_append finalize_command " @OUTPUT@"
+ ;;
+ esac
+
+ case $prev in
+ dlfiles|dlprefiles)
+ if test "$preload" = no; then
+ # Add the symbol object into the linking commands.
+ func_append compile_command " @SYMFILE@"
+ func_append finalize_command " @SYMFILE@"
+ preload=yes
+ fi
+ case $arg in
+ *.la | *.lo) ;; # We handle these cases below.
+ force)
+ if test "$dlself" = no; then
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ self)
+ if test "$prev" = dlprefiles; then
+ dlself=yes
+ elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+ dlself=yes
+ else
+ dlself=needless
+ export_dynamic=yes
+ fi
+ prev=
+ continue
+ ;;
+ *)
+ if test "$prev" = dlfiles; then
+ dlfiles="$dlfiles $arg"
+ else
+ dlprefiles="$dlprefiles $arg"
+ fi
+ prev=
+ continue
+ ;;
+ esac
+ ;;
+ expsyms)
+ export_symbols="$arg"
+ test -f "$arg" \
+ || func_fatal_error "symbol file \`$arg' does not exist"
+ prev=
+ continue
+ ;;
+ expsyms_regex)
+ export_symbols_regex="$arg"
+ prev=
+ continue
+ ;;
+ framework)
+ case $host in
+ *-*-darwin*)
+ case "$deplibs " in
+ *" $qarg.ltframework "*) ;;
+ *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
+ ;;
+ esac
+ ;;
+ esac
+ prev=
+ continue
+ ;;
+ inst_prefix)
+ inst_prefix_dir="$arg"
+ prev=
+ continue
+ ;;
+ objectlist)
+ if test -f "$arg"; then
+ save_arg=$arg
+ moreargs=
+ for fil in `cat "$save_arg"`
+ do
+# moreargs="$moreargs $fil"
+ arg=$fil
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ done
+ else
+ func_fatal_error "link input file \`$arg' does not exist"
+ fi
+ arg=$save_arg
+ prev=
+ continue
+ ;;
+ precious_regex)
+ precious_files_regex="$arg"
+ prev=
+ continue
+ ;;
+ release)
+ release="-$arg"
+ prev=
+ continue
+ ;;
+ rpath | xrpath)
+ # We need an absolute path.
+ case $arg in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ if test "$prev" = rpath; then
+ case "$rpath " in
+ *" $arg "*) ;;
+ *) rpath="$rpath $arg" ;;
+ esac
+ else
+ case "$xrpath " in
+ *" $arg "*) ;;
+ *) xrpath="$xrpath $arg" ;;
+ esac
+ fi
+ prev=
+ continue
+ ;;
+ shrext)
+ shrext_cmds="$arg"
+ prev=
+ continue
+ ;;
+ weak)
+ weak_libs="$weak_libs $arg"
+ prev=
+ continue
+ ;;
+ xcclinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xcompiler)
+ compiler_flags="$compiler_flags $qarg"
+ prev=
+ func_append compile_command " $qarg"
+ func_append finalize_command " $qarg"
+ continue
+ ;;
+ xlinker)
+ linker_flags="$linker_flags $qarg"
+ compiler_flags="$compiler_flags $wl$qarg"
+ prev=
+ func_append compile_command " $wl$qarg"
+ func_append finalize_command " $wl$qarg"
+ continue
+ ;;
+ *)
+ eval "$prev=\"\$arg\""
+ prev=
+ continue
+ ;;
+ esac
+ fi # test -n "$prev"
+
+ prevarg="$arg"
+
+ case $arg in
+ -all-static)
+ if test -n "$link_static_flag"; then
+ # See comment for -static flag below, for more details.
+ func_append compile_command " $link_static_flag"
+ func_append finalize_command " $link_static_flag"
+ fi
+ continue
+ ;;
+
+ -allow-undefined)
+ # FIXME: remove this flag sometime in the future.
+ func_fatal_error "\`-allow-undefined' must not be used because it is the default"
+ ;;
+
+ -avoid-version)
+ avoid_version=yes
+ continue
+ ;;
+
+ -dlopen)
+ prev=dlfiles
+ continue
+ ;;
+
+ -dlpreopen)
+ prev=dlprefiles
+ continue
+ ;;
+
+ -export-dynamic)
+ export_dynamic=yes
+ continue
+ ;;
+
+ -export-symbols | -export-symbols-regex)
+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+ func_fatal_error "more than one -exported-symbols argument is not allowed"
+ fi
+ if test "X$arg" = "X-export-symbols"; then
+ prev=expsyms
+ else
+ prev=expsyms_regex
+ fi
+ continue
+ ;;
+
+ -framework)
+ prev=framework
+ continue
+ ;;
+
+ -inst-prefix-dir)
+ prev=inst_prefix
+ continue
+ ;;
+
+ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+ # so, if we see these flags be careful not to treat them like -L
+ -L[A-Z][A-Z]*:*)
+ case $with_gcc/$host in
+ no/*-*-irix* | /*-*-irix*)
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ ;;
+ esac
+ continue
+ ;;
+
+ -L*)
+ func_stripname '-L' '' "$arg"
+ dir=$func_stripname_result
+ if test -z "$dir"; then
+ if test "$#" -gt 0; then
+ func_fatal_error "require no space between \`-L' and \`$1'"
+ else
+ func_fatal_error "need path for \`-L' option"
+ fi
+ fi
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ test -z "$absdir" && \
+ func_fatal_error "cannot determine absolute directory name of \`$dir'"
+ dir="$absdir"
+ ;;
+ esac
+ case "$deplibs " in
+ *" -L$dir "*) ;;
+ *)
+ deplibs="$deplibs -L$dir"
+ lib_search_path="$lib_search_path $dir"
+ ;;
+ esac
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$dir:"*) ;;
+ ::) dllsearchpath=$dir;;
+ *) dllsearchpath="$dllsearchpath:$dir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ ::) dllsearchpath=$testbindir;;
+ *) dllsearchpath="$dllsearchpath:$testbindir";;
+ esac
+ ;;
+ esac
+ continue
+ ;;
+
+ -l*)
+ if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
+ # These systems don't actually have a C or math library (as such)
+ continue
+ ;;
+ *-*-os2*)
+ # These systems don't actually have a C library (as such)
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C and math libraries are in the System framework
+ deplibs="$deplibs System.ltframework"
+ continue
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ test "X$arg" = "X-lc" && continue
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ test "X$arg" = "X-lc" && continue
+ ;;
+ esac
+ elif test "X$arg" = "X-lc_r"; then
+ case $host in
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc_r directly, use -pthread flag.
+ continue
+ ;;
+ esac
+ fi
+ deplibs="$deplibs $arg"
+ continue
+ ;;
+
+ -module)
+ module=yes
+ continue
+ ;;
+
+ # Tru64 UNIX uses -model [arg] to determine the layout of C++
+ # classes, name mangling, and exception handling.
+ # Darwin uses the -arch flag to determine output architecture.
+ -model|-arch|-isysroot)
+ compiler_flags="$compiler_flags $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ prev=xcompiler
+ continue
+ ;;
+
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+ compiler_flags="$compiler_flags $arg"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ case "$new_inherited_linker_flags " in
+ *" $arg "*) ;;
+ * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
+ esac
+ continue
+ ;;
+
+ -multi_module)
+ single_module="${wl}-multi_module"
+ continue
+ ;;
+
+ -no-fast-install)
+ fast_install=no
+ continue
+ ;;
+
+ -no-install)
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
+ # The PATH hackery in wrapper scripts is required on Windows
+ # and Darwin in order for the loader to find any dlls it needs.
+ func_warning "\`-no-install' is ignored for $host"
+ func_warning "assuming \`-no-fast-install' instead"
+ fast_install=no
+ ;;
+ *) no_install=yes ;;
+ esac
+ continue
+ ;;
+
+ -no-undefined)
+ allow_undefined=no
+ continue
+ ;;
+
+ -objectlist)
+ prev=objectlist
+ continue
+ ;;
+
+ -o) prev=output ;;
+
+ -precious-files-regex)
+ prev=precious_regex
+ continue
+ ;;
+
+ -release)
+ prev=release
+ continue
+ ;;
+
+ -rpath)
+ prev=rpath
+ continue
+ ;;
+
+ -R)
+ prev=xrpath
+ continue
+ ;;
+
+ -R*)
+ func_stripname '-R' '' "$arg"
+ dir=$func_stripname_result
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) ;;
+ *)
+ func_fatal_error "only absolute run-paths are allowed"
+ ;;
+ esac
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ continue
+ ;;
+
+ -shared)
+ # The effects of -shared are defined in a previous loop.
+ continue
+ ;;
+
+ -shrext)
+ prev=shrext
+ continue
+ ;;
+
+ -static | -static-libtool-libs)
+ # The effects of -static are defined in a previous loop.
+ # We used to do the same as -all-static on platforms that
+ # didn't have a PIC flag, but the assumption that the effects
+ # would be equivalent was wrong. It would break on at least
+ # Digital Unix and AIX.
+ continue
+ ;;
+
+ -thread-safe)
+ thread_safe=yes
+ continue
+ ;;
+
+ -version-info)
+ prev=vinfo
+ continue
+ ;;
+
+ -version-number)
+ prev=vinfo
+ vinfo_number=yes
+ continue
+ ;;
+
+ -weak)
+ prev=weak
+ continue
+ ;;
+
+ -Wc,*)
+ func_stripname '-Wc,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ arg="$arg $wl$func_quote_for_eval_result"
+ compiler_flags="$compiler_flags $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Wl,*)
+ func_stripname '-Wl,' '' "$arg"
+ args=$func_stripname_result
+ arg=
+ save_ifs="$IFS"; IFS=','
+ for flag in $args; do
+ IFS="$save_ifs"
+ func_quote_for_eval "$flag"
+ arg="$arg $wl$func_quote_for_eval_result"
+ compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
+ linker_flags="$linker_flags $func_quote_for_eval_result"
+ done
+ IFS="$save_ifs"
+ func_stripname ' ' '' "$arg"
+ arg=$func_stripname_result
+ ;;
+
+ -Xcompiler)
+ prev=xcompiler
+ continue
+ ;;
+
+ -Xlinker)
+ prev=xlinker
+ continue
+ ;;
+
+ -XCClinker)
+ prev=xcclinker
+ continue
+ ;;
+
+ # -msg_* for osf cc
+ -msg_*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+ # -r[0-9][0-9]* specifies the processor on the SGI compiler
+ # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+ # +DA*, +DD* enable 64-bit mode on the HP compiler
+ # -q* pass through compiler args for the IBM compiler
+ # -m*, -t[45]*, -txscale* pass through architecture-specific
+ # compiler args for GCC
+ # -F/path gives path to uninstalled frameworks, gcc on darwin
+ # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
+ # @file GCC response files
+ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
+ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ compiler_flags="$compiler_flags $arg"
+ continue
+ ;;
+
+ # Some other compiler flag.
+ -* | +*)
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+
+ *.$objext)
+ # A standard object.
+ objs="$objs $arg"
+ ;;
+
+ *.lo)
+ # A libtool-controlled object.
+
+ # Check to see that this really is a libtool object.
+ if func_lalib_unsafe_p "$arg"; then
+ pic_object=
+ non_pic_object=
+
+ # Read the .lo file
+ func_source "$arg"
+
+ if test -z "$pic_object" ||
+ test -z "$non_pic_object" ||
+ test "$pic_object" = none &&
+ test "$non_pic_object" = none; then
+ func_fatal_error "cannot find name of object for \`$arg'"
+ fi
+
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ if test "$pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ pic_object="$xdir$pic_object"
+
+ if test "$prev" = dlfiles; then
+ if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+ dlfiles="$dlfiles $pic_object"
+ prev=
+ continue
+ else
+ # If libtool objects are unsupported, then we need to preload.
+ prev=dlprefiles
+ fi
+ fi
+
+ # CHECK ME: I think I busted this. -Ossama
+ if test "$prev" = dlprefiles; then
+ # Preload the old-style object.
+ dlprefiles="$dlprefiles $pic_object"
+ prev=
+ fi
+
+ # A PIC object.
+ func_append libobjs " $pic_object"
+ arg="$pic_object"
+ fi
+
+ # Non-PIC object.
+ if test "$non_pic_object" != none; then
+ # Prepend the subdirectory the object is found in.
+ non_pic_object="$xdir$non_pic_object"
+
+ # A standard non-PIC object
+ func_append non_pic_objects " $non_pic_object"
+ if test -z "$pic_object" || test "$pic_object" = none ; then
+ arg="$non_pic_object"
+ fi
+ else
+ # If the PIC object exists, use it instead.
+ # $xdir was prepended to $pic_object above.
+ non_pic_object="$pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ fi
+ else
+ # Only an error if not doing a dry-run.
+ if $opt_dry_run; then
+ # Extract subdirectory from the argument.
+ func_dirname "$arg" "/" ""
+ xdir="$func_dirname_result"
+
+ func_lo2o "$arg"
+ pic_object=$xdir$objdir/$func_lo2o_result
+ non_pic_object=$xdir$func_lo2o_result
+ func_append libobjs " $pic_object"
+ func_append non_pic_objects " $non_pic_object"
+ else
+ func_fatal_error "\`$arg' is not a valid libtool object"
+ fi
+ fi
+ ;;
+
+ *.$libext)
+ # An archive.
+ deplibs="$deplibs $arg"
+ old_deplibs="$old_deplibs $arg"
+ continue
+ ;;
+
+ *.la)
+ # A libtool-controlled library.
+
+ if test "$prev" = dlfiles; then
+ # This library was specified with -dlopen.
+ dlfiles="$dlfiles $arg"
+ prev=
+ elif test "$prev" = dlprefiles; then
+ # The library was specified with -dlpreopen.
+ dlprefiles="$dlprefiles $arg"
+ prev=
+ else
+ deplibs="$deplibs $arg"
+ fi
+ continue
+ ;;
+
+ # Some other compiler argument.
+ *)
+ # Unknown arguments in both finalize_command and compile_command need
+ # to be aesthetically quoted because they are evaled later.
+ func_quote_for_eval "$arg"
+ arg="$func_quote_for_eval_result"
+ ;;
+ esac # arg
+
+ # Now actually substitute the argument into the commands.
+ if test -n "$arg"; then
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+ done # argument parsing loop
+
+ test -n "$prev" && \
+ func_fatal_help "the \`$prevarg' option requires an argument"
+
+ if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+ eval arg=\"$export_dynamic_flag_spec\"
+ func_append compile_command " $arg"
+ func_append finalize_command " $arg"
+ fi
+
+ oldlibs=
+ # calculate the name of the file, without its directory
+ func_basename "$output"
+ outputname="$func_basename_result"
+ libobjs_save="$libobjs"
+
+ if test -n "$shlibpath_var"; then
+ # get the directories listed in $shlibpath_var
+ eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+ else
+ shlib_search_path=
+ fi
+ eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+ func_dirname "$output" "/" ""
+ output_objdir="$func_dirname_result$objdir"
+ # Create the object directory.
+ func_mkdir_p "$output_objdir"
+
+ # Determine the type of output
+ case $output in
+ "")
+ func_fatal_help "you must specify an output file"
+ ;;
+ *.$libext) linkmode=oldlib ;;
+ *.lo | *.$objext) linkmode=obj ;;
+ *.la) linkmode=lib ;;
+ *) linkmode=prog ;; # Anything else should be a program.
+ esac
+
+ specialdeplibs=
+
+ libs=
+ # Find all interdependent deplibs by searching for libraries
+ # that are linked more than once (e.g. -la -lb -la)
+ for deplib in $deplibs; do
+ if $opt_duplicate_deps ; then
+ case "$libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ libs="$libs $deplib"
+ done
+
+ if test "$linkmode" = lib; then
+ libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+ # Compute libraries that are listed more than once in $predeps
+ # $postdeps and mark them as special (i.e., whose duplicates are
+ # not to be eliminated).
+ pre_post_deps=
+ if $opt_duplicate_compiler_generated_deps; then
+ for pre_post_dep in $predeps $postdeps; do
+ case "$pre_post_deps " in
+ *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+ esac
+ pre_post_deps="$pre_post_deps $pre_post_dep"
+ done
+ fi
+ pre_post_deps=
+ fi
+
+ deplibs=
+ newdependency_libs=
+ newlib_search_path=
+ need_relink=no # whether we're linking any uninstalled libtool libraries
+ notinst_deplibs= # not-installed libtool libraries
+ notinst_path= # paths that contain not-installed libtool libraries
+
+ case $linkmode in
+ lib)
+ passes="conv dlpreopen link"
+ for file in $dlfiles $dlprefiles; do
+ case $file in
+ *.la) ;;
+ *)
+ func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
+ ;;
+ esac
+ done
+ ;;
+ prog)
+ compile_deplibs=
+ finalize_deplibs=
+ alldeplibs=no
+ newdlfiles=
+ newdlprefiles=
+ passes="conv scan dlopen dlpreopen link"
+ ;;
+ *) passes="conv"
+ ;;
+ esac
+
+ for pass in $passes; do
+ # The preopen pass in lib mode reverses $deplibs; put it back here
+ # so that -L comes before libs that need it for instance...
+ if test "$linkmode,$pass" = "lib,link"; then
+ ## FIXME: Find the place where the list is rebuilt in the wrong
+ ## order, and fix it there properly
+ tmp_deplibs=
+ for deplib in $deplibs; do
+ tmp_deplibs="$deplib $tmp_deplibs"
+ done
+ deplibs="$tmp_deplibs"
+ fi
+
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan"; then
+ libs="$deplibs"
+ deplibs=
+ fi
+ if test "$linkmode" = prog; then
+ case $pass in
+ dlopen) libs="$dlfiles" ;;
+ dlpreopen) libs="$dlprefiles" ;;
+ link)
+ libs="$deplibs %DEPLIBS%"
+ test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
+ ;;
+ esac
+ fi
+ if test "$linkmode,$pass" = "lib,dlpreopen"; then
+ # Collect and forward deplibs of preopened libtool libs
+ for lib in $dlprefiles; do
+ # Ignore non-libtool-libs
+ dependency_libs=
+ case $lib in
+ *.la) func_source "$lib" ;;
+ esac
+
+ # Collect preopened libtool deplibs, except any this library
+ # has declared as weak libs
+ for deplib in $dependency_libs; do
+ deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
+ case " $weak_libs " in
+ *" $deplib_base "*) ;;
+ *) deplibs="$deplibs $deplib" ;;
+ esac
+ done
+ done
+ libs="$dlprefiles"
+ fi
+ if test "$pass" = dlopen; then
+ # Collect dlpreopened libraries
+ save_deplibs="$deplibs"
+ deplibs=
+ fi
+
+ for deplib in $libs; do
+ lib=
+ found=no
+ case $deplib in
+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ compiler_flags="$compiler_flags $deplib"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -l*)
+ if test "$linkmode" != lib && test "$linkmode" != prog; then
+ func_warning "\`-l' is ignored for archives/objects"
+ continue
+ fi
+ func_stripname '-l' '' "$deplib"
+ name=$func_stripname_result
+ if test "$linkmode" = lib; then
+ searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
+ else
+ searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
+ fi
+ for searchdir in $searchdirs; do
+ for search_ext in .la $std_shrext .so .a; do
+ # Search the libtool library
+ lib="$searchdir/lib${name}${search_ext}"
+ if test -f "$lib"; then
+ if test "$search_ext" = ".la"; then
+ found=yes
+ else
+ found=no
+ fi
+ break 2
+ fi
+ done
+ done
+ if test "$found" != yes; then
+ # deplib doesn't seem to be a libtool library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ else # deplib is a libtool library
+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+ # We need to do some special things here, and not later.
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $deplib "*)
+ if func_lalib_p "$lib"; then
+ library_names=
+ old_library=
+ func_source "$lib"
+ for l in $old_library $library_names; do
+ ll="$l"
+ done
+ if test "X$ll" = "X$old_library" ; then # only static version available
+ found=no
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+ lib=$ladir/$old_library
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+ fi
+ continue
+ fi
+ fi
+ ;;
+ *) ;;
+ esac
+ fi
+ fi
+ ;; # -l
+ *.ltframework)
+ if test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ deplibs="$deplib $deplibs"
+ if test "$linkmode" = lib ; then
+ case "$new_inherited_linker_flags " in
+ *" $deplib "*) ;;
+ * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
+ esac
+ fi
+ fi
+ continue
+ ;;
+ -L*)
+ case $linkmode in
+ lib)
+ deplibs="$deplib $deplibs"
+ test "$pass" = conv && continue
+ newdependency_libs="$deplib $newdependency_libs"
+ func_stripname '-L' '' "$deplib"
+ newlib_search_path="$newlib_search_path $func_stripname_result"
+ ;;
+ prog)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ if test "$pass" = scan; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ func_stripname '-L' '' "$deplib"
+ newlib_search_path="$newlib_search_path $func_stripname_result"
+ ;;
+ *)
+ func_warning "\`-L' is ignored for archives/objects"
+ ;;
+ esac # linkmode
+ continue
+ ;; # -L
+ -R*)
+ if test "$pass" = link; then
+ func_stripname '-R' '' "$deplib"
+ dir=$func_stripname_result
+ # Make sure the xrpath contains only unique directories.
+ case "$xrpath " in
+ *" $dir "*) ;;
+ *) xrpath="$xrpath $dir" ;;
+ esac
+ fi
+ deplibs="$deplib $deplibs"
+ continue
+ ;;
+ *.la) lib="$deplib" ;;
+ *.$libext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ continue
+ fi
+ case $linkmode in
+ lib)
+ # Linking convenience modules into shared libraries is allowed,
+ # but linking other static libraries is non-portable.
+ case " $dlpreconveniencelibs " in
+ *" $deplib "*) ;;
+ *)
+ valid_a_lib=no
+ case $deplibs_check_method in
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
+ | $EGREP "$match_pattern_regex" > /dev/null; then
+ valid_a_lib=yes
+ fi
+ ;;
+ pass_all)
+ valid_a_lib=yes
+ ;;
+ esac
+ if test "$valid_a_lib" != yes; then
+ $ECHO
+ $ECHO "*** Warning: Trying to link with static lib archive $deplib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because the file extensions .$libext of this argument makes me believe"
+ $ECHO "*** that it is just a static archive that I should not use here."
+ else
+ $ECHO
+ $ECHO "*** Warning: Linking the shared library $output against the"
+ $ECHO "*** static library $deplib is not portable!"
+ deplibs="$deplib $deplibs"
+ fi
+ ;;
+ esac
+ continue
+ ;;
+ prog)
+ if test "$pass" != link; then
+ deplibs="$deplib $deplibs"
+ else
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ fi
+ continue
+ ;;
+ esac # linkmode
+ ;; # *.$libext
+ *.lo | *.$objext)
+ if test "$pass" = conv; then
+ deplibs="$deplib $deplibs"
+ elif test "$linkmode" = prog; then
+ if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+ # If there is no dlopen support or we're linking statically,
+ # we need to preload.
+ newdlprefiles="$newdlprefiles $deplib"
+ compile_deplibs="$deplib $compile_deplibs"
+ finalize_deplibs="$deplib $finalize_deplibs"
+ else
+ newdlfiles="$newdlfiles $deplib"
+ fi
+ fi
+ continue
+ ;;
+ %DEPLIBS%)
+ alldeplibs=yes
+ continue
+ ;;
+ esac # case $deplib
+
+ if test "$found" = yes || test -f "$lib"; then :
+ else
+ func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
+ fi
+
+ # Check to see that this really is a libtool archive.
+ func_lalib_unsafe_p "$lib" \
+ || func_fatal_error "\`$lib' is not a valid libtool archive"
+
+ func_dirname "$lib" "" "."
+ ladir="$func_dirname_result"
+
+ dlname=
+ dlopen=
+ dlpreopen=
+ libdir=
+ library_names=
+ old_library=
+ inherited_linker_flags=
+ # If the library was installed with an old release of libtool,
+ # it will not redefine variables installed, or shouldnotlink
+ installed=yes
+ shouldnotlink=no
+ avoidtemprpath=
+
+
+ # Read the .la file
+ func_source "$lib"
+
+ # Convert "-framework foo" to "foo.ltframework"
+ if test -n "$inherited_linker_flags"; then
+ tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
+ for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
+ case " $new_inherited_linker_flags " in
+ *" $tmp_inherited_linker_flag "*) ;;
+ *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
+ esac
+ done
+ fi
+ dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ if test "$linkmode,$pass" = "lib,link" ||
+ test "$linkmode,$pass" = "prog,scan" ||
+ { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+ test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+ test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+ fi
+
+ if test "$pass" = conv; then
+ # Only check for convenience libraries
+ deplibs="$lib $deplibs"
+ if test -z "$libdir"; then
+ if test -z "$old_library"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+ # It is a libtool convenience library, so add in its objects.
+ convenience="$convenience $ladir/$objdir/$old_library"
+ old_convenience="$old_convenience $ladir/$objdir/$old_library"
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ deplibs="$deplib $deplibs"
+ if $opt_duplicate_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+ elif test "$linkmode" != prog && test "$linkmode" != lib; then
+ func_fatal_error "\`$lib' is not a convenience library"
+ fi
+ continue
+ fi # $pass = conv
+
+
+ # Get the name of the library we link against.
+ linklib=
+ for l in $old_library $library_names; do
+ linklib="$l"
+ done
+ if test -z "$linklib"; then
+ func_fatal_error "cannot find name of link library for \`$lib'"
+ fi
+
+ # This library was specified with -dlopen.
+ if test "$pass" = dlopen; then
+ if test -z "$libdir"; then
+ func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
+ fi
+ if test -z "$dlname" ||
+ test "$dlopen_support" != yes ||
+ test "$build_libtool_libs" = no; then
+ # If there is no dlname, no dlopen support or we're linking
+ # statically, we need to preload. We also need to preload any
+ # dependent libraries so libltdl's deplib preloader doesn't
+ # bomb out in the load deplibs phase.
+ dlprefiles="$dlprefiles $lib $dependency_libs"
+ else
+ newdlfiles="$newdlfiles $lib"
+ fi
+ continue
+ fi # $pass = dlopen
+
+ # We need an absolute path.
+ case $ladir in
+ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+ *)
+ abs_ladir=`cd "$ladir" && pwd`
+ if test -z "$abs_ladir"; then
+ func_warning "cannot determine absolute directory name of \`$ladir'"
+ func_warning "passing it literally to the linker, although it might fail"
+ abs_ladir="$ladir"
+ fi
+ ;;
+ esac
+ func_basename "$lib"
+ laname="$func_basename_result"
+
+ # Find the relevant object directory and library name.
+ if test "X$installed" = Xyes; then
+ if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ func_warning "library \`$lib' was moved."
+ dir="$ladir"
+ absdir="$abs_ladir"
+ libdir="$abs_ladir"
+ else
+ dir="$libdir"
+ absdir="$libdir"
+ fi
+ test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+ else
+ if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+ dir="$ladir"
+ absdir="$abs_ladir"
+ # Remove this search path later
+ notinst_path="$notinst_path $abs_ladir"
+ else
+ dir="$ladir/$objdir"
+ absdir="$abs_ladir/$objdir"
+ # Remove this search path later
+ notinst_path="$notinst_path $abs_ladir"
+ fi
+ fi # $installed = yes
+ func_stripname 'lib' '.la' "$laname"
+ name=$func_stripname_result
+
+ # This library was specified with -dlpreopen.
+ if test "$pass" = dlpreopen; then
+ if test -z "$libdir" && test "$linkmode" = prog; then
+ func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
+ fi
+ # Prefer using a static library (so that no silly _DYNAMIC symbols
+ # are required to link).
+ if test -n "$old_library"; then
+ newdlprefiles="$newdlprefiles $dir/$old_library"
+ # Keep a list of preopened convenience libraries to check
+ # that they are being used correctly in the link pass.
+ test -z "$libdir" && \
+ dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
+ # Otherwise, use the dlname, so that lt_dlopen finds it.
+ elif test -n "$dlname"; then
+ newdlprefiles="$newdlprefiles $dir/$dlname"
+ else
+ newdlprefiles="$newdlprefiles $dir/$linklib"
+ fi
+ fi # $pass = dlpreopen
+
+ if test -z "$libdir"; then
+ # Link the convenience library
+ if test "$linkmode" = lib; then
+ deplibs="$dir/$old_library $deplibs"
+ elif test "$linkmode,$pass" = "prog,link"; then
+ compile_deplibs="$dir/$old_library $compile_deplibs"
+ finalize_deplibs="$dir/$old_library $finalize_deplibs"
+ else
+ deplibs="$lib $deplibs" # used for prog,scan pass
+ fi
+ continue
+ fi
+
+
+ if test "$linkmode" = prog && test "$pass" != link; then
+ newlib_search_path="$newlib_search_path $ladir"
+ deplibs="$lib $deplibs"
+
+ linkalldeplibs=no
+ if test "$link_all_deplibs" != no || test -z "$library_names" ||
+ test "$build_libtool_libs" = no; then
+ linkalldeplibs=yes
+ fi
+
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ -L*) func_stripname '-L' '' "$deplib"
+ newlib_search_path="$newlib_search_path $func_stripname_result"
+ ;;
+ esac
+ # Need to link against all dependency_libs?
+ if test "$linkalldeplibs" = yes; then
+ deplibs="$deplib $deplibs"
+ else
+ # Need to hardcode shared library paths
+ # or/and link against static libraries
+ newdependency_libs="$deplib $newdependency_libs"
+ fi
+ if $opt_duplicate_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done # for deplib
+ continue
+ fi # $linkmode = prog...
+
+ if test "$linkmode,$pass" = "prog,link"; then
+ if test -n "$library_names" &&
+ { { test "$prefer_static_libs" = no ||
+ test "$prefer_static_libs,$installed" = "built,yes"; } ||
+ test -z "$old_library"; }; then
+ # We need to hardcode the library path
+ if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+ # Make sure the rpath contains only unique directories.
+ case "$temp_rpath:" in
+ *"$absdir:"*) ;;
+ *) temp_rpath="$temp_rpath$absdir:" ;;
+ esac
+ fi
+
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi # $linkmode,$pass = prog,link...
+
+ if test "$alldeplibs" = yes &&
+ { test "$deplibs_check_method" = pass_all ||
+ { test "$build_libtool_libs" = yes &&
+ test -n "$library_names"; }; }; then
+ # We only need to search for static libraries
+ continue
+ fi
+ fi
+
+ link_static=no # Whether the deplib will be linked statically
+ use_static_libs=$prefer_static_libs
+ if test "$use_static_libs" = built && test "$installed" = yes; then
+ use_static_libs=no
+ fi
+ if test -n "$library_names" &&
+ { test "$use_static_libs" = no || test -z "$old_library"; }; then
+ case $host in
+ *cygwin* | *mingw* | *cegcc*)
+ # No point in relinking DLLs because paths are not encoded
+ notinst_deplibs="$notinst_deplibs $lib"
+ need_relink=no
+ ;;
+ *)
+ if test "$installed" = no; then
+ notinst_deplibs="$notinst_deplibs $lib"
+ need_relink=yes
+ fi
+ ;;
+ esac
+ # This is a shared library
+
+ # Warn about portability, can't link against -module's on some
+ # systems (darwin). Don't bleat about dlopened modules though!
+ dlopenmodule=""
+ for dlpremoduletest in $dlprefiles; do
+ if test "X$dlpremoduletest" = "X$lib"; then
+ dlopenmodule="$dlpremoduletest"
+ break
+ fi
+ done
+ if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
+ $ECHO
+ if test "$linkmode" = prog; then
+ $ECHO "*** Warning: Linking the executable $output against the loadable module"
+ else
+ $ECHO "*** Warning: Linking the shared library $output against the loadable module"
+ fi
+ $ECHO "*** $linklib is not portable!"
+ fi
+ if test "$linkmode" = lib &&
+ test "$hardcode_into_libs" = yes; then
+ # Hardcode the library path.
+ # Skip directories that are in the system default run-time
+ # search path.
+ case " $sys_lib_dlsearch_path " in
+ *" $absdir "*) ;;
+ *)
+ case "$compile_rpath " in
+ *" $absdir "*) ;;
+ *) compile_rpath="$compile_rpath $absdir"
+ esac
+ ;;
+ esac
+ case " $sys_lib_dlsearch_path " in
+ *" $libdir "*) ;;
+ *)
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir"
+ esac
+ ;;
+ esac
+ fi
+
+ if test -n "$old_archive_from_expsyms_cmds"; then
+ # figure out the soname
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ # use dlname if we got it. it's perfectly good, no?
+ if test -n "$dlname"; then
+ soname="$dlname"
+ elif test -n "$soname_spec"; then
+ # bleh windows
+ case $host in
+ *cygwin* | mingw* | *cegcc*)
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+ esac
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+
+ # Make a new name for the extract_expsyms_cmds to use
+ soroot="$soname"
+ func_basename "$soroot"
+ soname="$func_basename_result"
+ func_stripname 'lib' '.dll' "$soname"
+ newlib=libimp-$func_stripname_result.a
+
+ # If the library has no export list, then create one now
+ if test -f "$output_objdir/$soname-def"; then :
+ else
+ func_verbose "extracting exported symbol list from \`$soname'"
+ func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
+ fi
+
+ # Create $newlib
+ if test -f "$output_objdir/$newlib"; then :; else
+ func_verbose "generating import library for \`$soname'"
+ func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
+ fi
+ # make sure the library variables are pointing to the new library
+ dir=$output_objdir
+ linklib=$newlib
+ fi # test -n "$old_archive_from_expsyms_cmds"
+
+ if test "$linkmode" = prog || test "$mode" != relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ lib_linked=yes
+ case $hardcode_action in
+ immediate | unsupported)
+ if test "$hardcode_direct" = no; then
+ add="$dir/$linklib"
+ case $host in
+ *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+ *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+ *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+ *-*-unixware7*) add_dir="-L$dir" ;;
+ *-*-darwin* )
+ # if the lib is a (non-dlopened) module then we can not
+ # link against it, someone is ignoring the earlier warnings
+ if /usr/bin/file -L $add 2> /dev/null |
+ $GREP ": [^:]* bundle" >/dev/null ; then
+ if test "X$dlopenmodule" != "X$lib"; then
+ $ECHO "*** Warning: lib $linklib is a module, not a shared library"
+ if test -z "$old_library" ; then
+ $ECHO
+ $ECHO "*** And there doesn't seem to be a static archive available"
+ $ECHO "*** The link will probably fail, sorry"
+ else
+ add="$dir/$old_library"
+ fi
+ elif test -n "$old_library"; then
+ add="$dir/$old_library"
+ fi
+ fi
+ esac
+ elif test "$hardcode_minus_L" = no; then
+ case $host in
+ *-*-sunos*) add_shlibpath="$dir" ;;
+ esac
+ add_dir="-L$dir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = no; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ relink)
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$dir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$dir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ add_dir="$add_dir -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ add_shlibpath="$dir"
+ add="-l$name"
+ else
+ lib_linked=no
+ fi
+ ;;
+ *) lib_linked=no ;;
+ esac
+
+ if test "$lib_linked" != yes; then
+ func_fatal_configuration "unsupported hardcode properties"
+ fi
+
+ if test -n "$add_shlibpath"; then
+ case :$compile_shlibpath: in
+ *":$add_shlibpath:"*) ;;
+ *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+ esac
+ fi
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+ test -n "$add" && compile_deplibs="$add $compile_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ if test "$hardcode_direct" != yes &&
+ test "$hardcode_minus_L" != yes &&
+ test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ fi
+ fi
+ fi
+
+ if test "$linkmode" = prog || test "$mode" = relink; then
+ add_shlibpath=
+ add_dir=
+ add=
+ # Finalize command for both is simple: just hardcode it.
+ if test "$hardcode_direct" = yes &&
+ test "$hardcode_direct_absolute" = no; then
+ add="$libdir/$linklib"
+ elif test "$hardcode_minus_L" = yes; then
+ add_dir="-L$libdir"
+ add="-l$name"
+ elif test "$hardcode_shlibpath_var" = yes; then
+ case :$finalize_shlibpath: in
+ *":$libdir:"*) ;;
+ *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+ esac
+ add="-l$name"
+ elif test "$hardcode_automatic" = yes; then
+ if test -n "$inst_prefix_dir" &&
+ test -f "$inst_prefix_dir$libdir/$linklib" ; then
+ add="$inst_prefix_dir$libdir/$linklib"
+ else
+ add="$libdir/$linklib"
+ fi
+ else
+ # We cannot seem to hardcode it, guess we'll fake it.
+ add_dir="-L$libdir"
+ # Try looking first in the location we're being installed to.
+ if test -n "$inst_prefix_dir"; then
+ case $libdir in
+ [\\/]*)
+ add_dir="$add_dir -L$inst_prefix_dir$libdir"
+ ;;
+ esac
+ fi
+ add="-l$name"
+ fi
+
+ if test "$linkmode" = prog; then
+ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+ test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+ else
+ test -n "$add_dir" && deplibs="$add_dir $deplibs"
+ test -n "$add" && deplibs="$add $deplibs"
+ fi
+ fi
+ elif test "$linkmode" = prog; then
+ # Here we assume that one of hardcode_direct or hardcode_minus_L
+ # is not unsupported. This is valid on all known static and
+ # shared platforms.
+ if test "$hardcode_direct" != unsupported; then
+ test -n "$old_library" && linklib="$old_library"
+ compile_deplibs="$dir/$linklib $compile_deplibs"
+ finalize_deplibs="$dir/$linklib $finalize_deplibs"
+ else
+ compile_deplibs="-l$name -L$dir $compile_deplibs"
+ finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+ fi
+ elif test "$build_libtool_libs" = yes; then
+ # Not a shared library
+ if test "$deplibs_check_method" != pass_all; then
+ # We're trying link a shared library against a static one
+ # but the system doesn't support it.
+
+ # Just print a warning and add the library to dependency_libs so
+ # that the program can be linked against the static library.
+ $ECHO
+ $ECHO "*** Warning: This system can not link to static lib archive $lib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have."
+ if test "$module" = yes; then
+ $ECHO "*** But as you try to build a module library, libtool will still create "
+ $ECHO "*** a static module, that should work as long as the dlopening application"
+ $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
+ if test -z "$global_symbol_pipe"; then
+ $ECHO
+ $ECHO "*** However, this would only work if libtool was able to extract symbol"
+ $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $ECHO "*** not find such a program. So, this module is probably useless."
+ $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ else
+ deplibs="$dir/$old_library $deplibs"
+ link_static=yes
+ fi
+ fi # link shared/static library?
+
+ if test "$linkmode" = lib; then
+ if test -n "$dependency_libs" &&
+ { test "$hardcode_into_libs" != yes ||
+ test "$build_old_libs" = yes ||
+ test "$link_static" = yes; }; then
+ # Extract -R from dependency_libs
+ temp_deplibs=
+ for libdir in $dependency_libs; do
+ case $libdir in
+ -R*) func_stripname '-R' '' "$libdir"
+ temp_xrpath=$func_stripname_result
+ case " $xrpath " in
+ *" $temp_xrpath "*) ;;
+ *) xrpath="$xrpath $temp_xrpath";;
+ esac;;
+ *) temp_deplibs="$temp_deplibs $libdir";;
+ esac
+ done
+ dependency_libs="$temp_deplibs"
+ fi
+
+ newlib_search_path="$newlib_search_path $absdir"
+ # Link against this library
+ test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+ # ... and its dependency_libs
+ tmp_libs=
+ for deplib in $dependency_libs; do
+ newdependency_libs="$deplib $newdependency_libs"
+ if $opt_duplicate_deps ; then
+ case "$tmp_libs " in
+ *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+ esac
+ fi
+ tmp_libs="$tmp_libs $deplib"
+ done
+
+ if test "$link_all_deplibs" != no; then
+ # Add the search paths of all dependency libraries
+ for deplib in $dependency_libs; do
+ path=
+ case $deplib in
+ -L*) path="$deplib" ;;
+ *.la)
+ func_dirname "$deplib" "" "."
+ dir="$func_dirname_result"
+ # We need an absolute path.
+ case $dir in
+ [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+ *)
+ absdir=`cd "$dir" && pwd`
+ if test -z "$absdir"; then
+ func_warning "cannot determine absolute directory name of \`$dir'"
+ absdir="$dir"
+ fi
+ ;;
+ esac
+ if $GREP "^installed=no" $deplib > /dev/null; then
+ case $host in
+ *-*-darwin*)
+ depdepl=
+ eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+ if test -n "$deplibrary_names" ; then
+ for tmp in $deplibrary_names ; do
+ depdepl=$tmp
+ done
+ if test -f "$absdir/$objdir/$depdepl" ; then
+ depdepl="$absdir/$objdir/$depdepl"
+ darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ if test -z "$darwin_install_name"; then
+ darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
+ fi
+ compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
+ linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
+ path=
+ fi
+ fi
+ ;;
+ *)
+ path="-L$absdir/$objdir"
+ ;;
+ esac
+ else
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ test "$absdir" != "$libdir" && \
+ func_warning "\`$deplib' seems to be moved"
+
+ path="-L$absdir"
+ fi
+ ;;
+ esac
+ case " $deplibs " in
+ *" $path "*) ;;
+ *) deplibs="$path $deplibs" ;;
+ esac
+ done
+ fi # link_all_deplibs != no
+ fi # linkmode = lib
+ done # for deplib in $libs
+ if test "$pass" = link; then
+ if test "$linkmode" = "prog"; then
+ compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
+ finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
+ else
+ compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ fi
+ fi
+ dependency_libs="$newdependency_libs"
+ if test "$pass" = dlpreopen; then
+ # Link the dlpreopened libraries before other libraries
+ for deplib in $save_deplibs; do
+ deplibs="$deplib $deplibs"
+ done
+ fi
+ if test "$pass" != dlopen; then
+ if test "$pass" != conv; then
+ # Make sure lib_search_path contains only unique directories.
+ lib_search_path=
+ for dir in $newlib_search_path; do
+ case "$lib_search_path " in
+ *" $dir "*) ;;
+ *) lib_search_path="$lib_search_path $dir" ;;
+ esac
+ done
+ newlib_search_path=
+ fi
+
+ if test "$linkmode,$pass" != "prog,link"; then
+ vars="deplibs"
+ else
+ vars="compile_deplibs finalize_deplibs"
+ fi
+ for var in $vars dependency_libs; do
+ # Add libraries to $var in reverse order
+ eval tmp_libs=\"\$$var\"
+ new_libs=
+ for deplib in $tmp_libs; do
+ # FIXME: Pedantically, this is the right thing to do, so
+ # that some nasty dependency loop isn't accidentally
+ # broken:
+ #new_libs="$deplib $new_libs"
+ # Pragmatically, this seems to cause very few problems in
+ # practice:
+ case $deplib in
+ -L*) new_libs="$deplib $new_libs" ;;
+ -R*) ;;
+ *)
+ # And here is the reason: when a library appears more
+ # than once as an explicit dependence of a library, or
+ # is implicitly linked in more than once by the
+ # compiler, it is considered special, and multiple
+ # occurrences thereof are not removed. Compare this
+ # with having the same library being listed as a
+ # dependency of multiple other libraries: in this case,
+ # we know (pedantically, we assume) the library does not
+ # need to be listed more than once, so we keep only the
+ # last copy. This is not always right, but it is rare
+ # enough that we require users that really mean to play
+ # such unportable linking tricks to link the library
+ # using -Wl,-lname, so that libtool does not consider it
+ # for duplicate removal.
+ case " $specialdeplibs " in
+ *" $deplib "*) new_libs="$deplib $new_libs" ;;
+ *)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$deplib $new_libs" ;;
+ esac
+ ;;
+ esac
+ ;;
+ esac
+ done
+ tmp_libs=
+ for deplib in $new_libs; do
+ case $deplib in
+ -L*)
+ case " $tmp_libs " in
+ *" $deplib "*) ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ ;;
+ *) tmp_libs="$tmp_libs $deplib" ;;
+ esac
+ done
+ eval $var=\"$tmp_libs\"
+ done # for var
+ fi
+ # Last step: remove runtime libs from dependency_libs
+ # (they stay in deplibs)
+ tmp_libs=
+ for i in $dependency_libs ; do
+ case " $predeps $postdeps $compiler_lib_search_path " in
+ *" $i "*)
+ i=""
+ ;;
+ esac
+ if test -n "$i" ; then
+ tmp_libs="$tmp_libs $i"
+ fi
+ done
+ dependency_libs=$tmp_libs
+ done # for pass
+ if test "$linkmode" = prog; then
+ dlfiles="$newdlfiles"
+ fi
+ if test "$linkmode" = prog || test "$linkmode" = lib; then
+ dlprefiles="$newdlprefiles"
+ fi
+
+ case $linkmode in
+ oldlib)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for archives"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for archives" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for archives"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for archives"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for archives"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for archives"
+
+ test -n "$export_symbols$export_symbols_regex" && \
+ func_warning "\`-export-symbols' is ignored for archives"
+
+ # Now set the variables for building old libraries.
+ build_libtool_libs=no
+ oldlibs="$output"
+ objs="$objs$old_deplibs"
+ ;;
+
+ lib)
+ # Make sure we only generate libraries of the form `libNAME.la'.
+ case $outputname in
+ lib*)
+ func_stripname 'lib' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ ;;
+ *)
+ test "$module" = no && \
+ func_fatal_help "libtool library \`$output' must begin with \`lib'"
+
+ if test "$need_lib_prefix" != no; then
+ # Add the "lib" prefix for modules if required
+ func_stripname '' '.la' "$outputname"
+ name=$func_stripname_result
+ eval shared_ext=\"$shrext_cmds\"
+ eval libname=\"$libname_spec\"
+ else
+ func_stripname '' '.la' "$outputname"
+ libname=$func_stripname_result
+ fi
+ ;;
+ esac
+
+ if test -n "$objs"; then
+ if test "$deplibs_check_method" != pass_all; then
+ func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
+ else
+ $ECHO
+ $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
+ $ECHO "*** objects $objs is not portable!"
+ libobjs="$libobjs $objs"
+ fi
+ fi
+
+ test "$dlself" != no && \
+ func_warning "\`-dlopen self' is ignored for libtool libraries"
+
+ set dummy $rpath
+ shift
+ test "$#" -gt 1 && \
+ func_warning "ignoring multiple \`-rpath's for a libtool library"
+
+ install_libdir="$1"
+
+ oldlibs=
+ if test -z "$rpath"; then
+ if test "$build_libtool_libs" = yes; then
+ # Building a libtool convenience library.
+ # Some compilers have problems with a `.al' extension so
+ # convenience libraries should have the same extension an
+ # archive normally would.
+ oldlibs="$output_objdir/$libname.$libext $oldlibs"
+ build_libtool_libs=convenience
+ build_old_libs=yes
+ fi
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for convenience libraries"
+ else
+
+ # Parse the version information argument.
+ save_ifs="$IFS"; IFS=':'
+ set dummy $vinfo 0 0 0
+ shift
+ IFS="$save_ifs"
+
+ test -n "$7" && \
+ func_fatal_help "too many parameters to \`-version-info'"
+
+ # convert absolute version numbers to libtool ages
+ # this retains compatibility with .la files and attempts
+ # to make the code below a bit more comprehensible
+
+ case $vinfo_number in
+ yes)
+ number_major="$1"
+ number_minor="$2"
+ number_revision="$3"
+ #
+ # There are really only two kinds -- those that
+ # use the current revision as the major version
+ # and those that subtract age and use age as
+ # a minor version. But, then there is irix
+ # which has an extra 1 added just for fun
+ #
+ case $version_type in
+ darwin|linux|osf|windows|none)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_revision"
+ ;;
+ freebsd-aout|freebsd-elf|sunos)
+ current="$number_major"
+ revision="$number_minor"
+ age="0"
+ ;;
+ irix|nonstopux)
+ func_arith $number_major + $number_minor
+ current=$func_arith_result
+ age="$number_minor"
+ revision="$number_minor"
+ lt_irix_increment=no
+ ;;
+ *)
+ func_fatal_configuration "$modename: unknown library version type \`$version_type'"
+ ;;
+ esac
+ ;;
+ no)
+ current="$1"
+ revision="$2"
+ age="$3"
+ ;;
+ esac
+
+ # Check that each of the things are valid numbers.
+ case $current in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "CURRENT \`$current' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $revision in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "REVISION \`$revision' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ case $age in
+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+ *)
+ func_error "AGE \`$age' must be a nonnegative integer"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ ;;
+ esac
+
+ if test "$age" -gt "$current"; then
+ func_error "AGE \`$age' is greater than the current interface number \`$current'"
+ func_fatal_error "\`$vinfo' is not valid version information"
+ fi
+
+ # Calculate the version variables.
+ major=
+ versuffix=
+ verstring=
+ case $version_type in
+ none) ;;
+
+ darwin)
+ # Like Linux, but with the current version available in
+ # verstring for coding it into the library header
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ # Darwin ld doesn't like 0 for these options...
+ func_arith $current + 1
+ minor_current=$func_arith_result
+ xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
+ ;;
+
+ freebsd-aout)
+ major=".$current"
+ versuffix=".$current.$revision";
+ ;;
+
+ freebsd-elf)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ irix | nonstopux)
+ if test "X$lt_irix_increment" = "Xno"; then
+ func_arith $current - $age
+ else
+ func_arith $current - $age + 1
+ fi
+ major=$func_arith_result
+
+ case $version_type in
+ nonstopux) verstring_prefix=nonstopux ;;
+ *) verstring_prefix=sgi ;;
+ esac
+ verstring="$verstring_prefix$major.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$revision
+ while test "$loop" -ne 0; do
+ func_arith $revision - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring_prefix$major.$iface:$verstring"
+ done
+
+ # Before this point, $major must not contain `.'.
+ major=.$major
+ versuffix="$major.$revision"
+ ;;
+
+ linux)
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix="$major.$age.$revision"
+ ;;
+
+ osf)
+ func_arith $current - $age
+ major=.$func_arith_result
+ versuffix=".$current.$age.$revision"
+ verstring="$current.$age.$revision"
+
+ # Add in all the interfaces that we are compatible with.
+ loop=$age
+ while test "$loop" -ne 0; do
+ func_arith $current - $loop
+ iface=$func_arith_result
+ func_arith $loop - 1
+ loop=$func_arith_result
+ verstring="$verstring:${iface}.0"
+ done
+
+ # Make executables depend on our current version.
+ verstring="$verstring:${current}.0"
+ ;;
+
+ qnx)
+ major=".$current"
+ versuffix=".$current"
+ ;;
+
+ sunos)
+ major=".$current"
+ versuffix=".$current.$revision"
+ ;;
+
+ windows)
+ # Use '-' rather than '.', since we only want one
+ # extension on DOS 8.3 filesystems.
+ func_arith $current - $age
+ major=$func_arith_result
+ versuffix="-$major"
+ ;;
+
+ *)
+ func_fatal_configuration "unknown library version type \`$version_type'"
+ ;;
+ esac
+
+ # Clear the version info if we defaulted, and they specified a release.
+ if test -z "$vinfo" && test -n "$release"; then
+ major=
+ case $version_type in
+ darwin)
+ # we can't check for "0.0" in archive_cmds due to quoting
+ # problems, so we reset it completely
+ verstring=
+ ;;
+ *)
+ verstring="0.0"
+ ;;
+ esac
+ if test "$need_version" = no; then
+ versuffix=
+ else
+ versuffix=".0.0"
+ fi
+ fi
+
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_version" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
+ # Check to see if the archive will have undefined symbols.
+ if test "$allow_undefined" = yes; then
+ if test "$allow_undefined_flag" = unsupported; then
+ func_warning "undefined symbols not allowed in $host shared libraries"
+ build_libtool_libs=no
+ build_old_libs=yes
+ fi
+ else
+ # Don't allow undefined symbols.
+ allow_undefined_flag="$no_undefined_flag"
+ fi
+
+ fi
+
+ func_generate_dlsyms "$libname" "$libname" "yes"
+ libobjs="$libobjs $symfileobj"
+ test "X$libobjs" = "X " && libobjs=
+
+ if test "$mode" != relink; then
+ # Remove our outputs, but don't remove object files since they
+ # may have been created when compiling PIC objects.
+ removelist=
+ tempremovelist=`$ECHO "$output_objdir/*"`
+ for p in $tempremovelist; do
+ case $p in
+ *.$objext | *.gcno)
+ ;;
+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+ if test "X$precious_files_regex" != "X"; then
+ if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+ then
+ continue
+ fi
+ fi
+ removelist="$removelist $p"
+ ;;
+ *) ;;
+ esac
+ done
+ test -n "$removelist" && \
+ func_show_eval "${RM}r \$removelist"
+ fi
+
+ # Now set the variables for building old libraries.
+ if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+ oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+ # Transform .lo files to .o files.
+ oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+ fi
+
+ # Eliminate all temporary directories.
+ #for path in $notinst_path; do
+ # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
+ # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
+ # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
+ #done
+
+ if test -n "$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ temp_xrpath=
+ for libdir in $xrpath; do
+ temp_xrpath="$temp_xrpath -R$libdir"
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+ dependency_libs="$temp_xrpath $dependency_libs"
+ fi
+ fi
+
+ # Make sure dlfiles contains only unique files that won't be dlpreopened
+ old_dlfiles="$dlfiles"
+ dlfiles=
+ for lib in $old_dlfiles; do
+ case " $dlprefiles $dlfiles " in
+ *" $lib "*) ;;
+ *) dlfiles="$dlfiles $lib" ;;
+ esac
+ done
+
+ # Make sure dlprefiles contains only unique files
+ old_dlprefiles="$dlprefiles"
+ dlprefiles=
+ for lib in $old_dlprefiles; do
+ case "$dlprefiles " in
+ *" $lib "*) ;;
+ *) dlprefiles="$dlprefiles $lib" ;;
+ esac
+ done
+
+ if test "$build_libtool_libs" = yes; then
+ if test -n "$rpath"; then
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
+ # these systems don't actually have a c library (as such)!
+ ;;
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # Rhapsody C library is in the System framework
+ deplibs="$deplibs System.ltframework"
+ ;;
+ *-*-netbsd*)
+ # Don't link with libc until the a.out ld.so is fixed.
+ ;;
+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+ # Do not include libc due to us having libc/libc_r.
+ ;;
+ *-*-sco3.2v5* | *-*-sco5v6*)
+ # Causes problems with __ctype
+ ;;
+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+ # Compiler inserts libc in the correct place for threads to work
+ ;;
+ *)
+ # Add libc to deplibs on all other systems if necessary.
+ if test "$build_libtool_need_lc" = "yes"; then
+ deplibs="$deplibs -lc"
+ fi
+ ;;
+ esac
+ fi
+
+ # Transform deplibs into only deplibs that can be linked in shared.
+ name_save=$name
+ libname_save=$libname
+ release_save=$release
+ versuffix_save=$versuffix
+ major_save=$major
+ # I'm not sure if I'm treating the release correctly. I think
+ # release should show up in the -l (ie -lgmp5) so we don't want to
+ # add it in twice. Is that correct?
+ release=""
+ versuffix=""
+ major=""
+ newdeplibs=
+ droppeddeps=no
+ case $deplibs_check_method in
+ pass_all)
+ # Don't check for shared/static. Everything works.
+ # This might be a little naive. We might want to check
+ # whether the library exists or not. But this is on
+ # osf3 & osf4 and I'm not really sure... Just
+ # implementing what was already the behavior.
+ newdeplibs=$deplibs
+ ;;
+ test_compile)
+ # This code stresses the "libraries are programs" paradigm to its
+ # limits. Maybe even breaks it. We compile a program, linking it
+ # against the deplibs as a proxy for the library. Then we can check
+ # whether they linked in statically or dynamically with ldd.
+ $opt_dry_run || $RM conftest.c
+ cat > conftest.c <<EOF
+ int main() { return 0; }
+EOF
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
+ ldd_output=`ldd conftest`
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which I believe you do not have"
+ $ECHO "*** because a test_compile did reveal that the linker did not use it for"
+ $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
+ fi
+ fi
+ ;;
+ *)
+ newdeplibs="$newdeplibs $i"
+ ;;
+ esac
+ done
+ else
+ # Error occurred in the first compile. Let's try to salvage
+ # the situation: Compile a separate program for each library.
+ for i in $deplibs; do
+ case $i in
+ -l*)
+ func_stripname -l '' "$i"
+ name=$func_stripname_result
+ $opt_dry_run || $RM conftest
+ if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
+ ldd_output=`ldd conftest`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $i "*)
+ newdeplibs="$newdeplibs $i"
+ i=""
+ ;;
+ esac
+ fi
+ if test -n "$i" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
+ set dummy $deplib_matches; shift
+ deplib_match=$1
+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+ newdeplibs="$newdeplibs $i"
+ else
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because a test_compile did reveal that the linker did not use this one"
+ $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
+ fi
+ fi
+ else
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
+ $ECHO "*** make it link in! You will probably need to install it or some"
+ $ECHO "*** library that it depends on before this library will be fully"
+ $ECHO "*** functional. Installing it before continuing would be even better."
+ fi
+ ;;
+ *)
+ newdeplibs="$newdeplibs $i"
+ ;;
+ esac
+ done
+ fi
+ ;;
+ file_magic*)
+ set dummy $deplibs_check_method; shift
+ file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ # Follow soft links.
+ if ls -lLd "$potent_lib" 2>/dev/null |
+ $GREP " -> " >/dev/null; then
+ continue
+ fi
+ # The statement above tries to avoid entering an
+ # endless loop below, in case of cyclic links.
+ # We might still enter an endless loop, since a link
+ # loop can be closed while we follow links,
+ # but so what?
+ potlib="$potent_lib"
+ while test -h "$potlib" 2>/dev/null; do
+ potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+ case $potliblink in
+ [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+ *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+ esac
+ done
+ if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
+ $SED -e 10q |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a file magic. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ match_pattern*)
+ set dummy $deplibs_check_method; shift
+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
+ for a_deplib in $deplibs; do
+ case $a_deplib in
+ -l*)
+ func_stripname -l '' "$a_deplib"
+ name=$func_stripname_result
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ case " $predeps $postdeps " in
+ *" $a_deplib "*)
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ ;;
+ esac
+ fi
+ if test -n "$a_deplib" ; then
+ libname=`eval "\\$ECHO \"$libname_spec\""`
+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+ for potent_lib in $potential_libs; do
+ potlib="$potent_lib" # see symlink-check above in file_magic test
+ if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
+ $EGREP "$match_pattern_regex" > /dev/null; then
+ newdeplibs="$newdeplibs $a_deplib"
+ a_deplib=""
+ break 2
+ fi
+ done
+ done
+ fi
+ if test -n "$a_deplib" ; then
+ droppeddeps=yes
+ $ECHO
+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
+ $ECHO "*** I have the capability to make that library automatically link in when"
+ $ECHO "*** you link to this library. But I can only do this if you have a"
+ $ECHO "*** shared version of the library, which you do not appear to have"
+ $ECHO "*** because I did check the linker path looking for a file starting"
+ if test -z "$potlib" ; then
+ $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
+ else
+ $ECHO "*** with $libname and none of the candidates passed a file format test"
+ $ECHO "*** using a regex pattern. Last file checked: $potlib"
+ fi
+ fi
+ ;;
+ *)
+ # Add a -L argument.
+ newdeplibs="$newdeplibs $a_deplib"
+ ;;
+ esac
+ done # Gone through all deplibs.
+ ;;
+ none | unknown | *)
+ newdeplibs=""
+ tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
+ -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
+ if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+ for i in $predeps $postdeps ; do
+ # can't use Xsed below, because $i might contain '/'
+ tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
+ done
+ fi
+ if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' |
+ $GREP . >/dev/null; then
+ $ECHO
+ if test "X$deplibs_check_method" = "Xnone"; then
+ $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
+ else
+ $ECHO "*** Warning: inter-library dependencies are not known to be supported."
+ fi
+ $ECHO "*** All declared inter-library dependencies are being dropped."
+ droppeddeps=yes
+ fi
+ ;;
+ esac
+ versuffix=$versuffix_save
+ major=$major_save
+ release=$release_save
+ libname=$libname_save
+ name=$name_save
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library with the System framework
+ newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ if test "$droppeddeps" = yes; then
+ if test "$module" = yes; then
+ $ECHO
+ $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
+ $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
+ $ECHO "*** a static module, that should work as long as the dlopening"
+ $ECHO "*** application is linked with the -dlopen flag."
+ if test -z "$global_symbol_pipe"; then
+ $ECHO
+ $ECHO "*** However, this would only work if libtool was able to extract symbol"
+ $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
+ $ECHO "*** not find such a program. So, this module is probably useless."
+ $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
+ fi
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ else
+ $ECHO "*** The inter-library dependencies that have been dropped here will be"
+ $ECHO "*** automatically added whenever a program is linked with this library"
+ $ECHO "*** or is declared to -dlopen it."
+
+ if test "$allow_undefined" = no; then
+ $ECHO
+ $ECHO "*** Since this library must not contain undefined symbols,"
+ $ECHO "*** because either the platform does not support them or"
+ $ECHO "*** it was explicitly requested with -no-undefined,"
+ $ECHO "*** libtool will only create a static version of it."
+ if test "$build_old_libs" = no; then
+ oldlibs="$output_objdir/$libname.$libext"
+ build_libtool_libs=module
+ build_old_libs=yes
+ else
+ build_libtool_libs=no
+ fi
+ fi
+ fi
+ fi
+ # Done checking deplibs!
+ deplibs=$newdeplibs
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ case $host in
+ *-*-darwin*)
+ newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $deplibs " in
+ *" -L$path/$objdir "*)
+ new_libs="$new_libs -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ done
+ deplibs="$new_libs"
+
+ # All the library-specific variables (install_libdir is set above).
+ library_names=
+ old_library=
+ dlname=
+
+ # Test again, we may have decided not to build it any more
+ if test "$build_libtool_libs" = yes; then
+ if test "$hardcode_into_libs" = yes; then
+ # Hardcode the library paths
+ hardcode_libdirs=
+ dep_rpath=
+ rpath="$finalize_rpath"
+ test "$mode" != relink && rpath="$compile_rpath$rpath"
+ for libdir in $rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ dep_rpath="$dep_rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ if test -n "$hardcode_libdir_flag_spec_ld"; then
+ eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+ else
+ eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+ fi
+ fi
+ if test -n "$runpath_var" && test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+ fi
+ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+ fi
+
+ shlibpath="$finalize_shlibpath"
+ test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+ if test -n "$shlibpath"; then
+ eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+ fi
+
+ # Get the real and link names of the library.
+ eval shared_ext=\"$shrext_cmds\"
+ eval library_names=\"$library_names_spec\"
+ set dummy $library_names
+ shift
+ realname="$1"
+ shift
+
+ if test -n "$soname_spec"; then
+ eval soname=\"$soname_spec\"
+ else
+ soname="$realname"
+ fi
+ if test -z "$dlname"; then
+ dlname=$soname
+ fi
+
+ lib="$output_objdir/$realname"
+ linknames=
+ for link
+ do
+ linknames="$linknames $link"
+ done
+
+ # Use standard objects if they are pic
+ test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ test "X$libobjs" = "X " && libobjs=
+
+ delfiles=
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
+ export_symbols="$output_objdir/$libname.uexp"
+ delfiles="$delfiles $export_symbols"
+ fi
+
+ orig_export_symbols=
+ case $host_os in
+ cygwin* | mingw* | cegcc*)
+ if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
+ # exporting using user supplied symfile
+ if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
+ # and it's NOT already a .def file. Must figure out
+ # which of the given symbols are data symbols and tag
+ # them as such. So, trigger use of export_symbols_cmds.
+ # export_symbols gets reassigned inside the "prepare
+ # the list of exported symbols" if statement, so the
+ # include_expsyms logic still works.
+ orig_export_symbols="$export_symbols"
+ export_symbols=
+ always_export_symbols=yes
+ fi
+ fi
+ ;;
+ esac
+
+ # Prepare the list of exported symbols
+ if test -z "$export_symbols"; then
+ if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ cmds=$export_symbols_cmds
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ eval cmd=\"$cmd\"
+ func_len " $cmd"
+ len=$func_len_result
+ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ func_show_eval "$cmd" 'exit $?'
+ skipped_export=false
+ else
+ # The command line is too long to execute in one step.
+ func_verbose "using reloadable object file for export list..."
+ skipped_export=:
+ # Break out early, otherwise skipped_export may be
+ # set to false by a later but shorter cmd.
+ break
+ fi
+ done
+ IFS="$save_ifs"
+ if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+ fi
+
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+
+ tmp_deplibs=
+ for test_deplib in $deplibs; do
+ case " $convenience " in
+ *" $test_deplib "*) ;;
+ *)
+ tmp_deplibs="$tmp_deplibs $test_deplib"
+ ;;
+ esac
+ done
+ deplibs="$tmp_deplibs"
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec" &&
+ test "$compiler_needs_object" = yes &&
+ test -z "$libobjs"; then
+ # extract the archives, so we have objects to list.
+ # TODO: could optimize this to just extract one archive.
+ whole_archive_flag_spec=
+ fi
+ if test -n "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ else
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $convenience
+ libobjs="$libobjs $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ fi
+
+ if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+ eval flag=\"$thread_safe_flag_spec\"
+ linker_flags="$linker_flags $flag"
+ fi
+
+ # Make a backup of the uninstalled library when relinking
+ if test "$mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
+ fi
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ eval test_cmds=\"$module_expsym_cmds\"
+ cmds=$module_expsym_cmds
+ else
+ eval test_cmds=\"$module_cmds\"
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ eval test_cmds=\"$archive_expsym_cmds\"
+ cmds=$archive_expsym_cmds
+ else
+ eval test_cmds=\"$archive_cmds\"
+ cmds=$archive_cmds
+ fi
+ fi
+
+ if test "X$skipped_export" != "X:" &&
+ func_len " $test_cmds" &&
+ len=$func_len_result &&
+ test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ :
+ else
+ # The command line is too long to link in one step, link piecewise
+ # or, if using GNU ld and skipped_export is not :, use a linker
+ # script.
+
+ # Save the value of $output and $libobjs because we want to
+ # use them later. If we have whole_archive_flag_spec, we
+ # want to use save_libobjs as it was before
+ # whole_archive_flag_spec was expanded, because we can't
+ # assume the linker understands whole_archive_flag_spec.
+ # This may have to be revisited, in case too many
+ # convenience libraries get linked in and end up exceeding
+ # the spec.
+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+ save_libobjs=$libobjs
+ fi
+ save_output=$output
+ output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
+
+ # Clear the reloadable object creation command queue and
+ # initialize k to one.
+ test_cmds=
+ concat_cmds=
+ objlist=
+ last_robj=
+ k=1
+
+ if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
+ output=${output_objdir}/${output_la}.lnkscript
+ func_verbose "creating GNU ld script: $output"
+ $ECHO 'INPUT (' > $output
+ for obj in $save_libobjs
+ do
+ $ECHO "$obj" >> $output
+ done
+ $ECHO ')' >> $output
+ delfiles="$delfiles $output"
+ elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
+ output=${output_objdir}/${output_la}.lnk
+ func_verbose "creating linker input file list: $output"
+ : > $output
+ set x $save_libobjs
+ shift
+ firstobj=
+ if test "$compiler_needs_object" = yes; then
+ firstobj="$1 "
+ shift
+ fi
+ for obj
+ do
+ $ECHO "$obj" >> $output
+ done
+ delfiles="$delfiles $output"
+ output=$firstobj\"$file_list_spec$output\"
+ else
+ if test -n "$save_libobjs"; then
+ func_verbose "creating reloadable object files..."
+ output=$output_objdir/$output_la-${k}.$objext
+ eval test_cmds=\"$reload_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+
+ # Loop over the list of objects to be linked.
+ for obj in $save_libobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ if test "X$objlist" = X ||
+ test "$len" -lt "$max_cmd_len"; then
+ func_append objlist " $obj"
+ else
+ # The command $test_cmds is almost too long, add a
+ # command to the queue.
+ if test "$k" -eq 1 ; then
+ # The first file doesn't have a previous command to add.
+ eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+ else
+ # All subsequent reloadable object files will link in
+ # the last one created.
+ eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
+ fi
+ last_robj=$output_objdir/$output_la-${k}.$objext
+ func_arith $k + 1
+ k=$func_arith_result
+ output=$output_objdir/$output_la-${k}.$objext
+ objlist=$obj
+ func_len " $last_robj"
+ func_arith $len0 + $func_len_result
+ len=$func_arith_result
+ fi
+ done
+ # Handle the remaining objects by creating one last
+ # reloadable object file. All subsequent reloadable object
+ # files will link in the last one created.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
+ fi
+ delfiles="$delfiles $output"
+
+ else
+ output=
+ fi
+
+ if ${skipped_export-false}; then
+ func_verbose "generating symbol list for \`$libname.la'"
+ export_symbols="$output_objdir/$libname.exp"
+ $opt_dry_run || $RM $export_symbols
+ libobjs=$output
+ # Append the command to create the export file.
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
+ if test -n "$last_robj"; then
+ eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
+ fi
+ fi
+
+ test -n "$save_libobjs" &&
+ func_verbose "creating a temporary reloadable object file: $output"
+
+ # Loop through the commands generated above and execute them.
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $concat_cmds; do
+ IFS="$save_ifs"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ if test -n "$export_symbols_regex" && ${skipped_export-false}; then
+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
+ fi
+ fi
+
+ if ${skipped_export-false}; then
+ if test -n "$export_symbols" && test -n "$include_expsyms"; then
+ tmp_export_symbols="$export_symbols"
+ test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
+ $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
+ fi
+
+ if test -n "$orig_export_symbols"; then
+ # The given exports_symbols file has to be filtered, so filter it.
+ func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
+ # FIXME: $output_objdir/$libname.filter potentially contains lots of
+ # 's' commands which not all seds can handle. GNU sed should be fine
+ # though. Also, the filter scales superlinearly with the number of
+ # global variables. join(1) would be nice here, but unfortunately
+ # isn't a blessed tool.
+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
+ delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
+ export_symbols=$output_objdir/$libname.def
+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
+ fi
+ fi
+
+ libobjs=$output
+ # Restore the value of output.
+ output=$save_output
+
+ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+ # Expand the library linking commands again to reset the
+ # value of $libobjs for piecewise linking.
+
+ # Do each of the archive commands.
+ if test "$module" = yes && test -n "$module_cmds" ; then
+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+ cmds=$module_expsym_cmds
+ else
+ cmds=$module_cmds
+ fi
+ else
+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+ cmds=$archive_expsym_cmds
+ else
+ cmds=$archive_cmds
+ fi
+ fi
+ fi
+
+ if test -n "$delfiles"; then
+ # Append the command to remove temporary files to $cmds.
+ eval cmds=\"\$cmds~\$RM $delfiles\"
+ fi
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ libobjs="$libobjs $func_extract_archives_result"
+ test "X$libobjs" = "X " && libobjs=
+ fi
+
+ save_ifs="$IFS"; IFS='~'
+ for cmd in $cmds; do
+ IFS="$save_ifs"
+ eval cmd=\"$cmd\"
+ $opt_silent || {
+ func_quote_for_expand "$cmd"
+ eval "func_echo $func_quote_for_expand_result"
+ }
+ $opt_dry_run || eval "$cmd" || {
+ lt_exit=$?
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ ( cd "$output_objdir" && \
+ $RM "${realname}T" && \
+ $MV "${realname}U" "$realname" )
+ fi
+
+ exit $lt_exit
+ }
+ done
+ IFS="$save_ifs"
+
+ # Restore the uninstalled library and exit
+ if test "$mode" = relink; then
+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
+
+ if test -n "$convenience"; then
+ if test -z "$whole_archive_flag_spec"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ # Create links to the real library.
+ for linkname in $linknames; do
+ if test "$realname" != "$linkname"; then
+ func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
+ fi
+ done
+
+ # If -module or -export-dynamic was specified, set the dlname.
+ if test "$module" = yes || test "$export_dynamic" = yes; then
+ # On all known operating systems, these are identical.
+ dlname="$soname"
+ fi
+ fi
+ ;;
+
+ obj)
+ if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+ func_warning "\`-dlopen' is ignored for objects"
+ fi
+
+ case " $deplibs" in
+ *\ -l* | *\ -L*)
+ func_warning "\`-l' and \`-L' are ignored for objects" ;;
+ esac
+
+ test -n "$rpath" && \
+ func_warning "\`-rpath' is ignored for objects"
+
+ test -n "$xrpath" && \
+ func_warning "\`-R' is ignored for objects"
+
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for objects"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for objects"
+
+ case $output in
+ *.lo)
+ test -n "$objs$old_deplibs" && \
+ func_fatal_error "cannot build library object \`$output' from non-libtool objects"
+
+ libobj=$output
+ func_lo2o "$libobj"
+ obj=$func_lo2o_result
+ ;;
+ *)
+ libobj=
+ obj="$output"
+ ;;
+ esac
+
+ # Delete the old objects.
+ $opt_dry_run || $RM $obj $libobj
+
+ # Objects from convenience libraries. This assumes
+ # single-version convenience libraries. Whenever we create
+ # different ones for PIC/non-PIC, this we'll have to duplicate
+ # the extraction.
+ reload_conv_objs=
+ gentop=
+ # reload_cmds runs $LD directly, so let us get rid of
+ # -Wl from whole_archive_flag_spec and hope we can get by with
+ # turning comma into space..
+ wl=
+
+ if test -n "$convenience"; then
+ if test -n "$whole_archive_flag_spec"; then
+ eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
+ reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
+ else
+ gentop="$output_objdir/${obj}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $convenience
+ reload_conv_objs="$reload_objs $func_extract_archives_result"
+ fi
+ fi
+
+ # Create the old-style object.
+ reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+ output="$obj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+
+ # Exit if we aren't doing a library object file.
+ if test -z "$libobj"; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$build_libtool_libs" != yes; then
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ # Create an invalid libtool object if no PIC, so that we don't
+ # accidentally link it into a program.
+ # $show "echo timestamp > $libobj"
+ # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
+ exit $EXIT_SUCCESS
+ fi
+
+ if test -n "$pic_flag" || test "$pic_mode" != default; then
+ # Only do commands if we really have different PIC objects.
+ reload_objs="$libobjs $reload_conv_objs"
+ output="$libobj"
+ func_execute_cmds "$reload_cmds" 'exit $?'
+ fi
+
+ if test -n "$gentop"; then
+ func_show_eval '${RM}r "$gentop"'
+ fi
+
+ exit $EXIT_SUCCESS
+ ;;
+
+ prog)
+ case $host in
+ *cygwin*) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result.exe;;
+ esac
+ test -n "$vinfo" && \
+ func_warning "\`-version-info' is ignored for programs"
+
+ test -n "$release" && \
+ func_warning "\`-release' is ignored for programs"
+
+ test "$preload" = yes \
+ && test "$dlopen_support" = unknown \
+ && test "$dlopen_self" = unknown \
+ && test "$dlopen_self_static" = unknown && \
+ func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
+
+ case $host in
+ *-*-rhapsody* | *-*-darwin1.[012])
+ # On Rhapsody replace the C library is the System framework
+ compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+ finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
+ ;;
+ esac
+
+ case $host in
+ *-*-darwin*)
+ # Don't allow lazy linking, it breaks C++ global constructors
+ # But is supposedly fixed on 10.4 or later (yay!).
+ if test "$tagname" = CXX ; then
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
+ 10.[0123])
+ compile_command="$compile_command ${wl}-bind_at_load"
+ finalize_command="$finalize_command ${wl}-bind_at_load"
+ ;;
+ esac
+ fi
+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"
+ compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
+ ;;
+ esac
+
+
+ # move library search paths that coincide with paths to not yet
+ # installed libraries to the beginning of the library search list
+ new_libs=
+ for path in $notinst_path; do
+ case " $new_libs " in
+ *" -L$path/$objdir "*) ;;
+ *)
+ case " $compile_deplibs " in
+ *" -L$path/$objdir "*)
+ new_libs="$new_libs -L$path/$objdir" ;;
+ esac
+ ;;
+ esac
+ done
+ for deplib in $compile_deplibs; do
+ case $deplib in
+ -L*)
+ case " $new_libs " in
+ *" $deplib "*) ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ ;;
+ *) new_libs="$new_libs $deplib" ;;
+ esac
+ done
+ compile_deplibs="$new_libs"
+
+
+ compile_command="$compile_command $compile_deplibs"
+ finalize_command="$finalize_command $finalize_deplibs"
+
+ if test -n "$rpath$xrpath"; then
+ # If the user specified any rpath flags, then add them.
+ for libdir in $rpath $xrpath; do
+ # This is the magic to use -rpath.
+ case "$finalize_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_rpath="$finalize_rpath $libdir" ;;
+ esac
+ done
+ fi
+
+ # Now hardcode the library paths
+ rpath=
+ hardcode_libdirs=
+ for libdir in $compile_rpath $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$perm_rpath " in
+ *" $libdir "*) ;;
+ *) perm_rpath="$perm_rpath $libdir" ;;
+ esac
+ fi
+ case $host in
+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
+ testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
+ case :$dllsearchpath: in
+ *":$libdir:"*) ;;
+ ::) dllsearchpath=$libdir;;
+ *) dllsearchpath="$dllsearchpath:$libdir";;
+ esac
+ case :$dllsearchpath: in
+ *":$testbindir:"*) ;;
+ ::) dllsearchpath=$testbindir;;
+ *) dllsearchpath="$dllsearchpath:$testbindir";;
+ esac
+ ;;
+ esac
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ compile_rpath="$rpath"
+
+ rpath=
+ hardcode_libdirs=
+ for libdir in $finalize_rpath; do
+ if test -n "$hardcode_libdir_flag_spec"; then
+ if test -n "$hardcode_libdir_separator"; then
+ if test -z "$hardcode_libdirs"; then
+ hardcode_libdirs="$libdir"
+ else
+ # Just accumulate the unique libdirs.
+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+ ;;
+ *)
+ hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+ ;;
+ esac
+ fi
+ else
+ eval flag=\"$hardcode_libdir_flag_spec\"
+ rpath="$rpath $flag"
+ fi
+ elif test -n "$runpath_var"; then
+ case "$finalize_perm_rpath " in
+ *" $libdir "*) ;;
+ *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+ esac
+ fi
+ done
+ # Substitute the hardcoded libdirs into the rpath.
+ if test -n "$hardcode_libdir_separator" &&
+ test -n "$hardcode_libdirs"; then
+ libdir="$hardcode_libdirs"
+ eval rpath=\" $hardcode_libdir_flag_spec\"
+ fi
+ finalize_rpath="$rpath"
+
+ if test -n "$libobjs" && test "$build_old_libs" = yes; then
+ # Transform all the library objects into standard objects.
+ compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ fi
+
+ func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
+
+ # template prelinking step
+ if test -n "$prelink_cmds"; then
+ func_execute_cmds "$prelink_cmds" 'exit $?'
+ fi
+
+ wrappers_required=yes
+ case $host in
+ *cygwin* | *mingw* )
+ if test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ *cegcc)
+ # Disable wrappers for cegcc, we are cross compiling anyway.
+ wrappers_required=no
+ ;;
+ *)
+ if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+ wrappers_required=no
+ fi
+ ;;
+ esac
+ if test "$wrappers_required" = no; then
+ # Replace the output file specification.
+ compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ link_command="$compile_command$compile_rpath"
+
+ # We have no uninstalled library dependencies, so finalize right now.
+ exit_status=0
+ func_show_eval "$link_command" 'exit_status=$?'
+
+ # Delete the generated files.
+ if test -f "$output_objdir/${outputname}S.${objext}"; then
+ func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
+ fi
+
+ exit $exit_status
+ fi
+
+ if test -n "$compile_shlibpath$finalize_shlibpath"; then
+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+ fi
+ if test -n "$finalize_shlibpath"; then
+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+ fi
+
+ compile_var=
+ finalize_var=
+ if test -n "$runpath_var"; then
+ if test -n "$perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ if test -n "$finalize_perm_rpath"; then
+ # We should set the runpath_var.
+ rpath=
+ for dir in $finalize_perm_rpath; do
+ rpath="$rpath$dir:"
+ done
+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+ fi
+ fi
+
+ if test "$no_install" = yes; then
+ # We don't need to create a wrapper script.
+ link_command="$compile_var$compile_command$compile_rpath"
+ # Replace the output file specification.
+ link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+ # Delete the old output file.
+ $opt_dry_run || $RM $output
+ # Link the executable and exit
+ func_show_eval "$link_command" 'exit $?'
+ exit $EXIT_SUCCESS
+ fi
+
+ if test "$hardcode_action" = relink; then
+ # Fast installation is not supported
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+ func_warning "this platform does not like uninstalled shared libraries"
+ func_warning "\`$output' will be relinked during installation"
+ else
+ if test "$fast_install" != no; then
+ link_command="$finalize_var$compile_command$finalize_rpath"
+ if test "$fast_install" = yes; then
+ relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+ else
+ # fast_install is set to needless
+ relink_command=
+ fi
+ else
+ link_command="$compile_var$compile_command$compile_rpath"
+ relink_command="$finalize_var$finalize_command$finalize_rpath"
+ fi
+ fi
+
+ # Replace the output file specification.
+ link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+ # Delete the old output files.
+ $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+ func_show_eval "$link_command" 'exit $?'
+
+ # Now create the wrapper script.
+ func_verbose "creating $output"
+
+ # Quote the relink command for shipping.
+ if test -n "$relink_command"; then
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ relink_command="(cd `pwd`; $relink_command)"
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Quote $ECHO for shipping.
+ if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
+ case $progpath in
+ [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+ *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+ esac
+ qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
+ else
+ qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
+ fi
+
+ # Only actually do things if not in dry run mode.
+ $opt_dry_run || {
+ # win32 will think the script is a binary if it has
+ # a .exe suffix, so we strip it off here.
+ case $output in
+ *.exe) func_stripname '' '.exe' "$output"
+ output=$func_stripname_result ;;
+ esac
+ # test for cygwin because mv fails w/o .exe extensions
+ case $host in
+ *cygwin*)
+ exeext=.exe
+ func_stripname '' '.exe' "$outputname"
+ outputname=$func_stripname_result ;;
+ *) exeext= ;;
+ esac
+ case $host in
+ *cygwin* | *mingw* )
+ func_dirname_and_basename "$output" "" "."
+ output_name=$func_basename_result
+ output_path=$func_dirname_result
+ cwrappersource="$output_path/$objdir/lt-$output_name.c"
+ cwrapper="$output_path/$output_name.exe"
+ $RM $cwrappersource $cwrapper
+ trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_cwrapperexe_src > $cwrappersource
+
+ # The wrapper executable is built using the $host compiler,
+ # because it contains $host paths and files. If cross-
+ # compiling, it, like the target executable, must be
+ # executed on the $host or under an emulation environment.
+ $opt_dry_run || {
+ $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
+ $STRIP $cwrapper
+ }
+
+ # Now, create the wrapper script for func_source use:
+ func_ltwrapper_scriptname $cwrapper
+ $RM $func_ltwrapper_scriptname_result
+ trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
+ $opt_dry_run || {
+ # note: this script will not be executed, so do not chmod.
+ if test "x$build" = "x$host" ; then
+ $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
+ else
+ func_emit_wrapper no > $func_ltwrapper_scriptname_result
+ fi
+ }
+ ;;
+ * )
+ $RM $output
+ trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
+
+ func_emit_wrapper no > $output
+ chmod +x $output
+ ;;
+ esac
+ }
+ exit $EXIT_SUCCESS
+ ;;
+ esac
+
+ # See if we need to build an old-fashioned archive.
+ for oldlib in $oldlibs; do
+
+ if test "$build_libtool_libs" = convenience; then
+ oldobjs="$libobjs_save $symfileobj"
+ addlibs="$convenience"
+ build_libtool_libs=no
+ else
+ if test "$build_libtool_libs" = module; then
+ oldobjs="$libobjs_save"
+ build_libtool_libs=no
+ else
+ oldobjs="$old_deplibs $non_pic_objects"
+ if test "$preload" = yes && test -f "$symfileobj"; then
+ oldobjs="$oldobjs $symfileobj"
+ fi
+ fi
+ addlibs="$old_convenience"
+ fi
+
+ if test -n "$addlibs"; then
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $addlibs
+ oldobjs="$oldobjs $func_extract_archives_result"
+ fi
+
+ # Do each command in the archive commands.
+ if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+ cmds=$old_archive_from_new_cmds
+ else
+
+ # Add any objects from preloaded convenience libraries
+ if test -n "$dlprefiles"; then
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+
+ func_extract_archives $gentop $dlprefiles
+ oldobjs="$oldobjs $func_extract_archives_result"
+ fi
+
+ # POSIX demands no paths to be encoded in archives. We have
+ # to avoid creating archives with duplicate basenames if we
+ # might have to extract them afterwards, e.g., when creating a
+ # static archive out of a convenience library, or when linking
+ # the entirety of a libtool archive into another (currently
+ # not supported by libtool).
+ if (for obj in $oldobjs
+ do
+ func_basename "$obj"
+ $ECHO "$func_basename_result"
+ done | sort | sort -uc >/dev/null 2>&1); then
+ :
+ else
+ $ECHO "copying selected object files to avoid basename conflicts..."
+ gentop="$output_objdir/${outputname}x"
+ generated="$generated $gentop"
+ func_mkdir_p "$gentop"
+ save_oldobjs=$oldobjs
+ oldobjs=
+ counter=1
+ for obj in $save_oldobjs
+ do
+ func_basename "$obj"
+ objbase="$func_basename_result"
+ case " $oldobjs " in
+ " ") oldobjs=$obj ;;
+ *[\ /]"$objbase "*)
+ while :; do
+ # Make sure we don't pick an alternate name that also
+ # overlaps.
+ newobj=lt$counter-$objbase
+ func_arith $counter + 1
+ counter=$func_arith_result
+ case " $oldobjs " in
+ *[\ /]"$newobj "*) ;;
+ *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+ esac
+ done
+ func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+ oldobjs="$oldobjs $gentop/$newobj"
+ ;;
+ *) oldobjs="$oldobjs $obj" ;;
+ esac
+ done
+ fi
+ eval cmds=\"$old_archive_cmds\"
+
+ func_len " $cmds"
+ len=$func_len_result
+ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+ cmds=$old_archive_cmds
+ else
+ # the command line is too long to link in one step, link in parts
+ func_verbose "using piecewise archive linking..."
+ save_RANLIB=$RANLIB
+ RANLIB=:
+ objlist=
+ concat_cmds=
+ save_oldobjs=$oldobjs
+ oldobjs=
+ # Is there a better way of finding the last object in the list?
+ for obj in $save_oldobjs
+ do
+ last_oldobj=$obj
+ done
+ eval test_cmds=\"$old_archive_cmds\"
+ func_len " $test_cmds"
+ len0=$func_len_result
+ len=$len0
+ for obj in $save_oldobjs
+ do
+ func_len " $obj"
+ func_arith $len + $func_len_result
+ len=$func_arith_result
+ func_append objlist " $obj"
+ if test "$len" -lt "$max_cmd_len"; then
+ :
+ else
+ # the above command should be used before it gets too long
+ oldobjs=$objlist
+ if test "$obj" = "$last_oldobj" ; then
+ RANLIB=$save_RANLIB
+ fi
+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+ eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+ objlist=
+ len=$len0
+ fi
+ done
+ RANLIB=$save_RANLIB
+ oldobjs=$objlist
+ if test "X$oldobjs" = "X" ; then
+ eval cmds=\"\$concat_cmds\"
+ else
+ eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+ fi
+ fi
+ fi
+ func_execute_cmds "$cmds" 'exit $?'
+ done
+
+ test -n "$generated" && \
+ func_show_eval "${RM}r$generated"
+
+ # Now create the libtool archive.
+ case $output in
+ *.la)
+ old_library=
+ test "$build_old_libs" = yes && old_library="$libname.$libext"
+ func_verbose "creating $output"
+
+ # Preserve any variables that may affect compiler behavior
+ for var in $variables_saved_for_relink; do
+ if eval test -z \"\${$var+set}\"; then
+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
+ elif eval var_value=\$$var; test -z "$var_value"; then
+ relink_command="$var=; export $var; $relink_command"
+ else
+ func_quote_for_eval "$var_value"
+ relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
+ fi
+ done
+ # Quote the link command for shipping.
+ relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+ relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+ if test "$hardcode_automatic" = yes ; then
+ relink_command=
+ fi
+
+ # Only create the output if not a dry run.
+ $opt_dry_run || {
+ for installed in no yes; do
+ if test "$installed" = yes; then
+ if test -z "$install_libdir"; then
+ break
+ fi
+ output="$output_objdir/$outputname"i
+ # Replace all uninstalled libtool libraries with the installed ones
+ newdependency_libs=
+ for deplib in $dependency_libs; do
+ case $deplib in
+ *.la)
+ func_basename "$deplib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$deplib' is not a valid libtool archive"
+ newdependency_libs="$newdependency_libs $libdir/$name"
+ ;;
+ *) newdependency_libs="$newdependency_libs $deplib" ;;
+ esac
+ done
+ dependency_libs="$newdependency_libs"
+ newdlfiles=
+
+ for lib in $dlfiles; do
+ case $lib in
+ *.la)
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ newdlfiles="$newdlfiles $libdir/$name"
+ ;;
+ *) newdlfiles="$newdlfiles $lib" ;;
+ esac
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ *.la)
+ # Only pass preopened files to the pseudo-archive (for
+ # eventual linking with the app. that links it) if we
+ # didn't already link the preopened objects directly into
+ # the library:
+ func_basename "$lib"
+ name="$func_basename_result"
+ eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+ test -z "$libdir" && \
+ func_fatal_error "\`$lib' is not a valid libtool archive"
+ newdlprefiles="$newdlprefiles $libdir/$name"
+ ;;
+ esac
+ done
+ dlprefiles="$newdlprefiles"
+ else
+ newdlfiles=
+ for lib in $dlfiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ newdlfiles="$newdlfiles $abs"
+ done
+ dlfiles="$newdlfiles"
+ newdlprefiles=
+ for lib in $dlprefiles; do
+ case $lib in
+ [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+ *) abs=`pwd`"/$lib" ;;
+ esac
+ newdlprefiles="$newdlprefiles $abs"
+ done
+ dlprefiles="$newdlprefiles"
+ fi
+ $RM $output
+ # place dlname in correct position for cygwin
+ tdlname=$dlname
+ case $host,$output,$installed,$module,$dlname in
+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+ esac
+ $ECHO > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Linker flags that can not go in dependency_libs.
+inherited_linker_flags='$new_inherited_linker_flags'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Names of additional weak libraries provided by this library
+weak_library_names='$weak_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+ if test "$installed" = no && test "$need_relink" = yes; then
+ $ECHO >> $output "\
+relink_command=\"$relink_command\""
+ fi
+ done
+ }
+
+ # Do a symbolic link so that the libtool archive can be found in
+ # LD_LIBRARY_PATH before the program is installed.
+ func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
+ ;;
+ esac
+ exit $EXIT_SUCCESS
+}
+
+{ test "$mode" = link || test "$mode" = relink; } &&
+ func_mode_link ${1+"$@"}
+
+
+# func_mode_uninstall arg...
+func_mode_uninstall ()
+{
+ $opt_debug
+ RM="$nonopt"
+ files=
+ rmforce=
+ exit_status=0
+
+ # This variable tells wrapper scripts just to set variables rather
+ # than running their programs.
+ libtool_install_magic="$magic"
+
+ for arg
+ do
+ case $arg in
+ -f) RM="$RM $arg"; rmforce=yes ;;
+ -*) RM="$RM $arg" ;;
+ *) files="$files $arg" ;;
+ esac
+ done
+
+ test -z "$RM" && \
+ func_fatal_help "you must specify an RM program"
+
+ rmdirs=
+
+ origobjdir="$objdir"
+ for file in $files; do
+ func_dirname "$file" "" "."
+ dir="$func_dirname_result"
+ if test "X$dir" = X.; then
+ objdir="$origobjdir"
+ else
+ objdir="$dir/$origobjdir"
+ fi
+ func_basename "$file"
+ name="$func_basename_result"
+ test "$mode" = uninstall && objdir="$dir"
+
+ # Remember objdir for removal later, being careful to avoid duplicates
+ if test "$mode" = clean; then
+ case " $rmdirs " in
+ *" $objdir "*) ;;
+ *) rmdirs="$rmdirs $objdir" ;;
+ esac
+ fi
+
+ # Don't error if the file doesn't exist and rm -f was used.
+ if { test -L "$file"; } >/dev/null 2>&1 ||
+ { test -h "$file"; } >/dev/null 2>&1 ||
+ test -f "$file"; then
+ :
+ elif test -d "$file"; then
+ exit_status=1
+ continue
+ elif test "$rmforce" = yes; then
+ continue
+ fi
+
+ rmfiles="$file"
+
+ case $name in
+ *.la)
+ # Possibly a libtool archive, so verify it.
+ if func_lalib_p "$file"; then
+ func_source $dir/$name
+
+ # Delete the libtool libraries and symlinks.
+ for n in $library_names; do
+ rmfiles="$rmfiles $objdir/$n"
+ done
+ test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+ case "$mode" in
+ clean)
+ case " $library_names " in
+ # " " in the beginning catches empty $dlname
+ *" $dlname "*) ;;
+ *) rmfiles="$rmfiles $objdir/$dlname" ;;
+ esac
+ test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+ ;;
+ uninstall)
+ if test -n "$library_names"; then
+ # Do each command in the postuninstall commands.
+ func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+
+ if test -n "$old_library"; then
+ # Do each command in the old_postuninstall commands.
+ func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
+ fi
+ # FIXME: should reinstall the best remaining shared library.
+ ;;
+ esac
+ fi
+ ;;
+
+ *.lo)
+ # Possibly a libtool object, so verify it.
+ if func_lalib_p "$file"; then
+
+ # Read the .lo file
+ func_source $dir/$name
+
+ # Add PIC object to the list of files to remove.
+ if test -n "$pic_object" &&
+ test "$pic_object" != none; then
+ rmfiles="$rmfiles $dir/$pic_object"
+ fi
+
+ # Add non-PIC object to the list of files to remove.
+ if test -n "$non_pic_object" &&
+ test "$non_pic_object" != none; then
+ rmfiles="$rmfiles $dir/$non_pic_object"
+ fi
+ fi
+ ;;
+
+ *)
+ if test "$mode" = clean ; then
+ noexename=$name
+ case $file in
+ *.exe)
+ func_stripname '' '.exe' "$file"
+ file=$func_stripname_result
+ func_stripname '' '.exe' "$name"
+ noexename=$func_stripname_result
+ # $file with .exe has already been added to rmfiles,
+ # add $file without .exe
+ rmfiles="$rmfiles $file"
+ ;;
+ esac
+ # Do a test to see if this is a libtool program.
+ if func_ltwrapper_p "$file"; then
+ if func_ltwrapper_executable_p "$file"; then
+ func_ltwrapper_scriptname "$file"
+ relink_command=
+ func_source $func_ltwrapper_scriptname_result
+ rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
+ else
+ relink_command=
+ func_source $dir/$noexename
+ fi
+
+ # note $name still contains .exe if it was in $file originally
+ # as does the version of $file that was added into $rmfiles
+ rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+ if test "$fast_install" = yes && test -n "$relink_command"; then
+ rmfiles="$rmfiles $objdir/lt-$name"
+ fi
+ if test "X$noexename" != "X$name" ; then
+ rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+ fi
+ fi
+ fi
+ ;;
+ esac
+ func_show_eval "$RM $rmfiles" 'exit_status=1'
+ done
+ objdir="$origobjdir"
+
+ # Try to remove the ${objdir}s in the directories where we deleted files
+ for dir in $rmdirs; do
+ if test -d "$dir"; then
+ func_show_eval "rmdir $dir >/dev/null 2>&1"
+ fi
+ done
+
+ exit $exit_status
+}
+
+{ test "$mode" = uninstall || test "$mode" = clean; } &&
+ func_mode_uninstall ${1+"$@"}
+
+test -z "$mode" && {
+ help="$generic_help"
+ func_fatal_help "you must specify a MODE"
+}
+
+test -z "$exec_cmd" && \
+ func_fatal_help "invalid operation mode \`$mode'"
+
+if test -n "$exec_cmd"; then
+ eval exec "$exec_cmd"
+ exit $EXIT_FAILURE
+fi
+
+exit $exit_status
+
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries. Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them. This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration. But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+build_libtool_libs=no
+build_old_libs=yes
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
+# vi:sw=2
+
diff --git a/m4/ac_have_attribute.m4 b/m4/ac_have_attribute.m4
new file mode 100644
index 0000000..19f4021
--- /dev/null
+++ b/m4/ac_have_attribute.m4
@@ -0,0 +1,16 @@
+AC_DEFUN([AX_C___ATTRIBUTE__], [
+ AC_MSG_CHECKING(for __attribute__)
+ AC_CACHE_VAL(ac_cv___attribute__, [
+ AC_TRY_COMPILE(
+ [#include <stdlib.h>
+ static void foo(void) __attribute__ ((unused));
+ void foo(void) { exit(1); }],
+ [],
+ ac_cv___attribute__=yes,
+ ac_cv___attribute__=no
+ )])
+ if test "$ac_cv___attribute__" = "yes"; then
+ AC_DEFINE(HAVE___ATTRIBUTE__, 1, [define if your compiler has __attribute__])
+ fi
+ AC_MSG_RESULT($ac_cv___attribute__)
+])
diff --git a/m4/ac_interlocked_exchange.m4 b/m4/ac_interlocked_exchange.m4
new file mode 100644
index 0000000..2de5007
--- /dev/null
+++ b/m4/ac_interlocked_exchange.m4
@@ -0,0 +1,36 @@
+# Check whether InterlockedExchange() takes a LONG or a volatile LONG
+# as its first argument. InterlockedCompareExchange is a windows
+# function; obviously, this macro is useful only for cygwin and mingw,
+# and other systems that compile against the windows API.
+#
+# Apparently the interface for this function is a bit inconsistent.
+# Windows likes volatile LONG, but mingw and cygwin don't, at least
+# for the versions I'm using. But rather than try to guess who
+# supports what, let's just check at configure time. (Note: this
+# is an error in C++ but only a warning in C, so we test in the former.)
+#
+# This function returns 'yes' if the type does not need volatile,
+# and defines the symbol INTERLOCKED_EXCHANGE_NONVOLATILE. (This
+# is the expected case for mingw and cygwin). It returns 'no',
+# and defines no symbol, otherwise. (This is the expected case for
+# MSVC.) The return value was sset this way so that we don't need
+# to define any symbols on windows, which doesn't run configure.
+
+AC_DEFUN([AC_INTERLOCKED_EXCHANGE_NONVOLATILE],
+[
+AC_MSG_CHECKING(whether first argument to InterlockedExchange omits volatile)
+AC_CACHE_VAL(ac_cv_interlocked_exchange_nonvolatile,
+[AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([#include <windows.h>],
+ [volatile LONG once; InterlockedExchange(&once, 1);],
+ ac_cv_interlocked_exchange_nonvolatile="no",
+ ac_cv_interlocked_exchange_nonvolatile="yes")
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_interlocked_exchange_nonvolatile" = "yes"; then
+ AC_DEFINE(INTERLOCKED_EXCHANGE_NONVOLATILE, 1,
+ [define if first argument to InterlockedExchange is just LONG])
+fi
+AC_MSG_RESULT($ac_cv_interlocked_exchange_nonvolatile)
+])
diff --git a/m4/ac_rwlock.m4 b/m4/ac_rwlock.m4
new file mode 100644
index 0000000..bf2f2c6
--- /dev/null
+++ b/m4/ac_rwlock.m4
@@ -0,0 +1,40 @@
+# TODO(csilvers): it would be better to actually try to link against
+# -pthreads, to make sure it defines these methods, but that may be
+# too hard, since pthread support is really tricky.
+
+# Check for support for pthread_rwlock_init() etc.
+# These aren't posix, but are widely supported. To get them on linux,
+# you need to define _XOPEN_SOURCE first, so this check assumes your
+# application does that.
+#
+# Note: OS X (as of 6/1/06) seems to support pthread_rwlock, but
+# doesn't define PTHREAD_RWLOCK_INITIALIZER. Therefore, we don't test
+# that particularly macro. It's probably best if you don't use that
+# macro in your code either.
+#
+# Note: Cygwin (as of 12/1/08) has a bug in pthread_rwlock, where
+# if you try to acquire a read-lock twice, you get EDEADLCK, where
+# it should succeed. It would be nice to test for that, but we
+# can't do runtime checks here. So we just manually fail for CYGWIN.
+# TODO(csilvers): do better.
+
+AC_DEFUN([AC_RWLOCK],
+[AC_CACHE_CHECK(support for pthread_rwlock_* functions,
+ac_cv_rwlock,
+[AC_LANG_SAVE
+ AC_LANG_C
+ AC_TRY_COMPILE([#define _XOPEN_SOURCE 500
+ #include <pthread.h>
+ #ifdef __CYGWIN32__
+ # error Cygwin has a bug in pthread_rwlock; disabling
+ #endif],
+ [pthread_rwlock_t l; pthread_rwlock_init(&l, NULL);
+ pthread_rwlock_rdlock(&l);
+ return 0;],
+ ac_cv_rwlock=yes, ac_cv_rwlock=no)
+ AC_LANG_RESTORE
+])
+if test "$ac_cv_rwlock" = yes; then
+ AC_DEFINE(HAVE_RWLOCK,1,[define if the compiler implements pthread_rwlock_*])
+fi
+])
diff --git a/m4/acx_pthread.m4 b/m4/acx_pthread.m4
new file mode 100644
index 0000000..89d42c7
--- /dev/null
+++ b/m4/acx_pthread.m4
@@ -0,0 +1,397 @@
+# This was retrieved from
+# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?revision=1277&root=avahi
+# See also (perhaps for new versions?)
+# http://svn.0pointer.de/viewvc/trunk/common/acx_pthread.m4?root=avahi
+#
+# We've rewritten the inconsistency check code (from avahi), to work
+# more broadly. In particular, it no longer assumes ld accepts -zdefs.
+# This caused a restructing of the code, but the functionality has only
+# changed a little.
+
+dnl @synopsis ACX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]])
+dnl
+dnl @summary figure out how to build C programs using POSIX threads
+dnl
+dnl This macro figures out how to build C programs using POSIX threads.
+dnl It sets the PTHREAD_LIBS output variable to the threads library and
+dnl linker flags, and the PTHREAD_CFLAGS output variable to any special
+dnl C compiler flags that are needed. (The user can also force certain
+dnl compiler flags/libs to be tested by setting these environment
+dnl variables.)
+dnl
+dnl Also sets PTHREAD_CC to any special C compiler that is needed for
+dnl multi-threaded programs (defaults to the value of CC otherwise).
+dnl (This is necessary on AIX to use the special cc_r compiler alias.)
+dnl
+dnl NOTE: You are assumed to not only compile your program with these
+dnl flags, but also link it with them as well. e.g. you should link
+dnl with $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS
+dnl $LIBS
+dnl
+dnl If you are only building threads programs, you may wish to use
+dnl these variables in your default LIBS, CFLAGS, and CC:
+dnl
+dnl LIBS="$PTHREAD_LIBS $LIBS"
+dnl CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+dnl CC="$PTHREAD_CC"
+dnl
+dnl In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute
+dnl constant has a nonstandard name, defines PTHREAD_CREATE_JOINABLE to
+dnl that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX).
+dnl
+dnl ACTION-IF-FOUND is a list of shell commands to run if a threads
+dnl library is found, and ACTION-IF-NOT-FOUND is a list of commands to
+dnl run it if it is not found. If ACTION-IF-FOUND is not specified, the
+dnl default action will define HAVE_PTHREAD.
+dnl
+dnl Please let the authors know if this macro fails on any platform, or
+dnl if you have any other suggestions or comments. This macro was based
+dnl on work by SGJ on autoconf scripts for FFTW (www.fftw.org) (with
+dnl help from M. Frigo), as well as ac_pthread and hb_pthread macros
+dnl posted by Alejandro Forero Cuervo to the autoconf macro repository.
+dnl We are also grateful for the helpful feedback of numerous users.
+dnl
+dnl @category InstalledPackages
+dnl @author Steven G. Johnson <stevenj@alum.mit.edu>
+dnl @version 2006-05-29
+dnl @license GPLWithACException
+dnl
+dnl Checks for GCC shared/pthread inconsistency based on work by
+dnl Marcin Owsiany <marcin@owsiany.pl>
+
+
+AC_DEFUN([ACX_PTHREAD], [
+AC_REQUIRE([AC_CANONICAL_HOST])
+AC_LANG_SAVE
+AC_LANG_C
+acx_pthread_ok=no
+
+# We used to check for pthread.h first, but this fails if pthread.h
+# requires special compiler flags (e.g. on True64 or Sequent).
+# It gets checked for in the link test anyway.
+
+# First of all, check if the user has set any of the PTHREAD_LIBS,
+# etcetera environment variables, and if threads linking works using
+# them:
+if test x"$PTHREAD_LIBS$PTHREAD_CFLAGS" != x; then
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ AC_MSG_CHECKING([for pthread_join in LIBS=$PTHREAD_LIBS with CFLAGS=$PTHREAD_CFLAGS])
+ AC_TRY_LINK_FUNC(pthread_join, acx_pthread_ok=yes)
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test x"$acx_pthread_ok" = xno; then
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+ fi
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+fi
+
+# We must check for the threads library under a number of different
+# names; the ordering is very important because some systems
+# (e.g. DEC) have both -lpthread and -lpthreads, where one of the
+# libraries is broken (non-POSIX).
+
+# Create a list of thread flags to try. Items starting with a "-" are
+# C compiler flags, and other items are library names, except for "none"
+# which indicates that we try without any flags at all, and "pthread-config"
+# which is a program returning the flags for the Pth emulation library.
+
+acx_pthread_flags="pthreads none -Kthread -kthread lthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config"
+
+# The ordering *is* (sometimes) important. Some notes on the
+# individual items follow:
+
+# pthreads: AIX (must check this before -lpthread)
+# none: in case threads are in libc; should be tried before -Kthread and
+# other compiler flags to prevent continual compiler warnings
+# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h)
+# -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able)
+# lthread: LinuxThreads port on FreeBSD (also preferred to -pthread)
+# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads)
+# -pthreads: Solaris/gcc
+# -mthreads: Mingw32/gcc, Lynx/gcc
+# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it
+# doesn't hurt to check since this sometimes defines pthreads too;
+# also defines -D_REENTRANT)
+# ... -mt is also the pthreads flag for HP/aCC
+# pthread: Linux, etcetera
+# --thread-safe: KAI C++
+# pthread-config: use pthread-config program (for GNU Pth library)
+
+case "${host_cpu}-${host_os}" in
+ *solaris*)
+
+ # On Solaris (at least, for some versions), libc contains stubbed
+ # (non-functional) versions of the pthreads routines, so link-based
+ # tests will erroneously succeed. (We need to link with -pthreads/-mt/
+ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather
+ # a function called by this macro, so we could check for that, but
+ # who knows whether they'll stub that too in a future libc.) So,
+ # we'll just look for -pthreads and -lpthread first:
+
+ acx_pthread_flags="-pthreads pthread -mt -pthread $acx_pthread_flags"
+ ;;
+esac
+
+if test x"$acx_pthread_ok" = xno; then
+for flag in $acx_pthread_flags; do
+
+ case $flag in
+ none)
+ AC_MSG_CHECKING([whether pthreads work without any flags])
+ ;;
+
+ -*)
+ AC_MSG_CHECKING([whether pthreads work with $flag])
+ PTHREAD_CFLAGS="$flag"
+ ;;
+
+ pthread-config)
+ AC_CHECK_PROG(acx_pthread_config, pthread-config, yes, no)
+ if test x"$acx_pthread_config" = xno; then continue; fi
+ PTHREAD_CFLAGS="`pthread-config --cflags`"
+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"
+ ;;
+
+ *)
+ AC_MSG_CHECKING([for the pthreads library -l$flag])
+ PTHREAD_LIBS="-l$flag"
+ ;;
+ esac
+
+ save_LIBS="$LIBS"
+ save_CFLAGS="$CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Check for various functions. We must include pthread.h,
+ # since some functions may be macros. (On the Sequent, we
+ # need a special flag -Kthread to make this header compile.)
+ # We check for pthread_join because it is in -lpthread on IRIX
+ # while pthread_create is in libc. We check for pthread_attr_init
+ # due to DEC craziness with -lpthreads. We check for
+ # pthread_cleanup_push because it is one of the few pthread
+ # functions on Solaris that doesn't have a non-functional libc stub.
+ # We try pthread_create on general principles.
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [acx_pthread_ok=yes])
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+
+ AC_MSG_RESULT($acx_pthread_ok)
+ if test "x$acx_pthread_ok" = xyes; then
+ break;
+ fi
+
+ PTHREAD_LIBS=""
+ PTHREAD_CFLAGS=""
+done
+fi
+
+# Various other checks:
+if test "x$acx_pthread_ok" = xyes; then
+ save_LIBS="$LIBS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
+
+ # Detect AIX lossage: JOINABLE attribute is called UNDETACHED.
+ AC_MSG_CHECKING([for joinable pthread attribute])
+ attr_name=unknown
+ for attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do
+ AC_TRY_LINK([#include <pthread.h>], [int attr=$attr; return attr;],
+ [attr_name=$attr; break])
+ done
+ AC_MSG_RESULT($attr_name)
+ if test "$attr_name" != PTHREAD_CREATE_JOINABLE; then
+ AC_DEFINE_UNQUOTED(PTHREAD_CREATE_JOINABLE, $attr_name,
+ [Define to necessary symbol if this constant
+ uses a non-standard name on your system.])
+ fi
+
+ AC_MSG_CHECKING([if more special flags are required for pthreads])
+ flag=no
+ case "${host_cpu}-${host_os}" in
+ *-aix* | *-freebsd* | *-darwin*) flag="-D_THREAD_SAFE";;
+ *solaris* | *-osf* | *-hpux*) flag="-D_REENTRANT";;
+ esac
+ AC_MSG_RESULT(${flag})
+ if test "x$flag" != xno; then
+ PTHREAD_CFLAGS="$flag $PTHREAD_CFLAGS"
+ fi
+
+ LIBS="$save_LIBS"
+ CFLAGS="$save_CFLAGS"
+ # More AIX lossage: must compile with xlc_r or cc_r
+ if test x"$GCC" != xyes; then
+ AC_CHECK_PROGS(PTHREAD_CC, xlc_r cc_r, ${CC})
+ else
+ PTHREAD_CC=$CC
+ fi
+
+ # The next part tries to detect GCC inconsistency with -shared on some
+ # architectures and systems. The problem is that in certain
+ # configurations, when -shared is specified, GCC "forgets" to
+ # internally use various flags which are still necessary.
+
+ #
+ # Prepare the flags
+ #
+ save_CFLAGS="$CFLAGS"
+ save_LIBS="$LIBS"
+ save_CC="$CC"
+
+ # Try with the flags determined by the earlier checks.
+ #
+ # -Wl,-z,defs forces link-time symbol resolution, so that the
+ # linking checks with -shared actually have any value
+ #
+ # FIXME: -fPIC is required for -shared on many architectures,
+ # so we specify it here, but the right way would probably be to
+ # properly detect whether it is actually required.
+ CFLAGS="-shared -fPIC -Wl,-z,defs $CFLAGS $PTHREAD_CFLAGS"
+ LIBS="$PTHREAD_LIBS $LIBS"
+ CC="$PTHREAD_CC"
+
+ # In order not to create several levels of indentation, we test
+ # the value of "$done" until we find the cure or run out of ideas.
+ done="no"
+
+ # First, make sure the CFLAGS we added are actually accepted by our
+ # compiler. If not (and OS X's ld, for instance, does not accept -z),
+ # then we can't do this test.
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether to check for GCC pthread/shared inconsistencies])
+ AC_TRY_LINK(,, , [done=yes])
+
+ if test "x$done" = xyes ; then
+ AC_MSG_RESULT([no])
+ else
+ AC_MSG_RESULT([yes])
+ fi
+ fi
+
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether -pthread is sufficient with -shared])
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+
+ #
+ # Linux gcc on some architectures such as mips/mipsel forgets
+ # about -lpthread
+ #
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether -lpthread fixes that])
+ LIBS="-lpthread $PTHREAD_LIBS $save_LIBS"
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ PTHREAD_LIBS="-lpthread $PTHREAD_LIBS"
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ #
+ # FreeBSD 4.10 gcc forgets to use -lc_r instead of -lc
+ #
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether -lc_r fixes that])
+ LIBS="-lc_r $PTHREAD_LIBS $save_LIBS"
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ PTHREAD_LIBS="-lc_r $PTHREAD_LIBS"
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ if test x"$done" = xno; then
+ # OK, we have run out of ideas
+ AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries])
+
+ # so it's not safe to assume that we may use pthreads
+ acx_pthread_ok=no
+ fi
+
+ AC_MSG_CHECKING([whether what we have so far is sufficient with -nostdlib])
+ CFLAGS="-nostdlib $CFLAGS"
+ # we need c with nostdlib
+ LIBS="$LIBS -lc"
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes],[done=no])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+
+ if test x"$done" = xno; then
+ AC_MSG_CHECKING([whether -lpthread saves the day])
+ LIBS="-lpthread $LIBS"
+ AC_TRY_LINK([#include <pthread.h>],
+ [pthread_t th; pthread_join(th, 0);
+ pthread_attr_init(0); pthread_cleanup_push(0, 0);
+ pthread_create(0,0,0,0); pthread_cleanup_pop(0); ],
+ [done=yes],[done=no])
+
+ if test "x$done" = xyes; then
+ AC_MSG_RESULT([yes])
+ PTHREAD_LIBS="$PTHREAD_LIBS -lpthread"
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_WARN([Impossible to determine how to use pthreads with shared libraries and -nostdlib])
+ fi
+ fi
+
+ CFLAGS="$save_CFLAGS"
+ LIBS="$save_LIBS"
+ CC="$save_CC"
+else
+ PTHREAD_CC="$CC"
+fi
+
+AC_SUBST(PTHREAD_LIBS)
+AC_SUBST(PTHREAD_CFLAGS)
+AC_SUBST(PTHREAD_CC)
+
+# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:
+if test x"$acx_pthread_ok" = xyes; then
+ ifelse([$1],,AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]),[$1])
+ :
+else
+ acx_pthread_ok=no
+ $2
+fi
+AC_LANG_RESTORE
+])dnl ACX_PTHREAD
diff --git a/m4/compiler_characteristics.m4 b/m4/compiler_characteristics.m4
new file mode 100644
index 0000000..2b62893
--- /dev/null
+++ b/m4/compiler_characteristics.m4
@@ -0,0 +1,24 @@
+# Check compiler characteristics (e.g. type sizes, PRIxx macros, ...)
+
+# If types $1 and $2 are compatible, perform action $3
+AC_DEFUN([AC_TYPES_COMPATIBLE],
+ [AC_TRY_COMPILE([#include <stddef.h>], [$1 v1 = 0; $2 v2 = 0; return (&v1 - &v2)], $3)])
+
+define(AC_PRIUS_COMMENT, [printf format code for printing a size_t and ssize_t])
+
+AC_DEFUN([AC_COMPILER_CHARACTERISTICS],
+ [AC_CACHE_CHECK(AC_PRIUS_COMMENT, ac_cv_formatting_prius_prefix,
+ [AC_TYPES_COMPATIBLE(unsigned int, size_t,
+ ac_cv_formatting_prius_prefix=; ac_cv_prius_defined=1)
+ AC_TYPES_COMPATIBLE(unsigned long, size_t,
+ ac_cv_formatting_prius_prefix=l; ac_cv_prius_defined=1)
+ AC_TYPES_COMPATIBLE(unsigned long long, size_t,
+ ac_cv_formatting_prius_prefix=ll; ac_cv_prius_defined=1
+ )])
+ if test -z "$ac_cv_prius_defined"; then
+ ac_cv_formatting_prius_prefix=z;
+ fi
+ AC_DEFINE_UNQUOTED(PRIuS, "${ac_cv_formatting_prius_prefix}u", AC_PRIUS_COMMENT)
+ AC_DEFINE_UNQUOTED(PRIxS, "${ac_cv_formatting_prius_prefix}x", AC_PRIUS_COMMENT)
+ AC_DEFINE_UNQUOTED(PRIdS, "${ac_cv_formatting_prius_prefix}d", AC_PRIUS_COMMENT)
+])
diff --git a/m4/google_namespace.m4 b/m4/google_namespace.m4
new file mode 100644
index 0000000..7f244cc
--- /dev/null
+++ b/m4/google_namespace.m4
@@ -0,0 +1,42 @@
+# Allow users to override the namespace we define our application's classes in
+# Arg $1 is the default namespace to use if --enable-namespace isn't present.
+
+# In general, $1 should be 'google', so we put all our exported symbols in a
+# unique namespace that is not likely to conflict with anyone else. However,
+# when it makes sense -- for instance, when publishing stl-like code -- you
+# may want to go with a different default, like 'std'.
+
+# We guarantee the invariant that GOOGLE_NAMESPACE starts with ::,
+# unless it's the empty string. Thus, it's always safe to do
+# GOOGLE_NAMESPACE::foo and be sure you're getting the foo that's
+# actually in the google namespace, and not some other namespace that
+# the namespace rules might kick in.
+
+AC_DEFUN([AC_DEFINE_GOOGLE_NAMESPACE],
+ [google_namespace_default=[$1]
+ AC_ARG_ENABLE(namespace, [ --enable-namespace=FOO to define these Google
+ classes in the FOO namespace. --disable-namespace
+ to define them in the global namespace. Default
+ is to define them in namespace $1.],
+ [case "$enableval" in
+ yes) google_namespace="$google_namespace_default" ;;
+ no) google_namespace="" ;;
+ *) google_namespace="$enableval" ;;
+ esac],
+ [google_namespace="$google_namespace_default"])
+ if test -n "$google_namespace"; then
+ ac_google_namespace="::$google_namespace"
+ ac_google_start_namespace="namespace $google_namespace {"
+ ac_google_end_namespace="}"
+ else
+ ac_google_namespace=""
+ ac_google_start_namespace=""
+ ac_google_end_namespace=""
+ fi
+ AC_DEFINE_UNQUOTED(GOOGLE_NAMESPACE, $ac_google_namespace,
+ Namespace for Google classes)
+ AC_DEFINE_UNQUOTED(_START_GOOGLE_NAMESPACE_, $ac_google_start_namespace,
+ Puts following code inside the Google namespace)
+ AC_DEFINE_UNQUOTED(_END_GOOGLE_NAMESPACE_, $ac_google_end_namespace,
+ Stops putting the code inside the Google namespace)
+])
diff --git a/m4/libtool.m4 b/m4/libtool.m4
new file mode 100644
index 0000000..a3fee53
--- /dev/null
+++ b/m4/libtool.m4
@@ -0,0 +1,7377 @@
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+m4_define([_LT_COPYING], [dnl
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+# 2006, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gordon Matzigkeit, 1996
+#
+# This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING. If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+])
+
+# serial 56 LT_INIT
+
+
+# LT_PREREQ(VERSION)
+# ------------------
+# Complain and exit if this libtool version is less that VERSION.
+m4_defun([LT_PREREQ],
+[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
+ [m4_default([$3],
+ [m4_fatal([Libtool version $1 or higher is required],
+ 63)])],
+ [$2])])
+
+
+# _LT_CHECK_BUILDDIR
+# ------------------
+# Complain if the absolute build directory name contains unusual characters
+m4_defun([_LT_CHECK_BUILDDIR],
+[case `pwd` in
+ *\ * | *\ *)
+ AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
+esac
+])
+
+
+# LT_INIT([OPTIONS])
+# ------------------
+AC_DEFUN([LT_INIT],
+[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
+AC_BEFORE([$0], [LT_LANG])dnl
+AC_BEFORE([$0], [LT_OUTPUT])dnl
+AC_BEFORE([$0], [LTDL_INIT])dnl
+m4_require([_LT_CHECK_BUILDDIR])dnl
+
+dnl Autoconf doesn't catch unexpanded LT_ macros by default:
+m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
+m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
+dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
+dnl unless we require an AC_DEFUNed macro:
+AC_REQUIRE([LTOPTIONS_VERSION])dnl
+AC_REQUIRE([LTSUGAR_VERSION])dnl
+AC_REQUIRE([LTVERSION_VERSION])dnl
+AC_REQUIRE([LTOBSOLETE_VERSION])dnl
+m4_require([_LT_PROG_LTMAIN])dnl
+
+dnl Parse OPTIONS
+_LT_SET_OPTIONS([$0], [$1])
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+_LT_SETUP
+
+# Only expand once:
+m4_define([LT_INIT])
+])# LT_INIT
+
+# Old names:
+AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
+AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
+dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.
+m4_defun([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+ case $cc_temp in
+ compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+ distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+ \-*) ;;
+ *) break;;
+ esac
+done
+cc_basename=`$ECHO "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_FILEUTILS_DEFAULTS
+# ----------------------
+# It is okay to use these file commands and assume they have been set
+# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
+m4_defun([_LT_FILEUTILS_DEFAULTS],
+[: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
+])# _LT_FILEUTILS_DEFAULTS
+
+
+# _LT_SETUP
+# ---------
+m4_defun([_LT_SETUP],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+_LT_DECL([], [host_alias], [0], [The host system])dnl
+_LT_DECL([], [host], [0])dnl
+_LT_DECL([], [host_os], [0])dnl
+dnl
+_LT_DECL([], [build_alias], [0], [The build system])dnl
+_LT_DECL([], [build], [0])dnl
+_LT_DECL([], [build_os], [0])dnl
+dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+dnl
+AC_REQUIRE([AC_PROG_LN_S])dnl
+test -z "$LN_S" && LN_S="ln -s"
+_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
+dnl
+AC_REQUIRE([LT_CMD_MAX_LEN])dnl
+_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
+_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
+dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_CHECK_SHELL_FEATURES])dnl
+m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_CHECK_MAGIC_METHOD])dnl
+m4_require([_LT_CMD_OLD_ARCHIVE])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+
+_LT_CONFIG_LIBTOOL_INIT([
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+])
+if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+fi
+
+_LT_CHECK_OBJDIR
+
+m4_require([_LT_TAG_COMPILER])dnl
+_LT_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+ # AIX sometimes has problems with the GCC collect2 program. For some
+ # reason, if we set the COLLECT_NAMES environment variable, the problems
+ # vanish in a puff of smoke.
+ if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+ fi
+ ;;
+esac
+
+# Sed substitution that helps us do robust quoting. It backslashifies
+# metacharacters that are still active within double-quoted strings.
+sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([["`\\]]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Global variables:
+ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+ _LT_PATH_MAGIC
+ fi
+ ;;
+esac
+
+# Use C for the default configuration in the libtool script
+LT_SUPPORTED_TAG([CC])
+_LT_LANG_C_CONFIG
+_LT_LANG_DEFAULT_CONFIG
+_LT_CONFIG_COMMANDS
+])# _LT_SETUP
+
+
+# _LT_PROG_LTMAIN
+# ---------------
+# Note that this code is called both from `configure', and `config.status'
+# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably,
+# `config.status' has no value for ac_aux_dir unless we are using Automake,
+# so we pass a copy along to make sure it has a sensible value anyway.
+m4_defun([_LT_PROG_LTMAIN],
+[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
+_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
+ltmain="$ac_aux_dir/ltmain.sh"
+])# _LT_PROG_LTMAIN
+
+
+## ------------------------------------- ##
+## Accumulate code for creating libtool. ##
+## ------------------------------------- ##
+
+# So that we can recreate a full libtool script including additional
+# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
+# in macros and then make a single call at the end using the `libtool'
+# label.
+
+
+# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
+# ----------------------------------------
+# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL_INIT],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_INIT])
+
+
+# _LT_CONFIG_LIBTOOL([COMMANDS])
+# ------------------------------
+# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
+m4_define([_LT_CONFIG_LIBTOOL],
+[m4_ifval([$1],
+ [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
+ [$1
+])])])
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
+
+
+# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
+# -----------------------------------------------------
+m4_defun([_LT_CONFIG_SAVE_COMMANDS],
+[_LT_CONFIG_LIBTOOL([$1])
+_LT_CONFIG_LIBTOOL_INIT([$2])
+])
+
+
+# _LT_FORMAT_COMMENT([COMMENT])
+# -----------------------------
+# Add leading comment marks to the start of each line, and a trailing
+# full-stop to the whole comment if one is not present already.
+m4_define([_LT_FORMAT_COMMENT],
+[m4_ifval([$1], [
+m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
+ [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
+)])
+
+
+
+## ------------------------ ##
+## FIXME: Eliminate VARNAME ##
+## ------------------------ ##
+
+
+# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
+# -------------------------------------------------------------------
+# CONFIGNAME is the name given to the value in the libtool script.
+# VARNAME is the (base) name used in the configure script.
+# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
+# VARNAME. Any other value will be used directly.
+m4_define([_LT_DECL],
+[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
+ [m4_ifval([$1], [$1], [$2])])
+ lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
+ m4_ifval([$4],
+ [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
+ lt_dict_add_subkey([lt_decl_dict], [$2],
+ [tagged?], [m4_ifval([$5], [yes], [no])])])
+])
+
+
+# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
+# --------------------------------------------------------
+m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
+
+
+# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_tag_varnames],
+[_lt_decl_filter([tagged?], [yes], $@)])
+
+
+# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
+# ---------------------------------------------------------
+m4_define([_lt_decl_filter],
+[m4_case([$#],
+ [0], [m4_fatal([$0: too few arguments: $#])],
+ [1], [m4_fatal([$0: too few arguments: $#: $1])],
+ [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
+ [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
+ [lt_dict_filter([lt_decl_dict], $@)])[]dnl
+])
+
+
+# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
+# --------------------------------------------------
+m4_define([lt_decl_quote_varnames],
+[_lt_decl_filter([value], [1], $@)])
+
+
+# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_dquote_varnames],
+[_lt_decl_filter([value], [2], $@)])
+
+
+# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
+# ---------------------------------------------------
+m4_define([lt_decl_varnames_tagged],
+[m4_assert([$# <= 2])dnl
+_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
+ m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
+m4_define([_lt_decl_varnames_tagged],
+[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
+
+
+# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
+# ------------------------------------------------
+m4_define([lt_decl_all_varnames],
+[_$0(m4_quote(m4_default([$1], [[, ]])),
+ m4_if([$2], [],
+ m4_quote(lt_decl_varnames),
+ m4_quote(m4_shift($@))))[]dnl
+])
+m4_define([_lt_decl_all_varnames],
+[lt_join($@, lt_decl_varnames_tagged([$1],
+ lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
+])
+
+
+# _LT_CONFIG_STATUS_DECLARE([VARNAME])
+# ------------------------------------
+# Quote a variable value, and forward it to `config.status' so that its
+# declaration there will have the same value as in `configure'. VARNAME
+# must have a single quote delimited value for this to work.
+m4_define([_LT_CONFIG_STATUS_DECLARE],
+[$1='`$ECHO "X$][$1" | $Xsed -e "$delay_single_quote_subst"`'])
+
+
+# _LT_CONFIG_STATUS_DECLARATIONS
+# ------------------------------
+# We delimit libtool config variables with single quotes, so when
+# we write them to config.status, we have to be sure to quote all
+# embedded single quotes properly. In configure, this macro expands
+# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
+#
+# <var>='`$ECHO "X$<var>" | $Xsed -e "$delay_single_quote_subst"`'
+m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
+ [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAGS
+# ----------------
+# Output comment and list of tags supported by the script
+m4_defun([_LT_LIBTOOL_TAGS],
+[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
+available_tags="_LT_TAGS"dnl
+])
+
+
+# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
+# -----------------------------------
+# Extract the dictionary values for VARNAME (optionally with TAG) and
+# expand to a commented shell variable setting:
+#
+# # Some comment about what VAR is for.
+# visible_name=$lt_internal_name
+m4_define([_LT_LIBTOOL_DECLARE],
+[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
+ [description])))[]dnl
+m4_pushdef([_libtool_name],
+ m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
+m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
+ [0], [_libtool_name=[$]$1],
+ [1], [_libtool_name=$lt_[]$1],
+ [2], [_libtool_name=$lt_[]$1],
+ [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
+m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
+])
+
+
+# _LT_LIBTOOL_CONFIG_VARS
+# -----------------------
+# Produce commented declarations of non-tagged libtool config variables
+# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
+# script. Tagged libtool config variables (even for the LIBTOOL CONFIG
+# section) are produced by _LT_LIBTOOL_TAG_VARS.
+m4_defun([_LT_LIBTOOL_CONFIG_VARS],
+[m4_foreach([_lt_var],
+ m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
+
+
+# _LT_LIBTOOL_TAG_VARS(TAG)
+# -------------------------
+m4_define([_LT_LIBTOOL_TAG_VARS],
+[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
+ [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
+
+
+# _LT_TAGVAR(VARNAME, [TAGNAME])
+# ------------------------------
+m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
+
+
+# _LT_CONFIG_COMMANDS
+# -------------------
+# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of
+# variables for single and double quote escaping we saved from calls
+# to _LT_DECL, we can put quote escaped variables declarations
+# into `config.status', and then the shell code to quote escape them in
+# for loops in `config.status'. Finally, any additional code accumulated
+# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
+m4_defun([_LT_CONFIG_COMMANDS],
+[AC_PROVIDE_IFELSE([LT_OUTPUT],
+ dnl If the libtool generation code has been placed in $CONFIG_LT,
+ dnl instead of duplicating it all over again into config.status,
+ dnl then we will have config.status run $CONFIG_LT later, so it
+ dnl needs to know what name is stored there:
+ [AC_CONFIG_COMMANDS([libtool],
+ [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
+ dnl If the libtool generation code is destined for config.status,
+ dnl expand the accumulated commands and init code now:
+ [AC_CONFIG_COMMANDS([libtool],
+ [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
+])#_LT_CONFIG_COMMANDS
+
+
+# Initialize.
+m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
+[
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+_LT_CONFIG_STATUS_DECLARATIONS
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# Quote evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_quote_varnames); do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Double-quote double-evaled strings.
+for var in lt_decl_all_varnames([[ \
+]], lt_decl_dquote_varnames); do
+ case \`eval \\\\\$ECHO "X\\\\\$\$var"\` in
+ *[[\\\\\\\`\\"\\\$]]*)
+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"X\\\$\$var\\" | \\\$Xsed -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+ ;;
+ *)
+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+ ;;
+ esac
+done
+
+# Fix-up fallback echo if it was mangled by the above quoting rules.
+case \$lt_ECHO in
+*'\\\[$]0 --fallback-echo"')dnl "
+ lt_ECHO=\`\$ECHO "X\$lt_ECHO" | \$Xsed -e 's/\\\\\\\\\\\\\\\[$]0 --fallback-echo"\[$]/\[$]0 --fallback-echo"/'\`
+ ;;
+esac
+
+_LT_OUTPUT_LIBTOOL_INIT
+])
+
+
+# LT_OUTPUT
+# ---------
+# This macro allows early generation of the libtool script (before
+# AC_OUTPUT is called), incase it is used in configure for compilation
+# tests.
+AC_DEFUN([LT_OUTPUT],
+[: ${CONFIG_LT=./config.lt}
+AC_MSG_NOTICE([creating $CONFIG_LT])
+cat >"$CONFIG_LT" <<_LTEOF
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate a libtool stub with the current configuration.
+
+lt_cl_silent=false
+SHELL=\${CONFIG_SHELL-$SHELL}
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AS_SHELL_SANITIZE
+_AS_PREPARE
+
+exec AS_MESSAGE_FD>&1
+exec AS_MESSAGE_LOG_FD>>config.log
+{
+ echo
+ AS_BOX([Running $as_me.])
+} >&AS_MESSAGE_LOG_FD
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $[0] [[OPTIONS]]
+
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit
+ -q, --quiet do not print progress messages
+ -d, --debug don't remove temporary files
+
+Report bugs to <bug-libtool@gnu.org>."
+
+lt_cl_version="\
+m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
+m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
+configured by $[0], generated by m4_PACKAGE_STRING.
+
+Copyright (C) 2008 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $[#] != 0
+do
+ case $[1] in
+ --version | --v* | -V )
+ echo "$lt_cl_version"; exit 0 ;;
+ --help | --h* | -h )
+ echo "$lt_cl_help"; exit 0 ;;
+ --debug | --d* | -d )
+ debug=: ;;
+ --quiet | --q* | --silent | --s* | -q )
+ lt_cl_silent=: ;;
+
+ -*) AC_MSG_ERROR([unrecognized option: $[1]
+Try \`$[0] --help' for more information.]) ;;
+
+ *) AC_MSG_ERROR([unrecognized argument: $[1]
+Try \`$[0] --help' for more information.]) ;;
+ esac
+ shift
+done
+
+if $lt_cl_silent; then
+ exec AS_MESSAGE_FD>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+AC_MSG_NOTICE([creating $ofile])
+_LT_OUTPUT_LIBTOOL_COMMANDS
+AS_EXIT(0)
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure. Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+if test "$no_create" != yes; then
+ lt_cl_success=:
+ test "$silent" = yes &&
+ lt_config_lt_args="$lt_config_lt_args --quiet"
+ exec AS_MESSAGE_LOG_FD>/dev/null
+ $SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+ exec AS_MESSAGE_LOG_FD>>config.log
+ $lt_cl_success || AS_EXIT(1)
+fi
+])# LT_OUTPUT
+
+
+# _LT_CONFIG(TAG)
+# ---------------
+# If TAG is the built-in tag, create an initial libtool script with a
+# default configuration from the untagged config vars. Otherwise add code
+# to config.status for appending the configuration named by TAG from the
+# matching tagged config vars.
+m4_defun([_LT_CONFIG],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_CONFIG_SAVE_COMMANDS([
+ m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
+ m4_if(_LT_TAG, [C], [
+ # See if we are running on zsh, and set the options which allow our
+ # commands through without removal of \ escapes.
+ if test -n "${ZSH_VERSION+set}" ; then
+ setopt NO_GLOB_SUBST
+ fi
+
+ cfgfile="${ofile}T"
+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+ $RM "$cfgfile"
+
+ cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+_LT_COPYING
+_LT_LIBTOOL_TAGS
+
+# ### BEGIN LIBTOOL CONFIG
+_LT_LIBTOOL_CONFIG_VARS
+_LT_LIBTOOL_TAG_VARS
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
+
+ case $host_os in
+ aix3*)
+ cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program. For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+ COLLECT_NAMES=
+ export COLLECT_NAMES
+fi
+_LT_EOF
+ ;;
+ esac
+
+ _LT_PROG_LTMAIN
+
+ # We use sed instead of cat because bash on DJGPP gets confused if
+ # if finds mixed CR/LF and LF-only lines. Since sed operates in
+ # text mode, it properly converts lines to CR/LF. This bash problem
+ # is reportedly fixed, but why not run on old versions too?
+ sed '/^# Generated shell functions inserted here/q' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ _LT_PROG_XSI_SHELLFNS
+
+ sed -n '/^# Generated shell functions inserted here/,$p' "$ltmain" >> "$cfgfile" \
+ || (rm -f "$cfgfile"; exit 1)
+
+ mv -f "$cfgfile" "$ofile" ||
+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+ chmod +x "$ofile"
+],
+[cat <<_LT_EOF >> "$ofile"
+
+dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
+dnl in a comment (ie after a #).
+# ### BEGIN LIBTOOL TAG CONFIG: $1
+_LT_LIBTOOL_TAG_VARS(_LT_TAG)
+# ### END LIBTOOL TAG CONFIG: $1
+_LT_EOF
+])dnl /m4_if
+],
+[m4_if([$1], [], [
+ PACKAGE='$PACKAGE'
+ VERSION='$VERSION'
+ TIMESTAMP='$TIMESTAMP'
+ RM='$RM'
+ ofile='$ofile'], [])
+])dnl /_LT_CONFIG_SAVE_COMMANDS
+])# _LT_CONFIG
+
+
+# LT_SUPPORTED_TAG(TAG)
+# ---------------------
+# Trace this macro to discover what tags are supported by the libtool
+# --tag option, using:
+# autoconf --trace 'LT_SUPPORTED_TAG:$1'
+AC_DEFUN([LT_SUPPORTED_TAG], [])
+
+
+# C support is built-in for now
+m4_define([_LT_LANG_C_enabled], [])
+m4_define([_LT_TAGS], [])
+
+
+# LT_LANG(LANG)
+# -------------
+# Enable libtool support for the given language if not already enabled.
+AC_DEFUN([LT_LANG],
+[AC_BEFORE([$0], [LT_OUTPUT])dnl
+m4_case([$1],
+ [C], [_LT_LANG(C)],
+ [C++], [_LT_LANG(CXX)],
+ [Java], [_LT_LANG(GCJ)],
+ [Fortran 77], [_LT_LANG(F77)],
+ [Fortran], [_LT_LANG(FC)],
+ [Windows Resource], [_LT_LANG(RC)],
+ [m4_ifdef([_LT_LANG_]$1[_CONFIG],
+ [_LT_LANG($1)],
+ [m4_fatal([$0: unsupported language: "$1"])])])dnl
+])# LT_LANG
+
+
+# _LT_LANG(LANGNAME)
+# ------------------
+m4_defun([_LT_LANG],
+[m4_ifdef([_LT_LANG_]$1[_enabled], [],
+ [LT_SUPPORTED_TAG([$1])dnl
+ m4_append([_LT_TAGS], [$1 ])dnl
+ m4_define([_LT_LANG_]$1[_enabled], [])dnl
+ _LT_LANG_$1_CONFIG($1)])dnl
+])# _LT_LANG
+
+
+# _LT_LANG_DEFAULT_CONFIG
+# -----------------------
+m4_defun([_LT_LANG_DEFAULT_CONFIG],
+[AC_PROVIDE_IFELSE([AC_PROG_CXX],
+ [LT_LANG(CXX)],
+ [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+ [LT_LANG(F77)],
+ [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
+
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+ [LT_LANG(FC)],
+ [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
+
+dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
+dnl pulling things in needlessly.
+AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
+ [LT_LANG(GCJ)],
+ [m4_ifdef([AC_PROG_GCJ],
+ [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([A][M_PROG_GCJ],
+ [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
+ m4_ifdef([LT_PROG_GCJ],
+ [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
+
+AC_PROVIDE_IFELSE([LT_PROG_RC],
+ [LT_LANG(RC)],
+ [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
+])# _LT_LANG_DEFAULT_CONFIG
+
+# Obsolete macros:
+AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
+AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
+AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
+AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
+dnl AC_DEFUN([AC_LIBTOOL_F77], [])
+dnl AC_DEFUN([AC_LIBTOOL_FC], [])
+dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
+
+
+# _LT_TAG_COMPILER
+# ----------------
+m4_defun([_LT_TAG_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
+_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
+_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
+_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_TAG_COMPILER
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+m4_defun([_LT_COMPILER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+m4_defun([_LT_LINKER_BOILERPLATE],
+[m4_require([_LT_DECL_SED])dnl
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+])# _LT_LINKER_BOILERPLATE
+
+# _LT_REQUIRED_DARWIN_CHECKS
+# -------------------------
+m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
+ case $host_os in
+ rhapsody* | darwin*)
+ AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
+ AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
+ AC_CHECK_TOOL([LIPO], [lipo], [:])
+ AC_CHECK_TOOL([OTOOL], [otool], [:])
+ AC_CHECK_TOOL([OTOOL64], [otool64], [:])
+ _LT_DECL([], [DSYMUTIL], [1],
+ [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
+ _LT_DECL([], [NMEDIT], [1],
+ [Tool to change global to local symbols on Mac OS X])
+ _LT_DECL([], [LIPO], [1],
+ [Tool to manipulate fat objects and archives on Mac OS X])
+ _LT_DECL([], [OTOOL], [1],
+ [ldd/readelf like tool for Mach-O binaries on Mac OS X])
+ _LT_DECL([], [OTOOL64], [1],
+ [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
+
+ AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
+ [lt_cv_apple_cc_single_mod=no
+ if test -z "${LT_MULTI_MODULE}"; then
+ # By default we will add the -single_module flag. You can override
+ # by either setting the environment variable LT_MULTI_MODULE
+ # non-empty at configure time, or by adding -multi_module to the
+ # link flags.
+ rm -rf libconftest.dylib*
+ echo "int foo(void){return 1;}" > conftest.c
+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+ _lt_result=$?
+ if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
+ lt_cv_apple_cc_single_mod=yes
+ else
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ fi
+ rm -rf libconftest.dylib*
+ rm -f conftest.*
+ fi])
+ AC_CACHE_CHECK([for -exported_symbols_list linker flag],
+ [lt_cv_ld_exported_symbols_list],
+ [lt_cv_ld_exported_symbols_list=no
+ save_LDFLAGS=$LDFLAGS
+ echo "_main" > conftest.sym
+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [lt_cv_ld_exported_symbols_list=yes],
+ [lt_cv_ld_exported_symbols_list=no])
+ LDFLAGS="$save_LDFLAGS"
+ ])
+ case $host_os in
+ rhapsody* | darwin1.[[012]])
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+ darwin1.*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ darwin*) # darwin 5.x on
+ # if running on 10.5 or later, the deployment target defaults
+ # to the OS version, if on x86, and 10.4, the deployment
+ # target defaults to 10.4. Don't you love it?
+ case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+ 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ 10.[[012]]*)
+ _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+ 10.*)
+ _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+ esac
+ ;;
+ esac
+ if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+ _lt_dar_single_mod='$single_module'
+ fi
+ if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+ _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+ else
+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+ fi
+ if test "$DSYMUTIL" != ":"; then
+ _lt_dsymutil='~$DSYMUTIL $lib || :'
+ else
+ _lt_dsymutil=
+ fi
+ ;;
+ esac
+])
+
+
+# _LT_DARWIN_LINKER_FEATURES
+# --------------------------
+# Checks for linker and compiler features on darwin
+m4_defun([_LT_DARWIN_LINKER_FEATURES],
+[
+ m4_require([_LT_REQUIRED_DARWIN_CHECKS])
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_automatic, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=''
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
+ case $cc_basename in
+ ifort*) _lt_dar_can_shared=yes ;;
+ *) _lt_dar_can_shared=$GCC ;;
+ esac
+ if test "$_lt_dar_can_shared" = "yes"; then
+ output_verbose_link_cmd=echo
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+ _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+ _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+ m4_if([$1], [CXX],
+[ if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+ _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+ fi
+],[])
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+])
+
+# _LT_SYS_MODULE_PATH_AIX
+# -----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+m4_defun([_LT_SYS_MODULE_PATH_AIX],
+[m4_require([_LT_DECL_SED])dnl
+AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+lt_aix_libpath_sed='
+ /Import File Strings/,/^$/ {
+ /^0/ {
+ s/^0 *\(.*\)$/\1/
+ p
+ }
+ }'
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then
+ aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_SYS_MODULE_PATH_AIX
+
+
+# _LT_SHELL_INIT(ARG)
+# -------------------
+m4_define([_LT_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+ [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+ [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_SHELL_INIT
+
+
+# _LT_PROG_ECHO_BACKSLASH
+# -----------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+m4_defun([_LT_PROG_ECHO_BACKSLASH],
+[_LT_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$lt_ECHO in
+X*--fallback-echo)
+ # Remove one level of quotation (which was required for Make).
+ ECHO=`echo "$lt_ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+ ;;
+esac
+
+ECHO=${lt_ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+ # Discard the --no-reexec flag, and continue.
+ shift
+elif test "X[$]1" = X--fallback-echo; then
+ # Avoid inline document here, it may be left over
+ :
+elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' ; then
+ # Yippee, $ECHO works!
+ :
+else
+ # Restart under the correct shell.
+ exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+ # used as fallback echo
+ shift
+ cat <<_LT_EOF
+[$]*
+_LT_EOF
+ exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$lt_ECHO"; then
+ if test "X${echo_test_string+set}" != Xset; then
+ # find a string as large as possible, as long as the shell can cope with it
+ for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+ # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+ if { echo_test_string=`eval $cmd`; } 2>/dev/null &&
+ { test "X$echo_test_string" = "X$echo_test_string"; } 2>/dev/null
+ then
+ break
+ fi
+ done
+ fi
+
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ :
+ else
+ # The Solaris, AIX, and Digital Unix default echo programs unquote
+ # backslashes. This makes it impossible to quote backslashes using
+ # echo "$something" | sed 's/\\/\\\\/g'
+ #
+ # So, first we look for a working echo in the user's PATH.
+
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for dir in $PATH /usr/ucb; do
+ IFS="$lt_save_ifs"
+ if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+ test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$dir/echo"
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+
+ if test "X$ECHO" = Xecho; then
+ # We didn't find a better echo, so look for alternatives.
+ if test "X`{ print -r '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ print -r "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # This shell has a builtin print -r that does the trick.
+ ECHO='print -r'
+ elif { test -f /bin/ksh || test -f /bin/ksh$ac_exeext; } &&
+ test "X$CONFIG_SHELL" != X/bin/ksh; then
+ # If we have ksh, try running configure again with it.
+ ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+ export ORIGINAL_CONFIG_SHELL
+ CONFIG_SHELL=/bin/ksh
+ export CONFIG_SHELL
+ exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+ else
+ # Try using printf.
+ ECHO='printf %s\n'
+ if test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t' &&
+ echo_testing_string=`{ $ECHO "$echo_test_string"; } 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ # Cool, printf works
+ :
+ elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+ export CONFIG_SHELL
+ SHELL="$CONFIG_SHELL"
+ export SHELL
+ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+ elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+ test "X$echo_testing_string" = 'X\t' &&
+ echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+ test "X$echo_testing_string" = "X$echo_test_string"; then
+ ECHO="$CONFIG_SHELL [$]0 --fallback-echo"
+ else
+ # maybe with a smaller string...
+ prev=:
+
+ for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+ if { test "X$echo_test_string" = "X`eval $cmd`"; } 2>/dev/null
+ then
+ break
+ fi
+ prev="$cmd"
+ done
+
+ if test "$prev" != 'sed 50q "[$]0"'; then
+ echo_test_string=`eval $prev`
+ export echo_test_string
+ exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+ else
+ # Oops. We lost completely, so just stick with echo.
+ ECHO=echo
+ fi
+ fi
+ fi
+ fi
+ fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+lt_ECHO=$ECHO
+if test "X$lt_ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+ lt_ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(lt_ECHO)
+])
+_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
+_LT_DECL([], [ECHO], [1],
+ [An echo program that does not interpret backslashes])
+])# _LT_PROG_ECHO_BACKSLASH
+
+
+# _LT_ENABLE_LOCK
+# ---------------
+m4_defun([_LT_ENABLE_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+ [AS_HELP_STRING([--disable-libtool-lock],
+ [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *ELF-32*)
+ HPUX_IA64_MODE="32"
+ ;;
+ *ELF-64*)
+ HPUX_IA64_MODE="64"
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+*-*-irix6*)
+ # Find out which ABI we are using.
+ echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -melf32bsmip"
+ ;;
+ *N32*)
+ LD="${LD-ld} -melf32bmipn32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -melf64bmip"
+ ;;
+ esac
+ else
+ case `/usr/bin/file conftest.$ac_objext` in
+ *32-bit*)
+ LD="${LD-ld} -32"
+ ;;
+ *N32*)
+ LD="${LD-ld} -n32"
+ ;;
+ *64-bit*)
+ LD="${LD-ld} -64"
+ ;;
+ esac
+ fi
+ fi
+ rm -rf conftest*
+ ;;
+
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *32-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_i386_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_i386"
+ ;;
+ ppc64-*linux*|powerpc64-*linux*)
+ LD="${LD-ld} -m elf32ppclinux"
+ ;;
+ s390x-*linux*)
+ LD="${LD-ld} -m elf_s390"
+ ;;
+ sparc64-*linux*)
+ LD="${LD-ld} -m elf32_sparc"
+ ;;
+ esac
+ ;;
+ *64-bit*)
+ case $host in
+ x86_64-*kfreebsd*-gnu)
+ LD="${LD-ld} -m elf_x86_64_fbsd"
+ ;;
+ x86_64-*linux*)
+ LD="${LD-ld} -m elf_x86_64"
+ ;;
+ ppc*-*linux*|powerpc*-*linux*)
+ LD="${LD-ld} -m elf64ppc"
+ ;;
+ s390*-*linux*|s390*-*tpf*)
+ LD="${LD-ld} -m elf64_s390"
+ ;;
+ sparc*-*linux*)
+ LD="${LD-ld} -m elf64_sparc"
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+
+*-*-sco3.2v5*)
+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+ SAVE_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS -belf"
+ AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+ [AC_LANG_PUSH(C)
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+ AC_LANG_POP])
+ if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+ CFLAGS="$SAVE_CFLAGS"
+ fi
+ ;;
+sparc*-*solaris*)
+ # Find out which ABI we are using.
+ echo 'int i;' > conftest.$ac_ext
+ if AC_TRY_EVAL(ac_compile); then
+ case `/usr/bin/file conftest.o` in
+ *64-bit*)
+ case $lt_cv_prog_gnu_ld in
+ yes*) LD="${LD-ld} -m elf64_sparc" ;;
+ *)
+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+ LD="${LD-ld} -64"
+ fi
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ rm -rf conftest*
+ ;;
+esac
+
+need_locks="$enable_libtool_lock"
+])# _LT_ENABLE_LOCK
+
+
+# _LT_CMD_OLD_ARCHIVE
+# -------------------
+m4_defun([_LT_CMD_OLD_ARCHIVE],
+[AC_CHECK_TOOL(AR, ar, false)
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+_LT_DECL([], [AR], [1], [The archiver])
+_LT_DECL([], [AR_FLAGS], [1])
+
+AC_CHECK_TOOL(STRIP, strip, :)
+test -z "$STRIP" && STRIP=:
+_LT_DECL([], [STRIP], [1], [A symbol stripping program])
+
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+test -z "$RANLIB" && RANLIB=:
+_LT_DECL([], [RANLIB], [1],
+ [Commands used to install an old-style archive])
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+ case $host_os in
+ openbsd*)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
+ ;;
+ *)
+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
+ ;;
+ esac
+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+_LT_DECL([], [old_postinstall_cmds], [2])
+_LT_DECL([], [old_postuninstall_cmds], [2])
+_LT_TAGDECL([], [old_archive_cmds], [2],
+ [Commands used to build an old-style archive])
+])# _LT_CMD_OLD_ARCHIVE
+
+
+# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([_LT_COMPILER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+ lt_compiler_flag="$3"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ # The option is referenced via a variable to avoid confusing sed.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>conftest.err)
+ ac_status=$?
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ 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.
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' >conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ fi
+ $RM conftest*
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$5], , :, [$5])
+else
+ m4_if([$6], , :, [$6])
+fi
+])# _LT_COMPILER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
+
+
+# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+# [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------
+# Check whether the given linker option works
+AC_DEFUN([_LT_LINKER_OPTION],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_CACHE_CHECK([$1], [$2],
+ [$2=no
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS $3"
+ echo "$lt_simple_link_test_code" > conftest.$ac_ext
+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+ # The linker can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ if test -s conftest.err; then
+ # Append any errors to the config.log.
+ cat conftest.err 1>&AS_MESSAGE_LOG_FD
+ $ECHO "X$_lt_linker_boilerplate" | $Xsed -e '/^$/d' > conftest.exp
+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+ if diff conftest.exp conftest.er2 >/dev/null; then
+ $2=yes
+ fi
+ else
+ $2=yes
+ fi
+ fi
+ $RM -r conftest*
+ LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+ m4_if([$4], , :, [$4])
+else
+ m4_if([$5], , :, [$5])
+fi
+])# _LT_LINKER_OPTION
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
+
+
+# LT_CMD_MAX_LEN
+#---------------
+AC_DEFUN([LT_CMD_MAX_LEN],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+ i=0
+ teststring="ABCD"
+
+ case $build_os in
+ msdosdjgpp*)
+ # On DJGPP, this test can blow up pretty badly due to problems in libc
+ # (any single argument exceeding 2000 bytes causes a buffer overrun
+ # during glob expansion). Even if it were fixed, the result of this
+ # check would be larger than it should be.
+ lt_cv_sys_max_cmd_len=12288; # 12K is about right
+ ;;
+
+ gnu*)
+ # Under GNU Hurd, this test is not required because there is
+ # no limit to the length of command line arguments.
+ # Libtool will interpret -1 as no limit whatsoever
+ lt_cv_sys_max_cmd_len=-1;
+ ;;
+
+ cygwin* | mingw* | cegcc*)
+ # On Win9x/ME, this test blows up -- it succeeds, but takes
+ # about 5 minutes as the teststring grows exponentially.
+ # Worse, since 9x/ME are not pre-emptively multitasking,
+ # you end up with a "frozen" computer, even though with patience
+ # the test eventually succeeds (with a max line length of 256k).
+ # Instead, let's just punt: use the minimum linelength reported by
+ # all of the supported platforms: 8192 (on NT/2K/XP).
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ amigaos*)
+ # On AmigaOS with pdksh, this test takes hours, literally.
+ # So we just punt and use a minimum line length of 8192.
+ lt_cv_sys_max_cmd_len=8192;
+ ;;
+
+ netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+ # This has been around since 386BSD, at least. Likely further.
+ if test -x /sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+ elif test -x /usr/sbin/sysctl; then
+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+ else
+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs
+ fi
+ # And add a safety zone
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ ;;
+
+ interix*)
+ # We know the value 262144 and hardcode it with a safety zone (like BSD)
+ lt_cv_sys_max_cmd_len=196608
+ ;;
+
+ osf*)
+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+ # nice to cause kernel panics so lets avoid the loop below.
+ # First set a reasonable default.
+ lt_cv_sys_max_cmd_len=16384
+ #
+ if test -x /sbin/sysconfig; then
+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+ *1*) lt_cv_sys_max_cmd_len=-1 ;;
+ esac
+ fi
+ ;;
+ sco3.2v5*)
+ lt_cv_sys_max_cmd_len=102400
+ ;;
+ sysv5* | sco5v6* | sysv4.2uw2*)
+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+ if test -n "$kargmax"; then
+ lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'`
+ else
+ lt_cv_sys_max_cmd_len=32768
+ fi
+ ;;
+ *)
+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+ if test -n "$lt_cv_sys_max_cmd_len"; then
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+ else
+ # Make teststring a little bigger before we do anything with it.
+ # a 1K string should be a reasonable start.
+ for i in 1 2 3 4 5 6 7 8 ; do
+ teststring=$teststring$teststring
+ done
+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+ # If test is not a shell built-in, we'll probably end up computing a
+ # maximum length that is only half of the actual maximum length, but
+ # we can't tell.
+ while { test "X"`$SHELL [$]0 --fallback-echo "X$teststring$teststring" 2>/dev/null` \
+ = "XX$teststring$teststring"; } >/dev/null 2>&1 &&
+ test $i != 17 # 1/2 MB should be enough
+ do
+ i=`expr $i + 1`
+ teststring=$teststring$teststring
+ done
+ # Only check the string length outside the loop.
+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+ teststring=
+ # Add a significant safety factor because C++ compilers can tack on
+ # massive amounts of additional arguments before passing them to the
+ # linker. It appears as though 1/2 is a usable value.
+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+ fi
+ ;;
+ esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+ AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+ AC_MSG_RESULT(none)
+fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
+_LT_DECL([], [max_cmd_len], [0],
+ [What is the maximum length of a command?])
+])# LT_CMD_MAX_LEN
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
+
+
+# _LT_HEADER_DLFCN
+# ----------------
+m4_defun([_LT_HEADER_DLFCN],
+[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
+])# _LT_HEADER_DLFCN
+
+
+# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ----------------------------------------------------------------
+m4_defun([_LT_TRY_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+ [$4]
+else
+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+ lt_status=$lt_dlunknown
+ cat > conftest.$ac_ext <<_LT_EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+# define LT_DLGLOBAL RTLD_GLOBAL
+#else
+# ifdef DL_GLOBAL
+# define LT_DLGLOBAL DL_GLOBAL
+# else
+# define LT_DLGLOBAL 0
+# endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+ find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+# ifdef RTLD_LAZY
+# define LT_DLLAZY_OR_NOW RTLD_LAZY
+# else
+# ifdef DL_LAZY
+# define LT_DLLAZY_OR_NOW DL_LAZY
+# else
+# ifdef RTLD_NOW
+# define LT_DLLAZY_OR_NOW RTLD_NOW
+# else
+# ifdef DL_NOW
+# define LT_DLLAZY_OR_NOW DL_NOW
+# else
+# define LT_DLLAZY_OR_NOW 0
+# endif
+# endif
+# endif
+# endif
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+ int status = $lt_dlunknown;
+
+ if (self)
+ {
+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;
+ else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+ /* dlclose (self); */
+ }
+ else
+ puts (dlerror ());
+
+ return status;
+}]
+_LT_EOF
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+ (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+ lt_status=$?
+ case x$lt_status in
+ x$lt_dlno_uscore) $1 ;;
+ x$lt_dlneed_uscore) $2 ;;
+ x$lt_dlunknown|x*) $3 ;;
+ esac
+ else :
+ # compilation failed
+ $3
+ fi
+fi
+rm -fr conftest*
+])# _LT_TRY_DLOPEN_SELF
+
+
+# LT_SYS_DLOPEN_SELF
+# ------------------
+AC_DEFUN([LT_SYS_DLOPEN_SELF],
+[m4_require([_LT_HEADER_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+ enable_dlopen=unknown
+ enable_dlopen_self=unknown
+ enable_dlopen_self_static=unknown
+else
+ lt_cv_dlopen=no
+ lt_cv_dlopen_libs=
+
+ case $host_os in
+ beos*)
+ lt_cv_dlopen="load_add_on"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ;;
+
+ mingw* | pw32* | cegcc*)
+ lt_cv_dlopen="LoadLibrary"
+ lt_cv_dlopen_libs=
+ ;;
+
+ cygwin*)
+ lt_cv_dlopen="dlopen"
+ lt_cv_dlopen_libs=
+ ;;
+
+ darwin*)
+ # if libdl is installed we need to link against it
+ AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+ lt_cv_dlopen="dyld"
+ lt_cv_dlopen_libs=
+ lt_cv_dlopen_self=yes
+ ])
+ ;;
+
+ *)
+ AC_CHECK_FUNC([shl_load],
+ [lt_cv_dlopen="shl_load"],
+ [AC_CHECK_LIB([dld], [shl_load],
+ [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
+ [AC_CHECK_FUNC([dlopen],
+ [lt_cv_dlopen="dlopen"],
+ [AC_CHECK_LIB([dl], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+ [AC_CHECK_LIB([svld], [dlopen],
+ [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+ [AC_CHECK_LIB([dld], [dld_link],
+ [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
+ ])
+ ])
+ ])
+ ])
+ ])
+ ;;
+ esac
+
+ if test "x$lt_cv_dlopen" != xno; then
+ enable_dlopen=yes
+ else
+ enable_dlopen=no
+ fi
+
+ case $lt_cv_dlopen in
+ dlopen)
+ save_CPPFLAGS="$CPPFLAGS"
+ test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+ save_LDFLAGS="$LDFLAGS"
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+ save_LIBS="$LIBS"
+ LIBS="$lt_cv_dlopen_libs $LIBS"
+
+ AC_CACHE_CHECK([whether a program can dlopen itself],
+ lt_cv_dlopen_self, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+ lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+ ])
+
+ if test "x$lt_cv_dlopen_self" = xyes; then
+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+ AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+ lt_cv_dlopen_self_static, [dnl
+ _LT_TRY_DLOPEN_SELF(
+ lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+ lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross)
+ ])
+ fi
+
+ CPPFLAGS="$save_CPPFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+ LIBS="$save_LIBS"
+ ;;
+ esac
+
+ case $lt_cv_dlopen_self in
+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+ *) enable_dlopen_self=unknown ;;
+ esac
+
+ case $lt_cv_dlopen_self_static in
+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+ *) enable_dlopen_self_static=unknown ;;
+ esac
+fi
+_LT_DECL([dlopen_support], [enable_dlopen], [0],
+ [Whether dlopen is supported])
+_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
+ [Whether dlopen of programs is supported])
+_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
+ [Whether dlopen of statically linked programs is supported])
+])# LT_SYS_DLOPEN_SELF
+
+# Old name:
+AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
+
+
+# _LT_COMPILER_C_O([TAGNAME])
+# ---------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler.
+# This macro does not hard code the compiler like AC_PROG_CC_C_O.
+m4_defun([_LT_COMPILER_C_O],
+[m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+ [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+ $RM -r conftest 2>/dev/null
+ mkdir conftest
+ cd conftest
+ mkdir out
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ lt_compiler_flag="-o out/conftest2.$ac_objext"
+ # Insert the option either (1) after the last *FLAGS variable, or
+ # (2) before a word containing "conftest.", or (3) at the end.
+ # Note that $ac_compile itself does not contain backslashes and begins
+ # with a dollar sign (not a hyphen), so the echo should work correctly.
+ lt_compile=`echo "$ac_compile" | $SED \
+ -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:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$lt_compile" 2>out/conftest.err)
+ ac_status=$?
+ cat out/conftest.err >&AS_MESSAGE_LOG_FD
+ echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+ if (exit $ac_status) && test -s out/conftest2.$ac_objext
+ then
+ # The compiler can only warn and ignore the option if not recognized
+ # So say no if there are warnings
+ $ECHO "X$_lt_compiler_boilerplate" | $Xsed -e '/^$/d' > out/conftest.exp
+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+ _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+ fi
+ fi
+ chmod u+w . 2>&AS_MESSAGE_LOG_FD
+ $RM conftest*
+ # SGI C++ compiler will create directory out/ii_files/ for
+ # template instantiation
+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+ $RM out/* && rmdir out
+ cd ..
+ $RM -r conftest
+ $RM conftest*
+])
+_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
+ [Does compiler simultaneously support -c and -o options?])
+])# _LT_COMPILER_C_O
+
+
+# _LT_COMPILER_FILE_LOCKS([TAGNAME])
+# ----------------------------------
+# Check to see if we can do hard links to lock some files if needed
+m4_defun([_LT_COMPILER_FILE_LOCKS],
+[m4_require([_LT_ENABLE_LOCK])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+_LT_COMPILER_C_O([$1])
+
+hard_links="nottested"
+if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+ # do not overwrite the value of need_locks provided by the user
+ AC_MSG_CHECKING([if we can lock with hard links])
+ hard_links=yes
+ $RM conftest*
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ touch conftest.a
+ ln conftest.a conftest.b 2>&5 || hard_links=no
+ ln conftest.a conftest.b 2>/dev/null && hard_links=no
+ AC_MSG_RESULT([$hard_links])
+ if test "$hard_links" = no; then
+ AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+ need_locks=warn
+ fi
+else
+ need_locks=no
+fi
+_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
+])# _LT_COMPILER_FILE_LOCKS
+
+
+# _LT_CHECK_OBJDIR
+# ----------------
+m4_defun([_LT_CHECK_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+ lt_cv_objdir=.libs
+else
+ # MS-DOS does not allow filenames that begin with a dot.
+ lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+_LT_DECL([], [objdir], [0],
+ [The name of the directory that contains temporary libtool files])dnl
+m4_pattern_allow([LT_OBJDIR])dnl
+AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
+ [Define to the sub-directory in which libtool stores uninstalled libraries.])
+])# _LT_CHECK_OBJDIR
+
+
+# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
+# --------------------------------------
+# Check hardcoding attributes.
+m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
+ test -n "$_LT_TAGVAR(runpath_var, $1)" ||
+ test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+ # We can hardcode non-existent directories.
+ if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
+ # If the only mechanism to avoid hardcoding is shlibpath_var, we
+ # have to relink, otherwise we might link with an installed library
+ # when we should be linking with a yet-to-be-installed one
+ ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+ test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
+ # Linking always hardcodes the temporary library directory.
+ _LT_TAGVAR(hardcode_action, $1)=relink
+ else
+ # We can link without hardcoding, and we can hardcode nonexisting dirs.
+ _LT_TAGVAR(hardcode_action, $1)=immediate
+ fi
+else
+ # We cannot hardcode anything, or else we can only hardcode existing
+ # directories.
+ _LT_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
+ test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
+ # Fast installation is not supported
+ enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+ test "$enable_shared" = no; then
+ # Fast installation is not necessary
+ enable_fast_install=needless
+fi
+_LT_TAGDECL([], [hardcode_action], [0],
+ [How to hardcode a shared library path into an executable])
+])# _LT_LINKER_HARDCODE_LIBPATH
+
+
+# _LT_CMD_STRIPLIB
+# ----------------
+m4_defun([_LT_CMD_STRIPLIB],
+[m4_require([_LT_DECL_EGREP])
+striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+ test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+ test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+ AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+ case $host_os in
+ darwin*)
+ if test -n "$STRIP" ; then
+ striplib="$STRIP -x"
+ old_striplib="$STRIP -S"
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no])
+ fi
+ ;;
+ *)
+ AC_MSG_RESULT([no])
+ ;;
+ esac
+fi
+_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
+_LT_DECL([], [striplib], [1])
+])# _LT_CMD_STRIPLIB
+
+
+# _LT_SYS_DYNAMIC_LINKER([TAG])
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+m4_defun([_LT_SYS_DYNAMIC_LINKER],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_OBJDUMP])dnl
+m4_require([_LT_DECL_SED])dnl
+AC_MSG_CHECKING([dynamic linker characteristics])
+m4_if([$1],
+ [], [
+if test "$GCC" = yes; then
+ case $host_os in
+ darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+ *) lt_awk_arg="/^libraries:/" ;;
+ esac
+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$lt_search_path_spec" | $GREP ';' >/dev/null ; then
+ # if the path contains ";" then we assume it to be the separator
+ # otherwise default to the standard path separator (i.e. ":") - it is
+ # assumed that no part of a normal pathname contains ";" but that should
+ # okay in the real world where ";" in dirpaths is itself problematic.
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ # Ok, now we have the path, separated by spaces, we can step through it
+ # and add multilib dir if necessary.
+ lt_tmp_lt_search_path_spec=
+ lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+ for lt_sys_path in $lt_search_path_spec; do
+ if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+ else
+ test -d "$lt_sys_path" && \
+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+ fi
+ done
+ lt_search_path_spec=`$ECHO $lt_tmp_lt_search_path_spec | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+ lt_foo="";
+ lt_count=0;
+ for (lt_i = NF; lt_i > 0; lt_i--) {
+ if ($lt_i != "" && $lt_i != ".") {
+ if ($lt_i == "..") {
+ lt_count++;
+ } else {
+ if (lt_count == 0) {
+ lt_foo="/" $lt_i lt_foo;
+ } else {
+ lt_count--;
+ }
+ }
+ }
+ }
+ if (lt_foo != "") { lt_freq[[lt_foo]]++; }
+ if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
+}'`
+ sys_lib_search_path_spec=`$ECHO $lt_search_path_spec`
+else
+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+ shlibpath_var=LIBPATH
+
+ # AIX 3 has no versioning support, so we append a major version to the name.
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+
+aix[[4-9]]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ hardcode_into_libs=yes
+ if test "$host_cpu" = ia64; then
+ # AIX 5 supports IA64
+ library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ else
+ # With GCC up to 2.95.x, collect2 would create an import file
+ # for dependence libraries. The import file would start with
+ # the line `#! .'. This would cause the generated library to
+ # depend on `.', always an invalid library. This was fixed in
+ # development snapshots of GCC prior to 3.0.
+ case $host_os in
+ aix4 | aix4.[[01]] | aix4.[[01]].*)
+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+ echo ' yes '
+ echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+ :
+ else
+ can_build_shared=no
+ fi
+ ;;
+ esac
+ # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+ # soname into executable. Probably we can add versioning support to
+ # collect2, so additional links can be useful in future.
+ if test "$aix_use_runtimelinking" = yes; then
+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+ # instead of lib<name>.a to let people know that these are not
+ # typical AIX shared libraries.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ else
+ # We preserve .a as extension for shared libraries through AIX4.2
+ # and later when we are not doing run time linking.
+ library_names_spec='${libname}${release}.a $libname.a'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ fi
+ shlibpath_var=LIBPATH
+ fi
+ ;;
+
+amigaos*)
+ case $host_cpu in
+ powerpc)
+ # Since July 2007 AmigaOS4 officially supports .so libraries.
+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ ;;
+ m68k)
+ library_names_spec='$libname.ixlibrary $libname.a'
+ # Create ${libname}_ixlibrary.a entries in /sys/libs.
+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$ECHO "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+ ;;
+ esac
+ ;;
+
+beos*)
+ library_names_spec='${libname}${shared_ext}'
+ dynamic_linker="$host_os ld.so"
+ shlibpath_var=LIBRARY_PATH
+ ;;
+
+bsdi[[45]]*)
+ version_type=linux
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+ # the default ld.so.conf also contains /usr/contrib/lib and
+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+ # libtool to hard-code these into programs
+ ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+ version_type=windows
+ shrext_cmds=".dll"
+ need_version=no
+ need_lib_prefix=no
+
+ case $GCC,$host_os in
+ yes,cygwin* | yes,mingw* | yes,pw32* | yes,cegcc*)
+ library_names_spec='$libname.dll.a'
+ # DLL is installed to $(libdir)/../bin by postinstall_cmds
+ postinstall_cmds='base_file=`basename \${file}`~
+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+ dldir=$destdir/`dirname \$dlpath`~
+ test -d \$dldir || mkdir -p \$dldir~
+ $install_prog $dir/$dlname \$dldir/$dlname~
+ chmod a+x \$dldir/$dlname~
+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+ fi'
+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+ dlpath=$dir/\$dldll~
+ $RM \$dlpath'
+ shlibpath_overrides_runpath=yes
+
+ case $host_os in
+ cygwin*)
+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+ soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+ ;;
+ mingw* | cegcc*)
+ # MinGW DLLs use traditional 'lib' prefix
+ soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ sys_lib_search_path_spec=`$CC -print-search-dirs | $GREP "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+ if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
+ # It is most probably a Windows format PATH printed by
+ # mingw gcc, but we are running on Cygwin. Gcc prints its search
+ # path with ; separators, and with drive letters. We can handle the
+ # drive letters (cygwin fileutils understands them), so leave them,
+ # especially as we might pass files found there to a mingw objdump,
+ # which wouldn't understand a cygwinified path. Ahh.
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+ else
+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+ fi
+ ;;
+ pw32*)
+ # pw32 DLLs use 'pw' prefix rather than 'lib'
+ library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+ ;;
+ esac
+ ;;
+
+ *)
+ library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+ ;;
+ esac
+ dynamic_linker='Win32 ld.exe'
+ # FIXME: first we should search . and the directory the executable is in
+ shlibpath_var=PATH
+ ;;
+
+darwin* | rhapsody*)
+ dynamic_linker="$host_os dyld"
+ version_type=darwin
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+ soname_spec='${libname}${release}${major}$shared_ext'
+ shlibpath_overrides_runpath=yes
+ shlibpath_var=DYLD_LIBRARY_PATH
+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+m4_if([$1], [],[
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+ ;;
+
+dgux*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+freebsd1*)
+ dynamic_linker=no
+ ;;
+
+freebsd* | dragonfly*)
+ # DragonFly does not have aout. When/if they implement a new
+ # versioning mechanism, adjust this.
+ if test -x /usr/bin/objformat; then
+ objformat=`/usr/bin/objformat`
+ else
+ case $host_os in
+ freebsd[[123]]*) objformat=aout ;;
+ *) objformat=elf ;;
+ esac
+ fi
+ version_type=freebsd-$objformat
+ case $version_type in
+ freebsd-elf*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ need_version=no
+ need_lib_prefix=no
+ ;;
+ freebsd-*)
+ library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+ need_version=yes
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_os in
+ freebsd2*)
+ shlibpath_overrides_runpath=yes
+ ;;
+ freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
+ freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+ *) # from 4.6 on, and DragonFly
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+ esac
+ ;;
+
+gnu*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ hardcode_into_libs=yes
+ ;;
+
+hpux9* | hpux10* | hpux11*)
+ # Give a soname corresponding to the major version so that dld.sl refuses to
+ # link against other versions.
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ case $host_cpu in
+ ia64*)
+ shrext_cmds='.so'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.so"
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ if test "X$HPUX_IA64_MODE" = X32; then
+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+ else
+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+ fi
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ hppa*64*)
+ shrext_cmds='.sl'
+ hardcode_into_libs=yes
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+ ;;
+ *)
+ shrext_cmds='.sl'
+ dynamic_linker="$host_os dld.sl"
+ shlibpath_var=SHLIB_PATH
+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ ;;
+ esac
+ # HP-UX runs *really* slowly unless shared libraries are mode 555.
+ postinstall_cmds='chmod 555 $lib'
+ ;;
+
+interix[[3-9]]*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $host_os in
+ nonstopux*) version_type=nonstopux ;;
+ *)
+ if test "$lt_cv_prog_gnu_ld" = yes; then
+ version_type=linux
+ else
+ version_type=irix
+ fi ;;
+ esac
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+ case $host_os in
+ irix5* | nonstopux*)
+ libsuff= shlibsuff=
+ ;;
+ *)
+ case $LD in # libtool.m4 will add one of these switches to LD
+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+ libsuff= shlibsuff= libmagic=32-bit;;
+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+ libsuff=32 shlibsuff=N32 libmagic=N32;;
+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+ libsuff=64 shlibsuff=64 libmagic=64-bit;;
+ *) libsuff= shlibsuff= libmagic=never-match;;
+ esac
+ ;;
+ esac
+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+ sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+ hardcode_into_libs=yes
+ ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+ dynamic_linker=no
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ # Some binutils ld are patched to set DT_RUNPATH
+ save_LDFLAGS=$LDFLAGS
+ save_libdir=$libdir
+ eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
+ LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
+ [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
+ [shlibpath_overrides_runpath=yes])])
+ LDFLAGS=$save_LDFLAGS
+ libdir=$save_libdir
+
+ # This implies no fast_install, which is unacceptable.
+ # Some rework will be needed to allow for fast_install
+ # before this can be enabled.
+ hardcode_into_libs=yes
+
+ # Append ld.so.conf contents to the search path
+ if test -f /etc/ld.so.conf; then
+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+ fi
+
+ # We used to test for /lib/ld.so.1 and disable shared libraries on
+ # powerpc, because MkLinux only supported shared libraries with the
+ # GNU dynamic linker. Since this was broken with cross compilers,
+ # most powerpc-linux boxes support dynamic linking these days and
+ # people can always --disable-shared, the test was removed, and we
+ # assume the GNU/Linux dynamic linker is in use.
+ dynamic_linker='GNU/Linux ld.so'
+ ;;
+
+netbsdelf*-gnu)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='NetBSD ld.elf_so'
+ ;;
+
+netbsd*)
+ version_type=sunos
+ need_lib_prefix=no
+ need_version=no
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ dynamic_linker='NetBSD (a.out) ld.so'
+ else
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ dynamic_linker='NetBSD ld.elf_so'
+ fi
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ ;;
+
+newsos6)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ ;;
+
+*nto* | *qnx*)
+ version_type=qnx
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ dynamic_linker='ldqnx.so'
+ ;;
+
+openbsd*)
+ version_type=sunos
+ sys_lib_dlsearch_path_spec="/usr/lib"
+ need_lib_prefix=no
+ # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+ case $host_os in
+ openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+ *) need_version=no ;;
+ esac
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ case $host_os in
+ openbsd2.[[89]] | openbsd2.[[89]].*)
+ shlibpath_overrides_runpath=no
+ ;;
+ *)
+ shlibpath_overrides_runpath=yes
+ ;;
+ esac
+ else
+ shlibpath_overrides_runpath=yes
+ fi
+ ;;
+
+os2*)
+ libname_spec='$name'
+ shrext_cmds=".dll"
+ need_lib_prefix=no
+ library_names_spec='$libname${shared_ext} $libname.a'
+ dynamic_linker='OS/2 ld.exe'
+ shlibpath_var=LIBPATH
+ ;;
+
+osf3* | osf4* | osf5*)
+ version_type=osf
+ need_lib_prefix=no
+ need_version=no
+ soname_spec='${libname}${release}${shared_ext}$major'
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+ sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+ ;;
+
+rdos*)
+ dynamic_linker=no
+ ;;
+
+solaris*)
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ # ldd complains unless libraries are executable
+ postinstall_cmds='chmod +x $lib'
+ ;;
+
+sunos4*)
+ version_type=sunos
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ if test "$with_gnu_ld" = yes; then
+ need_lib_prefix=no
+ fi
+ need_version=yes
+ ;;
+
+sysv4 | sysv4.3*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ case $host_vendor in
+ sni)
+ shlibpath_overrides_runpath=no
+ need_lib_prefix=no
+ runpath_var=LD_RUN_PATH
+ ;;
+ siemens)
+ need_lib_prefix=no
+ ;;
+ motorola)
+ need_lib_prefix=no
+ need_version=no
+ shlibpath_overrides_runpath=no
+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+ ;;
+ esac
+ ;;
+
+sysv4*MP*)
+ if test -d /usr/nec ;then
+ version_type=linux
+ library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+ soname_spec='$libname${shared_ext}.$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ fi
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ version_type=freebsd-elf
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=yes
+ hardcode_into_libs=yes
+ if test "$with_gnu_ld" = yes; then
+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+ else
+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+ case $host_os in
+ sco3.2v5*)
+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+ ;;
+ esac
+ fi
+ sys_lib_dlsearch_path_spec='/usr/lib'
+ ;;
+
+tpf*)
+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.
+ version_type=linux
+ need_lib_prefix=no
+ need_version=no
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ shlibpath_var=LD_LIBRARY_PATH
+ shlibpath_overrides_runpath=no
+ hardcode_into_libs=yes
+ ;;
+
+uts4*)
+ version_type=linux
+ library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+ soname_spec='${libname}${release}${shared_ext}$major'
+ shlibpath_var=LD_LIBRARY_PATH
+ ;;
+
+*)
+ dynamic_linker=no
+ ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+ sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+ sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+_LT_DECL([], [variables_saved_for_relink], [1],
+ [Variables whose values should be saved in libtool wrapper scripts and
+ restored at link time])
+_LT_DECL([], [need_lib_prefix], [0],
+ [Do we need the "lib" prefix for modules?])
+_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
+_LT_DECL([], [version_type], [0], [Library versioning type])
+_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable])
+_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
+_LT_DECL([], [shlibpath_overrides_runpath], [0],
+ [Is shlibpath searched before the hard-coded library search path?])
+_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
+_LT_DECL([], [library_names_spec], [1],
+ [[List of archive names. First name is the real one, the rest are links.
+ The last name is the one that the linker finds with -lNAME]])
+_LT_DECL([], [soname_spec], [1],
+ [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [postinstall_cmds], [2],
+ [Command to use after installation of a shared archive])
+_LT_DECL([], [postuninstall_cmds], [2],
+ [Command to use after uninstallation of a shared archive])
+_LT_DECL([], [finish_cmds], [2],
+ [Commands used to finish a libtool library installation in a directory])
+_LT_DECL([], [finish_eval], [1],
+ [[As "finish_cmds", except a single script fragment to be evaled but
+ not shown]])
+_LT_DECL([], [hardcode_into_libs], [0],
+ [Whether we should hardcode library paths into libraries])
+_LT_DECL([], [sys_lib_search_path_spec], [2],
+ [Compile-time system search path for libraries])
+_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
+ [Run-time system search path for libraries])
+])# _LT_SYS_DYNAMIC_LINKER
+
+
+# _LT_PATH_TOOL_PREFIX(TOOL)
+# --------------------------
+# find a file program which can recognize shared library
+AC_DEFUN([_LT_PATH_TOOL_PREFIX],
+[m4_require([_LT_DECL_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] | ?:[\\/]*])
+ lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+ ;;
+*)
+ lt_save_MAGIC_CMD="$MAGIC_CMD"
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word. This closes a longstanding sh security hole.
+ ac_dummy="m4_if([$2], , $PATH, [$2])"
+ for ac_dir in $ac_dummy; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f $ac_dir/$1; then
+ lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+ if test -n "$file_magic_test_file"; then
+ case $deplibs_check_method in
+ "file_magic "*)
+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+ MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+ $EGREP "$file_magic_regex" > /dev/null; then
+ :
+ else
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such. This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem. Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+_LT_EOF
+ fi ;;
+ esac
+ fi
+ break
+ fi
+ done
+ IFS="$lt_save_ifs"
+ MAGIC_CMD="$lt_save_MAGIC_CMD"
+ ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+ AC_MSG_RESULT($MAGIC_CMD)
+else
+ AC_MSG_RESULT(no)
+fi
+_LT_DECL([], [MAGIC_CMD], [0],
+ [Used to examine libraries when file_magic_cmd begins with "file"])dnl
+])# _LT_PATH_TOOL_PREFIX
+
+# Old name:
+AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
+
+
+# _LT_PATH_MAGIC
+# --------------
+# find a file program which can recognize a shared library
+m4_defun([_LT_PATH_MAGIC],
+[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+ if test -n "$ac_tool_prefix"; then
+ _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+ else
+ MAGIC_CMD=:
+ fi
+fi
+])# _LT_PATH_MAGIC
+
+
+# LT_PATH_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([LT_PATH_LD],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_ARG_WITH([gnu-ld],
+ [AS_HELP_STRING([--with-gnu-ld],
+ [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+ [test "$withval" = no || with_gnu_ld=yes],
+ [with_gnu_ld=no])dnl
+
+ac_prog=ld
+if test "$GCC" = yes; then
+ # Check if gcc -print-prog-name=ld gives a path.
+ AC_MSG_CHECKING([for ld used by $CC])
+ case $host in
+ *-*-mingw*)
+ # gcc leaves a trailing carriage return which upsets mingw
+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+ *)
+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+ esac
+ case $ac_prog in
+ # Accept absolute paths.
+ [[\\/]]* | ?:[[\\/]]*)
+ re_direlt='/[[^/]][[^/]]*/\.\./'
+ # Canonicalize the pathname of ld
+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+ done
+ test -z "$LD" && LD="$ac_prog"
+ ;;
+ "")
+ # If it fails, then pretend we aren't using GCC.
+ ac_prog=ld
+ ;;
+ *)
+ # If it is relative, then search for the first ld in PATH.
+ with_gnu_ld=unknown
+ ;;
+ esac
+elif test "$with_gnu_ld" = yes; then
+ AC_MSG_CHECKING([for GNU ld])
+else
+ AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+ lt_cv_path_LD="$ac_dir/$ac_prog"
+ # Check to see if the program is GNU ld. I'd rather use --version,
+ # but apparently some variants of GNU ld only accept -v.
+ # Break only if it was the GNU/non-GNU ld that we prefer.
+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+ *GNU* | *'with BFD'*)
+ test "$with_gnu_ld" != no && break
+ ;;
+ *)
+ test "$with_gnu_ld" != yes && break
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+else
+ lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+ AC_MSG_RESULT($LD)
+else
+ AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+_LT_PATH_LD_GNU
+AC_SUBST([LD])
+
+_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
+])# LT_PATH_LD
+
+# Old names:
+AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
+AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_LD], [])
+dnl AC_DEFUN([AC_PROG_LD], [])
+
+
+# _LT_PATH_LD_GNU
+#- --------------
+m4_defun([_LT_PATH_LD_GNU],
+[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+ lt_cv_prog_gnu_ld=yes
+ ;;
+*)
+ lt_cv_prog_gnu_ld=no
+ ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# _LT_PATH_LD_GNU
+
+
+# _LT_CMD_RELOAD
+# --------------
+# find reload flag for linker
+# -- PORTME Some linkers may need a different reload flag.
+m4_defun([_LT_CMD_RELOAD],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+ lt_cv_ld_reload_flag,
+ [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+ darwin*)
+ if test "$GCC" = yes; then
+ reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+ else
+ reload_cmds='$LD$reload_flag -o $output$reload_objs'
+ fi
+ ;;
+esac
+_LT_DECL([], [reload_flag], [1], [How to create reloadable object files])dnl
+_LT_DECL([], [reload_cmds], [2])dnl
+])# _LT_CMD_RELOAD
+
+
+# _LT_CHECK_MAGIC_METHOD
+# ----------------------
+# how to check for library dependencies
+# -- PORTME fill in with the dynamic library characteristics
+m4_defun([_LT_CHECK_MAGIC_METHOD],
+[m4_require([_LT_DECL_EGREP])
+m4_require([_LT_DECL_OBJDUMP])
+AC_CACHE_CHECK([how to recognize dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix[[4-9]]*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+beos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+bsdi[[45]]*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+ lt_cv_file_magic_cmd='/usr/bin/file -L'
+ lt_cv_file_magic_test_file=/shlib/libc.so
+ ;;
+
+cygwin*)
+ # func_win32_libid is a shell function defined in ltmain.sh
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ ;;
+
+mingw* | pw32*)
+ # Base MSYS/MinGW do not provide the 'file' command needed by
+ # func_win32_libid shell function, so use a weaker test based on 'objdump',
+ # unless we find 'file', for example because we are cross-compiling.
+ if ( file / ) >/dev/null 2>&1; then
+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+ lt_cv_file_magic_cmd='func_win32_libid'
+ else
+ lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ fi
+ ;;
+
+cegcc)
+ # use the weaker test based on 'objdump'. See mingw*.
+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+ lt_cv_file_magic_cmd='$OBJDUMP -f'
+ ;;
+
+darwin* | rhapsody*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+freebsd* | dragonfly*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ case $host_cpu in
+ i*86 )
+ # Not sure whether the presence of OpenBSD here was a mistake.
+ # Let's accept both of them until this is cleared up.
+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+ ;;
+ esac
+ else
+ lt_cv_deplibs_check_method=pass_all
+ fi
+ ;;
+
+gnu*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+hpux10.20* | hpux11*)
+ lt_cv_file_magic_cmd=/usr/bin/file
+ case $host_cpu in
+ ia64*)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+ ;;
+ hppa*64*)
+ [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+ ;;
+ *)
+ lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+ lt_cv_file_magic_test_file=/usr/lib/libc.sl
+ ;;
+ esac
+ ;;
+
+interix[[3-9]]*)
+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
+ ;;
+
+irix5* | irix6* | nonstopux*)
+ case $LD in
+ *-32|*"-32 ") libmagic=32-bit;;
+ *-n32|*"-n32 ") libmagic=N32;;
+ *-64|*"-64 ") libmagic=64-bit;;
+ *) libmagic=never-match;;
+ esac
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+# This must be Linux ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+ fi
+ ;;
+
+newos6*)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+ lt_cv_file_magic_cmd=/usr/bin/file
+ lt_cv_file_magic_test_file=/usr/lib/libnls.so
+ ;;
+
+*nto* | *qnx*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+openbsd*)
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+ else
+ lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+ fi
+ ;;
+
+osf3* | osf4* | osf5*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+rdos*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+solaris*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+
+sysv4 | sysv4.3*)
+ case $host_vendor in
+ motorola)
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+ ;;
+ ncr)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ sequent)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+ ;;
+ sni)
+ lt_cv_file_magic_cmd='/bin/file'
+ lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+ lt_cv_file_magic_test_file=/lib/libc.so
+ ;;
+ siemens)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ pc)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+ esac
+ ;;
+
+tpf*)
+ lt_cv_deplibs_check_method=pass_all
+ ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+_LT_DECL([], [deplibs_check_method], [1],
+ [Method to check whether dependent libraries are shared objects])
+_LT_DECL([], [file_magic_cmd], [1],
+ [Command to use when deplibs_check_method == "file_magic"])
+])# _LT_CHECK_MAGIC_METHOD
+
+
+# LT_PATH_NM
+# ----------
+# find the pathname to a BSD- or MS-compatible name lister
+AC_DEFUN([LT_PATH_NM],
+[AC_REQUIRE([AC_PROG_CC])dnl
+AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
+[if test -n "$NM"; then
+ # Let the user override the test.
+ lt_cv_path_NM="$NM"
+else
+ lt_nm_to_check="${ac_tool_prefix}nm"
+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+ lt_nm_to_check="$lt_nm_to_check nm"
+ fi
+ for lt_tmp_nm in $lt_nm_to_check; do
+ lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+ IFS="$lt_save_ifs"
+ test -z "$ac_dir" && ac_dir=.
+ tmp_nm="$ac_dir/$lt_tmp_nm"
+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+ # Check to see if the nm accepts a BSD-compat flag.
+ # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+ # nm: unknown option "B" ignored
+ # Tru64's nm complains that /dev/null is an invalid object file
+ case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+ */dev/null* | *'Invalid file or object type'*)
+ lt_cv_path_NM="$tmp_nm -B"
+ break
+ ;;
+ *)
+ case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+ */dev/null*)
+ lt_cv_path_NM="$tmp_nm -p"
+ break
+ ;;
+ *)
+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+ continue # so that we can try to find one that supports BSD flags
+ ;;
+ esac
+ ;;
+ esac
+ fi
+ done
+ IFS="$lt_save_ifs"
+ done
+ : ${lt_cv_path_NM=no}
+fi])
+if test "$lt_cv_path_NM" != "no"; then
+ NM="$lt_cv_path_NM"
+else
+ # Didn't find any BSD compatible name lister, look for dumpbin.
+ AC_CHECK_TOOLS(DUMPBIN, ["dumpbin -symbols" "link -dump -symbols"], :)
+ AC_SUBST([DUMPBIN])
+ if test "$DUMPBIN" != ":"; then
+ NM="$DUMPBIN"
+ fi
+fi
+test -z "$NM" && NM=nm
+AC_SUBST([NM])
+_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
+
+AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
+ [lt_cv_nm_interface="BSD nm"
+ echo "int some_variable = 0;" > conftest.$ac_ext
+ (eval echo "\"\$as_me:__oline__: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$ac_compile" 2>conftest.err)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:__oline__: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+ cat conftest.err >&AS_MESSAGE_LOG_FD
+ (eval echo "\"\$as_me:__oline__: output\"" >&AS_MESSAGE_LOG_FD)
+ cat conftest.out >&AS_MESSAGE_LOG_FD
+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+ lt_cv_nm_interface="MS dumpbin"
+ fi
+ rm -f conftest*])
+])# LT_PATH_NM
+
+# Old names:
+AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
+AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_PROG_NM], [])
+dnl AC_DEFUN([AC_PROG_NM], [])
+
+
+# LT_LIB_M
+# --------
+# check for math library
+AC_DEFUN([LT_LIB_M],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+ # These system don't have libm, or don't need it
+ ;;
+*-ncr-sysv4.3*)
+ AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+ AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+ ;;
+*)
+ AC_CHECK_LIB(m, cos, LIBM="-lm")
+ ;;
+esac
+AC_SUBST([LIBM])
+])# LT_LIB_M
+
+# Old name:
+AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_CHECK_LIBM], [])
+
+
+# _LT_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------
+m4_defun([_LT_COMPILER_NO_RTTI],
+[m4_require([_LT_TAG_COMPILER])dnl
+
+_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+ _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+ lt_cv_prog_compiler_rtti_exceptions,
+ [-fno-rtti -fno-exceptions], [],
+ [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
+ [Compiler flag to turn off builtin functions])
+])# _LT_COMPILER_NO_RTTI
+
+
+# _LT_CMD_GLOBAL_SYMBOLS
+# ----------------------
+m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+AC_REQUIRE([LT_PATH_LD])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix. What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+ symcode='[[BCDT]]'
+ ;;
+cygwin* | mingw* | pw32* | cegcc*)
+ symcode='[[ABCDGISTW]]'
+ ;;
+hpux*)
+ if test "$host_cpu" = ia64; then
+ symcode='[[ABCDEGRST]]'
+ fi
+ ;;
+irix* | nonstopux*)
+ symcode='[[BCDEGRST]]'
+ ;;
+osf*)
+ symcode='[[BCDEGQRST]]'
+ ;;
+solaris*)
+ symcode='[[BDRT]]'
+ ;;
+sco3.2v5*)
+ symcode='[[DT]]'
+ ;;
+sysv4.2uw2*)
+ symcode='[[DT]]'
+ ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+ symcode='[[ABDT]]'
+ ;;
+sysv4)
+ symcode='[[DFNSTU]]'
+ ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+ symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([[^ ]]*\) $/ {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \(lib[[^ ]]*\)$/ {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/ {\"lib\2\", (void *) \&\2},/p'"
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+ ;;
+esac
+
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
+
+ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+ symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+ # Write the raw and C identifiers.
+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+ # Fake it for dumpbin and say T for any non-static function
+ # and D for any global variable.
+ # Also find C++ and __fastcall symbols from MSVC++,
+ # which start with @ or ?.
+ lt_cv_sys_global_symbol_pipe="$AWK ['"\
+" {last_section=section; section=\$ 3};"\
+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+" \$ 0!~/External *\|/{next};"\
+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+" {if(hide[section]) next};"\
+" {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+" {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+" s[1]~/^[@?]/{print s[1], s[1]; next};"\
+" s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+" ' prfx=^$ac_symprfx]"
+ else
+ lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+ fi
+
+ # Check to see that the pipe works correctly.
+ pipe_works=no
+
+ rm -f conftest*
+ cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
+
+ if AC_TRY_EVAL(ac_compile); then
+ # Now try to grab the symbols.
+ nlist=conftest.nm
+ if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+ # Try sorting and uniquifying the output.
+ if sort "$nlist" | uniq > "$nlist"T; then
+ mv -f "$nlist"T "$nlist"
+ else
+ rm -f "$nlist"T
+ fi
+
+ # Make sure that we snagged all the symbols we need.
+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+ cat <<_LT_EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+_LT_EOF
+ # Now generate the symbol file.
+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
+
+ cat <<_LT_EOF >> conftest.$ac_ext
+
+/* The mapping between symbol names and symbols. */
+const struct {
+ const char *name;
+ void *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[[]] =
+{
+ { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+ $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/ {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+ cat <<\_LT_EOF >> conftest.$ac_ext
+ {0, (void *) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+ return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+ # Now try linking the two files.
+ mv conftest.$ac_objext conftstm.$ac_objext
+ lt_save_LIBS="$LIBS"
+ lt_save_CFLAGS="$CFLAGS"
+ LIBS="conftstm.$ac_objext"
+ CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+ if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+ pipe_works=yes
+ fi
+ LIBS="$lt_save_LIBS"
+ CFLAGS="$lt_save_CFLAGS"
+ else
+ echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+ fi
+ else
+ echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+ cat conftest.$ac_ext >&5
+ fi
+ rm -rf conftest* conftst*
+
+ # Do not use the global_symbol_pipe unless it works.
+ if test "$pipe_works" = yes; then
+ break
+ else
+ lt_cv_sys_global_symbol_pipe=
+ fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+ lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+ AC_MSG_RESULT(failed)
+else
+ AC_MSG_RESULT(ok)
+fi
+
+_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
+ [Take the output of nm and produce a listing of raw symbols and C names])
+_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
+ [Transform the output of nm in a proper C declaration])
+_LT_DECL([global_symbol_to_c_name_address],
+ [lt_cv_sys_global_symbol_to_c_name_address], [1],
+ [Transform the output of nm in a C name address pair])
+_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
+ [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
+ [Transform the output of nm in a C name address pair when lib prefix is needed])
+]) # _LT_CMD_GLOBAL_SYMBOLS
+
+
+# _LT_COMPILER_PIC([TAGNAME])
+# ---------------------------
+m4_defun([_LT_COMPILER_PIC],
+[m4_require([_LT_TAG_COMPILER])dnl
+_LT_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+m4_if([$1], [CXX], [
+ # C++ specific cases for pic, static, wl, etc.
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+ mingw* | cygwin* | os2* | pw32* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+ *djgpp*)
+ # DJGPP does not support shared libraries at all
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ case $host_os in
+ aix[[4-9]]*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+ chorus*)
+ case $cc_basename in
+ cxch68*)
+ # Green Hills C++ Compiler
+ # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+ ;;
+ esac
+ ;;
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ freebsd* | dragonfly*)
+ # FreeBSD uses GNU C++
+ ;;
+ hpux9* | hpux10* | hpux11*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ fi
+ ;;
+ aCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ interix*)
+ # This is c89, which is MS Visual C++ (no shared libs)
+ # Anyone wants to do a port?
+ ;;
+ irix5* | irix6* | nonstopux*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ # CC pic flag -KPIC is the default.
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # KAI C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ ecpc* )
+ # old Intel C++ for x86_64 which still supported -KPIC.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ icpc* )
+ # Intel C++, used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ cxx*)
+ # Compaq C++
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xlc* | xlC*)
+ # IBM XL 8.0 on PPC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+ lynxos*)
+ ;;
+ m88k*)
+ ;;
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ netbsd* | netbsdelf*-gnu)
+ ;;
+ *qnx* | *nto*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ cxx*)
+ # Digital/Compaq C++
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # Make sure the PIC flag is empty. It appears that all Alpha
+ # Linux and Compaq Tru64 Unix objects are PIC.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ psos*)
+ ;;
+ solaris*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ lcc*)
+ # Lucid
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ esac
+ ;;
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ ;;
+ *)
+ ;;
+ esac
+ ;;
+ vxworks*)
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+],
+[
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+ case $host_os in
+ aix*)
+ # All AIX code is PIC.
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ m68k)
+ # FIXME: we need at least 68020 code to build shared libraries, but
+ # adding the `-m68020' flag to GCC prevents building anything better,
+ # like `-m68040'.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+ ;;
+ esac
+ ;;
+
+ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+ # PIC is the default for these OSes.
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ # Although the cygwin gcc ignores -fPIC, still need this for old-style
+ # (--disable-auto-import) libraries
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ darwin* | rhapsody*)
+ # PIC is the default on this platform
+ # Common symbols not allowed in MH_DYLIB files
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+ ;;
+
+ hpux*)
+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag
+ # sets the default TLS model and affects inlining.
+ case $host_cpu in
+ hppa*64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+ # Instead, we relocate shared libraries at runtime.
+ ;;
+
+ msdosdjgpp*)
+ # Just because we use GCC doesn't mean we suddenly get shared libraries
+ # on systems that don't support them.
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ enable_shared=no
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+ fi
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ ;;
+ esac
+ else
+ # PORTME Check for flag to pass linker flags through the system compiler.
+ case $host_os in
+ aix*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ if test "$host_cpu" = ia64; then
+ # AIX 5 now supports IA64 processor
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ else
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+ fi
+ ;;
+
+ mingw* | cygwin* | pw32* | os2* | cegcc*)
+ # This hack is so that the source file can tell whether it is being
+ # built for inclusion in a dll (and should export symbols for example).
+ m4_if([$1], [GCJ], [],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
+ ;;
+
+ hpux9* | hpux10* | hpux11*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+ # not for PA HP-UX.
+ case $host_cpu in
+ hppa*64*|ia64*)
+ # +Z the default
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+ ;;
+ esac
+ # Is there a better lt_prog_compiler_static that works with the bundled CC?
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # PIC (with -KPIC) is the default.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ # old Intel for x86_64 which still supported -KPIC.
+ ecc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # icc used to be incompatible with GCC.
+ # ICC 10 doesn't accept -KPIC any more.
+ icc* | ifort*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
+ ;;
+ # Lahey Fortran 8.1.
+ lf95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
+ ;;
+ pgcc* | pgf77* | pgf90* | pgf95*)
+ # Portland Group compilers (*not* the Pentium gcc compiler,
+ # which looks to be a dead project)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+ ccc*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All Alpha code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+ xl*)
+ # IBM XL C 8.0/Fortran 10.1 on PPC
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C 5.9
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ ;;
+ *Sun\ F*)
+ # Sun Fortran 8.3 passes all unrecognized flags to the linker
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *nto* | *qnx*)
+ # QNX uses GNU C++, but need to define -shared option too, otherwise
+ # it will coredump.
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
+ ;;
+
+ osf3* | osf4* | osf5*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ # All OSF/1 code is PIC.
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ rdos*)
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ case $cc_basename in
+ f77* | f90* | f95*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4 | sysv4.2uw2* | sysv4.3*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec ;then
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ fi
+ ;;
+
+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ unicos*)
+ _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+ _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+ ;;
+
+ *)
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+ ;;
+ esac
+ fi
+])
+case $host_os in
+ # For platforms which do not support PIC, -DPIC is meaningless:
+ *djgpp*)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ ;;
+ *)
+ _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
+ ;;
+esac
+AC_MSG_RESULT([$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
+_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
+ [How to pass a linker flag through the compiler])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
+ _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
+ [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
+ [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
+ [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
+ "" | " "*) ;;
+ *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+ esac],
+ [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
+ _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
+ [Additional compiler flags for building library objects])
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
+_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
+ _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
+ $lt_tmp_static_flag,
+ [],
+ [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
+_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
+ [Compiler flag to prevent dynamic linking])
+])# _LT_COMPILER_PIC
+
+
+# _LT_LINKER_SHLIBS([TAGNAME])
+# ----------------------------
+# See if the linker supports building shared libraries.
+m4_defun([_LT_LINKER_SHLIBS],
+[AC_REQUIRE([LT_PATH_LD])dnl
+AC_REQUIRE([LT_PATH_NM])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+m4_require([_LT_DECL_SED])dnl
+m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
+m4_require([_LT_TAG_COMPILER])dnl
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+m4_if([$1], [CXX], [
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ case $host_os in
+ aix[[4-9]]*)
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ ;;
+ pw32*)
+ _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+ ;;
+ cygwin* | mingw* | cegcc*)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;/^.*[[ ]]__nm__/s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ linux* | k*bsd*-gnu)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ ;;
+ esac
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+], [
+ runpath_var=
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(archive_cmds, $1)=
+ _LT_TAGVAR(archive_expsym_cmds, $1)=
+ _LT_TAGVAR(compiler_needs_object, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+ _LT_TAGVAR(hardcode_automatic, $1)=no
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ _LT_TAGVAR(hardcode_minus_L, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+ _LT_TAGVAR(inherit_rpath, $1)=no
+ _LT_TAGVAR(link_all_deplibs, $1)=unknown
+ _LT_TAGVAR(module_cmds, $1)=
+ _LT_TAGVAR(module_expsym_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)=
+ _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+ _LT_TAGVAR(thread_safe_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ # include_expsyms should be a list of space-separated symbols to be *always*
+ # included in the symbol list
+ _LT_TAGVAR(include_expsyms, $1)=
+ # exclude_expsyms can be an extended regexp of symbols to exclude
+ # it will be wrapped by ` (' and `)$', so one must not match beginning or
+ # end of line. Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+ # as well as any symbol that contains `d'.
+ _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+ # platforms (ab)use it in PIC code, but their linkers get confused if
+ # the symbol is explicitly referenced. Since portable code cannot
+ # rely on this symbol name, it's probably fine to never include it in
+ # preloaded symbol tables.
+ # Exclude shared library initialization/finalization symbols.
+dnl Note also adjust exclude_expsyms for C++ above.
+ extract_expsyms_cmds=
+
+ case $host_os in
+ cygwin* | mingw* | pw32* | cegcc*)
+ # FIXME: the MSVC++ port hasn't been tested in a loooong time
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ if test "$GCC" != yes; then
+ with_gnu_ld=no
+ fi
+ ;;
+ interix*)
+ # we just hope/assume this is gcc and not c89 (= MSVC++)
+ with_gnu_ld=yes
+ ;;
+ openbsd*)
+ with_gnu_ld=no
+ ;;
+ linux* | k*bsd*-gnu)
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ ;;
+ esac
+
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ if test "$with_gnu_ld" = yes; then
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ wlarc='${wl}'
+
+ # Set some defaults for GNU ld with shared library support. These
+ # are reset later if shared libraries are not supported. Putting them
+ # here allows them to be overridden if necessary.
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ supports_anon_versioning=no
+ case `$LD -v 2>&1` in
+ *GNU\ gold*) supports_anon_versioning=yes ;;
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+ *\ 2.11.*) ;; # other 2.11 versions
+ *) supports_anon_versioning=yes ;;
+ esac
+
+ # See if GNU ld supports shared libraries.
+ case $host_os in
+ aix[[3-9]]*)
+ # On AIX/PPC, the GNU linker is very broken
+ if test "$host_cpu" != ia64; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support. If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+_LT_EOF
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols'
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+
+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+ tmp_diet=no
+ if test "$host_os" = linux-dietlibc; then
+ case $cc_basename in
+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)
+ esac
+ fi
+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+ && test "$tmp_diet" = no
+ then
+ tmp_addflag=
+ tmp_sharedflag='-shared'
+ case $cc_basename,$host_cpu in
+ pgcc*) # Portland Group C compiler
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag'
+ ;;
+ pgf77* | pgf90* | pgf95*) # Portland Group f77 and f90 compilers
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ tmp_addflag=' $pic_flag -Mnomain' ;;
+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64
+ tmp_addflag=' -i_dynamic' ;;
+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64
+ tmp_addflag=' -i_dynamic -nofor_main' ;;
+ ifc* | ifort*) # Intel Fortran compiler
+ tmp_addflag=' -nofor_main' ;;
+ lf95*) # Lahey Fortran 8.1
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ tmp_sharedflag='--shared' ;;
+ xl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+ tmp_sharedflag='-qmkshrobj'
+ tmp_addflag= ;;
+ esac
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*) # Sun C 5.9
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+ tmp_sharedflag='-G' ;;
+ *Sun\ F*) # Sun Fortran 8.3
+ tmp_sharedflag='-G' ;;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+
+ case $cc_basename in
+ xlf*)
+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $compiler_flags -soname $soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $LD -shared $libobjs $deplibs $compiler_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ esac
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+ wlarc=
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ fi
+ ;;
+
+ solaris*)
+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+ case `$LD -v 2>&1` in
+ *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ cat <<_LT_EOF 1>&2
+
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems. Therefore, libtool
+*** is disabling shared libraries support. We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+_LT_EOF
+ ;;
+ *)
+ # For security reasons, it is highly recommended that you always
+ # use absolute paths for naming shared libraries, and exclude the
+ # DT_RUNPATH tag from executables and libraries. But doing so
+ # requires that you compile everything twice, which is a pain.
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ sunos4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+
+ if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
+ runpath_var=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ # PORTME fill in a description of your system's linker (not GNU ld)
+ case $host_os in
+ aix3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+ # Note: this linker hardcodes the directories in LIBPATH if there
+ # are no directories specified by -L.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+ # Neither direct hardcoding nor static linking is supported with a
+ # broken collect2.
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ # If we're using GNU nm, then we don't want the "-C" option.
+ # -C means demangle to AIX nm, but means don't demangle with GNU nm
+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ else
+ _LT_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+ fi
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+ aix_use_runtimelinking=yes
+ break
+ fi
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GCC" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ ;;
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=no
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ amigaos*)
+ case $host_cpu in
+ powerpc)
+ # see comment about AmigaOS4 .so support
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)=''
+ ;;
+ m68k)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ ;;
+
+ bsdi[[45]]*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # When not using gcc, we currently assume that we are using
+ # Microsoft Visual C++.
+ # hardcode_libdir_flag_spec is actually meaningless, as there is
+ # no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Tell ltmain to make .lib files, not .a files.
+ libext=lib
+ # Tell ltmain to make .dll files, not .so files.
+ shrext_cmds=".dll"
+ # FIXME: Setting linknames here is a bad hack.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `$ECHO "X$deplibs" | $Xsed -e '\''s/ -lc$//'\''` -link -dll~linknames='
+ # The linker will automatically build a .lib file if we build a DLL.
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
+ # FIXME: Should let the user specify the lib program.
+ _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
+ _LT_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+ ;;
+
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ freebsd1*)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+ # support. Future versions do this automatically, but an explicit c++rt0.o
+ # does not break anything, and helps significantly (at the cost of a little
+ # extra space).
+ freebsd2.2*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+ freebsd2*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+ freebsd* | dragonfly*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ hpux9*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+
+ hpux10*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ fi
+ ;;
+
+ hpux11*)
+ if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ else
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ fi
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+ # hardcode_minus_L: Not really in the search PATH,
+ # but as the default location of the library.
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ ;;
+ esac
+ fi
+ ;;
+
+ irix5* | irix6* | nonstopux*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ # Try to use the -exported_symbol ld option, if it does not
+ # work, assume that -exports_file does not work either and
+ # implicitly export all symbols.
+ save_LDFLAGS="$LDFLAGS"
+ LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+ AC_LINK_IFELSE(int foo(void) {},
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+ )
+ LDFLAGS="$save_LDFLAGS"
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ netbsd* | netbsdelf*-gnu)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ newsos6)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *nto* | *qnx*)
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ else
+ case $host_os in
+ openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ ;;
+ esac
+ fi
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ os2*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$ECHO DATA >> $output_objdir/$libname.def~$ECHO " SINGLE NONSHARED" >> $output_objdir/$libname.def~$ECHO EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+ _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+ ;;
+
+ osf3*)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ osf4* | osf5*) # as osf3* with the addition of -msym flag
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ else
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+ $CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+ # Both c and cxx compiler support -rpath directly
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ fi
+ _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ ;;
+
+ solaris*)
+ _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
+ if test "$GCC" = yes; then
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ else
+ case `$CC -V 2>&1` in
+ *"Compilers 5.0"*)
+ wlarc=''
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+ ;;
+ *)
+ wlarc='${wl}'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+ ;;
+ esac
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'. GCC discards it without `$wl',
+ # but is careful enough not to reorder.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ fi
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+
+ sunos4*)
+ if test "x$host_vendor" = xsequent; then
+ # Use $CC to link under sequent, because it throws in some extra .o
+ # files that make .init and .fini sections work.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+ fi
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4)
+ case $host_vendor in
+ sni)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+ ;;
+ siemens)
+ ## LD is ld it makes a PLAMLIB
+ ## CC just makes a GrossModule.
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ ;;
+ motorola)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+ ;;
+ esac
+ runpath_var='LD_RUN_PATH'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ sysv4.3*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+ ;;
+
+ sysv4*MP*)
+ if test -d /usr/nec; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var=LD_RUN_PATH
+ hardcode_runpath_var=yes
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ fi
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ if test "$GCC" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ fi
+ ;;
+
+ uts4*)
+ _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+
+ *)
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ if test x$host_vendor = xsni; then
+ case $host in
+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
+ ;;
+ esac
+ fi
+ fi
+])
+AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
+
+_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
+_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
+_LT_DECL([], [extract_expsyms_cmds], [2],
+ [The commands to extract the exported symbol list from a shared archive])
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+ # Assume -lc should be added
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+ if test "$enable_shared" = yes && test "$GCC" = yes; then
+ case $_LT_TAGVAR(archive_cmds, $1) in
+ *'~'*)
+ # FIXME: we may have to deal with multi-command sequences.
+ ;;
+ '$CC '*)
+ # Test whether the compiler implicitly links with -lc since on some
+ # systems, -lgcc has to come before -lc. If gcc already passes -lc
+ # to ld, don't add -lc before -lgcc.
+ AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+ $RM conftest*
+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+ if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+ soname=conftest
+ lib=conftest
+ libobjs=conftest.$ac_objext
+ deplibs=
+ wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
+ pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
+ compiler_flags=-v
+ linker_flags=-v
+ verstring=
+ output_objdir=.
+ libname=conftest
+ lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
+ _LT_TAGVAR(allow_undefined_flag, $1)=
+ if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
+ then
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ else
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ fi
+ _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+ else
+ cat conftest.err 1>&5
+ fi
+ $RM conftest*
+ AC_MSG_RESULT([$_LT_TAGVAR(archive_cmds_need_lc, $1)])
+ ;;
+ esac
+ fi
+ ;;
+esac
+
+_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
+ [Whether or not to add -lc for building shared libraries])
+_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
+ [enable_shared_with_static_runtimes], [0],
+ [Whether or not to disallow shared libs when runtime libs are static])
+_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
+ [Compiler flag to allow reflexive dlopens])
+_LT_TAGDECL([], [whole_archive_flag_spec], [1],
+ [Compiler flag to generate shared objects directly from archives])
+_LT_TAGDECL([], [compiler_needs_object], [1],
+ [Whether the compiler copes with passing no objects directly])
+_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
+ [Create an old-style archive from a shared archive])
+_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
+ [Create a temporary old-style archive to link instead of a shared archive])
+_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
+_LT_TAGDECL([], [archive_expsym_cmds], [2])
+_LT_TAGDECL([], [module_cmds], [2],
+ [Commands used to build a loadable module if different from building
+ a shared archive.])
+_LT_TAGDECL([], [module_expsym_cmds], [2])
+_LT_TAGDECL([], [with_gnu_ld], [1],
+ [Whether we are building with GNU ld or not])
+_LT_TAGDECL([], [allow_undefined_flag], [1],
+ [Flag that allows shared libraries with undefined symbols to be built])
+_LT_TAGDECL([], [no_undefined_flag], [1],
+ [Flag that enforces no undefined symbols])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
+ [Flag to hardcode $libdir into a binary during linking.
+ This must work even if $libdir does not exist])
+_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
+ [[If ld is used when linking, flag to hardcode $libdir into a binary
+ during linking. This must work even if $libdir does not exist]])
+_LT_TAGDECL([], [hardcode_libdir_separator], [1],
+ [Whether we need a single "-rpath" flag with a separated argument])
+_LT_TAGDECL([], [hardcode_direct], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary])
+_LT_TAGDECL([], [hardcode_direct_absolute], [0],
+ [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
+ DIR into the resulting binary and the resulting library dependency is
+ "absolute", i.e impossible to change by setting ${shlibpath_var} if the
+ library is relocated])
+_LT_TAGDECL([], [hardcode_minus_L], [0],
+ [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
+ [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+ into the resulting binary])
+_LT_TAGDECL([], [hardcode_automatic], [0],
+ [Set to "yes" if building a shared library automatically hardcodes DIR
+ into the library and all subsequent libraries and executables linked
+ against it])
+_LT_TAGDECL([], [inherit_rpath], [0],
+ [Set to yes if linker adds runtime paths of dependent libraries
+ to runtime path list])
+_LT_TAGDECL([], [link_all_deplibs], [0],
+ [Whether libtool must link a program against all its dependency libraries])
+_LT_TAGDECL([], [fix_srcfile_path], [1],
+ [Fix the shell variable $srcfile for the compiler])
+_LT_TAGDECL([], [always_export_symbols], [0],
+ [Set to "yes" if exported symbols are required])
+_LT_TAGDECL([], [export_symbols_cmds], [2],
+ [The commands to list exported symbols])
+_LT_TAGDECL([], [exclude_expsyms], [1],
+ [Symbols that should not be listed in the preloaded symbols])
+_LT_TAGDECL([], [include_expsyms], [1],
+ [Symbols that must always be exported])
+_LT_TAGDECL([], [prelink_cmds], [2],
+ [Commands necessary for linking programs (against libraries) with templates])
+_LT_TAGDECL([], [file_list_spec], [1],
+ [Specify filename containing input files])
+dnl FIXME: Not yet implemented
+dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
+dnl [Compiler flag to generate thread safe objects])
+])# _LT_LINKER_SHLIBS
+
+
+# _LT_LANG_C_CONFIG([TAG])
+# ------------------------
+# Ensure that the configuration variables for a C compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_C_CONFIG],
+[m4_require([_LT_DECL_EGREP])dnl
+lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
+
+_LT_TAG_COMPILER
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+ LT_SYS_DLOPEN_SELF
+ _LT_CMD_STRIPLIB
+
+ # Report which library types will actually be built
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_CONFIG($1)
+fi
+AC_LANG_POP
+CC="$lt_save_CC"
+])# _LT_LANG_C_CONFIG
+
+
+# _LT_PROG_CXX
+# ------------
+# Since AC_PROG_CXX is broken, in that it returns g++ if there is no c++
+# compiler, we have our own version here.
+m4_defun([_LT_PROG_CXX],
+[
+pushdef([AC_MSG_ERROR], [_lt_caught_CXX_error=yes])
+AC_PROG_CXX
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+ ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+ (test "X$CXX" != "Xg++"))) ; then
+ AC_PROG_CXXCPP
+else
+ _lt_caught_CXX_error=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_CXX
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_CXX], [])
+
+
+# _LT_LANG_CXX_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a C++ compiler are suitably
+# defined. These variables are subsequently used by _LT_CONFIG to write
+# the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_CXX_CONFIG],
+[AC_REQUIRE([_LT_PROG_CXX])dnl
+m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+m4_require([_LT_DECL_EGREP])dnl
+
+AC_LANG_PUSH(C++)
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(compiler_needs_object, $1)=no
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="int some_variable = 0;"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC=$CC
+ lt_save_LD=$LD
+ lt_save_GCC=$GCC
+ GCC=$GXX
+ lt_save_with_gnu_ld=$with_gnu_ld
+ lt_save_path_LD=$lt_cv_path_LD
+ if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+ lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+ else
+ $as_unset lt_cv_prog_gnu_ld
+ fi
+ if test -n "${lt_cv_path_LDCXX+set}"; then
+ lt_cv_path_LD=$lt_cv_path_LDCXX
+ else
+ $as_unset lt_cv_path_LD
+ fi
+ test -z "${LDCXX+set}" || LD=$LDCXX
+ CC=${CXX-"c++"}
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ # We don't want -fno-exception when compiling C++ code, so set the
+ # no_builtin_flag separately
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+ else
+ _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+ fi
+
+ if test "$GXX" = yes; then
+ # Set up default GNU C++ configuration
+
+ LT_PATH_LD
+
+ # Check if GNU C++ uses GNU ld as the underlying linker, since the
+ # archiving commands below assume that GNU ld is being used.
+ if test "$with_gnu_ld" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # If archive_cmds runs LD, not CC, wlarc should be empty
+ # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+ # investigate it a little bit more. (MM)
+ wlarc='${wl}'
+
+ # ancient GNU ld didn't support --whole-archive et. al.
+ if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+ $GREP 'no-whole-archive' > /dev/null; then
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ else
+ _LT_TAGVAR(whole_archive_flag_spec, $1)=
+ fi
+ else
+ with_gnu_ld=no
+ wlarc=
+
+ # A generic and very simple default shared library creation
+ # command for GNU C++ for the case where it uses the native
+ # linker, instead of GNU ld. If possible, this setting should
+ # overridden to take advantage of the native linker features on
+ # the platform it is being used on.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ fi
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+ else
+ GXX=no
+ with_gnu_ld=no
+ wlarc=
+ fi
+
+ # PORTME: fill in a description of your system's C++ link characteristics
+ AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ case $host_os in
+ aix3*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" = ia64; then
+ # On IA64, the linker does run time linking by default, so we don't
+ # have to do anything special.
+ aix_use_runtimelinking=no
+ exp_sym_flag='-Bexport'
+ no_entry_flag=""
+ else
+ aix_use_runtimelinking=no
+
+ # Test if we are trying to use run time linking or normal
+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+ # need to do runtime linking.
+ case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
+ for ld_flag in $LDFLAGS; do
+ case $ld_flag in
+ *-brtl*)
+ aix_use_runtimelinking=yes
+ break
+ ;;
+ esac
+ done
+ ;;
+ esac
+
+ exp_sym_flag='-bexport'
+ no_entry_flag='-bnoentry'
+ fi
+
+ # When large executables or shared objects are built, AIX ld can
+ # have problems creating the table of contents. If linking a library
+ # or program results in "error TOC overflow" add -mminimal-toc to
+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not
+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+ _LT_TAGVAR(archive_cmds, $1)=''
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
+
+ if test "$GXX" = yes; then
+ case $host_os in aix4.[[012]]|aix4.[[012]].*)
+ # We only want to do this on AIX 4.2 and lower, the check
+ # below for broken collect2 doesn't work under 4.3+
+ collect2name=`${CC} -print-prog-name=collect2`
+ if test -f "$collect2name" &&
+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+ then
+ # We have reworked collect2
+ :
+ else
+ # We have old collect2
+ _LT_TAGVAR(hardcode_direct, $1)=unsupported
+ # It fails to find uninstalled libraries when the uninstalled
+ # path is not listed in the libpath. Setting hardcode_minus_L
+ # to unsupported forces relinking
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=
+ fi
+ esac
+ shared_flag='-shared'
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag="$shared_flag "'${wl}-G'
+ fi
+ else
+ # not using gcc
+ if test "$host_cpu" = ia64; then
+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+ # chokes on -Wl,-G. The following line is correct:
+ shared_flag='-G'
+ else
+ if test "$aix_use_runtimelinking" = yes; then
+ shared_flag='${wl}-G'
+ else
+ shared_flag='${wl}-bM:SRE'
+ fi
+ fi
+ fi
+
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
+ # It seems that -bexpall does not export symbols beginning with
+ # underscore (_), so it is better to generate a list of symbols to
+ # export.
+ _LT_TAGVAR(always_export_symbols, $1)=yes
+ if test "$aix_use_runtimelinking" = yes; then
+ # Warning - without using the other runtime loading flags (-brtl),
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
+ # Determine the default libpath from the value encoded in an empty
+ # executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then $ECHO "X${wl}${allow_undefined_flag}" | $Xsed; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+ else
+ if test "$host_cpu" = ia64; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+ _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+ else
+ # Determine the default libpath from the value encoded in an
+ # empty executable.
+ _LT_SYS_MODULE_PATH_AIX
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+ # Warning - without using the other run time loading flags,
+ # -berok will link without error, but may produce a broken library.
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+ # Exported symbols can be pulled into shared objects from archives
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
+ # This is similar to how AIX traditionally builds its shared
+ # libraries.
+ _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+ fi
+ fi
+ ;;
+
+ beos*)
+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+ # support --undefined. This deserves some investigation. FIXME
+ _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ chorus*)
+ case $cc_basename in
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ cygwin* | mingw* | pw32* | cegcc*)
+ # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+ # as there is no search path for DLLs.
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+ _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
+ _LT_TAGVAR(always_export_symbols, $1)=no
+ _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ # If the export-symbols file already is a .def file (1st line
+ # is EXPORTS), use it as is; otherwise, prepend...
+ _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+ cp $export_symbols $output_objdir/$soname.def;
+ else
+ echo EXPORTS > $output_objdir/$soname.def;
+ cat $export_symbols >> $output_objdir/$soname.def;
+ fi~
+ $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ darwin* | rhapsody*)
+ _LT_DARWIN_LINKER_FEATURES($1)
+ ;;
+
+ dgux*)
+ case $cc_basename in
+ ec++*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ ghcx*)
+ # Green Hills C++ Compiler
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ freebsd[[12]]*)
+ # C++ shared libraries reported to be fairly broken before
+ # switch to ELF
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ freebsd-elf*)
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ ;;
+
+ freebsd* | dragonfly*)
+ # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+ # conventions
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ gnu*)
+ ;;
+
+ hpux9*)
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ hpux10*|hpux11*)
+ if test $with_gnu_ld = no; then
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ case $host_cpu in
+ hppa*64*|ia64*)
+ ;;
+ *)
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ ;;
+ esac
+ fi
+ case $host_cpu in
+ hppa*64*|ia64*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ ;;
+ *)
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+ # but as the default
+ # location of the library.
+ ;;
+ esac
+
+ case $cc_basename in
+ CC*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ aCC*)
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test $with_gnu_ld = no; then
+ case $host_cpu in
+ hppa*64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ ia64*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ ;;
+ esac
+ fi
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ interix[[3-9]]*)
+ _LT_TAGVAR(hardcode_direct, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+ # Instead, shared libraries are loaded at an image base (0x10000000 by
+ # default) and relocated if they conflict, which is a slow very memory
+ # consuming and fragmenting process. To avoid this, we pick a random,
+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+ ;;
+ irix5* | irix6*)
+ case $cc_basename in
+ CC*)
+ # SGI C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+
+ # Archives containing C++ object files must be created using
+ # "CC -ar", where "CC" is the IRIX C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+ ;;
+ *)
+ if test "$GXX" = yes; then
+ if test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ else
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` -o $lib'
+ fi
+ fi
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ ;;
+ esac
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+ _LT_TAGVAR(inherit_rpath, $1)=yes
+ ;;
+
+ linux* | k*bsd*-gnu | kopensolaris*-gnu)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+ # Archives containing C++ object files must be created using
+ # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+ ;;
+ icpc* | ecpc* )
+ # Intel C++
+ with_gnu_ld=yes
+ # version 8.0 and above of icpc choke on multiply defined symbols
+ # if we add $predep_objects and $postdep_objects, however 7.1 and
+ # earlier do not add the objects themselves.
+ case `$CC -V 2>&1` in
+ *"Version 7."*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ *) # Version 8.0 or newer
+ tmp_idyn=
+ case $host_cpu in
+ ia64*) tmp_idyn=' -i_dynamic';;
+ esac
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+ ;;
+ esac
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+ ;;
+ pgCC* | pgcpp*)
+ # Portland Group C++ compiler
+ case `$CC -V` in
+ *pgCC\ [[1-5]]* | *pgcpp\ [[1-5]]*)
+ _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+ compile_command="$compile_command `find $tpldir -name \*.o | $NL2SP`"'
+ _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+ $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | $NL2SP`~
+ $RANLIB $oldlib'
+ _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
+ rm -rf $tpldir~
+ $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+ $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ *) # Version 6 will use weak symbols
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ ;;
+ cxx*)
+ # Compaq C++
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+ runpath_var=LD_RUN_PATH
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ xl*)
+ # IBM XL 8.0 on PPC, with GNU ld
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+ if test "x$supports_anon_versioning" = xyes; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
+ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+ echo "local: *; };" >> $output_objdir/$libname.ver~
+ $CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+ fi
+ ;;
+ *)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; $ECHO \"$new_convenience\"` ${wl}--no-whole-archive'
+ _LT_TAGVAR(compiler_needs_object, $1)=yes
+
+ # Not sure whether something based on
+ # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+ # would be better.
+ output_verbose_link_cmd='echo'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ esac
+ ;;
+ esac
+ ;;
+
+ lynxos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ m88k*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ mvs*)
+ case $cc_basename in
+ cxx*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ netbsd*)
+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+ wlarc=
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ fi
+ # Workaround some broken pre-1.5 toolchains
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+ ;;
+
+ *nto* | *qnx*)
+ _LT_TAGVAR(ld_shlibs, $1)=yes
+ ;;
+
+ openbsd2*)
+ # C++ shared libraries are fairly broken
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ openbsd*)
+ if test -f /usr/libexec/ld.so; then
+ _LT_TAGVAR(hardcode_direct, $1)=yes
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+ _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+ fi
+ output_verbose_link_cmd=echo
+ else
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+
+ osf3* | osf4* | osf5*)
+ case $cc_basename in
+ KCC*)
+ # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+ # KCC will only create a shared library if the output file
+ # ends with ".so" (or ".sl" for HP-UX), so rename the library
+ # to its proper name (with version) after linking.
+ _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Archives containing C++ object files must be created using
+ # the KAI C++ compiler.
+ case $host in
+ osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
+ *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
+ esac
+ ;;
+ RCC*)
+ # Rational C++ 2.4.1
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ cxx*)
+ case $host in
+ osf3*)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && $ECHO "X${wl}-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ ;;
+ *)
+ _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+ echo "-hidden">> $lib.exp~
+ $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp `test -n "$verstring" && $ECHO "X-set_version $verstring" | $Xsed` -update_registry ${output_objdir}/so_locations -o $lib~
+ $RM $lib.exp'
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ #
+ # There doesn't appear to be a way to prevent this compiler from
+ # explicitly linking system object files so we need to strip them
+ # from the output so that they don't get included in the library
+ # dependencies.
+ output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`$ECHO "X$templist" | $Xsed -e "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; $ECHO "X$list" | $Xsed'
+ ;;
+ *)
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+ case $host in
+ osf3*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "X${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && $ECHO "${wl}-set_version ${wl}$verstring" | $Xsed` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+ ;;
+ esac
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=:
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+
+ else
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ fi
+ ;;
+ esac
+ ;;
+
+ psos*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ sunos4*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.x
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ lcc*)
+ # Lucid
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ solaris*)
+ case $cc_basename in
+ CC*)
+ # Sun C++ 4.2, 5.x and Centerline C++
+ _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
+ _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ # The compiler driver will combine and reorder linker options,
+ # but understands `-z linker_flag'.
+ # Supported since Solaris 2.6 (maybe 2.5.1?)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
+ ;;
+ esac
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+
+ output_verbose_link_cmd='echo'
+
+ # Archives containing C++ object files must be created using
+ # "CC -xar", where "CC" is the Sun C++ compiler. This is
+ # necessary to make sure instantiated templates are included
+ # in the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+ ;;
+ gcx*)
+ # Green Hills C++ Compiler
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+ # The C++ compiler must be used to create the archive.
+ _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+ ;;
+ *)
+ # GNU C++ compiler with Solaris linker
+ if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+ _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+ if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ else
+ # g++ 2.7 appears to require `-G' NOT `-shared' on this
+ # platform.
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+ $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
+
+ # Commands to make compiler produce verbose output that lists
+ # what "hidden" libraries, object files and flags are used when
+ # linking a shared library.
+ output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP "\-L"'
+ fi
+
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+ case $host_os in
+ solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+ *)
+ _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+ ;;
+ esac
+ fi
+ ;;
+ esac
+ ;;
+
+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ sysv5* | sco3.2v5* | sco5v6*)
+ # Note: We can NOT use -z defs as we might desire, because we do not
+ # link with -lc, and that would cause any symbols used from libc to
+ # always be unresolved, which means just about no library would
+ # ever link correctly. If we're not using GNU ld we use -z text
+ # though, which does catch some bad symbols but isn't as heavy-handed
+ # as -z defs.
+ _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
+ _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
+ _LT_TAGVAR(archive_cmds_need_lc, $1)=no
+ _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
+ _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
+ _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
+ _LT_TAGVAR(link_all_deplibs, $1)=yes
+ _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+ runpath_var='LD_RUN_PATH'
+
+ case $cc_basename in
+ CC*)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ *)
+ _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+ ;;
+ esac
+ ;;
+
+ tandem*)
+ case $cc_basename in
+ NCC*)
+ # NonStop-UX NCC 3.20
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+ ;;
+
+ vxworks*)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+
+ *)
+ # FIXME: insert proper C++ library support
+ _LT_TAGVAR(ld_shlibs, $1)=no
+ ;;
+ esac
+
+ AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
+ test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+ _LT_TAGVAR(GCC, $1)="$GXX"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ CC=$lt_save_CC
+ LDCXX=$LD
+ LD=$lt_save_LD
+ GCC=$lt_save_GCC
+ with_gnu_ld=$lt_save_with_gnu_ld
+ lt_cv_path_LDCXX=$lt_cv_path_LD
+ lt_cv_path_LD=$lt_save_path_LD
+ lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+ lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
+AC_LANG_POP
+])# _LT_LANG_CXX_CONFIG
+
+
+# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
+# ---------------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
+[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
+# Dependencies to place before and after the object being linked:
+_LT_TAGVAR(predep_objects, $1)=
+_LT_TAGVAR(postdep_objects, $1)=
+_LT_TAGVAR(predeps, $1)=
+_LT_TAGVAR(postdeps, $1)=
+_LT_TAGVAR(compiler_lib_search_path, $1)=
+
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library. It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
+int a;
+void foo (void) { a = 0; }
+_LT_EOF
+], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+ Foo (void) { a = 0; }
+private:
+ int a;
+};
+_LT_EOF
+], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer*4 a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
+ subroutine foo
+ implicit none
+ integer a
+ a=0
+ return
+ end
+_LT_EOF
+], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
+public class foo {
+ private int a;
+ public void bar (void) {
+ a = 0;
+ }
+};
+_LT_EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+ # Parse the compiler output and extract the necessary
+ # objects, libraries and library flags.
+
+ # Sentinel used to keep track of whether or not we are before
+ # the conftest object file.
+ pre_test_object_deps_done=no
+
+ for p in `eval "$output_verbose_link_cmd"`; do
+ case $p in
+
+ -L* | -R* | -l*)
+ # Some compilers place space between "-{L,R}" and the path.
+ # Remove the space.
+ if test $p = "-L" ||
+ test $p = "-R"; then
+ prev=$p
+ continue
+ else
+ prev=
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ case $p in
+ -L* | -R*)
+ # Internal compiler library paths should come after those
+ # provided the user. The postdeps already come after the
+ # user supplied libs so there is no need to process them.
+ if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+ fi
+ ;;
+ # The "-l" case would never come before the object being
+ # linked, so don't bother handling this case.
+ esac
+ else
+ if test -z "$_LT_TAGVAR(postdeps, $1)"; then
+ _LT_TAGVAR(postdeps, $1)="${prev}${p}"
+ else
+ _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
+ fi
+ fi
+ ;;
+
+ *.$objext)
+ # This assumes that the test object file only shows up
+ # once in the compiler output.
+ if test "$p" = "conftest.$objext"; then
+ pre_test_object_deps_done=yes
+ continue
+ fi
+
+ if test "$pre_test_object_deps_done" = no; then
+ if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
+ _LT_TAGVAR(predep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
+ fi
+ else
+ if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
+ _LT_TAGVAR(postdep_objects, $1)="$p"
+ else
+ _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
+ fi
+ fi
+ ;;
+
+ *) ;; # Ignore the rest.
+
+ esac
+ done
+
+ # Clean up.
+ rm -f a.out a.exe
+else
+ echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$RM -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+m4_if([$1], [CXX],
+[case $host_os in
+interix[[3-9]]*)
+ # Interix 3.5 installs completely hosed .la files for C++, so rather than
+ # hack all around it, let's just trust "g++" to DTRT.
+ _LT_TAGVAR(predep_objects,$1)=
+ _LT_TAGVAR(postdep_objects,$1)=
+ _LT_TAGVAR(postdeps,$1)=
+ ;;
+
+linux*)
+ case `$CC -V 2>&1 | sed 5q` in
+ *Sun\ C*)
+ # Sun C++ 5.9
+
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+
+solaris*)
+ case $cc_basename in
+ CC*)
+ # The more standards-conforming stlport4 library is
+ # incompatible with the Cstd library. Avoid specifying
+ # it if it's in CXXFLAGS. Ignore libCrun as
+ # -library=stlport4 depends on it.
+ case " $CXX $CXXFLAGS " in
+ *" -library=stlport4 "*)
+ solaris_use_stlport4=yes
+ ;;
+ esac
+
+ # Adding this requires a known-good setup of shared libraries for
+ # Sun compiler versions before 5.6, else PIC objects from an old
+ # archive will be linked into the output, leading to subtle bugs.
+ if test "$solaris_use_stlport4" != yes; then
+ _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
+ fi
+ ;;
+ esac
+ ;;
+esac
+])
+
+case " $_LT_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=
+if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
+ _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
+ [The directories searched by this compiler when creating a shared library])
+_LT_TAGDECL([], [predep_objects], [1],
+ [Dependencies to place before and after the objects being linked to
+ create a shared library])
+_LT_TAGDECL([], [postdep_objects], [1])
+_LT_TAGDECL([], [predeps], [1])
+_LT_TAGDECL([], [postdeps], [1])
+_LT_TAGDECL([], [compiler_lib_search_path], [1],
+ [The library search path used internally by the compiler when linking
+ a shared library])
+])# _LT_SYS_HIDDEN_LIBDEPS
+
+
+# _LT_PROG_F77
+# ------------
+# Since AC_PROG_F77 is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_F77],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_F77=yes])
+AC_PROG_F77
+if test -z "$F77" || test "X$F77" = "Xno"; then
+ _lt_disable_F77=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_F77
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_F77], [])
+
+
+# _LT_LANG_F77_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for a Fortran 77 compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_F77_CONFIG],
+[AC_REQUIRE([_LT_PROG_F77])dnl
+AC_LANG_PUSH(Fortran 77)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the F77 compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_F77" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ CC=${F77-"f77"}
+ compiler=$CC
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+ GCC=$G77
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$G77"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+fi # test "$_lt_disable_F77" != yes
+
+AC_LANG_POP
+])# _LT_LANG_F77_CONFIG
+
+
+# _LT_PROG_FC
+# -----------
+# Since AC_PROG_FC is broken, in that it returns the empty string
+# if there is no fortran compiler, we have our own version here.
+m4_defun([_LT_PROG_FC],
+[
+pushdef([AC_MSG_ERROR], [_lt_disable_FC=yes])
+AC_PROG_FC
+if test -z "$FC" || test "X$FC" = "Xno"; then
+ _lt_disable_FC=yes
+fi
+popdef([AC_MSG_ERROR])
+])# _LT_PROG_FC
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([_LT_PROG_FC], [])
+
+
+# _LT_LANG_FC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for a Fortran compiler are
+# suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_FC_CONFIG],
+[AC_REQUIRE([_LT_PROG_FC])dnl
+AC_LANG_PUSH(Fortran)
+
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_TAGVAR(allow_undefined_flag, $1)=
+_LT_TAGVAR(always_export_symbols, $1)=no
+_LT_TAGVAR(archive_expsym_cmds, $1)=
+_LT_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_TAGVAR(hardcode_direct, $1)=no
+_LT_TAGVAR(hardcode_direct_absolute, $1)=no
+_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_TAGVAR(hardcode_minus_L, $1)=no
+_LT_TAGVAR(hardcode_automatic, $1)=no
+_LT_TAGVAR(inherit_rpath, $1)=no
+_LT_TAGVAR(module_cmds, $1)=
+_LT_TAGVAR(module_expsym_cmds, $1)=
+_LT_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_TAGVAR(no_undefined_flag, $1)=
+_LT_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working. Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+ # Code to be used in simple compile tests
+ lt_simple_compile_test_code="\
+ subroutine t
+ return
+ end
+"
+
+ # Code to be used in simple link tests
+ lt_simple_link_test_code="\
+ program t
+ end
+"
+
+ # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+ _LT_TAG_COMPILER
+
+ # save warnings/boilerplate of simple test code
+ _LT_COMPILER_BOILERPLATE
+ _LT_LINKER_BOILERPLATE
+
+ # Allow CC to be a program name with arguments.
+ lt_save_CC="$CC"
+ lt_save_GCC=$GCC
+ CC=${FC-"f95"}
+ compiler=$CC
+ GCC=$ac_cv_fc_compiler_gnu
+
+ _LT_TAGVAR(compiler, $1)=$CC
+ _LT_CC_BASENAME([$compiler])
+
+ if test -n "$compiler"; then
+ AC_MSG_CHECKING([if libtool supports shared libraries])
+ AC_MSG_RESULT([$can_build_shared])
+
+ AC_MSG_CHECKING([whether to build shared libraries])
+ test "$can_build_shared" = "no" && enable_shared=no
+
+ # On AIX, shared libraries and static libraries use the same namespace, and
+ # are all built from PIC.
+ case $host_os in
+ aix3*)
+ test "$enable_shared" = yes && enable_static=no
+ if test -n "$RANLIB"; then
+ archive_cmds="$archive_cmds~\$RANLIB \$lib"
+ postinstall_cmds='$RANLIB $lib'
+ fi
+ ;;
+ aix[[4-9]]*)
+ if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+ test "$enable_shared" = yes && enable_static=no
+ fi
+ ;;
+ esac
+ AC_MSG_RESULT([$enable_shared])
+
+ AC_MSG_CHECKING([whether to build static libraries])
+ # Make sure either enable_shared or enable_static is yes.
+ test "$enable_shared" = yes || enable_static=yes
+ AC_MSG_RESULT([$enable_static])
+
+ _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
+ _LT_TAGVAR(LD, $1)="$LD"
+
+ ## CAVEAT EMPTOR:
+ ## There is no encapsulation within the following macros, do not change
+ ## the running order or otherwise move them around unless you know exactly
+ ## what you are doing...
+ _LT_SYS_HIDDEN_LIBDEPS($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_SYS_DYNAMIC_LINKER($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+ fi # test -n "$compiler"
+
+ GCC=$lt_save_GCC
+ CC="$lt_save_CC"
+fi # test "$_lt_disable_FC" != yes
+
+AC_LANG_POP
+])# _LT_LANG_FC_CONFIG
+
+
+# _LT_LANG_GCJ_CONFIG([TAG])
+# --------------------------
+# Ensure that the configuration variables for the GNU Java Compiler compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_GCJ_CONFIG],
+[AC_REQUIRE([LT_PROG_GCJ])dnl
+AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=yes
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_TAGVAR(LD, $1)="$LD"
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
+ _LT_COMPILER_NO_RTTI($1)
+ _LT_COMPILER_PIC($1)
+ _LT_COMPILER_C_O($1)
+ _LT_COMPILER_FILE_LOCKS($1)
+ _LT_LINKER_SHLIBS($1)
+ _LT_LINKER_HARDCODE_LIBPATH($1)
+
+ _LT_CONFIG($1)
+fi
+
+AC_LANG_RESTORE
+
+GCC=$lt_save_GCC
+CC="$lt_save_CC"
+])# _LT_LANG_GCJ_CONFIG
+
+
+# _LT_LANG_RC_CONFIG([TAG])
+# -------------------------
+# Ensure that the configuration variables for the Windows resource compiler
+# are suitably defined. These variables are subsequently used by _LT_CONFIG
+# to write the compiler configuration to `libtool'.
+m4_defun([_LT_LANG_RC_CONFIG],
+[AC_REQUIRE([LT_PROG_RC])dnl
+AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_TAG_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+lt_save_GCC=$GCC
+GCC=
+CC=${RC-"windres"}
+compiler=$CC
+_LT_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+if test -n "$compiler"; then
+ :
+ _LT_CONFIG($1)
+fi
+
+GCC=$lt_save_GCC
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# _LT_LANG_RC_CONFIG
+
+
+# LT_PROG_GCJ
+# -----------
+AC_DEFUN([LT_PROG_GCJ],
+[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
+ [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
+ [AC_CHECK_TOOL(GCJ, gcj,)
+ test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+ AC_SUBST(GCJFLAGS)])])[]dnl
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
+
+
+# LT_PROG_RC
+# ----------
+AC_DEFUN([LT_PROG_RC],
+[AC_CHECK_TOOL(RC, windres,)
+])
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_RC], [])
+
+
+# _LT_DECL_EGREP
+# --------------
+# If we don't have a new enough Autoconf to choose the best grep
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_EGREP],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_REQUIRE([AC_PROG_FGREP])dnl
+test -z "$GREP" && GREP=grep
+_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
+_LT_DECL([], [EGREP], [1], [An ERE matcher])
+_LT_DECL([], [FGREP], [1], [A literal string matcher])
+dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
+AC_SUBST([GREP])
+])
+
+
+# _LT_DECL_OBJDUMP
+# --------------
+# If we don't have a new enough Autoconf to choose the best objdump
+# available, choose the one first in the user's PATH.
+m4_defun([_LT_DECL_OBJDUMP],
+[AC_CHECK_TOOL(OBJDUMP, objdump, false)
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
+AC_SUBST([OBJDUMP])
+])
+
+
+# _LT_DECL_SED
+# ------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible. Prefer GNU sed if found.
+m4_defun([_LT_DECL_SED],
+[AC_PROG_SED
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
+_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
+_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
+ [Sed that helps us avoid accidentally triggering echo(1) options like -n])
+])# _LT_DECL_SED
+
+m4_ifndef([AC_PROG_SED], [
+############################################################
+# NOTE: This macro has been submitted for inclusion into #
+# GNU Autoconf as AC_PROG_SED. When it is available in #
+# a released version of Autoconf we should remove this #
+# macro and use it instead. #
+############################################################
+
+m4_defun([AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for lt_ac_prog in sed gsed; do
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+ lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+ fi
+ done
+ done
+done
+IFS=$as_save_IFS
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+ test ! -f $lt_ac_sed && continue
+ cat /dev/null > conftest.in
+ lt_ac_count=0
+ echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+ # Check for GNU sed and select it if it is found.
+ if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+ lt_cv_path_SED=$lt_ac_sed
+ break
+ fi
+ while true; do
+ cat conftest.in conftest.in >conftest.tmp
+ mv conftest.tmp conftest.in
+ cp conftest.in conftest.nl
+ echo >>conftest.nl
+ $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+ cmp -s conftest.out conftest.nl || break
+ # 10000 chars as input seems more than enough
+ test $lt_ac_count -gt 10 && break
+ lt_ac_count=`expr $lt_ac_count + 1`
+ if test $lt_ac_count -gt $lt_ac_max; then
+ lt_ac_max=$lt_ac_count
+ lt_cv_path_SED=$lt_ac_sed
+ fi
+ done
+done
+])
+SED=$lt_cv_path_SED
+AC_SUBST([SED])
+AC_MSG_RESULT([$SED])
+])#AC_PROG_SED
+])#m4_ifndef
+
+# Old name:
+AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([LT_AC_PROG_SED], [])
+
+
+# _LT_CHECK_SHELL_FEATURES
+# ------------------------
+# Find out whether the shell is Bourne or XSI compatible,
+# or has some other useful features.
+m4_defun([_LT_CHECK_SHELL_FEATURES],
+[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+ test "${_lt_dummy##*/},${_lt_dummy%/*},"${_lt_dummy%"$_lt_dummy"}, \
+ = c,a/b,, \
+ && eval 'test $(( 1 + 1 )) -eq 2 \
+ && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+ && xsi_shell=yes
+AC_MSG_RESULT([$xsi_shell])
+_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
+
+AC_MSG_CHECKING([whether the shell understands "+="])
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
+ >/dev/null 2>&1 \
+ && lt_shell_append=yes
+AC_MSG_RESULT([$lt_shell_append])
+_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
+
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+ lt_unset=unset
+else
+ lt_unset=false
+fi
+_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+ lt_SP2NL='tr \040 \012'
+ lt_NL2SP='tr \015\012 \040\040'
+ ;;
+ *) # EBCDIC based system
+ lt_SP2NL='tr \100 \n'
+ lt_NL2SP='tr \r\n \100\100'
+ ;;
+esac
+_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
+_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
+])# _LT_CHECK_SHELL_FEATURES
+
+
+# _LT_PROG_XSI_SHELLFNS
+# ---------------------
+# Bourne and XSI compatible variants of some useful shell functions.
+m4_defun([_LT_PROG_XSI_SHELLFNS],
+[case $xsi_shell in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result="${1##*/}"
+}
+
+# func_dirname_and_basename file append nondir_replacement
+# perform func_basename and func_dirname in a single function
+# call:
+# dirname: Compute the dirname of FILE. If nonempty,
+# add APPEND to the result, otherwise set result
+# to NONDIR_REPLACEMENT.
+# value returned in "$func_dirname_result"
+# basename: Compute filename of FILE.
+# value retuned in "$func_basename_result"
+# Implementation must be kept synchronized with func_dirname
+# and func_basename. For efficiency, we do not delegate to
+# those functions but instead duplicate the functionality here.
+func_dirname_and_basename ()
+{
+ case ${1} in
+ */*) func_dirname_result="${1%/*}${2}" ;;
+ * ) func_dirname_result="${3}" ;;
+ esac
+ func_basename_result="${1##*/}"
+}
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+func_stripname ()
+{
+ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
+ # positional parameters, so assign one to ordinary parameter first.
+ func_stripname_result=${3}
+ func_stripname_result=${func_stripname_result#"${1}"}
+ func_stripname_result=${func_stripname_result%"${2}"}
+}
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=${1%%=*}
+ func_opt_split_arg=${1#*=}
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ case ${1} in
+ *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
+ *) func_lo2o_result=${1} ;;
+ esac
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=${1%.*}.lo
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=$(( $[*] ))
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=${#1}
+}
+
+_LT_EOF
+ ;;
+ *) # Bourne compatible functions.
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_dirname file append nondir_replacement
+# Compute the dirname of FILE. If nonempty, add APPEND to the result,
+# otherwise set result to NONDIR_REPLACEMENT.
+func_dirname ()
+{
+ # Extract subdirectory from the argument.
+ func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
+ if test "X$func_dirname_result" = "X${1}"; then
+ func_dirname_result="${3}"
+ else
+ func_dirname_result="$func_dirname_result${2}"
+ fi
+}
+
+# func_basename file
+func_basename ()
+{
+ func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
+}
+
+dnl func_dirname_and_basename
+dnl A portable version of this function is already defined in general.m4sh
+dnl so there is no need for it here.
+
+# func_stripname prefix suffix name
+# strip PREFIX and SUFFIX off of NAME.
+# PREFIX and SUFFIX must not contain globbing or regex special
+# characters, hashes, percent signs, but SUFFIX may contain a leading
+# dot (in which case that matches only a dot).
+# func_strip_suffix prefix name
+func_stripname ()
+{
+ case ${2} in
+ .*) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%\\\\${2}\$%%"`;;
+ *) func_stripname_result=`$ECHO "X${3}" \
+ | $Xsed -e "s%^${1}%%" -e "s%${2}\$%%"`;;
+ esac
+}
+
+# sed scripts:
+my_sed_long_opt='1s/^\(-[[^=]]*\)=.*/\1/;q'
+my_sed_long_arg='1s/^-[[^=]]*=//'
+
+# func_opt_split
+func_opt_split ()
+{
+ func_opt_split_opt=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_opt"`
+ func_opt_split_arg=`$ECHO "X${1}" | $Xsed -e "$my_sed_long_arg"`
+}
+
+# func_lo2o object
+func_lo2o ()
+{
+ func_lo2o_result=`$ECHO "X${1}" | $Xsed -e "$lo2o"`
+}
+
+# func_xform libobj-or-source
+func_xform ()
+{
+ func_xform_result=`$ECHO "X${1}" | $Xsed -e 's/\.[[^.]]*$/.lo/'`
+}
+
+# func_arith arithmetic-term...
+func_arith ()
+{
+ func_arith_result=`expr "$[@]"`
+}
+
+# func_len string
+# STRING may not start with a hyphen.
+func_len ()
+{
+ func_len_result=`expr "$[1]" : ".*" 2>/dev/null || echo $max_cmd_len`
+}
+
+_LT_EOF
+esac
+
+case $lt_shell_append in
+ yes)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$[1]+=\$[2]"
+}
+_LT_EOF
+ ;;
+ *)
+ cat << \_LT_EOF >> "$cfgfile"
+
+# func_append var value
+# Append VALUE to the end of shell variable VAR.
+func_append ()
+{
+ eval "$[1]=\$$[1]\$[2]"
+}
+
+_LT_EOF
+ ;;
+ esac
+])
diff --git a/m4/ltoptions.m4 b/m4/ltoptions.m4
new file mode 100644
index 0000000..34151a3
--- /dev/null
+++ b/m4/ltoptions.m4
@@ -0,0 +1,368 @@
+# Helper functions for option handling. -*- Autoconf -*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltoptions.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
+
+
+# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
+# ------------------------------------------
+m4_define([_LT_MANGLE_OPTION],
+[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
+
+
+# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
+# ---------------------------------------
+# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
+# matching handler defined, dispatch to it. Other OPTION-NAMEs are
+# saved as a flag.
+m4_define([_LT_SET_OPTION],
+[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
+m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
+ _LT_MANGLE_DEFUN([$1], [$2]),
+ [m4_warning([Unknown $1 option `$2'])])[]dnl
+])
+
+
+# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
+# ------------------------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+m4_define([_LT_IF_OPTION],
+[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
+
+
+# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
+# -------------------------------------------------------
+# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
+# are set.
+m4_define([_LT_UNLESS_OPTIONS],
+[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
+ [m4_define([$0_found])])])[]dnl
+m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
+])[]dnl
+])
+
+
+# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
+# ----------------------------------------
+# OPTION-LIST is a space-separated list of Libtool options associated
+# with MACRO-NAME. If any OPTION has a matching handler declared with
+# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
+# the unknown option and exit.
+m4_defun([_LT_SET_OPTIONS],
+[# Set options
+m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
+ [_LT_SET_OPTION([$1], _LT_Option)])
+
+m4_if([$1],[LT_INIT],[
+ dnl
+ dnl Simply set some default values (i.e off) if boolean options were not
+ dnl specified:
+ _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
+ ])
+ _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
+ ])
+ dnl
+ dnl If no reference was made to various pairs of opposing options, then
+ dnl we run the default mode handler for the pair. For example, if neither
+ dnl `shared' nor `disable-shared' was passed, we enable building of shared
+ dnl archives by default:
+ _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
+ _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
+ _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
+ [_LT_ENABLE_FAST_INSTALL])
+ ])
+])# _LT_SET_OPTIONS
+
+
+## --------------------------------- ##
+## Macros to handle LT_INIT options. ##
+## --------------------------------- ##
+
+# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
+# -----------------------------------------
+m4_define([_LT_MANGLE_DEFUN],
+[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
+
+
+# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
+# -----------------------------------------------
+m4_define([LT_OPTION_DEFINE],
+[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
+])# LT_OPTION_DEFINE
+
+
+# dlopen
+# ------
+LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
+])
+
+AU_DEFUN([AC_LIBTOOL_DLOPEN],
+[_LT_SET_OPTION([LT_INIT], [dlopen])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `dlopen' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
+
+
+# win32-dll
+# ---------
+# Declare package support for building win32 dll's.
+LT_OPTION_DEFINE([LT_INIT], [win32-dll],
+[enable_win32_dll=yes
+
+case $host in
+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-cegcc*)
+ AC_CHECK_TOOL(AS, as, false)
+ AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+ AC_CHECK_TOOL(OBJDUMP, objdump, false)
+ ;;
+esac
+
+test -z "$AS" && AS=as
+_LT_DECL([], [AS], [0], [Assembler program])dnl
+
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+_LT_DECL([], [DLLTOOL], [0], [DLL creation program])dnl
+
+test -z "$OBJDUMP" && OBJDUMP=objdump
+_LT_DECL([], [OBJDUMP], [0], [Object dumper program])dnl
+])# win32-dll
+
+AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+_LT_SET_OPTION([LT_INIT], [win32-dll])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `win32-dll' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
+
+
+# _LT_ENABLE_SHARED([DEFAULT])
+# ----------------------------
+# implement the --enable-shared flag, and supports the `shared' and
+# `disable-shared' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_SHARED],
+[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([shared],
+ [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+ [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_shared=yes ;;
+ no) enable_shared=no ;;
+ *)
+ enable_shared=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_shared=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
+
+ _LT_DECL([build_libtool_libs], [enable_shared], [0],
+ [Whether or not to build shared libraries])
+])# _LT_ENABLE_SHARED
+
+LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
+])
+
+AC_DEFUN([AC_DISABLE_SHARED],
+[_LT_SET_OPTION([LT_INIT], [disable-shared])
+])
+
+AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
+AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_SHARED], [])
+dnl AC_DEFUN([AM_DISABLE_SHARED], [])
+
+
+
+# _LT_ENABLE_STATIC([DEFAULT])
+# ----------------------------
+# implement the --enable-static flag, and support the `static' and
+# `disable-static' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_STATIC],
+[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([static],
+ [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+ [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_static=yes ;;
+ no) enable_static=no ;;
+ *)
+ enable_static=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_static=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
+
+ _LT_DECL([build_old_libs], [enable_static], [0],
+ [Whether or not to build static libraries])
+])# _LT_ENABLE_STATIC
+
+LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
+
+# Old names:
+AC_DEFUN([AC_ENABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
+])
+
+AC_DEFUN([AC_DISABLE_STATIC],
+[_LT_SET_OPTION([LT_INIT], [disable-static])
+])
+
+AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
+AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AM_ENABLE_STATIC], [])
+dnl AC_DEFUN([AM_DISABLE_STATIC], [])
+
+
+
+# _LT_ENABLE_FAST_INSTALL([DEFAULT])
+# ----------------------------------
+# implement the --enable-fast-install flag, and support the `fast-install'
+# and `disable-fast-install' LT_INIT options.
+# DEFAULT is either `yes' or `no'. If omitted, it defaults to `yes'.
+m4_define([_LT_ENABLE_FAST_INSTALL],
+[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
+AC_ARG_ENABLE([fast-install],
+ [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+ [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+ [p=${PACKAGE-default}
+ case $enableval in
+ yes) enable_fast_install=yes ;;
+ no) enable_fast_install=no ;;
+ *)
+ enable_fast_install=no
+ # Look at the argument we got. We use all the common list separators.
+ lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+ for pkg in $enableval; do
+ IFS="$lt_save_ifs"
+ if test "X$pkg" = "X$p"; then
+ enable_fast_install=yes
+ fi
+ done
+ IFS="$lt_save_ifs"
+ ;;
+ esac],
+ [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
+
+_LT_DECL([fast_install], [enable_fast_install], [0],
+ [Whether or not to optimize for fast installation])dnl
+])# _LT_ENABLE_FAST_INSTALL
+
+LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
+LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
+
+# Old names:
+AU_DEFUN([AC_ENABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `fast-install' option into LT_INIT's first parameter.])
+])
+
+AU_DEFUN([AC_DISABLE_FAST_INSTALL],
+[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you put
+the `disable-fast-install' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
+dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
+
+
+# _LT_WITH_PIC([MODE])
+# --------------------
+# implement the --with-pic flag, and support the `pic-only' and `no-pic'
+# LT_INIT options.
+# MODE is either `yes' or `no'. If omitted, it defaults to `both'.
+m4_define([_LT_WITH_PIC],
+[AC_ARG_WITH([pic],
+ [AS_HELP_STRING([--with-pic],
+ [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+ [pic_mode="$withval"],
+ [pic_mode=default])
+
+test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
+
+_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
+])# _LT_WITH_PIC
+
+LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
+LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
+
+# Old name:
+AU_DEFUN([AC_LIBTOOL_PICMODE],
+[_LT_SET_OPTION([LT_INIT], [pic-only])
+AC_DIAGNOSE([obsolete],
+[$0: Remove this warning and the call to _LT_SET_OPTION when you
+put the `pic-only' option into LT_INIT's first parameter.])
+])
+
+dnl aclocal-1.4 backwards compatibility:
+dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
+
+## ----------------- ##
+## LTDL_INIT Options ##
+## ----------------- ##
+
+m4_define([_LTDL_MODE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
+ [m4_define([_LTDL_MODE], [nonrecursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [recursive],
+ [m4_define([_LTDL_MODE], [recursive])])
+LT_OPTION_DEFINE([LTDL_INIT], [subproject],
+ [m4_define([_LTDL_MODE], [subproject])])
+
+m4_define([_LTDL_TYPE], [])
+LT_OPTION_DEFINE([LTDL_INIT], [installable],
+ [m4_define([_LTDL_TYPE], [installable])])
+LT_OPTION_DEFINE([LTDL_INIT], [convenience],
+ [m4_define([_LTDL_TYPE], [convenience])])
diff --git a/m4/ltsugar.m4 b/m4/ltsugar.m4
new file mode 100644
index 0000000..9000a05
--- /dev/null
+++ b/m4/ltsugar.m4
@@ -0,0 +1,123 @@
+# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
+# Written by Gary V. Vaughan, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 6 ltsugar.m4
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
+
+
+# lt_join(SEP, ARG1, [ARG2...])
+# -----------------------------
+# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
+# associated separator.
+# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
+# versions in m4sugar had bugs.
+m4_define([lt_join],
+[m4_if([$#], [1], [],
+ [$#], [2], [[$2]],
+ [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
+m4_define([_lt_join],
+[m4_if([$#$2], [2], [],
+ [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
+
+
+# lt_car(LIST)
+# lt_cdr(LIST)
+# ------------
+# Manipulate m4 lists.
+# These macros are necessary as long as will still need to support
+# Autoconf-2.59 which quotes differently.
+m4_define([lt_car], [[$1]])
+m4_define([lt_cdr],
+[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
+ [$#], 1, [],
+ [m4_dquote(m4_shift($@))])])
+m4_define([lt_unquote], $1)
+
+
+# lt_append(MACRO-NAME, STRING, [SEPARATOR])
+# ------------------------------------------
+# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
+# Note that neither SEPARATOR nor STRING are expanded; they are appended
+# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
+# No SEPARATOR is output if MACRO-NAME was previously undefined (different
+# than defined and empty).
+#
+# This macro is needed until we can rely on Autoconf 2.62, since earlier
+# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
+m4_define([lt_append],
+[m4_define([$1],
+ m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
+
+
+
+# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
+# ----------------------------------------------------------
+# Produce a SEP delimited list of all paired combinations of elements of
+# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list
+# has the form PREFIXmINFIXSUFFIXn.
+# Needed until we can rely on m4_combine added in Autoconf 2.62.
+m4_define([lt_combine],
+[m4_if(m4_eval([$# > 3]), [1],
+ [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
+[[m4_foreach([_Lt_prefix], [$2],
+ [m4_foreach([_Lt_suffix],
+ ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
+ [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
+
+
+# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
+# -----------------------------------------------------------------------
+# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
+# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
+m4_define([lt_if_append_uniq],
+[m4_ifdef([$1],
+ [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
+ [lt_append([$1], [$2], [$3])$4],
+ [$5])],
+ [lt_append([$1], [$2], [$3])$4])])
+
+
+# lt_dict_add(DICT, KEY, VALUE)
+# -----------------------------
+m4_define([lt_dict_add],
+[m4_define([$1($2)], [$3])])
+
+
+# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
+# --------------------------------------------
+m4_define([lt_dict_add_subkey],
+[m4_define([$1($2:$3)], [$4])])
+
+
+# lt_dict_fetch(DICT, KEY, [SUBKEY])
+# ----------------------------------
+m4_define([lt_dict_fetch],
+[m4_ifval([$3],
+ m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
+ m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
+
+
+# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
+# -----------------------------------------------------------------
+m4_define([lt_if_dict_fetch],
+[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
+ [$5],
+ [$6])])
+
+
+# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
+# --------------------------------------------------------------
+m4_define([lt_dict_filter],
+[m4_if([$5], [], [],
+ [lt_join(m4_quote(m4_default([$4], [[, ]])),
+ lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
+ [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
+])
diff --git a/m4/ltversion.m4 b/m4/ltversion.m4
new file mode 100644
index 0000000..f3c5309
--- /dev/null
+++ b/m4/ltversion.m4
@@ -0,0 +1,23 @@
+# ltversion.m4 -- version numbers -*- Autoconf -*-
+#
+# Copyright (C) 2004 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# Generated from ltversion.in.
+
+# serial 3017 ltversion.m4
+# This file is part of GNU Libtool
+
+m4_define([LT_PACKAGE_VERSION], [2.2.6b])
+m4_define([LT_PACKAGE_REVISION], [1.3017])
+
+AC_DEFUN([LTVERSION_VERSION],
+[macro_version='2.2.6b'
+macro_revision='1.3017'
+_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
+_LT_DECL(, macro_revision, 0)
+])
diff --git a/m4/lt~obsolete.m4 b/m4/lt~obsolete.m4
new file mode 100644
index 0000000..637bb20
--- /dev/null
+++ b/m4/lt~obsolete.m4
@@ -0,0 +1,92 @@
+# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
+#
+# Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
+# Written by Scott James Remnant, 2004.
+#
+# This file is free software; the Free Software Foundation gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+
+# serial 4 lt~obsolete.m4
+
+# These exist entirely to fool aclocal when bootstrapping libtool.
+#
+# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
+# which have later been changed to m4_define as they aren't part of the
+# exported API, or moved to Autoconf or Automake where they belong.
+#
+# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN
+# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
+# using a macro with the same name in our local m4/libtool.m4 it'll
+# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
+# and doesn't know about Autoconf macros at all.)
+#
+# So we provide this file, which has a silly filename so it's always
+# included after everything else. This provides aclocal with the
+# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
+# because those macros already exist, or will be overwritten later.
+# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6.
+#
+# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
+# Yes, that means every name once taken will need to remain here until
+# we give up compatibility with versions before 1.7, at which point
+# we need to keep only those names which we still refer to.
+
+# This is to help aclocal find these macros, as it can't see m4_define.
+AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
+
+m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])])
+m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
+m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])])
+m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
+m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])])
+m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])])
+m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
+m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])])
+m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])])
+m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])])
+m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
+m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
+m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
+m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
+m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])])
+m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
+m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
+m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])])
+m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])])
+m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
+m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
+m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
+m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
+m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
+m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
+m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])])
+m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])])
+m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])])
+m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
+m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])])
+m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])])
+m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])])
+m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])])
+m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
+m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])])
+m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
+m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])])
+m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])])
+m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])])
+m4_ifndef([AC_LIBTOOL_RC], [AC_DEFUN([AC_LIBTOOL_RC])])
+m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
+m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
+m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
+m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
+m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
+m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
+m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
+m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])])
+m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
diff --git a/m4/namespaces.m4 b/m4/namespaces.m4
new file mode 100644
index 0000000..d78dbe4
--- /dev/null
+++ b/m4/namespaces.m4
@@ -0,0 +1,15 @@
+# Checks whether the compiler implements namespaces
+AC_DEFUN([AC_CXX_NAMESPACES],
+ [AC_CACHE_CHECK(whether the compiler implements namespaces,
+ ac_cv_cxx_namespaces,
+ [AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([namespace Outer {
+ namespace Inner { int i = 0; }}],
+ [using namespace Outer::Inner; return i;],
+ ac_cv_cxx_namespaces=yes,
+ ac_cv_cxx_namespaces=no)
+ AC_LANG_RESTORE])
+ if test "$ac_cv_cxx_namespaces" = yes; then
+ AC_DEFINE(HAVE_NAMESPACES, 1, [define if the compiler implements namespaces])
+ fi])
diff --git a/m4/stl_hash.m4 b/m4/stl_hash.m4
new file mode 100644
index 0000000..a31baab
--- /dev/null
+++ b/m4/stl_hash.m4
@@ -0,0 +1,70 @@
+# We check two things: where the include file is for
+# unordered_map/hash_map (we prefer the first form), and what
+# namespace unordered/hash_map lives in within that include file. We
+# include AC_TRY_COMPILE for all the combinations we've seen in the
+# wild. We define HASH_MAP_H to the location of the header file, and
+# HASH_NAMESPACE to the namespace the class (unordered_map or
+# hash_map) is in. We define HAVE_UNORDERED_MAP if the class we found
+# is named unordered_map, or leave it undefined if not.
+
+# This also checks if unordered map exists.
+AC_DEFUN([AC_CXX_STL_HASH],
+ [AC_REQUIRE([AC_CXX_NAMESPACES])
+ AC_MSG_CHECKING(the location of hash_map)
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ ac_cv_cxx_hash_map=""
+ # First try unordered_map, but not on gcc's before 4.2 -- I've
+ # seen unexplainable unordered_map bugs with -O2 on older gcc's.
+ AC_TRY_COMPILE([#if defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
+ # error GCC too old for unordered_map
+ #endif
+ ],
+ [/* no program body necessary */],
+ [stl_hash_old_gcc=no],
+ [stl_hash_old_gcc=yes])
+ for location in unordered_map tr1/unordered_map; do
+ for namespace in std std::tr1; do
+ if test -z "$ac_cv_cxx_hash_map" -a "$stl_hash_old_gcc" != yes; then
+ # Some older gcc's have a buggy tr1, so test a bit of code.
+ AC_TRY_COMPILE([#include <$location>],
+ [const ${namespace}::unordered_map<int, int> t;
+ return t.find(5) == t.end();],
+ [ac_cv_cxx_hash_map="<$location>";
+ ac_cv_cxx_hash_namespace="$namespace";
+ ac_cv_cxx_have_unordered_map="yes";])
+ fi
+ done
+ done
+ # Now try hash_map
+ for location in ext/hash_map hash_map; do
+ for namespace in __gnu_cxx "" std stdext; do
+ if test -z "$ac_cv_cxx_hash_map"; then
+ AC_TRY_COMPILE([#include <$location>],
+ [${namespace}::hash_map<int, int> t],
+ [ac_cv_cxx_hash_map="<$location>";
+ ac_cv_cxx_hash_namespace="$namespace";
+ ac_cv_cxx_have_unordered_map="no";])
+ fi
+ done
+ done
+ ac_cv_cxx_hash_set=`echo "$ac_cv_cxx_hash_map" | sed s/map/set/`;
+ if test -n "$ac_cv_cxx_hash_map"; then
+ AC_DEFINE(HAVE_HASH_MAP, 1, [define if the compiler has hash_map])
+ AC_DEFINE(HAVE_HASH_SET, 1, [define if the compiler has hash_set])
+ AC_DEFINE_UNQUOTED(HASH_MAP_H,$ac_cv_cxx_hash_map,
+ [the location of <unordered_map> or <hash_map>])
+ AC_DEFINE_UNQUOTED(HASH_SET_H,$ac_cv_cxx_hash_set,
+ [the location of <unordered_set> or <hash_set>])
+ AC_DEFINE_UNQUOTED(HASH_NAMESPACE,$ac_cv_cxx_hash_namespace,
+ [the namespace of hash_map/hash_set])
+ if test "$ac_cv_cxx_have_unordered_map" = yes; then
+ AC_DEFINE(HAVE_UNORDERED_MAP,1,
+ [define if the compiler supports unordered_{map,set}])
+ fi
+ AC_MSG_RESULT([$ac_cv_cxx_hash_map])
+ else
+ AC_MSG_RESULT()
+ AC_MSG_WARN([could not find an STL hash_map])
+ fi
+])
diff --git a/m4/stl_namespace.m4 b/m4/stl_namespace.m4
new file mode 100644
index 0000000..989ad80
--- /dev/null
+++ b/m4/stl_namespace.m4
@@ -0,0 +1,25 @@
+# We check what namespace stl code like vector expects to be executed in
+
+AC_DEFUN([AC_CXX_STL_NAMESPACE],
+ [AC_CACHE_CHECK(
+ what namespace STL code is in,
+ ac_cv_cxx_stl_namespace,
+ [AC_REQUIRE([AC_CXX_NAMESPACES])
+ AC_LANG_SAVE
+ AC_LANG_CPLUSPLUS
+ AC_TRY_COMPILE([#include <vector>],
+ [vector<int> t; return 0;],
+ ac_cv_cxx_stl_namespace=none)
+ AC_TRY_COMPILE([#include <vector>],
+ [std::vector<int> t; return 0;],
+ ac_cv_cxx_stl_namespace=std)
+ AC_LANG_RESTORE])
+ if test "$ac_cv_cxx_stl_namespace" = none; then
+ AC_DEFINE(STL_NAMESPACE,,
+ [the namespace where STL code like vector<> is defined])
+ fi
+ if test "$ac_cv_cxx_stl_namespace" = std; then
+ AC_DEFINE(STL_NAMESPACE,std,
+ [the namespace where STL code like vector<> is defined])
+ fi
+])
diff --git a/missing b/missing
new file mode 100755
index 0000000..1c8ff70
--- /dev/null
+++ b/missing
@@ -0,0 +1,367 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2006-05-10.23
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006
+# Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+fi
+
+run=:
+sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p'
+sed_minuso='s/.* -o \([^ ]*\).*/\1/p'
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+ configure_ac=configure.ac
+else
+ configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case $1 in
+--run)
+ # Try to run requested program, and just exit if it succeeds.
+ run=
+ shift
+ "$@" && exit 0
+ # Exit code 63 means version mismatch. This often happens
+ # when the user try to use an ancient version of a tool on
+ # a file that requires a minimum version. In this case we
+ # we should proceed has if the program had been absent, or
+ # if --run hadn't been passed.
+ if test $? = 63; then
+ run=:
+ msg="probably too old"
+ fi
+ ;;
+
+ -h|--h|--he|--hel|--help)
+ echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+ -h, --help display this help and exit
+ -v, --version output version information and exit
+ --run try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+ aclocal touch file \`aclocal.m4'
+ autoconf touch file \`configure'
+ autoheader touch file \`config.h.in'
+ autom4te touch the output file, or create a stub one
+ automake touch all \`Makefile.in' files
+ bison create \`y.tab.[ch]', if possible, from existing .[ch]
+ flex create \`lex.yy.c', if possible, from existing .c
+ help2man touch the output file
+ lex create \`lex.yy.c', if possible, from existing .c
+ makeinfo touch the output file
+ tar try tar, gnutar, gtar, then tar without non-portable flags
+ yacc create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake@gnu.org>."
+ exit $?
+ ;;
+
+ -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+ echo "missing $scriptversion (GNU Automake)"
+ exit $?
+ ;;
+
+ -*)
+ echo 1>&2 "$0: Unknown \`$1' option"
+ echo 1>&2 "Try \`$0 --help' for more information"
+ exit 1
+ ;;
+
+esac
+
+# Now exit if we have it, but it failed. Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case $1 in
+ lex|yacc)
+ # Not GNU programs, they don't have --version.
+ ;;
+
+ tar)
+ if test -n "$run"; then
+ echo 1>&2 "ERROR: \`tar' requires --run"
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ exit 1
+ fi
+ ;;
+
+ *)
+ if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+ # We have it, but it failed.
+ exit 1
+ elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+ # Could not run --version or --help. This is probably someone
+ # running `$TOOL --version' or `$TOOL --help' to check whether
+ # $TOOL exists and not knowing $TOOL uses missing.
+ exit 1
+ fi
+ ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case $1 in
+ aclocal*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acinclude.m4' or \`${configure_ac}'. You might want
+ to install the \`Automake' and \`Perl' packages. Grab them from
+ any GNU archive site."
+ touch aclocal.m4
+ ;;
+
+ autoconf)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`${configure_ac}'. You might want to install the
+ \`Autoconf' and \`GNU m4' packages. Grab them from any GNU
+ archive site."
+ touch configure
+ ;;
+
+ autoheader)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`acconfig.h' or \`${configure_ac}'. You might want
+ to install the \`Autoconf' and \`GNU m4' packages. Grab them
+ from any GNU archive site."
+ files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+ test -z "$files" && files="config.h"
+ touch_files=
+ for f in $files; do
+ case $f in
+ *:*) touch_files="$touch_files "`echo "$f" |
+ sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+ *) touch_files="$touch_files $f.in";;
+ esac
+ done
+ touch $touch_files
+ ;;
+
+ automake*)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+ You might want to install the \`Automake' and \`Perl' packages.
+ Grab them from any GNU archive site."
+ find . -type f -name Makefile.am -print |
+ sed 's/\.am$/.in/' |
+ while read f; do touch "$f"; done
+ ;;
+
+ autom4te)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them.
+ You can get \`$1' as part of \`Autoconf' from any GNU
+ archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo "#! /bin/sh"
+ echo "# Created by GNU Automake missing as a replacement of"
+ echo "# $ $@"
+ echo "exit 0"
+ chmod +x $file
+ exit 1
+ fi
+ ;;
+
+ bison|yacc)
+ echo 1>&2 "\
+WARNING: \`$1' $msg. You should only need it if
+ you modified a \`.y' file. You may need the \`Bison' package
+ in order for those modifications to take effect. You can get
+ \`Bison' from any GNU archive site."
+ rm -f y.tab.c y.tab.h
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.y)
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.c
+ fi
+ SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" y.tab.h
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f y.tab.h; then
+ echo >y.tab.h
+ fi
+ if test ! -f y.tab.c; then
+ echo 'main() { return 0; }' >y.tab.c
+ fi
+ ;;
+
+ lex|flex)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.l' file. You may need the \`Flex' package
+ in order for those modifications to take effect. You can get
+ \`Flex' from any GNU archive site."
+ rm -f lex.yy.c
+ if test $# -ne 1; then
+ eval LASTARG="\${$#}"
+ case $LASTARG in
+ *.l)
+ SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+ if test -f "$SRCFILE"; then
+ cp "$SRCFILE" lex.yy.c
+ fi
+ ;;
+ esac
+ fi
+ if test ! -f lex.yy.c; then
+ echo 'main() { return 0; }' >lex.yy.c
+ fi
+ ;;
+
+ help2man)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a dependency of a manual page. You may need the
+ \`Help2man' package in order for those modifications to take
+ effect. You can get \`Help2man' from any GNU archive site."
+
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -f "$file"; then
+ touch $file
+ else
+ test -z "$file" || exec >$file
+ echo ".ab help2man is required to generate this page"
+ exit 1
+ fi
+ ;;
+
+ makeinfo)
+ echo 1>&2 "\
+WARNING: \`$1' is $msg. You should only need it if
+ you modified a \`.texi' or \`.texinfo' file, or any other file
+ indirectly affecting the aspect of the manual. The spurious
+ call might also be the consequence of using a buggy \`make' (AIX,
+ DU, IRIX). You might want to install the \`Texinfo' package or
+ the \`GNU make' package. Grab either from any GNU archive site."
+ # The file to touch is that specified with -o ...
+ file=`echo "$*" | sed -n "$sed_output"`
+ test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"`
+ if test -z "$file"; then
+ # ... or it is the one specified with @setfilename ...
+ infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+ file=`sed -n '
+ /^@setfilename/{
+ s/.* \([^ ]*\) *$/\1/
+ p
+ q
+ }' $infile`
+ # ... or it is derived from the source name (dir/f.texi becomes f.info)
+ test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+ fi
+ # If the file does not exist, the user really needs makeinfo;
+ # let's fail without touching anything.
+ test -f $file || exit 1
+ touch $file
+ ;;
+
+ tar)
+ shift
+
+ # We have already tried tar in the generic part.
+ # Look for gnutar/gtar before invocation to avoid ugly error
+ # messages.
+ if (gnutar --version > /dev/null 2>&1); then
+ gnutar "$@" && exit 0
+ fi
+ if (gtar --version > /dev/null 2>&1); then
+ gtar "$@" && exit 0
+ fi
+ firstarg="$1"
+ if shift; then
+ case $firstarg in
+ *o*)
+ firstarg=`echo "$firstarg" | sed s/o//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ case $firstarg in
+ *h*)
+ firstarg=`echo "$firstarg" | sed s/h//`
+ tar "$firstarg" "$@" && exit 0
+ ;;
+ esac
+ fi
+
+ echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+ You may want to install GNU tar or Free paxutils, or check the
+ command line arguments."
+ exit 1
+ ;;
+
+ *)
+ echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+ You might have modified some files without having the
+ proper tools for further handling them. Check the \`README' file,
+ it often tells you about the needed prerequisites for installing
+ this package. You may also peek at any GNU archive site, in case
+ some other package would contain this missing \`$1' program."
+ exit 1
+ ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/packages/deb.sh b/packages/deb.sh
new file mode 100755
index 0000000..31b423c
--- /dev/null
+++ b/packages/deb.sh
@@ -0,0 +1,74 @@
+#!/bin/bash -e
+
+# This takes one commandline argument, the name of the package. If no
+# name is given, then we'll end up just using the name associated with
+# an arbitrary .tar.gz file in the rootdir. That's fine: there's probably
+# only one.
+#
+# Run this from the 'packages' directory, just under rootdir
+
+## Set LIB to lib if exporting a library, empty-string else
+LIB=
+#LIB=lib
+
+PACKAGE="$1"
+VERSION="$2"
+
+# We can only build Debian packages, if the Debian build tools are installed
+if [ \! -x /usr/bin/debuild ]; then
+ echo "Cannot find /usr/bin/debuild. Not building Debian packages." 1>&2
+ exit 0
+fi
+
+# Double-check we're in the packages directory, just under rootdir
+if [ \! -r ../Makefile -a \! -r ../INSTALL ]; then
+ echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
+ echo "Also, you must run \"make dist\" before running this script." 1>&2
+ exit 0
+fi
+
+# Find the top directory for this package
+topdir="${PWD%/*}"
+
+# Find the tar archive built by "make dist"
+archive="${PACKAGE}-${VERSION}"
+archive_with_underscore="${PACKAGE}_${VERSION}"
+if [ -z "${archive}" ]; then
+ echo "Cannot find ../$PACKAGE*.tar.gz. Run \"make dist\" first." 1>&2
+ exit 0
+fi
+
+# Create a pristine directory for building the Debian package files
+trap 'rm -rf '`pwd`/tmp'; exit $?' EXIT SIGHUP SIGINT SIGTERM
+
+rm -rf tmp
+mkdir -p tmp
+cd tmp
+
+# Debian has very specific requirements about the naming of build
+# directories, and tar archives. It also wants to write all generated
+# packages to the parent of the source directory. We accommodate these
+# requirements by building directly from the tar file.
+ln -s "${topdir}/${archive}.tar.gz" "${LIB}${archive}.orig.tar.gz"
+# Some version of debuilder want foo.orig.tar.gz with _ between versions.
+ln -s "${topdir}/${archive}.tar.gz" "${LIB}${archive_with_underscore}.orig.tar.gz"
+tar zfx "${LIB}${archive}.orig.tar.gz"
+[ -n "${LIB}" ] && mv "${archive}" "${LIB}${archive}"
+cd "${LIB}${archive}"
+# This is one of those 'specific requirements': where the deb control files live
+cp -a "packages/deb" "debian"
+
+# Now, we can call Debian's standard build tool
+debuild -uc -us
+cd ../.. # get back to the original top-level dir
+
+# We'll put the result in a subdirectory that's named after the OS version
+# we've made this .deb file for.
+destdir="debian-$(cat /etc/debian_version 2>/dev/null || echo UNKNOWN)"
+
+rm -rf "$destdir"
+mkdir -p "$destdir"
+mv $(find tmp -mindepth 1 -maxdepth 1 -type f) "$destdir"
+
+echo
+echo "The Debian package files are located in $PWD/$destdir"
diff --git a/packages/deb/README b/packages/deb/README
new file mode 100644
index 0000000..57becfd
--- /dev/null
+++ b/packages/deb/README
@@ -0,0 +1,7 @@
+The list of files here isn't complete. For a step-by-step guide on
+how to set this package up correctly, check out
+ http://www.debian.org/doc/maint-guide/
+
+Most of the files that are in this directory are boilerplate.
+However, you may need to change the list of binary-arch dependencies
+in 'rules'.
diff --git a/packages/deb/changelog b/packages/deb/changelog
new file mode 100644
index 0000000..1bfd517
--- /dev/null
+++ b/packages/deb/changelog
@@ -0,0 +1,161 @@
+ctemplate (2.1-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Olaf van der Spek <olafvdspek@gmail.com> Thu, 22 Mar 2012 00:29:09 +0100
+
+ctemplate (2.0-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. and others <google-ctemplate@googlegroups.com> Tue, 24 Jan 2012 16:00:51 -0800
+
+ctemplate (1.1-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Thu, 22 Dec 2011 14:03:27 -0800
+
+ctemplate (1.0-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Fri, 26 Aug 2011 13:10:46 -0700
+
+ctemplate (1.0rc2-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Fri, 29 Jul 2011 12:19:50 -0700
+
+ctemplate (1.0rc1-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Fri, 22 Jul 2011 15:31:05 -0700
+
+ctemplate (0.99-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Mon, 24 Jan 2011 15:38:31 -0800
+
+ctemplate (0.98-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Fri, 24 Sep 2010 11:38:27 -0700
+
+ctemplate (0.97-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Mon, 19 Apr 2010 15:55:23 -0700
+
+ctemplate (0.96-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Mon, 19 Oct 2009 11:42:57 -0700
+
+ctemplate (0.95-2) unstable; urgency=low
+
+ * Fix the include directory in the spec files: google -> ctemplate
+
+ -- Google Inc. <opensource@google.com> Fri, 12 Jun 2009 08:13:35 -0700
+
+ctemplate (0.95-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Fri, 12 Jun 2009 08:13:35 -0700
+
+ctemplate (0.94-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Thu, 07 May 2009 11:27:28 -0700
+
+ctemplate (0.93-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Mon, 02 Feb 2009 13:51:33 -0800
+
+ctemplate (0.92-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Wed, 12 Nov 2008 11:24:33 -0800
+
+ctemplate (0.91-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Tue, 19 Aug 2008 16:20:27 -0700
+
+ctemplate (0.90-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Sun, 27 Apr 2008 15:06:15 -0700
+
+ctemplate (0.9-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Thu, 24 Jan 2008 16:09:43 -0800
+
+ctemplate (0.8-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Thu, 16 Aug 2007 21:42:55 -0700
+
+ctemplate (0.7-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Tue, 03 Jul 2007 12:46:59 -0700
+
+ctemplate (0.6.1-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Thu, 21 Jun 2007 14:02:32 -0700
+
+ctemplate (0.6-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Sat, 09 Jun 2007 22:34:52 -0700
+
+ctemplate (0.5-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Mon, 14 May 2007 17:27:10 -0700
+
+ctemplate (0.4-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Mon, 15 Jan 2007 14:10:42 -0800
+
+ctemplate (0.3-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Mon, 21 Aug 2006 17:44:32 -0700
+
+ctemplate (0.2-1) unstable; urgency=low
+
+ * New upstream release.
+
+ -- Google Inc. <opensource@google.com> Wed, 14 Jun 2006 14:56:04 -0700
+
+ctemplate (0.1-1) unstable; urgency=low
+
+ * Initial release.
+
+ -- Google Inc. <opensource@google.com> Mon, 13 Mar 2006 22:17:14 -0800
diff --git a/packages/deb/compat b/packages/deb/compat
new file mode 100644
index 0000000..b8626c4
--- /dev/null
+++ b/packages/deb/compat
@@ -0,0 +1 @@
+4
diff --git a/packages/deb/control b/packages/deb/control
new file mode 100644
index 0000000..6a3d574
--- /dev/null
+++ b/packages/deb/control
@@ -0,0 +1,27 @@
+Source: ctemplate
+Section: libdevel
+Priority: optional
+Maintainer: Google Inc. and others <google-ctemplate@googlegroups.com>
+Build-Depends: debhelper (>= 4.0.0)
+Standards-Version: 3.6.1
+
+Package: libctemplate-dev
+Section: libdevel
+Architecture: any
+Depends: libctemplate0 (= ${Source-Version})
+Description: This package contains a library implementing a simple but
+ powerful template language for C++. It emphasizes separating logic
+ from presentation: it is impossible to embed application logic in this
+ template language. The devel package contains static and debug
+ libraries and header files for developing applications that use the
+ ctemplate package.
+
+Package: libctemplate0
+Section: libs
+Architecture: any
+Description: This package contains a library implementing a simple but
+ powerful template language for C++. It emphasizes separating logic
+ from presentation: it is impossible to embed application logic in this
+ template language. This limits the power of the template language
+ without limiting the power of the template *system*. Indeed, Google's
+ "main" web search uses this system exclusively for formatting output.
diff --git a/packages/deb/copyright b/packages/deb/copyright
new file mode 100644
index 0000000..72c11a2
--- /dev/null
+++ b/packages/deb/copyright
@@ -0,0 +1,35 @@
+This package was debianized by Craig Silverstein <google-ctemplate@googlegroups.com>
+on Tue, 24 Jan 2012 16:00:51 -0800.
+
+It was downloaded from http://code.google.com/p/ctemplate/downloads/list
+
+Upstream Author: google-ctemplate@googlegroups.com
+
+Copyright (c) 2006, Google Inc.
+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 Google Inc. 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.
diff --git a/packages/deb/docs b/packages/deb/docs
new file mode 100644
index 0000000..25dee3a
--- /dev/null
+++ b/packages/deb/docs
@@ -0,0 +1,15 @@
+AUTHORS
+COPYING
+ChangeLog
+INSTALL
+NEWS
+README
+doc/designstyle.css
+doc/index.html
+doc/howto.html
+doc/tips.html
+doc/example.html
+doc/xss_resources.html
+contrib/README.contrib
+contrib/highlighting.vim
+contrib/tpl-mode.el
diff --git a/packages/deb/libctemplate-dev.dirs b/packages/deb/libctemplate-dev.dirs
new file mode 100644
index 0000000..ce71d19
--- /dev/null
+++ b/packages/deb/libctemplate-dev.dirs
@@ -0,0 +1,5 @@
+usr/lib
+usr/lib/pkgconfig
+usr/include
+usr/include/ctemplate
+usr/bin
diff --git a/packages/deb/libctemplate-dev.install b/packages/deb/libctemplate-dev.install
new file mode 100644
index 0000000..a4543d7
--- /dev/null
+++ b/packages/deb/libctemplate-dev.install
@@ -0,0 +1,12 @@
+usr/include/ctemplate/*
+usr/lib/lib*.so
+usr/lib/lib*.a
+usr/lib/lib*.la
+usr/bin/*
+usr/lib/pkgconfig/*
+debian/tmp/usr/include/ctemplate/*
+debian/tmp/usr/lib/lib*.so
+debian/tmp/usr/lib/lib*.a
+debian/tmp/usr/lib/lib*.la
+debian/tmp/usr/bin/*
+debian/tmp/usr/lib/pkgconfig/*
diff --git a/packages/deb/libctemplate0.dirs b/packages/deb/libctemplate0.dirs
new file mode 100644
index 0000000..6845771
--- /dev/null
+++ b/packages/deb/libctemplate0.dirs
@@ -0,0 +1 @@
+usr/lib
diff --git a/packages/deb/libctemplate0.install b/packages/deb/libctemplate0.install
new file mode 100644
index 0000000..704ea87
--- /dev/null
+++ b/packages/deb/libctemplate0.install
@@ -0,0 +1,2 @@
+usr/lib/lib*.so.*
+debian/tmp/usr/lib/lib*.so.*
diff --git a/packages/deb/rules b/packages/deb/rules
new file mode 100755
index 0000000..f520bef
--- /dev/null
+++ b/packages/deb/rules
@@ -0,0 +1,117 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+# These are used for cross-compiling and for saving the configure script
+# from having to guess our platform (since we know it already)
+DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
+DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
+
+
+CFLAGS = -Wall -g
+
+ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -O0
+else
+ CFLAGS += -O2
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+# shared library versions, option 1
+#version=2.0.5
+#major=2
+# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
+version=`ls src/.libs/lib*.so.* | \
+ awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
+major=`ls src/.libs/lib*.so.* | \
+ awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
+
+config.status: configure
+ dh_testdir
+ # Add here commands to configure the package.
+ CFLAGS="$(CFLAGS)" ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info
+
+
+build: build-stamp
+build-stamp: config.status
+ dh_testdir
+
+ # Add here commands to compile the package.
+ $(MAKE)
+
+ touch build-stamp
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp
+
+ # Add here commands to clean up after the build process.
+ -$(MAKE) distclean
+ifneq "$(wildcard /usr/share/misc/config.sub)" ""
+ cp -f /usr/share/misc/config.sub config.sub
+endif
+ifneq "$(wildcard /usr/share/misc/config.guess)" ""
+ cp -f /usr/share/misc/config.guess config.guess
+endif
+
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/tmp
+ $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs ChangeLog
+ dh_installdocs
+ dh_installexamples
+ dh_install --sourcedir=debian/tmp
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_python
+ dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
diff --git a/packages/rpm.sh b/packages/rpm.sh
new file mode 100755
index 0000000..0454225
--- /dev/null
+++ b/packages/rpm.sh
@@ -0,0 +1,86 @@
+#!/bin/sh -e
+
+# Run this from the 'packages' directory, just under rootdir
+
+# We can only build rpm packages, if the rpm build tools are installed
+if [ \! -x /usr/bin/rpmbuild ]
+then
+ echo "Cannot find /usr/bin/rpmbuild. Not building an rpm." 1>&2
+ exit 0
+fi
+
+# Check the commandline flags
+PACKAGE="$1"
+VERSION="$2"
+fullname="${PACKAGE}-${VERSION}"
+archive=../$fullname.tar.gz
+
+if [ -z "$1" -o -z "$2" ]
+then
+ echo "Usage: $0 <package name> <package version>" 1>&2
+ exit 0
+fi
+
+# Double-check we're in the packages directory, just under rootdir
+if [ \! -r ../Makefile -a \! -r ../INSTALL ]
+then
+ echo "Must run $0 in the 'packages' directory, under the root directory." 1>&2
+ echo "Also, you must run \"make dist\" before running this script." 1>&2
+ exit 0
+fi
+
+if [ \! -r "$archive" ]
+then
+ echo "Cannot find $archive. Run \"make dist\" first." 1>&2
+ exit 0
+fi
+
+# Create the directory where the input lives, and where the output should live
+RPM_SOURCE_DIR="/tmp/rpmsource-$fullname"
+RPM_BUILD_DIR="/tmp/rpmbuild-$fullname"
+
+trap 'rm -rf $RPM_SOURCE_DIR $RPM_BUILD_DIR; exit $?' EXIT SIGHUP SIGINT SIGTERM
+
+rm -rf "$RPM_SOURCE_DIR" "$RPM_BUILD_DIR"
+mkdir "$RPM_SOURCE_DIR"
+mkdir "$RPM_BUILD_DIR"
+
+cp "$archive" "$RPM_SOURCE_DIR"
+
+# rpmbuild -- as far as I can tell -- asks the OS what CPU it has.
+# This may differ from what kind of binaries gcc produces. dpkg
+# does a better job of this, so if we can run 'dpkg --print-architecture'
+# to get the build CPU, we use that in preference of the rpmbuild
+# default.
+target=`dpkg --print-architecture 2>/dev/null || echo ""`
+if [ -n "$target" ]
+then
+ target=" --target $target"
+fi
+
+rpmbuild -bb rpm/rpm.spec $target \
+ --define "NAME $PACKAGE" \
+ --define "VERSION $VERSION" \
+ --define "_sourcedir $RPM_SOURCE_DIR" \
+ --define "_builddir $RPM_BUILD_DIR" \
+ --define "_rpmdir $RPM_SOURCE_DIR"
+
+# We put the output in a directory based on what system we've built for
+destdir=rpm-unknown
+if [ -r /etc/issue ]
+then
+ grep "Red Hat.*release 7" /etc/issue >/dev/null 2>&1 && destdir=rh7
+ grep "Red Hat.*release 8" /etc/issue >/dev/null 2>&1 && destdir=rh8
+ grep "Red Hat.*release 9" /etc/issue >/dev/null 2>&1 && destdir=rh9
+ if grep Fedora /etc/issue >/dev/null; then
+ destdir=fc`grep Fedora /etc/issue | cut -d' ' -f 4`;
+ fi
+fi
+
+rm -rf "$destdir"
+mkdir -p "$destdir"
+# We want to get not only the main package but devel etc, hence the middle *
+mv "$RPM_SOURCE_DIR"/*/"${PACKAGE}"-*"${VERSION}"*.rpm "$destdir"
+
+echo
+echo "The rpm package file(s) are located in $PWD/$destdir"
diff --git a/packages/rpm/rpm.spec b/packages/rpm/rpm.spec
new file mode 100644
index 0000000..9e4453d
--- /dev/null
+++ b/packages/rpm/rpm.spec
@@ -0,0 +1,81 @@
+%define RELEASE 1
+%define rel %{?CUSTOM_RELEASE} %{!?CUSTOM_RELEASE:%RELEASE}
+%define prefix /usr
+
+Name: %NAME
+Summary: Simple but powerful template language for C++
+Version: %VERSION
+Release: %rel
+Group: Development/Libraries
+URL: http://code.google.com/p/ctemplate
+License: BSD
+Vendor: Google Inc. and others
+Packager: Google Inc. and others <google-ctemplate@googlegroups.com>
+Source: http://%{NAME}.googlecode.com/files/%{NAME}-%{VERSION}.tar.gz
+Distribution: Redhat 7 and above.
+Buildroot: %{_tmppath}/%{name}-root
+Prefix: %prefix
+
+%description
+The %name package contains a library implementing a simple but
+powerful template language for C++. It emphasizes separating logic
+from presentation: it is impossible to embed application logic in this
+template language. This limits the power of the template language
+without limiting the power of the template *system*. Indeed, Google's
+"main" web search uses this system exclusively for formatting output.
+
+%package devel
+Summary: Simple but powerful template language for C++
+Group: Development/Libraries
+Requires: %{NAME} = %{VERSION}
+
+%description devel
+The %name-devel package contains static and debug libraries and header
+files for developing applications that use the %name package.
+
+%changelog
+ * Wed Apr 22 2009 <opensource@google.com>
+ - Change build rule to use %configure instead of ./configure
+ - Change install to use DESTDIR instead of prefix for make install
+ - Use wildcards for doc/ and lib/ directories
+ - Use {_libdir}/{_includedir}/etc instead of {prefix}/lib, etc
+
+ * Mon Mar 13 2006 <opensource@google.com>
+ - First draft
+
+%prep
+%setup
+
+%build
+# I can't use '% configure', because it defines -m32 which breaks on
+# my development environment for some reason. But I do take
+# as much from % configure (in /usr/lib/rpm/macros) as I can.
+./configure --prefix=%{_prefix} --exec-prefix=%{_exec_prefix} --bindir=%{_bindir} --sbindir=%{_sbindir} --sysconfdir=%{_sysconfdir} --datadir=%{_datadir} --includedir=%{_includedir} --libdir=%{_libdir} --libexecdir=%{_libexecdir} --localstatedir=%{_localstatedir} --sharedstatedir=%{_sharedstatedir} --mandir=%{_mandir} --infodir=%{_infodir}
+make
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make DESTDIR=$RPM_BUILD_ROOT install
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%files
+%defattr(-,root,root)
+
+%docdir %{prefix}/share/doc/%{NAME}-%{VERSION}
+%{prefix}/share/doc/%{NAME}-%{VERSION}/*
+
+%{_libdir}/*.so.*
+
+%files devel
+%defattr(-,root,root)
+
+%{_includedir}/ctemplate
+%{_libdir}/*.a
+%{_libdir}/*.la
+%{_libdir}/*.so
+%{_bindir}/make_tpl_varnames_h
+%{_bindir}/template-converter
+%{_bindir}/diff_tpl_auto_escape
+%{_libdir}/pkgconfig/*.pc
diff --git a/src/base/arena-inl.h b/src/base/arena-inl.h
new file mode 100644
index 0000000..d4aee74
--- /dev/null
+++ b/src/base/arena-inl.h
@@ -0,0 +1,351 @@
+// Copyright (c) 2000, Google Inc.
+// 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 Google Inc. 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.
+// ---
+//
+// Reorganized by Craig Silverstein
+//
+// In this file we define the arena template code. This includes the
+// ArenaAllocator, which is meant only to be used with STL, and also
+// the Gladiator (which needs to know how to new and delete various
+// types of objects).
+//
+// If you're only using the MALLOC-LIKE functionality of the arena,
+// you don't need to include this file at all! You do need to include
+// it (in your own .cc file) if you want to use the STRING, STL, or
+// NEW aspects of the arena. See arena.h for details on these types.
+//
+// ArenaAllocator is an STL allocator, but because it relies on unequal
+// instances, it may not work with all standards-conforming STL
+// implementations. But it works with SGI STL so we're happy.
+//
+// Here's an example of how the ArenaAllocator would be used.
+// Say we have a vector of ints that we want to have use the arena
+// for memory allocation. Here's one way to do it:
+// UnsafeArena* arena = new UnsafeArena(1000); // or SafeArena(), or 10000
+// vector<int, ArenaAllocator<int, UnsafeArena> > v(arena);
+//
+// Note that every STL type always allows the allocator (in this case,
+// the arena, which is automatically promoted to an allocator) as the last
+// arg to the constructor. So if you would normally do
+// vector<...> v(foo, bar),
+// with the arena you can do
+// vector<...> v(foo, bar, arena);
+
+#ifndef BASE_ARENA_INL_H_
+#define BASE_ARENA_INL_H_
+
+#include <config.h>
+#include "base/arena.h"
+#include <assert.h>
+#include <stddef.h>
+#include <new>
+#include <memory>
+
+namespace ctemplate {
+
+// T is the type we want to allocate, and C is the type of the arena.
+// ArenaAllocator has the thread-safety characteristics of C.
+template <class T, class C> class ArenaAllocator {
+ public:
+ typedef T value_type;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ pointer address(reference r) const { return &r; }
+ const_pointer address(const_reference r) const { return &r; }
+ size_type max_size() const { return size_t(-1) / sizeof(T); }
+
+ // DO NOT USE! The default constructor is for gcc3 compatibility only.
+ ArenaAllocator() : arena_(0) { }
+ // This is not an explicit constructor! So you can pass in an arena*
+ // to functions needing an ArenaAllocator (like the astring constructor)
+ // and everything will work ok.
+ ArenaAllocator(C* arena) : arena_(arena) { } // NOLINT
+ ~ArenaAllocator() { }
+
+ pointer allocate(size_type n,
+ std::allocator<void>::const_pointer /*hint*/ = 0) {
+ assert(arena_ && "No arena to allocate from!");
+ return reinterpret_cast<T*>(arena_->AllocAligned(n * sizeof(T),
+ kAlignment));
+ }
+ void deallocate(pointer p, size_type n) {
+ arena_->Free(p, n * sizeof(T));
+ }
+ void construct(pointer p, const T & val) {
+ new(reinterpret_cast<void*>(p)) T(val);
+ }
+ void construct(pointer p) {
+ new(reinterpret_cast<void*>(p)) T();
+ }
+ void destroy(pointer p) { p->~T(); }
+
+ C* arena(void) const { return arena_; }
+
+ template<class U> struct rebind {
+ typedef ArenaAllocator<U, C> other;
+ };
+
+ template<class U> ArenaAllocator(const ArenaAllocator<U, C>& other)
+ : arena_(other.arena()) { }
+
+ template<class U> bool operator==(const ArenaAllocator<U, C>& other) const {
+ return arena_ == other.arena();
+ }
+
+ template<class U> bool operator!=(const ArenaAllocator<U, C>& other) const {
+ return arena_ != other.arena();
+ }
+
+ protected:
+ static const int kAlignment;
+ C* arena_;
+};
+
+template<class T, class C> const int ArenaAllocator<T, C>::kAlignment =
+ (1 == sizeof(T) ? 1 : BaseArena::kDefaultAlignment);
+
+
+// 'new' must be in the global namespace.
+}
+using GOOGLE_NAMESPACE::UnsafeArena;
+
+
+// Operators for allocation on the arena
+// Syntax: new (AllocateInArena, arena) MyClass;
+// new (AllocateInArena, arena) MyClass[num];
+// Useful for classes you can't descend from Gladiator, such as POD,
+// STL containers, etc.
+enum AllocateInArenaType { AllocateInArena };
+
+inline void* operator new(size_t size,
+ AllocateInArenaType /* unused */,
+ UnsafeArena *arena) {
+ return arena->Alloc(size);
+}
+
+inline void* operator new[](size_t size,
+ AllocateInArenaType /* unused */,
+ UnsafeArena *arena) {
+ return arena->Alloc(size);
+}
+
+namespace ctemplate {
+
+// Ordinarily in C++, one allocates all instances of a class from an
+// arena. If that's what you want to do, you don't need Gladiator.
+// (However you may find ArenaOnlyGladiator useful.)
+//
+// However, for utility classes that are used by multiple clients, the
+// everything-in-one-arena model may not work. Some clients may wish
+// not to use an arena at all. Or perhaps a composite structure
+// (tree) will contain multiple objects (nodes) and some of those
+// objects will be created by a factory, using an arena, while other
+// objects will be created on-the-fly by an unsuspecting user who
+// doesn't know anything about the arena.
+//
+// To support that, have the arena-allocated class inherit from
+// Gladiator. The ordinary operator new will continue to allocate
+// from the heap. To allocate from an arena, do
+// Myclass * m = new (AllocateInArena, a) Myclass (args, to, constructor);
+// where a is either an arena or an allocator. Now you can call
+// delete on all the objects, whether they are allocated from an arena
+// or on the heap. Heap memory will be released, while arena memory will
+// not be.
+//
+// If a client knows that no objects were allocated on the heap, it
+// need not delete any objects (but it may if it wishes). The only
+// objects that must be deleted are those that were actually allocated
+// from the heap.
+//
+// NOTE: an exception to the google C++ style guide rule for "No multiple
+// implementation inheritance" is granted for this class: you can treat this
+// class as an "Interface" class, and use it in a multiple inheritence context,
+// even though it implements operator new/delete.
+
+class Gladiator {
+ public:
+ Gladiator() { }
+ virtual ~Gladiator() { }
+
+ // We do not override the array allocators, so array allocation and
+ // deallocation will always be from the heap. Typically, arrays are
+ // larger, and thus the costs of arena allocation are higher and the
+ // benefits smaller. Since arrays are typically allocated and deallocated
+ // very differently from scalars, this may not interfere too much with
+ // the arena concept. If it does pose a problem, flesh out the
+ // ArrayGladiator class below.
+
+ void* operator new(size_t size) {
+ void* ret = ::operator new(1 + size);
+ static_cast<char *>(ret)[size] = 1; // mark as heap-allocated
+ return ret;
+ }
+ // the ignored parameter keeps us from stepping on placement new
+ template<class T> void* operator new(size_t size, const int ignored,
+ T* allocator) {
+ if (allocator) {
+ void* ret = allocator->AllocAligned(1 + size,
+ BaseArena::kDefaultAlignment);
+ static_cast<char*>(ret)[size] = 0; // mark as arena-allocated
+ return ret;
+ } else {
+ return operator new(size); // this is the function above
+ }
+ }
+ void operator delete(void* memory, size_t size) {
+ if (static_cast<char*>(memory)[size]) {
+ assert (1 == static_cast<char *>(memory)[size]);
+ ::operator delete(memory);
+ } else {
+ // We never call the allocator's Free method. If we need to do
+ // that someday, we can store a pointer to the arena instead of
+ // the Boolean marker flag.
+ }
+ }
+ template<class T> void operator delete(void* memory, size_t size,
+ const int ign, T* allocator) {
+ // This "placement delete" can only be called if the constructor
+ // throws an exception.
+ if (allocator) {
+ allocator->Free(memory, 1 + size);
+ } else {
+ ::operator delete(memory);
+ }
+ }
+};
+
+// This avoids the space overhead of Gladiator if you just want to
+// override new and delete. It helps avoid some of the more common
+// problems that can occur when overriding new and delete.
+
+class ArenaOnlyGladiator {
+ public:
+ ArenaOnlyGladiator() { }
+ // No virtual destructor is needed because we ignore the size
+ // parameter in all the delete functions.
+ // virtual ~ArenaOnlyGladiator() { }
+
+ // can't just return NULL here -- compiler gives a warning. :-|
+ void* operator new(size_t /*size*/) {
+ assert(0);
+ return reinterpret_cast<void *>(1);
+ }
+ void* operator new[](size_t /*size*/) {
+ assert(0);
+ return reinterpret_cast<void *>(1);
+ }
+
+ // the ignored parameter keeps us from stepping on placement new
+ template<class T> void* operator new(size_t size, const int ignored,
+ T* allocator) {
+ assert(allocator);
+ return allocator->AllocAligned(size, BaseArena::kDefaultAlignment);
+ }
+ template<class T> void* operator new[](size_t size,
+ const int ignored, T* allocator) {
+ assert(allocator);
+ return allocator->AllocAligned (size, BaseArena::kDefaultAlignment);
+ }
+ void operator delete(void* /*memory*/, size_t /*size*/) { }
+ template<class T> void operator delete(void* memory, size_t size,
+ const int ign, T* allocator) { }
+ void operator delete [](void* /*memory*/) { }
+ template<class T> void operator delete(void* memory,
+ const int ign, T* allocator) { }
+};
+
+#if 0 // ********** for example purposes only; 100% untested.
+
+// Note that this implementation incurs an overhead of kHeaderSize for
+// every array that is allocated. *Before* the space is returned to the
+// user, we store the address of the Arena that owns the space, and
+// the length of th space itself.
+
+class ArrayGladiator : public Gladiator {
+ public:
+ void * operator new[] (size_t size) {
+ const int sizeplus = size + kHeaderSize;
+ void * const ret = ::operator new(sizeplus);
+ *static_cast<Arena **>(ret) = NULL; // mark as heap-allocated
+ *static_cast<size_t *>(ret + sizeof(Arena *)) = sizeplus;
+ return ret + kHeaderSize;
+ }
+ // the ignored parameter keeps us from stepping on placement new
+ template<class T> void * operator new[] (size_t size,
+ const int ignored, T * allocator) {
+ if (allocator) {
+ const int sizeplus = size + kHeaderSize;
+ void * const ret =
+ allocator->AllocAligned(sizeplus, BaseArena::kDefaultAlignment);
+ *static_cast<Arena **>(ret) = allocator->arena();
+ *static_cast<size_t *>(ret + sizeof(Arena *)) = sizeplus;
+ return ret + kHeaderSize;
+ } else {
+ return operator new[](size); // this is the function above
+ }
+ }
+ void operator delete [] (void * memory) {
+ memory -= kHeaderSize;
+ Arena * const arena = *static_cast<Arena **>(memory);
+ size_t sizeplus = *static_cast<size_t *>(memory + sizeof(arena));
+ if (arena) {
+ arena->SlowFree(memory, sizeplus);
+ } else {
+ ::operator delete (memory);
+ }
+ }
+ template<class T> void * operator delete (void * memory,
+ const int ign, T * allocator) {
+ // This "placement delete" can only be called if the constructor
+ // throws an exception.
+ memory -= kHeaderSize;
+ size_t sizeplus = *static_cast<size_t *>(memory + sizeof(Arena *));
+ if (allocator) {
+ allocator->Free(memory, 1 + size);
+ } else {
+ operator delete (memory);
+ }
+ }
+
+ protected:
+ static const int kMinSize = sizeof size_t + sizeof(Arena *);
+ static const int kHeaderSize = kMinSize > BaseArena::kDefaultAlignment ?
+ 2 * BaseArena::kDefaultAlignment : BaseArena::kDefaultAlignment;
+};
+
+#endif // ********** example
+
+}
+
+#endif // BASE_ARENA_INL_H_
diff --git a/src/base/arena.cc b/src/base/arena.cc
new file mode 100644
index 0000000..62df770
--- /dev/null
+++ b/src/base/arena.cc
@@ -0,0 +1,505 @@
+// Copyright (c) 2000, Google Inc.
+// 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 Google Inc. 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.
+// ---
+//
+// Reorganized by Craig Silverstein
+// "Handles" by Ilan Horn
+//
+// This approach to arenas overcomes many of the limitations described
+// in the "Specialized allocators" section of
+// http://www.pdos.lcs.mit.edu/~dm/c++-new.html
+//
+// A somewhat similar approach to Gladiator, but for heap-detection, was
+// suggested by Ron van der Wal and Scott Meyers at
+// http://www.aristeia.com/BookErrata/M27Comments_frames.html
+
+#include <config.h>
+#include "base/arena.h"
+#include "base/arena-inl.h"
+#include <assert.h>
+#include <algorithm>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <vector>
+#include <sys/types.h> // one place uintptr_t might be
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif // another place uintptr_t might be
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif // last place uintptr_t might be
+#include "base/macros.h" // for uint64
+#include "base/mutex.h"
+#include "base/util.h" // for DCHECK_*
+
+using std::min;
+using std::vector;
+
+// TODO(csilvers): add in a portable implementation of aligned_malloc
+static void* aligned_malloc(size_t size, size_t alignment) {
+ LOG(FATAL) << "page_aligned_ not currently supported\n";
+}
+
+// The value here doesn't matter until page_aligned_ is supported.
+static const int kPageSize = 8192; // should be getpagesize()
+
+namespace ctemplate {
+
+// We used to only keep track of how much space has been allocated in
+// debug mode. Now we track this for optimized builds, as well. If you
+// want to play with the old scheme to see if this helps performance,
+// change this ARENASET() macro to a NOP. However, NOTE: some
+// applications of arenas depend on this space information (exported
+// via bytes_allocated()).
+#define ARENASET(x) (x)
+
+// ----------------------------------------------------------------------
+// BaseArena::BaseArena()
+// BaseArena::~BaseArena()
+// Destroying the arena automatically calls Reset()
+// ----------------------------------------------------------------------
+
+
+BaseArena::BaseArena(char* first, const size_t block_size, bool align_to_page)
+ : remaining_(0),
+ first_block_we_own_(first ? 1 : 0),
+ block_size_(block_size),
+ freestart_(NULL), // set for real in Reset()
+ last_alloc_(NULL),
+ blocks_alloced_(1),
+ overflow_blocks_(NULL),
+ page_aligned_(align_to_page),
+ handle_alignment_(1),
+ handle_alignment_bits_(0),
+ block_size_bits_(0) {
+ assert(block_size > kDefaultAlignment);
+
+ while ((static_cast<size_t>(1) << block_size_bits_) < block_size_) {
+ ++block_size_bits_;
+ }
+
+ if (page_aligned_) {
+ // kPageSize must be power of 2, so make sure of this.
+ CHECK(kPageSize > 0 && 0 == (kPageSize & (kPageSize - 1)))
+ << "kPageSize[ " << kPageSize << "] is not "
+ << "correctly initialized: not a power of 2.";
+ }
+
+ if (first) {
+ CHECK(!page_aligned_ ||
+ (reinterpret_cast<uintptr_t>(first) & (kPageSize - 1)) == 0);
+ first_blocks_[0].mem = first;
+ } else {
+ if (page_aligned_) {
+ // Make sure the blocksize is page multiple, as we need to end on a page
+ // boundary.
+ CHECK_EQ(block_size & (kPageSize - 1), 0) << "block_size is not a"
+ << "multiple of kPageSize";
+ first_blocks_[0].mem = reinterpret_cast<char*>(aligned_malloc(block_size_,
+ kPageSize));
+ PCHECK(NULL != first_blocks_[0].mem);
+ } else {
+ first_blocks_[0].mem = reinterpret_cast<char*>(malloc(block_size_));
+ }
+ }
+ first_blocks_[0].size = block_size_;
+
+ Reset();
+}
+
+BaseArena::~BaseArena() {
+ FreeBlocks();
+ assert(overflow_blocks_ == NULL); // FreeBlocks() should do that
+ // The first X blocks stay allocated always by default. Delete them now.
+ for ( int i = first_block_we_own_; i < blocks_alloced_; ++i )
+ free(first_blocks_[i].mem);
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::block_count()
+// Only reason this is in .cc file is because it involves STL.
+// ----------------------------------------------------------------------
+
+int BaseArena::block_count() const {
+ return (blocks_alloced_ +
+ (overflow_blocks_ ? static_cast<int>(overflow_blocks_->size()) : 0));
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::Reset()
+// Clears all the memory an arena is using.
+// ----------------------------------------------------------------------
+
+void BaseArena::Reset() {
+ FreeBlocks();
+ freestart_ = first_blocks_[0].mem;
+ remaining_ = first_blocks_[0].size;
+ last_alloc_ = NULL;
+
+ ARENASET(status_.bytes_allocated_ = block_size_);
+
+ // We do not know for sure whether or not the first block is aligned,
+ // so we fix that right now.
+ const int overage = reinterpret_cast<uintptr_t>(freestart_) &
+ (kDefaultAlignment-1);
+ if (overage > 0) {
+ const int waste = kDefaultAlignment - overage;
+ freestart_ += waste;
+ remaining_ -= waste;
+ }
+ freestart_when_empty_ = freestart_;
+ assert(!(reinterpret_cast<uintptr_t>(freestart_)&(kDefaultAlignment-1)));
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::MakeNewBlock()
+// Our sbrk() equivalent. We always make blocks of the same size
+// (though GetMemory() can also make a new block for really big
+// data.
+// ----------------------------------------------------------------------
+
+void BaseArena::MakeNewBlock() {
+ AllocatedBlock *block = AllocNewBlock(block_size_);
+ freestart_ = block->mem;
+ remaining_ = block->size;
+}
+
+// -------------------------------------------------------------
+// BaseArena::AllocNewBlock()
+// Adds and returns an AllocatedBlock.
+// The returned AllocatedBlock* is valid until the next call
+// to AllocNewBlock or Reset. (i.e. anything that might
+// affect overflow_blocks_).
+// -------------------------------------------------------------
+
+BaseArena::AllocatedBlock* BaseArena::AllocNewBlock(const size_t block_size) {
+ AllocatedBlock *block;
+ // Find the next block.
+ if ( blocks_alloced_ < ARRAYSIZE(first_blocks_) ) {
+ // Use one of the pre-allocated blocks
+ block = &first_blocks_[blocks_alloced_++];
+ } else { // oops, out of space, move to the vector
+ if (overflow_blocks_ == NULL) overflow_blocks_ = new vector<AllocatedBlock>;
+ // Adds another block to the vector.
+ overflow_blocks_->resize(overflow_blocks_->size()+1);
+ // block points to the last block of the vector.
+ block = &overflow_blocks_->back();
+ }
+
+ if (page_aligned_) {
+ // We need the size to be multiple of kPageSize to mprotect it later.
+ size_t num_pages = ((block_size - 1) / kPageSize) + 1;
+ size_t new_block_size = num_pages * kPageSize;
+ block->mem = reinterpret_cast<char*>(aligned_malloc(new_block_size,
+ kPageSize));
+ PCHECK(NULL != block->mem);
+ block->size = new_block_size;
+ } else {
+ block->mem = reinterpret_cast<char*>(malloc(block_size));
+ block->size = block_size;
+ }
+
+ ARENASET(status_.bytes_allocated_ += block_size);
+
+ return block;
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::IndexToBlock()
+// Index encoding is as follows:
+// For blocks in the first_blocks_ array, we use index of the block in
+// the array.
+// For blocks in the overflow_blocks_ vector, we use the index of the
+// block in iverflow_blocks_, plus the size of the first_blocks_ array.
+// ----------------------------------------------------------------------
+
+const BaseArena::AllocatedBlock *BaseArena::IndexToBlock(int index) const {
+ if (index < ARRAYSIZE(first_blocks_)) {
+ return &first_blocks_[index];
+ }
+ CHECK(overflow_blocks_ != NULL);
+ int index_in_overflow_blocks = index - ARRAYSIZE(first_blocks_);
+ CHECK_GE(index_in_overflow_blocks, 0);
+ CHECK_LT(static_cast<size_t>(index_in_overflow_blocks),
+ overflow_blocks_->size());
+ return &(*overflow_blocks_)[index_in_overflow_blocks];
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::GetMemoryFallback()
+// We take memory out of our pool, aligned on the byte boundary
+// requested. If we don't have space in our current pool, we
+// allocate a new block (wasting the remaining space in the
+// current block) and give you that. If your memory needs are
+// too big for a single block, we make a special your-memory-only
+// allocation -- this is equivalent to not using the arena at all.
+// ----------------------------------------------------------------------
+
+void* BaseArena::GetMemoryFallback(const size_t size, const int align_as_int) {
+ if (0 == size) {
+ return NULL; // stl/stl_alloc.h says this is okay
+ }
+ // This makes the type-checker happy.
+ const size_t align = static_cast<size_t>(align_as_int);
+
+ assert(align_as_int > 0 && 0 == (align & (align - 1))); // must be power of 2
+
+ // If the object is more than a quarter of the block size, allocate
+ // it separately to avoid wasting too much space in leftover bytes
+ if (block_size_ == 0 || size > block_size_/4) {
+ // then it gets its own block in the arena
+ assert(align <= kDefaultAlignment); // because that's what new gives us
+ // This block stays separate from the rest of the world; in particular
+ // we don't update last_alloc_ so you can't reclaim space on this block.
+ return AllocNewBlock(size)->mem;
+ }
+
+ const size_t overage =
+ (reinterpret_cast<uintptr_t>(freestart_) & (align-1));
+ if (overage) {
+ const size_t waste = align - overage;
+ freestart_ += waste;
+ if (waste < remaining_) {
+ remaining_ -= waste;
+ } else {
+ remaining_ = 0;
+ }
+ }
+ if (size > remaining_) {
+ MakeNewBlock();
+ }
+ remaining_ -= size;
+ last_alloc_ = freestart_;
+ freestart_ += size;
+ assert(0 == (reinterpret_cast<uintptr_t>(last_alloc_) & (align-1)));
+ return reinterpret_cast<void*>(last_alloc_);
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::ReturnMemoryFallback()
+// BaseArena::FreeBlocks()
+// Unlike GetMemory(), which does actual work, ReturnMemory() is a
+// no-op: we don't "free" memory until Reset() is called. We do
+// update some stats, though. Note we do no checking that the
+// pointer you pass in was actually allocated by us, or that it
+// was allocated for the size you say, so be careful here!
+// FreeBlocks() does the work for Reset(), actually freeing all
+// memory allocated in one fell swoop.
+// ----------------------------------------------------------------------
+
+void BaseArena::FreeBlocks() {
+ for ( int i = 1; i < blocks_alloced_; ++i ) { // keep first block alloced
+ free(first_blocks_[i].mem);
+ first_blocks_[i].mem = NULL;
+ first_blocks_[i].size = 0;
+ }
+ blocks_alloced_ = 1;
+ if (overflow_blocks_ != NULL) {
+ vector<AllocatedBlock>::iterator it;
+ for (it = overflow_blocks_->begin(); it != overflow_blocks_->end(); ++it) {
+ free(it->mem);
+ }
+ delete overflow_blocks_; // These should be used very rarely
+ overflow_blocks_ = NULL;
+ }
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::AdjustLastAlloc()
+// If you realize you didn't want your last alloc to be for
+// the size you asked, after all, you can fix it by calling
+// this. We'll grow or shrink the last-alloc region if we
+// can (we can always shrink, but we might not be able to
+// grow if you want to grow too big.
+// RETURNS true if we successfully modified the last-alloc
+// region, false if the pointer you passed in wasn't actually
+// the last alloc or if you tried to grow bigger than we could.
+// ----------------------------------------------------------------------
+
+bool BaseArena::AdjustLastAlloc(void *last_alloc, const size_t newsize) {
+ // It's only legal to call this on the last thing you alloced.
+ if (last_alloc == NULL || last_alloc != last_alloc_) return false;
+ // last_alloc_ should never point into a "big" block, w/ size >= block_size_
+ assert(freestart_ >= last_alloc_ && freestart_ <= last_alloc_ + block_size_);
+ assert(remaining_ >= 0); // should be: it's a size_t!
+ if (newsize > (freestart_ - last_alloc_) + remaining_)
+ return false; // not enough room, even after we get back last_alloc_ space
+ const char* old_freestart = freestart_; // where last alloc used to end
+ freestart_ = last_alloc_ + newsize; // where last alloc ends now
+ remaining_ -= (freestart_ - old_freestart); // how much new space we've taken
+ return true;
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::GetMemoryWithHandle()
+// First, memory is allocated using GetMemory, using handle_alignment_.
+// Since using different alignments for different handles would make
+// the handles incompatible (e.g., we could end up with the same handle
+// value referencing two different allocations, the alignment is not passed
+// as an argument to GetMemoryWithHandle, and handle_alignment_ is used
+// automatically for all GetMemoryWithHandle calls.
+// Then we go about building a handle to reference the allocated memory.
+// The block index used for the allocation, along with the offset inside
+// the block, are encoded into the handle as follows:
+// (block_index*block_size)+offset
+// offset is simply the difference between the pointer returned by
+// GetMemory and the starting pointer of the block.
+// The above value is then divided by the alignment. As we know that
+// both offset and the block_size are divisable by the alignment (this is
+// enforced by set_handle_alignment() for block_size, and by GetMemory()
+// for the offset), this does not lose any information, but allows to cram
+// more into the limited space in handle.
+// If the result does not fit into an unsigned 32-bit integer, we
+// have run out of space that the handle can represent, and return
+// an invalid handle. Note that the returned pointer is still usable,
+// but this allocation cannot be referenced by a handle.
+// ----------------------------------------------------------------------
+
+void* BaseArena::GetMemoryWithHandle(
+ const size_t size, BaseArena::Handle* handle) {
+ CHECK(handle != NULL);
+ // For efficiency, handles are always allocated aligned to a power of 2.
+ void* p = GetMemory(size, (1 << handle_alignment_bits_));
+ // Find the index of the block the memory was allocated from. In most
+ // cases, this will be the last block, so the following loop will
+ // iterate exactly once.
+ int block_index;
+ const AllocatedBlock* block = NULL;
+ for (block_index = block_count() - 1; block_index >= 0; --block_index) {
+ block = IndexToBlock(block_index);
+ if ((p >= block->mem) && (p < (block->mem + block->size))) {
+ break;
+ }
+ }
+ CHECK_GE(block_index, 0) << "Failed to find block that was allocated from";
+ CHECK(block != NULL) << "Failed to find block that was allocated from";
+ const uint64 offset = reinterpret_cast<char*>(p) - block->mem;
+ DCHECK_LT(offset, block_size_);
+ DCHECK((offset & ((1 << handle_alignment_bits_) - 1)) == 0);
+ DCHECK((block_size_ & ((1 << handle_alignment_bits_) - 1)) == 0);
+ uint64 handle_value =
+ ((static_cast<uint64>(block_index) << block_size_bits_) + offset) >>
+ handle_alignment_bits_;
+ if (handle_value >= static_cast<uint64>(0xFFFFFFFF)) {
+ // We ran out of space to be able to return a handle, so return an invalid
+ // handle.
+ handle_value = Handle::kInvalidValue;
+ }
+ handle->handle_ = static_cast<uint32>(handle_value);
+ return p;
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::set_handle_alignment()
+// Set the alignment to be used when Handles are requested. This can only
+// be set for an arena that is empty - it cannot be changed on the fly.
+// The alignment must be a power of 2 that the block size is divisable by.
+// The default alignment is 1.
+// Trying to set an alignment that does not meet the above constraints will
+// cause a CHECK-failure.
+// ----------------------------------------------------------------------
+
+void BaseArena::set_handle_alignment(int align) {
+ CHECK(align > 0 && 0 == (align & (align - 1))); // must be power of 2
+ CHECK(static_cast<size_t>(align) < block_size_);
+ CHECK((block_size_ % align) == 0);
+ CHECK(is_empty());
+ handle_alignment_ = align;
+ handle_alignment_bits_ = 0;
+ while ((1 << handle_alignment_bits_) < handle_alignment_) {
+ ++handle_alignment_bits_;
+ }
+}
+
+// ----------------------------------------------------------------------
+// BaseArena::HandleToPointer()
+// First, the handle value needs to gain back the alignment factor that
+// was divided out of it by GetMemoryWithHandle. Once this is done, it
+// becomes trivial to extract the block index and offset in the block out
+// of it, and calculate the pointer.
+// ----------------------------------------------------------------------
+
+void* BaseArena::HandleToPointer(const Handle& h) const {
+ CHECK(h.valid());
+ uint64 handle = static_cast<uint64>(h.handle_) << handle_alignment_bits_;
+ int block_index = static_cast<int>(handle >> block_size_bits_);
+ size_t block_offset =
+ static_cast<size_t>(handle & ((1 << block_size_bits_) - 1));
+ const AllocatedBlock* block = IndexToBlock(block_index);
+ CHECK(block != NULL);
+ return reinterpret_cast<void*>(block->mem + block_offset);
+}
+
+
+// ----------------------------------------------------------------------
+// UnsafeArena::Realloc()
+// SafeArena::Realloc()
+// If you decide you want to grow -- or shrink -- a memory region,
+// we'll do it for you here. Typically this will involve copying
+// the existing memory to somewhere else on the arena that has
+// more space reserved. But if you're reallocing the last-allocated
+// block, we may be able to accomodate you just by updating a
+// pointer. In any case, we return a pointer to the new memory
+// location, which may be the same as the pointer you passed in.
+// Here's an example of how you might use Realloc():
+//
+// compr_buf = arena->Alloc(uncompr_size); // get too-much space
+// int compr_size;
+// zlib.Compress(uncompr_buf, uncompr_size, compr_buf, &compr_size);
+// compr_buf = arena->Realloc(compr_buf, uncompr_size, compr_size);
+// ----------------------------------------------------------------------
+
+char* UnsafeArena::Realloc(char* s, size_t oldsize, size_t newsize) {
+ assert(oldsize >= 0 && newsize >= 0);
+ if ( AdjustLastAlloc(s, newsize) ) // in case s was last alloc
+ return s;
+ if ( newsize <= oldsize ) {
+ return s; // no need to do anything; we're ain't reclaiming any memory!
+ }
+ char * newstr = Alloc(newsize);
+ memcpy(newstr, s, min(oldsize, newsize));
+ return newstr;
+}
+
+char* SafeArena::Realloc(char* s, size_t oldsize, size_t newsize) {
+ assert(oldsize >= 0 && newsize >= 0);
+ { MutexLock lock(&mutex_);
+ if ( AdjustLastAlloc(s, newsize) ) // in case s was last alloc
+ return s;
+ }
+ if ( newsize <= oldsize ) {
+ return s; // no need to do anything; we're ain't reclaiming any memory!
+ }
+ char * newstr = Alloc(newsize);
+ memcpy(newstr, s, min(oldsize, newsize));
+ return newstr;
+}
+
+}
diff --git a/src/base/arena.h b/src/base/arena.h
new file mode 100644
index 0000000..049a6b5
--- /dev/null
+++ b/src/base/arena.h
@@ -0,0 +1,698 @@
+// Copyright (c) 2000, Google Inc.
+// 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 Google Inc. 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.
+// ---
+//
+// Reorganized by Craig Silverstein
+// "Handles" by Ilan Horn
+//
+// Sometimes it is necessary to allocate a large number of small
+// objects. Doing this the usual way (malloc, new) is slow,
+// especially for multithreaded programs. A BaseArena provides a
+// mark/release method of memory management: it asks for a large chunk
+// from the operating system and doles it out bit by bit as required.
+// Then you free all the memory at once by calling BaseArena::Reset().
+//
+// Use SafeArena for multi-threaded programs where multiple threads
+// could access the same arena at once. Use UnsafeArena otherwise.
+// Usually you'll want UnsafeArena.
+//
+// There are four ways to use the arena. arena.h and arena.cc are
+// sufficient for the MALLOC and STRINGS uses. For NEW and STL you'll
+// also need to include arena-inl.h in the appropriate .cc file.
+// However, we do *declare* (but not define) the template types here.
+//
+// LIKE MALLOC: --Uses UnsafeArena (or SafeArena)--
+// This is the simplest way. Just create an arena, and whenever you
+// need a block of memory to put something in, call BaseArena::Alloc(). eg
+// s = arena.Alloc(100);
+// snprintf(s, 100, "%s:%d", host, port);
+// arena.Shrink(strlen(s)+1); // optional; see below for use
+//
+// You'll probably use the convenience routines more often:
+// s = arena.Strdup(host); // a copy of host lives in the arena
+// s = arena.Strndup(host, 100); // we guarantee to NUL-terminate!
+// s = arena.Memdup(protobuf, sizeof(protobuf);
+//
+// If you go the Alloc() route, you'll probably allocate too-much-space.
+// You can reclaim the extra space by calling Shrink() before the next
+// Alloc() (or Strdup(), or whatever), with the #bytes you actually used.
+// If you use this method, memory management is easy: just call Alloc()
+// and friends a lot, and call Reset() when you're done with the data.
+//
+// FOR STRINGS: --Uses UnsafeArena (or SafeArena)--
+// This is a special case of STL (below), but is simpler. Use an
+// astring, which acts like a string but allocates from the passed-in
+// arena:
+// astring s(arena); // or "sastring" to use a SafeArena
+// s.assign(host);
+// astring s2(host, hostlen, arena);
+//
+// WITH NEW: --Uses BaseArena, Gladiator (or ArenaOnlyGladiator)--
+// Use this to allocate a C++ class object (or any other object you
+// have to get via new/delete rather than malloc/free).
+// There are several things you have to do in this case:
+// 1) Your class (the one you new) must inherit from Gladiator.
+// 2) To actually allocate this class on the arena, use
+// myclass = new (AllocateInArena, arena) MyClass(constructor, args)
+//
+// Note that MyClass doesn't need to have the arena passed in.
+// But if it, in turn, wants to call "new" on some of its member
+// variables, and you want those member vars to be on the arena
+// too, you better pass in an arena so it can call new(0,arena).
+//
+// If you can guarantee that everyone who ever calls new on
+// MyClass uses the new(0,arena) form (ie nobody ever just says
+// new), you can have MyClass subclass from ArenaOnlyGladiator
+// rather than from Gladiator. ArenaOnlyGladiator is a bit more
+// efficient (faster and smaller), but is otherwise identical.
+//
+// If you allocate myclass using new(0,arena), and MyClass only
+// does memory management in the destructor, it's not necessary
+// to even call "delete myclass;", you can just call arena.Reset();
+// If the destructor does something else (closes a file, logs
+// a message, whatever), you'll have to call destructor and Reset()
+// both: "delete myclass; arena.Reset();"
+//
+// Note that you can not allocate an array of classes this way:
+// noway = new (AllocateInArena, arena) MyClass[5]; // not supported!
+// It's not difficult to program, we just haven't done it. Arrays
+// are typically big and so there's little point to arena-izing them.
+//
+// WITH NEW: --Uses UnsafeArena--
+// There are cases where you can't inherit the class from Gladiator,
+// or inheriting would be too expensive. Examples of this include
+// plain-old-data (allocated using new) and third-party classes (such
+// as STL containers). arena-inl.h provides a global operator new
+// that can be used as follows:
+//
+// #include "base/arena-inl.h"
+//
+// UnsafeArena arena(1000);
+// Foo* foo = new (AllocateInArena, &arena) Foo;
+// Foo* foo_array = new (AllocateInArena, &arena) Foo[10];
+//
+// IN STL: --Uses BaseArena, ArenaAllocator--
+// All STL containers (vector, hash_map, etc) take an allocator.
+// You can use the arena as an allocator. Then whenever the vector
+// (or whatever) wants to allocate memory, it will take it from the
+// arena. To use, you just indicate in the type that you want to use the
+// arena, and then actually give a pointer to the arena as the last
+// constructor arg:
+// vector<int, ArenaAllocator<int, UnsafeArena> > v(&arena);
+// v.push_back(3);
+//
+// WARNING: Careless use of STL within an arena-allocated object can
+// result in memory leaks if you rely on arena.Reset() to free
+// memory and do not call the object destructor. This is actually
+// a subclass of a more general hazard: If an arena-allocated
+// object creates (and owns) objects that are not also
+// arena-allocated, then the creating object must have a
+// destructor that deletes them, or they will not be deleted.
+// However, since the outer object is arena allocated, it's easy to
+// forget to call delete on it, and needing to do so may seem to
+// negate much of the benefit of arena allocation. A specific
+// example is use of vector<string> in an arena-allocated object,
+// since type string is not atomic and is always allocated by the
+// default runtime allocator. The arena definition provided here
+// allows for much flexibility, but you ought to carefully consider
+// before defining arena-allocated objects which in turn create
+// non-arena allocated objects.
+//
+// WITH HANDLES:
+// The various arena classes can supply compact handles to data kept
+// in the arena. These handles consume only 4 bytes each, and are thus
+// more efficient than pointers - this may be interesting in cases
+// where a very large number of references to memory in the arena need
+// to be kept.
+// Note that handles are limited in the amount of data that can be reference
+// in the arena, typically to 4GB*the number given to set_handle_alignment()
+// (which defaults to 1). The number of allocations that can have handles
+// is, of course, smaller than 4G (that's what's representable by 32 bits).
+// It does depend on their sizes, however. In a worst-case scenario each
+// allocation consumes a page of its own, and we will run out of handles
+// after approximately (4G/block_size)*handle_alignment allocations.
+// When we run out of handles or allocate data over the amount of memory
+// that handles can reference, an invalid handle will be returned (but
+// the requested memory will still be allocated in the arena).
+// Handles memory use is most efficient when the arena block size is a power
+// of two. When this is not the case, we can run out of handles when at
+// most half of the addressable space (as described above) is not in use.
+// At worst handles can reference at least 2GB*handle_alignment.
+// Example use:
+// UnsafeArena arena(16384);
+// arena.set_handle_alignment(4);
+// // Assume you want to keep the string s in the arena.
+// Handle h = arena.MemdupWithHandle(s.c_str(), s.length());
+// // Later, to get the memory from the handle, use:
+// void* p = arena.HandleToPointer(h);
+// // Note that there's no way to retrieve the size from the handle.
+// // It probably makes sense to encode the size into the buffer saved,
+// // unless the size is known/fixed.
+// Internal machinery of handles:
+// The handle consists of the block index in the arena and the offset
+// inside the block, encoded into a single unsigned uint32 value.
+// Note that, the rightmost alignment bits (controlled by
+// set_handle_alignment()) are shaved off the saved offset in the Handle,
+// to give some extra capacity :)
+// set_handle_alignment() can only be called when the arena is empty,
+// as changing it invalidates any handles that are still in flight.
+//
+//
+// PUTTING IT ALL TOGETHER
+// Here's a program that uses all of the above. Note almost all the
+// examples are the various ways to use "new" and STL. Using the
+// malloc-like features and the string type are much easier!
+//
+// Class A : public Gladiator {
+// public:
+// int i;
+// vector<int> v1;
+// vector<int, ArenaAllocator<int, UnsafeArena> >* v3;
+// vector<int, ArenaAllocator<int, UnsafeArena> >* v4;
+// vector<int>* v5;
+// vector<string> vs;
+// vector<astring> va;
+// char *s;
+// A() : v1(), v3(NULL), v4(NULL), vs(), va(), s(NULL) {
+// // v1 is allocated on the arena whenever A is. Its ints never are.
+// v5 = new vector<int>;
+// // v5 is not allocated on the arena, and neither are any of its ints.
+// }
+// ~A() {
+// delete v5; // needed since v5 wasn't allocated on the arena
+// printf("I'm done!\n");
+// }
+// };
+//
+// class B : public A { // we inherit from Gladiator, but indirectly
+// public:
+// UnsafeArena* arena_;
+// vector<int, ArenaAllocator<int, UnsafeArena> > v2;
+// vector<A> va1;
+// vector<A, ArenaAllocator<A, UnsafeArena> > va2;
+// vector<A>* pva;
+// vector<A, ArenaAllocator<A, UnsafeArena> >* pva2;
+// astring a;
+//
+// B(UnsafeArena * arena)
+// : arena_(arena), v2(arena_), va1(), va2(arena_), a("initval", arena_) {
+// v3 = new vector<int, ArenaAllocator<int, UnsafeArena> >(arena_);
+// v4 = new (AllocateInArena, arena_) vector<int, ArenaAllocator<int, UnsafeArena> >(arena_);
+// v5 = new (AllocateInArena, arena_) vector<int>;
+// // v2 is allocated on the arena whenever B is. Its ints always are.
+// // v3 is not allocated on the arena, but the ints you give it are
+// // v4 is allocated on the arena, and so are the ints you give it
+// // v5 is allocated on the arena, but the ints you give it are not
+// // va1 is allocated on the arena whenever B is. No A ever is.
+// // va2 is allocated on the arena whenever B is. Its A's always are.
+// pva = new (AllocateInArena, arena_) vector<A>;
+// pva2 = new (AllocateInArena, arena_) vector<A, ArenaAllocator<A, UnsafeArena> >(arena_);
+// // pva is allocated on the arena, but its A's are not
+// // pva2 is allocated on the arena, and so are its A's.
+// // a's value "initval" is stored on the arena. If we reassign a,
+// // the new value will be stored on the arena too.
+// }
+// ~B() {
+// delete v3; // necessary to free v3's memory, though not its ints'
+// // don't need to delete v4: arena_.Reset() will do as good
+// delete v5; // necessary to free v5's ints memory, though not v5 itself
+// delete pva; // necessary to make sure you reclaim space used by A's
+// delete pva2; // safe to call this; needed if you want to see the printfs
+// // pva2->clear() -- not necessary, arena_.Reset() will do just as good
+// }
+// };
+//
+// main() {
+// UnsafeArena arena(1000);
+// A a1; // a1 is not on the arena
+// a1.vs.push_back(string("hello")); // hello is not copied onto the arena
+// a1.va.push_back(astring("hello", &arena)); // hello is on the arena,
+// // astring container isn't
+// a1.s = arena.Strdup("hello"); // hello is on the arena
+//
+// A* a2 = new (AllocateInArena, arena) A; // a2 is on the arena
+// a2.vs.push_back(string("hello")); // hello is *still* not on the arena
+// a2.s = arena.Strdup("world"); // world is on the arena. a1.s is ok
+//
+// B b1(&arena); // B is not allocated on the arena
+// b1.a.assign("hello"); // hello is on the arena
+// b1.pva2.push_back(a1); // our copy of a1 will be stored on
+// // the arena, though a1 itself wasn't
+// arena.Reset(); // all done with our memory!
+// }
+
+#ifndef BASE_ARENA_H_
+#define BASE_ARENA_H_
+
+#include <config.h>
+#include "base/mutex.h" // must go first to get _XOPEN_SOURCE
+#include <assert.h>
+#include <string.h>
+#include <vector>
+#include "base/thread_annotations.h"
+#include "base/macros.h" // for uint32
+#include "base/util.h" // for CHECK, etc
+
+namespace ctemplate {
+
+// Annoying stuff for windows -- make sure clients (in this case
+// unittests) can import the class definitions and variables.
+#ifndef CTEMPLATE_DLL_DECL
+# ifdef _MSC_VER
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+# else
+# define CTEMPLATE_DLL_DECL /* should be the empty string for non-windows */
+# endif
+#endif
+
+// This class is "thread-compatible": different threads can access the
+// arena at the same time without locking, as long as they use only
+// const methods.
+class CTEMPLATE_DLL_DECL BaseArena {
+ protected: // You can't make an arena directly; only a subclass of one
+ BaseArena(char* first_block, const size_t block_size, bool align_to_page);
+ public:
+ virtual ~BaseArena();
+
+ virtual void Reset();
+
+ // A handle to a pointer in an arena. An opaque type, with default
+ // copy and assignment semantics.
+ class Handle {
+ public:
+ static const uint32 kInvalidValue = 0xFFFFFFFF; // int32-max
+
+ Handle() : handle_(kInvalidValue) { }
+ // Default copy constructors are fine here.
+ bool operator==(const Handle& h) const { return handle_ == h.handle_; }
+ bool operator!=(const Handle& h) const { return handle_ != h.handle_; }
+
+ uint32 hash() const { return handle_; }
+ bool valid() const { return handle_ != kInvalidValue; }
+
+ private:
+ // Arena needs to be able to access the internal data.
+ friend class BaseArena;
+
+ explicit Handle(uint32 handle) : handle_(handle) { }
+
+ uint32 handle_;
+ };
+
+ // they're "slow" only 'cause they're virtual (subclasses define "fast" ones)
+ virtual char* SlowAlloc(size_t size) = 0;
+ virtual void SlowFree(void* memory, size_t size) = 0;
+ virtual char* SlowRealloc(char* memory, size_t old_size, size_t new_size) = 0;
+ virtual char* SlowAllocWithHandle(const size_t size, Handle* handle) = 0;
+
+ // Set the alignment to be used when Handles are requested. This can only
+ // be set for an arena that is empty - it cannot be changed on the fly.
+ // The alignment must be a power of 2 that the block size is divisable by.
+ // The default alignment is 1.
+ // Trying to set an alignment that does not meet the above constraints will
+ // cause a CHECK-failure.
+ void set_handle_alignment(int align);
+
+ // Retrieve the memory pointer that the supplied handle refers to.
+ // Calling this with an invalid handle will CHECK-fail.
+ void* HandleToPointer(const Handle& h) const;
+
+
+ class Status {
+ private:
+ friend class BaseArena;
+ size_t bytes_allocated_;
+ public:
+ Status() : bytes_allocated_(0) { }
+ size_t bytes_allocated() const {
+ return bytes_allocated_;
+ }
+ };
+
+ // Accessors and stats counters
+ // This accessor isn't so useful here, but is included so we can be
+ // type-compatible with ArenaAllocator (in arena-inl.h). That is,
+ // we define arena() because ArenaAllocator does, and that way you
+ // can template on either of these and know it's safe to call arena().
+ virtual BaseArena* arena() { return this; }
+ size_t block_size() const { return block_size_; }
+ int block_count() const;
+ bool is_empty() const {
+ // must check block count in case we allocated a block larger than blksize
+ return freestart_ == freestart_when_empty_ && 1 == block_count();
+ }
+
+ // This should be the worst-case alignment for any type. This is
+ // good for IA-32, SPARC version 7 (the last one I know), and
+ // supposedly Alpha. i386 would be more time-efficient with a
+ // default alignment of 8, but ::operator new() uses alignment of 4,
+ // and an assertion will fail below after the call to MakeNewBlock()
+ // if you try to use a larger alignment.
+#ifdef __i386__
+ static const int kDefaultAlignment = 4;
+#else
+ static const int kDefaultAlignment = 8;
+#endif
+
+ protected:
+ void MakeNewBlock();
+ void* GetMemoryFallback(const size_t size, const int align);
+ void* GetMemory(const size_t size, const int align) {
+ assert(remaining_ <= block_size_); // an invariant
+ if ( size > 0 && size < remaining_ && align == 1 ) { // common case
+ last_alloc_ = freestart_;
+ freestart_ += size;
+ remaining_ -= size;
+ return reinterpret_cast<void*>(last_alloc_);
+ }
+ return GetMemoryFallback(size, align);
+ }
+
+ // This doesn't actually free any memory except for the last piece allocated
+ void ReturnMemory(void* memory, const size_t size) {
+ if ( memory == last_alloc_ && size == freestart_ - last_alloc_ ) {
+ remaining_ += size;
+ freestart_ = last_alloc_;
+ }
+ }
+
+ // This is used by Realloc() -- usually we Realloc just by copying to a
+ // bigger space, but for the last alloc we can realloc by growing the region.
+ bool AdjustLastAlloc(void* last_alloc, const size_t newsize);
+
+ // Since using different alignments for different handles would make
+ // the handles incompatible (e.g., we could end up with the same handle
+ // value referencing two different allocations, the alignment is not passed
+ // as an argument to GetMemoryWithHandle, and handle_alignment_ is used
+ // automatically for all GetMemoryWithHandle calls.
+ void* GetMemoryWithHandle(const size_t size, Handle* handle);
+
+ Status status_;
+ size_t remaining_;
+
+ private:
+ struct AllocatedBlock {
+ char *mem;
+ size_t size;
+ };
+
+ // The returned AllocatedBlock* is valid until the next call to AllocNewBlock
+ // or Reset (i.e. anything that might affect overflow_blocks_).
+ AllocatedBlock *AllocNewBlock(const size_t block_size);
+
+ const AllocatedBlock *IndexToBlock(int index) const;
+
+ const int first_block_we_own_; // 1 if they pass in 1st block, 0 else
+ const size_t block_size_;
+ char* freestart_; // beginning of the free space in most recent block
+ char* freestart_when_empty_; // beginning of the free space when we're empty
+ char* last_alloc_; // used to make sure ReturnBytes() is safe
+ // STL vector isn't as efficient as it could be, so we use an array at first
+ int blocks_alloced_; // how many of the first_blocks_ have been alloced
+ AllocatedBlock first_blocks_[16]; // the length of this array is arbitrary
+ // if the first_blocks_ aren't enough, expand into overflow_blocks_.
+ std::vector<AllocatedBlock>* overflow_blocks_;
+ const bool page_aligned_; // when true, all blocks need to be page aligned
+ int handle_alignment_; // Alignment to be used when Handles are requested.
+ int handle_alignment_bits_; // log2(handle_alignment_).
+ // The amount of bits required to keep block_size_ (ceil(log2(block_size_))).
+ size_t block_size_bits_;
+
+ void FreeBlocks(); // Frees all except first block
+
+ // This subclass needs to alter permissions for all allocated blocks.
+ friend class ProtectableUnsafeArena;
+
+ DISALLOW_COPY_AND_ASSIGN(BaseArena);
+};
+
+class CTEMPLATE_DLL_DECL UnsafeArena : public BaseArena {
+ public:
+ // Allocates a thread-compatible arena with the specified block size.
+ explicit UnsafeArena(const size_t block_size)
+ : BaseArena(NULL, block_size, false) { }
+ UnsafeArena(const size_t block_size, bool align)
+ : BaseArena(NULL, block_size, align) { }
+
+ // Allocates a thread-compatible arena with the specified block
+ // size. "first_block" must have size "block_size". Memory is
+ // allocated from "first_block" until it is exhausted; after that
+ // memory is allocated by allocating new blocks from the heap.
+ UnsafeArena(char* first_block, const size_t block_size)
+ : BaseArena(first_block, block_size, false) { }
+ UnsafeArena(char* first_block, const size_t block_size, bool align)
+ : BaseArena(first_block, block_size, align) { }
+
+ char* Alloc(const size_t size) {
+ return reinterpret_cast<char*>(GetMemory(size, 1));
+ }
+ void* AllocAligned(const size_t size, const int align) {
+ return GetMemory(size, align);
+ }
+ char* Calloc(const size_t size) {
+ void* return_value = Alloc(size);
+ memset(return_value, 0, size);
+ return reinterpret_cast<char*>(return_value);
+ }
+ void* CallocAligned(const size_t size, const int align) {
+ void* return_value = AllocAligned(size, align);
+ memset(return_value, 0, size);
+ return return_value;
+ }
+ // Free does nothing except for the last piece allocated.
+ void Free(void* memory, size_t size) {
+ ReturnMemory(memory, size);
+ }
+ typedef BaseArena::Handle Handle;
+ char* AllocWithHandle(const size_t size, Handle* handle) {
+ return reinterpret_cast<char*>(GetMemoryWithHandle(size, handle));
+ }
+ virtual char* SlowAlloc(size_t size) { // "slow" 'cause it's virtual
+ return Alloc(size);
+ }
+ virtual void SlowFree(void* memory, size_t size) { // "slow" 'cause it's virt
+ Free(memory, size);
+ }
+ virtual char* SlowRealloc(char* memory, size_t old_size, size_t new_size) {
+ return Realloc(memory, old_size, new_size);
+ }
+ virtual char* SlowAllocWithHandle(const size_t size, Handle* handle) {
+ return AllocWithHandle(size, handle);
+ }
+
+ char* Memdup(const char* s, size_t bytes) {
+ char* newstr = Alloc(bytes);
+ memcpy(newstr, s, bytes);
+ return newstr;
+ }
+ char* MemdupPlusNUL(const char* s, size_t bytes) { // like "string(s, len)"
+ char* newstr = Alloc(bytes+1);
+ memcpy(newstr, s, bytes);
+ newstr[bytes] = '\0';
+ return newstr;
+ }
+ Handle MemdupWithHandle(const char* s, size_t bytes) {
+ Handle handle;
+ char* newstr = AllocWithHandle(bytes, &handle);
+ memcpy(newstr, s, bytes);
+ return handle;
+ }
+ char* Strdup(const char* s) {
+ return Memdup(s, strlen(s) + 1);
+ }
+ // Unlike libc's strncpy, I always NUL-terminate. libc's semantics are dumb.
+ // This will allocate at most n+1 bytes (+1 is for the NULL terminator).
+ char* Strndup(const char* s, size_t n) {
+ // Use memchr so we don't walk past n.
+ // We can't use the one in //strings since this is the base library,
+ // so we have to reinterpret_cast from the libc void *.
+ const char* eos = reinterpret_cast<const char*>(memchr(s, '\0', n));
+ // if no null terminator found, use full n
+ const size_t bytes = (eos == NULL) ? n + 1 : eos - s + 1;
+ char* ret = Memdup(s, bytes);
+ ret[bytes-1] = '\0'; // make sure the string is NUL-terminated
+ return ret;
+ }
+
+ // You can realloc a previously-allocated string either bigger or smaller.
+ // We can be more efficient if you realloc a string right after you allocate
+ // it (eg allocate way-too-much space, fill it, realloc to just-big-enough)
+ char* Realloc(char* s, size_t oldsize, size_t newsize);
+ // If you know the new size is smaller (or equal), you don't need to know
+ // oldsize. We don't check that newsize is smaller, so you'd better be sure!
+ char* Shrink(char* s, size_t newsize) {
+ AdjustLastAlloc(s, newsize); // reclaim space if we can
+ return s; // never need to move if we go smaller
+ }
+
+ // We make a copy so you can keep track of status at a given point in time
+ Status status() const { return status_; }
+
+ // Number of bytes remaining before the arena has to allocate another block.
+ size_t bytes_until_next_allocation() const { return remaining_; }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(UnsafeArena);
+};
+
+
+
+// we inherit from BaseArena instead of UnsafeArena so that we don't need
+// virtual methods for allocation/deallocation. This means, however,
+// I have to copy the definitions of strdup, strndup, etc. :-(
+
+class CTEMPLATE_DLL_DECL SafeArena : public BaseArena {
+ public:
+ // Allocates a thread-safe arena with the specified block size.
+ explicit SafeArena(const size_t block_size)
+ : BaseArena(NULL, block_size, false) { }
+
+ // Allocates a thread-safe arena with the specified block size.
+ // "first_block" must have size "block_size". Memory is allocated
+ // from "first_block" until it is exhausted; after that memory is
+ // allocated by allocating new blocks from the heap.
+ SafeArena(char* first_block, const size_t block_size)
+ : BaseArena(first_block, block_size, false) { }
+
+ virtual void Reset() LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_); // in case two threads Reset() at same time
+ BaseArena::Reset();
+ }
+
+ char* Alloc(const size_t size) LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_);
+ return reinterpret_cast<char*>(GetMemory(size, 1));
+ }
+ void* AllocAligned(const size_t size, const int align)
+ LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_);
+ return GetMemory(size, align);
+ }
+ char* Calloc(const size_t size) {
+ void* return_value = Alloc(size);
+ memset(return_value, 0, size);
+ return reinterpret_cast<char*>(return_value);
+ }
+ void* CallocAligned(const size_t size, const int align) {
+ void* return_value = AllocAligned(size, align);
+ memset(return_value, 0, size);
+ return return_value;
+ }
+ // Free does nothing except for the last piece allocated.
+ void Free(void* memory, size_t size) LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_);
+ ReturnMemory(memory, size);
+ }
+ typedef BaseArena::Handle Handle;
+ char* AllocWithHandle(const size_t size, Handle* handle)
+ LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_);
+ return reinterpret_cast<char*>(GetMemoryWithHandle(size, handle));
+ }
+ virtual char* SlowAlloc(size_t size) { // "slow" 'cause it's virtual
+ return Alloc(size);
+ }
+ virtual void SlowFree(void* memory, size_t size) { // "slow" 'cause it's virt
+ Free(memory, size);
+ }
+ virtual char* SlowRealloc(char* memory, size_t old_size, size_t new_size) {
+ return Realloc(memory, old_size, new_size);
+ }
+ virtual char* SlowAllocWithHandle(const size_t size, Handle* handle) {
+ return AllocWithHandle(size, handle);
+ }
+
+ char* Memdup(const char* s, size_t bytes) {
+ char* newstr = Alloc(bytes);
+ memcpy(newstr, s, bytes);
+ return newstr;
+ }
+ char* MemdupPlusNUL(const char* s, size_t bytes) { // like "string(s, len)"
+ char* newstr = Alloc(bytes+1);
+ memcpy(newstr, s, bytes);
+ newstr[bytes] = '\0';
+ return newstr;
+ }
+ Handle MemdupWithHandle(const char* s, size_t bytes) {
+ Handle handle;
+ char* newstr = AllocWithHandle(bytes, &handle);
+ memcpy(newstr, s, bytes);
+ return handle;
+ }
+ char* Strdup(const char* s) {
+ return Memdup(s, strlen(s) + 1);
+ }
+ // Unlike libc's strncpy, I always NUL-terminate. libc's semantics are dumb.
+ // This will allocate at most n+1 bytes (+1 is for the NULL terminator).
+ char* Strndup(const char* s, size_t n) {
+ // Use memchr so we don't walk past n.
+ // We can't use the one in //strings since this is the base library,
+ // so we have to reinterpret_cast from the libc void *.
+ const char* eos = reinterpret_cast<const char*>(memchr(s, '\0', n));
+ // if no null terminator found, use full n
+ const size_t bytes = (eos == NULL) ? n + 1 : eos - s + 1;
+ char* ret = Memdup(s, bytes);
+ ret[bytes-1] = '\0'; // make sure the string is NUL-terminated
+ return ret;
+ }
+
+ // You can realloc a previously-allocated string either bigger or smaller.
+ // We can be more efficient if you realloc a string right after you allocate
+ // it (eg allocate way-too-much space, fill it, realloc to just-big-enough)
+ char* Realloc(char* s, size_t oldsize, size_t newsize)
+ LOCKS_EXCLUDED(mutex_);
+ // If you know the new size is smaller (or equal), you don't need to know
+ // oldsize. We don't check that newsize is smaller, so you'd better be sure!
+ char* Shrink(char* s, size_t newsize) LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_);
+ AdjustLastAlloc(s, newsize); // reclaim space if we can
+ return s; // we never need to move if we go smaller
+ }
+
+ Status status() LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_);
+ return status_;
+ }
+
+ // Number of bytes remaining before the arena has to allocate another block.
+ size_t bytes_until_next_allocation() LOCKS_EXCLUDED(mutex_) {
+ MutexLock lock(&mutex_);
+ return remaining_;
+ }
+
+ protected:
+ Mutex mutex_;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(SafeArena);
+};
+
+}
+
+#endif // BASE_ARENA_H_
diff --git a/src/base/fileutil.h b/src/base/fileutil.h
new file mode 100644
index 0000000..4a207bb
--- /dev/null
+++ b/src/base/fileutil.h
@@ -0,0 +1,106 @@
+// Copyright (c) 2011, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// A tiny wrapper around struct stat and FILE*.
+
+#ifndef TEMPLATE_OPENSOURCE_FILEUTIL_H_
+#define TEMPLATE_OPENSOURCE_FILEUTIL_H_
+
+#include <config.h>
+#include <stdio.h>
+#include <sys/stat.h>
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <string>
+
+namespace ctemplate {
+
+class FileStat {
+ public:
+ time_t mtime;
+ off_t length;
+ bool IsDirectory() { return S_ISDIR(internal_statbuf.st_mode); }
+
+ private:
+ friend class File;
+ struct stat internal_statbuf;
+};
+
+class File {
+ public:
+ static bool Stat(const std::string& filename, FileStat* statbuf) {
+ if (stat(filename.c_str(), &statbuf->internal_statbuf) != 0)
+ return false;
+ statbuf->mtime = statbuf->internal_statbuf.st_mtime;
+ statbuf->length = statbuf->internal_statbuf.st_size;
+ return true;
+ }
+
+ static bool Readable(const char* filename) {
+ return access(filename, R_OK) == 0;
+ }
+
+ static File* Open(const char* filename, const char* mode) {
+ char binary_mode[3];
+ const char* mode_to_use = mode;
+ if ((mode[0] == 'r' || mode[0] == 'w') && mode[1] == '\0') {
+ // We add a 'b' to make sure we do the right thing even on
+ // Windows. On unix, this will be a noop.
+ binary_mode[0] = mode[0];
+ binary_mode[1] = 'b';
+ binary_mode[2] = '\0';
+ mode_to_use = binary_mode;
+ }
+ FILE* fp = fopen(filename, mode_to_use);
+ if (!fp) return NULL;
+ return new File(fp);
+ }
+
+ size_t Read(char* buf, size_t size) {
+ return fread(buf, 1, size, fp_);
+ }
+
+ void Close() {
+ fclose(fp_);
+ delete this; // naughty naughty!
+ }
+
+ private:
+ explicit File(FILE* fp) : fp_(fp) { }
+ FILE* fp_;
+};
+
+}
+
+#endif // TEMPLATE_OPENSOURCE_FILEUTIL_H_
diff --git a/src/base/macros.h b/src/base/macros.h
new file mode 100644
index 0000000..9d0327c
--- /dev/null
+++ b/src/base/macros.h
@@ -0,0 +1,114 @@
+// Copyright 2011 Google Inc. All Rights Reserved.
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// Provides macros and typedefs based on config.h settings.
+// Provides the following macros:
+// UNALIGNED_LOAD32 (may be an inline function on some architectures)
+// and the following typedefs:
+// uint32
+// uint64
+
+#ifndef CTEMPLATE_MACROS_H_
+#define CTEMPLATE_MACROS_H_
+
+#include <config.h>
+#ifdef HAVE_STDINT_H
+#include <stdint.h> // the normal place uint32_t is defined
+#endif
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h> // the normal place u_int32_t is defined
+#endif
+#ifdef HAVE_INTTYPES_H
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif // a third place for uint32_t or u_int32_t
+#endif
+
+#if defined(HAVE_U_INT32_T)
+typedef u_int32_t uint32;
+#elif defined(HAVE_UINT32_T)
+typedef uint32_t uint32;
+#elif defined(HAVE___INT32)
+typedef unsigned __int32 uint32;
+#endif
+
+#if defined(HAVE_U_INT64_T)
+typedef u_int64_t uint64;
+#elif defined(HAVE_UINT64_T)
+typedef uint64_t uint64;
+#elif defined(HAVE___INT64)
+typedef unsigned __int64 uint64;
+#endif
+
+
+// This is all to figure out endian-ness and byte-swapping on various systems
+#if defined(HAVE_ENDIAN_H)
+#include <endian.h> // for the __BYTE_ORDER use below
+#elif defined(HAVE_SYS_ENDIAN_H)
+#include <sys/endian.h> // location on FreeBSD
+#elif defined(HAVE_MACHINE_ENDIAN_H)
+#include <machine/endian.h> // location on OS X
+#endif
+#if defined(HAVE_SYS_BYTEORDER_H)
+#include <sys/byteorder.h> // BSWAP_32 on Solaris 10
+#endif
+#ifdef HAVE_SYS_ISA_DEFS_H
+#include <sys/isa_defs.h> // _BIG_ENDIAN/_LITTLE_ENDIAN on Solaris 10
+#endif
+
+// MurmurHash does a lot of 4-byte unaligned integer access. It
+// interprets these integers in little-endian order. This is perfect
+// on x86, for which this is a natural memory access; for other systems
+// we do what we can to make this as efficient as possible.
+#if defined(HAVE_BYTESWAP_H)
+# include <byteswap.h> // GNU (especially linux)
+# define BSWAP32(x) bswap_32(x)
+#elif defined(HAVE_LIBKERN_OSBYTEORDER_H)
+# include <libkern/OSByteOrder.h> // OS X
+# define BSWAP32(x) OSSwapInt32(x)
+#elif defined(bswap32) // FreeBSD
+ // FreeBSD defines bswap32 as a macro in sys/endian.h (already #included)
+# define BSWAP32(x) bswap32(x)
+#elif defined(BSWAP_32) // Solaris 10
+ // Solaris defines BSWSAP_32 as a macro in sys/byteorder.h (already #included)
+# define BSWAP32(x) BSWAP_32(x)
+#elif !defined(BSWAP32)
+# define BSWAP32(x) ((((x) & 0x000000ff) << 24) | \
+ (((x) & 0x0000ff00) << 8) | \
+ (((x) & 0x00ff0000) >> 8) | \
+ (((x) & 0xff000000) >> 24));
+#else
+# define CTEMPLATE_BSWAP32_ALREADY_DEFINED
+#endif
+
+#if defined(__i386__) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
+ // We know they allow unaligned memory access and are little-endian
+# define UNALIGNED_LOAD32(_p) (*reinterpret_cast<const uint32 *>(_p))
+#elif defined(__ppc__) || defined(__ppc64__)
+ // We know they allow unaligned memory access and are big-endian
+# define UNALIGNED_LOAD32(_p) BSWAP32(*reinterpret_cast<const uint32 *>(_p))
+#elif (BYTE_ORDER == 1234) || (_BYTE_ORDER == 1234) || defined(_LITTLE_ENDIAN)
+ // Use memcpy to align the memory properly
+ inline uint32 UNALIGNED_LOAD32(const void *p) {
+ uint32 t;
+ memcpy(&t, p, sizeof(t));
+ return t;
+ }
+#elif (BYTE_ORDER == 4321) || (_BYTE_ORDER == 4321) || defined(_BIG_ENDIAN)
+ inline uint32 UNALIGNED_LOAD32(const void *p) {
+ uint32 t;
+ memcpy(&t, p, sizeof(t));
+ return BSWAP32(t);
+ }
+#else
+ // Means we can't find find endian.h on this machine:
+# error Need to define UNALIGNED_LOAD32 for this architecture
+#endif
+
+#ifndef CTEMPLATE_BSWAP32_ALREADY_DEFINED
+# undef BSWAP32 // don't leak outside this file
+#else
+# undef CTEMPLATE_BSWAP32_ALREADY_DEFINED // just cleaning up
+#endif
+
+#endif // CTEMPLATE_MACROS_H_
diff --git a/src/base/manual_constructor.h b/src/base/manual_constructor.h
new file mode 100644
index 0000000..a5d430c
--- /dev/null
+++ b/src/base/manual_constructor.h
@@ -0,0 +1,237 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+// ---
+//
+// Author: kenton@google.com (Kenton Varda)
+//
+// ManualConstructor statically-allocates space in which to store some
+// object, but does not initialize it. You can then call the constructor
+// and destructor for the object yourself as you see fit. This is useful
+// for memory management optimizations, where you want to initialize and
+// destroy an object multiple times but only allocate it once.
+//
+// (When I say ManualConstructor statically allocates space, I mean that
+// the ManualConstructor object itself is forced to be the right size.)
+//
+// For example usage, check out util/gtl/small_map.h.
+
+#ifndef UTIL_GTL_MANUAL_CONSTRUCTOR_H_
+#define UTIL_GTL_MANUAL_CONSTRUCTOR_H_
+
+#include <config.h>
+
+namespace ctemplate {
+
+namespace util {
+namespace gtl {
+namespace internal {
+
+//
+// Provides a char array with the exact same alignment as another type. The
+// first parameter must be a complete type, the second parameter is how many
+// of that type to provide space for.
+//
+// UTIL_GTL_ALIGNED_CHAR_ARRAY(struct stat, 16) storage_;
+//
+// Because MSVC and older GCCs require that the argument to their alignment
+// construct to be a literal constant integer, we use a template instantiated
+// at all the possible powers of two.
+#ifndef SWIG
+template<int alignment, int size> struct AlignType { };
+template<int size> struct AlignType<0, size> { typedef char result[size]; };
+#if defined(_MSC_VER)
+#define UTIL_GTL_ALIGN_ATTRIBUTE(X) __declspec(align(X))
+#define UTIL_GTL_ALIGN_OF(T) __alignof(T)
+#elif defined(__GNUC__) || defined(__APPLE__) || defined(__INTEL_COMPILER) \
+ || defined(__nacl__)
+#define UTIL_GTL_ALIGN_ATTRIBUTE(X) __attribute__((aligned(X)))
+#define UTIL_GTL_ALIGN_OF(T) __alignof__(T)
+#endif
+
+#if defined(UTIL_GTL_ALIGN_ATTRIBUTE)
+
+#define UTIL_GTL_ALIGNTYPE_TEMPLATE(X) \
+ template<int size> struct AlignType<X, size> { \
+ typedef UTIL_GTL_ALIGN_ATTRIBUTE(X) char result[size]; \
+ }
+
+UTIL_GTL_ALIGNTYPE_TEMPLATE(1);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(2);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(4);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(8);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(16);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(32);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(64);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(128);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(256);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(512);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(1024);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(2048);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(4096);
+UTIL_GTL_ALIGNTYPE_TEMPLATE(8192);
+// Any larger and MSVC++ will complain.
+
+#define UTIL_GTL_ALIGNED_CHAR_ARRAY(T, Size) \
+ typename util::gtl::internal::AlignType<UTIL_GTL_ALIGN_OF(T), \
+ sizeof(T) * Size>::result
+
+#undef UTIL_GTL_ALIGNTYPE_TEMPLATE
+#undef UTIL_GTL_ALIGN_ATTRIBUTE
+
+#else // defined(UTIL_GTL_ALIGN_ATTRIBUTE)
+#error "You must define UTIL_GTL_ALIGNED_CHAR_ARRAY for your compiler."
+#endif // defined(UTIL_GTL_ALIGN_ATTRIBUTE)
+
+#else // !SWIG
+
+// SWIG can't represent alignment and doesn't care about alignment on data
+// members (it works fine without it).
+template<typename Size>
+struct AlignType { typedef char result[Size]; };
+#define UTIL_GTL_ALIGNED_CHAR_ARRAY(T, Size) \
+ util::gtl::internal::AlignType<Size * sizeof(T)>::result
+
+#endif // !SWIG
+
+} // namespace internal
+} // namespace gtl
+} // namespace util
+
+template <typename Type>
+class ManualConstructor {
+ public:
+ // No constructor or destructor because one of the most useful uses of
+ // this class is as part of a union, and members of a union cannot have
+ // constructors or destructors. And, anyway, the whole point of this
+ // class is to bypass these.
+
+ inline Type* get() {
+ return reinterpret_cast<Type*>(space_);
+ }
+ inline const Type* get() const {
+ return reinterpret_cast<const Type*>(space_);
+ }
+
+ inline Type* operator->() { return get(); }
+ inline const Type* operator->() const { return get(); }
+
+ inline Type& operator*() { return *get(); }
+ inline const Type& operator*() const { return *get(); }
+
+ // You can pass up to four constructor arguments as arguments of Init().
+ inline void Init() {
+ new(space_) Type;
+ }
+
+ template <typename T1>
+ inline void Init(const T1& p1) {
+ new(space_) Type(p1);
+ }
+
+ template <typename T1, typename T2>
+ inline void Init(const T1& p1, const T2& p2) {
+ new(space_) Type(p1, p2);
+ }
+
+ template <typename T1, typename T2, typename T3>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3) {
+ new(space_) Type(p1, p2, p3);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4) {
+ new(space_) Type(p1, p2, p3, p4);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4,
+ const T5& p5) {
+ new(space_) Type(p1, p2, p3, p4, p5);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4,
+ const T5& p5, const T6& p6) {
+ new(space_) Type(p1, p2, p3, p4, p5, p6);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4,
+ const T5& p5, const T6& p6, const T7& p7) {
+ new(space_) Type(p1, p2, p3, p4, p5, p6, p7);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4,
+ const T5& p5, const T6& p6, const T7& p7, const T8& p8) {
+ new(space_) Type(p1, p2, p3, p4, p5, p6, p7, p8);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8, typename T9>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4,
+ const T5& p5, const T6& p6, const T7& p7, const T8& p8,
+ const T9& p9) {
+ new(space_) Type(p1, p2, p3, p4, p5, p6, p7, p8, p9);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8, typename T9, typename T10>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4,
+ const T5& p5, const T6& p6, const T7& p7, const T8& p8,
+ const T9& p9, const T10& p10) {
+ new(space_) Type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10);
+ }
+
+ template <typename T1, typename T2, typename T3, typename T4, typename T5,
+ typename T6, typename T7, typename T8, typename T9, typename T10,
+ typename T11>
+ inline void Init(const T1& p1, const T2& p2, const T3& p3, const T4& p4,
+ const T5& p5, const T6& p6, const T7& p7, const T8& p8,
+ const T9& p9, const T10& p10, const T11& p11) {
+ new(space_) Type(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11);
+ }
+
+ inline void Destroy() {
+ get()->~Type();
+ }
+
+ private:
+ UTIL_GTL_ALIGNED_CHAR_ARRAY(Type, 1) space_;
+};
+
+#undef UTIL_GTL_ALIGNED_CHAR_ARRAY
+#undef UTIL_GTL_ALIGN_OF
+
+}
+
+#endif // UTIL_GTL_MANUAL_CONSTRUCTOR_H_
diff --git a/src/base/mutex.h b/src/base/mutex.h
new file mode 100644
index 0000000..3962a6d
--- /dev/null
+++ b/src/base/mutex.h
@@ -0,0 +1,408 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+//
+// ---
+//
+// A simple mutex wrapper, supporting locks and read-write locks.
+// You should assume the locks are *not* re-entrant.
+//
+// To use: you should define the following macros in your configure.ac:
+// ACX_PTHREAD
+// AC_RWLOCK
+// The latter is defined in ../autoconf.
+//
+// This class is meant to be internal-only and should be wrapped by an
+// internal namespace. Before you use this module, please give the
+// name of your internal namespace for this module. Or, if you want
+// to expose it, you'll want to move it to the Google namespace. We
+// cannot put this class in global namespace because there can be some
+// problems when we have multiple versions of Mutex in each shared object.
+//
+// NOTE: by default, we have #ifdef'ed out the TryLock() method.
+// This is for two reasons:
+// 1) TryLock() under Windows is a bit annoying (it requires a
+// #define to be defined very early).
+// 2) TryLock() is broken for NO_THREADS mode, at least in NDEBUG
+// mode.
+// If you need TryLock(), and either these two caveats are not a
+// problem for you, or you're willing to work around them, then
+// feel free to #define GMUTEX_TRYLOCK, or to remove the #ifdefs
+// in the code below.
+//
+// CYGWIN NOTE: Cygwin support for rwlock seems to be buggy:
+// http://www.cygwin.com/ml/cygwin/2008-12/msg00017.html
+// Because of that, we might as well use windows locks for
+// cygwin. They seem to be more reliable than the cygwin pthreads layer.
+//
+// TRICKY IMPLEMENTATION NOTE:
+// This class is designed to be safe to use during
+// dynamic-initialization -- that is, by global constructors that are
+// run before main() starts. The issue in this case is that
+// dynamic-initialization happens in an unpredictable order, and it
+// could be that someone else's dynamic initializer could call a
+// function that tries to acquire this mutex -- but that all happens
+// before this mutex's constructor has run. (This can happen even if
+// the mutex and the function that uses the mutex are in the same .cc
+// file.) Basically, because Mutex does non-trivial work in its
+// constructor, it's not, in the naive implementation, safe to use
+// before dynamic initialization has run on it.
+//
+// The solution used here is to pair the actual mutex primitive with a
+// bool that is set to true when the mutex is dynamically initialized.
+// (Before that it's false.) Then we modify all mutex routines to
+// look at the bool, and not try to lock/unlock until the bool makes
+// it to true (which happens after the Mutex constructor has run.)
+//
+// This works because before main() starts -- particularly, during
+// dynamic initialization -- there are no threads, so a) it's ok that
+// the mutex operations are a no-op, since we don't need locking then
+// anyway; and b) we can be quite confident our bool won't change
+// state between a call to Lock() and a call to Unlock() (that would
+// require a global constructor in one translation unit to call Lock()
+// and another global constructor in another translation unit to call
+// Unlock() later, which is pretty perverse).
+//
+// That said, it's tricky, and can conceivably fail; it's safest to
+// avoid trying to acquire a mutex in a global constructor, if you
+// can. One way it can fail is that a really smart compiler might
+// initialize the bool to true at static-initialization time (too
+// early) rather than at dynamic-initialization time. To discourage
+// that, we set is_safe_ to true in code (not the constructor
+// colon-initializer) and set it to true via a function that always
+// evaluates to true, but that the compiler can't know always
+// evaluates to true. This should be good enough.
+//
+// A related issue is code that could try to access the mutex
+// after it's been destroyed in the global destructors (because
+// the Mutex global destructor runs before some other global
+// destructor, that tries to acquire the mutex). The way we
+// deal with this is by taking a constructor arg that global
+// mutexes should pass in, that causes the destructor to do no
+// work. We still depend on the compiler not doing anything
+// weird to a Mutex's memory after it is destroyed, but for a
+// static global variable, that's pretty safe.
+
+#ifndef GOOGLE_MUTEX_H_
+#define GOOGLE_MUTEX_H_
+
+#include <config.h>
+#if defined(NO_THREADS)
+ typedef int MutexType; // to keep a lock-count
+#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN // We only need minimal includes
+# endif
+# ifndef NOMINMAX
+# define NOMINMAX // Don't want windows to override min()/max()
+# endif
+# ifdef GMUTEX_TRYLOCK
+ // We need Windows NT or later for TryEnterCriticalSection(). If you
+ // don't need that functionality, you can remove these _WIN32_WINNT
+ // lines, and change TryLock() to assert(0) or something.
+# ifndef _WIN32_WINNT
+# define _WIN32_WINNT 0x0400
+# endif
+# endif
+# include <windows.h>
+ typedef CRITICAL_SECTION MutexType;
+#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
+ // Needed for pthread_rwlock_*. If it causes problems, you could take it
+ // out, but then you'd have to unset HAVE_RWLOCK (at least on linux -- it
+ // *does* cause problems for FreeBSD, or MacOSX, but isn't needed
+ // for locking there.)
+# ifdef __linux__
+# if _XOPEN_SOURCE < 500 // including not being defined at all
+# undef _XOPEN_SOURCE
+# define _XOPEN_SOURCE 500 // may be needed to get the rwlock calls
+# endif
+# endif
+#if defined(HAVE_PTHREAD) && !defined(NO_THREADS)
+# include <pthread.h>
+#endif
+ typedef pthread_rwlock_t MutexType;
+#elif defined(HAVE_PTHREAD)
+#if defined(HAVE_PTHREAD) && !defined(NO_THREADS)
+# include <pthread.h>
+#endif
+ typedef pthread_mutex_t MutexType;
+#else
+# error Need to implement mutex.h for your architecture, or #define NO_THREADS
+#endif
+
+#include <assert.h>
+#include <stdlib.h> // for abort()
+
+namespace ctemplate {
+
+namespace base {
+// This is used for the single-arg constructor
+enum LinkerInitialized { LINKER_INITIALIZED };
+}
+
+class Mutex {
+ public:
+ // Create a Mutex that is not held by anybody. This constructor is
+ // typically used for Mutexes allocated on the heap or the stack.
+ inline Mutex();
+ // This constructor should be used for global, static Mutex objects.
+ // It inhibits work being done by the destructor, which makes it
+ // safer for code that tries to acqiure this mutex in their global
+ // destructor.
+ inline Mutex(base::LinkerInitialized);
+
+ // Destructor
+ inline ~Mutex();
+
+ inline void Lock(); // Block if needed until free then acquire exclusively
+ inline void Unlock(); // Release a lock acquired via Lock()
+#ifdef GMUTEX_TRYLOCK
+ inline bool TryLock(); // If free, Lock() and return true, else return false
+#endif
+ // Note that on systems that don't support read-write locks, these may
+ // be implemented as synonyms to Lock() and Unlock(). So you can use
+ // these for efficiency, but don't use them anyplace where being able
+ // to do shared reads is necessary to avoid deadlock.
+ inline void ReaderLock(); // Block until free or shared then acquire a share
+ inline void ReaderUnlock(); // Release a read share of this Mutex
+ inline void WriterLock() { Lock(); } // Acquire an exclusive lock
+ inline void WriterUnlock() { Unlock(); } // Release a lock from WriterLock()
+
+ private:
+ MutexType mutex_;
+ // We want to make sure that the compiler sets is_safe_ to true only
+ // when we tell it to, and never makes assumptions is_safe_ is
+ // always true. volatile is the most reliable way to do that.
+ volatile bool is_safe_;
+ // This indicates which constructor was called.
+ bool destroy_;
+
+ inline void SetIsSafe() { is_safe_ = true; }
+
+ // Catch the error of writing Mutex when intending MutexLock.
+ Mutex(Mutex* /*ignored*/) {}
+ // Disallow "evil" constructors
+ Mutex(const Mutex&);
+ void operator=(const Mutex&);
+};
+
+// We will also define GoogleOnceType, GOOGLE_ONCE_INIT, and
+// GoogleOnceInit, which are portable versions of pthread_once_t,
+// PTHREAD_ONCE_INIT, and pthread_once.
+
+// Now the implementation of Mutex for various systems
+#if defined(NO_THREADS)
+
+// When we don't have threads, we can be either reading or writing,
+// but not both. We can have lots of readers at once (in no-threads
+// mode, that's most likely to happen in recursive function calls),
+// but only one writer. We represent this by having mutex_ be -1 when
+// writing and a number > 0 when reading (and 0 when no lock is held).
+//
+// In debug mode, we assert these invariants, while in non-debug mode
+// we do nothing, for efficiency. That's why everything is in an
+// assert.
+
+Mutex::Mutex() : mutex_(0) { }
+Mutex::Mutex(base::LinkerInitialized) : mutex_(0) { }
+Mutex::~Mutex() { assert(mutex_ == 0); }
+void Mutex::Lock() { assert(--mutex_ == -1); }
+void Mutex::Unlock() { assert(mutex_++ == -1); }
+#ifdef GMUTEX_TRYLOCK
+bool Mutex::TryLock() { if (mutex_) return false; Lock(); return true; }
+#endif
+void Mutex::ReaderLock() { assert(++mutex_ > 0); }
+void Mutex::ReaderUnlock() { assert(mutex_-- > 0); }
+
+typedef int GoogleOnceType;
+const GoogleOnceType GOOGLE_ONCE_INIT = 0;
+inline int GoogleOnceInit(GoogleOnceType* once_control,
+ void (*init_routine)(void)) {
+ if ((*once_control)++ == 0)
+ (*init_routine)();
+ return 0;
+}
+
+#elif defined(_WIN32) || defined(__CYGWIN32__) || defined(__CYGWIN64__)
+
+Mutex::Mutex() : destroy_(true) {
+ InitializeCriticalSection(&mutex_);
+ SetIsSafe();
+}
+Mutex::Mutex(base::LinkerInitialized) : destroy_(false) {
+ InitializeCriticalSection(&mutex_);
+ SetIsSafe();
+}
+Mutex::~Mutex() { if (destroy_) DeleteCriticalSection(&mutex_); }
+void Mutex::Lock() { if (is_safe_) EnterCriticalSection(&mutex_); }
+void Mutex::Unlock() { if (is_safe_) LeaveCriticalSection(&mutex_); }
+#ifdef GMUTEX_TRYLOCK
+bool Mutex::TryLock() { return is_safe_ ?
+ TryEnterCriticalSection(&mutex_) != 0 : true; }
+#endif
+void Mutex::ReaderLock() { Lock(); } // we don't have read-write locks
+void Mutex::ReaderUnlock() { Unlock(); }
+
+// We do a simple spinlock for pthread_once_t. See
+// http://www.ddj.com/cpp/199203083?pgno=3
+#ifdef INTERLOCKED_EXCHANGE_NONVOLATILE
+typedef LONG GoogleOnceType;
+#else
+typedef volatile LONG GoogleOnceType;
+#endif
+const GoogleOnceType GOOGLE_ONCE_INIT = 0;
+inline int GoogleOnceInit(GoogleOnceType* once_control,
+ void (*init_routine)(void)) {
+ while (1) {
+ LONG prev = InterlockedCompareExchange(once_control, 1, 0);
+ if (prev == 2) { // We've successfully initted in the past.
+ return 0;
+ } else if (prev == 0) { // No init yet, but we have the lock.
+ (*init_routine)();
+ InterlockedExchange(once_control, 2);
+ return 0;
+ } else { // Someone else is holding the lock, so wait.
+ assert(1 == prev);
+ Sleep(1); // sleep for 1ms
+ }
+ }
+ return 1; // unreachable
+}
+
+#elif defined(HAVE_PTHREAD) && defined(HAVE_RWLOCK)
+
+#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
+ if (is_safe_ && fncall(&mutex_) != 0) abort(); \
+} while (0)
+
+Mutex::Mutex() : destroy_(true) {
+ SetIsSafe();
+ if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
+}
+Mutex::Mutex(base::LinkerInitialized) : destroy_(false) {
+ SetIsSafe();
+ if (is_safe_ && pthread_rwlock_init(&mutex_, NULL) != 0) abort();
+}
+Mutex::~Mutex() { if (destroy_) SAFE_PTHREAD(pthread_rwlock_destroy); }
+void Mutex::Lock() { SAFE_PTHREAD(pthread_rwlock_wrlock); }
+void Mutex::Unlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
+#ifdef GMUTEX_TRYLOCK
+bool Mutex::TryLock() { return is_safe_ ?
+ pthread_rwlock_trywrlock(&mutex_) == 0 : true; }
+#endif
+void Mutex::ReaderLock() { SAFE_PTHREAD(pthread_rwlock_rdlock); }
+void Mutex::ReaderUnlock() { SAFE_PTHREAD(pthread_rwlock_unlock); }
+#undef SAFE_PTHREAD
+
+typedef pthread_once_t GoogleOnceType;
+const GoogleOnceType GOOGLE_ONCE_INIT = PTHREAD_ONCE_INIT;
+inline int GoogleOnceInit(GoogleOnceType* once_control,
+ void (*init_routine)(void)) {
+ return pthread_once(once_control, init_routine);
+}
+
+#elif defined(HAVE_PTHREAD)
+
+#define SAFE_PTHREAD(fncall) do { /* run fncall if is_safe_ is true */ \
+ if (is_safe_ && fncall(&mutex_) != 0) abort(); \
+} while (0)
+
+Mutex::Mutex() : destroy_(true) {
+ SetIsSafe();
+ if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
+}
+Mutex::Mutex(base::LinkerInitialized) : destroy_(false) {
+ SetIsSafe();
+ if (is_safe_ && pthread_mutex_init(&mutex_, NULL) != 0) abort();
+}
+Mutex::~Mutex() { if (destroy_) SAFE_PTHREAD(pthread_mutex_destroy); }
+void Mutex::Lock() { SAFE_PTHREAD(pthread_mutex_lock); }
+void Mutex::Unlock() { SAFE_PTHREAD(pthread_mutex_unlock); }
+#ifdef GMUTEX_TRYLOCK
+bool Mutex::TryLock() { return is_safe_ ?
+ pthread_mutex_trylock(&mutex_) == 0 : true; }
+#endif
+void Mutex::ReaderLock() { Lock(); }
+void Mutex::ReaderUnlock() { Unlock(); }
+#undef SAFE_PTHREAD
+
+typedef pthread_once_t GoogleOnceType;
+const GoogleOnceType GOOGLE_ONCE_INIT = PTHREAD_ONCE_INIT;
+inline int GoogleOnceInit(GoogleOnceType* once_control,
+ void (*init_routine)(void)) {
+ return pthread_once(once_control, init_routine);
+}
+
+#endif
+
+// --------------------------------------------------------------------------
+// Some helper classes
+
+// MutexLock(mu) acquires mu when constructed and releases it when destroyed.
+class MutexLock {
+ public:
+ explicit MutexLock(Mutex *mu) : mu_(mu) { mu_->Lock(); }
+ ~MutexLock() { mu_->Unlock(); }
+ private:
+ Mutex * const mu_;
+ // Disallow "evil" constructors
+ MutexLock(const MutexLock&);
+ void operator=(const MutexLock&);
+};
+
+// ReaderMutexLock and WriterMutexLock do the same, for rwlocks
+class ReaderMutexLock {
+ public:
+ explicit ReaderMutexLock(Mutex *mu) : mu_(mu) { mu_->ReaderLock(); }
+ ~ReaderMutexLock() { mu_->ReaderUnlock(); }
+ private:
+ Mutex * const mu_;
+ // Disallow "evil" constructors
+ ReaderMutexLock(const ReaderMutexLock&);
+ void operator=(const ReaderMutexLock&);
+};
+
+class WriterMutexLock {
+ public:
+ explicit WriterMutexLock(Mutex *mu) : mu_(mu) { mu_->WriterLock(); }
+ ~WriterMutexLock() { mu_->WriterUnlock(); }
+ private:
+ Mutex * const mu_;
+ // Disallow "evil" constructors
+ WriterMutexLock(const WriterMutexLock&);
+ void operator=(const WriterMutexLock&);
+};
+
+// Catch bug where variable name is omitted, e.g. MutexLock (&mu);
+#define MutexLock(x) COMPILE_ASSERT(0, mutex_lock_decl_missing_var_name)
+#define ReaderMutexLock(x) COMPILE_ASSERT(0, rmutex_lock_decl_missing_var_name)
+#define WriterMutexLock(x) COMPILE_ASSERT(0, wmutex_lock_decl_missing_var_name)
+
+}
+
+#endif /* #define GOOGLE_MUTEX_H__ */
diff --git a/src/base/small_map.h b/src/base/small_map.h
new file mode 100644
index 0000000..3e17d71
--- /dev/null
+++ b/src/base/small_map.h
@@ -0,0 +1,569 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+// ---
+//
+// Author: kenton@google.com (Kenton Varda)
+//
+// small_map is a drop-in replacement for map or hash_map. It uses a fixed
+// array to store a certain number of elements, then reverts to using a
+// map or hash_map when it runs out of space. For maps that are typically
+// small, this can be considerably faster than using something like hash_map
+// directly, as hash_map is optimized for large data sets. Of course, in
+// order for this to be a significant win, you have to have a situation where
+// you are using lots and lots of these small maps. One such situation is
+// MessageSet: A set of search results may contain thousands of MessageSets,
+// each containing only a couple items.
+//
+// TODO(kenton): This is very minimal, and was originally written for a
+// very specific use (MessageSet). It only implements a few core methods
+// of the STL associative container interface, though you are welcome to
+// extend it.
+
+#ifndef UTIL_GTL_SMALL_MAP_H_
+#define UTIL_GTL_SMALL_MAP_H_
+
+#include <config.h>
+#include <assert.h>
+#include <utility> // for make_pair()
+#include "base/manual_constructor.h"
+
+namespace ctemplate {
+
+template <bool> struct CompileAssert { };
+#define COMPILE_ASSERT(expr, msg) \
+ typedef CompileAssert<(bool(expr))> msg[bool(expr) ? 1 : -1]
+
+// An STL-like associative container which starts out backed by a simple
+// array but switches to some other container type if it grows beyond a
+// fixed size.
+//
+// NormalMap: The map type to fall back to. This also defines the key
+// and value types for the small_map.
+// kArraySize: The size of the initial array of results. Once the map
+// grows beyond this size, the map type will be used instead.
+// EqualKey: A functor which tests two keys for equality. If the wrapped
+// map type has a "key_equal" member (hash_map does), then that
+// will be used by default. Otherwise you must specify this
+// manually.
+// MapInit: A functor that takes a ManualConstructor<NormalMap>* and uses it to
+// initialize the map. This functor will be called at most once per
+// small_map, when the map exceeds the threshold of kArraySize and we
+// are about to copy values from the array to the map. The functor
+// *must* call one of the Init() methods provided by
+// ManualConstructor, since after it runs we assume that the NormalMap
+// has been initialized.
+//
+// example:
+// small_map<hash_map<string, int> > days;
+// days["sunday" ] = 0;
+// days["monday" ] = 1;
+// days["tuesday" ] = 2;
+// days["wednesday"] = 3;
+// days["thursday" ] = 4;
+// days["friday" ] = 5;
+// days["saturday" ] = 6;
+//
+// You should assume that small_map might invalidate all the iterators
+// on any call to erase(), insert() and operator[].
+template <typename NormalMap>
+class small_map_default_init {
+ public:
+ void operator ()(ManualConstructor<NormalMap>* map) const {
+ map->Init();
+ }
+};
+
+template <typename NormalMap,
+ int kArraySize = 4,
+ typename EqualKey = typename NormalMap::key_equal,
+ typename MapInit = small_map_default_init<NormalMap> >
+class small_map {
+ // We cannot rely on the compiler to reject array of size 0. In
+ // particular, gcc 2.95.3 does it but later versions allow 0-length
+ // arrays. Therefore, we explicitly reject non-positive kArraySize
+ // here.
+ COMPILE_ASSERT(kArraySize > 0, default_initial_size_should_be_positive);
+
+ public:
+ typedef typename NormalMap::key_type key_type;
+ typedef typename NormalMap::mapped_type data_type;
+ typedef typename NormalMap::mapped_type mapped_type;
+ typedef typename NormalMap::value_type value_type;
+ typedef EqualKey key_equal;
+
+ small_map() : size_(0), functor_(MapInit()) {}
+
+ explicit small_map(const MapInit& functor) : size_(0), functor_(functor) {}
+
+ // Allow copy-constructor and assignment, since STL allows them too.
+ small_map(const small_map& src) {
+ // size_ and functor_ are initted in InitFrom()
+ InitFrom(src);
+ }
+ void operator=(const small_map& src) {
+ if (&src == this) return;
+
+ // This is not optimal. If src and dest are both using the small
+ // array, we could skip the teardown and reconstruct. One problem
+ // to be resolved is that the value_type itself is pair<const K,
+ // V>, and const K is not assignable.
+ Destroy();
+ InitFrom(src);
+ }
+ ~small_map() {
+ Destroy();
+ }
+
+ class const_iterator;
+
+ class iterator {
+ public:
+ typedef typename NormalMap::iterator::iterator_category iterator_category;
+ typedef typename NormalMap::iterator::value_type value_type;
+ typedef typename NormalMap::iterator::difference_type difference_type;
+ typedef typename NormalMap::iterator::pointer pointer;
+ typedef typename NormalMap::iterator::reference reference;
+
+ inline iterator(): array_iter_(NULL) {}
+
+ inline iterator& operator++() {
+ if (array_iter_ != NULL) {
+ ++array_iter_;
+ } else {
+ ++hash_iter_;
+ }
+ return *this;
+ }
+ inline iterator operator++(int) {
+ iterator result(*this);
+ ++(*this);
+ return result;
+ }
+ inline iterator& operator--() {
+ if (array_iter_ != NULL) {
+ --array_iter_;
+ } else {
+ --hash_iter_;
+ }
+ return *this;
+ }
+ inline iterator operator--(int) {
+ iterator result(*this);
+ --(*this);
+ return result;
+ }
+ inline value_type* operator->() const {
+ if (array_iter_ != NULL) {
+ return array_iter_->get();
+ } else {
+ return hash_iter_.operator->();
+ }
+ }
+
+ inline value_type& operator*() const {
+ if (array_iter_ != NULL) {
+ return *array_iter_->get();
+ } else {
+ return *hash_iter_;
+ }
+ }
+
+ inline bool operator==(const iterator& other) const {
+ if (array_iter_ != NULL) {
+ return array_iter_ == other.array_iter_;
+ } else {
+ return other.array_iter_ == NULL && hash_iter_ == other.hash_iter_;
+ }
+ }
+
+ inline bool operator!=(const iterator& other) const {
+ return !(*this == other);
+ }
+
+ bool operator==(const const_iterator& other) const;
+ bool operator!=(const const_iterator& other) const;
+
+ private:
+ friend class small_map;
+ friend class const_iterator;
+ inline explicit iterator(ManualConstructor<value_type>* init)
+ : array_iter_(init) {}
+ inline explicit iterator(const typename NormalMap::iterator& init)
+ : array_iter_(NULL), hash_iter_(init) {}
+
+ ManualConstructor<value_type>* array_iter_;
+ typename NormalMap::iterator hash_iter_;
+ };
+
+ class const_iterator {
+ public:
+ typedef typename NormalMap::const_iterator::iterator_category iterator_category;
+ typedef typename NormalMap::const_iterator::value_type value_type;
+ typedef typename NormalMap::const_iterator::difference_type difference_type;
+ typedef typename NormalMap::const_iterator::pointer pointer;
+ typedef typename NormalMap::const_iterator::reference reference;
+
+ inline const_iterator(): array_iter_(NULL) {}
+ inline const_iterator(const iterator& other)
+ : array_iter_(other.array_iter_), hash_iter_(other.hash_iter_) {}
+
+ inline const_iterator& operator++() {
+ if (array_iter_ != NULL) {
+ ++array_iter_;
+ } else {
+ ++hash_iter_;
+ }
+ return *this;
+ }
+ inline const_iterator operator++(int) {
+ const_iterator result(*this);
+ ++(*this);
+ return result;
+ }
+
+ inline const_iterator& operator--() {
+ if (array_iter_ != NULL) {
+ --array_iter_;
+ } else {
+ --hash_iter_;
+ }
+ return *this;
+ }
+ inline const_iterator operator--(int) {
+ const_iterator result(*this);
+ --(*this);
+ return result;
+ }
+
+ inline const value_type* operator->() const {
+ if (array_iter_ != NULL) {
+ return array_iter_->get();
+ } else {
+ return hash_iter_.operator->();
+ }
+ }
+
+ inline const value_type& operator*() const {
+ if (array_iter_ != NULL) {
+ return *array_iter_->get();
+ } else {
+ return *hash_iter_;
+ }
+ }
+
+ inline bool operator==(const const_iterator& other) const {
+ if (array_iter_ != NULL) {
+ return array_iter_ == other.array_iter_;
+ } else {
+ return other.array_iter_ == NULL && hash_iter_ == other.hash_iter_;
+ }
+ }
+
+ inline bool operator!=(const const_iterator& other) const {
+ return !(*this == other);
+ }
+
+ private:
+ friend class small_map;
+ inline explicit const_iterator(
+ const ManualConstructor<value_type>* init)
+ : array_iter_(init) {}
+ inline explicit const_iterator(
+ const typename NormalMap::const_iterator& init)
+ : array_iter_(NULL), hash_iter_(init) {}
+
+ const ManualConstructor<value_type>* array_iter_;
+ typename NormalMap::const_iterator hash_iter_;
+ };
+
+ iterator find(const key_type& key) {
+ key_equal compare;
+ if (size_ >= 0) {
+ for (int i = 0; i < size_; i++) {
+ if (compare(array_[i]->first, key)) {
+ return iterator(array_ + i);
+ }
+ }
+ return iterator(array_ + size_);
+ } else {
+ return iterator(map()->find(key));
+ }
+ }
+
+ const_iterator find(const key_type& key) const {
+ key_equal compare;
+ if (size_ >= 0) {
+ for (int i = 0; i < size_; i++) {
+ if (compare(array_[i]->first, key)) {
+ return const_iterator(array_ + i);
+ }
+ }
+ return const_iterator(array_ + size_);
+ } else {
+ return const_iterator(map()->find(key));
+ }
+ }
+
+ // Invalidates iterators.
+ data_type& operator[](const key_type& key) {
+ key_equal compare;
+
+ if (size_ >= 0) {
+ // operator[] searches backwards, favoring recently-added
+ // elements.
+ for (int i = size_-1; i >= 0; --i) {
+ if (compare(array_[i]->first, key)) {
+ return array_[i]->second;
+ }
+ }
+ if (size_ == kArraySize) {
+ ConvertToRealMap();
+ return (*map_)[key];
+ } else {
+ array_[size_].Init(key, data_type());
+ return array_[size_++]->second;
+ }
+ } else {
+ return (*map_)[key];
+ }
+ }
+
+ // Invalidates iterators.
+ std::pair<iterator, bool> insert(const value_type& x) {
+ key_equal compare;
+
+ if (size_ >= 0) {
+ for (int i = 0; i < size_; i++) {
+ if (compare(array_[i]->first, x.first)) {
+ return std::make_pair(iterator(array_ + i), false);
+ }
+ }
+ if (size_ == kArraySize) {
+ ConvertToRealMap(); // Invalidates all iterators!
+ std::pair<typename NormalMap::iterator, bool> ret = map_->insert(x);
+ return std::make_pair(iterator(ret.first), ret.second);
+ } else {
+ array_[size_].Init(x);
+ return std::make_pair(iterator(array_ + size_++), true);
+ }
+ } else {
+ std::pair<typename NormalMap::iterator, bool> ret = map_->insert(x);
+ return std::make_pair(iterator(ret.first), ret.second);
+ }
+ }
+
+ // Invalidates iterators.
+ template <class InputIterator>
+ void insert(InputIterator f, InputIterator l) {
+ while (f != l) {
+ insert(*f);
+ ++f;
+ }
+ }
+
+ iterator begin() {
+ if (size_ >= 0) {
+ return iterator(array_);
+ } else {
+ return iterator(map_->begin());
+ }
+ }
+ const_iterator begin() const {
+ if (size_ >= 0) {
+ return const_iterator(array_);
+ } else {
+ return const_iterator(map_->begin());
+ }
+ }
+
+ iterator end() {
+ if (size_ >= 0) {
+ return iterator(array_ + size_);
+ } else {
+ return iterator(map_->end());
+ }
+ }
+ const_iterator end() const {
+ if (size_ >= 0) {
+ return const_iterator(array_ + size_);
+ } else {
+ return const_iterator(map_->end());
+ }
+ }
+
+ void clear() {
+ if (size_ >= 0) {
+ for (int i = 0; i < size_; i++) {
+ array_[i].Destroy();
+ }
+ } else {
+ map_.Destroy();
+ }
+ size_ = 0;
+ }
+
+ // Invalidates iterators.
+ void erase(const iterator& position) {
+ if (size_ >= 0) {
+ int i = position.array_iter_ - array_;
+ array_[i].Destroy();
+ --size_;
+ if (i != size_) {
+ array_[i].Init(*array_[size_]);
+ array_[size_].Destroy();
+ }
+ } else {
+ map_->erase(position.hash_iter_);
+ }
+ }
+
+ int erase(const key_type& key) {
+ iterator iter = find(key);
+ if (iter == end()) return 0;
+ erase(iter);
+ return 1;
+ }
+
+ int count(const key_type& key) const {
+ return (find(key) == end()) ? 0 : 1;
+ }
+
+ int size() const {
+ if (size_ >= 0) {
+ return size_;
+ } else {
+ return map_->size();
+ }
+ }
+
+ bool empty() const {
+ if (size_ >= 0) {
+ return (size_ == 0);
+ } else {
+ return map_->empty();
+ }
+ }
+
+ // Returns true if we have fallen back to using the underlying map
+ // representation.
+ bool using_full_map() const {
+ return size_ < 0;
+ }
+
+ inline NormalMap* map() {
+ assert(using_full_map());
+ return map_.get();
+ }
+ inline const NormalMap* map() const {
+ assert(using_full_map());
+ return map_.get();
+ }
+
+ private:
+ int size_; // negative = using hash_map
+
+ MapInit functor_;
+
+ // We want to call constructors and destructors manually, but we don't
+ // want to allocate and deallocate the memory used for them separately.
+ // So, we use this crazy ManualConstructor class.
+ //
+ // Since array_ and map_ are mutually exclusive, we'll put them in a
+ // union, too. We add in a dummy_ value which quiets MSVC (both
+ // 7.1 and 8.0) from otherwise giving an erroneous "union member has
+ // copy constructor" error message (C2621). This dummy member has
+ // to come before array_ to quiet the compiler. Shrug.
+ union {
+ ManualConstructor<value_type> dummy_;
+ ManualConstructor<value_type> array_[kArraySize];
+ ManualConstructor<NormalMap> map_;
+ };
+
+ void ConvertToRealMap() {
+ // Move the current elements into a temporary array.
+ ManualConstructor<value_type> temp_array[kArraySize];
+
+ for (int i = 0; i < kArraySize; i++) {
+ temp_array[i].Init(*array_[i]);
+ array_[i].Destroy();
+ }
+
+ // Initialize the map.
+ size_ = -1;
+ functor_(&map_);
+
+ // Insert elements into it.
+ for (int i = 0; i < kArraySize; i++) {
+ map_->insert(*temp_array[i]);
+ temp_array[i].Destroy();
+ }
+ }
+
+ // Helpers for constructors and destructors.
+ void InitFrom(const small_map& src) {
+ functor_ = src.functor_;
+ size_ = src.size_;
+ if (src.size_ >= 0) {
+ for (int i = 0; i < size_; i++) {
+ array_[i].Init(*src.array_[i]);
+ }
+ } else {
+ functor_(&map_);
+ (*map_.get()) = (*src.map_.get());
+ }
+ }
+ void Destroy() {
+ if (size_ >= 0) {
+ for (int i = 0; i < size_; i++) {
+ array_[i].Destroy();
+ }
+ } else {
+ map_.Destroy();
+ }
+ }
+};
+
+template <typename NormalMap, int kArraySize, typename EqualKey,
+ typename Functor>
+inline bool small_map<NormalMap, kArraySize, EqualKey,
+ Functor>::iterator::operator==(
+ const const_iterator& other) const {
+ return other == *this;
+}
+template <typename NormalMap, int kArraySize, typename EqualKey,
+ typename Functor>
+inline bool small_map<NormalMap, kArraySize, EqualKey,
+ Functor>::iterator::operator!=(
+ const const_iterator& other) const {
+ return other != *this;
+}
+
+}
+
+#endif // UTIL_GTL_SMALL_MAP_H_
diff --git a/src/base/thread_annotations.h b/src/base/thread_annotations.h
new file mode 100644
index 0000000..b6db61b
--- /dev/null
+++ b/src/base/thread_annotations.h
@@ -0,0 +1,130 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+// ---
+//
+//
+// This header file contains the macro definitions for thread safety
+// annotations that allow the developers to document the locking policies
+// of their multi-threaded code. The annotations can also help program
+// analysis tools to identify potential thread safety issues.
+//
+//
+// The annotations are implemented using GCC's "attributes" extension.
+// Using the macros defined here instead of the raw GCC attributes allows
+// for portability and future compatibility.
+//
+
+#ifndef BASE_THREAD_ANNOTATIONS_H_
+#define BASE_THREAD_ANNOTATIONS_H_
+
+
+#include <config.h>
+#if defined(__GNUC__) && defined(__SUPPORT_TS_ANNOTATION__) && !defined(SWIG)
+#define THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
+#else
+#define THREAD_ANNOTATION_ATTRIBUTE__(x) // no-op
+#endif
+
+
+// Document if a shared variable/field needs to be protected by a lock.
+// GUARDED_BY allows the user to specify a particular lock that should be
+// held when accessing the annotated variable, while GUARDED_VAR only
+// indicates a shared variable should be guarded (by any lock). GUARDED_VAR
+// is primarily used when the client cannot express the name of the lock.
+#define GUARDED_BY(x) THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
+#define GUARDED_VAR THREAD_ANNOTATION_ATTRIBUTE__(guarded)
+
+// Document if the memory location pointed to by a pointer should be guarded
+// by a lock when dereferencing the pointer. Similar to GUARDED_VAR,
+// PT_GUARDED_VAR is primarily used when the client cannot express the name
+// of the lock. Note that a pointer variable to a shared memory location
+// could itself be a shared variable. For example, if a shared global pointer
+// q, which is guarded by mu1, points to a shared memory location that is
+// guarded by mu2, q should be annotated as follows:
+// int *q GUARDED_BY(mu1) PT_GUARDED_BY(mu2);
+#define PT_GUARDED_BY(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(point_to_guarded_by(x))
+#define PT_GUARDED_VAR \
+ THREAD_ANNOTATION_ATTRIBUTE__(point_to_guarded)
+
+// Document the acquisition order between locks that can be held
+// simultaneously by a thread. For any two locks that need to be annotated
+// to establish an acquisition order, only one of them needs the annotation.
+// (i.e. You don't have to annotate both locks with both ACQUIRED_AFTER
+// and ACQUIRED_BEFORE.)
+#define ACQUIRED_AFTER(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x))
+#define ACQUIRED_BEFORE(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x))
+
+// The following three annotations document the lock requirements for
+// functions/methods.
+
+// Document if a function expects certain locks to be held before it is called
+#define EXCLUSIVE_LOCKS_REQUIRED(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(exclusive_locks_required(x))
+
+#define SHARED_LOCKS_REQUIRED(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(shared_locks_required(x))
+
+// Document the locks acquired in the body of the function. These locks
+// non-reentrant).
+#define LOCKS_EXCLUDED(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x))
+
+// Document the lock the annotated function returns without acquiring it.
+#define LOCK_RETURNED(x) THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
+
+// Document if a class/type is a lockable type (such as the Mutex class).
+#define LOCKABLE THREAD_ANNOTATION_ATTRIBUTE__(lockable)
+
+// Document if a class is a scoped lockable type (such as the MutexLock class).
+#define SCOPED_LOCKABLE THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
+
+// The following annotations specify lock and unlock primitives.
+#define EXCLUSIVE_LOCK_FUNCTION(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(exclusive_lock(x))
+
+#define SHARED_LOCK_FUNCTION(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(shared_lock(x))
+
+#define EXCLUSIVE_TRYLOCK_FUNCTION(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(exclusive_trylock(x))
+
+#define SHARED_TRYLOCK_FUNCTION(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(shared_trylock(x))
+
+#define UNLOCK_FUNCTION(x) \
+ THREAD_ANNOTATION_ATTRIBUTE__(unlock(x))
+
+// An escape hatch for thread safety analysis to ignore the annotated function.
+#define NO_THREAD_SAFETY_ANALYSIS \
+ THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
+
+#endif // BASE_THREAD_ANNOTATIONS_H_
diff --git a/src/base/util.h b/src/base/util.h
new file mode 100644
index 0000000..2d9f1db
--- /dev/null
+++ b/src/base/util.h
@@ -0,0 +1,235 @@
+// Copyright (c) 2011, Google Inc.
+// 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 Google Inc. 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.
+// ---
+//
+// Some generically useful utility routines that in google-land would
+// be their own projects. We make a shortened version here.
+
+#ifndef TEMPLATE_UTIL_H_
+#define TEMPLATE_UTIL_H_
+
+#include <config.h>
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <iostream>
+#include <string>
+#include <utility>
+#include <vector>
+
+// -- utility macros ---------------------------------------------------------
+
+#define DISALLOW_COPY_AND_ASSIGN(TypeName) \
+ TypeName(const TypeName&); \
+ void operator=(const TypeName&)
+
+// Starting with Visual C++ 2005, WinNT.h includes ARRAYSIZE.
+#if !defined(_MSC_VER) || _MSC_VER < 1400
+#define ARRAYSIZE(a) \
+ ((sizeof(a) / sizeof(*(a))) / \
+ static_cast<size_t>(!(sizeof(a) % sizeof(*(a)))))
+#endif
+
+template<typename To, typename From> // use like this: down_cast<T*>(foo);
+inline To down_cast(From* f) { // so we only accept pointers
+ return static_cast<To>(f);
+}
+
+// -- CHECK macros ---------------------------------------------------------
+
+// CHECK dies with a fatal error if condition is not true. It is *not*
+// controlled by NDEBUG, so the check will be executed regardless of
+// compilation mode. Therefore, it is safe to do things like:
+// CHECK(fp->Write(x) == 4)
+// We allow stream-like objects after this for debugging, but they're ignored.
+#define CHECK(condition) \
+ if (true) { \
+ if (!(condition)) { \
+ fprintf(stderr, "Check failed: %s\n", #condition); \
+ exit(1); \
+ } \
+ } else std::cerr << ""
+
+#define CHECK_OP(op, val1, val2) \
+ if (true) { \
+ if (!((val1) op (val2))) { \
+ fprintf(stderr, "Check failed: %s %s %s\n", #val1, #op, #val2); \
+ exit(1); \
+ } \
+ } else std::cerr << ""
+
+#define CHECK_EQ(val1, val2) CHECK_OP(==, val1, val2)
+#define CHECK_NE(val1, val2) CHECK_OP(!=, val1, val2)
+#define CHECK_LE(val1, val2) CHECK_OP(<=, val1, val2)
+#define CHECK_LT(val1, val2) CHECK_OP(< , val1, val2)
+#define CHECK_GE(val1, val2) CHECK_OP(>=, val1, val2)
+#define CHECK_GT(val1, val2) CHECK_OP(> , val1, val2)
+// Synonyms for CHECK_* that are used in some unittests.
+#define EXPECT_EQ(val1, val2) CHECK_EQ(val1, val2)
+#define EXPECT_NE(val1, val2) CHECK_NE(val1, val2)
+#define EXPECT_LE(val1, val2) CHECK_LE(val1, val2)
+#define EXPECT_LT(val1, val2) CHECK_LT(val1, val2)
+#define EXPECT_GE(val1, val2) CHECK_GE(val1, val2)
+#define EXPECT_GT(val1, val2) CHECK_GT(val1, val2)
+#define EXPECT_TRUE(cond) CHECK(cond)
+#define EXPECT_FALSE(cond) CHECK(!(cond))
+#define EXPECT_STREQ(a, b) CHECK(strcmp(a, b) == 0)
+#define ASSERT_TRUE(cond) EXPECT_TRUE(cond)
+// LOG(FATAL) is an alias for CHECK(FALSE). We define FATAL, but no
+// other value that is reasonable inside LOG(), so the compile will
+// fail if someone tries to use LOG(DEBUG) or the like.
+#define LOG(x) INTERNAL_DO_LOG_ ## x
+#define INTERNAL_DO_LOG_FATAL CHECK(false)
+
+// These are used only in debug mode.
+#ifdef NDEBUG
+#define DCHECK(condition) CHECK(condition)
+#define DCHECK_EQ(val1, val2) CHECK_EQ(val1, val2)
+#define DCHECK_NE(val1, val2) CHECK_NE(val1, val2)
+#define DCHECK_LE(val1, val2) CHECK_LE(val1, val2)
+#define DCHECK_LT(val1, val2) CHECK_LT(val1, val2)
+#define DCHECK_GE(val1, val2) CHECK_GE(val1, val2)
+#define DCHECK_GT(val1, val2) CHECK_GT(val1, val2)
+#else
+#define DCHECK(condition) if (true) {} else std::cerr << ""
+#define DCHECK_EQ(val1, val2) if (true) {} else std::cerr << ""
+#define DCHECK_NE(val1, val2) if (true) {} else std::cerr << ""
+#define DCHECK_LE(val1, val2) if (true) {} else std::cerr << ""
+#define DCHECK_LT(val1, val2) if (true) {} else std::cerr << ""
+#define DCHECK_GE(val1, val2) if (true) {} else std::cerr << ""
+#define DCHECK_GT(val1, val2) if (true) {} else std::cerr << ""
+#endif
+
+#define PCHECK(cond) CHECK(cond) << ": " << strerror(errno)
+#define PFATAL(s) do { perror(s); exit(1); } while (0)
+
+// -- testing-related macros --------------------------------------------------
+
+// Call this in a .cc file where you will later call RUN_ALL_TESTS in main().
+#define TEST_INIT \
+ static std::vector<void (*)()> g_testlist; /* the tests to run */ \
+ static int RUN_ALL_TESTS() { \
+ std::vector<void (*)()>::const_iterator it; \
+ for (it = g_testlist.begin(); it != g_testlist.end(); ++it) { \
+ (*it)(); /* The test will error-exit if there's a problem. */ \
+ } \
+ fprintf(stderr, "\nPassed %d tests\n\nPASS\n", \
+ static_cast<int>(g_testlist.size())); \
+ return 0; \
+ }
+
+#define TEST(a, b) \
+ class Test_##a##_##b { \
+ public: \
+ Test_##a##_##b() { g_testlist.push_back(&Run); } \
+ static void Run(); \
+ }; \
+ static Test_##a##_##b g_test_##a##_##b; \
+ void Test_##a##_##b::Run()
+
+// This is a dummy class that eases the google->opensource transition.
+namespace testing {
+class Test {};
+}
+
+// -- template-related macros ----------------------------------------------
+
+#ifndef DEFAULT_TEMPLATE_ROOTDIR
+# define DEFAULT_TEMPLATE_ROOTDIR "."
+#endif
+
+// -- string-related functions ----------------------------------------------
+
+inline bool safe_strto32(const std::string& s, int* i) {
+ char* error_pos;
+ if (s.empty()) return false; // no input at all
+ errno = 0; // just to be sure
+ *i = strtol(s.c_str(), &error_pos, 10);
+ return *error_pos == '\0' && errno == 0;
+}
+
+inline int atoi32(const char* s) {
+ return atoi(s);
+}
+
+inline void StripWhiteSpace(std::string* str) {
+ int str_length = str->length();
+
+ // Strip off leading whitespace.
+ int first = 0;
+ while (first < str_length && isspace(str->at(first))) {
+ ++first;
+ }
+ // If entire string is white space.
+ if (first == str_length) {
+ str->clear();
+ return;
+ }
+ if (first > 0) {
+ str->erase(0, first);
+ str_length -= first;
+ }
+
+ // Strip off trailing whitespace.
+ int last = str_length - 1;
+ while (last >= 0 && isspace(str->at(last))) {
+ --last;
+ }
+ if (last != (str_length - 1) && last >= 0) {
+ str->erase(last + 1, std::string::npos);
+ }
+}
+
+inline void SplitStringIntoKeyValuePairs(
+ const std::string& s,
+ const char* kv_split, // For instance: "="
+ const char* pair_split, // For instance: ","
+ std::vector< std::pair<std::string, std::string> > *pairs) {
+ std::string key, value;
+ std::string* add_to = &key;
+ for (std::string::size_type i = 0; i < s.length(); ++i) {
+ if (s[i] == kv_split[0]) {
+ add_to = &value;
+ } else if (s[i] == pair_split[0]) {
+ if (!key.empty())
+ pairs->push_back(std::pair<std::string, std::string>(key, value));
+ key.clear();
+ value.clear();
+ add_to = &key;
+ } else {
+ *add_to += s[i];
+ }
+ }
+ if (!key.empty())
+ pairs->push_back(std::pair<std::string, std::string>(key, value));
+}
+
+#endif // TEMPLATE_UTIL_H_
diff --git a/src/config.h.in b/src/config.h.in
new file mode 100644
index 0000000..440f123
--- /dev/null
+++ b/src/config.h.in
@@ -0,0 +1,195 @@
+/* src/config.h.in. Generated from configure.ac by autoheader. */
+
+/* Namespace for Google classes */
+#undef GOOGLE_NAMESPACE
+
+/* the location of <unordered_map> or <hash_map> */
+#undef HASH_MAP_H
+
+/* the namespace of hash_map/hash_set */
+#undef HASH_NAMESPACE
+
+/* the location of <unordered_set> or <hash_set> */
+#undef HASH_SET_H
+
+/* Define to 1 if you have the <byteswap.h> header file. */
+#undef HAVE_BYTESWAP_H
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <endian.h> header file. */
+#undef HAVE_ENDIAN_H
+
+/* Define to 1 if you have the `getopt' function. */
+#undef HAVE_GETOPT
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
+/* define if the compiler has hash_map */
+#undef HAVE_HASH_MAP
+
+/* define if the compiler has hash_set */
+#undef HAVE_HASH_SET
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <libkern/OSByteOrder.h> header file. */
+#undef HAVE_LIBKERN_OSBYTEORDER_H
+
+/* Define to 1 if you have the <machine/endian.h> header file. */
+#undef HAVE_MACHINE_ENDIAN_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* define if the compiler implements namespaces */
+#undef HAVE_NAMESPACES
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define if you have POSIX threads libraries and header files. */
+#undef HAVE_PTHREAD
+
+/* define if the compiler implements pthread_rwlock_* */
+#undef HAVE_RWLOCK
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/byteorder.h> header file. */
+#undef HAVE_SYS_BYTEORDER_H
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/endian.h> header file. */
+#undef HAVE_SYS_ENDIAN_H
+
+/* Define to 1 if you have the <sys/isa_defs.h> header file. */
+#undef HAVE_SYS_ISA_DEFS_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#undef HAVE_UINT32_T
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#undef HAVE_UINT64_T
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* define if the compiler supports unordered_{map,set} */
+#undef HAVE_UNORDERED_MAP
+
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
+
+/* Define to 1 if the system has the type `u_int32_t'. */
+#undef HAVE_U_INT32_T
+
+/* Define to 1 if the system has the type `u_int64_t'. */
+#undef HAVE_U_INT64_T
+
+/* define if your compiler has __attribute__ */
+#undef HAVE___ATTRIBUTE__
+
+/* Define to 1 if the system has the type `__int32'. */
+#undef HAVE___INT32
+
+/* Define to 1 if the system has the type `__int64'. */
+#undef HAVE___INT64
+
+/* The namespace to put the htmlparser code. */
+#undef HTMLPARSER_NAMESPACE
+
+/* define if first argument to InterlockedExchange is just LONG */
+#undef INTERLOCKED_EXCHANGE_NONVOLATILE
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* printf format code for printing a size_t and ssize_t */
+#undef PRIdS
+
+/* printf format code for printing a size_t and ssize_t */
+#undef PRIuS
+
+/* printf format code for printing a size_t and ssize_t */
+#undef PRIxS
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+ your system. */
+#undef PTHREAD_CREATE_JOINABLE
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* the namespace where STL code like vector<> is defined */
+#undef STL_NAMESPACE
+
+/* Version number of package */
+#undef VERSION
+
+/* Stops putting the code inside the Google namespace */
+#undef _END_GOOGLE_NAMESPACE_
+
+/* Puts following code inside the Google namespace */
+#undef _START_GOOGLE_NAMESPACE_
+
+
+#if defined( __MINGW32__) || defined(__MINGW64__)
+#include "windows/port.h"
+#endif
+
diff --git a/src/ctemplate/find_ptr.h.in b/src/ctemplate/find_ptr.h.in
new file mode 100644
index 0000000..e67e532
--- /dev/null
+++ b/src/ctemplate/find_ptr.h.in
@@ -0,0 +1,79 @@
+// Copyright (c) 2012, Olaf van der Spek <olafvdspek@gmail.com>
+// 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 Google Inc. 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.
+
+// ---
+// Author: Olaf van der Spek <olafvdspek@gmail.com>
+
+#ifndef TEMPLATE_FIND_PTR_H_
+#define TEMPLATE_FIND_PTR_H_
+
+#include <cstddef>
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+template <class T, class U>
+const typename T::value_type* find_ptr0(const T& c, U v)
+{
+ typename T::const_iterator i = c.find(v);
+ return i == c.end() ? NULL : &*i;
+}
+
+template <class T, class U>
+typename T::value_type::second_type* find_ptr(T& c, U v)
+{
+ typename T::iterator i = c.find(v);
+ return i == c.end() ? NULL : &i->second;
+}
+
+template <class T, class U>
+const typename T::value_type::second_type* find_ptr(const T& c, U v)
+{
+ typename T::const_iterator i = c.find(v);
+ return i == c.end() ? NULL : &i->second;
+}
+
+template <class T, class U>
+typename T::value_type::second_type find_ptr2(T& c, U v)
+{
+ typename T::iterator i = c.find(v);
+ return i == c.end() ? NULL : i->second;
+}
+
+template <class T, class U>
+const typename T::value_type::second_type find_ptr2(const T& c, U v)
+{
+ typename T::const_iterator i = c.find(v);
+ return i == c.end() ? NULL : i->second;
+}
+
+}
+
+#endif // TEMPLATE_FIND_PTR_H_
diff --git a/src/ctemplate/per_expand_data.h.in b/src/ctemplate/per_expand_data.h.in
new file mode 100644
index 0000000..96e628b
--- /dev/null
+++ b/src/ctemplate/per_expand_data.h.in
@@ -0,0 +1,149 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// In addition to a TemplateDictionary, there is also a PerExpandData
+// dictionary. This dictionary holds information that applies to one
+// call to Expand, such as whether to annotate the template expansion
+// output. A template dictionary is associated with a template (.tpl)
+// file; a per-expand dictionary is associated to a particular call to
+// Expand() in a .cc file.
+//
+// For (many) more details, see the doc/ directory.
+
+#ifndef TEMPLATE_PER_EXPAND_DATA_H_
+#define TEMPLATE_PER_EXPAND_DATA_H_
+
+#include <stdlib.h> // for NULL
+#include <string.h> // for strcmp
+#include <sys/types.h>
+#include @ac_cv_cxx_hash_map@
+#include <ctemplate/template_string.h> // for StringHash
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+class TemplateModifier;
+class TemplateAnnotator;
+
+class @ac_windows_dllexport@ PerExpandData {
+ public:
+ PerExpandData()
+ : annotate_path_(NULL),
+ annotator_(NULL),
+ expand_modifier_(NULL),
+ map_(NULL) { }
+
+ ~PerExpandData();
+
+ // Indicate that annotations should be inserted during template expansion.
+ // template_path_start - the start of a template path. When
+ // printing the filename for template-includes, anything before and
+ // including template_path_start is elided. This can make the
+ // output less dependent on filesystem location for template files.
+ void SetAnnotateOutput(const char* template_path_start) {
+ annotate_path_ = template_path_start;
+ }
+
+ // Whether to annotate the expanded output.
+ bool annotate() const { return annotate_path_ != NULL; }
+
+ // The annotate-path; undefined if annotate() != true
+ const char* annotate_path() const { return annotate_path_; }
+
+ // This sets the TemplateAnnotator to be used when annotating is on.
+ // This allows you to override the default text-based annotator
+ // that will be used if you do not call this. The passed annotator
+ // will be aliased by this object and returned by annotator().
+ // Passing NULL has the special behavior of causing annotator() to
+ // revert to returning its built-in instance.
+ void SetAnnotator(TemplateAnnotator* annotator) {
+ annotator_ = annotator;
+ }
+
+ // This returns the TemplateAnnotator to be used when annotating is on.
+ // The value returned will be either an instance previously provided
+ // to SetAnnotator() or the callable built-in text-based annotator.
+ TemplateAnnotator* annotator() const;
+
+ // This is a TemplateModifier to be applied to all templates
+ // expanded via this call to Expand(). That is, this modifier is
+ // applies to the template (.tpl) file we expand, as well as
+ // sub-templates that are expanded due to {{>INCLUDE}} directives.
+ // Caller is responsible for ensuring that modifier exists for the
+ // lifetime of this object.
+ void SetTemplateExpansionModifier(const TemplateModifier* modifier) {
+ expand_modifier_ = modifier;
+ }
+
+ const TemplateModifier* template_expansion_modifier() const {
+ return expand_modifier_;
+ }
+
+ // Store data in this structure, to be used by template modifiers
+ // (see template_modifiers.h). Call with value set to NULL to clear
+ // any value previously set. Caller is responsible for ensuring key
+ // and value point to valid data for the lifetime of this object.
+ void InsertForModifiers(const char* key, const void* value);
+
+ // Retrieve data specific to this Expand call. Returns NULL if key
+ // is not found. This should only be used by template modifiers.
+ const void* LookupForModifiers(const char* key) const;
+
+ // Same as Lookup, but casts the result to a c string.
+ const char* LookupForModifiersAsString(const char* key) const {
+ return static_cast<const char*>(LookupForModifiers(key));
+ }
+
+ private:
+#ifdef _MSC_VER
+ typedef @ac_cv_cxx_hash_map_class@<const char*, const void*, StringHash> DataMap;
+#else
+ struct DataEq {
+ bool operator()(const char* s1, const char* s2) const;
+ };
+ typedef @ac_cv_cxx_hash_map_class@<const char*, const void*, StringHash, DataEq>
+ DataMap;
+#endif
+
+ const char* annotate_path_;
+ TemplateAnnotator* annotator_;
+ const TemplateModifier* expand_modifier_;
+ DataMap* map_;
+
+ PerExpandData(const PerExpandData&); // disallow evil copy constructor
+ void operator=(const PerExpandData&); // disallow evil operator=
+};
+
+}
+
+#endif // TEMPLATE_PER_EXPAND_DATA_H_
diff --git a/src/ctemplate/str_ref.h.in b/src/ctemplate/str_ref.h.in
new file mode 100644
index 0000000..68b591a
--- /dev/null
+++ b/src/ctemplate/str_ref.h.in
@@ -0,0 +1,129 @@
+// Copyright (c) 2012, Olaf van der Spek <olafvdspek@gmail.com>
+// 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 Google Inc. 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.
+
+// ---
+// Author: Olaf van der Spek <olafvdspek@gmail.com>
+
+#ifndef TEMPLATE_STR_REF_H_
+#define TEMPLATE_STR_REF_H_
+
+#include <cstddef>
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+template <class T>
+class str_ref_basic
+{
+public:
+ str_ref_basic()
+ {
+ clear();
+ }
+
+ template <class U>
+ str_ref_basic(const U& c)
+ {
+ if (c.end() != c.begin())
+ assign(&*c.begin(), c.end() - c.begin() + &*c.begin());
+ else
+ clear();
+ }
+
+ str_ref_basic(const void* b, const void* e)
+ {
+ assign(b, e);
+ }
+
+ str_ref_basic(const void* b, size_t sz)
+ {
+ assign(b, sz);
+ }
+
+ str_ref_basic(const char* b)
+ {
+ if (b)
+ assign(b, strlen(b));
+ else
+ clear();
+ }
+
+ void clear()
+ {
+ begin_ = end_ = NULL;
+ }
+
+ void assign(const void* b, const void* e)
+ {
+ begin_ = reinterpret_cast<T>(b);
+ end_ = reinterpret_cast<T>(e);
+ }
+
+ void assign(const void* b, size_t sz)
+ {
+ begin_ = reinterpret_cast<T>(b);
+ end_ = begin_ + sz;
+ }
+
+ T begin() const
+ {
+ return begin_;
+ }
+
+ T end() const
+ {
+ return end_;
+ }
+
+ T data() const
+ {
+ return begin();
+ }
+
+ size_t size() const
+ {
+ return end() - begin();
+ }
+
+ bool empty() const
+ {
+ return begin() == end();
+ }
+private:
+ T begin_;
+ T end_;
+};
+
+typedef str_ref_basic<const unsigned char*> data_ref;
+typedef str_ref_basic<const char*> str_ref;
+
+}
+
+#endif // TEMPLATE_STR_REF_H_
diff --git a/src/ctemplate/template.h.in b/src/ctemplate/template.h.in
new file mode 100644
index 0000000..c2201f8
--- /dev/null
+++ b/src/ctemplate/template.h.in
@@ -0,0 +1,483 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// This file implements the Template class. For information about
+// how to use this class, and to write the templates it takes as input,
+// see the doc/ directory.
+
+#ifndef CTEMPLATE_TEMPLATE_H_
+#define CTEMPLATE_TEMPLATE_H_
+
+#include <time.h> // for time_t
+#include <string>
+#include <ctemplate/template_cache.h>
+#include <ctemplate/template_enums.h>
+#include <ctemplate/template_string.h>
+
+// We include this just so folks don't have to include both template.h
+// and template_dictionary.h, or template_namelist.h etc, to use the
+// template system; we don't actually use anything in these files
+// ourselves.
+#if 1
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_namelist.h>
+#include <ctemplate/per_expand_data.h>
+#else
+@ac_google_start_namespace@
+class TemplateDictionaryInterface;
+class PerExpandData;
+}
+#endif
+
+namespace ctemplate_htmlparser {
+class HtmlParser;
+}
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+// These free functions form the "simple" template API, and support
+// the most common operations (expanding a template from a file, and
+// from a string). They all just delegate to a default instance of
+// the TemplateCache object.
+//
+// For more sophisticated use of the template system, you may need
+// to create your own TemplateCache object, and work directly with
+// it. See template_cache.h for details.
+
+extern @ac_windows_dllexport@ const TemplateCache* default_template_cache();
+extern @ac_windows_dllexport@ TemplateCache* mutable_default_template_cache();
+
+
+// ---- EXPANDING A TEMPLATE -------
+// ExpandTemplate
+// ExpandWithData
+
+// Loads the template named filename from disk if necessary -- it
+// gets it from the cache instead, if the template had been loaded
+// before or if it had been put explicitly in the cache via a call
+// to StringToTemplateCache() -- and expands it using the given
+// dictionary.
+// The first version is the most general, followed by common-case code.
+inline bool ExpandTemplate(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ ExpandEmitter* output) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, NULL, output);
+}
+inline bool ExpandTemplate(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ std::string* output_buffer) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, NULL, output_buffer);
+}
+
+// If you want any per-expand data to be used at expand time, call
+// this routine instead of Expand. You pass in an extra
+// PerExpandData structure (see per_expand_data.h) which sets this
+// data: whether or not you want the template to be annotated, and
+// any data you want to pass in to template modifers. If
+// per_expand_data is NULL, this is exactly the same as Expand().
+// The first version is the most general, followed by common-case code.
+inline bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ ExpandEmitter* output) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, per_expand_data, output);
+}
+inline bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data,
+ std::string* output_buffer) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, per_expand_data, output_buffer);
+}
+
+// ---- INSERTING INTO THE CACHE -------
+// LoadTemplate
+// StringToTemplateCache
+
+// Reads a file from disk and inserts it into the template, if it's
+// not already there. Returns true on success or false if the
+// template could not be found, or could not be parsed. It's never
+// necessary to call this -- Expand() will load templates lazily if
+// needed -- but you may want to if you want to make sure templates
+// exist before trying to expand them, or because you want to
+// control disk access patterns, or for some other reason.
+inline bool LoadTemplate(const TemplateString& filename, Strip strip) {
+ return mutable_default_template_cache()->LoadTemplate(filename, strip);
+}
+
+// Inserts the given string into the default template cache, as if
+// it were a file read from disk. You can call Expand() with its
+// first arg (filename) the same as the key you use here. You can
+// also use this key as the 'filename' for sub-included templates,
+// in TemplateDictionary::SetFilename().
+inline bool StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content,
+ Strip strip) {
+ return mutable_default_template_cache()->StringToTemplateCache(
+ key, content, strip);
+}
+inline bool StringToTemplateCache(const TemplateString& key,
+ const char* content, size_t content_len,
+ Strip strip) {
+ return mutable_default_template_cache()->StringToTemplateCache(
+ key, content, content_len, strip);
+}
+
+
+// ---------------------------------------------------------------------
+// The follow are deprecated.
+// TODO(csilvers): move to parsed_template.h
+
+// TemplateState of a template is:
+// - TS_EMPTY before parsing is complete,
+// - TS_ERROR if a syntax error was found during parsing, and
+// - TS_READY if parsing has completed successfully
+// (TS_UNUSED is not used)
+enum TemplateState { TS_UNUSED, TS_EMPTY, TS_ERROR, TS_READY };
+
+// Used for Auto-Escape. It represents the different contexts a template may
+// be initialized in via the AUTOESCAPE pragma in the template file
+// (or string). It is only public for testing. The contexts are:
+// - TC_HTML: The template contains HTML code. Need not be a complete HTML
+// page just content the browser interprets in the context of
+// HTML parsing. This should be the most common context to use.
+// This mode activates our HTML parser.
+// - TC_JS: The template contains raw javascript. If your template
+// starts with <script> tag, it is of type TC_HTML not TC_JS.
+// TC_JS is typically associated with a content-type of
+// text/javascript. This mode activates our HTML parser.
+// - TC_CSS: The template contains CSS (cascaded style-sheet). If your
+// template starts with a <style> tag, it is of type TC_HTML
+// not TC_CSS. A TC_CSS template is typically associated with a
+// text/css content-type header. Currently treated same as
+// TC_HTML but don't rely on that. We may later develop
+// CSS-specific sanitizers and parsers.
+// - TC_JSON: The template contains raw JSON. Applies javascript_escape
+// to variables. Note: javascript_escape is safer than
+// json_escape which we may want to remove.
+// - TC_XML: The template contains raw XML. Applies xml_escape to variables.
+// CAUTION: This mode is not suitable for cases where the
+// application data encapsulated in XML requires special
+// escaping, such as the case of XHTML.
+// TC_XML is typically associated with text/xml content-type.
+// - TC_MANUAL: Equivalent to not specifying auto-escaping at all.
+//
+// TODO(csilvers): Make this a private part of the Template class.
+enum TemplateContext { TC_UNUSED, TC_HTML, TC_JS, TC_CSS, TC_JSON,
+ TC_XML, TC_MANUAL };
+
+
+// This class is deprecated. Old code uses this class heavily (via
+// GetTemplate() to obtain a Template*, and then methods on that
+// Template*) but new code should use the free functions above.
+class @ac_windows_dllexport@ Template {
+ public:
+ // ---- METHODS FOR TOOLS ----
+ // These are not intended for normal use, but are public so a
+ // tool can use them.
+
+ // Used by make_tpl_varnames_h.cc.
+ void WriteHeaderEntries(std::string *outstring) const;
+
+ // ---- DEPRECATED METHODS ----
+ // These methods used to be the primary way of using the Template
+ // object, but have been deprecated in favor of the (static)
+ // methods above. If you are using these deprecated methods,
+ // consider moving to the above methods instead, or to moving to
+ // using your own TemplateCache (which supports richer operations
+ // on parsed templates).
+
+ // Loads a template from disk or cache or string, and returns the Template*.
+ // INSTEAD, use the static Expand that takes a filename.
+ static Template *GetTemplate(const TemplateString& filename, Strip strip);
+ virtual ~Template(); // when the time comes to delete these Template*'s.
+
+ // Parses a string immediately and returns the resulting Template*.
+ // You can call the (deprecated) non-static Expand() method on this
+ // template in order to expand it with a dictionary. You are
+ // responsible for deleting the Template* when you are done with it.
+ // INSTEAD, use StringToTemplateCache (with a key) plus the static Expand().
+ // TOOO(csilvers): return a const Template* instead.
+ static Template* StringToTemplate(const TemplateString& content,
+ Strip strip);
+ static Template* StringToTemplate(const char* content, size_t content_len,
+ Strip strip) {
+ return StringToTemplate(TemplateString(content, content_len), strip);
+ }
+
+ // Non-static Expand*() works on a Template* returned from GetTemplate().
+ // INSTEAD, use static expand with a filename (or key-name for strings).
+ bool ExpandWithData(ExpandEmitter* output,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data) const {
+ return ExpandWithDataAndCache(output, dictionary, per_expand_data,
+ default_template_cache());
+ }
+ bool ExpandWithData(std::string* output_buffer,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data) const {
+ if (output_buffer == NULL) return false;
+ StringEmitter e(output_buffer);
+ return ExpandWithData(&e, dictionary, per_expand_data);
+ }
+ bool Expand(ExpandEmitter* output,
+ const TemplateDictionaryInterface* dictionary) const {
+ return ExpandWithData(output, dictionary, NULL);
+ }
+ bool Expand(std::string* output_buffer,
+ const TemplateDictionaryInterface* dictionary) const {
+ return ExpandWithData(output_buffer, dictionary, NULL);
+ }
+
+ // Dump to stdout or a string. filename is just used to annotate output.
+ void Dump(const char *filename) const;
+ void DumpToString(const char *filename, std::string *out) const;
+
+ // Retrieves the state, template-file, or strip mode of this Template.
+ TemplateState state() const;
+ const char *template_file() const;
+ const char *original_filename() const;
+ Strip strip() const;
+
+ // Work at the level of groups of templates, so just call through to
+ // the default TemplateCache; see template_cache.h for what these do.
+ // INSTEAD, create your own TemplateCache and call these methods on that.
+ static bool SetTemplateRootDirectory(const std::string& dir) {
+ return mutable_default_template_cache()->SetTemplateRootDirectory(dir);
+ }
+ static bool AddAlternateTemplateRootDirectory(const std::string& dir) {
+ return mutable_default_template_cache()->AddAlternateTemplateRootDirectory(
+ dir);
+ }
+ static std::string template_root_directory() {
+ return default_template_cache()->template_root_directory();
+ }
+ static std::string FindTemplateFilename(
+ const std::string& unresolved) {
+ return default_template_cache()->FindTemplateFilename(unresolved);
+ }
+ static void RemoveStringFromTemplateCache(const std::string& key) {
+ mutable_default_template_cache()->Delete(key);
+ }
+ static void ClearCache() {
+ mutable_default_template_cache()->ClearCache();
+ }
+ static void ReloadAllIfChanged() {
+ mutable_default_template_cache()->ReloadAllIfChanged(
+ TemplateCache::LAZY_RELOAD);
+ }
+
+ // ---- EXTRA-DEPRECATED METHODS ----
+ // These methods were deprecated even before the move to
+ // TemplateCache. We'd really like you to move from these to one
+ // of the "approved" methods, or even one of the deprecated
+ // methods. Comments here don't even describe what these
+ // functions do, just how to transition off of using them.
+
+ // INSTEAD, use the StringToTemplateCache function that takes the strip mode.
+ static bool StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content);
+ static bool StringToTemplateCache(const TemplateString& key,
+ const char* content, size_t content_len) {
+ return StringToTemplateCache(key, TemplateString(content, content_len));
+ }
+ // This is to prevent against typos: you want the global (free-function)
+ // StringToTemplateCache here, not the one in Template.
+ static bool StringToTemplateCache(const TemplateString& key,
+ const char* content, Strip);
+
+ protected:
+ friend class SectionTemplateNode; // for access to set_state(), ParseState
+ friend class TemplateTemplateNode; // for recursive call to Expand()
+
+ // Template constructor
+ // Reads the template file and parses it into a parse tree of TemplateNodes
+ // by calling the method ReloadIfChanged
+ // The top node is a section node with the arbitrary name "__{{MAIN}}__"
+ // 'Strip' indicates how to handle whitespace when expanding the
+ // template. DO_NOT_STRIP keeps the template exactly as-is.
+ // STRIP_BLANK_LINES elides all blank lines in the template.
+ // STRIP_WHITESPACE elides all blank lines, and also all whitespace
+ // at either the beginning or end of a line. It also removes
+ // any linefeed (possibly following whitespace) that follows a closing
+ // '}}' of any kind of template marker EXCEPT a template variable.
+ // This means a linefeed may be removed anywhere by simply placing
+ // a comment marker as the last element on the line.
+ // These two options allow the template to include whitespace for
+ // readability without adding to the expanded output.
+ Template(const TemplateString& filename, Strip strip, TemplateCache* owner);
+
+ // MaybeInitHtmlParser
+ // In TemplateContexts where the HTML parser is needed, we
+ // initialize it in the appropriate mode. Also we do a sanity
+ // check (cannot fail) on the template filename. This function is
+ // called at most once for a Template. In_tag is only meaningful
+ // for TC_HTML: It is true for templates that start inside an HTML
+ // tag and hence are expected to contain HTML attribute name/value
+ // pairs only. It is false for standard HTML templates.
+ void MaybeInitHtmlParser(bool in_tag);
+
+ // BuildTree
+ // Parses the contents of the file (retrieved via ReloadIfChanged)
+ // and stores the resulting parse structure in tree_. Returns true
+ // iff the tree-builder encountered no errors. Note: takes
+ // ownership of input_buffer, and will delete it. It should have
+ // been created via new[].
+ bool BuildTree(const char *input_buffer, const char* input_buffer_end);
+
+ // Internal version of ReloadIfChanged, used when the function already
+ // has a write-lock on g_template_mutex.
+ bool ReloadIfChangedLocked();
+
+ // set_state
+ // Sets the state of the template. Used during BuildTree().
+ void set_state(TemplateState new_state);
+
+ // StripBuffer
+ // Modifies buffer in-place based on the strip_ mode, to remove
+ // extra whitespace. May delete[] the input buffer and replace
+ // it with a new buffer. Used by ReloadIfChanged().
+ void StripBuffer(char **buffer, size_t* len);
+
+ // The file we originally got from the Template() constructor
+ const std::string original_filename_;
+ // The pathname as fully resolved on the filesystem
+ std::string resolved_filename_;
+ time_t filename_mtime_; // lastmod time for filename last time we loaded it
+
+ // What to do with whitespace at template-expand time
+ Strip strip_;
+
+ // Keeps track of where we are in reloading, or if there was an error loading
+ TemplateState state_;
+
+ // The cache we got this template from. This is not well-defined: a
+ // Template can be in more than one cache.
+ // TODO(csilvers): remove this once we deprecate the one user, which
+ // is ReloadIfChanged.
+ TemplateCache* template_cache_;
+
+ // The current template-contents, as read from the file
+ const char* template_text_;
+ int template_text_len_;
+
+ // The current parsed template structure. Has pointers into template_text_.
+ class SectionTemplateNode *tree_; // defined in template.cc
+
+ // Template markers have the form {{VARIABLE}}, etc. These constants
+ // define the {{ and }} that delimit template markers.
+ struct @ac_windows_dllexport@ MarkerDelimiters {
+ const char* start_marker;
+ size_t start_marker_len;
+ const char* end_marker;
+ size_t end_marker_len;
+
+ MarkerDelimiters() {
+ start_marker = "{{"; // The default start-marker
+ start_marker_len = strlen(start_marker);
+ end_marker = "}}";
+ end_marker_len = strlen(end_marker);
+ }
+ };
+
+ // The current parsing state. Used in BuildTree() and subroutines
+ struct @ac_windows_dllexport@ ParseState {
+ const char* bufstart;
+ const char* bufend;
+ enum { PS_UNUSED, GETTING_TEXT, GETTING_NAME } phase;
+ MarkerDelimiters current_delimiters;
+ ParseState()
+ : bufstart(NULL), bufend(NULL), phase(PS_UNUSED), current_delimiters()
+ {}
+ };
+ ParseState parse_state_;
+
+ // All templates are initialized to TC_MANUAL (no Auto-Escape). Then,
+ // during template parsing (BuildTree()), if an AUTOESCAPE pragma is
+ // encountered, the context changes appropriately.
+ TemplateContext initial_context_;
+ // Non-null if the template was initialized in an Auto-Escape mode that
+ // requires a parser (currently TC_HTML, TC_CSS and TC_JS).
+ ctemplate_htmlparser::HtmlParser *htmlparser_;
+
+ // A sorted list of trusted variable names, declared here because a unittest
+ // needs to verify that it is appropriately sorted (an unsorted array would
+ // lead to the binary search of this array failing).
+ static const char * const kSafeWhitelistedVariables[];
+ static const size_t kNumSafeWhitelistedVariables;
+
+ private:
+ friend class TemplateCache;
+ friend class TemplateCachePeer; // to access num_deletes_
+
+ // Internal implementation of Expand
+ bool ExpandWithDataAndCache(ExpandEmitter* output,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ const TemplateCache* cache) const;
+
+ // This is called for recursive expands, when we already hold template_lock.
+ bool ExpandLocked(ExpandEmitter* output,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ const TemplateCache* cache) const;
+
+ // Returns the lastmod time in mtime_
+ // For string-based templates, not backed by a file, this returns 0
+ time_t mtime() const;
+
+ // These are helper routines to StripFile. I would make them static
+ // inside template.cc, but they use the MarerDelimiters struct.
+ static bool ParseDelimiters(const char* text, size_t textlen,
+ MarkerDelimiters* delim);
+ static bool IsBlankOrOnlyHasOneRemovableMarker(const char** line, size_t* len,
+ const MarkerDelimiters& delim);
+ static size_t InsertLine(const char *line, size_t len, Strip strip,
+ const MarkerDelimiters& delim, char* buffer);
+
+ // This is only used by template_cache_test, via TemplateCachePeer.
+ static int num_deletes() { return num_deletes_; }
+
+ static int num_deletes_; // how many times the destructor has been called
+
+ // Can't invoke copy constructor or assignment operator
+ Template(const Template&);
+ void operator=(const Template &);
+};
+
+}
+
+#endif // CTEMPLATE_TEMPLATE_H_
diff --git a/src/ctemplate/template_annotator.h.in b/src/ctemplate/template_annotator.h.in
new file mode 100644
index 0000000..29c703a
--- /dev/null
+++ b/src/ctemplate/template_annotator.h.in
@@ -0,0 +1,136 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// The template expansion system provides a set of hooks that allow for
+// the insertion of diagnostic content into the output stream for the use
+// by content developers and testers. For instance, the default text
+// annotation mode inserts strings bracketed by {{ }} to describe every
+// occurrence of a dynamic substitution feature. That mode turns the
+// rendering into a logical text description of the construction of
+// template-based output. It is useful for regression testing of output
+// in conjunction with text-based diffing tools.
+//
+// An annotation mode is implemented with the TemplateAnnotator interface.
+// When template annotation is turned on, then during template expansion
+// whenever a dynamic substitution feature is encountered, a call is made
+// to one of the TemplateAnnotator functions. In response to a call
+// an implementation can render any additional content into the passed
+// emitter, which is the same emitter that the rendering output is going
+// to.
+//
+// Template annotation is turned on and the template annotator subclass
+// set by methods in @ac_google_namespace@::PerExpandData.
+
+#ifndef TEMPLATE_TEMPLATE_ANNOTATOR_H_
+#define TEMPLATE_TEMPLATE_ANNOTATOR_H_
+
+#include <string>
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+class ExpandEmitter;
+
+// This is the abstract interface for an annotation mode. A new annotation
+// mode is introduced by subclassing and implementing each function
+// to add annotation content. There is one function for each internal
+// template expansion event type. The emitter argument passed to the
+// function is the same stream that the expanding content is being output to;
+// so the action of an implementation will be to add additional inline
+// content. The emitter argument is never to be remembered beyond each
+// function call.
+class @ac_windows_dllexport@ TemplateAnnotator {
+ public:
+ TemplateAnnotator() { }
+ virtual ~TemplateAnnotator() { }
+
+ // Called before processing a subtemplate include marker.
+ // Passed value is the include marker name.
+ virtual void EmitOpenInclude(ExpandEmitter* emitter, const std::string& value) = 0;
+ // Called after processing a subtemplate include marker.
+ virtual void EmitCloseInclude(ExpandEmitter* emitter) = 0;
+
+ // Called before opening a template or subtemplate file for processing.
+ // Passed value is the filename.
+ virtual void EmitOpenFile(ExpandEmitter* emitter, const std::string& value) = 0;
+ // Called after processing a template or subtemplate file.
+ virtual void EmitCloseFile(ExpandEmitter* emitter) = 0;
+
+ // Called before processing a section.
+ // Passed value is the section name.
+ virtual void EmitOpenSection(ExpandEmitter* emitter, const std::string& value) = 0;
+ // Called after processing a section.
+ virtual void EmitCloseSection(ExpandEmitter* emitter) = 0;
+
+ // Called before processing a variable marker.
+ // Passed value is the variable name.
+ virtual void EmitOpenVariable(ExpandEmitter* emitter,
+ const std::string& value) = 0;
+ // Called after processing a variable marker.
+ virtual void EmitCloseVariable(ExpandEmitter* emitter) = 0;
+
+ virtual void EmitFileIsMissing(ExpandEmitter* emitter,
+ const std::string& value) = 0;
+
+ private:
+ // Can't invoke copy constructor or assignment operator
+ TemplateAnnotator(const TemplateAnnotator&);
+ void operator=(const TemplateAnnotator&);
+};
+
+// This is a concrete template annotator class that inserts annotations
+// that have a standard text form bracketed by {{ }}. It is used as
+// the default annotation implementation when annotation is turned on
+// by PerExpandData and no annotator type is specified.
+class @ac_windows_dllexport@ TextTemplateAnnotator : public TemplateAnnotator {
+ public:
+ TextTemplateAnnotator() { }
+ virtual void EmitOpenInclude(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseInclude(ExpandEmitter* emitter);
+ virtual void EmitOpenFile(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseFile(ExpandEmitter* emitter);
+ virtual void EmitOpenSection(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseSection(ExpandEmitter* emitter);
+ virtual void EmitOpenVariable(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseVariable(ExpandEmitter* emitter);
+ virtual void EmitFileIsMissing(ExpandEmitter* emitter,
+ const std::string& value);
+
+ private:
+ // Can't invoke copy constructor or assignment operator
+ TextTemplateAnnotator(const TextTemplateAnnotator&);
+ void operator=(const TextTemplateAnnotator&);
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_ANNOTATOR_H_
diff --git a/src/ctemplate/template_cache.h.in b/src/ctemplate/template_cache.h.in
new file mode 100644
index 0000000..998eff2
--- /dev/null
+++ b/src/ctemplate/template_cache.h.in
@@ -0,0 +1,368 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// This file implements the Template Cache used to store templates.
+
+#ifndef TEMPLATE_TEMPLATE_CACHE_H_
+#define TEMPLATE_TEMPLATE_CACHE_H_
+
+#include @ac_cv_cxx_hash_map@ // for @ac_cv_cxx_hash_map_class@<>
+#include <string> // for string
+#include <utility> // for pair
+#include <vector> // for vector<>
+#include <ctemplate/template_emitter.h> // for ExpandEmitter, etc
+#include <ctemplate/template_enums.h> // for Strip
+#include <ctemplate/template_string.h>
+#include <ctemplate/per_expand_data.h>
+@ac_google_start_namespace@
+class FileStat;
+}
+class Mutex;
+class TemplateCacheUnittest;
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+class PerExpandData;
+class Template;
+class TemplateCachePeer;
+class TemplateDictionaryInterface;
+
+// A cache to store parsed templates.
+class @ac_windows_dllexport@ TemplateCache {
+ public:
+ TemplateCache();
+ ~TemplateCache();
+
+ // ---- CREATING A TEMPLATE OBJECT -------
+ // LoadTemplate
+ // StringToTemplateCache
+
+ // Attempts to load the template object stored under its filename,
+ // into the template cache. It first checks if the object is already
+ // in the cache. Any object retrieved from the cache is then
+ // checked to see if its status is marked for "reload if changed."
+ // If so, ReloadIfChanged is called on the retrieved object. Returns
+ // true if the object is loaded. Also returns true if the object
+ // already exists, and no reload was required.
+ //
+ // When it fails to retrieve one from the cache, it creates a new
+ // template object, passing the filename and 'strip' values to the
+ // constructor. (See constructor below for the meaning of the
+ // flags.) If it succeeds in creating an object, including loading
+ // and parsing the associated template file, the object is stored in
+ // the cache, and the method returns true.
+ //
+ // If it fails in loading and parsing the template file, either
+ // because the file was not found or it contained syntax errors,
+ // then the newly created object is deleted and the method returns
+ // false. (NOTE: This description is much longer and less precise
+ // and probably harder to understand than the method itself. Read
+ // the code.)
+ //
+ // To enable Auto-Escape on that template, place the corresponding
+ // AUTOESCAPE pragma at the top of the template file. The template
+ // will then be Auto-Escaped independently of the template it may be
+ // included from or the templates it may include.
+ //
+ // 'Strip' indicates how to handle whitespace when expanding the
+ // template. DO_NOT_STRIP keeps the template exactly as-is.
+ // STRIP_BLANK_LINES elides all blank lines in the template.
+ // STRIP_WHITESPACE elides all blank lines, and also all whitespace
+ // at either the beginning or end of a line. See template constructor
+ // for more details.
+ bool LoadTemplate(const TemplateString& filename, Strip strip);
+
+ // Parses the string as a template file (e.g. "Hello {{WORLD}}"),
+ // and inserts it into the parsed template cache, so it can later be
+ // used by the user. The user specifies a key and a strip, which are
+ // later passed in to expand the template.
+ // Returns true if the template was successfully parsed and
+ // inserted to the template cache, or false otherwise. In particular,
+ // we return false if a string was already cached with the given key.
+ // NOTE: to include this template from within another template (via
+ // "{{>TEMPLATE_THAT_COMES_FROM_A_STRING}}"), the argument you pass
+ // to TemplateDictionary::SetFilename() is the key you used to register
+ // the string-template.
+ bool StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content,
+ Strip strip);
+ bool StringToTemplateCache(const TemplateString& key,
+ const char* content,
+ size_t content_len,
+ Strip strip) {
+ return StringToTemplateCache(key,
+ TemplateString(content, content_len),
+ strip);
+ }
+
+ // ---- EXPANDING A TEMPLATE -------
+ // ExpandWithData
+ // ExpandFrozen
+
+ // This returns false if the expand failed for some reason: filename
+ // could not be found on disk (and isn't already in the cache), or
+ // the template is mal-formed, or a sub-included template couldn't
+ // be found. Note that even if it returns false, it may have emitted
+ // some output to ExpandEmitter, before it noticed the problem.
+ bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ ExpandEmitter* output);
+ bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data,
+ std::string* output_buffer) {
+ if (output_buffer == NULL) return false;
+ StringEmitter e(output_buffer);
+ return ExpandWithData(filename, strip, dictionary, per_expand_data, &e);
+ }
+
+ // Const version of ExpandWithData, intended for use with frozen
+ // caches. This method returns false if the requested
+ // template-filename is not found in the cache, rather than fetching
+ // the template from disk and continuing, as ExpandWithData does.
+ // (That is why the method can be const.) Likewise, it will return
+ // false, rather than fetch, if any sub-included template filename
+ // is not found in the cache.
+ // Unfortunately, the only way to enforce this last requirement at
+ // the moment is to have the template-cache be Frozen(). So that
+ // is a pre-requisite for calling this method. It may be relaxed
+ // in the future (if we rewrite the control flow to pass around the
+ // necessary state).
+ // Like ExpandWithData(), this may write partial results into output
+ // even if it returns false (due to template error or file not found).
+ bool ExpandNoLoad(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ ExpandEmitter* output) const;
+ bool ExpandNoLoad(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data,
+ std::string* output_buffer) const {
+ if (output_buffer == NULL) return false;
+ StringEmitter e(output_buffer);
+ return ExpandNoLoad(filename, strip, dictionary, per_expand_data, &e);
+ }
+
+ // ---- FINDING A TEMPLATE FILE -------
+
+ // Sets the root directory for all templates used by the program.
+ // After calling this method, the filename passed to GetTemplate may
+ // be a relative pathname (no leading '/'), in which case this
+ // root-directory is prepended to the filename. This clears the old
+ // 'main' root directory, and also all alternate root directories
+ // that may had been added previously.
+ bool SetTemplateRootDirectory(const std::string& directory);
+
+ // Adds an additional search path for all templates used by the
+ // program. You may call this multiple times.
+ bool AddAlternateTemplateRootDirectory(const std::string& directory);
+
+ // Returns the 'main' root directory set by SetTemplateRootDirectory().
+ std::string template_root_directory() const;
+
+ // Given an unresolved filename, look through the template search
+ // path to see if the template can be found. If so, return the path
+ // of the resolved filename, otherwise return an empty string.
+ std::string FindTemplateFilename(const std::string& unresolved)
+ const;
+
+ // ---- MANAGING THE CACHE -------
+ // Freeze
+ // Delete
+ // ClearCache
+ // ReloadAllIfChanged
+ // Clone
+
+ // Marks the template cache as immutable. After this method is called,
+ // the cache can no longer be modified by loading new templates or
+ // reloading existing templates. During expansion only cached
+ // included templates will be used, they won't be loaded on-demand.
+ void Freeze();
+
+ // Delete
+ // Deletes one template object from the cache, if it exists.
+ // This can be used for either file- or string-based templates.
+ // Returns true if the object was deleted, false otherwise.
+ bool Delete(const TemplateString& key);
+
+ // ClearCache
+ // Deletes all the template objects in the cache and all raw
+ // contents cached from StringToTemplateCache. This should only
+ // be done once, just before exiting the program and after all
+ // template expansions are completed. (If you want to refresh the
+ // cache, the correct method to use is ReloadAllIfChanged, not
+ // this one.) Note: this method is not necessary unless you are
+ // testing for memory leaks. Calling this before exiting the
+ // program will prevent unnecessary reporting in that case.
+ void ClearCache();
+
+ // ReloadAllIfChanged
+ // If IMMEDIATE_RELOAD, reloads and parses all templates right away,
+ // if the corresponding template files have changed.
+ // If LAZY_RELOAD, then sets the reload bit on all templates.
+ // Subsequent call to GetTemplate() checks if file has changed, and if so
+ // reloads and parses the file into the cache.
+ //
+ // IMMEDIATE_RELOAD gives a more consistent snapshot of the current
+ // templates, since all templates in the cache are reloaded at
+ // (approximately) the same time. On the other hand, LAZY_RELOAD
+ // causes less of a latency spike, since it does not require
+ // loading lots of templates from disk at the same time. If in
+ // doubt, LAZY_RELOAD is probably a better choice.
+
+ // If a file with the same name as an existing template-file, is added
+ // in another search path, ReloadAllIfChanged will pick up the file in the
+ // earlier search-path.
+ enum ReloadType { LAZY_RELOAD, IMMEDIATE_RELOAD };
+ void ReloadAllIfChanged(ReloadType reload_tyle);
+
+ // Clone
+ // Returns a copy of the cache. It makes a shallow copy of the
+ // parsed_template_cache_, incrementing refcount of templates.
+ // The caller is responsible for deallocating the returned TemplateCache.
+ // NOTE(user): Annotalysis expects this method to have a lock for
+ // a TemplateCache instance local to the method, but we
+ // know that no other threads will have access to the
+ // instance, so ignore thread safety errors.
+ TemplateCache* Clone() const;
+
+ // ---- INSPECTING THE CACHE -------
+ // Dump
+ // DumpToString
+ // TODO(csilvers): implement these?
+
+ private:
+ // TODO(csilvers): nix Template friend once Template::ReloadIfChanged is gone
+ friend class Template; // for ResolveTemplateFilename
+ friend class TemplateTemplateNode; // for ExpandLocked
+ friend class TemplateCachePeer; // for unittests
+ friend class ::TemplateCacheUnittest; // for unittests
+
+ class RefcountedTemplate;
+ struct CachedTemplate;
+ class TemplateCacheHash;
+ class RefTplPtrHash;
+ // due to a bug(?) in MSVC, TemplateCachePeer won't compile unless this
+ // particular typedef is public. Ugh.
+ public:
+ typedef std::pair<TemplateId, int> TemplateCacheKey;
+ private:
+ typedef @ac_cv_cxx_hash_map_class@<TemplateCacheKey, CachedTemplate, TemplateCacheHash>
+ TemplateMap;
+ typedef @ac_cv_cxx_hash_map_class@<RefcountedTemplate*, int, RefTplPtrHash> TemplateCallMap;
+ // Where to search for files.
+ typedef std::vector<std::string> TemplateSearchPath;
+
+ // GetTemplate
+ // This method is deprecated. It exists here because it is called by
+ // Template::GetTemplate. Also this is used in tests.
+ const Template* GetTemplate(const TemplateString& key, Strip strip);
+
+ bool ResolveTemplateFilename(const std::string& unresolved,
+ std::string* resolved,
+ FileStat* statbuf) const;
+
+ // This is used only for internal (recursive) calls to Expand due
+ // to internal template-includes. It doesn't try to acquire the
+ // global template_lock again, in template.cc.
+ // TODO(csilvers): remove this when template.cc's g_template_lock goes away.
+ bool ExpandLocked(const TemplateString& filename, Strip strip,
+ ExpandEmitter* output,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data);
+
+ bool AddAlternateTemplateRootDirectoryHelper(
+ const std::string& directory,
+ bool clear_template_search_path);
+
+ // DoneWithGetTemplatePtrs
+ // For historical reasons, GetTemplate() returns a raw Template
+ // pointer rather than a refcounted pointer. So it's impossible
+ // for the user to call DecRef on the template when it's done
+ // using it. To make up for that, we provide this routine, which
+ // says "call DecRef()" on *all* Templates ever used by
+ // GetTemplate(). It's safe for the client to call this when it's
+ // done using all templates it's ever retrieved before (via
+ // GetTemplate). Most likely, the user will call this indirectly,
+ // via ClearCache().
+ // TODO(panicker): Consider making this method public.
+ void DoneWithGetTemplatePtrs();
+
+ // ValidTemplateFilename
+ // Validates the user provided filename before constructing the template
+ bool IsValidTemplateFilename(const std::string& filename,
+ std::string* resolved_filename,
+ FileStat* statbuf) const;
+
+ // GetTemplateLocked
+ // Internal version of GetTemplate. It's used when the function already
+ // has a write-lock on mutex_. It returns a pointer to a refcounted
+ // template (in the cache), or NULL if the template is not found.
+ // Its used by GetTemplate & ForceReloadAllIfChanged.
+ RefcountedTemplate* GetTemplateLocked(
+ const TemplateString& filename,
+ Strip strip,
+ const TemplateCacheKey& key);
+
+ // Refcount
+ // Testing only. Returns the refcount of a template, given its cache key.
+ int Refcount(const TemplateCacheKey template_cache_key) const;
+
+ // GetCachedTemplate
+ // Debug only. Returns whether the cache key is in the parsed cache.
+ bool TemplateIsCached(const TemplateCacheKey template_cache_key) const;
+
+ TemplateMap* parsed_template_cache_;
+ bool is_frozen_;
+ TemplateSearchPath search_path_;
+
+ // Since GetTemplate() returns a raw pointer, it's impossible for
+ // the caller to call DecRef() on the returned template when it's
+ // done using it. To make up for that, we store each retval of
+ // GetTemplate in this data structure. Then the user can call
+ // DecRef() on all of them at once, via a DoneWithGetTemplatePtrs()
+ // (which they will probably get at via a call to ClearCache()).
+ TemplateCallMap* get_template_calls_;
+
+ Mutex* const mutex_;
+ Mutex* const search_path_mutex_;
+
+ // Can't invoke copy constructor or assignment operator
+ TemplateCache(const TemplateCache&);
+ void operator=(const TemplateCache &);
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_CACHE_H_
diff --git a/src/ctemplate/template_dictionary.h.in b/src/ctemplate/template_dictionary.h.in
new file mode 100644
index 0000000..e0c9942
--- /dev/null
+++ b/src/ctemplate/template_dictionary.h.in
@@ -0,0 +1,454 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// Based on the 'old' TemplateDictionary by Frank Jernigan.
+//
+// A template dictionary maps names (as found in template files)
+// to their values. There are three types of names:
+// variables: value is a string.
+// sections: value is a list of sub-dicts to use when expanding the section;
+// the section is expanded once per sub-dict.
+// template-include: value is a list of pairs: name of the template file
+// to include, and the sub-dict to use when expanding it.
+// TemplateDictionary has routines for setting these values.
+//
+// For (many) more details, see the doc/ directory.
+
+#ifndef TEMPLATE_TEMPLATE_DICTIONARY_H_
+#define TEMPLATE_TEMPLATE_DICTIONARY_H_
+
+#include <stdarg.h> // for StringAppendV()
+#include <stddef.h> // for size_t and ptrdiff_t
+#include <stdlib.h> // for NULL
+#include <sys/types.h>
+#include <functional> // for less<>
+#include <map>
+#include <string>
+#include <vector>
+
+#include <ctemplate/str_ref.h>
+#include <ctemplate/template_dictionary_interface.h>
+#include <ctemplate/template_modifiers.h>
+#include <ctemplate/template_string.h>
+
+@ac_windows_dllexport_defines@
+
+@ac_google_start_namespace@
+template <class T, class C> class ArenaAllocator;
+class UnsafeArena;
+template<typename A, int B, typename C, typename D> class small_map;
+template<typename NormalMap> class small_map_default_init; // in small_map.h
+}
+
+namespace ctemplate {
+
+
+class @ac_windows_dllexport@ TemplateDictionary : public TemplateDictionaryInterface {
+ public:
+ // name is used only for debugging.
+ // arena is used to store all names and values. It can be NULL (the
+ // default), in which case we create own own arena.
+ explicit TemplateDictionary(const TemplateString& name,
+ UnsafeArena* arena=NULL);
+ ~TemplateDictionary();
+
+ // If you want to be explicit, you can use NO_ARENA as a synonym to NULL.
+ static UnsafeArena* const NO_ARENA;
+
+ std::string name() const {
+ return std::string(name_.data(), name_.size());
+ }
+
+ // Returns a recursive copy of this dictionary. This dictionary
+ // *must* be a "top-level" dictionary (that is, not created via
+ // AddSectionDictionary() or AddIncludeDictionary()). Caller owns
+ // the resulting dict, and must delete it. If arena is NULL, we
+ // create our own. Returns NULL if the copy fails (probably because
+ // the "top-level" rule was violated).
+ TemplateDictionary* MakeCopy(const TemplateString& name_of_copy,
+ UnsafeArena* arena=NULL);
+
+ // --- Routines for VARIABLES
+ // These are the five main routines used to set the value of a variable.
+ // As always, wherever you see TemplateString, you can also pass in
+ // either a char* or a C++ string, or a TemplateString(s, slen).
+
+ void SetValue(const TemplateString variable, const TemplateString value);
+ void SetIntValue(const TemplateString variable, long value);
+ void SetFormattedValue(const TemplateString variable, const char* format, ...)
+#if @ac_google_attribute@
+ __attribute__((__format__ (__printf__, 3, 4)))
+#endif
+ ; // starts at 3 because of implicit 1st arg 'this'
+
+ class SetProxy {
+ public:
+ SetProxy(TemplateDictionary& dict, const TemplateString& variable) :
+ dict_(dict),
+ variable_(variable) {
+ }
+
+ void operator=(str_ref value) {
+ dict_.SetValue(variable_, TemplateString(value.data(), value.size()));
+ }
+
+ void operator=(long value) {
+ dict_.SetIntValue(variable_, value);
+ }
+
+ private:
+ TemplateDictionary& dict_;
+ const TemplateString& variable_;
+ };
+
+ SetProxy operator[](const TemplateString& variable) {
+ return SetProxy(*this, variable);
+ }
+
+ // We also let you set values in the 'global' dictionary which is
+ // referenced when all other dictionaries fail. Note this is a
+ // static method: no TemplateDictionary instance needed. Since
+ // this routine is rarely used, we don't provide variants.
+ static void SetGlobalValue(const TemplateString variable,
+ const TemplateString value);
+
+ // This is used for a value that you want to be 'global', but only
+ // in the scope of a given template, including all its sections and
+ // all its sub-included dictionaries. The main difference between
+ // SetTemplateGlobalValue() and SetValue(), is that
+ // SetTemplateGlobalValue() values persist across template-includes.
+ // This is intended for session-global data; since that should be
+ // fairly rare, we don't provide variants.
+ void SetTemplateGlobalValue(const TemplateString variable,
+ const TemplateString value);
+
+ // Similar SetTemplateGlobalValue above, this method shows a section in this
+ // template, all its sections, and all its template-includes. This is intended
+ // for session-global data, for example allowing you to show variant portions
+ // of your template for certain browsers/languages without having to call
+ // ShowSection on each template you use.
+ void ShowTemplateGlobalSection(const TemplateString variable);
+
+ // These routines are like SetValue and SetTemplateGlobalValue, but
+ // they do not make a copy of the input data. THE CALLER IS
+ // RESPONSIBLE FOR ENSURING THE PASSED-IN STRINGS LIVE FOR AT LEAST
+ // AS LONG AS THIS DICTIONARY! In general, they yield a quite minor
+ // performance increase for significant increased code fragility,
+ // so do not use them unless you really need the speed improvements.
+ void SetValueWithoutCopy(const TemplateString variable,
+ const TemplateString value);
+ void SetTemplateGlobalValueWithoutCopy(const TemplateString variable,
+ const TemplateString value);
+
+
+ // --- Routines for SECTIONS
+ // We show a section once per dictionary that is added with its name.
+ // Recall that lookups are hierarchical: if a section tried to look
+ // up a variable in its sub-dictionary and fails, it will look next
+ // in its parent dictionary (us). So it's perfectly appropriate to
+ // keep the sub-dictionary empty: that will show the section once,
+ // and take all var definitions from us. ShowSection() is a
+ // convenience routine that does exactly that.
+
+ // Creates an empty dictionary whose parent is us, and returns it.
+ // As always, wherever you see TemplateString, you can also pass in
+ // either a char* or a C++ string, or a TemplateString(s, slen).
+ TemplateDictionary* AddSectionDictionary(const TemplateString section_name);
+ void ShowSection(const TemplateString section_name);
+
+ // A convenience method. Often a single variable is surrounded by
+ // some HTML that should not be printed if the variable has no
+ // value. The way to do this is to put that html in a section.
+ // This method makes it so the section is shown exactly once, with a
+ // dictionary that maps the variable to the proper value. If the
+ // value is "", on the other hand, this method does nothing, so the
+ // section remains hidden.
+ void SetValueAndShowSection(const TemplateString variable,
+ const TemplateString value,
+ const TemplateString section_name);
+
+
+ // --- Routines for TEMPLATE-INCLUDES
+ // Included templates are treated like sections, but they require
+ // the name of the include-file to go along with each dictionary.
+
+ TemplateDictionary* AddIncludeDictionary(const TemplateString variable);
+
+ // This is required for include-templates; it specifies what template
+ // to include. But feel free to call this on any dictionary, to
+ // document what template-file the dictionary is intended to go with.
+ void SetFilename(const TemplateString filename);
+
+ // --- DEBUGGING TOOLS
+
+ // Logs the contents of a dictionary and its sub-dictionaries.
+ // Dump goes to stdout/stderr, while DumpToString goes to the given string.
+ // 'indent' is how much to indent each line of the output.
+ void Dump(int indent=0) const;
+ virtual void DumpToString(std::string* out, int indent=0) const;
+
+
+ // --- DEPRECATED ESCAPING FUNCTIONALITY
+
+ // Escaping in the binary has been deprecated in favor of using modifiers
+ // to do the escaping in the template:
+ // "...{{MYVAR:html_escape}}..."
+ void SetEscapedValue(const TemplateString variable, const TemplateString value,
+ const TemplateModifier& escfn);
+ void SetEscapedFormattedValue(const TemplateString variable,
+ const TemplateModifier& escfn,
+ const char* format, ...)
+#if @ac_google_attribute@
+ __attribute__((__format__ (__printf__, 4, 5)))
+#endif
+ ; // starts at 4 because of implicit 1st arg 'this'
+
+
+ private:
+ friend class SectionTemplateNode; // for access to GetSectionValue(), etc.
+ friend class TemplateTemplateNode; // for access to GetSectionValue(), etc.
+ friend class VariableTemplateNode; // for access to GetSectionValue(), etc.
+ // For unittesting code using a TemplateDictionary.
+ friend class TemplateDictionaryPeer;
+
+ class DictionaryPrinter; // nested class
+ friend class DictionaryPrinter;
+
+ // We need this functor to tell small_map how to create a map<> when
+ // it decides to do so: we want it to create that map on the arena.
+ class map_arena_init;
+
+ typedef std::vector<TemplateDictionary*,
+ ArenaAllocator<TemplateDictionary*, UnsafeArena> >
+ DictVector;
+ // The '4' here is the size where small_map switches from vector<> to map<>.
+ typedef small_map<std::map<TemplateId, TemplateString, std::less<TemplateId>,
+ ArenaAllocator<std::pair<const TemplateId, TemplateString>,
+ UnsafeArena> >,
+ 4, std::equal_to<TemplateId>, map_arena_init>
+ VariableDict;
+ typedef small_map<std::map<TemplateId, DictVector*, std::less<TemplateId>,
+ ArenaAllocator<std::pair<const TemplateId, DictVector*>,
+ UnsafeArena> >,
+ 4, std::equal_to<TemplateId>, map_arena_init>
+ SectionDict;
+ typedef small_map<std::map<TemplateId, DictVector*, std::less<TemplateId>,
+ ArenaAllocator<std::pair<const TemplateId, DictVector*>,
+ UnsafeArena> >,
+ 4, std::equal_to<TemplateId>, map_arena_init>
+ IncludeDict;
+ // This is used only for global_dict_, which is just like a VariableDict
+ // but does not bother with an arena (since this memory lives forever).
+ typedef small_map<std::map<TemplateId, TemplateString, std::less<TemplateId> >,
+ 4, std::equal_to<TemplateId>,
+ small_map_default_init<
+ std::map<TemplateId, TemplateString,
+ std::less<TemplateId> > > >
+ GlobalDict;
+
+
+ // These are helper functions to allocate the parts of the dictionary
+ // on the arena.
+ template<typename T> inline void LazilyCreateDict(T** dict);
+ inline void LazyCreateTemplateGlobalDict();
+ inline DictVector* CreateDictVector();
+ inline TemplateDictionary* CreateTemplateSubdict(
+ const TemplateString& name,
+ UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner);
+
+ // This is a helper function to insert <key,value> into m.
+ // Normally, we'd just use m[key] = value, but map rules
+ // require default constructor to be public for that to compile, and
+ // for some types we'd rather not allow that. HashInsert also inserts
+ // the key into an id(key)->key map, to allow for id-lookups later.
+ template<typename MapType, typename ValueType>
+ static void HashInsert(MapType* m, TemplateString key, ValueType value);
+
+ // Constructor created for all children dictionaries. This includes
+ // both a pointer to the parent dictionary and also the the
+ // template-global dictionary from which all children (both
+ // IncludeDictionary and SectionDictionary) inherit. Values are
+ // filled into global_template_dict via SetTemplateGlobalValue.
+ explicit TemplateDictionary(const TemplateString& name,
+ class UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner);
+
+ // Helps set up the static stuff. Must be called exactly once before
+ // accessing global_dict_. GoogleOnceInit() is used to manage that
+ // initialization in a thread-safe way.
+ static void SetupGlobalDict();
+
+ // Utility functions for copying a string into the arena.
+ // Memdup also copies in a trailing NUL, which is why we have the
+ // trailing-NUL check in the TemplateString version of Memdup.
+ TemplateString Memdup(const char* s, size_t slen);
+ TemplateString Memdup(const TemplateString& s) {
+ if (s.is_immutable() && s.data()[s.size()] == '\0') {
+ return s;
+ }
+ return Memdup(s.data(), s.size());
+ }
+
+ // Used for recursive MakeCopy calls.
+ TemplateDictionary* InternalMakeCopy(
+ const TemplateString& name_of_copy,
+ UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner);
+
+ // A helper for creating section and include dicts.
+ static std::string CreateSubdictName(
+ const TemplateString& dict_name, const TemplateString& sub_name,
+ size_t index, const char* suffix);
+
+ // Must be called whenever we add a value to one of the dictionaries above,
+ // to ensure that we can reconstruct the id -> string mapping.
+ static void AddToIdToNameMap(TemplateId id, const TemplateString& str);
+
+ // Used to do the formatting for the SetFormatted*() functions
+ static int StringAppendV(char* space, char** out,
+ const char* format, va_list ap);
+
+ // How Template::Expand() and its children access the template-dictionary.
+ // These fill the API required by TemplateDictionaryInterface.
+ virtual TemplateString GetValue(const TemplateString& variable) const;
+ virtual bool IsHiddenSection(const TemplateString& name) const;
+ virtual bool IsUnhiddenSection(const TemplateString& name) const {
+ return !IsHiddenSection(name);
+ }
+ virtual bool IsHiddenTemplate(const TemplateString& name) const;
+ virtual const char* GetIncludeTemplateName(
+ const TemplateString& variable, int dictnum) const;
+
+ // Determine whether there's anything set in this dictionary
+ bool Empty() const;
+
+ // This is needed by DictionaryPrinter because it's not a friend
+ // of TemplateString, but we are
+ static std::string PrintableTemplateString(
+ const TemplateString& ts) {
+ return std::string(ts.data(), ts.size());
+ }
+ static bool InvalidTemplateString(const TemplateString& ts) {
+ return ts.data() == NULL;
+ }
+ // Compilers differ about whether nested classes inherit our friendship.
+ // The only thing DictionaryPrinter needs is IdToString, so just re-export.
+ static TemplateString IdToString(TemplateId id) { // for DictionaryPrinter
+ return TemplateString::IdToString(id);
+ }
+
+ // CreateTemplateIterator
+ // This is SectionIterator exactly, just with a different name to
+ // self-document the fact the value applies to a template include.
+ // Caller frees return value.
+ virtual TemplateDictionaryInterface::Iterator* CreateTemplateIterator(
+ const TemplateString& section_name) const;
+
+ // CreateSectionIterator
+ // Factory method implementation that constructs a iterator representing the
+ // set of dictionaries associated with a section name, if any. This
+ // implementation checks the local dictionary itself, not the template-wide
+ // dictionary or the global dictionary.
+ // Caller frees return value.
+ virtual TemplateDictionaryInterface::Iterator* CreateSectionIterator(
+ const TemplateString& section_name) const;
+
+ // TemplateDictionary-specific implementation of dictionary iterators.
+ template <typename T> // T is *TemplateDictionary::const_iterator
+ class Iterator : public TemplateDictionaryInterface::Iterator {
+ protected:
+ friend class TemplateDictionary;
+ Iterator(T begin, T end) : begin_(begin), end_(end) { }
+ public:
+ virtual ~Iterator() { }
+ virtual bool HasNext() const;
+ virtual const TemplateDictionaryInterface& Next();
+ private:
+ T begin_;
+ const T end_;
+ };
+
+ // A small helper factory function for Iterator
+ template <typename T>
+ static Iterator<typename T::const_iterator>* MakeIterator(const T& dv) {
+ return new Iterator<typename T::const_iterator>(dv.begin(), dv.end());
+ }
+
+
+ // The "name" of the dictionary for debugging output (Dump, etc.)
+ // The arena, also set at construction time.
+ class UnsafeArena* const arena_;
+ bool should_delete_arena_; // only true if we 'new arena' in constructor
+ TemplateString name_; // points into the arena, or to static memory
+
+ // The three dictionaries that I own -- for vars, sections, and template-incs
+ VariableDict* variable_dict_;
+ SectionDict* section_dict_;
+ IncludeDict* include_dict_;
+
+
+ // The template_global_dict is consulted if a lookup in the variable, section,
+ // or include dicts named above fails. It forms a convenient place to store
+ // session-specific data that's applicable to all templates in the dictionary
+ // tree.
+ // For the parent-template, template_global_dict_ is not NULL, and
+ // template_global_dict_owner_ is this. For all of its children,
+ // template_global_dict_ is NULL, and template_global_dict_owner_ points to
+ // the root parent-template (the one with the non-NULL template_global_dict_).
+ TemplateDictionary* template_global_dict_;
+ TemplateDictionary* template_global_dict_owner_;
+
+ // My parent dictionary, used when variable lookups at this level fail.
+ // Note this is only for *variables* and *sections*, not templates.
+ TemplateDictionary* parent_dict_;
+ // The static, global dictionary, at the top of the parent-dictionary chain
+ static GlobalDict* global_dict_;
+ static TemplateString* empty_string_; // what is returned on lookup misses
+
+ // The filename associated with this dictionary. If set, this declares
+ // what template the dictionary is supposed to be expanded with. Required
+ // for template-includes, optional (but useful) for 'normal' dicts.
+ const char* filename_;
+
+ private:
+ // Can't invoke copy constructor or assignment operator
+ TemplateDictionary(const TemplateDictionary&);
+ void operator=(const TemplateDictionary&);
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_DICTIONARY_H_
diff --git a/src/ctemplate/template_dictionary_interface.h.in b/src/ctemplate/template_dictionary_interface.h.in
new file mode 100644
index 0000000..0cc9171
--- /dev/null
+++ b/src/ctemplate/template_dictionary_interface.h.in
@@ -0,0 +1,143 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: williasr@google.com (Scott Williams)
+//
+// This file implements the TemplateDictionaryInterface class. This interface
+// forms the root of the TemplateDictionary class tree, but the interface is
+// minimal enough to allow other sources of template data. Note that the
+// TemplateDictionaryInterface class enumerates the properties expected by
+// Template: it doesn't constrain how data gets into the
+// TemplateDictionaryInterface class to begin with. For these methods, see
+// TemplateDictionary.
+//
+
+#ifndef TEMPLATE_TEMPLATE_DICTIONARY_INTERFACE_H_
+#define TEMPLATE_TEMPLATE_DICTIONARY_INTERFACE_H_
+
+#include <stdlib.h>
+#include <string>
+#include <ctemplate/template_string.h>
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+const int kIndent = 2; // num spaces to indent each level -- used with dump
+
+// TemplateDictionaryInterface
+// The template data contains the associated values for
+// variables, the hidden/visible state for sections and included
+// templates, the associated set of dictionaries for sections and
+// included templates, and the template filenames to be expanded in
+// place of template-include nodes.
+class @ac_windows_dllexport@ TemplateDictionaryInterface {
+ public:
+ // TemplateDictionaryInterface destructor
+ virtual ~TemplateDictionaryInterface() {}
+
+ protected:
+ // The interface as follows is used at expand-time by Expand.
+ friend class VariableTemplateNode;
+ friend class SectionTemplateNode;
+ friend class TemplateTemplateNode;
+ // This class reaches into our internals for testing.
+ friend class TemplateDictionaryPeer;
+ friend class TemplateDictionaryPeerIterator;
+
+ // GetSectionValue
+ // Returns the value of a variable.
+ virtual TemplateString GetValue(const TemplateString& variable) const = 0;
+
+ // IsHiddenSection
+ // A predicate to indicate the current hidden/visible state of a section
+ // whose name is passed to it.
+ virtual bool IsHiddenSection(const TemplateString& name) const = 0;
+
+ // Dump a string representation of this dictionary to the supplied string.
+ virtual void DumpToString(std::string* out, int level) const = 0;
+
+ // TemplateDictionaryInterface is an abstract class, so its constructor is
+ // only visible to its subclasses.
+ TemplateDictionaryInterface() {}
+
+ class Iterator {
+ protected:
+ Iterator() { }
+ public:
+ virtual ~Iterator() { }
+
+ // Returns false if the iterator is exhausted.
+ virtual bool HasNext() const = 0;
+
+ // Returns the current referent and increments the iterator to the next.
+ virtual const TemplateDictionaryInterface& Next() = 0;
+ };
+
+ // IsHiddenTemplate
+ // Returns true if the template include is hidden. This is analogous to
+ // IsHiddenSection, but for template nodes.
+ virtual bool IsHiddenTemplate(const TemplateString& name) const = 0;
+
+ // GetIncludeTemplateName
+ // Returns the name of the template associated with the given template
+ // include variable. If more than one dictionary is attached to the include
+ // symbol, dictnum can be used to disambiguate which include name you mean.
+ virtual const char* GetIncludeTemplateName(
+ const TemplateString& variable, int dictnum) const = 0;
+
+ // CreateTemplateIterator
+ // A factory method for constructing an iterator representing the
+ // subdictionaries of the given include node. The caller is
+ // responsible for deleting the return value when it's done with it.
+ virtual Iterator* CreateTemplateIterator(
+ const TemplateString& section) const = 0;
+
+ // CreateSectionIterator
+ // A factory method for constructing an iterator representing the
+ // subdictionaries of the given section node. The caller is
+ // responsible for deleting the return value when it's done with it.
+ virtual Iterator* CreateSectionIterator(
+ const TemplateString& section) const = 0;
+
+ // IsUnhiddenSection
+ // Returns true if the section has been marked visible and false otherwise.
+ virtual bool IsUnhiddenSection(
+ const TemplateString& name) const = 0;
+
+ private:
+ // Disallow copy and assign.
+ TemplateDictionaryInterface(const TemplateDictionaryInterface&);
+ void operator=(const TemplateDictionaryInterface&);
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_DICTIONARY_INTERFACE_H_
diff --git a/src/ctemplate/template_emitter.h.in b/src/ctemplate/template_emitter.h.in
new file mode 100644
index 0000000..fc29098
--- /dev/null
+++ b/src/ctemplate/template_emitter.h.in
@@ -0,0 +1,70 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// When we expand a template, we expand into an abstract "emitter".
+// This is typically a string, but could be a file-wrapper, or any
+// other data structure that supports this very simple "append" API.
+
+#ifndef TEMPLATE_TEMPLATE_EMITTER_H_
+#define TEMPLATE_TEMPLATE_EMITTER_H_
+
+#include <sys/types.h> // for size_t
+#include <string>
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+class @ac_windows_dllexport@ ExpandEmitter {
+ public:
+ ExpandEmitter() {}
+ virtual ~ExpandEmitter() {}
+ virtual void Emit(char c) = 0;
+ virtual void Emit(const std::string& s) = 0;
+ virtual void Emit(const char* s) = 0;
+ virtual void Emit(const char* s, size_t slen) = 0;
+};
+
+
+class @ac_windows_dllexport@ StringEmitter : public ExpandEmitter {
+ std::string* const outbuf_;
+ public:
+ StringEmitter(std::string* outbuf) : outbuf_(outbuf) {}
+ virtual void Emit(char c) { *outbuf_ += c; }
+ virtual void Emit(const std::string& s) { *outbuf_ += s; }
+ virtual void Emit(const char* s) { *outbuf_ += s; }
+ virtual void Emit(const char* s, size_t slen) { outbuf_->append(s, slen); }
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_EMITTER_H_
diff --git a/src/ctemplate/template_enums.h.in b/src/ctemplate/template_enums.h.in
new file mode 100644
index 0000000..57db6ca
--- /dev/null
+++ b/src/ctemplate/template_enums.h.in
@@ -0,0 +1,46 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// Alas that we can't forward-declare enums! These are the ones
+// used by multiple files
+
+#ifndef TEMPLATE_TEMPLATE_ENUMS_H_
+#define TEMPLATE_TEMPLATE_ENUMS_H_
+
+namespace ctemplate {
+
+// Enums for GetTemplate flag values
+enum Strip { DO_NOT_STRIP, STRIP_BLANK_LINES, STRIP_WHITESPACE,
+ NUM_STRIPS }; // sentinel value
+
+}
+
+#endif // TEMPLATE_TEMPLATE_ENUMS_H_
diff --git a/src/ctemplate/template_modifiers.h.in b/src/ctemplate/template_modifiers.h.in
new file mode 100644
index 0000000..dd7b158
--- /dev/null
+++ b/src/ctemplate/template_modifiers.h.in
@@ -0,0 +1,350 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// We allow template variables to have modifiers, each possibly with a
+// value associated with it. Format is
+// {{VARNAME:modname[=modifier-value]:modname[=modifier-value]:...}}
+// Modname refers to a functor that takes the variable's value
+// and modifier-value (empty-string if no modifier-value was
+// specified), and returns a munged value. Modifiers are applied
+// left-to-right. We define the legal modnames here, and the
+// functors they refer to.
+//
+// Modifiers have a long-name, an optional short-name (one char;
+// may be \0 if you don't want a shortname), and a functor that's
+// applied to the variable.
+//
+// In addition to the list of modifiers hard-coded in the source code
+// here, it is possible to dynamicly register modifiers using a long
+// name starting with "x-". If you wish to define your own modifier
+// class, in your own source code, just subclass TemplateModifier --
+// see template_modifiers.cc for details of how to do that.
+//
+// Adding a new built-in modifier, to this file, takes several steps,
+// both in this .h file and in the corresponding .cc file:
+// 1) .h file: Define a struct for the modifier. It must subclass
+// TemplateModifier.
+// 2) .h file: declare a variable that's an instance of the struct.
+// This is used for people who want to modify the string themselves,
+// via TemplateDictionary::SetEscapedValue.
+// 5) .cc file: define the new modifier's Modify method.
+// 6) .cc file: give storage for the variable declared in the .h file (in 2).
+// 7) .cc file: add the modifier to the g_modifiers array.
+
+#ifndef TEMPLATE_TEMPLATE_MODIFIERS_H_
+#define TEMPLATE_TEMPLATE_MODIFIERS_H_
+
+#include <sys/types.h> // for size_t
+#include <string>
+#include <ctemplate/template_emitter.h> // so we can inline operator()
+#include <ctemplate/per_expand_data.h> // could probably just forward-declare
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+class Template;
+
+#define MODIFY_SIGNATURE_ \
+ public: \
+ virtual void Modify(const char* in, size_t inlen, \
+ const PerExpandData*, ExpandEmitter* outbuf, \
+ const std::string& arg) const
+
+// If you wish to write your own modifier, it should subclass this
+// method. Your subclass should only define Modify(); for efficiency,
+// we do not make operator() virtual.
+class @ac_windows_dllexport@ TemplateModifier {
+ public:
+ // This function takes a string as input, a char*/size_t pair, and
+ // appends the modified version to the end of outbuf. In addition
+ // to the variable-value to modify (specified via in/inlen), each
+ // Modify passes in two pieces of user-supplied data:
+ // 1) arg: this is the modifier-value, for modifiers that take a
+ // value (e.g. "{{VAR:modifier=value}}"). This value
+ // comes from the template file. For modifiers that take
+ // no modval argument, arg will always be "". For modifiers
+ // that do take such an argument, arg will always start with "=".
+ // 2) per_expand_data: this is a set of data that the application can
+ // associate with a TemplateDictionary, and is passed in to
+ // every variable expanded using that dictionary. This value
+ // comes from the source code.
+ virtual void Modify(const char* in, size_t inlen,
+ const PerExpandData* per_expand_data,
+ ExpandEmitter* outbuf,
+ const std::string& arg) const = 0;
+
+ // This function can be used to speed up modification. If Modify()
+ // is often a noop, you can implement MightModify() to indicate
+ // situations where it's safe to avoid the call to Modify(), because
+ // Modify() won't do any modifications in this case. Note it's
+ // always safe to return true here; you should just return false if
+ // you're certain Modify() can be ignored. This function is
+ // advisory; the template system is not required to call
+ // MightModify() before Modify().
+ virtual bool MightModify(const PerExpandData* /*per_expand_data*/,
+ const std::string& /*arg*/) const {
+ return true;
+ }
+
+ // We support both modifiers that take an argument, and those that don't.
+ // We also support passing in a string, or a char*/int pair.
+ std::string operator()(const char* in, size_t inlen, const std::string& arg="") const {
+ std::string out;
+ // we'll reserve some space to account for minimal escaping: say 12%
+ out.reserve(inlen + inlen/8 + 16);
+ StringEmitter outbuf(&out);
+ Modify(in, inlen, NULL, &outbuf, arg);
+ return out;
+ }
+ std::string operator()(const std::string& in, const std::string& arg="") const {
+ return operator()(in.data(), in.size(), arg);
+ }
+
+ virtual ~TemplateModifier(); // always need a virtual destructor!
+};
+
+
+// Returns the input verbatim (for testing)
+class @ac_windows_dllexport@ NullModifier : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ NullModifier null_modifier;
+
+// Escapes < > " ' & <non-space whitespace> to < > "
+// ' & <space>
+class @ac_windows_dllexport@ HtmlEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ HtmlEscape html_escape;
+
+// Same as HtmlEscape but leaves all whitespace alone. Eg. for <pre>..</pre>
+class @ac_windows_dllexport@ PreEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ PreEscape pre_escape;
+
+// Like HtmlEscape but allows HTML entities, <br> tags, <wbr> tags,
+// matched <b> and </b> tags, matched <i> and </i> tags, matched <em> and </em>
+// tags, and matched <span dir=(rtl|ltr)> tags.
+class @ac_windows_dllexport@ SnippetEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ SnippetEscape snippet_escape;
+
+// Replaces characters not safe for an unquoted attribute with underscore.
+// Safe characters are alphanumeric, underscore, dash, period, and colon.
+// The equal sign is also considered safe unless it is at the start
+// or end of the input in which case it is replaced with underscore.
+//
+// We added the equal sign to the safe characters to allow this modifier
+// to be used on attribute name/value pairs in HTML tags such as
+// <div {{CLASS:H=attribute}}>
+// where CLASS is expanded to "class=bla".
+//
+// Note: The equal sign is replaced when found at either boundaries of the
+// string due to the concern it may be lead to XSS under some special
+// circumstances: Say, if this string is the value of an attribute in an
+// HTML tag and ends with an equal sign, a browser may possibly end up
+// interpreting the next token as the value of this string rather than
+// a new attribute (esoteric).
+class @ac_windows_dllexport@ CleanseAttribute : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ CleanseAttribute cleanse_attribute;
+
+// Removes characters not safe for a CSS value. Safe characters are
+// alphanumeric, space, underscore, period, coma, exclamation mark,
+// pound, percent, and dash.
+class @ac_windows_dllexport@ CleanseCss : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ CleanseCss cleanse_css;
+
+// Checks that a url is either an absolute http(s) URL or a relative
+// url that doesn't have a protocol hidden in it (ie [foo.html] is
+// fine, but not [javascript:foo]) and then performs another type of
+// escaping. Returns the url escaped with the specified modifier if
+// good, otherwise returns a safe replacement URL.
+// This is normally "#", but for <img> tags, it is not safe to set
+// the src attribute to "#". This is because this causes some browsers
+// to reload the page, which can cause a DoS.
+class @ac_windows_dllexport@ ValidateUrl : public TemplateModifier {
+ public:
+ explicit ValidateUrl(const TemplateModifier& chained_modifier,
+ const char* unsafe_url_replacement)
+ : chained_modifier_(chained_modifier),
+ unsafe_url_replacement_(unsafe_url_replacement),
+ unsafe_url_replacement_length_(strlen(unsafe_url_replacement)) { }
+ MODIFY_SIGNATURE_;
+ static const char* const kUnsafeUrlReplacement;
+ static const char* const kUnsafeImgSrcUrlReplacement;
+ private:
+ const TemplateModifier& chained_modifier_;
+ const char* unsafe_url_replacement_;
+ int unsafe_url_replacement_length_;
+};
+extern @ac_windows_dllexport@ ValidateUrl validate_url_and_html_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_url_and_javascript_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_url_and_css_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_img_src_url_and_html_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_img_src_url_and_javascript_escape;
+extern @ac_windows_dllexport@ ValidateUrl validate_img_src_url_and_css_escape;
+
+// Escapes < > & " ' to < > & " ' (same as in HtmlEscape).
+// If you use it within a CDATA section, you may be escaping more characters
+// than strictly necessary. If this turns out to be an issue, we will need
+// to add a variant just for CDATA.
+class @ac_windows_dllexport@ XmlEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ XmlEscape xml_escape;
+
+// Escapes characters that cannot appear unescaped in a javascript string
+// assuming UTF-8 encoded input.
+// This does NOT escape all characters that cannot appear unescaped in a
+// javascript regular expression literal.
+class @ac_windows_dllexport@ JavascriptEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ JavascriptEscape javascript_escape;
+
+// Checks that the input is a valid javascript non-string literal
+// meaning a boolean (true, false) or a numeric value (decimal, hex or octal).
+// If valid, we output the input as is, otherwise we output null instead.
+// Input of zero length is considered valid and nothing is output.
+//
+// The emphasis is on safety against injection of javascript code rather
+// than perfect validation, as such it is possible for non-valid literals to
+// pass through.
+//
+// You would use this modifier for javascript variables that are not
+// enclosed in quotes such as:
+// <script>var a = {{VALUE}};</script> OR
+// <a href="url" onclick="doSubmit({{ID}})">
+// For variables that are quoted (i.e. string literals) use javascript_escape.
+//
+// Limitations:
+// . NaN, +/-Infinity and null are not recognized.
+// . Output is not guaranteed to be a valid literal,
+// e.g: +55+-e34 will output as is.
+// e.g: trueeee will output nothing as it is not a valid boolean.
+//
+// Details:
+// . For Hex numbers, it checks for case-insensitive 0x[0-9A-F]+
+// that should be a proper check.
+// . For other numbers, it checks for case-insensitive [0-9eE+-.]*
+// so can also accept invalid numbers such as the number 5..45--10.
+// . "true" and "false" (without quotes) are also accepted and that's it.
+//
+class @ac_windows_dllexport@ JavascriptNumber : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ JavascriptNumber javascript_number;
+
+// Escapes characters not in [0-9a-zA-Z.,_:*/~!()-] as %-prefixed hex.
+// Space is encoded as a +.
+class @ac_windows_dllexport@ UrlQueryEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ UrlQueryEscape url_query_escape;
+
+// Escapes " \ / <FF> <CR> <LF> <BS> <TAB> to \" \\ \/ \f \r \n \b \t
+// Also escapes < > & to their corresponding \uXXXX representation
+// (\u003C, \u003E, \u0026 respectively).
+class @ac_windows_dllexport@ JsonEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ JsonEscape json_escape;
+
+// Inserts the given prefix (given as the argument to this modifier)
+// after every newline in the text. Note that it does *not* insert
+// prefix at the very beginning of the text -- in its expected use,
+// that prefix will already be present before this text, in the
+// template. This is meant to be used internally, and is not exported
+// via the g_modifiers list.
+class @ac_windows_dllexport@ PrefixLine : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern @ac_windows_dllexport@ PrefixLine prefix_line;
+
+
+#undef MODIFY_SIGNATURE_
+
+
+// Registers a new template modifier.
+// long_name must start with "x-".
+// If the modifier takes a value (eg "{{VAR:x-name=value}}"), then
+// long_name should end with "=". This is similar to getopt(3) syntax.
+// We also allow value-specializations, with specific values specified
+// as part of long-name. For instance:
+// AddModifier("x-mod=", &my_modifierA);
+// AddModifier("x-mod=bar", &my_modifierB);
+// AddModifier("x-mod2", &my_modifierC);
+// For the template
+// {{VAR1:x-mod=foo}} {{VAR2:x-mod=bar}} {{VAR3:x-mod=baz}} {{VAR4:x-mod2}}
+// VAR1 and VAR3 would get modified by my_modifierA, VAR2 by my_modifierB,
+// and VAR4 by my_modifierC. The order of the AddModifier calls is not
+// significant.
+extern @ac_windows_dllexport@
+bool AddModifier(const char* long_name, const TemplateModifier* modifier);
+
+// Same as AddModifier() above except that the modifier is considered
+// to produce safe output that can be inserted in any context without
+// the need for additional escaping. This difference only impacts
+// the Auto-Escape mode: In that mode, when a variable (or template-include)
+// has a modifier added via AddXssSafeModifier(), it is excluded from
+// further escaping, effectively treated as though it had the :none modifier.
+// Because Auto-Escape is disabled for any variable and template-include
+// that includes such a modifier, use this function with care and ensure
+// that it may not emit harmful output that could lead to XSS.
+//
+// Some valid uses of AddXssSafeModifier:
+// . A modifier that converts a string to an integer since
+// an integer is generally safe in any context.
+// . A modifier that returns one of a fixed number of safe values
+// depending on properties of the input.
+//
+// Some not recommended uses of AddXssSafeModifier:
+// . A modifier that applies some extra formatting to the input
+// before returning it since the output will still contain
+// harmful content if the input does.
+// . A modifier that applies one type of escaping to the input
+// (say HTML-escape). This may be dangerous when the modifier
+// is used in a different context (say Javascript) where this
+// escaping may be inadequate.
+extern @ac_windows_dllexport@
+bool AddXssSafeModifier(const char* long_name, const TemplateModifier* modifier);
+
+}
+
+#endif // TEMPLATE_TEMPLATE_MODIFIERS_H_
diff --git a/src/ctemplate/template_namelist.h.in b/src/ctemplate/template_namelist.h.in
new file mode 100644
index 0000000..2758a8b
--- /dev/null
+++ b/src/ctemplate/template_namelist.h.in
@@ -0,0 +1,163 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// This class implements some template helper classes, that manage
+// template files and make it easier to monitor them.
+//
+// For information about how to use these classes and macros, and to
+// write the templates it takes as input,
+// see the doc/ directory.
+
+#ifndef TEMPLATE_TEMPLATE_NAMELIST_H_
+#define TEMPLATE_TEMPLATE_NAMELIST_H_
+
+#include <time.h> // for time_t
+#include @ac_cv_cxx_hash_set@
+#include <string>
+#include <vector>
+#include <ctemplate/template_enums.h> // for Strip
+#include <ctemplate/template_string.h> // for StringHash
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+// RegisterTemplateFilename
+// Used to define a reference variable for the name of a template file. E.g:
+// RegisterTemplateFilename(EXAMPLE_FN, "example.tpl");
+// This should be used rather than the seemingly equivalent:
+// #define EXAMPLE_FN "example.tpl"
+// As in the latter, any call to GetTemplate may then reference the name
+// via the first argument. In the example, that would be:
+// Template::GetTemplate(EXAMPLE_FN, DO_NOT_STRIP);
+// By using this macro, rather than the #define, all templates can
+// later be tested for either existence or correct syntax after program
+// start-up.
+// TODO (we wish): Make this macro produce the #include for the auto-generated
+// header files, when and if the macro pre-processor supports that
+#define RegisterTemplateFilename(var, name) \
+ const char* const var = @ac_google_namespace@::TemplateNamelist::RegisterTemplate(name);
+
+// Class: TemplateNamelist
+// Each time this class is instantiated, the name passed to
+// the constructor is added to the class's static list of names. The
+// entire list may be retrieved later by calling the GetList accessor
+// method. Or they may all be checked for existence or for correct
+// syntax via the other methods. We use this in our
+// sanity-checking code to make sure all the templates used by a program
+// exist and are syntactically correct.
+
+class @ac_windows_dllexport@ TemplateNamelist {
+ friend class TemporaryRegisterTemplate;
+ public:
+ // These types should be taken as 'generic' containers. The only
+ // thing you should do with them is call size() and/or iterate
+ // between begin() and end(), and the only operations we promise
+ // the iterators will support are operator* and operator++.
+ typedef @ac_cv_cxx_hash_set_class@<std::string, StringHash> NameListType;
+ typedef std::vector<std::string> MissingListType;
+ typedef std::vector<std::string> SyntaxListType;
+
+ public:
+ // Takes a name and pushes it onto the static namelist
+ // Returns: a pointer to the entry in namelist which holds the name
+ static const char* RegisterTemplate(const char* name);
+
+ // GetList
+ // Description: Returns the collected list of names.
+ static const NameListType& GetList();
+
+ // GetMissingList
+ // If refresh is true or if it is the first time the function is called
+ // in the execution of the program, it creates (or clears) the missing
+ // list and then fills it with the list of
+ // templates that the program knows about but are missing from
+ // the template directory.
+ // If refresh is false and it is not the first time the function is
+ // called, it merely returns the list created in the
+ // call when the last refresh was done.
+ // NOTE: The templates are NOT read, parsed, or cached
+ // by this function.
+ static const MissingListType& GetMissingList(bool refresh);
+
+ // GetBadSyntaxList
+ // If refresh is true or if it is the first time the function is called
+ // in the execution of the program, it creates (or clears) the "bad
+ // syntax" list and then fills it with the list of
+ // templates that the program knows about but contain syntax errors.
+ // A missing file is not considered a syntax error, and thus is
+ // not included in this list.
+ // If refresh is false and it is not the first time the function is
+ // called, it merely returns the list created in the
+ // call when the last refresh was done.
+ // NOTE: The side effect of calling this the first time or
+ // with refresh equal true is that all templates are parsed and cached.
+ // Hence they need to be retrieved with the flags that
+ // the program needs them loaded with (i.e, the strip parameter
+ // passed to Template::GetTemplate.)
+ static const SyntaxListType& GetBadSyntaxList(bool refresh, Strip strip);
+
+ // GetLastmodTime
+ // Iterates through all non-missing templates, and returns the latest
+ // last-modification time for the template files, as returned by stat().
+ // This can be used to make sure template files are getting refreshed.
+ static time_t GetLastmodTime();
+
+ // AllDoExist
+ // Retrieves the missing list (always refreshing the list)
+ // and returns true if it contains any names.
+ // Else, returns false.
+ static bool AllDoExist();
+
+ // IsAllSyntaxOkay
+ // Retrieves the "bad syntax" list (always refreshing the list)
+ // and returns true if it contains any names.
+ // Else, returns false.
+ // NOTE: The side effect of calling this is that all templates are parsed
+ // and cached, hence they need to be retrieved with the flags that
+ // the program needs them loaded with. (I.e, the strip parameter
+ // ultimately passed to Template::GetTemplate.)
+ static bool IsAllSyntaxOkay(Strip strip);
+
+ protected:
+ // The static list of names
+ static NameListType *namelist_;
+ static MissingListType *missing_list_;
+ static SyntaxListType *bad_syntax_list_;
+
+ private:
+ TemplateNamelist(const TemplateNamelist&); // disallow copying
+ void operator=(const TemplateNamelist&);
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_NAMELIST_H_
diff --git a/src/ctemplate/template_pathops.h.in b/src/ctemplate/template_pathops.h.in
new file mode 100644
index 0000000..7a11ade
--- /dev/null
+++ b/src/ctemplate/template_pathops.h.in
@@ -0,0 +1,73 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+
+#ifndef TEMPLATE_TEMPLATE_PATHOPS_H_
+#define TEMPLATE_TEMPLATE_PATHOPS_H_
+
+#include <string>
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+extern @ac_windows_dllexport@
+const char kCWD[]; // a string that's equivalent to "./"
+extern @ac_windows_dllexport@
+const char kRootdir[]; // a string that's equivalent to "/"
+
+extern @ac_windows_dllexport@
+std::string PathJoin(const std::string& a, const std::string& b);
+
+extern @ac_windows_dllexport@
+bool IsAbspath(const std::string& path);
+
+extern @ac_windows_dllexport@
+bool IsDirectory(const std::string& path); // checks if path ends with /
+
+extern @ac_windows_dllexport@
+void NormalizeDirectory(std::string* dir); // adds trailing / if needed
+
+extern @ac_windows_dllexport@
+std::string Basename(const std::string& path); // everything after last /
+
+// Returns true iff text contains the word as a full word, i.e. delimited by one
+// of [.,_-#*?:] on both the sides.
+// This is used while loading a template, to check that the file's name matches
+// the auto-escape mode specified by it.
+// NOTE: This assumes that the word doesn't contain any of the delimiter
+// characters.
+extern @ac_windows_dllexport@
+bool ContainsFullWord(const std::string& text, const std::string& word);
+
+}
+
+#endif // TEMPLATE_TEMPLATE_PATHOPS_H_
diff --git a/src/ctemplate/template_string.h.in b/src/ctemplate/template_string.h.in
new file mode 100644
index 0000000..e151a35
--- /dev/null
+++ b/src/ctemplate/template_string.h.in
@@ -0,0 +1,357 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+//
+// ---
+// Author: csilvers@google.com (Craig Silerstein)
+
+#ifndef TEMPLATE_TEMPLATE_STRING_H_
+#define TEMPLATE_TEMPLATE_STRING_H_
+
+#include <string.h> // for memcmp() and size_t
+#include @ac_cv_cxx_hash_map@
+#include <string>
+#include <vector>
+
+#include <assert.h>
+#if @ac_cv_have_stdint_h@
+#include <stdint.h> // one place @ac_cv_unit64@ might live
+#endif
+#if @ac_cv_have_inttypes_h@
+#include <inttypes.h> // another place @ac_cv_unit64@ might live
+#endif
+#include <sys/types.h> // final place @ac_cv_unit64@ might live
+
+class TemplateStringTest; // needed for friendship declaration
+class StaticTemplateStringTest;
+
+#if @ac_have_attribute_weak@
+extern char _start[] __attribute__((weak)); // linker emits: start of .text
+extern char data_start[] __attribute__((weak)); // start of .data
+#endif
+
+@ac_windows_dllexport_defines@
+
+namespace ctemplate {
+
+// Most methods of TemplateDictionary take a TemplateString rather than a
+// C++ string. This is for efficiency: it can avoid extra string copies.
+// For any argument that takes a TemplateString, you can pass in any of:
+// * A C++ string
+// * A char*
+// * A StringPiece
+// * TemplateString(char*, length)
+// The last of these is the most efficient, though it requires more work
+// on the call site (you have to create the TemplateString explicitly).
+class TemplateString;
+
+// If you have a string constant (e.g. the string literal "foo") that
+// you need to pass into template routines repeatedly, it is more
+// efficient if you convert it into a TemplateString only once. The
+// way to do this is to use a global StaticTemplateString via STS_INIT
+// (note: do this at global scope *only*!):
+// static const StaticTemplateString kMyVar = STS_INIT(kMyVar, "MY_VALUE");
+struct StaticTemplateString;
+
+#define STS_INIT(name, str) STS_INIT_WITH_HASH(name, str, 0)
+
+// Let's define a convenient hash function for hashing 'normal'
+// strings: char* and string. We'll use MurmurHash, which is probably
+// better than the STL default. We don't include TemplateString or
+// StaticTemplateString here, since they are hashed more efficiently
+// based on their id.
+struct @ac_windows_dllexport@ StringHash {
+ inline size_t operator()(const char* s) const {
+ return Hash(s, strlen(s));
+ };
+
+ inline size_t operator()(const std::string& s) const {
+ return Hash(s.data(), s.size());
+ }
+
+ inline bool operator()(const char* a, const char* b) const {
+ return (a != b) && (strcmp(a, b) < 0); // <, for MSVC
+ }
+
+ inline bool operator()(const std::string& a, const std::string& b) const {
+ return a < b;
+ }
+
+ static const size_t bucket_size = 4; // These are required by MSVC
+ static const size_t min_buckets = 8; // 4 and 8 are the defaults
+ private:
+ size_t Hash(const char* s, size_t slen) const;
+};
+
+// ----------------------- THE CLASSES -------------------------------
+
+typedef @ac_cv_uint64@ TemplateId;
+
+const TemplateId kIllegalTemplateId = 0;
+
+struct @ac_windows_dllexport@ StaticTemplateString {
+ // Do not define a constructor! We use only brace-initialization,
+ // so the data is constructed at static-initialization time.
+ // Anything you want to put in a constructor, put in
+ // StaticTemplateStringInitializer instead.
+
+ // These members shouldn't be accessed directly, except in the
+ // internals of the template code. They are public because that is
+ // the only way we can brace-initialize them. NOTE: MSVC (at least
+ // up to 8.0) has a bug where it ignores 'mutable' when it's buried
+ // in an internal struct. To fix that, we have to make this whole
+ // internal struct mutable. We only do this on MSVC, so on other
+ // compilers we get the full constness we want.
+#ifdef _MSC_VER
+ mutable
+#endif
+ struct {
+ const char* ptr_;
+ size_t length_;
+ mutable TemplateId id_; // sometimes lazily-initialized.
+ } do_not_use_directly_;
+
+ // This class is a good hash functor to pass in as the third
+ // argument to @ac_cv_cxx_hash_map_class@<>, when creating a map whose keys are
+ // StaticTemplateString. NOTE: This class isn't that safe to use,
+ // because it requires that StaticTemplateStringInitializer has done
+ // its job. Unfortunately, even when you use the STS_INIT macro
+ // (which is always, right??), dynamic initialiation does not happen
+ // in a particular order, and objects in different .cc files may
+ // reference a StaticTemplateString before the corresponding
+ // StaticTemplateStringInitializer sets the id.
+ struct Hasher {
+ inline size_t operator()(const StaticTemplateString& sts) const;
+ inline bool operator()(const StaticTemplateString& a, // <, for MSVC
+ const StaticTemplateString& b) const;
+ static const size_t bucket_size = 4; // These are required by MSVC
+ static const size_t min_buckets = 8; // 4 and 8 are the defaults
+ };
+
+ inline bool empty() const {
+ return do_not_use_directly_.length_ == 0;
+ }
+
+ // Allows comparisons of StaticTemplateString objects as if they were
+ // strings. This is useful for STL.
+ inline bool operator==(const StaticTemplateString& x) const;
+};
+
+class @ac_windows_dllexport@ TemplateString {
+ public:
+ TemplateString(const char* s)
+ : ptr_(s ? s : ""), length_(strlen(ptr_)),
+ is_immutable_(InTextSegment(ptr_)), id_(kIllegalTemplateId) {
+ }
+ TemplateString(const std::string& s)
+ : ptr_(s.data()), length_(s.size()),
+ is_immutable_(false), id_(kIllegalTemplateId) {
+ }
+ TemplateString(const char* s, size_t slen)
+ : ptr_(s), length_(slen),
+ is_immutable_(InTextSegment(s)), id_(kIllegalTemplateId) {
+ }
+ TemplateString(const StaticTemplateString& s)
+ : ptr_(s.do_not_use_directly_.ptr_),
+ length_(s.do_not_use_directly_.length_),
+ is_immutable_(true), id_(s.do_not_use_directly_.id_) {
+ }
+
+ const char* begin() const {
+ return ptr_;
+ }
+
+ const char* end() const {
+ return ptr_ + length_;
+ }
+
+ const char* data() const {
+ return ptr_;
+ }
+
+ size_t size() const {
+ return length_;
+ }
+
+ inline bool empty() const {
+ return length_ == 0;
+ };
+
+ inline bool is_immutable() const {
+ return is_immutable_;
+ }
+
+ // STL requires this to be public for hash_map, though I'd rather not.
+ inline bool operator==(const TemplateString& x) const {
+ return GetGlobalId() == x.GetGlobalId();
+ }
+
+ private:
+ // Only TemplateDictionaries and template expansion code can read these.
+ friend class TemplateDictionary;
+ friend class TemplateCache; // for GetGlobalId
+ friend class StaticTemplateStringInitializer; // for AddToGlo...
+ friend struct TemplateStringHasher; // for GetGlobalId
+ friend TemplateId GlobalIdForTest(const char* ptr, int len);
+ friend TemplateId GlobalIdForSTS_INIT(const TemplateString& s);
+
+ TemplateString(const char* s, size_t slen, bool is_immutable, TemplateId id)
+ : ptr_(s), length_(slen), is_immutable_(is_immutable), id_(id) {
+ }
+
+ // This returns true if s is in the .text segment of the binary.
+ // (Note this only checks .text of the main executable, not of
+ // shared libraries. So it may not be all that useful.)
+ // This requires the gnu linker (and probably elf), to define
+ // _start and data_start.
+ static bool InTextSegment(const char* s) {
+#if @ac_have_attribute_weak@
+ return (s >= _start && s < data_start); // in .text
+#else
+ return false; // the conservative choice: assume it's not static memory
+#endif
+ }
+
+ protected:
+ inline void CacheGlobalId() { // used by HashedTemplateString
+ id_ = GetGlobalId();
+ };
+
+ private:
+ // Returns the global id, computing it for the first time if
+ // necessary. Note that since this is a const method, we don't
+ // store the computed value in id_, even if id_ is 0.
+ TemplateId GetGlobalId() const;
+ // Adds this TemplateString to the map from global-id to name.
+ void AddToGlobalIdToNameMap();
+
+ // Use sparingly. Converting to a string loses information about the
+ // id of the template string, making operations require extra hash
+ // computations.
+ std::string ToString() const { return std::string(ptr_, length_); }
+
+ // Does the reverse map from TemplateId to TemplateString contents.
+ // Returns a TemplateString(kStsEmpty) if id isn't found. Note that
+ // the TemplateString returned is not necessarily NUL terminated.
+ static TemplateString IdToString(TemplateId id);
+
+ const char* ptr_;
+ size_t length_;
+ // Do we need to manage memory for this string?
+ bool is_immutable_;
+ // Id for hash lookups. If 0, we don't have one and it should be
+ // computed as-needed.
+ TemplateId id_;
+};
+
+// ----------------------- THE CODE -------------------------------
+
+// Use the low-bit from TemplateId as the "initialized" flag. Note
+// that since all initialized TemplateId have the lower bit set, it's
+// safe to have used 0 for kIllegalTemplateId, as we did above.
+const TemplateId kTemplateStringInitializedFlag = 1;
+
+inline bool IsTemplateIdInitialized(TemplateId id) {
+ return id & kTemplateStringInitializedFlag;
+}
+
+// This is a helper struct used in TemplateString::Hasher/TemplateStringHasher
+struct TemplateIdHasher {
+ size_t operator()(TemplateId id) const {
+ // The shift has two effects: it randomizes the "initialized" flag,
+ // and slightly improves the randomness of the low bits. This is
+ // slightly useful when size_t is 32 bits, or when using a small
+ // hash tables with power-of-2 sizes.
+ return static_cast<size_t>(id ^ (id >> 33));
+ }
+ bool operator()(TemplateId a, TemplateId b) const { // <, for MSVC
+ return a < b;
+ }
+ static const size_t bucket_size = 4; // These are required by MSVC
+ static const size_t min_buckets = 8; // 4 and 8 are the defaults
+};
+
+
+inline size_t StaticTemplateString::Hasher::operator()(
+ const StaticTemplateString& sts) const {
+ TemplateId id = sts.do_not_use_directly_.id_;
+ assert(IsTemplateIdInitialized(id));
+ return TemplateIdHasher()(id);
+}
+
+inline bool StaticTemplateString::Hasher::operator()(
+ const StaticTemplateString& a, const StaticTemplateString& b) const {
+ TemplateId id_a = a.do_not_use_directly_.id_;
+ TemplateId id_b = b.do_not_use_directly_.id_;
+ assert(IsTemplateIdInitialized(id_a));
+ assert(IsTemplateIdInitialized(id_b));
+ return TemplateIdHasher()(id_a, id_b);
+}
+
+inline bool StaticTemplateString::operator==(
+ const StaticTemplateString& x) const {
+ return (do_not_use_directly_.length_ == x.do_not_use_directly_.length_ &&
+ (do_not_use_directly_.ptr_ == x.do_not_use_directly_.ptr_ ||
+ memcmp(do_not_use_directly_.ptr_, x.do_not_use_directly_.ptr_,
+ do_not_use_directly_.length_) == 0));
+}
+
+// We set up as much of StaticTemplateString as we can at
+// static-initialization time (using brace-initialization), but some
+// things can't be set up then. This class is for those things; it
+// runs at dynamic-initialization time. If you add logic here, only
+// do so as an optimization: this may be called rather late (though
+// before main), so other code should not depend on this being called
+// before them.
+class @ac_windows_dllexport@ StaticTemplateStringInitializer {
+ public:
+ // This constructor operates on a const StaticTemplateString - we should
+ // only change those things that are mutable.
+ explicit StaticTemplateStringInitializer(const StaticTemplateString* sts);
+};
+
+// Don't use this. This is used only in auto-generated .varnames.h files.
+#define STS_INIT_WITH_HASH(name, str, hash) \
+ { { str, sizeof("" str "")-1, hash } }; \
+ namespace ctemplate_sts_init { \
+ static const @ac_google_namespace@::StaticTemplateStringInitializer name##_init(&name); \
+ }
+
+// We computed this hash value for the empty string online. In debug
+// mode, we verify it's correct during runtime (that is, that we
+// verify the hash function used by make_tpl_varnames_h hasn't changed
+// since we computed this number). Note this struct is logically
+// static, but since it's in a .h file, we don't say 'static' but
+// instead rely on the linker to provide the POD-with-internal-linkage
+// magic.
+const StaticTemplateString kStsEmpty =
+ STS_INIT_WITH_HASH(kStsEmpty, "", 1457976849674613049ULL);
+
+}
+
+#endif // TEMPLATE_TEMPLATE_STRING_H_
diff --git a/src/diff_tpl_auto_escape.cc b/src/diff_tpl_auto_escape.cc
new file mode 100644
index 0000000..5a833f8
--- /dev/null
+++ b/src/diff_tpl_auto_escape.cc
@@ -0,0 +1,337 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Heavily inspired from make_tpl_varnames_h.cc
+//
+// A utility for evaluating the changes in escaping modifiers
+// applied to variables between two versions of a template file.
+// This may come in handy when converting a template to Auto-Escape:
+// If the template previously had escaping modifiers, this tool will show
+// the variables for which Auto-Escaped determined a different escaping.
+//
+// How it works:
+// . You provide two template files, assumed to be identical in content
+// (same variables in the same order) except for escaping modifiers
+// and possibly the AUTOESCAPE pragma. You also provide the Strip mode
+// or a default of STRIP_WHITESPACE is assumed.
+//
+// . The tool loads both files and invokes DumpToString on both. It then
+// compares the escaping modifiers for each variable and when they do
+// not match, it prints a line with the variable name as well as
+// the differing modifiers.
+//
+// . We accept some command-line flags, the most notable are:
+// --template_dir to set a template root directory other than cwd
+// --strip to set the Strip mode to other than STRIP_WHITESPACE.
+// For correct operation of Auto-Escape, ensure this matches
+// the Strip mode you normally use on these templates.
+//
+//
+// Exit code is zero if there were no differences. It is non-zero
+// if we failed to load the templates or we found one or more
+// differences.
+//
+// TODO(jad): Add flag to optionally report differences when a variable
+// does not have modifiers in either template.
+
+// This is for opensource ctemplate on windows. Even though we
+// #include config.h, just like the files used to compile the dll, we
+// are actually a *client* of the dll, so we don't get to decl anything.
+#include <config.h>
+#undef CTEMPLATE_DLL_DECL
+
+#include <stdlib.h>
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdarg.h>
+#ifdef HAVE_GETOPT_H
+# include <getopt.h>
+#endif
+#include <string.h>
+#include <string>
+#include <ctemplate/template.h>
+#include <ctemplate/template_pathops.h>
+using std::string;
+using std::vector;
+using GOOGLE_NAMESPACE::Template;
+using GOOGLE_NAMESPACE::TemplateContext;
+using GOOGLE_NAMESPACE::Strip;
+using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
+using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
+using GOOGLE_NAMESPACE::DO_NOT_STRIP;
+
+enum {LOG_VERBOSE, LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL};
+
+// A variable name and optional modifiers.
+// For example: in {{NAME:j:x-bla}}
+// variable_name is "NAME" and modifiers is "j:x-bla".
+struct VariableAndMod {
+ VariableAndMod(string name, string mods)
+ : variable_name(name), modifiers(mods) { }
+ string variable_name;
+ string modifiers;
+};
+typedef vector<VariableAndMod> VariableAndMods;
+
+static string FLAG_template_dir(GOOGLE_NAMESPACE::kCWD); // "./"
+static string FLAG_strip = ""; // cmd-line arg -s
+static bool FLAG_verbose = false; // cmd-line arg -v
+
+static void LogPrintf(int severity, const char* pat, ...) {
+ if (severity == LOG_VERBOSE && !FLAG_verbose)
+ return;
+ if (severity == LOG_FATAL)
+ fprintf(stderr, "FATAL ERROR: ");
+ if (severity == LOG_VERBOSE)
+ fprintf(stdout, "[VERBOSE] ");
+ va_list ap;
+ va_start(ap, pat);
+ vfprintf(severity == LOG_INFO || severity == LOG_VERBOSE ? stdout: stderr,
+ pat, ap);
+ va_end(ap);
+ if (severity == LOG_FATAL)
+ exit(1);
+}
+
+// Prints to outfile -- usually stdout or stderr -- and then exits
+static int Usage(const char* argv0, FILE* outfile) {
+ fprintf(outfile, "USAGE: %s [-t<dir>] [-v] [-b] [-s<n>] <file1> <file2>\n",
+ argv0);
+
+ fprintf(outfile,
+ " -t --template_dir=<dir> Root directory of templates\n"
+ " -s --strip=<strip> STRIP_WHITESPACE [default],\n"
+ " STRIP_BLANK_LINES, DO_NOT_STRIP\n"
+ " -h --help This help\n"
+ " -v --verbose For a bit more output\n"
+ " -V --version Version information\n");
+ fprintf(outfile, "\n"
+ "This program reports changes to modifiers between two template\n"
+ "files assumed to be identical except for modifiers applied\n"
+ "to variables. One use case is converting a template to\n"
+ "Auto-Escape and using this program to obtain the resulting\n"
+ "changes in escaping modifiers.\n"
+ "The Strip value should match what you provide in\n"
+ "Template::GetTemplate.\n"
+ "NOTE: Variables that do not have escaping modifiers in one of\n"
+ "two templates are ignored and do not count in the differences.\n");
+ exit(0);
+}
+
+static int Version(FILE* outfile) {
+ fprintf(outfile,
+ "diff_tpl_auto_escape (part of google-template 0.9x)\n"
+ "\n"
+ "Copyright 2008 Google Inc.\n"
+ "\n"
+ "This is BSD licensed software; see the source for copying conditions\n"
+ "and license information.\n"
+ "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n"
+ "PARTICULAR PURPOSE.\n"
+ );
+ exit(0);
+}
+
+// Populates the vector of VariableAndMods from the DumpToString
+// representation of the template file.
+//
+// Each VariableAndMod represents a variable node found in the template
+// along with the optional modifiers attached to it (or empty string).
+// The parsing is very simple. It looks for lines of the form:
+// "Variable Node: <VAR_NAME>[:<VAR_MODS>]\n"
+// as outputted by DumpToString() and extracts from each such line the
+// variable name and modifiers when present.
+// Because DumpToString also outputs text nodes, it is possible
+// to trip this function. Probably ok since this is just a helper tool.
+bool LoadVariables(const char* filename, Strip strip,
+ VariableAndMods& vars_and_mods) {
+ const string kVariablePreambleText = "Variable Node: ";
+ Template *tpl;
+ tpl = Template::GetTemplate(filename, strip);
+ if (tpl == NULL) {
+ LogPrintf(LOG_FATAL, "Could not load file: %s\n", filename);
+ return false;
+ }
+
+ string output;
+ tpl->DumpToString(filename, &output);
+
+ string::size_type index = 0;
+ string::size_type delim, end;
+ // TODO(jad): Switch to using regular expressions.
+ while((index = output.find(kVariablePreambleText, index)) != string::npos) {
+ index += kVariablePreambleText.length();
+ end = output.find('\n', index);
+ if (end == string::npos) {
+ // Should never happen but no need to LOG_FATAL.
+ LogPrintf(LOG_ERROR, "%s: Did not find terminating newline...\n",
+ filename);
+ end = output.length();
+ }
+ string name_and_mods = output.substr(index, end - index);
+ delim = name_and_mods.find(":");
+ if (delim == string::npos) // no modifiers.
+ delim = name_and_mods.length();
+ VariableAndMod var_mod(name_and_mods.substr(0, delim),
+ name_and_mods.substr(delim));
+ vars_and_mods.push_back(var_mod);
+ }
+ return true;
+}
+
+// Returns true if the difference in the modifier strings
+// is non-significant and can be safely omitted. This is the
+// case when one is ":j:h" and the other is ":j" since
+// the :h is a no-op after a :j.
+bool SuppressLameDiff(string modifiers_a, string modifiers_b) {
+ if ((modifiers_a == ":j:h" && modifiers_b == ":j") ||
+ (modifiers_a == ":j" && modifiers_b == ":j:h"))
+ return true;
+ return false;
+}
+
+// Main function to analyze differences in escaping modifiers between
+// two template files. These files are assumed to be identical in
+// content [strictly speaking: same number of variables in the same order].
+// If that is not the case, we fail.
+// We return true if there were no differences, false if we failed
+// or we found one or more differences.
+bool DiffTemplates(const char* filename_a, const char* filename_b,
+ Strip strip) {
+ vector<VariableAndMod> vars_and_mods_a, vars_and_mods_b;
+
+ if (!LoadVariables(filename_a, strip, vars_and_mods_a) ||
+ !LoadVariables(filename_b, strip, vars_and_mods_b))
+ return false;
+
+ if (vars_and_mods_a.size() != vars_and_mods_b.size())
+ LogPrintf(LOG_FATAL, "Templates differ: %s [%d vars] vs. %s [%d vars].\n",
+ filename_a, vars_and_mods_a.size(),
+ filename_b, vars_and_mods_b.size());
+
+ int mismatch_count = 0; // How many differences there were.
+ int no_modifiers_count = 0; // How many variables without modifiers.
+ VariableAndMods::const_iterator iter_a, iter_b;
+ for (iter_a = vars_and_mods_a.begin(), iter_b = vars_and_mods_b.begin();
+ iter_a != vars_and_mods_a.end() && iter_b != vars_and_mods_b.end();
+ ++iter_a, ++iter_b) {
+ // The templates have different variables, we fail!
+ if (iter_a->variable_name != iter_b->variable_name)
+ LogPrintf(LOG_FATAL, "Variable name mismatch: %s vs. %s\n",
+ iter_a->variable_name.c_str(),
+ iter_b->variable_name.c_str());
+ // Variables without modifiers are ignored from the diff. They simply
+ // get counted and the count is shown in verbose logging/
+ if (iter_a->modifiers == "" || iter_b->modifiers == "") {
+ no_modifiers_count++;
+ } else {
+ if (iter_a->modifiers != iter_b->modifiers &&
+ !SuppressLameDiff(iter_a->modifiers, iter_b->modifiers)) {
+ mismatch_count++;
+ LogPrintf(LOG_INFO, "Difference for variable %s -- %s vs. %s\n",
+ iter_a->variable_name.c_str(),
+ iter_a->modifiers.c_str(), iter_b->modifiers.c_str());
+ }
+ }
+ }
+
+ LogPrintf(LOG_VERBOSE, "Variables Found: Total=%d; Diffs=%d; NoMods=%d\n",
+ vars_and_mods_a.size(), mismatch_count, no_modifiers_count);
+
+ return (mismatch_count == 0);
+}
+
+int main(int argc, char **argv) {
+#if defined(HAVE_GETOPT_LONG)
+ static struct option longopts[] = {
+ {"help", 0, NULL, 'h'},
+ {"strip", 1, NULL, 's'},
+ {"template_dir", 1, NULL, 't'},
+ {"verbose", 0, NULL, 'v'},
+ {"version", 0, NULL, 'V'},
+ {0, 0, 0, 0}
+ };
+ int option_index;
+# define GETOPT(argc, argv) getopt_long(argc, argv, "t:s:hvV", \
+ longopts, &option_index)
+#elif defined(HAVE_GETOPT_H)
+# define GETOPT(argc, argv) getopt(argc, argv, "t:s:hvV")
+#else
+ // TODO(csilvers): implement something reasonable for windows/etc
+# define GETOPT(argc, argv) -1
+ int optind = 1; // first non-opt argument
+ const char* optarg = ""; // not used
+#endif
+
+ int r = 0;
+ while (r != -1) { // getopt()/getopt_long() return -1 upon no-more-input
+ r = GETOPT(argc, argv);
+ switch (r) {
+ case 's': FLAG_strip.assign(optarg); break;
+ case 't': FLAG_template_dir.assign(optarg); break;
+ case 'v': FLAG_verbose = true; break;
+ case 'V': Version(stdout); break;
+ case -1: break; // means 'no more input'
+ default: Usage(argv[0], stderr);
+ }
+ }
+
+ Template::SetTemplateRootDirectory(FLAG_template_dir);
+
+
+ if (argc != (optind + 2))
+ LogPrintf(LOG_FATAL,
+ "Must specify exactly two template files on the command line.\n");
+
+ // Validate the Strip value. Default is STRIP_WHITESPACE.
+ Strip strip = STRIP_WHITESPACE; // To avoid compiler warnings.
+ if (FLAG_strip == "STRIP_WHITESPACE" || FLAG_strip == "")
+ strip = STRIP_WHITESPACE;
+ else if (FLAG_strip == "STRIP_BLANK_LINES")
+ strip = STRIP_BLANK_LINES;
+ else if (FLAG_strip == "DO_NOT_STRIP")
+ strip = DO_NOT_STRIP;
+ else
+ LogPrintf(LOG_FATAL, "Unrecognized Strip: %s. Must be one of: "
+ "STRIP_WHITESPACE, STRIP_BLANK_LINES or DO_NOT_STRIP\n",
+ FLAG_strip.c_str());
+
+ const char* filename_a = argv[optind];
+ const char* filename_b = argv[optind + 1];
+ LogPrintf(LOG_VERBOSE, "------ Diff of [%s, %s] ------\n",
+ filename_a, filename_b);
+
+ if (DiffTemplates(filename_a, filename_b, strip))
+ return 0;
+ else
+ return 1;
+}
diff --git a/src/htmlparser/README b/src/htmlparser/README
new file mode 100644
index 0000000..83ff6bb
--- /dev/null
+++ b/src/htmlparser/README
@@ -0,0 +1,13 @@
+This directory contains an implementation of an html context scanner with no
+lookahead. Its purpose is to scan an html stream and provide context
+information at any point within the input stream. This is used in the
+auto escaping functionality of the templating system, which would require
+html context information at very specific points within the html stream. The
+implementation is based on a simplified state machine of HTML4.1.
+
+The implementation is written in C, with the idea of making is usable
+in other contexts besides this html paresr; however, we compile all
+the files as c++ files in order to be able to use a namespace (and
+avoid global namespace pollution). There's also a c++ shim to give an
+object-oriented look at the html parser state, which is what the
+ctemplate system actually uses.
diff --git a/src/htmlparser/fsm_config.py b/src/htmlparser/fsm_config.py
new file mode 100755
index 0000000..ff27c89
--- /dev/null
+++ b/src/htmlparser/fsm_config.py
@@ -0,0 +1,221 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+# ---
+#
+# Create a state machine object based on a definition file.
+#
+
+__author__ = 'falmeida@google.com (Filipe Almeida)'
+
+class OrderedDict:
+ """Ordered dictionary implementation."""
+
+ # Define the minimum functionality we need for our application.
+ # Easiser would be to subclass from UserDict.DictMixin, and only
+ # define __getitem__, __setitem__, __delitem__, and keys, but that's
+ # not as portable. We don't need to define much more, so we just do.
+
+ def __init__(self):
+ self._dict = {}
+ self._keys = []
+
+ def __getitem__(self, key):
+ return self._dict[key]
+
+ def __setitem__(self, key, value):
+ if key not in self._keys:
+ self._keys.append(key)
+ self._dict[key] = value
+
+ def __delitem__(self, key):
+ self._keys.remove(key)
+ del self._dict[key]
+
+ def keys(self):
+ return self._keys
+
+ # Below are all we have to define in addition to what DictMixin would need
+ def __len__(self):
+ return len(self.keys())
+
+ def __contains__(self, key):
+ return self.has_key(key)
+
+ def __iter__(self):
+ # It's not as portable -- though it would be more space-efficient -- to do
+ # for k in self.keys(): yield k
+ return iter(self.keys())
+
+class State(object):
+ """Contains information about a specific state."""
+
+ def __init__(self):
+ pass
+
+ name = None
+ external_name = None
+ transitions = []
+
+
+class Transition(object):
+ """Contains information about a specific transition."""
+
+ def __init__(self, condition, source, destination):
+ self.condition = condition
+ self.source = source
+ self.destination = destination
+
+
+class FSMConfig(object):
+ """Container for the statemachine definition."""
+
+ sm = {} # dictionary that contains the finite state machine definition
+ # loaded from a config file.
+ transitions = [] # List of transitions.
+ conditions = {} # Mapping between the condition name and the bracket
+ # expression.
+ states = OrderedDict() # Ordered dictionary of states.
+ name = None
+ comment = None
+
+ def AddState(self, **dic):
+ """Called from the definition file with the description of the state.
+
+ Receives a dictionary and populates internal structures based on it. The
+ dictionary is in the following format:
+
+ {'name': state_name,
+ 'external': exposed state name,
+ 'transitions': [
+ [condition, destination_state ],
+ [condition, destination_state ]
+ ]
+ }
+
+ """
+
+ state = State()
+ state.name = dic['name']
+ state.external_name = dic['external']
+
+ state_transitions = []
+
+ for (condition, destination) in dic['transitions']:
+ transition = Transition(condition, state.name, destination)
+ state_transitions.append(transition)
+
+ self.transitions.extend(state_transitions)
+ state.transitions = state_transitions
+ self.states[state.name] = state
+
+ def AddCondition(self, name, expression):
+ """Called from the definition file with the definition of a condition.
+
+ Receives the name of the condition and it's expression.
+ """
+ self.conditions[name] = expression
+
+ def Load(self, filename):
+ """Load the state machine definition file.
+
+ In the definition file, which is based on the python syntax, the following
+ variables and functions are defined.
+
+ name: Name of the state machine
+ comment: Comment line on the generated file.
+ condition(): A mapping between condition names and bracket expressions.
+ state(): Defines a state and it's transitions. It accepts the following
+ attributes:
+ name: name of the state
+ external: exported name of the state. The exported name can be used
+ multiple times in order to create a super state.
+ transitions: List of pairs containing the condition for the transition
+ and the destination state. Transitions are ordered so if
+ a default rule is used, it must be the last one in the list.
+
+ Example:
+
+ name = 'c comment parser'
+
+ condition('/', '/')
+ condition('*', '*')
+ condition('linefeed', '\\n')
+ condition('default', '[:default:]')
+
+ state(name = 'text',
+ external = 'comment',
+ transitions = [
+ [ '/', 'comment_start' ],
+ [ 'default', 'text' ]
+ ])
+
+ state(name = 'comment_start',
+ external = 'comment',
+ transitions = [
+ [ '/', 'comment_line' ],
+ [ '*', 'comment_multiline' ],
+ [ 'default', 'text' ]
+ ])
+
+ state(name = 'comment_line',
+ external = 'comment',
+ transitions = [
+ [ 'linefeed', 'text' ],
+ [ 'default', 'comment_line' ]
+ ])
+
+ state(name = 'comment_multiline',
+ external = 'comment',
+ transitions = [
+ [ '*', 'comment_multiline_close' ],
+ [ 'default', 'comment_multiline' ]
+ ])
+
+ state(name = 'comment_multiline_close',
+ external = 'comment',
+ transitions = [
+ [ '/', 'text' ],
+ [ 'default', 'comment_multiline' ]
+ ])
+
+ """
+
+ self.sm['state'] = self.AddState
+ self.sm['condition'] = self.AddCondition
+ execfile(filename, self.sm)
+ self.name = self.sm['name']
+ if not self.name.isalnum():
+ raise Exception("State machine name must consist of only alphanumeric"
+ "characters.")
+ self.comment = self.sm['comment']
+
+ def __init__(self):
+ pass
diff --git a/src/htmlparser/generate_fsm.py b/src/htmlparser/generate_fsm.py
new file mode 100755
index 0000000..9106b96
--- /dev/null
+++ b/src/htmlparser/generate_fsm.py
@@ -0,0 +1,330 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+# ---
+#
+# Generate a C include file from a finite state machine definition.
+#
+# Right now the form is the one expected by htmlparser.c so this file is pretty
+# tightly coupled with htmlparser.c.
+#
+
+__author__ = 'falmeida@google.com (Filipe Almeida)'
+
+import sys
+
+from fsm_config import FSMConfig
+
+
+class FSMGenerateAbstract(object):
+
+ def __init__(self, config):
+ self._config = config
+
+ def Generate(self):
+ """Returns the generated FSM description for the specified language.
+
+ Raises a TypeError, because abstract methods can not be called.
+
+ Raises:
+ TypeError
+ """
+ raise TypeError('Abstract method %s.%s called' % (self._class.__name__,
+ self._function))
+
+
+class FSMGenerateC(FSMGenerateAbstract):
+ """Generate the C definition from a statemachien configuration object."""
+
+ TABSTOP_ = 2
+
+ def _Prefix(self):
+ """Return a c declaration prefix."""
+
+ return self._config.name.lower() + '_'
+
+ def _StateInternalC(self, st):
+ """Return the internal name of the state."""
+
+ return '%sSTATE_INT_%s' % (self._Prefix().upper(), st.upper())
+
+ def _StateExternalC(self, st):
+ """Return the external name of the state."""
+
+ return '%sSTATE_%s' % (self._Prefix().upper(), st.upper())
+
+ def _MakeTuple(self, data):
+ """Converts data to a string representation of a C tuple."""
+
+ return '{ %s }' % ', '.join(data)
+
+ def _CreateHeader(self):
+ """Print the include file header."""
+
+ out = []
+
+ if self._config.comment:
+ out.append('/* ' + self._config.comment)
+ else:
+ out.append('/* State machine definition for ' + self._config.name)
+ out.append(' * Auto generated by generate_fsm.py. Please do not edit.')
+ out.append(' */')
+
+ return '\n'.join(out)
+
+ def _ListToIndentedString(self, list):
+ indented_list = [' ' + e for e in list]
+ return ',\n'.join(indented_list)
+
+ def _CreateEnum(self, name, data):
+ """Print a c enum definition."""
+
+ return 'enum %s {\n%s\n};\n' % (name,
+ self._ListToIndentedString(data))
+
+ def _CreateStructList(self, name, type, data):
+ """Print a c flat list.
+
+ Generic function to print list in c in the form of a struct.
+
+ Args:
+ name: name of the structure.
+ type: type of the struct.
+ data: contents of the struct as a list of elements
+
+ Returns:
+ String with the generated list.
+ """
+
+ return "static const %s %s[] = {\n%s\n};\n" % (
+ type,
+ name,
+ self._ListToIndentedString(data))
+
+ def _CreateStatesEnum(self):
+ """Print the internal states enum.
+
+ Prints an enum containing all the valid states.
+
+ Returns:
+ String containing a C enumeration of the states.
+ """
+ list = [] # output list
+
+ for state in self._config.states:
+ list.append(self._StateInternalC(state))
+ return self._CreateEnum(self._Prefix() + 'state_internal_enum', list)
+
+ def _CreateStatesExternal(self):
+ """Print a struct with a mapping from internal to external states."""
+ list = [] # output list
+
+ for state_name in self._config.states:
+ list.append(self._StateExternalC(
+ self._config.states[state_name].external_name))
+
+ return self._CreateStructList(self._Prefix() + 'states_external',
+ 'int',
+ list)
+
+ def _CreateStatesInternalNames(self):
+ """Return a struct mapping internal states to a strings."""
+ out = [] # output list
+
+ for state_name in self._config.states:
+ out.append('"' + state_name + '"')
+
+ return self._CreateStructList(self._Prefix() + 'states_internal_names',
+ 'char *',
+ out)
+
+ def _CreateNumStates(self):
+ """Print a Macro defining the number of states."""
+
+ return "#define %s_NUM_STATES %s" % (self._config.name.upper(),
+ str(len(self._config.states) + 1))
+
+ def _ExpandBracketExpression(self, expression):
+ """Expand ranges in a regexp bracket expression.
+
+ Returns a string with the ranges in a bracket expression expanded.
+
+ The bracket expression is similar to grep(1) or regular expression bracket
+ expressions but it does not support the negation (^) modifier or named
+ character classes like [:alpha:] or [:alnum:].
+
+ The especial character class [:default:] will expand to all elements in the
+ ascii range.
+
+ For example, the expression 'a-c13A-D' will expand to 'abc13ABCD'.
+
+ Args:
+ expression: A regexp bracket expression. Ie: 'A-Z0-9'.
+
+ Returns:
+ A string with the ranges in the bracket expression expanded.
+ """
+
+ def ExpandRange(start, end):
+ """Return a sequence of characters between start and end.
+
+ Args:
+ start: first character of the sequence.
+ end: last character of the sequence.
+
+ Returns:
+ string containing the sequence of characters between start and end.
+ """
+ return [chr(c) for c in range(ord(start), ord(end) + 1)]
+
+ def ListNext(input_list):
+ """Pop the first element of a list.
+
+ Args:
+ input_list: python list object.
+
+ Returns:
+ First element of the list or None if the list is empty.
+ """
+ if input_list:
+ return input_list.pop(0)
+ else:
+ return None
+
+ out = [] # List containing the output
+
+ # Special case for the character class [:default:]
+ if expression == '[:default:]':
+ out = [chr(c) for c in range(0, 255)]
+ return ''.join(out)
+
+ chars = [c for c in expression] # list o characters in the expression.
+
+ current = ListNext(chars)
+ while current:
+ next = ListNext(chars)
+ if next == '-':
+ next = ListNext(chars)
+ if next:
+ out.extend(ExpandRange(current, next))
+ else:
+ out.append(current)
+ out.append('-')
+ current = ListNext(chars)
+ else:
+ out.append(current)
+ current = next
+
+ return ''.join(out)
+
+ def _CreateTransitionTable(self):
+ """Print the state transition list.
+
+ Returns a set of C structures that define the transition table for the state
+ machine. This structure is a list of lists of ints (int **). The outer list
+ indexes the source state and the inner list contains the destination state
+ for each of the possible input characters:
+
+ const int * const* transitions[source][input] == destination.
+
+ The conditions are mapped from the conditions variable.
+
+ Returns:
+ String containing the generated transition table in a C struct.
+ """
+ out = [] # output list
+ default_state = 'STATEMACHINE_ERROR'
+ state_table = {}
+
+ for state in self._config.states:
+ state_table[state] = [default_state for col in xrange(255)]
+
+ # We process the transition in reverse order while updating the table.
+ for i_transition in range(len(self._config.transitions) - 1, -1, -1):
+ transition = self._config.transitions[i_transition]
+ (condition_name, src, dst) = (transition.condition,
+ transition.source,
+ transition.destination)
+ condition = self._config.conditions[condition_name]
+ char_list = self._ExpandBracketExpression(condition)
+
+ for c in char_list:
+ state_table[src][ord(c)] = self._StateInternalC(dst)
+
+ # Create the inner lists which map input characters to destination states.
+ for state in self._config.states:
+ transition_row = []
+ for c in xrange(0, 255):
+ transition_row.append(' /* %06s */ %s' % (repr(chr(c)),
+ state_table[state][c]))
+
+ out.append(self._CreateStructList('%stransition_row_%s' %
+ (self._Prefix(),
+ state),
+ 'int',
+ transition_row))
+ out.append('\n')
+
+ # Create the outer list, which map source states to input characters.
+ out.append('static const %s %s[] = {\n' % ('int *', self._Prefix() +
+ 'state_transitions'))
+
+ row_list = [' %stransition_row_%s' %
+ (self._Prefix(), row) for row in self._config.states]
+ out.append(',\n'.join(row_list))
+ out.append('\n};\n')
+
+ return ''.join(out)
+
+ def Generate(self):
+ """Returns the generated the C include statements for the statemachine."""
+
+ print '\n'.join((self._CreateHeader(),
+ self._CreateNumStates(),
+ self._CreateStatesEnum(),
+ self._CreateStatesExternal(),
+ self._CreateStatesInternalNames(),
+ self._CreateTransitionTable()))
+
+
+def main():
+ if len(sys.argv) != 2:
+ print "usage: generate_fsm.py config_file"
+ sys.exit(1)
+
+ config = FSMConfig()
+ config.Load(sys.argv[1])
+
+ gen = FSMGenerateC(config)
+ gen.Generate()
+
+
+if __name__ == "__main__":
+ main()
diff --git a/src/htmlparser/htmlparser.cc b/src/htmlparser/htmlparser.cc
new file mode 100644
index 0000000..749a74e
--- /dev/null
+++ b/src/htmlparser/htmlparser.cc
@@ -0,0 +1,1096 @@
+/*
+ * Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ * ---
+ *
+ * Author: falmeida@google.com (Filipe Almeida)
+ */
+
+/* TODO(falmeida): Breaks on NULL characters in the stream. fix.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <assert.h>
+
+#include "htmlparser/statemachine.h"
+#include "htmlparser/htmlparser.h"
+#include "htmlparser/jsparser.h"
+
+/* So we can support both C and C++ compilers, we use the CAST() macro instead
+ * of using C style casts or static_cast<>() directly.
+ */
+#ifdef __cplusplus
+ #define CAST(type, expression) (static_cast<type>(expression))
+#else
+ #define CAST(type, expression) ((type)(expression))
+#endif
+
+#ifdef __cplusplus
+namespace ctemplate_htmlparser {
+#endif
+
+/* Generated state machine definition. */
+#include "htmlparser/htmlparser_fsm.h"
+
+#define is_js_attribute(attr) ((attr)[0] == 'o' && (attr)[1] == 'n')
+#define is_style_attribute(attr) (strcmp((attr), "style") == 0)
+
+/* html entity filter */
+static struct entityfilter_table_s {
+ const char *entity;
+ const char *value;
+} entityfilter_table[] = {
+ { "lt", "<" },
+ { "gt", ">" },
+ { "quot", "\"" },
+ { "amp", "&" },
+ { "apos", "\'" },
+ { NULL, NULL }
+};
+
+/* Utility functions */
+
+/* Similar to strncpy() but avoids the NULL padding. */
+static inline void nopad_strncpy(char *dst, const char *src, size_t dst_size,
+ size_t src_size)
+{
+ size_t size;
+
+ /* size = min(dst_size, src_size) */
+ size = dst_size > src_size ? src_size : dst_size;
+ strncpy(dst, src, size);
+ if (size > 0)
+ dst[size - 1] = '\0';
+}
+
+/* Converts the internal state into the external superstate.
+ */
+static int state_external(int st)
+{
+ if (st == STATEMACHINE_ERROR)
+ return HTMLPARSER_STATE_ERROR;
+ else
+ return htmlparser_states_external[st];
+}
+
+/* Returns true if the character is considered an html whitespace character.
+ *
+ * From: http://www.w3.org/TR/html401/struct/text.html#h-9.1
+ */
+static inline int html_isspace(char chr)
+{
+ if (chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r') {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+/* Returns true if the attribute is expected to contain a url
+ * This list was taken from: http://www.w3.org/TR/html4/index/attributes.html
+ */
+static int is_uri_attribute(char *attr)
+{
+ if (attr == NULL)
+ return 0;
+
+ switch (attr[0]) {
+ case 'a':
+ if (strcmp(attr, "action") == 0)
+ return 1;
+ /* TODO(falmeida): This is a uri list. Should we treat it diferently? */
+ if (strcmp(attr, "archive") == 0) /* This is a uri list */
+ return 1;
+ break;
+
+ case 'b':
+ if (strcmp(attr, "background") == 0)
+ return 1;
+ break;
+
+ case 'c':
+ if (strcmp(attr, "cite") == 0)
+ return 1;
+ if (strcmp(attr, "classid") == 0)
+ return 1;
+ if (strcmp(attr, "codebase") == 0)
+ return 1;
+ break;
+
+ case 'd':
+ if (strcmp(attr, "data") == 0)
+ return 1;
+ if (strcmp(attr, "dynsrc") == 0) /* from msdn */
+ return 1;
+ break;
+
+ case 'h':
+ if (strcmp(attr, "href") == 0)
+ return 1;
+ break;
+
+ case 'l':
+ if (strcmp(attr, "longdesc") == 0)
+ return 1;
+ break;
+
+ case 's':
+ if (strcmp(attr, "src") == 0)
+ return 1;
+ break;
+
+ case 'u':
+ if (strcmp(attr, "usemap") == 0)
+ return 1;
+ break;
+ }
+
+ return 0;
+
+}
+
+/* Convert a string to lower case characters inplace.
+ */
+static void tolower_str(char *s)
+{
+ while (*s != '\0') {
+ *s = CAST(char, tolower(CAST(unsigned char,*s)));
+ s++;
+ }
+}
+
+static const char *ignore_spaces_or_digits(const char *value) {
+ while (html_isspace(*value) || ((*value >= '0' && *value <= '9')))
+ value++;
+
+ return value;
+}
+
+static const char *ignore_spaces(const char *value) {
+ while (html_isspace(*value))
+ value++;
+
+ return value;
+}
+
+/* Return type of the function meta_redirect_type.
+ */
+enum meta_redirect_type_enum {
+ META_REDIRECT_TYPE_NONE,
+ META_REDIRECT_TYPE_URL_START,
+ META_REDIRECT_TYPE_URL
+};
+
+/* Analyzes a string for the presence of a meta refresh type url.
+ *
+ * This function receives the value of the content attribute of a meta tag and
+ * parses it in order to identify if a url is going to be present. This is the
+ * format of such tag:
+ *
+ * <meta http-equiv="refresh" content="5; URL=http://www.google.com">
+ *
+ * Using a regular expression library would be the most obvious way to implement
+ * this functionality, but introducing such a dependency is undesirable. We
+ * opted instead to parse programmaticly since the expression is simple enough.
+ *
+ * For reference, this is the spec on the meta http refresh tag:
+ * http://dev.w3.org/html5/spec/Overview.html#attr-meta-http-equiv-refresh
+ *
+ * If the value has no content after the expression, we know we are at the start
+ * of the URL. Otherwise we are past the start of the URL.
+ *
+ *
+ * Returns:
+ *
+ * This functions returns one of the following values:
+ * META_REDIRECT_TYPE_NONE - A url was not identified in the input string.
+ * META_REDIRECT_TYPE_URL_START - The input string ends exactly at the start
+ * of the url.
+ * META_REDIRECT_TYPE_URL - The input string ends somewhere in the middle or
+ * the end of the url.
+ *
+ * A few examples:
+ * "5"
+ * Returns META_REDIRECT_TYPE_NONE since we don't expect a url to follow.
+ *
+ * "5; URL = "
+ * The function returns META_REDIRECT_TYPE_URL_START since we expect a url to
+ * follow.
+ *
+ * "5; URL = http://www.google.com/?"
+ * Returns META_REDIRECT_TYPE_URL since the input value terminates in the
+ * middle or end of a url.
+ *
+ *
+ * Caveats: We are only recording up to 256 characters of attribute values, so
+ * our analysis is limited to that. This shouldn't be an issue in practice
+ * though as it would be unexpected for the part of the string that we are
+ * matching to be so long.
+ */
+enum meta_redirect_type_enum meta_redirect_type(const char *value) {
+
+ if (value == NULL)
+ return META_REDIRECT_TYPE_NONE;
+
+ /* Match while [ \t\r\n0-9]* */
+ value = ignore_spaces_or_digits(value);
+
+ /* Verify that we got a semi-colon character */
+ if (*value != ';')
+ return META_REDIRECT_TYPE_NONE;
+ value++;
+
+ /* Match while [ \t\r\n]* */
+ value = ignore_spaces(value);
+
+ /* Validate that we have 'URL' */
+ if (strncasecmp(value, "url", strlen("url")) != 0)
+ return META_REDIRECT_TYPE_NONE;
+
+ value += strlen("url");
+
+ /* Match while [ \t\r\n]* */
+ value = ignore_spaces(value);
+
+ if (*value != '=')
+ return META_REDIRECT_TYPE_NONE;
+ value++;
+
+ /* Match while [ \t\r\n]* */
+ value = ignore_spaces(value);
+
+ /* The HTML5 spec allows for the url to be quoted, so we skip a single or
+ * double quote if we find one.
+ */
+ if (*value == '"' || *value == '\'')
+ value++;
+
+ if (*value == '\0')
+ return META_REDIRECT_TYPE_URL_START;
+ else
+ return META_REDIRECT_TYPE_URL;
+}
+
+
+/* Resets the entityfilter to it's initial state so it can be reused.
+ */
+void entityfilter_reset(entityfilter_ctx *ctx)
+{
+ ctx->buffer[0] = 0;
+ ctx->buffer_pos = 0;
+ ctx->in_entity = 0;
+}
+
+/* Initializes a new entity filter object.
+ */
+entityfilter_ctx *entityfilter_new()
+{
+ entityfilter_ctx *ctx;
+ ctx = CAST(entityfilter_ctx *,
+ malloc(sizeof(entityfilter_ctx)));
+
+ if (ctx == NULL)
+ return NULL;
+ ctx->buffer[0] = 0;
+ ctx->buffer_pos = 0;
+ ctx->in_entity = 0;
+
+ return ctx;
+}
+
+/* Copies the context of the entityfilter pointed to by src to the entityfilter
+ * dst.
+ */
+void entityfilter_copy(entityfilter_ctx *dst, entityfilter_ctx *src)
+{
+ assert(src != NULL);
+ assert(dst != NULL);
+ assert(src != dst);
+ memcpy(dst, src, sizeof(entityfilter_ctx));
+}
+
+
+/* Deallocates an entity filter object.
+ */
+void entityfilter_delete(entityfilter_ctx *ctx)
+{
+ free(ctx);
+}
+
+/* Converts a string containing an hexadecimal number to a string containing
+ * one character with the corresponding ascii value.
+ *
+ * The provided output char array must be at least 2 chars long.
+ */
+static const char *parse_hex(const char *s, char *output)
+{
+ int n;
+ n = strtol(s, NULL, 16);
+ output[0] = n;
+ output[1] = 0;
+ /* TODO(falmeida): Make this function return void */
+ return output;
+}
+
+/* Converts a string containing a decimal number to a string containing one
+ * character with the corresponding ascii value.
+ *
+ * The provided output char array must be at least 2 chars long.
+ */
+static const char *parse_dec(const char *s, char *output)
+{
+ int n;
+ n = strtol(s, NULL, 10);
+ output[0] = n;
+ output[1] = 0;
+ return output;
+}
+
+/* Converts a string with an html entity to it's encoded form, which is written
+ * to the output string.
+ */
+static const char *entity_convert(const char *s, char *output, char terminator)
+{
+ /* TODO(falmeida): Handle wide char encodings */
+ struct entityfilter_table_s *t = entityfilter_table;
+
+ if (s[0] == '#') {
+ if (s[1] == 'x' || s[1] == 'X') { /* hex */
+ return parse_hex(s + 2, output);
+ } else { /* decimal */
+ return parse_dec(s + 1, output);
+ }
+ }
+
+ while (t->entity != NULL) {
+ if (strcasecmp(t->entity, s) == 0)
+ return t->value;
+ t++;
+ }
+
+ snprintf(output, HTMLPARSER_MAX_ENTITY_SIZE, "&%s%c", s, terminator);
+ output[HTMLPARSER_MAX_ENTITY_SIZE - 1] = '\0';
+
+ return output;
+}
+
+
+/* Processes a character from the input stream and decodes any html entities
+ * in the processed input stream.
+ */
+const char *entityfilter_process(entityfilter_ctx *ctx, char c)
+{
+ if (ctx->in_entity) {
+ if (c == ';' || html_isspace(c)) {
+ ctx->in_entity = 0;
+ ctx->buffer[ctx->buffer_pos] = '\0';
+ ctx->buffer_pos = 0;
+ return entity_convert(ctx->buffer, ctx->output, c);
+ } else {
+ ctx->buffer[ctx->buffer_pos++] = c;
+ if (ctx->buffer_pos >= HTMLPARSER_MAX_ENTITY_SIZE - 2) {
+ /* No more buffer to use, finalize and return.
+ * We need two characters left, one for the '&' character and
+ * another for the NULL termination. */
+ ctx->buffer[ctx->buffer_pos] = '\0';
+ ctx->in_entity=0;
+ ctx->buffer_pos = 0;
+ snprintf(ctx->output, HTMLPARSER_MAX_ENTITY_SIZE, "&%s",
+ ctx->buffer);
+ ctx->output[HTMLPARSER_MAX_ENTITY_SIZE - 1] = '\0';
+ return ctx->output;
+ }
+ }
+ } else {
+ if (c == '&') {
+ ctx->in_entity = 1;
+ ctx->buffer_pos = 0;
+ } else {
+ ctx->output[0] = c;
+ ctx->output[1] = 0;
+ return ctx->output;
+ }
+ }
+ return "";
+}
+
+/* Called when the parser enters a new tag. Starts recording it's name into
+ * html->tag.
+ */
+static void enter_tag_name(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ html->tag[0] = '\0';
+ statemachine_start_record(ctx);
+}
+
+/* Called when the parser exits the tag name in order to finalize the recording.
+ *
+ * It converts the tag name to lowercase, and if the tag was closed, just
+ * clears html->tag.
+ */
+static void exit_tag_name(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ nopad_strncpy(html->tag, statemachine_stop_record(ctx),
+ HTMLPARSER_MAX_STRING, statemachine_record_length(ctx));
+
+ tolower_str(html->tag);
+
+ if (html->tag[0] == '/')
+ html->tag[0] = '\0';
+}
+
+/* Called when the parser enters a new tag. Starts recording it's name into
+ * html->attr
+ */
+static void enter_attr(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ html->attr[0] = '\0';
+ statemachine_start_record(ctx);
+}
+
+/* Called when the parser exits the attribute name in order to finalize the
+ * recording.
+ *
+ * It converts the tag name to lowercase.
+ */
+static void exit_attr(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ nopad_strncpy(html->attr, statemachine_stop_record(ctx),
+ HTMLPARSER_MAX_STRING, statemachine_record_length(ctx));
+
+ tolower_str(html->attr);
+}
+
+/* Called when we enter an attribute value.
+ *
+ * Keeps track of a position index inside the value and initializes the
+ * javascript state machine for attributes that accept javascript.
+ */
+static void enter_value(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ html->value_index = 0;
+
+ if (is_js_attribute(html->attr)) {
+ entityfilter_reset(html->entityfilter);
+ jsparser_reset(html->jsparser);
+ html->in_js = 1;
+ } else {
+ html->in_js = 0;
+ }
+}
+
+/* Called when we enter the contents of an attribute value.
+ *
+ * Initializes the recording of the contents of the value.
+ */
+static void enter_value_content(statemachine_ctx *ctx, int start, char chr,
+ int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ html->value[0] = '\0';
+ statemachine_start_record(ctx);
+}
+
+/* Called when we exit the contents of an attribute value.
+ *
+ * Finalizes the recording of the contents of the value.
+ */
+static void exit_value_content(statemachine_ctx *ctx, int start, char chr,
+ int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ nopad_strncpy(html->value, statemachine_stop_record(ctx),
+ HTMLPARSER_MAX_STRING, statemachine_record_length(ctx));
+
+ html->in_js = 0;
+}
+
+/* Called for every character inside an attribute value.
+ *
+ * Used to process javascript and keep track of the position index inside the
+ * attribute value.
+ */
+static void in_state_value(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ html->value_index++;
+
+ if (html->in_js == 1) {
+ const char *output;
+ output = entityfilter_process(html->entityfilter, chr);
+ jsparser_parse_str(html->jsparser, output);
+ }
+}
+
+/* Called everytime the parser leaves a tag definition.
+ *
+ * When we encounter a script tag, we initialize the js parser and switch the
+ * state to cdata. We also switch to the cdata state when we encounter any
+ * other CDATA/RCDATA tag (style, title or textarea) except that we do not
+ * initialize the js parser.
+ *
+ * To simplify the code, we treat RCDATA and CDATA sections the same since the
+ * differences between them don't affect the context we are in.
+ */
+static void tag_close(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ if (strcmp(html->tag, "script") == 0) {
+ ctx->next_state = HTMLPARSER_STATE_INT_CDATA_TEXT;
+ jsparser_reset(html->jsparser);
+ html->in_js = 1;
+ } else if (strcmp(html->tag, "style") == 0 ||
+ strcmp(html->tag, "title") == 0 ||
+ strcmp(html->tag, "textarea") == 0) {
+ ctx->next_state = HTMLPARSER_STATE_INT_CDATA_TEXT;
+ html->in_js = 0;
+ }
+}
+
+/* Called inside cdata blocks in order to parse the javascript.
+ *
+ * Calls the javascript parser if currently in a script tag.
+ */
+static void in_state_cdata(statemachine_ctx *ctx, int start, char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ assert(html != NULL);
+
+ if (html->in_js)
+ jsparser_parse_chr(html->jsparser, chr);
+}
+
+/* Called if we encounter a '<' character in a cdata section.
+ *
+ * When encountering a '<' character inside cdata, we need to find the closing
+ * tag name in order to know if the tag is going to be closed or not, so we
+ * start recording the name of what could be the closing tag.
+ */
+static void enter_state_cdata_may_close(statemachine_ctx *ctx, int start,
+ char chr, int end)
+{
+ statemachine_start_record(ctx);
+}
+
+/* Called when we finish reading what could be a closing cdata tag.
+ *
+ * Checks if the closing tag name matches the current entity, and if so closes
+ * the element.
+ */
+static void exit_state_cdata_may_close(statemachine_ctx *ctx, int start,
+ char chr, int end)
+{
+ htmlparser_ctx *html = CAST(htmlparser_ctx *, ctx->user);
+ const char *cdata_close_tag;
+ assert(html != NULL);
+
+ cdata_close_tag = statemachine_stop_record(ctx);
+ assert(cdata_close_tag[0] == '/');
+
+ if (strcasecmp(&cdata_close_tag[1], html->tag) == 0 &&
+ (chr == '>' || html_isspace(chr))) { /* Make sure we have a delimiter */
+ html->tag[0] = '\0'; /* Empty tag mimicking exit_tag_name(). */
+ html->in_js = 0; /* In case this was a script tag. */
+ } else {
+ /* Does not close the CDATA section. Go back to CDATA. */
+ ctx->next_state = HTMLPARSER_STATE_INT_CDATA_TEXT;
+ }
+}
+
+/* Resets the parser to it's initial state and changes the parser mode.
+ */
+void htmlparser_reset_mode(htmlparser_ctx *ctx, int mode)
+{
+ assert(ctx != NULL);
+ statemachine_reset(ctx->statemachine);
+ ctx->in_js = 0;
+ ctx->tag[0] = '\0';
+ ctx->attr[0] = '\0';
+ ctx->value[0] = '\0';
+
+ jsparser_reset(ctx->jsparser);
+
+ switch (mode) {
+ case HTMLPARSER_MODE_HTML:
+ ctx->statemachine->current_state = HTMLPARSER_STATE_INT_TEXT;
+ break;
+ case HTMLPARSER_MODE_JS:
+ ctx->statemachine->current_state = HTMLPARSER_STATE_INT_JS_FILE;
+ ctx->in_js = 1;
+ break;
+ case HTMLPARSER_MODE_CSS:
+ ctx->statemachine->current_state = HTMLPARSER_STATE_INT_CSS_FILE;
+ break;
+ case HTMLPARSER_MODE_HTML_IN_TAG:
+ ctx->statemachine->current_state = HTMLPARSER_STATE_INT_TAG_SPACE;
+ break;
+ default:
+ assert("Invalid mode in htmlparser_reset_mode()." && 0);
+ }
+}
+
+/* Resets the parser to it's initial state and to the default mode, which
+ * is MODE_HTML.
+ */
+void htmlparser_reset(htmlparser_ctx *ctx)
+{
+ assert(ctx != NULL);
+ htmlparser_reset_mode(ctx, HTMLPARSER_MODE_HTML);
+}
+
+/* Creates a new state machine definition and initializes the events for the
+ * state transitions.
+ *
+ * Although each instance of the parser has it's own private instance of a
+ * statemachine definition, they are still identical across html parser objects
+ * and are never modified after creation. As such, changes to this definition
+ * should not occur outside this function and should not depend on properties
+ * of this particular parser instance as in the future we may opt to use a
+ * single public definition across parser objects.
+ */
+static statemachine_definition *create_statemachine_definition()
+{
+ statemachine_definition *def;
+ def = statemachine_definition_new(HTMLPARSER_NUM_STATES);
+ if (def == NULL)
+ return NULL;
+
+ statemachine_definition_populate(def, htmlparser_state_transitions,
+ htmlparser_states_internal_names);
+
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_TAG_NAME,
+ enter_tag_name);
+ statemachine_exit_state(def, HTMLPARSER_STATE_INT_TAG_NAME, exit_tag_name);
+
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_ATTR, enter_attr);
+ statemachine_exit_state(def, HTMLPARSER_STATE_INT_ATTR, exit_attr);
+
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_TAG_CLOSE, tag_close);
+
+ /* CDATA states. We must list all cdata and javascript states here. */
+ /* TODO(falmeida): Declare this list in htmlparser_fsm.config so it doesn't
+ * go out of sync.
+ */
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_TEXT, in_state_cdata);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_COMMENT_START,
+ in_state_cdata);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_COMMENT_START_DASH,
+ in_state_cdata);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_COMMENT_BODY,
+ in_state_cdata);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_COMMENT_DASH,
+ in_state_cdata);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_COMMENT_DASH_DASH,
+ in_state_cdata);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_LT, in_state_cdata);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_CDATA_MAY_CLOSE,
+ in_state_cdata);
+
+ /* For simplification, we treat the javascript mode as if it were cdata. */
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_JS_FILE, in_state_cdata);
+
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_CDATA_MAY_CLOSE,
+ enter_state_cdata_may_close);
+ statemachine_exit_state(def, HTMLPARSER_STATE_INT_CDATA_MAY_CLOSE,
+ exit_state_cdata_may_close);
+ /* value states */
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_VALUE, enter_value);
+
+ /* Called when we enter the content of the value */
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_VALUE_TEXT,
+ enter_value_content);
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_VALUE_Q,
+ enter_value_content);
+ statemachine_enter_state(def, HTMLPARSER_STATE_INT_VALUE_DQ,
+ enter_value_content);
+
+ /* Called when we exit the content of the value */
+ statemachine_exit_state(def, HTMLPARSER_STATE_INT_VALUE_TEXT,
+ exit_value_content);
+ statemachine_exit_state(def, HTMLPARSER_STATE_INT_VALUE_Q,
+ exit_value_content);
+ statemachine_exit_state(def, HTMLPARSER_STATE_INT_VALUE_DQ,
+ exit_value_content);
+
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_VALUE_TEXT, in_state_value);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_VALUE_Q, in_state_value);
+ statemachine_in_state(def, HTMLPARSER_STATE_INT_VALUE_DQ, in_state_value);
+
+ return def;
+}
+
+
+/* Initializes a new htmlparser instance.
+ *
+ * Returns a pointer to the new instance or NULL if the initialization fails.
+ * Initialization failure is fatal, and if this function fails it may not
+ * deallocate all previsouly allocated memory.
+ */
+htmlparser_ctx *htmlparser_new()
+{
+ htmlparser_ctx *html;
+
+ html = CAST(htmlparser_ctx *, calloc(1, sizeof(htmlparser_ctx)));
+ if (html == NULL)
+ return NULL;
+
+ html->statemachine_def = create_statemachine_definition();
+ if (html->statemachine_def == NULL)
+ return NULL;
+
+ html->statemachine = statemachine_new(html->statemachine_def, html);
+ if (html->statemachine == NULL)
+ return NULL;
+
+ html->jsparser = jsparser_new();
+ if (html->jsparser == NULL)
+ return NULL;
+
+ html->entityfilter = entityfilter_new();
+ if (html->entityfilter == NULL)
+ return NULL;
+
+ htmlparser_reset(html);
+
+ return html;
+}
+
+/* Copies the context of the htmlparser pointed to by src to the htmlparser dst.
+ */
+void htmlparser_copy(htmlparser_ctx *dst, const htmlparser_ctx *src)
+{
+ dst->value_index = src->value_index;
+ dst->in_js = src->in_js;
+ strcpy(dst->tag, src->tag);
+ strcpy(dst->attr, src->attr);
+ strcpy(dst->value, src->value);
+
+ statemachine_copy(dst->statemachine,
+ src->statemachine,
+ dst->statemachine_def,
+ dst);
+
+ jsparser_copy(dst->jsparser, src->jsparser);
+
+ entityfilter_copy(dst->entityfilter, src->entityfilter);
+
+}
+
+/* Receives an htmlparser context and Returns the current html state.
+ */
+int htmlparser_state(htmlparser_ctx *ctx)
+{
+ return state_external(ctx->statemachine->current_state);
+}
+
+/* Parses the input html stream and returns the finishing state.
+ */
+int htmlparser_parse(htmlparser_ctx *ctx, const char *str, int size)
+{
+ int internal_state;
+ internal_state = statemachine_parse(ctx->statemachine, str, size);
+ return state_external(internal_state);
+}
+
+
+/* Returns true if the parser is inside an attribute value and the value is
+ * surrounded by single or double quotes. */
+int htmlparser_is_attr_quoted(htmlparser_ctx *ctx) {
+ int st = statemachine_get_state(ctx->statemachine);
+ if (st == HTMLPARSER_STATE_INT_VALUE_Q_START ||
+ st == HTMLPARSER_STATE_INT_VALUE_Q ||
+ st == HTMLPARSER_STATE_INT_VALUE_DQ_START ||
+ st == HTMLPARSER_STATE_INT_VALUE_DQ)
+ return 1;
+ else
+ return 0;
+}
+
+/* Returns true if the parser is currently in javascript.
+ */
+int htmlparser_in_js(htmlparser_ctx *ctx) {
+ int st = statemachine_get_state(ctx->statemachine);
+
+/* CDATA states plus JS_FILE. We must list all cdata and javascript states
+ * here. */
+/* TODO(falmeida): Declare this list in htmlparser_fsm.config so it doesn't go
+ * out of sync. */
+ if (ctx->in_js &&
+ (st == HTMLPARSER_STATE_INT_CDATA_TEXT ||
+ st == HTMLPARSER_STATE_INT_CDATA_COMMENT_START ||
+ st == HTMLPARSER_STATE_INT_CDATA_COMMENT_START_DASH ||
+ st == HTMLPARSER_STATE_INT_CDATA_COMMENT_BODY ||
+ st == HTMLPARSER_STATE_INT_CDATA_COMMENT_DASH ||
+ st == HTMLPARSER_STATE_INT_CDATA_COMMENT_DASH_DASH ||
+ st == HTMLPARSER_STATE_INT_CDATA_LT ||
+ st == HTMLPARSER_STATE_INT_CDATA_MAY_CLOSE ||
+ st == HTMLPARSER_STATE_INT_JS_FILE))
+ return 1;
+
+ if (state_external(st) == HTMLPARSER_STATE_VALUE && ctx->in_js)
+ return 1;
+ else
+ return 0;
+}
+
+/* Returns the current tag or NULL if not available or we haven't seen the
+ * entire tag yet.
+ */
+const char *htmlparser_tag(htmlparser_ctx *ctx)
+{
+ if (ctx->tag[0] != '\0')
+ return ctx->tag;
+ else
+ return NULL;
+}
+
+/* Returns true if inside an attribute or a value */
+int htmlparser_in_attr(htmlparser_ctx *ctx)
+{
+ int ext_state = state_external(statemachine_get_state(ctx->statemachine));
+ return ext_state == HTMLPARSER_STATE_ATTR ||
+ ext_state == HTMLPARSER_STATE_VALUE;
+}
+
+/* Returns the current attribute name if after an attribute name or in an
+ * attribute value. Returns NULL otherwise. */
+const char *htmlparser_attr(htmlparser_ctx *ctx)
+{
+ if (htmlparser_in_attr(ctx))
+ return ctx->attr;
+ else
+ return NULL;
+}
+
+/* Returns true if the parser is currently inside a CSS construct.
+ */
+int htmlparser_in_css(htmlparser_ctx *ctx) {
+ int state = statemachine_get_state(ctx->statemachine);
+ const char *tag = htmlparser_tag(ctx);
+ int external_state = state_external(state);
+
+ if (state == HTMLPARSER_STATE_INT_CSS_FILE ||
+ (external_state == HTMLPARSER_STATE_VALUE &&
+ htmlparser_attr_type(ctx) == HTMLPARSER_ATTR_STYLE) ||
+ (tag && strcmp(tag, "style") == 0)) {
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
+/* Returns the contents of the current attribute value.
+ */
+const char *htmlparser_value(htmlparser_ctx *ctx)
+{
+ int ext_state = state_external(statemachine_get_state(ctx->statemachine));
+ if (ext_state == HTMLPARSER_STATE_VALUE) {
+ strncpy(ctx->value, statemachine_record_buffer(ctx->statemachine),
+ HTMLPARSER_MAX_STRING);
+ ctx->value[HTMLPARSER_MAX_STRING - 1] = '\0';
+ return ctx->value;
+ } else {
+ return NULL;
+ }
+}
+
+
+/* Returns the current state of the javascript state machine
+ *
+ * Currently only present for testing purposes.
+ */
+int htmlparser_js_state(htmlparser_ctx *ctx)
+{
+ return jsparser_state(ctx->jsparser);
+}
+
+/* True is currently inside a javascript string literal
+ */
+int htmlparser_is_js_quoted(htmlparser_ctx *ctx)
+{
+ if (htmlparser_in_js(ctx)) {
+ int st = jsparser_state(ctx->jsparser);
+ if (st == JSPARSER_STATE_Q ||
+ st == JSPARSER_STATE_DQ)
+ return 1;
+ }
+ return 0;
+}
+
+/* True if currently inside an attribute value
+ */
+int htmlparser_in_value(htmlparser_ctx *ctx)
+{
+ int ext_state = state_external(statemachine_get_state(ctx->statemachine));
+ return ext_state == HTMLPARSER_STATE_VALUE;
+}
+
+/* Returns the position inside the current attribute value
+ */
+int htmlparser_value_index(htmlparser_ctx *ctx)
+{
+ if (htmlparser_in_value(ctx))
+ return ctx->value_index;
+
+ return -1;
+}
+
+/* Returns true if this is the first character of a url inside an attribute.
+ */
+int htmlparser_is_url_start(htmlparser_ctx *ctx)
+{
+ if (htmlparser_attr_type(ctx) == HTMLPARSER_ATTR_URI) {
+ const char* tag = htmlparser_tag(ctx);
+ /*const char* attr =*/ htmlparser_attr(ctx);
+
+ if ((tag && strcmp(tag, "meta") == 0 &&
+ meta_redirect_type(htmlparser_value(ctx)) ==
+ META_REDIRECT_TYPE_URL_START) ||
+ htmlparser_value_index(ctx) == 0)
+ return 1;
+
+ }
+ return 0;
+}
+
+/* Returns the current attribute type.
+ */
+int htmlparser_attr_type(htmlparser_ctx *ctx)
+{
+ if (!htmlparser_in_attr(ctx))
+ return HTMLPARSER_ATTR_NONE;
+
+ if (is_js_attribute(ctx->attr))
+ return HTMLPARSER_ATTR_JS;
+
+ if (is_uri_attribute(ctx->attr))
+ return HTMLPARSER_ATTR_URI;
+
+ if (is_style_attribute(ctx->attr))
+ return HTMLPARSER_ATTR_STYLE;
+
+ const char* tag = htmlparser_tag(ctx);
+ const char* attr = htmlparser_attr(ctx);
+
+ /* Special logic to handle meta redirect type tags. */
+ if (tag && strcmp(tag, "meta") == 0 &&
+ attr && strcmp(attr, "content") == 0) {
+
+ const char* value = htmlparser_value(ctx);
+ meta_redirect_type_enum redirect_type = meta_redirect_type(value);
+
+ if (redirect_type == META_REDIRECT_TYPE_URL ||
+ redirect_type == META_REDIRECT_TYPE_URL_START)
+ return HTMLPARSER_ATTR_URI;
+ }
+
+ return HTMLPARSER_ATTR_REGULAR;
+}
+
+/* Return the current line number. */
+int htmlparser_get_line_number(htmlparser_ctx *ctx) {
+ return statemachine_get_line_number(ctx->statemachine);
+}
+
+/* Set the current line number. */
+void htmlparser_set_line_number(htmlparser_ctx *ctx, int line) {
+ statemachine_set_line_number(ctx->statemachine, line);
+}
+
+/* Return the current column number. */
+int htmlparser_get_column_number(htmlparser_ctx *ctx) {
+ return statemachine_get_column_number(ctx->statemachine);
+}
+
+/* Set the current column number. */
+void htmlparser_set_column_number(htmlparser_ctx *ctx, int column) {
+ statemachine_set_column_number(ctx->statemachine, column);
+}
+
+/* Retrieve a human readable error message in case an error occurred.
+ *
+ * NULL is returned if the parser didn't encounter an error.
+ */
+const char *htmlparser_get_error_msg(htmlparser_ctx *ctx) {
+ return statemachine_get_error_msg(ctx->statemachine);
+}
+
+/* Invoked by the caller when text is expanded by the caller.
+ */
+int htmlparser_insert_text(htmlparser_ctx *ctx)
+{
+ /* TODO(falmeida): Generalize and use a table for these values. */
+
+ if (statemachine_get_state(ctx->statemachine) == HTMLPARSER_STATE_INT_VALUE) {
+ statemachine_set_state(ctx->statemachine, HTMLPARSER_STATE_INT_VALUE_TEXT);
+ }
+ return 1;
+}
+
+/* Deallocates an htmlparser context object.
+ */
+void htmlparser_delete(htmlparser_ctx *ctx)
+{
+ assert(ctx != NULL);
+ statemachine_definition_delete(ctx->statemachine_def);
+ statemachine_delete(ctx->statemachine);
+ jsparser_delete(ctx->jsparser);
+ entityfilter_delete(ctx->entityfilter);
+ free(ctx);
+}
+
+#ifdef __cplusplus
+} /* namespace security_streamhtmlparser */
+#endif
diff --git a/src/htmlparser/htmlparser.h b/src/htmlparser/htmlparser.h
new file mode 100644
index 0000000..120fb3e
--- /dev/null
+++ b/src/htmlparser/htmlparser.h
@@ -0,0 +1,441 @@
+/*
+ * Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ * ---
+ *
+ * Author: falmeida@google.com (Filipe Almeida)
+ */
+
+#ifndef SECURITY_STREAMHTMLPARSER_HTMLPARSER_H
+#define SECURITY_STREAMHTMLPARSER_HTMLPARSER_H
+
+#include <config.h>
+#include "htmlparser/statemachine.h"
+#include "htmlparser/jsparser.h"
+
+// Annoying stuff for windows in opensource-land -- make sure clients
+// (in this case unittests) can import the functions.
+#ifndef CTEMPLATE_DLL_DECL
+# ifdef _MSC_VER
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+# else
+# define CTEMPLATE_DLL_DECL /* should be the empty string for non-windows */
+# endif
+#endif
+
+#ifdef __cplusplus
+namespace ctemplate_htmlparser {
+#endif
+
+/* entity filter */
+
+/* String sizes used in htmlparser and entityfilter structures including the
+ * NULL terminator.
+ */
+#define HTMLPARSER_MAX_STRING STATEMACHINE_RECORD_BUFFER_SIZE
+#define HTMLPARSER_MAX_ENTITY_SIZE 10
+
+
+enum htmlparser_state_external_enum {
+ HTMLPARSER_STATE_TEXT,
+ HTMLPARSER_STATE_TAG,
+ HTMLPARSER_STATE_ATTR,
+ HTMLPARSER_STATE_VALUE,
+ HTMLPARSER_STATE_COMMENT,
+ HTMLPARSER_STATE_JS_FILE,
+ HTMLPARSER_STATE_CSS_FILE,
+ HTMLPARSER_STATE_ERROR
+};
+
+enum htmlparser_mode {
+ HTMLPARSER_MODE_HTML,
+ HTMLPARSER_MODE_JS,
+ HTMLPARSER_MODE_CSS,
+ HTMLPARSER_MODE_HTML_IN_TAG
+};
+
+enum htmlparser_attr_type {
+ HTMLPARSER_ATTR_NONE,
+ HTMLPARSER_ATTR_REGULAR,
+ HTMLPARSER_ATTR_URI,
+ HTMLPARSER_ATTR_JS,
+ HTMLPARSER_ATTR_STYLE
+};
+
+
+/* TODO(falmeida): Maybe move some of these declaration to the .c and only keep
+ * a forward declaration in here, since these structures are private.
+ */
+
+/* entityfilter context structure.
+ *
+ * The entity filter collection of routines provide a way to decode html
+ * entities from an html document in a streaming way.
+ *
+ * The html_process() function receives a character at a time from the input
+ * stream and returns 0 or more characters which should be appended to the
+ * resulting decoded document.
+ *
+ * Currently this collection of functions are only exported for testing purposes
+ * and shouldn't be called from outside of htmlparser.c.
+ *
+ * Since we really only use these functions with the very specific purpose of
+ * decoding html entities for javascript attributes, only a small subset of
+ * entities are supported: <, >, "e;, &, &apos, and the numeric
+ * character references for both decimal and hexadecimal.
+ */
+typedef struct entityfilter_ctx_s {
+
+ /* Current position into the buffer. */
+ int buffer_pos;
+
+ /* True if currently processing an html entity. */
+ int in_entity;
+
+ /* Temporary character buffer that is used while processing html entities.
+ */
+ char buffer[HTMLPARSER_MAX_ENTITY_SIZE];
+
+ /* String buffer returned to the application after we decoded an html
+ * entity.
+ */
+ char output[HTMLPARSER_MAX_ENTITY_SIZE];
+} entityfilter_ctx;
+
+/* Resets the entityfilter to its initial state so it can be reused.
+ */
+void entityfilter_reset(entityfilter_ctx *ctx);
+
+/* Initializes a new entity filter object.
+ */
+entityfilter_ctx *entityfilter_new(void);
+
+/* Deallocates an entity filter object.
+ */
+void entityfilter_delete(entityfilter_ctx *ctx);
+
+/* Copies the context of the entityfilter pointed to by src to the entityfilter
+ * dst.
+ */
+void entityfilter_copy(entityfilter_ctx *dst, entityfilter_ctx *src);
+
+/* Processes a character from the input stream and decodes any html entities
+ * in the accumulated buffer.
+ *
+ * Returns a reference to a string that points to an internal buffer. This
+ * buffer will be changed after every call to entityfilter_process(). As
+ * such this string should be duplicated before subsequent calls to
+ * entityfilter_process().
+ */
+const char *entityfilter_process(entityfilter_ctx *ctx, char c);
+
+
+/* html parser */
+
+/* Stores the context of the html parser.
+ * If this structure is changed, htmlparser_new(), htmlparser_copy() and
+ * htmlparser_reset() should be updated accordingly.
+ */
+typedef struct htmlparser_ctx_s {
+
+ /* Holds a reference to the statemachine context. */
+ statemachine_ctx *statemachine;
+
+ /* Holds a reference to the statemachine definition in use. Right now this is
+ * only used so we can deallocate it at the end.
+ *
+ * It should be readonly and contain the same values across jsparser
+ * instances.
+ */
+ /* TODO(falmeida): Change statemachine_def to const. */
+ statemachine_definition *statemachine_def;
+
+ /* Holds a reference to the javascript parser. */
+ jsparser_ctx *jsparser;
+
+ /* Holds a reference to the entity filter. Used for decoding html entities
+ * inside javascript attributes. */
+ entityfilter_ctx *entityfilter;
+
+ /* Offset into the current attribute value where 0 is the first character in
+ * the value. */
+ int value_index;
+
+ /* True if currently processing javascript. */
+ int in_js;
+
+ /* Current tag name. */
+ char tag[HTMLPARSER_MAX_STRING];
+
+ /* Current attribute name. */
+ char attr[HTMLPARSER_MAX_STRING];
+
+ /* Contents of the current value capped to HTMLPARSER_MAX_STRING. */
+ char value[HTMLPARSER_MAX_STRING];
+
+} htmlparser_ctx;
+
+/* Resets the parser to its initial state and to the default mode, which
+ * is MODE_HTML.
+ *
+ * All internal context like tag name, attribute name or the state of the
+ * statemachine are reset to its original values as if the object was just
+ * created.
+ */
+extern CTEMPLATE_DLL_DECL
+void htmlparser_reset(htmlparser_ctx *ctx);
+
+/* Resets the parser to its initial state and changes the parser mode.
+ * All internal context like tag name, attribute name or the state of the
+ * statemachine are reset to their original values as if the object was just
+ * created.
+ *
+ * Available modes:
+ * HTMLPARSER_MODE_HTML - Parses html text
+ * HTMLPARSER_MODE_JS - Parses javascript files
+ * HTMLPARSER_MODE_CSS - Parses CSS files. No actual parsing is actually done
+ * but htmlparser_in_css() always returns true.
+ * HTMLPARSER_MODE_HTML_IN_TAG - Parses an attribute list inside a tag. To
+ * be used in a template expanded in the
+ * following context: <a $template>
+ *
+ */
+extern CTEMPLATE_DLL_DECL
+void htmlparser_reset_mode(htmlparser_ctx *ctx, int mode);
+
+/* Initializes a new htmlparser instance.
+ *
+ * Returns a pointer to the new instance or NULL if the initialization fails.
+ * Initialization failure is fatal, and if this function fails it may not
+ * deallocate all previsouly allocated memory.
+ */
+extern CTEMPLATE_DLL_DECL
+htmlparser_ctx *htmlparser_new(void);
+
+/* Copies the context of the htmlparser pointed to by src to the htmlparser dst.
+ *
+ * Also copies over the instances of the state machine, the jsparser and the
+ * entity filter but not the statemachine definition since this one is read
+ * only.
+ */
+extern CTEMPLATE_DLL_DECL
+void htmlparser_copy(htmlparser_ctx *dst, const htmlparser_ctx *src);
+
+/* Receives an htmlparser context and returns the current html state.
+ *
+ * The return value will be one of the states of htmlparser_state_external_enum.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_state(htmlparser_ctx *ctx);
+
+/* Parses the input html stream and returns the finishing state.
+ *
+ * Returns HTMLPARSER_ERROR if unable to parse the input. If htmlparser_parse()
+ * is called after an error situation was encountered the behaviour is
+ * unspecified. At this point, htmlparser_reset() or htmlparser_reset_mode()
+ * can be called to reset the state.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_parse(htmlparser_ctx *ctx, const char *str, int size);
+
+/* Returns true if the parser is inside an attribute value and the value is
+ * surrounded by single or double quotes. */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_is_attr_quoted(htmlparser_ctx *ctx);
+
+/* Returns true if the parser is currently in javascript. This can be a
+ * an attribute that takes javascript, a javascript block or the parser
+ * can just be in MODE_JS. */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_in_js(htmlparser_ctx *ctx);
+
+/* Returns the current tag or NULL if not available or we haven't seen the
+ * entire tag yet.
+ *
+ * There is no stack implemented because we currently don't have a need for
+ * it, which means tag names are tracked only one level deep.
+ *
+ * This is better understood by looking at the following example:
+ *
+ * <b [tag=b]>
+ * [tag=b]
+ * <i>
+ * [tag=i]
+ * </i>
+ * [tag=NULL]
+ * </b>
+ *
+ * The tag is correctly filled inside the tag itself and before any new inner
+ * tag is closed, at which point the tag will be null.
+ *
+ * For our current purposes this is not a problem, but we may implement a tag
+ * tracking stack in the future for completeness.
+ *
+ */
+extern CTEMPLATE_DLL_DECL
+const char *htmlparser_tag(htmlparser_ctx *ctx);
+
+/* Returns the current attribute name if after an attribute name or in an
+ * attribute value. Returns NULL otherwise. */
+extern CTEMPLATE_DLL_DECL
+const char *htmlparser_attr(htmlparser_ctx *ctx);
+
+/* Returns the contents of the current attribute value.
+ *
+ * Returns NULL if not inside an attribute value.
+ */
+extern CTEMPLATE_DLL_DECL
+const char *htmlparser_value(htmlparser_ctx *ctx);
+
+/* Returns true if the parser is currently inside a CSS construct.
+ *
+ * Currently this can be either a STYLE tag, a STYLE attribute or the fact that
+ * the parser was reset in HTMLPARSER_MODE_CSS using
+ * htmlparser_reset_mode().
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_in_css(htmlparser_ctx *ctx);
+
+/* Returns the current state of the javascript state machine.
+ *
+ * Currently only present for testing purposes.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_js_state(htmlparser_ctx *ctx);
+
+/* Returns non-zero if currently inside a javascript string literal and zero
+ * otherwise.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_is_js_quoted(htmlparser_ctx *ctx);
+
+/* Returns non-zero if currently inside an attribute value and zero otherwise.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_value_index(htmlparser_ctx *ctx);
+
+/* Returns true if this is the first character of a url inside an attribute.
+ *
+ * This function can be used by an html sanitizer or auto escaping system as a
+ * hint that it should validate the url for a whitelist of protocol handlers and
+ * for well-formedness, or that it should just escape a component of it.
+ *
+ * For attributes that expect a URL, this will return true if we are at the
+ * first character of the URL, false otherwise.
+ * For most attributes, this is the same as checking that we are at the first
+ * character of the attribute value but it also works correctly for the
+ * "content" attribute of the "meta" tag where the URL follows some earlier
+ * content.
+ * e.g: <meta http-equiv="refresh" * content="5; URL=http://bla.">
+ *
+ * For any other attributes, the result will always be false.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_is_url_start(htmlparser_ctx *ctx);
+
+/* Returns the current attribute type.
+ *
+ * The attribute type can be one of:
+ * HTMLPARSER_ATTR_NONE - not inside an attribute.
+ * HTMLPARSER_ATTR_REGULAR - Inside a normal attribute.
+ * HTMLPARSER_ATTR_URI - Inside an attribute that accepts a uri.
+ * HTMLPARSER_ATTR_JS - Inside a javascript attribute.
+ * HTMLPARSER_ATTR_STYLE - Inside a css style attribute.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_attr_type(htmlparser_ctx *ctx);
+
+/* Return the current line number. */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_get_line_number(htmlparser_ctx *ctx);
+
+/* Set the current line number. */
+extern CTEMPLATE_DLL_DECL
+void htmlparser_set_line_number(htmlparser_ctx *ctx, int line);
+
+/* Return the current column number. */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_get_column_number(htmlparser_ctx *ctx);
+
+/* Set the current column number. */
+extern CTEMPLATE_DLL_DECL
+void htmlparser_set_column_number(htmlparser_ctx *ctx, int column);
+
+/* Retrieve a human readable error message in case an error occurred.
+ *
+ * NULL is returned if the parser didn't encounter an error.
+ */
+extern CTEMPLATE_DLL_DECL
+const char *htmlparser_get_error_msg(htmlparser_ctx *ctx);
+
+/* Invoked by the caller when text is expanded by the caller.
+ *
+ * Should be invoked when a template directive that expands to content is
+ * executed but we don't provide this content to the parser itself. This changes
+ * the current state by following the default rule, ensuring we stay in sync
+ * with the template.
+ *
+ * Returns 1 if template directives are accepted for this state and 0 if they
+ * are not, which should result in an error condition.
+ *
+ * Right now the only case being handled are unquoted attribute values and it
+ * always returns 1. When insert_text() is called after the equals sign, we
+ * assume some text was consumed and we are now in the middle of the attribute
+ * value itself. Example:
+ *
+ * <a href=$HREF_VALUE alt=alternate_text>
+ *
+ * The template calls insert_text() when it encounters $HREF_VALUE. If it didn't
+ * the parser would only have seen the following html:
+ *
+ * <a href= alt=alternate_text>
+ *
+ * and would interpret alt=alternate_text as the value of the href attribute.
+ */
+extern CTEMPLATE_DLL_DECL
+int htmlparser_insert_text(htmlparser_ctx *ctx);
+
+/* Deallocates an htmlparser context object.
+ */
+extern CTEMPLATE_DLL_DECL
+void htmlparser_delete(htmlparser_ctx *ctx);
+
+#define htmlparser_parse_chr(a,b) htmlparser_parse(a, &(b), 1);
+#ifdef __cplusplus
+#define htmlparser_parse_str(a,b) htmlparser_parse(a, b, \
+ static_cast<int>(strlen(b)));
+#else
+#define htmlparser_parse_str(a,b) htmlparser_parse(a, b, (int)strlen(b));
+#endif
+
+#ifdef __cplusplus
+} /* namespace security_streamhtmlparser */
+#endif
+
+#endif /* SECURITY_STREAMHTMLPARSER_HTMLPARSER_H */
diff --git a/src/htmlparser/htmlparser_cpp.h b/src/htmlparser/htmlparser_cpp.h
new file mode 100644
index 0000000..0557783
--- /dev/null
+++ b/src/htmlparser/htmlparser_cpp.h
@@ -0,0 +1,318 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+// ---
+// Author: falmeida@google.com (Filipe Almeida)
+//
+// c++ bindings for htmlparser.
+
+#ifndef SECURITY_STREAMHTMLPARSER_HTMLPARSER_CPP_H__
+#define SECURITY_STREAMHTMLPARSER_HTMLPARSER_CPP_H__
+
+#include <config.h>
+#include <string>
+#include "htmlparser/htmlparser.h"
+#include "htmlparser/jsparser.h"
+#include "base/util.h"
+
+namespace ctemplate_htmlparser {
+
+class JavascriptParser {
+ public:
+ enum State {
+ STATE_TEXT = JSPARSER_STATE_TEXT,
+ STATE_Q = JSPARSER_STATE_Q,
+ STATE_DQ = JSPARSER_STATE_DQ,
+ STATE_REGEXP = JSPARSER_STATE_REGEXP,
+ STATE_COMMENT = JSPARSER_STATE_COMMENT,
+ };
+};
+
+class HtmlParser {
+ public:
+
+ /* html states */
+ enum State {
+ STATE_TEXT = HTMLPARSER_STATE_TEXT,
+ STATE_TAG = HTMLPARSER_STATE_TAG,
+ STATE_ATTR = HTMLPARSER_STATE_ATTR,
+ STATE_VALUE = HTMLPARSER_STATE_VALUE,
+ STATE_COMMENT = HTMLPARSER_STATE_COMMENT,
+ STATE_JS_FILE = HTMLPARSER_STATE_JS_FILE,
+ STATE_CSS_FILE = HTMLPARSER_STATE_CSS_FILE,
+ STATE_ERROR = HTMLPARSER_STATE_ERROR
+ };
+
+ /* attribute types */
+ enum AttributeType {
+ ATTR_NONE = HTMLPARSER_ATTR_NONE,
+ ATTR_REGULAR = HTMLPARSER_ATTR_REGULAR,
+ ATTR_URI = HTMLPARSER_ATTR_URI,
+ ATTR_JS = HTMLPARSER_ATTR_JS,
+ ATTR_STYLE = HTMLPARSER_ATTR_STYLE
+ };
+
+ /* Parser modes */
+ enum Mode {
+ MODE_HTML = HTMLPARSER_MODE_HTML,
+ MODE_JS = HTMLPARSER_MODE_JS,
+ MODE_CSS = HTMLPARSER_MODE_CSS,
+ MODE_HTML_IN_TAG = HTMLPARSER_MODE_HTML_IN_TAG
+ };
+
+ HtmlParser() {
+ parser_ = htmlparser_new();
+ CHECK(parser_ != NULL);
+ };
+
+ /* Parses the input html stream and returns the finishing state.
+ *
+ * Returns HtmlParser::STATE_ERROR if unable to parse the input. If
+ * htmlparser_parse() is called after an error situation was encountered
+ * the behaviour is unspecified. At this point, Reset() or ResetMode()
+ * can be called to reset the state so it can be used to parse a new file.
+ */
+ int Parse(const char *str, int len) {
+ return htmlparser_parse(parser_, str, len);
+ };
+
+ int Parse(const std::string &str) {
+ return Parse(str.c_str(), static_cast<int>(str.length()));
+ };
+
+ /* Returns the current state the parser is in */
+ int state() const {
+ return htmlparser_state(parser_);
+ };
+
+ /* Returns the current tag or NULL if not available.
+ *
+ * There is no stack implemented because we currently don't have a need for
+ * it, which means tag names are tracked only one level deep.
+ *
+ * This is better understood by looking at the following example:
+ *
+ * <b [tag=b]>
+ * [tag=b]
+ * <i>
+ * [tag=i]
+ * </i>
+ * [tag=NULL]
+ * </b>
+ *
+ * The tag is correctly filled inside the tag itself and before any new
+ * inner tag is closed, at which point the tag will be set to NULL.
+ *
+ * For our current purposes this is not a problem, but we may implement a
+ * tag tracking stack in the future for completeness.
+ */
+ const char *tag() const {
+ return htmlparser_tag(parser_);
+ }
+
+ /* Returns the current attribute name if inside an attribute name or an
+ * attribute value. Returns NULL otherwise. */
+ const char *attribute() const {
+ return htmlparser_attr(parser_);
+ }
+
+ /* Returns the contents of the current attribute value. */
+ const char *value() const {
+ return htmlparser_value(parser_);
+ }
+
+ /* Returns true if inside javascript. This can be a javascript block, a
+ * javascript attribute value or the parser may just be in javascript mode
+ * (HtmlParser::MODE_JS) */
+ bool InJavascript() const {
+ return static_cast<bool>(htmlparser_in_js(parser_));
+ }
+
+ /* Returns true if the parser is currently inside a CSS construct.
+ *
+ * Currently this can be either a STYLE tag, a STYLE attribute or the fact
+ * that the parser was reset using MODE_CSS using ResetMode().
+ */
+ bool InCss() const {
+ return static_cast<bool>(htmlparser_in_css(parser_));
+ }
+
+ /* Returns true if the current attribute is quoted */
+ bool IsAttributeQuoted() const {
+ return static_cast<bool>(htmlparser_is_attr_quoted(parser_));
+ }
+
+ /* Returns true if the parser is inside a js string literal.
+ */
+ bool IsJavascriptQuoted() const {
+ return static_cast<bool>(htmlparser_is_js_quoted(parser_));
+ }
+
+ /* Returns the index within the current value or -1 if the parser is not
+ * inside an attribute value */
+ int ValueIndex() const {
+ return htmlparser_value_index(parser_);
+ }
+
+ /* Returns true if this is the first character of a url inside an attribute.
+ *
+ * This function can be used by an html sanitizer or auto escaping system as
+ * a hint that it should validate the url for a whitelist of protocol
+ * handlers and for well-formedness, or that it should just escape a
+ * component of it.
+ *
+ * For attributes that expect a url this will return true if we are at the
+ * first character of the attribute, but for the special case of a meta
+ * redirect tag some analysis is made in order to verify if we are at the
+ * start of a url or not.
+ *
+ * For any other attributes, the result will always be false.
+ *
+ */
+ bool IsUrlStart() const {
+ return htmlparser_is_url_start(parser_);
+ }
+
+ /* Returns the current attribute type.
+ *
+ * The attribute type can be one of:
+ * ATTR_NONE - not inside an attribute
+ * ATTR_REGULAR - Inside a normal attribute
+ * ATTR_URI - Inside an attribute that accepts a uri
+ * ATTR_JS - Inside a javascript attribute
+ * ATTR_STYLE - Inside a css style attribute
+ * */
+ int AttributeType() const {
+ return htmlparser_attr_type(parser_);
+ }
+
+ /* Return the current line number. */
+ int line_number() const {
+ return htmlparser_get_line_number(parser_);
+ }
+
+ /* Set the current line number. */
+ void set_line_number(int line) {
+ return htmlparser_set_line_number(parser_, line);
+ }
+
+ /* Return the current column number. */
+ int column_number() const {
+ return htmlparser_get_column_number(parser_);
+ }
+
+ /* Set the current line number. */
+ void set_column_number(int column) {
+ return htmlparser_set_column_number(parser_, column);
+ }
+
+ /* Retrieve a human readable error message in case an error occurred.
+ *
+ * NULL is returned if the parser didn't encounter an error.
+ */
+ const char *GetErrorMessage() {
+ return htmlparser_get_error_msg(parser_);
+ }
+
+ /* Returns the current state the javascript parser is in.
+ *
+ * Should only be used for testing.
+ */
+ int javascript_state() const {
+ return htmlparser_js_state(parser_);
+ };
+
+ /* Resets the parser to it's initial state and changes the parser mode.
+ *
+ * Internal state (tag name, attribute name, state of statemachine) is
+ * reset as * though the object was just created.
+ *
+ * Available modes:
+ * MODE_HTML - Parses html text
+ * MODE_JS - Parses javascript files
+ * MODE_CSS - Parses CSS files. No actual parsing is actually done
+ * but InCss() always returns true.
+ * MODE_HTML_IN_TAG - Parses an attribute list inside a tag. To
+ * be used in a template expanded in the
+ * following context: <a $template>
+ */
+ void ResetMode(enum Mode mode) {
+ return htmlparser_reset_mode(parser_, mode);
+ }
+
+ /* Resets the parser to it's initial state and to the default mode, which is
+ * MODE_HTML.
+ *
+ * All internal context like tag name, attribute name or the state of the
+ * statemachine are reset to it's original values as if the object was just
+ * created.
+ */
+ void Reset() {
+ return htmlparser_reset(parser_);
+ }
+
+ /* Invoked when text is inserted by the caller.
+ *
+ * Should be called before a template directive that expands to content is
+ * found. This changes the current state by following the default rule,
+ * ensuring we stay in sync with template.
+ *
+ * Returns true if template directives are accepted for this state and
+ * false if they are not, which should result in an error condition.
+ *
+ * Right now the only case being handled are unquoted attribute values and
+ * it always returns true. In the future we can handle more cases and
+ * restrict the states were we allow template directives by returning false
+ * for those.
+ */
+ bool InsertText() {
+ return static_cast<bool>(htmlparser_insert_text(parser_));
+ }
+
+ /* Copies the context of the HtmlParser object referenced in source to the
+ * current object.
+ */
+ void CopyFrom(const HtmlParser *source) {
+ CHECK(this != source);
+ CHECK(source != NULL);
+ htmlparser_copy(parser_, source->parser_);
+ }
+
+ ~HtmlParser() {
+ htmlparser_delete(parser_);
+ };
+
+
+ private:
+ htmlparser_ctx *parser_;
+ DISALLOW_COPY_AND_ASSIGN(HtmlParser);
+};
+
+} // namespace security_streamhtmlparser
+
+#endif // SECURITY_STREAMHTMLPARSER_HTMLPARSER_CPP_H__
diff --git a/src/htmlparser/htmlparser_fsm.config b/src/htmlparser/htmlparser_fsm.config
new file mode 100644
index 0000000..8ca4b7b
--- /dev/null
+++ b/src/htmlparser/htmlparser_fsm.config
@@ -0,0 +1,365 @@
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+# ---
+#
+# Author: falmeida@google.com (Filipe Almeida)
+
+# TODO(falmeida): Add more descriptive names to the states and drop the
+# abbreviations.
+# TODO(falmeida): Reorder the states so that it's easier to read.
+# TODO(falmeida): Support CDATA blocks in the form: <![CDATA[.
+
+name = 'htmlparser'
+
+comment = 'Definition of a finite state machine for a subset of HTTP 4.1'
+
+condition('<', '<')
+condition('>', '>')
+condition('=', '=')
+
+# TODO(falmeida): This is not the correct expression. tag and attribute names
+# can only consist of alpha character.
+condition('id', 'A-Za-z0-9_:.-')
+condition('idtag', 'A-Za-z0-9/_:.-')
+
+# Whitespace according to: http://www.w3.org/TR/html401/struct/text.html#h-9.1
+condition('space', ' \t\n\r')
+condition('!', '!')
+condition('q', '\'')
+condition('dq', '\"')
+condition('/', '/')
+condition('*', '*')
+condition('-', '-')
+condition('?', '?')
+condition('lf', '\n')
+condition('quote', '\\')
+
+# TODO(falmeida): This default rule is a hack and shouldn't be here.
+condition('default', '[:default:]')
+
+state(name = 'text',
+ external = 'text',
+ transitions = [
+ ['<', 'tag_start'],
+ ['default', 'text']
+ ])
+
+# When we found the < character in text.
+# Tag opening is defined in the HTML5 draft here:
+# http://www.whatwg.org/specs/web-apps/current-work/#tag-open-state
+# We don't exactly follow this and are much more loose in order to mimic the way
+# the major browsers behave.
+state(name = 'tag_start',
+ external = 'tag',
+ transitions = [
+ ['idtag', 'tag_name'],
+ ['?', 'pi'],
+ ['!', 'declaration_start'],
+ ['<', 'tag_start'],
+ ['default', 'text']
+ ])
+
+# Name of the tag. Includes the closing tag character '/'.
+state(name = 'tag_name',
+ external = 'tag',
+ transitions = [
+ ['idtag', 'tag_name'],
+ ['space', 'tag_space'],
+ ['>', 'tag_close']
+ ])
+
+# HTML declaration and comment parsing
+#
+# We don't expose declaration state because at this point we only want to
+# ensure that we are parsing them correctly so we don't get out of sync.
+# This is specifically made for DOCTYPE declarations and won't work if DTD's
+# are defined inside the declaration.
+# The HTML5 spec says we should specificly look for the string '<!DOCTYPE HTML'
+# but that will add a lot of unecessary states, and unless we build a simple
+# declarative way to unfold a string match into multiple states, I don't
+# think it's worth worrying about for now.
+
+# Got '<!'. The next character will decide if we open a declaration or a
+# comment.
+state(name = 'declaration_start',
+ external = 'text',
+ transitions = [
+ ['-', 'comment_open'],
+ ['>', 'text'],
+ ['default', 'declaration_body']
+ ])
+
+# Inside a declaration. Ie: <!DOCTYPE. We close when we see a '>'
+state(name = 'declaration_body',
+ external = 'text',
+ transitions = [
+ ['>', 'text'],
+ ['default', 'declaration_body']
+ ])
+
+# Got '<!-'.
+state(name = 'comment_open',
+ external = 'text',
+ transitions = [
+ ['-', 'comment_body'],
+ ['default', 'text']
+ ])
+
+# Inside a comment. We only close when we see '-->'
+state(name = 'comment_body',
+ external = 'comment',
+ transitions = [
+ ['-', 'comment_dash'],
+ ['default', 'comment_body']
+ ])
+
+# Got '-' inside a comment.
+state(name = 'comment_dash',
+ external = 'comment',
+ transitions = [
+ ['-', 'comment_dash_dash'],
+ ['default', 'comment_body']
+ ])
+
+# Got '--' inside a comment.
+state(name = 'comment_dash_dash',
+ external = 'comment',
+ transitions = [
+ ['-', 'comment_dash_dash'],
+ ['>', 'text'],
+ ['default', 'comment_body']
+ ])
+
+# XML Processing instruction parsing according to:
+# http://www.w3.org/TR/REC-xml/#sec-pi
+#
+# Everything between the characters <? and ?> is considered to be part of the
+# processing instruction.
+state(name = 'pi',
+ external = 'text',
+ transitions = [
+ ['?', 'pi_may_end'],
+ ['default', 'pi']
+ ])
+
+state(name = 'pi_may_end',
+ external = 'text',
+ transitions = [
+ ['>', 'text'],
+ ['default', 'pi']
+ ])
+
+# Whitespace between tag name, attributes.
+state(name = 'tag_space',
+ external = 'tag',
+ transitions = [
+ ['>', 'tag_close'],
+ ['space', 'tag_space'],
+ ['id', 'attr'],
+ ['/', 'tag_space']
+ ])
+
+state(name = 'tag_close',
+ external = 'text',
+ transitions = [
+ ['<', 'tag_start'],
+ ['default', 'text']
+ ])
+
+# Name of the attribute.
+state(name = 'attr',
+ external = 'attr',
+ transitions = [
+ ['id', 'attr'],
+ ['>', 'tag_close'],
+ ['/', 'tag_space'],
+ ['=', 'value'],
+ ['space', 'attr_space']
+ ])
+
+# After the attribute name.
+state(name = 'attr_space',
+ external = 'attr',
+ transitions = [
+ ['>', 'tag_close'],
+ ['space', 'attr_space'],
+ ['id', 'attr'],
+ ['/', 'tag_space'],
+ ['=', 'value']
+ ])
+
+# Expecting a value, after attribute=
+state(name = 'value',
+ external = 'value',
+ transitions = [
+ ['q', 'value_q_start'],
+ ['dq', 'value_dq_start'],
+ ['space', 'value'],
+ ['>', 'tag_close'],
+ ['default', 'value_text']
+ ])
+
+# Unquoted attribute value.
+state(name = 'value_text',
+ external = 'value',
+ transitions = [
+ ['>', 'tag_close'],
+ ['space', 'tag_space'],
+ ['default', 'value_text']
+ ])
+
+# First character of a single quoted attribute value.
+state(name = 'value_q_start',
+ external = 'value',
+ transitions = [
+ ['q', 'tag_space'],
+ ['default', 'value_q']
+ ])
+
+# In the middle of a single quoted attribute value.
+state(name = 'value_q',
+ external = 'value',
+ transitions = [
+ ['q', 'tag_space'],
+ ['default', 'value_q']
+ ])
+
+# First character of a double quoted attribute value.
+state(name = 'value_dq_start',
+ external = 'value',
+ transitions = [
+ ['dq', 'tag_space'],
+ ['default', 'value_dq']
+ ])
+
+# In the middle of a double quoted attribute value.
+state(name = 'value_dq',
+ external = 'value',
+ transitions = [
+ ['dq', 'tag_space'],
+ ['default', 'value_dq']
+ ])
+
+# CDATA escaping text spans.
+# TODO(falmeida): These states should go after cdata_text.
+
+# Got '<!'
+state(name = 'cdata_comment_start',
+ external = 'text',
+ transitions = [
+ ['-', 'cdata_comment_start_dash'],
+ ['default', 'cdata_text'],
+ ])
+
+# Got '<!-'.
+state(name = 'cdata_comment_start_dash',
+ external = 'text',
+ transitions = [
+ ['-', 'cdata_comment_body'],
+ ['default', 'cdata_text']
+ ])
+
+# Inside a comment
+state(name = 'cdata_comment_body',
+ external = 'text',
+ transitions = [
+ ['-', 'cdata_comment_dash'],
+ ['default', 'cdata_comment_body']
+ ])
+
+# Got '-' inside a comment.
+state(name = 'cdata_comment_dash',
+ external = 'text',
+ transitions = [
+ ['-', 'cdata_comment_dash_dash'],
+ ['default', 'cdata_comment_body']
+ ])
+
+# Got '--' inside a comment.
+state(name = 'cdata_comment_dash_dash',
+ external = 'text',
+ transitions = [
+ ['-', 'cdata_comment_dash_dash'],
+ ['>', 'cdata_text'],
+ ['default', 'cdata_comment_body']
+ ])
+
+# CDATA processing
+#
+# To simplify the code, we treat RCDATA and CDATA sections the same since the
+# differences between them don't affect the context we are in.
+state(name = 'cdata_text',
+ external = 'text',
+ transitions = [
+ ['<', 'cdata_lt'],
+ ['default', 'cdata_text']
+ ])
+
+# Possible beginning of the closing tag.
+state(name = 'cdata_lt',
+ external = 'text',
+ transitions = [
+ ['/', 'cdata_may_close'],
+ ['!', 'cdata_comment_start'],
+ ['default', 'cdata_text']
+ ])
+
+# If we encounter </tag where tag matches the last opened tag, we exit the
+# CDATA section. Part of this logic is handled in the code.
+state(name = 'cdata_may_close',
+ external = 'text',
+ transitions = [
+ ['idtag', 'cdata_may_close'],
+ ['>', 'text'],
+ ['space', 'tag_space'],
+ ['default', 'cdata_text']
+ ])
+
+# The next states are used for specialized parser modes.
+state(name = 'js_file',
+ external = 'js_file',
+ transitions = [
+ ['default', 'js_file']
+ ])
+
+# TODO(falmeida): Having css_file and js_file as the external name doesn't make
+# sense. This should instead be text and the js/css state be
+# returned by # in_js() and in_css().
+state(name = 'css_file',
+ external = 'css_file',
+ transitions = [
+ ['default', 'css_file']
+ ])
+
+state(name = 'null',
+ external = 'text',
+ transitions = [
+ ['default', 'null']
+ ])
+
diff --git a/src/htmlparser/jsparser.cc b/src/htmlparser/jsparser.cc
new file mode 100644
index 0000000..15be35d
--- /dev/null
+++ b/src/htmlparser/jsparser.cc
@@ -0,0 +1,659 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ * ---
+ *
+ * Author: falmeida@google.com (Filipe Almeida)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "htmlparser/statemachine.h"
+#include "htmlparser/jsparser.h"
+
+/* So we can support both C and C++ compilers, we use the CAST() macro instead
+ * of using C style casts or static_cast<>() directly.
+ */
+#ifdef __cplusplus
+ #define CAST(type, expression) (static_cast<type>(expression))
+#else
+ #define CAST(type, expression) ((type)(expression))
+#endif
+
+#ifdef __cplusplus
+namespace ctemplate_htmlparser {
+#endif /* __cplusplus */
+
+/* Generated state machine definition. */
+#include "htmlparser/jsparser_fsm.h"
+
+/* List of keywords that can precede a regular expression literal. Taken from:
+ * http://www.mozilla.org/js/language/js20-2000-07/rationale/syntax.html
+ *
+ * 'void' was added to this list.
+ * The list is used as input to a binary search, so it must be kept in a sorted
+ * form.
+ * There are a large number of keywords in here that don't exist in
+ * ecmascript 3, either because they are reserved or because they are part of
+ * ecmascript 4. However they weren't removed in order to keep the list in sync
+ * with the previous document.
+ */
+static const char *regexp_token_prefix[] = {
+ "abstract",
+ "break",
+ "case",
+ "catch",
+ "class",
+ "const",
+ "continue",
+ "debugger",
+ "default",
+ "delete",
+ "do",
+ "else",
+ "enum",
+ "eval",
+ "export",
+ "extends",
+ "field",
+ "final",
+ "finally",
+ "for",
+ "function",
+ "goto",
+ "if",
+ "implements",
+ "import",
+ "in",
+ "instanceof",
+ "native",
+ "new",
+ "package",
+ "private",
+ "protected",
+ "public",
+ "return",
+ "static",
+ "switch",
+ "synchronized",
+ "throw",
+ "throws",
+ "transient",
+ "try",
+ "typeof",
+ "var",
+ "void",
+ "volatile",
+ "while",
+ "with"
+};
+
+/* Utility functions */
+
+/* Converts the internal state into the external superstate.
+ */
+static inline int state_external(int state)
+{
+ assert(state < JSPARSER_NUM_STATES);
+ assert(state >= 0);
+ return jsparser_states_external[state];
+}
+
+/* Returns true if the character is an ecmascript whitespace or line terminator
+ * character. Includes the characters in sections 7.2 and 7.3 of ECMAScript 3
+ * with the exception of unicode space and line terminators:
+ * http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
+ */
+static inline int js_is_whitespace(char c)
+{
+ return c == '\t' || /* Tab 0x09 */
+ c == '\v' || /* Vertical Tab 0x0B */
+ c == '\f' || /* Form Feed 0x0C */
+ c == ' ' || /* Space 0x20 */
+ c == '\xa0' || /* No-Break Space 0xA0 */
+ c == '\n' || /* line Feed 0x0A */
+ c == '\r'; /* Carriage Return 0x0D */
+}
+
+/* Returns true if the character is part of a javascript identifier. The rules
+ * are pretty relaxed here since we don't accept unicode and don't care if the
+ * first character doesn't contain numbers or not.
+ *
+ * For more detail on the limitations of having this relaxed set of characters
+ * please see the comments in_state_js_text().
+ */
+static inline int js_is_identifier(char c) {
+ return (c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9') ||
+ c == '_' ||
+ c == '$';
+}
+
+/* Appends a character to the ring buffer. Sequences of whitespace and newlines
+ * are folded into one.
+ *
+ * js->buffer_start points to the first character in the buffer and
+ * js->buffer_end points to the position of the next character to be written,
+ * or one plus the last character written. If the buffer is full there will be
+ * an empty slot position so we can diferentiate an empty buffer from a full
+ * buffer.
+ *
+ * If the buffer is empty, then:
+ * js->buffer_start == js->buffer_end.
+ * If the buffer is full, then:
+ * (js->buffer_end + 1) % JSPARSER_RING_BUFFER_SIZE == js->buffer_start.
+ *
+ */
+void jsparser_buffer_append_chr(jsparser_ctx *js, char chr)
+{
+ /* Fold whitespace so we have enough space in the buffer. */
+ if (js_is_whitespace(chr) &&
+ js_is_whitespace(jsparser_buffer_get(js, -1))) {
+ return;
+ }
+
+ js->buffer[js->buffer_end] = chr;
+ js->buffer_end = (js->buffer_end + 1) % JSPARSER_RING_BUFFER_SIZE;
+ if (js->buffer_end == js->buffer_start) {
+ js->buffer_start = (js->buffer_end + 1) %
+ JSPARSER_RING_BUFFER_SIZE;
+ }
+}
+
+/* Appends a string to the ring buffer. Sequences of whitespace and newlines
+ * are folded into one.
+ */
+void jsparser_buffer_append_str(jsparser_ctx *js, const char *str)
+{
+ assert(js != NULL);
+ assert(str != NULL);
+
+ while(*str != '\0') {
+ jsparser_buffer_append_chr(js, *str++);
+ }
+}
+
+/* Returns the position relative to the start of the buffer or -1 if past the
+ * size of the buffer..
+ */
+static inline int jsparser_buffer_absolute_pos(jsparser_ctx *js, int pos)
+{
+ int absolute_pos;
+ int buffer_len;
+ assert(pos < 0);
+
+ if(pos <= -JSPARSER_RING_BUFFER_SIZE) {
+ return -1;
+ }
+
+ buffer_len = js->buffer_end - js->buffer_start;
+ if (buffer_len < 0) {
+ buffer_len += JSPARSER_RING_BUFFER_SIZE;
+ }
+
+ if (pos < -buffer_len) {
+ return -1;
+ }
+
+ absolute_pos = (pos + js->buffer_end) % JSPARSER_RING_BUFFER_SIZE;
+ if (absolute_pos < 0) {
+ absolute_pos += JSPARSER_RING_BUFFER_SIZE;
+ }
+
+ return absolute_pos;
+}
+
+/* Returns the last appended character and removes it from the buffer. If the
+ * buffer is empty, then it returns ASCII 0 ('\0').
+ */
+char jsparser_buffer_pop(jsparser_ctx *js)
+{
+ if (js->buffer_start == js->buffer_end) {
+ return '\0';
+ }
+
+ js->buffer_end--;
+ if (js->buffer_end < 0) {
+ js->buffer_end += JSPARSER_RING_BUFFER_SIZE;
+ }
+
+ return js->buffer[js->buffer_end];
+}
+
+/* Returns the value of the character at a certain index in the buffer or an
+ * ASCII 0 ('\0') character if the index is outside the buffer boundaries.
+ *
+ * Index positions are negative, were -1 is the last character appended to the
+ * buffer. Using positive integers for the index will result in undefined
+ * behaviour.
+ */
+char jsparser_buffer_get(jsparser_ctx *js, int pos)
+{
+ int absolute_pos;
+ assert(pos < 0);
+
+ absolute_pos = jsparser_buffer_absolute_pos(js, pos);
+ if (absolute_pos < 0) {
+ return '\0';
+ }
+
+ return js->buffer[absolute_pos];
+}
+
+/* Sets the value of the character at a certain index in the buffer. Returns
+ * true if the write was successful or false if there was an attempt to write
+ * outside of the buffer boundaries.
+ *
+ * Index positions are negative, were -1 is the last character appended to the
+ * buffer. Using positive integers for the index will result in undefined
+ * behaviour.
+ */
+int jsparser_buffer_set(jsparser_ctx *js, int pos, char value)
+{
+ int absolute_pos;
+ assert(pos < 0);
+
+ absolute_pos = jsparser_buffer_absolute_pos(js, pos);
+ if (absolute_pos < 0) {
+ return 0;
+ }
+
+ js->buffer[absolute_pos] = value;
+ return 1;
+}
+
+/* Copies a slice of the buffer to the string pointed to by output. start and
+ * end are the indexes of the sliced region. If start extends beyond the
+ * beginning of the buffer, the slice will only contain character from the
+ * beginning of the buffer.
+ */
+void jsparser_buffer_slice(jsparser_ctx *js, char *output, int start, int end)
+{
+ int pos;
+
+ assert(start <= end);
+ assert(start < 0);
+ assert(end < 0);
+
+ for (pos = start; pos <= end; ++pos) {
+ char c;
+ c = jsparser_buffer_get(js, pos);
+ if (c != '\0') {
+ *output++ = jsparser_buffer_get(js, pos);
+ }
+ }
+ *output++ = '\0';
+}
+
+/* Copy the last javascript identifier or keyword found in the buffer to the
+ * string pointed by identifier.
+ *
+ * For simplicity, we consider an identifier to be a sequence of alphanumeric
+ * characters (as opposed to a digit followed by an alphanumeric character.
+ *
+ * Returns 0 if no identifier was matched, in which case the identifier
+ * argument is replaced with an empty string, or non 0 if the identifier was
+ * found.
+ */
+int jsparser_buffer_last_identifier(jsparser_ctx *js, char *identifier)
+{
+ int end;
+ int pos;
+
+ assert(identifier != NULL);
+
+ end = -1;
+ /* Ignore the optional whitespace delimiter */
+ if (js_is_whitespace(jsparser_buffer_get(js, -1))) {
+ --end;
+ }
+
+ /* Find the beginning of the identifier. This loop ends either when we find a
+ * character that doesn't belong to an identifier, or when we find a '\0'
+ * character, which means we reached the end of the buffer. */
+ for(pos = end; js_is_identifier(jsparser_buffer_get(js, pos)); --pos) {
+ }
+ if (pos + 1 >= end) {
+ identifier[0] = '\0';
+ return 0;
+ }
+
+ jsparser_buffer_slice(js, identifier, pos + 1, end);
+ return 1;
+}
+
+/* Callback used in bsearch() for comparing a string against an array of
+ * strings.
+ */
+static int bsearch_strcmp(const void *a, const void *b)
+{
+ return strcmp(CAST(const char*, a), *CAST(const char * const *, b));
+}
+
+/* Returns true if the token argument can be a token prefix to a javascript
+ * regular expression.
+ *
+ * The token argument is compared against a list of identifiers that can
+ * precede a regular expression in the javascript grammar, and returns true if
+ * the argument is found on that list.
+ */
+static inline int is_regexp_token_prefix(char *token)
+{
+ assert(token != NULL);
+
+ return bsearch(token,
+ regexp_token_prefix,
+ sizeof(regexp_token_prefix) / sizeof(char *),
+ sizeof(char *), bsearch_strcmp) != NULL;
+}
+
+/* Called for every character in state text.
+ *
+ * We copy every character we find when we are in state text to the ring
+ * buffer. This has the side effect of also pushing slash characters that are
+ * part of comments into the buffer, although for parsing purposes these should
+ * be treated as whitespace. This issue is addressed in
+ * enter_state_js_comment_ml_after().
+ */
+static void in_state_js_text(statemachine_ctx *ctx, int start, char chr,
+ int end)
+{
+ jsparser_ctx *js = CAST(jsparser_ctx *, ctx->user);
+ assert(js != NULL);
+
+ jsparser_buffer_append_chr(js, chr);
+}
+
+/* This function is called every time we find a slash ('/') character in the
+ * javascript text (except for slashes that close comments or regexp literals).
+ *
+ * Implements the logic to figure out if this slash character is a division
+ * operator or if it opens a regular expression literal. This is heavily
+ * inspired by the syntactic resynchronization for javascript 2.0:
+ * http://www.mozilla.org/js/language/js20-2000-07/rationale/syntax.html
+ *
+ * When we receive a '/', we look at the previous non space character to figure
+ * out if it's the ending of a punctuator that can precede a regexp literal, in
+ * which case we assume the current '/' is part of a regular expression literal
+ * (or the opening of a javascript comment, but that part is dealt with in the
+ * state machine). The exceptions to this are unary operators, so we look back
+ * a second character to rule out '++' and '--'. Although it is not
+ * straightforward to figure out if the binary operator is a postfix of the
+ * previous expression or a prefix of the regular expression, we rule out the
+ * later as it is an uncommon practice.
+ *
+ * If we ruled out the previous token to be a valid regexp preceding
+ * punctuator, we extract the last identifier in the buffer and match against a
+ * list of keywords that are known to precede expressions in the grammar. If we
+ * get a match on any of these keywords, then we are opening a regular
+ * expression, if not, then we have a division operator.
+ *
+ * Known cases that are accepted by the grammar but we handle differently,
+ * although I don't believe there is a legitimate usage for those:
+ *
+ * Division of a regular expression:
+ * var result = /test/ / 5;
+ *
+ * Prefix unary increment of a regular expression:
+ * var result = ++/test/;
+ *
+ * Division of an object literal:
+ * { a: 1 } /x/.exec('x');
+ *
+ * We only support ascii right now, so unicode characters in identifiers will
+ * be treated as delimiters, effectively breaking the identifier name where
+ * they appear, and this may cause issues in very specific situations. Namely,
+ * if we have a unicode character in an identifier directly preceding a suffix
+ * that matches one of the keywords in regexp_token_prefix[], if this
+ * identifier precedes a / (slash) character:
+ *
+ * var x = test<unicode char>return / 5;
+ *
+ * We will interpret that slash as the start of a regular expression, when in
+ * reality it is a division operator.
+ */
+static void enter_state_js_slash(statemachine_ctx *ctx, int start, char chr,
+ int end)
+{
+ jsparser_ctx *js;
+ char buffer[JSPARSER_RING_BUFFER_SIZE];
+ int pos;
+
+ assert(ctx != NULL);
+ assert(ctx->user != NULL);
+
+ js = CAST(jsparser_ctx *, ctx->user);
+ assert(js != NULL);
+
+ pos = -1;
+ /* Consume the last whitespace. */
+ if (js_is_whitespace(jsparser_buffer_get(js, pos))) {
+ --pos;
+ }
+
+ switch (jsparser_buffer_get(js, pos)) {
+ /* Ignore unary increment */
+ case '+':
+ if (jsparser_buffer_get(js, pos - 1) != '+') {
+ ctx->next_state = JSPARSER_STATE_INT_JS_REGEXP_SLASH;
+ }
+ break;
+
+ /* Ignore unary decrement */
+ case '-':
+ if (jsparser_buffer_get(js, pos - 1) != '-') {
+ ctx->next_state = JSPARSER_STATE_INT_JS_REGEXP_SLASH;
+ }
+ break;
+
+ /* List of punctuator endings except ), ], }, + and - */
+ case '=':
+ case '<':
+ case '>':
+ case '&':
+ case '|':
+ case '!':
+ case '%':
+ case '*':
+ case '/':
+ case ',':
+ case ';':
+ case '?':
+ case ':':
+ case '^':
+ case '~':
+ case '{':
+ case '(':
+ case '[':
+ case '}':
+ case '\0':
+ ctx->next_state = JSPARSER_STATE_INT_JS_REGEXP_SLASH;
+ break;
+
+ default:
+ if (jsparser_buffer_last_identifier(js, buffer) &&
+ is_regexp_token_prefix(buffer)) {
+ ctx->next_state = JSPARSER_STATE_INT_JS_REGEXP_SLASH;
+ }
+ }
+
+ jsparser_buffer_append_chr(js, chr);
+}
+
+/* Called at the end of a javascript comment.
+ *
+ * When we open a comment, the initial '/' was inserted into the ring buffer,
+ * but it is not a token and should be considered whitespace for parsing
+ * purposes.
+ *
+ * When we first saw the '/' character, we didn't yet know if it was the
+ * beginning of a comment, a division operator, or a regexp.
+ *
+ * In this function we just replace the inital '/' with a whitespace character,
+ * unless we had a preceding whitespace character, in which case we just remove
+ * the '/'. This is needed to ensure all spaces in the buffer are correctly
+ * folded.
+ */
+static void enter_state_js_comment_after(statemachine_ctx *ctx, int start,
+ char chr, int end)
+{
+ jsparser_ctx *js;
+
+ assert(ctx != NULL);
+ assert(ctx->user != NULL);
+
+ js = CAST(jsparser_ctx *, ctx->user);
+
+ if (js_is_whitespace(jsparser_buffer_get(js, -2))) {
+ (void)jsparser_buffer_pop(js);
+ } else {
+ jsparser_buffer_set(js, -1, ' ');
+ }
+}
+
+static statemachine_definition *create_statemachine_definition()
+{
+ statemachine_definition *def;
+ def = statemachine_definition_new(JSPARSER_NUM_STATES);
+ if (def == NULL)
+ return NULL;
+
+ /* TODO(falmeida): Check return value. */
+ statemachine_definition_populate(def, jsparser_state_transitions,
+ jsparser_states_internal_names);
+
+ statemachine_in_state(def, JSPARSER_STATE_INT_JS_TEXT,
+ in_state_js_text);
+ statemachine_enter_state(def, JSPARSER_STATE_INT_JS_SLASH,
+ enter_state_js_slash);
+ statemachine_enter_state(def, JSPARSER_STATE_INT_JS_COMMENT_AFTER,
+ enter_state_js_comment_after);
+
+ return def;
+}
+
+
+/* Initializes a new jsparser instance.
+ *
+ * Returns a pointer to the new instance or NULL if the initialization
+ * fails.
+ *
+ * Initialization failure is fatal, and if this function fails it may not
+ * deallocate all previsouly allocated memory.
+ */
+
+jsparser_ctx *jsparser_new()
+{
+ jsparser_ctx *js;
+
+ js = CAST(jsparser_ctx *, calloc(1, sizeof(jsparser_ctx)));
+ if (js == NULL)
+ return NULL;
+
+ js->statemachine_def = create_statemachine_definition();
+ if (js->statemachine_def == NULL)
+ return NULL;
+
+ js->statemachine = statemachine_new(js->statemachine_def, js);
+ if (js->statemachine == NULL)
+ return NULL;
+
+ jsparser_reset(js);
+
+ return js;
+}
+
+/* Returns a pointer to a context which is a duplicate of the jsparser src.
+ */
+jsparser_ctx *jsparser_duplicate(jsparser_ctx *src)
+{
+ jsparser_ctx *dst;
+ assert(src != NULL);
+
+ dst = jsparser_new();
+ if (dst == NULL)
+ return NULL;
+
+ jsparser_copy(dst, src);
+
+ return dst;
+}
+
+/* Copies the context of the jsparser pointed to by src to the jsparser dst.
+ *
+ * The state machine definition is preserved since it is read only.
+ */
+void jsparser_copy(jsparser_ctx *dst, jsparser_ctx *src)
+{
+
+ dst->buffer_start = src->buffer_start;
+ dst->buffer_end = src->buffer_end;
+ memcpy(dst->buffer, src->buffer, sizeof(src->buffer));
+
+ statemachine_copy(dst->statemachine,
+ src->statemachine,
+ dst->statemachine_def,
+ dst);
+
+}
+
+void jsparser_reset(jsparser_ctx *ctx)
+{
+ assert(ctx != NULL);
+ ctx->statemachine->current_state = 0;
+ ctx->buffer_start = 0;
+ ctx->buffer_end = 0;
+}
+
+int jsparser_state(jsparser_ctx *ctx)
+{
+ return state_external(ctx->statemachine->current_state);
+}
+
+int jsparser_parse(jsparser_ctx *ctx, const char *str, int size)
+{
+ int internal_state;
+ internal_state = statemachine_parse(ctx->statemachine, str, size);
+ return state_external(internal_state);
+}
+
+void jsparser_delete(jsparser_ctx *ctx)
+{
+ assert(ctx != NULL);
+ statemachine_delete(ctx->statemachine);
+ statemachine_definition_delete(ctx->statemachine_def);
+ free(ctx);
+}
+
+#ifdef __cplusplus
+} /* namespace security_streamhtmlparser */
+#endif /* __cplusplus */
diff --git a/src/htmlparser/jsparser.h b/src/htmlparser/jsparser.h
new file mode 100644
index 0000000..6987cb4
--- /dev/null
+++ b/src/htmlparser/jsparser.h
@@ -0,0 +1,172 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ * ---
+ *
+ * Author: falmeida@google.com (Filipe Almeida)
+ */
+
+#ifndef SECURITY_STREAMHTMLPARSER_JSPARSER_H
+#define SECURITY_STREAMHTMLPARSER_JSPARSER_H
+
+#include <config.h>
+#include "htmlparser/statemachine.h"
+
+#ifdef __cplusplus
+namespace ctemplate_htmlparser {
+#endif /* __cplusplus */
+
+/* Size of the ring buffer used to lookup the last token in the javascript
+ * stream. The size is pretty much arbitrary at this point but must be bigger
+ * than the biggest token we want to lookup plus 3: Two delimiters plus an empty
+ * ring buffer slot. */
+#define JSPARSER_RING_BUFFER_SIZE 18
+
+enum js_state_external_enum {
+ JSPARSER_STATE_TEXT,
+ JSPARSER_STATE_Q,
+ JSPARSER_STATE_DQ,
+ JSPARSER_STATE_REGEXP,
+ JSPARSER_STATE_COMMENT
+};
+
+/* Stores the context of the javascript parser.
+ *
+ * If this structure is changed, jsparser_new(), jsparser_copy() and
+ * jsparser_reset() should be updated accordingly.
+ */
+typedef struct jsparser_ctx_s {
+
+ /* Reference to the statemachine context. */
+ statemachine_ctx *statemachine;
+
+ /* Reference to the statemachine definition.
+ *
+ * It should be readonly and contain the same values across jsparser
+ * instances.
+ */
+ /* TODO(falmeida): Change statemachine_def to const. */
+ statemachine_definition *statemachine_def;
+
+ /* Index to the start of the buffer. */
+ int buffer_start;
+
+ /* Index the current writing position (end of the buffer plus one). */
+ int buffer_end;
+
+ /* Ring buffer used to lookup the last token. */
+ char buffer[JSPARSER_RING_BUFFER_SIZE];
+
+} jsparser_ctx;
+
+
+void jsparser_reset(jsparser_ctx *ctx);
+jsparser_ctx *jsparser_new(void);
+
+/* Returns a pointer to a context which is a duplicate of the jsparser src.
+ */
+jsparser_ctx *jsparser_duplicate(jsparser_ctx *src);
+
+/* Copies the context of the jsparser pointed to by src to the jsparser dst.
+ */
+void jsparser_copy(jsparser_ctx *dst, jsparser_ctx *src);
+int jsparser_state(jsparser_ctx *ctx);
+int jsparser_parse(jsparser_ctx *ctx, const char *str, int size);
+
+void jsparser_delete(jsparser_ctx *ctx);
+
+/**
+ * Ring buffer functions.
+ *
+ * These functions are only exported for testing and should not be called from
+ * outside of jsparser.c in production code.
+ */
+
+/* Appends a character to the ring buffer.
+ *
+ * Sequences of whitespaces and newlines are folded into one character.
+ */
+void jsparser_buffer_append_chr(jsparser_ctx *js, char chr);
+
+/* Appends a string to the ring buffer.
+ *
+ * Sequences of whitespaces and newlines are folded into one character.
+ */
+void jsparser_buffer_append_str(jsparser_ctx *js, const char *str);
+
+/* Returns the last appended character and removes it from the buffer. If the
+ * buffer is empty, then it returns ASCII 0 ('\0').
+ */
+char jsparser_buffer_pop(jsparser_ctx *js);
+
+/* Returns the value of the character at a certain index in the buffer or an
+ * ASCII 0 ('\0') character if the index is extends beyond the size of the
+ * buffer, either because we don't have as many characters in the buffer, or
+ * because the index points to a place bigger than the size of the buffer..
+ *
+ * Index positions must be negative, where -1 is the last character appended to
+ * the buffer.
+ */
+char jsparser_buffer_get(jsparser_ctx *js, int pos);
+
+/* Sets the value of the character at a certain index in the buffer. Returns
+ * true if the write was successful or false if there was an attempt to write
+ * outside of the buffer boundaries.
+ *
+ * Index positions are negative, were -1 is the last character appended to the
+ * buffer. Using positive integers for the index will result in undefined
+ * behaviour.
+ */
+int jsparser_buffer_set(jsparser_ctx *js, int pos, char value);
+
+/* Copies a slice of the buffer to the string pointed to by output. start and
+ * end are the indexes of the sliced region. If the start argument extends
+ * beyond the beginning of the buffer, the slice will only contain characters
+ * starting from beginning of the buffer.
+ */
+void jsparser_buffer_slice(jsparser_ctx *js, char *buffer, int start, int end);
+
+/* Copy the last javascript identifier or keyword found in the buffer to the
+ * string pointed by identifier.
+ */
+int jsparser_buffer_last_identifier(jsparser_ctx *js, char *identifier);
+
+
+#define jsparser_parse_chr(a,b) jsparser_parse(a, &(b), 1);
+#ifdef __cplusplus
+#define jsparser_parse_str(a,b) jsparser_parse(a, b, \
+ static_cast<int>(strlen(b)));
+#else
+#define jsparser_parse_str(a,b) jsparser_parse(a, b, (int)strlen(b));
+#endif
+
+#ifdef __cplusplus
+} /* namespace security_streamhtmlparser */
+#endif /* __cplusplus */
+
+#endif /* SECURITY_STREAMHTMLPARSER_JSPARSER_H */
diff --git a/src/htmlparser/jsparser_fsm.config b/src/htmlparser/jsparser_fsm.config
new file mode 100644
index 0000000..874b735
--- /dev/null
+++ b/src/htmlparser/jsparser_fsm.config
@@ -0,0 +1,186 @@
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+# ---
+#
+# Author: falmeida@google.com (Filipe Almeida)
+
+name = 'jsparser'
+
+comment = 'Simplified finite state machine for tracking of javascript states'
+
+condition('q', '\''),
+condition('dq', '\"'),
+condition('/', '/'),
+condition('*', '*'),
+condition('[', '['),
+condition(']', ']'),
+condition('lf', '\n'),
+condition('backslash', '\\'),
+condition('default', '[:default:]')
+
+# Main javascript body.
+state(name = 'js_text',
+ external = 'text',
+ transitions = [
+ ['q', 'js_q'],
+ ['dq', 'js_dq'],
+ ['/', 'js_slash'],
+ ['default', 'js_text']
+ ])
+
+# Single quoted string literal.
+state(name = 'js_q',
+ external = 'q',
+ transitions = [
+ ['backslash', 'js_q_e'],
+ ['q', 'js_text'],
+ ['default', 'js_q']
+ ])
+
+# Javascript escaped character in a single quoted string literal.
+state(name = 'js_q_e',
+ external = 'q',
+ transitions = [
+ ['default', 'js_q']
+ ])
+
+# Double quoted string literal
+state(name = 'js_dq',
+ external = 'dq',
+ transitions = [
+ ['backslash', 'js_dq_e'],
+ ['dq', 'js_text'],
+ ['default', 'js_dq']
+ ])
+
+# Javascript escaped character in a double quoted string literal.
+state(name = 'js_dq_e',
+ external = 'dq',
+ transitions = [
+ ['default', 'js_dq']
+ ])
+
+# Possible start of a javascript comment.
+state(name = 'js_slash',
+ external = 'text',
+ transitions = [
+ ['/', 'js_comment_ln'],
+ ['*', 'js_comment_ml'],
+ ['default', 'js_text']
+ ])
+
+# Possible start of a regular expression literal.
+#
+# The state diagram does not reach this state directly. When js_slash is
+# reached, the function enter_state_js_slash() is called, which checks if the
+# last token belongs to the set of tokens that can precede a regular
+# expression, in which case it changes the state to js_regexp_slash.
+#
+# For more information please read the comments in
+# jsparser.c:enter_state_js_slash().
+state(name = 'js_regexp_slash',
+ external = 'text',
+ transitions = [
+ ['/', 'js_comment_ln'],
+ ['*', 'js_comment_ml'],
+ ['backslash', 'js_regexp_e'],
+ ['[', 'js_regexp_bracket'],
+ ['default', 'js_regexp']
+ ])
+
+# Regular expression literal.
+state(name = 'js_regexp',
+ external = 'regexp',
+ transitions = [
+ ['backslash', 'js_regexp_e'],
+ ['[', 'js_regexp_bracket'],
+ ['/', 'js_text'],
+ ['default', 'js_regexp']
+ ])
+
+# Regexp bracket expression
+state(name = 'js_regexp_bracket',
+ external = 'regexp',
+ transitions = [
+ ['backslash', 'js_regexp_bracket_e'],
+ [']', 'js_regexp'],
+ ['default', 'js_regexp_bracket']
+ ])
+
+# Backslash escaped regexp bracket expression
+state(name = 'js_regexp_bracket_e',
+ external = 'regexp',
+ transitions = [
+ ['default', 'js_regexp_bracket']
+ ])
+
+# Escaped regular expression char.
+state(name = 'js_regexp_e',
+ external = 'regexp',
+ transitions = [
+ ['default', 'js_regexp']
+ ])
+
+# Start of a single line javascript comment (//).
+state(name = 'js_comment_ln',
+ external = 'comment',
+ transitions = [
+ ['lf', 'js_comment_after'],
+ ['default', 'js_comment_ln']
+ ])
+
+# Start of a multiline javascript comment (/*).
+state(name = 'js_comment_ml',
+ external = 'comment',
+ transitions = [
+ ['*', 'js_comment_ml_close'],
+ ['default', 'js_comment_ml']
+ ])
+
+# Close of a multiline javascript comment (*/).
+state(name = 'js_comment_ml_close',
+ external = 'comment',
+ transitions = [
+ ['/', 'js_comment_after'],
+ ['default', 'js_comment_ml']
+ ])
+
+# Ending character of a javascript comment.
+# In can either be a '/ in the case of a multiline comment, or a line
+# terminator in the case of a single line comment.
+# This is needed so we don't insert the '/' or the new line character into the
+# ring buffer.
+state(name = 'js_comment_after',
+ external = 'text',
+ transitions = [
+ ['q', 'js_q'],
+ ['dq', 'js_dq'],
+ ['/', 'js_slash'],
+ ['default', 'js_text']
+ ])
diff --git a/src/htmlparser/statemachine.cc b/src/htmlparser/statemachine.cc
new file mode 100644
index 0000000..00fbe26
--- /dev/null
+++ b/src/htmlparser/statemachine.cc
@@ -0,0 +1,457 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ * ---
+ *
+ * Author: falmeida@google.com (Filipe Almeida)
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "htmlparser/statemachine.h"
+
+/* So we can support both C and C++ compilers, we use the CAST() macro instead
+ * of using C style casts or static_cast<>() directly.
+ */
+#ifdef __cplusplus
+ #define CAST(type, expression) (static_cast<type>(expression))
+#else
+ #define CAST(type, expression) ((type)(expression))
+#endif
+
+#ifdef __cplusplus
+namespace ctemplate_htmlparser {
+#endif
+
+#define MAX_CHAR_8BIT 256
+
+/* Populates the statemachine definition.
+ */
+void statemachine_definition_populate(statemachine_definition *def,
+ const int* const* transition_table,
+ const char* const* state_names)
+{
+ assert(def != NULL);
+ assert(transition_table != NULL);
+
+ def->transition_table = transition_table;
+
+ def->state_names = state_names;
+}
+
+/* Add's the callback for the event in_state that is called when the
+ * statemachine is in state st.
+ *
+ * This event is called everytime the the statemachine is in the specified
+ * state forevery character in the input stream even if the state remains
+ * the same.
+ *
+ * This is event is the last event to be called and is fired after both events
+ * exit_state and enter_state.
+ */
+void statemachine_in_state(statemachine_definition *def, int st,
+ state_event_function func)
+{
+ assert(def != NULL);
+ assert(st < def->num_states);
+ def->in_state_events[st] = func;
+}
+
+/* Add's the callback for the event enter_state that is called when the
+ * statemachine enters state st.
+ *
+ * This event is fired after the event exit_state but before the event
+ * in_state.
+ */
+void statemachine_enter_state(statemachine_definition *def, int st,
+ state_event_function func)
+{
+ assert(def != NULL);
+ assert(st < def->num_states);
+ def->enter_state_events[st] = func;
+}
+
+/* Add's the callback for the event exit_state that is called when the
+ * statemachine exits from state st.
+ *
+ * This is the first event to be called and is fired before both the events
+ * enter_state and in_state.
+ */
+void statemachine_exit_state(statemachine_definition *def, int st,
+ state_event_function func)
+{
+ assert(def != NULL);
+ assert(st < def->num_states);
+ def->exit_state_events[st] = func;
+}
+
+/* Initializes a new statemachine definition with a defined number of states.
+ *
+ * Returns NULL if initialization fails.
+ *
+ * Initialization failure is fatal, and if this function fails it may not
+ * deallocate all previsouly allocated memory.
+ */
+statemachine_definition *statemachine_definition_new(int states)
+{
+ statemachine_definition *def;
+ def = CAST(statemachine_definition *,
+ malloc(sizeof(statemachine_definition)));
+ if (def == NULL)
+ return NULL;
+
+ def->in_state_events = CAST(state_event_function *,
+ calloc(states, sizeof(state_event_function)));
+ if (def->in_state_events == NULL)
+ return NULL;
+
+ def->enter_state_events =CAST(state_event_function *,
+ calloc(states,
+ sizeof(state_event_function)));
+ if (def->enter_state_events == NULL)
+ return NULL;
+
+ def->exit_state_events = CAST(state_event_function *,
+ calloc(states, sizeof(state_event_function)));
+ if (def->exit_state_events == NULL)
+ return NULL;
+
+ def->num_states = states;
+ def->state_names = NULL;
+ return def;
+}
+
+/* Deallocates a statemachine definition object
+ */
+void statemachine_definition_delete(statemachine_definition *def)
+{
+ assert(def != NULL);
+ free(def->in_state_events);
+ free(def->enter_state_events);
+ free(def->exit_state_events);
+ free(def);
+}
+
+/* Returns the current state.
+ */
+int statemachine_get_state(statemachine_ctx *ctx) {
+ return ctx->current_state;
+}
+
+/* Sets the current state.
+ *
+ * It calls the exit event for the old state and the enter event for the state
+ * we intend to move into.
+ *
+ * Since this state change was not initiated by a character in the input stream
+ * we pass a null char to the event functions.
+ */
+void statemachine_set_state(statemachine_ctx *ctx, int state)
+{
+
+ statemachine_definition *def;
+
+ assert(ctx != NULL);
+ assert(ctx->definition != NULL);
+
+ def = ctx->definition;
+
+ assert(state < def->num_states);
+
+ ctx->next_state = state;
+
+ if (ctx->current_state != ctx->next_state) {
+ if (def->exit_state_events[ctx->current_state])
+ def->exit_state_events[ctx->current_state](ctx,
+ ctx->current_state,
+ '\0',
+ ctx->next_state);
+
+ if (def->enter_state_events[ctx->next_state])
+ def->enter_state_events[ctx->next_state](ctx,
+ ctx->current_state,
+ '\0',
+ ctx->next_state);
+ }
+
+ ctx->current_state = state;
+}
+
+/* Reset the statemachine.
+ *
+ * The state is set to the initialization values. This includes setting the
+ * state to the default state (0), stopping recording and setting the line
+ * number to 1.
+ */
+void statemachine_reset(statemachine_ctx *ctx)
+{
+ ctx->current_state = 0;
+ ctx->next_state = 0;
+ ctx->record_buffer[0] = '\0';
+ ctx->record_pos = 0;
+ ctx->recording = 0;
+ ctx->line_number = 1;
+ ctx->column_number = 1;
+}
+
+/* Initializes a new statemachine. Receives a statemachine definition object
+ * that should have been initialized with statemachine_definition_new() and a
+ * user reference to be used by the caller.
+ *
+ * The user reference is used by the caller to store any instance specific data
+ * the caller may need and is typically used to propagate context information
+ * to the event callbacks. The user pointer can just be set to NULL if the
+ * caller doesn't need it.
+ *
+ * Returns NULL if initialization fails.
+ *
+ * Initialization failure is fatal, and if this function fails it may not
+ * deallocate all previously allocated memory.
+ */
+statemachine_ctx *statemachine_new(statemachine_definition *def,
+ void *user)
+{
+ statemachine_ctx *ctx;
+ assert(def != NULL);
+ ctx = CAST(statemachine_ctx *, malloc(sizeof(statemachine_ctx)));
+ if (ctx == NULL)
+ return NULL;
+
+ statemachine_reset(ctx);
+
+ ctx->definition = def;
+ ctx->user = user;
+
+ return ctx;
+}
+
+/* Returns a pointer to a context which is a duplicate of the statemachine src.
+ * The statemachine definition and the user pointer have to be provided since
+ * these references are not owned by the statemachine itself, but this will be
+ * shallow copies as they point to data structures we do not own.
+ */
+statemachine_ctx *statemachine_duplicate(statemachine_ctx *src,
+ statemachine_definition *def,
+ void *user)
+{
+ statemachine_ctx *dst;
+ assert(src != NULL);
+ dst = statemachine_new(def, user);
+ if (dst == NULL)
+ return NULL;
+
+ statemachine_copy(dst, src, def, user);
+
+ return dst;
+}
+
+/* Copies the context of the statemachine pointed to by src to the statemachine
+ * provided by dst.
+ * The statemachine definition and the user pointer have to be provided since
+ * these references are not owned by the statemachine itself.
+ */
+void statemachine_copy(statemachine_ctx *dst,
+ statemachine_ctx *src,
+ statemachine_definition *def,
+ void *user)
+{
+ memcpy(dst, src, sizeof(statemachine_ctx));
+ dst->definition = def;
+ dst->user = user;
+}
+
+/* Deallocates a statemachine object
+ */
+void statemachine_delete(statemachine_ctx *ctx)
+{
+ assert(ctx != NULL);
+ free(ctx);
+}
+
+/* Starts recording the current input stream into an internal buffer.
+ * The current input character is included in the recording.
+ */
+void statemachine_start_record(statemachine_ctx *ctx)
+{
+ assert(ctx != NULL);
+ ctx->record_buffer[0] = '\0';
+ ctx->record_pos = 0;
+ ctx->recording = 1;
+}
+
+/* Stops recording the current input stream.
+ * The last input character is not included in the recording.
+ * This function returns a pointer to the recorded string buffer.
+ */
+const char *statemachine_stop_record(statemachine_ctx *ctx)
+{
+ assert(ctx != NULL);
+ assert(ctx->recording);
+ ctx->record_buffer[ctx->record_pos] = '\0';
+ ctx->recording = 0;
+ return ctx->record_buffer;
+}
+
+ /* Returns a pointer to the record string buffer.
+ */
+const char *statemachine_record_buffer(statemachine_ctx *ctx)
+{
+ return ctx->record_buffer;
+}
+
+void statemachine_encode_char(char schr, char *output, size_t len)
+{
+ unsigned char chr = schr;
+ if (chr == '\'') {
+ strncpy(output, "\\'", len);
+ } else if (chr == '\\') {
+ strncpy(output, "\\\\", len);
+
+ /* Like isprint() but not dependent on locale. */
+ } else if (chr >= 32 && chr <= 126) {
+ snprintf(output, len, "%c", chr);
+ } else if (chr == '\n') {
+ strncpy(output, "\\n", len);
+ } else if (chr == '\r') {
+ strncpy(output, "\\r", len);
+ } else if (chr == '\t') {
+ strncpy(output, "\\t", len);
+ } else {
+ snprintf(output, len, "\\x%.2x", chr);
+ }
+
+ output[len - 1] = '\0';
+}
+
+/* Sets the error message in case of a transition error.
+ *
+ * Called from statemachine_parse to set the error message in case of a
+ * transition error.
+ */
+static void statemachine_set_transition_error_message(statemachine_ctx *ctx)
+{
+ char encoded_char[10];
+ statemachine_encode_char(ctx->current_char, encoded_char,
+ sizeof(encoded_char));
+
+ if (ctx->definition->state_names) {
+ snprintf(ctx->error_msg, STATEMACHINE_MAX_STR_ERROR,
+ "Unexpected character '%s' in state '%s'",
+ encoded_char,
+ ctx->definition->state_names[ctx->current_state]);
+ } else {
+ snprintf(ctx->error_msg, STATEMACHINE_MAX_STR_ERROR,
+ "Unexpected character '%s'", encoded_char);
+ }
+
+}
+
+/* Parses the input html stream and returns the finishing state.
+ *
+ * Returns STATEMACHINE_ERROR if unable to parse the input. If
+ * statemachine_parse() is called after an error situation was encountered
+ * the behaviour is unspecified.
+ */
+/* TODO(falmeida): change int size to size_t size */
+int statemachine_parse(statemachine_ctx *ctx, const char *str, int size)
+{
+ int i;
+ const int* const* state_table = ctx->definition->transition_table;
+ statemachine_definition *def;
+
+ assert(ctx !=NULL &&
+ ctx->definition != NULL &&
+ ctx->definition->transition_table != NULL);
+
+ if (size < 0) {
+ snprintf(ctx->error_msg, STATEMACHINE_MAX_STR_ERROR, "%s",
+ "Negative size in statemachine_parse().");
+ return STATEMACHINE_ERROR;
+ }
+
+ def = ctx->definition;
+
+ for (i = 0; i < size; i++) {
+ ctx->current_char = *str;
+ ctx->next_state =
+ state_table[ctx->current_state][CAST(unsigned char, *str)];
+ if (ctx->next_state == STATEMACHINE_ERROR) {
+ statemachine_set_transition_error_message(ctx);
+ return STATEMACHINE_ERROR;
+ }
+
+ if (ctx->current_state != ctx->next_state) {
+ if (def->exit_state_events[ctx->current_state])
+ def->exit_state_events[ctx->current_state](ctx,
+ ctx->current_state,
+ *str,
+ ctx->next_state);
+ }
+ if (ctx->current_state != ctx->next_state) {
+ if (def->enter_state_events[ctx->next_state])
+ def->enter_state_events[ctx->next_state](ctx,
+ ctx->current_state,
+ *str,
+ ctx->next_state);
+ }
+
+ if (def->in_state_events[ctx->next_state])
+ def->in_state_events[ctx->next_state](ctx,
+ ctx->current_state,
+ *str,
+ ctx->next_state);
+
+ /* We need two bytes left so we can NULL terminate the string. */
+ if (ctx->recording &&
+ STATEMACHINE_RECORD_BUFFER_SIZE - 1 > ctx->record_pos) {
+ ctx->record_buffer[ctx->record_pos++] = *str;
+ ctx->record_buffer[ctx->record_pos] = '\0';
+ }
+
+/* TODO(falmeida): Should clarify the contract here, since an event can change
+ * ctx->next_state and we need this functionality */
+
+ ctx->current_state = ctx->next_state;
+ ctx->column_number++;
+
+ if (*str == '\n') {
+ ctx->line_number++;
+ ctx->column_number = 1;
+ }
+ str++;
+ }
+
+ return ctx->current_state;
+}
+
+#ifdef __cplusplus
+} /* namespace security_streamhtmlparser */
+#endif
diff --git a/src/htmlparser/statemachine.h b/src/htmlparser/statemachine.h
new file mode 100644
index 0000000..2784604
--- /dev/null
+++ b/src/htmlparser/statemachine.h
@@ -0,0 +1,234 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ * ---
+ *
+ * Author: falmeida@google.com (Filipe Almeida)
+ */
+
+#ifndef SECURITY_STREAMHTMLPARSER_STATEMACHINE_H
+#define SECURITY_STREAMHTMLPARSER_STATEMACHINE_H
+
+#include <config.h>
+#ifdef __cplusplus
+namespace ctemplate_htmlparser {
+#endif
+
+/* TODO(falmeida): I'm not sure about these limits, but since right now we only
+ * have 24 states it should be fine */
+
+enum {
+ STATEMACHINE_ERROR = 127
+};
+
+#define STATEMACHINE_RECORD_BUFFER_SIZE 256
+
+#define STATEMACHINE_MAX_STR_ERROR 80
+
+struct statemachine_ctx_s;
+
+typedef void(*state_event_function)(struct statemachine_ctx_s *, int, char,
+ int);
+
+typedef struct statemachine_definition_s {
+ int num_states;
+ const int* const* transition_table;
+
+ /* Array containing the name of the states as a C string.
+ * This field is optional and if not in use it should be set to NULL.
+ */
+ const char* const* state_names;
+ state_event_function *in_state_events;
+ state_event_function *enter_state_events;
+ state_event_function *exit_state_events;
+} statemachine_definition;
+
+typedef struct statemachine_ctx_s {
+ int current_state;
+ int next_state;
+ statemachine_definition *definition;
+ char current_char;
+
+ /* Current line number. */
+ int line_number;
+
+ /* Current column number. */
+ int column_number;
+ char record_buffer[STATEMACHINE_RECORD_BUFFER_SIZE];
+ size_t record_pos;
+
+ /* True if we are recording the stream to record_buffer. */
+ int recording;
+
+ /* In case there was an error (we are in state STATEMACHINE_ERROR), it will
+ * contain a human readable description of the error.
+ */
+ char error_msg[STATEMACHINE_MAX_STR_ERROR];
+
+ /* Storage space for the layer above. */
+ void *user;
+} statemachine_ctx;
+
+/* Populates the statemachine definition.
+ *
+ * Receives a transition table and an optional array of state names. It uses
+ * this data to populate the state machine definition.
+ *
+ * The transition table structure is a list of lists of ints (int **). The
+ * outer list indexes the source state and the inner list contains the
+ * destination state for each of the possible input characters:
+ *
+ * const int* const* transitions[source][input] == destination.
+ *
+ * The optional argument state_names points to a list of strings containing
+ * human readable state names. These strings are used when reporting error
+ * messages.
+ */
+void statemachine_definition_populate(statemachine_definition *def,
+ const int* const* transition_table,
+ const char* const* state_names);
+
+void statemachine_in_state(statemachine_definition *def, int st,
+ state_event_function func);
+void statemachine_enter_state(statemachine_definition *def, int st,
+ state_event_function func);
+void statemachine_exit_state(statemachine_definition *def, int st,
+ state_event_function func);
+
+statemachine_definition *statemachine_definition_new(int states);
+void statemachine_definition_delete(statemachine_definition *def);
+
+int statemachine_get_state(statemachine_ctx *ctx);
+void statemachine_set_state(statemachine_ctx *ctx, int state);
+
+void statemachine_start_record(statemachine_ctx *ctx);
+const char *statemachine_stop_record(statemachine_ctx *ctx);
+const char *statemachine_record_buffer(statemachine_ctx *ctx);
+
+/* Returns the the number of characters currently stored in the record buffer.
+ */
+static inline size_t statemachine_record_length(statemachine_ctx *ctx) {
+ return ctx->record_pos + 1;
+}
+
+/* Return the current line number. */
+static inline int statemachine_get_line_number(statemachine_ctx *ctx) {
+ return ctx->line_number;
+}
+
+/* Set the current line number. */
+static inline void statemachine_set_line_number(statemachine_ctx *ctx,
+ int line) {
+ ctx->line_number = line;
+}
+
+/* Return the current column number. */
+static inline int statemachine_get_column_number(statemachine_ctx *ctx) {
+ return ctx->column_number;
+}
+
+/* Set the current column number. */
+static inline void statemachine_set_column_number(statemachine_ctx *ctx,
+ int column) {
+ ctx->column_number = column;
+}
+
+
+/* Retrieve a human readable error message in case an error occurred.
+ *
+ * NULL is returned if the parser didn't encounter an error.
+ */
+static inline const char *statemachine_get_error_msg(statemachine_ctx *ctx) {
+ if (ctx->next_state == STATEMACHINE_ERROR) {
+ return ctx->error_msg;
+ } else {
+ return NULL;
+ }
+}
+
+/* Reset the statemachine.
+ *
+ * The state is set to the initialization values. This includes setting the
+ * state to the default state (0), stopping recording and setting the line
+ * number to 1.
+ */
+void statemachine_reset(statemachine_ctx *ctx);
+
+/* Initializes a new statemachine. Receives a statemachine definition object
+ * that should have been initialized with statemachine_definition_new() and a
+ * user reference to be used by the caller.
+ *
+ * Returns NULL if initialization fails.
+ *
+ * Initialization failure is fatal, and if this function fails it may not
+ * deallocate all previsouly allocated memory.
+ */
+statemachine_ctx *statemachine_new(statemachine_definition *def,
+ void *user);
+
+/* Returns a pointer to a context which is a duplicate of the statemachine src.
+ * The statemachine definition and the user pointer have to be provided since
+ * these references are not owned by the statemachine itself.
+ */
+statemachine_ctx *statemachine_duplicate(statemachine_ctx *ctx,
+ statemachine_definition *def,
+ void *user);
+
+/* Copies the context of the statemachine pointed to by src to the statemachine
+ * provided by dst.
+ * The statemachine definition and the user pointer have to be provided since
+ * these references are not owned by the statemachine itself.
+ */
+void statemachine_copy(statemachine_ctx *dst,
+ statemachine_ctx *src,
+ statemachine_definition *def,
+ void *user);
+
+int statemachine_parse(statemachine_ctx *ctx, const char *str, int size);
+
+void statemachine_delete(statemachine_ctx *ctx);
+
+
+/*****
+ * The following functions are only exported for testing purposes and should
+ * be treated as private. */
+
+
+/* Encode the character as an escaped C string.
+ *
+ * Encode the character chr into the string output. Writes at most len
+ * characters to the output string but makes sure output is NULL terminated.
+ */
+void statemachine_encode_char(char chr, char *output, size_t len);
+
+
+#ifdef __cplusplus
+} /* namespace security_streamhtmlparser */
+#endif
+
+#endif /* SECURITY_STREAMHTMLPARSER_STATEMACHINE_H */
diff --git a/src/indented_writer.h b/src/indented_writer.h
new file mode 100644
index 0000000..6df190e
--- /dev/null
+++ b/src/indented_writer.h
@@ -0,0 +1,134 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: williasr@google.com (Scott Williams)
+
+#ifndef TEMPLATE_INDENTED_WRITER_H_
+#define TEMPLATE_INDENTED_WRITER_H_
+
+#include <config.h>
+#include <string>
+
+namespace ctemplate {
+
+using std::string;
+
+// An indented writer is a wrapper around a string buffer. It takes care of
+// tracking and applying leading whitespace to the buffer at the beginning of
+// new lines.
+class IndentedWriter {
+ public:
+ IndentedWriter(string* out, int starting_indentation)
+ : out_(out), current_indentation_(starting_indentation),
+ original_indentation_(starting_indentation), line_state_(AT_BEGINNING) { }
+
+ ~IndentedWriter() {
+ assert(original_indentation_ == current_indentation_);
+ }
+
+ // Append some output to the buffer. If the string ends with a newline, then
+ // the output buffer will be indented before the next Write() call. If the
+ // output contains embedded newlines, these won't have proper indentation, so
+ // call Write() at least once per physical line of output.
+ void Write(string s1,
+ string s2 = string(),
+ string s3 = string(),
+ string s4 = string(),
+ string s5 = string(),
+ string s6 = string(),
+ string s7 = string()) {
+ DoWrite(s1);
+ if (!s2.empty()) DoWrite(s2);
+ if (!s3.empty()) DoWrite(s3);
+ if (!s4.empty()) DoWrite(s4);
+ if (!s5.empty()) DoWrite(s5);
+ if (!s6.empty()) DoWrite(s6);
+ if (!s7.empty()) DoWrite(s7);
+ }
+
+ // Increment the indentation level. This only has a meaning after outputting a
+ // complete line (otherwise, are you saying you want to modify the indentation
+ // of the current line or the next line?)
+ void Indent() {
+ assert(line_state_ == AT_BEGINNING);
+ current_indentation_ += kIndent;
+ }
+
+ // Decrement the indentation level. This only has a meaning after outputting a
+ // complete line (otherwise, are you saying you want to modify the indentation
+ // of the current line or the next line?)
+ void Dedent() {
+ assert(line_state_ == AT_BEGINNING);
+ current_indentation_ -= kIndent;
+ assert(current_indentation_ >= original_indentation_);
+ }
+
+ // Get access to the underlying indentation level and string buffer. Most
+ // useful for interfacing with non-IndentedWriter printing code.
+ int GetIndent() const { return current_indentation_; }
+ string* GetBuffer() { return out_; }
+
+ private:
+ void DoWrite(const string& line) {
+ if (line_state_ == AT_BEGINNING) {
+ IndentLine();
+ }
+ out_->append(line);
+ if (EndsWithNewline(line)) {
+ line_state_ = AT_BEGINNING;
+ } else {
+ line_state_ = MID_LINE;
+ }
+ }
+
+ static bool EndsWithNewline(const string& line) {
+ return !line.empty() && (*(line.end() - 1) == '\n');
+ }
+
+ void IndentLine() {
+ assert(line_state_ == AT_BEGINNING);
+ out_->append(string(current_indentation_, ' ') +
+ (current_indentation_ ? " " : ""));
+ }
+
+ string* out_;
+ int current_indentation_;
+ int original_indentation_;
+ enum LineState {
+ AT_BEGINNING,
+ MID_LINE
+ } line_state_;
+
+ const static int kIndent = 2; // num spaces to indent each level
+};
+
+}
+
+#endif // TEMPLATE_INDENTED_WRITER_H_
diff --git a/src/make_tpl_varnames_h.cc b/src/make_tpl_varnames_h.cc
new file mode 100644
index 0000000..1dcb069
--- /dev/null
+++ b/src/make_tpl_varnames_h.cc
@@ -0,0 +1,468 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// A utility for checking syntax and generating headers to
+// use with Google Templates.
+//
+// For example:
+//
+// > <path_to>/make_tpl_varnames_h some_template_file.tpl
+//
+// This creates the header file some_template_file.tpl.varnames.h. If
+// there are any syntax errors they are reported to stderr (in which
+// case, no header file is created).
+//
+//
+// Exit code is the number of templates we were unable to parse.
+//
+// Headers can be all written to one output file (via --outputfile)
+// or written to one output file per template processed (via --header_dir).
+// As such, we have a first stage where we load each template and generate
+// its headers and a second stage where we write the headers to disk.
+//
+// TODO(jad): Prevent -f and -o from being used together.
+// Previously -o would be silently ignored.
+
+// This is for windows. Even though we #include config.h, just like
+// the files used to compile the dll, we are actually a *client* of
+// the dll, so we don't get to decl anything.
+#include <config.h>
+#undef CTEMPLATE_DLL_DECL
+#include <ctype.h> // for toupper(), isalnum()
+#include <errno.h>
+#ifdef HAVE_GETOPT_H
+# include <getopt.h>
+#endif
+#include <stdarg.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <string>
+#include <set>
+#include <vector>
+
+#include <ctemplate/template_pathops.h>
+#include <ctemplate/template.h>
+using std::set;
+using std::string;
+using std::vector;
+using GOOGLE_NAMESPACE::Template;
+
+enum {LOG_INFO, LOG_WARNING, LOG_ERROR, LOG_FATAL};
+
+// Holds information on each template we process.
+struct TemplateRecord {
+ const string name; // filename given on cmd-line (may be relative
+ bool error; // true iff an error occurred during template loading
+ string header_entries; // output of tpl->WriteHeaderEntries()
+
+ explicit TemplateRecord(const string& aname)
+ : name(aname), error(false) {
+ }
+};
+
+static void LogPrintf(int severity, int should_log_info, const char* pat, ...) {
+ if (severity == LOG_INFO && !should_log_info)
+ return;
+ if (severity == LOG_FATAL)
+ fprintf(stderr, "FATAL ERROR: ");
+ va_list ap;
+ va_start(ap, pat);
+ vfprintf(stderr, pat, ap);
+ va_end(ap);
+ fprintf(stderr, "\n");
+ if (severity == LOG_FATAL)
+ exit(1);
+}
+
+// prints to outfile -- usually stdout or stderr
+static void Usage(const char* argv0, FILE* outfile) {
+ fprintf(outfile, "USAGE: %s [-t<dir>] [-o<dir>] [-s<suffix>] [-f<filename>]"
+ " [-n] [-d] [-q] <template_filename> ...\n", argv0);
+ fprintf(outfile,
+ " -t<dir> --template_dir=<dir> Root directory of templates\n"
+ " -o<dir> --header_dir=<dir> Where to place output files\n"
+ " -s<suffix> --outputfile_suffix=<suffix>\n"
+ " outname = inname + suffix\n"
+ " -f<filename> --outputfile=<filename>\n"
+ " outname = filename (when given, \n"
+ " --header_dir is ignored)\n"
+ " -n --noheader Just check syntax, no output\n"
+ " -d --dump_templates Cause templates dump contents\n"
+ " -q --nolog_info Only log on error\n"
+ " --v=-1 Obsolete, confusing synonym for -q\n"
+ " -h --help This help\n"
+ " -V --version Version information\n");
+ fprintf(outfile, "\n"
+ "This program checks the syntax of one or more google templates.\n"
+ "By default (without -n) it also emits a header file to an output\n"
+ "directory that defines all valid template keys. This can be used\n"
+ "in programs to minimze the probability of typos in template code.\n");
+}
+
+static void Version(FILE* outfile) {
+ fprintf(outfile,
+ "make_tpl_varnames_h "
+ " (part of " PACKAGE_STRING ")"
+ "\n\n"
+ "Copyright 1998 Google Inc.\n"
+ "\n"
+ "This is BSD licensed software; see the source for copying conditions\n"
+ "and license information.\n"
+ "There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A\n"
+ "PARTICULAR PURPOSE.\n"
+ );
+}
+
+// Removes all non alphanumeric characters from a string to form a
+// valid C identifier to use as a double-inclusion guard.
+static void ConvertToIdentifier(string* s) {
+ for (string::size_type i = 0; i < s->size(); i++) {
+ if (!isalnum((*s)[i]))
+ (*s)[i] = '_';
+ else
+ (*s)[i] = toupper((*s)[i]);
+ }
+}
+
+// Returns the given header entries wrapped with a compiler guard
+// whose name is generated from the output_file name.
+static string WrapWithGuard(const string& output_file,
+ const string& header_entries) {
+ string guard(string("TPL_") + output_file);
+ ConvertToIdentifier(&guard);
+ guard.append("_H_");
+
+ string out;
+ out.append(string("#ifndef ") + guard + "\n");
+ out.append(string("#define ") + guard + "\n\n");
+
+ // Now append the header-entry info to the intro above
+ out.append(header_entries);
+
+ out.append(string("\n#endif // ") + guard + "\n");
+ return out;
+}
+
+// Generates a multi-line comment that will go at the top of the output file.
+// The comment includes the filename(s) that produced the output, one per line.
+static string Boilerplate(const string& progname,
+ const vector<string>& filenames) {
+ string out(string("//\n"));
+ if (filenames.size() > 1)
+ out.append("// This header file auto-generated for the templates\n");
+ else
+ out.append("// This header file auto-generated for the template\n");
+
+ for (vector<string>::size_type i = 0; i < filenames.size(); ++i)
+ out.append("// " + filenames[i] + "\n");
+
+ out.append("// by " + progname + "\n" +
+ "// DO NOT MODIFY THIS FILE DIRECTLY\n" +
+ "//\n");
+ return out;
+}
+
+// Returns true iff line is empty or only contains whitespace
+// (space, horizontal tab, vertical tab, form feed, carriage return).
+static bool LineIsAllWhitespace(const string& input) {
+ static const string kWhitespace(" \f\t\v\r");
+ return input.find_first_not_of(kWhitespace) == string::npos;
+}
+
+// Splits the input string into lines using the newline (\n)
+// as delimiter. The newlines are discarded.
+// An empty string input results in one empty line output.
+//
+// Examples: "Hello\nWorld\n" input results in two lines,
+// "Hello" and "World".
+// Same result for "Hello\nWorld" (not newline terminated).
+//
+static vector<string> SplitIntoLines(const string &input) {
+ vector<string> lines;
+
+ string::size_type begin_index = 0;
+ string::size_type input_len = input.length();
+
+ while (1) {
+ string::size_type end_index = input.find_first_of('\n', begin_index);
+ if (end_index == string::npos) {
+ lines.push_back(input.substr(begin_index));
+ break;
+ }
+ lines.push_back(input.substr(begin_index, (end_index - begin_index)));
+ begin_index = end_index + 1;
+ if (begin_index >= input_len) // To avoid adding a trailing empty line.
+ break;
+ }
+ return lines;
+}
+
+// Receives header entries concatenated together from one or more
+// templates and returns a string with the duplicate lines removed.
+//
+// Duplicate lines that contain only whitespace are not removed,
+// all other duplicate lines (identical #include directives and
+// identical variable definitions) are removed. If the last
+// (or only) input line did not terminate with newline, we add one.
+//
+// Consider the following two templates:
+// ex1.tpl: <p>{{USER}}</p>
+// ex2.tpl: <a href="{{URL}}">{{USER}}</a>
+//
+// The header entries for ex1.tpl are:
+// #include "template/template_string.h"
+// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_USER =
+// STS_INIT_WITH_HASH(ke_USER, "USER", 3254611514008215315LLU);
+//
+// The header entries for ex2.tpl are:
+// #include "template/template_string.h"
+// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_URL =
+// STS_INIT_WITH_HASH(ke_URL, "URL", 1026025273225241985LLU);
+// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_USER =
+// STS_INIT_WITH_HASH(ke_USER, "USER", 3254611514008215315LLU);
+//
+// Simply concatenating both header entries will result in
+// duplicate #include directives and duplicate definitions of
+// the ke_USER variable. This function instead outputs:
+//
+// #include "template/template_string.h"
+// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_USER =
+// STS_INIT_WITH_HASH(ke_USER, "USER", 3254611514008215315LLU);
+// static const ::GOOGLE_NAMESPACE::StaticTemplateString ke_URL =
+// STS_INIT_WITH_HASH(ke_URL, "URL", 1026025273225241985LLU);
+//
+static string TextWithDuplicateLinesRemoved(const string& header_entries) {
+ string output;
+ set<string> lines_seen;
+ vector<string> lines = SplitIntoLines(header_entries);
+ const int lines_len = lines.size();
+ for (int i = 0; i < lines_len; ++i) {
+ const string& line = lines[i];
+ if (LineIsAllWhitespace(line) || // Blank lines always go in
+ !lines_seen.count(line)) { // So do new lines
+ output.append(line);
+ output.append("\n");
+ lines_seen.insert(line);
+ }
+ }
+ return output;
+}
+
+// Writes the given text to the filename header_file.
+// Returns true if it succeeded, false otherwise.
+static bool WriteToDisk(bool log_info, const string& output_file,
+ const string& text) {
+ FILE* outfile = fopen(output_file.c_str(), "wb");
+ if (!outfile) {
+ LogPrintf(LOG_ERROR, log_info, "Can't open %s", output_file.c_str());
+ return false;
+ }
+ LogPrintf(LOG_INFO, log_info, "Creating %s", output_file.c_str());
+ if (fwrite(text.c_str(), 1, text.length(), outfile) != text.length()) {
+ LogPrintf(LOG_ERROR, log_info, "Can't write %s: %s",
+ output_file.c_str(), strerror(errno));
+ }
+ fclose(outfile);
+ return true;
+}
+
+int main(int argc, char **argv) {
+ string FLAG_template_dir(GOOGLE_NAMESPACE::kCWD); // "./"
+ string FLAG_header_dir(GOOGLE_NAMESPACE::kCWD);
+ GOOGLE_NAMESPACE::NormalizeDirectory(&FLAG_header_dir); // adds trailing slash
+ string FLAG_outputfile_suffix(".varnames.h");
+ string FLAG_outputfile("");
+ bool FLAG_header = true;
+ bool FLAG_dump_templates = false;
+ bool FLAG_log_info = true;
+
+#if defined(HAVE_GETOPT_LONG)
+ static struct option longopts[] = {
+ {"help", 0, NULL, 'h'},
+ {"version", 0, NULL, 'V'},
+ {"template_dir", 1, NULL, 't'},
+ {"header_dir", 1, NULL, 'o'},
+ {"outputfile_suffix", 1, NULL, 's'},
+ {"outputfile", 1, NULL, 'f'},
+ {"noheader", 0, NULL, 'n'},
+ {"dump_templates", 0, NULL, 'd'},
+ {"nolog_info", 0, NULL, 'q'},
+ {"v", 1, NULL, 'q'},
+ {0, 0, 0, 0}
+ };
+ int option_index;
+# define GETOPT(argc, argv) getopt_long(argc, argv, "t:o:s:f:ndqhV", \
+ longopts, &option_index)
+#elif defined(HAVE_GETOPT_H)
+# define GETOPT(argc, argv) getopt(argc, argv, "t:o:s:f:ndqhV")
+#else // TODO(csilvers): implement something reasonable for windows
+# define GETOPT(argc, argv) -1
+ int optind = 1; // first non-opt argument
+ const char* optarg = ""; // not used
+#endif
+
+ int r = 0;
+ while (r != -1) { // getopt()/getopt_long() return -1 upon no-more-input
+ r = GETOPT(argc, argv);
+ switch (r) {
+ case 't': FLAG_template_dir.assign(optarg); break;
+ case 'o': FLAG_header_dir.assign(optarg); break;
+ case 's': FLAG_outputfile_suffix.assign(optarg); break;
+ case 'f': FLAG_outputfile.assign(optarg); break;
+ case 'n': FLAG_header = false; break;
+ case 'd': FLAG_dump_templates = true; break;
+ case 'q': FLAG_log_info = false; break;
+ case 'V': Version(stdout); return 0; break;
+ case 'h': Usage(argv[0], stderr); return 0; break;
+ case -1: break; // means 'no more input'
+ default: Usage(argv[0], stderr); return 1; break;
+ }
+ }
+
+ if (optind >= argc) {
+ LogPrintf(LOG_FATAL, FLAG_log_info,
+ "Must specify at least one template file on the command line.");
+ }
+
+ Template::SetTemplateRootDirectory(FLAG_template_dir);
+
+
+ // Initialize the TemplateRecord array. It holds one element per
+ // template given on the command-line.
+ vector<TemplateRecord*> template_records;
+ for (int i = optind; i < argc; ++i) {
+ TemplateRecord *template_rec = new TemplateRecord(argv[i]);
+ template_records.push_back(template_rec);
+ }
+
+ // Iterate through each template and (unless -n is given), write
+ // its header entries into the headers array.
+ int num_errors = 0;
+ for (vector<TemplateRecord*>::iterator it = template_records.begin();
+ it != template_records.end(); ++it) {
+ const char* tplname = (*it)->name.c_str();
+ LogPrintf(LOG_INFO, FLAG_log_info, "\n------ Checking %s ------", tplname);
+
+ // The last two arguments in the following call do not matter
+ // since they control how the template gets expanded and we never
+ // expand the template after loading it here
+ Template * tpl = Template::GetTemplate(tplname, GOOGLE_NAMESPACE::DO_NOT_STRIP);
+
+ // The call to GetTemplate (above) loads the template from disk
+ // and attempts to parse it. If it cannot find the file or if it
+ // detects any template syntax errors, the parsing routines
+ // report the error and GetTemplate returns NULL. Syntax errors
+ // include such things as mismatched double-curly-bracket pairs,
+ // e.g. '{{VAR}', Invalid characters in template variables or
+ // section names, e.g. '{{BAD_VAR?}}' [the question mark is
+ // illegal], improperly nested section/end section markers,
+ // e.g. a section close marker with no section start marker or a
+ // section start of a different name.
+ // If that happens, since the parsing errors have already been reported
+ // we just continue on to the next one.
+ if (!tpl) {
+ LogPrintf(LOG_ERROR, FLAG_log_info, "Could not load file: %s", tplname);
+ num_errors++;
+ (*it)->error = true;
+ continue;
+ } else {
+ LogPrintf(LOG_INFO, FLAG_log_info, "No syntax errors detected in %s",
+ tplname);
+ if (FLAG_dump_templates)
+ tpl->Dump(tpl->template_file());
+ }
+
+ // The rest of the loop creates the header file
+ if (!FLAG_header)
+ continue; // They don't want header files
+
+ tpl->WriteHeaderEntries(&((*it)->header_entries));
+ }
+
+ // We have headers to emit:
+ // . If --outputfile was given, we combine all the header entries and
+ // write them to the given output file. If any template had errors,
+ // we fail and do not generate an output file.
+ // . Otherwise, we write one output file per template we processed.
+ // . In both cases, we add proper boilerplate first.
+ if (FLAG_header) {
+ string progname = argv[0];
+
+ if (!FLAG_outputfile.empty()) { // All header entries written to one file.
+ // If any template had an error, we do not produce an output file.
+ if (num_errors == 0) {
+ vector<string> template_filenames;
+ string all_header_entries;
+ for (vector<TemplateRecord*>::const_iterator
+ it = template_records.begin(); it != template_records.end(); ++it) {
+ all_header_entries.append((*it)->header_entries);
+ template_filenames.push_back((*it)->name);
+ }
+ string output = Boilerplate(progname, template_filenames);
+ const string cleantext =
+ TextWithDuplicateLinesRemoved(all_header_entries);
+ output.append(WrapWithGuard(FLAG_outputfile, cleantext));
+ if (!WriteToDisk(FLAG_log_info, FLAG_outputfile, output))
+ num_errors++;
+ }
+ } else {
+ // Each template will have its own output file. Skip any that had errors.
+ for (vector<TemplateRecord*>::const_iterator
+ it = template_records.begin(); it != template_records.end(); ++it) {
+ if ((*it)->error)
+ continue;
+ string basename = GOOGLE_NAMESPACE::Basename((*it)->name);
+ string output_file =
+ GOOGLE_NAMESPACE::PathJoin(FLAG_header_dir,
+ basename + FLAG_outputfile_suffix);
+ vector<string> template_filenames; // Contains one template filename.
+ template_filenames.push_back((*it)->name);
+ string output = Boilerplate(progname, template_filenames);
+ output.append(WrapWithGuard(output_file, (*it)->header_entries));
+ if (!WriteToDisk(FLAG_log_info, output_file, output))
+ num_errors++;
+ }
+ }
+ }
+
+ // Free dynamic memory
+ for (vector<TemplateRecord*>::iterator it = template_records.begin();
+ it != template_records.end(); ++it) {
+ delete *it;
+ }
+
+ // Cap at 127 to avoid causing problems with return code
+ return num_errors > 127 ? 127 : num_errors;
+}
diff --git a/src/per_expand_data.cc b/src/per_expand_data.cc
new file mode 100644
index 0000000..0a468cf
--- /dev/null
+++ b/src/per_expand_data.cc
@@ -0,0 +1,78 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// This contains some implementation of PerExpandData that is still simple
+// but is not conveniently defined in the header file, e.g., because it would
+// introduce new include dependencies.
+
+#include <config.h>
+#include <ctemplate/find_ptr.h>
+#include <ctemplate/per_expand_data.h>
+#include <ctemplate/template_annotator.h>
+
+namespace ctemplate {
+
+using std::string;
+
+#ifndef _MSC_VER
+bool PerExpandData::DataEq::operator()(const char* s1, const char* s2) const {
+ return ((s1 == 0 && s2 == 0) ||
+ (s1 && s2 && *s1 == *s2 && strcmp(s1, s2) == 0));
+}
+#endif
+
+PerExpandData::~PerExpandData() {
+ delete map_;
+}
+
+TemplateAnnotator* PerExpandData::annotator() const {
+ if (annotator_ != NULL) {
+ return annotator_;
+ }
+ // TextTemplateAnnotator has no static state. So direct static definition
+ // should be safe.
+ static TextTemplateAnnotator g_default_annotator;
+ return &g_default_annotator;
+}
+
+void PerExpandData::InsertForModifiers(const char* key, const void* value) {
+ if (!map_)
+ map_ = new DataMap;
+ (*map_)[key] = value;
+}
+
+ // Retrieve data specific to this Expand call. Returns NULL if key
+ // is not found. This should only be used by template modifiers.
+const void* PerExpandData::LookupForModifiers(const char* key) const {
+ return map_ ? find_ptr2(*map_, key) : NULL;
+}
+
+}
diff --git a/src/solaris/libstdc++.la b/src/solaris/libstdc++.la
new file mode 100644
index 0000000..3edf425
--- /dev/null
+++ b/src/solaris/libstdc++.la
@@ -0,0 +1,51 @@
+# libstdc++.la - a libtool library file
+# Generated by ltmain.sh - GNU libtool 1.4a-GCC3.0 (1.641.2.256 2001/05/28 20:09:07 with GCC-local changes)
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# ---
+# NOTE: This file lives in /usr/sfw/lib on Solaris 10. Unfortunately,
+# due to an apparent bug in the Solaris 10 6/06 release,
+# /usr/sfw/lib/libstdc++.la is empty. Below is the correct content,
+# according to
+# http://forum.java.sun.com/thread.jspa?threadID=5073150
+# By passing LDFLAGS='-Lsrc/solaris' to configure, make will pick up
+# this copy of the file rather than the empty copy in /usr/sfw/lib.
+#
+# Also see
+# http://www.technicalarticles.org/index.php/Compiling_MySQL_5.0_on_Solaris_10
+#
+# Note: this is for 32-bit systems. If you have a 64-bit system,
+# uncomment the appropriate dependency_libs line below.
+# ----
+
+# The name that we can dlopen(3).
+dlname='libstdc++.so.6'
+
+# Names of this library.
+library_names='libstdc++.so.6.0.3 libstdc++.so.6 libstdc++.so'
+
+# The name of the static archive.
+old_library='libstdc++.a'
+
+# Libraries that this one depends upon.
+# 32-bit version:
+dependency_libs='-lc -lm -L/usr/sfw/lib -lgcc_s'
+# 64-bit version:
+#dependency_libs='-L/lib/64 -lc -lm -L/usr/sfw/lib/64 -lgcc_s'
+
+# Version information for libstdc++.
+current=6
+age=0
+revision=3
+
+# Is this an already installed library?
+installed=yes
+
+# Files to dlopen/dlpreopen
+dlopen=''
+dlpreopen=''
+
+# Directory that this library needs to be installed in:
+libdir='/usr/sfw/lib'
diff --git a/src/template-converter b/src/template-converter
new file mode 100755
index 0000000..7aedaed
--- /dev/null
+++ b/src/template-converter
@@ -0,0 +1,111 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2001 Google Inc.
+# 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 Google Inc. 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.
+
+# ---
+# Author: Andrew Fikes
+#
+# Tool to convert a template file (.tpl) into a C++ header
+# file with a const string defining the same template. This string
+# can then be used to create/retrieve a template using
+# Template::StringToTemplate()/StringToTemplateCache() (see template.h).
+#
+# Usage: template-converter <template_name> < infile > outfile
+#
+# template_name is the name of the variable we export. A good choice
+# is to pass in the outfile name. To make that easier, we treat
+# <template_name> as a pathname, and take the basename, strip the
+# suffix if it's .h, and sanitize the rest of the name to be a legal
+# C variable name.
+# MOE:insert # NOTE: See doc/index.html for a general description of Google ctemplate.
+
+
+# Store the input argv.
+my $argv = join(" ", $0, @ARGV);
+
+# Open template file
+(my $template_name = shift) || usage("Need to specify template variable name.");
+
+# If a second argument is supplied, treat it as an input filename.
+if (my $infile = shift) {
+ open(STDIN, "<", $infile) or usage("Can't open $infile for reading.");
+}
+
+# If a third argument is supplied, treat it as an output filename.
+if (my $outfile = shift) {
+ open(STDOUT, ">", $outfile) or usage("Can't open $outfile for writing.");
+}
+
+# Get base name of template file
+$base_name = $template_name;
+$base_name =~ s|^.*/([^/]*)$|$1|; # Strip out directory name
+$base_name =~ s|\.h$||; # Strip out suffix, if it's .h
+$base_name =~ tr|A-Za-z0-9_|_|c; # Sanitize name to remove non-letters/nums
+
+# Print header
+print "// This file automatically generated by template-converter:\n";
+print "// $argv\n";
+print "//\n";
+print "// DO NOT EDIT!\n\n";
+print "#ifndef " . uc($base_name) . "_H_\n";
+print "#define " . uc($base_name) . "_H_\n\n";
+print "#include <string>\n\n";
+
+# Read in template file and print template as a string
+# MOE:begin_strip
+print "const string ${base_name} (\n";
+# MOE:end_strip_and_replace print "const std::string ${base_name} (\n";
+while (<>) {
+ chomp;
+ my $escaped_line = escape_line($_);
+ print "\"$escaped_line\\n\"\n";
+}
+print ");\n\n";
+
+# Print footer and exit
+print "#endif /* " . uc($base_name) . "_H_ */\n";
+exit(0);
+
+# Prints usage message
+sub usage {
+ my $msg = shift;
+ print STDERR "\n$msg\n";
+ print STDERR "Usage: template-converter <template-varname>",
+ " [infile] [outfile]\n\n";
+ exit(1);
+}
+
+# Escapes line (adds a '\' to quotes and possible control characters)
+sub escape_line {
+ (my $line) = (@_);
+ $line =~ s|\\|\\\\|g;
+ $line =~ s|\"|\\"|g;
+ return $line;
+}
diff --git a/src/template.cc b/src/template.cc
new file mode 100644
index 0000000..de20d06
--- /dev/null
+++ b/src/template.cc
@@ -0,0 +1,2777 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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 <config.h>
+#include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE
+#include <ctemplate/template.h>
+
+#include <assert.h>
+#include <errno.h>
+#include <stdio.h> // for fwrite, fflush
+#include <stdlib.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <time.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif // for stat() and open() and getcwd()
+#include <algorithm> // for binary_search()
+#include <functional> // for binary_function()
+#include HASH_MAP_H
+#include <iterator>
+#include <list>
+#include <string>
+#include <utility> // for pair
+#include <vector>
+
+#include "base/thread_annotations.h"
+#include "htmlparser/htmlparser_cpp.h"
+#include <ctemplate/per_expand_data.h>
+#include <ctemplate/template_annotator.h>
+#include <ctemplate/template_cache.h>
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_dictionary_interface.h> // also gets kIndent
+#include <ctemplate/template_modifiers.h>
+#include "template_modifiers_internal.h"
+#include <ctemplate/template_pathops.h>
+#include <ctemplate/template_string.h>
+#include "base/fileutil.h"
+#include <ctype.h>
+#include <iostream>
+#include <sstream> // for ostringstream
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 4096 // seems conservative for max filename len!
+#endif
+#endif
+
+#define arraysize(x) ( sizeof(x) / sizeof(*(x)) )
+
+#define AS_STR1(x) #x
+#define AS_STR(x) AS_STR1(x)
+
+// A very simple logging system
+#undef LOG // a non-working version is provided in base/util.h; redefine it
+static int kVerbosity = 0; // you can change this by hand to get vlogs
+#define LOG(level) std::cerr << #level ": "
+#define VLOG(level) if (kVerbosity >= level) LOG(level)
+
+// TODO(csilvers): use our own tables for these?
+static bool ascii_isalnum(char c) {
+ return ((c & 0x80) == 0) && isalnum(c); // 7-bit ascii, and an alnum
+}
+
+static bool ascii_isspace(char c) {
+ return ((c & 0x80) == 0) && isspace(c); // 7-bit ascii, and a space
+}
+
+#define strsuffix(str, suffix) \
+ ( strlen(str) > (sizeof("" suffix "") - 1) && \
+ strcmp(str + strlen(str) - (sizeof(suffix) - 1), suffix) == 0 )
+
+using std::endl;
+using std::string;
+using std::list;
+using std::vector;
+using std::pair;
+using std::binary_search;
+#ifdef HAVE_UNORDERED_MAP
+using HASH_NAMESPACE::unordered_map;
+// This is totally cheap, but minimizes the need for #ifdef's below...
+#define hash_map unordered_map
+#else
+using HASH_NAMESPACE::hash_map;
+#endif
+
+namespace ctemplate {
+
+using ctemplate_htmlparser::HtmlParser;
+
+TemplateId GlobalIdForSTS_INIT(const TemplateString& s) {
+ return s.GetGlobalId(); // normally this method is private
+}
+
+int Template::num_deletes_ = 0;
+
+namespace {
+// Mutex for protecting Expand calls against ReloadIfChanged, which
+// might change a template while it's being expanded. This mutex used
+// to be a per-template mutex, rather than a global mutex, which seems
+// like it would be strictly better, but we ran into subtle problems
+// with deadlocks when a template would sub-include itself (thus
+// requiring a recursive read-lock during Expand), and the template
+// was Expanded and ReloadIfChanged at the same time. Rather than
+// deal with that complication, we just go with a global mutex. Since
+// ReloadIfChanged is deprecated, in most applications all the mutex
+// uses will be as read-locks, so this shouldn't cause much contention.
+static Mutex g_template_mutex(base::LINKER_INITIALIZED);
+
+// Mutex for protecting vars_seen in WriteOneHeaderEntry, below.
+// g_template_mutex and g_header_mutex are never held at the same time.
+// TODO(csilvers): assert this in the codebase.
+static Mutex g_header_mutex(base::LINKER_INITIALIZED);
+
+// It's not great to have a global variable with a constructor, but
+// it's safe in this case: the constructor is trivial and does not
+// depend on any other global constructors running first, and the
+// variable is used in only one place below, always after main() has
+// started.
+// It is ok for this modifier to be in XssClass XSS_WEB_STANDARD because
+// it only adds indentation characters - typically whitespace - iff these
+// are already present in the text. If such characters were XSS-harmful
+// in a given context, they would have already been escaped or replaced
+// by earlier escaping such as H=attribute.
+static const ModifierInfo g_prefix_line_info("", '\0', XSS_WEB_STANDARD,
+ &prefix_line);
+
+const char * const kDefaultTemplateDirectory = kCWD; // "./"
+// Note this name is syntactically impossible for a user to accidentally use.
+const char * const kMainSectionName = "__{{MAIN}}__";
+
+// A TemplateString object that precomputes its hash. This can be
+// useful in places like template filling code, where we'd like to
+// hash the string once then reuse it many times. This should not be
+// used for filling any part of a template dictionary, since we don't
+// map the id to its corresponding string or manage memory for the
+// string - it is for lookups *only*.
+class HashedTemplateString : public TemplateString {
+ public:
+ HashedTemplateString(const char* s, size_t slen) : TemplateString(s, slen) {
+ CacheGlobalId();
+ }
+};
+
+#define LOG_TEMPLATE_NAME(severity, template) \
+ LOG(severity) << "Template " << template->template_file() << ": "
+
+#define LOG_AUTO_ESCAPE_ERROR(error_msg, my_template) do { \
+ LOG_TEMPLATE_NAME(ERROR, my_template); \
+ LOG(ERROR) << "Auto-Escape: " << error_msg << endl; \
+ } while (0)
+
+// We are in auto-escape mode.
+#define AUTO_ESCAPE_MODE(context) ((context) != TC_MANUAL)
+
+// Auto-Escape contexts which utilize the HTML Parser.
+#define AUTO_ESCAPE_PARSING_CONTEXT(context) \
+ ((context) == TC_HTML || (context) == TC_JS || (context) == TC_CSS)
+
+// ----------------------------------------------------------------------
+// PragmaId
+// PragmaDefinition
+// PragmaMarker
+// Functionality to support the PRAGMA marker in the template, i.e
+// the {{%IDENTIFIER [name1="value1" [name2="value2"]...]}} syntax:
+// . IDENTIFIER as well as all attribute names are case-insensitive
+// whereas attribute values are case-sensitive.
+// . No extraneous whitespace is allowed (e.g. between name and '=').
+// . Double quotes inside an attribute value need to be backslash
+// escaped, i.e. " -> \". We unescape them during parsing.
+//
+// The only identifier currently supported is AUTOESCAPE which is
+// used to auto-escape a given template. Its syntax is:
+// {{%AUTOESCAPE context="context" [state="state"]}} where:
+// . context is one of: "HTML", "JAVASCRIPT", "CSS", "XML", "JSON".
+// . state may be omitted or equivalently, it may be set to "default".
+// It also accepts the value "IN_TAG" in the HTML context to
+// indicate the template contains HTML attribute name/value
+// pairs that are enclosed in a tag specified in a parent template.
+// e.g: Consider the parent template:
+// <a href="/bla" {{>INC}}>text</a>
+// and the included template:
+// class="{{CLASS}}" target="{{TARGET}}"
+// Then, for the included template to be auto-escaped properly, it
+// must have the pragma: {{%AUTOESCAPE context="HTML" state="IN_TAG"}}.
+// This is a very uncommon template structure.
+//
+// To add a new pragma identifier, you'll have to at least:
+// 1. Add a new id for it in PragmaId enum.
+// 2. Add the corresponding definition in static g_pragmas array
+// 3. If you accept more than 2 attributes, increase the size
+// of attribute_names in the PragmaDefinition struct.
+// 4. Add handling of that pragma in SectionTemplateNode::GetNextToken()
+// and possibly SectionTemplateNode::AddPragmaNode()
+// ----------------------------------------------------------------------
+
+// PragmaId
+// Identify all the pragma identifiers we support. Currently only
+// one (for AutoEscape). PI_ERROR is only for internal error reporting,
+// and is not a valid pragma identifier.
+enum PragmaId { PI_UNUSED, PI_ERROR, PI_AUTOESCAPE, NUM_PRAGMA_IDS };
+
+// Each pragma definition has a unique identifier as well as a list of
+// attribute names it accepts. This allows initial error checking while
+// parsing a pragma definition. Such error checking will need supplementing
+// with more pragma-specific logic in SectionTemplateNode::GetNextToken().
+static struct PragmaDefinition {
+ PragmaId pragma_id;
+ const char* identifier;
+ const char* attribute_names[2]; // Increase as needed.
+} g_pragmas[NUM_PRAGMA_IDS] = {
+ /* PI_UNUSED */ { PI_UNUSED, NULL, {} },
+ /* PI_ERROR */ { PI_ERROR, NULL, {} },
+ /* PI_AUTOESCAPE */ { PI_AUTOESCAPE, "AUTOESCAPE", {"context", "state"} }
+};
+
+// PragmaMarker
+// Functionality to parse the {{%...}} syntax and extract the
+// provided attribute values. We store the PragmaId as well
+// as a vector of all the attribute names and values provided.
+class PragmaMarker {
+ public:
+ // Constructs a PragmaMarker object from the PRAGMA marker
+ // {{%ID [[name1=\"value1"] ...]}}. On error (unable to parse
+ // the marker), returns an error description in error_msg. On
+ // success, error_msg is cleared.
+ PragmaMarker(const char* token_start, const char* token_end,
+ string* error_msg);
+
+ // Returns the attribute value for the corresponding attribute name
+ // or NULL if none is found (as is the case with optional attributes).
+ // Ensure you only call it on attribute names registered in g_pragmas
+ // for that PragmaId.
+ const string* GetAttributeValue(const char* attribute_name) const;
+
+ private:
+ // Checks that the identifier given matches one of the pragma
+ // identifiers we know of, in which case returns the corresponding
+ // PragmaId. In case of error, returns PI_ERROR.
+ static PragmaId GetPragmaId(const char* id, size_t id_len);
+
+ // Parses an attribute value enclosed in double quotes and updates
+ // value_end to point at ending double quotes. Returns the attribute
+ // value. If an error occurred, error_msg is set with information.
+ // It is cleared on success.
+ // Unescapes backslash-escaped double quotes ('\"' -> '"') if present.
+ static string ParseAttributeValue(const char* value_start,
+ const char** value_end,
+ string* error_msg);
+
+ // Returns true if the attribute name is an accepted one for that
+ // given PragmaId. Otherwise returns false.
+ static bool IsValidAttribute(PragmaId pragma_id, const char* name,
+ size_t namelen);
+
+ PragmaId pragma_id_;
+ // A vector of attribute (name, value) pairs.
+ vector<pair<string, string> > names_and_values_;
+};
+
+PragmaId PragmaMarker::GetPragmaId(const char* id, size_t id_len) {
+ for (int i = 0; i < NUM_PRAGMA_IDS; ++i) {
+ if (g_pragmas[i].identifier == NULL) // PI_UNUSED, PI_ERROR
+ continue;
+ if ((strlen(g_pragmas[i].identifier) == id_len) &&
+ (strncasecmp(id, g_pragmas[i].identifier, id_len) == 0))
+ return g_pragmas[i].pragma_id;
+ }
+ return PI_ERROR;
+}
+
+bool PragmaMarker::IsValidAttribute(PragmaId pragma_id, const char* name,
+ size_t namelen) {
+ const int kMaxAttributes = sizeof(g_pragmas[0].attribute_names) /
+ sizeof(*g_pragmas[0].attribute_names);
+ for (int i = 0; i < kMaxAttributes; ++i) {
+ const char* attr_name = g_pragmas[pragma_id].attribute_names[i];
+ if (attr_name == NULL)
+ break;
+ if ((strlen(attr_name) == namelen) &&
+ (strncasecmp(attr_name, name, namelen) == 0))
+ // We found the given name in our accepted attribute list.
+ return true;
+ }
+ return false; // We did not find the name.
+}
+
+const string* PragmaMarker::GetAttributeValue(
+ const char* attribute_name) const {
+ // Developer error if assert triggers.
+ assert(IsValidAttribute(pragma_id_, attribute_name, strlen(attribute_name)));
+ for (vector<pair<string, string> >::const_iterator it =
+ names_and_values_.begin(); it != names_and_values_.end(); ++it) {
+ if (strcasecmp(attribute_name, it->first.c_str()) == 0)
+ return &it->second;
+ }
+ return NULL;
+}
+
+string PragmaMarker::ParseAttributeValue(const char* value_start,
+ const char** value_end,
+ string* error_msg) {
+ assert(error_msg);
+ if (*value_start != '"') {
+ error_msg->append("Attribute value is not enclosed in double quotes.");
+ return "";
+ }
+ const char* current = ++value_start; // Advance past the leading '"'
+ const char* val_end;
+ do {
+ if (current >= *value_end ||
+ ((val_end =
+ (const char*)memchr(current, '"', *value_end - current)) == NULL)) {
+ error_msg->append("Attribute value not terminated.");
+ return "";
+ }
+ current = val_end + 1; // Advance past the current '"'
+ } while (val_end[-1] == '\\');
+
+ string attribute_value(value_start, val_end - value_start);
+ // Now replace \" with "
+ size_t found;
+ while ((found = attribute_value.find("\\\"")) != string::npos)
+ attribute_value.erase(found, 1);
+ *value_end = val_end;
+ error_msg->clear();
+ return attribute_value;
+}
+
+PragmaMarker::PragmaMarker(const char* token_start, const char* token_end,
+ string* error_msg) {
+ assert(error_msg);
+ string error;
+ const char* identifier_end =
+ (const char*)memchr(token_start, ' ', token_end - token_start);
+ if (identifier_end == NULL)
+ identifier_end = token_end;
+ pragma_id_ = PragmaMarker::GetPragmaId(token_start,
+ identifier_end - token_start);
+ if (pragma_id_ == PI_ERROR) {
+ error = "Unrecognized pragma identifier.";
+ } else {
+ const char* val_end;
+ // Loop through attribute name/value pairs.
+ for (const char* nameval = identifier_end; nameval < token_end;
+ nameval = val_end + 1) {
+ // Either after identifier or afer a name/value pair. Must be whitespace.
+ if (*nameval++ != ' ') {
+ error = "Extraneous text.";
+ break;
+ }
+ const char* val = (const char*)memchr(nameval, '=', token_end - nameval);
+ if (val == NULL || val == nameval) {
+ error = "Missing attribute name or value";
+ break;
+ }
+ const string attribute_name(nameval, val - nameval);
+ if (!PragmaMarker::IsValidAttribute(pragma_id_, attribute_name.data(),
+ attribute_name.length())) {
+ error = "Unrecognized attribute name: " + attribute_name;
+ break;
+ }
+ ++val; // Advance past '='
+ val_end = token_end;
+ const string attribute_value = ParseAttributeValue(val, &val_end, &error);
+ if (!error.empty()) // Failed to parse attribute value.
+ break;
+ names_and_values_.push_back(pair<const string, const string>(
+ attribute_name, attribute_value));
+ }
+ }
+ if (error.empty()) // Success
+ error_msg->clear();
+ else // Error
+ error_msg->append("In PRAGMA directive '" +
+ string(token_start, token_end - token_start) +
+ "' Error: " + error);
+}
+
+// ----------------------------------------------------------------------
+// memmatch()
+// Return a pointer to the first occurrences of the given
+// length-denominated string, inside a bigger length-denominated
+// string, or NULL if not found. The mem version of strstr.
+// ----------------------------------------------------------------------
+
+static const char *memmatch(const char *haystack, size_t haystack_len,
+ const char *needle, size_t needle_len) {
+ if (needle_len == 0)
+ return haystack; // even if haystack_len is 0
+ else if (needle_len > haystack_len)
+ return NULL;
+
+ const char* match;
+ const char* hayend = haystack + haystack_len - needle_len + 1;
+ while ((match = (const char*)memchr(haystack, needle[0],
+ hayend - haystack))) {
+ if (memcmp(match, needle, needle_len) == 0)
+ return match;
+ else
+ haystack = match + 1;
+ }
+ return NULL;
+}
+
+// ----------------------------------------------------------------------
+// FilenameValidForContext()
+// GetTemplateContextFromPragma()
+// GetModifierForContext()
+// FindLongestMatch()
+// PrettyPrintTokenModifiers()
+// Static methods for the auto-escape mode specifically.
+
+// Perfoms matching of filename against the TemplateContext
+// and warns in the log on mismatch using "unwritten" filename
+// conventions below for templates in our codebase:
+// 1. If filename contains "css", "stylesheet" or "style"
+// check that it has type TC_CSS.
+// 2. If filename contains "js" or "javascript" check that
+// it has type TC_JS.
+// Returns false if there was a mismatch although currently
+// we ignore it and just rely on the LOG(WARNING) in the logs.
+static bool FilenameValidForContext(const string& filename,
+ TemplateContext context) {
+ string stripped_filename = Basename(filename);
+
+ if (GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "css") ||
+ GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "stylesheet") ||
+ GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "style")) {
+ if (context != TC_CSS) {
+ LOG(WARNING) << "Template filename " << filename
+ << " indicates CSS but given TemplateContext"
+ << " was not TC_CSS." << endl;
+ return false;
+ }
+ } else if (GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "js") ||
+ GOOGLE_NAMESPACE::ContainsFullWord(stripped_filename, "javascript")) {
+ if (context != TC_JS) {
+ LOG(WARNING) << "Template filename " << filename
+ << " indicates javascript but given TemplateContext"
+ << " was not TC_JS." << endl;
+ return false;
+ }
+ }
+ return true;
+}
+
+// Returns a string containing a human-readable description of
+// the modifiers in the vector. The format is:
+// :modifier1[=val1][:modifier2][=val2]...
+static string PrettyPrintTokenModifiers(
+ const vector<ModifierAndValue>& modvals) {
+ string out;
+ for (vector<ModifierAndValue>::const_iterator it =
+ modvals.begin(); it != modvals.end(); ++it) {
+ string one_mod = PrettyPrintOneModifier(*it);
+ out.append(one_mod);
+ }
+ return out;
+}
+
+// Returns the TemplateContext corresponding to the "context" attribute
+// of the AUTOESCAPE pragma. Returns TC_MANUAL to indicate an error,
+// meaning an invalid context was given in the pragma.
+static TemplateContext GetTemplateContextFromPragma(
+ const PragmaMarker& pragma) {
+ const string* context = pragma.GetAttributeValue("context");
+ if (context == NULL)
+ return TC_MANUAL;
+ if (*context == "HTML" || *context == "html")
+ return TC_HTML;
+ else if (*context == "JAVASCRIPT" || *context == "javascript")
+ return TC_JS;
+ else if (*context == "CSS" || *context == "css")
+ return TC_CSS;
+ else if (*context == "JSON" || *context == "json")
+ return TC_JSON;
+ else if (*context == "XML" || *context == "xml")
+ return TC_XML;
+ return TC_MANUAL;
+}
+
+// Based on the state of the parser, determines the appropriate escaping
+// directive and returns a pointer to the corresponding
+// global ModifierAndValue vector. Called when a variable template node
+// is traversed.
+// Returns NULL if there is no suitable modifier for that context in
+// which the case the caller is expected to fail the template initialization.
+static const vector<const ModifierAndValue*> GetModifierForContext(
+ TemplateContext my_context, HtmlParser *htmlparser,
+ const Template* my_template) {
+ assert(AUTO_ESCAPE_MODE(my_context));
+ vector<const ModifierAndValue*> modvals;
+ string error_msg;
+
+ switch (my_context) {
+ case TC_XML:
+ modvals = GetModifierForXml(htmlparser, &error_msg);
+ break;
+ case TC_JSON:
+ modvals = GetModifierForJson(htmlparser, &error_msg);
+ break;
+ case TC_CSS:
+ assert(htmlparser); // Parser is active in CSS
+ modvals = GetModifierForCss(htmlparser, &error_msg);
+ break;
+ default:
+ // Must be in TC_HTML or TC_JS. Parser is active in these modes.
+ assert(AUTO_ESCAPE_PARSING_CONTEXT(my_context));
+ assert(htmlparser);
+ modvals = GetModifierForHtmlJs(htmlparser, &error_msg);
+ }
+ // In any mode, there should be at least one modifier.
+ if (modvals.empty())
+ LOG_AUTO_ESCAPE_ERROR(error_msg, my_template);
+ return modvals;
+}
+
+// Returns the largest int N indicating how many XSS safe alternative
+// modifiers are in the in-template modifiers already.
+// . If N is equal to the number of modifiers determined by the Auto Escaper,
+// we have a full match and the in-template modifiers were safe. We leave
+// them untouched.
+// . Otherwise, N is less (or zero) and we have a partial match (or none).
+// The in-template modifiers are not XSS safe and need the missing ones,
+// i.e. those in the auto escape modifiers which are not in the first N.
+//
+// We allow in-template modifiers to have extra modifiers than we deem
+// necessary, for e.g. :j:h when :j would have sufficed. But to make sure
+// these modifiers do not introduce XSS concerns we require that they
+// be in the same XssClass as the modifier we had.
+// For example :h:x-bla is not safe in HTML context because x-bla is
+// in a different XssClass as our :h whereas :h:j would be safe.
+static size_t FindLongestMatch(
+ const vector<ModifierAndValue>& modvals_man,
+ const vector<const ModifierAndValue*>& modvals_auto) {
+ if (modvals_auto.empty())
+ return 0;
+
+ // See if modvals_auto is "consistent" with the modifiers that are
+ // already present (modvals_man). This is true if all the
+ // modifiers in auto also occur in man, and any gaps between them
+ // (if any) are filled by "neutral" modifiers that do not affect
+ // xss-safety. We go through the vectors backwards.
+ // If all of modvals_auto is not consistent, maybe a prefix of it
+ // is; that's better than nothing, since we only need to auto-apply
+ // the suffix that's not already in modvals_man.
+ typedef vector<const ModifierAndValue*>::const_reverse_iterator
+ ModAutoIterator;
+ typedef vector<ModifierAndValue>::const_reverse_iterator ModManIterator;
+ for (ModAutoIterator end_of_prefix = modvals_auto.rbegin();
+ end_of_prefix != modvals_auto.rend();
+ ++end_of_prefix) {
+ ModAutoIterator curr_auto = end_of_prefix;
+ ModManIterator curr_man = modvals_man.rbegin();
+ while (curr_auto != modvals_auto.rend() &&
+ curr_man != modvals_man.rend()) {
+ if (IsSafeXSSAlternative(*(*curr_auto)->modifier_info,
+ *curr_man->modifier_info)) {
+ ++curr_auto;
+ ++curr_man;
+ } else if ((curr_man->modifier_info->xss_class ==
+ (*curr_auto)->modifier_info->xss_class) &&
+ (curr_man->modifier_info->xss_class != XSS_UNIQUE)) {
+ ++curr_man; // Ignore this modifier: it's harmless.
+ } else {
+ break; // An incompatible modifier; we've failed
+ }
+ }
+ if (curr_auto == modvals_auto.rend()) // got through them all, full match!
+ return curr_auto - end_of_prefix;
+ }
+ return 0;
+}
+
+// ----------------------------------------------------------------------
+// WriteOneHeaderEntry()
+// This dumps information about a template that is useful to
+// make_tpl_varnames_h -- information about the variable and
+// section names used in a template, so we can define constants
+// to refer to them instead of having to type them in by hand.
+// Output is *appended* to outstring.
+// ----------------------------------------------------------------------
+
+static void WriteOneHeaderEntry(
+ string *outstring, const string& variable, const string& full_pathname)
+ LOCKS_EXCLUDED(g_header_mutex) {
+ MutexLock ml(&g_header_mutex);
+
+ // we use hash_map instead of hash_set just to keep the stl size down
+ static hash_map<string, bool, StringHash> vars_seen
+ GUARDED_BY(g_header_mutex);
+ static string current_file GUARDED_BY(g_header_mutex);
+ static string prefix GUARDED_BY(g_header_mutex);
+
+ if (full_pathname != current_file) {
+ // changed files so re-initialize the static variables
+ vars_seen.clear();
+ current_file = full_pathname;
+
+ // remove the path before the filename
+ string filename(Basename(full_pathname));
+
+ prefix = "k";
+ bool take_next = true;
+
+ for (string::size_type i = 0; i < filename.length(); i++) {
+ if (filename[i] == '.') {
+ // stop when we find the dot
+ break;
+ }
+ if (take_next) {
+ if (filename.substr(i, 4) == "post") {
+ // stop before we process post...
+ break;
+ }
+ prefix = prefix + filename[i];
+ take_next = false;
+ }
+ if (filename[i] == '_') {
+ take_next = true;
+ }
+ }
+ prefix = prefix + "_";
+ }
+
+ // print out the variable, but only if we haven't seen it before.
+ if (!vars_seen.count(variable)) {
+ if (variable == kMainSectionName || variable.find("BI_") == 0) {
+ // We don't want to write entries for __MAIN__ or the built-ins
+ } else {
+ const TemplateId id = GlobalIdForSTS_INIT(TemplateString(variable));
+ std::ostringstream outstream;
+ outstream << "static const "
+ << AS_STR(GOOGLE_NAMESPACE) << "::StaticTemplateString "
+ << prefix << variable << " = STS_INIT_WITH_HASH("
+ << prefix << variable << ", \"" << variable << "\", "
+ << id << "ULL);\n";
+ outstring->append(outstream.str());
+ }
+ vars_seen[variable] = true;
+ }
+}
+
+// ----------------------------------------------------------------------
+// TemplateToken
+// A TemplateToken is a string marked with a token type enum. The string
+// has different meanings for different token types. For text, the
+// string is the text itself. For variable and template types, the
+// string is the name of the variable holding the value or the
+// template name, resp. For section types, the string is the name
+// of the section, used to retrieve the hidden/visible state and
+// the associated list of dictionaries, if any. For pragma type,
+// the string is the full text of the marker and is only used for
+// debug information.
+// ----------------------------------------------------------------------
+
+enum TemplateTokenType { TOKENTYPE_UNUSED, TOKENTYPE_TEXT,
+ TOKENTYPE_VARIABLE, TOKENTYPE_SECTION_START,
+ TOKENTYPE_SECTION_END, TOKENTYPE_TEMPLATE,
+ TOKENTYPE_COMMENT, TOKENTYPE_SET_DELIMITERS,
+ TOKENTYPE_PRAGMA, TOKENTYPE_NULL,
+ TOKENTYPE_HIDDEN_DEFAULT_SECTION,
+ };
+
+} // unnamed namespace
+
+// A sorted array of Template variable names that Auto-Escape should
+// not escape. Variables that you may want to add here typically
+// satisfy all the following conditions:
+// 1. Are "trusted" variables, meaning variables you know to not
+// contain potentially harmful content.
+// 2. Contain some markup that gets broken when escaping is
+// applied to them.
+// 3. Are used often such that requiring developers to add
+// ":none" to each use is error-prone and inconvenient.
+//
+// Note: Keep this array sorted as you add new elements!
+//
+const char * const Template::kSafeWhitelistedVariables[] = {
+ "" // a placekeeper element: replace with your real values!
+};
+const size_t Template::kNumSafeWhitelistedVariables =
+ arraysize(Template::kSafeWhitelistedVariables);
+
+// A TemplateToken is a typed string. The semantics of the string depends on the
+// token type, as follows:
+// TOKENTYPE_TEXT - the text
+// TOKENTYPE_VARIABLE - the name of the variable
+// TOKENTYPE_SECTION_START - the name of the section being started
+// TOKENTYPE_SECTION_END - the name of the section being ended
+// TOKENTYPE_TEMPLATE - the name of the variable whose value will be
+// the template filename
+// TOKENTYPE_COMMENT - the empty string, not used
+// TOKENTYPE_SET_DELIMITERS- the empty string, not used
+// TOKENTYPE_PRAGMA - identifier and optional set of name/value pairs
+// - exactly as given in the template
+// TOKENTYPE_NULL - the empty string
+// TOKENTYPE_HIDDEN_DEFAULT_SECTION
+// - like TOKENTYPE_SECTION_START, but defaults to
+// hidden
+// All non-comment tokens may also have modifiers, which follow the name
+// of the token: the syntax is {{<PREFIX><NAME>:<mod>:<mod>:<mod>...}}
+// The modifiers are also stored as a string, starting with the first :
+struct TemplateToken {
+ TemplateTokenType type;
+ const char* text;
+ size_t textlen;
+ vector<ModifierAndValue> modvals;
+ TemplateToken(TemplateTokenType t, const char* txt, size_t len,
+ const vector<ModifierAndValue>* m)
+ : type(t), text(txt), textlen(len) {
+ if (m) modvals = *m;
+ }
+
+ string ToString() const { // used for debugging (annotations)
+ string retval(text, textlen);
+ for (vector<ModifierAndValue>::const_iterator it = modvals.begin();
+ it != modvals.end(); ++it) {
+ const string& modname = it->modifier_info->long_name;
+ retval += string(":") + modname;
+ if (!it->modifier_info->is_registered)
+ retval += "<not registered>";
+ }
+ return retval;
+ }
+
+ // Updates the correct modifiers for the token (variable or template node)
+ // based on our computed modifiers from the HTML parser context as well
+ // as the in-template modifiers that may have been provided.
+ // If the in-template modifiers are considered safe, we use them
+ // without modification. This could happen in one of three cases:
+ // 1. The token has the ":none" modifier as one of the modifiers.
+ // 2. The token has a custom modifier considered XSS-Safe as one of
+ // the modifiers. The modifier was added via AddXssSafeModifier()
+ // and has the XSS_SAFE XssClass.
+ // 3. The escaping modifiers are XSS-equivalent to the ones we computed.
+ //
+ // If the in-template modifiers are not found to be safe, we add
+ // the escaping modifiers we determine missing. This is done based on a
+ // longest match search between the two modifiers vectors, refer to comment
+ // in FindLongestMatch. We also issue a warning in the log, unless the
+ // in-template modifiers were all not escaping related (e.g. custom)
+ // since that case is similar to that of not providing any modifiers.
+ void UpdateModifier(const vector<const ModifierAndValue*>& auto_modvals) {
+ // Common case: no modifiers given in template. Assign our own. No warning.
+ if (modvals.empty()) {
+ for (vector<const ModifierAndValue*>::const_iterator it
+ = auto_modvals.begin(); it != auto_modvals.end(); ++it) {
+ modvals.push_back(**it);
+ }
+ return;
+ }
+
+ // Look for any XSS-Safe modifiers (added via AddXssSafeModifier or :none).
+ // If one is found anywhere in the vector, consider the variable safe.
+ for (vector<ModifierAndValue>::const_iterator it = modvals.begin();
+ it != modvals.end(); ++it) {
+ if (it->modifier_info->xss_class == XSS_SAFE)
+ return;
+ }
+
+ size_t longest_match = FindLongestMatch(modvals, auto_modvals);
+ if (longest_match == auto_modvals.size()) {
+ return; // We have a complete match, nothing to do.
+ } else { // Copy missing ones and issue warning.
+ assert(longest_match >= 0 && longest_match < auto_modvals.size());
+ // We only log if one or more of the in-template modifiers was
+ // escaping-related which we infer from the XssClass. Currently,
+ // all escaping modifiers are in XSS_WEB_STANDARD except for 'none'
+ // but that one is handled above.
+ bool do_log = false;
+ for (vector<ModifierAndValue>::const_iterator it = modvals.begin();
+ it != modvals.end(); ++it) {
+ if (it->modifier_info->xss_class == XSS_WEB_STANDARD) {
+ do_log = true;
+ break;
+ }
+ }
+ string before = PrettyPrintTokenModifiers(modvals); // for logging
+ for (vector<const ModifierAndValue*>::const_iterator it
+ = auto_modvals.begin() + longest_match;
+ it != auto_modvals.end(); ++it) {
+ modvals.push_back(**it);
+ }
+ if (do_log)
+ LOG(ERROR)
+ << "Token: " << string(text, textlen)
+ << " has missing in-template modifiers. You gave " << before
+ << " and we computed " << PrettyPrintModifiers(auto_modvals, "")
+ << ". We changed to " << PrettyPrintTokenModifiers(modvals) << endl;
+ }
+ }
+};
+
+static bool AnyMightModify(const vector<ModifierAndValue>& modifiers,
+ const PerExpandData* data) {
+ for (vector<ModifierAndValue>::const_iterator it = modifiers.begin();
+ it != modifiers.end(); ++it) {
+ string value_string(it->value, it->value_len);
+ if (it->modifier_info->modifier->MightModify(data, value_string)) {
+ return true;
+ }
+ }
+ return false;
+}
+
+// This applies the modifiers to the string in/inlen, and writes the end
+// result directly to the end of outbuf. Precondition: |modifiers| > 0.
+//
+// TODO(user): In the case of multiple modifiers, we are applying
+// all of them if any of them MightModify the output. We can do
+// better. We should store the MightModify values that we use to
+// compute AnyMightModify and respect them here.
+static void EmitModifiedString(const vector<ModifierAndValue>& modifiers,
+ const char* in, size_t inlen,
+ const PerExpandData* data,
+ ExpandEmitter* outbuf) {
+ string result;
+ string value_string;
+ if (modifiers.size() > 1) {
+ // If there's more than one modifiers, we need to store the
+ // intermediate results in a temp-buffer. We use a string.
+ // We'll assume that each modifier adds about 12% to the input
+ // size.
+ result.reserve((inlen + inlen/8) + 16);
+ StringEmitter scratchbuf(&result);
+ value_string = string(modifiers.front().value, modifiers.front().value_len);
+ modifiers.front().modifier_info->modifier->Modify(in, inlen, data,
+ &scratchbuf,
+ value_string);
+ // Only used when modifiers.size() > 2
+ for (vector<ModifierAndValue>::const_iterator it = modifiers.begin() + 1;
+ it != modifiers.end()-1; ++it) {
+ string output_of_this_modifier;
+ output_of_this_modifier.reserve(result.size() + result.size()/8 + 16);
+ StringEmitter scratchbuf2(&output_of_this_modifier);
+ value_string = string(it->value, it->value_len);
+ it->modifier_info->modifier->Modify(result.c_str(), result.size(), data,
+ &scratchbuf2, value_string);
+ result.swap(output_of_this_modifier);
+ }
+ in = result.data();
+ inlen = result.size();
+ }
+ // For the last modifier, we can write directly into outbuf
+ assert(!modifiers.empty());
+ value_string = string(modifiers.back().value, modifiers.back().value_len);
+ modifiers.back().modifier_info->modifier->Modify(in, inlen, data, outbuf,
+ value_string);
+}
+
+static void AppendTokenWithIndent(int level, string *out, const string& before,
+ const TemplateToken& token,
+ const string& after) {
+ out->append(string(level * kIndent, ' '));
+ string token_string(token.text, token.textlen);
+ out->append(before + token_string + after);
+}
+
+// ----------------------------------------------------------------------
+// TemplateNode
+// When we read a template, we decompose it into its components:
+// variables, sections, include-templates, and runs of raw text.
+// Each of these we see becomes one TemplateNode. TemplateNode
+// is the abstract base class; each component has its own type.
+// ----------------------------------------------------------------------
+
+class TemplateNode {
+ public:
+ TemplateNode() {}
+ virtual ~TemplateNode() {}
+
+ // Expands the template node using the supplied dictionary. The
+ // result is placed into output_buffer. If
+ // per_expand_data->annotate() is true, the output is annotated.
+ // Returns true iff all the template files load and parse correctly.
+ virtual bool Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const = 0;
+
+ // Writes entries to a header file to provide syntax checking at
+ // compile time.
+ virtual void WriteHeaderEntries(string *outstring,
+ const string& filename) const = 0;
+
+ // Appends a representation of the node and its subnodes to a string
+ // as a debugging aid.
+ virtual void DumpToString(int level, string *out) const = 0;
+
+ protected:
+ typedef list<TemplateNode *> NodeList;
+
+ private:
+ TemplateNode(const TemplateNode&); // disallow copying
+ void operator=(const TemplateNode&);
+};
+
+// ----------------------------------------------------------------------
+// TextTemplateNode
+// The simplest template-node: it holds runs of raw template text,
+// that should be emitted verbatim. The text points into
+// template_text_.
+// ----------------------------------------------------------------------
+
+class TextTemplateNode : public TemplateNode {
+ public:
+ explicit TextTemplateNode(const TemplateToken& token)
+ : token_(token) {
+ VLOG(2) << "Constructing TextTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+ }
+ virtual ~TextTemplateNode() {
+ VLOG(2) << "Deleting TextTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+ }
+
+ // Expands the text node by simply outputting the text string. This
+ // virtual method does not use TemplateDictionaryInterface or PerExpandData.
+ // Returns true iff all the template files load and parse correctly.
+ virtual bool Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *,
+ PerExpandData *,
+ const TemplateCache *) const {
+ output_buffer->Emit(token_.text, token_.textlen);
+ return true;
+ }
+
+ // A noop for text nodes
+ virtual void WriteHeaderEntries(string *outstring,
+ const string& filename) const {
+ return;
+ }
+
+ // Appends a representation of the text node to a string.
+ virtual void DumpToString(int level, string *out) const {
+ assert(out);
+ AppendTokenWithIndent(level, out, "Text Node: -->|", token_, "|<--\n");
+ }
+
+ private:
+ TemplateToken token_; // The text held by this node.
+};
+
+// ----------------------------------------------------------------------
+// VariableTemplateNode
+// Holds a variable to be replaced when the template is expanded.
+// The variable is stored in a token object, which has a char*
+// that points into template_text_. There may also be modifiers,
+// which are applied at Expand time.
+// ----------------------------------------------------------------------
+
+class VariableTemplateNode : public TemplateNode {
+ public:
+ explicit VariableTemplateNode(const TemplateToken& token)
+ : token_(token),
+ variable_(token_.text, token_.textlen) {
+ VLOG(2) << "Constructing VariableTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+ }
+ virtual ~VariableTemplateNode() {
+ VLOG(2) << "Deleting VariableTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+ }
+
+ // Expands the variable node by outputting the value (if there is one)
+ // of the node variable which is retrieved from the dictionary
+ // Returns true iff all the template files load and parse correctly.
+ virtual bool Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const;
+
+ virtual void WriteHeaderEntries(string *outstring,
+ const string& filename) const {
+ WriteOneHeaderEntry(outstring, string(token_.text, token_.textlen),
+ filename);
+ }
+
+ // Appends a representation of the variable node to a string. We
+ // also append the modifiers for that variable in the form:
+ // :modifier1[=val1][:modifier2][=val2]...\n
+ virtual void DumpToString(int level, string *out) const {
+ assert(out);
+ AppendTokenWithIndent(level, out, "Variable Node: ", token_,
+ PrettyPrintTokenModifiers(token_.modvals) + "\n");
+ }
+
+ private:
+ const TemplateToken token_;
+ const HashedTemplateString variable_;
+};
+
+bool VariableTemplateNode::Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ const TemplateCache *cache) const {
+ if (per_expand_data->annotate()) {
+ per_expand_data->annotator()->EmitOpenVariable(output_buffer,
+ token_.ToString());
+ }
+
+ const TemplateString value = dictionary->GetValue(variable_);
+
+ if (AnyMightModify(token_.modvals, per_expand_data)) {
+ EmitModifiedString(token_.modvals, value.data(), value.size(),
+ per_expand_data, output_buffer);
+ } else {
+ // No need to modify value, so just emit it.
+ output_buffer->Emit(value.data(), value.size());
+ }
+
+ if (per_expand_data->annotate()) {
+ per_expand_data->annotator()->EmitCloseVariable(output_buffer);
+ }
+
+ return true;
+}
+
+// ----------------------------------------------------------------------
+// PragmaTemplateNode
+// It simply stores the text given inside the pragma marker
+// {{%...}} for possible use in DumpToString().
+// ----------------------------------------------------------------------
+
+class PragmaTemplateNode : public TemplateNode {
+ public:
+ explicit PragmaTemplateNode(const TemplateToken& token)
+ : token_(token) {
+ VLOG(2) << "Constructing PragmaTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+ }
+ virtual ~PragmaTemplateNode() {
+ VLOG(2) << "Deleting PragmaTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+ }
+
+ // A no-op for pragma nodes.
+ virtual bool Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *,
+ PerExpandData *,
+ const TemplateCache *) const {
+ return true;
+ };
+
+ // A no-op for pragma nodes.
+ virtual void WriteHeaderEntries(string *outstring,
+ const string& filename) const { }
+
+ // Appends a representation of the pragma node to a string. We output
+ // the full text given in {{%...}} verbatim.
+ virtual void DumpToString(int level, string *out) const {
+ assert(out);
+ AppendTokenWithIndent(level, out, "Pragma Node: -->|", token_, "|<--\n");
+ }
+
+ private:
+ TemplateToken token_; // The text of the pragma held by this node.
+};
+
+// ----------------------------------------------------------------------
+// TemplateTemplateNode
+// Holds a variable to be replaced by an expanded (included)
+// template whose filename is the value of the variable in the
+// dictionary.
+// Also holds the TemplateContext which it passes on to
+// GetTemplateCommon when this included template is initialized.
+// The indentation_ string is used by the PrefixLine modifier so be
+// careful not to perform any operation on it that might invalidate
+// its character array (indentation_.data()).
+//
+// In the Auto Escape mode, the PrefixLine modifier is added *after*
+// auto-escape has updated the modifiers that may be present for that
+// template include, but that is ok because PrefixLine does not invalidate
+// their XSS-safety.
+// ----------------------------------------------------------------------
+
+class TemplateTemplateNode : public TemplateNode {
+ public:
+ explicit TemplateTemplateNode(const TemplateToken& token, Strip strip,
+ const string& indentation)
+ : token_(token),
+ variable_(token_.text, token_.textlen),
+ strip_(strip), indentation_(indentation) {
+ VLOG(2) << "Constructing TemplateTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+
+ // If this template is indented (eg, " {{>SUBTPL}}"), make sure
+ // every line of the expanded template is indented, not just the
+ // first one. We do this by adding a modifier that applies to
+ // the entire template node, that inserts spaces after newlines.
+ if (!indentation_.empty()) {
+ token_.modvals.push_back(ModifierAndValue(&g_prefix_line_info,
+ indentation_.data(),
+ indentation_.length()));
+ }
+ }
+ virtual ~TemplateTemplateNode() {
+ VLOG(2) << "Deleting TemplateTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+ }
+
+ // Expands the template node by retrieving the name of a template
+ // file from the supplied dictionary, expanding it (using this
+ // dictionary if none other is provided in the TemplateDictionary),
+ // and then outputting this newly expanded template in place of the
+ // original variable.
+ // Returns true iff all the template files load and parse correctly.
+ virtual bool Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const;
+
+ virtual void WriteHeaderEntries(string *outstring,
+ const string& filename) const {
+ WriteOneHeaderEntry(outstring, string(token_.text, token_.textlen),
+ filename);
+ }
+
+ virtual void DumpToString(int level, string *out) const {
+ assert(out);
+ AppendTokenWithIndent(level, out, "Template Node: ", token_, "\n");
+ }
+
+ private:
+ TemplateToken token_; // text is the name of a template file.
+ const HashedTemplateString variable_;
+ Strip strip_; // Flag to pass from parent template to included template.
+ const string indentation_; // Used by ModifierAndValue for g_prefix_line.
+
+ // A helper used for expanding one child dictionary.
+ bool ExpandOnce(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface &dictionary,
+ const char* const filename,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const;
+};
+
+// If no value is found in the dictionary for the template variable
+// in this node, then no output is generated in place of this variable.
+bool TemplateTemplateNode::Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const {
+ if (dictionary->IsHiddenTemplate(variable_)) {
+ // if this "template include" section is "hidden", do nothing
+ return true;
+ }
+
+ TemplateDictionaryInterface::Iterator* di =
+ dictionary->CreateTemplateIterator(variable_);
+
+ if (!di->HasNext()) { // empty dict means 'expand once using containing dict'
+ delete di;
+ // TODO(csilvers): have this return a TemplateString instead?
+ const char* const filename =
+ dictionary->GetIncludeTemplateName(variable_, 0);
+ // If the filename wasn't set then treat it as if it were "hidden", i.e, do
+ // nothing
+ if (filename && *filename) {
+ return ExpandOnce(output_buffer, *dictionary, filename, per_expand_data,
+ cache);
+ } else {
+ return true;
+ }
+ }
+
+ bool error_free = true;
+ for (int dict_num = 0; di->HasNext(); ++dict_num) {
+ const TemplateDictionaryInterface& child = di->Next();
+ // We do this in the loop, because maybe one day we'll support
+ // each expansion having its own template dictionary. That's also
+ // why we pass in the dictionary-index as an argument.
+ const char* const filename = dictionary->GetIncludeTemplateName(
+ variable_, dict_num);
+ // If the filename wasn't set then treat it as if it were "hidden", i.e, do
+ // nothing
+ if (filename && *filename) {
+ error_free &= ExpandOnce(output_buffer, child, filename, per_expand_data,
+ cache);
+ }
+ }
+ delete di;
+
+ return error_free;
+}
+
+static void EmitMissingInclude(const char* const filename,
+ ExpandEmitter *output_buffer,
+ PerExpandData *per_expand_data) {
+ // if there was a problem retrieving the template, bail!
+ if (per_expand_data->annotate()) {
+ TemplateAnnotator* annotator = per_expand_data->annotator();
+ annotator->EmitFileIsMissing(output_buffer, filename);
+ }
+ LOG(ERROR) << "Failed to load included template: \"" << filename << "\"\n";
+}
+
+bool TemplateTemplateNode::ExpandOnce(
+ ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface &dictionary,
+ const char* const filename,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const {
+ bool error_free = true;
+ // NOTE: Although we do this const_cast here, if the cache is frozen
+ // the expansion doesn't mutate the cache, and is effectively 'const'.
+ TemplateCache* cache_ptr = const_cast<TemplateCache*>(cache);
+
+ // Expand the included template once for each "template specific"
+ // dictionary. Normally this will only iterate once, but it's
+ // possible to supply a list of more than one sub-dictionary and
+ // then the template explansion will be iterative, just as though
+ // the included template were an iterated section.
+ if (per_expand_data->annotate()) {
+ per_expand_data->annotator()->EmitOpenInclude(output_buffer,
+ token_.ToString());
+ }
+ // sub-dictionary NULL means 'just use the current dictionary instead'.
+ // We force children to annotate the output if we have to.
+ // If the include-template has modifiers, we need to expand to a string,
+ // modify the string, and append to output_buffer. Otherwise (common
+ // case), we can just expand into the output-buffer directly.
+ if (AnyMightModify(token_.modvals, per_expand_data)) {
+ string sub_template;
+ StringEmitter subtemplate_buffer(&sub_template);
+ if (!cache_ptr->ExpandLocked(filename, strip_,
+ &subtemplate_buffer,
+ &dictionary,
+ per_expand_data)) {
+ EmitMissingInclude(filename, output_buffer, per_expand_data);
+ error_free = false;
+ } else {
+ EmitModifiedString(token_.modvals,
+ sub_template.data(), sub_template.size(),
+ per_expand_data, output_buffer);
+ }
+ } else {
+ // No need to modify sub-template
+ if (!cache_ptr->ExpandLocked(filename, strip_,
+ output_buffer,
+ &dictionary,
+ per_expand_data)) {
+ EmitMissingInclude(filename, output_buffer, per_expand_data);
+ error_free = false;
+ }
+ }
+ if (per_expand_data->annotate()) {
+ per_expand_data->annotator()->EmitCloseInclude(output_buffer);
+ }
+ return error_free;
+}
+
+// ----------------------------------------------------------------------
+// SectionTemplateNode
+// Holds the name of a section and a list of subnodes contained
+// in that section.
+// ----------------------------------------------------------------------
+
+class SectionTemplateNode : public TemplateNode {
+ public:
+ SectionTemplateNode(const TemplateToken& token, bool hidden_by_default);
+ virtual ~SectionTemplateNode();
+
+ // The highest level parsing method. Reads a single token from the
+ // input -- taken from my_template->parse_state_ -- and adds the
+ // corresponding type of node to the template's parse
+ // tree. It may add a node of any type, whether text, variable,
+ // section, or template to the list of nodes contained in this
+ // section. Returns true iff we really added a node and didn't just
+ // end a section or hit a syntax error in the template file.
+ // You should hold the g_template_mutex write-lock when calling this
+ // (unless you're calling it from a constructor).
+ bool AddSubnode(Template *my_template);
+
+ // Expands a section node as follows:
+ // - Checks to see if the section is hidden and if so, does nothing but
+ // return
+ // - Tries to retrieve a list of dictionaries from the supplied dictionary
+ // stored under this section's name
+ // - If it finds a non-empty list of dictionaries, it iterates over the
+ // list and calls itself recursively to expand the section once for
+ // each dictionary
+ // - If there is no dictionary list (or an empty dictionary list somehow)
+ // is found, then the section is expanded once using the supplied
+ // dictionary. (This is the mechanism used to expand each single
+ // iteration of the section as well as to show a non-hidden section,
+ // allowing the section template syntax to be used for both conditional
+ // and iterative text).
+ // Returns true iff all the template files load and parse correctly.
+ virtual bool Expand(ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ const TemplateCache *cache) const;
+
+ // Writes a header entry for the section name and calls the same
+ // method on all the nodes in the section
+ virtual void WriteHeaderEntries(string *outstring,
+ const string& filename) const;
+
+ virtual void DumpToString(int level, string *out) const;
+
+ private:
+ const TemplateToken token_; // text is the name of the section
+ const HashedTemplateString variable_;
+ NodeList node_list_; // The list of subnodes in the section
+ // A sub-section named "OURNAME_separator" is special. If we see it
+ // when parsing our section, store a pointer to it for ease of use.
+ SectionTemplateNode* separator_section_;
+
+ // When the last node read was literal text that ends with "\n? +"
+ // (that is, leading whitespace on a line), this stores the leading
+ // whitespace. This is used to properly indent included
+ // sub-templates.
+ string indentation_;
+
+ // If true, hide sections that have not explicitly had their hidden/visible
+ // state set. If false, use the underlying template dictionary's default
+ // behavior for hiding.
+ // This bool is currently always set to true.
+ bool hidden_by_default_;
+
+ // A protected method used in parsing the template file
+ // Finds the next token in the file and return it. Anything not inside
+ // a template marker is just text. Each template marker type, delimited
+ // by "{{" and "}}" (or parser_state_->marker_delimiters.start_marker
+ // and .end_marker, more precisely) is a different type of token. The
+ // first character inside the opening curly braces indicates the type
+ // of the marker, as follows:
+ // # - Start a section
+ // / - End a section
+ // > - A template file variable (the "include" directive)
+ // ! - A template comment
+ // % - A pragma such as AUTOESCAPE
+ // = - Change marker delimiters (from the default of '{{' and '}}')
+ // <alnum or _> - A scalar variable
+ // One more thing. Before a name token is returned, if it happens to be
+ // any type other than a scalar variable, and if the next character after
+ // the closing curly braces is a newline, then the newline is eliminated
+ // from the output. This reduces the number of extraneous blank
+ // lines in the output. If the template author desires a newline to be
+ // retained after a final marker on a line, they must add a space character
+ // between the marker and the linefeed character.
+ TemplateToken GetNextToken(Template* my_template);
+
+ // Helper routine used by Expand
+ virtual bool ExpandOnce(
+ ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ bool is_last_child_dict,
+ const TemplateCache *cache) const;
+
+ // The specific methods called used by AddSubnode to add the
+ // different types of nodes to this section node.
+ // Currently only reasons to fail (return false) are if the
+ // HTML parser failed to parse in auto-escape mode or the
+ // PRAGMA marker was invalid in the template.
+ bool AddTextNode(const TemplateToken* token, Template* my_template);
+ bool AddVariableNode(TemplateToken* token, Template* my_template);
+ bool AddPragmaNode(TemplateToken* token, Template* my_template);
+ bool AddTemplateNode(TemplateToken* token, Template* my_template,
+ const string& indentation);
+ bool AddSectionNode(const TemplateToken* token, Template* my_template,
+ bool hidden_by_default);
+ bool AddSectionNode(const TemplateToken* token, Template* my_template);
+};
+
+// --- constructor and destructor, Expand, Dump, and WriteHeaderEntries
+
+SectionTemplateNode::SectionTemplateNode(const TemplateToken& token,
+ bool hidden_by_default)
+
+ : token_(token),
+ variable_(token_.text, token_.textlen),
+ separator_section_(NULL), indentation_("\n"),
+ hidden_by_default_(hidden_by_default) {
+ VLOG(2) << "Constructing SectionTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+}
+
+SectionTemplateNode::~SectionTemplateNode() {
+ VLOG(2) << "Deleting SectionTemplateNode: "
+ << string(token_.text, token_.textlen) << " and its subnodes"
+ << endl;
+
+ // Need to delete the member of the list because the list is a list
+ // of pointers to these instances.
+ NodeList::iterator iter = node_list_.begin();
+ for (; iter != node_list_.end(); ++iter) {
+ delete (*iter);
+ }
+ VLOG(2) << "Finished deleting subnodes of SectionTemplateNode: "
+ << string(token_.text, token_.textlen) << endl;
+}
+
+bool SectionTemplateNode::ExpandOnce(
+ ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData *per_expand_data,
+ bool is_last_child_dict,
+ const TemplateCache* cache) const {
+ bool error_free = true;
+
+ if (per_expand_data->annotate()) {
+ per_expand_data->annotator()->EmitOpenSection(output_buffer,
+ token_.ToString());
+ }
+
+ // Expand using the section-specific dictionary.
+ // We force children to annotate the output if we have to.
+ NodeList::const_iterator iter = node_list_.begin();
+ for (; iter != node_list_.end(); ++iter) {
+ error_free &=
+ (*iter)->Expand(output_buffer, dictionary, per_expand_data, cache);
+ // If this sub-node is a "separator section" -- a subsection
+ // with the name "OURNAME_separator" -- expand it every time
+ // through but the last.
+ if (*iter == separator_section_ && !is_last_child_dict) {
+ // We call ExpandOnce to make sure we always expand,
+ // even if *iter would normally be hidden.
+ error_free &= separator_section_->ExpandOnce(output_buffer, dictionary,
+ per_expand_data, true,
+ cache);
+ }
+ }
+
+ if (per_expand_data->annotate()) {
+ per_expand_data->annotator()->EmitCloseSection(output_buffer);
+ }
+
+ return error_free;
+}
+
+bool SectionTemplateNode::Expand(
+ ExpandEmitter *output_buffer,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const {
+ // The section named __{{MAIN}}__ is special: you always expand it
+ // exactly once using the containing (main) dictionary.
+ if (token_.text == kMainSectionName) {
+ return ExpandOnce(output_buffer, dictionary, per_expand_data, true, cache);
+ } else if (hidden_by_default_ ?
+ !dictionary->IsUnhiddenSection(variable_) :
+ dictionary->IsHiddenSection(variable_)) {
+ // Some dictionaries might have sections that can be explicitly hidden
+ // and unhidden, so by default both IsHidden() and IsUnhidden() are false,
+ // in which case hidden_by_default_ controls the behavior.
+ return true; // if this section is "hidden", do nothing
+ }
+
+ TemplateDictionaryInterface::Iterator* di =
+ dictionary->CreateSectionIterator(variable_);
+
+ // If there are no child dictionaries, that means we should expand with the
+ // current dictionary instead. This corresponds to the situation where
+ // template variables within a section are set on the template-wide dictionary
+ // instead of adding a dictionary to the section and setting them there.
+ if (!di->HasNext()) {
+ delete di;
+ return ExpandOnce(output_buffer, dictionary, per_expand_data,
+ true, cache);
+ }
+
+ // Otherwise, there's at least one child dictionary, and when expanding this
+ // section, we should use the child dictionaries instead of the current one.
+ bool error_free = true;
+ while (di->HasNext()) {
+ const TemplateDictionaryInterface& child = di->Next();
+ error_free &= ExpandOnce(output_buffer, &child, per_expand_data,
+ !di->HasNext(), cache);
+ }
+ delete di;
+ return error_free;
+}
+
+void SectionTemplateNode::WriteHeaderEntries(string *outstring,
+ const string& filename) const {
+ WriteOneHeaderEntry(outstring, string(token_.text, token_.textlen),
+ filename);
+
+ NodeList::const_iterator iter = node_list_.begin();
+ for (; iter != node_list_.end(); ++iter) {
+ (*iter)->WriteHeaderEntries(outstring, filename);
+ }
+}
+
+void SectionTemplateNode::DumpToString(int level, string *out) const {
+ assert(out);
+ AppendTokenWithIndent(level, out, "Section Start: ", token_, "\n");
+ NodeList::const_iterator iter = node_list_.begin();
+ for (; iter != node_list_.end(); ++iter) {
+ (*iter)->DumpToString(level + 1, out);
+ }
+ AppendTokenWithIndent(level, out, "Section End: ", token_, "\n");
+}
+
+// --- AddSubnode and its sub-routines
+
+// Under auto-escape (and parsing-enabled modes) advance the parser state.
+// TextTemplateNode is the only TemplateNode type that can change
+// the state of the parser.
+// Returns false only if the HTML parser failed to parse in
+// auto-escape mode.
+bool SectionTemplateNode::AddTextNode(const TemplateToken* token,
+ Template* my_template) {
+ assert(token);
+ bool success = true;
+ HtmlParser *htmlparser = my_template->htmlparser_;
+
+ if (token->textlen > 0) { // ignore null text sections
+ node_list_.push_back(new TextTemplateNode(*token));
+ if (AUTO_ESCAPE_PARSING_CONTEXT(my_template->initial_context_)) {
+ assert(htmlparser);
+ if (htmlparser->state() == HtmlParser::STATE_ERROR ||
+ htmlparser->Parse(token->text, static_cast<int>(token->textlen)) ==
+ HtmlParser::STATE_ERROR) {
+ string error_msg = "Failed parsing: " +
+ string(token->text, token->textlen) +
+ "\nIn: " + string(token_.text, token_.textlen);
+ LOG_AUTO_ESCAPE_ERROR(error_msg, my_template);
+ success = false;
+ }
+ }
+ }
+ return success;
+}
+
+// In Auto Escape mode, we update the variable modifiers based on what
+// modifiers are specified in the template and what Auto-Escape computes
+// for that context. Returns false only if the HTML parser failed to parse
+// in auto-escape mode.
+//
+// We also have special logic for BI_SPACE and BI_NEWLINE.
+// Even though they look like variables, they're really not: the user
+// is expected to use them in situations where they'd normally put
+// a space character or a newline character, but can't for technical
+// reasons (namely, that the template parser would strip these
+// characters because of the STRIP mode it's in). So unlike other
+// variables, we want to treat these variables as literal text. This
+// means that we never add modifiers to them, but we do let the
+// htmlparser know about them in order to update its state. Existing
+// modifiers will be honored.
+//
+// Finally, we check if the variable is whitelisted, in which case
+// Auto-Escape does not apply escaping to it. See comment for global
+// array kSafeWhitelistedVariables[].
+bool SectionTemplateNode::AddVariableNode(TemplateToken* token,
+ Template* my_template) {
+ assert(token);
+ bool success = true;
+ HtmlParser *htmlparser = my_template->htmlparser_;
+ TemplateContext initial_context = my_template->initial_context_;
+
+ if (AUTO_ESCAPE_MODE(initial_context)) {
+ // Determines modifiers for the variable in auto escape mode.
+ string variable_name(token->text, token->textlen);
+ // We declare in the documentation that if the user changes the
+ // value of these variables, they must only change it to a value
+ // that's "equivalent" from the point of view of an html parser.
+ // So it's ok to hard-code in that these are " " and "\n",
+ // respectively, even though in theory the user could change them
+ // (to say, BI_NEWLINE == "\r\n").
+ if (variable_name == "BI_SPACE" || variable_name == "BI_NEWLINE") {
+ if (AUTO_ESCAPE_PARSING_CONTEXT(initial_context)) {
+ assert(htmlparser);
+ if (htmlparser->state() == HtmlParser::STATE_ERROR ||
+ htmlparser->Parse(variable_name == "BI_SPACE" ? " " : "\n") ==
+ HtmlParser::STATE_ERROR)
+ success = false;
+ }
+ } else if (binary_search(Template::kSafeWhitelistedVariables,
+ Template::kSafeWhitelistedVariables +
+ arraysize(Template::kSafeWhitelistedVariables),
+ variable_name.c_str(),
+ // Luckily, StringHash(a, b) is defined as "a < b"
+ StringHash())) {
+ // Do not escape the variable, it is whitelisted.
+ } else {
+ vector<const ModifierAndValue*> modvals =
+ GetModifierForContext(initial_context, htmlparser, my_template);
+ // There should always be at least one modifier in any Auto-Escape mode.
+ if (modvals.empty())
+ success = false;
+ else
+ token->UpdateModifier(modvals);
+ }
+ }
+ node_list_.push_back(new VariableTemplateNode(*token));
+ return success;
+}
+
+// AddPragmaNode
+// Create a pragma node from the given token and add it
+// to the node list.
+// The AUTOESCAPE pragma is only allowed at the top of a template
+// file (above any non-comment node) to minimize the chance of the
+// HTML parser being out of sync with the template text. So we check
+// that the section is the MAIN section and we are the first node.
+// Note: Since currently we only support one pragma, we apply the check
+// always but when other pragmas are added we'll need to propagate the
+// Pragma identifier from GetNextToken().
+bool SectionTemplateNode::AddPragmaNode(TemplateToken* token,
+ Template* my_template) {
+ if (token_.text != kMainSectionName || !node_list_.empty())
+ return false;
+
+ node_list_.push_back(new PragmaTemplateNode(*token));
+ return true;
+}
+
+// AddSectionNode
+bool SectionTemplateNode::AddSectionNode(const TemplateToken* token,
+ Template* my_template,
+ bool hidden_by_default) {
+ assert(token);
+ SectionTemplateNode *new_node = new SectionTemplateNode(*token,
+ hidden_by_default);
+
+ // Not only create a new section node, but fill it with all *its*
+ // subnodes by repeatedly calling AddSubNode until it returns false
+ // (indicating either the end of the section or a syntax error)
+ while (new_node->AddSubnode(my_template)) {
+ // Found a new subnode to add
+ }
+ node_list_.push_back(new_node);
+ // Check the name of new_node. If it's "OURNAME_separator", store it
+ // as a special "separator" section.
+ if (token->textlen == token_.textlen + sizeof("_separator")-1 &&
+ memcmp(token->text, token_.text, token_.textlen) == 0 &&
+ memcmp(token->text + token_.textlen, "_separator", sizeof("_separator")-1)
+ == 0)
+ separator_section_ = new_node;
+ return true;
+}
+
+// Note: indentation will be used in constructor of TemplateTemplateNode.
+// Note on Auto-Escape: Each template is Auto-Escaped independently of
+// the template it may be included from or templates it may include.
+// The context does not carry on and hence does not need to be provided
+// to the new TemplateNode.
+bool SectionTemplateNode::AddTemplateNode(TemplateToken* token,
+ Template* my_template,
+ const string& indentation) {
+ assert(token);
+ bool success = true;
+ node_list_.push_back(
+ new TemplateTemplateNode(*token, my_template->strip_, indentation));
+ return success;
+}
+
+// If "text" ends with a newline followed by whitspace, returns a
+// string holding that whitespace. Otherwise, returns the empty
+// string. If implicit_newline is true, also consider the text to be
+// an indentation if it consists entirely of whitespace; this is set
+// when we know that right before this text there was a newline, or
+// this text is the beginning of a document.
+static string GetIndentation(const char* text, size_t textlen,
+ bool implicit_newline) {
+ const char* nextline; // points to one char past the last newline
+ for (nextline = text + textlen; nextline > text; --nextline)
+ if (nextline[-1] == '\n') break;
+ if (nextline == text && !implicit_newline)
+ return ""; // no newline found, so no indentation
+
+ bool prefix_is_whitespace = true;
+ for (const char* p = nextline; p < text + textlen; ++p) {
+ if (*p != ' ' && *p != '\t') {
+ prefix_is_whitespace = false;
+ break;
+ }
+ }
+ if (prefix_is_whitespace && text + textlen > nextline)
+ return string(nextline, text + textlen - nextline);
+ else
+ return "";
+}
+
+bool SectionTemplateNode::AddSubnode(Template *my_template) {
+ bool auto_escape_success = true;
+ // Don't proceed if we already found an error
+ if (my_template->state() == TS_ERROR) {
+ return false;
+ }
+
+ // Stop when the buffer is empty.
+ if (my_template->parse_state_.bufstart >= my_template->parse_state_.bufend) {
+ // running out of file contents ends the section too
+ if (token_.text != kMainSectionName) {
+ // if we are not in the main section, we have a syntax error in the file
+ LOG_TEMPLATE_NAME(ERROR, my_template);
+ LOG(ERROR) << "File ended before all sections were closed" << endl;
+ my_template->set_state(TS_ERROR);
+ }
+ return false;
+ }
+
+ TemplateToken token = GetNextToken(my_template);
+
+ switch (token.type) {
+ case TOKENTYPE_TEXT:
+ auto_escape_success = this->AddTextNode(&token, my_template);
+ // Store the indentation (trailing whitespace after a newline), if any.
+ this->indentation_ = GetIndentation(token.text, token.textlen,
+ indentation_ == "\n");
+ break;
+ case TOKENTYPE_VARIABLE:
+ auto_escape_success = this->AddVariableNode(&token, my_template);
+ this->indentation_.clear(); // clear whenever last read wasn't whitespace
+ break;
+ case TOKENTYPE_SECTION_START:
+ auto_escape_success = this->AddSectionNode(&token, my_template, false);
+ this->indentation_.clear(); // clear whenever last read wasn't whitespace
+ break;
+ case TOKENTYPE_HIDDEN_DEFAULT_SECTION:
+ auto_escape_success = this->AddSectionNode(&token, my_template, true);
+ this->indentation_.clear(); // clear whenever last read wasn't whitespace
+ break;
+ case TOKENTYPE_SECTION_END:
+ // Don't add a node. Just make sure we are ending the right section
+ // and return false to indicate the section is complete
+ if (token.textlen != token_.textlen ||
+ memcmp(token.text, token_.text, token.textlen)) {
+ LOG_TEMPLATE_NAME(ERROR, my_template);
+ LOG(ERROR) << "Found end of different section than the one I am in"
+ << "\nFound: " << string(token.text, token.textlen)
+ << "\nIn: " << string(token_.text, token_.textlen) << endl;
+ my_template->set_state(TS_ERROR);
+ }
+ this->indentation_.clear(); // clear whenever last read wasn't whitespace
+ return false;
+ break;
+ case TOKENTYPE_TEMPLATE:
+ auto_escape_success = this->AddTemplateNode(&token, my_template,
+ this->indentation_);
+ this->indentation_.clear(); // clear whenever last read wasn't whitespace
+ break;
+ case TOKENTYPE_COMMENT:
+ // Do nothing. Comments just drop out of the file altogether.
+ break;
+ case TOKENTYPE_SET_DELIMITERS:
+ if (!Template::ParseDelimiters(
+ token.text, token.textlen,
+ &my_template->parse_state_.current_delimiters)) {
+ LOG_TEMPLATE_NAME(ERROR, my_template);
+ LOG(ERROR) << "Invalid delimiter-setting command."
+ << "\nFound: " << string(token.text, token.textlen)
+ << "\nIn: " << string(token_.text, token_.textlen) << endl;
+ my_template->set_state(TS_ERROR);
+ }
+ break;
+ case TOKENTYPE_PRAGMA:
+ // We can do nothing and simply drop the pragma of the file as is done
+ // for comments. But, there is value in keeping it for debug purposes
+ // (via DumpToString) so add it as a pragma node.
+ if (!this->AddPragmaNode(&token, my_template)) {
+ LOG_TEMPLATE_NAME(ERROR, my_template);
+ LOG(ERROR) << "Pragma marker must be at the top of the template: '"
+ << string(token.text, token.textlen) << "'" << endl;
+ my_template->set_state(TS_ERROR);
+ }
+ break;
+ case TOKENTYPE_NULL:
+ // GetNextToken either hit the end of the file or a syntax error
+ // in the file. Do nothing more here. Just return false to stop
+ // processing.
+ return false;
+ break;
+ default:
+ // This shouldn't happen. If it does, it's a programmer error.
+ LOG_TEMPLATE_NAME(ERROR, my_template);
+ LOG(ERROR) << "Invalid token type returned from GetNextToken" << endl;
+ }
+
+ if (!auto_escape_success) {
+ // The error is logged where it happens. Here indicate
+ // the initialization failed.
+ my_template->set_state(TS_ERROR);
+ return false;
+ }
+
+ // for all the cases where we did not return false
+ return true;
+}
+
+// --- GetNextToken and its subroutines
+
+// A valid marker name is made up of alphanumerics and underscores...
+// nothing else.
+static bool IsValidName(const char* name, int namelen) {
+ for (const char *cur_char = name; cur_char - name < namelen; ++cur_char) {
+ if (!ascii_isalnum(*cur_char) && *cur_char != '_')
+ return false;
+ }
+ return true;
+}
+
+// If we're pointing to the end of a line, and in a high enough strip mode,
+// pass over the newline. If the line ends in a \, we skip over the \ and
+// keep the newline. Returns a pointer to the new 'start' location, which
+// is either 'start' or after a newline.
+static const char* MaybeEatNewline(const char* start, const char* end,
+ Strip strip) {
+ // first, see if we have the escaped linefeed sequence
+ if (end - start >= 2 && start[0] == '\\' && start[1] == '\n') {
+ ++start; // skip over the \, which keeps the \n
+ } else if (end - start >= 1 && start[0] == '\n' &&
+ strip >= STRIP_WHITESPACE) {
+ ++start; // skip over the \n in high strip_ modes
+ }
+ return start;
+}
+
+// When the parse fails, we take several actions. msg is a stream
+#define FAIL(msg) do { \
+ LOG_TEMPLATE_NAME(ERROR, my_template); \
+ LOG(ERROR) << msg << endl; \
+ my_template->set_state(TS_ERROR); \
+ /* make extra-sure we never try to parse anything more */ \
+ my_template->parse_state_.bufstart = my_template->parse_state_.bufend; \
+ return TemplateToken(TOKENTYPE_NULL, "", 0, NULL); \
+ } while (0)
+
+// Parses the text of the template file in the input_buffer as
+// follows: If the buffer is empty, return the null token. If getting
+// text, search for the next "{{" sequence (more precisely, for
+// parse_state_->marker_delimiters.start_marker). If one is found,
+// return all the text collected up to that sequence in a TextToken
+// and change the token-parsing phase variable to GETTING_NAME, so the
+// next call will know to look for a named marker, instead of more
+// text. If getting a name, read the next character to learn what
+// kind of marker it is. Then collect the characters of the name up
+// to the "}}" sequence. If the "name" is a template comment, then we
+// do not return the text of the comment in the token. If it is any
+// other valid type of name, we return the token with the appropriate
+// type and the name. If any syntax errors are discovered (like
+// inappropriate characters in a name, not finding the closing curly
+// braces, etc.) an error message is logged, the error state of the
+// template is set, and a NULL token is returned. Updates
+// parse_state_. You should hold the g_template_mutex write-lock
+// when calling this (unless you're calling it from a constructor).
+TemplateToken SectionTemplateNode::GetNextToken(Template *my_template) {
+ Template::ParseState* ps = &my_template->parse_state_; // short abbrev.
+ const char* token_start = ps->bufstart;
+
+ if (ps->bufstart >= ps->bufend) { // at end of buffer
+ return TemplateToken(TOKENTYPE_NULL, "", 0, NULL);
+ }
+
+ switch (ps->phase) {
+ case Template::ParseState::GETTING_TEXT: {
+ const char* token_end = memmatch(ps->bufstart, ps->bufend - ps->bufstart,
+ ps->current_delimiters.start_marker,
+ ps->current_delimiters.start_marker_len);
+ if (!token_end) {
+ // Didn't find the start-marker ('{{'), so just grab all the
+ // rest of the buffer.
+ token_end = ps->bufend;
+ ps->bufstart = ps->bufend; // next token will start at EOF
+ } else {
+ // If we see code like this: "{{{VAR}}, we want to match the
+ // second "{{", not the first.
+ while ((token_end + 1 + ps->current_delimiters.start_marker_len
+ <= ps->bufend) &&
+ memcmp(token_end + 1, ps->current_delimiters.start_marker,
+ ps->current_delimiters.start_marker_len) == 0)
+ token_end++;
+ ps->phase = Template::ParseState::GETTING_NAME;
+ ps->bufstart = token_end + ps->current_delimiters.start_marker_len;
+ }
+ return TemplateToken(TOKENTYPE_TEXT, token_start,
+ token_end - token_start, NULL);
+ }
+
+ case Template::ParseState::GETTING_NAME: {
+ TemplateTokenType ttype;
+ const char* token_end = NULL;
+ // Find out what type of name we are getting
+ switch (token_start[0]) {
+ case '#':
+ ttype = TOKENTYPE_SECTION_START;
+ ++token_start;
+ break;
+ case '/':
+ ttype = TOKENTYPE_SECTION_END;
+ ++token_start;
+ break;
+ case '!':
+ ttype = TOKENTYPE_COMMENT;
+ ++token_start;
+ break;
+ case '=':
+ ttype = TOKENTYPE_SET_DELIMITERS;
+ // Keep token_start the same; the token includes the leading '='.
+ // But we have to figure token-end specially: it should be "=}}".
+ if (ps->bufend > (token_start + 1))
+ token_end = (char*)memchr(token_start + 1, '=',
+ ps->bufend - (token_start + 1));
+ if (!token_end ||
+ token_end + ps->current_delimiters.end_marker_len > ps->bufend ||
+ memcmp(token_end + 1, ps->current_delimiters.end_marker,
+ ps->current_delimiters.end_marker_len) != 0)
+ token_end = NULL; // didn't find it, fall through to code below
+ else
+ token_end++; // advance past the "=" to the "}}".
+ break;
+ case '>':
+ ttype = TOKENTYPE_TEMPLATE;
+ ++token_start;
+ break;
+ case '%':
+ ttype = TOKENTYPE_PRAGMA;
+ ++token_start;
+ break;
+ default:
+ // the assumption that the next char is alnum or _ will be
+ // tested below in the call to IsValidName().
+ ttype = TOKENTYPE_VARIABLE;
+ }
+
+ // Now get the name (or the comment, as the case may be)
+ if (!token_end) // that is, it wasn't set in special-case code above
+ token_end = memmatch(token_start, ps->bufend - token_start,
+ ps->current_delimiters.end_marker,
+ ps->current_delimiters.end_marker_len);
+ if (!token_end) { // Didn't find the '}}', so name never ended. Error!
+ FAIL("No ending '" << string(ps->current_delimiters.end_marker,
+ ps->current_delimiters.end_marker_len)
+ << "' when parsing name starting with "
+ << "'" << string(token_start, ps->bufend-token_start) << "'");
+ }
+
+ if (ttype == TOKENTYPE_PRAGMA) {
+ string error_msg;
+ const PragmaMarker pragma(token_start, token_end, &error_msg);
+ if (!error_msg.empty())
+ FAIL(error_msg);
+ TemplateContext context = GetTemplateContextFromPragma(pragma);
+ if (context == TC_MANUAL) // TC_MANUAL is used to indicate error.
+ FAIL("Invalid context in Pragma directive.");
+ const string* parser_state = pragma.GetAttributeValue("state");
+ bool in_tag = false;
+ if (parser_state != NULL) {
+ if (context == TC_HTML && (*parser_state == "IN_TAG" ||
+ *parser_state == "in_tag"))
+ in_tag = true;
+ else if (*parser_state != "default")
+ FAIL("Unsupported state '" + *parser_state +
+ "'in Pragma directive.");
+ }
+ // Only an AUTOESCAPE pragma can change the initial_context
+ // away from TC_MANUAL and we do not support multiple such pragmas.
+ assert(my_template->initial_context_ == TC_MANUAL);
+ my_template->initial_context_ = context;
+ my_template->MaybeInitHtmlParser(in_tag);
+ // ParseState change will happen below.
+ }
+
+ // Comments are a special case, since they don't have a name or action.
+ // The set-delimiters command is the same way.
+ if (ttype == TOKENTYPE_COMMENT || ttype == TOKENTYPE_SET_DELIMITERS ||
+ ttype == TOKENTYPE_PRAGMA) {
+ ps->phase = Template::ParseState::GETTING_TEXT;
+ ps->bufstart = token_end + ps->current_delimiters.end_marker_len;
+ // If requested, remove any unescaped linefeed following a comment
+ ps->bufstart = MaybeEatNewline(ps->bufstart, ps->bufend,
+ my_template->strip_);
+ // For comments, don't bother returning the text
+ if (ttype == TOKENTYPE_COMMENT)
+ token_start = token_end;
+ return TemplateToken(ttype, token_start, token_end - token_start, NULL);
+ }
+
+ // Now we have the name, possibly with following modifiers.
+ // Find the modifier-start.
+ const char* mod_start = (const char*)memchr(token_start, ':',
+ token_end - token_start);
+ if (mod_start == NULL)
+ mod_start = token_end;
+
+ // Make sure the name is legal.
+ if (!IsValidName(token_start, mod_start - token_start)) {
+ FAIL("Illegal name in template '"
+ << string(token_start, mod_start-token_start) << "'");
+ }
+
+ // Figure out what all the modifiers are. Mods are colon-separated.
+ vector<ModifierAndValue> modifiers;
+ const char* mod_end;
+ for (const char* mod = mod_start; mod < token_end; mod = mod_end) {
+ assert(*mod == ':');
+ ++mod; // skip past the starting colon
+ mod_end = (const char*)memchr(mod, ':', token_end - mod);
+ if (mod_end == NULL)
+ mod_end = token_end;
+ // Modifiers can be of the form :modname=value. Extract out value
+ const char* value = (const char*)memchr(mod, '=', mod_end - mod);
+ if (value == NULL)
+ value = mod_end;
+ string value_string(value, mod_end - value);
+ // Convert the string to a functor, and error out if we can't.
+ const ModifierInfo* modstruct = FindModifier(mod, value - mod,
+ value, mod_end - value);
+ // There are various ways a modifier syntax can be illegal.
+ if (modstruct == NULL) {
+ FAIL("Unknown modifier for variable "
+ << string(token_start, mod_start - token_start) << ": "
+ << "'" << string(mod, value - mod) << "'");
+ } else if (!modstruct->modval_required && value < mod_end) {
+ FAIL("Modifier for variable "
+ << string(token_start, mod_start - token_start) << ":"
+ << string(mod, value - mod) << " "
+ << "has illegal mod-value '" << value_string << "'");
+ } else if (modstruct->modval_required && value == mod_end) {
+ FAIL("Modifier for variable "
+ << string(token_start, mod_start - token_start) << ":"
+ << string(mod, value - mod) << " "
+ << "is missing a required mod-value");
+ }
+
+ // We rely on the fact that the memory pointed to by 'value'
+ // remains valid throughout the life of this token since
+ // ModifierAndValue does not itself manage its memory.
+ modifiers.push_back(
+ ModifierAndValue(modstruct, value, mod_end - value));
+ }
+
+ // For now, we only allow variable and include nodes to have
+ // modifiers. I think it's better not to have this for
+ // sections, but instead to modify all the text and vars in the
+ // section appropriately, but I could be convinced otherwise.
+ if (!modifiers.empty() &&
+ ttype != TOKENTYPE_VARIABLE && ttype != TOKENTYPE_TEMPLATE) {
+ FAIL(string(token_start, token_end - token_start)
+ << "malformed: only variables and template-includes "
+ << "are allowed to have modifiers");
+ }
+
+ // Whew! We passed the gauntlet. Get ready for the next token
+ ps->phase = Template::ParseState::GETTING_TEXT;
+ ps->bufstart = token_end + ps->current_delimiters.end_marker_len;
+ // If requested, remove any linefeed following a comment,
+ // or section start or end, or template marker, unless
+ // it is escaped by '\'
+ if (ttype != TOKENTYPE_VARIABLE) {
+ ps->bufstart = MaybeEatNewline(ps->bufstart, ps->bufend,
+ my_template->strip_);
+ }
+
+ // create and return the TEXT token that we found
+ return TemplateToken(ttype, token_start, mod_start - token_start,
+ &modifiers);
+ }
+
+ default: {
+ FAIL("Programming error: Unexpected parse phase while "
+ << "parsing template: " << ps->phase);
+ }
+ }
+}
+
+// ----------------------------------------------------------------------
+// CreateTemplateCache()
+// default_template_cache()
+// mutable_default_template_cache()
+// These create the default TemplateCache object, that Template
+// often just delegates (deprecated) operations to.
+// ----------------------------------------------------------------------
+
+static TemplateCache* g_default_template_cache = NULL;
+GoogleOnceType g_default_cache_init_once = GOOGLE_ONCE_INIT;
+
+static void CreateTemplateCache() {
+ g_default_template_cache = new TemplateCache();
+}
+
+const TemplateCache* default_template_cache() {
+ GoogleOnceInit(&g_default_cache_init_once, &CreateTemplateCache);
+ return g_default_template_cache;
+}
+
+TemplateCache* mutable_default_template_cache() {
+ GoogleOnceInit(&g_default_cache_init_once, &CreateTemplateCache);
+ return g_default_template_cache;
+}
+
+// ----------------------------------------------------------------------
+// Template::StringToTemplate()
+// StringToTemplate reads a string representing a template (eg
+// "Hello {{WORLD}}"), and parses it to a Template*. It returns
+// the parsed template, or NULL if there was a parsing error.
+// StringToTemplateCache does the same, but then inserts the
+// resulting Template* into the template cache, for future retrieval
+// via GetTemplate. You pass in the key to use with GetTemplate.
+// It returns a bool indicating success or failure of template
+// creation/insertion. (Insertion will fail if a string or file
+// with that key already exists in the cache.)
+// RemoveStringFromTemplateCache() lets you remove a string that
+// you had previously interned via StringToTemplateCache().
+// ----------------------------------------------------------------------
+
+Template* Template::StringToTemplate(const TemplateString& content,
+ Strip strip) {
+ // An empty original_filename_ keeps ReloadIfChangedLocked from performing
+ // file operations.
+
+ Template *tpl = new Template("", strip, NULL);
+
+ // But we have to do the "loading" and parsing ourselves:
+
+ // BuildTree deletes the buffer when done, so we need a copy for it.
+ char* buffer = new char[content.size()];
+ size_t content_len = content.size();
+ memcpy(buffer, content.data(), content_len);
+ tpl->StripBuffer(&buffer, &content_len);
+ if ( tpl->BuildTree(buffer, buffer + content_len) ) {
+ assert(tpl->state() == TS_READY);
+ } else {
+ assert(tpl->state() != TS_READY);
+ delete tpl;
+ return NULL;
+ }
+ return tpl;
+}
+
+// ----------------------------------------------------------------------
+// Template::Template()
+// Template::~Template()
+// Template::MaybeInitHtmlParser()
+// Calls ReloadIfChanged to load the template the first time.
+// The constructor is private; GetTemplate() is the factory
+// method used to actually construct a new template if needed.
+// GetTemplateCommon() first looks in the two caches -- the
+// cache of parsed template trees, and the cache of raw
+// template-file contents -- before trying to load the
+// template-file from disk.
+// ----------------------------------------------------------------------
+
+Template::Template(const TemplateString& filename, Strip strip,
+ TemplateCache* owner)
+ // TODO(csilvers): replace ToString() with an is_immutable() check
+ : original_filename_(filename.data(), filename.size()), resolved_filename_(),
+ filename_mtime_(0), strip_(strip), state_(TS_EMPTY),
+ template_cache_(owner), template_text_(NULL), template_text_len_(0),
+ tree_(NULL), parse_state_(),
+ initial_context_(TC_MANUAL), htmlparser_(NULL) {
+ VLOG(2) << "Constructing Template for " << template_file()
+ << "; with context " << initial_context_
+ << "; and strip " << strip_ << endl;
+
+ // Preserve whitespace in Javascript files because carriage returns
+ // can convey meaning for comment termination and closures
+ if (strsuffix(original_filename_.c_str(), ".js") &&
+ strip_ == STRIP_WHITESPACE) {
+ strip_ = STRIP_BLANK_LINES;
+ }
+ ReloadIfChangedLocked();
+}
+
+Template::~Template() {
+ VLOG(2) << endl << "Deleting Template for " << template_file()
+ << "; with context " << initial_context_
+ << "; and strip " << strip_ << endl;
+ // Since this is only used by tests, we don't bother with locking
+ num_deletes_++;
+ delete tree_;
+ // Delete this last, since tree has pointers into template_text_
+ delete[] template_text_;
+ delete htmlparser_;
+}
+
+// In TemplateContexts where the HTML parser is needed, we initialize it in
+// the appropriate mode. Also we do a sanity check (cannot fail) on the
+// template filename. This function is invoked when an AUTOESCAPE pragma is
+// found during template parsing and should at most be called once per template.
+//
+// In_tag is only meaningful for TC_HTML: It is true for templates that
+// start inside an HTML tag and hence are expected to contain HTML attribute
+// name/value pairs only. It is false for standard HTML templates.
+void Template::MaybeInitHtmlParser(bool in_tag) {
+ assert(!htmlparser_);
+ if (AUTO_ESCAPE_PARSING_CONTEXT(initial_context_)) {
+ htmlparser_ = new HtmlParser();
+ switch (initial_context_) {
+ case TC_JS:
+ htmlparser_->ResetMode(HtmlParser::MODE_JS);
+ break;
+ case TC_CSS:
+ htmlparser_->ResetMode(HtmlParser::MODE_CSS);
+ break;
+ default:
+ if (in_tag)
+ htmlparser_->ResetMode(HtmlParser::MODE_HTML_IN_TAG);
+ break;
+ }
+ FilenameValidForContext(original_filename_, initial_context_);
+ }
+}
+
+// ----------------------------------------------------------------------
+// Template::BuildTree()
+// Template::WriteHeaderEntry()
+// Template::Dump()
+// These kick off their various parsers -- BuildTree for the
+// main task of parsing a Template when it's read from memory,
+// WriteHeaderEntry for parsing for make_tpl_varnames_h, and
+// Dump() for when Dump() is called by the caller.
+// ----------------------------------------------------------------------
+
+// NOTE: BuildTree takes over ownership of input_buffer, and will delete it.
+// It should have been created via new[].
+// You should hold a write-lock on g_template_mutex before calling this
+// (unless you're calling it from a constructor).
+// In auto-escape mode, the HTML context is tracked as the tree is being
+// built, in a single pass. When this function completes, all variables
+// will have the proper modifiers set.
+bool Template::BuildTree(const char* input_buffer,
+ const char* input_buffer_end) {
+ set_state(TS_EMPTY);
+ parse_state_.bufstart = input_buffer;
+ parse_state_.bufend = input_buffer_end;
+ parse_state_.phase = ParseState::GETTING_TEXT;
+ parse_state_.current_delimiters = Template::MarkerDelimiters();
+ // Assign an arbitrary name to the top-level node
+ SectionTemplateNode *top_node = new SectionTemplateNode(
+ TemplateToken(TOKENTYPE_SECTION_START,
+ kMainSectionName, strlen(kMainSectionName), NULL),
+ false);
+ while (top_node->AddSubnode(this)) {
+ // Add the rest of the template in.
+ }
+
+ // get rid of the old tree, whenever we try to build a new one.
+ delete tree_;
+ delete[] template_text_;
+ tree_ = top_node;
+ template_text_ = input_buffer;
+ template_text_len_ = input_buffer_end - input_buffer;
+
+ // TS_ERROR can also be set by the auto-escape mode, at the point
+ // where the parser failed to parse.
+ if (state() != TS_ERROR) {
+ set_state(TS_READY);
+ return true;
+ } else {
+ delete tree_;
+ tree_ = NULL;
+ delete[] template_text_;
+ template_text_ = NULL;
+ template_text_len_ = 0;
+ return false;
+ }
+}
+
+void Template::WriteHeaderEntries(string *outstring) const {
+ if (state() == TS_READY) { // only write header entries for 'good' tpls
+ outstring->append("#include <ctemplate/template_string.h>\n");
+ tree_->WriteHeaderEntries(outstring, template_file());
+ }
+}
+
+// Dumps the parsed structure of the template for debugging assistance.
+// It goes to stdout instead of LOG to avoid possible truncation due to size.
+void Template::Dump(const char *filename) const {
+ string out;
+ DumpToString(filename, &out);
+ fwrite(out.data(), 1, out.length(), stdout);
+ fflush(stdout);
+}
+
+void Template::DumpToString(const char *filename, string *out) const {
+ if (!out)
+ return;
+ out->append("------------Start Template Dump [" + string(filename) +
+ "]--------------\n");
+ if (tree_) {
+ tree_->DumpToString(1, out);
+ } else {
+ out->append("No parse tree has been produced for this template\n");
+ }
+ out->append("------------End Template Dump----------------\n");
+}
+
+// -------------------------------------------------------------------------
+// Template::state()
+// Template::set_state()
+// Template::template_file()
+// Template::original_filename()
+// Template::strip()
+// Template::mtime()
+// Various introspection methods. state() is the parse-state
+// (success, error). template_file() is the resolved filename of a
+// given template object's input. original_filename() is the unresolved,
+// original filename, strip() is the Strip type. mtime() is
+// the lastmod time. For string-based templates, not backed by a file,
+// mtime() returns 0.
+// -------------------------------------------------------------------------
+
+void Template::set_state(TemplateState new_state) {
+ state_ = new_state;
+}
+
+TemplateState Template::state() const {
+ return state_;
+}
+
+const char *Template::template_file() const {
+ return resolved_filename_.c_str();
+}
+
+const char *Template::original_filename() const {
+ return original_filename_.c_str();
+}
+
+Strip Template::strip() const {
+ return strip_;
+}
+
+time_t Template::mtime() const {
+ return filename_mtime_;
+}
+
+// ----------------------------------------------------------------------
+// Template::GetTemplate()
+// Template::StringToTemplateCache()
+// Template::SetTemplateRootDirectory()
+// Template::AddAlternateTemplateRootDirectory()
+// Template::template_root_directory()
+// Template::FindTemplateFilename()
+// Template::RemoveStringFromTemplateCache()
+// Template::ClearCache()
+// Template::ReloadAllIfChanged()
+// These are deprecated static methods that have been moved to
+// template_cache.h. We just forward to them, using the global
+// default template cache.
+// ----------------------------------------------------------------------
+
+Template *Template::GetTemplate(const TemplateString& filename, Strip strip) {
+ // Until I've resolved the TODO that lets me return a const Template*
+ // here, I have to do an ugly cast. :-(
+ return const_cast<Template*>(
+ mutable_default_template_cache()->GetTemplate(filename, strip));
+}
+
+// This method is deprecated (and slow). Instead, use the above
+// StringToTemplateCache method that takes a Strip argument.
+bool Template::StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content) {
+ // We say the insert succeeded only if it succeded for all strip values.
+ bool retval = true;
+ for (int i = 0; i < static_cast<int>(NUM_STRIPS); ++i) {
+ if (!GOOGLE_NAMESPACE::StringToTemplateCache(key, content, static_cast<Strip>(i)))
+ retval = false;
+ }
+ return retval;
+}
+
+// ----------------------------------------------------------------------
+// Template::ParseDelimiters()
+// Given an input that looks like =XXX YYY=, set the
+// MarkerDelimiters to point to XXX and YYY. This is used to parse
+// {{=XXX YYY=}} markers, which reset the marker delimiters.
+// Returns true if successfully parsed (starts and ends with =,
+// exactly one space, no internal ='s), false else.
+// ----------------------------------------------------------------------
+
+bool Template::ParseDelimiters(const char* text, size_t textlen,
+ MarkerDelimiters* delim) {
+ const char* space = (const char*)memchr(text, ' ', textlen);
+ if (textlen < 3 ||
+ text[0] != '=' || text[textlen - 1] != '=' || // no = at ends
+ memchr(text + 1, '=', textlen - 2) || // = in the middle
+ !space || // no interior space
+ memchr(space + 1, ' ', text + textlen - (space+1))) // too many spaces
+ return false;
+
+ delim->start_marker = text + 1;
+ delim->start_marker_len = space - delim->start_marker;
+ delim->end_marker = space + 1;
+ delim->end_marker_len = text + textlen - 1 - delim->end_marker;
+ return true;
+}
+
+// ----------------------------------------------------------------------
+// StripTemplateWhiteSpace()
+// Template::IsBlankOrOnlyHasOneRemovableMarker()
+// Template::InsertLine()
+// Template::StripBuffer()
+// This mini-parser modifies an input buffer, replacing it with a
+// new buffer that is the same as the old, but with whitespace
+// removed as is consistent with the given strip-mode:
+// STRIP_WHITESPACE, STRIP_BLANK_LINES, DO_NOT_STRIP (the last
+// of these is a no-op). This parser may work by allocating
+// a new buffer and deleting the input buffer when it's done).
+// The trickiest bit if in STRIP_BLANK_LINES mode, if we see
+// a line that consits entirely of one "removable" marker on it,
+// and nothing else other than whitespace. ("Removable" markers
+// are comments, start sections, end sections, pragmas and
+// template-include.) In such a case, we elide the newline at
+// the end of that line.
+// ----------------------------------------------------------------------
+
+// We define our own version rather than using the one in strutil, mostly
+// so we can take a size_t instead of an int. The code is simple enough.
+static void StripTemplateWhiteSpace(const char** str, size_t* len) {
+ // Strip off trailing whitespace.
+ while ((*len) > 0 && ascii_isspace((*str)[(*len)-1])) {
+ (*len)--;
+ }
+
+ // Strip off leading whitespace.
+ while ((*len) > 0 && ascii_isspace((*str)[0])) {
+ (*len)--;
+ (*str)++;
+ }
+}
+
+// Adjusts line and length iff condition is met, and RETURNS true.
+// MarkerDelimiters are {{ and }}, or equivalent.
+bool Template::IsBlankOrOnlyHasOneRemovableMarker(
+ const char** line, size_t* len, const Template::MarkerDelimiters& delim) {
+ const char *clean_line = *line;
+ size_t new_len = *len;
+ StripTemplateWhiteSpace(&clean_line, &new_len);
+
+ // If there was only white space on the line, new_len will now be zero.
+ // In that case the line should be removed, so return true.
+ if (new_len == 0) {
+ *line = clean_line;
+ *len = new_len;
+ return true;
+ }
+
+ // The smallest removable marker is at least start_marker_len +
+ // end_marker_len + 1 characters long. If there aren't enough
+ // characters, then keep the line by returning false.
+ if (new_len < delim.start_marker_len + delim.end_marker_len + 1) {
+ return false;
+ }
+
+ // Only {{#...}}, {{/....}, {{>...}, {{!...}, {{%...}} and {{=...=}}
+ // are "removable"
+ if (memcmp(clean_line, delim.start_marker, delim.start_marker_len) != 0 ||
+ !strchr("#/>!%=", clean_line[delim.start_marker_len])) {
+ return false;
+ }
+
+ const char *found_end_marker = memmatch(clean_line + delim.start_marker_len,
+ new_len - delim.start_marker_len,
+ delim.end_marker,
+ delim.end_marker_len);
+
+ // Make sure the end marker comes at the end of the line.
+ if (!found_end_marker ||
+ found_end_marker + delim.end_marker_len != clean_line + new_len) {
+ return false;
+ }
+
+ // else return the line stripped of its white space chars so when the
+ // marker is removed in expansion, no white space is left from the line
+ // that has now been removed
+ *line = clean_line;
+ *len = new_len;
+ return true;
+}
+
+size_t Template::InsertLine(const char *line, size_t len, Strip strip,
+ const MarkerDelimiters& delim, char* buffer) {
+ bool add_newline = (len > 0 && line[len-1] == '\n');
+ if (add_newline)
+ len--; // so we ignore the newline from now on
+
+ if (strip >= STRIP_WHITESPACE) {
+ StripTemplateWhiteSpace(&line, &len);
+ add_newline = false;
+
+ // IsBlankOrOnlyHasOneRemovableMarker may modify the two input
+ // parameters if the line contains only spaces or only one input
+ // marker. This modification must be done before the line is
+ // written to the input buffer. Hence the need for the boolean flag
+ // add_newline to be referenced after the Write statement.
+ } else if (strip >= STRIP_BLANK_LINES
+ && IsBlankOrOnlyHasOneRemovableMarker(&line, &len, delim)) {
+ add_newline = false;
+ }
+
+ memcpy(buffer, line, len);
+
+ if (add_newline) {
+ buffer[len++] = '\n';
+ }
+ return len;
+}
+
+void Template::StripBuffer(char **buffer, size_t* len) {
+ if (strip_ == DO_NOT_STRIP)
+ return;
+
+ char* bufend = *buffer + *len;
+ char* retval = new char[*len];
+ char* write_pos = retval;
+
+ MarkerDelimiters delim;
+
+ const char* next_pos = NULL;
+ for (const char* prev_pos = *buffer; prev_pos < bufend; prev_pos = next_pos) {
+ next_pos = (char*)memchr(prev_pos, '\n', bufend - prev_pos);
+ if (next_pos)
+ next_pos++; // include the newline
+ else
+ next_pos = bufend; // for the last line, when it has no newline
+
+ write_pos += InsertLine(prev_pos, next_pos - prev_pos, strip_, delim,
+ write_pos);
+ assert(write_pos >= retval &&
+ static_cast<size_t>(write_pos-retval) <= *len);
+
+ // Before looking at the next line, see if the current line
+ // changed the marker-delimiter. We care for
+ // IsBlankOrOnlyHasOneRemovableMarker, so we don't need to be
+ // perfect -- we don't have to handle the delimiter changing in
+ // the middle of a line -- just make sure that the next time
+ // there's only one marker on a line, we notice because we know
+ // the right delim.
+ const char* end_marker = NULL;
+ for (const char* marker = prev_pos; marker; marker = end_marker) {
+ marker = memmatch(marker, next_pos - marker,
+ delim.start_marker, delim.start_marker_len);
+ if (!marker) break;
+ end_marker = memmatch(marker + delim.start_marker_len,
+ next_pos - (marker + delim.start_marker_len),
+ delim.end_marker, delim.end_marker_len);
+ if (!end_marker) break;
+ end_marker += delim.end_marker_len; // needed for the for loop
+ // This tries to parse the marker as a set-delimiters marker.
+ // If it succeeds, it updates delim. If not, it ignores it.
+ assert(((end_marker - delim.end_marker_len)
+ - (marker + delim.start_marker_len)) >= 0);
+ Template::ParseDelimiters(marker + delim.start_marker_len,
+ ((end_marker - delim.end_marker_len)
+ - (marker + delim.start_marker_len)),
+ &delim);
+ }
+ }
+ assert(write_pos >= retval);
+
+ // Replace the input retval with our new retval.
+ delete[] *buffer;
+ *buffer = retval;
+ *len = static_cast<size_t>(write_pos - retval);
+}
+
+// ----------------------------------------------------------------------
+// Template::ReloadIfChanged()
+// Template::ReloadIfChangedLocked()
+// If one template, try immediately to reload it from disk. If all
+// templates, just set all their reload statuses to true, so next time
+// GetTemplate() is called on the template, it will be reloaded from disk if
+// the disk version is newer than the one currently in memory.
+// ReloadIfChanged() returns true if the file changed and disk *and* we
+// successfully reloaded and parsed it. It never returns true if
+// original_filename_ is "".
+// ----------------------------------------------------------------------
+
+// Besides being called when locked, it's also ok to call this from
+// the constructor, when you know nobody else will be messing with
+// this object.
+bool Template::ReloadIfChangedLocked()
+ EXCLUSIVE_LOCKS_REQUIRED(g_template_mutex) {
+ // TODO(panicker): Remove this duplicate code when constructing the template,
+ // after deprecating this method.
+ // TemplateCache::GetTemplate() already checks if the template filename is
+ // valid and resolvable. It also checks if the file needs to be reloaded
+ // based on mtime.
+
+ // NOTE(panicker): we should not be using original_filename_ to determine
+ // if a template is string-based, instead use the boolean 'string_based'
+ // in the template cache.
+ if (original_filename_.empty()) {
+ // string-based templates don't reload
+ return false;
+ }
+
+ FileStat statbuf;
+ if (resolved_filename_.empty()) {
+ if (!template_cache_->ResolveTemplateFilename(original_filename_,
+ &resolved_filename_,
+ &statbuf)) {
+ LOG(WARNING) << "Unable to locate file " << original_filename_ << endl;
+ set_state(TS_ERROR);
+ return false;
+ }
+ } else {
+ if (!File::Stat(resolved_filename_, &statbuf)) {
+ LOG(WARNING) << "Unable to stat file " << resolved_filename_ << endl;
+ // We keep the old tree if there is one, otherwise we're in error
+ set_state(TS_ERROR);
+ return false;
+ }
+ }
+
+ if (statbuf.IsDirectory()) {
+ LOG(WARNING) << resolved_filename_
+ << "is a directory and thus not readable" << endl;
+ // We keep the old tree if there is one, otherwise we're in error
+ set_state(TS_ERROR);
+ return false;
+ }
+ if (statbuf.mtime == filename_mtime_ && filename_mtime_ > 0
+ && tree_) { // force a reload if we don't already have a tree_
+ VLOG(1) << "Not reloading file " << resolved_filename_
+ << ": no new mod-time" << endl;
+ set_state(TS_READY);
+ return false; // file's timestamp hasn't changed, so no need to reload
+ }
+
+ File* fp = File::Open(resolved_filename_.c_str(), "r");
+ if (fp == NULL) {
+ LOG(ERROR) << "Can't find file " << resolved_filename_
+ << "; skipping" << endl;
+ // We keep the old tree if there is one, otherwise we're in error
+ set_state(TS_ERROR);
+ return false;
+ }
+ size_t buflen = statbuf.length;
+ char* file_buffer = new char[buflen];
+ if (fp->Read(file_buffer, buflen) != buflen) {
+ LOG(ERROR) << "Error reading file " << resolved_filename_
+ << ": " << strerror(errno) << endl;
+ fp->Close();
+ delete[] file_buffer;
+ // We could just keep the old tree, but probably safer to say 'error'
+ set_state(TS_ERROR);
+ return false;
+ }
+ fp->Close();
+
+ // Now that we know we've read the file ok, mark the new mtime
+ filename_mtime_ = statbuf.mtime;
+
+ // Parse the input one line at a time to get the "stripped" input.
+ StripBuffer(&file_buffer, &buflen);
+
+ // Re-initialize Auto-Escape data. Delete the parser and reset the template
+ // context back to TC_MANUAL. If the new content has the AUTOESCAPE pragma,
+ // the parser will then be re-created.
+ initial_context_ = TC_MANUAL;
+ delete htmlparser_;
+ htmlparser_ = NULL;
+
+ // Now parse the template we just read. BuildTree takes over ownership
+ // of input_buffer in every case, and will eventually delete it.
+ if ( BuildTree(file_buffer, file_buffer + buflen) ) {
+ assert(state() == TS_READY);
+ return true;
+ } else {
+ assert(state() != TS_READY);
+ return false;
+ }
+}
+
+// ----------------------------------------------------------------------
+// Template::ExpandLocked()
+// Template::ExpandWithDataAndCache()
+// This is the main function clients call: it expands a template
+// by expanding its parse tree (which starts with a top-level
+// section node). For each variable/section/include-template it
+// sees, it replaces the name stored in the parse-tree with the
+// appropriate value from the passed-in dictionary.
+// ----------------------------------------------------------------------
+
+bool Template::ExpandLocked(ExpandEmitter *expand_emitter,
+ const TemplateDictionaryInterface *dict,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const
+ SHARED_LOCKS_REQUIRED(g_template_mutex) {
+ // Accumulator for the results of Expand for each sub-tree.
+ bool error_free = true;
+
+ // TODO(csilvers): could make this static if it's expensive to construct.
+ PerExpandData empty_per_expand_data;
+ if (per_expand_data == NULL)
+ per_expand_data = &empty_per_expand_data;
+
+ if (state() != TS_READY) {
+ // We'd like to reload if reload status is true, but ExpandWD() is const
+ return false;
+ }
+
+ if (per_expand_data->annotate()) {
+ // Remove the machine dependent prefix from the template file name.
+ const char* file = template_file();
+ const char* short_file = strstr(file, per_expand_data->annotate_path());
+ if (short_file != NULL) {
+ file = short_file;
+ }
+ per_expand_data->annotator()->EmitOpenFile(expand_emitter,
+ string(file));
+ }
+
+ // If the client registered an expand-modifier, which is a modifier
+ // meant to modify all templates after they are expanded, apply it
+ // now.
+ const TemplateModifier* modifier =
+ per_expand_data->template_expansion_modifier();
+ if (modifier && modifier->MightModify(per_expand_data, template_file())) {
+ // We found a expand TemplateModifier. Apply it.
+ //
+ // Since the expand-modifier doesn't ever have an arg (it doesn't
+ // have a name and can't be applied in the text of a template), we
+ // pass the template name in as the string arg in this case.
+ string value;
+ StringEmitter tmp_emitter(&value);
+ error_free &= tree_->Expand(&tmp_emitter, dict, per_expand_data, cache);
+ modifier->Modify(value.data(), value.size(), per_expand_data,
+ expand_emitter, template_file());
+ } else {
+ // No need to modify this template.
+ error_free &= tree_->Expand(expand_emitter, dict, per_expand_data, cache);
+ }
+
+ if (per_expand_data->annotate()) {
+ per_expand_data->annotator()->EmitCloseFile(expand_emitter);
+ }
+
+ return error_free;
+}
+
+bool Template::ExpandWithDataAndCache(
+ ExpandEmitter *expand_emitter,
+ const TemplateDictionaryInterface *dict,
+ PerExpandData *per_expand_data,
+ const TemplateCache *cache) const LOCKS_EXCLUDED(g_template_mutex) {
+ // We hold g_template_mutex the entire time we expand, because
+ // ReloadIfChanged(), which also holds template_mutex, is allowed to
+ // delete tree_, and we want to make sure it doesn't do that (in another
+ // thread) while we're expanding. We also protect state_, etc.
+ // Note we only need a read-lock here, so many expands can go on at once.
+ // TODO(csilvers): We can remove this once we delete ReloadIfChanged.
+ // When we do that, ExpandLocked() can go away as well.
+ ReaderMutexLock ml(&g_template_mutex);
+ return ExpandLocked(expand_emitter, dict, per_expand_data, cache);
+}
+
+}
diff --git a/src/template_annotator.cc b/src/template_annotator.cc
new file mode 100644
index 0000000..57d5a2b
--- /dev/null
+++ b/src/template_annotator.cc
@@ -0,0 +1,108 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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 <config.h>
+#include <ctemplate/template_annotator.h>
+#include <string>
+#include <ctemplate/template_emitter.h>
+
+// Emits an open annotation string. 'name' must be a string literal.
+#define EMIT_OPEN_ANNOTATION(emitter, name, value) \
+ (emitter)->Emit("{{#" name "=", 4 + sizeof(name)-1); \
+ (emitter)->Emit(value); \
+ (emitter)->Emit("}}", 2);
+
+// Emits a close annotation string. 'name' must be a string literal.
+#define EMIT_CLOSE_ANNOTATION(emitter, name) \
+ (emitter)->Emit("{{/" name "}}", 5 + sizeof(name)-1);
+
+#define EMIT_MISSING_ANNOTATION(emitter, name, value) \
+ (emitter)->Emit("{{" name "=", 3 + sizeof(name)-1); \
+ (emitter)->Emit(value); \
+ (emitter)->Emit("}}", 2);
+
+namespace ctemplate {
+
+using std::string;
+
+// Implementation note: TextTemplateAnnotator contains no state, and
+// code elsewhere is depending on this. E.g., a statically allocated
+// instance is used as the default annotator in the implementation of
+// PerExpandData. If you add state to this class, please revisit
+// the setup of such static instances.
+
+// This implements precisely the same annotation that was originally
+// built into the template.cc. Many upstream tools depend on the
+// exact formatting that this implementation happens to produce--
+// so do not consider changes to this lightly.
+
+void TextTemplateAnnotator::EmitOpenInclude(ExpandEmitter* emitter,
+ const string& value) {
+ EMIT_OPEN_ANNOTATION(emitter, "INC", value);
+}
+
+void TextTemplateAnnotator::EmitCloseInclude(ExpandEmitter* emitter) {
+ EMIT_CLOSE_ANNOTATION(emitter, "INC");
+}
+
+void TextTemplateAnnotator::EmitOpenFile(ExpandEmitter* emitter,
+ const string& value) {
+ EMIT_OPEN_ANNOTATION(emitter, "FILE", value);
+}
+
+void TextTemplateAnnotator::EmitCloseFile(ExpandEmitter* emitter) {
+ EMIT_CLOSE_ANNOTATION(emitter, "FILE");
+}
+
+void TextTemplateAnnotator::EmitOpenSection(ExpandEmitter* emitter,
+ const string& value) {
+ EMIT_OPEN_ANNOTATION(emitter, "SEC", value);
+}
+
+void TextTemplateAnnotator::EmitCloseSection(ExpandEmitter* emitter) {
+ EMIT_CLOSE_ANNOTATION(emitter, "SEC");
+}
+
+void TextTemplateAnnotator::EmitOpenVariable(ExpandEmitter* emitter,
+ const string& value) {
+ EMIT_OPEN_ANNOTATION(emitter, "VAR", value);
+}
+
+void TextTemplateAnnotator::EmitCloseVariable(ExpandEmitter* emitter) {
+ EMIT_CLOSE_ANNOTATION(emitter, "VAR");
+}
+
+void TextTemplateAnnotator::EmitFileIsMissing(ExpandEmitter* emitter,
+ const string& value) {
+ EMIT_MISSING_ANNOTATION(emitter,"MISSING_FILE", value);
+}
+
+}
diff --git a/src/template_cache.cc b/src/template_cache.cc
new file mode 100644
index 0000000..819a0b6
--- /dev/null
+++ b/src/template_cache.cc
@@ -0,0 +1,772 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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 <config.h>
+#include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE
+#include <ctemplate/template_cache.h>
+#include <assert.h> // for assert()
+#include <errno.h>
+#include <stddef.h> // for size_t
+#include <stdlib.h> // for strerror()
+#include <sys/stat.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif // for getcwd()
+#include HASH_MAP_H // for hash_map<>::iterator, hash_map<>, etc
+#include <utility> // for pair<>, make_pair()
+#include <vector> // for vector<>::size_type, vector<>, etc
+#include "base/thread_annotations.h" // for GUARDED_BY
+#include <ctemplate/find_ptr.h>
+#include <ctemplate/template.h> // for Template, TemplateState
+#include <ctemplate/template_enums.h> // for Strip, DO_NOT_STRIP
+#include <ctemplate/template_pathops.h> // for PathJoin(), IsAbspath(), etc
+#include <ctemplate/template_string.h> // for StringHash
+#include "base/fileutil.h"
+#include <iostream> // for cerr
+
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 4096 // seems conservative for max filename len!
+#endif
+#endif
+
+using std::endl;
+using std::string;
+using std::vector;
+using std::pair;
+using std::make_pair;
+#ifdef HAVE_UNORDERED_MAP
+using HASH_NAMESPACE::unordered_map;
+// This is totally cheap, but minimizes the need for #ifdef's below...
+#define hash_map unordered_map
+#else
+using HASH_NAMESPACE::hash_map;
+#endif
+
+static int kVerbosity = 0; // you can change this by hand to get vlogs
+#define LOG(level) std::cerr << #level ": "
+#define PLOG(level) std::cerr << #level ": [" << strerror(errno) << "] "
+#define VLOG(level) if (kVerbosity >= level) std::cerr << "V" #level ": "
+
+namespace ctemplate {
+
+// ----------------------------------------------------------------------
+// TemplateCache::RefcountedTemplate
+// A simple refcounting class to keep track of templates, which
+// might be shared between caches. It also owns the pointer to
+// the template itself.
+// ----------------------------------------------------------------------
+
+class TemplateCache::RefcountedTemplate {
+ public:
+ explicit RefcountedTemplate(const Template* ptr) : ptr_(ptr), refcount_(1) { }
+ void IncRef() {
+ MutexLock ml(&mutex_);
+ assert(refcount_ > 0);
+ ++refcount_;
+ }
+ void DecRefN(int n) {
+ bool refcount_is_zero;
+ {
+ MutexLock ml(&mutex_);
+ assert(refcount_ >= n);
+ refcount_ -= n;
+ refcount_is_zero = (refcount_ == 0);
+ }
+ // We can't delete this within the MutexLock, because when the
+ // MutexLock tries to unlock Mutex at function-exit, the mutex
+ // will have been deleted! This is just as safe as doing the
+ // delete within the lock -- in either case, if anyone tried to do
+ // anything to this class after the refcount got to 0, bad things
+ // would happen.
+ if (refcount_is_zero)
+ delete this;
+ }
+ void DecRef() {
+ DecRefN(1);
+ }
+ int refcount() const {
+ MutexLock ml(&mutex_); // could be ReaderMutexLock, but whatever
+ return refcount_;
+ }
+ const Template* tpl() const { return ptr_; }
+
+ private:
+ ~RefcountedTemplate() { delete ptr_; }
+ const Template* const ptr_;
+ int refcount_ GUARDED_BY(mutex_);
+ mutable Mutex mutex_;
+};
+
+// ----------------------------------------------------------------------
+// TemplateCache::RefTplPtrHash
+// TemplateCache::TemplateCacheHash
+// TemplateCache::CachedTemplate
+// These are used for the cache-map. CachedTemplate is what is
+// actually stored in the map: the Template* and some information
+// about it (whether we need to reload it, etc.). Refcount is
+// a simple refcounting class, used to keep track of templates.
+// ----------------------------------------------------------------------
+
+// This is needed just because many STLs (eg FreeBSD's) are unable to
+// hash pointers by default.
+class TemplateCache::RefTplPtrHash {
+ public:
+ size_t operator()(const RefcountedTemplate* p) const {
+ return reinterpret_cast<size_t>(p);
+ }
+ // Less operator for MSVC's hash containers.
+ bool operator()(const RefcountedTemplate* a,
+ const RefcountedTemplate* b) const {
+ return a < b;
+ }
+ // These two public members are required by msvc. 4 and 8 are defaults.
+ static const size_t bucket_size = 4;
+ static const size_t min_buckets = 8;
+};
+
+class TemplateCache::TemplateCacheHash {
+ public:
+ size_t operator()(const TemplateCacheKey& p) const {
+ // Using + here is silly, but should work ok in practice.
+ return p.first + p.second;
+}
+ // Less operator for MSVC's hash containers.
+ bool operator()(const TemplateCacheKey& a,
+ const TemplateCacheKey& b) const {
+ return (a.first == b.first
+ ? a.second < b.second
+ : a.first < b.first);
+ }
+ // These two public members are required by msvc. 4 and 8 are defaults.
+ static const size_t bucket_size = 4;
+ static const size_t min_buckets = 8;
+};
+
+struct TemplateCache::CachedTemplate {
+ enum TemplateType { UNUSED, FILE_BASED, STRING_BASED };
+ CachedTemplate()
+ : refcounted_tpl(NULL),
+ should_reload(false),
+ template_type(UNUSED) {
+ }
+ CachedTemplate(const Template* tpl_ptr, TemplateType type)
+ : refcounted_tpl(new TemplateCache::RefcountedTemplate(tpl_ptr)),
+ should_reload(false),
+ template_type(type) {
+ }
+
+ // we won't remove the template from the cache until refcount drops to 0
+ TemplateCache::RefcountedTemplate* refcounted_tpl; // shared across Clone()
+ // reload status
+ bool should_reload;
+ // indicates if the template is string-based or file-based
+ TemplateType template_type;
+};
+
+
+// ----------------------------------------------------------------------
+// TemplateCache::TemplateCache()
+// TemplateCache::~TemplateCache()
+// ----------------------------------------------------------------------
+
+TemplateCache::TemplateCache()
+ : parsed_template_cache_(new TemplateMap),
+ is_frozen_(false),
+ search_path_(),
+ get_template_calls_(new TemplateCallMap),
+ mutex_(new Mutex),
+ search_path_mutex_(new Mutex) {
+}
+
+TemplateCache::~TemplateCache() {
+ ClearCache();
+ delete parsed_template_cache_;
+ delete get_template_calls_;
+ delete mutex_;
+ delete search_path_mutex_;
+}
+
+
+// ----------------------------------------------------------------------
+// HasTemplateChangedOnDisk
+// Indicates whether the template has changed, based on the
+// backing file's last modtime.
+// ----------------------------------------------------------------------
+
+bool HasTemplateChangedOnDisk(const char* resolved_filename,
+ time_t mtime,
+ FileStat* statbuf) {
+ if (!File::Stat(resolved_filename, statbuf)) {
+ LOG(WARNING) << "Unable to stat file " << resolved_filename << endl;
+ // If we can't Stat the file then the file may have been deleted,
+ // so reload the template.
+ return true;
+ }
+ if (statbuf->mtime == mtime && mtime > 0) {
+ // No need to reload yet.
+ return false;
+ }
+ return true;
+}
+
+
+// ----------------------------------------------------------------------
+// TemplateCache::LoadTemplate()
+// TemplateCache::GetTemplate()
+// TemplateCache::GetTemplateLocked()
+// TemplateCache::StringToTemplateCache()
+// The routines for adding a template to the cache. LoadTemplate
+// loads the template into the cache and returns true if the
+// template was successfully loaded or if it already exists in the
+// cache. GetTemplate loads the template into the cache from disk
+// and returns the parsed template. StringToTemplateCache parses
+// and loads the template from the given string into the parsed
+// cache, or returns false if an older version already exists in
+// the cache.
+// ----------------------------------------------------------------------
+
+bool TemplateCache::LoadTemplate(const TemplateString& filename, Strip strip) {
+ TemplateCacheKey cache_key = TemplateCacheKey(filename.GetGlobalId(), strip);
+ WriterMutexLock ml(mutex_);
+ return GetTemplateLocked(filename, strip, cache_key) != NULL;
+}
+
+const Template *TemplateCache::GetTemplate(const TemplateString& filename,
+ Strip strip) {
+ // No need to have the cache-mutex acquired for this step
+ TemplateCacheKey cache_key = TemplateCacheKey(filename.GetGlobalId(), strip);
+ CachedTemplate retval;
+ WriterMutexLock ml(mutex_);
+ RefcountedTemplate* refcounted_tpl =
+ GetTemplateLocked(filename, strip, cache_key);
+ if (!refcounted_tpl)
+ return NULL;
+
+ refcounted_tpl->IncRef(); // DecRef() is in DoneWithGetTemplatePtrs()
+ (*get_template_calls_)[refcounted_tpl]++; // set up for DoneWith...()
+ return refcounted_tpl->tpl();
+}
+
+TemplateCache::RefcountedTemplate* TemplateCache::GetTemplateLocked(
+ const TemplateString& filename,
+ Strip strip,
+ const TemplateCacheKey& template_cache_key) {
+ // NOTE: A write-lock must be held on mutex_ when this method is called.
+ CachedTemplate* it = find_ptr(*parsed_template_cache_, template_cache_key);
+ if (!it) {
+ // If the cache is frozen and the template doesn't already exist in cache,
+ // do not load the template, return NULL.
+ if (is_frozen_) {
+ return NULL;
+ }
+ // TODO(panicker): Validate the filename here, and if the file can't be
+ // resolved then insert a NULL in the cache.
+ // If validation succeeds then pass in resolved filename, mtime &
+ // file length (from statbuf) to the constructor.
+ const Template* tpl = new Template(filename, strip, this);
+ it = &(*parsed_template_cache_)[template_cache_key];
+ *it = CachedTemplate(tpl, CachedTemplate::FILE_BASED);
+ assert(it);
+ }
+ if (it->should_reload) {
+ // check if the template has changed on disk or if a new template with the
+ // same name has been added earlier in the search path:
+ const string resolved = FindTemplateFilename(
+ it->refcounted_tpl->tpl()->original_filename());
+ FileStat statbuf;
+ if (it->template_type == CachedTemplate::FILE_BASED &&
+ (resolved != it->refcounted_tpl->tpl()->template_file() ||
+ HasTemplateChangedOnDisk(
+ it->refcounted_tpl->tpl()->template_file(),
+ it->refcounted_tpl->tpl()->mtime(),
+ &statbuf))) {
+ // Create a new template, insert it into the cache under
+ // template_cache_key, and DecRef() the old one to indicate
+ // the cache no longer has a reference to it.
+ const Template* tpl = new Template(filename, strip, this);
+ // DecRef after creating the new template since DecRef may free up
+ // the storage for filename,
+ it->refcounted_tpl->DecRef();
+ *it = CachedTemplate(tpl, CachedTemplate::FILE_BASED);
+ }
+ it->should_reload = false;
+ }
+
+ // If the state is TS_ERROR, we leave the state as is, but return
+ // NULL. We won't try to load the template file again until the
+ // reload status is set to true by another call to ReloadAllIfChanged.
+ return it->refcounted_tpl->tpl()->state() == TS_READY ? it->refcounted_tpl : NULL;
+}
+
+bool TemplateCache::StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content,
+ Strip strip) {
+ TemplateCacheKey template_cache_key = TemplateCacheKey(key.GetGlobalId(), strip);
+ {
+ ReaderMutexLock ml(mutex_);
+ if (is_frozen_) {
+ return false;
+ }
+ // If the key is already in the parsed-cache, we just return false.
+ CachedTemplate* it = find_ptr(*parsed_template_cache_, template_cache_key);
+ if (it && it->refcounted_tpl->tpl()->state() != TS_ERROR) {
+ return false;
+ }
+ }
+ Template* tpl = Template::StringToTemplate(content, strip);
+ if (tpl == NULL) {
+ return false;
+ }
+ if (tpl->state() != TS_READY) {
+ delete tpl;
+ return false;
+ }
+
+ WriterMutexLock ml(mutex_);
+ // Double-check it wasn't just inserted.
+ CachedTemplate* it = find_ptr(*parsed_template_cache_, template_cache_key);
+ if (it) {
+ if (it->refcounted_tpl->tpl()->state() == TS_ERROR) {
+ // replace the old entry with the new one
+ it->refcounted_tpl->DecRef();
+ } else {
+ delete tpl;
+ return false;
+ }
+ }
+ // Insert into cache.
+ (*parsed_template_cache_)[template_cache_key] =
+ CachedTemplate(tpl, CachedTemplate::STRING_BASED);
+ return true;
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::ExpandWithData()
+// TemplateCache::ExpandFrozen()
+// TemplateCache::ExpandLocked()
+// ExpandWithData gets the template from the parsed-cache, possibly
+// loading the template on-demand, and then expands the template.
+// ExpandFrozen is for frozen caches only -- if the filename isn't
+// in the cache, the routine fails (returns false) rather than trying
+// to fetch the template. ExpandLocked is used for recursive
+// sub-template includes, and just tells template.cc it doesn't
+// need to recursively acquire any locks.
+// ----------------------------------------------------------------------
+
+bool TemplateCache::ExpandWithData(const TemplateString& filename,
+ Strip strip,
+ const TemplateDictionaryInterface *dict,
+ PerExpandData *per_expand_data,
+ ExpandEmitter *expand_emitter) {
+ TemplateCacheKey template_cache_key(filename.GetGlobalId(), strip);
+ // We make a local copy of this struct so we don't have to worry about
+ // what happens to our cache while we don't hold the lock (during Expand).
+ RefcountedTemplate* refcounted_tpl = NULL;
+ {
+ WriterMutexLock ml(mutex_);
+ // Optionally load the template (depending on whether the cache is frozen,
+ // the reload bit is set etc.)
+ refcounted_tpl = GetTemplateLocked(filename, strip, template_cache_key);
+ if (!refcounted_tpl)
+ return false;
+ refcounted_tpl->IncRef();
+ }
+ const bool result = refcounted_tpl->tpl()->ExpandWithDataAndCache(
+ expand_emitter, dict, per_expand_data, this);
+ {
+ WriterMutexLock ml(mutex_);
+ refcounted_tpl->DecRef();
+ }
+ return result;
+}
+
+bool TemplateCache::ExpandNoLoad(
+ const TemplateString& filename,
+ Strip strip,
+ const TemplateDictionaryInterface *dict,
+ PerExpandData *per_expand_data,
+ ExpandEmitter *expand_emitter) const {
+ TemplateCacheKey template_cache_key(filename.GetGlobalId(), strip);
+ CachedTemplate cached_tpl;
+ {
+ ReaderMutexLock ml(mutex_);
+ if (!is_frozen_) {
+ LOG(DFATAL) << ": ExpandNoLoad() only works on frozen caches.";
+ return false;
+ }
+ CachedTemplate* it = find_ptr(*parsed_template_cache_, template_cache_key);
+ if (!it) {
+ return false;
+ }
+ cached_tpl = *it;
+ cached_tpl.refcounted_tpl->IncRef();
+ }
+ const bool result = cached_tpl.refcounted_tpl->tpl()->ExpandWithDataAndCache(
+ expand_emitter, dict, per_expand_data, this);
+ {
+ WriterMutexLock ml(mutex_);
+ cached_tpl.refcounted_tpl->DecRef();
+ }
+ return result;
+}
+
+// Note: "Locked" in this name refers to the template object, not to
+// use; we still need to acquire our locks as per normal.
+bool TemplateCache::ExpandLocked(const TemplateString& filename,
+ Strip strip,
+ ExpandEmitter *expand_emitter,
+ const TemplateDictionaryInterface *dict,
+ PerExpandData *per_expand_data) {
+ TemplateCacheKey template_cache_key(filename.GetGlobalId(), strip);
+ RefcountedTemplate* refcounted_tpl = NULL;
+ {
+ WriterMutexLock ml(mutex_);
+ refcounted_tpl = GetTemplateLocked(filename, strip, template_cache_key);
+ if (!refcounted_tpl)
+ return false;
+ refcounted_tpl->IncRef();
+ }
+ const bool result = refcounted_tpl->tpl()->ExpandLocked(
+ expand_emitter, dict, per_expand_data, this);
+ {
+ WriterMutexLock ml(mutex_);
+ refcounted_tpl->DecRef();
+ }
+ return result;
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::SetTemplateRootDirectory()
+// TemplateCache::AddAlternateTemplateRootDirectory()
+// TemplateCache::template_root_directory()
+// TemplateCache::FindTemplateFilename()
+// The template-root-directory is where we look for template
+// files (in GetTemplate and include templates) when they're
+// given with a relative rather than absolute name. You can
+// set a 'main' root directory (where we look first), as well
+// as alternates.
+// ----------------------------------------------------------------------
+
+bool TemplateCache::AddAlternateTemplateRootDirectoryHelper(
+ const string& directory,
+ bool clear_template_search_path) {
+ {
+ ReaderMutexLock ml(mutex_);
+ if (is_frozen_) { // Cannot set root-directory on a frozen cache.
+ return false;
+ }
+ }
+ string normalized = directory;
+ // make sure it ends with '/'
+ NormalizeDirectory(&normalized);
+ // Make the directory absolute if it isn't already. This makes code
+ // safer if client later does a chdir.
+ if (!IsAbspath(normalized)) {
+ char* cwdbuf = new char[PATH_MAX]; // new to avoid stack overflow
+ const char* cwd = getcwd(cwdbuf, PATH_MAX);
+ if (!cwd) { // probably not possible, but best to be defensive
+ PLOG(WARNING) << "Unable to convert '" << normalized
+ << "' to an absolute path, with cwd=" << cwdbuf;
+ } else {
+ normalized = PathJoin(cwd, normalized);
+ }
+ delete[] cwdbuf;
+ }
+
+ VLOG(2) << "Setting Template directory to " << normalized << endl;
+ {
+ WriterMutexLock ml(search_path_mutex_);
+ if (clear_template_search_path) {
+ search_path_.clear();
+ }
+ search_path_.push_back(normalized);
+ }
+
+ // NOTE(williasr): The template root is not part of the template
+ // cache key, so we need to invalidate the cache contents.
+ ReloadAllIfChanged(LAZY_RELOAD);
+ return true;
+}
+
+bool TemplateCache::SetTemplateRootDirectory(const string& directory) {
+ return AddAlternateTemplateRootDirectoryHelper(directory, true);
+}
+
+bool TemplateCache::AddAlternateTemplateRootDirectory(
+ const string& directory) {
+ return AddAlternateTemplateRootDirectoryHelper(directory, false);
+}
+
+string TemplateCache::template_root_directory() const {
+ ReaderMutexLock ml(search_path_mutex_);
+ if (search_path_.empty()) {
+ return kCWD;
+ }
+ return search_path_[0];
+}
+
+// Given an unresolved filename, look through the template search path
+// to see if the template can be found. If so, resolved contains the
+// resolved filename, statbuf contains the stat structure for the file
+// (to avoid double-statting the file), and the function returns
+// true. Otherwise, the function returns false.
+bool TemplateCache::ResolveTemplateFilename(const string& unresolved,
+ string* resolved,
+ FileStat* statbuf) const {
+ ReaderMutexLock ml(search_path_mutex_);
+ if (search_path_.empty() || IsAbspath(unresolved)) {
+ *resolved = unresolved;
+ if (File::Stat(*resolved, statbuf)) {
+ VLOG(1) << "Resolved " << unresolved << " to " << *resolved << endl;
+ return true;
+ }
+ } else {
+ for (TemplateSearchPath::const_iterator path = search_path_.begin();
+ path != search_path_.end();
+ ++path) {
+ *resolved = PathJoin(*path, unresolved);
+ if (File::Stat(*resolved, statbuf)) {
+ VLOG(1) << "Resolved " << unresolved << " to " << *resolved << endl;
+ return true;
+ }
+ }
+ }
+
+ resolved->clear();
+ return false;
+}
+
+string TemplateCache::FindTemplateFilename(const string& unresolved)
+ const {
+ string resolved;
+ FileStat statbuf;
+ if (!ResolveTemplateFilename(unresolved, &resolved, &statbuf))
+ resolved.clear();
+ return resolved;
+}
+
+
+// ----------------------------------------------------------------------
+// TemplateCache::Delete()
+// TemplateCache::ClearCache()
+// Delete deletes one entry from the cache.
+// ----------------------------------------------------------------------
+
+bool TemplateCache::Delete(const TemplateString& key) {
+ WriterMutexLock ml(mutex_);
+ if (is_frozen_) { // Cannot delete from a frozen cache.
+ return false;
+ }
+ vector<TemplateCacheKey> to_erase;
+ const TemplateId key_id = key.GetGlobalId();
+ for (TemplateMap::iterator it = parsed_template_cache_->begin();
+ it != parsed_template_cache_->end(); ++it) {
+ if (it->first.first == key_id) {
+ // We'll delete the content pointed to by the entry here, since
+ // it's handy, but we won't delete the entry itself quite yet.
+ it->second.refcounted_tpl->DecRef();
+ to_erase.push_back(it->first);
+ }
+ }
+ for (vector<TemplateCacheKey>::iterator it = to_erase.begin();
+ it != to_erase.end(); ++it) {
+ parsed_template_cache_->erase(*it);
+ }
+ return !to_erase.empty();
+}
+
+void TemplateCache::ClearCache() {
+ // NOTE: We allow a frozen cache to be cleared with this method, although
+ // no other changes can be made to the cache.
+ // We clear the cache by swapping it with an empty cache. This lets
+ // us delete the items in the cache at our leisure without needing
+ // to hold mutex_.
+ TemplateMap tmp_cache;
+ {
+ WriterMutexLock ml(mutex_);
+ parsed_template_cache_->swap(tmp_cache);
+ is_frozen_ = false;
+ }
+ for (TemplateMap::iterator it = tmp_cache.begin();
+ it != tmp_cache.end();
+ ++it) {
+ it->second.refcounted_tpl->DecRef();
+ }
+
+ // Do a decref for all templates ever returned by GetTemplate().
+ DoneWithGetTemplatePtrs();
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::DoneWithGetTemplatePtrs()
+// DoneWithGetTemplatePtrs() DecRefs every template in the
+// get_template_calls_ list. This is because the user of
+// GetTemplate() didn't have a pointer to the refcounted Template
+// to do this themselves. Note we only provide this as a batch
+// operation, so the user should be careful to only call this when
+// they are no longer using *any* template ever retrieved by
+// this cache's GetTemplate().
+// ----------------------------------------------------------------------
+
+void TemplateCache::DoneWithGetTemplatePtrs() {
+ WriterMutexLock ml(mutex_);
+ for (TemplateCallMap::iterator it = get_template_calls_->begin();
+ it != get_template_calls_->end(); ++it) {
+ it->first->DecRefN(it->second); // it.second: # of times GetTpl was called
+ }
+ get_template_calls_->clear();
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::ReloadAllIfChanged()
+// IMMEDIATE_RELOAD attempts to immediately reload and parse
+// all templates if the corresponding template files have changed.
+// LAZY_RELOAD just sets the reload bit in the cache so that the next
+// GetTemplate will reload and parse the template, if it changed.
+
+// NOTE: Suppose the search path is "dira:dirb", and a template is
+// created with name "foo", which resolves to "dirb/foo" because
+// dira/foo does not exist. Then suppose dira/foo is created and then
+// ReloadAllIfChanged() is called. Then ReloadAllIfChanged() will replace
+// the contents of the template with dira/foo, *not* dirb/foo, even if
+// dirb/foo hasn't changed.
+// ----------------------------------------------------------------------
+
+void TemplateCache::ReloadAllIfChanged(ReloadType reload_type) {
+ WriterMutexLock ml(mutex_);
+ if (is_frozen_) { // do not reload a frozen cache.
+ return;
+ }
+ for (TemplateMap::iterator it = parsed_template_cache_->begin();
+ it != parsed_template_cache_->end();
+ ++it) {
+ it->second.should_reload = true;
+ if (reload_type == IMMEDIATE_RELOAD) {
+ const Template* tpl = it->second.refcounted_tpl->tpl();
+ // Reload should always use the original filename.
+ // For instance on reload, we may replace an existing template with a
+ // new one that came earlier on the search path.
+ GetTemplateLocked(tpl->original_filename(), tpl->strip(), it->first);
+ }
+ }
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::Freeze()
+// This method marks the cache as 'frozen'. After this method is called,
+// the cache is immutable, and cannot be modified. New templates cannot be
+// loaded and existing templates cannot be reloaded.
+// ----------------------------------------------------------------------
+
+void TemplateCache::Freeze() {
+ {
+ ReaderMutexLock ml(mutex_);
+ if (is_frozen_) { // if already frozen, then this is a no-op.
+ return;
+ }
+ }
+ // A final reload before freezing the cache.
+ ReloadAllIfChanged(IMMEDIATE_RELOAD);
+ {
+ WriterMutexLock ml(mutex_);
+ is_frozen_ = true;
+ }
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::Clone()
+// Clone makes a shallow copy of the parsed cache by incrementing
+// templates' refcount.
+// The caller is responsible for deallocating the returned TemplateCache.
+// ----------------------------------------------------------------------
+
+TemplateCache* TemplateCache::Clone() const {
+ ReaderMutexLock ml(mutex_);
+ TemplateCache* new_cache = new TemplateCache();
+ *(new_cache->parsed_template_cache_) = *parsed_template_cache_;
+ for (TemplateMap::iterator it = parsed_template_cache_->begin();
+ it != parsed_template_cache_->end(); ++it) {
+ it->second.refcounted_tpl->IncRef();
+ }
+
+ return new_cache;
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::Refcount()
+// This routine is DEBUG-only. It returns the refcount of a template,
+// given the TemplateCacheKey.
+// ----------------------------------------------------------------------
+
+int TemplateCache::Refcount(const TemplateCacheKey template_cache_key) const {
+ ReaderMutexLock ml(mutex_);
+ CachedTemplate* it = find_ptr(*parsed_template_cache_, template_cache_key);
+ return it ? it->refcounted_tpl->refcount() : 0;
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::TemplateIsCached()
+// This routine is for testing only -- is says whether a given
+// template is already in the cache or not.
+// ----------------------------------------------------------------------
+
+bool TemplateCache::TemplateIsCached(const TemplateCacheKey template_cache_key)
+ const {
+ ReaderMutexLock ml(mutex_);
+ return parsed_template_cache_->count(template_cache_key);
+}
+
+// ----------------------------------------------------------------------
+// TemplateCache::ValidTemplateFilename
+// Validates the filename before constructing the template.
+// ----------------------------------------------------------------------
+
+bool TemplateCache::IsValidTemplateFilename(const string& filename,
+ string* resolved_filename,
+ FileStat* statbuf) const {
+ if (!ResolveTemplateFilename(filename,
+ resolved_filename,
+ statbuf)) {
+ LOG(WARNING) << "Unable to locate file " << filename << endl;
+ return false;
+ }
+ if (statbuf->IsDirectory()) {
+ LOG(WARNING) << *resolved_filename
+ << "is a directory and thus not readable" << endl;
+ return false;
+ }
+ return true;
+}
+
+}
diff --git a/src/template_dictionary.cc b/src/template_dictionary.cc
new file mode 100644
index 0000000..14e45a3
--- /dev/null
+++ b/src/template_dictionary.cc
@@ -0,0 +1,1032 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// Based on the 'old' TemplateDictionary by Frank Jernigan.
+
+#include <config.h>
+#include "base/mutex.h" // This must go first so we get _XOPEN_SOURCE
+#include <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <algorithm> // for sort()
+#include HASH_MAP_H
+#include <map>
+#include <string>
+#include <utility> // for pair<>
+#include <vector>
+
+#include "base/arena-inl.h"
+#include "base/thread_annotations.h"
+#include "indented_writer.h"
+#include <ctemplate/find_ptr.h>
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_modifiers.h>
+#include "base/small_map.h"
+#include "base/util.h" // for DCHECK
+
+using std::vector;
+using std::string;
+using std::map;
+using std::pair;
+using std::make_pair;
+
+namespace ctemplate {
+
+// Guards the initialization of the global dictionary.
+static GoogleOnceType g_once = GOOGLE_ONCE_INIT;
+// Guard access to the global dictionary.
+static Mutex g_static_mutex(base::LINKER_INITIALIZED);
+
+/*static*/ UnsafeArena* const TemplateDictionary::NO_ARENA = NULL;
+/*static*/ TemplateDictionary::GlobalDict* TemplateDictionary::global_dict_
+GUARDED_BY(g_static_mutex) PT_GUARDED_BY(g_static_mutex) = NULL;
+/*static*/ TemplateString* TemplateDictionary::empty_string_ = NULL;
+
+
+static const char* const kAnnotateOutput = "__ctemplate_annotate_output__";
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::map_arena_init
+// This class is what small_map<> uses to create a new
+// arena-allocated map<> when it decides it needs to do that.
+// ----------------------------------------------------------------------
+
+class TemplateDictionary::map_arena_init {
+ public:
+ map_arena_init(UnsafeArena* arena) : arena_(arena) { }
+ template<typename T> void operator ()(ManualConstructor<T>* map) const {
+ map->Init(typename T::key_compare(), arena_);
+ }
+ private:
+ UnsafeArena* arena_;
+};
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::LazilyCreateDict()
+// TemplateDictionary::LazilyCreateTemplateGlobalDict()
+// TemplateDictionary::CreateDictVector()
+// TemplateDictionary::CreateTemplateSubdict()
+// These routines allocate the objects that TemplateDictionary
+// allocates (sub-dictionaries, variable maps, etc). Each
+// allocates memory on the arena, and instructs the STL objects
+// to use the arena for their own internal allocations as well.
+// ----------------------------------------------------------------------
+
+template<typename T>
+inline void TemplateDictionary::LazilyCreateDict(T** dict) {
+ if (*dict != NULL)
+ return;
+ // Placement new: construct the map in the memory used by *dict.
+ void* buffer = arena_->AllocAligned(sizeof(**dict),
+ BaseArena::kDefaultAlignment);
+ new (buffer) T(arena_);
+ *dict = reinterpret_cast<T*>(buffer);
+}
+
+inline void TemplateDictionary::LazyCreateTemplateGlobalDict() {
+ if (!template_global_dict_owner_->template_global_dict_) {
+ template_global_dict_owner_->template_global_dict_ =
+ CreateTemplateSubdict("Template Globals", arena_,
+ template_global_dict_owner_,
+ template_global_dict_owner_);
+ }
+}
+
+inline TemplateDictionary::DictVector* TemplateDictionary::CreateDictVector() {
+ void* buffer = arena_->AllocAligned(sizeof(DictVector),
+ BaseArena::kDefaultAlignment);
+ // Placement new: construct the vector in the memory used by buffer.
+ new (buffer) DictVector(arena_);
+ return reinterpret_cast<DictVector*>(buffer);
+}
+
+inline TemplateDictionary* TemplateDictionary::CreateTemplateSubdict(
+ const TemplateString& name,
+ UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner) {
+ void* buffer = arena->AllocAligned(sizeof(TemplateDictionary),
+ BaseArena::kDefaultAlignment);
+ // Placement new: construct the sub-tpl in the memory used by tplbuf.
+ new (buffer) TemplateDictionary(name, arena, parent_dict,
+ template_global_dict_owner);
+ return reinterpret_cast<TemplateDictionary*>(buffer);
+}
+
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::HashInsert()
+// A convenience function that's equivalent to m[key] = value, but
+// converting the key to an id first, and without necessarily needing
+// key to have a default constructor like operator[] does. It also
+// inserts (key, id(key)) into a map to allow for id->key mapping.
+// ----------------------------------------------------------------------
+
+// By default, prefer the m[key] = value construct. We do something
+// more complex for TemplateString, though, since m[key] requires a
+// zero-arg constructor, which TemplateString doesn't have. We could
+// do the more complex thing everywhere, but that seems to trigger a
+// bug in in gcc 4.1.2 (at least) when compiled with -O2. Shrug.
+namespace {
+template<typename MapType, typename ValueType>
+inline void DoHashInsert(MapType* m, TemplateId id, ValueType value) {
+ (*m)[id] = value;
+}
+
+template<typename MapType>
+inline void DoHashInsert(MapType* m, TemplateId id, TemplateString value) {
+ pair<typename MapType::iterator, bool> r
+ = m->insert(typename MapType::value_type(id, value));
+ // Unfortunately, insert() doesn't actually replace if key is
+ // already in the map. Thus, in that case (insert().second == false),
+ // we need to overwrite the old value. Since TemplateString
+ // doesn't define operator=, the easiest legal way to overwrite is
+ // to use the copy-constructor with placement-new. Note that since
+ // TemplateString has no destructor, we don't need to call the
+ // destructor to 'clear out' the old value.
+ if (r.second == false) {
+ new (&r.first->second) TemplateString(value);
+ }
+}
+}
+
+template<typename MapType, typename ValueType>
+void TemplateDictionary::HashInsert(MapType* m,
+ TemplateString key, ValueType value) {
+ const TemplateId id = key.GetGlobalId();
+ DoHashInsert(m, id, value);
+ AddToIdToNameMap(id, key); // allows us to do the hash-key -> name mapping
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::SetupGlobalDict()
+// Must be called exactly once before accessing global_dict_.
+// GoogleOnceInit() is used to manage that initialization in a thread-safe
+// way.
+// ----------------------------------------------------------------------
+/*static*/ void TemplateDictionary::SetupGlobalDict()
+ NO_THREAD_SAFETY_ANALYSIS {
+ global_dict_ = new TemplateDictionary::GlobalDict;
+ // Initialize the built-ins
+ HashInsert(global_dict_, TemplateString("BI_SPACE"), TemplateString(" "));
+ HashInsert(global_dict_, TemplateString("BI_NEWLINE"), TemplateString("\n"));
+ // This is used for name-lookup misses.
+ empty_string_ = new TemplateString("");
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::TemplateDictionary()
+// TemplateDictionary::~TemplateDictionary()
+// The only tricky thing is that we make sure the static vars are
+// set up properly. This must be done at each construct time,
+// because it's the responsibility of the first dictionary created
+// in the program to set up the globals, and that could be us.
+// The UnsafeArena() argument is how big to make each arena
+// block. Too big and space is wasted. Too small and we spend
+// a lot of time allocating new arena blocks. 32k seems right.
+// ----------------------------------------------------------------------
+
+TemplateDictionary::TemplateDictionary(const TemplateString& name,
+ UnsafeArena* arena)
+ : arena_(arena ? arena : new UnsafeArena(32768)),
+ should_delete_arena_(arena ? false : true), // true if we called new
+ name_(Memdup(name)), // arena must have been set up first
+ variable_dict_(NULL),
+ section_dict_(NULL),
+ include_dict_(NULL),
+ template_global_dict_(NULL),
+ template_global_dict_owner_(this),
+ parent_dict_(NULL),
+ filename_(NULL) {
+ GoogleOnceInit(&g_once, &SetupGlobalDict);
+}
+
+TemplateDictionary::TemplateDictionary(
+ const TemplateString& name,
+ UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner)
+ : arena_(arena), should_delete_arena_(false), // parents own it
+ name_(Memdup(name)), // arena must have been set up first
+ variable_dict_(NULL),
+ section_dict_(NULL),
+ include_dict_(NULL),
+ template_global_dict_(NULL),
+ template_global_dict_owner_(template_global_dict_owner),
+ parent_dict_(parent_dict),
+ filename_(NULL) {
+ assert(template_global_dict_owner_ != NULL);
+ GoogleOnceInit(&g_once, &SetupGlobalDict);
+}
+
+TemplateDictionary::~TemplateDictionary() {
+ // Everything we allocate, we allocate on the arena, so we
+ // don't need to free anything here.
+ if (should_delete_arena_) {
+ delete arena_;
+ }
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::MakeCopy()
+// Makes a recursive copy: so we copy any include dictionaries and
+// section dictionaries we see as well. InternalMakeCopy() is
+// needed just so we can ensure that if we're doing a copy of a
+// subtree, it's due to a recursive call. Returns NULL if there
+// is an error copying.
+// ----------------------------------------------------------------------
+
+TemplateDictionary* TemplateDictionary::InternalMakeCopy(
+ const TemplateString& name_of_copy,
+ UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner) {
+
+ TemplateDictionary* newdict;
+ if (template_global_dict_owner_ == this) {
+ // We're a root-level template. We want the copy to be just like
+ // us, and have its own template_global_dict_, that it owns.
+ // We use the normal global new, since newdict will be returned
+ // to the user.
+ newdict = new TemplateDictionary(name_of_copy, arena);
+ } else { // recursive calls use private contructor
+ // We're not a root-level template, so we want the copy to refer to the
+ // same template_global_dict_ owner that we do.
+ // Note: we always use our own arena, even when we have a parent
+ // (though we have the same arena as our parent when we have one).
+ assert(arena);
+ assert(parent_dict ? arena == parent_dict->arena_ : true);
+ newdict = CreateTemplateSubdict(name_of_copy, arena,
+ parent_dict, template_global_dict_owner);
+ }
+
+ // Copy the variable dictionary
+ if (variable_dict_) {
+ newdict->LazilyCreateDict(&newdict->variable_dict_);
+ for (VariableDict::const_iterator it = variable_dict_->begin();
+ it != variable_dict_->end(); ++it) {
+ newdict->variable_dict_->insert(make_pair(it->first,
+ newdict->Memdup(it->second)));
+ }
+ }
+ // ...and the template-global-dict, if we have one (only root-level tpls do)
+ if (template_global_dict_) {
+ newdict->template_global_dict_ = template_global_dict_->InternalMakeCopy(
+ template_global_dict_->name(), newdict->arena_, newdict,
+ newdict->template_global_dict_owner_);
+ }
+ // Copy the section dictionary
+ if (section_dict_) {
+ newdict->LazilyCreateDict(&newdict->section_dict_);
+ for (SectionDict::iterator it = section_dict_->begin();
+ it != section_dict_->end(); ++it) {
+ DictVector* dicts = newdict->CreateDictVector();
+ newdict->section_dict_->insert(make_pair(it->first, dicts));
+ for (DictVector::iterator it2 = it->second->begin();
+ it2 != it->second->end(); ++it2) {
+ TemplateDictionary* subdict = *it2;
+ // In this case, we pass in newdict as the parent of our new dict.
+ dicts->push_back(subdict->InternalMakeCopy(
+ subdict->name(), newdict->arena_,
+ newdict, newdict->template_global_dict_owner_));
+ }
+ }
+ }
+ // Copy the includes-dictionary
+ if (include_dict_) {
+ newdict->LazilyCreateDict(&newdict->include_dict_);
+ for (IncludeDict::iterator it = include_dict_->begin();
+ it != include_dict_->end(); ++it) {
+ DictVector* dicts = newdict->CreateDictVector();
+ newdict->include_dict_->insert(make_pair(it->first, dicts));
+ for (DictVector::iterator it2 = it->second->begin();
+ it2 != it->second->end(); ++it2) {
+ TemplateDictionary* subdict = *it2;
+ // In this case, we pass in NULL as the parent of our new dict:
+ // parents are not inherited across include-dictionaries.
+ dicts->push_back(subdict->InternalMakeCopy(
+ subdict->name(), newdict->arena_,
+ NULL, newdict->template_global_dict_owner_));
+ }
+ }
+ }
+
+ // Finally, copy everything else not set properly by the constructor
+ newdict->filename_ = newdict->Memdup(filename_).ptr_;
+
+ return newdict;
+}
+
+TemplateDictionary* TemplateDictionary::MakeCopy(
+ const TemplateString& name_of_copy, UnsafeArena* arena) {
+ if (template_global_dict_owner_ != this) {
+ // We're not at the root, which is illegal.
+ return NULL;
+ }
+ return InternalMakeCopy(name_of_copy, arena,
+ NULL, template_global_dict_owner_);
+}
+
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::StringAppendV()
+// Does an snprintf to a string. Idea is to grow string as needed.
+// Writes to space if possible -- caller must ensure space has
+// size at least 1024 -- and if not allocates a buffer of its
+// own which the caller must free. Sets out to the buffer written
+// to (space or something else). Returns the number of bytes
+// written into out.
+// ----------------------------------------------------------------------
+
+int TemplateDictionary::StringAppendV(char* space, char** out,
+ const char* format, va_list ap) {
+ const int kBufsize = 1024;
+ // It's possible for methods that use a va_list to invalidate
+ // the data in it upon use. The fix is to make a copy
+ // of the structure before using it and use that copy instead.
+ va_list backup_ap;
+ va_copy(backup_ap, ap);
+ int result = vsnprintf(space, kBufsize, format, backup_ap);
+ va_end(backup_ap);
+
+ if ((result >= 0) && (result < kBufsize)) {
+ *out = space;
+ return result; // It fit
+ }
+
+ // Repeatedly increase buffer size until it fits
+ int length = kBufsize;
+ while (true) {
+ if (result < 0) {
+ // Older snprintf() behavior. :-( Just try doubling the buffer size
+ length *= 2;
+ } else {
+ // We need exactly "result+1" characters
+ length = result+1;
+ }
+ char* buf = new char[length];
+
+ // Restore the va_list before we use it again
+ va_copy(backup_ap, ap);
+ result = vsnprintf(buf, length, format, backup_ap);
+ va_end(backup_ap);
+
+ if ((result >= 0) && (result < length)) {
+ *out = buf;
+ return result;
+ }
+ delete[] buf;
+ }
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::SetValue()
+// TemplateDictionary::SetIntValue()
+// TemplateDictionary::SetFormattedValue()
+// TemplateDictionary::SetEscapedValue()
+// TemplateDictionary::SetEscapedFormattedValue()
+// The functions to set the value of a variable. For each,
+// I first define the char*+length version. Then, after those
+// five definitions, I define a zillion alternate versions:
+// strings, char*s, etc. The only non-obvious thing about
+// each function is I make sure to copy both key and value to
+// the arena, so we have our own, persistent copy of them.
+// ----------------------------------------------------------------------
+
+void TemplateDictionary::SetValue(const TemplateString variable,
+ const TemplateString value) {
+ LazilyCreateDict(&variable_dict_);
+ HashInsert(variable_dict_, variable, Memdup(value));
+}
+
+void TemplateDictionary::SetValueWithoutCopy(const TemplateString variable,
+ const TemplateString value) {
+ LazilyCreateDict(&variable_dict_);
+ // Don't memdup value - the caller will manage memory.
+ HashInsert(variable_dict_, variable, value);
+}
+
+void TemplateDictionary::SetIntValue(const TemplateString variable,
+ long value) {
+ char buffer[64]; // big enough for any int
+ int valuelen = snprintf(buffer, sizeof(buffer), "%ld", value);
+ LazilyCreateDict(&variable_dict_);
+ HashInsert(variable_dict_, variable, Memdup(buffer, valuelen));
+}
+
+void TemplateDictionary::SetFormattedValue(const TemplateString variable,
+ const char* format, ...) {
+ char* buffer;
+
+ char* scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes
+ va_list ap;
+ va_start(ap, format);
+ const int buflen = StringAppendV(scratch, &buffer, format, ap);
+ va_end(ap);
+
+ LazilyCreateDict(&variable_dict_);
+
+ // If it fit into scratch, great, otherwise we need to copy into arena
+ if (buffer == scratch) {
+ scratch = arena_->Shrink(scratch, buflen+1); // from 1024 to |value+\0|
+ HashInsert(variable_dict_, variable, TemplateString(scratch, buflen));
+ } else {
+ arena_->Shrink(scratch, 0); // reclaim arena space we didn't use
+ HashInsert(variable_dict_, variable, Memdup(buffer, buflen));
+ delete[] buffer;
+ }
+}
+
+void TemplateDictionary::SetEscapedValue(TemplateString variable,
+ TemplateString value,
+ const TemplateModifier& escfn) {
+ SetValue(variable, string(escfn(value.data(), value.size())));
+}
+
+void TemplateDictionary::SetEscapedFormattedValue(TemplateString variable,
+ const TemplateModifier& escfn,
+ const char* format, ...) {
+ char* buffer;
+
+ char* scratch = arena_->Alloc(1024); // StringAppendV requires >=1024 bytes
+ va_list ap;
+ va_start(ap, format);
+ const int buflen = StringAppendV(scratch, &buffer, format, ap);
+ va_end(ap);
+
+ string escaped_string(escfn(buffer, buflen));
+ // Reclaim the arena space: the value we care about is now in escaped_string
+ arena_->Shrink(scratch, 0); // reclaim arena space we didn't use
+ if (buffer != scratch)
+ delete[] buffer;
+
+ SetValue(variable, escaped_string);
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::SetTemplateGlobalValue()
+// Sets a value in the template-global dict. Unlike normal
+// variable lookups, these persist across sub-includes.
+// ----------------------------------------------------------------------
+
+void TemplateDictionary::SetTemplateGlobalValue(const TemplateString variable,
+ const TemplateString value) {
+ assert(template_global_dict_owner_ != NULL);
+ LazyCreateTemplateGlobalDict();
+ template_global_dict_owner_->template_global_dict_->SetValue(variable, value);
+}
+
+void TemplateDictionary::SetTemplateGlobalValueWithoutCopy(
+ const TemplateString variable,
+ const TemplateString value) {
+ assert(template_global_dict_owner_ != NULL);
+ LazyCreateTemplateGlobalDict();
+ // Don't memdup value - the caller will manage memory.
+ template_global_dict_owner_->template_global_dict_->
+ SetValueWithoutCopy(variable, value);
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::SetGlobalValue()
+// Sets a value in the global dict. Note this is a static method.
+// ----------------------------------------------------------------------
+
+/*static*/ void TemplateDictionary::SetGlobalValue(
+ const TemplateString variable,
+ const TemplateString value) LOCKS_EXCLUDED(g_static_mutex) {
+ // We can't use memdup here, since we're a static method. We do a strdup,
+ // which is fine, since global_dict_ lives the entire program anyway.
+ // It's unnecessary to copy the variable, since HashInsert takes care of
+ // that for us.
+ char* value_copy = new char[value.length_ + 1];
+ memcpy(value_copy, value.ptr_, value.length_);
+ value_copy[value.length_] = '\0';
+
+ GoogleOnceInit(&g_once, &SetupGlobalDict);
+
+ MutexLock ml(&g_static_mutex);
+ HashInsert(global_dict_,
+ variable,
+ TemplateString(value_copy, value.length_));
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::AddSectionDictionary()
+// TemplateDictionary::ShowSection()
+// TemplateDictionary::ShowTemplateGlobalSection()
+// The new dictionary starts out empty, with us as the parent.
+// It shares our arena. The name is constructed out of our
+// name plus the section name. ShowSection() is the equivalent
+// to AddSectionDictionary("empty_dict").
+// ----------------------------------------------------------------------
+
+/*static*/ string TemplateDictionary::CreateSubdictName(
+ const TemplateString& dict_name, const TemplateString& sub_name,
+ size_t index, const char* suffix) {
+ char index_str[64];
+ snprintf(index_str, sizeof(index_str), "%" PRIuS, index);
+ return (PrintableTemplateString(dict_name) + "/" +
+ PrintableTemplateString(sub_name) + "#" + index_str + suffix);
+}
+
+TemplateDictionary* TemplateDictionary::AddSectionDictionary(
+ const TemplateString section_name) {
+ LazilyCreateDict(§ion_dict_);
+ DictVector* dicts = find_ptr2(*section_dict_, section_name.GetGlobalId());
+ if (!dicts) {
+ dicts = CreateDictVector();
+ // Since most lists will remain under 8 or 16 entries but will frequently
+ // be more than four, this prevents copying from 1->2->4->8.
+ dicts->reserve(8);
+ HashInsert(section_dict_, section_name, dicts);
+ }
+ assert(dicts != NULL);
+ const string newname(CreateSubdictName(name_, section_name,
+ dicts->size() + 1, ""));
+ TemplateDictionary* retval = CreateTemplateSubdict(
+ newname, arena_, this, template_global_dict_owner_);
+ dicts->push_back(retval);
+ return retval;
+}
+
+
+void TemplateDictionary::ShowSection(const TemplateString section_name) {
+ LazilyCreateDict(§ion_dict_);
+ if (!section_dict_->count(section_name.GetGlobalId())) {
+ TemplateDictionary* empty_dict = CreateTemplateSubdict(
+ "empty dictionary", arena_, this, template_global_dict_owner_);
+ DictVector* sub_dict = CreateDictVector();
+ sub_dict->push_back(empty_dict);
+ HashInsert(section_dict_, section_name, sub_dict);
+ }
+}
+
+void TemplateDictionary::ShowTemplateGlobalSection(
+ const TemplateString section_name) {
+ assert(template_global_dict_owner_ != NULL);
+ LazyCreateTemplateGlobalDict();
+ template_global_dict_owner_->template_global_dict_->
+ ShowSection(section_name);
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::SetValueAndShowSection()
+// TemplateDictionary::SetEscapedValueAndShowSection()
+// If value is "", do nothing. Otherwise, call AddSectionDictionary()
+// on the section and add exactly one entry to the sub-dictionary:
+// the given variable/value pair.
+// ----------------------------------------------------------------------
+
+void TemplateDictionary::SetValueAndShowSection(const TemplateString variable,
+ const TemplateString value,
+ const TemplateString section_name) {
+ if (value.length_ == 0) // no value: the do-nothing case
+ return;
+ TemplateDictionary* sub_dict = AddSectionDictionary(section_name);
+ sub_dict->SetValue(variable, value);
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::AddIncludeDictionary()
+// This is much like AddSectionDictionary(). One major difference
+// is that the new dictionary does not have a parent dictionary:
+// there's no automatic variable inclusion across template-file
+// boundaries. Note there is no ShowTemplate() -- you must always
+// specify the dictionary to use explicitly.
+// ----------------------------------------------------------------------
+
+TemplateDictionary* TemplateDictionary::AddIncludeDictionary(
+ const TemplateString include_name) {
+ LazilyCreateDict(&include_dict_);
+ DictVector* dicts = find_ptr2(*include_dict_, include_name.GetGlobalId());
+ if (!dicts) {
+ dicts = CreateDictVector();
+ HashInsert(include_dict_, include_name, dicts);
+ }
+ assert(dicts != NULL);
+ const string newname(CreateSubdictName(name_, include_name,
+ dicts->size() + 1, ""));
+ TemplateDictionary* retval = CreateTemplateSubdict(
+ newname, arena_, NULL, template_global_dict_owner_);
+ dicts->push_back(retval);
+ return retval;
+}
+
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::SetFilename()
+// Sets the filename this dictionary is meant to be associated with.
+// When set, it's possible to expand a template with just the
+// template-dict; the template is loaded via SetFilename() (though
+// we'd have to assume a value for strip). This is required for
+// dictionaries that are meant to be used with an include-template.
+// ----------------------------------------------------------------------
+
+void TemplateDictionary::SetFilename(const TemplateString filename) {
+ filename_ = Memdup(filename).ptr_;
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::AddToIdToNameMap()
+// We have a problem when we try to dump the contents of the
+// dictionary, because instead of storing the keys to global_dict_
+// etc as strings, we store them as integer id's. We need this
+// map, from id->string, to be able to dump. This should be called
+// every time we add a string to a TemplateDictionary hashtable.
+// ----------------------------------------------------------------------
+
+/*static*/ void TemplateDictionary::AddToIdToNameMap(TemplateId id,
+ const TemplateString& str) {
+ // If str.id_ is set, that means we were added to the id-to-name map
+ // at TemplateString constructor time, when the id_ was set. So we
+ // don't need to bother again here.
+ if (str.id_ != 0) {
+ return;
+ }
+ // Verify that if this id is already in the map, it's there with our
+ // contents. If not, that would mean a hash collision (since our
+ // id's are hash values).
+ DCHECK(TemplateString::IdToString(id) == kStsEmpty ||
+ memcmp(str.ptr_, TemplateString::IdToString(id).ptr_,
+ str.length_) == 0)
+ << string(str.ptr_, str.length_) << " vs "
+ << string(TemplateString::IdToString(id).ptr_,
+ TemplateString::IdToString(id).length_);
+ TemplateString str_with_id(str.ptr_, str.length_, str.is_immutable(), id);
+ str_with_id.AddToGlobalIdToNameMap();
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::DumpToString()
+// TemplateDictionary::Dump()
+// The values are shown in the following order:
+// - Scalar values
+// - Sub-dictionaries and their associated section names.
+// - Sub-dictionaries and their associated template names, with filename.
+// ----------------------------------------------------------------------
+
+// DictionaryPrinter knows how to dump a whole dictionary tree.
+class TemplateDictionary::DictionaryPrinter {
+ public:
+ DictionaryPrinter(string* out, int initial_indent)
+ : writer_(out, initial_indent) {
+ }
+
+ void DumpToString(const TemplateDictionary& dict) {
+ // Show globals if we're a top-level dictionary
+ if (dict.parent_dict_ == NULL) {
+ DumpGlobals();
+ }
+
+ // Show template-globals
+ if (dict.template_global_dict_ && !dict.template_global_dict_->Empty()) {
+ DumpTemplateGlobals(*dict.template_global_dict_);
+ }
+
+ DumpDictionary(dict);
+ }
+
+ private:
+ void FillSortedGlobalDictMap(map<string, string>* sorted_global_dict)
+ LOCKS_EXCLUDED(g_static_mutex) {
+ ReaderMutexLock ml(&g_static_mutex);
+ for (GlobalDict::const_iterator it = global_dict_->begin();
+ it != global_dict_->end(); ++it) {
+ const TemplateString key = TemplateDictionary::IdToString(it->first);
+ assert(!InvalidTemplateString(key)); // checks key.ptr_ != NULL
+ (*sorted_global_dict)[PrintableTemplateString(key)] =
+ PrintableTemplateString(it->second);
+ }
+ }
+ void DumpGlobals() {
+ writer_.Write("global dictionary {\n");
+ writer_.Indent();
+
+ // We could be faster than converting every TemplateString into a
+ // string and inserted into an ordered data structure, but why bother?
+ map<string, string> sorted_global_dict;
+ FillSortedGlobalDictMap(&sorted_global_dict);
+ for (map<string, string>::const_iterator it = sorted_global_dict.begin();
+ it != sorted_global_dict.end(); ++it) {
+ writer_.Write(it->first + ": >" + it->second + "<\n");
+ }
+
+ writer_.Dedent();
+ writer_.Write("};\n");
+ }
+
+ void DumpTemplateGlobals(const TemplateDictionary& template_global_dict) {
+ writer_.Write("template dictionary {\n");
+ writer_.Indent();
+ DumpDictionaryContent(template_global_dict);
+ writer_.Dedent();
+ writer_.Write("};\n");
+ }
+
+ void DumpDictionary(const TemplateDictionary& dict) {
+ string intended_for = dict.filename_ && dict.filename_[0] ?
+ string(" (intended for ") + dict.filename_ + ")" : "";
+ writer_.Write("dictionary '", PrintableTemplateString(dict.name_),
+ intended_for, "' {\n");
+ writer_.Indent();
+ DumpDictionaryContent(dict);
+ writer_.Dedent();
+ writer_.Write("}\n");
+ }
+
+ void DumpDictionaryContent(const TemplateDictionary& dict) {
+ if (dict.variable_dict_) { // Show variables
+ DumpVariables(*dict.variable_dict_);
+ }
+
+
+ if (dict.section_dict_) { // Show section sub-dictionaries
+ DumpSectionDict(*dict.section_dict_);
+ }
+
+
+ if (dict.include_dict_) { // Show template-include sub-dictionaries
+ DumpIncludeDict(*dict.include_dict_);
+ }
+ }
+
+ void DumpVariables(const VariableDict& dict) {
+ map<string, string> sorted_variable_dict;
+ for (VariableDict::const_iterator it = dict.begin();
+ it != dict.end(); ++it) {
+ const TemplateString key = TemplateDictionary::IdToString(it->first);
+ assert(!InvalidTemplateString(key)); // checks key.ptr_ != NULL
+ sorted_variable_dict[PrintableTemplateString(key)] =
+ PrintableTemplateString(it->second);
+ }
+ for (map<string,string>::const_iterator it = sorted_variable_dict.begin();
+ it != sorted_variable_dict.end(); ++it) {
+ writer_.Write(it->first + ": >" + it->second + "<\n");
+ }
+ }
+
+
+ template<typename MyMap, typename MySectionDict>
+ void SortSections(MyMap* sorted_section_dict,
+ const MySectionDict& section_dict) {
+ typename MySectionDict::const_iterator it = section_dict.begin();
+ for (; it != section_dict.end(); ++it) {
+ const TemplateString key = TemplateDictionary::IdToString(it->first);
+ assert(!InvalidTemplateString(key)); // checks key.ptr_ != NULL
+ (*sorted_section_dict)[PrintableTemplateString(key)] = it->second;
+ }
+ }
+
+ void DumpSectionDict(const SectionDict& section_dict) {
+ map<string, const DictVector*> sorted_section_dict;
+ SortSections(&sorted_section_dict, section_dict);
+ for (map<string, const DictVector*>::const_iterator it =
+ sorted_section_dict.begin();
+ it != sorted_section_dict.end(); ++it) {
+ for (DictVector::const_iterator it2 = it->second->begin();
+ it2 != it->second->end(); ++it2) {
+ TemplateDictionary* dict = *it2;
+ writer_.Write("section ", it->first, " (dict ",
+ GetDictNum(it2 - it->second->begin() + 1,
+ it->second->size()),
+ ") -->\n");
+ writer_.Indent();
+ DumpToString(*dict);
+ writer_.Dedent();
+ }
+ }
+ }
+
+ void DumpIncludeDict(const IncludeDict& include_dict) {
+ map<string, const DictVector*> sorted_include_dict;
+ SortSections(&sorted_include_dict, include_dict);
+ for (map<string, const DictVector*>::const_iterator it =
+ sorted_include_dict.begin();
+ it != sorted_include_dict.end(); ++it) {
+ for (vector<TemplateDictionary*>::size_type i = 0;
+ i < it->second->size(); ++i) {
+ TemplateDictionary* dict = (*it->second)[i];
+ string from_name = (dict->filename_ && *dict->filename_) ?
+ string(", from ") + dict->filename_ :
+ string(", **NO FILENAME SET; THIS DICT WILL BE IGNORED**");
+ writer_.Write("include-template ", it->first, " (dict ",
+ GetDictNum(static_cast<int>(i + 1), it->second->size()),
+ from_name, ") -->\n");
+ writer_.Indent();
+ DumpToString(*dict);
+ writer_.Dedent();
+ }
+ }
+ }
+
+ string GetDictNum(size_t index, size_t size) const {
+ char buf[64]; // big enough for two ints
+ snprintf(buf, sizeof(buf), "%" PRIuS " of %" PRIuS, index, size);
+ return buf;
+ }
+
+ IndentedWriter writer_;
+};
+
+void TemplateDictionary::DumpToString(string* out, int indent) const {
+ DictionaryPrinter printer(out, indent);
+ printer.DumpToString(*this);
+}
+
+void TemplateDictionary::Dump(int indent) const {
+ string out;
+ DumpToString(&out, indent);
+ fwrite(out.data(), 1, out.length(), stdout);
+ fflush(stdout);
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::Memdup()
+// Copy the input into the arena, so we have a permanent copy of
+// it. Returns a pointer to the arena-copy, as a TemplateString
+// (in case the input has internal NULs).
+// ----------------------------------------------------------------------
+
+TemplateString TemplateDictionary::Memdup(const char* s, size_t slen) {
+ return TemplateString(arena_->MemdupPlusNUL(s, slen), slen); // add a \0 too
+}
+
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::GetSectionValue()
+// TemplateDictionary::IsHiddenSection()
+// TemplateDictionary::IsHiddenTemplate()
+// TemplateDictionary::GetIncludeTemplateName()
+// The 'introspection' routines that tell Expand() what's in the
+// template dictionary. GetSectionValue() does variable lookup:
+// first look in this dict, then in parent dicts, etc. IsHidden*()
+// returns true iff the name is not present in the appropriate
+// dictionary. None of these functions ever returns NULL.
+// ----------------------------------------------------------------------
+
+TemplateString TemplateDictionary::GetValue(
+ const TemplateString& variable) const LOCKS_EXCLUDED(g_static_mutex) {
+ for (const TemplateDictionary* d = this; d; d = d->parent_dict_) {
+ if (d->variable_dict_) {
+ if (const TemplateString* it = find_ptr(*d->variable_dict_, variable.GetGlobalId()))
+ return *it;
+ }
+ }
+
+ // No match in the dict tree. Check the template-global dict.
+ assert(template_global_dict_owner_ != NULL);
+ if (template_global_dict_owner_->template_global_dict_
+ && template_global_dict_owner_->template_global_dict_->variable_dict_) {
+ const VariableDict* template_global_vars =
+ template_global_dict_owner_->template_global_dict_->variable_dict_;
+
+ if (const TemplateString* it = find_ptr(*template_global_vars, variable.GetGlobalId()))
+ return *it;
+ }
+
+ // No match in dict tree or template-global dict. Last chance: global dict.
+ {
+ ReaderMutexLock ml(&g_static_mutex);
+ if (const TemplateString* it = find_ptr(*global_dict_, variable.GetGlobalId()))
+ return *it;
+ return *empty_string_;
+ }
+}
+
+bool TemplateDictionary::IsHiddenSection(const TemplateString& name) const {
+ for (const TemplateDictionary* d = this; d; d = d->parent_dict_) {
+ if (d->section_dict_ &&
+ d->section_dict_->count(name.GetGlobalId()))
+ return false;
+ }
+ assert(template_global_dict_owner_ != NULL);
+ if (template_global_dict_owner_->template_global_dict_ &&
+ template_global_dict_owner_->template_global_dict_->section_dict_) {
+ SectionDict* sections =
+ template_global_dict_owner_->template_global_dict_->section_dict_;
+ if (sections->count(name.GetGlobalId())) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool TemplateDictionary::IsHiddenTemplate(const TemplateString& name) const {
+ for (const TemplateDictionary* d = this; d; d = d->parent_dict_) {
+ if (d->include_dict_ &&
+ d->include_dict_->count(name.GetGlobalId()))
+ return false;
+ }
+ return true;
+}
+
+const char *TemplateDictionary::GetIncludeTemplateName(
+ const TemplateString& variable, int dictnum) const {
+ for (const TemplateDictionary* d = this; d; d = d->parent_dict_) {
+ if (d->include_dict_) {
+ if (DictVector* it = find_ptr2(*d->include_dict_, variable.GetGlobalId())) {
+ TemplateDictionary* dict = (*it)[dictnum];
+ return dict->filename_ ? dict->filename_ : ""; // map NULL to ""
+ }
+ }
+ }
+ assert("Call IsHiddenTemplate before GetIncludeTemplateName" && 0);
+ abort();
+}
+
+bool TemplateDictionary::Empty() const {
+ if ((variable_dict_ && !variable_dict_->empty()) ||
+ (section_dict_ && section_dict_->empty()) ||
+ (include_dict_ && include_dict_->empty())) {
+ return false;
+ }
+ return true;
+}
+
+// ----------------------------------------------------------------------
+// TemplateDictionary::CreateSectionIterator()
+// TemplateDictionary::CreateTemplateIterator()
+// TemplateDictionary::Iterator::HasNext()
+// TemplateDictionary::Iterator::Next()
+// Iterator framework.
+// ----------------------------------------------------------------------
+
+template <typename T> bool TemplateDictionary::Iterator<T>::HasNext() const {
+ return begin_ != end_;
+}
+
+template <typename T> const TemplateDictionaryInterface&
+TemplateDictionary::Iterator<T>::Next() {
+ return **(begin_++);
+}
+
+TemplateDictionaryInterface::Iterator*
+TemplateDictionary::CreateTemplateIterator(
+ const TemplateString& section_name) const {
+ for (const TemplateDictionary* d = this; d; d = d->parent_dict_) {
+ if (d->include_dict_) {
+ if (DictVector* it = find_ptr2(*d->include_dict_, section_name.GetGlobalId())) {
+ // Found it! Return it as an Iterator
+ return MakeIterator(*it);
+ }
+ }
+ }
+ assert("Call IsHiddenTemplate before CreateTemplateIterator" && 0);
+ abort();
+}
+
+TemplateDictionaryInterface::Iterator*
+TemplateDictionary::CreateSectionIterator(
+ const TemplateString& section_name) const {
+ for (const TemplateDictionary* d = this; d; d = d->parent_dict_) {
+ if (d->section_dict_) {
+ if (const DictVector* it = find_ptr2(*d->section_dict_, section_name.GetGlobalId())) {
+ // Found it! Return it as an Iterator
+ return MakeIterator(*it);
+ }
+ }
+ }
+ // Check the template global dictionary.
+ assert(template_global_dict_owner_);
+ const TemplateDictionary* template_global_dict =
+ template_global_dict_owner_->template_global_dict_;
+ if (template_global_dict && template_global_dict->section_dict_) {
+ if (const DictVector* it = find_ptr2(*template_global_dict->section_dict_, section_name.GetGlobalId())) {
+ return MakeIterator(*it);
+ }
+ }
+ assert("Call IsHiddenSection before GetDictionaries" && 0);
+ abort();
+}
+
+}
diff --git a/src/template_modifiers.cc b/src/template_modifiers.cc
new file mode 100644
index 0000000..4e35281
--- /dev/null
+++ b/src/template_modifiers.cc
@@ -0,0 +1,1417 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// template_modifiers.h has a description of what each escape-routine does.
+//
+// When creating a new modifier, you must subclass TemplateModifier
+// and define your own Modify() method. This method takes the string
+// to be modified as a char*/int pair. It then emits the modified
+// version of the string to outbuf. Outbuf is an ExpandEmitter, as
+// defined in template_modifiers.h. It's a very simple type that
+// supports appending to a data stream.
+//
+// Be very careful editing an existing modifier. Subtle changes can
+// introduce the possibility for cross-site scripting attacks. If you
+// do change a modifier, be careful that it does not affect
+// the list of Safe XSS Alternatives.
+//
+
+#include <config.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <string>
+#include <vector>
+#include "htmlparser/htmlparser_cpp.h"
+#include <ctemplate/template_modifiers.h>
+#include "template_modifiers_internal.h"
+#include <ctemplate/per_expand_data.h>
+using std::string;
+using std::vector;
+
+#define strliterallen(s) (sizeof("" s "") - 1)
+
+// Really we should be using uint_16_t or something, but this is good
+// enough, and more portable...
+typedef unsigned int uint16;
+
+namespace URL {
+bool HasInsecureProtocol(const char* in, int inlen) {
+ if (inlen > strliterallen("http://") &&
+ strncasecmp(in, "http://", strliterallen("http://")) == 0) {
+ return false; // We're ok, it's an http protocol
+ }
+ if (inlen > strliterallen("https://") &&
+ strncasecmp(in, "https://", strliterallen("https://")) == 0) {
+ return false; // https is ok as well
+ }
+ if (inlen > strliterallen("ftp://") &&
+ strncasecmp(in, "ftp://", strliterallen("ftp://")) == 0) {
+ return false; // and ftp
+ }
+ return true;
+}
+} // namespace URL
+
+namespace ctemplate {
+
+using ctemplate_htmlparser::HtmlParser;
+
+// A most-efficient way to append a string literal to the var named 'out'.
+// The ""s ensure literal is actually a string literal
+#define APPEND(literal) out->Emit("" literal "", sizeof(literal)-1)
+
+// Check whether the string of length len is identical to the literal.
+// The ""s ensure literal is actually a string literal
+#define STR_IS(str, len, literal) \
+ ((len) == sizeof("" literal "") - 1 && \
+ memcmp(str, literal, sizeof("" literal "") - 1) == 0)
+
+TemplateModifier::~TemplateModifier() {}
+
+void NullModifier::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ out->Emit(in, inlen);
+}
+NullModifier null_modifier;
+
+static inline void EmitRun(const char* start, const char* limit,
+ ExpandEmitter* out) {
+ if (start < limit) {
+ out->Emit(start, (limit - start));
+ }
+}
+
+void HtmlEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ const char* pos = in;
+ const char* start = pos;
+ const char* const limit = in + inlen;
+ while (pos < limit) {
+ switch (*pos) {
+ default:
+ // Increment our counter and look at the next character.
+ ++pos;
+ continue;
+
+ case '&': EmitRun(start, pos, out); APPEND("&"); break;
+ case '"': EmitRun(start, pos, out); APPEND("""); break;
+ case '\'': EmitRun(start, pos, out); APPEND("'"); break;
+ case '<': EmitRun(start, pos, out); APPEND("<"); break;
+ case '>': EmitRun(start, pos, out); APPEND(">"); break;
+
+ case '\r': case '\n': case '\v': case '\f': case '\t':
+ EmitRun(start, pos, out); APPEND(" "); break;
+ }
+ start = ++pos;
+ }
+ EmitRun(start, pos, out);
+}
+HtmlEscape html_escape;
+
+void PreEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ const char* pos = in;
+ const char* start = pos;
+ const char* const limit = in + inlen;
+ while (pos < limit) {
+ switch (*pos) {
+ default:
+ // Increment our counter and look at the next character.
+ ++pos;
+ continue;
+
+ // Unlike HtmlEscape, we leave whitespace as is.
+ case '&': EmitRun(start, pos, out); APPEND("&"); break;
+ case '"': EmitRun(start, pos, out); APPEND("""); break;
+ case '\'': EmitRun(start, pos, out); APPEND("'"); break;
+ case '<': EmitRun(start, pos, out); APPEND("<"); break;
+ case '>': EmitRun(start, pos, out); APPEND(">"); break;
+ }
+ start = ++pos;
+ }
+ EmitRun(start, pos, out);
+}
+PreEscape pre_escape;
+
+// We encode the presence and ordering of unclosed tags in a string, using the
+// letters b, i, s, and e to stand for <b>, <i>, <span>, and <em> respectively.
+// The most recently opened tag is appended onto the end of the string, so in
+// the common case of properly nested tags, we need only look at the last
+// character. If we don't find it there, we need to continue looking at
+// everything until we find it, because tags may not necessarily be in order.
+// Similarly, when we add a tag, we need to check each existing tag for a match
+// so that we don't nest.
+class UnclosedSnippetTags {
+ public:
+ // We could use ordinary ints for the enum values, but using mnemonic
+ // characters potentially makes debugging easier.
+ typedef enum {
+ TAG_B = 'b',
+ TAG_I = 'i',
+ TAG_EM = 'e',
+ TAG_SPAN = 's',
+ } Tag;
+
+ UnclosedSnippetTags() : tag_length(0) {
+ memset(tags, 0, 5);
+ }
+
+ // Adds a tag to the set of open tags if it's not already open, or otherwise
+ // return false.
+ inline bool MaybeAdd(Tag tag) {
+ if (strchr(tags, tag)) {
+ return false;
+ } else {
+ tags[tag_length++] = tag;
+ return true;
+ }
+ }
+
+ // Removes a tag from the set of open tags if it's open, or otherwise return
+ // false.
+ inline bool MaybeRemove(Tag tag) {
+ char* tag_location = strchr(tags, tag);
+ if (tag_location) {
+ for (char* c = tag_location; *c; ++c) {
+ // Have to copy all later tags down by one so we don't leave a gap in the
+ // array.
+ *c = *(c + 1);
+ }
+ --tag_length;
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ inline void PrintClosingTags(ExpandEmitter* out) {
+ for (int i = tag_length; i >= 0; --i) {
+ switch (tags[i]) {
+ case TAG_B:
+ out->Emit("</b>"); break;
+ case TAG_I:
+ out->Emit("</i>"); break;
+ case TAG_EM:
+ out->Emit("</em>"); break;
+ case TAG_SPAN:
+ out->Emit("</span>"); break;
+ }
+ }
+ }
+
+ private:
+ char tags[5];
+ int tag_length;
+};
+
+void SnippetEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ UnclosedSnippetTags unclosed;
+ const char* pos = in;
+ const char* start = pos;
+ const char* const limit = in + inlen;
+ while (pos < limit) {
+ switch (*pos) {
+ default:
+ // Increment our counter and look at the next character.
+ ++pos;
+ continue;
+
+ case '<': {
+ // If there is a permissible tag, just advance pos past it to
+ // make it part of the current run. Notice the use of
+ // "continue" below.
+ const char* const next_pos = pos + 1;
+ const int chars_left = limit - next_pos;
+ if ((chars_left >= 2) && !memcmp(next_pos, "b>", 2)
+ && unclosed.MaybeAdd(UnclosedSnippetTags::TAG_B)) {
+ pos += strliterallen("<b>");
+ continue;
+ } else if ((chars_left >= 2) && !memcmp(next_pos, "i>", 2)
+ && unclosed.MaybeAdd(UnclosedSnippetTags::TAG_I)) {
+ pos += strliterallen("<i>");
+ continue;
+ } else if ((chars_left >= 3) && !memcmp(next_pos, "em>", 3)
+ && unclosed.MaybeAdd(UnclosedSnippetTags::TAG_EM)) {
+ pos += strliterallen("<em>");
+ continue;
+ } else if ((chars_left >= 13) && !memcmp(next_pos, "span dir=", 9)
+ && (!memcmp(next_pos + 9, "ltr>", 4) ||
+ !memcmp(next_pos + 9, "rtl>", 4))
+ && unclosed.MaybeAdd(UnclosedSnippetTags::TAG_SPAN)) {
+ pos += strliterallen("<span dir=ltr>");
+ continue;
+ } else if ((chars_left >= 3) && !memcmp(next_pos, "/b>", 3)
+ && unclosed.MaybeRemove(UnclosedSnippetTags::TAG_B)) {
+ pos += strliterallen("</b>");
+ continue;
+ } else if ((chars_left >= 3) && !memcmp(next_pos, "/i>", 3)
+ && unclosed.MaybeRemove(UnclosedSnippetTags::TAG_I)) {
+ pos += strliterallen("</i>");
+ continue;
+ } else if ((chars_left >= 4) && !memcmp(next_pos, "/em>", 4)
+ && unclosed.MaybeRemove(UnclosedSnippetTags::TAG_EM)) {
+ pos += strliterallen("</em>");
+ continue;
+ } else if ((chars_left >= 6) && !memcmp(next_pos, "/span>", 6)
+ && unclosed.MaybeRemove(UnclosedSnippetTags::TAG_SPAN)) {
+ pos += strliterallen("</span>");
+ continue;
+ } else if ((chars_left >= 3) && !memcmp(next_pos, "br>", 3)) {
+ pos += strliterallen("<br>");
+ continue;
+ } else if ((chars_left >= 4) && !memcmp(next_pos, "wbr>", 4)) {
+ pos += strliterallen("<wbr>");
+ continue;
+ }
+
+ // Emit the entity and break out of the switch.
+ EmitRun(start, pos, out);
+ APPEND("<");
+ break;
+ }
+
+ case '&':
+ EmitRun(start, pos, out);
+ if (pos + 1 < limit && pos[1] == '{') {
+ // Could be a javascript entity, so we need to escape.
+ // (Javascript entities are an xss risk in Netscape 4.)
+ APPEND("&");
+ } else {
+ APPEND("&");
+ }
+ break;
+
+ case '"': EmitRun(start, pos, out); APPEND("""); break;
+ case '\'': EmitRun(start, pos, out); APPEND("'"); break;
+ case '>': EmitRun(start, pos, out); APPEND(">"); break;
+
+ case '\r': case '\n': case '\v': case '\f': case '\t':
+ // non-space whitespace
+ EmitRun(start, pos, out); APPEND(" "); break;
+
+ }
+ start = ++pos;
+ }
+ EmitRun(start, pos, out);
+ unclosed.PrintClosingTags(out);
+}
+SnippetEscape snippet_escape;
+
+void CleanseAttribute::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ for (size_t i = 0; i < inlen; ++i) {
+ char c = in[i];
+ switch (c) {
+ case '=': {
+ if (i == 0 || i == (inlen - 1))
+ out->Emit('_');
+ else
+ out->Emit(c);
+ break;
+ }
+ case '-':
+ case '.':
+ case '_':
+ case ':': {
+ out->Emit(c);
+ break;
+ }
+ default: {
+ if ((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9')) {
+ out->Emit(c);
+ } else {
+ APPEND("_");
+ }
+ break;
+ }
+ }
+ }
+}
+CleanseAttribute cleanse_attribute;
+
+void CleanseCss::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ for (size_t i = 0; i < inlen; ++i) {
+ char c = in[i];
+ switch (c) {
+ case ' ':
+ case '_':
+ case '.':
+ case ',':
+ case '!':
+ case '#':
+ case '%':
+ case '-': {
+ out->Emit(c);
+ break;
+ }
+ default: {
+ if ((c >= 'a' && c <= 'z') ||
+ (c >= 'A' && c <= 'Z') ||
+ (c >= '0' && c <= '9')) {
+ out->Emit(c);
+ }
+ break;
+ }
+ }
+ }
+}
+CleanseCss cleanse_css;
+
+// CssUrlEscape is used as a chained modifier by ValidateUrl
+// (validate_url_and_css_escape) and is not directly exposed.
+class CssUrlEscape : public TemplateModifier {
+ public:
+ virtual void Modify(const char* in, size_t inlen,
+ const PerExpandData*, ExpandEmitter* outbuf,
+ const string& arg) const;
+};
+
+// URL-encodes the characters [\n\r\\'"()<>*] to ensure the URL can be safely
+// inserted in a CSS context, e.g:
+// . In an '@import url("URL");' statement
+// . In a CSS property such as 'background: url("URL");'
+// In both locations above, enclosing quotes are optional but parens are not.
+// We want to make sure the URL cannot exit the parens enclosure, close a
+// STYLE tag or reset the browser's CSS parser (via comments or newlines).
+//
+// References:
+// . CSS 2.1 URLs: http://www.w3.org/TR/CSS21/syndata.html#url
+// . CSS 1 URLs: http://www.w3.org/TR/REC-CSS1/#url
+void CssUrlEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ for (size_t i = 0; i < inlen; ++i) {
+ char c = in[i];
+ switch (c) {
+ case '\n': APPEND("%0A"); break;
+ case '\r': APPEND("%0D"); break;
+ case '"': APPEND("%22"); break;
+ case '\'': APPEND("%27"); break;
+ case '(': APPEND("%28"); break;
+ case ')': APPEND("%29"); break;
+ case '*': APPEND("%2A"); break;
+ case '<': APPEND("%3C"); break;
+ case '>': APPEND("%3E"); break;
+ case '\\': APPEND("%5C"); break;
+ default: out->Emit(c); break;
+ }
+ }
+}
+CssUrlEscape css_url_escape;
+
+// These URLs replace unsafe URLs for :U and :I url-escaping modes.
+const char* const ValidateUrl::kUnsafeUrlReplacement = "#";
+const char* const ValidateUrl::kUnsafeImgSrcUrlReplacement =
+ "/images/cleardot.gif";
+
+void ValidateUrl::Modify(const char* in, size_t inlen,
+ const PerExpandData* per_expand_data,
+ ExpandEmitter* out, const string& arg) const {
+ const char* slashpos = (char*)memchr(in, '/', inlen);
+ if (slashpos == NULL) {
+ slashpos = in + inlen;
+ }
+ const void* colonpos = memchr(in, ':', slashpos - in);
+ // colon before first slash, could be a protocol
+ if (colonpos != NULL && URL::HasInsecureProtocol(in, inlen)) {
+ // It's a bad protocol, so return something safe
+ chained_modifier_.Modify(unsafe_url_replacement_,
+ unsafe_url_replacement_length_,
+ per_expand_data,
+ out,
+ "");
+ return;
+ }
+ // If we get here, it's a valid url, so just escape it
+ chained_modifier_.Modify(in, inlen, per_expand_data, out, "");
+}
+ValidateUrl validate_url_and_html_escape(
+ html_escape,
+ ValidateUrl::kUnsafeUrlReplacement);
+ValidateUrl validate_url_and_javascript_escape(
+ javascript_escape,
+ ValidateUrl::kUnsafeUrlReplacement);
+ValidateUrl validate_url_and_css_escape(
+ css_url_escape,
+ ValidateUrl::kUnsafeUrlReplacement);
+ValidateUrl validate_img_src_url_and_html_escape(
+ html_escape,
+ ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ValidateUrl validate_img_src_url_and_javascript_escape(
+ javascript_escape,
+ ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ValidateUrl validate_img_src_url_and_css_escape(
+ css_url_escape,
+ ValidateUrl::kUnsafeImgSrcUrlReplacement);
+
+void XmlEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ const char* pos = in;
+ const char* start = pos;
+ const char* const limit = in + inlen;
+ while (pos < limit) {
+ char ch = *pos;
+
+ // According to section 2.2 of the spec
+ // http://www.w3.org/TR/REC-xml/#charsets control characters in range
+ // 0x00-0x1F (except \t, \r and \n) are not valid XML characters. In
+ // particular, conformant parsers are allowed to die when encountering a FF
+ // char in PCDATA sections. These chars are replaced by a space.
+ if (ch >= 0x00 && ch < 0x20 && ch != '\t' && ch != '\r' && ch != '\n') {
+ EmitRun(start, pos, out);
+ out->Emit(' ');
+ start = ++pos;
+ continue;
+ }
+
+ switch (ch) {
+ default:
+ // Increment our counter and look at the next character.
+ ++pos;
+ continue;
+
+ case '&': EmitRun(start, pos, out); APPEND("&"); break;
+ case '"': EmitRun(start, pos, out); APPEND("""); break;
+ case '\'': EmitRun(start, pos, out); APPEND("'"); break;
+ case '<': EmitRun(start, pos, out); APPEND("<"); break;
+ case '>': EmitRun(start, pos, out); APPEND(">"); break;
+ }
+ start = ++pos;
+ }
+ EmitRun(start, pos, out);
+}
+XmlEscape xml_escape;
+
+// This table maps initial characters to code lengths. This could be
+// done with a 16-byte table and a shift, but there's a substantial
+// performance increase by eliminating the shift.
+static const char kCodeLengths[256] = {
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+};
+
+// Returns the UTF-8 code-unit starting at start, or the special codepoint
+// 0xFFFD if the input ends abruptly or is not well-formed UTF-8.
+// start -- address of the start of the code unit which also receives the
+// address past the end of the code unit returned.
+// end -- exclusive end of the string
+static inline uint16 UTF8CodeUnit(const char** start, const char *end) {
+ // Use kCodeLengths table to calculate the length of the code unit
+ // from the first character.
+ unsigned char first_char = static_cast<unsigned char>(**start);
+ size_t code_unit_len = kCodeLengths[first_char];
+ if (code_unit_len == 1) {
+ // Return the current byte as a codepoint.
+ // Either it is a valid single byte codepoint, or it's not part of a valid
+ // UTF-8 sequence, and so has to be handled individually.
+ ++*start;
+ return first_char;
+ }
+ const char *code_unit_end = *start + code_unit_len;
+ if (code_unit_end < *start || code_unit_end > end) { // Truncated code unit.
+ ++*start;
+ return 0xFFFDU;
+ }
+ const char* pos = *start;
+ uint16 code_unit = *pos & (0xFFU >> code_unit_len);
+ while (--code_unit_len) {
+ uint16 tail_byte = *(++pos);
+ if ((tail_byte & 0xC0U) != 0x80U) { // Malformed code unit.
+ ++*start;
+ return 0xFFFDU;
+ }
+ code_unit = (code_unit << 6) | (tail_byte & 0x3FU);
+ }
+ *start = code_unit_end;
+ return code_unit;
+}
+
+// A good reference is the ECMA standard (3rd ed), section 7.8.4:
+// http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
+void JavascriptEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ const char* pos = in;
+ const char* start = pos;
+ const char* const limit = in + inlen;
+
+ if (limit < in) { return; }
+
+ while (pos < limit) {
+ const char* next_pos = pos;
+ uint16 code_unit = UTF8CodeUnit(&next_pos, limit);
+
+ // Test for 16-bit values outside the switch below, because gcc
+ // will emit chained branches rather than a jump table for such a
+ // wide range of values.
+ if (code_unit & 0xFF00) {
+ // Linebreaks according to EcmaScript 262 which cannot appear in strings.
+ if (code_unit == 0x2028) {
+ // Line separator
+ EmitRun(start, pos, out); APPEND("\\u2028");
+ } else if (code_unit == 0x2029) {
+ // Paragraph separator
+ EmitRun(start, pos, out); APPEND("\\u2029");
+ } else {
+ pos = next_pos;
+ continue;
+ }
+ } else {
+ switch (code_unit) {
+ default:
+ // Increment our counter and look at the next character.
+ pos = next_pos;
+ continue;
+
+ case '\0': EmitRun(start, pos, out); APPEND("\\x00"); break;
+ case '"': EmitRun(start, pos, out); APPEND("\\x22"); break;
+ case '\'': EmitRun(start, pos, out); APPEND("\\x27"); break;
+ case '\\': EmitRun(start, pos, out); APPEND("\\\\"); break;
+ case '\t': EmitRun(start, pos, out); APPEND("\\t"); break;
+ case '\r': EmitRun(start, pos, out); APPEND("\\r"); break;
+ case '\n': EmitRun(start, pos, out); APPEND("\\n"); break;
+ case '\b': EmitRun(start, pos, out); APPEND("\\b"); break;
+ case '\f': EmitRun(start, pos, out); APPEND("\\f"); break;
+ case '&': EmitRun(start, pos, out); APPEND("\\x26"); break;
+ case '<': EmitRun(start, pos, out); APPEND("\\x3c"); break;
+ case '>': EmitRun(start, pos, out); APPEND("\\x3e"); break;
+ case '=': EmitRun(start, pos, out); APPEND("\\x3d"); break;
+
+ case '\v':
+ // Do not escape vertical tabs to "\\v" since it is interpreted as 'v'
+ // by JScript according to section 2.1 of
+ // http://wiki.ecmascript.org/lib/exe/fetch.php?
+ // id=resources%3Aresources&cache=cache&
+ // media=resources:jscriptdeviationsfromes3.pdf
+ EmitRun(start, pos, out); APPEND("\\x0b"); break;
+ }
+ }
+ start = pos = next_pos;
+ }
+ EmitRun(start, pos, out);
+}
+JavascriptEscape javascript_escape;
+
+
+void JavascriptNumber::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ if (inlen == 0)
+ return;
+
+ if (STR_IS(in, inlen, "true") || STR_IS(in, inlen, "false")) {
+ out->Emit(in, inlen);
+ return;
+ }
+
+ bool valid = true;
+ if (in[0] == '0' && inlen > 2 && (in[1] == 'x' || in[1] == 'X')) {
+ // There must be at least one hex digit after the 0x for it to be valid.
+ // Hex number. Check that it is of the form 0(x|X)[0-9A-Fa-f]+
+ for (size_t i = 2; i < inlen; i++) {
+ char c = in[i];
+ if (!((c >= 'a' && c <= 'f') ||
+ (c >= 'A' && c <= 'F') ||
+ (c >= '0' && c <= '9'))) {
+ valid = false;
+ break;
+ }
+ }
+ } else {
+ // Must be a base-10 (or octal) number.
+ // Check that it has the form [0-9+-.eE]+
+ for (size_t i = 0; i < inlen; i++) {
+ char c = in[i];
+ if (!((c >= '0' && c <= '9') ||
+ c == '+' || c == '-' || c == '.' ||
+ c == 'e' || c == 'E')) {
+ valid = false;
+ break;
+ }
+ }
+ }
+ if (valid) {
+ out->Emit(in, inlen); // Number was valid, output it.
+ } else {
+ APPEND("null"); // Number was not valid, output null instead.
+ }
+}
+JavascriptNumber javascript_number;
+
+static inline bool IsUrlQueryEscapeSafeChar(unsigned char c) {
+ // Everything not matching [0-9a-zA-Z.,_*/~!()-] is escaped.
+ static unsigned long _safe_characters[8] = {
+ 0x00000000L, 0x03fff702L, 0x87fffffeL, 0x47fffffeL,
+ 0x00000000L, 0x00000000L, 0x00000000L, 0x00000000L
+ };
+
+ return (_safe_characters[(c)>>5] & (1 << ((c) & 31)));
+}
+
+void UrlQueryEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ const char* pos = in;
+ const char* const limit = in + inlen;
+ while (true) {
+ // Peel off any initial runs of safe characters and emit them all
+ // at once.
+ const char* start = pos;
+ while (pos < limit && IsUrlQueryEscapeSafeChar(*pos)) {
+ pos++;
+ }
+ EmitRun(start, pos, out);
+
+ // Now deal with a single unsafe character.
+ if (pos < limit) {
+ unsigned char c = *pos;
+ if (c == ' ') {
+ out->Emit('+');
+ } else {
+ out->Emit('%');
+ out->Emit(((c>>4) < 10 ? ((c>>4) + '0') : (((c>>4) - 10) + 'A')));
+ out->Emit(((c&0xf) < 10 ? ((c&0xf) + '0') : (((c&0xf) - 10) + 'A')));
+ }
+ pos++;
+ } else {
+ // We're done!
+ break;
+ }
+ }
+}
+UrlQueryEscape url_query_escape;
+
+// For more information on escaping JSON, see section 2.5 in
+// http://www.ietf.org/rfc/rfc4627.txt.
+// Escaping '&', '<', '>' is optional in the JSON proposed RFC
+// but alleviates concerns with content sniffing if JSON is used
+// in a context where the browser may attempt to interpret HTML.
+void JsonEscape::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ const char* pos = in;
+ const char* start = pos;
+ const char* const limit = in + inlen;
+ while (pos < limit) {
+ switch (*pos) {
+ default:
+ // Increment our counter and look at the next character.
+ ++pos;
+ continue;
+
+ case '"': EmitRun(start, pos, out); APPEND("\\\""); break;
+ case '\\': EmitRun(start, pos, out); APPEND("\\\\"); break;
+ case '/': EmitRun(start, pos, out); APPEND("\\/"); break;
+ case '\b': EmitRun(start, pos, out); APPEND("\\b"); break;
+ case '\f': EmitRun(start, pos, out); APPEND("\\f"); break;
+ case '\n': EmitRun(start, pos, out); APPEND("\\n"); break;
+ case '\r': EmitRun(start, pos, out); APPEND("\\r"); break;
+ case '\t': EmitRun(start, pos, out); APPEND("\\t"); break;
+ case '&': EmitRun(start, pos, out); APPEND("\\u0026"); break;
+ case '<': EmitRun(start, pos, out); APPEND("\\u003C"); break;
+ case '>': EmitRun(start, pos, out); APPEND("\\u003E"); break;
+ }
+ start = ++pos;
+ }
+ EmitRun(start, pos, out);
+}
+JsonEscape json_escape;
+
+void PrefixLine::Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* out, const string& arg) const {
+ while (inlen > 0) {
+ const char* nl = (const char*)memchr(in, '\n', inlen);
+ const char* cr = (const char*)memchr(in, '\r', nl ? nl - in : inlen);
+ size_t linelen;
+ if (nl == NULL && cr == NULL) {
+ // We're at the last line
+ out->Emit(in, inlen);
+ break;
+ } else {
+ // One or both of \r and \n is set; point to the first char past
+ // the newline. Note for \r\n, that's the char after the \n,
+ // otherwise, it's the char past the \r or the \n we see.
+ if ((nl == NULL) != (cr == NULL)) // one is set, the other is NULL
+ linelen = (nl ? nl : cr) + 1 - in;
+ else if (nl == cr + 1 || nl < cr) // \r\n, or \n comes first
+ linelen = nl + 1 - in;
+ else
+ linelen = cr + 1 - in;
+ }
+ out->Emit(in, linelen);
+ out->Emit(arg); // a new line, so emit the prefix
+ in += linelen;
+ inlen -= linelen;
+ assert(inlen >= 0);
+ }
+}
+PrefixLine prefix_line;
+
+
+// Must be at least one more than the maximum number of alternative modifiers
+// specified in any given element of g_modifiers.
+# define MAX_SAFE_ALTERNATIVES 10 // If the compiler complains, increase it.
+
+// Use the empty string if you want a modifier not to have a long-name.
+// Use '\0' if you want a modifier not to have a short-name.
+// Note: not all modifiers are in this array:
+// 1) SnippetEscape: use html_escape_with_arg=snippet to get this
+// 2) CleanseAttribute: use html_escape_with_arg=attribute to get this
+// 3) ValidateUrl: use html_escape_with_arg=url to get this
+//
+// Some modifiers define other modifiers that are safe replacements
+// from an XSS perspective. Replacements are not commutative so for
+// example H=pre considers H=attribute a safe replacement to it
+// but H=attribute has no safe replacements.
+// This struct is not pretty but allows the definitions to be
+// done without the need for a global initialization method.
+// Be very careful making a change to g_modifiers as modifiers
+// point to other ones within that same array so elements
+// may not be re-ordered easily. Also you need to change
+// the global g_am_dirs correspondingly.
+//
+static struct ModifierWithAlternatives {
+ ModifierInfo modifier_info;
+ ModifierInfo* safe_alt_mods[MAX_SAFE_ALTERNATIVES];
+} g_modifiers[] = {
+ /* 0 */ { ModifierInfo("cleanse_css", 'c',
+ XSS_WEB_STANDARD, &cleanse_css),
+ {&g_modifiers[16].modifier_info, // url_escape_with_arg=css
+ // img_src_url_escape_with_arg=css
+ &g_modifiers[19].modifier_info} },
+ /* 1 */ { ModifierInfo("html_escape", 'h',
+ XSS_WEB_STANDARD, &html_escape),
+ {&g_modifiers[2].modifier_info, // html_escape_with_arg=snippet
+ &g_modifiers[3].modifier_info, // html_escape_with_arg=pre
+ &g_modifiers[4].modifier_info, // html_escape_with_arg=attribute
+ &g_modifiers[5].modifier_info, // html_escape_with_arg=url
+ &g_modifiers[8].modifier_info, // pre_escape
+ &g_modifiers[9].modifier_info, // url_query_escape
+ &g_modifiers[11].modifier_info, // url_escape_with_arg=html
+ &g_modifiers[12].modifier_info, // url_escape_with_arg=query
+ // img_src_url_escape_with_arg=html
+ &g_modifiers[18].modifier_info} },
+ /* 2 */ { ModifierInfo("html_escape_with_arg=snippet", 'H',
+ XSS_WEB_STANDARD, &snippet_escape),
+ {&g_modifiers[1].modifier_info, // html_escape
+ &g_modifiers[3].modifier_info, // html_escape_with_arg=pre
+ &g_modifiers[4].modifier_info, // html_escape_with_arg=attribute
+ &g_modifiers[8].modifier_info, // pre_escape
+ &g_modifiers[9].modifier_info, // url_query_escape
+ &g_modifiers[12].modifier_info} }, // url_escape_with_arg=query
+ /* 3 */ { ModifierInfo("html_escape_with_arg=pre", 'H',
+ XSS_WEB_STANDARD, &pre_escape),
+ {&g_modifiers[1].modifier_info, // html_escape
+ &g_modifiers[2].modifier_info, // html_escape_with_arg=snippet
+ &g_modifiers[4].modifier_info, // html_escape_with_arg=attribute
+ &g_modifiers[8].modifier_info, // pre_escape
+ &g_modifiers[9].modifier_info, // url_query_escape
+ &g_modifiers[12].modifier_info} }, // url_escape_with_arg=query
+ /* 4 */ { ModifierInfo("html_escape_with_arg=attribute", 'H',
+ XSS_WEB_STANDARD, &cleanse_attribute), {} },
+ /* 5 */ { ModifierInfo("html_escape_with_arg=url", 'H',
+ XSS_WEB_STANDARD, &validate_url_and_html_escape),
+ // img_src_url_escape_with_arg=html
+ {&g_modifiers[18].modifier_info} },
+ /* 6 */ { ModifierInfo("javascript_escape", 'j',
+ XSS_WEB_STANDARD, &javascript_escape),
+ {&g_modifiers[7].modifier_info, // json_escape
+ &g_modifiers[10].modifier_info, // url_escape_with_arg=javascript
+ // img_src_url_escape_with_arg=javascript
+ &g_modifiers[17].modifier_info} },
+ /* 7 */ { ModifierInfo("json_escape", 'o', XSS_WEB_STANDARD, &json_escape),
+ {&g_modifiers[6].modifier_info} }, // javascript_escape
+ /* 8 */ { ModifierInfo("pre_escape", 'p', XSS_WEB_STANDARD, &pre_escape),
+ {&g_modifiers[1].modifier_info, // html_escape
+ &g_modifiers[2].modifier_info, // html_escape_with_arg=snippet
+ &g_modifiers[3].modifier_info, // html_escape_with_arg=pre
+ &g_modifiers[4].modifier_info, // html_escape_with_arg=attr...
+ &g_modifiers[9].modifier_info, // url_query_escape
+ &g_modifiers[12].modifier_info} }, // url_escape_with_arg=query
+ /* 9 */ { ModifierInfo("url_query_escape", 'u',
+ XSS_WEB_STANDARD, &url_query_escape), {} },
+ /* 10 */ { ModifierInfo("url_escape_with_arg=javascript", 'U',
+ XSS_WEB_STANDARD,
+ &validate_url_and_javascript_escape),
+ // img_src_url_escape_with_arg=javascript
+ {&g_modifiers[17].modifier_info} },
+ /* 11 */ { ModifierInfo("url_escape_with_arg=html", 'U',
+ XSS_WEB_STANDARD, &validate_url_and_html_escape),
+ // img_src_url_escape_with_arg=html
+ {&g_modifiers[18].modifier_info} },
+ /* 12 */ { ModifierInfo("url_escape_with_arg=query", 'U',
+ XSS_WEB_STANDARD, &url_query_escape), {} },
+ /* 13 */ { ModifierInfo("none", '\0', XSS_SAFE, &null_modifier), {} },
+ /* 14 */ { ModifierInfo("xml_escape", '\0', XSS_WEB_STANDARD, &xml_escape),
+ {&g_modifiers[1].modifier_info, // html_escape
+ &g_modifiers[4].modifier_info,} }, // H=attribute
+ /* 15 */ { ModifierInfo("javascript_escape_with_arg=number", 'J',
+ XSS_WEB_STANDARD, &javascript_number), {} },
+ /* 16 */ { ModifierInfo("url_escape_with_arg=css", 'U',
+ XSS_WEB_STANDARD, &validate_url_and_css_escape), {} },
+ /* 17 */ { ModifierInfo("img_src_url_escape_with_arg=javascript", 'I',
+ XSS_WEB_STANDARD,
+ &validate_img_src_url_and_javascript_escape), {} },
+ /* 18 */ { ModifierInfo("img_src_url_escape_with_arg=html", 'I',
+ XSS_WEB_STANDARD,
+ &validate_img_src_url_and_html_escape), {} },
+ /* 19 */ { ModifierInfo("img_src_url_escape_with_arg=css", 'I',
+ XSS_WEB_STANDARD,
+ &validate_img_src_url_and_css_escape), {} },
+};
+
+static vector<const ModifierInfo*> g_extension_modifiers;
+static vector<const ModifierInfo*> g_unknown_modifiers;
+
+// Returns whether or not candidate can be safely (w.r.t XSS)
+// used in lieu of our ModifierInfo. This is true iff:
+// 1. Both have the same modifier function OR
+// 2. Candidate's modifier function is in our ModifierInfo's
+// list (vector) of safe alternative modifier functions.
+//
+// This is used with the auto-escaping code, which automatically
+// figures out which modifier to apply to a variable based on the
+// variable's context (in an html "<A HREF", for instance). Some
+// built-in modifiers are considered safe alternatives from the perspective
+// of preventing XSS (cross-site-scripting) attacks, in which case
+// the auto-escaper should allow the choice of which to use in the
+// template. This is intended only for internal use as it is dangerous
+// and complicated to figure out which modifier is an XSS-safe
+// replacement for a given one. Custom modifiers currently may not
+// indicate safe replacements, only built-in ones may do so.
+//
+// Note that this function is not commutative therefore
+// IsSafeXSSAlternative(a, b) may not be equal to IsSafeXSSAlternative(b, a).
+bool IsSafeXSSAlternative(const ModifierInfo& our,
+ const ModifierInfo& candidate) {
+ // Succeeds even for non built-in modifiers but no harm.
+ if (our.modifier == candidate.modifier)
+ return true;
+
+ for (const ModifierWithAlternatives* mod_with_alts = g_modifiers;
+ mod_with_alts < g_modifiers + sizeof(g_modifiers)/sizeof(*g_modifiers);
+ ++mod_with_alts) {
+ if (mod_with_alts->modifier_info.long_name == our.long_name)
+ // We found our Modifier in the built-in array g_modifiers.
+ for (int i = 0; mod_with_alts->safe_alt_mods[i] != NULL &&
+ i < MAX_SAFE_ALTERNATIVES; ++i)
+ if (mod_with_alts->safe_alt_mods[i]->long_name == candidate.long_name)
+ // We found candidate in our Modifier's list of safe alternatives.
+ return true;
+ }
+ // our is not built-in or candidate is not a safe replacement to our.
+ return false;
+}
+
+static inline bool IsExtensionModifier(const char* long_name) {
+ return memcmp(long_name, "x-", 2) == 0;
+}
+
+static bool AddModifierCommon(const char* long_name,
+ const TemplateModifier* modifier, bool xss_safe) {
+ if (!IsExtensionModifier(long_name))
+ return false;
+
+ // TODO(csilvers): store in a map or multimap, rather than a vector
+ for (vector<const ModifierInfo*>::const_iterator mod =
+ g_extension_modifiers.begin();
+ mod != g_extension_modifiers.end();
+ ++mod) {
+ // Check if mod has the same name as us. For modifiers that also take
+ // values, this is everything before the =. The only time it's ok to
+ // have the same name is when we have different modval specializations:
+ // "foo=bar" and "foo=baz" are both valid names. Note "foo" and
+ // "foo=bar" is not valid: foo has no modval, but "foo=bar" does.
+ const size_t new_modifier_namelen = strcspn(long_name, "=");
+ const size_t existing_modifier_namelen = strcspn((*mod)->long_name.c_str(),
+ "=");
+ if (new_modifier_namelen == existing_modifier_namelen &&
+ !memcmp(long_name, (*mod)->long_name.c_str(), new_modifier_namelen)) {
+ if (long_name[new_modifier_namelen] == '=' &&
+ (*mod)->long_name[existing_modifier_namelen] == '=' &&
+ (*mod)->long_name != long_name) {
+ // It's ok, we're different specializations!
+ } else {
+ // It's not ok: we have the same name and no good excuse.
+ return false;
+ }
+ }
+ }
+
+ g_extension_modifiers.push_back(
+ new ModifierInfo(long_name, '\0',
+ xss_safe ? XSS_SAFE : XSS_UNIQUE,
+ modifier));
+ return true;
+}
+
+// Modifier added with XSS_UNIQUE XssClass.
+bool AddModifier(const char* long_name,
+ const TemplateModifier* modifier) {
+ return AddModifierCommon(long_name, modifier, false);
+}
+
+// Modifier added with XSS_SAFE XssClass.
+bool AddXssSafeModifier(const char* long_name,
+ const TemplateModifier* modifier) {
+ return AddModifierCommon(long_name, modifier, true);
+}
+
+// If candidate_match is a better match for modname/modval than bestmatch,
+// update bestmatch. To be a better match, two conditions must be met:
+// 1) The candidate's name must match modname
+// 2) If the candidate is a specialization (that is, name is of the form
+// "foo=bar", then modval matches the specialization value).
+// 3) If the candidate is not a specialization, bestmatch isn't a
+// specialization either.
+// Condition (3) makes sure that if we match the ModifierInfo with name
+// "foo=bar", we don't claim the ModifierInfo "foo=" is a better match.
+// Recall that by definition, modval will always start with a '=' if present.
+static void UpdateBestMatch(const char* modname, size_t modname_len,
+ const char* modval, size_t modval_len,
+ const ModifierInfo* candidate_match,
+ const ModifierInfo** best_match) {
+ // It's easiest to handle the two case differently: (1) candidate_match
+ // refers to a modifier that expects a modifier-value; (2) it doesn't.
+ if (candidate_match->modval_required) {
+ // To be a match, we have to fulfill three requirements: we have a
+ // modval, our modname matches candidate_match's modname (either
+ // shortname or longname), and our modval is consistent with the
+ // value specified in the longname (whatever might follow the =).
+ const char* const longname_start = candidate_match->long_name.c_str();
+ const char* const equals = strchr(longname_start, '=');
+ assert(equals != NULL);
+ if (modval_len > 0 &&
+ ((modname_len == 1 && *modname == candidate_match->short_name) ||
+ (modname_len == equals - longname_start &&
+ memcmp(modname, longname_start, modname_len) == 0)) &&
+ ((equals[1] == '\0') || // name is "foo=" (not a specialization)
+ (modval_len
+ == longname_start + candidate_match->long_name.size() - equals &&
+ memcmp(modval, equals, modval_len) == 0))) {
+ // Condition (3) above is satisfied iff our longname is longer than
+ // best-match's longname (so we prefer "foo=bar" to "foo=").
+ if (*best_match == NULL ||
+ candidate_match->long_name.size() > (*best_match)->long_name.size())
+ *best_match = candidate_match;
+ }
+ } else {
+ // In this case, to be a match: we must *not* have a modval. Our
+ // modname still must match modinfo's modname (either short or long).
+ if (modval_len == 0 &&
+ ((modname_len == 1 && *modname == candidate_match->short_name) ||
+ (modname_len == candidate_match->long_name.size() &&
+ !memcmp(modname, candidate_match->long_name.data(), modname_len)))) {
+ // In the no-modval case, only one match should exist.
+ assert(*best_match == NULL);
+ *best_match = candidate_match;
+ }
+ }
+}
+
+const ModifierInfo* FindModifier(const char* modname, size_t modname_len,
+ const char* modval, size_t modval_len) {
+ // More than one modifier can match, in the case of modval specializations
+ // (e.g., the modifier "foo=" and "foo=bar" will both match on input of
+ // modname="foo", modval="bar"). In that case, we take the ModifierInfo
+ // with the longest longname, since that's the most specialized match.
+ const ModifierInfo* best_match = NULL;
+ if (modname_len >= 2 && IsExtensionModifier(modname)) {
+ for (vector<const ModifierInfo*>::const_iterator mod =
+ g_extension_modifiers.begin();
+ mod != g_extension_modifiers.end();
+ ++mod) {
+ UpdateBestMatch(modname, modname_len, modval, modval_len,
+ *mod, &best_match);
+ }
+ if (best_match != NULL)
+ return best_match;
+
+ for (vector<const ModifierInfo*>::const_iterator mod =
+ g_unknown_modifiers.begin();
+ mod != g_unknown_modifiers.end();
+ ++mod) {
+ UpdateBestMatch(modname, modname_len, modval, modval_len,
+ *mod, &best_match);
+ }
+ if (best_match != NULL)
+ return best_match;
+ // This is the only situation where we can pass in a modifier of NULL.
+ // It means "we don't know about this modifier-name."
+ string fullname(modname, modname_len);
+ if (modval_len) {
+ fullname.append(modval, modval_len);
+ }
+ // TODO(csilvers): store in a map or multimap, rather than a vector
+ g_unknown_modifiers.push_back(new ModifierInfo(fullname, '\0',
+ XSS_UNIQUE, NULL));
+ return g_unknown_modifiers.back();
+ } else {
+ for (const ModifierWithAlternatives* mod_with_alts = g_modifiers;
+ mod_with_alts < g_modifiers + sizeof(g_modifiers)/sizeof(*g_modifiers);
+ ++mod_with_alts) {
+ UpdateBestMatch(modname, modname_len, modval, modval_len,
+ &mod_with_alts->modifier_info, &best_match);
+ }
+ return best_match;
+ }
+}
+
+// For escaping variables under the auto-escape mode:
+// Each directive below maps to a distinct sequence of
+// escaping directives (i.e a vector<ModifierAndValue>) applied
+// to a variable during run-time substitution.
+// The directives are stored in a global array (g_mods_ae)
+// initialized under lock in InitializeGlobalModifiers.
+enum AutoModifyDirective {
+ AM_EMPTY, // Unused, kept as marker.
+ AM_HTML,
+ AM_HTML_UNQUOTED,
+ AM_JS,
+ AM_JS_NUMBER,
+ AM_URL_HTML,
+ AM_URL_QUERY,
+ AM_STYLE,
+ AM_XML,
+ NUM_ENTRIES_AM,
+};
+
+// Populates the global vector of hard-coded modifiers that
+// Auto-Escape may pick. We point to the appropriate modifier in
+// the global g_modifiers.
+// Reference these globals via the global array g_am_dirs[] for consistency.
+// Note: We allow for more than one ModifierAndValue in the array hence
+// the need to terminate with a Null marker. However currently all the
+// escaping directives have exactly one ModifierAndValue.
+static const ModifierAndValue g_am_empty[] = {
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_html[] = {
+ ModifierAndValue(&g_modifiers[1].modifier_info, "", 0),
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_html_unquoted[] = {
+ ModifierAndValue(&g_modifiers[4].modifier_info, "=attribute", 10),
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_js[] = {
+ ModifierAndValue(&g_modifiers[6].modifier_info, "", 0),
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_js_number[] = {
+ ModifierAndValue(&g_modifiers[15].modifier_info, "=number", 7),
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_url_html[] = {
+ ModifierAndValue(&g_modifiers[11].modifier_info, "=html", 5),
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_url_query[] = {
+ ModifierAndValue(&g_modifiers[9].modifier_info, "", 0),
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_style[] = {
+ ModifierAndValue(&g_modifiers[0].modifier_info, "", 0),
+ ModifierAndValue(NULL, "", 0)
+};
+static const ModifierAndValue g_am_xml[] = {
+ ModifierAndValue(&g_modifiers[14].modifier_info, "", 0),
+ ModifierAndValue(NULL, "", 0)
+};
+
+static const ModifierAndValue* g_am_dirs[NUM_ENTRIES_AM] = {
+ g_am_empty, /* AM_EMPTY */
+ g_am_html, /* AM_HTML */
+ g_am_html_unquoted, /* AM_HTML_UNQUOTED */
+ g_am_js, /* AM_JS */
+ g_am_js_number, /* AM_JS_NUMBER */
+ g_am_url_html, /* AM_URL_HTML */
+ g_am_url_query, /* AM_URL_QUERY */
+ g_am_style, /* AM_STYLE */
+ g_am_xml, /* AM_XML */
+};
+
+string PrettyPrintOneModifier(const ModifierAndValue& modval) {
+ string out;
+ out.append(":");
+ if (modval.modifier_info->short_name) // short_name is a char.
+ out.append(1, modval.modifier_info->short_name);
+ else
+ out.append(modval.modifier_info->long_name);
+ if (modval.value_len != 0)
+ out.append(modval.value, modval.value_len);
+ return out;
+}
+
+string PrettyPrintModifiers(const vector<const ModifierAndValue*>& modvals,
+ const string& separator) {
+ string out;
+ for (vector<const ModifierAndValue*>::const_iterator it =
+ modvals.begin(); it != modvals.end(); ++it) {
+ if (it != modvals.begin())
+ out.append(separator);
+ out.append(PrettyPrintOneModifier(**it));
+ }
+ return out;
+}
+
+// Return the sequence of escaping directives to apply for the given context.
+// An empty vector indicates an error occurred. Currently we never need
+// to chain escaping directives hence on success, the vector is always of
+// size 1. This may change in the future.
+vector<const ModifierAndValue*> GetModifierForHtmlJs(
+ HtmlParser* htmlparser, string* error_msg) {
+ assert(htmlparser);
+ assert(error_msg);
+ vector<const ModifierAndValue*> modvals;
+
+ // Two cases of being inside javascript:
+ // 1. Inside raw javascript (within a <script> tag). If the value
+ // is quoted we apply javascript_escape, if not we have to coerce
+ // it to a safe value due to the risk of javascript code execution
+ // hence apply :J=number. If arbitrary code needs to be inserted
+ // at run-time, the developer must use :none.
+ // 2. In the value of an attribute that takes javascript such
+ // as onmouseevent in '<a href="someUrl" onmousevent="{{EVENT}}">'.
+ // That will be covered in the STATE_VALUE state logic below.
+ if (htmlparser->InJavascript() &&
+ htmlparser->state() != HtmlParser::STATE_VALUE) {
+ if (htmlparser->IsJavascriptQuoted()) {
+ modvals.push_back(g_am_dirs[AM_JS]);
+ assert(modvals.size() == 1);
+ return modvals;
+ } else {
+ modvals.push_back(g_am_dirs[AM_JS_NUMBER]);
+ assert(modvals.size() == 1);
+ return modvals;
+ }
+ }
+ switch (htmlparser->state()) {
+ case HtmlParser::STATE_VALUE:{
+ string attribute_name = htmlparser->attribute();
+ switch (htmlparser->AttributeType()) {
+ case HtmlParser::ATTR_URI:
+ // Case 1: The URL is quoted:
+ // . Apply :U=html if it is a complete URL or :h if it is a fragment.
+ // Case 2: The URL is not quoted:
+ // . If it is a complete URL, we have no safe modifiers that
+ // won't break it so we have to fail.
+ // . If it is a URL fragment, then :u is safe and not likely to
+ // break the URL.
+ if (!htmlparser->IsAttributeQuoted()) {
+ if (htmlparser->IsUrlStart()) { // Complete URL.
+ error_msg->append("Value of URL attribute \"" + attribute_name +
+ "\" must be enclosed in quotes.");
+ assert(modvals.empty());
+ return modvals; // Empty
+ } else { // URL fragment.
+ modvals.push_back(g_am_dirs[AM_URL_QUERY]);
+ }
+ } else {
+ // Only validate the URL if we have a complete URL,
+ // otherwise simply html_escape.
+ if (htmlparser->IsUrlStart())
+ modvals.push_back(g_am_dirs[AM_URL_HTML]);
+ else
+ modvals.push_back(g_am_dirs[AM_HTML]);
+ }
+ break;
+ case HtmlParser::ATTR_REGULAR:
+ // If the value is quoted, simply HTML escape, otherwise
+ // apply stricter escaping using H=attribute.
+ if (htmlparser->IsAttributeQuoted())
+ modvals.push_back(g_am_dirs[AM_HTML]);
+ else
+ modvals.push_back(g_am_dirs[AM_HTML_UNQUOTED]);
+ break;
+ case HtmlParser::ATTR_STYLE:
+ // If the value is quoted apply :c, otherwise fail.
+ if (htmlparser->IsAttributeQuoted()) {
+ modvals.push_back(g_am_dirs[AM_STYLE]);
+ } else {
+ error_msg->append("Value of style attribute \"" + attribute_name +
+ "\" must be enclosed in quotes.");
+ assert(modvals.empty());
+ return modvals; // Empty
+ }
+ break;
+ case HtmlParser::ATTR_JS:
+ // We require javascript accepting attributes (such as onclick)
+ // to be HTML quoted, otherwise they are vulnerable to
+ // HTML attribute insertion via the use of whitespace.
+ if (!htmlparser->IsAttributeQuoted()) {
+ error_msg->append("Value of javascript attribute \"" +
+ attribute_name +
+ "\" must be enclosed in quotes.");
+ assert(modvals.empty());
+ return modvals; // Empty
+ }
+ // If the variable is quoted apply javascript_escape otherwise
+ // apply javascript_number which will ensure it is safe against
+ // code injection.
+ // Note: We normally need to HTML escape after javascript escape
+ // but the javascript escape implementation provided makes the
+ // HTML escape redundant so simply javascript escape.
+ if (htmlparser->IsJavascriptQuoted())
+ modvals.push_back(g_am_dirs[AM_JS]);
+ else
+ modvals.push_back(g_am_dirs[AM_JS_NUMBER]);
+ break;
+ case HtmlParser::ATTR_NONE:
+ assert("We should be in attribute!" && 0);
+ default:
+ assert("Should not be able to get here." && 0);
+ return modvals; // Empty
+ }
+ // In STATE_VALUE particularly, the parser may get out of sync with
+ // the correct state - that the browser sees - due to the fact that
+ // it does not get to parse run-time content (variables). So we tell
+ // the parser there is content that will be expanded here.
+ // A good example is:
+ // <a href={{URL}} alt={{NAME}}>
+ // The parser sees <a href= alt=> and interprets 'alt=' to be
+ // the value of href.
+ htmlparser->InsertText(); // Ignore return value.
+ assert(modvals.size() == 1);
+ return modvals;
+ }
+ case HtmlParser::STATE_TAG:{
+ // Apply H=attribute to tag names since they are alphabetic.
+ // Examples of tag names: TITLE, BODY, A and BR.
+ modvals.push_back(g_am_dirs[AM_HTML_UNQUOTED]);
+ assert(modvals.size() == 1);
+ return modvals;
+ }
+ case HtmlParser::STATE_ATTR:{
+ // Apply H=attribute to attribute names since they are alphabetic.
+ // Examples of attribute names: HREF, SRC and WIDTH.
+ modvals.push_back(g_am_dirs[AM_HTML_UNQUOTED]);
+ assert(modvals.size() == 1);
+ return modvals;
+ }
+ case HtmlParser::STATE_COMMENT:
+ case HtmlParser::STATE_TEXT:{
+ // Apply :h to regular HTML text and :c if within a style tag.
+ if (htmlparser->InCss())
+ modvals.push_back(g_am_dirs[AM_STYLE]);
+ else
+ modvals.push_back(g_am_dirs[AM_HTML]);
+ assert(modvals.size() == 1);
+ return modvals;
+ }
+ default:{
+ assert("Should not be able to get here." && 0);
+ return modvals; // Empty
+ }
+ }
+ assert("Should not be able to get here." && 0);
+ return modvals; // Empty
+}
+
+// TODO(jad): Memoize all GetModifierForXXX functions below.
+// They don't depend on parser context (from csilvers).
+vector<const ModifierAndValue*> GetModifierForCss(HtmlParser* htmlparser,
+ string* error_msg) {
+ vector<const ModifierAndValue*> modvals;
+ modvals.push_back(g_am_dirs[AM_STYLE]);
+ return modvals;
+}
+
+vector<const ModifierAndValue*> GetModifierForXml(HtmlParser* htmlparser,
+ string* error_msg) {
+ vector<const ModifierAndValue*> modvals;
+ modvals.push_back(g_am_dirs[AM_XML]);
+ return modvals;
+}
+
+vector<const ModifierAndValue*> GetModifierForJson(HtmlParser* htmlparser,
+ string* error_msg) {
+ vector<const ModifierAndValue*> modvals;
+ modvals.push_back(g_am_dirs[AM_JS]);
+ return modvals;
+}
+
+vector<const ModifierAndValue*> GetDefaultModifierForHtml() {
+ vector<const ModifierAndValue*> modvals;
+ modvals.push_back(g_am_dirs[AM_HTML]);
+ return modvals;
+}
+
+vector<const ModifierAndValue*> GetDefaultModifierForJs() {
+ vector<const ModifierAndValue*> modvals;
+ modvals.push_back(g_am_dirs[AM_JS]);
+ return modvals;
+}
+
+vector<const ModifierAndValue*> GetDefaultModifierForCss() {
+ return GetModifierForCss(NULL, NULL);
+}
+
+vector<const ModifierAndValue*> GetDefaultModifierForXml() {
+ return GetModifierForXml(NULL, NULL);
+}
+
+vector<const ModifierAndValue*> GetDefaultModifierForJson() {
+ return GetModifierForJson(NULL, NULL);
+}
+
+}
diff --git a/src/template_modifiers_internal.h b/src/template_modifiers_internal.h
new file mode 100644
index 0000000..b453e18
--- /dev/null
+++ b/src/template_modifiers_internal.h
@@ -0,0 +1,246 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+//
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// These are used by template.cc and when registering new modifiers.
+// (Or more exactly, registering new modifier/value pairs.)
+// They are not intended for any other users.
+//
+// If you do find yourself needing to use them directly, please email
+// template-users.
+//
+// Known outside-template users of this class:
+// template/bidi/bidi_modifiers_test.cc
+//
+// These routines are implemented in template_modifiers.cc.
+
+#ifndef TEMPLATE_TEMPLATE_MODIFIERS_INTERNAL_H_
+#define TEMPLATE_TEMPLATE_MODIFIERS_INTERNAL_H_
+
+#include <config.h>
+#include <sys/types.h> // for size_t
+#include <string.h> // for strchr
+#include <string>
+#include <vector>
+#include <ctemplate/template_modifiers.h> // for null_modifier
+
+// Annoying stuff for windows -- make sure clients (in this case
+// unittests) can import the class definitions and variables.
+#ifndef CTEMPLATE_DLL_DECL
+# ifdef _MSC_VER
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+# else
+# define CTEMPLATE_DLL_DECL /* should be the empty string for non-windows */
+# endif
+#endif
+
+using std::string;
+using std::vector;
+
+namespace ctemplate_htmlparser {
+class HtmlParser;
+}
+
+namespace ctemplate {
+
+class TemplateModifier;
+
+// A Modifier belongs to an XssClass which determines whether
+// it is an XSS safe addition to a modifier chain or not. This
+// is used by the Auto-Escape mode when determining how to handle
+// extra modifiers provided in template. For example, :j is a safe
+// addition to :h because they are both in the same class (XSS_WEB_STANDARD).
+//
+// XssClass is not exposed in any API and cannot be set in custom
+// modifiers, it is for internal use only (for Auto-Escape). We currently
+// have only three classes.
+//
+// XSS_UNUSED: not used.
+// XSS_WEB_STANDARD: All the curent built-in escaping modifiers.
+// XSS_UNIQUE: Set for all custom modifiers added via AddModifier()
+// and may need to be escaped.
+// XSS_SAFE: Set for all custom modifiers added via AddXssSafeModifier()
+// that are considered to produce safe output and hence
+// do not need further escaping. Also includes the :none modifier.
+enum XssClass {
+ XSS_UNUSED,
+ XSS_WEB_STANDARD,
+ XSS_UNIQUE,
+ XSS_SAFE,
+};
+
+// TODO(csilvers): collapse this into the TemplateModifier class?
+struct ModifierInfo {
+ // longname should end in an '=' iff the modifier takes a value
+ // (same as in getopt(3)).
+ // To specialize -- add a modifier that applies only when we see the name
+ // with a particular value -- specify longname like so: "longname=value".
+ // (See example in the comment-doc below, for AddModifier.)
+ // sn can be '\0' if there is no associated shortname.
+ // m should be NULL *only if* default-registering a user-defined longname
+ // that the user neglected to register themselves. In this case, we
+ // use the null modifier as the actual modifier.
+ // xss_class indicates an equivalence class this modifier is
+ // in, such that any other modifier in the class could be applied
+ // after this modifier without affecting its XSS-safety. If in
+ // doubt, say XSS_UNIQUE, which is the most conservative choice.
+ ModifierInfo(string ln, char sn, XssClass xc, const TemplateModifier* m)
+ : long_name(ln), short_name(sn),
+ modval_required(strchr(ln.c_str(), '=') != NULL),
+ is_registered(m != NULL), xss_class(xc),
+ modifier(m ? m : &null_modifier) { }
+ string long_name;
+ char short_name;
+ bool modval_required; // true iff ln has an '=' in it
+ bool is_registered; // true for built-in and AddModifier mods
+ XssClass xss_class;
+ const TemplateModifier* modifier;
+};
+
+// An escaping directive is completely defined by the escaping function to use
+// (ModifierInfo.modifier) as well as the optional value it may require. This
+// structure is a small wrapper on ModifierInfo to convey that needed value.
+// Note: The given value pointer must be valid for the life of the struct.
+// Also, value is not null-terminated.
+struct ModifierAndValue {
+ ModifierAndValue(const ModifierInfo* mod_info, const char* val,
+ size_t val_len)
+ : modifier_info(mod_info), value(val), value_len(val_len) { }
+ const ModifierInfo* modifier_info;
+ const char* value;
+ size_t value_len;
+};
+
+// Returns whether or not candidate can be safely (w.r.t XSS)
+// used in lieu of our ModifierInfo. This is true iff:
+// 1. Both have the same modifier function OR
+// 2. Candidate's modifier function is in our ModifierInfo's
+// list (vector) of safe alternative modifier functions.
+// Note that this function is not commutative therefore
+// IsSafeXSSAlternative(a, b) may not be equal to IsSafeXSSAlternative(b, a).
+extern CTEMPLATE_DLL_DECL
+bool IsSafeXSSAlternative(const ModifierInfo& our,
+ const ModifierInfo& candidate);
+
+// modname is the name of the modifier (shortname or longname).
+// value is the modifier-value (empty string if there is no modval).
+// Returns a pointer into g_modifiers, or NULL if not found.
+extern CTEMPLATE_DLL_DECL
+const ModifierInfo* FindModifier(const char* modname, size_t modname_len,
+ const char* modval, size_t modval_len);
+
+
+// Convenience function to dump the (zero or more) modifiers (and values)
+// in the format:
+// :<modifier1>[=<val1>]<seperator>[:<modifier2>][=<val2>]...
+// If the modifier does not have a short_name, we print its long_name instead.
+// The separator may be an empty string.
+extern CTEMPLATE_DLL_DECL
+string PrettyPrintModifiers(
+ const vector<const ModifierAndValue*>& modvals,
+ const string& separator);
+
+extern CTEMPLATE_DLL_DECL
+string PrettyPrintOneModifier(const ModifierAndValue& modval);
+
+// Returns the appropriate escaping directives to escape content in an
+// HTML or Javascript context. HTML and Javascript contexts exercise
+// the same parser APIs and hence are combined here.
+// If an error occurs, we return NULL and append and error to error_msg.
+// The htmlparser and error_msg arguments must be non-NULL.
+// Currently, on success, we always return a vector of length 1, meaning
+// we never need to chain escaping directives. However, this is subject
+// to change.
+extern CTEMPLATE_DLL_DECL
+vector<const ModifierAndValue*> GetModifierForHtmlJs(
+ ctemplate_htmlparser::HtmlParser* htmlparser, string* error_msg);
+
+// Returns the appropriate escaping directives to escape content
+// in a CSS context.
+// Currently always returns cleanse_css and hence does not require the
+// parser nor can it fail. This will change once the parser is able to
+// distinguish between different CSS contexts, in particular CSS properties
+// that take URLs, which require a different escaping function (non-existent).
+extern CTEMPLATE_DLL_DECL
+vector<const ModifierAndValue*> GetModifierForCss(
+ ctemplate_htmlparser::HtmlParser* htmlparser, string* error_msg);
+
+// Returns the appropriate escaping directives to escape content
+// in an XML context.
+// Currently always returns xml_escape and hence does not require the
+// parser nor can it fail. This may change once the parser can parse XML.
+extern CTEMPLATE_DLL_DECL
+vector<const ModifierAndValue*> GetModifierForXml(
+ ctemplate_htmlparser::HtmlParser* htmlparser, string* error_msg);
+
+// Returns the appropriate escaping directives to escape content
+// in a JSON context.
+// Currently always returns javascript_escape and hence does not require the
+// parser nor can it fail. This may change once the parser can parse
+// and distinguish different contexts within JSON.
+extern CTEMPLATE_DLL_DECL
+vector<const ModifierAndValue*> GetModifierForJson(
+ ctemplate_htmlparser::HtmlParser* htmlparser, string* error_msg);
+
+// Return the default escaping directives to escape content for the given
+// context. These methods are useful when the caller does not have
+// access to a parser or when the parsed failed to parse.
+
+// GetDefaultModifierForHtml
+// GetDefaultModifierForJs
+// GetDefaultModifierForCss
+// GetDefaultModifierForXxml
+// GetDefaultModifierForJson
+// These functions are different from the GetModifierForXXX functions
+// in that they do not take a parser and cannot fail. They simply
+// return the most common escaping directive for the context they refer to.
+//
+// Some of these contexts (currently HTML and Javascript) have more than
+// one escaping directive associated with them and so we usually rely on
+// the current state of the parser to determine which directive to chose.
+// However, in some cases, the parser may fail to parse a given input
+// and so we may want to select the most likely escaping directive that
+// applies to the given context. Hence we use these functions instead of
+// the corresponding GetModifierForXXX ones.
+extern CTEMPLATE_DLL_DECL
+std::vector<const ModifierAndValue*> GetDefaultModifierForHtml();
+extern CTEMPLATE_DLL_DECL
+std::vector<const ModifierAndValue*> GetDefaultModifierForJs();
+extern CTEMPLATE_DLL_DECL
+std::vector<const ModifierAndValue*> GetDefaultModifierForCss();
+extern CTEMPLATE_DLL_DECL
+std::vector<const ModifierAndValue*> GetDefaultModifierForXml();
+extern CTEMPLATE_DLL_DECL
+std::vector<const ModifierAndValue*> GetDefaultModifierForJson();
+
+}
+
+#endif // TEMPLATE_TEMPLATE_MODIFIERS_INTERNAL_H_
diff --git a/src/template_namelist.cc b/src/template_namelist.cc
new file mode 100644
index 0000000..c834120
--- /dev/null
+++ b/src/template_namelist.cc
@@ -0,0 +1,194 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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 <config.h>
+#include <stdlib.h>
+#include <sys/stat.h> // for stat()
+#include <time.h> // for time_t
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <algorithm> // for binary_search
+#include HASH_SET_H // that's NameListType
+#include <string>
+#include <vector> // that's MissingListType, SyntaxListType
+#include <ctemplate/template_namelist.h>
+#include <ctemplate/template_pathops.h>
+#include <ctemplate/template.h> // for Strip, GetTemplate(), etc.
+#include <assert.h>
+#include <iostream> // for cerr
+#include "base/fileutil.h"
+
+using std::max;
+using std::pair;
+using std::string;
+using std::vector;
+
+#define LOG(level) std::cerr << #level << ": "
+
+namespace ctemplate {
+
+TemplateNamelist::NameListType *TemplateNamelist::namelist_ = NULL;
+TemplateNamelist::MissingListType *TemplateNamelist::missing_list_ = NULL;
+TemplateNamelist::SyntaxListType *TemplateNamelist::bad_syntax_list_ = NULL;
+
+// Make sure there is a namelist_ and then insert the name onto it
+const char* TemplateNamelist::RegisterTemplate(const char* name) {
+ if (!namelist_) {
+ namelist_ = new NameListType;
+ }
+ pair<NameListType::iterator, bool> insert_result = namelist_->insert(name);
+ // return a pointer to the entry corresponding to name;
+ return insert_result.first->c_str();
+}
+
+// GetList
+// Make sure there is a namelist_ and return a reference to it.
+const TemplateNamelist::NameListType& TemplateNamelist::GetList() {
+ if ( !namelist_ ) {
+ namelist_ = new NameListType;
+ }
+ return *namelist_;
+}
+
+// GetMissingList
+// On the first invocation, it creates a new missing list and sets
+// refresh to true.
+// If refresh is true, whether from being passed to the function
+// or being set when the list is created the first time, it iterates
+// through the complete list of registered template files
+// and adds to the list any that are missing
+// On subsequent calls, if refresh is false it merely returns the
+// list created in the prior call that refreshed the list.
+// Returns a sorted list of missing templates.
+const TemplateNamelist::MissingListType& TemplateNamelist::GetMissingList(
+ bool refresh) {
+ if (!missing_list_) {
+ missing_list_ = new MissingListType;
+ refresh = true; // always refresh the first time
+ }
+
+ if (refresh) {
+ const NameListType& the_list = TemplateNamelist::GetList();
+ missing_list_->clear();
+
+ for (NameListType::const_iterator iter = the_list.begin();
+ iter != the_list.end();
+ ++iter) {
+ const string path = Template::FindTemplateFilename(*iter);
+ if (path.empty() || !File::Readable(path.c_str())) {
+ missing_list_->push_back(*iter);
+ LOG(ERROR) << "Template file missing: " << *iter
+ << " at path: " << (path.empty() ? "(empty path)" : path)
+ << "\n";
+ }
+ }
+ }
+
+ sort(missing_list_->begin(), missing_list_->end());
+ return *missing_list_;
+}
+
+// GetBadSyntaxList
+// On the first invocation, it creates a new "bad syntax" list and
+// sets refresh to true.
+// If refresh is true, whether from being passed to the function
+// or being set when the list is created the first time, it
+// iterates through the complete list of registered template files
+// and adds to the list any that cannot be loaded. In the process, it
+// calls GetMissingList, refreshing it. It does not include any
+// files in the bad syntax list which are in the missing list.
+// On subsequent calls, if refresh is false it merely returns the
+// list created in the prior call that refreshed the list.
+const TemplateNamelist::SyntaxListType& TemplateNamelist::GetBadSyntaxList(
+ bool refresh, Strip strip) {
+ if (!bad_syntax_list_) {
+ bad_syntax_list_ = new SyntaxListType;
+ refresh = true; // always refresh the first time
+ }
+
+ if (refresh) {
+ const NameListType& the_list = TemplateNamelist::GetList();
+
+ bad_syntax_list_->clear();
+
+ const MissingListType& missing_list = GetMissingList(true);
+ for (NameListType::const_iterator iter = the_list.begin();
+ iter != the_list.end();
+ ++iter) {
+ Template *tpl = Template::GetTemplate((*iter), strip);
+ if (!tpl) {
+ if (!binary_search(missing_list.begin(), missing_list.end(), *iter)) {
+ // If it's not in the missing list, then we're here because
+ // it caused an error during parsing
+ bad_syntax_list_->push_back(*iter);
+ LOG(ERROR) << "Error loading template: " << (*iter) << "\n";
+ }
+ }
+ }
+ }
+ return *bad_syntax_list_;
+}
+
+// Look at all the existing template files, and get their lastmod time via stat()
+time_t TemplateNamelist::GetLastmodTime() {
+ time_t retval = -1;
+
+ const NameListType& the_list = TemplateNamelist::GetList();
+ for (NameListType::const_iterator iter = the_list.begin();
+ iter != the_list.end();
+ ++iter) {
+ // Only prepend root_dir if *iter isn't an absolute path:
+ const string path = Template::FindTemplateFilename(*iter);
+ struct stat statbuf;
+ if (path.empty() || stat(path.c_str(), &statbuf) != 0)
+ continue; // ignore files we can't find
+ retval = max(retval, statbuf.st_mtime);
+ }
+ return retval;
+}
+
+// AllDoExist
+bool TemplateNamelist::AllDoExist() {
+ // AllDoExist always refreshes the list, hence the "true"
+ const MissingListType& missing_list = TemplateNamelist::GetMissingList(true);
+ return missing_list.empty();
+}
+
+// IsAllSyntaxOkay
+bool TemplateNamelist::IsAllSyntaxOkay(Strip strip) {
+ // IsAllSyntaxOkay always refreshes the list, hence the "true"
+ const SyntaxListType& bad_syntax_list =
+ TemplateNamelist::GetBadSyntaxList(true, strip);
+ return bad_syntax_list.empty();
+}
+
+}
diff --git a/src/template_pathops.cc b/src/template_pathops.cc
new file mode 100644
index 0000000..177d730
--- /dev/null
+++ b/src/template_pathops.cc
@@ -0,0 +1,145 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// Routines for dealing with filesystem paths. Mostly to make porting
+// to windows easier, though it's nice to have an API for this kind of
+// thing.
+
+#include <config.h>
+#include <string>
+#include <ctype.h> // for isalpha, used on windows
+#include <string.h> // for strchr
+#include <ctemplate/template_pathops.h>
+
+#ifndef PATH_SEP
+# ifdef _WIN32
+# define PATH_SEP '\\'
+# else
+# define PATH_SEP '/' // assume a unix-like system
+# endif
+#endif
+
+namespace ctemplate {
+
+using std::string;
+
+const char kCWD[] = { '.', PATH_SEP, '\0' };
+const char kRootdir[] = { PATH_SEP, '\0' };
+
+// Windows is bi-slashual: we always write separators using PATH_SEP (\),
+// but accept either PATH_SEP or the unix / as a separator on input.
+inline bool IsPathSep(char c) {
+#ifdef _WIN32
+ if (c == '/') return true;
+#endif
+ return c == PATH_SEP;
+}
+
+// ----------------------------------------------------------------------
+// PathJoin()
+// Joins a and b together to form a path. If 'b' starts with '/'
+// then we just return b, otherwise a + b. If 'a' does not end in
+// a slash we put a slash in the middle. Does *not* resolve ..'s
+// and stuff like that, for now. Not very efficient.
+// Returns a string which is the joining.
+// ----------------------------------------------------------------------
+
+string PathJoin(const string& a, const string& b) {
+ if (b.empty()) return a; // degenerate case 1
+ if (a.empty()) return b; // degenerate case 2
+ if (IsAbspath(b)) return b; // absolute path
+ if (IsDirectory(a)) return a + b; // 'well-formed' case
+ return a + PATH_SEP + b;
+}
+
+bool IsAbspath(const string& path) {
+#ifdef _WIN32
+ if (path.size() > 2 && // c:\ is an absolute path on windows
+ path[1] == ':' && IsPathSep(path[2]) && isalpha(path[0])) {
+ return true;
+ }
+#endif
+ return !path.empty() && IsPathSep(path[0]);
+}
+
+bool IsDirectory(const string& path) {
+ return !path.empty() && IsPathSep(path[path.size()-1]);
+}
+
+void NormalizeDirectory(string* dir) {
+ if (dir->empty()) return; // I guess "" means 'current directory'
+ if (!IsPathSep((*dir)[dir->size()-1]))
+ *dir += PATH_SEP;
+}
+
+string Basename(const string& path) {
+ for (const char* p = path.data() + path.size()-1; p >= path.data(); --p) {
+ if (IsPathSep(*p))
+ return string(p+1, path.data() + path.size() - (p+1));
+ }
+ return path; // no path-separator found, so whole string is the basename
+}
+
+bool ContainsFullWord(const string& text, const string& word) {
+ // List of delimiter characters to be considered. Please update the comment in
+ // the header file if you change this list.
+ static const char* delim = ".,_-#*?:";
+
+ const int inputlength = text.length();
+ const int wordlength = word.length();
+
+ // corner cases
+ if (inputlength == 0 || wordlength == 0 || wordlength > inputlength) {
+ return false;
+ }
+
+ int nextmatchpos = 0; // position from where search in the input string
+ while (nextmatchpos < inputlength) {
+ const int pos = text.find(word, nextmatchpos);
+ if (pos == string::npos) {
+ return false; // no match at all
+ }
+
+ // if found, check that it is surrounded by delimiter characters.
+ bool pre_delimited = (pos == 0) ||
+ (strchr(delim, text.at(pos - 1)) != NULL);
+ bool post_delimited = (pos >= inputlength - wordlength) ||
+ (strchr(delim, text.at(pos + wordlength)) != NULL);
+ if (pre_delimited && post_delimited) return true;
+
+ nextmatchpos = (pos + wordlength + 1);
+ }
+
+ return false;
+}
+
+}
diff --git a/src/template_string.cc b/src/template_string.cc
new file mode 100644
index 0000000..a77d37f
--- /dev/null
+++ b/src/template_string.cc
@@ -0,0 +1,256 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Authors: jcrim@google.com (Jay Crim)
+// csilvers@google.com (Craig Silverstein)
+
+#include <config.h>
+#include "base/mutex.h" // This has to come first to get _XOPEN_SOURCE
+#include <ctemplate/find_ptr.h>
+#include <ctemplate/template_string.h>
+#include HASH_SET_H
+#include "base/arena.h"
+#include "base/thread_annotations.h"
+#include <assert.h>
+#include "base/macros.h" // for uint32, uint64, UNALIGNED_LOAD32
+#include "base/util.h"
+
+#ifdef HAVE_UNORDERED_MAP
+using HASH_NAMESPACE::unordered_set;
+// This is totally cheap, but minimizes the need for #ifdef's below...
+#define hash_set unordered_set
+#else
+using HASH_NAMESPACE::hash_set;
+#endif
+
+namespace ctemplate {
+
+// Based on public domain MurmurHashUnaligned2, by Austin Appleby.
+// http://murmurhash.googlepages.com/
+// This variation:
+// - interleaves odd/even 32-bit words to improve performance and
+// to generate more random bits,
+// - has a more complex final mix to combine the 32-bit hashes into
+// 64-bits,
+// - uses a fixed seed.
+// This is not static because template_string_test accesses it directly.
+uint64 MurmurHash64(const char* ptr, size_t len) {
+ const uint32 kMultiplyVal = 0x5bd1e995;
+ const int kShiftVal = 24;
+ const uint32 kHashSeed1 = 0xc86b14f7;
+ const uint32 kHashSeed2 = 0x650f5c4d;
+
+ uint32 h1 = kHashSeed1 ^ len, h2 = kHashSeed2;
+ while (len >= 8) {
+ uint32 k1 = UNALIGNED_LOAD32(ptr);
+ k1 *= kMultiplyVal;
+ k1 ^= k1 >> kShiftVal;
+ k1 *= kMultiplyVal;
+
+ h1 *= kMultiplyVal;
+ h1 ^= k1;
+ ptr += 4;
+
+ uint32 k2 = UNALIGNED_LOAD32(ptr);
+ k2 *= kMultiplyVal;
+ k2 ^= k2 >> kShiftVal;
+ k2 *= kMultiplyVal;
+
+ h2 *= kMultiplyVal;
+ h2 ^= k2;
+ ptr += 4;
+
+ len -= 8;
+ }
+
+ if (len >= 4) {
+ uint32 k1 = UNALIGNED_LOAD32(ptr);
+ k1 *= kMultiplyVal;
+ k1 ^= k1 >> kShiftVal;
+ k1 *= kMultiplyVal;
+
+ h1 *= kShiftVal;
+ h1 ^= k1;
+
+ ptr += 4;
+ len -= 4;
+ }
+
+ switch(len) {
+ case 3:
+ h2 ^= ptr[2] << 16; // fall through.
+ case 2:
+ h2 ^= ptr[1] << 8; // fall through.
+ case 1:
+ h2 ^= ptr[0]; // fall through.
+ default:
+ h2 *= kMultiplyVal;
+ }
+
+ h1 ^= h2 >> 18;
+ h1 *= kMultiplyVal;
+ h2 ^= h1 >> 22;
+ h2 *= kMultiplyVal;
+ h1 ^= h2 >> 17;
+ h1 *= kMultiplyVal;
+
+ uint64 h = h1;
+ h = (h << 32) | h2;
+ return h;
+}
+
+// Unlike StaticTemplateString, it is not a good idea to have a
+// default TemplateString::Hasher because TemplateString does not
+// provide any lifetime guarantees. The global template_string_set is
+// an obvious exception.
+struct TemplateStringHasher {
+ size_t operator()(const TemplateString& ts) const {
+ TemplateId id = ts.GetGlobalId();
+ DCHECK(IsTemplateIdInitialized(id));
+ return hasher(id);
+ }
+ // Less operator for MSVC's hash containers.
+ bool operator()(const TemplateString& a, const TemplateString& b) const {
+ const TemplateId id_a = a.GetGlobalId();
+ const TemplateId id_b = b.GetGlobalId();
+ assert(IsTemplateIdInitialized(id_a));
+ assert(IsTemplateIdInitialized(id_b));
+ return hasher(id_a, id_b);
+ }
+ TemplateIdHasher hasher;
+ // These two public members are required by msvc. 4 and 8 are defaults.
+ static const size_t bucket_size = 4;
+ static const size_t min_buckets = 8;
+};
+
+namespace {
+Mutex mutex(base::LINKER_INITIALIZED);
+
+typedef hash_set<TemplateString, TemplateStringHasher> TemplateStringSet;
+
+TemplateStringSet* template_string_set
+GUARDED_BY(mutex) PT_GUARDED_BY(mutex) = NULL;
+
+UnsafeArena* arena
+GUARDED_BY(mutex) PT_GUARDED_BY(mutex) = NULL;
+} // unnamed namespace
+
+
+size_t StringHash::Hash(const char* s, size_t slen) const {
+ return static_cast<size_t>(MurmurHash64(s, slen));
+}
+
+void TemplateString::AddToGlobalIdToNameMap() LOCKS_EXCLUDED(mutex) {
+ // shouldn't be calling this if we don't have an id.
+ CHECK(IsTemplateIdInitialized(id_));
+ {
+ // Check to see if it's already here.
+ ReaderMutexLock reader_lock(&mutex);
+ if (template_string_set) {
+ const TemplateString* iter =
+ find_ptr0(*template_string_set, *this);
+ if (iter) {
+ DCHECK_EQ(TemplateString(ptr_, length_),
+ TemplateString(iter->ptr_, iter->length_))
+ << "TemplateId collision!";
+ return;
+ }
+ }
+ }
+ WriterMutexLock writer_lock(&mutex);
+ // First initialize our data structures if we need to.
+ if (!template_string_set) {
+ template_string_set = new TemplateStringSet;
+ }
+
+ if (!arena) {
+ arena = new UnsafeArena(1024); // 1024 was picked out of a hat.
+ }
+
+ if (template_string_set->count(*this)) {
+ return;
+ }
+ // If we are immutable, we can store ourselves directly in the map.
+ // Otherwise, we need to make an immutable copy.
+ if (is_immutable()) {
+ template_string_set->insert(*this);
+ } else {
+ const char* immutable_copy = arena->Memdup(ptr_, length_);
+ template_string_set->insert(
+ TemplateString(immutable_copy, length_, true, id_));
+ }
+}
+
+TemplateId TemplateString::GetGlobalId() const {
+ if (IsTemplateIdInitialized(id_)) {
+ return id_;
+ }
+ // Initialize the id and sets the "initialized" flag.
+ return static_cast<TemplateId>(MurmurHash64(ptr_, length_) |
+ kTemplateStringInitializedFlag);
+}
+
+// static
+TemplateString TemplateString::IdToString(TemplateId id) LOCKS_EXCLUDED(mutex) {
+ ReaderMutexLock reader_lock(&mutex);
+ if (!template_string_set)
+ return TemplateString(kStsEmpty);
+ // To search the set by TemplateId, we must first construct a dummy
+ // TemplateString. This may seem weird, but it lets us use a
+ // hash_set instead of a hash_map.
+ TemplateString id_as_template_string(NULL, 0, false, id);
+ const TemplateString* iter = find_ptr0(*template_string_set, id_as_template_string);
+ return iter ? *iter : TemplateString(kStsEmpty);
+}
+
+StaticTemplateStringInitializer::StaticTemplateStringInitializer(
+ const StaticTemplateString* sts) {
+ // Compute the sts's id if it wasn't specified at static-init
+ // time. If it was specified at static-init time, verify it's
+ // correct. This is necessary because static-init id's are, by
+ // nature, pre-computed, and the id-generating algorithm may have
+ // changed between the time they were computed and now.
+ if (sts->do_not_use_directly_.id_ == 0) {
+ sts->do_not_use_directly_.id_ = TemplateString(*sts).GetGlobalId();
+ } else {
+ // Don't use the TemplateString(const StaticTemplateString& sts)
+ // constructor below, since if we do, GetGlobalId will just return
+ // sts->do_not_use_directly_.id_ and the check will be pointless.
+ DCHECK_EQ(TemplateString(sts->do_not_use_directly_.ptr_,
+ sts->do_not_use_directly_.length_).GetGlobalId(),
+ sts->do_not_use_directly_.id_);
+ }
+
+ // Now add this id/name pair to the backwards map from id to name.
+ TemplateString ts_copy_of_sts(*sts);
+ ts_copy_of_sts.AddToGlobalIdToNameMap();
+}
+
+}
diff --git a/src/tests/compile_test.cc b/src/tests/compile_test.cc
new file mode 100644
index 0000000..4951e56
--- /dev/null
+++ b/src/tests/compile_test.cc
@@ -0,0 +1,76 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: Craig Silverstein
+//
+// Most other tests use "config_for_unittests.h" to make testing easier.
+// This brings in some code most users won't use. This test is meant
+// entirely to use ctemplate as users will, just #including the public
+// .h files directly. It does hardly any work, and is mainly intended
+// as a compile check for the .h files. It will not work if you use
+// a non-standard name for the package namespace (via
+// ./configure --enable-namespace=foo
+// ), though you can fix that by changing the namespace alias below.
+
+// These are all the .h files that we export
+#include <ctemplate/per_expand_data.h>
+#include <ctemplate/template.h>
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_dictionary_interface.h>
+#include <ctemplate/template_emitter.h>
+#include <ctemplate/template_enums.h>
+#include <ctemplate/template_modifiers.h>
+#include <ctemplate/template_namelist.h>
+#include <ctemplate/template_pathops.h>
+#include <ctemplate/template_string.h>
+#include <stdio.h>
+#include <string>
+
+// If you used ./configure --enable-namespace=foo, replace 'ctemplate'
+// here with 'foo'.
+namespace template_ns = ctemplate;
+
+int main() {
+ template_ns::Template::StringToTemplateCache("key", "example");
+ template_ns::Template* tpl = template_ns::Template::GetTemplate(
+ "key", template_ns::DO_NOT_STRIP);
+ template_ns::TemplateDictionary dict("my dict");
+ std::string nothing_will_come_of_nothing;
+ tpl->Expand(¬hing_will_come_of_nothing, &dict);
+
+ // Try using a bit more functionality.
+ template_ns::PerExpandData data;
+ nothing_will_come_of_nothing.clear();
+ template_ns::ExpandWithData("key", template_ns::DO_NOT_STRIP, &dict, &data,
+ ¬hing_will_come_of_nothing);
+
+ printf("PASS.\n");
+ return 0;
+}
diff --git a/src/tests/config_for_unittests.h b/src/tests/config_for_unittests.h
new file mode 100644
index 0000000..aa20d9f
--- /dev/null
+++ b/src/tests/config_for_unittests.h
@@ -0,0 +1,63 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// All Rights Reserved.
+//
+//
+// This file is needed for windows -- unittests are not part of the
+// ctemplate dll, but still want to include config.h just like the
+// dll does, so they can use internal tools and APIs for testing.
+//
+// The problem is that config.h declares CTEMPLATE_DLL_DECL to be
+// for exporting symbols, but the unittest needs to *import* symbols
+// (since it's not the dll).
+//
+// The solution is to have this file, which is just like config.h but
+// sets CTEMPLATE_DLL_DECL to do a dllimport instead of a dllexport.
+//
+// The reason we need this extra CTEMPLATE_DLL_DECL_FOR_UNITTESTS
+// variable is in case people want to set CTEMPLATE_DLL_DECL explicitly
+// to something other than __declspec(dllexport). In that case, they
+// may want to use something other than __declspec(dllimport) for the
+// unittest case. For that, we allow folks to define both
+// CTEMPLATE_DLL_DECL and CTEMPLATE_DLL_DECL_FOR_UNITTESTS explicitly.
+//
+// NOTE: This file is equivalent to config.h on non-windows systems,
+// which never defined CTEMPLATE_DLL_DECL_FOR_UNITTESTS and always
+// define CTEMPLATE_DLL_DECL to the empty string.
+
+#include "config.h"
+
+#undef CTEMPLATE_DLL_DECL
+#ifdef CTEMPLATE_DLL_DECL_FOR_UNITTESTS
+# define CTEMPLATE_DLL_DECL CTEMPLATE_DLL_DECL_FOR_UNITTESTS
+#else
+# define CTEMPLATE_DLL_DECL // if DLL_DECL_FOR_UNITTESTS isn't defined, use ""
+#endif
diff --git a/src/tests/diff_tpl_auto_escape_unittest.sh b/src/tests/diff_tpl_auto_escape_unittest.sh
new file mode 100755
index 0000000..b74f112
--- /dev/null
+++ b/src/tests/diff_tpl_auto_escape_unittest.sh
@@ -0,0 +1,196 @@
+#!/bin/sh
+
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+
+# ---
+# Author: jad@google.com (Jad Boutros)
+# Heavily inspired from make_tpl_varnames_h_unittest.sh
+#
+#
+# TODO(jad): Add better testing of Strip mode.
+# TODO(jad): Add testing for (lame) suppressed diffs.
+
+die() {
+ echo "Test failed: $@" 1>&2
+ exit 1
+}
+
+TEST_SRCDIR=${TEST_SRCDIR-"."}
+TEST_TMPDIR=${TMPDIR-"/tmp"}
+
+# Optional first argument is where the executable lives
+DIFFTPL=${1-"$TEST_SRCDIR/diff_tpl_auto_escape"}
+
+# Optional second argument is tmpdir to use
+TMPDIR=${2-"$TEST_TMPDIR/difftpl"}
+
+rm -rf $TMPDIR
+mkdir $TMPDIR || die "$LINENO: Can't make $TMPDIR"
+
+# Let's make some templates
+# ok1.tpl is valid HTML and has one correct modifier.
+echo '<a href="{{URL}}">{{USER:h}}</a>' > $TMPDIR/ok1.tpl
+
+# ok2.tpl is valid HTML and has one right and one wrong modifier.
+echo '<a href="{{URL:U=html}}">{{USER:j}}</a>' > $TMPDIR/ok2.tpl
+
+# ok3.tpl is valid HTML and has both wrong modifiers.
+echo '<a href="{{URL:h}}">{{USER:c}}</a>' > $TMPDIR/ok3.tpl
+
+# ok4.tpl is valid HTML and is auto-escaped.
+echo '{{%AUTOESCAPE context="HTML"}}' \
+ '<a href="{{URL}}">{{USER}}</a>' > $TMPDIR/ok4.tpl
+# bad1.tpl will fail auto-escape parsing.
+echo '{{%AUTOESCAPE context="HTML"}}<a href={{QC' > $TMPDIR/bad1.tpl
+
+# First, test commandline flags
+$DIFFTPL >/dev/null 2>&1 \
+ && die "$LINENO: $DIFFTPL with no args didn't give an error"
+$DIFFTPL --strip=STRIP_WHITESPACE >/dev/null 2>&1 \
+ && die "$LINENO: $DIFFTPL with no template didn't give an error"
+$DIFFTPL $TMPDIR/ok1.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $DIFFTPL with only one template didn't give an error"
+$DIFFTPL -sFOO $TMPDIR/ok1.tpl $TMPDIR/ok1.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $DIFFTPL with bad strip didn't given an error"
+$DIFFTPL --strip=BLA $TMPDIR/ok1.tpl $TMPDIR/ok1.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $DIFFTPL with other bad strip didn't given an error"
+$DIFFTPL -h >/dev/null 2>&1 \
+ || die "$LINENO: $DIFFTPL -h failed"
+$DIFFTPL --help >/dev/null 2>&1 \
+ || die "$LINENO: $DIFFTPL --help failed"
+
+# Some weird (broken) shells leave the ending EOF in the here-document,
+# hence the grep.
+# Diff between ok1.tpl and ok4.tpl. No differences.
+expected_test1_verbose=`cat <<EOF | grep -v '^EOF$'
+[VERBOSE] ------ Diff of [$TMPDIR/ok1.tpl, $TMPDIR/ok4.tpl] ------
+[VERBOSE] Variables Found: Total=2; Diffs=0; NoMods=1
+EOF`
+
+expected_test1=`cat <<EOF | grep -v '^EOF$'
+EOF`
+
+# Diff between ok1.tpl and ok2.tpl. Expect one difference.
+expected_test2_verbose=`cat <<EOF | grep -v '^EOF$'
+[VERBOSE] ------ Diff of [$TMPDIR/ok1.tpl, $TMPDIR/ok2.tpl] ------
+Difference for variable USER -- :h vs. :j
+[VERBOSE] Variables Found: Total=2; Diffs=1; NoMods=1
+EOF`
+
+expected_test2=`cat <<EOF | grep -v '^EOF$'
+Difference for variable USER -- :h vs. :j
+EOF`
+
+# Diff between ok3.tpl and ok4.tpl. Expect two differences.
+expected_test3_verbose=`cat <<EOF | grep -v '^EOF$'
+[VERBOSE] ------ Diff of [$TMPDIR/ok3.tpl, $TMPDIR/ok4.tpl] ------
+Difference for variable URL -- :h vs. :U=html
+Difference for variable USER -- :c vs. :h
+[VERBOSE] Variables Found: Total=2; Diffs=2; NoMods=0
+EOF`
+
+expected_test3=`cat <<EOF | grep -v '^EOF$'
+Difference for variable URL -- :h vs. :U=html
+Difference for variable USER -- :c vs. :h
+EOF`
+
+# Diff between ok2.tpl and ok3.tpl. Expect two differences.
+expected_test4_verbose=`cat <<EOF | grep -v '^EOF$'
+[VERBOSE] ------ Diff of [$TMPDIR/ok2.tpl, $TMPDIR/ok3.tpl] ------
+Difference for variable URL -- :U=html vs. :h
+Difference for variable USER -- :j vs. :c
+[VERBOSE] Variables Found: Total=2; Diffs=2; NoMods=0
+EOF`
+
+expected_test4=`cat <<EOF | grep -v '^EOF$'
+Difference for variable URL -- :U=html vs. :h
+Difference for variable USER -- :j vs. :c
+EOF`
+
+
+# syntax-check these templates
+echo "TMPDIR is: $TMPDIR"
+$DIFFTPL $TMPDIR/ok1.tpl $TMPDIR/ok1.tpl >/dev/null 2>&1 \
+ || die "$LINENO: $DIFFTPL gave error parsing identical templates"
+$DIFFTPL $TMPDIR/ok1.tpl $TMPDIR/bad1.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $DIFFTPL gave no error parsing bad template"
+$DIFFTPL $TMPDIR/ok100.tpl $TMPDIR/ok1.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $DIFFTPL gave no error parsing non-existent template"
+
+# Now try the same thing, but use template-root so we don't need absdirs
+$DIFFTPL --template_root=$TMPDIR ok2.tpl ok2.tpl >/dev/null 2>&1 \
+ || die "$LINENO: $DIFFTPL gave error parsing identical templates"
+
+# Diffing the same template produces exit code 0. Check with all Strip values.
+$DIFFTPL -sSTRIP_WHITESPACE $TMPDIR/ok1.tpl $TMPDIR/ok1.tpl >/dev/null 2>&1
+[ $? = 0 ] || die "$LINENO: $DIFFTPL: wrong error-code on same template: $?"
+$DIFFTPL -sSTRIP_BLANK_LINES $TMPDIR/ok1.tpl $TMPDIR/ok1.tpl >/dev/null 2>&1
+[ $? = 0 ] || die "$LINENO: $DIFFTPL: wrong error-code on same template: $?"
+$DIFFTPL -sDO_NOT_STRIP $TMPDIR/ok1.tpl $TMPDIR/ok1.tpl >/dev/null 2>&1
+[ $? = 0 ] || die "$LINENO: $DIFFTPL: wrong error-code on same template: $?"
+
+# Diffing templates with diff, should produce exit code 1.
+$DIFFTPL $TMPDIR/ok1.tpl $TMPDIR/ok2.tpl >/dev/null 2>&1
+[ $? = 1 ] || die "$LINENO: $DIFFTPL: wrong error-code on diff. templates: $?"
+
+# Diffing templates with failure, should produce exit code 1.
+$DIFFTPL $TMPDIR/ok1.tpl $TMPDIR/ok100.tpl >/dev/null 2>&1
+[ $? = 1 ] || die "$LINENO: $DIFFTPL: wrong error-code on failed template: $?"
+
+# If you use relative filenames, must first fix expected outputs.
+out=`$DIFFTPL -v $TMPDIR/ok1.tpl $TMPDIR/ok4.tpl 2>&1`
+[ "$out" != "$expected_test1_verbose" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test1_verbose: $out\n"
+out=`$DIFFTPL $TMPDIR/ok1.tpl $TMPDIR/ok4.tpl 2>&1`
+[ "$out" != "$expected_test1" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test1: $out\n"
+
+out=`$DIFFTPL -v $TMPDIR/ok1.tpl $TMPDIR/ok2.tpl 2>&1`
+[ "$out" != "$expected_test2_verbose" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test2_verbose: $out\n"
+out=`$DIFFTPL $TMPDIR/ok1.tpl $TMPDIR/ok2.tpl 2>&1`
+[ "$out" != "$expected_test2" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test2: $out\n"
+
+out=`$DIFFTPL -v $TMPDIR/ok3.tpl $TMPDIR/ok4.tpl 2>&1`
+[ "$out" != "$expected_test3_verbose" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test3_verbose: $out\n"
+out=`$DIFFTPL $TMPDIR/ok3.tpl $TMPDIR/ok4.tpl 2>&1`
+[ "$out" != "$expected_test3" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test3: $out\n"
+
+out=`$DIFFTPL -v $TMPDIR/ok2.tpl $TMPDIR/ok3.tpl 2>&1`
+[ "$out" != "$expected_test4_verbose" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test4_verbose: $out\n"
+out=`$DIFFTPL $TMPDIR/ok2.tpl $TMPDIR/ok3.tpl 2>&1`
+[ "$out" != "$expected_test4" ] &&\
+ die "$LINENO: $DIFFTPL: bad output for test4: $out\n"
+
+echo "PASSED"
diff --git a/src/tests/generate_fsm_c_test.c b/src/tests/generate_fsm_c_test.c
new file mode 100644
index 0000000..83ca730
--- /dev/null
+++ b/src/tests/generate_fsm_c_test.c
@@ -0,0 +1,53 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ * ---
+ *
+ * Author: falmeida@google.com (Filipe Almeida)
+ *
+ * Validate that sample_fsm.c compiles.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include "htmlparser/statemachine.h"
+
+enum states {
+ STRINGPARSER_STATE_TEXT,
+ STRINGPARSER_STATE_STRING
+};
+
+#include "tests/htmlparser_testdata/sample_fsm.c"
+
+int main()
+{
+ (void)stringparser_states_internal_names;
+ (void)stringparser_state_transitions;
+ printf("DONE.\n");
+ exit(0);
+}
diff --git a/src/tests/generate_fsm_test.sh b/src/tests/generate_fsm_test.sh
new file mode 100755
index 0000000..6d26947
--- /dev/null
+++ b/src/tests/generate_fsm_test.sh
@@ -0,0 +1,77 @@
+#!/bin/bash
+#
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+# ---
+#
+# Author: falmeida@google.com (Filipe Almeida)
+
+die() {
+ echo "Test failed: $@" 1>&2
+ exit 1
+}
+TEST_SRCDIR=${1:-$TEST_SRCDIR}
+TOOLS_DIR="$TEST_SRCDIR/src/htmlparser"
+TESTDATA_DIR="$TEST_SRCDIR/src/tests/htmlparser_testdata"
+
+# Find input files
+INPUT_FILE="$TESTDATA_DIR/sample_fsm.config"
+OUTPUT_FILE="$TESTDATA_DIR/sample_fsm.c"
+GENERATE_FSM="$TOOLS_DIR/generate_fsm.py"
+
+EXPECTED="`cat $OUTPUT_FILE`"
+if [ -z "$EXPECTED" ]; then die "Error reading $OUTPUT_FILE"; fi
+
+# Let's make sure the script works with python2.2 and above
+for PYTHON in "" "python2.2" "python2.3" "python2.4" "python2.5" "python2.6"; do
+ # Skip the versions of python that are not installed.
+ if [ -n "$PYTHON" ]; then
+ $PYTHON -h >/dev/null 2>/dev/null || continue
+ else # use the python that's in the shebang line
+ SHEBANG_PYTHON=`head -n1 "$GENERATE_FSM" | tr -d '#!'`
+ # SHEBANG_PYTHON could be something like "env python" so don't quotify it
+ $SHEBANG_PYTHON -h >/dev/null 2>/dev/null || continue
+ fi
+ echo "-- Running $PYTHON $GENERATE_FSM $INPUT_FILE"
+ # The tr is to get rid of windows-style line endings (\r)
+ GENERATED="`$PYTHON $GENERATE_FSM $INPUT_FILE | tr -d '\015'`"
+ if [ -z "$GENERATED" ]; then die "Error running $GENERATE_FSM"; fi
+
+ if [ "$EXPECTED" != "$GENERATED" ]; then
+ echo "Test failed ($PYTHON $GENERATE_FSM $INPUT_FILE)" 1>&2
+ echo "-- EXPECTED --" 1>&2
+ echo "$EXPECTED" 1>&2
+ echo "-- GENERATED --" 1>&2
+ echo "$GENERATED" 1>&2
+ echo "--"
+ exit 1
+ fi
+done
+
+echo "PASS"
diff --git a/src/tests/htmlparser_cpp_test.cc b/src/tests/htmlparser_cpp_test.cc
new file mode 100644
index 0000000..a8bcf79
--- /dev/null
+++ b/src/tests/htmlparser_cpp_test.cc
@@ -0,0 +1,629 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+// ---
+// Author: falmeida@google.com (Filipe Almeida)
+//
+// Verify at different points during HTML processing that the parser is in the
+// correct state.
+//
+// The annotated file consists of regular html blocks and html processing
+// instructions with a target name of "state" and a list of comma separated key
+// value pairs describing the expected state or invoking a parser method.
+// Example:
+//
+// <html><body><?state state=text, tag=body ?>
+//
+// For a more detailed explanation of the acceptable values please consult
+// htmlparser_cpp.h. Following is a list of the possible keys:
+//
+// state: Current parser state as returned by HtmlParser::state().
+// Possible values: text, tag, attr, value, comment or error.
+// tag: Current tag name as returned by HtmlParser::tag()
+// attr: Current attribute name as returned by HtmlParser::attr()
+// attr_type: Current attribute type as returned by HtmlParser::attr_type()
+// Possible values: none, regular, uri, js or style.
+// attr_quoted: True if the attribute is quoted, false if it's not.
+// in_js: True if currently processing javascript (either an attribute value
+// that expects javascript, a script block or the parser being in
+// MODE_JS)
+// js_quoted: True if inside a javascript string literal.
+// js_state: Current javascript state as returned by
+// HtmlParser::javascript_state().
+// Possible values: text, q, dq, regexp or comment.
+// in_css: True if currently inside a CSS section or attribute.
+// line_number: Integer value containing the current line count.
+// column_number: Integer value containing the current column count.
+// value_index: Integer value containing the current character index in the
+// current value starting from 0.
+// is_url_start: True if if this is the first character of a url attribute.
+// reset: If true, resets the parser state to it's initial values.
+// reset_mode: Similar to reset but receives an argument that changes the
+// parser mode into either mode html or mode js.
+// insert_text: Executes HtmlParser::InsertText() if the argument is true.
+
+#include "config_for_unittests.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <string>
+#include <utility>
+#include <vector>
+#include <map>
+#include "htmlparser/htmlparser_cpp.h"
+#include "ctemplate/template_pathops.h"
+#include "base/util.h"
+
+#define FAIL() EXPECT_TRUE(false)
+TEST_INIT // Among other things, defines RUN_ALL_TESTS
+
+using std::map;
+using std::pair;
+using std::string;
+using std::vector;
+using GOOGLE_NAMESPACE::PathJoin;
+
+namespace ctemplate_htmlparser {
+
+// Maximum file size limit.
+static const int kMaxFileSize = 1000000;
+
+static void ReadToString(const char* filename, string* s) {
+ const int bufsize = 8092;
+ char buffer[bufsize];
+ size_t n;
+ FILE* fp = fopen(filename, "rb");
+ if (!fp) PFATAL(filename);
+ while ((n=fread(buffer, 1, bufsize, fp)) > 0) {
+ if (ferror(fp)) PFATAL(filename);
+ s->append(string(buffer, n));
+ }
+ fclose(fp);
+}
+
+class HtmlparserCppTest : public testing::Test {
+ protected:
+
+ typedef map<string, HtmlParser *> ContextMap;
+
+ // Structure that stores the mapping between an id and a name.
+ struct IdNameMap {
+ int id;
+ const char *name;
+ };
+
+ // Mapping between the enum and the string representation of the state.
+ static const struct IdNameMap kStateMap[];
+
+ // Mapping between the enum and the string representation of the javascript
+ // state.
+ static const struct IdNameMap kJavascriptStateMap[];
+
+ // Mapping between the enum and the string representation of the attribute
+ // type.
+ static const struct IdNameMap kAttributeTypeMap[];
+
+ // Mapping between the enum and the string representation of the reset mode.
+ static const struct IdNameMap kResetModeMap[];
+
+ // String that marks the start of an annotation.
+ static const char kDirectiveBegin[];
+
+ // String that marks the end of an annotation.
+ static const char kDirectiveEnd[];
+
+ // Count the number of lines in a string.
+ static int UpdateLines(const string &str, int line);
+
+ // Count the number of columns in a string.
+ static int UpdateColumns(const string &str, int column);
+
+ // Converts a string to a boolean.
+ static bool StringToBool(const string &value);
+
+ // Returns the name of the corresponding enum_id by consulting an array of
+ // type IdNameMap.
+ const char *IdToName(const struct IdNameMap *list, int enum_id);
+
+ // Returns the enum_id of the correspondent name by consulting an array of
+ // type IdNameMap.
+ int NameToId(const struct IdNameMap *list, const string &name);
+
+ // Reads the filename of an annotated html file and validates the
+ // annotations against the html parser state.
+ void ValidateFile(string filename);
+
+ // Validate an annotation string against the current parser state.
+ void ProcessAnnotation(const string &dir);
+
+ // Validate the parser state against the provided state.
+ void ValidateState(const string &tag);
+
+ // Validate the parser tag name against the provided tag name.
+ void ValidateTag(const string &tag);
+
+ // Validate the parser attribute name against the provided attribute name.
+ void ValidateAttribute(const string &attr);
+
+ // Validate the parser attribute value contents against the provided string.
+ void ValidateValue(const string &contents);
+
+ // Validate the parser attribute type against the provided attribute type.
+ void ValidateAttributeType(const string &attr);
+
+ // Validate the parser attribute quoted state against the provided
+ // boolean.
+ void ValidateAttributeQuoted(const string "ed);
+
+ // Validates the parser in javascript state against the provided boolean.
+ void ValidateInJavascript(const string "ed);
+
+ // Validate the current parser javascript quoted state against the provided
+ // boolean.
+ void ValidateJavascriptQuoted(const string "ed);
+
+ // Validate the javascript parser state against the provided state.
+ void ValidateJavascriptState(const string &expected_state);
+
+ // Validates the parser css state against the provided boolean.
+ void ValidateInCss(const string "ed);
+
+ // Validate the line count against the expected count.
+ void ValidateLine(const string &expected_line);
+
+ // Validate the line count against the expected count.
+ void ValidateColumn(const string &expected_column);
+
+ // Validate the current parser value index against the provided index.
+ void ValidateValueIndex(const string &value_index);
+
+ // Validate the parser is_url_start value against the provided one.
+ void ValidateIsUrlStart(const string &expected_is_url_start);
+
+ void SetUp() {
+ parser_.Reset();
+ }
+
+ void TearDown() {
+ // Delete all parser instances from the context map
+ for (ContextMap::iterator iter = contextMap.begin();
+ iter != contextMap.end(); ++iter) {
+ delete iter->second;
+ }
+ contextMap.clear();
+ }
+
+ // Map containing the registers where the parser context is saved.
+ ContextMap contextMap;
+
+ // Parser instance
+ HtmlParser parser_;
+
+ friend class Test_HtmlparserTest_TestFiles;
+};
+
+const char HtmlparserCppTest::kDirectiveBegin[] = "<?state";
+const char HtmlparserCppTest::kDirectiveEnd[] = "?>";
+
+const struct HtmlparserCppTest::IdNameMap
+ HtmlparserCppTest::kStateMap[] = {
+ { HtmlParser::STATE_TEXT, "text" },
+ { HtmlParser::STATE_TAG, "tag" },
+ { HtmlParser::STATE_ATTR, "attr" },
+ { HtmlParser::STATE_VALUE, "value" },
+ { HtmlParser::STATE_COMMENT, "comment" },
+ { HtmlParser::STATE_JS_FILE, "js_file" },
+ { HtmlParser::STATE_CSS_FILE, "css_file" },
+ { HtmlParser::STATE_ERROR, "error" },
+ { 0, NULL }
+};
+
+const struct HtmlparserCppTest::IdNameMap
+ HtmlparserCppTest::kAttributeTypeMap[] = {
+ { HtmlParser::ATTR_NONE, "none" },
+ { HtmlParser::ATTR_REGULAR, "regular" },
+ { HtmlParser::ATTR_URI, "uri" },
+ { HtmlParser::ATTR_JS, "js" },
+ { HtmlParser::ATTR_STYLE, "style" },
+ { 0, NULL }
+};
+
+const struct HtmlparserCppTest::IdNameMap
+ HtmlparserCppTest::kJavascriptStateMap[] = {
+ { JavascriptParser::STATE_TEXT, "text" },
+ { JavascriptParser::STATE_Q, "q" },
+ { JavascriptParser::STATE_DQ, "dq" },
+ { JavascriptParser::STATE_REGEXP, "regexp" },
+ { JavascriptParser::STATE_COMMENT, "comment" },
+ { 0, NULL }
+};
+
+const struct HtmlparserCppTest::IdNameMap
+ HtmlparserCppTest::kResetModeMap[] = {
+ { HtmlParser::MODE_HTML, "html" },
+ { HtmlParser::MODE_JS, "js" },
+ { HtmlParser::MODE_CSS, "css" },
+ { HtmlParser::MODE_HTML_IN_TAG, "html_in_tag" },
+ { 0, NULL }
+};
+
+
+// Count the number of lines in a string.
+int HtmlparserCppTest::UpdateLines(const string &str, int line) {
+ int linecount = line;
+ for (string::size_type i = 0; i < str.length(); ++i) {
+ if (str[i] == '\n')
+ ++linecount;
+ }
+ return linecount;
+}
+
+// Count the number of columns in a string.
+int HtmlparserCppTest::UpdateColumns(const string &str, int column) {
+ // Number of bytes since the last newline.
+ size_t last_newline = str.rfind('\n');
+
+ // If no newline was found, we just sum up all the characters in the
+ // annotation.
+ if (last_newline == string::npos) {
+ return static_cast<int>(column + str.size() +
+ strlen(kDirectiveBegin) + strlen(kDirectiveEnd));
+ // If a newline was found, the new column count becomes the number of
+ // characters after the last newline.
+ } else {
+ return static_cast<int>(str.size() + strlen(kDirectiveEnd) - last_newline);
+ }
+}
+
+
+// Converts a string to a boolean.
+bool HtmlparserCppTest::StringToBool(const string &value) {
+ if (strcasecmp(value.c_str(), "true") == 0) {
+ return true;
+ } else if (strcasecmp(value.c_str(), "false") == 0) {
+ return false;
+ } else {
+ LOG(FATAL) << "Unknown boolean value";
+ }
+}
+
+// Returns the name of the corresponding enum_id by consulting an array of
+// type IdNameMap.
+const char *HtmlparserCppTest::IdToName(const struct IdNameMap *list,
+ int enum_id) {
+ CHECK(list != NULL);
+ while (list->name) {
+ if (enum_id == list->id) {
+ return list->name;
+ }
+ list++;
+ }
+ LOG(FATAL) << "Unknown id";
+}
+
+// Returns the enum_id of the correspondent name by consulting an array of
+// type IdNameMap.
+int HtmlparserCppTest::NameToId(const struct IdNameMap *list,
+ const string &name) {
+ CHECK(list != NULL);
+ while (list->name) {
+ if (name.compare(list->name) == 0) {
+ return list->id;
+ }
+ list++;
+ }
+ LOG(FATAL) << "Unknown name";
+}
+
+// Validate the parser state against the provided state.
+void HtmlparserCppTest::ValidateState(const string &expected_state) {
+ const char* parsed_state = IdToName(kStateMap, parser_.state());
+ EXPECT_TRUE(parsed_state != NULL);
+ EXPECT_TRUE(!expected_state.empty());
+ EXPECT_EQ(expected_state, string(parsed_state))
+ << "Unexpected state at line " << parser_.line_number();
+}
+
+// Validate the parser tag name against the provided tag name.
+void HtmlparserCppTest::ValidateTag(const string &expected_tag) {
+ EXPECT_TRUE(parser_.tag() != NULL);
+ EXPECT_TRUE(expected_tag == parser_.tag())
+ << "Unexpected attr tag name at line " << parser_.line_number();
+}
+
+// Validate the parser attribute name against the provided attribute name.
+void HtmlparserCppTest::ValidateAttribute(const string &expected_attr) {
+ EXPECT_TRUE(parser_.attribute() != NULL);
+ EXPECT_EQ(expected_attr, parser_.attribute())
+ << "Unexpected attr name value at line " << parser_.line_number();
+}
+
+// Validate the parser attribute value contents against the provided string.
+void HtmlparserCppTest::ValidateValue(const string &expected_value) {
+ EXPECT_TRUE(parser_.value() != NULL);
+ const string parsed_state(parser_.value());
+ EXPECT_EQ(expected_value, parsed_state)
+ << "Unexpected value at line " << parser_.line_number();
+}
+
+// Validate the parser attribute type against the provided attribute type.
+void HtmlparserCppTest::ValidateAttributeType(
+ const string &expected_attr_type) {
+ const char *parsed_attr_type = IdToName(kAttributeTypeMap,
+ parser_.AttributeType());
+ EXPECT_TRUE(parsed_attr_type != NULL);
+ EXPECT_TRUE(!expected_attr_type.empty());
+ EXPECT_EQ(expected_attr_type, string(parsed_attr_type))
+ << "Unexpected attr_type value at line " << parser_.line_number();
+}
+
+// Validate the parser attribute quoted state against the provided
+// boolean.
+void HtmlparserCppTest::ValidateAttributeQuoted(
+ const string &expected_attr_quoted) {
+ bool attr_quoted_bool = StringToBool(expected_attr_quoted);
+ EXPECT_EQ(attr_quoted_bool, parser_.IsAttributeQuoted())
+ << "Unexpected attr_quoted value at line " << parser_.line_number();
+}
+
+// Validates the parser in javascript state against the provided boolean.
+void HtmlparserCppTest::ValidateInJavascript(const string &expected_in_js) {
+ bool in_js_bool = StringToBool(expected_in_js);
+ EXPECT_EQ(in_js_bool, parser_.InJavascript())
+ << "Unexpected in_js value at line " << parser_.line_number();
+}
+
+// Validate the current parser javascript quoted state against the provided
+// boolean.
+void HtmlparserCppTest::ValidateJavascriptQuoted(
+ const string &expected_js_quoted) {
+ bool js_quoted_bool = StringToBool(expected_js_quoted);
+ EXPECT_EQ(js_quoted_bool, parser_.IsJavascriptQuoted())
+ << "Unexpected js_quoted value at line " << parser_.line_number();
+}
+
+// Validate the javascript parser state against the provided state.
+void HtmlparserCppTest::ValidateJavascriptState(const string &expected_state) {
+ const char* parsed_state = IdToName(kJavascriptStateMap,
+ parser_.javascript_state());
+ EXPECT_TRUE(parsed_state != NULL);
+ EXPECT_TRUE(!expected_state.empty());
+ EXPECT_EQ(expected_state, string(parsed_state))
+ << "Unexpected javascript state at line " << parser_.line_number();
+}
+
+// Validates the parser css state against the provided boolean.
+void HtmlparserCppTest::ValidateInCss(const string &expected_in_css) {
+ bool in_css_bool = StringToBool(expected_in_css);
+ EXPECT_EQ(in_css_bool, parser_.InCss())
+ << "Unexpected in_css value at line " << parser_.line_number();
+}
+
+// Validate the line count against the expected count.
+void HtmlparserCppTest::ValidateLine(const string &expected_line) {
+ int line;
+ CHECK(safe_strto32(expected_line, &line));
+ EXPECT_EQ(line, parser_.line_number())
+ << "Unexpected line count at line " << parser_.line_number();
+}
+
+// Validate the line count against the expected count.
+void HtmlparserCppTest::ValidateColumn(const string &expected_column) {
+ int column;
+ CHECK(safe_strto32(expected_column, &column));
+ EXPECT_EQ(column, parser_.column_number())
+ << "Unexpected column count at line " << parser_.line_number();
+}
+
+// Validate the current parser value index against the provided index.
+void HtmlparserCppTest::ValidateValueIndex(const string &expected_value_index) {
+ int index;
+ CHECK(safe_strto32(expected_value_index, &index));
+ EXPECT_EQ(index, parser_.ValueIndex())
+ << "Unexpected value_index value at line " << parser_.line_number();
+}
+
+// Validate the parser is_url_start value against the provided one.
+void HtmlparserCppTest::ValidateIsUrlStart(
+ const string &expected_is_url_start) {
+ bool is_url_start_bool = StringToBool(expected_is_url_start);
+ EXPECT_EQ(is_url_start_bool, parser_.IsUrlStart())
+ << "Unexpected is_url_start value at line " << parser_.line_number();
+}
+
+// Validate an annotation string against the current parser state.
+//
+// Split the annotation into a list of key value pairs and call the appropriate
+// handler for each pair.
+void HtmlparserCppTest::ProcessAnnotation(const string &annotation) {
+ vector< pair< string, string > > pairs;
+ SplitStringIntoKeyValuePairs(annotation, "=", ",", &pairs);
+
+ vector< pair< string, string > >::iterator iter;
+
+ iter = pairs.begin();
+ for (iter = pairs.begin(); iter != pairs.end(); ++iter) {
+ StripWhiteSpace(&iter->first);
+ StripWhiteSpace(&iter->second);
+
+ if (iter->first.compare("state") == 0) {
+ ValidateState(iter->second);
+ } else if (iter->first.compare("tag") == 0) {
+ ValidateTag(iter->second);
+ } else if (iter->first.compare("attr") == 0) {
+ ValidateAttribute(iter->second);
+ } else if (iter->first.compare("value") == 0) {
+ ValidateValue(iter->second);
+ } else if (iter->first.compare("attr_type") == 0) {
+ ValidateAttributeType(iter->second);
+ } else if (iter->first.compare("attr_quoted") == 0) {
+ ValidateAttributeQuoted(iter->second);
+ } else if (iter->first.compare("in_js") == 0) {
+ ValidateInJavascript(iter->second);
+ } else if (iter->first.compare("js_quoted") == 0) {
+ ValidateJavascriptQuoted(iter->second);
+ } else if (iter->first.compare("js_state") == 0) {
+ ValidateJavascriptState(iter->second);
+ } else if (iter->first.compare("in_css") == 0) {
+ ValidateInCss(iter->second);
+ } else if (iter->first.compare("line_number") == 0) {
+ ValidateLine(iter->second);
+ } else if (iter->first.compare("column_number") == 0) {
+ ValidateColumn(iter->second);
+ } else if (iter->first.compare("value_index") == 0) {
+ ValidateValueIndex(iter->second);
+ } else if (iter->first.compare("is_url_start") == 0) {
+ ValidateIsUrlStart(iter->second);
+ } else if (iter->first.compare("save_context") == 0) {
+ if (!contextMap.count(iter->second)) {
+ contextMap[iter->second] = new HtmlParser();
+ }
+ contextMap[iter->second]->CopyFrom(&parser_);
+ } else if (iter->first.compare("load_context") == 0) {
+ CHECK(contextMap.count(iter->second));
+ parser_.CopyFrom(contextMap[iter->second]);
+ } else if (iter->first.compare("reset") == 0) {
+ if (StringToBool(iter->second)) {
+ parser_.Reset();
+ }
+ } else if (iter->first.compare("reset_mode") == 0) {
+ HtmlParser::Mode mode =
+ static_cast<HtmlParser::Mode>(NameToId(kResetModeMap, iter->second));
+ parser_.ResetMode(mode);
+ } else if (iter->first.compare("insert_text") == 0) {
+ if (StringToBool(iter->second)) {
+ parser_.InsertText();
+ }
+ } else {
+ FAIL() << "Unknown test directive: " << iter->first;
+ }
+ }
+}
+
+// Validates an html annotated file against the parser state.
+//
+// It iterates over the html file splitting it into html blocks and annotation
+// blocks. It sends the html block to the parser and uses the annotation block
+// to validate the parser state.
+void HtmlparserCppTest::ValidateFile(string filename) {
+ // If TEMPLATE_ROOTDIR is set in the environment, it overrides the
+ // default of ".". We use an env-var rather than argv because
+ // that's what automake supports most easily.
+ const char* template_rootdir = getenv("TEMPLATE_ROOTDIR");
+ if (template_rootdir == NULL)
+ template_rootdir = DEFAULT_TEMPLATE_ROOTDIR; // probably "."
+ string dir = PathJoin(template_rootdir, "src");
+ dir = PathJoin(dir, "tests");
+ dir = PathJoin(dir, "htmlparser_testdata");
+ const string fullpath = PathJoin(dir, filename);
+ fprintf(stderr, "Validating %s", fullpath.c_str());
+ string buffer;
+ ReadToString(fullpath.c_str(), &buffer);
+
+ // Start of the current html block.
+ size_t start_html = 0;
+
+ // Start of the next annotation.
+ size_t start_annotation = buffer.find(kDirectiveBegin, 0);
+
+ // Ending of the current annotation.
+ size_t end_annotation = buffer.find(kDirectiveEnd, start_annotation);
+
+ while (start_annotation != string::npos) {
+ string html_block(buffer, start_html, start_annotation - start_html);
+ parser_.Parse(html_block);
+
+ start_annotation += strlen(kDirectiveBegin);
+
+ string annotation_block(buffer, start_annotation,
+ end_annotation - start_annotation);
+ ProcessAnnotation(annotation_block);
+
+ // Update line and column count.
+ parser_.set_line_number(UpdateLines(annotation_block,
+ parser_.line_number()));
+ parser_.set_column_number(UpdateColumns(annotation_block,
+ parser_.column_number()));
+
+ start_html = end_annotation + strlen(kDirectiveEnd);
+ start_annotation = buffer.find(kDirectiveBegin, start_html);
+ end_annotation = buffer.find(kDirectiveEnd, start_annotation);
+
+ // Check for unclosed annotation.
+ CHECK(!(start_annotation != string::npos &&
+ end_annotation == string::npos));
+ }
+}
+
+static vector<string> g_filenames;
+#define TEST_FILE(testname, filename) \
+ struct Register_##testname { \
+ Register_##testname() { g_filenames.push_back(filename); } \
+ }; \
+ static Register_##testname g_register_##testname
+
+TEST(HtmlparserTest, TestFiles) {
+ HtmlparserCppTest tester;
+ for (vector<string>::const_iterator it = g_filenames.begin();
+ it != g_filenames.end(); ++it) {
+ tester.SetUp();
+ tester.ValidateFile(*it);
+ tester.TearDown();
+ }
+}
+
+TEST_FILE(SimpleHtml, "simple.html");
+TEST_FILE(Comments, "comments.html");
+TEST_FILE(JavascriptBlock, "javascript_block.html");
+TEST_FILE(JavascriptAttribute, "javascript_attribute.html");
+TEST_FILE(JavascriptRegExp, "javascript_regexp.html");
+TEST_FILE(Tags, "tags.html");
+TEST_FILE(Context, "context.html");
+TEST_FILE(Reset, "reset.html");
+TEST_FILE(CData, "cdata.html");
+TEST_FILE(LineCount, "position.html");
+
+TEST(Htmlparser, Error) {
+ HtmlParser html;
+
+ EXPECT_EQ(html.GetErrorMessage(), (const char *)NULL);
+ EXPECT_EQ(html.Parse("<a href='http://www.google.com' ''>\n"),
+ HtmlParser::STATE_ERROR);
+
+ EXPECT_STREQ(html.GetErrorMessage(),
+ "Unexpected character '\\'' in state 'tag_space'");
+ html.Reset();
+ EXPECT_EQ(html.GetErrorMessage(), (const char *)NULL);
+}
+
+} // namespace security_streamhtmlparser
+
+int main(int argc, char **argv) {
+
+ return RUN_ALL_TESTS();
+}
diff --git a/src/tests/htmlparser_testdata/cdata.html b/src/tests/htmlparser_testdata/cdata.html
new file mode 100644
index 0000000..817938b
--- /dev/null
+++ b/src/tests/htmlparser_testdata/cdata.html
@@ -0,0 +1,112 @@
+<html>
+<?state state=text, tag=html ?>
+
+ <head>
+ <?state state=text, tag=head ?>
+ <!-- Title element with markup -->
+ <title>
+ <?state state=text, tag=title ?>
+ <h1>
+ <?state state=text, tag=title ?>
+ </h1>
+ <!--
+ <?state state=text, tag=title ?>
+ </title>
+ <?state state=text, tag=title ?>
+ -->
+ <?state state=text, tag=title ?>
+ </title>
+ <?state state=text ?>
+
+ <!-- Style element with attributes -->
+ <style a=b>
+ <b><?state state=text, tag=style, in_js=false, in_css=true?></b>
+ </style>
+ <?state in_css=false?>
+ </head>
+<body>
+<?state state=text, in_js=false ?>
+ <!-- PCDATA nested block -->
+ <b>
+ <?state state=text, tag=b ?>
+ <i>
+ <?state state=text, tag=i ?>
+ </i>
+ <?state state=text ?>
+ </b>
+ <?state state=text ?>
+
+ <!-- Textarea element with space at the end of the closing tag -->
+ <textarea>
+ <?state state=text, tag=textarea ?>
+ <b>
+ <?state state=text, tag=textarea ?>
+ <i>
+ <?state state=text, tag=textarea, in_css=false ?>
+ <!--
+ <?state state=text, tag=textarea ?>
+ </textarea>
+ <?state state=text, tag=textarea ?>
+ -->
+ </i>
+ <?state state=text, tag=textarea ?>
+ </b>
+ <?state state=text, tag=textarea ?>
+ </textarea >
+
+<?state state=text ?>
+
+ <!-- script tag with other tags inside -->
+ <script>
+ document.write("
+ <?state in_js=true, js_quoted=true, tag=script ?>
+ <style>
+ .none { display:none }
+ </style>
+ <?state in_js=true, js_quoted=true ?>
+ ");
+ <?state in_js=true, js_quoted=false ?>
+ </script>
+
+ <?state in_js=false ?>
+
+ <!-- script tag with a backslash quoted script tag -->
+ <script>
+ <?state in_js=true, js_quoted=false ?>
+ document.body.innerHTML = '<script><\/script>'
+ <?state in_js=true, js_quoted=false ?>
+ </script>
+
+ <?state in_js=false ?>
+
+ <!-- </script> appearing between javascript comments -->
+ <script>
+ <!--
+ <?state in_js=true, js_quoted=false ?>
+ document.body.innerHTML = '<script></script>'
+ <?state in_js=true, js_quoted=false ?>
+ -->
+ </script>
+
+ <?state in_js=false ?>
+
+ <!-- Closing script with an extra space at the end of the tag. Some browsers
+ ignore this tag and some browsers honour it. We honour it. -->
+ <script>
+ <?state in_js=true, js_quoted=false ?>
+ document.body.innerHTML = '<script><\/script>'
+ <?state in_js=true, js_quoted=false ?>
+ </script >
+
+ <script>
+ <?state in_js=true, js_quoted=false ?>
+ </script%>
+ <?state in_js=true, js_quoted=false ?>
+ </script >
+
+ <?state in_js=false ?>
+
+</body>
+<?state in_js=false ?>
+</html>
+
diff --git a/src/tests/htmlparser_testdata/comments.html b/src/tests/htmlparser_testdata/comments.html
new file mode 100644
index 0000000..391f3f0
--- /dev/null
+++ b/src/tests/htmlparser_testdata/comments.html
@@ -0,0 +1,61 @@
+<!-- Tests for HTML comments and cdata escaping text spans. -->
+<html>
+
+<body>
+
+<?state state=text, tag=body ?>
+
+<!-- HTML doctype declaration -->
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
+<?state state=text, tag=body?>
+"http://www.w3.org/TR/html4/strict.dtd">
+<?state state=text, tag=body ?>
+
+<!-- Regular HTML comment -->
+<!-- <?state state=comment, tag=body ?> -->
+<?state state=text, tag=body ?>
+
+<!-- HTML comment with tags -->
+<!-- > -> </b> <a href="<?state state=comment, tag=body ?>"></a>-->
+<?state state=text, tag=body ?>
+
+<!-- Should not be interpreted as an SGML comment -->
+<?state state=text, tag=body ?>
+<!-- -- -->
+<?state state=text, tag=body ?>
+
+<!-- -- Sync back the SGML comment for editors who parse SGML comments
+(ie: vim) -->
+<?state state=text, tag=body ?>
+
+<!-- Multiple dashes at the end. -->
+<!----- <?state state=comment, tag=body ?> --><?state state=text, tag=body ?>
+<!----- <?state state=comment, tag=body ?> ---><?state state=text, tag=body ?>
+<!----- <?state state=comment, tag=body ?> ----><?state state=text, tag=body ?>
+<!----- <?state state=comment, tag=body ?> -----><?state state=text, tag=body ?>
+
+<!-- Some more misc tests -->
+<!-- test <?state state=comment?> --><?state state=text?> test test --><?state state=text?>
+<!-- test -> test test --><?state state=text?>
+<!-- test test='--><?state state=text?>'
+<!----><?state state=text?>
+<!-----><?state state=text?>
+
+<!-- Make sure the double dash sequence is not interpreted as an SGML comment
+by introducing a legit postfix decrement operator -->
+<?state state=text, in_js=false ?>
+<script>
+<!--
+<?state state=text, in_js=true ?>
+
+var x = 1;
+x--;
+<?state state=text, in_js=true ?>
+-->
+</script>
+<?state state=text, in_js=false ?>
+
+</body>
+
+</html>
+<?state state=text ?>
diff --git a/src/tests/htmlparser_testdata/context.html b/src/tests/htmlparser_testdata/context.html
new file mode 100644
index 0000000..aaaaa46
--- /dev/null
+++ b/src/tests/htmlparser_testdata/context.html
@@ -0,0 +1,79 @@
+<!-- Tests for CopyFrom() -->
+<html>
+ <body>
+ <?state save_context=body?>
+ <?state tag=body?>
+ <h1>
+ <?state save_context=h1?>
+ <?state tag=h1?>
+ <?state load_context=body?>
+ <?state tag=body?>
+
+ <a href="http://www.google.com<?state save_context=href?>"></a>
+
+ <script>
+ <?state save_context=js?>
+ var x ='<?state save_context=js_str_literal?>
+ <?state load_context=href?><?state state=value,
+ tag=a,
+ attr=href,
+ in_js=false,
+ value=http://www.google.com?>
+ <?state load_context=js_str_literal?>
+ <?state state=text,
+ tag=script,
+ in_js=true,
+ js_quoted=true?>';
+
+ // Regexp handling
+ var expression = 10 / <?state save_context=js_expression?> / <?state save_context=js_regexp?> /;
+
+ <?state load_context=js_expression?><?state js_state=text?>
+ <?state load_context=js_regexp?><?state js_state=regexp?> /;
+ <?state js_state=text?>
+
+ </script>
+ <?state in_js=false?>
+ <?state load_context=js?>
+ <?state tag=script, js_state=text, in_js=true?>
+ </script>
+
+ <!-- html encoded script attribute -->
+ <a onclick="alert('<?state save_context=onclick_str_literal?>'"></a>
+ <?state in_js=false?>
+ <?state load_context=onclick_str_literal?><?state state=value,
+ tag=a,
+ attr=onclick,
+ attr_type=js,
+ in_js=true,
+ js_quoted=true?>'">
+ <?state state=text, tag=a?>
+ </a>
+
+<!-- ResetMode() tests -->
+
+<?state reset_mode=css?>
+<?state in_css=true?>
+<?state state=css_file?>
+<?state save_context=mode_css?>
+
+<?state reset_mode=html?>
+<?state state=text?>
+<?state in_css=false?>
+<?state load_context=mode_css?>
+<?state in_css=true?>
+<?state state=css_file?>
+
+<?state reset_mode=html_in_tag?>blah=<?state save_context=in_tag?>
+<?state load_context=onclick_str_literal?><?state state=value,
+ tag=a,
+ attr=onclick,
+ attr_type=js,
+ in_js=true,
+ js_quoted=true?>'">
+<?state load_context=in_tag?>
+<?state attr=blah?>xpto<?state value=xpto?>
+
+
+ </body>
+</html>
diff --git a/src/tests/htmlparser_testdata/google.html b/src/tests/htmlparser_testdata/google.html
new file mode 100644
index 0000000..45dddd8
--- /dev/null
+++ b/src/tests/htmlparser_testdata/google.html
@@ -0,0 +1,3 @@
+<html><head><meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"><title>Google</title><style>body,td,a,p,.h{font-family:arial,sans-serif}.h{font-size:20px}.h{color:#3366cc}.q{color:#00c}.ts td{padding:0}.ts{border-collapse:collapse}#gbar{height:22px;padding-left:2px}.gbh,.gbd{border-top:1px solid #c9d7f1;font-size:1px}.gbh{height:0;position:absolute;top:24px;width:100%}#gbi,#gbs{background:#fff;left:0;position:absolute;top:24px;visibility:hidden;z-index:1000}#gbi{border:1px solid;border-color:#c9d7f1 #36c #36c #a2bae7;z-index:1001}#guser{padding-bottom:7px !important}#gbar,#guser{font-size:13px;padding-top:1px !important}@media all{.gb1,.gb3{height:22px;margin-right:.73em;vertical-align:top}#gbar{float:left}}.gb2{display:block;padding:.2em .5em}a.gb1,a.gb2,a.gb3{color:#00c !important}.gb2,.gb3{text-decoration:none}a.gb2:hover{background:#36c;color:#fff !important}</style><script>window.google={kEI:"jigHScf6BKDwswP7-eSsAw",kEXPI:"17259,19016",kHL:"en"};
+function sf(){document.f.q.focus()}
+window.gbar={};(function(){var b=window.gbar,f,h;b.qs=function(a){var c=window.encodeURIComponent&&(document.forms[0].q||"").value;if(c)a.href=a.href.replace(/([?&])q=[^&]*|$/,function(i,g){return(g||"&")+"q="+encodeURIComponent(c)})};function j(a,c){a.visibility=h?"hidden":"visible";a.left=c+"px"}b.tg=function(a){a=a||window.event;var c=0,i,g=window.navExtra,d=document.getElementById("gbi"),e=a.target||a.srcElement;a.cancelBubble=true;if(!f){f=document.createElement(Array.every||window.createPopup?"iframe":"div");f.frameBorder="0";f.src="#";d.parentNode.appendChild(f).id="gbs";if(g)for(i in g)d.insertBefore(g[i],d.firstChild).className="gb2";document.onclick=b.close}if(e.className!="gb3")e=e.parentNode;do c+=e.offsetLeft;while(e=e.offsetParent);j(d.style,c);f.style.width=d.offsetWidth+"px";f.style.height=d.offsetHeight+"px";j(f.style,c);h=!h};b.close=function(a){h&&b.tg(a)}})();</script></head><body bgcolor=#ffffff text=#000000 link=#0000cc vlink=#551a8b alink=#ff0000 onload="sf();if(document.images){new Image().src='/images/nav_logo3.png'}" topmargin=3 marginheight=3><div id=gbar><nobr><b class=gb1>Web</b> <a href="http://images.google.com/imghp?hl=en&tab=wi" onclick=gbar.qs(this) class=gb1>Images</a> <a href="http://maps.google.com/maps?hl=en&tab=wl" onclick=gbar.qs(this) class=gb1>Maps</a> <a href="http://news.google.com/nwshp?hl=en&tab=wn" onclick=gbar.qs(this) class=gb1>News</a> <a href="http://www.google.com/prdhp?hl=en&tab=wf" onclick=gbar.qs(this) class=gb1>Shopping</a> <a href="http://mail.google.com/mail/?hl=en&tab=wm" class=gb1>Gmail</a> <a href="http://www.google.com/intl/en/options/" onclick="this.blur();gbar.tg(event);return !1" class=gb3><u>more</u> <small>▼</small></a><div id=gbi> <a href="http://video.google.com/?hl=en&tab=wv" onclick=gbar.qs(this) class=gb2>Video</a> <a href="http://groups.google.com/grphp?hl=en&tab=wg" onclick=gbar.qs(this) class=gb2>Groups</a> <a href="http://books.google.com/bkshp?hl=en&tab=wp" onclick=gbar.qs(this) class=gb2>Books</a> <a href="http://scholar.google.com/schhp?hl=en&tab=ws" onclick=gbar.qs(this) class=gb2>Scholar</a> <a href="http://finance.google.com/finance?hl=en&tab=we" onclick=gbar.qs(this) class=gb2>Finance</a> <a href="http://blogsearch.google.com/?hl=en&tab=wb" onclick=gbar.qs(this) class=gb2>Blogs</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.youtube.com/?hl=en&tab=w1" onclick=gbar.qs(this) class=gb2>YouTube</a> <a href="http://www.google.com/calendar/render?hl=en&tab=wc" class=gb2>Calendar</a> <a href="http://picasaweb.google.com/home?hl=en&tab=wq" onclick=gbar.qs(this) class=gb2>Photos</a> <a href="http://docs.google.com/?hl=en&tab=wo" class=gb2>Documents</a> <a href="http://www.google.com/reader/view/?hl=en&tab=wy" class=gb2>Reader</a> <a href="http://sites.google.com/?hl=en&tab=w3" class=gb2>Sites</a> <div class=gb2><div class=gbd></div></div> <a href="http://www.google.com/intl/en/options/" class=gb2>even more »</a></div> </nobr></div><div class=gbh style=left:0></div><div class=gbh style=right:0></div><div align=right id=guser style="font-size:84%;padding:0 0 4px" width=100%><nobr><a href="/url?sa=p&pref=ig&pval=3&q=http://www.google.com/ig%3Fhl%3Den%26source%3Diglk&usg=AFQjCNFA18XPfgb7dKnXfKz7x7g1GDH1tg">iGoogle</a> | <a href="https://www.google.com/accounts/Login?continue=http://www.google.com/&hl=en">Sign in</a></nobr></div><center><br clear=all id=lgpd><img alt="Google" height=110 src="/intl/en_ALL/images/logo.gif" width=276><br><br><form action="/search" name=f><table cellpadding=0 cellspacing=0><tr valign=top><td width=25%> </td><td align=center nowrap><input name=hl type=hidden value=en><input type=hidden name=ie value="ISO-8859-1"><input autocomplete="off" maxlength=2048 name=q size=55 title="Google Search" value=""><br><input name=btnG type=submit value="Google Search"><input name=btnI type=submit value="I'm Feeling Lucky"></td><td nowrap width=25%><font size=-2> <a href=/advanced_search?hl=en>Advanced Search</a><br> <a href=/preferences?hl=en>Preferences</a><br> <a href=/language_tools?hl=en>Language Tools</a></font></td></tr></table></form><br><font size=-1><font color=red>New!</font> The G1 phone is on sale now. <a href="/aclk?sa=L&ai=BuJQcgigHSbvbCqDUsAPGm6X7DvPUz3en34zVCcHZnNkT0IYDEAEYASDBVDgAUJL0-Mb8_____wFgyQY&num=1&sig=AGiWqtxZNijZyCsNtIwkfSx_S1WSW0Uh8A&q=http://www.google.com/intl/en_us/mobile/android/hpp.html">Learn more</a>.</font><br><br><br><font size=-1><a href="/intl/en/ads/">Advertising Programs</a> - <a href="/services/">Business Solutions</a> - <a href="/intl/en/about.html">About Google</a></font><p><font size=-2>©2008 - <a href="/intl/en/privacy.html">Privacy</a></font></p></center></body><script>google.y={first:[]};window.setTimeout(function(){var xjs=document.createElement('script');xjs.src='/extern_js/f/CgJlbhICdXMgACswCjgILCswGDgDLA/Vh5nhw3Xn6A.js';document.getElementsByTagName('head')[0].appendChild(xjs)},0);google.y.first.push(function(){google.ac.i(document.f,document.f.q,'','')})</script></html>
\ No newline at end of file
diff --git a/src/tests/htmlparser_testdata/javascript_attribute.html b/src/tests/htmlparser_testdata/javascript_attribute.html
new file mode 100644
index 0000000..db096f0
--- /dev/null
+++ b/src/tests/htmlparser_testdata/javascript_attribute.html
@@ -0,0 +1,27 @@
+<html>
+<body>
+
+<a onclick="alert('<?state state=value, tag=a, attr=onclick, attr_type=js,
+in_js=true, js_quoted=true?> x') &; &a; &x;/*blah <?state state=value,
+tag=a, attr=onclick, attr_type=js, in_js=true ?> */ "></a>
+
+<?state state=text, in_js=false ?>
+
+<a onmouseover='alert(document.domain<?state state=value, tag=a,
+attr=onmouseover, attr_type=js, in_js=true ?>)'>test</a>
+
+<?state state=text, in_js=false ?>
+
+<a onmouseover="">test</a>
+
+<?state state=text, in_js=false ?>
+
+<a onclick="<?state in_js=true, js_quoted=false?>">test</a>
+<?state state=text, in_js=false ?>
+
+<a onclick="'<?state in_js=true, js_quoted=true?>">test</a>
+<?state state=text, in_js=false ?>
+
+</body>
+</html>
+<?state state=text ?><?state state=text ?>
diff --git a/src/tests/htmlparser_testdata/javascript_block.html b/src/tests/htmlparser_testdata/javascript_block.html
new file mode 100644
index 0000000..539c1a6
--- /dev/null
+++ b/src/tests/htmlparser_testdata/javascript_block.html
@@ -0,0 +1,50 @@
+<html>
+<body>
+
+<script>
+
+x < 1;
+
+<?state state=text, tag=script, in_js=true ?>
+
+</script>
+
+<?state state=text?>
+
+<script>
+//<!--
+var x = 1;
+<?state state=text, tag=script, in_js=true ?>
+//--> </script>
+
+<?state state=text?>
+
+<script> //<!--
+var x = 1;
+<?state state=text, tag=script, in_js=true ?>
+</script>
+<?state state=text, tag=script, in_js=true ?>
+//--> </script>
+
+<?state state=text?>
+
+<script>
+<!--
+var x = 1;
+<?state state=text, tag=script, in_js=true ?>
+</script>
+<?state state=text, tag=script, in_js=true ?>
+-->
+</script>
+
+<?state state=text?>
+
+<script><?state tag=script, in_js=true?> </script><?state in_js=false?>
+<script><?state tag=script, in_js=true, js_quoted=false?></script><?state in_js=false?>
+<script>'<?state tag=script, in_js=true, js_quoted=true?></script><?state in_js=false?>
+<script>"<?state tag=script, in_js=true, js_quoted=true?></script><?state in_js=false?>
+
+</body>
+</html>
+<?state state=text ?>
+<?state state=text ?>
diff --git a/src/tests/htmlparser_testdata/javascript_regexp.html b/src/tests/htmlparser_testdata/javascript_regexp.html
new file mode 100644
index 0000000..7c1f88d
--- /dev/null
+++ b/src/tests/htmlparser_testdata/javascript_regexp.html
@@ -0,0 +1,171 @@
+<html>
+<body>
+
+
+<script>
+
+// General regular expression literal synching tests.
+
+var regexp = /x'/;
+<?state state=text, in_js=true, js_quoted=false?>
+
+var string = '<?state state=text, in_js=true, js_quoted=true?>';
+<?state state=text, in_js=true, js_quoted=false?>
+
+var op = 1 / 2;
+var string2 = '<?state state=text, in_js=true, js_quoted=true?>';
+<?state state=text, in_js=true, js_quoted=false?>
+
+return /x'/;
+<?state state=text, in_js=true, js_quoted=false?>
+
+
+// General regular expression state tests
+
+var regexp = / <?state js_state=regexp?> /; <?state js_state=text?>
+
+var a = /"hello/.exec("<?state state=text, in_js=true, js_quoted=true ?>");
+var a = /"hello"/.exec("<?state state=text, in_js=true, js_quoted=true ?>");
+
+var expression = 10 / <?state js_state=text?> / <?state js_state=regexp?> /;
+
+<?state js_state=text?>
+
+var expression2 = / <?state js_state=regexp?> /;
+
+if (window.frames.length < /\d+<?state js_state=regexp?>/.exec(<?state js_state=text?>)[0]) {
+ alert(/ '" <?state js_state=regexp?>/.exec(<?state js_state=text?>)/);
+ var quoted_string = "<?state js_state=dq?>" <?state js_state=text?>;
+}
+
+switch(/ <?state js_state=regexp?> /) { <?state js_state=text?>
+ case / <?state js_state=regexp?> /: <?state js_state=text?>
+ break;
+ case / \/<?state js_state=regexp?> /: <?state js_state=text?>
+ break;
+}
+
+delete / <?state js_state=regexp?> x / <?state js_state=text?>;
+id / <?state js_state=text?> x / <?state js_state=text?>;
+
+function test(/ <?state js_state=regexp?> /) {
+ return / <?state js_state=regexp?> /.exec(<?state js_state=text?>);
+}
+
+function test2(/ <?state js_state=regexp?> /, <?state js_state=text?>) {
+ return / '"<?state js_state=regexp?> /.exec(<?state js_state=text?>);
+}
+
+var a = "/<?state js_state=dq?>"/<?state js_state=text?>;
+
+test in / <?state js_state=regexp?>/;
+min / <?state js_state=text?>;
+IN / <?state js_state=text?>;
+
+3.. /<?state js_state=text?>/;
+0x3./<?state js_state=text?>/;
+
+// Escaping in regular expressions
+
+var a = / blah\/<?state js_state=regexp?>/<?state js_state=text?>,
+/\//<?state js_state=text?>,
+/\/*/<?state js_state=text?> /**/ <?state js_state=text?>,
+
+// Bracket expressions
+var a = [/[/] <?state js_state=regexp?> / <?state js_state=text?>,
+var a = /[/\]/ <?state js_state=regexp?> ]/ <?state js_state=text?>,
+var a = /[/\\]/ <?state js_state=text?>];
+
+/* Unary incremented/decremented variable, followed by a division. */
+
+var w = w++ / 1 <?state js_state=text?>;
+var w = w-- / 1 <?state js_state=text?>;
+
+/* Division after array acessor. */
+var test = xpto[2] / <?state js_state=text?>;
+
+/* Division after parenthesis expression. */
+var test = (2 + 2) / <?state js_state=text?>;
+
+/* Division with comments before the the previous token. */
+var test = x/* test *// <?state js_state=text?>;
+var test = x /* test *// <?state js_state=text?>;
+var test = x/* test */ / <?state js_state=text?>;
+var test = x /* test */ / <?state js_state=text?>;
+var test = x /* test */
+/ <?state js_state=text?>;
+
+var test = x // test
+/ <?state js_state=text?>;
+
+var test = x // test
+ / <?state js_state=text?>;
+
+var test = x // test
+
+/ <?state js_state=text?>;
+
+/* Regexp with multi line comment before the the previous token. */
+var test =/* test *// <?state js_state=regexp?> /;
+var test = /* test *// <?state js_state=regexp?> /;
+var test = /* test *// <?state js_state=regexp?> /;
+var test = /* test */ / <?state js_state=regexp?> /;
+var test = /* test */
+/ <?state js_state=regexp?> /;
+
+var test = // test
+/ <?state js_state=regexp?> /;
+
+var test = // test
+ / <?state js_state=regexp?> /;
+
+var test = // test
+
+/ <?state js_state=regexp?> /;
+
+
+/* Semicolon insertion after a code block */
+function() {} / <?state js_state=regexp?>/
+
+/****************************************************************************
+ Tests that won't pass right now due to design or implementation choices.
+*/
+
+/* Division after a regular expression.
+
+var test = <?nopstate js_state=text?>
+/ <?nopstate js_state=regexp?>
+/ <?nopstate js_state=text?>
+/ <?nopstate js_state=text?>
+/ <?nopstate js_state=regexp?>
+/ <?nopstate js_state=text?>;
+
+*/
+
+/* Division of an object literal
+
+{
+ a: 1,
+ b : 2
+} / <?nopstate js_state=text?>/
+
+*/
+
+/* Unary increment and decrement of regular expressions.
+
+var w = ++/ <?nopstate js_state=regexp?>/i;
+var x = --/ <?nopstate js_state=regexp?>/i
+
+*/
+
+
+</script>
+
+<script>
+
+/ <?state js_state=regexp?> /;
+
+</script>
+
+</body>
+</html>
diff --git a/src/tests/htmlparser_testdata/position.html b/src/tests/htmlparser_testdata/position.html
new file mode 100644
index 0000000..120ca4e
--- /dev/null
+++ b/src/tests/htmlparser_testdata/position.html
@@ -0,0 +1,33 @@
+<?state line_number=1?>
+<?state line_number=2?>
+<html>
+<?state column_number=1?>
+ <body><?state column_number=9?>
+ <?state line_number=6?><?state column_number=28?>
+ <?state
+
+ line_number=7
+ ?><?state column_number=7?>
+ <?state line_number=11?><?state column_number=29?>
+ </body>
+ <?state line_number=13?>
+
+
+
+<?state column_number=1?>
+ <?state column_number=2?>
+ <?state column_number=3?>
+
+
+
+
+
+<a href="http://ww.google.com" onclick="var x=<?state column_number=47?>">
+</a>
+
+<img src="http://www.google.com" onerror="var w = &qu<?state column_number=54?>ot;test"">
+
+
+
+ <?state line_number=32?>
+</html>
diff --git a/src/tests/htmlparser_testdata/reset.html b/src/tests/htmlparser_testdata/reset.html
new file mode 100644
index 0000000..cd0d070
--- /dev/null
+++ b/src/tests/htmlparser_testdata/reset.html
@@ -0,0 +1,31 @@
+<html>
+ <body>
+ <?state state=text, attr_type=none?>
+ <b font="<?state state=value, tag=b, attr=font, attr_quoted=true,
+ in_js=false, attr_type=regular ?>
+<?state reset=true ?>
+<?state state=text, attr_type=none ?>
+<b <?state state=tag, tag=b ?>
+<?state reset_mode=js ?>
+<?state state=js_file?>
+var unquoted =<?state js_quoted=false, in_js=true ?>;
+var single_quoted ='<?state js_quoted=true, in_js=true ?>';
+var unquoted =<?state js_quoted=false, in_js=true ?>;
+<?state reset_mode=html_in_tag?>blah=<?state attr=blah?>xpto<?state value=xpto?>
+test<?state state=attr?>
+<?state reset_mode=html_in_tag?>
+test="test123<?state attr=test, value=test123?>">
+<?state state=text?>
+<?state reset_mode=css?>
+<?state in_css=true?>
+<?state state=css_file?>
+
+<a href="<?state in_css=true?>"></style><?state in_css=true?>
+
+<123 <script><?state in_css=true?>
+
+<?state reset_mode=html?>
+<?state in_css=false?>
+ <?state state=text, attr_type=none?>
+ <b font="<?state state=value, tag=b, attr=font, attr_quoted=true,
+ in_js=false, attr_type=regular ?>
diff --git a/src/tests/htmlparser_testdata/sample_fsm.c b/src/tests/htmlparser_testdata/sample_fsm.c
new file mode 100644
index 0000000..ed85c5f
--- /dev/null
+++ b/src/tests/htmlparser_testdata/sample_fsm.c
@@ -0,0 +1,802 @@
+/* Parses C style strings
+ * Auto generated by generate_fsm.py. Please do not edit.
+ */
+#define STRINGPARSER_NUM_STATES 4
+enum stringparser_state_internal_enum {
+ STRINGPARSER_STATE_INT_TEXT,
+ STRINGPARSER_STATE_INT_STRING,
+ STRINGPARSER_STATE_INT_STRING_ESCAPE
+};
+
+static const int stringparser_states_external[] = {
+ STRINGPARSER_STATE_TEXT,
+ STRINGPARSER_STATE_STRING,
+ STRINGPARSER_STATE_STRING
+};
+
+static const char * stringparser_states_internal_names[] = {
+ "text",
+ "string",
+ "string_escape"
+};
+
+static const int stringparser_transition_row_text[] = {
+ /* '\x00' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x01' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x02' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x03' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x04' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x05' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x06' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x07' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x08' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\t' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\n' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x0b' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x0c' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\r' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x0e' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x0f' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x10' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x11' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x12' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x13' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x14' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x15' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x16' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x17' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x18' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x19' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x1a' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x1b' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x1c' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x1d' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x1e' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x1f' */ STRINGPARSER_STATE_INT_TEXT,
+ /* ' ' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '!' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '"' */ STRINGPARSER_STATE_INT_STRING,
+ /* '#' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '$' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '%' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '&' */ STRINGPARSER_STATE_INT_TEXT,
+ /* "'" */ STRINGPARSER_STATE_INT_TEXT,
+ /* '(' */ STRINGPARSER_STATE_INT_TEXT,
+ /* ')' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '*' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '+' */ STRINGPARSER_STATE_INT_TEXT,
+ /* ',' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '-' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '.' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '/' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '0' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '1' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '2' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '3' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '4' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '5' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '6' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '7' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '8' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '9' */ STRINGPARSER_STATE_INT_TEXT,
+ /* ':' */ STRINGPARSER_STATE_INT_TEXT,
+ /* ';' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '<' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '=' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '>' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '?' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '@' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'A' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'B' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'C' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'D' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'E' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'F' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'G' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'H' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'I' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'J' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'K' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'L' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'M' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'N' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'O' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'P' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'Q' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'R' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'S' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'T' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'U' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'V' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'W' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'X' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'Y' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'Z' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '[' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\\' */ STRINGPARSER_STATE_INT_STRING,
+ /* ']' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '^' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '_' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '`' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'a' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'b' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'c' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'd' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'e' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'f' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'g' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'h' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'i' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'j' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'k' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'l' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'm' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'n' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'o' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'p' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'q' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'r' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 's' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 't' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'u' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'v' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'w' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'x' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'y' */ STRINGPARSER_STATE_INT_TEXT,
+ /* 'z' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '{' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '|' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '}' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '~' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x7f' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x80' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x81' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x82' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x83' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x84' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x85' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x86' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x87' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x88' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x89' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x8a' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x8b' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x8c' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x8d' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x8e' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x8f' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x90' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x91' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x92' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x93' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x94' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x95' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x96' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x97' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x98' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x99' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x9a' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x9b' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x9c' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x9d' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x9e' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\x9f' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa0' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa1' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa2' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa3' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa4' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa5' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa6' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa7' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa8' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xa9' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xaa' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xab' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xac' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xad' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xae' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xaf' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb0' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb1' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb2' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb3' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb4' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb5' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb6' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb7' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb8' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xb9' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xba' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xbb' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xbc' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xbd' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xbe' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xbf' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc0' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc1' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc2' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc3' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc4' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc5' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc6' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc7' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc8' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xc9' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xca' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xcb' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xcc' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xcd' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xce' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xcf' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd0' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd1' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd2' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd3' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd4' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd5' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd6' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd7' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd8' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xd9' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xda' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xdb' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xdc' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xdd' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xde' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xdf' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe0' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe1' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe2' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe3' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe4' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe5' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe6' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe7' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe8' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xe9' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xea' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xeb' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xec' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xed' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xee' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xef' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf0' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf1' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf2' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf3' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf4' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf5' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf6' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf7' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf8' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xf9' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xfa' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xfb' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xfc' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xfd' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '\xfe' */ STRINGPARSER_STATE_INT_TEXT
+};
+
+static const int stringparser_transition_row_string[] = {
+ /* '\x00' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x01' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x02' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x03' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x04' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x05' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x06' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x07' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x08' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\t' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\n' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\r' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x10' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x11' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x12' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x13' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x14' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x15' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x16' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x17' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x18' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x19' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1a' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1d' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1f' */ STRINGPARSER_STATE_INT_STRING,
+ /* ' ' */ STRINGPARSER_STATE_INT_STRING,
+ /* '!' */ STRINGPARSER_STATE_INT_STRING,
+ /* '"' */ STRINGPARSER_STATE_INT_TEXT,
+ /* '#' */ STRINGPARSER_STATE_INT_STRING,
+ /* '$' */ STRINGPARSER_STATE_INT_STRING,
+ /* '%' */ STRINGPARSER_STATE_INT_STRING,
+ /* '&' */ STRINGPARSER_STATE_INT_STRING,
+ /* "'" */ STRINGPARSER_STATE_INT_STRING,
+ /* '(' */ STRINGPARSER_STATE_INT_STRING,
+ /* ')' */ STRINGPARSER_STATE_INT_STRING,
+ /* '*' */ STRINGPARSER_STATE_INT_STRING,
+ /* '+' */ STRINGPARSER_STATE_INT_STRING,
+ /* ',' */ STRINGPARSER_STATE_INT_STRING,
+ /* '-' */ STRINGPARSER_STATE_INT_STRING,
+ /* '.' */ STRINGPARSER_STATE_INT_STRING,
+ /* '/' */ STRINGPARSER_STATE_INT_STRING,
+ /* '0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '9' */ STRINGPARSER_STATE_INT_STRING,
+ /* ':' */ STRINGPARSER_STATE_INT_STRING,
+ /* ';' */ STRINGPARSER_STATE_INT_STRING,
+ /* '<' */ STRINGPARSER_STATE_INT_STRING,
+ /* '=' */ STRINGPARSER_STATE_INT_STRING,
+ /* '>' */ STRINGPARSER_STATE_INT_STRING,
+ /* '?' */ STRINGPARSER_STATE_INT_STRING,
+ /* '@' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'A' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'B' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'C' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'D' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'E' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'F' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'G' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'H' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'I' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'J' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'K' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'L' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'M' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'N' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'O' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'P' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'Q' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'R' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'S' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'T' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'U' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'V' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'W' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'X' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'Y' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'Z' */ STRINGPARSER_STATE_INT_STRING,
+ /* '[' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\\' */ STRINGPARSER_STATE_INT_STRING_ESCAPE,
+ /* ']' */ STRINGPARSER_STATE_INT_STRING,
+ /* '^' */ STRINGPARSER_STATE_INT_STRING,
+ /* '_' */ STRINGPARSER_STATE_INT_STRING,
+ /* '`' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'a' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'b' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'c' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'd' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'e' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'f' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'g' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'h' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'i' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'j' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'k' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'l' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'm' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'n' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'o' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'p' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'q' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'r' */ STRINGPARSER_STATE_INT_STRING,
+ /* 's' */ STRINGPARSER_STATE_INT_STRING,
+ /* 't' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'u' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'v' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'w' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'x' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'y' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'z' */ STRINGPARSER_STATE_INT_STRING,
+ /* '{' */ STRINGPARSER_STATE_INT_STRING,
+ /* '|' */ STRINGPARSER_STATE_INT_STRING,
+ /* '}' */ STRINGPARSER_STATE_INT_STRING,
+ /* '~' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x7f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x80' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x81' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x82' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x83' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x84' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x85' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x86' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x87' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x88' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x89' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8a' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8d' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x90' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x91' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x92' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x93' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x94' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x95' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x96' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x97' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x98' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x99' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9a' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9d' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xaa' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xab' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xac' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xad' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xae' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xaf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xba' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbe' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xca' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xce' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xda' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xde' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xea' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xeb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xec' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xed' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xee' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xef' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfa' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfe' */ STRINGPARSER_STATE_INT_STRING
+};
+
+static const int stringparser_transition_row_string_escape[] = {
+ /* '\x00' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x01' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x02' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x03' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x04' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x05' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x06' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x07' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x08' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\t' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\n' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\r' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x0f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x10' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x11' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x12' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x13' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x14' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x15' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x16' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x17' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x18' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x19' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1a' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1d' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x1f' */ STRINGPARSER_STATE_INT_STRING,
+ /* ' ' */ STRINGPARSER_STATE_INT_STRING,
+ /* '!' */ STRINGPARSER_STATE_INT_STRING,
+ /* '"' */ STRINGPARSER_STATE_INT_STRING,
+ /* '#' */ STRINGPARSER_STATE_INT_STRING,
+ /* '$' */ STRINGPARSER_STATE_INT_STRING,
+ /* '%' */ STRINGPARSER_STATE_INT_STRING,
+ /* '&' */ STRINGPARSER_STATE_INT_STRING,
+ /* "'" */ STRINGPARSER_STATE_INT_STRING,
+ /* '(' */ STRINGPARSER_STATE_INT_STRING,
+ /* ')' */ STRINGPARSER_STATE_INT_STRING,
+ /* '*' */ STRINGPARSER_STATE_INT_STRING,
+ /* '+' */ STRINGPARSER_STATE_INT_STRING,
+ /* ',' */ STRINGPARSER_STATE_INT_STRING,
+ /* '-' */ STRINGPARSER_STATE_INT_STRING,
+ /* '.' */ STRINGPARSER_STATE_INT_STRING,
+ /* '/' */ STRINGPARSER_STATE_INT_STRING,
+ /* '0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '9' */ STRINGPARSER_STATE_INT_STRING,
+ /* ':' */ STRINGPARSER_STATE_INT_STRING,
+ /* ';' */ STRINGPARSER_STATE_INT_STRING,
+ /* '<' */ STRINGPARSER_STATE_INT_STRING,
+ /* '=' */ STRINGPARSER_STATE_INT_STRING,
+ /* '>' */ STRINGPARSER_STATE_INT_STRING,
+ /* '?' */ STRINGPARSER_STATE_INT_STRING,
+ /* '@' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'A' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'B' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'C' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'D' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'E' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'F' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'G' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'H' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'I' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'J' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'K' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'L' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'M' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'N' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'O' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'P' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'Q' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'R' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'S' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'T' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'U' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'V' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'W' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'X' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'Y' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'Z' */ STRINGPARSER_STATE_INT_STRING,
+ /* '[' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\\' */ STRINGPARSER_STATE_INT_STRING,
+ /* ']' */ STRINGPARSER_STATE_INT_STRING,
+ /* '^' */ STRINGPARSER_STATE_INT_STRING,
+ /* '_' */ STRINGPARSER_STATE_INT_STRING,
+ /* '`' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'a' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'b' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'c' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'd' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'e' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'f' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'g' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'h' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'i' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'j' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'k' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'l' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'm' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'n' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'o' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'p' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'q' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'r' */ STRINGPARSER_STATE_INT_STRING,
+ /* 's' */ STRINGPARSER_STATE_INT_STRING,
+ /* 't' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'u' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'v' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'w' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'x' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'y' */ STRINGPARSER_STATE_INT_STRING,
+ /* 'z' */ STRINGPARSER_STATE_INT_STRING,
+ /* '{' */ STRINGPARSER_STATE_INT_STRING,
+ /* '|' */ STRINGPARSER_STATE_INT_STRING,
+ /* '}' */ STRINGPARSER_STATE_INT_STRING,
+ /* '~' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x7f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x80' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x81' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x82' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x83' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x84' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x85' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x86' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x87' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x88' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x89' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8a' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8d' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x8f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x90' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x91' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x92' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x93' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x94' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x95' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x96' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x97' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x98' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x99' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9a' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9b' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9c' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9d' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9e' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\x9f' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xa9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xaa' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xab' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xac' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xad' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xae' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xaf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xb9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xba' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbe' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xbf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xc9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xca' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xce' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xcf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xd9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xda' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xde' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xdf' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xe9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xea' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xeb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xec' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xed' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xee' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xef' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf0' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf1' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf2' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf3' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf4' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf5' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf6' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf7' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf8' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xf9' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfa' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfb' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfc' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfd' */ STRINGPARSER_STATE_INT_STRING,
+ /* '\xfe' */ STRINGPARSER_STATE_INT_STRING
+};
+
+static const int * stringparser_state_transitions[] = {
+ stringparser_transition_row_text,
+ stringparser_transition_row_string,
+ stringparser_transition_row_string_escape
+};
+
diff --git a/src/tests/htmlparser_testdata/sample_fsm.config b/src/tests/htmlparser_testdata/sample_fsm.config
new file mode 100644
index 0000000..df66e69
--- /dev/null
+++ b/src/tests/htmlparser_testdata/sample_fsm.config
@@ -0,0 +1,64 @@
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+# ---
+#
+# Author: falmeida@google.com (Filipe Almeida)
+
+name = 'stringparser'
+
+comment = 'Parses C style strings'
+
+condition('dq', '\\"'),
+condition('backslash', '\\\\'),
+condition('default', '[:default:]')
+
+# Outside a string
+state(name = 'text',
+ external = 'text',
+ transitions = [
+ ['dq', 'string'],
+ ['default', 'text']
+ ])
+
+# String literal
+state(name = 'string',
+ external = 'string',
+ transitions = [
+ ['backslash', 'string_escape'],
+ ['dq', 'text'],
+ ['default', 'string']
+ ])
+
+# Escaped character in a string literal. Ignore the next character
+state(name = 'string_escape',
+ external = 'string',
+ transitions = [
+ ['default', 'string']
+ ])
+
diff --git a/src/tests/htmlparser_testdata/simple.html b/src/tests/htmlparser_testdata/simple.html
new file mode 100644
index 0000000..555928f
--- /dev/null
+++ b/src/tests/htmlparser_testdata/simple.html
@@ -0,0 +1,26 @@
+<html>
+ <body>
+ <?state state=text,tag=body?>
+ <a href="<?state state=value,tag=a?>">test</a>
+
+ <test test123=<?state state=value, tag=test, attr=test123,
+ attr_type=regular ?>>
+
+ <?state state=text?>
+
+ <body blah='<?state state=value, tag=body, attr=blah, attr_type=regular
+ ?>'>
+
+ <style>
+ <?state in_css=true?>
+ </style>
+ <?state in_css=false?>
+
+ <h1 onclick="<?state state=value, tag=h1, attr=onclick, attr_type=js,
+ in_js=true ?>" style="<?state in_css=true?>" <?state in_css=false?>>
+ <?state state=text, tag=h1?>
+ </h1>
+
+
+ </body>
+</html>
diff --git a/src/tests/htmlparser_testdata/tags.html b/src/tests/htmlparser_testdata/tags.html
new file mode 100644
index 0000000..1caf68d
--- /dev/null
+++ b/src/tests/htmlparser_testdata/tags.html
@@ -0,0 +1,214 @@
+<html>
+
+<body blah='<?state state=value, tag=body, attr=blah, attr_type=regular,
+attr_quoted=true ?>'>
+
+<?state state=text, tag=body ?>
+<a href=<?state state=value, tag=a, attr=href, attr_type=uri ?>><?state state=text, tag=a ?></a>
+<a href=
+ "<?state state=value, tag=a, attr=href, attr_type=uri, attr_quoted=true ?>"></a>
+
+<a href=<?state state=value, tag=a, attr=href, attr_type=uri ?> blah=x></a>
+<a href=
+ "<?state state=value, tag=a, attr=href, attr_type=uri ?>" blah=x></a>
+
+<a href=
+ <?state state=value, tag=a, attr=href, attr_type=uri, attr_quoted=false ?> blah=x></a>
+
+<a href><?state state=text, tag=a ?></a>
+
+<a href=x<?state state=value, tag=a, attr=href, attr_type=uri ?> <?state state=tag, tag=a ?>></a>
+
+<a href =<?state state=value, tag=a, attr=href, attr_type=uri ?>></a>
+<a href
+=<?state state=value, tag=a, attr=href, attr_type=uri ?>></a>
+<a href
+ =<?state state=value, tag=a, attr=href, attr_type=uri ?>></a>
+
+<?state state=text?>
+
+<b font=<?state state=value, value_index=0?>></b>
+<b font=x<?state state=value, value_index=1?>></b>
+<b font='<?state state=value, value_index=0?>'></b>
+<b font='x<?state state=value, value_index=1?>'></b>
+
+<!-- XML Processing instruction -->
+
+<?example <?state state=text?> <a href=<?state state=text?>></a
+ <script>
+ <?state state=text, in_js=false?>
+ </script>
+?>
+
+<a href=http://www.google.com/<?state state=value, tag=a, attr=href, attr_type=uri ?>?q=tt<?state state=value, tag=a, attr=href, attr_type=uri ?>>test</a>
+
+<!-- Test javascript url handling -->
+<a href="test<?state value=test, in_js=false ?>">test</a>
+<a href="javascript<?state value=javascript, in_js=false ?>">test</a>
+<a href="javascript:<?state value=javascript:, in_js=false ?>">test</a>
+<a href="javascript:alert('<?state in_js=false ?>">test</a>
+<a href="http:<?state value=http:, in_js=false ?>">test</a>
+<a href="http://www.google.com"
+ alt="javascript:<?state value=javascript:, in_js=false ?>">test</a>
+
+<!-- Test calls to TemplateDirective() -->
+<b font=<?state state=value?>
+ color<?state state=value?>></b>
+
+<b font=<?state state=value?><?state insert_text=true?>
+ color<?state state=attr?>></b>
+
+<b font="<?state state=value?><?state insert_text=true?>
+ color<?state state=value?>"></b>
+
+<a href=
+ <?state state=value?><?state insert_text=true?> alt<?state state=attr?>>
+ link
+</a>
+
+<b font=<?state state=value?>><?state state=text, tag=b?></b>
+
+<!-- Large invalid HTML entity -->
+<a onclick="&testtesttesttesttesttesttesttesttesttesttesttest;"
+ href="http://www.google.com/"></a>
+
+<!-- URI attributes. The attribute list can be found in
+ htmlparser.c:is_uri_attribute() -->
+<a target="<?state attr_type=regular?>"></a>
+<!-- -->
+<form action="<?state attr_type=uri?>"></form>
+<applet archive="<?state attr_type=uri?>"></applet>
+<blockquote cite="<?state attr_type=uri?>"></blockquote>
+<object classid="<?state attr_type=uri?>"></object>
+<object codebase="<?state attr_type=uri?>"></object>
+<object data="<?state attr_type=uri?>"></object>
+<img dynsrc="<?state attr_type=uri?>"></img>
+<a href="<?state attr_type=uri?>"></a>
+<img longdesc="<?state attr_type=uri?>"></img>
+<img src="<?state attr_type=uri?>"></img>
+<img usemap="<?state attr_type=uri?>"></img>
+<!-- -->
+<form style="x" action="<?state attr_type=uri?>"></form>
+<applet style="x" archive="<?state attr_type=uri?>"></applet>
+<blockquote style="x" cite="<?state attr_type=uri?>"></blockquote>
+<object style="x" classid="<?state attr_type=uri?>"></object>
+<object style="x" codebase="<?state attr_type=uri?>"></object>
+<object style="x" data="<?state attr_type=uri?>"></object>
+<img style="x" dynsrc="<?state attr_type=uri?>"></img>
+<a style="x" href="<?state attr_type=uri?>"></a>
+<img style="x" longdesc="<?state attr_type=uri?>"></img>
+<img style="x" src="<?state attr_type=uri?>"></img>
+<img style="x" usemap="<?state attr_type=uri?>"></img>
+<!-- -->
+<img alt="<?state attr_type=regular?>"></a>
+
+
+<!-- Style attributes as returned by htmlparser.c:is_style_attribute() -->
+<a target="<?state attr_type=regular?>"></a>
+<!-- -->
+<b style="<?state attr_type=style?>"></b>
+<!-- -->
+<a target="<?state attr_type=regular?>"></a>
+
+<!-- Big attribute value. We can't do prefix checking right now so we can't
+ validate the contents of the value here, although statemachine_test.c has
+ a test for that. -->
+
+<a href="http://www.google.com/"
+ alt="01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ 01234567890123456789012345678901234567890123456789
+ <?state state=value, attr_quoted=true, tag=a, attr=alt?>"></a>
+
+<?state state=text?>
+
+<!-- is_url_start tests -->
+
+<a href="<?state is_url_start=true?>"></a>
+<a href="http://<?state is_url_start=false?>"></a>
+<a href="http://www.google.com?q=<?state is_url_start=false?>"></a>
+<b font="<?state is_url_start=false?>"></b>
+<b font="http://www.google.com?q=<?state is_url_start=false?>"></b>
+<?state is_url_start=false?>
+
+<!-- <?state is_url_start=false?> -->
+
+<!-- Tag opening tests -->
+
+<a <?state state=tag?>></a><?state state=text?>
+<br <?state state=tag?>></br><?state state=text?>
+< br <?state state=text?>></br><?state state=text?>
+<< <?state state=text?>><?state state=text?>
+< <?state state=text?> alt="<?state state=text?>">
+</blah <?state state=tag?>><?state state=text?>
+<<i<?state state=tag?>><?state state=text?></i>
+
+
+<!-- We do allow numbers to open html tags, which is not how most browsers
+behave. We still test this anyway. -->
+<0 <?state state=tag?>><?state state=text?>
+<1 <?state state=tag?>><?state state=text?>
+
+<!-- meta redirect url tests. -->
+<meta http-equiv="refresh" content="5;URL=<?state attr_type=uri, is_url_start=true?>">
+<meta http-equiv="refresh" content="10;URL=<?state attr_type=uri, is_url_start=true?>">
+<meta http-equiv="refresh" content="5 ;URL=<?state attr_type=uri, is_url_start=true?>">
+<meta http-equiv="refresh" content=" 5 ;URL=<?state attr_type=uri, is_url_start=true?>">
+<?state attr_type=none, is_url_start=false?>
+<meta http-equiv="refresh" content=" 5 ; url = <?state attr_type=uri, is_url_start=true?>">
+<meta http-equiv="refresh" content="5;Url=<?state attr_type=uri, is_url_start=true?>">
+<meta http-equiv="refresh" content="5;UrL=<?state attr_type=uri, is_url_start=true?>">
+<meta http-equiv="refresh" content="5;uRL=<?state attr_type=uri, is_url_start=true?>">
+<?state attr_type=none, is_url_start=false?>
+<meta http-equiv="refresh" content="5;uRL=http://<?state attr_type=uri, is_url_start=false?>">
+<meta http-equiv="refresh" content="5 ; URL=http://www.google.com/<?state attr_type=uri, is_url_start=false?>">
+<meta http-equiv="refresh" content="5;URL=/<?state attr_type=uri, is_url_start=false?>">
+<meta http-equiv="refresh" content="5;URL=../<?state attr_type=uri, is_url_start=false?>">
+<meta http-equiv="refresh" content=" 123456789 ; url = ../<?state attr_type=uri, is_url_start=false?>">
+
+<!-- Quoted url's -->
+<meta http-equiv="refresh" content="5;URL = '<?state attr_type=uri, is_url_start=true?>">
+<meta http-equiv="refresh" content='5;URL = "<?state attr_type=uri, is_url_start=true?>"'>
+<meta http-equiv="refresh" content="5;URL = ' <?state attr_type=uri, is_url_start=false?>">
+<meta http-equiv="refresh" content='5;URL = " <?state attr_type=uri, is_url_start=false?>"'>
+
+<?state attr_type=none, is_url_start=false?>
+
+<meta http-equiv="refresh" content="5x;URL=<?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="<?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="5<?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="5;<?state attr_type=regular, is_url_start=false?>">
+<?state attr_type=none, is_url_start=false?>
+<meta http-equiv="refresh" content="5;U<?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="5;UR<?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="5;URL<?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="5;URL <?state attr_type=regular, is_url_start=false?>">
+<?state attr_type=none, is_url_start=false?>
+<meta http-equiv="refresh" content="5x;URL= <?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="5;UR L <?state attr_type=regular, is_url_start=false?>">
+<meta http-equiv="refresh" content="URL = <?state attr_type=regular, is_url_start=false?>">
+
+<meta http-equiv="refresh" content="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA <?state attr_type=regular?>">
+
+<span a:type="<?state state=value, attr=a:type?>"
+ a:abc.abc="<?state state=value, attr=a:abc.abc?>"
+ b:a.b.c.d.e.f=<?state state=value, attr=b:a.b.c.d.e.f?>>
+
+<tag.test>
+<?state state=text, tag=tag.test?>
+</tag.test>
+
+<!-- Tests regarding our specific implementation -->
+<meta content="5;URL=<?state attr_type=uri, is_url_start=true?>">
+
+</body>
+
+</html>
+<?state state=text ?>
diff --git a/src/tests/make_tpl_varnames_h_unittest.sh b/src/tests/make_tpl_varnames_h_unittest.sh
new file mode 100755
index 0000000..5d541cf
--- /dev/null
+++ b/src/tests/make_tpl_varnames_h_unittest.sh
@@ -0,0 +1,239 @@
+#!/bin/sh
+
+# Copyright (c) 2006, Google Inc.
+# 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 Google Inc. 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.
+
+# ---
+# Author: csilvers@google.com (Craig Silverstein)
+#
+
+die() {
+ echo "Test failed: $@" 1>&2
+ exit 1
+}
+
+MAKETPL=${1-"$TEST_SRCDIR/make_tpl_varnames_h"}
+
+# Optional second argument is tmpdir to use
+TMPDIR=${2-"$TEST_TMPDIR/maketpl"}
+
+rm -rf $TMPDIR
+mkdir $TMPDIR || die "$LINENO: Can't make $TMPDIR"
+
+# Let's make some templates: three that are ok, and three that are not
+echo '<a href={{QCHAR}}{{HREF}}{{QCHAR}} {{PARAMS}}>' > $TMPDIR/ok1.tpl
+echo '<img {{#ATTRIBUTES}}{{ATTRIBUTE}}{{/ATTRIBUTES}}>' > $TMPDIR/ok2.tpl
+echo '<html><head><title>{{TITLE}}</title></head></html>' > $TMPDIR/ok3.tpl
+echo '<a href={{QCHAR}}{{HREF}}{{QC' > $TMPDIR/bad1.tpl
+echo '<img {{#ATTRIBUTES}}{{ATTRIBUTE}}>' > $TMPDIR/bad2.tpl
+echo '<html><head><title>{{TITLE?}}</title></head></html>' > $TMPDIR/bad3.tpl
+
+# We'll make some templates with modifiers as well.
+echo '<a href={{HREF:h}} {{PARAMS}}>' > $TMPDIR/ok4.tpl
+echo '<a href={{HREF:html_escape_with_arg=url}} {{PARAMS}}>' > $TMPDIR/ok5.tpl
+echo '<a href={{HREF:x-custom-modifier}} {{PARAMS}}>' > $TMPDIR/ok6.tpl
+echo '<a href={{HREF:x-custom-modifier=arg}} {{PARAMS}}>' > $TMPDIR/ok7.tpl
+echo '<a href={{HREF:x-custom-modifier=}} {{PARAMS}}>' > $TMPDIR/ok8.tpl
+
+
+# First, test commandline flags
+$MAKETPL >/dev/null 2>&1 \
+ && die "$LINENO: $MAKETPL with no args didn't give an error"
+$MAKETPL -o$TMPDIR/foo >/dev/null 2>&1 \
+ && die "$LINENO: $MAKETPL with no template didn't give an error"
+$MAKETPL -h >/dev/null 2>&1 \
+ || die "$LINENO: $MAKETPL -h failed"
+$MAKETPL --help >/dev/null 2>&1 \
+ || die "$LINENO: $MAKETPL --help failed"
+$MAKETPL --nonsense >/dev/null 2>&1 \
+ && die "$LINENO: $MAKETPL --nonsense didn't give an error"
+$MAKETPL -f$TMPDIR/bar.h >/dev/null 2>&1 \
+ && die "$LINENO: $MAKETPL -f with no templates didn't give an error"
+
+# Some weird (broken) shells leave the ending EOF in the here-document,
+# hence the grep.
+expected_ok1=`cat <<EOF | grep -v '^EOF$'
+#ifndef %%%OUTPUT_NAME%%%
+#define %%%OUTPUT_NAME%%%
+
+#include <ctemplate/template_string.h>
+static const ::ctemplate::StaticTemplateString ko_QCHAR = STS_INIT_WITH_HASH(ko_QCHAR, "QCHAR", 13739615363438531061ULL);
+static const ::ctemplate::StaticTemplateString ko_HREF = STS_INIT_WITH_HASH(ko_HREF, "HREF", 4441707909033668369ULL);
+static const ::ctemplate::StaticTemplateString ko_PARAMS = STS_INIT_WITH_HASH(ko_PARAMS, "PARAMS", 10755877064288701757ULL);
+
+#endif // %%%OUTPUT_NAME%%%
+EOF`
+
+expected_ok2=`cat <<EOF | grep -v '^EOF$'
+#ifndef %%%OUTPUT_NAME%%%
+#define %%%OUTPUT_NAME%%%
+
+#include <ctemplate/template_string.h>
+static const ::ctemplate::StaticTemplateString ko_ATTRIBUTES = STS_INIT_WITH_HASH(ko_ATTRIBUTES, "ATTRIBUTES", 11813232524653503831ULL);
+static const ::ctemplate::StaticTemplateString ko_ATTRIBUTE = STS_INIT_WITH_HASH(ko_ATTRIBUTE, "ATTRIBUTE", 14959290143384361001ULL);
+
+#endif // %%%OUTPUT_NAME%%%
+EOF`
+
+expected_ok3=`cat <<EOF | grep -v '^EOF$'
+#ifndef %%%OUTPUT_NAME%%%
+#define %%%OUTPUT_NAME%%%
+
+#include <ctemplate/template_string.h>
+static const ::ctemplate::StaticTemplateString ko_TITLE = STS_INIT_WITH_HASH(ko_TITLE, "TITLE", 8931122033088041025ULL);
+
+#endif // %%%OUTPUT_NAME%%%
+EOF`
+
+expected_ok4=`cat <<EOF | grep -v '^EOF$'
+#ifndef %%%OUTPUT_NAME%%%
+#define %%%OUTPUT_NAME%%%
+
+#include <ctemplate/template_string.h>
+static const ::ctemplate::StaticTemplateString ko_HREF = STS_INIT_WITH_HASH(ko_HREF, "HREF", 4441707909033668369ULL);
+static const ::ctemplate::StaticTemplateString ko_PARAMS = STS_INIT_WITH_HASH(ko_PARAMS, "PARAMS", 10755877064288701757ULL);
+
+#endif // %%%OUTPUT_NAME%%%
+EOF`
+
+expected_ok5=`echo "$expected_ok4" | sed s/ok4/ok5/g`
+expected_ok6=`echo "$expected_ok4" | sed s/ok4/ok6/g`
+expected_ok7=`echo "$expected_ok4" | sed s/ok4/ok7/g`
+expected_ok8=`echo "$expected_ok4" | sed s/ok4/ok8/g`
+
+# When -f (--output-file) is used on ok1.tpl and ok2.tpl
+# Note that there are no variables in common in these two templates.
+# All should be returned.
+expected_ok1and2=`cat <<EOF | grep -v '^EOF$'
+#ifndef %%%OUTPUT_NAME%%%
+#define %%%OUTPUT_NAME%%%
+
+#include <ctemplate/template_string.h>
+static const ::ctemplate::StaticTemplateString ko_QCHAR = STS_INIT_WITH_HASH(ko_QCHAR, "QCHAR", 13739615363438531061ULL);
+static const ::ctemplate::StaticTemplateString ko_HREF = STS_INIT_WITH_HASH(ko_HREF, "HREF", 4441707909033668369ULL);
+static const ::ctemplate::StaticTemplateString ko_PARAMS = STS_INIT_WITH_HASH(ko_PARAMS, "PARAMS", 10755877064288701757ULL);
+static const ::ctemplate::StaticTemplateString ko_ATTRIBUTES = STS_INIT_WITH_HASH(ko_ATTRIBUTES, "ATTRIBUTES", 11813232524653503831ULL);
+static const ::ctemplate::StaticTemplateString ko_ATTRIBUTE = STS_INIT_WITH_HASH(ko_ATTRIBUTE, "ATTRIBUTE", 14959290143384361001ULL);
+
+#endif // %%%OUTPUT_NAME%%%
+EOF`
+
+# When -f (--output-file) is used on ok1.tpl and ok4.tpl
+# Note that both variables in ok4.tpl will be duplicates and hence not returned.
+expected_ok1and4=`echo "$expected_ok1" | sed s/ok1/ok1and4/g`
+
+# Suppress unimportant aspects of the make_tpl_varnames_h output.
+Cleanse() {
+ # Replace the file name guard with %%%OUTPUT_NAME%%% so we can use
+ # the same expected_ok* variables for different file names.
+ # Note that we only append 'H_' to the end of the string, instead
+ # of '_H_'. This is because the first call to 'tr' is already
+ # adding a '_' at the end of the converted $1 (due to the newline
+ # emitted by echo).
+ n="`basename $1 | sed -e 's/[^0-9a-zA-Z]/_/g' | tr 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'`"
+ grep -v '^//' "$1" | sed -e "s:TPL_.*${n}_H_:%%%OUTPUT_NAME%%%:" > "$1.cleansed"
+}
+
+# syntax-check these templates
+$MAKETPL -n $TMPDIR/ok1.tpl $TMPDIR/ok2.tpl $TMPDIR/ok3.tpl >/dev/null 2>&1 \
+ || die "$LINENO: $MAKETPL gave error parsing good templates"
+$MAKETPL -n $TMPDIR/ok1.tpl $TMPDIR/ok2.tpl $TMPDIR/bad3.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $MAKETPL gave no error parsing bad template"
+$MAKETPL -n $TMPDIR/ok1.tpl $TMPDIR/ok2.tpl $TMPDIR/ok100.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $MAKETPL gave no error parsing non-existent template"
+
+# Now try the same thing, but use template-root so we don't need absdirs
+$MAKETPL -n --template_dir=$TMPDIR ok1.tpl ok2.tpl ok3.tpl >/dev/null 2>&1 \
+ || die "$LINENO: $MAKETPL gave error parsing good templates"
+
+# Parse the templates. Bad one in the middle should be ignored.
+$MAKETPL --header_dir=$TMPDIR $TMPDIR/ok1.tpl $TMPDIR/bad2.tpl $TMPDIR/ok3.tpl >/dev/null 2>&1
+[ $? = 1 ] || die "$LINENO: $MAKETPL gave wrong error-code parsing 1 bad template: $?"
+Cleanse "$TMPDIR/ok1.tpl.varnames.h"
+echo "$expected_ok1" | diff - "$TMPDIR/ok1.tpl.varnames.h.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok1 output correctly"
+[ -f "$TMPDIR/bad2.tpl.varnames.h" ] \
+ && die "$LINENO: $MAKETPL >did< make bad2 output"
+Cleanse "$TMPDIR/ok3.tpl.varnames.h"
+echo "$expected_ok3" | diff - "$TMPDIR/ok3.tpl.varnames.h.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok3 output correctly"
+
+# Now try the same but with a different suffix. Try an alternate -t/-o form too.
+# Also test not being able to output the file for some reason.
+$MAKETPL -t$TMPDIR -o$TMPDIR -s.out ok1.tpl bad2.tpl ok3.tpl >/dev/null 2>&1
+[ $? = 1 ] || die "$LINENO: $MAKETPL gave wrong error-code parsing 1 bad template: $?"
+Cleanse "$TMPDIR/ok1.tpl.out"
+echo "$expected_ok1" | diff - "$TMPDIR/ok1.tpl.out.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok1 output correctly"
+[ -f "$TMPDIR/bad2.tpl.out" ] && die "$LINENO: $MAKETPL >did< make bad2 output"
+Cleanse "$TMPDIR/ok3.tpl.out"
+echo "$expected_ok3" | diff - "$TMPDIR/ok3.tpl.out.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok3 output correctly"
+
+# Verify that -f generates the requested output file:
+# -f with one file
+$MAKETPL -t$TMPDIR -f$TMPDIR/ok1.h ok1.tpl >/dev/null 2>&1
+Cleanse "$TMPDIR/ok1.h"
+echo "$expected_ok1" | diff - "$TMPDIR/ok1.h.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok1.h output correctly"
+# -f with two files - no common template variables
+$MAKETPL -t$TMPDIR -f$TMPDIR/ok1and2.h ok1.tpl ok2.tpl >/dev/null 2>&1
+Cleanse "$TMPDIR/ok1and2.h"
+echo "$expected_ok1and2" | diff - "$TMPDIR/ok1and2.h.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok1and2.h output correctly"
+# -f with two files - two common template variables
+$MAKETPL -t$TMPDIR -f$TMPDIR/ok1and4.h ok1.tpl ok4.tpl >/dev/null 2>&1
+Cleanse "$TMPDIR/ok1and4.h"
+echo "$expected_ok1and4" | diff - "$TMPDIR/ok1and4.h.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok1and4.h output correctly"
+# -f with a bad file should not produce an output
+$MAKETPL -t$TMPDIR -f$TMPDIR/bar.h ok1.tpl bad1.tpl >/dev/null 2>&1 \
+ && die "$LINENO: $MAKETPL -f gave no error parsing bad template"
+
+# Verify we don't give any output iff everything works, with -q flag.
+# Also test using a different output dir. Also, test *every* ok template.
+mkdir $TMPDIR/output
+# Normally I'd do {1,2,3,4,...}, but solaris sh doesn't understand that syntax
+out=`$MAKETPL -q -t$TMPDIR -o$TMPDIR/output -s"#" \
+ ok1.tpl ok2.tpl ok3.tpl ok4.tpl ok5.tpl ok6.tpl ok7.tpl ok8.tpl \
+ 2>&1`
+[ -z "$out" ] || die "$LINENO: $MAKETPL -q wasn't so quiet: '$out'"
+for i in 1 2 3 4 5 6 7 8; do
+ Cleanse "$TMPDIR/output/ok$i.tpl#"
+ eval "echo \"\$expected_ok$i\"" | diff - "$TMPDIR/output/ok$i.tpl#.cleansed" \
+ || die "$LINENO: $MAKETPL didn't make ok$i output correctly"
+done
+
+out=`$MAKETPL -q --outputfile_suffix=2 $TMPDIR/bad{1,2,3}.tpl 2>&1`
+[ -z "$out" ] && die "$LINENO: $MAKETPL -q was too quiet"
+for i in 1 2 3; do
+ [ -f "$TMPDIR/output/bad$i.tpl2" ] && die "$LINENO: $MAKETPL made bad$i output"
+done
+
+echo "PASSED"
diff --git a/src/tests/statemachine_test.c b/src/tests/statemachine_test.c
new file mode 100644
index 0000000..33481d6
--- /dev/null
+++ b/src/tests/statemachine_test.c
@@ -0,0 +1,365 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+
+#include "htmlparser/statemachine.h"
+
+enum {
+ SIMPLE_STATE_A,
+ SIMPLE_STATE_B,
+ SIMPLE_STATE_C,
+ SIMPLE_STATE_D,
+ SIMPLE_STATE_ERROR_TEST
+};
+
+/* Include the test state machine definition. */
+#include "tests/statemachine_test_fsm.h"
+
+/* Taken from google templates */
+
+#define ASSERT(cond) do { \
+ if (!(cond)) { \
+ printf("%s: %d: ASSERT FAILED: %s\n", __FILE__, __LINE__, \
+ #cond); \
+ assert(cond); \
+ exit(1); \
+ } \
+} while (0)
+
+#define ASSERT_STREQ(a, b) do { \
+ if (strcmp((a), (b))) { \
+ printf("%s: %d: ASSERT FAILED: '%s' != '%s'\n", __FILE__, __LINE__, \
+ (a), (b)); \
+ assert(!strcmp((a), (b))); \
+ exit(1); \
+ } \
+} while (0)
+
+#define ASSERT_STRSTR(text, substr) do { \
+ if (!strstr((text), (substr))) { \
+ printf("%s: %d: ASSERT FAILED: '%s' not in '%s'\n", \
+ __FILE__, __LINE__, (substr), (text)); \
+ assert(strstr((text), (substr))); \
+ exit(1); \
+ } \
+} while (0)
+
+
+#define NUM_STATES 10
+
+/* To simply the tests */
+#define statemachine_parse_str(a,b) statemachine_parse(a, b, strlen(b));
+
+/* Simple state machine test. */
+int test_simple()
+{
+ statemachine_definition *def;
+ statemachine_ctx *sm;
+ def = statemachine_definition_new(NUM_STATES);
+ sm = statemachine_new(def, NULL);
+
+ statemachine_definition_populate(def, simple_state_transitions,
+ simple_states_internal_names);
+ ASSERT(sm->current_state == SIMPLE_STATE_A);
+
+ statemachine_parse(sm, "001", 3);
+ ASSERT(sm->current_state == SIMPLE_STATE_B);
+
+ statemachine_parse(sm, "001", 3);
+ ASSERT(sm->current_state == SIMPLE_STATE_C);
+
+ statemachine_parse(sm, "2", 1);
+ ASSERT(sm->current_state == SIMPLE_STATE_B);
+
+ statemachine_parse(sm, "11", 2);
+ ASSERT(sm->current_state == SIMPLE_STATE_D);
+
+ statemachine_delete(sm);
+ return 0;
+}
+
+/* Tests error handling logic when we try to follow non existent transitions. */
+int test_error()
+{
+ statemachine_definition *def;
+ statemachine_ctx *sm;
+ int res;
+
+ def = statemachine_definition_new(NUM_STATES);
+ sm = statemachine_new(def, NULL);
+
+ statemachine_definition_populate(def, simple_state_transitions,
+ NULL);
+ ASSERT(sm->current_state == SIMPLE_STATE_A);
+
+ ASSERT(statemachine_get_error_msg(sm) == NULL);
+
+ res = statemachine_parse_str(sm, "00E");
+ ASSERT(sm->current_state == SIMPLE_STATE_ERROR_TEST);
+ ASSERT(sm->current_state == res);
+
+ res = statemachine_parse(sm, "3", 1);
+ ASSERT(res == STATEMACHINE_ERROR);
+ ASSERT_STREQ(statemachine_get_error_msg(sm),
+ "Unexpected character '3'");
+
+ statemachine_reset(sm);
+ ASSERT(statemachine_get_error_msg(sm) == NULL);
+
+ statemachine_delete(sm);
+
+ def = statemachine_definition_new(NUM_STATES);
+ sm = statemachine_new(def, NULL);
+
+ statemachine_definition_populate(def, simple_state_transitions,
+ simple_states_internal_names);
+ ASSERT(sm->current_state == SIMPLE_STATE_A);
+
+ res = statemachine_parse_str(sm, "00E");
+ ASSERT(sm->current_state == SIMPLE_STATE_ERROR_TEST);
+ ASSERT(sm->current_state == res);
+
+ res = statemachine_parse(sm, "3", 1);
+ ASSERT(res == STATEMACHINE_ERROR);
+ ASSERT_STREQ(statemachine_get_error_msg(sm),
+ "Unexpected character '3' in state 'error_test'");
+
+ statemachine_delete(sm);
+
+ return 0;
+}
+
+/* Tests htmlparser_start_record() and htmlparser_end_record() logic. */
+
+int test_record()
+{
+ statemachine_definition *def;
+ statemachine_ctx *sm;
+ const char *actual;
+ char expected[STATEMACHINE_RECORD_BUFFER_SIZE];
+ int res;
+ int counter;
+ def = statemachine_definition_new(NUM_STATES);
+ sm = statemachine_new(def, NULL);
+
+ statemachine_definition_populate(def, simple_state_transitions,
+ simple_states_internal_names);
+
+ ASSERT(sm->current_state == SIMPLE_STATE_A);
+
+ res = statemachine_parse_str(sm, "001");
+ ASSERT(sm->current_state == SIMPLE_STATE_B);
+ ASSERT(sm->current_state == res);
+
+ statemachine_start_record(sm);
+ statemachine_parse_str(sm, "121212");
+ ASSERT_STREQ("121212", statemachine_stop_record(sm));
+
+ statemachine_parse_str(sm, "not recorded");
+
+ statemachine_start_record(sm);
+ statemachine_parse_str(sm, "121212000");
+ ASSERT_STREQ("121212000", statemachine_stop_record(sm));
+
+ statemachine_start_record(sm);
+ statemachine_parse_str(sm, "1234567890");
+ ASSERT_STREQ("1234567890", statemachine_record_buffer(sm));
+
+ statemachine_parse_str(sm, "test");
+ ASSERT_STREQ("1234567890test", statemachine_stop_record(sm));
+
+ statemachine_start_record(sm);
+
+ /* Record 1000 chars + strlen("beginning-") */
+ statemachine_parse_str(sm, "beginning-");
+ for (counter = 0; counter < 100; counter++) {
+ statemachine_parse_str(sm, "1234567890");
+ }
+
+ /* Make sure we preserved the start of the buffer. */
+ ASSERT_STRSTR(statemachine_record_buffer(sm), "beginning-");
+
+ /* And make sure the size is what we expect. */
+ ASSERT(STATEMACHINE_RECORD_BUFFER_SIZE - 1 ==
+ strlen(statemachine_stop_record(sm)));
+
+ statemachine_start_record(sm);
+ for (counter = 0; counter < 100; counter++) {
+ statemachine_parse_str(sm, "0123456789ABCDEF");
+ }
+
+ expected[0] = '\0';
+ /* Fill the buffer with a pattern 255 chars long (16 * 15 + 15). */
+ for (counter = 0; counter < 15; counter++) {
+ strcat(expected, "0123456789ABCDEF");
+ }
+ strcat(expected, "0123456789ABCDE");
+ actual = statemachine_stop_record(sm);
+ ASSERT_STREQ(expected, actual);
+
+ statemachine_delete(sm);
+ return 0;
+}
+
+/* Test with characters outside of the ascii range */
+int test_no_ascii()
+{
+ statemachine_definition *def;
+ statemachine_ctx *sm;
+ def = statemachine_definition_new(NUM_STATES);
+ sm = statemachine_new(def, NULL);
+
+ statemachine_definition_populate(def, simple_state_transitions,
+ simple_states_internal_names);
+
+ ASSERT(sm->current_state == SIMPLE_STATE_A);
+
+ statemachine_parse(sm, "\xf0\xf0\xf1", 3);
+ ASSERT(sm->current_state == SIMPLE_STATE_B);
+
+ statemachine_parse(sm, "\xf0\xf0\xf1", 3);
+ ASSERT(sm->current_state == SIMPLE_STATE_C);
+
+ statemachine_parse(sm, "\xf2", 1);
+ ASSERT(sm->current_state == SIMPLE_STATE_B);
+
+ statemachine_parse(sm, "\xf1\xf1", 2);
+ ASSERT(sm->current_state == SIMPLE_STATE_D);
+
+ statemachine_delete(sm);
+ return 0;
+
+}
+
+int test_copy()
+{
+ statemachine_definition *def;
+ statemachine_ctx *sm1;
+ statemachine_ctx *sm2;
+ statemachine_ctx *sm3;
+ def = statemachine_definition_new(NUM_STATES);
+ sm1 = statemachine_new(def, NULL);
+
+ statemachine_definition_populate(def, simple_state_transitions,
+ simple_states_internal_names);
+
+ ASSERT(sm1->current_state == SIMPLE_STATE_A);
+
+ sm2 = statemachine_duplicate(sm1, def, NULL);
+ ASSERT(sm2->current_state == SIMPLE_STATE_A);
+
+ statemachine_parse(sm1, "001", 3);
+ ASSERT(sm1->current_state == SIMPLE_STATE_B);
+ ASSERT(sm2->current_state == SIMPLE_STATE_A);
+
+
+ statemachine_parse(sm1, "001", 3);
+ statemachine_parse(sm2, "001", 3);
+ ASSERT(sm1->current_state == SIMPLE_STATE_C);
+ ASSERT(sm2->current_state == SIMPLE_STATE_B);
+
+ sm3 = statemachine_duplicate(sm2, def, NULL);
+ ASSERT(sm3->current_state == SIMPLE_STATE_B);
+
+ statemachine_parse(sm1, "001", 3);
+ statemachine_parse(sm2, "001", 3);
+ statemachine_parse(sm3, "002", 3);
+ ASSERT(sm1->current_state == SIMPLE_STATE_D);
+ ASSERT(sm2->current_state == SIMPLE_STATE_C);
+ ASSERT(sm3->current_state == SIMPLE_STATE_A);
+
+ statemachine_delete(sm1);
+ statemachine_delete(sm2);
+ statemachine_delete(sm3);
+
+ return 0;
+}
+
+/* Tests statemachine_encode_char().
+ */
+int test_encode_char()
+{
+ char encoded_char[10];
+ int i;
+
+ struct {
+ char chr;
+ const char *result;
+ } encode_map[] = {
+ { 'x', "x" },
+ { '0', "0" },
+ { '\n', "\\n" },
+ { '\r', "\\r" },
+ { '\t', "\\t" },
+ { '\\', "\\\\" },
+ { '\0', "\\x00" },
+ { '\xF0', "\\xf0" },
+ { '\0', NULL} // Terminates when output == NULL
+ };
+
+ for (i = 0; encode_map[i].result; i++) {
+ statemachine_encode_char(encode_map[i].chr, encoded_char,
+ sizeof(encoded_char) / sizeof(*encoded_char));
+ ASSERT_STREQ(encoded_char, encode_map[i].result);
+ }
+
+ statemachine_encode_char('\xFF', encoded_char, 1);
+ ASSERT_STREQ(encoded_char, "");
+
+ statemachine_encode_char('\xFF', encoded_char, 2);
+ ASSERT_STREQ(encoded_char, "\\");
+
+ statemachine_encode_char('\xFF', encoded_char, 3);
+ ASSERT_STREQ(encoded_char, "\\x");
+
+ statemachine_encode_char('\xFF', encoded_char, 4);
+ ASSERT_STREQ(encoded_char, "\\xf");
+
+ statemachine_encode_char('\xFF', encoded_char, 5);
+ ASSERT_STREQ(encoded_char, "\\xff");
+
+ return 0;
+}
+
+int main(int argc, char **argv)
+{
+ test_simple();
+ test_error();
+ test_record();
+ test_no_ascii();
+ test_copy();
+ test_encode_char();
+ printf("DONE.\n");
+ return 0;
+}
diff --git a/src/tests/statemachine_test_fsm.config b/src/tests/statemachine_test_fsm.config
new file mode 100644
index 0000000..c781c0a
--- /dev/null
+++ b/src/tests/statemachine_test_fsm.config
@@ -0,0 +1,79 @@
+# Copyright (c) 2008, Google Inc.
+# 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 Google Inc. 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.
+# ---
+#
+# Author: falmeida@google.com (Filipe Almeida)
+#
+# Simple state machine definition used in for testing the state machine.
+
+name = 'simple'
+
+comment = 'Simple state machine'
+
+condition('1', '1\xf1')
+condition('2', '2\xf2')
+condition('E', 'E')
+condition('default', '[:default:]')
+
+state(name = 'A',
+ external = 'A',
+ transitions = [
+ ['1', 'B'],
+ ['E', 'error_test'],
+ ['default', 'A'],
+ ])
+
+state(name = 'B',
+ external = 'B',
+ transitions = [
+ ['1', 'C'],
+ ['2', 'A'],
+ ['default', 'B'],
+ ])
+
+state(name = 'C',
+ external = 'C',
+ transitions = [
+ ['1', 'D'],
+ ['2', 'B'],
+ ['default', 'C'],
+ ])
+
+state(name = 'D',
+ external = 'D',
+ transitions = [
+ ['2', 'C'],
+ ['default', 'D'],
+ ])
+
+state(name = 'error_test',
+ external = 'error_test',
+ transitions = [
+ ['2', 'A'],
+ ])
diff --git a/src/tests/template_cache_test.cc b/src/tests/template_cache_test.cc
new file mode 100644
index 0000000..5a23716
--- /dev/null
+++ b/src/tests/template_cache_test.cc
@@ -0,0 +1,1064 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+
+#include "config_for_unittests.h"
+#include <ctemplate/template_cache.h>
+#include <assert.h> // for assert()
+#include <stdio.h> // for printf()
+#include <stdlib.h> // for exit()
+#include <string.h> // for strcmp()
+#include <sys/types.h> // for mode_t
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif // for unlink()
+#include <ctemplate/template.h> // for Template
+#include <ctemplate/template_dictionary.h> // for TemplateDictionary
+#include <ctemplate/template_enums.h> // for DO_NOT_STRIP, etc
+#include <ctemplate/template_pathops.h> // for PathJoin(), kCWD
+#include <ctemplate/template_string.h> // for TemplateString
+#include "tests/template_test_util.h" // for AssertExpandIs(), etc
+using std::string;
+using GOOGLE_NAMESPACE::FLAGS_test_tmpdir;
+using GOOGLE_NAMESPACE::AssertExpandIs;
+using GOOGLE_NAMESPACE::CreateOrCleanTestDir;
+using GOOGLE_NAMESPACE::CreateOrCleanTestDirAndSetAsTmpdir;
+using GOOGLE_NAMESPACE::DO_NOT_STRIP;
+using GOOGLE_NAMESPACE::PathJoin;
+using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
+using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
+using GOOGLE_NAMESPACE::StaticTemplateString;
+using GOOGLE_NAMESPACE::StringToFile;
+using GOOGLE_NAMESPACE::StringToTemplateCache;
+using GOOGLE_NAMESPACE::StringToTemplateFile;
+using GOOGLE_NAMESPACE::Template;
+using GOOGLE_NAMESPACE::TemplateCache;
+using GOOGLE_NAMESPACE::TemplateCachePeer;
+using GOOGLE_NAMESPACE::TemplateDictionary;
+using GOOGLE_NAMESPACE::kCWD;
+
+#define ASSERT(cond) do { \
+ if (!(cond)) { \
+ printf("ASSERT FAILED, line %d: %s\n", __LINE__, #cond); \
+ assert(cond); \
+ exit(1); \
+ } \
+} while (0)
+
+#define ASSERT_STREQ(a, b) ASSERT(strcmp(a, b) == 0)
+
+static const StaticTemplateString kKey = STS_INIT(kKey, "MY_KEY");
+static const StaticTemplateString kContent = STS_INIT(kContent, "content");
+
+// It would be nice to use the TEST framework, but it makes friendship
+// more difficult. (TemplateCache befriends TemplateCacheUnittest.)
+class TemplateCacheUnittest {
+ public:
+ static void TestGetTemplate() {
+ // Tests the cache
+ TemplateCache cache1;
+ const char* text = "{This is perfectly valid} yay!";
+ TemplateDictionary empty_dict("dict");
+
+ string filename = StringToTemplateFile(text);
+ const Template* tpl1 = cache1.GetTemplate(filename, DO_NOT_STRIP);
+ const Template* tpl2 = cache1.GetTemplate(filename.c_str(), DO_NOT_STRIP);
+ const Template* tpl3 = cache1.GetTemplate(filename, STRIP_WHITESPACE);
+ ASSERT(tpl1 && tpl2 && tpl3);
+ ASSERT(tpl1 == tpl2);
+ ASSERT(tpl1 != tpl3);
+ AssertExpandIs(tpl1, &empty_dict, text, true);
+ AssertExpandIs(tpl2, &empty_dict, text, true);
+ AssertExpandIs(tpl3, &empty_dict, text, true);
+
+ // Tests that a nonexistent template returns NULL
+ const Template* tpl4 = cache1.GetTemplate("/yakakak", STRIP_WHITESPACE);
+ ASSERT(!tpl4);
+
+ // Make sure we get different results if we use a different cache.
+ TemplateCache cache2;
+ const Template* tpl5 = cache2.GetTemplate(filename, DO_NOT_STRIP);
+ ASSERT(tpl5);
+ ASSERT(tpl5 != tpl1);
+ AssertExpandIs(tpl5, &empty_dict, text, true);
+
+ // And different results yet if we use the default cache.
+ const Template* tpl6 = Template::GetTemplate(filename, DO_NOT_STRIP);
+ ASSERT(tpl6);
+ ASSERT(tpl6 != tpl1);
+ AssertExpandIs(tpl6, &empty_dict, text, true);
+ }
+
+ static void TestLoadTemplate() {
+ // Tests the cache
+ TemplateCache cache1;
+ const char* text = "{This is perfectly valid} yay!";
+ TemplateDictionary empty_dict("dict");
+ string filename = StringToTemplateFile(text);
+
+ ASSERT(cache1.LoadTemplate(filename, DO_NOT_STRIP));
+
+ // Tests that a nonexistent template returns false
+ ASSERT(!cache1.LoadTemplate("/yakakak", STRIP_WHITESPACE));
+ }
+
+ static void TestStringGetTemplate() {
+ // If you use these same cache keys somewhere else,
+ // call Template::ClearCache first.
+ const string cache_key_a = "cache key a";
+ const string text = "Test template 1";
+ TemplateDictionary empty_dict("dict");
+
+ TemplateCache cache1;
+ const Template *tpl1;
+ ASSERT(cache1.StringToTemplateCache(cache_key_a, text, DO_NOT_STRIP));
+ tpl1 = cache1.GetTemplate(cache_key_a, DO_NOT_STRIP);
+ AssertExpandIs(tpl1, &empty_dict, text, true);
+
+ // A different cache should give different templates.
+ TemplateCache cache2;
+ const Template *tpl3;
+ ASSERT(cache2.StringToTemplateCache(cache_key_a, text, DO_NOT_STRIP));
+ tpl3 = cache2.GetTemplate(cache_key_a, DO_NOT_STRIP);
+ ASSERT(tpl3 != tpl1);
+ AssertExpandIs(tpl3, &empty_dict, text, true);
+
+ // And the main cache different still
+ const Template *tpl4;
+ ASSERT(StringToTemplateCache(cache_key_a, text, DO_NOT_STRIP));
+ tpl4 = Template::GetTemplate(cache_key_a, DO_NOT_STRIP);
+ ASSERT(tpl4 != tpl1);
+ AssertExpandIs(tpl4, &empty_dict, text, true);
+
+ // If we register a new string with the same text, it should be ignored.
+ ASSERT(!cache1.StringToTemplateCache(cache_key_a, "new text",
+ DO_NOT_STRIP));
+
+ Template::ClearCache();
+ }
+
+ static void TestStringToTemplateCacheWithStrip() {
+ const string cache_key_a = "cache key a";
+ const string text = "Test template 1";
+ TemplateDictionary empty_dict("dict");
+
+ TemplateCache cache;
+ ASSERT(cache.StringToTemplateCache(cache_key_a, text, DO_NOT_STRIP));
+
+ TemplateCachePeer cache_peer(&cache);
+ TemplateCachePeer::TemplateCacheKey cache_key1(cache_key_a, DO_NOT_STRIP);
+ ASSERT(cache_peer.TemplateIsCached(cache_key1));
+ const Template* tpl1 = cache_peer.GetTemplate(cache_key_a, DO_NOT_STRIP);
+ ASSERT(tpl1);
+ AssertExpandIs(tpl1, &empty_dict, text, true);
+
+ // Different strip: when a string template is registered via
+ // StringToTemplateCache with a strip, we cannot use a different
+ // strip later to fetch the template.
+ TemplateCachePeer::TemplateCacheKey cache_key2(cache_key_a,
+ STRIP_WHITESPACE);
+ ASSERT(!cache_peer.TemplateIsCached(cache_key2));
+ }
+
+ static void TestExpandNoLoad() {
+ TemplateCache cache;
+ string filename = StringToTemplateFile("alone");
+ string top_filename = StringToTemplateFile("Hello, {{>WORLD}}");
+ string inc_filename = StringToTemplateFile("world");
+
+ TemplateDictionary dict("ExpandNoLoad");
+ dict.AddIncludeDictionary("WORLD")->SetFilename(inc_filename);
+ string out;
+
+ // This should fail because the cache is empty.
+ cache.Freeze();
+ ASSERT(!cache.ExpandNoLoad(filename, DO_NOT_STRIP, &dict, NULL, &out));
+
+ cache.ClearCache(); // also clears the "frozen" state
+ // This should succeed -- it loads inc_filename from disk.
+ ASSERT(cache.ExpandWithData(filename, DO_NOT_STRIP, &dict, NULL, &out));
+ ASSERT(out == "alone");
+ out.clear();
+ // Now this should succeed -- it's in the cache.
+ cache.Freeze();
+ ASSERT(cache.ExpandNoLoad(filename, DO_NOT_STRIP, &dict, NULL, &out));
+ ASSERT(out == "alone");
+ out.clear();
+
+ // This should fail because neither top nor inc are in the cache.
+ cache.ClearCache();
+ cache.Freeze();
+ ASSERT(!cache.ExpandNoLoad(top_filename, DO_NOT_STRIP, &dict, NULL, &out));
+ cache.ClearCache();
+ ASSERT(cache.LoadTemplate(top_filename, DO_NOT_STRIP));
+ // This *should* fail, but because inc_filename isn't in the cache.
+ cache.Freeze();
+ ASSERT(!cache.ExpandNoLoad(top_filename, DO_NOT_STRIP, &dict, NULL, &out));
+ // TODO(csilvers): this should not be necessary. But expand writes
+ // to its output even before it fails.
+ out.clear();
+ cache.ClearCache();
+ ASSERT(cache.LoadTemplate(top_filename, DO_NOT_STRIP));
+ ASSERT(cache.LoadTemplate(inc_filename, DO_NOT_STRIP));
+ cache.Freeze();
+ // *Now* it should succeed, with everything it needs loaded.
+ ASSERT(cache.ExpandNoLoad(top_filename, DO_NOT_STRIP, &dict, NULL, &out));
+ ASSERT(out == "Hello, world");
+ out.clear();
+ // This should succeed too, of course.
+ ASSERT(cache.ExpandWithData(top_filename, DO_NOT_STRIP, &dict, NULL, &out));
+ ASSERT(out == "Hello, world");
+ out.clear();
+
+ cache.ClearCache();
+ ASSERT(cache.ExpandWithData(top_filename, DO_NOT_STRIP, &dict, NULL, &out));
+ ASSERT(out == "Hello, world");
+ out.clear();
+ // Now everything NoLoad needs should be in the cache again.
+ cache.Freeze();
+ ASSERT(cache.ExpandNoLoad(top_filename, DO_NOT_STRIP, &dict, NULL, &out));
+ ASSERT(out == "Hello, world");
+ out.clear();
+
+ cache.ClearCache();
+ ASSERT(cache.LoadTemplate(top_filename, DO_NOT_STRIP));
+ cache.Freeze();
+ // This fails, of course, because we're frozen.
+ ASSERT(!cache.LoadTemplate(inc_filename, DO_NOT_STRIP));
+ // And thus, this fails too.
+ ASSERT(!cache.ExpandNoLoad(top_filename, DO_NOT_STRIP, &dict, NULL, &out));
+ }
+
+ static void TestTemplateSearchPath() {
+ TemplateCache cache1;
+
+ const string pathA = PathJoin(FLAGS_test_tmpdir, "a/");
+ const string pathB = PathJoin(FLAGS_test_tmpdir, "b/");
+ CreateOrCleanTestDir(pathA);
+ CreateOrCleanTestDir(pathB);
+
+ TemplateDictionary dict("");
+ cache1.SetTemplateRootDirectory(pathA);
+ cache1.AddAlternateTemplateRootDirectory(pathB);
+ ASSERT(cache1.template_root_directory() == pathA);
+
+ // 1. Show that a template in the secondary path can be found.
+ const string path_b_bar = PathJoin(pathB, "template_bar");
+ StringToFile("b/template_bar", path_b_bar);
+ ASSERT_STREQ(path_b_bar.c_str(),
+ cache1.FindTemplateFilename("template_bar").c_str());
+ const Template* b_bar = cache1.GetTemplate("template_bar", DO_NOT_STRIP);
+ ASSERT(b_bar);
+ AssertExpandIs(b_bar, &dict, "b/template_bar", true);
+
+ // 2. Show that the search stops once the first match is found.
+ // Create two templates in separate directories with the same name.
+ const string path_a_foo = PathJoin(pathA, "template_foo");
+ const string path_b_foo = PathJoin(pathB, "template_foo");
+ StringToFile("a/template_foo", path_a_foo);
+ StringToFile("b/template_foo", path_b_foo);
+ ASSERT_STREQ(path_a_foo.c_str(),
+ cache1.FindTemplateFilename("template_foo").c_str());
+ const Template* a_foo = cache1.GetTemplate("template_foo", DO_NOT_STRIP);
+ ASSERT(a_foo);
+ AssertExpandIs(a_foo, &dict, "a/template_foo", true);
+
+ // 3. Show that attempting to find a non-existent template gives an
+ // empty path.
+ ASSERT(cache1.FindTemplateFilename("baz").empty());
+
+ // 4. If we make a new cache, its path will be followed.
+ TemplateCache cache2;
+ cache2.SetTemplateRootDirectory(pathB);
+ ASSERT_STREQ(path_b_foo.c_str(),
+ cache2.FindTemplateFilename("template_foo").c_str());
+ const Template* b_foo = cache2.GetTemplate("template_foo", DO_NOT_STRIP);
+ ASSERT(b_foo);
+ AssertExpandIs(b_foo, &dict, "b/template_foo", true);
+
+ // 5. Neither path will work for the default cache, which has no path.
+ ASSERT(Template::template_root_directory() == kCWD);
+ ASSERT(Template::FindTemplateFilename("template_foo").empty());
+ ASSERT(!Template::GetTemplate("template_foo", DO_NOT_STRIP));
+
+ CreateOrCleanTestDir(pathA);
+ CreateOrCleanTestDir(pathB);
+ }
+
+ static void TestDelete() {
+ Template::ClearCache(); // just for exercise.
+ const string cache_key = "TestRemoveStringFromTemplateCache";
+ const string text = "<html>here today...</html>";
+ const string text2 = "<html>on disk tomorrow</html>";
+
+ TemplateDictionary dict("test");
+ TemplateCache cache1;
+
+ ASSERT(cache1.StringToTemplateCache(cache_key, text, DO_NOT_STRIP));
+ const Template* tpl = cache1.GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(tpl);
+ AssertExpandIs(tpl, &dict, text, true);
+
+ cache1.Delete(cache_key);
+ tpl = cache1.GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(!tpl);
+ tpl = cache1.GetTemplate(cache_key, STRIP_WHITESPACE);
+ ASSERT(!tpl);
+ tpl = cache1.GetTemplate(cache_key, STRIP_BLANK_LINES);
+ ASSERT(!tpl);
+
+ // Try delete on a file-based template as well.
+ string filename = StringToTemplateFile(text2);
+ tpl = cache1.GetTemplate(filename, DO_NOT_STRIP);
+ ASSERT(tpl);
+ AssertExpandIs(tpl, &dict, text2, true);
+ cache1.Delete(filename);
+ tpl = cache1.GetTemplate(filename, DO_NOT_STRIP);
+ ASSERT(tpl);
+ AssertExpandIs(tpl, &dict, text2, true);
+
+ // Try re-adding a cache key after deleting it.
+ ASSERT(cache1.StringToTemplateCache(cache_key, text, DO_NOT_STRIP));
+ tpl = cache1.GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(tpl);
+ AssertExpandIs(tpl, &dict, text, true);
+
+ // Try ClearCache while we're at it.
+ cache1.ClearCache();
+ tpl = cache1.GetTemplate(cache_key, STRIP_BLANK_LINES);
+ ASSERT(!tpl);
+
+ // Test on the Template class, which has a different function name.
+ ASSERT(StringToTemplateCache(cache_key, text, DO_NOT_STRIP));
+ tpl = Template::GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(tpl);
+ AssertExpandIs(tpl, &dict, text, true);
+
+ Template::RemoveStringFromTemplateCache(cache_key);
+ tpl = Template::GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(!tpl);
+ tpl = Template::GetTemplate(cache_key, STRIP_WHITESPACE);
+ ASSERT(!tpl);
+ tpl = Template::GetTemplate(cache_key, STRIP_BLANK_LINES);
+ ASSERT(!tpl);
+ }
+
+ static void TestTemplateCache() {
+ const string filename_a = StringToTemplateFile("Test template 1");
+ const string filename_b = StringToTemplateFile("Test template 2.");
+
+ TemplateCache cache1;
+ const Template *tpl, *tpl2;
+ ASSERT(tpl = cache1.GetTemplate(filename_a, DO_NOT_STRIP));
+
+ ASSERT(tpl2 = cache1.GetTemplate(filename_b, DO_NOT_STRIP));
+ ASSERT(tpl2 != tpl); // different filenames.
+ ASSERT(tpl2 = cache1.GetTemplate(filename_a, STRIP_BLANK_LINES));
+ ASSERT(tpl2 != tpl); // different strip.
+ ASSERT(tpl2 = cache1.GetTemplate(filename_b, STRIP_BLANK_LINES));
+ ASSERT(tpl2 != tpl); // different filenames and strip.
+ ASSERT(tpl2 = cache1.GetTemplate(filename_a, DO_NOT_STRIP));
+ ASSERT(tpl2 == tpl); // same filename and strip.
+ }
+
+ static void TestReloadAllIfChangedLazyLoad() {
+ TemplateDictionary dict("empty");
+ TemplateCache cache1;
+
+ string filename = StringToTemplateFile("{valid template}");
+ string nonexistent = StringToTemplateFile("dummy");
+ unlink(nonexistent.c_str());
+
+ const Template* tpl = cache1.GetTemplate(filename, STRIP_WHITESPACE);
+ assert(tpl);
+ const Template* tpl2 = cache1.GetTemplate(nonexistent, STRIP_WHITESPACE);
+ assert(!tpl2);
+
+ StringToFile("exists now!", nonexistent);
+ tpl2 = cache1.GetTemplate(nonexistent, STRIP_WHITESPACE);
+ ASSERT(!tpl2);
+ cache1.ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ tpl = cache1.GetTemplate(filename, STRIP_WHITESPACE); // force the reload
+ tpl2 = cache1.GetTemplate(nonexistent, STRIP_WHITESPACE);
+ ASSERT(tpl2); // file exists now
+
+ unlink(nonexistent.c_str()); // here today...
+ cache1.ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ ASSERT(cache1.GetTemplate(filename, STRIP_WHITESPACE));
+ ASSERT(!cache1.GetTemplate(nonexistent, STRIP_WHITESPACE));
+
+ StringToFile("lazarus", nonexistent);
+ StringToFile("{new template}", filename);
+ tpl = cache1.GetTemplate(filename, STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "{valid template}", true); // haven't reloaded
+ // But a different cache (say, the default) should load the new content.
+ const Template* tpl3 = Template::GetTemplate(filename, STRIP_WHITESPACE);
+ AssertExpandIs(tpl3, &dict, "{new template}", true);
+
+ cache1.ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ tpl = cache1.GetTemplate(filename, STRIP_WHITESPACE); // needed
+ AssertExpandIs(tpl, &dict, "{new template}", true);
+ tpl2 = cache1.GetTemplate(nonexistent, STRIP_WHITESPACE);
+ ASSERT(tpl2);
+ AssertExpandIs(tpl2, &dict, "lazarus", true);
+
+ // Ensure that string templates don't reload
+ const string cache_key_a = "cache key a";
+ const string text = "Test template 1";
+ const Template *str_tpl;
+ ASSERT(cache1.StringToTemplateCache(cache_key_a, text, DO_NOT_STRIP));
+ str_tpl = cache1.GetTemplate(cache_key_a, DO_NOT_STRIP);
+ AssertExpandIs(str_tpl, &dict, text, true);
+ cache1.ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ ASSERT(cache1.GetTemplate(cache_key_a, DO_NOT_STRIP) == str_tpl);
+
+ cache1.ClearCache();
+ }
+
+ static void TestReloadAllIfChangedImmediateLoad() {
+ TemplateDictionary dict("empty");
+ TemplateCache cache1;
+ TemplateCachePeer cache_peer(&cache1);
+
+ // Add templates
+ string filename1 = StringToTemplateFile("{valid template}");
+ string filename2 = StringToTemplateFile("{another valid template}");
+
+ const Template* tpl1 = cache1.GetTemplate(filename1,
+ STRIP_WHITESPACE);
+ assert(tpl1);
+ const Template* tpl2 = cache1.GetTemplate(filename2,
+ STRIP_WHITESPACE);
+ assert(tpl2);
+
+ StringToFile("{file1 contents changed}", filename1);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+
+ TemplateCachePeer::TemplateCacheKey cache_key1(filename1, STRIP_WHITESPACE);
+ ASSERT(cache_peer.TemplateIsCached(cache_key1));
+ const Template* tpl1_post_reload = cache_peer.GetTemplate(filename1,
+ STRIP_WHITESPACE);
+ ASSERT(tpl1_post_reload != tpl1);
+ // Check that cache1's tpl1 has the new contents
+ AssertExpandIs(tpl1_post_reload, &dict, "{file1 contents changed}",
+ true);
+
+ // Ensure tpl2 is unchanged
+ TemplateCachePeer::TemplateCacheKey cache_key2(filename2, STRIP_WHITESPACE);
+ ASSERT(cache_peer.TemplateIsCached(cache_key2));
+ const Template* tpl2_post_reload = cache_peer.GetTemplate(filename2,
+ STRIP_WHITESPACE);
+ ASSERT(tpl2_post_reload == tpl2);
+
+ // Test delete & re-add: delete tpl2, and reload.
+ unlink(filename2.c_str());
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ ASSERT(!cache_peer.GetTemplate(filename2, STRIP_WHITESPACE));
+ // Re-add tpl2 and ensure it reloads.
+ StringToFile("{re-add valid template contents}", filename2);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ ASSERT(cache_peer.GetTemplate(filename2, STRIP_WHITESPACE));
+
+ // Ensure that string templates don't reload
+ const string cache_key_a = "cache key a";
+ const string text = "Test template 1";
+ const Template *str_tpl;
+ ASSERT(cache1.StringToTemplateCache(cache_key_a, text, DO_NOT_STRIP));
+ str_tpl = cache1.GetTemplate(cache_key_a, DO_NOT_STRIP);
+ AssertExpandIs(str_tpl, &dict, text, true);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ ASSERT(cache1.GetTemplate(cache_key_a, DO_NOT_STRIP) == str_tpl);
+
+ cache1.ClearCache();
+ }
+
+ static void TestReloadImmediateWithDifferentSearchPaths() {
+ TemplateDictionary dict("empty");
+ TemplateCache cache1;
+ TemplateCachePeer cache_peer(&cache1);
+
+ const string pathA = PathJoin(FLAGS_test_tmpdir, "a/");
+ const string pathB = PathJoin(FLAGS_test_tmpdir, "b/");
+ CreateOrCleanTestDir(pathA);
+ CreateOrCleanTestDir(pathB);
+
+ cache1.SetTemplateRootDirectory(pathA);
+ cache1.AddAlternateTemplateRootDirectory(pathB);
+ ASSERT(cache1.template_root_directory() == pathA);
+
+ // Add b/foo
+ const string path_b_foo = PathJoin(pathB, "template_foo");
+ StringToFile("b/template_foo", path_b_foo);
+ ASSERT_STREQ(path_b_foo.c_str(),
+ cache1.FindTemplateFilename("template_foo").c_str());
+ // Add b/foo to the template cache.
+ cache1.GetTemplate("template_foo", DO_NOT_STRIP);
+
+ // Add a/foo
+ const string path_a_foo = PathJoin(pathA, "template_foo");
+ StringToFile("a/template_foo", path_a_foo);
+ ASSERT_STREQ(path_a_foo.c_str(),
+ cache1.FindTemplateFilename("template_foo").c_str());
+
+ // Now, on reload we pick up foo from the earlier search path: a/foo
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ const Template* foo_post_reload = cache_peer.GetTemplate("template_foo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(foo_post_reload, &dict, "a/template_foo",
+ true);
+
+ // Delete a/foo and reload. Now we pick up the next available foo: b/foo
+ unlink(path_a_foo.c_str());
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ foo_post_reload = cache_peer.GetTemplate("template_foo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(foo_post_reload, &dict, "b/template_foo",
+ true);
+ }
+
+ static void TestReloadLazyWithDifferentSearchPaths() {
+ // Identical test as above with but with LAZY_RELOAD
+ TemplateDictionary dict("empty");
+ TemplateCache cache1;
+ TemplateCachePeer cache_peer(&cache1);
+
+ const string pathA = PathJoin(FLAGS_test_tmpdir, "a/");
+ const string pathB = PathJoin(FLAGS_test_tmpdir, "b/");
+ CreateOrCleanTestDir(pathA);
+ CreateOrCleanTestDir(pathB);
+
+ cache1.SetTemplateRootDirectory(pathA);
+ cache1.AddAlternateTemplateRootDirectory(pathB);
+ ASSERT(cache1.template_root_directory() == pathA);
+
+ // Add b/foo
+ const string path_b_foo = PathJoin(pathB, "template_foo");
+ StringToFile("b/template_foo", path_b_foo);
+ ASSERT_STREQ(path_b_foo.c_str(),
+ cache1.FindTemplateFilename("template_foo").c_str());
+ // Add b/foo to the template cache.
+ cache1.GetTemplate("template_foo", DO_NOT_STRIP);
+
+ // Add a/foo
+ const string path_a_foo = PathJoin(pathA, "template_foo");
+ StringToFile("a/template_foo", path_a_foo);
+ ASSERT_STREQ(path_a_foo.c_str(),
+ cache1.FindTemplateFilename("template_foo").c_str());
+
+ // Now, on reload we pick up foo from the earlier search path: a/foo
+ cache1.ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ const Template* foo_post_reload = cache_peer.GetTemplate("template_foo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(foo_post_reload, &dict, "a/template_foo",
+ true);
+
+ // Delete a/foo and reload. Now we pick up the next available foo: b/foo
+ unlink(path_a_foo.c_str());
+ cache1.ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ foo_post_reload = cache_peer.GetTemplate("template_foo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(foo_post_reload, &dict, "b/template_foo",
+ true);
+ }
+
+ static void TestRefcounting() {
+ TemplateCache cache1;
+ TemplateCachePeer cache_peer(&cache1);
+ TemplateDictionary dict("dict");
+
+ // Add templates
+ string filename1 = StringToTemplateFile("{valid template}");
+ string filename2 = StringToTemplateFile("{another valid template}");
+
+ const Template* cache1_tpl1 = cache1.GetTemplate(filename1,
+ STRIP_WHITESPACE);
+ assert(cache1_tpl1);
+ const Template* cache1_tpl2 = cache1.GetTemplate(filename2,
+ STRIP_WHITESPACE);
+ assert(cache1_tpl2);
+
+ // Check refcount. It should be 2 -- one for the originalvalue
+ // when it's constructed, and one for the call to GetTemplate.
+ TemplateCachePeer::TemplateCacheKey cache_key1(filename1, STRIP_WHITESPACE);
+ ASSERT(cache_peer.Refcount(cache_key1) == 2);
+ TemplateCachePeer::TemplateCacheKey cache_key2(filename2, STRIP_WHITESPACE);
+ ASSERT(cache_peer.Refcount(cache_key2) == 2);
+
+ // Clone cache2 from cache1
+ TemplateCache* cache2 = cache1.Clone();
+ TemplateCachePeer cache_peer2(cache2);
+
+ // Check refcount was incremented. It should be the same for both caches.
+ ASSERT(cache_peer.Refcount(cache_key1) == 3);
+ ASSERT(cache_peer2.Refcount(cache_key1) == 3);
+ ASSERT(cache_peer.Refcount(cache_key2) == 3);
+ ASSERT(cache_peer2.Refcount(cache_key2) == 3);
+
+ // Check that the template ptrs in both caches are the same.
+ const Template* cache2_tpl1 = cache2->GetTemplate(filename1,
+ STRIP_WHITESPACE);
+ const Template* cache2_tpl2 = cache2->GetTemplate(filename2,
+ STRIP_WHITESPACE);
+ ASSERT(cache2_tpl1 == cache1_tpl1);
+ ASSERT(cache2_tpl2 == cache1_tpl2);
+
+ // GetTemplate should have augmented the refcount.
+ ASSERT(cache_peer.Refcount(cache_key1) == 4);
+ ASSERT(cache_peer2.Refcount(cache_key1) == 4);
+ ASSERT(cache_peer.Refcount(cache_key2) == 4);
+ ASSERT(cache_peer2.Refcount(cache_key2) == 4);
+
+ // Change tpl1 file contents and reload.
+ StringToFile("{file1 contents changed}", filename1);
+ cache2->ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ // Since the template will be reloaded into a new instance,
+ // GetTemplate will return new pointers. The older template
+ // pointer was moved to the freelist.
+ const Template* cache2_tpl1_post_reload = cache2->GetTemplate(
+ filename1, STRIP_WHITESPACE);
+ ASSERT(cache2_tpl1_post_reload != cache2_tpl1);
+ // Check that cache1's tpl1 has the new contents
+ AssertExpandIs(cache2_tpl1_post_reload, &dict, "{file1 contents changed}",
+ true);
+
+ // Ensure tpl2 is unchanged
+ const Template* cache2_tpl2_post_reload = cache2->GetTemplate(
+ filename2, STRIP_WHITESPACE);
+ ASSERT(cache2_tpl2_post_reload == cache2_tpl2);
+
+ // Now key1 points to different templates in cache1 and cache2.
+ // cache1's version should have a refcount of 3 (was 4, went down
+ // by 1 when cache2 dropped its reference to it). cache2's
+ // version should be 2 (one for the new file, 1 for the call to
+ // GetTemplate() that followed it), while key2 should have a
+ // refcount of 5 in both caches (due to the new call, above, to
+ // GetTemplate()).
+ ASSERT(cache_peer.Refcount(cache_key1) == 3);
+ ASSERT(cache_peer2.Refcount(cache_key1) == 2);
+ ASSERT(cache_peer.Refcount(cache_key2) == 5);
+ ASSERT(cache_peer2.Refcount(cache_key2) == 5);
+
+ const int old_delete_count = cache_peer.NumTotalTemplateDeletes();
+
+ // Clear up the cache2's freelist, this should drop all refcounts,
+ // due to the calls cache_peer2 made to
+ // GetTemplate(the-old-filename1), GetTemplate(the-new-filename1),
+ // and GetTemplate(filename2) (twice!)
+ cache_peer2.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer.Refcount(cache_key1) == 2);
+ ASSERT(cache_peer2.Refcount(cache_key1) == 1);
+ ASSERT(cache_peer.Refcount(cache_key2) == 3);
+ ASSERT(cache_peer2.Refcount(cache_key2) == 3);
+
+ // Make sure that deleting from the cache causes deletion.
+ // ClearCache() on peer1 should finally get rid of the old filename1.
+ cache_peer.ClearCache();
+ ASSERT(cache_peer.NumTotalTemplateDeletes() == old_delete_count + 1);
+ cache_peer2.ClearCache();
+ // Delete-count should go up by 2 as both the new tpl1, and tpl2, go away.
+ ASSERT(cache_peer.NumTotalTemplateDeletes() == old_delete_count + 3);
+
+ delete cache2;
+ }
+
+ static void TestDoneWithGetTemplatePtrs() {
+ TemplateCache cache1;
+ TemplateCachePeer cache_peer1(&cache1);
+ TemplateDictionary dict("dict");
+
+ // Add templates
+ string fname = StringToTemplateFile("{valid template}");
+ TemplateCachePeer::TemplateCacheKey cache_key(fname, STRIP_WHITESPACE);
+ string out;
+
+ int old_delete_count = cache_peer1.NumTotalTemplateDeletes();
+
+ // OK, let's get the templates in the cache.
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ // This should not have changed the delete-count.
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ // And the refcount should be 1.
+ ASSERT(cache_peer1.Refcount(cache_key) == 1);
+ // Same holds if we expand again.
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ ASSERT(cache_peer1.Refcount(cache_key) == 1);
+
+ // Now we delete from the cache. Should up the delete_count.
+ ASSERT(cache1.Delete(fname));
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+
+ // Calling DoneWithGetTemplatePtrs() should be a noop -- we
+ // haven't called GetTemplate() yet.
+ cache1.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+
+ // Now do the same thing, but throw in a GetTemplate(). Now
+ // DoneWithGetTemplatePtrs() should still cause a delete, but only
+ // after a call to Delete() deletes the cache's refcount too.
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ cache1.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ ASSERT(cache1.Delete(fname));
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ cache1.ClearCache();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+
+ // Now load in a replacement. The loading itself should cause a
+ // delete (no GetTemplate calls, so no need to involve the freelist).
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ StringToFile("{file1 contents changed}", fname);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ // DoneWithGetTemplatePtrs() should just be a noop.
+ cache1.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ // Delete the new version of fname too!
+ cache1.Delete(fname);
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+
+ // Now load in a replacement, but having done a GetTemplate() first.
+ // We need DoneWithGetTemplatePtrs() to delete, in this case.
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ ASSERT(cache_peer1.Refcount(cache_key) == 2);
+ StringToFile("{file1 contents changed}", fname);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ cache1.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ // Delete the new version of fname too!
+ cache1.Delete(fname);
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+
+ // Add a Clone() into the mix. Now Delete() calls, even from both
+ // caches, won't up the delete-count until we DoneWithGetTemplatePtrs()
+ // -- but only from the cache that called GetTemplate().
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ ASSERT(cache_peer1.Refcount(cache_key) == 2);
+ {
+ TemplateCache* cache2 = cache1.Clone();
+ TemplateCachePeer cache_peer2(cache2);
+ ASSERT(cache_peer1.Refcount(cache_key) == 3);
+ ASSERT(cache_peer2.Refcount(cache_key) == 3);
+ // Do all sorts of Delete()s.
+ StringToFile("{file1 contents changed}", fname);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ ASSERT(cache_peer1.Refcount(cache_key) == 1); // the new file
+ ASSERT(cache_peer2.Refcount(cache_key) == 2); // the old file
+ cache2->ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ // Each cache has a different copy of the new file.
+ ASSERT(cache_peer1.Refcount(cache_key) == 1); // the new file
+ ASSERT(cache_peer2.Refcount(cache_key) == 1); // the new file
+ ASSERT(cache1.Delete(fname)); // should delete the new file
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ ASSERT(cache2->Delete(fname));
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ cache2->DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ cache1.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ cache1.ClearCache();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ delete cache2;
+ }
+
+ // If we call DoneWithGetTemplatePtrs() while a clone points to the
+ // template, it won't delete the template yet.
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ {
+ TemplateCache* cache2 = cache1.Clone();
+ TemplateCachePeer cache_peer2(cache2);
+ StringToFile("{file1 contents changed}", fname);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ delete cache2;
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ }
+ cache1.ClearCache();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+
+ // If we throw an explicit GetTemplate() in, we still need
+ // DoneWithGetTemplatePtrs().
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ {
+ TemplateCache* cache2 = cache1.Clone();
+ TemplateCachePeer cache_peer2(cache2);
+ StringToFile("{file1 contents changed}", fname);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ cache1.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ delete cache2;
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ }
+ cache1.ClearCache();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+
+ // Multiple GetTemplate()s should still all be cleared by
+ // DoneWithGetTemplatePtrs().
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ ASSERT(cache_peer1.Refcount(cache_key) == 3);
+ StringToFile("{file1 contents changed}", fname);
+ cache1.ReloadAllIfChanged(TemplateCache::IMMEDIATE_RELOAD);
+ cache1.DoneWithGetTemplatePtrs();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ cache1.ClearCache();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+
+ // Calling ClearCache() deletes old templates too -- we don't even
+ // need to change the content.
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ cache1.GetTemplate(fname, STRIP_WHITESPACE);
+ cache1.ClearCache();
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+
+ // So does deleting the cache object.
+ ASSERT(cache1.ExpandWithData(fname, STRIP_WHITESPACE, &dict, NULL, &out));
+ {
+ TemplateCache* cache2 = cache1.Clone();
+ TemplateCachePeer cache_peer2(cache2);
+ ASSERT(cache_peer1.Refcount(cache_key) == 2);
+ cache2->GetTemplate(fname, STRIP_WHITESPACE);
+ ASSERT(cache_peer1.Refcount(cache_key) == 3);
+ ASSERT(cache_peer2.Refcount(cache_key) == 3);
+ ASSERT(cache1.Delete(fname));
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == old_delete_count);
+ ASSERT(cache_peer2.Refcount(cache_key) == 2);
+ delete cache2;
+ }
+ ASSERT(cache_peer1.NumTotalTemplateDeletes() == ++old_delete_count);
+ }
+
+ static void TestCloneStringTemplates() {
+ TemplateCache cache1;
+
+ // Create & insert a string template
+ const string cache_key_a = "cache key a";
+ const string text = "Test template 1";
+ TemplateDictionary empty_dict("dict");
+
+ ASSERT(cache1.StringToTemplateCache(cache_key_a, text, DO_NOT_STRIP));
+
+ // Clone cache2 from cache1
+ TemplateCache* cache2 = cache1.Clone();
+
+ // Check that the string template was copied into cache2
+ const Template* cache2_tpl = cache2->GetTemplate(cache_key_a,
+ DO_NOT_STRIP);
+ ASSERT(cache2_tpl);
+ AssertExpandIs(cache2_tpl, &empty_dict, text, true);
+
+ delete cache2;
+ }
+
+ static void TestInclude() {
+ TemplateCache cache;
+ string incname = StringToTemplateFile("include & print file\n");
+ string tpl_file = StringToTemplateFile("hi {{>INC:h}} bar\n");
+ const Template* tpl = cache.GetTemplate(tpl_file, DO_NOT_STRIP);
+ ASSERT(tpl);
+
+ TemplateDictionary dict("dict");
+ AssertExpandWithCacheIs(&cache, tpl_file, DO_NOT_STRIP, &dict, NULL,
+ "hi bar\n", true);
+ dict.AddIncludeDictionary("INC")->SetFilename(incname);
+ AssertExpandWithCacheIs(&cache, tpl_file, DO_NOT_STRIP, &dict, NULL,
+ "hi include & print file bar\n",
+ true);
+ }
+
+ // Make sure we don't deadlock when a template includes itself.
+ // This also tests we handle recursive indentation properly.
+ static void TestRecursiveInclude() {
+ TemplateCache cache;
+ string incname = StringToTemplateFile("hi {{>INC}} bar\n {{>INC}}!");
+ const Template* tpl = cache.GetTemplate(incname, DO_NOT_STRIP);
+ ASSERT(tpl);
+ TemplateDictionary dict("dict");
+ dict.AddIncludeDictionary("INC")->SetFilename(incname);
+ // Note the last line is indented 4 spaces instead of 2. This is
+ // because the last sub-include is indented.
+ AssertExpandWithCacheIs(&cache, incname, DO_NOT_STRIP, &dict, NULL,
+ "hi hi bar\n ! bar\n hi bar\n !!",
+ true);
+ }
+
+ static void TestStringTemplateInclude() {
+ const string cache_key = "TestStringTemplateInclude";
+ const string cache_key_inc = "TestStringTemplateInclude-inc";
+ const string text = "<html>{{>INC}}</html>";
+ const string text_inc = "<div>\n<p>\nUser {{USER}}\n</div>";
+
+ TemplateCache cache;
+ ASSERT(cache.StringToTemplateCache(cache_key, text, DO_NOT_STRIP));
+ ASSERT(cache.StringToTemplateCache(cache_key_inc, text_inc, DO_NOT_STRIP));
+
+ const Template *tpl = cache.GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(tpl);
+
+ TemplateDictionary dict("dict");
+ TemplateDictionary* sub_dict = dict.AddIncludeDictionary("INC");
+ sub_dict->SetFilename(cache_key_inc);
+
+ sub_dict->SetValue("USER", "John<>Doe");
+ string expected = "<html><div>\n<p>\nUser John<>Doe\n</div></html>";
+ AssertExpandWithCacheIs(&cache, cache_key, DO_NOT_STRIP, &dict, NULL,
+ expected, true);
+ }
+
+ static void TestTemplateString() {
+ TemplateCache cache;
+ ASSERT(cache.StringToTemplateCache(kKey, kContent, DO_NOT_STRIP));
+ const Template *tpl = cache.GetTemplate(kKey, DO_NOT_STRIP);
+ ASSERT(tpl);
+
+ TemplateDictionary dict("dict");
+ AssertExpandWithCacheIs(&cache, "MY_KEY", DO_NOT_STRIP, &dict, NULL,
+ "content", true);
+
+ // Try retrieving with a char* rather than a TemplateString*.
+ tpl = cache.GetTemplate("MY_KEY", DO_NOT_STRIP);
+ ASSERT(tpl);
+ AssertExpandWithCacheIs(&cache, "MY_KEY", DO_NOT_STRIP, &dict, NULL,
+ "content", true);
+
+ // Delete with a char* rather than a TemplateString*.
+ cache.Delete("MY_KEY");
+ tpl = cache.GetTemplate("MY_KEY", DO_NOT_STRIP);
+ ASSERT(!tpl);
+
+ ASSERT(cache.StringToTemplateCache("MY_KEY", "content", DO_NOT_STRIP));
+ tpl = cache.GetTemplate(kKey, DO_NOT_STRIP);
+ ASSERT(tpl);
+ cache.Delete(kKey);
+ tpl = cache.GetTemplate("MY_KEY", DO_NOT_STRIP);
+ ASSERT(!tpl);
+ }
+
+ static void TestFreeze() {
+ TemplateCache cache;
+ TemplateDictionary dict("dict");
+
+ // Load some templates
+ string filename1 = StringToTemplateFile("{valid template}");
+ string filename2 = StringToTemplateFile("hi {{>INC:h}} bar\n");
+
+ const Template* cache_tpl1 = cache.GetTemplate(filename1, STRIP_WHITESPACE);
+ assert(cache_tpl1);
+ AssertExpandIs(cache_tpl1, &dict, "{valid template}", true);
+ const Template* cache_tpl2 = cache.GetTemplate(filename2, DO_NOT_STRIP);
+ assert(cache_tpl2);
+ static_cast<void>(cache_tpl2); // avoid unused var warning in opt mode
+ AssertExpandWithCacheIs(&cache, filename2, DO_NOT_STRIP, &dict, NULL,
+ "hi bar\n", true);
+
+ // Set the root directory
+ const string pathA = PathJoin(FLAGS_test_tmpdir, "a/");
+ CreateOrCleanTestDir(pathA);
+ cache.SetTemplateRootDirectory(pathA);
+ ASSERT(cache.template_root_directory() == pathA);
+
+ // Freeze the cache now, and test its impact.
+ cache.Freeze();
+
+ // 1. Loading new templates fails.
+ string filename3 = StringToTemplateFile("{yet another valid template}");
+ const Template* cache_tpl3 = cache.GetTemplate(filename3, STRIP_WHITESPACE);
+ assert(!cache_tpl3);
+ static_cast<void>(cache_tpl3); // avoid unused var warning in opt mode
+
+ // 2. Reloading existing templates fails.
+ StringToFile("{file1 contents changed}", filename1);
+ cache.ReloadAllIfChanged(TemplateCache::LAZY_RELOAD);
+ const Template* cache_tpl1_post_reload = cache.GetTemplate(
+ filename1, STRIP_WHITESPACE);
+ ASSERT(cache_tpl1_post_reload == cache_tpl1);
+ // Check that cache's tpl1 has the same old contents
+ AssertExpandIs(cache_tpl1_post_reload, &dict, "{valid template}",
+ true);
+ // 3. Cannot delete from a frozen cache.
+ cache.Delete(filename1);
+ ASSERT(cache.GetTemplate(filename1, STRIP_WHITESPACE));
+
+ // 4. Expand won't load an included template on-demand.
+ string incname = StringToTemplateFile("include & print file\n");
+ dict.AddIncludeDictionary("INC")->SetFilename(incname);
+ AssertExpandWithCacheIs(&cache, filename2, DO_NOT_STRIP, &dict, NULL,
+ "hi bar\n", false);
+
+ // 5. Cannot change template root directory.
+ const string pathB = PathJoin(FLAGS_test_tmpdir, "b/");
+ CreateOrCleanTestDir(pathB);
+ cache.SetTemplateRootDirectory(pathB);
+ ASSERT(cache.template_root_directory() == pathA); // Still the old path
+
+ CreateOrCleanTestDir(pathA);
+ CreateOrCleanTestDir(pathB);
+ }
+};
+
+
+int main(int argc, char** argv) {
+
+ CreateOrCleanTestDirAndSetAsTmpdir(FLAGS_test_tmpdir);
+
+ TemplateCacheUnittest::TestGetTemplate();
+ TemplateCacheUnittest::TestLoadTemplate();
+ TemplateCacheUnittest::TestStringGetTemplate();
+ TemplateCacheUnittest::TestStringToTemplateCacheWithStrip();
+ TemplateCacheUnittest::TestExpandNoLoad();
+ TemplateCacheUnittest::TestTemplateSearchPath();
+ TemplateCacheUnittest::TestDelete();
+ TemplateCacheUnittest::TestTemplateCache();
+ TemplateCacheUnittest::TestReloadAllIfChangedLazyLoad();
+ TemplateCacheUnittest::TestReloadAllIfChangedImmediateLoad();
+ TemplateCacheUnittest::TestReloadImmediateWithDifferentSearchPaths();
+ TemplateCacheUnittest::TestReloadLazyWithDifferentSearchPaths();
+ TemplateCacheUnittest::TestRefcounting();
+ TemplateCacheUnittest::TestDoneWithGetTemplatePtrs();
+ TemplateCacheUnittest::TestCloneStringTemplates();
+ TemplateCacheUnittest::TestInclude();
+ TemplateCacheUnittest::TestRecursiveInclude();
+ TemplateCacheUnittest::TestStringTemplateInclude();
+ TemplateCacheUnittest::TestTemplateString();
+ TemplateCacheUnittest::TestFreeze();
+
+ printf("DONE\n");
+ return 0;
+}
diff --git a/src/tests/template_dictionary_unittest.cc b/src/tests/template_dictionary_unittest.cc
new file mode 100644
index 0000000..f524a21
--- /dev/null
+++ b/src/tests/template_dictionary_unittest.cc
@@ -0,0 +1,1012 @@
+// Copyright (c) 2005, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// This code is written to not use the google testing framework
+// as much as possible, to make it easier to opensource.
+
+#include "config_for_unittests.h"
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <vector>
+#include "base/arena.h"
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_modifiers.h>
+#include <ctemplate/per_expand_data.h>
+#include "tests/template_test_util.h"
+#include "base/util.h"
+TEST_INIT // defines RUN_ALL_TESTS
+
+using std::string;
+using std::vector;
+using GOOGLE_NAMESPACE::UnsafeArena;
+using GOOGLE_NAMESPACE::DO_NOT_STRIP;
+using GOOGLE_NAMESPACE::ExpandEmitter;
+using GOOGLE_NAMESPACE::PerExpandData;
+using GOOGLE_NAMESPACE::StaticTemplateString;
+using GOOGLE_NAMESPACE::StringToTemplateCache;
+using GOOGLE_NAMESPACE::TemplateDictionary;
+using GOOGLE_NAMESPACE::TemplateDictionaryInterface;
+using GOOGLE_NAMESPACE::TemplateDictionaryPeer;
+using GOOGLE_NAMESPACE::TemplateString;
+
+#define ASSERT_STRSTR(text, substr) do { \
+ if (!strstr((text), (substr))) { \
+ printf("%s: %d: ASSERT FAILED: '%s' not in '%s'\n", \
+ __FILE__, __LINE__, (substr), (text)); \
+ assert(strstr((text), (substr))); \
+ exit(1); \
+ } \
+} while (0)
+
+
+// test escape-functor that replaces all input with "foo"
+class FooEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
+ public:
+ void Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* outbuf, const string& arg) const {
+ assert(arg.empty()); // we don't take an argument
+ outbuf->Emit("foo");
+ }
+};
+
+// test escape-functor that replaces all input with ""
+class NullEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
+ public:
+ void Modify(const char* in, size_t inlen,
+ const PerExpandData*,
+ ExpandEmitter* outbuf, const string& arg) const {
+ assert(arg.empty()); // we don't take an argument
+ }
+};
+
+// first does javascript-escaping, then html-escaping
+class DoubleEscaper : public GOOGLE_NAMESPACE::TemplateModifier {
+ public:
+ void Modify(const char* in, size_t inlen,
+ const PerExpandData* data,
+ ExpandEmitter* outbuf, const string& arg) const {
+ assert(arg.empty()); // we don't take an argument
+ string tmp = GOOGLE_NAMESPACE::javascript_escape(in, inlen);
+ GOOGLE_NAMESPACE::html_escape.Modify(tmp.data(), tmp.size(), data, outbuf, "");
+ }
+};
+
+namespace {
+
+static const TemplateDictionary* GetSectionDict(
+ const TemplateDictionary* d, const char* name, int i) {
+ TemplateDictionaryPeer peer(d);
+ vector<const TemplateDictionary*> dicts;
+ EXPECT_GE(peer.GetSectionDictionaries(name, &dicts), i);
+ return dicts[i];
+}
+static const TemplateDictionary* GetIncludeDict(
+ const TemplateDictionary* d, const char* name, int i) {
+ TemplateDictionaryPeer peer(d);
+ vector<const TemplateDictionary*> dicts;
+ EXPECT_GE(peer.GetIncludeDictionaries(name, &dicts), i);
+ return dicts[i];
+}
+
+static void SetUp() {
+ TemplateDictionary::SetGlobalValue("GLOBAL", "top");
+}
+
+TEST(TemplateDictionary, SetValueAndTemplateStringAndArena) {
+ // Try both with the arena, and without.
+ UnsafeArena arena(100);
+ // We run the test with arena twice to double-check we don't ever delete it
+ UnsafeArena* arenas[] = {&arena, &arena, NULL};
+ for (int i = 0; i < sizeof(arenas)/sizeof(*arenas); ++i) {
+ TemplateDictionary dict(string("test_arena") + char('0'+i), arenas[i]);
+
+ // Test copying char*s, strings, and explicit TemplateStrings
+ dict.SetValue("FOO", "foo");
+ dict.SetValue(string("FOO2"), TemplateString("foo2andmore", 4));
+ dict["FOO3"] = "foo3";
+ dict[string("FOO4")] = TemplateString("foo4andmore", 4);
+ dict["FOO5"] = string("Olaf");
+ dict["FOO6"] = 6;
+ dict["FOO7"] = long(7);
+
+ TemplateDictionaryPeer peer(&dict);
+ // verify what happened
+ EXPECT_TRUE(peer.ValueIs("FOO", "foo"));
+ EXPECT_TRUE(peer.ValueIs("FOO2", "foo2"));
+ string dump;
+ dict.DumpToString(&dump);
+ char expected[256];
+ snprintf(expected, sizeof(expected),
+ ("global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ "};\n"
+ "dictionary 'test_arena%d' {\n"
+ " FOO: >foo<\n"
+ " FOO2: >foo2<\n"
+ " FOO3: >foo3<\n"
+ " FOO4: >foo4<\n"
+ " FOO5: >Olaf<\n"
+ " FOO6: >6<\n"
+ " FOO7: >7<\n"
+ "}\n"), i);
+ EXPECT_STREQ(dump.c_str(), expected);
+ }
+}
+
+TEST(TemplateDictionary, SetValueWithoutCopy) {
+ UnsafeArena arena(100);
+ TemplateDictionary dict("Test arena", &arena);
+
+ char value[32];
+ snprintf(value, sizeof(value), "%s", "value");
+
+ const void* const ptr = arena.Alloc(0);
+ dict.SetValueWithoutCopy("key", value);
+ // We shouldn't have copied the value string.
+ EXPECT_EQ(ptr, arena.Alloc(0));
+
+ TemplateDictionaryPeer peer(&dict);
+ EXPECT_TRUE(peer.ValueIs("key", "value"));
+ // If our content changes, so does what's in the dictionary -- but
+ // only the contents of the buffer, not its length!
+ snprintf(value, sizeof(value), "%s", "not_value");
+ EXPECT_TRUE(peer.ValueIs("key", "not_v")); // sizeof("not_v") == sizeof("value")
+}
+
+TEST(TemplateDictionary, SetIntValue) {
+ TemplateDictionary dict("test_SetIntValue", NULL);
+ TemplateDictionaryPeer peer(&dict);
+
+ dict.SetIntValue("INT", 5);
+ // - is an illegal varname in templates, but perfectly fine in dicts
+ dict.SetIntValue("-INT", -5);
+
+ EXPECT_TRUE(peer.ValueIs("INT", "5"));
+ EXPECT_TRUE(peer.ValueIs("-INT", "-5"));
+ string dump;
+ dict.DumpToString(&dump);
+ ASSERT_STRSTR(dump.c_str(), "\n INT: >5<\n");
+ ASSERT_STRSTR(dump.c_str(), "\n -INT: >-5<\n");
+
+}
+
+TEST(TemplateDictionary, SetFormattedValue) {
+ TemplateDictionary dict("test_SetFormattedValue", NULL);
+ TemplateDictionaryPeer peer(&dict);
+
+ dict.SetFormattedValue(TemplateString("PRINTF", sizeof("PRINTF")-1),
+ "%s test %04d", "template test", 1);
+
+ EXPECT_TRUE(peer.ValueIs("PRINTF", "template test test 0001"));
+ string dump;
+ dict.DumpToString(&dump);
+ ASSERT_STRSTR(dump.c_str(), "\n PRINTF: >template test test 0001<\n");
+
+ // Now test something of size 4k or so, where we can't use scratchbuf
+ dict.SetFormattedValue(TemplateString("PRINTF", sizeof("PRINTF")-1),
+ "%s test %04444d", "template test", 2);
+ string expected("template test test ");
+ for (int i = 0; i < 4443; ++i)
+ expected.append("0");
+ expected.append("2");
+ EXPECT_TRUE(peer.ValueIs("PRINTF", expected));
+ string dump2;
+ dict.DumpToString(&dump2);
+ expected = string("\n PRINTF: >") + expected + string("<\n");
+ ASSERT_STRSTR(dump2.c_str(), expected.c_str());
+}
+
+TEST(TemplateDictionary, SetEscapedValue) {
+ TemplateDictionary dict("test_SetEscapedValue", NULL);
+ TemplateDictionaryPeer peer(&dict);
+
+ dict.SetEscapedValue("hardest HTML",
+ "<A HREF='foo'\nid=\"bar\t\t&&\vbaz\">",
+ GOOGLE_NAMESPACE::html_escape);
+ dict.SetEscapedValue("hardest JS",
+ ("f = 'foo';\r\n\tprint \"\\&foo = \b\", \"foo\""),
+ GOOGLE_NAMESPACE::javascript_escape);
+ dict.SetEscapedValue("query escape 0", "",
+ GOOGLE_NAMESPACE::url_query_escape);
+
+ EXPECT_TRUE(peer.ValueIs("hardest HTML",
+ "<A HREF='foo' id="bar && "
+ "baz">"));
+ EXPECT_TRUE(peer.ValueIs("hardest JS",
+ "f \\x3d \\x27foo\\x27;\\r\\n\\tprint \\x22\\\\\\x26"
+ "foo \\x3d \\b\\x22, \\x22foo\\x22"));
+ EXPECT_TRUE(peer.ValueIs("query escape 0", ""));
+
+ // Test using hand-made modifiers.
+ FooEscaper foo_escaper;
+ dict.SetEscapedValue("easy foo", "hello there!",
+ FooEscaper());
+ dict.SetEscapedValue("harder foo", "so much to say\nso many foos",
+ foo_escaper);
+ DoubleEscaper double_escaper;
+ dict.SetEscapedValue("easy double", "doo",
+ double_escaper);
+ dict.SetEscapedValue("harder double", "<A HREF='foo'>\n",
+ DoubleEscaper());
+ dict.SetEscapedValue("hardest double",
+ "print \"<A HREF='foo'>\";\r\n\\1;",
+ double_escaper);
+
+ EXPECT_TRUE(peer.ValueIs("easy foo", "foo"));
+ EXPECT_TRUE(peer.ValueIs("harder foo", "foo"));
+ EXPECT_TRUE(peer.ValueIs("easy double", "doo"));
+ EXPECT_TRUE(peer.ValueIs("harder double",
+ "\\x3cA HREF\\x3d\\x27foo\\x27\\x3e\\n"));
+ EXPECT_TRUE(peer.ValueIs("hardest double",
+ "print \\x22\\x3cA HREF\\x3d\\x27foo\\x27\\x3e\\x22;"
+ "\\r\\n\\\\1;"));
+}
+
+TEST(TemplateDictionary, SetEscapedFormattedValue) {
+ TemplateDictionary dict("test_SetEscapedFormattedValue", NULL);
+ TemplateDictionaryPeer peer(&dict);
+
+ dict.SetEscapedFormattedValue("HTML", GOOGLE_NAMESPACE::html_escape,
+ "This is <%s> #%.4f", "a & b", 1.0/3);
+ dict.SetEscapedFormattedValue("PRE", GOOGLE_NAMESPACE::pre_escape,
+ "if %s x = %.4f;", "(a < 1 && b > 2)\n\t", 1.0/3);
+ dict.SetEscapedFormattedValue("URL", GOOGLE_NAMESPACE::url_query_escape,
+ "pageviews-%s", "r?egex");
+ dict.SetEscapedFormattedValue("XML", GOOGLE_NAMESPACE::xml_escape,
+ "This&is%s -- ok?", "just&");
+
+ EXPECT_TRUE(peer.ValueIs("HTML",
+ "This is <a & b> #0.3333"));
+ EXPECT_TRUE(peer.ValueIs("PRE",
+ "if (a < 1 && b > 2)\n\t x = 0.3333;"));
+ EXPECT_TRUE(peer.ValueIs("URL", "pageviews-r%3Fegex"));
+
+ EXPECT_TRUE(peer.ValueIs("XML", "This&isjust& -- ok?"));
+}
+
+static const StaticTemplateString kSectName =
+ STS_INIT(kSectName, "test_SetAddSectionDictionary");
+
+TEST(TemplateDictionary, AddSectionDictionary) {
+ // For fun, we'll make this constructor take a static template string.
+ TemplateDictionary dict(kSectName, NULL);
+ TemplateDictionaryPeer peer(&dict);
+ dict.SetValue("TOPLEVEL", "foo");
+ dict.SetValue("TOPLEVEL2", "foo2");
+
+ TemplateDictionary* subdict_1a = dict.AddSectionDictionary("section1");
+ // This is the same dict, but name is specified a different way.
+ TemplateDictionary* subdict_1b = dict.AddSectionDictionary(
+ TemplateString("section1__ignored__", strlen("section1")));
+ TemplateDictionaryPeer subdict_1a_peer(subdict_1a);
+ TemplateDictionaryPeer subdict_1b_peer(subdict_1b);
+ subdict_1a->SetValue("SUBLEVEL", "subfoo");
+ subdict_1b->SetValue("SUBLEVEL", "subbar");
+
+ TemplateDictionary* subdict_2 = dict.AddSectionDictionary("section2");
+ TemplateDictionaryPeer subdict_2_peer(subdict_2);
+ subdict_2->SetValue("TOPLEVEL", "bar"); // overriding top dict
+ TemplateDictionary* subdict_2_1 = subdict_2->AddSectionDictionary("sub");
+ TemplateDictionaryPeer subdict_2_1_peer(subdict_2_1);
+ subdict_2_1->SetIntValue("GLOBAL", 21); // overrides value in setUp()
+
+ // Verify that all variables that should be look-up-able are, and that
+ // we have proper precedence.
+ EXPECT_TRUE(peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(peer.ValueIs("TOPLEVEL", "foo"));
+ EXPECT_TRUE(peer.ValueIs("TOPLEVEL2", "foo2"));
+ EXPECT_TRUE(peer.ValueIs("SUBLEVEL", ""));
+
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("TOPLEVEL", "foo"));
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("TOPLEVEL2", "foo2"));
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("SUBLEVEL", "subfoo"));
+
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("TOPLEVEL", "foo"));
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("TOPLEVEL2", "foo2"));
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("SUBLEVEL", "subbar"));
+
+ EXPECT_TRUE(subdict_2_peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(subdict_2_peer.ValueIs("TOPLEVEL", "bar"));
+ EXPECT_TRUE(subdict_2_peer.ValueIs("TOPLEVEL2", "foo2"));
+ EXPECT_TRUE(subdict_2_peer.ValueIs("SUBLEVEL", ""));
+
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("GLOBAL", "21"));
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("TOPLEVEL", "bar"));
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("TOPLEVEL2", "foo2"));
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("SUBLEVEL", ""));
+
+ // Verify that everyone knows about its sub-dictionaries, and also
+ // that these go 'up the chain' on lookup failure
+ EXPECT_FALSE(peer.IsHiddenSection("section1"));
+ EXPECT_FALSE(peer.IsHiddenSection("section2"));
+ EXPECT_TRUE(peer.IsHiddenSection("section3"));
+ EXPECT_TRUE(peer.IsHiddenSection("sub"));
+ EXPECT_FALSE(subdict_1a_peer.IsHiddenSection("section1"));
+ EXPECT_TRUE(subdict_1a_peer.IsHiddenSection("sub"));
+ EXPECT_FALSE(subdict_2_peer.IsHiddenSection("sub"));
+ EXPECT_FALSE(subdict_2_1_peer.IsHiddenSection("sub"));
+
+ // We should get the dictionary-lengths right as well
+ vector<const TemplateDictionary*> dummy;
+ EXPECT_EQ(2, peer.GetSectionDictionaries("section1", &dummy));
+ EXPECT_EQ(1, peer.GetSectionDictionaries("section2", &dummy));
+ EXPECT_EQ(1, subdict_2_peer.GetSectionDictionaries("sub", &dummy));
+ // Test some of the values
+ EXPECT_TRUE(TemplateDictionaryPeer(GetSectionDict(&dict, "section1", 0))
+ .ValueIs("SUBLEVEL", "subfoo"));
+ EXPECT_TRUE(TemplateDictionaryPeer(GetSectionDict(&dict, "section1", 1))
+ .ValueIs("SUBLEVEL", "subbar"));
+ EXPECT_TRUE(TemplateDictionaryPeer(GetSectionDict(&dict, "section2", 0))
+ .ValueIs("TOPLEVEL", "bar"));
+ EXPECT_TRUE(TemplateDictionaryPeer(
+ GetSectionDict(GetSectionDict(&dict, "section2", 0), "sub", 0))
+ .ValueIs("TOPLEVEL", "bar"));
+ EXPECT_TRUE(TemplateDictionaryPeer(
+ GetSectionDict(GetSectionDict(&dict, "section2", 0), "sub", 0))
+ .ValueIs("GLOBAL", "21"));
+
+ // Make sure we're making descriptive names
+ EXPECT_STREQ(dict.name().c_str(),
+ "test_SetAddSectionDictionary");
+ EXPECT_STREQ(subdict_1a->name().c_str(),
+ "test_SetAddSectionDictionary/section1#1");
+ EXPECT_STREQ(subdict_1b->name().c_str(),
+ "test_SetAddSectionDictionary/section1#2");
+ EXPECT_STREQ(subdict_2->name().c_str(),
+ "test_SetAddSectionDictionary/section2#1");
+ EXPECT_STREQ(subdict_2_1->name().c_str(),
+ "test_SetAddSectionDictionary/section2#1/sub#1");
+
+ // Finally, we can test the whole kit and kaboodle
+ string dump;
+ dict.DumpToString(&dump);
+ const char* const expected =
+ ("global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ "};\n"
+ "dictionary 'test_SetAddSectionDictionary' {\n"
+ " TOPLEVEL: >foo<\n"
+ " TOPLEVEL2: >foo2<\n"
+ " section section1 (dict 1 of 2) -->\n"
+ " dictionary 'test_SetAddSectionDictionary/section1#1' {\n"
+ " SUBLEVEL: >subfoo<\n"
+ " }\n"
+ " section section1 (dict 2 of 2) -->\n"
+ " dictionary 'test_SetAddSectionDictionary/section1#2' {\n"
+ " SUBLEVEL: >subbar<\n"
+ " }\n"
+ " section section2 (dict 1 of 1) -->\n"
+ " dictionary 'test_SetAddSectionDictionary/section2#1' {\n"
+ " TOPLEVEL: >bar<\n"
+ " section sub (dict 1 of 1) -->\n"
+ " dictionary 'test_SetAddSectionDictionary/section2#1/sub#1' {\n"
+ " GLOBAL: >21<\n"
+ " }\n"
+ " }\n"
+ "}\n");
+ EXPECT_STREQ(dump.c_str(), expected);
+}
+
+TEST(TemplateDictionary, ShowSection) {
+ TemplateDictionary dict("test_SetShowSection", NULL);
+ // Let's say what filename dict is associated with
+ dict.SetFilename("bigmamainclude!.tpl");
+ dict.SetValue("TOPLEVEL", "foo");
+ dict.SetValue("TOPLEVEL2", "foo2");
+ dict.ShowSection("section1");
+ dict.ShowSection("section2");
+ // Test calling ShowSection twice on the same section
+ dict.ShowSection("section2");
+ // Test that ShowSection is a no-op if called after AddSectionDictionary()
+ TemplateDictionary* subdict = dict.AddSectionDictionary("section3");
+ TemplateDictionaryPeer subdict_peer(subdict);
+ subdict->SetValue("TOPLEVEL", "bar");
+ dict.ShowSection("section3");
+
+ EXPECT_TRUE(subdict_peer.ValueIs("TOPLEVEL", "bar"));
+
+ // Since ShowSection() doesn't return a sub-dict, the only way to
+ // probe what the dicts look like is via Dump()
+ string dump;
+ dict.DumpToString(&dump);
+ const char* const expected =
+ ("global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ "};\n"
+ "dictionary 'test_SetShowSection (intended for bigmamainclude!.tpl)' {\n"
+ " TOPLEVEL: >foo<\n"
+ " TOPLEVEL2: >foo2<\n"
+ " section section1 (dict 1 of 1) -->\n"
+ " dictionary 'empty dictionary' {\n"
+ " }\n"
+ " section section2 (dict 1 of 1) -->\n"
+ " dictionary 'empty dictionary' {\n"
+ " }\n"
+ " section section3 (dict 1 of 1) -->\n"
+ " dictionary 'test_SetShowSection/section3#1' {\n"
+ " TOPLEVEL: >bar<\n"
+ " }\n"
+ "}\n");
+ EXPECT_STREQ(dump.c_str(), expected);
+}
+
+TEST(TemplateDictionary, SetValueAndShowSection) {
+ TemplateDictionary dict("test_SetValueAndShowSection");
+ TemplateDictionaryPeer peer(&dict);
+ dict.SetValue("TOPLEVEL", "foo");
+
+ dict.SetValueAndShowSection("INSEC", "bar", "SEC1");
+ dict.SetValueAndShowSection("NOTINSEC", "", "SEC2");
+ dict.SetValueAndShowSection("NOTINSEC2", NULL, "SEC3");
+
+ EXPECT_FALSE(peer.IsHiddenSection("SEC1"));
+ EXPECT_TRUE(peer.IsHiddenSection("SEC2"));
+ EXPECT_TRUE(peer.IsHiddenSection("SEC3"));
+
+ // Again, we don't get subdicts, so we have to dump to check values
+ string dump;
+ dict.DumpToString(&dump);
+ const char* const expected =
+ ("global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ "};\n"
+ "dictionary 'test_SetValueAndShowSection' {\n"
+ " TOPLEVEL: >foo<\n"
+ " section SEC1 (dict 1 of 1) -->\n"
+ " dictionary 'test_SetValueAndShowSection/SEC1#1' {\n"
+ " INSEC: >bar<\n"
+ " }\n"
+ "}\n");
+ EXPECT_STREQ(dump.c_str(), expected);
+}
+
+TEST(TemplateDictionary, SetTemplateGlobalValue) {
+ // The functionality involving it passing across the included dictionaries
+ // is also tested in TestAddIncludeDictionary
+ TemplateDictionary dict("test_SetTemplateGlobalValue", NULL);
+ TemplateDictionary* subdict = dict.AddSectionDictionary("section1");
+ TemplateDictionary* subsubdict =
+ subdict->AddSectionDictionary("section1's child");
+ TemplateDictionary* includedict = dict.AddIncludeDictionary("include1");
+
+ TemplateDictionaryPeer peer(&dict);
+ TemplateDictionaryPeer subdict_peer(subdict);
+ TemplateDictionaryPeer subsubdict_peer(subsubdict);
+ TemplateDictionaryPeer includedict_peer(includedict);
+
+ // Setting a template value after sub dictionaries are created should
+ // affect the sub dictionaries as well.
+ dict.SetTemplateGlobalValue("TEMPLATEVAL", "templateval");
+ EXPECT_TRUE(peer.ValueIs("TEMPLATEVAL", "templateval"));
+ EXPECT_TRUE(subdict_peer.ValueIs("TEMPLATEVAL", "templateval"));
+ EXPECT_TRUE(subsubdict_peer.ValueIs("TEMPLATEVAL", "templateval"));
+ EXPECT_TRUE(includedict_peer.ValueIs("TEMPLATEVAL", "templateval"));
+
+ // sub dictionaries after you set the template value should also
+ // get the template value
+ TemplateDictionary* subdict2 = dict.AddSectionDictionary("section2");
+ TemplateDictionary* includedict2 = dict.AddIncludeDictionary("include2");
+ TemplateDictionaryPeer subdict2_peer(subdict2);
+ TemplateDictionaryPeer includedict2_peer(includedict2);
+
+ EXPECT_TRUE(subdict2_peer.ValueIs("TEMPLATEVAL", "templateval"));
+ EXPECT_TRUE(includedict2_peer.ValueIs("TEMPLATEVAL", "templateval"));
+
+ // setting a template value on a sub dictionary should affect all the other
+ // sub dictionaries and the parent as well
+ subdict->SetTemplateGlobalValue("TEMPLATEVAL2", "templateval2");
+ EXPECT_TRUE(peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+ EXPECT_TRUE(subdict_peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+ EXPECT_TRUE(subsubdict_peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+ EXPECT_TRUE(includedict_peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+ EXPECT_TRUE(subdict2_peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+ EXPECT_TRUE(includedict2_peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+
+ includedict->SetTemplateGlobalValue("TEMPLATEVAL3", "templateval3");
+ EXPECT_TRUE(peer.ValueIs("TEMPLATEVAL3", "templateval3"));
+ EXPECT_TRUE(subdict_peer.ValueIs("TEMPLATEVAL3", "templateval3"));
+ EXPECT_TRUE(subsubdict_peer.ValueIs("TEMPLATEVAL3", "templateval3"));
+ EXPECT_TRUE(includedict_peer.ValueIs("TEMPLATEVAL3", "templateval3"));
+ EXPECT_TRUE(subdict2_peer.ValueIs("TEMPLATEVAL3", "templateval3"));
+ EXPECT_TRUE(includedict2_peer.ValueIs("TEMPLATEVAL3", "templateval3"));
+
+ // you should be able to override a template value with a regular value
+ // and the overwritten regular value should pass on to its children
+ subdict->SetValue("TEMPLATEVAL2", "subdictval");
+ includedict->SetValue("TEMPLATEVAL2", "includedictval");
+ EXPECT_TRUE(peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+ EXPECT_TRUE(subdict_peer.ValueIs("TEMPLATEVAL2", "subdictval"));
+ EXPECT_TRUE(subsubdict_peer.ValueIs("TEMPLATEVAL2", "subdictval"));
+ EXPECT_TRUE(includedict_peer.ValueIs("TEMPLATEVAL2", "includedictval"));
+ EXPECT_TRUE(subdict2_peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+ EXPECT_TRUE(includedict2_peer.ValueIs("TEMPLATEVAL2", "templateval2"));
+
+ // A section shown template-globally will be shown in all its children.
+ dict.ShowTemplateGlobalSection("ShownTemplateGlobalSection");
+ EXPECT_FALSE(peer.IsHiddenSection("ShownTemplateGlobalSection"));
+
+ EXPECT_FALSE(subdict2_peer.IsHiddenSection("ShownTemplateGlobalSection"));
+ EXPECT_FALSE(subsubdict_peer.IsHiddenSection("ShownTemplateGlobalSection"));
+
+ // Showing a template-global section in a child will show it in all templates
+ // in the tree
+ subdict->ShowTemplateGlobalSection("ShownFromAChild");
+ EXPECT_FALSE(peer.IsHiddenSection("ShownFromAChild"));
+ EXPECT_FALSE(subsubdict_peer.IsHiddenSection("ShownFromAChild"));
+
+ // Asking for a section that doesn't exist shouldn't cause infinite recursion
+ peer.IsHiddenSection("NAVBAR_SECTION");
+}
+
+TEST(TemplateDictionary, SetTemplateGlobalValueWithoutCopy) {
+ UnsafeArena arena(100);
+ TemplateDictionary dict("Test arena", &arena);
+ TemplateDictionaryPeer peer(&dict);
+
+ char value[32];
+ snprintf(value, sizeof(value), "%s", "value");
+
+ const void* const ptr = arena.Alloc(0);
+ dict.SetTemplateGlobalValueWithoutCopy("key", value);
+ // We shouldn't have copied the value string.
+ EXPECT_EQ(ptr, arena.Alloc(0));
+
+ EXPECT_TRUE(peer.ValueIs("key", "value"));
+ // If our content changes, so does what's in the dictionary -- but
+ // only the contents of the buffer, not its length!
+ snprintf(value, sizeof(value), "%s", "not_value");
+ EXPECT_TRUE(peer.ValueIs("key", "not_v")); // "not_v" size == value" size
+}
+
+TEST(TemplateDictionary, AddIncludeDictionary) {
+ TemplateDictionary dict("test_SetAddIncludeDictionary", NULL);
+ TemplateDictionaryPeer peer(&dict);
+ dict.SetValue("TOPLEVEL", "foo");
+ dict.SetValue("TOPLEVEL2", "foo2");
+ dict.SetTemplateGlobalValue("TEMPLATELEVEL", "foo3");
+
+ TemplateDictionary* subdict_1a = dict.AddIncludeDictionary("include1");
+ TemplateDictionaryPeer subdict_1a_peer(subdict_1a);
+ subdict_1a->SetFilename("incfile1a");
+ // This is the same dict, but name is specified a different way.
+ TemplateDictionary* subdict_1b = dict.AddIncludeDictionary(
+ TemplateString("include1__ignored__", strlen("include1")));
+ TemplateDictionaryPeer subdict_1b_peer(subdict_1b);
+ // Let's try not calling SetFilename on this one.
+ subdict_1a->SetValue("SUBLEVEL", "subfoo");
+ subdict_1b->SetValue("SUBLEVEL", "subbar");
+
+ TemplateDictionary* subdict_2 = dict.AddIncludeDictionary("include2");
+ TemplateDictionaryPeer subdict_2_peer(subdict_2);
+ subdict_2->SetFilename("foo/bar");
+ subdict_2->SetValue("TOPLEVEL", "bar"); // overriding top dict
+ // overriding template dict
+ subdict_2->SetValue("TEMPLATELEVEL", "subfoo3");
+ TemplateDictionary* subdict_2_1 = subdict_2->AddIncludeDictionary("sub");
+ TemplateDictionaryPeer subdict_2_1_peer(subdict_2_1);
+ subdict_2_1->SetFilename("baz");
+ subdict_2_1->SetIntValue("GLOBAL", 21); // overrides value in setUp()
+
+ // Verify that all variables that should be look-up-able are, and that
+ // we have proper precedence. Unlike with sections, includes lookups
+ // do not go 'up the chain'.
+ EXPECT_TRUE(peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(peer.ValueIs("TOPLEVEL", "foo"));
+ EXPECT_TRUE(peer.ValueIs("TOPLEVEL2", "foo2"));
+ EXPECT_TRUE(peer.ValueIs("TEMPLATELEVEL", "foo3"));
+ EXPECT_TRUE(peer.ValueIs("SUBLEVEL", ""));
+
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("TOPLEVEL", ""));
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("TOPLEVEL2", ""));
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("TEMPLATELEVEL", "foo3"));
+ EXPECT_TRUE(subdict_1a_peer.ValueIs("SUBLEVEL", "subfoo"));
+
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("TOPLEVEL", ""));
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("TOPLEVEL2", ""));
+ EXPECT_TRUE(subdict_1b_peer.ValueIs("SUBLEVEL", "subbar"));
+
+ EXPECT_TRUE(subdict_2_peer.ValueIs("GLOBAL", "top"));
+ EXPECT_TRUE(subdict_2_peer.ValueIs("TOPLEVEL", "bar"));
+ EXPECT_TRUE(subdict_2_peer.ValueIs("TOPLEVEL2", ""));
+ EXPECT_TRUE(subdict_2_peer.ValueIs("TEMPLATELEVEL", "subfoo3"));
+ EXPECT_TRUE(subdict_2_peer.ValueIs("SUBLEVEL", ""));
+
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("GLOBAL", "21"));
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("TOPLEVEL", ""));
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("TOPLEVEL2", ""));
+ EXPECT_TRUE(subdict_2_1_peer.ValueIs("SUBLEVEL", ""));
+
+ // Verify that everyone knows about its sub-dictionaries, but that
+ // these do not try to go 'up the chain' on lookup failure
+ EXPECT_FALSE(peer.IsHiddenTemplate("include1"));
+ EXPECT_FALSE(peer.IsHiddenTemplate("include2"));
+ EXPECT_TRUE(peer.IsHiddenTemplate("include3"));
+ EXPECT_TRUE(peer.IsHiddenTemplate("sub"));
+ EXPECT_TRUE(subdict_1a_peer.IsHiddenTemplate("include1"));
+ EXPECT_TRUE(subdict_1a_peer.IsHiddenTemplate("sub"));
+ EXPECT_FALSE(subdict_2_peer.IsHiddenTemplate("sub"));
+ EXPECT_TRUE(subdict_2_1_peer.IsHiddenTemplate("sub"));
+
+ // We should get the dictionary-lengths right as well
+ vector<const TemplateDictionary*> dummy;
+ EXPECT_EQ(2, peer.GetIncludeDictionaries("include1", &dummy));
+ EXPECT_EQ(1, peer.GetIncludeDictionaries("include2", &dummy));
+ EXPECT_EQ(1, subdict_2_peer.GetIncludeDictionaries("sub", &dummy));
+
+ // We can also test the include-files are right
+ EXPECT_EQ(2, peer.GetIncludeDictionaries("include1", &dummy));
+ EXPECT_EQ(1, peer.GetIncludeDictionaries("include2", &dummy));
+ EXPECT_EQ(1, subdict_2_peer.GetIncludeDictionaries("sub", &dummy));
+ // Test some of the values
+ EXPECT_TRUE(TemplateDictionaryPeer(GetIncludeDict(&dict, "include1", 0))
+ .ValueIs("SUBLEVEL", "subfoo"));
+ EXPECT_TRUE(TemplateDictionaryPeer(GetIncludeDict(&dict, "include1", 1))
+ .ValueIs("SUBLEVEL", "subbar"));
+ EXPECT_TRUE(TemplateDictionaryPeer(GetIncludeDict(&dict, "include2", 0))
+ .ValueIs("TOPLEVEL", "bar"));
+ EXPECT_TRUE(TemplateDictionaryPeer(
+ GetIncludeDict(GetIncludeDict(&dict, "include2", 0), "sub", 0))
+ .ValueIs("TOPLEVEL", ""));
+ EXPECT_TRUE(TemplateDictionaryPeer(
+ GetIncludeDict(GetIncludeDict(&dict, "include2", 0), "sub", 0))
+ .ValueIs("GLOBAL", "21"));
+ // We can test the include-names as well
+ EXPECT_STREQ(peer.GetIncludeTemplateName("include1", 0), "incfile1a");
+ EXPECT_STREQ(peer.GetIncludeTemplateName("include1", 1), "");
+ EXPECT_STREQ(peer.GetIncludeTemplateName("include2", 0), "foo/bar");
+ EXPECT_STREQ(TemplateDictionaryPeer(GetIncludeDict(&dict, "include2", 0))
+ .GetIncludeTemplateName("sub", 0),
+ "baz");
+
+ // Make sure we're making descriptive names
+ EXPECT_STREQ(dict.name().c_str(),
+ "test_SetAddIncludeDictionary");
+ EXPECT_STREQ(subdict_1a->name().c_str(),
+ "test_SetAddIncludeDictionary/include1#1");
+ EXPECT_STREQ(subdict_1b->name().c_str(),
+ "test_SetAddIncludeDictionary/include1#2");
+ EXPECT_STREQ(subdict_2->name().c_str(),
+ "test_SetAddIncludeDictionary/include2#1");
+ EXPECT_STREQ(subdict_2_1->name().c_str(),
+ "test_SetAddIncludeDictionary/include2#1/sub#1");
+
+ // Finally, we can test the whole kit and kaboodle
+ string dump;
+ dict.DumpToString(&dump);
+ const char* const expected =
+ ("global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ "};\n"
+ "template dictionary {\n"
+ " TEMPLATELEVEL: >foo3<\n"
+ "};\n"
+ "dictionary 'test_SetAddIncludeDictionary' {\n"
+ " TOPLEVEL: >foo<\n"
+ " TOPLEVEL2: >foo2<\n"
+ " include-template include1 (dict 1 of 2, from incfile1a) -->\n"
+ " global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ " };\n"
+ " dictionary 'test_SetAddIncludeDictionary/include1#1 (intended for incfile1a)' {\n"
+ " SUBLEVEL: >subfoo<\n"
+ " }\n"
+ " include-template include1 (dict 2 of 2, **NO FILENAME SET; THIS DICT WILL BE IGNORED**) -->\n"
+ " global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ " };\n"
+ " dictionary 'test_SetAddIncludeDictionary/include1#2' {\n"
+ " SUBLEVEL: >subbar<\n"
+ " }\n"
+ " include-template include2 (dict 1 of 1, from foo/bar) -->\n"
+ " global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ " };\n"
+ " dictionary 'test_SetAddIncludeDictionary/include2#1 (intended for foo/bar)' {\n"
+ " TEMPLATELEVEL: >subfoo3<\n"
+ " TOPLEVEL: >bar<\n"
+ " include-template sub (dict 1 of 1, from baz) -->\n"
+ " global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ " };\n"
+ " dictionary 'test_SetAddIncludeDictionary/include2#1/sub#1 (intended for baz)' {\n"
+ " GLOBAL: >21<\n"
+ " }\n"
+ " }\n"
+ "}\n");
+ EXPECT_STREQ(dump.c_str(), expected);
+}
+
+static void TestMakeCopy(bool use_local_arena) {
+ UnsafeArena local_arena(1024);
+ UnsafeArena* arena = NULL;
+ if (use_local_arena)
+ arena = &local_arena;
+
+ // First, let's make a non-trivial template dictionary (We use
+ // 'new' because later we'll test deleting this dict but keeping
+ // around the copy.)
+ TemplateDictionary* dict = new TemplateDictionary("testdict", arena);
+
+ dict->SetValue("TOPLEVEL", "foo");
+
+ dict->SetTemplateGlobalValue("TEMPLATELEVEL", "foo3");
+
+ TemplateDictionary* subdict_1a = dict->AddIncludeDictionary("include1");
+ subdict_1a->SetFilename("incfile1a");
+ subdict_1a->SetValue("SUBLEVEL", "subfoo");
+ TemplateDictionary* subdict_1b = dict->AddIncludeDictionary("include1");
+ // Let's try not calling SetFilename on this one.
+ subdict_1b->SetValue("SUBLEVEL", "subbar");
+
+ TemplateDictionary* subdict_2a = dict->AddSectionDictionary("section1");
+ TemplateDictionary* subdict_2b = dict->AddSectionDictionary("section1");
+ subdict_2a->SetValue("SUBLEVEL", "subfoo");
+ subdict_2b->SetValue("SUBLEVEL", "subbar");
+ TemplateDictionary* subdict_3 = dict->AddSectionDictionary("section2");
+ subdict_3->SetValue("TOPLEVEL", "bar"); // overriding top dict
+ TemplateDictionary* subdict_3_1 = subdict_3->AddSectionDictionary("sub");
+ subdict_3_1->SetIntValue("GLOBAL", 21); // overrides value in setUp()
+
+ string orig;
+ dict->DumpToString(&orig);
+
+ // Make a copy
+ TemplateDictionary* dict_copy = dict->MakeCopy("testdict", NULL);
+ // Make sure it doesn't work to copy a sub-dictionary
+ EXPECT_TRUE(subdict_1a->MakeCopy("copy of subdict") == NULL);
+ EXPECT_TRUE(subdict_2a->MakeCopy("copy of subdict") == NULL);
+
+ // Delete the original dict, to make sure the copy really is independent
+ delete dict;
+ dict = NULL;
+ string copy;
+ dict_copy->DumpToString(©);
+ delete dict_copy;
+
+ EXPECT_STREQ(orig.c_str(), copy.c_str());
+}
+
+TEST(MakeCopy, UseLocalArena) {
+ TestMakeCopy(true);
+}
+
+TEST(MakeCopy, DoNotUseLocalArena) {
+ TestMakeCopy(false);
+}
+
+TEST(TemplateDictionary, SetModifierData) {
+ PerExpandData per_expand_data;
+ const void* data = "test";
+ per_expand_data.InsertForModifiers("a", data);
+ EXPECT_EQ(data, per_expand_data.LookupForModifiers("a"));
+}
+
+TEST(TemplateDictionary, Iterator) {
+ // Build up a nice community of TemplateDictionaries.
+ TemplateDictionary farm("Farm");
+ TemplateDictionaryPeer farm_peer(&farm);
+ TemplateDictionaryInterface* grey_barn =
+ farm.AddIncludeDictionary("BARN");
+ TemplateDictionaryInterface* duck_pond =
+ farm.AddIncludeDictionary("POND");
+ TemplateDictionaryInterface* cattle_pond =
+ farm.AddIncludeDictionary("POND");
+ TemplateDictionaryInterface* irrigation_pond =
+ farm.AddIncludeDictionary("POND");
+
+ // A section name with repeated sections
+ TemplateDictionaryInterface* lillies = farm.AddSectionDictionary("FLOWERS");
+ TemplateDictionaryInterface* lilacs = farm.AddSectionDictionary("FLOWERS");
+ TemplateDictionaryInterface* daisies = farm.AddSectionDictionary("FLOWERS");
+ // A section name with one repeat
+ TemplateDictionaryInterface* wheat = farm.AddSectionDictionary("WHEAT");
+ // A section name, just shown
+ farm.ShowSection("CORN");
+
+ // Check that the iterators expose all of the dictionaries.
+ TemplateDictionaryPeer::Iterator* barns =
+ farm_peer.CreateTemplateIterator("BARN");
+ EXPECT_TRUE(barns->HasNext());
+ EXPECT_EQ(&barns->Next(), grey_barn);
+ EXPECT_FALSE(barns->HasNext());
+ delete barns;
+
+ TemplateDictionaryPeer::Iterator* ponds =
+ farm_peer.CreateTemplateIterator("POND");
+ EXPECT_TRUE(ponds->HasNext());
+ EXPECT_EQ(&ponds->Next(), duck_pond);
+ EXPECT_TRUE(ponds->HasNext());
+ EXPECT_EQ(&ponds->Next(), cattle_pond);
+ EXPECT_TRUE(ponds->HasNext());
+ EXPECT_EQ(&ponds->Next(), irrigation_pond);
+ EXPECT_FALSE(ponds->HasNext());
+ delete ponds;
+
+ TemplateDictionaryPeer::Iterator* flowers =
+ farm_peer.CreateSectionIterator("FLOWERS");
+ EXPECT_TRUE(flowers->HasNext());
+ EXPECT_EQ(&flowers->Next(), lillies);
+ EXPECT_TRUE(flowers->HasNext());
+ EXPECT_EQ(&flowers->Next(), lilacs);
+ EXPECT_TRUE(flowers->HasNext());
+ EXPECT_EQ(&flowers->Next(), daisies);
+ EXPECT_FALSE(flowers->HasNext());
+ delete flowers;
+
+ TemplateDictionaryPeer::Iterator* crop =
+ farm_peer.CreateSectionIterator("WHEAT");
+ EXPECT_TRUE(crop->HasNext());
+ EXPECT_EQ(&crop->Next(), wheat);
+ EXPECT_FALSE(crop->HasNext());
+ delete crop;
+
+ TemplateDictionaryPeer::Iterator* corn_crop =
+ farm_peer.CreateSectionIterator("CORN");
+ EXPECT_TRUE(corn_crop->HasNext());
+ EXPECT_TRUE(&corn_crop->Next()); // ShowSection doesn't give us the dict back
+ EXPECT_FALSE(corn_crop->HasNext());
+ delete corn_crop;
+}
+
+TEST(TemplateDictionary, IsHiddenSectionDefault) {
+ TemplateDictionary dict("dict");
+ TemplateDictionaryPeer peer(&dict);
+ EXPECT_TRUE(peer.IsHiddenSection("UNDEFINED"));
+ EXPECT_FALSE(peer.IsUnhiddenSection("UNDEFINED"));
+ dict.ShowSection("VISIBLE");
+ EXPECT_FALSE(peer.IsHiddenSection("VISIBLE"));
+ EXPECT_TRUE(peer.IsUnhiddenSection("VISIBLE"));
+}
+
+// This has to run last, since its SetGlobalValue modifies the global
+// state, which can affect other tests (especially given the embedded
+// NUL!) So we don't use the normal TEST() here, and call it manually
+// in main().
+
+void TestSetValueWithNUL() {
+ TemplateDictionary dict("test_SetValueWithNUL", NULL);
+ TemplateDictionaryPeer peer(&dict);
+
+ // Test copying char*s, strings, and explicit TemplateStrings
+ dict.SetValue(string("FOO\0BAR", 7), string("QUX\0QUUX", 8));
+ dict.SetGlobalValue(string("GOO\0GAR", 7), string("GUX\0GUUX", 8));
+
+ // FOO should not match FOO\0BAR
+ EXPECT_TRUE(peer.ValueIs("FOO", ""));
+ EXPECT_TRUE(peer.ValueIs("GOO", ""));
+
+ EXPECT_TRUE(peer.ValueIs(string("FOO\0BAR", 7), string("QUX\0QUUX", 8)));
+ EXPECT_TRUE(peer.ValueIs(string("GOO\0GAR", 7), string("GUX\0GUUX", 8)));
+
+ string dump;
+ dict.DumpToString(&dump);
+ // We can't use EXPECT_STREQ here because of the embedded NULs.
+ // They also require I count the length of the string by hand. :-(
+ string expected(("global dictionary {\n"
+ " BI_NEWLINE: >\n"
+ "<\n"
+ " BI_SPACE: > <\n"
+ " GLOBAL: >top<\n"
+ " GOO\0GAR: >GUX\0GUUX<\n"
+ "};\n"
+ "dictionary 'test_SetValueWithNUL' {\n"
+ " FOO\0BAR: >QUX\0QUUX<\n"
+ "}\n"),
+ 160);
+ EXPECT_EQ(dump, expected);
+}
+
+TEST(TemplateDictionary, TestShowTemplateGlobalSection) {
+ StringToTemplateCache("test.tpl", "{{#sect}}OK{{/sect}}", DO_NOT_STRIP);
+
+ TemplateDictionary dict("mydict");
+ dict.ShowTemplateGlobalSection("sect");
+
+ string out;
+ ExpandTemplate("test.tpl", DO_NOT_STRIP, &dict, &out);
+}
+
+TEST(TemplateDictionary, TestShowTemplateGlobalSection_Child) {
+ // The TemplateDictionary::template_global_dict_ behaves differently for child
+ // dictionaries than for the root parent dictionary.
+ StringToTemplateCache("test2.tpl",
+ "{{#foo}}{{#sect}}OK{{/sect}}{{/foo}}",
+ DO_NOT_STRIP);
+
+ TemplateDictionary dict("mydict");
+ dict.ShowTemplateGlobalSection("sect");
+
+ dict.AddSectionDictionary("foo");
+
+ string out;
+ ExpandTemplate("test2.tpl", DO_NOT_STRIP, &dict, &out);
+}
+
+TEST(TemplateDictionary, TestShowTemplateGlobalSection_SectionDoesntExist) {
+ StringToTemplateCache("test3.tpl",
+ "{{#bad}}bad{{/bad}}",
+ DO_NOT_STRIP);
+
+ TemplateDictionary dict("mydict");
+
+ string out;
+ ExpandTemplate("test3.tpl", DO_NOT_STRIP, &dict, &out);
+}
+
+
+} // unnamed namespace
+
+
+int main(int argc, char** argv) {
+
+ SetUp();
+
+ const int retval = RUN_ALL_TESTS();
+
+ // This has to run last, so we run it manually
+ TestSetValueWithNUL();
+
+ return retval;
+}
diff --git a/src/tests/template_modifiers_unittest.cc b/src/tests/template_modifiers_unittest.cc
new file mode 100644
index 0000000..781d3d3
--- /dev/null
+++ b/src/tests/template_modifiers_unittest.cc
@@ -0,0 +1,1117 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// This code is written to not use the google testing framework
+// as much as possible, to make it easier to opensource.
+
+#include "config_for_unittests.h"
+#include <stdio.h>
+#include <string.h>
+#include <assert.h>
+#include <string>
+#include <vector>
+#include <ctemplate/template.h>
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_emitter.h>
+#include <ctemplate/template_modifiers.h>
+#include "template_modifiers_internal.h"
+#include "tests/template_test_util.h"
+#include "base/util.h"
+TEST_INIT // defines RUN_ALL_TESTS
+
+using std::string;
+using std::vector;
+
+// Rather than put all these tests in the ctemplate namespace, or use
+// using-declarations, for this test I've decided to manually prepend
+// GOOGLE_NAMESPACE:: everywhere it's needed. This test can serve as an
+// example of how that approach looks.
+
+TEST(TemplateModifiers, HtmlEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestHtmlEscape", NULL);
+ dict.SetEscapedValue("easy HTML", "foo",
+ GOOGLE_NAMESPACE::html_escape);
+ dict.SetEscapedValue("harder HTML", "foo & bar",
+ GOOGLE_NAMESPACE::html_escape);
+ dict.SetEscapedValue("hardest HTML",
+ "<A HREF='foo'\nid=\"bar\t\t&&\vbaz\">",
+ GOOGLE_NAMESPACE::html_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ // TODO(csilvers): change this (and all other expect_*'s in all files
+ // in this directory) to take the expected value first, not second.
+ EXPECT_STREQ(peer.GetSectionValue("easy HTML"), "foo");
+ EXPECT_STREQ(peer.GetSectionValue("harder HTML"), "foo & bar");
+ EXPECT_STREQ(peer.GetSectionValue("hardest HTML"),
+ "<A HREF='foo' id="bar && "
+ "baz">");
+}
+
+TEST(TemplateModifiers, SnippetEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestSnippetEscape", NULL);
+ dict.SetEscapedValue("easy snippet", "foo",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("valid snippet",
+ "<b>foo<br> & b<wbr>­ar</b>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("invalid snippet",
+ "<b><A HREF='foo'\nid=\"bar\t\t&&{\vbaz\">",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("snippet with italics",
+ "<i>foo<br> & b<wbr>­ar</i>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unclosed snippet",
+ "<b>foo",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("snippet with interleaving",
+ "<b><i>foo</b></i>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unclosed interleaving",
+ "<b><i><b>foo</b>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unclosed",
+ "<b><i>foo",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unterminated 1",
+ "foo<",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unterminated 2",
+ "foo<b",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unterminated 3",
+ "foo</",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unterminated 4",
+ "foo</b",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unterminated 5",
+ "<b>foo</b",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("close b i",
+ "<i><b>foo",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("close i b",
+ "<b><i>foo",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("em",
+ "<em>foo</em>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("nested em",
+ "<b>This is foo<em>...</em></b>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unclosed em",
+ "<em>foo",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("wrongly closed em",
+ "foo</em>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("misnested em",
+ "<i><em>foo</i></em>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("span ltr",
+ "<span dir=ltr>bidi text</span>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("span rtl",
+ "<span dir=rtl>bidi text</span>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("span garbage dir attr",
+ "<span dir=foo>bidi text</span>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("span no dir",
+ "<span>bidi text</span>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("span bad attribute",
+ "<span onclick=alert('foo')>bidi text</span>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("span quotes",
+ "<span dir=\"rtl\">bidi text</span>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("nested span",
+ "<b>This is <span dir=rtl>bidi text</span></b>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("doubly-nested span",
+ "<span dir=rtl>This is <span dir=rtl>"
+ "bidi text</span></span>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("two spans",
+ "<b>This is <span dir=rtl>text</span> that is "
+ "<span dir=rtl>bidi.</span></b>",
+ GOOGLE_NAMESPACE::snippet_escape);
+ dict.SetEscapedValue("unclosed span",
+ "<b>This is <span dir=rtl>bidi text",
+ GOOGLE_NAMESPACE::snippet_escape);
+
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy snippet"), "foo");
+ EXPECT_STREQ(peer.GetSectionValue("valid snippet"),
+ "<b>foo<br> & b<wbr>­ar</b>");
+ EXPECT_STREQ(peer.GetSectionValue("invalid snippet"),
+ "<b><A HREF='foo' id="bar &&{ "
+ "baz"></b>");
+ EXPECT_STREQ(peer.GetSectionValue("snippet with italics"),
+ "<i>foo<br> & b<wbr>­ar</i>");
+ EXPECT_STREQ(peer.GetSectionValue("unclosed snippet"),
+ "<b>foo</b>");
+ EXPECT_STREQ(peer.GetSectionValue("snippet with interleaving"),
+ "<b><i>foo</b></i>");
+ EXPECT_STREQ(peer.GetSectionValue("unclosed interleaving"),
+ "<b><i><b>foo</b></i>");
+ EXPECT_STREQ(peer.GetSectionValue("unclosed"),
+ "<b><i>foo</i></b>");
+ EXPECT_STREQ(peer.GetSectionValue("unterminated 1"), "foo<");
+ EXPECT_STREQ(peer.GetSectionValue("unterminated 2"), "foo<b");
+ EXPECT_STREQ(peer.GetSectionValue("unterminated 3"), "foo</");
+ EXPECT_STREQ(peer.GetSectionValue("unterminated 4"), "foo</b");
+ EXPECT_STREQ(peer.GetSectionValue("unterminated 5"), "<b>foo</b</b>");
+ EXPECT_STREQ(peer.GetSectionValue("close b i"), "<i><b>foo</b></i>");
+ EXPECT_STREQ(peer.GetSectionValue("close i b"), "<b><i>foo</i></b>");
+ EXPECT_STREQ(peer.GetSectionValue("em"), "<em>foo</em>");
+ EXPECT_STREQ(peer.GetSectionValue("nested em"),
+ "<b>This is foo<em>...</em></b>");
+ EXPECT_STREQ(peer.GetSectionValue("unclosed em"), "<em>foo</em>");
+ EXPECT_STREQ(peer.GetSectionValue("wrongly closed em"), "foo</em>");
+ EXPECT_STREQ(peer.GetSectionValue("misnested em"), "<i><em>foo</i></em>");
+ EXPECT_STREQ(peer.GetSectionValue("span ltr"),
+ "<span dir=ltr>bidi text</span>");
+ EXPECT_STREQ(peer.GetSectionValue("span rtl"),
+ "<span dir=rtl>bidi text</span>");
+ EXPECT_STREQ(peer.GetSectionValue("span garbage dir attr"),
+ "<span dir=foo>bidi text</span>");
+ EXPECT_STREQ(peer.GetSectionValue("span no dir"),
+ "<span>bidi text</span>");
+ EXPECT_STREQ(peer.GetSectionValue("span bad attribute"),
+ "<span onclick=alert('foo')>bidi text</span>");
+ EXPECT_STREQ(peer.GetSectionValue("span quotes"),
+ "<span dir="rtl">bidi text</span>");
+ EXPECT_STREQ(peer.GetSectionValue("nested span"),
+ "<b>This is <span dir=rtl>bidi text</span></b>");
+ EXPECT_STREQ(peer.GetSectionValue("doubly-nested span"),
+ "<span dir=rtl>This is <span dir=rtl>bidi text"
+ "</span></span>");
+ EXPECT_STREQ(peer.GetSectionValue("two spans"),
+ "<b>This is <span dir=rtl>text</span> that is "
+ "<span dir=rtl>bidi.</span></b>");
+ EXPECT_STREQ(peer.GetSectionValue("unclosed span"),
+ "<b>This is <span dir=rtl>bidi text</span></b>");
+}
+
+TEST(TemplateModifiers, PreEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestPreEscape", NULL);
+ dict.SetEscapedValue("easy PRE", "foo",
+ GOOGLE_NAMESPACE::pre_escape);
+ dict.SetEscapedValue("harder PRE", "foo & bar",
+ GOOGLE_NAMESPACE::pre_escape);
+ dict.SetEscapedValue("hardest PRE",
+ " \"--\v--\f--\n--\t--&--<-->--'--\"",
+ GOOGLE_NAMESPACE::pre_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy PRE"), "foo");
+ EXPECT_STREQ(peer.GetSectionValue("harder PRE"), "foo & bar");
+ EXPECT_STREQ(peer.GetSectionValue("hardest PRE"),
+ " "--\v--\f--\n--\t--&--<-->--'--"");
+}
+
+TEST(TemplateModifiers, XmlEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestXmlEscape", NULL);
+ dict.SetEscapedValue("no XML", "",
+ GOOGLE_NAMESPACE::xml_escape);
+ dict.SetEscapedValue("easy XML", "xoo",
+ GOOGLE_NAMESPACE::xml_escape);
+ dict.SetEscapedValue("harder XML-1", "<>&'\"",
+ GOOGLE_NAMESPACE::xml_escape);
+ dict.SetEscapedValue("harder XML-2", "Hello<script>alert('&')</script>",
+ GOOGLE_NAMESPACE::xml_escape);
+ dict.SetEscapedValue("hardest XML", "<<b>>&!''\"\"foo",
+ GOOGLE_NAMESPACE::xml_escape);
+ // Characters 0x00-0x1F (except \t, \r and \n) are not valid for XML and
+ // compliant parsers are allowed to die when they encounter them. They
+ // should be replaced with spaces.
+ dict.SetEscapedValue("Spacey XML", " \r\n\f",
+ GOOGLE_NAMESPACE::xml_escape);
+ dict.SetEscapedValue("XML with control chars",
+ "\x01\x02\x03\x09\x0A\x0B\x0D\x15\x16\x1F",
+ GOOGLE_NAMESPACE::xml_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("no XML"), "");
+ EXPECT_STREQ(peer.GetSectionValue("easy XML"), "xoo");
+ EXPECT_STREQ(peer.GetSectionValue("harder XML-1"),
+ "<>&'"");
+ EXPECT_STREQ(peer.GetSectionValue("harder XML-2"),
+ "Hello<script>alert('&')</script>");
+ EXPECT_STREQ(peer.GetSectionValue("hardest XML"),
+ "<<b>>&!''""foo");
+ EXPECT_STREQ(peer.GetSectionValue("Spacey XML"),
+ " \r\n ");
+ EXPECT_STREQ(peer.GetSectionValue("XML with control chars"),
+ " \t\n \r ");
+}
+
+TEST(TemplateModifiers, ValidateUrlHtmlEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestValidateUrlHtmlEscape", NULL);
+ dict.SetEscapedValue("easy http URL", "http://www.google.com",
+ GOOGLE_NAMESPACE::validate_url_and_html_escape);
+ dict.SetEscapedValue("harder https URL",
+ "https://www.google.com/search?q=f&hl=en",
+ GOOGLE_NAMESPACE::validate_url_and_html_escape);
+ dict.SetEscapedValue("easy javascript URL",
+ "javascript:alert(document.cookie)",
+ GOOGLE_NAMESPACE::validate_url_and_html_escape);
+ dict.SetEscapedValue("harder javascript URL",
+ "javascript:alert(10/5)",
+ GOOGLE_NAMESPACE::validate_url_and_html_escape);
+ dict.SetEscapedValue("easy relative URL",
+ "foobar.html",
+ GOOGLE_NAMESPACE::validate_url_and_html_escape);
+ dict.SetEscapedValue("harder relative URL",
+ "/search?q=green flowers&hl=en",
+ GOOGLE_NAMESPACE::validate_url_and_html_escape);
+ dict.SetEscapedValue("ftp URL",
+ "ftp://ftp.example.org/pub/file.txt",
+ GOOGLE_NAMESPACE::validate_url_and_html_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy http URL"),
+ "http://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("harder https URL"),
+ "https://www.google.com/search?q=f&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("easy javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("harder javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("easy relative URL"),
+ "foobar.html");
+ EXPECT_STREQ(peer.GetSectionValue("harder relative URL"),
+ "/search?q=green flowers&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("ftp URL"),
+ "ftp://ftp.example.org/pub/file.txt");
+}
+
+TEST(TemplateModifiers, ValidateImgSrcUrlHtmlEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestValidateImgSrcUrlHtmlEscape", NULL);
+ dict.SetEscapedValue("easy http URL", "http://www.google.com",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_html_escape);
+ dict.SetEscapedValue("harder https URL",
+ "https://www.google.com/search?q=f&hl=en",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_html_escape);
+ dict.SetEscapedValue("easy javascript URL",
+ "javascript:alert(document.cookie)",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_html_escape);
+ dict.SetEscapedValue("harder javascript URL",
+ "javascript:alert(10/5)",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_html_escape);
+ dict.SetEscapedValue("easy relative URL",
+ "foobar.html",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_html_escape);
+ dict.SetEscapedValue("harder relative URL",
+ "/search?q=green flowers&hl=en",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_html_escape);
+ dict.SetEscapedValue("ftp URL",
+ "ftp://ftp.example.org/pub/file.txt",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_html_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy http URL"),
+ "http://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("harder https URL"),
+ "https://www.google.com/search?q=f&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("easy javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("harder javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("easy relative URL"),
+ "foobar.html");
+ EXPECT_STREQ(peer.GetSectionValue("harder relative URL"),
+ "/search?q=green flowers&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("ftp URL"),
+ "ftp://ftp.example.org/pub/file.txt");
+}
+
+TEST(TemplateModifiers, ValidateUrlJavascriptEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestValidateUrlJavascriptEscape", NULL);
+ dict.SetEscapedValue(
+ "easy http URL", "http://www.google.com",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder https URL",
+ "https://www.google.com/search?q=f&hl=en",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "mangled http URL", "HTTP://www.google.com",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "easy javascript URL",
+ "javascript:alert(document.cookie)",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder javascript URL",
+ "javascript:alert(10/5)",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "easy relative URL",
+ "foobar.html",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder relative URL",
+ "/search?q=green flowers&hl=en",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "data URL",
+ "data: text/html",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "mangled javascript URL",
+ "javaSCRIPT:alert(5)",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder mangled javascript URL",
+ "java\nSCRIPT:alert(5)",
+ GOOGLE_NAMESPACE::validate_url_and_javascript_escape);
+
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy http URL"),
+ "http://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("harder https URL"),
+ "https://www.google.com/search?q\\x3df\\x26hl\\x3den");
+ EXPECT_STREQ(peer.GetSectionValue("mangled http URL"),
+ "HTTP://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("easy javascript URL"), "#");
+ EXPECT_STREQ(peer.GetSectionValue("harder javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("easy relative URL"),
+ "foobar.html");
+ EXPECT_STREQ(peer.GetSectionValue("harder relative URL"),
+ "/search?q\\x3dgreen flowers\\x26hl\\x3den");
+ EXPECT_STREQ(peer.GetSectionValue("data URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("mangled javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("harder mangled javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeUrlReplacement);
+}
+
+TEST(TemplateModifiers, ValidateImgSrcUrlJavascriptEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestValidateImgSrcUrlJavascriptEscape", NULL);
+ dict.SetEscapedValue(
+ "easy http URL", "http://www.google.com",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder https URL",
+ "https://www.google.com/search?q=f&hl=en",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "mangled http URL", "HTTP://www.google.com",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "easy javascript URL",
+ "javascript:alert(document.cookie)",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder javascript URL",
+ "javascript:alert(10/5)",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "easy relative URL",
+ "foobar.html",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder relative URL",
+ "/search?q=green flowers&hl=en",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "data URL",
+ "data: text/html",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "mangled javascript URL",
+ "javaSCRIPT:alert(5)",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+ dict.SetEscapedValue(
+ "harder mangled javascript URL",
+ "java\nSCRIPT:alert(5)",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_javascript_escape);
+
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy http URL"),
+ "http://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("harder https URL"),
+ "https://www.google.com/search?q\\x3df\\x26hl\\x3den");
+ EXPECT_STREQ(peer.GetSectionValue("mangled http URL"),
+ "HTTP://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("easy javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("harder javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("easy relative URL"),
+ "foobar.html");
+ EXPECT_STREQ(peer.GetSectionValue("harder relative URL"),
+ "/search?q\\x3dgreen flowers\\x26hl\\x3den");
+ EXPECT_STREQ(peer.GetSectionValue("data URL"),
+ "/images/cleardot.gif");
+ EXPECT_STREQ(peer.GetSectionValue("mangled javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("harder mangled javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeImgSrcUrlReplacement);
+}
+
+TEST(TemplateModifiers, ValidateUrlCssEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestValidateUrlCssEscape", NULL);
+ dict.SetEscapedValue("easy http URL", "http://www.google.com",
+ GOOGLE_NAMESPACE::validate_url_and_css_escape);
+ dict.SetEscapedValue("harder https URL",
+ "https://www.google.com/search?q=f&hl=en",
+ GOOGLE_NAMESPACE::validate_url_and_css_escape);
+ dict.SetEscapedValue("javascript URL",
+ "javascript:alert(document.cookie)",
+ GOOGLE_NAMESPACE::validate_url_and_css_escape);
+ dict.SetEscapedValue("relative URL", "/search?q=green flowers&hl=en",
+ GOOGLE_NAMESPACE::validate_url_and_css_escape);
+ dict.SetEscapedValue("hardest URL", "http://www.google.com/s?q='bla'"
+ "&a=\"\"&b=(<tag>)&c=*\r\n\\\\bla",
+ GOOGLE_NAMESPACE::validate_url_and_css_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy http URL"),
+ "http://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("harder https URL"),
+ "https://www.google.com/search?q=f&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("relative URL"),
+ "/search?q=green flowers&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("hardest URL"),
+ "http://www.google.com/s?q=%27bla%27"
+ "&a=%22%22&b=%28%3Ctag%3E%29&c=%2A%0D%0A%5C%5Cbla");
+}
+
+TEST(TemplateModifiers, ValidateImgSrcUrlCssEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestValidateImgSrcUrlCssEscape", NULL);
+ dict.SetEscapedValue("easy http URL", "http://www.google.com",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_css_escape);
+ dict.SetEscapedValue("harder https URL",
+ "https://www.google.com/search?q=f&hl=en",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_css_escape);
+ dict.SetEscapedValue("javascript URL",
+ "javascript:alert(document.cookie)",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_css_escape);
+ dict.SetEscapedValue("relative URL", "/search?q=green flowers&hl=en",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_css_escape);
+ dict.SetEscapedValue("hardest URL", "http://www.google.com/s?q='bla'"
+ "&a=\"\"&b=(<tag>)&c=*\r\n\\\\bla",
+ GOOGLE_NAMESPACE::validate_img_src_url_and_css_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy http URL"),
+ "http://www.google.com");
+ EXPECT_STREQ(peer.GetSectionValue("harder https URL"),
+ "https://www.google.com/search?q=f&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("javascript URL"),
+ GOOGLE_NAMESPACE::ValidateUrl::kUnsafeImgSrcUrlReplacement);
+ EXPECT_STREQ(peer.GetSectionValue("relative URL"),
+ "/search?q=green flowers&hl=en");
+ EXPECT_STREQ(peer.GetSectionValue("hardest URL"),
+ "http://www.google.com/s?q=%27bla%27"
+ "&a=%22%22&b=%28%3Ctag%3E%29&c=%2A%0D%0A%5C%5Cbla");
+}
+
+TEST(TemplateModifiers, CleanseAttribute) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestCleanseAttribute", NULL);
+ dict.SetEscapedValue("easy attribute", "top",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+ dict.SetEscapedValue("harder attribute", "foo & bar",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+ dict.SetEscapedValue("hardest attribute",
+ "top onclick='alert(document.cookie)'",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+ dict.SetEscapedValue("equal in middle", "foo = bar",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+ dict.SetEscapedValue("leading equal", "=foo",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+ dict.SetEscapedValue("trailing equal", "foo=",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+ dict.SetEscapedValue("all equals", "===foo===bar===",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+ dict.SetEscapedValue("just equals", "===",
+ GOOGLE_NAMESPACE::cleanse_attribute);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy attribute"), "top");
+ EXPECT_STREQ(peer.GetSectionValue("harder attribute"), "foo___bar");
+ EXPECT_STREQ(peer.GetSectionValue("hardest attribute"),
+ "top_onclick=_alert_document.cookie__");
+
+ EXPECT_STREQ(peer.GetSectionValue("equal in middle"), "foo_=_bar");
+ EXPECT_STREQ(peer.GetSectionValue("leading equal"), "_foo");
+ EXPECT_STREQ(peer.GetSectionValue("trailing equal"), "foo_");
+ EXPECT_STREQ(peer.GetSectionValue("just equals"), "_=_");
+ EXPECT_STREQ(peer.GetSectionValue("all equals"), "_==foo===bar==_");
+}
+
+TEST(TemplateModifiers, CleanseCss) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestCleanseCss", NULL);
+ dict.SetEscapedValue("easy css", "top",
+ GOOGLE_NAMESPACE::cleanse_css);
+ dict.SetEscapedValue("harder css", "foo & bar",
+ GOOGLE_NAMESPACE::cleanse_css);
+ dict.SetEscapedValue("hardest css",
+ ";width:expression(document.cookie)",
+ GOOGLE_NAMESPACE::cleanse_css);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy css"),
+ "top");
+ EXPECT_STREQ(peer.GetSectionValue("harder css"),
+ "foo bar");
+ EXPECT_STREQ(peer.GetSectionValue("hardest css"),
+ "widthexpressiondocument.cookie");
+}
+
+TEST(TemplateModifiers, JavascriptEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestJavascriptEscape", NULL);
+ dict.SetEscapedValue("easy JS", "joo",
+ GOOGLE_NAMESPACE::javascript_escape);
+ dict.SetEscapedValue("harder JS", "f = 'joo';",
+ GOOGLE_NAMESPACE::javascript_escape);
+ dict.SetEscapedValue("hardest JS",
+ ("f = 'foo\f';\r\n\tprint \"\\&foo = \b\", \"foo\""),
+ GOOGLE_NAMESPACE::javascript_escape);
+ dict.SetEscapedValue("close script JS",
+ "//--></script><script>alert(123);</script>",
+ GOOGLE_NAMESPACE::javascript_escape);
+ dict.SetEscapedValue("unicode codepoints",
+ ("line1" "\xe2\x80\xa8" "line2" "\xe2\x80\xa9" "line3"
+ /* \u2027 */ "\xe2\x80\xa7"
+ /* \u202A */ "\xe2\x80\xaa"
+ /* malformed */ "\xe2" "\xe2\x80\xa8"
+ /* truncated */ "\xe2\x80"),
+ GOOGLE_NAMESPACE::javascript_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy JS"), "joo");
+ EXPECT_STREQ(peer.GetSectionValue("harder JS"), "f \\x3d \\x27joo\\x27;");
+ EXPECT_STREQ(peer.GetSectionValue("hardest JS"),
+ "f \\x3d \\x27foo\\f\\x27;\\r\\n\\tprint \\x22\\\\\\x26foo "
+ "\\x3d \\b\\x22, \\x22foo\\x22");
+ EXPECT_STREQ(peer.GetSectionValue("close script JS"),
+ "//--\\x3e\\x3c/script\\x3e\\x3cscript\\x3e"
+ "alert(123);\\x3c/script\\x3e");
+ EXPECT_STREQ(peer.GetSectionValue("unicode codepoints"),
+ "line1" "\\u2028" "line2" "\\u2029" "line3"
+ "\xe2\x80\xa7"
+ "\xe2\x80\xaa"
+ "\xe2" "\\u2028"
+ "\xe2\x80");
+}
+
+TEST(TemplateModifiers, JavascriptNumber) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestJavascriptNumber", NULL);
+ dict.SetEscapedValue("empty string", "",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("boolean true", "true",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("boolean false", "false",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("bad boolean 1", "tfalse",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("bad boolean 2", "tru",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("bad boolean 3", "truee",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("bad boolean 4", "invalid",
+ GOOGLE_NAMESPACE::javascript_number);
+
+ // Check that our string comparisons for booleans do not
+ // assume input is null terminated.
+ dict.SetEscapedValue("good boolean 5", GOOGLE_NAMESPACE::TemplateString("truee", 4),
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("bad boolean 6", GOOGLE_NAMESPACE::TemplateString("true", 3),
+ GOOGLE_NAMESPACE::javascript_number);
+
+ dict.SetEscapedValue("hex number 1", "0x123456789ABCDEF",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("hex number 2", "0X123456789ABCDEF",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("bad hex number 1", "0x123GAC",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("bad hex number 2", "0x",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("number zero", "0",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("invalid number", "A9",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("decimal zero", "0.0",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("octal number", "01234567",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("decimal number", "799.123",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("negative number", "-244",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("positive number", "+244",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("valid float 1", ".55",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("valid float 2", "8.55e-12",
+ GOOGLE_NAMESPACE::javascript_number);
+ dict.SetEscapedValue("invalid float", "8.55ABC",
+ GOOGLE_NAMESPACE::javascript_number);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("empty string"), "");
+ EXPECT_STREQ(peer.GetSectionValue("boolean true"), "true");
+ EXPECT_STREQ(peer.GetSectionValue("boolean false"), "false");
+ EXPECT_STREQ(peer.GetSectionValue("bad boolean 1"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("bad boolean 2"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("bad boolean 3"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("bad boolean 4"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("good boolean 5"), "true");
+ EXPECT_STREQ(peer.GetSectionValue("bad boolean 6"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("hex number 1"), "0x123456789ABCDEF");
+ EXPECT_STREQ(peer.GetSectionValue("hex number 2"), "0X123456789ABCDEF");
+ EXPECT_STREQ(peer.GetSectionValue("bad hex number 1"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("bad hex number 2"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("number zero"), "0");
+ EXPECT_STREQ(peer.GetSectionValue("invalid number"), "null");
+ EXPECT_STREQ(peer.GetSectionValue("decimal zero"), "0.0");
+ EXPECT_STREQ(peer.GetSectionValue("octal number"), "01234567");
+ EXPECT_STREQ(peer.GetSectionValue("decimal number"), "799.123");
+ EXPECT_STREQ(peer.GetSectionValue("negative number"), "-244");
+ EXPECT_STREQ(peer.GetSectionValue("positive number"), "+244");
+ EXPECT_STREQ(peer.GetSectionValue("valid float 1"), ".55");
+ EXPECT_STREQ(peer.GetSectionValue("valid float 2"), "8.55e-12");
+ EXPECT_STREQ(peer.GetSectionValue("invalid float"), "null");
+}
+
+TEST(TemplateModifiers, JsonEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestJsonEscape", NULL);
+ dict.SetEscapedValue("easy JSON", "joo",
+ GOOGLE_NAMESPACE::json_escape);
+ dict.SetEscapedValue("harder JSON", "f = \"joo\"; e = 'joo';",
+ GOOGLE_NAMESPACE::json_escape);
+ dict.SetEscapedValue("hardest JSON",
+ "f = 'foo<>';\r\n\t\fprint \"\\&foo = /\b\", \"foo\"",
+ GOOGLE_NAMESPACE::json_escape);
+ dict.SetEscapedValue("html in JSON", "<html> </html>",
+ GOOGLE_NAMESPACE::json_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("easy JSON"), "joo");
+ EXPECT_STREQ(peer.GetSectionValue("harder JSON"), "f = \\\"joo\\\"; "
+ "e = 'joo';");
+ EXPECT_STREQ(peer.GetSectionValue("html in JSON"),
+ "\\u003Chtml\\u003E\\u0026nbsp;\\u003C\\/html\\u003E");
+ // There's a bug in MSVC 7.1 where you can't pass a literal string
+ // with more than one \" in it to a macro (!) -- see
+ // http://marc.info/?t=110853662500001&r=1&w=2
+ // We work around this by assigning the string to a variable first.
+ const char* expected = ("f = 'foo\\u003C\\u003E';\\r\\n\\t\\fprint \\\""
+ "\\\\\\u0026foo = \\/\\b\\\", \\\"foo\\\"");
+ EXPECT_STREQ(peer.GetSectionValue("hardest JSON"), expected);
+}
+
+TEST(TemplateModifiers, UrlQueryEscape) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestUrlQueryEscape", NULL);
+ // The first three tests do not need escaping.
+ dict.SetEscapedValue("query escape 0", "",
+ GOOGLE_NAMESPACE::url_query_escape);
+ dict.SetEscapedValue("query escape 1", "noop",
+ GOOGLE_NAMESPACE::url_query_escape);
+ dict.SetEscapedValue("query escape 2",
+ "0123456789abcdefghjijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ.-_*/~!(),",
+ GOOGLE_NAMESPACE::url_query_escape);
+ dict.SetEscapedValue("query escape 3", " ?a=b;c#d ",
+ GOOGLE_NAMESPACE::url_query_escape);
+ dict.SetEscapedValue("query escape 4", "#$%&+<=>?@[\\]^`{|}",
+ GOOGLE_NAMESPACE::url_query_escape);
+ dict.SetEscapedValue("query escape 5", "\xDE\xAD\xCA\xFE",
+ GOOGLE_NAMESPACE::url_query_escape);
+ dict.SetEscapedValue("query escape 6", "\"':",
+ GOOGLE_NAMESPACE::url_query_escape);
+
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&dict); // peer can look inside dicts
+ EXPECT_STREQ(peer.GetSectionValue("query escape 0"), "");
+ EXPECT_STREQ(peer.GetSectionValue("query escape 1"), "noop");
+ EXPECT_STREQ(peer.GetSectionValue("query escape 2"),
+ "0123456789abcdefghjijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ.-_*/~!(),");
+ EXPECT_STREQ(peer.GetSectionValue("query escape 3"), "+%3Fa%3Db%3Bc%23d+");
+ EXPECT_STREQ(peer.GetSectionValue("query escape 4"),
+ "%23%24%25%26%2B%3C%3D%3E%3F%40%5B%5C%5D%5E%60%7B%7C%7D");
+ EXPECT_STREQ(peer.GetSectionValue("query escape 5"), "%DE%AD%CA%FE");
+ EXPECT_STREQ(peer.GetSectionValue("query escape 6"), "%22%27%3A");
+}
+
+TEST(TemplateModifiers, PrefixLine) {
+ GOOGLE_NAMESPACE::TemplateDictionary dict("TestPrefixLine", NULL);
+ // These don't escape: we don't put the prefix before the first line
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1", " ").c_str(),
+ "pt 1");
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1", "::").c_str(),
+ "pt 1");
+
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1\npt 2", ":").c_str(),
+ "pt 1\n:pt 2");
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1\npt 2", " ").c_str(),
+ "pt 1\n pt 2");
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1\npt 2", "\n").c_str(),
+ "pt 1\n\npt 2");
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1\npt 2\n", " ").c_str(),
+ "pt 1\n pt 2\n ");
+
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1\rpt 2\n", ":").c_str(),
+ "pt 1\r:pt 2\n:");
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1\npt 2\r", ":").c_str(),
+ "pt 1\n:pt 2\r:");
+ EXPECT_STREQ(GOOGLE_NAMESPACE::prefix_line("pt 1\r\npt 2\r", ":").c_str(),
+ "pt 1\r\n:pt 2\r:");
+}
+
+TEST(TemplateModifiers, FindModifier) {
+ const GOOGLE_NAMESPACE::ModifierInfo* info;
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("html_escape", 11, "", 0)));
+ EXPECT_EQ(info->modifier, &GOOGLE_NAMESPACE::html_escape);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("h", 1, "", 0)));
+ EXPECT_EQ(info->modifier, &GOOGLE_NAMESPACE::html_escape);
+
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("html_escape_with_arg", 20,
+ "=pre", 4)));
+ EXPECT_EQ(info->modifier, &GOOGLE_NAMESPACE::pre_escape);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("H", 1, "=pre", 4)));
+ EXPECT_EQ(info->modifier, &GOOGLE_NAMESPACE::pre_escape);
+
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("javascript_escape_with_arg",
+ 26, "=number", 7)));
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("J", 1, "=number", 7)));
+ EXPECT_EQ(info->modifier, &GOOGLE_NAMESPACE::javascript_number);
+
+ // html_escape_with_arg doesn't have a default value, so these should fail.
+ EXPECT_FALSE(GOOGLE_NAMESPACE::FindModifier("H", 1, "=pre", 2)); // "=p"
+ EXPECT_FALSE(GOOGLE_NAMESPACE::FindModifier("H", 1, "=pree", 5));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::FindModifier("H", 1, "=notpresent", 11));
+
+ // If we don't have a modifier-value when we ought, we should fail.
+ EXPECT_FALSE(GOOGLE_NAMESPACE::FindModifier("html_escape", 11, "=p", 2));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::FindModifier("h", 1, "=p", 2));
+
+ EXPECT_FALSE(GOOGLE_NAMESPACE::FindModifier("html_escape_with_arg", 20,
+ "", 0));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::FindModifier("H", 1, "", 0));
+
+ // Test with added modifiers as well.
+ GOOGLE_NAMESPACE::NullModifier foo_modifier1;
+ GOOGLE_NAMESPACE::NullModifier foo_modifier2;
+ GOOGLE_NAMESPACE::NullModifier foo_modifier3;
+ GOOGLE_NAMESPACE::NullModifier foo_modifier4;
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-test", &foo_modifier1));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-test-arg=", &foo_modifier2));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-test-arg=h", &foo_modifier3));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-test-arg=json", &foo_modifier4));
+
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test", 6, "", 0)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier1);
+ EXPECT_EQ(info->xss_class, GOOGLE_NAMESPACE::XSS_UNIQUE);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test", 6, "=h", 2)));
+ EXPECT_FALSE(info->is_registered);
+ // This tests default values
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10, "=p", 2)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier2);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10, "=h", 2)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier3);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10, "=html", 5)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier2);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10, "=json", 5)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier4);
+ // The value is required to start with an '=' to match the
+ // specialization. If it doesn't, it will match the default.
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10, "json", 4)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier2);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10,
+ "=jsonnabbe", 5)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier4);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10,
+ "=jsonnabbe", 6)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier2);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-test-arg", 10,
+ "=jsonnabbe", 4)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->modifier, &foo_modifier2);
+
+ // If we try to find an x- modifier that wasn't added, we should get
+ // a legit but "unknown" modifier back.
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-foo", 5, "", 0)));
+ EXPECT_FALSE(info->is_registered);
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-bar", 5, "=p", 2)));
+ EXPECT_FALSE(info->is_registered);
+
+ // Basic test with added XssSafe modifier.
+ GOOGLE_NAMESPACE::NullModifier foo_modifier5;
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-safetest",
+ &foo_modifier5));
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-safetest", 10, "", 0)));
+ EXPECT_TRUE(info->is_registered);
+ EXPECT_EQ(info->xss_class, GOOGLE_NAMESPACE::XSS_SAFE);
+ EXPECT_EQ(info->modifier, &foo_modifier5);
+}
+
+TEST(TemplateModifiers, AddModifier) {
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-atest", &GOOGLE_NAMESPACE::html_escape));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=", &GOOGLE_NAMESPACE::html_escape));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=h", &GOOGLE_NAMESPACE::html_escape));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=html", &GOOGLE_NAMESPACE::html_escape));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=json", &GOOGLE_NAMESPACE::json_escape));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=j", &GOOGLE_NAMESPACE::json_escape));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=J", &GOOGLE_NAMESPACE::json_escape));
+
+ // Make sure AddModifier fails with an invalid name.
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("test", &GOOGLE_NAMESPACE::html_escape));
+
+ // Make sure AddModifier fails with a duplicate name.
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("x-atest", &GOOGLE_NAMESPACE::html_escape));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=", &GOOGLE_NAMESPACE::html_escape));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=h", &GOOGLE_NAMESPACE::html_escape));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("x-atest-arg=html", &GOOGLE_NAMESPACE::html_escape));
+
+ const GOOGLE_NAMESPACE::ModifierInfo* info;
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-atest", 7, "", 0)));
+ EXPECT_FALSE(info->modval_required);
+
+ // Make sure we can still add a modifier after having already
+ // searched for it.
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-foo", 5, "", 0)));
+ EXPECT_FALSE(info->is_registered);
+
+ GOOGLE_NAMESPACE::NullModifier foo_modifier;
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-foo", &foo_modifier));
+ EXPECT_TRUE((info = GOOGLE_NAMESPACE::FindModifier("x-foo", 5, "", 0)));
+ EXPECT_EQ(info->modifier, &foo_modifier);
+}
+
+TEST(TemplateModifiers, AddXssSafeModifier) {
+ // For shorter lines.
+ const GOOGLE_NAMESPACE::TemplateModifier* esc_fn =
+ &GOOGLE_NAMESPACE::html_escape;
+
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-asafetest", esc_fn));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-asafetest-arg=", esc_fn));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-asafetest-arg=h", esc_fn));
+
+ // Make sure AddXssSafeModifier fails with an invalid name.
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddXssSafeModifier("test", esc_fn));
+
+ // Make sure AddXssSafeModifier fails with a duplicate name.
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-asafetest", esc_fn));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-asafetest-arg=", esc_fn));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-asafetest-arg=h",
+ esc_fn));
+
+ // Make sure AddXssSafeModifier fails if the same modifier was
+ // previously added via AddModifier.
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-safetest2", esc_fn));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-safetest2-arg=", esc_fn));
+ EXPECT_TRUE(GOOGLE_NAMESPACE::AddModifier("x-safetest2-arg=h", esc_fn));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-safetest2", esc_fn));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-safetest2-arg=", esc_fn));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddXssSafeModifier("x-safetest2-arg=h", esc_fn));
+
+ // and vice versa.
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("x-asafetest", esc_fn));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("x-asafetest-arg=", esc_fn));
+ EXPECT_FALSE(GOOGLE_NAMESPACE::AddModifier("x-asafetest-arg=h", esc_fn));
+}
+
+// Helper function. Determines whether the Modifier specified by
+// alt_modname/alt_modval is a safe XSS alternative to
+// the Modifier specified by modname/modval.
+static bool CheckXSSAlternative(const string& modname, const string& modval,
+ const string& alt_modname,
+ const string& alt_modval) {
+ const GOOGLE_NAMESPACE::ModifierInfo *mod, *alt_mod;
+ mod = GOOGLE_NAMESPACE::FindModifier(modname.c_str(), modname.length(),
+ modval.c_str(), modval.length());
+ alt_mod = GOOGLE_NAMESPACE::FindModifier(alt_modname.c_str(),
+ alt_modname.length(),
+ alt_modval.c_str(),
+ alt_modval.length());
+ EXPECT_TRUE(mod != NULL && alt_mod != NULL);
+ return IsSafeXSSAlternative(*mod, *alt_mod);
+}
+
+TEST(TemplateModifiers, XSSAlternatives) {
+ // A modifier is always a safe replacement to itself, even non built-in.
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "h", ""));
+ EXPECT_TRUE(CheckXSSAlternative("url_escape_with_arg", "=javascript",
+ "url_escape_with_arg", "=javascript"));
+ EXPECT_TRUE(CheckXSSAlternative("x-bla", "", "x-bla", ""));
+
+ // A built-in modifier is always a safe replacement to
+ // another with the same function.
+ EXPECT_TRUE(CheckXSSAlternative("H", "=pre", "p", ""));
+ EXPECT_TRUE(CheckXSSAlternative("url_query_escape", "",
+ "url_escape_with_arg", "=query"));
+
+ // H=(pre|snippet|attribute), p, u, U=query, U=html (a.k.a H=url)
+ // and I=html are all alternatives to h.
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "H", "=pre"));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "H", "=snippet"));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "H", "=attribute"));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "H", "=url"));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "p", ""));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "u", ""));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "U", "=query"));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "U", "=html"));
+ EXPECT_TRUE(CheckXSSAlternative("h", "", "I", "=html"));
+
+ // But h is not an alternative to H=attribute and I=html,
+ // nor is json_escape an alternative to h.
+ EXPECT_FALSE(CheckXSSAlternative("H", "=attribute", "h", ""));
+ EXPECT_FALSE(CheckXSSAlternative("I", "=html", "h", ""));
+ EXPECT_FALSE(CheckXSSAlternative("h", "", "json_escape", ""));
+
+ // H=snippet and H=attribute are alternatives to H=pre
+ // But H=pre is not an alternative to H=attribute.
+ EXPECT_TRUE(CheckXSSAlternative("H", "=pre", "H", "=snippet"));
+ EXPECT_TRUE(CheckXSSAlternative("H", "=pre", "H", "=attribute"));
+ EXPECT_FALSE(CheckXSSAlternative("H", "=attribute", "H", "=pre"));
+
+ // javascript_escape is an alternative to json_escape and vice versa
+ EXPECT_TRUE(CheckXSSAlternative("json_escape", "", "javascript_escape", ""));
+ EXPECT_TRUE(CheckXSSAlternative("javascript_escape", "", "json_escape", ""));
+
+ // I=javascript is an alternative to :j and :U=javascript but not
+ // vice versa
+ EXPECT_TRUE(CheckXSSAlternative("javascript_escape", "", "I", "=javascript"));
+ EXPECT_TRUE(CheckXSSAlternative("U", "=javascript", "I", "=javascript"));
+ EXPECT_FALSE(CheckXSSAlternative("I", "=javascript", "javascript_escape", ""));
+ EXPECT_FALSE(CheckXSSAlternative("I", "=javascript", "U", "=javascript"));
+
+ // U=css and I=css are alternatives to :c but not vice versa
+ EXPECT_TRUE(CheckXSSAlternative("c", "", "U", "=css"));
+ EXPECT_TRUE(CheckXSSAlternative("c", "", "I", "=css"));
+ EXPECT_FALSE(CheckXSSAlternative("U", "=css", "c", ""));
+ EXPECT_FALSE(CheckXSSAlternative("I", "=css", "c", ""));
+
+ // Extended modifier should not match any other except itself.
+ EXPECT_FALSE(CheckXSSAlternative("x-bla", "", "x-foo", ""));
+}
+
+// This is a basic sanity check for the GetDefaultModifierForXXX() functions.
+// More testing happens in AutoEscaper code which uses them.
+TEST(TemplateModifiers, DefaultModifiersForContext) {
+ const GOOGLE_NAMESPACE::ModifierAndValue* modval;
+ string print_mods;
+
+ const vector<const GOOGLE_NAMESPACE::ModifierAndValue*> modvals_html =
+ GOOGLE_NAMESPACE::GetDefaultModifierForHtml();
+ EXPECT_EQ(1, modvals_html.size());
+ print_mods = GOOGLE_NAMESPACE::PrettyPrintModifiers(modvals_html, ";");
+ EXPECT_STREQ(":h", print_mods.c_str());
+ modval = modvals_html.front();
+ EXPECT_EQ(modval->modifier_info->modifier, &GOOGLE_NAMESPACE::html_escape);
+
+ const vector<const GOOGLE_NAMESPACE::ModifierAndValue*> modvals_js =
+ GOOGLE_NAMESPACE::GetDefaultModifierForJs();
+ EXPECT_EQ(1, modvals_js.size());
+ print_mods = GOOGLE_NAMESPACE::PrettyPrintModifiers(modvals_js, ";");
+ EXPECT_STREQ(":j", print_mods.c_str());
+ modval = modvals_js.front();
+ EXPECT_EQ(modval->modifier_info->modifier, &GOOGLE_NAMESPACE::javascript_escape);
+
+ const vector<const GOOGLE_NAMESPACE::ModifierAndValue*> modvals_xml =
+ GOOGLE_NAMESPACE::GetDefaultModifierForXml();
+ EXPECT_EQ(1, modvals_xml.size());
+ print_mods = GOOGLE_NAMESPACE::PrettyPrintModifiers(modvals_xml, ";");
+ EXPECT_STREQ(":xml_escape", print_mods.c_str());
+ modval = modvals_xml.front();
+ EXPECT_EQ(modval->modifier_info->modifier, &GOOGLE_NAMESPACE::xml_escape);
+
+ const vector<const GOOGLE_NAMESPACE::ModifierAndValue*> modvals_json =
+ GOOGLE_NAMESPACE::GetDefaultModifierForJson();
+ EXPECT_EQ(1, modvals_json.size());
+ print_mods = GOOGLE_NAMESPACE::PrettyPrintModifiers(modvals_json, ";");
+ EXPECT_STREQ(":j", print_mods.c_str());
+ modval = modvals_json.front();
+ EXPECT_EQ(modval->modifier_info->modifier, &GOOGLE_NAMESPACE::javascript_escape);
+}
+
+// This tests for a bug we had where we were returning a pointer into
+// a vector that became invalid after the vector was resized.
+TEST(TemplateModifiers, ManyUnknownModifiers) {
+ string tpl_str1 = "{{from_name:x-test=4}} sent you a message";
+ const GOOGLE_NAMESPACE::Template* tpl1 = GOOGLE_NAMESPACE::Template::StringToTemplate(
+ tpl_str1, GOOGLE_NAMESPACE::DO_NOT_STRIP);
+
+ string tpl_str2 = "{{from_name:x-test=4}} sent you a message:";
+ string expected_out = "me sent you a message:";
+ // All those new unknown varnames should cause g_unknown_modifiers
+ // to resize. 1111 is an arbitrary large number.
+ for (int i = 0; i < 1111; i++) {
+ tpl_str2.append("{{from_name:x-" + string(i, 't') + "=4}}");
+ expected_out.append("me");
+ }
+ const GOOGLE_NAMESPACE::Template* tpl2 = GOOGLE_NAMESPACE::Template::StringToTemplate(
+ tpl_str2, GOOGLE_NAMESPACE::DO_NOT_STRIP);
+
+ // Even after the resizing, the references to the unknown
+ // modifiers in tpl1 and tpl2 should still be valid.
+ GOOGLE_NAMESPACE::TemplateDictionary dict("test");
+ dict.SetValue("from_name", "me");
+ string out;
+
+ out.clear();
+ tpl1->Expand(&out, &dict);
+ EXPECT_STREQ("me sent you a message", out.c_str());
+ delete tpl1;
+
+ out.clear();
+ tpl2->Expand(&out, &dict);
+ EXPECT_STREQ(expected_out.c_str(), out.c_str());
+ delete tpl2;
+}
+
+
+int main(int argc, char** argv) {
+
+ return RUN_ALL_TESTS();
+}
diff --git a/src/tests/template_regtest.cc b/src/tests/template_regtest.cc
new file mode 100644
index 0000000..bc1297f
--- /dev/null
+++ b/src/tests/template_regtest.cc
@@ -0,0 +1,498 @@
+// Copyright (c) 2005, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// This test consists of creating a pretty complicated
+// dictionary, and then applying it to a bunch of templates
+// (specified in the testdata dir) and making sure the output
+// is as expected. We actually support testing with multiple
+// dictionaries. We glob the testdat dir, so it's possible to
+// add a new test just by creating a template and expected-output
+// file in the testdata directory. Files are named
+// template_unittest_testXX.in
+// template_unittest_testXX_dictYY.out
+// YY should start with 01 (not 00). XX can be an arbitrary string.
+
+#include "config_for_unittests.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <assert.h>
+#include <sys/types.h>
+#ifdef HAVE_DIRENT_H
+# include <dirent.h> // for opendir() etc
+#else
+# define dirent direct
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif // for opendir() etc
+#include <algorithm> // for sort() and stable_partition
+#include <string>
+#include <vector>
+#include <ctemplate/template.h>
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_modifiers.h>
+#include <ctemplate/template_pathops.h>
+#include "base/util.h"
+
+using std::vector;
+using std::string;
+using std::sort;
+
+using GOOGLE_NAMESPACE::DO_NOT_STRIP;
+using GOOGLE_NAMESPACE::PerExpandData;
+using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
+using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
+using GOOGLE_NAMESPACE::TC_HTML;
+using GOOGLE_NAMESPACE::TC_MANUAL;
+using GOOGLE_NAMESPACE::Template;
+using GOOGLE_NAMESPACE::TemplateDictionary;
+
+#define ASSERT(cond) do { \
+ if (!(cond)) { \
+ printf("%s: %d: ASSERT FAILED: %s\n", __FILE__, __LINE__, \
+ #cond); \
+ assert(cond); \
+ exit(1); \
+ } \
+} while (0)
+
+#define ASSERT_STRING_EQ(a, b) do { \
+ assert(StringEq(a, b, __FILE__, __LINE__, #a, #b)); \
+} while (0)
+
+bool StringEq(const string& a, const string& b,
+ const char* filename, int lineno,
+ const char* namea, const char* nameb) {
+ if (a != b) {
+ printf("%s: %d: ASSERT FAILED: %s == %s:\n", filename, lineno,
+ namea, nameb);
+ printf("EXPECTED:\n%s\n", a.c_str());
+ printf("ACTUAL:\n%s\n", b.c_str());
+ return false;
+ }
+ return true;
+}
+
+#define ASSERT_STREQ_EXCEPT(a, b, except) ASSERT(StreqExcept(a, b, except))
+#define ASSERT_STREQ(a, b) ASSERT(strcmp(a, b) == 0)
+#define ASSERT_NOT_STREQ(a, b) ASSERT(strcmp(a, b) != 0)
+
+// First, (conceptually) remove all chars in "except" from both a and b.
+// Then return true iff munged_a == munged_b.
+bool StreqExcept(const char* a, const char* b, const char* except) {
+ const char* pa = a, *pb = b;
+ const size_t exceptlen = strlen(except);
+ while (1) {
+ // Use memchr instead of strchr because strchr(foo, '\0') always fails
+ while (memchr(except, *pa, exceptlen)) pa++; // ignore "except" chars in a
+ while (memchr(except, *pb, exceptlen)) pb++; // ignore "except" chars in b
+ if ((*pa == '\0') && (*pb == '\0'))
+ return true;
+ if (*pa++ != *pb++) // includes case where one is at \0
+ return false;
+ }
+}
+
+
+RegisterTemplateFilename(VALID1_FN, "template_unittest_test_valid1.in");
+RegisterTemplateFilename(INVALID1_FN, "template_unittest_test_invalid1.in");
+RegisterTemplateFilename(INVALID2_FN, "template_unittest_test_invalid2.in");
+RegisterTemplateFilename(NONEXISTENT_FN, "nonexistent__file.tpl");
+
+struct Testdata {
+ string input_template_name; // the filename of the input template
+ string input_template; // the contents of the input template
+ vector<string> output; // entry i is the output of using dict i.
+ vector<string> annotated_output; // used to test annotations
+};
+
+static void ReadToString(const string& filename, string* s) {
+ const int bufsize = 8092;
+ char buffer[bufsize];
+ size_t n;
+ FILE* fp = fopen(filename.c_str(), "rb");
+ if (!fp) PFATAL(filename.c_str());
+ while ((n=fread(buffer, 1, bufsize, fp)) > 0) {
+ if (ferror(fp)) PFATAL(filename.c_str());
+ s->append(string(buffer, n));
+ }
+ fclose(fp);
+}
+
+static bool EndsWith(const string& s, const string& suffix) {
+ return (s.length() >= suffix.length() &&
+ s.substr(s.length() - suffix.length()) == suffix);
+}
+
+#ifndef USING_PORT_CC /* windows defines its own version in windows/port.cc */
+static void GetNamelist(const char* testdata_dir, vector<string>* namelist) {
+ DIR* dir = opendir(testdata_dir);
+ struct dirent* dir_entry;
+ if (dir == NULL) PFATAL("opendir");
+ while ( (dir_entry=readdir(dir)) != NULL ) {
+ if (!strncmp(dir_entry->d_name, "template_unittest_test",
+ sizeof("template_unittest_test")-1)) {
+ namelist->push_back(dir_entry->d_name); // collect test files
+ }
+ }
+ if (closedir(dir) != 0) PFATAL("closedir");
+}
+#endif
+
+// expensive to resize this vector and copy it and all, but that's ok
+static vector<Testdata> ReadDataFiles(const char* testdata_dir) {
+ vector<Testdata> retval;
+ vector<string> namelist;
+
+ GetNamelist(testdata_dir, &namelist);
+ sort(namelist.begin(), namelist.end());
+
+ for (vector<string>::const_iterator it = namelist.begin();
+ it != namelist.end(); ++it) {
+ vector<string>* new_output = NULL;
+ const string fname = string(testdata_dir) + "/" + it->c_str();
+ if (EndsWith(fname, ".in")) {
+ retval.push_back(Testdata());
+ retval.back().input_template_name = *it;
+ ReadToString(fname, &retval.back().input_template);
+ } else if (EndsWith(fname, ".out")) {
+ new_output = &retval.back().output;
+ } else if (EndsWith(fname, ".anno_out")) {
+ new_output = &retval.back().annotated_output;
+ } else {
+ ASSERT(false); // Filename must end in either .in, .out, or .anno_out.
+ }
+ if (new_output) { // the .out and .anno_out cases
+ ASSERT(!retval.empty()); // an .out without any corresponding .in?
+ ASSERT(it->length() > retval.back().input_template_name.length() + 4);
+ // input file is foo.in, and output is foo_dictYY.out. This gets to YY.
+ const char* dictnum_pos = (it->c_str() +
+ retval.back().input_template_name.length() + 2);
+ int dictnum = atoi32(dictnum_pos); // just ignore chars after the YY
+ ASSERT(dictnum); // dictnums should start with 01
+ while (new_output->size() <
+ static_cast<vector<string>::size_type>(dictnum))
+ new_output->push_back(string());
+ ReadToString(fname, &((*new_output)[dictnum-1]));
+ }
+ }
+ return retval;
+}
+
+
+// Creates a complicated dictionary, using every TemplateDictionary
+// command under the sun. Returns a pointer to the new dictionary-root.
+// Should be freed by the caller.
+static TemplateDictionary* MakeDict1() {
+ TemplateDictionary* dict = new TemplateDictionary("dict1", NULL);
+ dict->SetFilename("just used for debugging, so doesn't matter.txt");
+
+ // --- These are used by template_unittest_test_simple.in
+ dict->SetValue("HEAD", " This is the head ");
+ // We leave BODY undefined, to make sure that expansion works properly.
+
+ // --- These are used by template_unittest_test_footer.in
+ TemplateDictionary* fbt = dict->AddSectionDictionary("FOOTER_BAR_TEXT");
+ fbt->SetValue("BODY", "Should never be shown"); // this is part of simple
+ fbt->SetEscapedValue("HOME_LINK", "<b>Time to go home!</b>",
+ GOOGLE_NAMESPACE::html_escape);
+ // Note: you should never have code like this in real life! The <b>
+ // and </b> should be part of the template proper.
+ fbt->SetFormattedValue("ADVERTISE_LINK", "<b>Be advertiser #%d</b>", 2);
+ fbt->SetValue("ABOUT_GOOGLE_LINK", "<A HREF=/>About Google!</A>");
+
+ // We show PROMO_LICENSING_SECTION in the main dict, even though
+ // it's defined in the fbt subsection. This will still work: section
+ // showing goes to the parent dict if not found in the current dict.
+ dict->ShowSection("PROMO_LICENSING_SECTION");
+ dict->SetValue("PROMO_LICENSING_LINK", "<A HREF='foo'>");
+
+ // We don't show the TRIM_LINE section, so these vars shouldn't be seen
+ dict->SetValue("TRIM_LINE_COLOR", "Who cares?");
+ dict->SetIntValue("TRIM_LINE_HEIGHT", 10);
+
+ dict->SetIntValue("MODIFIED_BY_GOOGLE", 2005);
+ dict->SetValue("MSG_copyright", "© Google Inc. (all rights reserved)");
+ // We don't set ODP_ATTRIBUTION, so this include is ignored.
+
+ dict->ShowSection("CLOSING_DIV_SECTION");
+
+ // We won't set any of the includes that follow, just to keep things simple
+
+ // First, call SetValueAndShowSection on a non-existence section, should noop
+ dict->SetValueAndShowSection("LATENCY_PREFETCH_URL", "/huh?",
+ "UNUSED_SECTION_NAME");
+ // Now try the real URL
+ dict->SetValueAndShowSection("LATENCY_PREFETCH_URL", string("/latency"),
+ "LATENCY_PREFETCH");
+
+ // JAVASCRIPT_FOOTER_SECTION was meant to be either shown or hidden, but
+ // hey, let's try showing it several times, each with a different include.
+ // And let's include each one several times.
+ TemplateDictionary* jfs1 = dict->AddSectionDictionary(
+ "JAVASCRIPT_FOOTER_SECTION");
+ // This first dictionary should have an empty HEAD and BODY
+ TemplateDictionary* inc1a = jfs1->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT");
+ inc1a->SetFilename("template_unittest_test_simple.in");
+ // For the second dict, let's set an illegal filename: should be ignored
+ TemplateDictionary* inc1b = jfs1->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT");
+ inc1b->SetFilename(INVALID1_FN);
+ // For the third dict, let's do the same as the first, but with a HEAD
+ TemplateDictionary* inc1c = jfs1->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT");
+ inc1c->SetFilename("template_unittest_test_simple.in");
+ inc1c->SetValue("HEAD", "head");
+
+ // Let's expand the section again with two different includes, and again a
+ // third template not meant to be expanded (in this case, don't set filename)
+ TemplateDictionary* jfs2 = dict->AddSectionDictionary(
+ "JAVASCRIPT_FOOTER_SECTION");
+ TemplateDictionary* inc2a = jfs2->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT");
+ inc2a->SetFilename("template_unittest_test_simple.in");
+ inc2a->SetValue("HEAD", "include-head");
+ inc2a->SetEscapedFormattedValue("BODY", GOOGLE_NAMESPACE::html_escape,
+ "<b>%s</b>: %.4f", "<A HREF=/>", 1.0/3);
+ inc2a->SetValue("BI_NEWLINE", ""); // override the global default
+ TemplateDictionary* inc2b = jfs2->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT");
+ inc2b->SetFilename("template_unittest_test_html.in");
+ inc2b->SetValue("HEAD", "should be ignored");
+ jfs2->AddIncludeDictionary("FAST_NEXT_JAVASCRIPT"); // ignored: no filename
+
+ // --- These are used by template_unittest_test_html.in
+
+ // This should returns in NO_MOUSEOVER_FUNCTIONS remaining hidden
+ dict->SetValueAndShowSection("DUMMY", "", "NO_MOUSEOVER_FUNCTIONS");
+
+ dict->ShowSection("MOUSEOVER_FUNCTIONS");
+ TemplateDictionary* foo = dict->AddIncludeDictionary("MOUSEOVER_JAVASCRIPT");
+ foo->SetFilename(string("not_a_template"));
+ foo->SetValue("BI_NEWLINE", "not gonna matter");
+
+ dict->SetEscapedValue("GOTO_MESSAGE", "print \"Go home\"",
+ GOOGLE_NAMESPACE::javascript_escape);
+
+ dict->SetEscapedValue("UPDATE", "monday & tuesday",
+ GOOGLE_NAMESPACE::html_escape);
+ dict->ShowSection("UPDATE_SECTION");
+
+ dict->SetValue("ALIGNMENT", "\"right\""); // all results sections see this
+ for (int i = 0; i < 3; ++i) { // we'll do three results
+ TemplateDictionary* result = dict->AddSectionDictionary("RESULTS");
+ if (i % 2 == 0)
+ result->ShowSection("WHITE_BG"); // gives us striped results!
+ const char* res = "<&>\"result\" #%d'&'";
+ result->SetFormattedValue("RESULT", res, i);
+ result->SetEscapedFormattedValue("XML_RESULT",
+ GOOGLE_NAMESPACE::xml_escape,
+ res, i);
+ result->SetIntValue("GOODNESS", i + 5);
+ }
+
+ // For testing auto-escape.
+ dict->SetValue("AE_TITLE_GOOD", "Hello World!");
+ dict->SetValue("AE_TITLE_BAD", "Hello <script>alert(1)</script> World!");
+ dict->SetValue("AE_URL_GOOD", "http://www.google.com/");
+ dict->SetValue("AE_URL_BAD", "javascript:alert(1)");
+ dict->SetValue("AE_BG_COLOR_GOOD", "red");
+ dict->SetValue("AE_BG_COLOR_BAD", "evil! &");
+ dict->SetValue("AE_JS_GOOD", "your text here");
+ dict->SetValue("AE_JS_BAD", "your text'is clever'thanks");
+ dict->SetValue("AE_USERNAME_GOOD", "Mr. Nice");
+ dict->SetValue("AE_USERNAME_BAD", "Doctor<script>alert(2)</script>Evil");
+ dict->SetValue("AE_START_EDGE", "left");
+ dict->SetValue("AE_END_EDGE", ";:center()$$"); // Some invalid chars.
+ dict->SetValue("AE_FONT_SIZE_PC", "120%");
+ dict->SetValue("AE_FONT_SIZE_PT", "12pt");
+ dict->SetValue("AE_MAUVE_RGB", "#FF7BD5");
+ dict->SetValue("AE_ITALIC", "italic");
+
+ // This won't see any of the vars *we* set
+ TemplateDictionary* footer_dict = dict->AddIncludeDictionary("FOOTER");
+ footer_dict->SetFilename("template_unittest_test_footer.in");
+
+ // --- These are used by template_unittest_test_modifiers.in
+
+ // UPDATE and UPDATE_SECTION we inherit from test_html.in
+ TemplateDictionary* inc_simple = dict->AddIncludeDictionary("SIMPLE");
+ inc_simple->SetFilename("template_unittest_test_simple.in");
+
+ return dict;
+}
+
+
+// Quite opposite of dict1, dict2 is a dictionary that has nothing in it
+static TemplateDictionary* MakeDict2() {
+ return new TemplateDictionary("dict2");
+}
+
+
+// dict3 tests just the handling of whitespace
+static TemplateDictionary* MakeDict3() {
+ TemplateDictionary* dict = new TemplateDictionary("dict3");
+
+ dict->SetValue("HEAD", " ");
+ dict->SetValue("BODY", "\r\n");
+ return dict;
+}
+
+static TemplateDictionary* MakeDictionary(int i) {
+ switch (i) {
+ case 1: return MakeDict1();
+ case 2: return MakeDict2();
+ case 3: return MakeDict3();
+ default: ASSERT(false); // No dictionary with this number yet.
+ }
+ return NULL;
+}
+
+
+static void TestExpand(const vector<Testdata>::const_iterator& begin,
+ const vector<Testdata>::const_iterator& end) {
+ for (vector<Testdata>::const_iterator one_test = begin;
+ one_test != end; ++one_test) {
+ Template* tpl_none = Template::GetTemplate(one_test->input_template_name,
+ DO_NOT_STRIP);
+ Template* tpl_lines = Template::GetTemplate(one_test->input_template_name,
+ STRIP_BLANK_LINES);
+ Template* tpl_ws = Template::GetTemplate(one_test->input_template_name,
+ STRIP_WHITESPACE);
+
+ // Test TemplateToString while we're at it.
+ Template* tplstr_none = Template::StringToTemplate(
+ one_test->input_template, DO_NOT_STRIP);
+ Template* tplstr_lines = Template::StringToTemplate(
+ one_test->input_template, STRIP_BLANK_LINES);
+ Template* tplstr_ws = Template::StringToTemplate(
+ one_test->input_template, STRIP_WHITESPACE);
+
+ for (vector<string>::const_iterator out = one_test->output.begin();
+ out != one_test->output.end(); ++out) {
+ int dictnum = out - one_test->output.begin() + 1; // first dict is 01
+ // If output is the empty string, we assume the file does not exist
+ if (out->empty())
+ continue;
+
+ printf("Testing template %s on dict #%d\n",
+ one_test->input_template_name.c_str(), dictnum);
+ // If we're expecting output, the template better not have had an error
+ ASSERT(tpl_none && tpl_lines && tpl_ws);
+ ASSERT(tplstr_none && tplstr_lines && tplstr_ws);
+
+ TemplateDictionary* dict = MakeDictionary(dictnum);
+
+ string stroutput_none, stroutput_lines, stroutput_ws;
+ string stroutput_strnone, stroutput_strlines, stroutput_strws;
+
+ tpl_none->Expand(&stroutput_none, dict);
+ tpl_lines->Expand(&stroutput_lines, dict);
+ tpl_ws->Expand(&stroutput_ws, dict);
+ tplstr_none->Expand(&stroutput_strnone, dict);
+ tplstr_lines->Expand(&stroutput_strlines, dict);
+ tplstr_ws->Expand(&stroutput_strws, dict);
+
+ // "out" is the output for STRIP_WHITESPACE mode.
+ ASSERT_STRING_EQ(*out, stroutput_ws);
+
+ // Now compare the variants against each other.
+ // NONE and STRIP_LINES may actually be the same on simple inputs
+ //ASSERT(output_none != output_lines);
+ ASSERT(stroutput_none != stroutput_ws);
+ ASSERT(stroutput_lines != stroutput_ws);
+ ASSERT_STREQ_EXCEPT(stroutput_none.c_str(), stroutput_lines.c_str(),
+ " \t\v\f\r\n");
+ ASSERT_STREQ_EXCEPT(stroutput_none.c_str(), stroutput_ws.c_str(),
+ " \t\v\f\r\n");
+
+ // It shouldn't matter if we read stuff from a file or a string.
+ ASSERT(stroutput_none == stroutput_strnone);
+ ASSERT(stroutput_lines == stroutput_strlines);
+ ASSERT(stroutput_ws == stroutput_strws);
+
+
+ delete dict; // it's our responsibility
+ }
+
+ // The annotation test is a bit simpler; we only strip one way
+ for (vector<string>::const_iterator out = one_test->annotated_output.begin();
+ out != one_test->annotated_output.end(); ++out) {
+ int dictnum = out - one_test->annotated_output.begin() + 1;
+ // If output is the empty string, we assume the file does not exist
+ if (out->empty())
+ continue;
+
+ printf("Testing template %s on dict #%d (annotated)\n",
+ one_test->input_template_name.c_str(), dictnum);
+
+ TemplateDictionary* dict = MakeDictionary(dictnum);
+ PerExpandData per_expand_data;
+ per_expand_data.SetAnnotateOutput("template_unittest_test");
+ string output;
+ tpl_lines->ExpandWithData(&output, dict, &per_expand_data);
+ ASSERT_STREQ_EXCEPT(out->c_str(), output.c_str(), "\r\n");
+ delete dict; // it's our responsibility
+ }
+ delete tplstr_none; // these are our responsibility too
+ delete tplstr_lines;
+ delete tplstr_ws;
+ }
+}
+
+
+int main(int argc, char** argv) {
+ // If TEMPLATE_ROOTDIR is set in the environment, it overrides the
+ // default of ".". We use an env-var rather than argv because
+ // that's what automake supports most easily.
+ const char* template_rootdir = getenv("TEMPLATE_ROOTDIR");
+ if (template_rootdir == NULL)
+ template_rootdir = DEFAULT_TEMPLATE_ROOTDIR; // probably "."
+ string rootdir = GOOGLE_NAMESPACE::PathJoin(template_rootdir, "src");
+ rootdir = GOOGLE_NAMESPACE::PathJoin(rootdir, "tests");
+ Template::SetTemplateRootDirectory(rootdir);
+
+ vector<Testdata> testdata = ReadDataFiles(
+ Template::template_root_directory().c_str());
+ if (testdata.empty()) {
+ printf("FATAL ERROR: No test files found for template_regtest\n");
+ return 1;
+ }
+
+ TestExpand(testdata.begin(), testdata.end());
+
+ printf("DONE\n");
+ return 0;
+}
diff --git a/src/tests/template_setglobals_unittest.cc b/src/tests/template_setglobals_unittest.cc
new file mode 100644
index 0000000..4d59e22
--- /dev/null
+++ b/src/tests/template_setglobals_unittest.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2002, Google Inc.
+// 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 Google Inc. 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 "config_for_unittests.h"
+#include <assert.h>
+#include <stdio.h>
+#include <ctemplate/template.h>
+#include <ctemplate/template_dictionary.h>
+#include "tests/template_test_util.h"
+#include "base/util.h"
+TEST_INIT // defines RUN_ALL_TESTS()
+
+using GOOGLE_NAMESPACE::Template;
+using GOOGLE_NAMESPACE::TemplateDictionary;
+
+TEST(SetGlobalValue, TemplateDictionary) {
+ // Test to see that the global dictionary object gets created when you
+ // first call the static function TemplateDictionary::SetGlobalValue().
+ TemplateDictionary::SetGlobalValue("TEST_GLOBAL_VAR", "test_value");
+ TemplateDictionary tpl("empty");
+ GOOGLE_NAMESPACE::TemplateDictionaryPeer peer(&tpl);
+ EXPECT_STREQ(peer.GetSectionValue("TEST_GLOBAL_VAR"),
+ "test_value");
+
+}
+
+TEST(SetGlobalValue, SetRootDirectory) {
+ // Test to see that the Template static variables get created when you
+ // first call the static function Template::SetRootDirectory().
+ Template::SetTemplateRootDirectory("/some/directory/path");
+ // We don't know if we appended a / or a \, so we test indirectly
+ EXPECT_EQ(strlen("/some/directory/path")+1, // assert they added a char
+ Template::template_root_directory().size());
+ EXPECT_EQ(0, memcmp(Template::template_root_directory().c_str(),
+ "/some/directory/path",
+ strlen("/some/directory/path")));
+}
+
+int main(int argc, char **argv) {
+
+ return RUN_ALL_TESTS();
+}
diff --git a/src/tests/template_test_util.cc b/src/tests/template_test_util.cc
new file mode 100644
index 0000000..57f7f91
--- /dev/null
+++ b/src/tests/template_test_util.cc
@@ -0,0 +1,309 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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 "config_for_unittests.h"
+#include "base/mutex.h" // must come first, for _XOPEN_SOURCE
+#include "tests/template_test_util.h"
+#include <assert.h> // for assert()
+#ifdef HAVE_DIRENT_H
+# include <dirent.h> // for opendir() etc
+#else
+# define dirent direct
+# ifdef HAVE_SYS_NDIR_H
+# include <sys/ndir.h>
+# endif
+# ifdef HAVE_SYS_DIR_H
+# include <sys/dir.h>
+# endif
+# ifdef HAVE_NDIR_H
+# include <ndir.h>
+# endif
+#endif // for DIR, dirent, closedir(), opendir(), etc
+#include <stdio.h> // for printf(), FILE, fclose(), fopen(), etc
+#include <stdlib.h> // for exit()
+#include <string.h> // for strcmp(), strcpy(), strstr()
+#include <sys/stat.h> // for mkdir()
+#include <sys/types.h> // for mode_t
+#include <time.h> // for time_t
+#ifdef HAVE_UTIME_H
+# include <utime.h>
+#endif // for utime()
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif // for unlink()
+#include <vector> // for vector<>, vector<>::size_type
+#include <ctemplate/template.h> // for Template
+#include <ctemplate/template_dictionary.h> // for TemplateDictionary
+#include <ctemplate/template_dictionary_interface.h>
+#include <ctemplate/template_enums.h> // for Strip
+#include <ctemplate/template_namelist.h> // for TemplateNamelist, etc
+#include <ctemplate/template_pathops.h> // for PathJoin()
+#include "base/util.h" // for down_cast()
+
+using std::string;
+using std::vector;
+
+#ifdef ASSERT
+# undef ASSERT
+#endif
+#define ASSERT(cond) do { \
+ if (!(cond)) { \
+ printf("ASSERT FAILED, line %d: %s\n", __LINE__, #cond); \
+ assert(cond); \
+ exit(1); \
+ } \
+} while (0)
+
+namespace ctemplate {
+
+// Deletes all files named *template* in dir, and sets up dir as the
+// place where StringToTemplate writes.
+static char* g_tmpdir = NULL;
+
+#ifndef USING_PORT_CC /* windows defines its own version in windows/port.cc */
+void CreateOrCleanTestDir(const string& dirname) {
+ DIR* dir = opendir(dirname.c_str());
+ if (!dir) { // directory doesn't exist or something like that
+ mkdir(dirname.c_str(), 0755); // make the dir if we can
+ return;
+ }
+ while (struct dirent* d = readdir(dir)) {
+ if (strstr(d->d_name, "template"))
+ unlink(PathJoin(dirname, d->d_name).c_str());
+ }
+ closedir(dir);
+}
+
+static string TmpFile(const char* basename) {
+ return string("/tmp/") + basename;
+}
+
+#endif // #ifndef USING_PORT_CC
+
+void CreateOrCleanTestDirAndSetAsTmpdir(const string& dirname) {
+ CreateOrCleanTestDir(dirname);
+ delete[] g_tmpdir;
+ g_tmpdir = new char[dirname.length() + 1];
+ strcpy(g_tmpdir, dirname.c_str());
+}
+
+const string FLAGS_test_tmpdir(TmpFile("template_unittest_dir"));
+
+// This writes s to the given file. We want to make sure that every
+// time we create a file, it has a different mtime (just like would
+// be the case in real life), so we use a mock clock.
+static Mutex g_time_mutex(base::LINKER_INITIALIZED);
+static time_t mock_time = 946713600; // jan 1, 2000, in california
+
+void StringToFile(const string& s, const string& filename) {
+ FILE* fp = fopen(filename.c_str(), "wb");
+ ASSERT(fp);
+ size_t r = fwrite(s.data(), 1, s.length(), fp);
+ ASSERT(r == s.length());
+ fclose(fp);
+
+ g_time_mutex.Lock();
+ const time_t file_time = mock_time++;
+ g_time_mutex.Unlock();
+ struct utimbuf timbuf = { file_time, file_time };
+ utime(filename.c_str(), &timbuf);
+}
+
+time_t Now() {
+ g_time_mutex.Lock();
+ const time_t now = mock_time;
+ g_time_mutex.Unlock();
+ return now;
+}
+
+// This writes s to a file and returns the filename.
+string StringToTemplateFile(const string& s) {
+ static int filenum = 0;
+ char buf[16];
+ snprintf(buf, sizeof(buf), "%03d", ++filenum);
+ string filename = PathJoin(g_tmpdir ? g_tmpdir : "",
+ string("template.") + buf);
+ StringToFile(s, filename);
+ return filename;
+}
+
+// This writes s to a file and then loads it into a template object.
+Template* StringToTemplate(const string& s, Strip strip) {
+ return Template::GetTemplate(StringToTemplateFile(s), strip);
+}
+
+// This is esp. useful for calling from within gdb.
+// The gdb nice-ness is balanced by the need for the caller to delete the buf.
+
+const char* ExpandIs(const Template* tpl, const TemplateDictionary *dict,
+ PerExpandData* per_expand_data, bool expected) {
+ string outstring;
+ if (per_expand_data)
+ ASSERT(expected == tpl->ExpandWithData(&outstring, dict, per_expand_data));
+ else
+ ASSERT(expected == tpl->Expand(&outstring, dict));
+
+
+ char* buf = new char[outstring.size()+1];
+ strcpy(buf, outstring.c_str());
+ return buf;
+}
+
+const char* ExpandWithCacheIs(TemplateCache* cache,
+ const string& filename, Strip strip,
+ const TemplateDictionary *dict,
+ PerExpandData* per_expand_data, bool expected) {
+ string outstring;
+ ASSERT(expected == cache->ExpandWithData(filename, strip, dict,
+ per_expand_data, &outstring));
+
+
+ char* buf = new char[outstring.size()+1];
+ strcpy(buf, outstring.c_str());
+ return buf;
+}
+
+void AssertExpandWithDataIs(const Template* tpl,
+ const TemplateDictionary *dict,
+ PerExpandData* per_expand_data,
+ const string& is, bool expected) {
+ const char* buf = ExpandIs(tpl, dict, per_expand_data, expected);
+ if (strcmp(buf, is.c_str())) {
+ printf("expected = '%s'\n", is.c_str());
+ printf("actual = '%s'\n", buf);
+ }
+ ASSERT(string(buf) == is);
+ delete [] buf;
+}
+
+void AssertExpandIs(const Template* tpl, const TemplateDictionary *dict,
+ const string& is, bool expected) {
+ AssertExpandWithDataIs(tpl, dict, NULL, is, expected);
+}
+
+void AssertExpandWithCacheIs(TemplateCache* cache,
+ const string& filename, Strip strip,
+ const TemplateDictionary *dict,
+ PerExpandData* per_expand_data,
+ const string& is, bool expected) {
+ const char* buf = ExpandWithCacheIs(cache, filename, strip, dict,
+ per_expand_data, expected);
+ if (strcmp(buf, is.c_str())) {
+ printf("expected = '%s'\n", is.c_str());
+ printf("actual = '%s'\n", buf);
+ }
+ ASSERT(string(buf) == is);
+ delete [] buf;
+}
+
+TemporaryRegisterTemplate::TemporaryRegisterTemplate(const char* name) {
+ old_namelist_ = TemplateNamelist::namelist_;
+ if (old_namelist_) {
+ namelist_ = *old_namelist_;
+ }
+
+ namelist_.insert(name);
+ TemplateNamelist::namelist_ = &namelist_;
+}
+
+TemporaryRegisterTemplate::~TemporaryRegisterTemplate() {
+ TemplateNamelist::namelist_ = old_namelist_;
+}
+
+const char* TemplateDictionaryPeer::GetSectionValue(
+ const TemplateString& variable)
+ const {
+ // Luckily, TemplateDictionary stores all values with a trailing NUL.
+ return dict_->GetValue(variable).data();
+}
+
+bool TemplateDictionaryPeer::ValueIs(const TemplateString& variable,
+ const TemplateString& expected) const {
+ return dict_->GetValue(variable) == expected;
+}
+
+bool TemplateDictionaryPeer::IsHiddenSection(
+ const TemplateString& name) const {
+ return dict_->IsHiddenSection(name);
+}
+
+bool TemplateDictionaryPeer::IsUnhiddenSection(
+ const TemplateString& name) const {
+ return dict_->IsUnhiddenSection(name);
+}
+
+bool TemplateDictionaryPeer::IsHiddenTemplate(
+ const TemplateString& name) const {
+ return dict_->IsHiddenTemplate(name);
+}
+
+int TemplateDictionaryPeer::GetSectionDictionaries(
+ const TemplateString& section_name,
+ vector<const TemplateDictionary*>* dicts) const {
+ dicts->clear();
+ if (dict_->IsHiddenSection(section_name))
+ return 0;
+
+ TemplateDictionaryInterface::Iterator* di =
+ dict_->CreateSectionIterator(section_name);
+ while (di->HasNext())
+ dicts->push_back(down_cast<const TemplateDictionary*>(&di->Next()));
+ delete di;
+
+ return static_cast<int>(dicts->size());
+}
+
+int TemplateDictionaryPeer::GetIncludeDictionaries(
+ const TemplateString& section_name,
+ vector<const TemplateDictionary*>* dicts) const {
+ dicts->clear();
+ if (dict_->IsHiddenTemplate(section_name))
+ return 0;
+
+ TemplateDictionaryInterface::Iterator* di =
+ dict_->CreateTemplateIterator(section_name);
+ while (di->HasNext())
+ dicts->push_back(down_cast<const TemplateDictionary*>(&di->Next()));
+ delete di;
+
+ return static_cast<int>(dicts->size());
+}
+
+const char* TemplateDictionaryPeer::GetIncludeTemplateName(
+ const TemplateString& variable, int dictnum) const {
+ return dict_->GetIncludeTemplateName(variable, dictnum);
+}
+
+const char* TemplateDictionaryPeer::GetFilename() const {
+ return dict_->filename_;
+}
+
+}
diff --git a/src/tests/template_test_util.h b/src/tests/template_test_util.h
new file mode 100644
index 0000000..ec3cc84
--- /dev/null
+++ b/src/tests/template_test_util.h
@@ -0,0 +1,283 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// Intended usage of TemplateDictionaryPeer:
+// Use this class if you need to TEST that a dictionary has certain
+// expected contents. This should be fairly uncommon outside the
+// template directory.
+//
+
+
+#ifndef TEMPLATE_TEMPLATE_TEST_UTIL_H_
+#define TEMPLATE_TEMPLATE_TEST_UTIL_H_
+
+#include "config_for_unittests.h"
+#include <time.h> // for time_t
+#include <string> // for string
+#include <vector> // for vector<>
+#include HASH_MAP_H // UNUSED
+#include <ctemplate/template.h> // for Template::num_deletes_
+#include <ctemplate/template_cache.h> // for TemplateCache
+#include <ctemplate/template_dictionary.h> // for TemplateDictionary
+#include <ctemplate/template_dictionary_interface.h>
+#include <ctemplate/template_enums.h> // for Strip
+#include <ctemplate/template_namelist.h>
+#include <ctemplate/template_string.h> // for TemplateString, TemplateId
+
+namespace ctemplate {
+
+using std::string;
+
+class PerExpandData;
+class TemplateCache;
+class TemplateDictionary;
+
+inline TemplateId GlobalIdForTest(const char* ptr, int len) {
+ return TemplateString(ptr, len).GetGlobalId();
+}
+
+// Call this to create a StaticTemplateString for testing when the ptr is
+// not guaranteed to be allocated for the entire length of the test.
+#define STS_INIT_FOR_TEST(ptr, len, arena) \
+ { { arena->Memdup(ptr, len), len, GOOGLE_NAMESPACE::GlobalIdForTest(ptr, len) } };
+
+extern const std::string FLAGS_test_tmpdir;
+
+// These are routines that are useful for creating template files for testing.
+
+// Deletes all files named *template* in dir.
+void CreateOrCleanTestDir(const string& dirname);
+// This delets all files named *template*, and also sets dirname to be
+// the directory that all future StringToFile calls will place their
+// templates.
+void CreateOrCleanTestDirAndSetAsTmpdir(const string& dirname);
+
+// This writes s to the given file. We want to make sure that every
+// time we create a file, it has a different mtime (just like would
+// be the case in real life), so we use a mock clock. Filenames created
+// by this routine will all have an mtime of around Jan 1, 2000.
+void StringToFile(const string& s, const string& filename);
+
+// This is the (mock) time used when creating the last file in StringToFile.
+time_t Now();
+
+// This writes s to a file and returns the filename.
+string StringToTemplateFile(const string& s);
+
+// This writes s to a file and then loads it into a template object.
+Template* StringToTemplate(const string& s, Strip strip);
+
+// This is esp. useful for calling from within gdb.
+// The gdb nice-ness is balanced by the need for the caller to delete the buf.
+const char* ExpandIs(const Template* tpl, const TemplateDictionary *dict,
+ PerExpandData* per_expand_data, bool expected);
+
+void AssertExpandWithDataIs(const Template* tpl,
+ const TemplateDictionary *dict,
+ PerExpandData* per_expand_data,
+ const string& is, bool expected);
+
+void AssertExpandIs(const Template* tpl, const TemplateDictionary *dict,
+ const string& is, bool expected);
+
+void AssertExpandWithCacheIs(TemplateCache* cache,
+ const string& filename, Strip strip,
+ const TemplateDictionary *dict,
+ PerExpandData* per_expand_data,
+ const string& is, bool expected);
+
+class TemporaryRegisterTemplate {
+ public:
+ explicit TemporaryRegisterTemplate(const char* name);
+ ~TemporaryRegisterTemplate();
+ private:
+ GOOGLE_NAMESPACE::TemplateNamelist::NameListType* old_namelist_;
+ GOOGLE_NAMESPACE::TemplateNamelist::NameListType namelist_;
+
+ // disallow copy constructor and assignment
+ TemporaryRegisterTemplate(const TemporaryRegisterTemplate&);
+ void operator=(const TemporaryRegisterTemplate&);
+};
+
+// For friendship reasons, we make this a top-level class rather
+// than a nested class. It's used only in TemplateDictionaryPeer.
+// We take ownership of the iterator passed to us. To make sure that
+// isn't a problem, we make this class not-copyable.
+class TemplateDictionaryPeerIterator {
+ public:
+ explicit TemplateDictionaryPeerIterator(
+ TemplateDictionaryInterface::Iterator* it) : it_(it) { }
+ ~TemplateDictionaryPeerIterator() { delete it_; }
+ bool HasNext() const { return it_->HasNext(); }
+ const TemplateDictionaryInterface& Next() { return it_->Next(); }
+ private:
+ TemplateDictionaryInterface::Iterator* it_;
+ TemplateDictionaryPeerIterator(const TemplateDictionaryPeerIterator&);
+ TemplateDictionaryPeerIterator& operator=(
+ const TemplateDictionaryPeerIterator&);
+};
+
+// This class is meant for use in unittests. This class wraps the
+// TemplateDictionary and provides access to internal data that should
+// not be used in production code. If you need this kind of
+// functionality in production, use TemplateDictionaryWrapper or
+// TemplateDictionaryInterface; see top of file for details.
+//
+// Example Usage:
+// TemplateDictionary dict("test dictionary");
+// FillDictionaryValues(&dict);
+//
+// TemplateDictionaryPeer peer(&dict);
+// EXPECT_EQ("5", peer.GetSectionValue("width"));
+class TemplateDictionaryPeer {
+ public:
+ explicit TemplateDictionaryPeer(const TemplateDictionary* dict)
+ : dict_(dict) {}
+
+ // Returns whether the named variable has value equal to "expected".
+ bool ValueIs(const TemplateString& variable,
+ const TemplateString& expected) const;
+
+ // DEPRECATED: Returns the value of the named variable. Does not
+ // deal properly with values that have an internal NUL. Use ValueIs
+ // for new code.
+ const char* GetSectionValue(const TemplateString& variable) const;
+
+ // Returns true if the named section is hidden.
+ bool IsHiddenSection(const TemplateString& name) const;
+
+ // IsUnhiddenSection
+ // Returns true if the section has been marked visible and false otherwise.
+ bool IsUnhiddenSection(const TemplateString& name) const;
+
+ // Returns true if the named sub-template is hidden.
+ bool IsHiddenTemplate(const TemplateString& name) const;
+
+ // Retrieves TemplateDictionary instances for the given section name. The
+ // caller does not assume ownership of the returned TemplateDictionary
+ // instances. The number of instances is returned. All prior entries in
+ // the dicts vector are cleared.
+ //
+ // NOTE: This method assumes that old-style template dictionaries are not in
+ // use. That is, it assumes that all section dictionaries have been added
+ // with AddSectionDictionary rather than AddOldstyleSectionDictionary.
+ int GetSectionDictionaries(const TemplateString& section_name,
+ std::vector<const TemplateDictionary*>* dicts)
+ const;
+
+ // Retrieves included TemplateDictionary instances for the given name. The
+ // caller does not assume ownership of the returned TemplateDictionary
+ // instances. The number of instances is returned. All prior entries in
+ // the dicts vector are cleared.
+ //
+ // NOTE: This method assumes that old-style template dictionaries are not in
+ // use. That is, it assumes that all section dictionaries have been added
+ // with AddIncludeDictionary rather than AddOldstyleIncludeDictionary.
+ int GetIncludeDictionaries(const TemplateString& section_name,
+ std::vector<const TemplateDictionary*>* dicts)
+ const;
+
+ const char* GetIncludeTemplateName(const TemplateString& variable,
+ int dictnum) const;
+
+ typedef TemplateDictionaryPeerIterator Iterator;
+
+ Iterator* CreateTemplateIterator(const TemplateString& section)
+ const {
+ return new Iterator(dict_->CreateTemplateIterator(section));
+ }
+
+ Iterator* CreateSectionIterator(const TemplateString& section)
+ const {
+ return new Iterator(dict_->CreateSectionIterator(section));
+ }
+
+ // Returns the filename associated with the TemplateDictionary.
+ const char* GetFilename() const;
+
+ private:
+ const TemplateDictionary* dict_; // Not owned.
+
+ // disallow copy constructor and assignment
+ TemplateDictionaryPeer(const TemplateDictionaryPeer&);
+ void operator=(const TemplateDictionaryPeer&);
+};
+
+class TemplateCachePeer {
+ public:
+ TemplateCachePeer(TemplateCache* cache)
+ : cache_(cache) {}
+
+ struct TemplateCacheKey : public TemplateCache::TemplateCacheKey {
+ TemplateCacheKey(const string& key, int strip) {
+ this->first = GlobalIdForTest(key.data(), key.length());
+ this->second = strip;
+ }
+ };
+
+ TemplateCache::TemplateMap* parsed_template_cache() {
+ return cache_->parsed_template_cache_;
+ }
+
+ bool TemplateIsCached(const TemplateCacheKey key) const {
+ return cache_->TemplateIsCached(key);
+ }
+
+ const Template* GetTemplate(const TemplateString& key, Strip strip) const {
+ return cache_->GetTemplate(key, strip);
+ }
+
+ int Refcount(const TemplateCacheKey key) const {
+ return cache_->Refcount(key);
+ }
+
+ void DoneWithGetTemplatePtrs() {
+ cache_->DoneWithGetTemplatePtrs();
+ }
+ void ClearCache() {
+ cache_->ClearCache();
+ }
+
+ static int NumTotalTemplateDeletes() {
+ return Template::num_deletes();
+ }
+
+ private:
+ TemplateCache* cache_; // Not owned.
+
+ // Don't allow copying
+ TemplateCachePeer(const TemplateCachePeer&);
+ void operator=(const TemplateCachePeer&);
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_TEST_UTIL_H_
diff --git a/src/tests/template_test_util_test.cc b/src/tests/template_test_util_test.cc
new file mode 100644
index 0000000..190ac95
--- /dev/null
+++ b/src/tests/template_test_util_test.cc
@@ -0,0 +1,262 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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 "config_for_unittests.h"
+#include "tests/template_test_util.h"
+
+#include <stdio.h>
+#include <string>
+#include <vector>
+
+#include "base/arena.h"
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_string.h>
+#include "base/util.h"
+TEST_INIT // defines RUN_ALL_TESTS()
+
+#define ASSERT_EQ(a, b) EXPECT_EQ(a, b)
+
+using std::vector;
+using std::string;
+using GOOGLE_NAMESPACE::UnsafeArena;
+
+using GOOGLE_NAMESPACE::TemplateDictionary;
+using GOOGLE_NAMESPACE::TemplateDictionaryPeer;
+using GOOGLE_NAMESPACE::TemplateString;
+using GOOGLE_NAMESPACE::StaticTemplateString;
+
+namespace {
+
+TEST(TemplateTestUtilTest, GetSectionValue) {
+ TemplateDictionary dict("test_GetSectionValue");
+ dict.SetValue("VALUE", "value");
+
+ TemplateDictionaryPeer peer(&dict);
+ EXPECT_STREQ("value", peer.GetSectionValue("VALUE"));
+}
+
+TEST(TemplateTestUtilTest, IsHiddenSection) {
+ TemplateDictionary dict("test_IsHiddenSection");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ EXPECT_TRUE(peer.IsHiddenSection("SECTION"));
+ }
+
+ dict.AddSectionDictionary("SECTION");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ EXPECT_FALSE(peer.IsHiddenSection("SECTION"));
+ }
+}
+
+TEST(TemplateTestUtilTest, GetSectionDictionaries) {
+ TemplateDictionary dict("test_GetSectionDictionaries");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ // Add some dummy value into the vector to confirm that the call to
+ // GetSectionDictionaries will correctly clear the vector.
+ dicts.push_back(NULL);
+ EXPECT_EQ(0, peer.GetSectionDictionaries("SECTION", &dicts));
+ EXPECT_TRUE(dicts.empty());
+ }
+
+ dict.AddSectionDictionary("SECTION")->SetValue("SECTION_VALUE", "0");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ ASSERT_EQ(1, peer.GetSectionDictionaries("SECTION", &dicts));
+
+ TemplateDictionaryPeer peer_section(dicts[0]);
+ EXPECT_STREQ("0", peer_section.GetSectionValue("SECTION_VALUE"));
+ }
+
+ dict.AddSectionDictionary("SECTION")->SetValue("SECTION_VALUE", "1");
+ dict.AddSectionDictionary("ANOTHER_SECTION")->SetValue("ANOTHER_VALUE", "2");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ ASSERT_EQ(2, peer.GetSectionDictionaries("SECTION", &dicts));
+
+ TemplateDictionaryPeer peer_section0(dicts[0]);
+ EXPECT_STREQ("0", peer_section0.GetSectionValue("SECTION_VALUE"));
+
+ TemplateDictionaryPeer peer_section1(dicts[1]);
+ EXPECT_STREQ("1", peer_section1.GetSectionValue("SECTION_VALUE"));
+ }
+}
+
+TEST(TemplateTestUtilTest, GetIncludeDictionaries) {
+ TemplateDictionary dict("test_GetIncludeDictionaries");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ // Add some dummy value into the vector to confirm that the call to
+ // GetSectionDictionaries will correctly clear the vector.
+ dicts.push_back(NULL);
+ EXPECT_EQ(0, peer.GetIncludeDictionaries("SECTION", &dicts));
+ EXPECT_TRUE(dicts.empty());
+ }
+
+ dict.AddIncludeDictionary("SECTION")->SetValue("SECTION_VALUE", "0");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ ASSERT_EQ(1, peer.GetIncludeDictionaries("SECTION", &dicts));
+
+ TemplateDictionaryPeer peer_section(dicts[0]);
+ EXPECT_STREQ("0", peer_section.GetSectionValue("SECTION_VALUE"));
+ }
+
+ dict.AddIncludeDictionary("SECTION")->SetValue("SECTION_VALUE", "1");
+ dict.AddIncludeDictionary("ANOTHER_SECTION")->SetValue("ANOTHER_VALUE", "2");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ ASSERT_EQ(2, peer.GetIncludeDictionaries("SECTION", &dicts));
+
+ TemplateDictionaryPeer peer_section0(dicts[0]);
+ EXPECT_STREQ("0", peer_section0.GetSectionValue("SECTION_VALUE"));
+
+ TemplateDictionaryPeer peer_section1(dicts[1]);
+ EXPECT_STREQ("1", peer_section1.GetSectionValue("SECTION_VALUE"));
+ }
+}
+
+TEST(TemplateTestUtilTest, GetIncludeAndSectionDictionaries) {
+ TemplateDictionary dict("test_GetIncludeAndSectionDictionaries");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ EXPECT_EQ(0, peer.GetIncludeDictionaries("SECTION", &dicts));
+ EXPECT_EQ(0, peer.GetSectionDictionaries("SECTION", &dicts));
+ }
+
+ dict.AddIncludeDictionary("SECTION")->SetValue("SECTION_VALUE", "0");
+ dict.AddSectionDictionary("SECTION")->SetValue("SECTION_VALUE", "1");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> include_dicts;
+ ASSERT_EQ(1, peer.GetIncludeDictionaries("SECTION", &include_dicts));
+
+ TemplateDictionaryPeer include_peer(include_dicts[0]);
+ EXPECT_STREQ("0", include_peer.GetSectionValue("SECTION_VALUE"));
+
+ vector<const TemplateDictionary*> section_dicts;
+ ASSERT_EQ(1, peer.GetSectionDictionaries("SECTION", §ion_dicts));
+
+ TemplateDictionaryPeer section_peer(section_dicts[0]);
+ EXPECT_STREQ("1", section_peer.GetSectionValue("SECTION_VALUE"));
+ }
+
+ dict.AddIncludeDictionary("SECTION")->SetValue("SECTION_VALUE", "2");
+ dict.AddIncludeDictionary("ANOTHER_SECTION")->SetValue("ANOTHER_VALUE", "3");
+
+ dict.AddSectionDictionary("SECTION")->SetValue("SECTION_VALUE", "4");
+ dict.AddSectionDictionary("ONE_MORE_SECTION")->SetValue("ANOTHER_VALUE", "5");
+
+ {
+ TemplateDictionaryPeer peer(&dict);
+ vector<const TemplateDictionary*> dicts;
+ ASSERT_EQ(2, peer.GetIncludeDictionaries("SECTION", &dicts));
+
+ TemplateDictionaryPeer include_peer0(dicts[0]);
+ EXPECT_STREQ("0", include_peer0.GetSectionValue("SECTION_VALUE"));
+
+ TemplateDictionaryPeer include_peer1(dicts[1]);
+ EXPECT_STREQ("2", include_peer1.GetSectionValue("SECTION_VALUE"));
+
+ EXPECT_EQ(1, peer.GetIncludeDictionaries("ANOTHER_SECTION", &dicts));
+ EXPECT_EQ(0, peer.GetIncludeDictionaries("ONE_MORE_SECTION", &dicts));
+
+ vector<const TemplateDictionary*> section_dicts;
+ ASSERT_EQ(2, peer.GetSectionDictionaries("SECTION", §ion_dicts));
+
+ TemplateDictionaryPeer section_peer0(section_dicts[0]);
+ EXPECT_STREQ("1", section_peer0.GetSectionValue("SECTION_VALUE"));
+
+ TemplateDictionaryPeer section_peer1(section_dicts[1]);
+ EXPECT_STREQ("4", section_peer1.GetSectionValue("SECTION_VALUE"));
+
+ EXPECT_EQ(0, peer.GetSectionDictionaries("ANOTHER_SECTION", &dicts));
+ EXPECT_EQ(1, peer.GetSectionDictionaries("ONE_MORE_SECTION", &dicts));
+ }
+}
+
+TEST(TemplateTestUtilTest, GetFilename) {
+ TemplateDictionary parent("test_GetFilename");
+ TemplateDictionary* child = parent.AddIncludeDictionary("INCLUDE_marker");
+ child->SetFilename("included_filename");
+
+ TemplateDictionaryPeer parent_peer(&parent);
+ EXPECT_EQ(NULL, parent_peer.GetFilename());
+
+ TemplateDictionaryPeer child_peer(child);
+ EXPECT_STREQ("included_filename", child_peer.GetFilename());
+}
+
+StaticTemplateString GetTestTemplateString(UnsafeArena* arena) {
+ string will_go_out_of_scope("VALUE");
+ // We want to ensure that the STS_INIT_FOR_TEST macro:
+ // - Can produce a StaticTemplateString (guard again its format changing).
+ // - Produces a StaticTemplateString that is still valid after the string
+ // used to initialize it goes out-of-scope.
+ StaticTemplateString sts = STS_INIT_FOR_TEST(will_go_out_of_scope.c_str(),
+ will_go_out_of_scope.length(),
+ arena);
+ return sts;
+}
+
+TEST(TemplateUtilTest, InitStaticTemplateStringForTest) {
+ UnsafeArena arena(1024);
+ StaticTemplateString kValue = GetTestTemplateString(&arena);
+
+ TemplateDictionary dict("test_GetSectionValue");
+ dict.SetValue(kValue, "value");
+
+ TemplateDictionaryPeer peer(&dict);
+ EXPECT_STREQ("value", peer.GetSectionValue(kValue));
+}
+
+} // namespace anonymous
+
+int main(int argc, char **argv) {
+
+ return RUN_ALL_TESTS();
+}
diff --git a/src/tests/template_unittest.cc b/src/tests/template_unittest.cc
new file mode 100644
index 0000000..8d615c0
--- /dev/null
+++ b/src/tests/template_unittest.cc
@@ -0,0 +1,2149 @@
+// Copyright (c) 2005, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+
+#include "config_for_unittests.h"
+#include <ctemplate/template.h>
+#include <assert.h> // for assert()
+#if defined(HAVE_PTHREAD) && !defined(NO_THREADS)
+# include <pthread.h>
+#endif // for pthread_t, pthread_create(), etc
+#include <stddef.h> // for size_t
+#include <stdio.h> // for printf(), FILE, snprintf(), fclose(), etc
+#include <stdlib.h> // for exit()
+#include <string.h> // for strcmp(), memchr(), strlen(), strstr()
+#include <sys/types.h> // for mode_t
+#include <time.h> // for time_t, time()
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif // for link(), unlink()
+#include <list> // for list<>::size_type
+#include <vector> // for vector<>
+#include <ctemplate/per_expand_data.h> // for PerExpandData
+#include <ctemplate/template_annotator.h> // for TextTemplateAnnotator
+#include <ctemplate/template_dictionary.h> // for TemplateDictionary
+#include <ctemplate/template_emitter.h> // for ExpandEmitter
+#include <ctemplate/template_enums.h> // for STRIP_WHITESPACE, Strip, etc
+#include <ctemplate/template_modifiers.h> // for AddModifier(), HtmlEscape, etc
+#include <ctemplate/template_namelist.h> // for TemplateNamelist, etc
+#include <ctemplate/template_pathops.h> // for PathJoin(), IsAbspath(), etc
+#include <ctemplate/template_string.h> // for TemplateString, StringHash, etc
+#include "tests/template_test_util.h" // for StringToTemplate(), etc
+#include "base/util.h"
+TEST_INIT // defines RUN_ALL_TESTS()
+
+using std::vector;
+using std::string;
+using GOOGLE_NAMESPACE::FLAGS_test_tmpdir;
+
+using GOOGLE_NAMESPACE::AssertExpandIs;
+using GOOGLE_NAMESPACE::AssertExpandWithDataIs;
+using GOOGLE_NAMESPACE::CreateOrCleanTestDir;
+using GOOGLE_NAMESPACE::CreateOrCleanTestDirAndSetAsTmpdir;
+using GOOGLE_NAMESPACE::DO_NOT_STRIP;
+using GOOGLE_NAMESPACE::ExpandEmitter;
+using GOOGLE_NAMESPACE::IsAbspath;
+using GOOGLE_NAMESPACE::Now;
+using GOOGLE_NAMESPACE::PathJoin;
+using GOOGLE_NAMESPACE::PerExpandData;
+using GOOGLE_NAMESPACE::STRIP_BLANK_LINES;
+using GOOGLE_NAMESPACE::STRIP_WHITESPACE;
+using GOOGLE_NAMESPACE::StaticTemplateString;
+using GOOGLE_NAMESPACE::StringToFile;
+using GOOGLE_NAMESPACE::StringToTemplate;
+using GOOGLE_NAMESPACE::StringToTemplateFile;
+using GOOGLE_NAMESPACE::Strip;
+using GOOGLE_NAMESPACE::TC_CSS;
+using GOOGLE_NAMESPACE::TC_HTML;
+using GOOGLE_NAMESPACE::TC_JS;
+using GOOGLE_NAMESPACE::TC_JSON;
+using GOOGLE_NAMESPACE::TC_MANUAL;
+using GOOGLE_NAMESPACE::TC_UNUSED;
+using GOOGLE_NAMESPACE::TC_XML;
+using GOOGLE_NAMESPACE::Template;
+using GOOGLE_NAMESPACE::TemplateContext;
+using GOOGLE_NAMESPACE::TemplateDictionary;
+using GOOGLE_NAMESPACE::TemplateNamelist;
+using GOOGLE_NAMESPACE::TemplateString;
+using GOOGLE_NAMESPACE::kRootdir;
+
+using GOOGLE_NAMESPACE::ExpandTemplate;
+using GOOGLE_NAMESPACE::ExpandWithData;
+using GOOGLE_NAMESPACE::StringToTemplateCache;
+
+static const StaticTemplateString kHello = STS_INIT(kHello, "Hello");
+static const StaticTemplateString kWorld = STS_INIT(kWorld, "World");
+
+static const char* kPragmaHtml = "{{%AUTOESCAPE context=\"HTML\"}}\n";
+static const char* kPragmaJs = "{{%AUTOESCAPE context=\"JAVASCRIPT\"}}\n";
+static const char* kPragmaCss = "{{%AUTOESCAPE context=\"CSS\"}}\n";
+static const char* kPragmaXml = "{{%AUTOESCAPE context=\"XML\"}}\n";
+static const char* kPragmaJson = "{{%AUTOESCAPE context=\"JSON\"}}\n";
+
+// How many threads to use for our threading test.
+// This is a #define instead of a const int so we can use it in array-sizes
+// even on c++ compilers that don't support var-length arrays.
+#define kNumThreads 10
+
+#define PFATAL(s) do { perror(s); exit(1); } while (0)
+
+// TODO(csilvers): rewrite to be more gunit-like: use expectations
+// instead of asserts, and move assert-checking out of helper routines
+// and into tests proper. Ideally, replace AssertExpandIs() with
+// VerifyExpandIs().
+#define ASSERT(cond) do { \
+ if (!(cond)) { \
+ printf("ASSERT FAILED, line %d: %s\n", __LINE__, #cond); \
+ assert(cond); \
+ exit(1); \
+ } \
+} while (0)
+
+#define ASSERT_STREQ_EXCEPT(a, b, except) ASSERT(StreqExcept(a, b, except))
+#define ASSERT_STREQ(a, b) ASSERT(strcmp(a, b) == 0)
+#define ASSERT_NOT_STREQ(a, b) ASSERT(strcmp(a, b) != 0)
+#define ASSERT_STREQ_VERBOSE(a, b, c) ASSERT(StrEqVerbose(a, b, c))
+#define ASSERT_INTEQ(a, b) ASSERT(IntEqVerbose(a, b))
+
+namespace {
+
+// First, (conceptually) remove all chars in "except" from both a and b.
+// Then return true iff munged_a == munged_b.
+bool StreqExcept(const char* a, const char* b, const char* except) {
+ const char* pa = a, *pb = b;
+ const size_t exceptlen = strlen(except);
+ while (1) {
+ // Use memchr isntead of strchr because memchr(foo, '\0') always fails
+ while (memchr(except, *pa, exceptlen)) pa++; // ignore "except" chars in a
+ while (memchr(except, *pb, exceptlen)) pb++; // ignore "except" chars in b
+ if ((*pa == '\0') && (*pb == '\0'))
+ return true;
+ if (*pa++ != *pb++) // includes case where one is at \0
+ return false;
+ }
+}
+
+// If a and b do not match, print their values and that of text
+// and return false.
+bool StrEqVerbose(const string& a, const string& b,
+ const string& text) {
+ if (a != b) {
+ printf("EXPECTED: %s\n", a.c_str());
+ printf("ACTUAL: %s\n", b.c_str());
+ printf("TEXT: %s\n", text.c_str());
+ return false;
+ }
+ return true;
+}
+
+bool IntEqVerbose(int a, int b) {
+ if (a != b) {
+ printf("EXPECTED: %d\n", a);
+ printf("ACTUAL: %d\n", b);
+ return false;
+ }
+ return true;
+}
+
+// This test emitter writes to a string, but writes X's of the right
+// length, rather than the actual content passed in.
+class SizeofEmitter : public ExpandEmitter {
+ string* const outbuf_;
+ public:
+ SizeofEmitter(string* outbuf) : outbuf_(outbuf) {}
+ virtual void Emit(char c) { Emit(&c, 1); }
+ virtual void Emit(const string& s) { Emit(s.data(), s.length()); }
+ virtual void Emit(const char* s) { Emit(s, strlen(s)); }
+ virtual void Emit(const char*, size_t slen) { outbuf_->append(slen, 'X'); }
+};
+
+} // unnamed namespace
+
+RegisterTemplateFilename(VALID1_FN, "template_unittest_test_valid1.in");
+RegisterTemplateFilename(INVALID1_FN, "template_unittest_test_invalid1.in");
+RegisterTemplateFilename(INVALID2_FN, "template_unittest_test_invalid2.in");
+RegisterTemplateFilename(NONEXISTENT_FN, "nonexistent__file.tpl");
+
+// Returns the proper AUTOESCAPE pragma that corresponds to the
+// given TemplateContext.
+static string GetPragmaForContext(TemplateContext context) {
+ switch(context) {
+ case TC_HTML:
+ return kPragmaHtml;
+ case TC_JS:
+ return kPragmaJs;
+ case TC_CSS:
+ return kPragmaCss;
+ case TC_JSON:
+ return kPragmaJson;
+ case TC_XML:
+ return kPragmaXml;
+ case TC_MANUAL:
+ return ""; // No AUTOESCAPE pragma.
+ case TC_UNUSED:
+ ASSERT(false); // Developer error, this TC is not to be used.
+ }
+ ASSERT(false); // Developer error - invalid TemplateContext.
+ return "";
+}
+
+// This writes s to a file with the AUTOESCAPE pragma corresponding
+// to the given TemplateContext and then loads it into a template object.
+static Template* StringToTemplateWithAutoEscaping(const string& s,
+ Strip strip,
+ TemplateContext context) {
+ string text = GetPragmaForContext(context) + s;
+ return Template::GetTemplate(StringToTemplateFile(text), strip);
+}
+
+// A helper method used by TestCorrectModifiersForAutoEscape.
+// Populates out with lines of the form:
+// VARNAME:mod1[=val1][:mod2[=val2]]...\n from the dump of the template
+// and compares against the expected string.
+static void AssertCorrectModifiersInTemplate(Template* tpl,
+ const string& text,
+ const string& expected_out) {
+ ASSERT(tpl);
+ string dump_out, out;
+ tpl->DumpToString("bogus_filename", &dump_out);
+ string::size_type i, j;
+ i = 0;
+ while ((i = dump_out.find("Variable Node: ", i)) != string::npos) {
+ i += strlen("Variable Node: ");
+ j = dump_out.find("\n", i);
+ out.append(dump_out.substr(i, j - i)); // should be safe.
+ out.append("\n");
+ }
+ ASSERT_STREQ_VERBOSE(expected_out, out, text);
+}
+
+// Wrapper on top of AssertCorrectModifiersInTemplate which first
+// obtains a template from the given contents and template context.
+static void AssertCorrectModifiers(TemplateContext template_type,
+ const string& text,
+ const string& expected_out) {
+ Strip strip = STRIP_WHITESPACE;
+ Template *tpl = StringToTemplateWithAutoEscaping(text, strip, template_type);
+ AssertCorrectModifiersInTemplate(tpl, text, expected_out);
+}
+
+// A helper method used by TestCorrectModifiersForAutoEscape.
+// Initializes the template in the Auto Escape mode with the
+// given TemplateContext, expands it with the given dictionary
+// and checks that the output matches the expected value.
+static void AssertCorrectEscaping(TemplateContext template_type,
+ const TemplateDictionary& dict,
+ const string& text,
+ const string& expected_out) {
+ Strip strip = STRIP_WHITESPACE;
+ Template *tpl = StringToTemplateWithAutoEscaping(text, strip, template_type);
+ string outstring;
+ tpl->Expand(&outstring, &dict);
+ ASSERT_STREQ_VERBOSE(expected_out, outstring, text);
+}
+
+class DynamicModifier : public GOOGLE_NAMESPACE::TemplateModifier {
+ public:
+ void Modify(const char* in, size_t inlen,
+ const PerExpandData* per_expand_data,
+ ExpandEmitter* outbuf, const string& arg) const {
+ assert(arg.empty()); // we don't take an argument
+ assert(per_expand_data);
+ const char* value = per_expand_data->LookupForModifiersAsString("value");
+ if (value)
+ outbuf->Emit(value);
+ }
+};
+
+class EmphasizeTemplateModifier : public GOOGLE_NAMESPACE::TemplateModifier {
+ public:
+ EmphasizeTemplateModifier(const string& match)
+ : match_(match) {
+ }
+
+ bool MightModify(const PerExpandData* per_expand_data,
+ const string& arg) const {
+ return strstr(arg.c_str(), match_.c_str());
+ }
+
+ void Modify(const char* in, size_t inlen,
+ const PerExpandData* per_expand_data,
+ ExpandEmitter* outbuf, const string& arg) const {
+ outbuf->Emit(">>");
+ outbuf->Emit(in, inlen);
+ outbuf->Emit("<<");
+ }
+
+ private:
+ string match_;
+};
+
+// This is used by TestAnnotation(). It behaves like
+// TextTemplateAnnotator but just to test our ability to customize
+// annotation, and with stateful one, it prefixes each text annotation
+// with an event (call) count.
+class CustomTestAnnotator : public GOOGLE_NAMESPACE::TextTemplateAnnotator {
+ public:
+ CustomTestAnnotator() : event_count_(0) { }
+ void Reset() { event_count_ = 0; }
+
+ virtual void EmitOpenInclude(ExpandEmitter* emitter, const string& value) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenInclude(emitter, value);
+ }
+ virtual void EmitCloseInclude(ExpandEmitter* emitter) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseInclude(emitter);
+ }
+ virtual void EmitOpenFile(ExpandEmitter* emitter, const string& value) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenFile(emitter, value);
+ }
+ virtual void EmitCloseFile(ExpandEmitter* emitter) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseFile(emitter);
+ }
+ virtual void EmitOpenSection(ExpandEmitter* emitter, const string& value) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenSection(emitter, value);
+ }
+ virtual void EmitCloseSection(ExpandEmitter* emitter) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseSection(emitter);
+ }
+ virtual void EmitOpenVariable(ExpandEmitter* emitter, const string& value) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitOpenVariable(emitter, value);
+ }
+ virtual void EmitCloseVariable(ExpandEmitter* emitter) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitCloseVariable(emitter);
+ }
+ virtual void EmitFileIsMissing(ExpandEmitter* emitter,
+ const string& value) {
+ EmitTestPrefix(emitter);
+ GOOGLE_NAMESPACE::TextTemplateAnnotator::EmitFileIsMissing(emitter, value);
+ }
+
+ private:
+ void EmitTestPrefix(ExpandEmitter* emitter) {
+ char buf[128];
+ snprintf(buf, sizeof(buf), "{{EVENT=%d}}", ++event_count_);
+ emitter->Emit(buf);
+ }
+ int event_count_;
+ DISALLOW_COPY_AND_ASSIGN(CustomTestAnnotator);
+};
+
+class TemplateForTest : public Template {
+ public:
+ using Template::kSafeWhitelistedVariables;
+ using Template::kNumSafeWhitelistedVariables;
+ private:
+ // This quiets gcc3, which otherwise complains: "base `Template'
+ // with only non-default constructor in class without a constructor".
+ TemplateForTest();
+};
+
+// Tests annotation, in particular inheriting annotation among children
+// This should be called first, so the filenames don't change as we add
+// more tests.
+static void TestAnnotation() {
+ string incname = StringToTemplateFile("include {{#ISEC}}file{{/ISEC}}\n");
+ string incname2 = StringToTemplateFile("include #2\n");
+ Template* tpl = StringToTemplate(
+ "boo!\n{{>INC}}\nhi {{#SEC}}lo{{#SUBSEC}}jo{{/SUBSEC}}{{/SEC}} bar "
+ "{{VAR:x-foo}}",
+ DO_NOT_STRIP);
+ TemplateDictionary dict("dict");
+ PerExpandData per_expand_data;
+
+ dict.ShowSection("SEC");
+ TemplateDictionary* incdict = dict.AddIncludeDictionary("INC");
+ incdict->SetFilename(incname);
+ incdict->ShowSection("ISEC");
+ dict.AddIncludeDictionary("INC")->SetFilename(incname2);
+ dict.SetValue("VAR", "var");
+
+ // This string is equivalent to "/template." (at least on unix)
+ string slash_tpl(PathJoin(kRootdir, "template."));
+ per_expand_data.SetAnnotateOutput("");
+ char expected[10240]; // 10k should be big enough!
+ snprintf(expected, sizeof(expected),
+ "{{#FILE=%s003}}{{#SEC=__{{MAIN}}__}}boo!\n"
+ "{{#INC=INC}}{{#FILE=%s001}}"
+ "{{#SEC=__{{MAIN}}__}}include {{#SEC=ISEC}}file{{/SEC}}\n"
+ "{{/SEC}}{{/FILE}}{{/INC}}"
+ "{{#INC=INC}}{{#FILE=%s002}}"
+ "{{#SEC=__{{MAIN}}__}}include #2\n{{/SEC}}{{/FILE}}{{/INC}}"
+ "\nhi {{#SEC=SEC}}lo{{/SEC}} bar "
+ "{{#VAR=VAR:x-foo<not registered>}}var{{/VAR}}{{/SEC}}{{/FILE}}",
+ (FLAGS_test_tmpdir + slash_tpl).c_str(),
+ (FLAGS_test_tmpdir + slash_tpl).c_str(),
+ (FLAGS_test_tmpdir + slash_tpl).c_str());
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data, expected, true);
+
+ // Test ability to set custom annotator.
+ CustomTestAnnotator custom_annotator;
+ per_expand_data.SetAnnotator(&custom_annotator);
+ snprintf(expected, sizeof(expected),
+ "{{EVENT=1}}{{#FILE=%s003}}"
+ "{{EVENT=2}}{{#SEC=__{{MAIN}}__}}boo!\n"
+ "{{EVENT=3}}{{#INC=INC}}"
+ "{{EVENT=4}}{{#FILE=%s001}}"
+ "{{EVENT=5}}{{#SEC=__{{MAIN}}__}}include "
+ "{{EVENT=6}}{{#SEC=ISEC}}file"
+ "{{EVENT=7}}{{/SEC}}\n"
+ "{{EVENT=8}}{{/SEC}}"
+ "{{EVENT=9}}{{/FILE}}"
+ "{{EVENT=10}}{{/INC}}"
+ "{{EVENT=11}}{{#INC=INC}}"
+ "{{EVENT=12}}{{#FILE=%s002}}"
+ "{{EVENT=13}}{{#SEC=__{{MAIN}}__}}include #2\n"
+ "{{EVENT=14}}{{/SEC}}"
+ "{{EVENT=15}}{{/FILE}}"
+ "{{EVENT=16}}{{/INC}}\nhi "
+ "{{EVENT=17}}{{#SEC=SEC}}lo"
+ "{{EVENT=18}}{{/SEC}} bar "
+ "{{EVENT=19}}{{#VAR=VAR:x-foo<not registered>}}var"
+ "{{EVENT=20}}{{/VAR}}"
+ "{{EVENT=21}}{{/SEC}}"
+ "{{EVENT=22}}{{/FILE}}",
+ (FLAGS_test_tmpdir + slash_tpl).c_str(),
+ (FLAGS_test_tmpdir + slash_tpl).c_str(),
+ (FLAGS_test_tmpdir + slash_tpl).c_str());
+ // We can't use AssertExpandWithDataIs() on our deliberately stateful
+ // test annotator because it internally does a second expansion
+ // assuming no state change between calls.
+ string custom_outstring;
+ ASSERT(tpl->ExpandWithData(&custom_outstring, &dict, &per_expand_data));
+ ASSERT_STREQ(custom_outstring.c_str(), expected);
+
+ // Unset annotator and continue with next test as test of ability
+ // to revert to built-in annotator.
+ per_expand_data.SetAnnotator(NULL);
+
+ per_expand_data.SetAnnotateOutput(slash_tpl.c_str());
+ snprintf(expected, sizeof(expected),
+ "{{#FILE=%s003}}{{#SEC=__{{MAIN}}__}}boo!\n"
+ "{{#INC=INC}}{{#FILE=%s001}}"
+ "{{#SEC=__{{MAIN}}__}}include {{#SEC=ISEC}}file{{/SEC}}\n"
+ "{{/SEC}}{{/FILE}}{{/INC}}"
+ "{{#INC=INC}}{{#FILE=%s002}}"
+ "{{#SEC=__{{MAIN}}__}}include #2\n{{/SEC}}{{/FILE}}{{/INC}}"
+ "\nhi {{#SEC=SEC}}lo{{/SEC}} bar "
+ "{{#VAR=VAR:x-foo<not registered>}}var{{/VAR}}{{/SEC}}{{/FILE}}",
+ (slash_tpl).c_str(),
+ (slash_tpl).c_str(),
+ (slash_tpl).c_str());
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data, expected, true);
+
+ per_expand_data.SetAnnotateOutput(NULL); // should turn off annotations
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data,
+ "boo!\ninclude file\ninclude #2\n\nhi lo bar var",
+ true);
+
+ // Test that even if we set an annotator we shouldn't get annotation
+ // if it is not turned on with SetAnnotateOutput().
+ per_expand_data.SetAnnotator(&custom_annotator);
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data,
+ "boo!\ninclude file\ninclude #2\n\nhi lo bar var",
+ true);
+
+ // Test annotation of "missing include" condition.
+ Template* one_inc_tpl =
+ StringToTemplate("File contents: {{>INC}}\n", DO_NOT_STRIP);
+ TemplateDictionary dict_missing_file("dict_with_missing_file");
+ dict_missing_file.AddIncludeDictionary("INC")->SetFilename("missing.tpl");
+
+ per_expand_data.SetAnnotateOutput("");
+ per_expand_data.SetAnnotator(NULL);
+ snprintf(expected, sizeof(expected),
+ "{{#FILE=%s004}}{{#SEC=__{{MAIN}}__}}File contents: "
+ "{{#INC=INC}}{{MISSING_FILE=missing.tpl}}{{/INC}}\n"
+ "{{/SEC}}{{/FILE}}",
+ (FLAGS_test_tmpdir + slash_tpl).c_str());
+ // We expect a false return value because of the missing file.
+ AssertExpandWithDataIs(one_inc_tpl, &dict_missing_file, &per_expand_data,
+ expected, false);
+
+ // Same missing include test with custom annotator
+ custom_annotator.Reset();
+ per_expand_data.SetAnnotator(&custom_annotator);
+ snprintf(expected, sizeof(expected),
+ "{{EVENT=1}}{{#FILE=%s004}}"
+ "{{EVENT=2}}{{#SEC=__{{MAIN}}__}}File contents: "
+ "{{EVENT=3}}{{#INC=INC}}"
+ "{{EVENT=4}}{{MISSING_FILE=missing.tpl}}"
+ "{{EVENT=5}}{{/INC}}\n"
+ "{{EVENT=6}}{{/SEC}}"
+ "{{EVENT=7}}{{/FILE}}",
+ (FLAGS_test_tmpdir + slash_tpl).c_str());
+ // See comment above on why we can't use AssertExpandWithDataIs() for
+ // our stateful test annotator.
+ custom_outstring.clear();
+ ASSERT(!one_inc_tpl->ExpandWithData(&custom_outstring,
+ &dict_missing_file,
+ &per_expand_data));
+ ASSERT_STREQ(custom_outstring.c_str(), expected);
+}
+
+TEST(Template, CheckWhitelistedVariablesSorted) {
+ // NOTE(williasr): kSafeWhitelistedVariables must be sorted, it's accessed
+ // using binary search.
+ for (size_t i = 1; i < TemplateForTest::kNumSafeWhitelistedVariables; i++) {
+ assert(strcmp(TemplateForTest::kSafeWhitelistedVariables[i-1],
+ TemplateForTest::kSafeWhitelistedVariables[i]) < 0);
+ }
+}
+
+
+// The following tests test various aspects of how Expand() should behave.
+TEST(Template, WeirdSyntax) {
+ TemplateDictionary dict("dict");
+
+ // When we see {{{, we should match the second {{, not the first.
+ Template* tpl1 = StringToTemplate("hi {{{! VAR {{!VAR} }} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl1, &dict, "hi { lo", true);
+
+ // Likewise for }}}
+ Template* tpl2 = StringToTemplate("fn(){{{BI_NEWLINE}} x=4;{{BI_NEWLINE}}}",
+ DO_NOT_STRIP);
+ AssertExpandIs(tpl2, &dict, "fn(){\n x=4;\n}", true);
+
+ // Try lots of {'s!
+ Template* tpl3 = StringToTemplate("{{{{{{VAR}}}}}}}}", DO_NOT_STRIP);
+ AssertExpandIs(tpl3, &dict, "{{{{}}}}}}", true);
+}
+
+TEST(Template, Comment) {
+ TemplateDictionary dict("dict");
+ Template* tpl1 = StringToTemplate("hi {{!VAR}} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl1, &dict, "hi lo", true);
+
+ Template* tpl2 = StringToTemplate("hi {{!VAR {VAR} }} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl2, &dict, "hi lo", true);
+
+ Template* tpl3 = StringToTemplate("hi {{! VAR {{!VAR} }} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl3, &dict, "hi lo", true);
+}
+
+TEST(Template, SetMarkerDelimiters) {
+ TemplateDictionary dict("dict");
+ dict.SetValue("VAR", "yo");
+ Template* tpl1 = StringToTemplate("{{=| |=}}\nhi |VAR| {{lo}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl1, &dict, "hi yo {{lo}}", true);
+
+ Template* tpl2 = StringToTemplate("{{=| |=}}hi |VAR| {{lo}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl2, &dict, "hi yo {{lo}}", true);
+
+ Template* tpl3 = StringToTemplate("{{=| ||=}}hi ||VAR|||VAR|| {{lo}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl3, &dict, "hi |yoyo {{lo}}", true);
+
+ Template* tpl4 = StringToTemplate("{{=< >=}}hi <<VAR>> {{lo}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl4, &dict, "hi <yo> {{lo}}", true);
+
+ Template* tpl4b = StringToTemplate("{{=<< >>=}}hi <<VAR>> {{lo}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl4b, &dict, "hi yo {{lo}}", true);
+
+ Template* tpl4c = StringToTemplate("{{=<< <<=}}hi <<VAR<< {{lo}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl4c, &dict, "hi yo {{lo}}", true);
+
+ Template* tpl5 = StringToTemplate("hi {{VAR}} lo\n{{=< >=}}\n"
+ "hi {{VAR}} lo\n"
+ "hi <VAR> lo\n<={ }=>\n"
+ "hi {{VAR}} lo\n{={{ }}=}\n"
+ "hi {{VAR}} lo\n",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl5, &dict,
+ "hi yo lohi {{VAR}} lohi yo lohi {yo} lohi yo lo",
+ true);
+
+ Template* tpl6 = StringToTemplate("hi {{VAR}} lo\n{{=< >}}\n",
+ STRIP_WHITESPACE);
+ ASSERT(tpl6 == NULL);
+
+ Template* tpl7 = StringToTemplate("hi {{VAR}} lo\n{{=<>}}\n",
+ STRIP_WHITESPACE);
+ ASSERT(tpl7 == NULL);
+
+ Template* tpl8 = StringToTemplate("hi {{VAR}} lo\n{{=< >=}}\n",
+ STRIP_WHITESPACE);
+ ASSERT(tpl8 == NULL);
+
+ Template* tpl9 = StringToTemplate("hi {{VAR}} lo\n{{==}}\n",
+ STRIP_WHITESPACE);
+ ASSERT(tpl9 == NULL);
+
+ Template* tpl10 = StringToTemplate("hi {{VAR}} lo\n{{=}}\n",
+ STRIP_WHITESPACE);
+ ASSERT(tpl10 == NULL);
+
+ // Test that {{= =}} is a "removable" marker.
+ Template* tpl11 = StringToTemplate("line\n {{=| |=}} \nhi |VAR| {{lo}}\n",
+ STRIP_BLANK_LINES);
+ AssertExpandIs(tpl11, &dict, "line\nhi yo {{lo}}\n", true);
+
+ // Test that "removable" markers survive marker-modification.
+ Template* tpl12 = StringToTemplate(" {{#SEC1}} \n"
+ "{{=| |=}} |VAR|\n"
+ " |/SEC1|\ntada! |VAR|\n"
+ "hello|=<< >>=|\n"
+ " <<! a blank line>> \n"
+ "done",
+ STRIP_BLANK_LINES);
+ AssertExpandIs(tpl12, &dict, "tada! yo\nhello\ndone", true);
+}
+
+TEST(Template, Variable) {
+ Template* tpl = StringToTemplate("hi {{VAR}} lo", STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+ AssertExpandIs(tpl, &dict, "hi lo", true);
+ dict.SetValue("VAR", "yo");
+ AssertExpandIs(tpl, &dict, "hi yo lo", true);
+ dict.SetValue("VAR", "yoyo");
+ AssertExpandIs(tpl, &dict, "hi yoyo lo", true);
+ dict.SetValue("VA", "noyo");
+ dict.SetValue("VAR ", "noyo2");
+ dict.SetValue("var", "noyo3");
+ AssertExpandIs(tpl, &dict, "hi yoyo lo", true);
+
+ // Sanity check string template behaviour while we're at it.
+ Template* tpl2 = Template::StringToTemplate("hi {{VAR}} lo",
+ STRIP_WHITESPACE);
+ TemplateDictionary dict2("dict");
+ AssertExpandIs(tpl2, &dict2, "hi lo", true);
+ dict2.SetValue("VAR", "yo");
+ AssertExpandIs(tpl2, &dict2, "hi yo lo", true);
+ dict2.SetValue("VAR", "yoyo");
+ AssertExpandIs(tpl2, &dict2, "hi yoyo lo", true);
+ dict2.SetValue("VA", "noyo");
+ dict2.SetValue("VAR ", "noyo2");
+ dict2.SetValue("var", "noyo3");
+ AssertExpandIs(tpl2, &dict2, "hi yoyo lo", true);
+ delete tpl2; // You have to delete StringToTemplate strings
+}
+
+TEST(Template, VariableWithModifiers) {
+ Template* tpl = StringToTemplate("hi {{VAR:html_escape}} lo",
+ STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+
+ // Test with no modifiers.
+ dict.SetValue("VAR", "yo");
+ AssertExpandIs(tpl, &dict, "hi yo lo", true);
+ dict.SetValue("VAR", "yo&yo");
+ AssertExpandIs(tpl, &dict, "hi yo&yo lo", true);
+
+ // Test with URL escaping.
+ tpl = StringToTemplate("<a href=\"/servlet?param={{VAR:u}}\">",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "<a href=\"/servlet?param=yo%26yo\">", true);
+ tpl = StringToTemplate("<a href='/servlet?param={{VAR:url_query_escape}}'>",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "<a href='/servlet?param=yo%26yo'>", true);
+
+ // Test with multiple URL escaping.
+ tpl = StringToTemplate("<a href=\"/servlet?param={{VAR:u:u}}\">",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "<a href=\"/servlet?param=yo%2526yo\">", true);
+
+ // Test HTML escaping.
+ tpl = StringToTemplate("hi {{VAR:h}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo&yo lo", true);
+
+ tpl = StringToTemplate("hi {{VAR:h:h}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo&amp;yo lo", true);
+
+ // Test special HTML escaping
+ dict.SetValue("URL_VAR", "javascript:void");
+ dict.SetValue("SNIPPET_VAR", "<b>foo & bar</b>");
+ tpl = StringToTemplate("hi {{VAR:H=attribute}} {{URL_VAR:H=url}} "
+ "{{SNIPPET_VAR:H=snippet}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo_yo # <b>foo & bar</b> lo", true);
+
+ // Test with custom modifiers [regular or XssSafe should not matter].
+ ASSERT(GOOGLE_NAMESPACE::AddModifier("x-test",
+ &GOOGLE_NAMESPACE::html_escape));
+ ASSERT(GOOGLE_NAMESPACE::AddModifier("x-test-arg=",
+ &GOOGLE_NAMESPACE::html_escape));
+ ASSERT(GOOGLE_NAMESPACE::AddXssSafeModifier("x-test-arg=snippet",
+ &GOOGLE_NAMESPACE::snippet_escape));
+
+ tpl = StringToTemplate("hi {{VAR:x-test}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo&yo lo", true);
+ tpl = StringToTemplate("hi {{SNIPPET_VAR:x-test-arg=snippet}} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi <b>foo & bar</b> lo", true);
+ tpl = StringToTemplate("hi {{VAR:x-unknown}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo&yo lo", true);
+
+ // Test with a modifier taking per-expand data
+ DynamicModifier dynamic_modifier;
+ ASSERT(GOOGLE_NAMESPACE::AddModifier("x-dynamic", &dynamic_modifier));
+ PerExpandData per_expand_data;
+ tpl = StringToTemplate("hi {{VAR:x-dynamic}} lo", STRIP_WHITESPACE);
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data, "hi lo", true);
+ per_expand_data.InsertForModifiers("value", "foo");
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data, "hi foo lo", true);
+ per_expand_data.InsertForModifiers("value", "bar");
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data, "hi bar lo", true);
+ per_expand_data.InsertForModifiers("value", NULL);
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data, "hi lo", true);
+
+ // Test with no modifiers.
+ tpl = StringToTemplate("hi {{VAR}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo&yo lo", true);
+
+ // Check that ordering is right
+ dict.SetValue("VAR", "yo\nyo");
+ tpl = StringToTemplate("hi {{VAR:h}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo yo lo", true);
+ tpl = StringToTemplate("hi {{VAR:p}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo\nyo lo", true);
+ tpl = StringToTemplate("hi {{VAR:j}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo\\nyo lo", true);
+ tpl = StringToTemplate("hi {{VAR:h:j}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo yo lo", true);
+ tpl = StringToTemplate("hi {{VAR:j:h}} lo", STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo\\nyo lo", true);
+
+ // Check more complicated modifiers using fullname
+ tpl = StringToTemplate("hi {{VAR:javascript_escape:h}} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo\\nyo lo", true);
+ tpl = StringToTemplate("hi {{VAR:j:html_escape}} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo\\nyo lo", true);
+ tpl = StringToTemplate("hi {{VAR:pre_escape:j}} lo",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict, "hi yo\\nyo lo", true);
+
+ // Check that illegal modifiers are rejected
+ tpl = StringToTemplate("hi {{VAR:j:h2}} lo", STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+ tpl = StringToTemplate("hi {{VAR:html_ecap}} lo", STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+ tpl = StringToTemplate("hi {{VAR:javascript_escaper}} lo",
+ STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+ tpl = StringToTemplate("hi {{VAR:js:j}} lo", STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+ tpl = StringToTemplate("hi {{VAR:}} lo", STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+
+ // Check we reject modifier-values when we ought to
+ tpl = StringToTemplate("hi {{VAR:j=4}} lo", STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+ tpl = StringToTemplate("hi {{VAR:html_escape=yes}} lo", STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+ tpl = StringToTemplate("hi {{VAR:url_query_escape=wombats}} lo",
+ STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+
+ // Check we don't allow modifiers on sections
+ tpl = StringToTemplate("hi {{#VAR:h}} lo {{/VAR}}", STRIP_WHITESPACE);
+ ASSERT(tpl == NULL);
+
+ // Test when expanded grows by more than 12% per modifier.
+ dict.SetValue("VAR", "http://a.com?b=c&d=e&f=g&q=a>b");
+ tpl = StringToTemplate("{{VAR:u:j:h}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict,
+ "http%3A//a.com%3Fb%3Dc%26d%3De%26f%3Dg%26q%3Da%3Eb",
+ true);
+
+ // As above with 4 modifiers.
+ dict.SetValue("VAR", "http://a.com?b=c&d=e&f=g&q=a>b");
+ tpl = StringToTemplate("{{VAR:u:j:h:h}}",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl, &dict,
+ "http%3A//a.com%3Fb%3Dc%26d%3De%26f%3Dg%26q%3Da%3Eb",
+ true);
+}
+
+TEST(Template, Section) {
+ Template* tpl = StringToTemplate(
+ "boo!\nhi {{#SEC}}lo{{#SUBSEC}}jo{{/SUBSEC}}{{/SEC}} bar",
+ STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+ AssertExpandIs(tpl, &dict, "boo!hi bar", true);
+ dict.ShowSection("SEC");
+ AssertExpandIs(tpl, &dict, "boo!hi lo bar", true);
+ dict.ShowSection("SEC");
+ AssertExpandIs(tpl, &dict, "boo!hi lo bar", true);
+ // This should work even though subsec isn't a child of the main dict
+ dict.ShowSection("SUBSEC");
+ AssertExpandIs(tpl, &dict, "boo!hi lojo bar", true);
+
+ TemplateDictionary dict2("dict2");
+ dict2.AddSectionDictionary("SEC");
+ AssertExpandIs(tpl, &dict2, "boo!hi lo bar", true);
+ dict2.AddSectionDictionary("SEC");
+ AssertExpandIs(tpl, &dict2, "boo!hi lolo bar", true);
+ dict2.AddSectionDictionary("sec");
+ AssertExpandIs(tpl, &dict2, "boo!hi lolo bar", true);
+ dict2.ShowSection("SUBSEC");
+ AssertExpandIs(tpl, &dict2, "boo!hi lojolojo bar", true);
+}
+
+
+TEST(Template, SectionSeparator) {
+ Template* tpl = StringToTemplate(
+ "hi {{#SEC}}lo{{#SEC_separator}}jo{{JO}}{{/SEC_separator}}{{/SEC}} bar",
+ STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+ AssertExpandIs(tpl, &dict, "hi bar", true);
+ // Since SEC is only expanded once, the separator section shouldn't show.
+ dict.ShowSection("SEC");
+ AssertExpandIs(tpl, &dict, "hi lo bar", true);
+ dict.ShowSection("SEC");
+ AssertExpandIs(tpl, &dict, "hi lo bar", true);
+ // This should work even though SEC_separator isn't a child of the
+ // main dict. It verifies SEC_separator is just a normal section, too.
+ dict.ShowSection("SEC_separator");
+ AssertExpandIs(tpl, &dict, "hi lojo bar", true);
+
+ TemplateDictionary dict2("dict2");
+ dict2.AddSectionDictionary("SEC");
+ AssertExpandIs(tpl, &dict2, "hi lo bar", true);
+ dict2.AddSectionDictionary("SEC");
+ AssertExpandIs(tpl, &dict2, "hi lojolo bar", true);
+ // This is a weird case: using separator and specifying manually.
+ dict2.ShowSection("SEC_separator");
+ AssertExpandIs(tpl, &dict2, "hi lojojolojo bar", true);
+
+ TemplateDictionary dict3("dict3");
+ TemplateDictionary* sec1 = dict3.AddSectionDictionary("SEC");
+ TemplateDictionary* sec2 = dict3.AddSectionDictionary("SEC");
+ TemplateDictionary* sec3 = dict3.AddSectionDictionary("SEC");
+ dict3.SetValue("JO", "J");
+ AssertExpandIs(tpl, &dict3, "hi lojoJlojoJlo bar", true);
+ sec1->SetValue("JO", "JO");
+ AssertExpandIs(tpl, &dict3, "hi lojoJOlojoJlo bar", true);
+ sec2->SetValue("JO", "JOO");
+ AssertExpandIs(tpl, &dict3, "hi lojoJOlojoJOOlo bar", true);
+ dict3.AddSectionDictionary("SEC");
+ AssertExpandIs(tpl, &dict3, "hi lojoJOlojoJOOlojoJlo bar", true);
+ sec3->AddSectionDictionary("SEC_separator");
+ AssertExpandIs(tpl, &dict3, "hi lojoJOlojoJOOlojoJjoJlo bar", true);
+
+ // Make sure we don't do anything special with var or include names
+ Template* tpl2 = StringToTemplate(
+ "hi {{#SEC}}lo{{>SEC_separator}}{{/SEC}} bar",
+ STRIP_WHITESPACE);
+ AssertExpandIs(tpl2, &dict2, "hi lolo bar", true);
+
+ Template* tpl3 = StringToTemplate(
+ "hi {{#SEC}}lo{{SEC_separator}}{{/SEC}} bar",
+ STRIP_WHITESPACE);
+ dict2.SetValue("SEC_separator", "-");
+ AssertExpandIs(tpl3, &dict2, "hi lo-lo- bar", true);
+}
+
+TEST(Template, Include) {
+ string incname = StringToTemplateFile("include file\n");
+ string incname2 = StringToTemplateFile("inc2a\ninc2b\n");
+ string incname_bad = StringToTemplateFile("{{syntax_error");
+ Template* tpl = StringToTemplate("hi {{>INC}} bar\n", STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+ AssertExpandIs(tpl, &dict, "hi bar", true);
+ dict.AddIncludeDictionary("INC");
+ AssertExpandIs(tpl, &dict, "hi bar", true); // noop: no filename was set
+ dict.AddIncludeDictionary("INC")->SetFilename("/notarealfile ");
+ AssertExpandIs(tpl, &dict, "hi bar", false); // noop: illegal filename
+ dict.AddIncludeDictionary("INC")->SetFilename(incname);
+ AssertExpandIs(tpl, &dict, "hi include file bar", false);
+ dict.AddIncludeDictionary("INC")->SetFilename(incname_bad);
+ AssertExpandIs(tpl, &dict, "hi include file bar",
+ false); // noop: syntax error
+ dict.AddIncludeDictionary("INC")->SetFilename(incname);
+ AssertExpandIs(tpl, &dict, "hi include fileinclude file bar", false);
+ dict.AddIncludeDictionary("inc")->SetFilename(incname);
+ AssertExpandIs(tpl, &dict, "hi include fileinclude file bar", false);
+ dict.AddIncludeDictionary("INC")->SetFilename(incname2);
+ AssertExpandIs(tpl, &dict,
+ "hi include fileinclude fileinc2ainc2b bar", false);
+
+ // Now test that includes preserve Strip
+ Template* tpl2 = StringToTemplate("hi {{>INC}} bar", DO_NOT_STRIP);
+ AssertExpandIs(tpl2, &dict,
+ "hi include file\ninclude file\ninc2a\ninc2b\n bar", false);
+
+ // Test that if we indent the include, every line on the include
+ // is indented.
+ Template* tpl3 = StringToTemplate("hi\n {{>INC}} bar", DO_NOT_STRIP);
+ AssertExpandIs(tpl3, &dict,
+ "hi\n include file\n include file\n"
+ " inc2a\n inc2b\n bar",
+ false);
+ // But obviously, if we strip leading whitespace, no indentation.
+ Template* tpl4 = StringToTemplate("hi\n {{>INC}} bar", STRIP_WHITESPACE);
+ AssertExpandIs(tpl4, &dict,
+ "hiinclude fileinclude fileinc2ainc2b bar", false);
+ // And if it's not a whitespace indent, we don't indent either.
+ Template* tpl5 = StringToTemplate("hi\n - {{>INC}} bar", DO_NOT_STRIP);
+ AssertExpandIs(tpl5, &dict,
+ "hi\n - include file\ninclude file\n"
+ "inc2a\ninc2b\n bar",
+ false);
+ // Make sure we indent properly at the beginning.
+ Template* tpl6 = StringToTemplate(" {{>INC}}\nbar", DO_NOT_STRIP);
+ AssertExpandIs(tpl6, &dict,
+ " include file\n include file\n"
+ " inc2a\n inc2b\n \nbar",
+ false);
+ // And deal correctly when we include twice in a row.
+ Template* tpl7 = StringToTemplate(" {{>INC}}-{{>INC}}", DO_NOT_STRIP);
+ AssertExpandIs(tpl7, &dict,
+ " include file\n include file\n inc2a\n inc2b\n "
+ "-include file\ninclude file\ninc2a\ninc2b\n",
+ false);
+}
+
+TEST(Template, IncludeWithModifiers) {
+ string incname = StringToTemplateFile("include & print file\n");
+ string incname2 = StringToTemplateFile("inc2\n");
+ string incname3 = StringToTemplateFile("yo&yo");
+ // Note this also tests that html-escape, but not javascript-escape or
+ // pre-escape, escapes \n to <space>
+ Template* tpl1 = StringToTemplate("hi {{>INC:h}} bar\n", DO_NOT_STRIP);
+ Template* tpl2 = StringToTemplate("hi {{>INC:javascript_escape}} bar\n",
+ DO_NOT_STRIP);
+ Template* tpl3 = StringToTemplate("hi {{>INC:pre_escape}} bar\n",
+ DO_NOT_STRIP);
+ Template* tpl4 = StringToTemplate("hi {{>INC:u}} bar\n", DO_NOT_STRIP);
+ // Test that if we include the same template twice, once with a modifer
+ // and once without, they each get applied properly.
+ Template* tpl5 = StringToTemplate("hi {{>INC:h}} bar {{>INC}} baz\n",
+ DO_NOT_STRIP);
+
+ TemplateDictionary dict("dict");
+ AssertExpandIs(tpl1, &dict, "hi bar\n", true);
+ dict.AddIncludeDictionary("INC")->SetFilename(incname);
+ AssertExpandIs(tpl1, &dict, "hi include & print file bar\n", true);
+ dict.AddIncludeDictionary("INC")->SetFilename(incname2);
+ AssertExpandIs(tpl1, &dict, "hi include & print file inc2 bar\n",
+ true);
+ AssertExpandIs(tpl2, &dict, "hi include \\x26 print file\\ninc2\\n bar\n",
+ true);
+ AssertExpandIs(tpl3, &dict, "hi include & print file\ninc2\n bar\n",
+ true);
+ dict.AddIncludeDictionary("INC")->SetFilename(incname3);
+ AssertExpandIs(tpl4, &dict,
+ "hi include+%26+print+file%0Ainc2%0Ayo%26yo bar\n",
+ true);
+ AssertExpandIs(tpl5, &dict,
+ "hi include & print file inc2 yo&yo bar "
+ "include & print file\ninc2\nyo&yo baz\n",
+ true);
+
+ // Don't test modifier syntax here; that's in TestVariableWithModifiers()
+}
+
+// Make sure we don't deadlock when a template includes itself.
+// This also tests we handle recursive indentation properly.
+TEST(Template, RecursiveInclude) {
+ string incname = StringToTemplateFile("hi {{>INC}} bar\n {{>INC}}!");
+ Template* tpl = Template::GetTemplate(incname, DO_NOT_STRIP);
+ TemplateDictionary dict("dict");
+ dict.AddIncludeDictionary("INC")->SetFilename(incname);
+ // Note the last line is indented 4 spaces instead of 2. This is
+ // because the last sub-include is indented.
+ AssertExpandIs(tpl, &dict, "hi hi bar\n ! bar\n hi bar\n !!", true);
+}
+
+// Tests that vars inherit/override their parents properly
+TEST(Template, Inheritence) {
+ Template* tpl = StringToTemplate("{{FOO}}{{#SEC}}{{FOO}}{{#SEC}}{{FOO}}{{/SEC}}{{/SEC}}",
+ STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+ dict.SetValue("FOO", "foo");
+ dict.ShowSection("SEC");
+ AssertExpandIs(tpl, &dict, "foofoofoo", true);
+
+ TemplateDictionary dict2("dict2");
+ dict2.SetValue("FOO", "foo");
+ TemplateDictionary* sec = dict2.AddSectionDictionary("SEC");
+ AssertExpandIs(tpl, &dict2, "foofoofoo", true);
+ sec->SetValue("FOO", "bar");
+ AssertExpandIs(tpl, &dict2, "foobarbar", true);
+ TemplateDictionary* sec2 = sec->AddSectionDictionary("SEC");
+ AssertExpandIs(tpl, &dict2, "foobarbar", true);
+ sec2->SetValue("FOO", "baz");
+ AssertExpandIs(tpl, &dict2, "foobarbaz", true);
+
+ // Now test an include template, which shouldn't inherit from its parents
+ tpl = StringToTemplate("{{FOO}}{{#SEC}}hi{{/SEC}}\n{{>INC}}",
+ STRIP_WHITESPACE);
+ string incname = StringToTemplateFile(
+ "include {{FOO}}{{#SEC}}invisible{{/SEC}}file\n");
+ TemplateDictionary incdict("dict");
+ incdict.ShowSection("SEC");
+ incdict.SetValue("FOO", "foo");
+ incdict.AddIncludeDictionary("INC")->SetFilename(incname);
+ AssertExpandIs(tpl, &incdict, "foohiinclude file", true);
+}
+
+TEST(Template, TemplateString) {
+ // Make sure using TemplateString and StaticTemplateString for the
+ // dictionary expands the same as using char*'s.
+ Template* tpl = StringToTemplate("hi {{VAR}} lo", STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+ dict.SetValue("VAR", TemplateString("short-lived", strlen("short")));
+ AssertExpandIs(tpl, &dict, "hi short lo", true);
+ dict.SetValue("VAR", kHello);
+ AssertExpandIs(tpl, &dict, "hi Hello lo", true);
+}
+
+// Tests that we append to the output string, rather than overwrite
+TEST(Template, Expand) {
+ Template* tpl = StringToTemplate("hi", STRIP_WHITESPACE);
+ TemplateDictionary dict("test_expand");
+ string output("premade");
+ ASSERT(tpl->Expand(&output, &dict));
+ ASSERT_STREQ(output.c_str(), "premadehi");
+
+ tpl = StringToTemplate(" lo ", STRIP_WHITESPACE);
+ ASSERT(tpl->Expand(&output, &dict));
+ ASSERT_STREQ(output.c_str(), "premadehilo");
+}
+
+TEST(Template, ExpandTemplate) {
+ string filename = StringToTemplateFile(" hi {{THERE}}");
+ TemplateDictionary dict("test_expand");
+ dict.SetValue("THERE", "test");
+ string output;
+ ASSERT(ExpandTemplate(filename, STRIP_WHITESPACE, &dict, &output));
+ ASSERT_STREQ(output.c_str(), "hi test");
+
+ // This will append to output, so we see both together.
+ ASSERT(ExpandWithData(filename, DO_NOT_STRIP, &dict, NULL, &output));
+ ASSERT_STREQ(output.c_str(), "hi test hi test");
+
+ ASSERT(!ExpandTemplate(filename + " not found", DO_NOT_STRIP, &dict,
+ &output));
+}
+
+TEST(Template, ExpandWithCustomEmitter) {
+ Template* tpl = StringToTemplate("{{VAR}} {{VAR}}", STRIP_WHITESPACE);
+ TemplateDictionary dict("test_expand");
+ dict.SetValue("VAR", "this song is just six words long");
+ string output;
+ SizeofEmitter e(&output);
+ ASSERT(tpl->Expand(&e, &dict));
+ ASSERT_STREQ("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
+ "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
+ output.c_str());
+}
+
+TEST(Template, TemplateExpansionModifier) {
+ string parent_tpl_name = StringToTemplateFile("before {{>INC}} after");
+ string child_tpl_name1 = StringToTemplateFile("child1");
+ string child_tpl_name2 = StringToTemplateFile("child2");
+ Template* tpl = Template::GetTemplate(parent_tpl_name, DO_NOT_STRIP);
+
+ TemplateDictionary dict("parent dict");
+ dict.AddIncludeDictionary("INC")->SetFilename(child_tpl_name1);
+ dict.AddIncludeDictionary("INC")->SetFilename(child_tpl_name2);
+
+ PerExpandData per_expand_data;
+
+ EmphasizeTemplateModifier modifier1(child_tpl_name1);
+ per_expand_data.SetTemplateExpansionModifier(&modifier1);
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data,
+ "before >>child1<<child2 after", true);
+
+ EmphasizeTemplateModifier modifier2(child_tpl_name2);
+ per_expand_data.SetTemplateExpansionModifier(&modifier2);
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data,
+ "before child1>>child2<< after", true);
+
+ EmphasizeTemplateModifier modifier3(parent_tpl_name);
+ per_expand_data.SetTemplateExpansionModifier(&modifier3);
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data,
+ ">>before child1child2 after<<", true);
+
+ per_expand_data.SetTemplateExpansionModifier(NULL);
+ AssertExpandWithDataIs(tpl, &dict, &per_expand_data,
+ "before child1child2 after", true);
+}
+
+TEST(Template, GetTemplate) {
+ // Tests the cache
+ string filename = StringToTemplateFile("{This is perfectly valid} yay!");
+ Template* tpl1 = Template::GetTemplate(filename, DO_NOT_STRIP);
+ Template* tpl2 = Template::GetTemplate(filename.c_str(), DO_NOT_STRIP);
+ Template* tpl3 = Template::GetTemplate(filename, STRIP_WHITESPACE);
+ ASSERT(tpl1 && tpl2 && tpl3);
+ ASSERT(tpl1 == tpl2);
+ ASSERT(tpl1 != tpl3);
+
+ // Tests that a nonexistent template returns NULL
+ Template* tpl4 = Template::GetTemplate("/yakakak", STRIP_WHITESPACE);
+ ASSERT(!tpl4);
+
+ // Tests that syntax errors cause us to return NULL
+ Template* tpl5 = StringToTemplate("{{This has spaces in it}}", DO_NOT_STRIP);
+ ASSERT(!tpl5);
+ Template* tpl6 = StringToTemplate("{{#SEC}}foo", DO_NOT_STRIP);
+ ASSERT(!tpl6);
+ Template* tpl7 = StringToTemplate("{{#S1}}foo{{/S2}}", DO_NOT_STRIP);
+ ASSERT(!tpl7);
+ Template* tpl8 = StringToTemplate("{{#S1}}foo{{#S2}}bar{{/S1}{{/S2}",
+ DO_NOT_STRIP);
+ ASSERT(!tpl8);
+ Template* tpl9 = StringToTemplate("{{noend", DO_NOT_STRIP);
+ ASSERT(!tpl9);
+}
+
+TEST(Template, StringCacheKey) {
+ // If you use these same cache keys somewhere else,
+ // call Template::ClearCache first.
+ const string cache_key_a = "cache key a";
+ const string text = "Test template 1";
+ TemplateDictionary empty_dict("dict");
+
+ // When a string template is registered via StringToTemplateCache,
+ // we can use GetTemplate for that same cache-key under any other
+ // Strip because we cache the contents.
+ Template *tpl1, *tpl2;
+ ASSERT(Template::StringToTemplateCache(cache_key_a, text));
+ tpl1 = Template::GetTemplate(cache_key_a, DO_NOT_STRIP);
+ AssertExpandIs(tpl1, &empty_dict, text, true);
+
+ // Different strip.
+ ASSERT(tpl2 = Template::GetTemplate(cache_key_a, STRIP_BLANK_LINES));
+ ASSERT(tpl2 != tpl1);
+ AssertExpandIs(tpl2, &empty_dict, text, true);
+
+ Template::ClearCache();
+}
+
+TEST(Template, StringGetTemplate) {
+ TemplateDictionary dict("dict");
+
+ // Test cache lookups
+ const char* const tpltext = "{This is perfectly valid} yay!";
+ ASSERT(Template::StringToTemplateCache("tgt", tpltext));
+
+ Template* tpl1 = Template::GetTemplate("tgt", DO_NOT_STRIP);
+ Template* tpl2 = Template::GetTemplate("tgt", STRIP_WHITESPACE);
+ ASSERT(tpl1 && tpl2);
+ ASSERT(tpl1 != tpl2);
+ AssertExpandIs(tpl1, &dict, tpltext, true);
+ AssertExpandIs(tpl2, &dict, tpltext, true);
+
+ // If we register a new string under the same text, it should be
+ // ignored.
+ ASSERT(!Template::StringToTemplateCache("tgt", tpltext));
+ ASSERT(!Template::StringToTemplateCache("tgt", "new text"));
+ Template* tpl3 = Template::GetTemplate("tgt", DO_NOT_STRIP);
+ ASSERT(tpl3 == tpl1);
+ AssertExpandIs(tpl3, &dict, tpltext, true);
+
+ // Tests that syntax errors cause us to return NULL
+ ASSERT(!Template::StringToTemplateCache("tgt2", "{{This has spaces}}"));
+ ASSERT(!Template::StringToTemplateCache("tgt3", "{{#SEC}}foo"));
+ ASSERT(!Template::StringToTemplateCache("tgt4", "{{#S1}}foo{{/S2}}"));
+ ASSERT(!Template::StringToTemplateCache("tgt5",
+ "{{#S1}}foo{{#S2}}bar{{/S1}{{/S2}"));
+ ASSERT(!Template::StringToTemplateCache("tgt6", "{{noend"));
+ // And that we didn't cache them by mistake
+ ASSERT(!Template::GetTemplate("tgt2", STRIP_WHITESPACE));
+
+ Template::ClearCache();
+}
+
+TEST(Template, StringTemplateInclude) {
+ Template::ClearCache(); // just for exercise.
+ const string cache_key = "TestStringTemplateInclude";
+ const string cache_key_inc = "TestStringTemplateInclude-inc";
+ const string cache_key_indent = "TestStringTemplateInclude-indent";
+ const string text = "<html>{{>INC}}</html>";
+ const string text_inc = "<div>\n<p>\nUser {{USER}}\n</div>";
+ const string text_indent = "<html>\n {{>INC}}</html>";
+
+ ASSERT(Template::StringToTemplateCache(cache_key, text));
+ ASSERT(Template::StringToTemplateCache(cache_key_inc, text_inc));
+ ASSERT(Template::StringToTemplateCache(cache_key_indent, text_indent));
+
+ Template *tpl = Template::GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(tpl);
+
+ TemplateDictionary dict("dict");
+ TemplateDictionary* sub_dict = dict.AddIncludeDictionary("INC");
+ sub_dict->SetFilename(cache_key_inc);
+
+ sub_dict->SetValue("USER", "John<>Doe");
+ string expected = "<html><div>\n<p>\nUser John<>Doe\n</div></html>";
+ AssertExpandIs(tpl, &dict, expected, true);
+
+ // Repeat the same except that now the parent has a template-level
+ // directive (by way of the automatic-line-indenter).
+ tpl = Template::GetTemplate(cache_key_indent, DO_NOT_STRIP);
+ ASSERT(tpl);
+ expected =
+ "<html>\n"
+ " <div>\n"
+ " <p>\n"
+ " User John<>Doe\n"
+ " </div>"
+ "</html>";
+ AssertExpandIs(tpl, &dict, expected, true);
+
+ Template::ClearCache();
+}
+
+TEST(Template, TemplateSearchPath) {
+ const string pathA = PathJoin(FLAGS_test_tmpdir, "a/");
+ const string pathB = PathJoin(FLAGS_test_tmpdir, "b/");
+ CreateOrCleanTestDir(pathA);
+ CreateOrCleanTestDir(pathB);
+
+ TemplateDictionary dict("");
+ Template::SetTemplateRootDirectory(pathA);
+ Template::AddAlternateTemplateRootDirectory(pathB);
+
+ // 1. Show that a template in the secondary path can be found.
+ const string path_b_bar = PathJoin(pathB, "template_bar");
+ StringToFile("b/template_bar", path_b_bar);
+ ASSERT_STREQ(path_b_bar.c_str(),
+ Template::FindTemplateFilename("template_bar").c_str());
+ Template* b_bar = Template::GetTemplate("template_bar", DO_NOT_STRIP);
+ ASSERT(b_bar);
+ AssertExpandIs(b_bar, &dict, "b/template_bar", true);
+
+ // 2. Show that the search stops once the first match is found.
+ // Create two templates in separate directories with the same name.
+ const string path_a_foo = PathJoin(pathA, "template_foo");
+ StringToFile("a/template_foo", path_a_foo);
+ StringToFile("b/template_foo", PathJoin(pathB, "template_foo"));
+ ASSERT_STREQ(path_a_foo.c_str(),
+ Template::FindTemplateFilename("template_foo").c_str());
+ Template* a_foo = Template::GetTemplate("template_foo", DO_NOT_STRIP);
+ ASSERT(a_foo);
+ AssertExpandIs(a_foo, &dict, "a/template_foo", true);
+
+ // 3. Show that attempting to find a non-existent template gives an
+ // empty path.
+ ASSERT(Template::FindTemplateFilename("baz").empty());
+
+ CreateOrCleanTestDir(pathA);
+ CreateOrCleanTestDir(pathB);
+}
+
+TEST(Template, RemoveStringFromTemplateCache) {
+ Template::ClearCache(); // just for exercise.
+ const string cache_key = "TestRemoveStringFromTemplateCache";
+ const string text = "<html>here today...</html>";
+
+ TemplateDictionary dict("test");
+ ASSERT(Template::StringToTemplateCache(cache_key, text));
+ Template* tpl = Template::GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(tpl);
+ AssertExpandIs(tpl, &dict, text, true);
+ tpl = Template::GetTemplate(cache_key, STRIP_WHITESPACE);
+ ASSERT(tpl);
+ AssertExpandIs(tpl, &dict, text, true);
+
+ Template::RemoveStringFromTemplateCache(cache_key);
+ tpl = Template::GetTemplate(cache_key, DO_NOT_STRIP);
+ ASSERT(!tpl);
+ tpl = Template::GetTemplate(cache_key, STRIP_WHITESPACE);
+ ASSERT(!tpl);
+ tpl = Template::GetTemplate(cache_key, STRIP_BLANK_LINES);
+ ASSERT(!tpl);
+}
+
+TEST(Template, TemplateCache) {
+ const string filename_a = StringToTemplateFile("Test template 1");
+ const string filename_b = StringToTemplateFile("Test template 2.");
+
+ Template *tpl, *tpl2;
+ ASSERT(tpl = Template::GetTemplate(filename_a, DO_NOT_STRIP));
+
+ ASSERT(tpl2 = Template::GetTemplate(filename_b, DO_NOT_STRIP));
+ ASSERT(tpl2 != tpl); // different filenames.
+ ASSERT(tpl2 = Template::GetTemplate(filename_a, STRIP_BLANK_LINES));
+ ASSERT(tpl2 != tpl); // different strip.
+ ASSERT(tpl2 = Template::GetTemplate(filename_b, STRIP_BLANK_LINES));
+ ASSERT(tpl2 != tpl); // different filenames and strip.
+ ASSERT(tpl2 = Template::GetTemplate(filename_a, DO_NOT_STRIP));
+ ASSERT(tpl2 == tpl); // same filename and strip.
+}
+
+// Tests that the various strip values all do the expected thing.
+TEST(Template, Strip) {
+ TemplateDictionary dict("dict");
+ dict.SetValue("FOO", "foo");
+
+ const char* tests[][4] = { // 0: in, 1: do-not-strip, 2: blanklines, 3: ws
+ {"hi!\n", "hi!\n", "hi!\n", "hi!"},
+ {"hi!", "hi!", "hi!", "hi!"},
+ // These test strip-blank-lines, primarily
+ {"{{FOO}}\n\n{{FOO}}", "foo\n\nfoo", "foo\nfoo", "foofoo"},
+ {"{{FOO}}\r\n\r\n{{FOO}}", "foo\r\n\r\nfoo", "foo\r\nfoo", "foofoo"},
+ {"{{FOO}}\n \n{{FOO}}\n", "foo\n \nfoo\n", "foo\nfoo\n", "foofoo"},
+ {"{{FOO}}\n{{BI_NEWLINE}}\nb", "foo\n\n\nb", "foo\n\n\nb", "foo\nb"},
+ {"{{FOO}}\n{{!comment}}\nb", "foo\n\nb", "foo\nb", "foob"},
+ {"{{FOO}}\n{{!comment}}{{!comment2}}\nb", "foo\n\nb", "foo\n\nb", "foob"},
+ {"{{FOO}}\n{{>ONE_INC}}\nb", "foo\n\nb", "foo\nb", "foob"},
+ {"{{FOO}}\n\t{{>ONE_INC}} \nb", "foo\n\t \nb", "foo\nb", "foob"},
+ {"{{FOO}}\n{{>ONE_INC}}{{>TWO_INC}}\nb", "foo\n\nb", "foo\n\nb", "foob"},
+ {"{{FOO}}\n {{#SEC}}\ntext \n {{/SEC}}\n", "foo\n \n", "foo\n", "foo"},
+ {"{{%AUTOESCAPE context=\"HTML\"}}\nBLA", "\nBLA", "BLA", "BLA"},
+ // These test strip-whitespace
+ {"foo\nbar\n", "foo\nbar\n", "foo\nbar\n", "foobar"},
+ {"{{FOO}}\nbar\n", "foo\nbar\n", "foo\nbar\n", "foobar"},
+ {" {{FOO}} {{!comment}}\nb", " foo \nb", " foo \nb", "foo b"},
+ {" {{FOO}} {{BI_SPACE}}\n", " foo \n", " foo \n", "foo "},
+ {" \t \f\v \n\r\n ", " \t \f\v \n\r\n ", "", ""},
+ };
+
+ for (int i = 0; i < sizeof(tests)/sizeof(*tests); ++i) {
+ Template* tpl1 = StringToTemplate(tests[i][0], DO_NOT_STRIP);
+ Template* tpl2 = StringToTemplate(tests[i][0], STRIP_BLANK_LINES);
+ Template* tpl3 = StringToTemplate(tests[i][0], STRIP_WHITESPACE);
+ AssertExpandIs(tpl1, &dict, tests[i][1], true);
+ AssertExpandIs(tpl2, &dict, tests[i][2], true);
+ AssertExpandIs(tpl3, &dict, tests[i][3], true);
+ }
+}
+
+TEST(Template, TemplateRootDirectory) {
+ string filename = StringToTemplateFile("Test template");
+ ASSERT(IsAbspath(filename));
+ Template* tpl1 = Template::GetTemplate(filename, DO_NOT_STRIP);
+ Template::SetTemplateRootDirectory(kRootdir); // "/"
+ // template-root shouldn't matter for absolute directories
+ Template* tpl2 = Template::GetTemplate(filename, DO_NOT_STRIP);
+ Template::SetTemplateRootDirectory("/sadfadsf/waerfsa/safdg");
+ Template* tpl3 = Template::GetTemplate(filename, DO_NOT_STRIP);
+ ASSERT(tpl1 != NULL);
+ ASSERT(tpl1 == tpl2);
+ ASSERT(tpl1 == tpl3);
+
+ // Now test it actually works by breaking the abspath in various places.
+ // We do it twice, since we don't know if the path-sep is "/" or "\".
+ // NOTE: this depends on filename not using "/" or "\" except as a
+ // directory separator (so nothing like "/var/tmp/foo\a/weirdfile").
+ const char* const kPathSeps = "/\\";
+ for (const char* path_sep = kPathSeps; *path_sep; path_sep++) {
+ for (string::size_type sep_pos = filename.find(*path_sep, 0);
+ sep_pos != string::npos;
+ sep_pos = filename.find(*path_sep, sep_pos + 1)) {
+ Template::SetTemplateRootDirectory(filename.substr(0, sep_pos + 1));
+ Template* tpl = Template::GetTemplate(filename.substr(sep_pos + 1),
+ DO_NOT_STRIP);
+ ASSERT(string(tpl->template_file()) == tpl1->template_file());
+ }
+ }
+}
+
+#if defined(HAVE_PTHREAD) && !defined(NO_THREADS)
+struct ThreadReturn {
+ Template* file_template;
+ bool string_to_template_cache_return;
+ Template* string_template;
+};
+
+// RunThread returns a ThreadReturn* that should be deleted.
+static void* RunThread(void* vfilename) {
+ const char* filename = reinterpret_cast<const char*>(vfilename);
+ ThreadReturn* ret = new ThreadReturn;
+ ret->file_template = Template::GetTemplate(filename, DO_NOT_STRIP);
+ ASSERT(ret->file_template != NULL);
+ const char* const key = "RunThread key";
+ ret->string_to_template_cache_return =
+ StringToTemplateCache(key, " RunThread text ", STRIP_WHITESPACE);
+ ret->string_template = Template::GetTemplate(key, STRIP_WHITESPACE);
+ ASSERT(ret->string_template != NULL);
+ return ret;
+}
+
+TEST(Template, ThreadSafety) {
+ string filename = StringToTemplateFile("(testing thread-safety)");
+
+ // GetTemplate() is the most thread-contended routine. We get a
+ // template in many threads, and assert we get the same template
+ // from each.
+ pthread_t thread_ids[kNumThreads];
+ for (int i = 0; i < kNumThreads; ++i) {
+ ASSERT(pthread_create(thread_ids+i, NULL, RunThread,
+ (void*)filename.c_str())
+ == 0);
+ }
+
+ // Wait for all the threads to terminate (should be very quick!)
+ ThreadReturn* first_thread_return = NULL;
+ int num_times_string_to_template_cache_returned_true = 0;
+ for (int i = 0; i < kNumThreads; ++i) {
+ void* vthread_return;
+ ASSERT(pthread_join(thread_ids[i], &vthread_return) == 0);
+ ThreadReturn* thread_return =
+ reinterpret_cast<ThreadReturn*>(vthread_return);
+ if (thread_return->string_to_template_cache_return) {
+ ++num_times_string_to_template_cache_returned_true;
+ }
+ if (first_thread_return == NULL) { // we're the first thread
+ first_thread_return = thread_return;
+ } else {
+ ASSERT(thread_return->file_template ==
+ first_thread_return->file_template);
+ ASSERT(thread_return->string_template ==
+ first_thread_return->string_template);
+ delete thread_return;
+ }
+ }
+ delete first_thread_return;
+ ASSERT_INTEQ(1, num_times_string_to_template_cache_returned_true);
+ Template::ClearCache();
+}
+#endif // #if defined(HAVE_PTHREAD) && !defined(NO_THREADS)
+
+// Tests all the static methods in TemplateNamelist
+TEST(Template, TemplateNamelist) {
+ time_t before_time = Now(); // in template_test_util.cc
+ string f1 = StringToTemplateFile("{{This has spaces in it}}");
+ string f2 = StringToTemplateFile("{{#SEC}}foo");
+ string f3 = StringToTemplateFile("{This is ok");
+ // Where we'll copy f1 - f3 to: these are names known at compile-time
+ string f1_copy = PathJoin(FLAGS_test_tmpdir, INVALID1_FN);
+ string f2_copy = PathJoin(FLAGS_test_tmpdir, INVALID2_FN);
+ string f3_copy = PathJoin(FLAGS_test_tmpdir, VALID1_FN);
+ Template::SetTemplateRootDirectory(FLAGS_test_tmpdir);
+ time_t after_time = Now(); // f1, f2, f3 all written by now
+
+ TemplateNamelist::NameListType names = TemplateNamelist::GetList();
+ ASSERT(names.size() == 4);
+ ASSERT(names.count(NONEXISTENT_FN));
+ ASSERT(names.count(INVALID1_FN));
+ ASSERT(names.count(INVALID2_FN));
+ ASSERT(names.count(VALID1_FN));
+
+ // Before creating the files INVALID1_FN, etc., all should be missing.
+ for (int i = 0; i < 3; ++i) { // should be consistent all 3 times
+ const TemplateNamelist::MissingListType& missing =
+ TemplateNamelist::GetMissingList(false);
+ ASSERT(missing.size() == 4);
+ }
+ // Everyone is missing, but nobody should have bad syntax
+ ASSERT(!TemplateNamelist::AllDoExist());
+ ASSERT(TemplateNamelist::IsAllSyntaxOkay(DO_NOT_STRIP));
+
+ // Now create those files
+ ASSERT(link(f1.c_str(), f1_copy.c_str()) == 0);
+ ASSERT(link(f2.c_str(), f2_copy.c_str()) == 0);
+ ASSERT(link(f3.c_str(), f3_copy.c_str()) == 0);
+ // We also have to clear the template cache, since we created a new file.
+ // ReloadAllIfChanged() would probably work, too.
+ Template::ClearCache();
+
+ // When GetMissingList is false, we don't reload, so you still get all-gone
+ TemplateNamelist::MissingListType missing =
+ TemplateNamelist::GetMissingList(false);
+ ASSERT(missing.size() == 4);
+ // But with true, we should have a different story
+ missing = TemplateNamelist::GetMissingList(true);
+ ASSERT(missing.size() == 1);
+ missing = TemplateNamelist::GetMissingList(false);
+ ASSERT(missing.size() == 1);
+ ASSERT(missing[0] == NONEXISTENT_FN);
+ ASSERT(!TemplateNamelist::AllDoExist());
+
+ // IsAllSyntaxOK did a badsyntax check, before the files were created.
+ // So with a false arg, should still say everything is ok
+ TemplateNamelist::SyntaxListType badsyntax =
+ TemplateNamelist::GetBadSyntaxList(false, DO_NOT_STRIP);
+ ASSERT(badsyntax.size() == 0);
+ // But IsAllSyntaxOK forces a refresh
+ ASSERT(!TemplateNamelist::IsAllSyntaxOkay(DO_NOT_STRIP));
+ badsyntax = TemplateNamelist::GetBadSyntaxList(false, DO_NOT_STRIP);
+ ASSERT(badsyntax.size() == 2);
+ ASSERT(badsyntax[0] == INVALID1_FN || badsyntax[1] == INVALID1_FN);
+ ASSERT(badsyntax[0] == INVALID2_FN || badsyntax[1] == INVALID2_FN);
+ ASSERT(!TemplateNamelist::IsAllSyntaxOkay(DO_NOT_STRIP));
+ badsyntax = TemplateNamelist::GetBadSyntaxList(true, DO_NOT_STRIP);
+ ASSERT(badsyntax.size() == 2);
+
+ time_t modtime = TemplateNamelist::GetLastmodTime();
+ ASSERT(modtime >= before_time && modtime <= after_time);
+ // Now update a file and make sure lastmod time is updated.
+ // Note that since TemplateToFile uses "fake" timestamps way
+ // in the past, this append should definitely give a time
+ // that's after after_time.
+ FILE* fp = fopen(f1_copy.c_str(), "ab");
+ ASSERT(fp);
+ fwrite("\n", 1, 1, fp);
+ fclose(fp);
+ modtime = TemplateNamelist::GetLastmodTime();
+ ASSERT(modtime > after_time);
+
+ // Checking if we can register templates at run time.
+ string f4 = StringToTemplateFile("{{ONE_GOOD_TEMPLATE}}");
+ TemplateNamelist::RegisterTemplate(f4.c_str());
+ names = TemplateNamelist::GetList();
+ ASSERT(names.size() == 5);
+
+ string f5 = StringToTemplateFile("{{ONE BAD TEMPLATE}}");
+ TemplateNamelist::RegisterTemplate(f5.c_str());
+ names = TemplateNamelist::GetList();
+ ASSERT(names.size() == 6);
+ badsyntax = TemplateNamelist::GetBadSyntaxList(false, DO_NOT_STRIP);
+ ASSERT(badsyntax.size() == 2); // we did not refresh the bad syntax list
+ badsyntax = TemplateNamelist::GetBadSyntaxList(true, DO_NOT_STRIP);
+ // After refresh, the file we just registerd also added in bad syntax list
+ ASSERT(badsyntax.size() == 3);
+
+ TemplateNamelist::RegisterTemplate("A_non_existant_file.tpl");
+ names = TemplateNamelist::GetList();
+ ASSERT(names.size() == 7);
+ missing = TemplateNamelist::GetMissingList(false);
+ ASSERT(missing.size() == 1); // we did not refresh the missing list
+ missing = TemplateNamelist::GetMissingList(true);
+ // After refresh, the file we just registerd also added in missing list
+ ASSERT(missing.size() == 2);
+}
+
+// This test is not "end-to-end", it doesn't use a dictionary
+// and only outputs what the template system thinks is the
+// correct modifier for variables.
+TEST(Template, CorrectModifiersForAutoEscape) {
+ string text, expected_out;
+
+ // template with no variable, nothing to emit.
+ text = "Static template.";
+ AssertCorrectModifiers(TC_HTML, text, "");
+
+ // Simple templates with one variable substitution.
+
+ // 1. No in-template modifiers. Auto Escaper sets correct ones.
+ text = "Hello {{USER}}";
+ AssertCorrectModifiers(TC_HTML, text, "USER:h\n");
+
+ // Complete URLs in different attributes that take URLs.
+ text = "<a href=\"{{URL}}\">bla</a>";
+ AssertCorrectModifiers(TC_HTML, text, "URL:U=html\n");
+ text = "<script src=\"{{URL}}\"></script>";
+ AssertCorrectModifiers(TC_HTML, text, "URL:U=html\n");
+ text = "<img src=\"{{URL}}\">";
+ AssertCorrectModifiers(TC_HTML, text, "URL:U=html\n");
+ // URL fragment only so just html_escape.
+ text = "<img src=\"/bla?q={{QUERY}}\">";
+ AssertCorrectModifiers(TC_HTML, text, "QUERY:h\n");
+ // URL fragment not quoted, so url_escape.
+ text = "<img src=/bla?q={{QUERY}}>";
+ AssertCorrectModifiers(TC_HTML, text, "QUERY:u\n");
+
+ text = "<br class=\"{{CLASS}}\">";
+ AssertCorrectModifiers(TC_HTML, text, "CLASS:h\n");
+ text = "<br class={{CLASS}}>";
+ AssertCorrectModifiers(TC_HTML, text, "CLASS:H=attribute\n");
+ text = "<br {{CLASS}}>"; // CLASS here is name/value pair.
+ AssertCorrectModifiers(TC_HTML, text, "CLASS:H=attribute\n");
+ text = "<br style=\"display:{{DISPLAY}}\">"; // Style attribute.
+ AssertCorrectModifiers(TC_HTML, text, "DISPLAY:c\n");
+
+ // Content inside a style tag should have :c regardless of quoting.
+ text = "<style>color:{{COLOR}}; font:\"{{FONT}}\"</style>";
+ AssertCorrectModifiers(TC_HTML, text, "COLOR:c\nFONT:c\n");
+
+ // onMouseEvent and onKeyUp accept javascript.
+ text = "<a href=\"url\" onkeyup=\"doX('{{ID}}');\">"; // ID quoted
+ AssertCorrectModifiers(TC_HTML, text, "ID:j\n");
+ text = "<a href=\"url\" onclick=\"doX({{ID}});\">"; // ID not quoted
+ AssertCorrectModifiers(TC_HTML, text, "ID:J=number\n");
+ text = "<a href=\"url\" onclick=\"'{{ID}}'\">"; // not common
+ AssertCorrectModifiers(TC_HTML, text, "ID:j\n");
+ // If ID is javascript code, J=number will break it, for good and bad.
+ text = "<a href=\"url\" onclick=\"{{ID}}\">";
+ AssertCorrectModifiers(TC_HTML, text, "ID:J=number\n");
+
+ // Target just needs html escaping.
+ text = "<a href=\"url\" target=\"{{TARGET}}\">";
+ AssertCorrectModifiers(TC_HTML, text, "TARGET:h\n");
+
+ // Test a parsing corner case which uses TemplateDirective
+ // call in the parser to change state properly. To reproduce
+ // both variables should be unquoted and the first should
+ // have no value except the variable substitution.
+ text = "<img class={{CLASS}} src=/bla?q={{QUERY}}>";
+ AssertCorrectModifiers(TC_HTML, text, "CLASS:H=attribute\nQUERY:u\n");
+
+ // TODO(jad): Once we have a fix for it in code, fix me.
+ // Javascript URL is not properly supported, we currently
+ // apply :h which is not sufficient.
+ text = "<a href=\"javascript:foo('{{VAR}}')>bla</a>";
+ AssertCorrectModifiers(TC_HTML, text, "VAR:h\n");
+
+ // Special handling for BI_SPACE and BI_NEWLINE.
+ text = "{{BI_SPACE}}";
+ AssertCorrectModifiers(TC_HTML, text, "BI_SPACE\n"); // Untouched.
+ text = "{{BI_NEWLINE}}";
+ AssertCorrectModifiers(TC_HTML, text, "BI_NEWLINE\n"); // Untouched.
+ // Check that the parser is parsing BI_SPACE, if not, it would have failed.
+ text = "<a href=/bla{{BI_SPACE}}style=\"{{VAR}}\">text</a>";
+ AssertCorrectModifiers(TC_HTML, text, "BI_SPACE\nVAR:c\n");
+
+
+ // XML and JSON modes.
+ text = "<PARAM name=\"{{VAL}}\">{{DATA}}";
+ AssertCorrectModifiers(TC_XML, text, "VAL:xml_escape\nDATA:xml_escape\n");
+ text = "{ x = \"{{VAL}}\"}";
+ AssertCorrectModifiers(TC_JSON, text, "VAL:j\n");
+
+ // 2. Escaping modifiers were set, handle them.
+
+ // 2a: Modifier :none is honored whether the escaping is correct or not.
+ text = "Hello {{USER:none}}"; // :none on its own.
+ AssertCorrectModifiers(TC_HTML, text, "USER:none\n");
+ text = "Hello {{USER:h:none}}"; // correct escaping.
+ AssertCorrectModifiers(TC_HTML, text, "USER:h:none\n");
+ text = "Hello {{USER:j:none}}"; // incorrect escaping.
+ AssertCorrectModifiers(TC_HTML, text, "USER:j:none\n");
+ text = "<a href=\"url\" onkeyup=\"doX('{{ID:none}}');\">";
+ AssertCorrectModifiers(TC_HTML, text, "ID:none\n");
+
+ // 2b: Correct modifiers, nothing to change.
+ text = "Hello {{USER:h}}";
+ AssertCorrectModifiers(TC_HTML, text, "USER:h\n");
+ text = "Hello {{USER:U=html}}"; // :U=html is a valid replacement for .h
+ AssertCorrectModifiers(TC_HTML, text, "USER:U=html\n");
+ text = "Hello {{USER:H=url}}"; // :H=url (a.k.a. U=html) is valid too
+ AssertCorrectModifiers(TC_HTML, text, "USER:H=url\n");
+ text = "Hello {{USER:h:j}}"; // Extra :j, honor it.
+ AssertCorrectModifiers(TC_HTML, text, "USER:h:j\n");
+ text = "<a href=\"{{URL:U=html}}\">bla</a>";
+ AssertCorrectModifiers(TC_HTML, text, "URL:U=html\n");
+ text = "<a href=\"/bla?q={{QUERY:h}}\">bla</a>"; // :h is valid.
+ AssertCorrectModifiers(TC_HTML, text, "QUERY:h\n");
+ text = "<a href=\"/bla?q={{QUERY:u}}\">bla</a>"; // so is :u.
+ AssertCorrectModifiers(TC_HTML, text, "QUERY:u\n");
+ text = "<a href=\"url\" onclick=\"doX('{{ID:j}}');\">";
+ AssertCorrectModifiers(TC_HTML, text, "ID:j\n");
+ text = "<a href=\"url\" onclick=\"doX({{ID:J=number}});\">";
+ AssertCorrectModifiers(TC_HTML, text, "ID:J=number\n");
+ text = "<style>@import url(\"{{URL:U=css}}\")</style>"; // correct :U=css
+ AssertCorrectModifiers(TC_HTML, text, "URL:U=css\n");
+
+ // 2c: Incorrect modifiers, add our own.
+ text = "Hello {{USER:j}}"; // Missing :h
+ AssertCorrectModifiers(TC_HTML, text, "USER:j:h\n");
+ text = "Hello {{USER:c:c:c:c:c:j}}"; // Still missing :h
+ AssertCorrectModifiers(TC_HTML, text, "USER:c:c:c:c:c:j:h\n");
+ text = "<script>var a = \"{{VAR:h}}\";</script>"; // Missing :j
+ AssertCorrectModifiers(TC_HTML, text, "VAR:h:j\n");
+ text = "<script>var a = \"{{VAR:j:h:j}}\";</script>"; // Extra :h:j
+ AssertCorrectModifiers(TC_HTML, text, "VAR:j:h:j\n");
+ text = "<a href=\"url\" onclick=\"doX({{ID:j}});\">"; // Unquoted
+ AssertCorrectModifiers(TC_HTML, text, "ID:j:J=number\n");
+
+ // 2d: Custom modifiers are maintained.
+ text = "Hello {{USER:x-bla}}"; // Missing :h
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-bla:h\n");
+ text = "Hello {{USER:x-bla:h}}"; // Correct, accept it.
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-bla:h\n");
+ text = "Hello {{USER:x-bla:x-foo}}"; // Missing :h
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-bla:x-foo:h\n");
+ text = "Hello {{USER:x-bla:none}}"; // Complete due to :none
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-bla:none\n");
+ text = "Hello {{USER:h:x-bla}}"; // Still missing :h.
+ AssertCorrectModifiers(TC_HTML, text, "USER:h:x-bla:h\n");
+ text = "Hello {{USER:x-bla:h:x-foo}}"; // Still missing :h
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-bla:h:x-foo:h\n");
+ text = "Hello {{USER:x-bla:h:x-foo:h}}"; // Valid, accept it.
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-bla:h:x-foo:h\n");
+
+ // 2e: Equivalent modifiers are honored. All HTML Escapes.
+ text = "Hello {{USER:p}}";
+ AssertCorrectModifiers(TC_HTML, text, "USER:p\n");
+ text = "Hello {{USER:H=attribute}}";
+ AssertCorrectModifiers(TC_HTML, text, "USER:H=attribute\n");
+ text = "Hello {{USER:H=snippet}}";
+ AssertCorrectModifiers(TC_HTML, text, "USER:H=snippet\n");
+ text = "Hello {{USER:H=pre}}";
+ AssertCorrectModifiers(TC_HTML, text, "USER:H=pre\n");
+ // All URL + HTML Escapes.
+ text = "<a href=\"{{URL:H=url}}\">bla</a>";
+ AssertCorrectModifiers(TC_HTML, text, "URL:H=url\n");
+ text = "<a href=\"{{URL:U=html}}\">bla</a>";
+ AssertCorrectModifiers(TC_HTML, text, "URL:U=html\n");
+
+ // 2f: Initialize template in Javascript Context.
+ text = "var a = '{{VAR}}'"; // Escaping not given.
+ AssertCorrectModifiers(TC_JS, text, "VAR:j\n");
+ text = "var a = '{{VAR:none}}'"; // Variable safe.
+ AssertCorrectModifiers(TC_JS, text, "VAR:none\n");
+ text = "var a = '{{VAR:j}}'"; // Escaping correct.
+ AssertCorrectModifiers(TC_JS, text, "VAR:j\n");
+ text = "var a = '{{VAR:h}}'"; // Escaping incorrect.
+ AssertCorrectModifiers(TC_JS, text, "VAR:h:j\n");
+ text = "var a = '{{VAR:J=number}}'"; // Not considered equiv.
+ AssertCorrectModifiers(TC_JS, text, "VAR:J=number:j\n");
+
+ // 2g: Honor any modifiers for BI_SPACE and BI_NEWLINE.
+ text = "{{BI_NEWLINE:j}}"; // An invalid modifier for the context.
+ AssertCorrectModifiers(TC_HTML, text, "BI_NEWLINE:j\n");
+ text = "{{BI_SPACE:h}}"; // An otherwise valid modifier.
+ AssertCorrectModifiers(TC_HTML, text, "BI_SPACE:h\n");
+ text = "{{BI_SPACE:x-bla}}"; // Also support custom modifiers.
+ AssertCorrectModifiers(TC_HTML, text, "BI_SPACE:x-bla\n");
+
+ // 2h: TC_CSS, TC_XML and TC_JSON
+ text = "H1{margin-{{START_EDGE}}:0;\n text-align:{{END_EDGE}}\n}";
+ AssertCorrectModifiers(TC_CSS, text, "START_EDGE:c\nEND_EDGE:c\n");
+ text = "body{background:url('{{URL:U=css}}')}"; // :U=css valid substitute
+ AssertCorrectModifiers(TC_CSS, text, "URL:U=css\n");
+ text = "body{background:url('{{URL:U=html}}')}"; // Not valid, will add :c.
+ AssertCorrectModifiers(TC_CSS, text, "URL:U=html:c\n");
+ text = "<PARAM name=\"{{VAL:xml_escape}}\">"; // Correct escaping
+ AssertCorrectModifiers(TC_XML, text, "VAL:xml_escape\n");
+ text = "<PARAM name=\"{{VAL:H=attribute}}\">"; // XSS equivalent
+ AssertCorrectModifiers(TC_XML, text, "VAL:H=attribute\n");
+ text = "<PARAM name=\"{{VAL:h}}\">"; // XSS equivalent
+ AssertCorrectModifiers(TC_XML, text, "VAL:h\n");
+ text = "<PARAM name=\"{{VAL:H=pre}}\">"; // Not XSS equivalent
+ AssertCorrectModifiers(TC_XML, text, "VAL:H=pre:xml_escape\n");
+ text = "<PARAM name=\"{{VAL:c}}\">"; // Not XSS equivalent
+ AssertCorrectModifiers(TC_XML, text, "VAL:c:xml_escape\n");
+ text = "{user={{USER:j}}"; // Correct escaping
+ AssertCorrectModifiers(TC_JSON, text, "USER:j\n");
+ text = "{user={{USER:o}}"; // json_escape is XSS equivalent
+ AssertCorrectModifiers(TC_JSON, text, "USER:o\n");
+ text = "{user={{USER:h}}"; // but html_escape is not
+ AssertCorrectModifiers(TC_JSON, text, "USER:h:j\n");
+
+ // 2i: Variables with XssSafe Custom modifiers are untouched.
+ ASSERT(GOOGLE_NAMESPACE::AddXssSafeModifier("x-test-cm",
+ &GOOGLE_NAMESPACE::html_escape));
+ text = "Hello {{USER:x-test-cm}}"; // Missing :h
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-test-cm\n");
+ text = "Hello {{USER:x-test-cm:j}}"; // Extra :j
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-test-cm:j\n");
+ text = "Hello {{USER:x-test-cm:x-foo}}"; // Non-safe modifier
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-test-cm:x-foo\n");
+ text = "Hello {{USER:x-foo:x-test-cm}}"; // Non-safe modifier
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-foo:x-test-cm\n");
+ text = "Hello {{USER:x-test-cm:none}}"; // Complete due to :none
+ AssertCorrectModifiers(TC_HTML, text, "USER:x-test-cm:none\n");
+ text = "Hello {{USER:h:x-test-cm}}"; // Prior escaping
+ AssertCorrectModifiers(TC_HTML, text, "USER:h:x-test-cm\n");
+
+ // 3. Larger test with close to every escaping case.
+
+ text = "<html><head>\n"
+ "<style>\n"
+ "@import url(\"{{CSS_URL:U=css}}\");\n"
+ "color:{{COLOR}}</style></head><body>\n"
+ "<h1>{{TITLE}}</h1>\n"
+ "<img src=\"{{IMG_URL}}\">\n"
+ "<form action=\"/search\">\n"
+ " <input name=\"hl\" value={{HL}}>\n"
+ " <input name=\"m\" value=\"{{FORM_MSG}}\">\n"
+ "</form>\n"
+ "<div style=\"background:{{BG_COLOR}}\">\n"
+ "</div>\n"
+ "<script>\n"
+ " var msg_text = '{{MSG_TEXT}}';\n"
+ "</script>\n"
+ "<a href=\"url\" onmouseover=\"'{{MOUSE}}'\">bla</a>\n"
+ "Goodbye friend {{USER}}!\n</body></html>\n";
+ expected_out = "CSS_URL:U=css\n"
+ "COLOR:c\n"
+ "TITLE:h\n"
+ "IMG_URL:U=html\n"
+ "HL:H=attribute\n"
+ "FORM_MSG:h\n"
+ "BG_COLOR:c\n"
+ "MSG_TEXT:j\n"
+ "MOUSE:j\n" // :j also escapes html entities
+ "USER:h\n";
+ AssertCorrectModifiers(TC_HTML, text, expected_out);
+}
+
+// More "end-to-end" test to ensure that variables are
+// escaped as expected with auto-escape mode enabled.
+// Obviously there is a lot more we can test.
+TEST(Template, VariableWithAutoEscape) {
+ string text, expected_out;
+ TemplateDictionary dict("dict");
+ string good_url("http://www.google.com/");
+ string bad_url("javascript:alert();");
+
+ text = "hi {{VAR}} lo";
+ dict.SetValue("VAR", "<bad>yo");
+ AssertCorrectEscaping(TC_HTML, dict, text, "hi <bad>yo lo");
+
+ text = "<a href=\"{{URL}}\">bla</a>";
+ dict.SetValue("URL", good_url);
+ expected_out = "<a href=\"" + good_url + "\">bla</a>";
+ AssertCorrectEscaping(TC_HTML, dict, text, expected_out);
+ dict.SetValue("URL", bad_url);
+ expected_out = "<a href=\"#\">bla</a>";
+ AssertCorrectEscaping(TC_HTML, dict, text, expected_out);
+
+ text = "<br style=\"display:{{DISPLAY}}\">";
+ dict.SetValue("DISPLAY", "none");
+ expected_out = "<br style=\"display:none\">";
+ AssertCorrectEscaping(TC_HTML, dict, text, expected_out);
+ // Bad characters are simply removed in CleanseCss.
+ dict.SetValue("URL", "!#none_ ");
+ expected_out = "<br style=\"display:none\">";
+ AssertCorrectEscaping(TC_HTML, dict, text, expected_out);
+
+ text = "<a href=\"url\" onkeyup=\"'{{EVENT}}'\">";
+ dict.SetValue("EVENT", "safe");
+ expected_out = "<a href=\"url\" onkeyup=\"'safe'\">";
+ AssertCorrectEscaping(TC_HTML, dict, text, expected_out);
+ dict.SetValue("EVENT", "f = 'y';");
+ expected_out = "<a href=\"url\" onkeyup=\"'f \\x3d \\x27y\\x27;'\">";
+
+ // Check special handling of BI_SPACE and BI_NEWLINE.
+ text = "Hello\n{{BI_SPACE}}bla{{BI_NEWLINE}}foo.";
+ expected_out = "Hello bla\nfoo.";
+ AssertCorrectEscaping(TC_HTML, dict, text, expected_out);
+
+ // TC_CSS
+ text = "H1{margin-{{EDGE}}:0; text-align:{{BAD_EDGE}}}";
+ dict.SetValue("EDGE", "left");
+ dict.SetValue("BAD_EDGE", "$$center()!!"); // Bad chars are removed.
+ AssertCorrectEscaping(TC_CSS, dict, text,
+ "H1{margin-left:0; text-align:center!!}");
+
+ // TC_XML and TC_JSON
+ text = "<Q>{{DATA}}</Q>";
+ dict.SetValue("DATA", "good-data");
+ AssertCorrectEscaping(TC_XML, dict, text, "<Q>good-data</Q>");
+ dict.SetValue("DATA", "<BAD>FOO</BAD>");
+ AssertCorrectEscaping(TC_XML, dict, text,
+ "<Q><BAD>FOO</BAD></Q>");
+ text = "{user = \"{{USER}}\"}";
+ dict.SetValue("USER", "good-user");
+ AssertCorrectEscaping(TC_JSON, dict, text, "{user = \"good-user\"}");
+ dict.SetValue("USER", "evil'<>\"");
+ AssertCorrectEscaping(TC_JSON, dict, text,
+ "{user = \"evil\\x27\\x3c\\x3e\\x22\"}");
+}
+
+// Test that the template initialization fails in auto-escape
+// mode if the parser failed to parse.
+TEST(Template, FailedInitWithAutoEscape) {
+ Strip strip = STRIP_WHITESPACE;
+ // Taken from HTML Parser test suite.
+ string bad_html = "<a href='http://www.google.com' ''>\n";
+ ASSERT(NULL == StringToTemplateWithAutoEscaping(bad_html, strip, TC_HTML));
+
+ // Missing quotes around URL, not accepted in URL-taking attributes.
+ bad_html = "<a href={{URL}}>bla</a>";
+ ASSERT(NULL == StringToTemplateWithAutoEscaping(bad_html, strip, TC_HTML));
+
+ // Missing quotes around STYLE, not accepted in style-taking attributes.
+ bad_html = "<div style={{STYLE}}>";
+ ASSERT(NULL == StringToTemplateWithAutoEscaping(bad_html, strip, TC_HTML));
+}
+
+TEST(Template, AutoEscaping) {
+ Strip strip = STRIP_WHITESPACE;
+ Template *tpl;
+ string filename;
+ string text;
+ string user = "John<>Doe";
+ string user_esc = "John<>Doe";
+
+ // Positive test cases -- template initialization succeeds.
+ // We also check that modifiers that were missing or given incorrect
+ // have been updated as expected.
+ // TODO(jad): Cut-down redundancy by merging with
+ // TestCorrectModifiersForAutoEscape.
+ text = "{{%AUTOESCAPE context=\"HTML\"}}" // HTML
+ "{{USER:o}}<a href=\"{{URL}}\" class={{CLASS:h}}</a>";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ string expected_mods = "USER:o:h\nURL:U=html\nCLASS:h:H=attribute\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{%AUTOESCAPE context=\"HTML\" state=\"IN_TAG\"}}" // HTML in tag
+ "href=\"{{URL}}\" class={{CLASS:h}} style=\"font:{{COLOR}}\"";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "URL:U=html\nCLASS:h:H=attribute\nCOLOR:c\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{%AUTOESCAPE context=\"HTML\" state=\"in_tag\"}}" // lowercase ok
+ "href=\"{{URL}}\" class={{CLASS:h}} style=\"font:{{COLOR}}\"";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "URL:U=html\nCLASS:h:H=attribute\nCOLOR:c\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ // Repeat the test with trailing HTML that closes the tag. This is
+ // undefined behavior. We test it to ensure the parser does not choke.
+ text += ">Hello</a><span>Some text</span></body></html>";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "URL:U=html\nCLASS:h:H=attribute\nCOLOR:c\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{%AUTOESCAPE context=\"JAVASCRIPT\"}}" // JAVASCRIPT
+ "var a = {{A}}; var b = '{{B:h}}';";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "A:J=number\nB:h:j\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{%AUTOESCAPE context=\"CSS\"}}" // CSS
+ "body {color:\"{{COLOR}}\"; font-size:{{SIZE:j}}";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "COLOR:c\nSIZE:j:c\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{%AUTOESCAPE context=\"JSON\"}}" // JSON
+ "{ 'id': {{ID:j}}, 'value': {{VALUE:h}} }";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "ID:j\nVALUE:h:j\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{%AUTOESCAPE context=\"XML\"}}" // XML
+ "<PARAM name=\"{{VAL}}\">{{DATA:h}}";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "VAL:xml_escape\nDATA:h\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{%AUTOESCAPE context=\"xml\"}}" // lower-case XML
+ "<PARAM name=\"{{VAL}}\">{{DATA:h}}";
+ ASSERT(tpl = StringToTemplate(text, strip));
+ expected_mods = "VAL:xml_escape\nDATA:h\n";
+ AssertCorrectModifiersInTemplate(tpl, text, expected_mods);
+
+ text = "{{!bla}}{{%AUTOESCAPE context=\"HTML\"}}"; // after comment
+ ASSERT(tpl = StringToTemplate(text, strip));
+ text = "{{%AUTOESCAPE context=\"HTML\" state=\"default\"}}";
+ ASSERT(tpl = StringToTemplate(text, strip)); // adding state
+
+ // Negative test cases - template initialization fails due to errors
+ // in the marker. Also checks that our parsing is defensive.
+ text = "{{%AUTOESCAPE}}"; // missing context
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPER context=\"HTML\"}}"; // invalid id
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%}}"; // missing id
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{% }}"; // missing id
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{% =}}"; // missing id
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE =\"HTML\"}}"; // missing name
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE foo=\"HTML\"}}"; // bogus name
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE =}}"; // lone '='
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=HTML}}"; // val not quoted
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"HTML}}"; // no end quotes
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"\\\"HTML\"}}"; // Unescape val
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"\\\"HT\\\"\\\"ML\\\"\"}}"; // more complex
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"\"HTML\"}}"; // Unescape val
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"JAVASCRIPT\" bla}}"; // extra attr
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"JAVASCRIPT\"bla}}"; // invalid value
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"JAVASCRIPT\" foo=bla}}"; // extra attr/val
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"HTML\"}}"; // extra whitesp
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context =\"HTML\"}}"; // extra whitesp
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context= \"HTML\"}}"; // extra whitesp
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"HTML\" }}"; // extra whitesp
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"Xml\"}}"; // mixed-case xml
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"HTML\" state=\"tag\"}}"; // bad state
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{%AUTOESCAPE context=\"CSS\" state=\"IN_TAG\"}}"; // invalid state
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "Hello{{%AUTOESCAPE context=\"HTML\"}}"; // after text
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{USER}}{{%AUTOESCAPE context=\"HTML\"}}"; // after variable
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+ text = "{{#SEC}}{{%AUTOESCAPE context=\"HTML\"}}{{/SEC}}"; // not in MAIN
+ ASSERT((tpl = StringToTemplate(text, strip)) == NULL);
+
+ string kAutoescapeHtmlPragma = "{{%AUTOESCAPE context=\"HTML\"}}";
+
+ // Check that Selective Auto-Escape does not auto-escape included templates
+ // unless these are also marked for auto-escape. To attest that,
+ // we check that when no escaping was given in the included template, none
+ // will be applied to it. USER will not get html-escaped.
+ text = kAutoescapeHtmlPragma + "{{>INC}}";
+ tpl = StringToTemplate(text, strip);
+ ASSERT(tpl);
+ string inc_text = "{{USER}}"; // missing :h escaping.
+ TemplateDictionary dict("dict");
+ TemplateDictionary *inc_dict = dict.AddIncludeDictionary("INC");
+ inc_dict->SetFilename(StringToTemplateFile(inc_text));
+ inc_dict->SetValue("USER", user);
+ AssertExpandIs(tpl, &dict, user, true);
+
+ // Add AUTOESCAPE pragma to included template and check that it works.
+ inc_text = kAutoescapeHtmlPragma + inc_text;
+ filename = StringToTemplateFile(inc_text);
+ inc_dict->SetFilename(filename);
+ AssertExpandIs(tpl, &dict, user_esc, true);
+
+ // Check that Selective Auto-Escape works with Template::StringToTemplate.
+ tpl = Template::StringToTemplate(inc_text, strip);
+ ASSERT(tpl);
+ TemplateDictionary dict2("dict2");
+ dict2.SetValue("USER", user);
+ AssertExpandIs(tpl, &dict2, user_esc, true);
+ delete tpl;
+
+ // Test that Selective AutoEscape follows included templates: Included
+ // templates 2 and 4 are registered for auto-escaping but not included
+ // templates 1 and 3. Check that only templates 2 and 4 get escaped.
+ text = "Parent: {{USER}}; {{>INCONE}}";
+ string text_inc1 = "INC1: {{USER1}}; {{>INCTWO}}";
+ string text_inc2 = kAutoescapeHtmlPragma + "INC2: {{USER2}}; {{>INCTHREE}}";
+ string text_inc3 = "INC3: {{USER3}}; {{>INCFOUR}}";
+ string text_inc4 = kAutoescapeHtmlPragma + "INC4: {{USER4}}";
+ dict.SetValue("USER", user);
+
+ TemplateDictionary *dict_inc1 = dict.AddIncludeDictionary("INCONE");
+ dict_inc1->SetFilename(StringToTemplateFile(text_inc1));
+ dict_inc1->SetValue("USER1", user);
+
+ TemplateDictionary *dict_inc2 = dict_inc1->AddIncludeDictionary("INCTWO");
+ filename = StringToTemplateFile(text_inc2);
+ dict_inc2->SetFilename(filename);
+ dict_inc2->SetValue("USER2", user);
+
+ TemplateDictionary *dict_inc3 = dict_inc2->AddIncludeDictionary("INCTHREE");
+ dict_inc3->SetFilename(StringToTemplateFile(text_inc3));
+ dict_inc3->SetValue("USER3", user);
+
+ TemplateDictionary *dict_inc4 = dict_inc3->AddIncludeDictionary("INCFOUR");
+ filename = StringToTemplateFile(text_inc4);
+ dict_inc4->SetFilename(filename);
+ dict_inc4->SetValue("USER4", user);
+
+ tpl = StringToTemplate(text, strip);
+ string expected_out = "Parent: " + user + "; INC1: " + user +
+ "; INC2: " + user_esc + "; INC3: " + user + "; INC4: " + user_esc;
+ AssertExpandIs(tpl, &dict, expected_out, true);
+
+ // Check that we do not modify template-includes.
+ // Here, xml_escape would have been changed to :h:xml_escape
+ // causing a double-escaping of the USER.
+ text = kAutoescapeHtmlPragma + "{{>INC:xml_escape}}";
+ inc_text = "{{USER}}";
+ tpl = StringToTemplate(text, strip);
+ ASSERT(tpl);
+ TemplateDictionary dict3("dict");
+ inc_dict = dict3.AddIncludeDictionary("INC");
+ inc_dict->SetFilename(StringToTemplateFile(inc_text));
+ inc_dict->SetValue("USER", user);
+ AssertExpandIs(tpl, &dict3, user_esc, true);
+
+ // Test that {{%...}} is a "removable" marker. A related test is
+ // also added to TestStrip().
+ tpl = StringToTemplate("{{%AUTOESCAPE context=\"HTML\"}}\nText\n Text",
+ STRIP_BLANK_LINES);
+ AssertExpandIs(tpl, &dict, "Text\n Text", true);
+}
+
+TEST(Template, RegisterString) {
+ ASSERT(Template::StringToTemplateCache("file1", "Some text"));
+ Template* tpl = Template::GetTemplate("file1", STRIP_WHITESPACE);
+ ASSERT(tpl);
+ ASSERT(Template::GetTemplate("file1", STRIP_WHITESPACE) == tpl);
+
+ ASSERT(Template::StringToTemplateCache("file2", "Top {{>INC}}"));
+
+ TemplateDictionary dict("dict");
+ string expected = "Some text";
+ AssertExpandIs(tpl, &dict, expected, true);
+
+ TemplateDictionary* sub_dict = dict.AddIncludeDictionary("INC");
+ sub_dict->SetFilename("file1");
+ tpl = Template::GetTemplate("file2", STRIP_WHITESPACE);
+ expected = "Top Some text";
+ AssertExpandIs(tpl, &dict, expected, true);
+}
+
+// This tests that StaticTemplateString is sufficiently initialized at
+// static-initialization time (as opposed to dynamic-initialization
+// time, which comes later), that we can safely expand templates
+// during dynamic initialization. This is worth testing, because some
+// parts of a StaticTemplateString -- especially the hash value, *do*
+// get computed later at dynamic-initialization time, and we want to
+// make sure that things still work properly even if we access the
+// StaticTemplateString before that happens.
+extern const StaticTemplateString kLateDefine;
+class DynamicInitializationTemplateExpander {
+ public:
+ DynamicInitializationTemplateExpander() {
+ Template* tpl = Template::StringToTemplate("hi {{VAR}} lo",
+ STRIP_WHITESPACE);
+ TemplateDictionary dict("dict");
+ dict.SetValue("VAR", TemplateString("short-lived", strlen("short")));
+ AssertExpandIs(tpl, &dict, "hi short lo", true);
+ dict.SetValue("VAR", kHello);
+ AssertExpandIs(tpl, &dict, "hi Hello lo", true);
+ dict.SetValue("VAR", kLateDefine);
+ AssertExpandIs(tpl, &dict, "hi laterz lo", true);
+ delete tpl;
+ }
+};
+DynamicInitializationTemplateExpander sts_tester; // this runs before main()
+const StaticTemplateString kLateDefine = STS_INIT(kLateDefine, "laterz");
+
+int main(int argc, char** argv) {
+
+ CreateOrCleanTestDirAndSetAsTmpdir(FLAGS_test_tmpdir);
+
+ // This goes first so that future tests don't mess up the filenames.
+ // So we make it a normal function rather than using TEST() on it.
+ TestAnnotation();
+ return RUN_ALL_TESTS();
+}
diff --git a/src/tests/template_unittest_test_footer.in b/src/tests/template_unittest_test_footer.in
new file mode 100644
index 0000000..c81be51
--- /dev/null
+++ b/src/tests/template_unittest_test_footer.in
@@ -0,0 +1,49 @@
+<center><p><hr class=z>
+
+{{#TRIM_LINE}}
+<table width=100% border=0 cellpadding=0 cellspacing=0>
+ <tr>
+ <td bgcolor={{TRIM_LINE_COLOR}} colspan=2{{TRIM_LINE_HEIGHT}}>{{CLEARDOT}}</td>
+ </tr>
+</table>
+{{/TRIM_LINE}}
+ <table width=100% cellpadding=2 cellspacing=0 border=0>
+ <tr>
+ <td align=center{{FOOTER_BAR_ATTRIBUTES}}><font size=-1>
+ {{#FOOTER_BAR_TEXT}}
+ {{HOME_LINK}} -{{BI_SPACE}}
+ {{ADVERTISE_LINK}} -{{BI_SPACE}}
+ {{#PROMO_LICENSING_SECTION}}
+ {{PROMO_LICENSING_LINK}} -{{BI_SPACE}}
+ {{/PROMO_LICENSING_SECTION}}
+ {{ABOUT_GOOGLE_LINK}}
+ {{/FOOTER_BAR_TEXT}}
+ {{#EMPTY_FOOTER_BAR_TEXT}}
+ {{/EMPTY_FOOTER_BAR_TEXT}}
+ </font>
+ </table>
+ <br>
+ <font size=-1 class=p>
+ {{MODIFIED_BY_GOOGLE}}{{MSG_copyright}}
+ </font>
+ {{>ODP_ATTRIBUTION}}
+</center>
+
+{{#CLOSING_DIV_SECTION}}
+ </div>
+{{/CLOSING_DIV_SECTION}}
+
+{{>GOOGLE_COMPLETE_JS}}
+{{>SITE_SPEED_SCRIPT_FOOTER}}
+{{>AD_WIDE_WRAP_JAVASCRIPT}}
+{{>BROWSER_STATS_INCLUDE}}
+{{#LATENCY_PREFETCH}}
+ <link rel=prefetch href="{{LATENCY_PREFETCH_URL}}">
+{{/LATENCY_PREFETCH}}
+
+{{#JAVASCRIPT_FOOTER_SECTION}}
+ <script><!--{{BI_NEWLINE}}
+ {{>FAST_NEXT_JAVASCRIPT}}
+ //-->{{BI_NEWLINE}}
+ </script>
+{{/JAVASCRIPT_FOOTER_SECTION}}
diff --git a/src/tests/template_unittest_test_footer_dict01.out b/src/tests/template_unittest_test_footer_dict01.out
new file mode 100644
index 0000000..9bd3bf3
--- /dev/null
+++ b/src/tests/template_unittest_test_footer_dict01.out
@@ -0,0 +1,10 @@
+<center><p><hr class=z><table width=100% cellpadding=2 cellspacing=0 border=0><tr><td align=center><font size=-1><b>Time to go home!</b> - <b>Be advertiser #2</b> - <A HREF='foo'> - <A HREF=/>About Google!</A></font></table><br><font size=-1 class=p>2005© Google Inc. (all rights reserved)</font></center></div><link rel=prefetch href="/latency"><script><!--
+<html><head></head><body></body></html>
+<html><head>head</head><body></body></html>
+//-->
+</script><script><!--
+<html><head>include-head</head><body><b><A HREF=/></b>: 0.3333</body></html><html><head><script>
+<!--
+</script>
+</head><html><a id="aw" onMouseOver="return ss('')"><b></b></a></html></body>//-->
+</script>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_footer_dict02.out b/src/tests/template_unittest_test_footer_dict02.out
new file mode 100644
index 0000000..dcdb111
--- /dev/null
+++ b/src/tests/template_unittest_test_footer_dict02.out
@@ -0,0 +1 @@
+<center><p><hr class=z><table width=100% cellpadding=2 cellspacing=0 border=0><tr><td align=center><font size=-1></font></table><br><font size=-1 class=p></font></center>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_html.in b/src/tests/template_unittest_test_html.in
new file mode 100644
index 0000000..5d8ad35
--- /dev/null
+++ b/src/tests/template_unittest_test_html.in
@@ -0,0 +1,65 @@
+<html>
+<head>
+<script>{{BI_NEWLINE}}
+ <!--{{BI_NEWLINE}}
+
+ {{! Include the JS code to do query tracking. }}
+ {{! javascript_query_tracking_post*.tpl }}
+ {{>JAVASCRIPT_QUERY_TRACKING_FUNCTION}}
+
+ {{! netscape requires "window.status"; IE allows just "status" here }}
+ {{! must return true when mousing over a link; not necessary when over }}
+ {{! the table cell in general }}
+
+ {{! The "id" parameter here refers to the value of the id attribute }}
+ {{! of the anchor element for the ad (of the form "aw[POS]"). }}
+ {{! This is used by some spam-protection JavaScript to modify }}
+ {{! parameters in the URL of the link. }}
+
+ {{#NO_MOUSEOVER_FUNCTIONS}}
+ function ss(w,id){
+ window.status=w;
+ return true;
+ }{{BI_NEWLINE}}
+ {{/NO_MOUSEOVER_FUNCTIONS}}
+
+ {{#MOUSEOVER_FUNCTIONS}}
+ {{! If any ads are mouseover ads, this is used to import
+ increment_mouseover_js.tpl, which redefines function ss to count
+ mouseovers. Otherwise it produces no output. }}
+ {{>MOUSEOVER_JAVASCRIPT}}
+ {{! Since JSCompiler renames all functions/variables not beginning with an
+ underscore, we use _ss as our compiled function name,
+ then set ss to _ss }}
+ ss = _ss;
+ {{/MOUSEOVER_FUNCTIONS}}
+</script>{{BI_NEWLINE}}
+</head>
+
+<html>
+
+<a id="aw" onMouseOver="return ss('{{GOTO_MESSAGE}}')"{{TARGET}}>
+<b>{{TAG_LINE}}</b>
+</a>
+
+{{#UPDATE_SECTION}}Last updated: {{UPDATE}}<br>{{/UPDATE_SECTION}}
+
+{{#RESULTS}}
+<table cellspacing=0 cellpadding=0{{TABLE_WIDTH}} align={{ALIGNMENT}}{{BI_SPACE}}
+ {{#WHITE_BG}}bgColor=#ffffff {{/WHITE_BG}}border=0>
+ <tr>
+ <td>
+ <ol>
+ <li> Result: {{RESULT}}
+ <li> Goodness of result: {{GOODNESS}}
+ <li> xml-safe result: {{XML_RESULT}}
+ </ol>
+ </td>
+ </tr>
+</table>
+{{/RESULTS}}
+
+{{>FOOTER}}
+
+</html>
+</body>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_html_dict01.anno_out b/src/tests/template_unittest_test_html_dict01.anno_out
new file mode 100644
index 0000000..40012d9
--- /dev/null
+++ b/src/tests/template_unittest_test_html_dict01.anno_out
@@ -0,0 +1,66 @@
+{{#FILE=template_unittest_test_html.in}}{{#SEC=__{{MAIN}}__}}<html>
+<head>
+<script>{{#VAR=BI_NEWLINE}}
+{{/VAR}}
+ <!--{{#VAR=BI_NEWLINE}}
+{{/VAR}}
+{{#SEC=MOUSEOVER_FUNCTIONS}}
+{{#INC=MOUSEOVER_JAVASCRIPT}}{{MISSING_FILE=not_a_template}}{{/INC}}
+ ss = _ss;
+{{/SEC}}</script>{{#VAR=BI_NEWLINE}}
+{{/VAR}}
+</head>
+<html>
+<a id="aw" onMouseOver="return ss('{{#VAR=GOTO_MESSAGE}}print \x22Go home\x22{{/VAR}}')"{{#VAR=TARGET}}{{/VAR}}>
+<b>{{#VAR=TAG_LINE}}{{/VAR}}</b>
+</a>
+{{#SEC=UPDATE_SECTION}}Last updated: {{#VAR=UPDATE}}monday & tuesday{{/VAR}}<br>{{/SEC}}
+{{#SEC=RESULTS}}<table cellspacing=0 cellpadding=0{{#VAR=TABLE_WIDTH}}{{/VAR}} align={{#VAR=ALIGNMENT}}"right"{{/VAR}}{{#VAR=BI_SPACE}} {{/VAR}}
+ {{#SEC=WHITE_BG}}bgColor=#ffffff {{/SEC}}border=0>
+ <tr>
+ <td>
+ <ol>
+ <li> Result: {{#VAR=RESULT}}<&>"result" #0'&'{{/VAR}}
+ <li> Goodness of result: {{#VAR=GOODNESS}}5{{/VAR}}
+ <li> xml-safe result: {{#VAR=XML_RESULT}}<&>"result" #0'&'{{/VAR}}
+ </ol>
+ </td>
+ </tr>
+</table>
+{{/SEC}}{{#SEC=RESULTS}}<table cellspacing=0 cellpadding=0{{#VAR=TABLE_WIDTH}}{{/VAR}} align={{#VAR=ALIGNMENT}}"right"{{/VAR}}{{#VAR=BI_SPACE}} {{/VAR}}
+ border=0>
+ <tr>
+ <td>
+ <ol>
+ <li> Result: {{#VAR=RESULT}}<&>"result" #1'&'{{/VAR}}
+ <li> Goodness of result: {{#VAR=GOODNESS}}6{{/VAR}}
+ <li> xml-safe result: {{#VAR=XML_RESULT}}<&>"result" #1'&'{{/VAR}}
+ </ol>
+ </td>
+ </tr>
+</table>
+{{/SEC}}{{#SEC=RESULTS}}<table cellspacing=0 cellpadding=0{{#VAR=TABLE_WIDTH}}{{/VAR}} align={{#VAR=ALIGNMENT}}"right"{{/VAR}}{{#VAR=BI_SPACE}} {{/VAR}}
+ {{#SEC=WHITE_BG}}bgColor=#ffffff {{/SEC}}border=0>
+ <tr>
+ <td>
+ <ol>
+ <li> Result: {{#VAR=RESULT}}<&>"result" #2'&'{{/VAR}}
+ <li> Goodness of result: {{#VAR=GOODNESS}}7{{/VAR}}
+ <li> xml-safe result: {{#VAR=XML_RESULT}}<&>"result" #2'&'{{/VAR}}
+ </ol>
+ </td>
+ </tr>
+</table>
+{{/SEC}}{{#INC=FOOTER}}{{#FILE=template_unittest_test_footer.in}}{{#SEC=__{{MAIN}}__}}<center><p><hr class=z>
+ <table width=100% cellpadding=2 cellspacing=0 border=0>
+ <tr>
+ <td align=center{{#VAR=FOOTER_BAR_ATTRIBUTES}}{{/VAR}}><font size=-1>
+ </font>
+ </table>
+ <br>
+ <font size=-1 class=p>
+ {{#VAR=MODIFIED_BY_GOOGLE}}{{/VAR}}{{#VAR=MSG_copyright}}{{/VAR}}
+ </font>
+</center>
+{{/SEC}}{{/FILE}}{{/INC}}</html>
+</body>{{/SEC}}{{/FILE}}
diff --git a/src/tests/template_unittest_test_html_dict01.out b/src/tests/template_unittest_test_html_dict01.out
new file mode 100644
index 0000000..1abe7b7
--- /dev/null
+++ b/src/tests/template_unittest_test_html_dict01.out
@@ -0,0 +1,4 @@
+<html><head><script>
+<!--
+ss = _ss;</script>
+</head><html><a id="aw" onMouseOver="return ss('print \x22Go home\x22')"><b></b></a>Last updated: monday & tuesday<br><table cellspacing=0 cellpadding=0 align="right" bgColor=#ffffff border=0><tr><td><ol><li> Result: <&>"result" #0'&'<li> Goodness of result: 5<li> xml-safe result: <&>"result" #0'&'</ol></td></tr></table><table cellspacing=0 cellpadding=0 align="right" border=0><tr><td><ol><li> Result: <&>"result" #1'&'<li> Goodness of result: 6<li> xml-safe result: <&>"result" #1'&'</ol></td></tr></table><table cellspacing=0 cellpadding=0 align="right" bgColor=#ffffff border=0><tr><td><ol><li> Result: <&>"result" #2'&'<li> Goodness of result: 7<li> xml-safe result: <&>"result" #2'&'</ol></td></tr></table><center><p><hr class=z><table width=100% cellpadding=2 cellspacing=0 border=0><tr><td align=center><font size=-1></font></table><br><font size=-1 class=p></font></center></html></body>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_html_dict02.out b/src/tests/template_unittest_test_html_dict02.out
new file mode 100644
index 0000000..2fed87b
--- /dev/null
+++ b/src/tests/template_unittest_test_html_dict02.out
@@ -0,0 +1,4 @@
+<html><head><script>
+<!--
+</script>
+</head><html><a id="aw" onMouseOver="return ss('')"><b></b></a></html></body>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_invalid1.in b/src/tests/template_unittest_test_invalid1.in
new file mode 100644
index 0000000..cf0e80a
--- /dev/null
+++ b/src/tests/template_unittest_test_invalid1.in
@@ -0,0 +1,3 @@
+This is html
+{This is fine}
+{{This is not so fine}} {{! Can't have spaces in a variable name!}}
diff --git a/src/tests/template_unittest_test_invalid2.in b/src/tests/template_unittest_test_invalid2.in
new file mode 100644
index 0000000..48383a6
--- /dev/null
+++ b/src/tests/template_unittest_test_invalid2.in
@@ -0,0 +1,7 @@
+This is html.
+
+{{#SECTION}}
+Happy section
+{{/SEC}}
+
+But the section never ends!
diff --git a/src/tests/template_unittest_test_markerdelim.in b/src/tests/template_unittest_test_markerdelim.in
new file mode 100644
index 0000000..e3762e6
--- /dev/null
+++ b/src/tests/template_unittest_test_markerdelim.in
@@ -0,0 +1,67 @@
+{{! Use <<< and >>> to delimit template stuff, rather than {{ and }}
+{{=<<< >>>=}}
+<html>
+<head>
+<script><<<BI_NEWLINE>>>
+ <!--<<<BI_NEWLINE>>>
+
+ <<<! Include the JS code to do query tracking. >>>
+ <<<! javascript_query_tracking_post*.tpl >>>
+ <<<>JAVASCRIPT_QUERY_TRACKING_FUNCTION>>>
+
+ <<<! netscape requires "window.status"; IE allows just "status" here >>>
+ <<<! must return true when mousing over a link; not necessary when over >>>
+ <<<! the table cell in general >>>
+
+ <<<! The "id" parameter here refers to the value of the id attribute >>>
+ <<<! of the anchor element for the ad (of the form "aw[POS]"). >>>
+ <<<! This is used by some spam-protection JavaScript to modify >>>
+ <<<! parameters in the URL of the link. >>>
+
+ <<<#NO_MOUSEOVER_FUNCTIONS>>>
+ function ss(w,id){
+ window.status=w;
+ return true;
+ }<<<BI_NEWLINE>>>
+ <<</NO_MOUSEOVER_FUNCTIONS>>>
+
+ <<<#MOUSEOVER_FUNCTIONS>>>
+ <<<! If any ads are mouseover ads, this is used to import
+ increment_mouseover_js.tpl, which redefines function ss to count
+ mouseovers. Otherwise it produces no output. >>>
+ <<<>MOUSEOVER_JAVASCRIPT>>>
+ <<<! Since JSCompiler renames all functions/variables not beginning with an
+ underscore, we use _ss as our compiled function name,
+ then set ss to _ss >>>
+ ss = _ss;
+ <<</MOUSEOVER_FUNCTIONS>>>
+</script><<<BI_NEWLINE>>>
+</head>
+
+<html>
+
+<a id="aw" onMouseOver="return ss('<<<GOTO_MESSAGE>>>')"<<<TARGET>>>>
+<b><<<TAG_LINE>>></b>
+</a>
+
+<<<#UPDATE_SECTION>>>Last updated: <<<UPDATE>>><br><<</UPDATE_SECTION>>>
+
+<<<#RESULTS>>>
+<table cellspacing=0 cellpadding=0<<<TABLE_WIDTH>>> align=<<<ALIGNMENT>>><<<BI_SPACE>>>
+ <<<#WHITE_BG>>>bgColor=#ffffff <<</WHITE_BG>>>border=0>
+ <tr>
+ <td>
+ <ol>
+ <li> Result: <<<RESULT>>>
+ <li> Goodness of result: <<<GOODNESS>>>
+ <li> xml-safe result: <<<XML_RESULT>>>
+ </ol>
+ </td>
+ </tr>
+</table>
+<<</RESULTS>>>
+
+<<<>FOOTER>>>
+
+</html>
+</body>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_markerdelim_dict01.out b/src/tests/template_unittest_test_markerdelim_dict01.out
new file mode 100644
index 0000000..1abe7b7
--- /dev/null
+++ b/src/tests/template_unittest_test_markerdelim_dict01.out
@@ -0,0 +1,4 @@
+<html><head><script>
+<!--
+ss = _ss;</script>
+</head><html><a id="aw" onMouseOver="return ss('print \x22Go home\x22')"><b></b></a>Last updated: monday & tuesday<br><table cellspacing=0 cellpadding=0 align="right" bgColor=#ffffff border=0><tr><td><ol><li> Result: <&>"result" #0'&'<li> Goodness of result: 5<li> xml-safe result: <&>"result" #0'&'</ol></td></tr></table><table cellspacing=0 cellpadding=0 align="right" border=0><tr><td><ol><li> Result: <&>"result" #1'&'<li> Goodness of result: 6<li> xml-safe result: <&>"result" #1'&'</ol></td></tr></table><table cellspacing=0 cellpadding=0 align="right" bgColor=#ffffff border=0><tr><td><ol><li> Result: <&>"result" #2'&'<li> Goodness of result: 7<li> xml-safe result: <&>"result" #2'&'</ol></td></tr></table><center><p><hr class=z><table width=100% cellpadding=2 cellspacing=0 border=0><tr><td align=center><font size=-1></font></table><br><font size=-1 class=p></font></center></html></body>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_markerdelim_dict02.out b/src/tests/template_unittest_test_markerdelim_dict02.out
new file mode 100644
index 0000000..2fed87b
--- /dev/null
+++ b/src/tests/template_unittest_test_markerdelim_dict02.out
@@ -0,0 +1,4 @@
+<html><head><script>
+<!--
+</script>
+</head><html><a id="aw" onMouseOver="return ss('')"><b></b></a></html></body>
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_modifiers.in b/src/tests/template_unittest_test_modifiers.in
new file mode 100644
index 0000000..b70e93f
--- /dev/null
+++ b/src/tests/template_unittest_test_modifiers.in
@@ -0,0 +1,15 @@
+<html>
+<body>
+{{#UPDATE_SECTION}}
+ {{UPDATE}}
+ {{UPDATE:h}}
+ {{UPDATE:javascript_escape}}
+ {{UPDATE:h:u}}
+{{/UPDATE_SECTION}}
+{{! There should be no problem with this comment having a : in it. }}
+ <IMG src=foo.jpg align={{ALIGNMENT}}>
+ <IMG src="mouseover() {img=\'foo.jpg\' align={{ALIGNMENT:j}}}">
+
+{{>SIMPLE:html_escape}}
+</body>
+</html>{{BI_NEWLINE}}
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_modifiers_dict01.anno_out b/src/tests/template_unittest_test_modifiers_dict01.anno_out
new file mode 100644
index 0000000..e14adb6
--- /dev/null
+++ b/src/tests/template_unittest_test_modifiers_dict01.anno_out
@@ -0,0 +1,11 @@
+{{#FILE=template_unittest_test_modifiers.in}}{{#SEC=__{{MAIN}}__}}<html>
+<body>
+{{#SEC=UPDATE_SECTION}} {{#VAR=UPDATE}}monday & tuesday{{/VAR}}
+ {{#VAR=UPDATE:html_escape}}monday &amp; tuesday{{/VAR}}
+ {{#VAR=UPDATE:javascript_escape}}monday \x26amp; tuesday{{/VAR}}
+ {{#VAR=UPDATE:html_escape:url_query_escape}}monday+%26amp%3Bamp%3B+tuesday{{/VAR}}
+{{/SEC}} <IMG src=foo.jpg align={{#VAR=ALIGNMENT}}"right"{{/VAR}}>
+ <IMG src="mouseover() {img=\'foo.jpg\' align={{#VAR=ALIGNMENT:javascript_escape}}\x22right\x22{{/VAR}}}">
+{{#INC=SIMPLE:html_escape}}{{#FILE=template_unittest_test_simple.in}}{{#SEC=__{{MAIN}}__}}<html> <head> {{#VAR=HEAD}}{{/VAR}} </head> <body> {{#VAR=BODY}}{{/VAR}} </body> </html>{{#VAR=BI_NEWLINE}} {{/VAR}}{{/SEC}}{{/FILE}}{{/INC}}</body>
+</html>{{#VAR=BI_NEWLINE}}
+{{/VAR}}{{/SEC}}{{/FILE}}
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_modifiers_dict01.out b/src/tests/template_unittest_test_modifiers_dict01.out
new file mode 100644
index 0000000..ea3cbad
--- /dev/null
+++ b/src/tests/template_unittest_test_modifiers_dict01.out
@@ -0,0 +1 @@
+<html><body>monday & tuesdaymonday &amp; tuesdaymonday \x26amp; tuesdaymonday+%26amp%3Bamp%3B+tuesday<IMG src=foo.jpg align="right"><IMG src="mouseover() {img=\'foo.jpg\' align=\x22right\x22}"><html><head></head><body></body></html> </body></html>
diff --git a/src/tests/template_unittest_test_nul.in b/src/tests/template_unittest_test_nul.in
new file mode 100644
index 0000000..82a536b
--- /dev/null
+++ b/src/tests/template_unittest_test_nul.in
Binary files differ
diff --git a/src/tests/template_unittest_test_nul_dict01.out b/src/tests/template_unittest_test_nul_dict01.out
new file mode 100644
index 0000000..90e9c58
--- /dev/null
+++ b/src/tests/template_unittest_test_nul_dict01.out
Binary files differ
diff --git a/src/tests/template_unittest_test_selective_css.in b/src/tests/template_unittest_test_selective_css.in
new file mode 100644
index 0000000..96e8246
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_css.in
@@ -0,0 +1,15 @@
+{{%AUTOESCAPE context="CSS"}}
+
+P.abstract {
+ margin-{{AE_START_EDGE}}:0;
+ text-align:{{AE_END_EDGE}};
+ font-size:{{AE_FONT_SIZE_PC}};
+}
+.italic {font-style:{{AE_ITALIC}}}
+
+H1 {
+ font-size:{{AE_FONT_SIZE_PT}};
+ color:{{AE_MAUVE_RGB}};
+}
+
+BODY {background:transparent url('{{AE_URL_GOOD}}');}
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_css_dict01.out b/src/tests/template_unittest_test_selective_css_dict01.out
new file mode 100644
index 0000000..1abf6f8
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_css_dict01.out
@@ -0,0 +1 @@
+P.abstract {margin-left:0;text-align:center;font-size:120%;}.italic {font-style:italic}H1 {font-size:12pt;color:#FF7BD5;}BODY {background:transparent url('httpwww.google.com');}
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_css_dict02.out b/src/tests/template_unittest_test_selective_css_dict02.out
new file mode 100644
index 0000000..f86da6f
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_css_dict02.out
@@ -0,0 +1 @@
+P.abstract {margin-:0;text-align:;font-size:;}.italic {font-style:}H1 {font-size:;color:;}BODY {background:transparent url('');}
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_html.in b/src/tests/template_unittest_test_selective_html.in
new file mode 100644
index 0000000..e005fbc
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_html.in
@@ -0,0 +1,15 @@
+{{%AUTOESCAPE context="HTML"}}
+{{!Is a copy of template_unittest_test_autoescape_simple.in}}
+<h1>{{AE_TITLE_GOOD}}</h1>
+<h1>{{AE_TITLE_BAD}}</h1>
+<img src="{{AE_URL_GOOD}}">
+<img src="{{AE_URL_BAD}}">
+<div style="background:{{AE_BG_COLOR_GOOD}}">
+<div style="background:{{AE_BG_COLOR_BAD}}">
+</div>
+<script>
+ var msg_text = '{{AE_JS_GOOD}}';
+ var msg_text = '{{AE_JS_BAD}}';
+</script>
+Goodbye {{AE_USERNAME_GOOD}}!
+Goodbye {{AE_USERNAME_BAD}}!
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_html_dict01.out b/src/tests/template_unittest_test_selective_html_dict01.out
new file mode 100644
index 0000000..4bec106
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_html_dict01.out
@@ -0,0 +1 @@
+<h1>Hello World!</h1><h1>Hello <script>alert(1)</script> World!</h1><img src="http://www.google.com/"><img src="#"><div style="background:red"><div style="background:evil! "></div><script>var msg_text = 'your text here';var msg_text = 'your text\x27is clever\x27thanks';</script>Goodbye Mr. Nice!Goodbye Doctor<script>alert(2)</script>Evil!
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_html_dict02.out b/src/tests/template_unittest_test_selective_html_dict02.out
new file mode 100644
index 0000000..2aa9b17
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_html_dict02.out
@@ -0,0 +1 @@
+<h1></h1><h1></h1><img src=""><img src=""><div style="background:"><div style="background:"></div><script>var msg_text = '';var msg_text = '';</script>Goodbye !Goodbye !
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_js.in b/src/tests/template_unittest_test_selective_js.in
new file mode 100644
index 0000000..de511db
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_js.in
@@ -0,0 +1,7 @@
+{{%AUTOESCAPE context="JAVASCRIPT"}}
+ var msg_text1 = '{{AE_JS_GOOD}}';
+ var msg_text2 = '{{AE_JS_BAD}}';
+{{!Below variable is not quoted}}
+ var msg_text3 = {{AE_JS_BAD}};
+{{!Below variable ends up with :h:j}}
+ var msg_text4 = '{{AE_JS_BAD:h}}';
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_js_dict01.out b/src/tests/template_unittest_test_selective_js_dict01.out
new file mode 100644
index 0000000..75fce98
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_js_dict01.out
@@ -0,0 +1 @@
+var msg_text1 = 'your text here';var msg_text2 = 'your text\x27is clever\x27thanks';var msg_text3 = null;var msg_text4 = 'your text\x26#39;is clever\x26#39;thanks';
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_selective_js_dict02.out b/src/tests/template_unittest_test_selective_js_dict02.out
new file mode 100644
index 0000000..440a14b
--- /dev/null
+++ b/src/tests/template_unittest_test_selective_js_dict02.out
@@ -0,0 +1 @@
+var msg_text1 = '';var msg_text2 = '';var msg_text3 = ;var msg_text4 = '';
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_simple.in b/src/tests/template_unittest_test_simple.in
new file mode 100644
index 0000000..386fb63
--- /dev/null
+++ b/src/tests/template_unittest_test_simple.in
@@ -0,0 +1,8 @@
+<html>
+<head>
+ {{HEAD}}
+</head>
+<body>
+ {{BODY}}
+</body>
+</html>{{BI_NEWLINE}}
\ No newline at end of file
diff --git a/src/tests/template_unittest_test_simple_dict01.out b/src/tests/template_unittest_test_simple_dict01.out
new file mode 100644
index 0000000..e91f0cc
--- /dev/null
+++ b/src/tests/template_unittest_test_simple_dict01.out
@@ -0,0 +1 @@
+<html><head> This is the head </head><body></body></html>
diff --git a/src/tests/template_unittest_test_simple_dict02.out b/src/tests/template_unittest_test_simple_dict02.out
new file mode 100644
index 0000000..30e84fd
--- /dev/null
+++ b/src/tests/template_unittest_test_simple_dict02.out
@@ -0,0 +1 @@
+<html><head></head><body></body></html>
diff --git a/src/tests/template_unittest_test_simple_dict03.out b/src/tests/template_unittest_test_simple_dict03.out
new file mode 100644
index 0000000..5106739
--- /dev/null
+++ b/src/tests/template_unittest_test_simple_dict03.out
@@ -0,0 +1,2 @@
+<html><head> </head><body>
+</body></html>
diff --git a/src/tests/template_unittest_test_valid1.in b/src/tests/template_unittest_test_valid1.in
new file mode 100644
index 0000000..57f72b3
--- /dev/null
+++ b/src/tests/template_unittest_test_valid1.in
@@ -0,0 +1,3 @@
+This is ok.
+{This is also ok.}
+Look ma!, no template substitutions at all!
diff --git a/src/tests/template_unittest_test_valid1_dict01.out b/src/tests/template_unittest_test_valid1_dict01.out
new file mode 100644
index 0000000..c8e3d30
--- /dev/null
+++ b/src/tests/template_unittest_test_valid1_dict01.out
@@ -0,0 +1 @@
+This is ok.{This is also ok.}Look ma!, no template substitutions at all!
\ No newline at end of file
diff --git a/src/windows/config.h b/src/windows/config.h
new file mode 100644
index 0000000..d8a1e94
--- /dev/null
+++ b/src/windows/config.h
@@ -0,0 +1,222 @@
+/* A manual version of config.h fit for windows machines. */
+
+/* Sometimes we accidentally #include this config.h instead of the one
+ in .. -- this is particularly true for msys/mingw, which uses the
+ unix config.h but also runs code in the windows directory.
+*/
+#if defined(__MINGW32__) || defined(__MING64__)
+#define CTEMPLATE_DLL_DECL
+// These two lines make sure we read the unix-style config.h, and not the
+// windows-style config.h -- it would be bad if we tried to read both!
+#include "../config.h"
+#define GOOGLE_CTEMPLATE_WINDOWS_CONFIG_H_
+#endif
+
+#ifndef GOOGLE_CTEMPLATE_WINDOWS_CONFIG_H_
+#define GOOGLE_CTEMPLATE_WINDOWS_CONFIG_H_
+
+/* Namespace for Google classes */
+#define GOOGLE_NAMESPACE ctemplate
+
+/* the location of <unordered_map> or <hash_map> */
+#define HASH_MAP_H <hash_map>
+
+/* the namespace of hash_map/hash_set */
+#define HASH_NAMESPACE stdext
+
+/* the location of <unordered_set> or <hash_set> */
+#define HASH_SET_H <hash_set>
+
+/* Define to 1 if you have the <byteswap.h> header file. */
+#undef HAVE_BYTESWAP_H
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <endian.h> header file. */
+#undef HAVE_ENDIAN_H
+
+/* Define to 1 if you have the `getopt' function. */
+#undef HAVE_GETOPT
+
+/* Define to 1 if you have the <getopt.h> header file. */
+#undef HAVE_GETOPT_H
+
+/* Define to 1 if you have the `getopt_long' function. */
+#undef HAVE_GETOPT_LONG
+
+/* define if the compiler has hash_map */
+#define HAVE_HASH_MAP 1
+
+/* define if the compiler has hash_set */
+#define HAVE_HASH_SET 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <libkern/OSByteOrder.h> header file. */
+#undef HAVE_LIBKERN_OSBYTEORDER_H
+
+/* Define to 1 if you have the <machine/endian.h> header file. */
+#undef HAVE_MACHINE_ENDIAN_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* define if the compiler implements namespaces */
+#define HAVE_NAMESPACES 1
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define if you have POSIX threads libraries and header files. */
+#undef HAVE_PTHREAD
+
+/* define if the compiler implements pthread_rwlock_* */
+#undef HAVE_RWLOCK
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if you have the <sys/byteorder.h> header file. */
+#undef HAVE_SYS_BYTEORDER_H
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/endian.h> header file. */
+#undef HAVE_SYS_ENDIAN_H
+
+/* Define to 1 if you have the <sys/isa_defs.h> header file. */
+#undef HAVE_SYS_ISA_DEFS_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+ */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#define HAVE_SYS_STAT_H 1
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#define HAVE_SYS_TYPES_H 1
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#undef HAVE_UINT32_T
+
+/* Define to 1 if the system has the type `uint64_t'. */
+#undef HAVE_UINT64_T
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* define if the compiler supports unordered_{map,set} */
+#undef HAVE_UNORDERED_MAP
+
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
+
+/* Define to 1 if the system has the type `u_int32_t'. */
+#undef HAVE_U_INT32_T
+
+/* Define to 1 if the system has the type `u_int64_t'. */
+#undef HAVE_U_INT64_T
+
+/* define if your compiler has __attribute__ */
+#undef HAVE___ATTRIBUTE__
+
+/* Define to 1 if the system has the type `__uint32. */
+#define HAVE___INT32 1
+
+/* Define to 1 if the system has the type `__uint64. */
+#define HAVE___INT64 1
+
+/* The namespace to put the htmlparser code. */
+#define HTMLPARSER_NAMESPACE google_ctemplate_streamhtmlparser
+
+/* define if first argument to InterlockedExchange is just LONG */
+#undef INTERLOCKED_EXCHANGE_NONVOLATILE
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "ctemplate 1.1"
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* printf format code for printing a size_t and ssize_t */
+#define PRIdS "Id"
+
+/* printf format code for printing a size_t and ssize_t */
+#define PRIuS "Iu"
+
+/* printf format code for printing a size_t and ssize_t */
+#define PRIxS "Ix"
+
+/* Define to necessary symbol if this constant uses a non-standard name on
+ your system. */
+#undef PTHREAD_CREATE_JOINABLE
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* the namespace where STL code like vector<> is defined */
+#define STL_NAMESPACE std
+
+/* Version number of package */
+#undef VERSION
+
+/* Stops putting the code inside the Google namespace */
+#define _END_GOOGLE_NAMESPACE_ }
+
+/* Puts following code inside the Google namespace */
+#define _START_GOOGLE_NAMESPACE_ namespace ctemplate {
+
+// ---------------------------------------------------------------------
+// Extra stuff not found in config.h.in
+
+// This must be defined before anything else in our project: make sure
+// that when compiling the dll, we export our functions/classes. Safe
+// to define this here because this file is only used internally, to
+// compile the DLL, and every dll source file #includes "config.h"
+// before anything else.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllexport)
+# define CTEMPLATE_DLL_DECL_FOR_UNITTESTS __declspec(dllimport)
+#endif
+
+// TODO(csilvers): include windows/port.h in every relevant source file instead?
+#include "windows/port.h"
+
+#endif /* GOOGLE_CTEMPLATE_WINDOWS_CONFIG_H_ */
diff --git a/src/windows/ctemplate/find_ptr.h b/src/windows/ctemplate/find_ptr.h
new file mode 100644
index 0000000..8e6fec5
--- /dev/null
+++ b/src/windows/ctemplate/find_ptr.h
@@ -0,0 +1,75 @@
+// Copyright (c) 2012, Olaf van der Spek <olafvdspek@gmail.com>
+// 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 Google Inc. 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.
+
+// ---
+// Author: Olaf van der Spek <olafvdspek@gmail.com>
+
+#ifndef TEMPLATE_FIND_PTR_H_
+#define TEMPLATE_FIND_PTR_H_
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+template <class T, class U>
+typename T::value_type::second_type* find_ptr(T& c, U v)
+{
+ typename T::iterator i = c.find(v);
+ return i == c.end() ? NULL : &i->second;
+}
+
+template <class T, class U>
+const typename T::value_type::second_type* find_ptr(const T& c, U v)
+{
+ typename T::const_iterator i = c.find(v);
+ return i == c.end() ? NULL : &i->second;
+}
+
+template <class T, class U>
+typename T::value_type::second_type find_ptr2(T& c, U v)
+{
+ typename T::iterator i = c.find(v);
+ return i == c.end() ? NULL : i->second;
+}
+
+template <class T, class U>
+const typename T::value_type::second_type find_ptr2(const T& c, U v)
+{
+ typename T::const_iterator i = c.find(v);
+ return i == c.end() ? NULL : i->second;
+}
+
+}
+
+#endif // TEMPLATE_FIND_PTR_H_
diff --git a/src/windows/ctemplate/per_expand_data.h b/src/windows/ctemplate/per_expand_data.h
new file mode 100644
index 0000000..6abce97
--- /dev/null
+++ b/src/windows/ctemplate/per_expand_data.h
@@ -0,0 +1,154 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// In addition to a TemplateDictionary, there is also a PerExpandData
+// dictionary. This dictionary holds information that applies to one
+// call to Expand, such as whether to annotate the template expansion
+// output. A template dictionary is associated with a template (.tpl)
+// file; a per-expand dictionary is associated to a particular call to
+// Expand() in a .cc file.
+//
+// For (many) more details, see the doc/ directory.
+
+#ifndef TEMPLATE_PER_EXPAND_DATA_H_
+#define TEMPLATE_PER_EXPAND_DATA_H_
+
+#include <stdlib.h> // for NULL
+#include <string.h> // for strcmp
+#include <sys/types.h>
+#include <hash_map>
+#include <ctemplate/template_string.h> // for StringHash
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+class TemplateModifier;
+class TemplateAnnotator;
+
+class CTEMPLATE_DLL_DECL PerExpandData {
+ public:
+ PerExpandData()
+ : annotate_path_(NULL),
+ annotator_(NULL),
+ expand_modifier_(NULL),
+ map_(NULL) { }
+
+ ~PerExpandData();
+
+ // Indicate that annotations should be inserted during template expansion.
+ // template_path_start - the start of a template path. When
+ // printing the filename for template-includes, anything before and
+ // including template_path_start is elided. This can make the
+ // output less dependent on filesystem location for template files.
+ void SetAnnotateOutput(const char* template_path_start) {
+ annotate_path_ = template_path_start;
+ }
+
+ // Whether to annotate the expanded output.
+ bool annotate() const { return annotate_path_ != NULL; }
+
+ // The annotate-path; undefined if annotate() != true
+ const char* annotate_path() const { return annotate_path_; }
+
+ // This sets the TemplateAnnotator to be used when annotating is on.
+ // This allows you to override the default text-based annotator
+ // that will be used if you do not call this. The passed annotator
+ // will be aliased by this object and returned by annotator().
+ // Passing NULL has the special behavior of causing annotator() to
+ // revert to returning its built-in instance.
+ void SetAnnotator(TemplateAnnotator* annotator) {
+ annotator_ = annotator;
+ }
+
+ // This returns the TemplateAnnotator to be used when annotating is on.
+ // The value returned will be either an instance previously provided
+ // to SetAnnotator() or the callable built-in text-based annotator.
+ TemplateAnnotator* annotator() const;
+
+ // This is a TemplateModifier to be applied to all templates
+ // expanded via this call to Expand(). That is, this modifier is
+ // applies to the template (.tpl) file we expand, as well as
+ // sub-templates that are expanded due to {{>INCLUDE}} directives.
+ // Caller is responsible for ensuring that modifier exists for the
+ // lifetime of this object.
+ void SetTemplateExpansionModifier(const TemplateModifier* modifier) {
+ expand_modifier_ = modifier;
+ }
+
+ const TemplateModifier* template_expansion_modifier() const {
+ return expand_modifier_;
+ }
+
+ // Store data in this structure, to be used by template modifiers
+ // (see template_modifiers.h). Call with value set to NULL to clear
+ // any value previously set. Caller is responsible for ensuring key
+ // and value point to valid data for the lifetime of this object.
+ void InsertForModifiers(const char* key, const void* value);
+
+ // Retrieve data specific to this Expand call. Returns NULL if key
+ // is not found. This should only be used by template modifiers.
+ const void* LookupForModifiers(const char* key) const;
+
+ // Same as Lookup, but casts the result to a c string.
+ const char* LookupForModifiersAsString(const char* key) const {
+ return static_cast<const char*>(LookupForModifiers(key));
+ }
+
+ private:
+#ifdef _MSC_VER
+ typedef stdext::hash_map<const char*, const void*, StringHash> DataMap;
+#else
+ struct DataEq {
+ bool operator()(const char* s1, const char* s2) const;
+ };
+ typedef stdext::hash_map<const char*, const void*, StringHash, DataEq>
+ DataMap;
+#endif
+
+ const char* annotate_path_;
+ TemplateAnnotator* annotator_;
+ const TemplateModifier* expand_modifier_;
+ DataMap* map_;
+
+ PerExpandData(const PerExpandData&); // disallow evil copy constructor
+ void operator=(const PerExpandData&); // disallow evil operator=
+};
+
+}
+
+#endif // TEMPLATE_PER_EXPAND_DATA_H_
diff --git a/src/windows/ctemplate/str_ref.h b/src/windows/ctemplate/str_ref.h
new file mode 100644
index 0000000..20a2663
--- /dev/null
+++ b/src/windows/ctemplate/str_ref.h
@@ -0,0 +1,134 @@
+// Copyright (c) 2012, Olaf van der Spek <olafvdspek@gmail.com>
+// 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 Google Inc. 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.
+
+// ---
+// Author: Olaf van der Spek <olafvdspek@gmail.com>
+
+#ifndef TEMPLATE_STR_REF_H_
+#define TEMPLATE_STR_REF_H_
+
+#include <cstddef>
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+template <class T>
+class str_ref_basic
+{
+public:
+ str_ref_basic()
+ {
+ clear();
+ }
+
+ template <class U>
+ str_ref_basic(const U& c)
+ {
+ if (c.end() != c.begin())
+ assign(&*c.begin(), c.end() - c.begin() + &*c.begin());
+ else
+ clear();
+ }
+
+ str_ref_basic(const void* b, const void* e)
+ {
+ assign(b, e);
+ }
+
+ str_ref_basic(const void* b, size_t sz)
+ {
+ assign(b, sz);
+ }
+
+ str_ref_basic(const char* b)
+ {
+ if (b)
+ assign(b, strlen(b));
+ else
+ clear();
+ }
+
+ void clear()
+ {
+ begin_ = end_ = NULL;
+ }
+
+ void assign(const void* b, const void* e)
+ {
+ begin_ = reinterpret_cast<T>(b);
+ end_ = reinterpret_cast<T>(e);
+ }
+
+ void assign(const void* b, size_t sz)
+ {
+ begin_ = reinterpret_cast<T>(b);
+ end_ = begin_ + sz;
+ }
+
+ T begin() const
+ {
+ return begin_;
+ }
+
+ T end() const
+ {
+ return end_;
+ }
+
+ T data() const
+ {
+ return begin();
+ }
+
+ size_t size() const
+ {
+ return end() - begin();
+ }
+
+ bool empty() const
+ {
+ return begin() == end();
+ }
+private:
+ T begin_;
+ T end_;
+};
+
+typedef str_ref_basic<const unsigned char*> data_ref;
+typedef str_ref_basic<const char*> str_ref;
+
+}
+
+#endif // TEMPLATE_STR_REF_H_
diff --git a/src/windows/ctemplate/template.h b/src/windows/ctemplate/template.h
new file mode 100644
index 0000000..4d12cb7
--- /dev/null
+++ b/src/windows/ctemplate/template.h
@@ -0,0 +1,492 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// This file implements the Template class. For information about
+// how to use this class, and to write the templates it takes as input,
+// see the doc/ directory.
+
+#ifndef CTEMPLATE_TEMPLATE_H_
+#define CTEMPLATE_TEMPLATE_H_
+
+#include <time.h> // for time_t
+#include <string>
+#include <ctemplate/template_cache.h>
+#include <ctemplate/template_enums.h>
+#include <ctemplate/template_string.h>
+
+// We include this just so folks don't have to include both template.h
+// and template_dictionary.h, or template_namelist.h etc, to use the
+// template system; we don't actually use anything in these files
+// ourselves.
+#if 1
+#include <ctemplate/template_dictionary.h>
+#include <ctemplate/template_namelist.h>
+#include <ctemplate/per_expand_data.h>
+#else
+namespace ctemplate {
+class TemplateDictionaryInterface;
+class PerExpandData;
+}
+#endif
+
+namespace google_ctemplate_streamhtmlparser {
+class HtmlParser;
+}
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+// These free functions form the "simple" template API, and support
+// the most common operations (expanding a template from a file, and
+// from a string). They all just delegate to a default instance of
+// the TemplateCache object.
+//
+// For more sophisticated use of the template system, you may need
+// to create your own TemplateCache object, and work directly with
+// it. See template_cache.h for details.
+
+extern CTEMPLATE_DLL_DECL const TemplateCache* default_template_cache();
+extern CTEMPLATE_DLL_DECL TemplateCache* mutable_default_template_cache();
+
+
+// ---- EXPANDING A TEMPLATE -------
+// ExpandTemplate
+// ExpandWithData
+
+// Loads the template named filename from disk if necessary -- it
+// gets it from the cache instead, if the template had been loaded
+// before or if it had been put explicitly in the cache via a call
+// to StringToTemplateCache() -- and expands it using the given
+// dictionary.
+// The first version is the most general, followed by common-case code.
+inline bool ExpandTemplate(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ ExpandEmitter* output) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, NULL, output);
+}
+inline bool ExpandTemplate(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ std::string* output_buffer) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, NULL, output_buffer);
+}
+
+// If you want any per-expand data to be used at expand time, call
+// this routine instead of Expand. You pass in an extra
+// PerExpandData structure (see per_expand_data.h) which sets this
+// data: whether or not you want the template to be annotated, and
+// any data you want to pass in to template modifers. If
+// per_expand_data is NULL, this is exactly the same as Expand().
+// The first version is the most general, followed by common-case code.
+inline bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ ExpandEmitter* output) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, per_expand_data, output);
+}
+inline bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data,
+ std::string* output_buffer) {
+ return mutable_default_template_cache()->ExpandWithData(
+ filename, strip, dictionary, per_expand_data, output_buffer);
+}
+
+// ---- INSERTING INTO THE CACHE -------
+// LoadTemplate
+// StringToTemplateCache
+
+// Reads a file from disk and inserts it into the template, if it's
+// not already there. Returns true on success or false if the
+// template could not be found, or could not be parsed. It's never
+// necessary to call this -- Expand() will load templates lazily if
+// needed -- but you may want to if you want to make sure templates
+// exist before trying to expand them, or because you want to
+// control disk access patterns, or for some other reason.
+inline bool LoadTemplate(const TemplateString& filename, Strip strip) {
+ return mutable_default_template_cache()->LoadTemplate(filename, strip);
+}
+
+// Inserts the given string into the default template cache, as if
+// it were a file read from disk. You can call Expand() with its
+// first arg (filename) the same as the key you use here. You can
+// also use this key as the 'filename' for sub-included templates,
+// in TemplateDictionary::SetFilename().
+inline bool StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content,
+ Strip strip) {
+ return mutable_default_template_cache()->StringToTemplateCache(
+ key, content, strip);
+}
+inline bool StringToTemplateCache(const TemplateString& key,
+ const char* content, size_t content_len,
+ Strip strip) {
+ return mutable_default_template_cache()->StringToTemplateCache(
+ key, content, content_len, strip);
+}
+
+
+// ---------------------------------------------------------------------
+// The follow are deprecated.
+// TODO(csilvers): move to parsed_template.h
+
+// TemplateState of a template is:
+// - TS_EMPTY before parsing is complete,
+// - TS_ERROR if a syntax error was found during parsing, and
+// - TS_READY if parsing has completed successfully
+// (TS_UNUSED is not used)
+enum TemplateState { TS_UNUSED, TS_EMPTY, TS_ERROR, TS_READY };
+
+// Used for Auto-Escape. It represents the different contexts a template may
+// be initialized in via the AUTOESCAPE pragma in the template file
+// (or string). It is only public for testing. The contexts are:
+// - TC_HTML: The template contains HTML code. Need not be a complete HTML
+// page just content the browser interprets in the context of
+// HTML parsing. This should be the most common context to use.
+// This mode activates our HTML parser.
+// - TC_JS: The template contains raw javascript. If your template
+// starts with <script> tag, it is of type TC_HTML not TC_JS.
+// TC_JS is typically associated with a content-type of
+// text/javascript. This mode activates our HTML parser.
+// - TC_CSS: The template contains CSS (cascaded style-sheet). If your
+// template starts with a <style> tag, it is of type TC_HTML
+// not TC_CSS. A TC_CSS template is typically associated with a
+// text/css content-type header. Currently treated same as
+// TC_HTML but don't rely on that. We may later develop
+// CSS-specific sanitizers and parsers.
+// - TC_JSON: The template contains raw JSON. Applies javascript_escape
+// to variables. Note: javascript_escape is safer than
+// json_escape which we may want to remove.
+// - TC_XML: The template contains raw XML. Applies xml_escape to variables.
+// CAUTION: This mode is not suitable for cases where the
+// application data encapsulated in XML requires special
+// escaping, such as the case of XHTML.
+// TC_XML is typically associated with text/xml content-type.
+// - TC_MANUAL: Equivalent to not specifying auto-escaping at all.
+//
+// TODO(csilvers): Make this a private part of the Template class.
+enum TemplateContext { TC_UNUSED, TC_HTML, TC_JS, TC_CSS, TC_JSON,
+ TC_XML, TC_MANUAL };
+
+
+// This class is deprecated. Old code uses this class heavily (via
+// GetTemplate() to obtain a Template*, and then methods on that
+// Template*) but new code should use the free functions above.
+class CTEMPLATE_DLL_DECL Template {
+ public:
+ // ---- METHODS FOR TOOLS ----
+ // These are not intended for normal use, but are public so a
+ // tool can use them.
+
+ // Used by make_tpl_varnames_h.cc.
+ void WriteHeaderEntries(std::string *outstring) const;
+
+ // ---- DEPRECATED METHODS ----
+ // These methods used to be the primary way of using the Template
+ // object, but have been deprecated in favor of the (static)
+ // methods above. If you are using these deprecated methods,
+ // consider moving to the above methods instead, or to moving to
+ // using your own TemplateCache (which supports richer operations
+ // on parsed templates).
+
+ // Loads a template from disk or cache or string, and returns the Template*.
+ // INSTEAD, use the static Expand that takes a filename.
+ static Template *GetTemplate(const TemplateString& filename, Strip strip);
+ virtual ~Template(); // when the time comes to delete these Template*'s.
+
+ // Parses a string immediately and returns the resulting Template*.
+ // You can call the (deprecated) non-static Expand() method on this
+ // template in order to expand it with a dictionary. You are
+ // responsible for deleting the Template* when you are done with it.
+ // INSTEAD, use StringToTemplateCache (with a key) plus the static Expand().
+ // TOOO(csilvers): return a const Template* instead.
+ static Template* StringToTemplate(const TemplateString& content,
+ Strip strip);
+ static Template* StringToTemplate(const char* content, size_t content_len,
+ Strip strip) {
+ return StringToTemplate(TemplateString(content, content_len), strip);
+ }
+
+ // Non-static Expand*() works on a Template* returned from GetTemplate().
+ // INSTEAD, use static expand with a filename (or key-name for strings).
+ bool ExpandWithData(ExpandEmitter* output,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data) const {
+ return ExpandWithDataAndCache(output, dictionary, per_expand_data,
+ default_template_cache());
+ }
+ bool ExpandWithData(std::string* output_buffer,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data) const {
+ if (output_buffer == NULL) return false;
+ StringEmitter e(output_buffer);
+ return ExpandWithData(&e, dictionary, per_expand_data);
+ }
+ bool Expand(ExpandEmitter* output,
+ const TemplateDictionaryInterface* dictionary) const {
+ return ExpandWithData(output, dictionary, NULL);
+ }
+ bool Expand(std::string* output_buffer,
+ const TemplateDictionaryInterface* dictionary) const {
+ return ExpandWithData(output_buffer, dictionary, NULL);
+ }
+
+ // Dump to stdout or a string. filename is just used to annotate output.
+ void Dump(const char *filename) const;
+ void DumpToString(const char *filename, std::string *out) const;
+
+ // Retrieves the state, template-file, or strip mode of this Template.
+ TemplateState state() const;
+ const char *template_file() const;
+ const char *original_filename() const;
+ Strip strip() const;
+
+ // Work at the level of groups of templates, so just call through to
+ // the default TemplateCache; see template_cache.h for what these do.
+ // INSTEAD, create your own TemplateCache and call these methods on that.
+ static bool SetTemplateRootDirectory(const std::string& dir) {
+ return mutable_default_template_cache()->SetTemplateRootDirectory(dir);
+ }
+ static bool AddAlternateTemplateRootDirectory(const std::string& dir) {
+ return mutable_default_template_cache()->AddAlternateTemplateRootDirectory(
+ dir);
+ }
+ static std::string template_root_directory() {
+ return default_template_cache()->template_root_directory();
+ }
+ static std::string FindTemplateFilename(
+ const std::string& unresolved) {
+ return default_template_cache()->FindTemplateFilename(unresolved);
+ }
+ static void RemoveStringFromTemplateCache(const std::string& key) {
+ mutable_default_template_cache()->Delete(key);
+ }
+ static void ClearCache() {
+ mutable_default_template_cache()->ClearCache();
+ }
+ static void ReloadAllIfChanged() {
+ mutable_default_template_cache()->ReloadAllIfChanged(
+ TemplateCache::LAZY_RELOAD);
+ }
+
+ // ---- EXTRA-DEPRECATED METHODS ----
+ // These methods were deprecated even before the move to
+ // TemplateCache. We'd really like you to move from these to one
+ // of the "approved" methods, or even one of the deprecated
+ // methods. Comments here don't even describe what these
+ // functions do, just how to transition off of using them.
+
+ // INSTEAD, use the StringToTemplateCache function that takes the strip mode.
+ static bool StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content);
+ static bool StringToTemplateCache(const TemplateString& key,
+ const char* content, size_t content_len) {
+ return StringToTemplateCache(key, TemplateString(content, content_len));
+ }
+ // This is to prevent against typos: you want the global (free-function)
+ // StringToTemplateCache here, not the one in Template.
+ static bool StringToTemplateCache(const TemplateString& key,
+ const char* content, Strip);
+
+ // INSTEAD, use ReloadAllIfChanged.
+ bool ReloadIfChanged();
+
+ protected:
+ friend class SectionTemplateNode; // for access to set_state(), ParseState
+ friend class TemplateTemplateNode; // for recursive call to Expand()
+
+ // Template constructor
+ // Reads the template file and parses it into a parse tree of TemplateNodes
+ // by calling the method ReloadIfChanged
+ // The top node is a section node with the arbitrary name "__{{MAIN}}__"
+ // 'Strip' indicates how to handle whitespace when expanding the
+ // template. DO_NOT_STRIP keeps the template exactly as-is.
+ // STRIP_BLANK_LINES elides all blank lines in the template.
+ // STRIP_WHITESPACE elides all blank lines, and also all whitespace
+ // at either the beginning or end of a line. It also removes
+ // any linefeed (possibly following whitespace) that follows a closing
+ // '}}' of any kind of template marker EXCEPT a template variable.
+ // This means a linefeed may be removed anywhere by simply placing
+ // a comment marker as the last element on the line.
+ // These two options allow the template to include whitespace for
+ // readability without adding to the expanded output.
+ Template(const TemplateString& filename, Strip strip, TemplateCache* owner);
+
+ // MaybeInitHtmlParser
+ // In TemplateContexts where the HTML parser is needed, we
+ // initialize it in the appropriate mode. Also we do a sanity
+ // check (cannot fail) on the template filename. This function is
+ // called at most once for a Template. In_tag is only meaningful
+ // for TC_HTML: It is true for templates that start inside an HTML
+ // tag and hence are expected to contain HTML attribute name/value
+ // pairs only. It is false for standard HTML templates.
+ void MaybeInitHtmlParser(bool in_tag);
+
+ // BuildTree
+ // Parses the contents of the file (retrieved via ReloadIfChanged)
+ // and stores the resulting parse structure in tree_. Returns true
+ // iff the tree-builder encountered no errors. Note: takes
+ // ownership of input_buffer, and will delete it. It should have
+ // been created via new[].
+ bool BuildTree(const char *input_buffer, const char* input_buffer_end);
+
+ // Internal version of ReloadIfChanged, used when the function already
+ // has a write-lock on g_template_mutex.
+ bool ReloadIfChangedLocked();
+
+ // set_state
+ // Sets the state of the template. Used during BuildTree().
+ void set_state(TemplateState new_state);
+
+ // StripBuffer
+ // Modifies buffer in-place based on the strip_ mode, to remove
+ // extra whitespace. May delete[] the input buffer and replace
+ // it with a new buffer. Used by ReloadIfChanged().
+ void StripBuffer(char **buffer, size_t* len);
+
+ // The file we originally got from the Template() constructor
+ const std::string original_filename_;
+ // The pathname as fully resolved on the filesystem
+ std::string resolved_filename_;
+ time_t filename_mtime_; // lastmod time for filename last time we loaded it
+
+ // What to do with whitespace at template-expand time
+ Strip strip_;
+
+ // Keeps track of where we are in reloading, or if there was an error loading
+ TemplateState state_;
+
+ // The cache we got this template from. This is not well-defined: a
+ // Template can be in more than one cache.
+ // TODO(csilvers): remove this once we deprecate the one user, which
+ // is ReloadIfChanged.
+ TemplateCache* template_cache_;
+
+ // The current template-contents, as read from the file
+ const char* template_text_;
+ int template_text_len_;
+
+ // The current parsed template structure. Has pointers into template_text_.
+ class SectionTemplateNode *tree_; // defined in template.cc
+
+ // Template markers have the form {{VARIABLE}}, etc. These constants
+ // define the {{ and }} that delimit template markers.
+ struct CTEMPLATE_DLL_DECL MarkerDelimiters {
+ const char* start_marker;
+ size_t start_marker_len;
+ const char* end_marker;
+ size_t end_marker_len;
+
+ MarkerDelimiters() {
+ start_marker = "{{"; // The default start-marker
+ start_marker_len = strlen(start_marker);
+ end_marker = "}}";
+ end_marker_len = strlen(end_marker);
+ }
+ };
+
+ // The current parsing state. Used in BuildTree() and subroutines
+ struct CTEMPLATE_DLL_DECL ParseState {
+ const char* bufstart;
+ const char* bufend;
+ enum { PS_UNUSED, GETTING_TEXT, GETTING_NAME } phase;
+ MarkerDelimiters current_delimiters;
+ ParseState()
+ : bufstart(NULL), bufend(NULL), phase(PS_UNUSED), current_delimiters()
+ {}
+ };
+ ParseState parse_state_;
+
+ // All templates are initialized to TC_MANUAL (no Auto-Escape). Then,
+ // during template parsing (BuildTree()), if an AUTOESCAPE pragma is
+ // encountered, the context changes appropriately.
+ TemplateContext initial_context_;
+ // Non-null if the template was initialized in an Auto-Escape mode that
+ // requires a parser (currently TC_HTML, TC_CSS and TC_JS).
+ google_ctemplate_streamhtmlparser::HtmlParser *htmlparser_;
+
+ // A sorted list of trusted variable names, declared here because a unittest
+ // needs to verify that it is appropriately sorted (an unsorted array would
+ // lead to the binary search of this array failing).
+ static const char * const kSafeWhitelistedVariables[];
+ static const size_t kNumSafeWhitelistedVariables;
+
+ private:
+ friend class TemplateCache;
+ friend class TemplateCachePeer; // to access num_deletes_
+
+ // Internal implementation of Expand
+ bool ExpandWithDataAndCache(ExpandEmitter* output,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ const TemplateCache* cache) const;
+
+ // This is called for recursive expands, when we already hold template_lock.
+ bool ExpandLocked(ExpandEmitter* output,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ const TemplateCache* cache) const;
+
+ // Returns the lastmod time in mtime_
+ // For string-based templates, not backed by a file, this returns 0
+ time_t mtime() const;
+
+ // These are helper routines to StripFile. I would make them static
+ // inside template.cc, but they use the MarerDelimiters struct.
+ static bool ParseDelimiters(const char* text, size_t textlen,
+ MarkerDelimiters* delim);
+ static bool IsBlankOrOnlyHasOneRemovableMarker(const char** line, size_t* len,
+ const MarkerDelimiters& delim);
+ static size_t InsertLine(const char *line, size_t len, Strip strip,
+ const MarkerDelimiters& delim, char* buffer);
+
+ // This is only used by template_cache_test, via TemplateCachePeer.
+ static int num_deletes() { return num_deletes_; }
+
+ static int num_deletes_; // how many times the destructor has been called
+
+ // Can't invoke copy constructor or assignment operator
+ Template(const Template&);
+ void operator=(const Template &);
+};
+
+}
+
+
+#endif // CTEMPLATE_TEMPLATE_H_
diff --git a/src/windows/ctemplate/template_annotator.h b/src/windows/ctemplate/template_annotator.h
new file mode 100644
index 0000000..e7daf6d
--- /dev/null
+++ b/src/windows/ctemplate/template_annotator.h
@@ -0,0 +1,142 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// The template expansion system provides a set of hooks that allow for
+// the insertion of diagnostic content into the output stream for the use
+// by content developers and testers. For instance, the default text
+// annotation mode inserts strings bracketed by {{ }} to describe every
+// occurrence of a dynamic substitution feature. That mode turns the
+// rendering into a logical text description of the construction of
+// template-based output. It is useful for regression testing of output
+// in conjunction with text-based diffing tools.
+//
+// An annotation mode is implemented with the TemplateAnnotator interface.
+// When template annotation is turned on, then during template expansion
+// whenever a dynamic substitution feature is encountered, a call is made
+// to one of the TemplateAnnotator functions. In response to a call
+// an implementation can render any additional content into the passed
+// emitter, which is the same emitter that the rendering output is going
+// to.
+//
+// Template annotation is turned on and the template annotator subclass
+// set by methods in ctemplate::PerExpandData.
+
+#ifndef TEMPLATE_TEMPLATE_ANNOTATOR_H_
+#define TEMPLATE_TEMPLATE_ANNOTATOR_H_
+
+#include <string>
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+class ExpandEmitter;
+
+// This is the abstract interface for an annotation mode. A new annotation
+// mode is introduced by subclassing and implementing each function
+// to add annotation content. There is one function for each internal
+// template expansion event type. The emitter argument passed to the
+// function is the same stream that the expanding content is being output to;
+// so the action of an implementation will be to add additional inline
+// content. The emitter argument is never to be remembered beyond each
+// function call.
+class CTEMPLATE_DLL_DECL TemplateAnnotator {
+ public:
+ TemplateAnnotator() { }
+ virtual ~TemplateAnnotator() { }
+
+ // Called before processing a subtemplate include marker.
+ // Passed value is the include marker name.
+ virtual void EmitOpenInclude(ExpandEmitter* emitter, const std::string& value) = 0;
+ // Called after processing a subtemplate include marker.
+ virtual void EmitCloseInclude(ExpandEmitter* emitter) = 0;
+
+ // Called before opening a template or subtemplate file for processing.
+ // Passed value is the filename.
+ virtual void EmitOpenFile(ExpandEmitter* emitter, const std::string& value) = 0;
+ // Called after processing a template or subtemplate file.
+ virtual void EmitCloseFile(ExpandEmitter* emitter) = 0;
+
+ // Called before processing a section.
+ // Passed value is the section name.
+ virtual void EmitOpenSection(ExpandEmitter* emitter, const std::string& value) = 0;
+ // Called after processing a section.
+ virtual void EmitCloseSection(ExpandEmitter* emitter) = 0;
+
+ // Called before processing a variable marker.
+ // Passed value is the variable name.
+ virtual void EmitOpenVariable(ExpandEmitter* emitter,
+ const std::string& value) = 0;
+ // Called after processing a variable marker.
+ virtual void EmitCloseVariable(ExpandEmitter* emitter) = 0;
+
+ virtual void EmitFileIsMissing(ExpandEmitter* emitter,
+ const std::string& value) = 0;
+
+ private:
+ // Can't invoke copy constructor or assignment operator
+ TemplateAnnotator(const TemplateAnnotator&);
+ void operator=(const TemplateAnnotator&);
+};
+
+// This is a concrete template annotator class that inserts annotations
+// that have a standard text form bracketed by {{ }}. It is used as
+// the default annotation implementation when annotation is turned on
+// by PerExpandData and no annotator type is specified.
+class CTEMPLATE_DLL_DECL TextTemplateAnnotator : public TemplateAnnotator {
+ public:
+ TextTemplateAnnotator() { }
+ virtual void EmitOpenInclude(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseInclude(ExpandEmitter* emitter);
+ virtual void EmitOpenFile(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseFile(ExpandEmitter* emitter);
+ virtual void EmitOpenSection(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseSection(ExpandEmitter* emitter);
+ virtual void EmitOpenVariable(ExpandEmitter* emitter, const std::string& value);
+ virtual void EmitCloseVariable(ExpandEmitter* emitter);
+ virtual void EmitFileIsMissing(ExpandEmitter* emitter,
+ const std::string& value);
+
+ private:
+ // Can't invoke copy constructor or assignment operator
+ TextTemplateAnnotator(const TextTemplateAnnotator&);
+ void operator=(const TextTemplateAnnotator&);
+};
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_ANNOTATOR_H_
diff --git a/src/windows/ctemplate/template_cache.h b/src/windows/ctemplate/template_cache.h
new file mode 100644
index 0000000..2ee6b67
--- /dev/null
+++ b/src/windows/ctemplate/template_cache.h
@@ -0,0 +1,378 @@
+// Copyright (c) 2009, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// This file implements the Template Cache used to store templates.
+
+#ifndef TEMPLATE_TEMPLATE_CACHE_H_
+#define TEMPLATE_TEMPLATE_CACHE_H_
+
+#include <hash_map> // for stdext::hash_map<>
+#include <string> // for string
+#include <utility> // for pair
+#include <vector> // for vector<>
+#include <ctemplate/template_emitter.h> // for ExpandEmitter, etc
+#include <ctemplate/template_enums.h> // for Strip
+#include <ctemplate/template_string.h>
+#include <ctemplate/per_expand_data.h>
+namespace ctemplate {
+class FileStat;
+}
+class Mutex;
+class TemplateCacheUnittest;
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+extern template class __declspec(dllimport) std::allocator<std::string>;
+extern template class __declspec(dllimport) std::vector<std::string>;
+#else
+template class __declspec(dllexport) std::allocator<std::string>;
+template class __declspec(dllexport) std::vector<std::string>;
+#endif
+
+namespace ctemplate {
+
+class PerExpandData;
+class Template;
+class TemplateCachePeer;
+class TemplateDictionaryInterface;
+
+// A cache to store parsed templates.
+class CTEMPLATE_DLL_DECL TemplateCache {
+ public:
+ TemplateCache();
+ ~TemplateCache();
+
+ // ---- CREATING A TEMPLATE OBJECT -------
+ // LoadTemplate
+ // StringToTemplateCache
+
+ // Attempts to load the template object stored under its filename,
+ // into the template cache. It first checks if the object is already
+ // in the cache. Any object retrieved from the cache is then
+ // checked to see if its status is marked for "reload if changed."
+ // If so, ReloadIfChanged is called on the retrieved object. Returns
+ // true if the object is loaded. Also returns true if the object
+ // already exists, and no reload was required.
+ //
+ // When it fails to retrieve one from the cache, it creates a new
+ // template object, passing the filename and 'strip' values to the
+ // constructor. (See constructor below for the meaning of the
+ // flags.) If it succeeds in creating an object, including loading
+ // and parsing the associated template file, the object is stored in
+ // the cache, and the method returns true.
+ //
+ // If it fails in loading and parsing the template file, either
+ // because the file was not found or it contained syntax errors,
+ // then the newly created object is deleted and the method returns
+ // false. (NOTE: This description is much longer and less precise
+ // and probably harder to understand than the method itself. Read
+ // the code.)
+ //
+ // To enable Auto-Escape on that template, place the corresponding
+ // AUTOESCAPE pragma at the top of the template file. The template
+ // will then be Auto-Escaped independently of the template it may be
+ // included from or the templates it may include.
+ //
+ // 'Strip' indicates how to handle whitespace when expanding the
+ // template. DO_NOT_STRIP keeps the template exactly as-is.
+ // STRIP_BLANK_LINES elides all blank lines in the template.
+ // STRIP_WHITESPACE elides all blank lines, and also all whitespace
+ // at either the beginning or end of a line. See template constructor
+ // for more details.
+ bool LoadTemplate(const TemplateString& filename, Strip strip);
+
+ // Parses the string as a template file (e.g. "Hello {{WORLD}}"),
+ // and inserts it into the parsed template cache, so it can later be
+ // used by the user. The user specifies a key and a strip, which are
+ // later passed in to expand the template.
+ // Returns true if the template was successfully parsed and
+ // inserted to the template cache, or false otherwise. In particular,
+ // we return false if a string was already cached with the given key.
+ // NOTE: to include this template from within another template (via
+ // "{{>TEMPLATE_THAT_COMES_FROM_A_STRING}}"), the argument you pass
+ // to TemplateDictionary::SetFilename() is the key you used to register
+ // the string-template.
+ bool StringToTemplateCache(const TemplateString& key,
+ const TemplateString& content,
+ Strip strip);
+ bool StringToTemplateCache(const TemplateString& key,
+ const char* content,
+ size_t content_len,
+ Strip strip) {
+ return StringToTemplateCache(key,
+ TemplateString(content, content_len),
+ strip);
+ }
+
+ // ---- EXPANDING A TEMPLATE -------
+ // ExpandWithData
+ // ExpandFrozen
+
+ // This returns false if the expand failed for some reason: filename
+ // could not be found on disk (and isn't already in the cache), or
+ // the template is mal-formed, or a sub-included template couldn't
+ // be found. Note that even if it returns false, it may have emitted
+ // some output to ExpandEmitter, before it noticed the problem.
+ bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ ExpandEmitter* output);
+ bool ExpandWithData(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data,
+ std::string* output_buffer) {
+ if (output_buffer == NULL) return false;
+ StringEmitter e(output_buffer);
+ return ExpandWithData(filename, strip, dictionary, per_expand_data, &e);
+ }
+
+ // Const version of ExpandWithData, intended for use with frozen
+ // caches. This method returns false if the requested
+ // template-filename is not found in the cache, rather than fetching
+ // the template from disk and continuing, as ExpandWithData does.
+ // (That is why the method can be const.) Likewise, it will return
+ // false, rather than fetch, if any sub-included template filename
+ // is not found in the cache.
+ // Unfortunately, the only way to enforce this last requirement at
+ // the moment is to have the template-cache be Frozen(). So that
+ // is a pre-requisite for calling this method. It may be relaxed
+ // in the future (if we rewrite the control flow to pass around the
+ // necessary state).
+ // Like ExpandWithData(), this may write partial results into output
+ // even if it returns false (due to template error or file not found).
+ bool ExpandNoLoad(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data,
+ ExpandEmitter* output) const;
+ bool ExpandNoLoad(const TemplateString& filename, Strip strip,
+ const TemplateDictionaryInterface* dictionary,
+ PerExpandData* per_expand_data,
+ std::string* output_buffer) const {
+ if (output_buffer == NULL) return false;
+ StringEmitter e(output_buffer);
+ return ExpandNoLoad(filename, strip, dictionary, per_expand_data, &e);
+ }
+
+ // ---- FINDING A TEMPLATE FILE -------
+
+ // Sets the root directory for all templates used by the program.
+ // After calling this method, the filename passed to GetTemplate may
+ // be a relative pathname (no leading '/'), in which case this
+ // root-directory is prepended to the filename. This clears the old
+ // 'main' root directory, and also all alternate root directories
+ // that may had been added previously.
+ bool SetTemplateRootDirectory(const std::string& directory);
+
+ // Adds an additional search path for all templates used by the
+ // program. You may call this multiple times.
+ bool AddAlternateTemplateRootDirectory(const std::string& directory);
+
+ // Returns the 'main' root directory set by SetTemplateRootDirectory().
+ std::string template_root_directory() const;
+
+ // Given an unresolved filename, look through the template search
+ // path to see if the template can be found. If so, return the path
+ // of the resolved filename, otherwise return an empty string.
+ std::string FindTemplateFilename(const std::string& unresolved)
+ const;
+
+ // ---- MANAGING THE CACHE -------
+ // Freeze
+ // Delete
+ // ClearCache
+ // ReloadAllIfChanged
+ // Clone
+
+ // Marks the template cache as immutable. After this method is called,
+ // the cache can no longer be modified by loading new templates or
+ // reloading existing templates. During expansion only cached
+ // included templates will be used, they won't be loaded on-demand.
+ void Freeze();
+
+ // Delete
+ // Deletes one template object from the cache, if it exists.
+ // This can be used for either file- or string-based templates.
+ // Returns true if the object was deleted, false otherwise.
+ bool Delete(const TemplateString& key);
+
+ // ClearCache
+ // Deletes all the template objects in the cache and all raw
+ // contents cached from StringToTemplateCache. This should only
+ // be done once, just before exiting the program and after all
+ // template expansions are completed. (If you want to refresh the
+ // cache, the correct method to use is ReloadAllIfChanged, not
+ // this one.) Note: this method is not necessary unless you are
+ // testing for memory leaks. Calling this before exiting the
+ // program will prevent unnecessary reporting in that case.
+ void ClearCache();
+
+ // ReloadAllIfChanged
+ // If IMMEDIATE_RELOAD, reloads and parses all templates right away,
+ // if the corresponding template files have changed.
+ // If LAZY_RELOAD, then sets the reload bit on all templates.
+ // Subsequent call to GetTemplate() checks if file has changed, and if so
+ // reloads and parses the file into the cache.
+ //
+ // IMMEDIATE_RELOAD gives a more consistent snapshot of the current
+ // templates, since all templates in the cache are reloaded at
+ // (approximately) the same time. On the other hand, LAZY_RELOAD
+ // causes less of a latency spike, since it does not require
+ // loading lots of templates from disk at the same time. If in
+ // doubt, LAZY_RELOAD is probably a better choice.
+
+ // If a file with the same name as an existing template-file, is added
+ // in another search path, ReloadAllIfChanged will pick up the file in the
+ // earlier search-path.
+ enum ReloadType { LAZY_RELOAD, IMMEDIATE_RELOAD };
+ void ReloadAllIfChanged(ReloadType reload_tyle);
+
+ // Clone
+ // Returns a copy of the cache. It makes a shallow copy of the
+ // parsed_template_cache_, incrementing refcount of templates.
+ // The caller is responsible for deallocating the returned TemplateCache.
+ // NOTE(user): Annotalysis expects this method to have a lock for
+ // a TemplateCache instance local to the method, but we
+ // know that no other threads will have access to the
+ // instance, so ignore thread safety errors.
+ TemplateCache* Clone() const;
+
+ // ---- INSPECTING THE CACHE -------
+ // Dump
+ // DumpToString
+ // TODO(csilvers): implement these?
+
+ private:
+ // TODO(csilvers): nix Template friend once Template::ReloadIfChanged is gone
+ friend class Template; // for ResolveTemplateFilename
+ friend class TemplateTemplateNode; // for ExpandLocked
+ friend class TemplateCachePeer; // for unittests
+ friend class ::TemplateCacheUnittest; // for unittests
+
+ class RefcountedTemplate;
+ struct CachedTemplate;
+ class TemplateCacheHash;
+ class RefTplPtrHash;
+ // due to a bug(?) in MSVC, TemplateCachePeer won't compile unless this
+ // particular typedef is public. Ugh.
+ public:
+ typedef std::pair<TemplateId, int> TemplateCacheKey;
+ private:
+ typedef stdext::hash_map<TemplateCacheKey, CachedTemplate, TemplateCacheHash>
+ TemplateMap;
+ typedef stdext::hash_map<RefcountedTemplate*, int, RefTplPtrHash> TemplateCallMap;
+ // Where to search for files.
+ typedef std::vector<std::string> TemplateSearchPath;
+
+ // GetTemplate
+ // This method is deprecated. It exists here because it is called by
+ // Template::GetTemplate. Also this is used in tests.
+ const Template* GetTemplate(const TemplateString& key, Strip strip);
+
+ bool ResolveTemplateFilename(const std::string& unresolved,
+ std::string* resolved,
+ FileStat* statbuf) const;
+
+ // This is used only for internal (recursive) calls to Expand due
+ // to internal template-includes. It doesn't try to acquire the
+ // global template_lock again, in template.cc.
+ // TODO(csilvers): remove this when template.cc's g_template_lock goes away.
+ bool ExpandLocked(const TemplateString& filename, Strip strip,
+ ExpandEmitter* output,
+ const TemplateDictionaryInterface *dictionary,
+ PerExpandData* per_expand_data);
+
+ bool AddAlternateTemplateRootDirectoryHelper(
+ const std::string& directory,
+ bool clear_template_search_path);
+
+ // DoneWithGetTemplatePtrs
+ // For historical reasons, GetTemplate() returns a raw Template
+ // pointer rather than a refcounted pointer. So it's impossible
+ // for the user to call DecRef on the template when it's done
+ // using it. To make up for that, we provide this routine, which
+ // says "call DecRef()" on *all* Templates ever used by
+ // GetTemplate(). It's safe for the client to call this when it's
+ // done using all templates it's ever retrieved before (via
+ // GetTemplate). Most likely, the user will call this indirectly,
+ // via ClearCache().
+ // TODO(panicker): Consider making this method public.
+ void DoneWithGetTemplatePtrs();
+
+ // ValidTemplateFilename
+ // Validates the user provided filename before constructing the template
+ bool IsValidTemplateFilename(const std::string& filename,
+ std::string* resolved_filename,
+ FileStat* statbuf) const;
+
+ // GetTemplateLocked
+ // Internal version of GetTemplate. It's used when the function already
+ // has a write-lock on mutex_. It returns a pointer to a refcounted
+ // template (in the cache), or NULL if the template is not found.
+ // Its used by GetTemplate & ForceReloadAllIfChanged.
+ RefcountedTemplate* GetTemplateLocked(
+ const TemplateString& filename,
+ Strip strip,
+ const TemplateCacheKey& key);
+
+ // Refcount
+ // Testing only. Returns the refcount of a template, given its cache key.
+ int Refcount(const TemplateCacheKey template_cache_key) const;
+
+ // GetCachedTemplate
+ // Debug only. Returns whether the cache key is in the parsed cache.
+ bool TemplateIsCached(const TemplateCacheKey template_cache_key) const;
+
+ TemplateMap* parsed_template_cache_;
+ bool is_frozen_;
+ TemplateSearchPath search_path_;
+
+ // Since GetTemplate() returns a raw pointer, it's impossible for
+ // the caller to call DecRef() on the returned template when it's
+ // done using it. To make up for that, we store each retval of
+ // GetTemplate in this data structure. Then the user can call
+ // DecRef() on all of them at once, via a DoneWithGetTemplatePtrs()
+ // (which they will probably get at via a call to ClearCache()).
+ TemplateCallMap* get_template_calls_;
+
+ Mutex* const mutex_;
+ Mutex* const search_path_mutex_;
+
+ // Can't invoke copy constructor or assignment operator
+ TemplateCache(const TemplateCache&);
+ void operator=(const TemplateCache &);
+};
+
+}
+
+#endif // TEMPLATE_TEMPLATE_CACHE_H_
diff --git a/src/windows/ctemplate/template_dictionary.h b/src/windows/ctemplate/template_dictionary.h
new file mode 100644
index 0000000..c1f3869
--- /dev/null
+++ b/src/windows/ctemplate/template_dictionary.h
@@ -0,0 +1,464 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// Based on the 'old' TemplateDictionary by Frank Jernigan.
+//
+// A template dictionary maps names (as found in template files)
+// to their values. There are three types of names:
+// variables: value is a string.
+// sections: value is a list of sub-dicts to use when expanding the section;
+// the section is expanded once per sub-dict.
+// template-include: value is a list of pairs: name of the template file
+// to include, and the sub-dict to use when expanding it.
+// TemplateDictionary has routines for setting these values.
+//
+// For (many) more details, see the doc/ directory.
+
+#ifndef TEMPLATE_TEMPLATE_DICTIONARY_H_
+#define TEMPLATE_TEMPLATE_DICTIONARY_H_
+
+#include <stdarg.h> // for StringAppendV()
+#include <stddef.h> // for size_t and ptrdiff_t
+#include <stdlib.h> // for NULL
+#include <sys/types.h>
+#include <functional> // for less<>
+#include <map>
+#include <string>
+#include <vector>
+
+#include <ctemplate/str_ref.h>
+#include <ctemplate/template_dictionary_interface.h>
+#include <ctemplate/template_modifiers.h>
+#include <ctemplate/template_string.h>
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+template <class T, class C> class ArenaAllocator;
+class UnsafeArena;
+template<typename A, int B, typename C, typename D> class small_map;
+template<typename NormalMap> class small_map_default_init; // in small_map.h
+}
+
+namespace ctemplate {
+
+
+class CTEMPLATE_DLL_DECL TemplateDictionary : public TemplateDictionaryInterface {
+ public:
+ // name is used only for debugging.
+ // arena is used to store all names and values. It can be NULL (the
+ // default), in which case we create own own arena.
+ explicit TemplateDictionary(const TemplateString& name,
+ UnsafeArena* arena=NULL);
+ ~TemplateDictionary();
+
+ // If you want to be explicit, you can use NO_ARENA as a synonym to NULL.
+ static UnsafeArena* const NO_ARENA;
+
+ std::string name() const {
+ return std::string(name_.data(), name_.size());
+ }
+
+ // Returns a recursive copy of this dictionary. This dictionary
+ // *must* be a "top-level" dictionary (that is, not created via
+ // AddSectionDictionary() or AddIncludeDictionary()). Caller owns
+ // the resulting dict, and must delete it. If arena is NULL, we
+ // create our own. Returns NULL if the copy fails (probably because
+ // the "top-level" rule was violated).
+ TemplateDictionary* MakeCopy(const TemplateString& name_of_copy,
+ UnsafeArena* arena=NULL);
+
+ // --- Routines for VARIABLES
+ // These are the five main routines used to set the value of a variable.
+ // As always, wherever you see TemplateString, you can also pass in
+ // either a char* or a C++ string, or a TemplateString(s, slen).
+
+ void SetValue(const TemplateString variable, const TemplateString value);
+ void SetIntValue(const TemplateString variable, long value);
+ void SetFormattedValue(const TemplateString variable, const char* format, ...)
+#if 0
+ __attribute__((__format__ (__printf__, 3, 4)))
+#endif
+ ; // starts at 3 because of implicit 1st arg 'this'
+
+ class SetProxy {
+ public:
+ SetProxy(TemplateDictionary& dict, const TemplateString& variable) :
+ dict_(dict),
+ variable_(variable) {
+ }
+
+ void operator=(str_ref value) {
+ dict_.SetValue(variable_, TemplateString(value.data(), value.size()));
+ }
+
+ void operator=(long value) {
+ dict_.SetIntValue(variable_, value);
+ }
+
+ private:
+ TemplateDictionary& dict_;
+ const TemplateString& variable_;
+ };
+
+ SetProxy operator[](const TemplateString& variable) {
+ return SetProxy(*this, variable);
+ }
+
+ // We also let you set values in the 'global' dictionary which is
+ // referenced when all other dictionaries fail. Note this is a
+ // static method: no TemplateDictionary instance needed. Since
+ // this routine is rarely used, we don't provide variants.
+ static void SetGlobalValue(const TemplateString variable,
+ const TemplateString value);
+
+ // This is used for a value that you want to be 'global', but only
+ // in the scope of a given template, including all its sections and
+ // all its sub-included dictionaries. The main difference between
+ // SetTemplateGlobalValue() and SetValue(), is that
+ // SetTemplateGlobalValue() values persist across template-includes.
+ // This is intended for session-global data; since that should be
+ // fairly rare, we don't provide variants.
+ void SetTemplateGlobalValue(const TemplateString variable,
+ const TemplateString value);
+
+ // Similar SetTemplateGlobalValue above, this method shows a section in this
+ // template, all its sections, and all its template-includes. This is intended
+ // for session-global data, for example allowing you to show variant portions
+ // of your template for certain browsers/languages without having to call
+ // ShowSection on each template you use.
+ void ShowTemplateGlobalSection(const TemplateString variable);
+
+ // These routines are like SetValue and SetTemplateGlobalValue, but
+ // they do not make a copy of the input data. THE CALLER IS
+ // RESPONSIBLE FOR ENSURING THE PASSED-IN STRINGS LIVE FOR AT LEAST
+ // AS LONG AS THIS DICTIONARY! In general, they yield a quite minor
+ // performance increase for significant increased code fragility,
+ // so do not use them unless you really need the speed improvements.
+ void SetValueWithoutCopy(const TemplateString variable,
+ const TemplateString value);
+ void SetTemplateGlobalValueWithoutCopy(const TemplateString variable,
+ const TemplateString value);
+
+
+ // --- Routines for SECTIONS
+ // We show a section once per dictionary that is added with its name.
+ // Recall that lookups are hierarchical: if a section tried to look
+ // up a variable in its sub-dictionary and fails, it will look next
+ // in its parent dictionary (us). So it's perfectly appropriate to
+ // keep the sub-dictionary empty: that will show the section once,
+ // and take all var definitions from us. ShowSection() is a
+ // convenience routine that does exactly that.
+
+ // Creates an empty dictionary whose parent is us, and returns it.
+ // As always, wherever you see TemplateString, you can also pass in
+ // either a char* or a C++ string, or a TemplateString(s, slen).
+ TemplateDictionary* AddSectionDictionary(const TemplateString section_name);
+ void ShowSection(const TemplateString section_name);
+
+ // A convenience method. Often a single variable is surrounded by
+ // some HTML that should not be printed if the variable has no
+ // value. The way to do this is to put that html in a section.
+ // This method makes it so the section is shown exactly once, with a
+ // dictionary that maps the variable to the proper value. If the
+ // value is "", on the other hand, this method does nothing, so the
+ // section remains hidden.
+ void SetValueAndShowSection(const TemplateString variable,
+ const TemplateString value,
+ const TemplateString section_name);
+
+
+ // --- Routines for TEMPLATE-INCLUDES
+ // Included templates are treated like sections, but they require
+ // the name of the include-file to go along with each dictionary.
+
+ TemplateDictionary* AddIncludeDictionary(const TemplateString variable);
+
+ // This is required for include-templates; it specifies what template
+ // to include. But feel free to call this on any dictionary, to
+ // document what template-file the dictionary is intended to go with.
+ void SetFilename(const TemplateString filename);
+
+ // --- DEBUGGING TOOLS
+
+ // Logs the contents of a dictionary and its sub-dictionaries.
+ // Dump goes to stdout/stderr, while DumpToString goes to the given string.
+ // 'indent' is how much to indent each line of the output.
+ void Dump(int indent=0) const;
+ virtual void DumpToString(std::string* out, int indent=0) const;
+
+
+ // --- DEPRECATED ESCAPING FUNCTIONALITY
+
+ // Escaping in the binary has been deprecated in favor of using modifiers
+ // to do the escaping in the template:
+ // "...{{MYVAR:html_escape}}..."
+ void SetEscapedValue(const TemplateString variable, const TemplateString value,
+ const TemplateModifier& escfn);
+ void SetEscapedFormattedValue(const TemplateString variable,
+ const TemplateModifier& escfn,
+ const char* format, ...)
+#if 0
+ __attribute__((__format__ (__printf__, 4, 5)))
+#endif
+ ; // starts at 4 because of implicit 1st arg 'this'
+ void SetEscapedValueAndShowSection(const TemplateString variable,
+ const TemplateString value,
+ const TemplateModifier& escfn,
+ const TemplateString section_name);
+
+
+ private:
+ friend class SectionTemplateNode; // for access to GetSectionValue(), etc.
+ friend class TemplateTemplateNode; // for access to GetSectionValue(), etc.
+ friend class VariableTemplateNode; // for access to GetSectionValue(), etc.
+ // For unittesting code using a TemplateDictionary.
+ friend class TemplateDictionaryPeer;
+
+ class DictionaryPrinter; // nested class
+ friend class DictionaryPrinter;
+
+ // We need this functor to tell small_map how to create a map<> when
+ // it decides to do so: we want it to create that map on the arena.
+ class map_arena_init;
+
+ typedef std::vector<TemplateDictionary*,
+ ArenaAllocator<TemplateDictionary*, UnsafeArena> >
+ DictVector;
+ // The '4' here is the size where small_map switches from vector<> to map<>.
+ typedef small_map<std::map<TemplateId, TemplateString, std::less<TemplateId>,
+ ArenaAllocator<std::pair<const TemplateId, TemplateString>,
+ UnsafeArena> >,
+ 4, std::equal_to<TemplateId>, map_arena_init>
+ VariableDict;
+ typedef small_map<std::map<TemplateId, DictVector*, std::less<TemplateId>,
+ ArenaAllocator<std::pair<const TemplateId, DictVector*>,
+ UnsafeArena> >,
+ 4, std::equal_to<TemplateId>, map_arena_init>
+ SectionDict;
+ typedef small_map<std::map<TemplateId, DictVector*, std::less<TemplateId>,
+ ArenaAllocator<std::pair<const TemplateId, DictVector*>,
+ UnsafeArena> >,
+ 4, std::equal_to<TemplateId>, map_arena_init>
+ IncludeDict;
+ // This is used only for global_dict_, which is just like a VariableDict
+ // but does not bother with an arena (since this memory lives forever).
+ typedef small_map<std::map<TemplateId, TemplateString, std::less<TemplateId> >,
+ 4, std::equal_to<TemplateId>,
+ small_map_default_init<
+ std::map<TemplateId, TemplateString,
+ std::less<TemplateId> > > >
+ GlobalDict;
+
+
+ // These are helper functions to allocate the parts of the dictionary
+ // on the arena.
+ template<typename T> inline void LazilyCreateDict(T** dict);
+ inline void LazyCreateTemplateGlobalDict();
+ inline DictVector* CreateDictVector();
+ inline TemplateDictionary* CreateTemplateSubdict(
+ const TemplateString& name,
+ UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner);
+
+ // This is a helper function to insert <key,value> into m.
+ // Normally, we'd just use m[key] = value, but map rules
+ // require default constructor to be public for that to compile, and
+ // for some types we'd rather not allow that. HashInsert also inserts
+ // the key into an id(key)->key map, to allow for id-lookups later.
+ template<typename MapType, typename ValueType>
+ static void HashInsert(MapType* m, TemplateString key, ValueType value);
+
+ // Constructor created for all children dictionaries. This includes
+ // both a pointer to the parent dictionary and also the the
+ // template-global dictionary from which all children (both
+ // IncludeDictionary and SectionDictionary) inherit. Values are
+ // filled into global_template_dict via SetTemplateGlobalValue.
+ explicit TemplateDictionary(const TemplateString& name,
+ class UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner);
+
+ // Helps set up the static stuff. Must be called exactly once before
+ // accessing global_dict_. GoogleOnceInit() is used to manage that
+ // initialization in a thread-safe way.
+ static void SetupGlobalDict();
+
+ // Utility functions for copying a string into the arena.
+ // Memdup also copies in a trailing NUL, which is why we have the
+ // trailing-NUL check in the TemplateString version of Memdup.
+ TemplateString Memdup(const char* s, size_t slen);
+ TemplateString Memdup(const TemplateString& s) {
+ if (s.is_immutable() && s.data()[s.size()] == '\0') {
+ return s;
+ }
+ return Memdup(s.data(), s.size());
+ }
+
+ // Used for recursive MakeCopy calls.
+ TemplateDictionary* InternalMakeCopy(
+ const TemplateString& name_of_copy,
+ UnsafeArena* arena,
+ TemplateDictionary* parent_dict,
+ TemplateDictionary* template_global_dict_owner);
+
+ // A helper for creating section and include dicts.
+ static std::string CreateSubdictName(
+ const TemplateString& dict_name, const TemplateString& sub_name,
+ size_t index, const char* suffix);
+
+ // Must be called whenever we add a value to one of the dictionaries above,
+ // to ensure that we can reconstruct the id -> string mapping.
+ static void AddToIdToNameMap(TemplateId id, const TemplateString& str);
+
+ // Used to do the formatting for the SetFormatted*() functions
+ static int StringAppendV(char* space, char** out,
+ const char* format, va_list ap);
+
+ // How Template::Expand() and its children access the template-dictionary.
+ // These fill the API required by TemplateDictionaryInterface.
+ virtual TemplateString GetValue(const TemplateString& variable) const;
+ virtual bool IsHiddenSection(const TemplateString& name) const;
+ virtual bool IsUnhiddenSection(const TemplateString& name) const {
+ return !IsHiddenSection(name);
+ }
+ virtual bool IsHiddenTemplate(const TemplateString& name) const;
+ virtual const char* GetIncludeTemplateName(
+ const TemplateString& variable, int dictnum) const;
+
+ // Determine whether there's anything set in this dictionary
+ bool Empty() const;
+
+ // This is needed by DictionaryPrinter because it's not a friend
+ // of TemplateString, but we are
+ static std::string PrintableTemplateString(
+ const TemplateString& ts) {
+ return std::string(ts.data(), ts.size());
+ }
+ static bool InvalidTemplateString(const TemplateString& ts) {
+ return ts.data() == NULL;
+ }
+ // Compilers differ about whether nested classes inherit our friendship.
+ // The only thing DictionaryPrinter needs is IdToString, so just re-export.
+ static TemplateString IdToString(TemplateId id) { // for DictionaryPrinter
+ return TemplateString::IdToString(id);
+ }
+
+ // CreateTemplateIterator
+ // This is SectionIterator exactly, just with a different name to
+ // self-document the fact the value applies to a template include.
+ // Caller frees return value.
+ virtual TemplateDictionaryInterface::Iterator* CreateTemplateIterator(
+ const TemplateString& section_name) const;
+
+ // CreateSectionIterator
+ // Factory method implementation that constructs a iterator representing the
+ // set of dictionaries associated with a section name, if any. This
+ // implementation checks the local dictionary itself, not the template-wide
+ // dictionary or the global dictionary.
+ // Caller frees return value.
+ virtual TemplateDictionaryInterface::Iterator* CreateSectionIterator(
+ const TemplateString& section_name) const;
+
+ // TemplateDictionary-specific implementation of dictionary iterators.
+ template <typename T> // T is *TemplateDictionary::const_iterator
+ class Iterator : public TemplateDictionaryInterface::Iterator {
+ protected:
+ friend class TemplateDictionary;
+ Iterator(T begin, T end) : begin_(begin), end_(end) { }
+ public:
+ virtual ~Iterator() { }
+ virtual bool HasNext() const;
+ virtual const TemplateDictionaryInterface& Next();
+ private:
+ T begin_;
+ const T end_;
+ };
+
+ // A small helper factory function for Iterator
+ template <typename T>
+ static Iterator<typename T::const_iterator>* MakeIterator(const T& dv) {
+ return new Iterator<typename T::const_iterator>(dv.begin(), dv.end());
+ }
+
+
+ // The "name" of the dictionary for debugging output (Dump, etc.)
+ // The arena, also set at construction time.
+ class UnsafeArena* const arena_;
+ bool should_delete_arena_; // only true if we 'new arena' in constructor
+ TemplateString name_; // points into the arena, or to static memory
+
+ // The three dictionaries that I own -- for vars, sections, and template-incs
+ VariableDict* variable_dict_;
+ SectionDict* section_dict_;
+ IncludeDict* include_dict_;
+
+
+ // The template_global_dict is consulted if a lookup in the variable, section,
+ // or include dicts named above fails. It forms a convenient place to store
+ // session-specific data that's applicable to all templates in the dictionary
+ // tree.
+ // For the parent-template, template_global_dict_ is not NULL, and
+ // template_global_dict_owner_ is this. For all of its children,
+ // template_global_dict_ is NULL, and template_global_dict_owner_ points to
+ // the root parent-template (the one with the non-NULL template_global_dict_).
+ TemplateDictionary* template_global_dict_;
+ TemplateDictionary* template_global_dict_owner_;
+
+ // My parent dictionary, used when variable lookups at this level fail.
+ // Note this is only for *variables* and *sections*, not templates.
+ TemplateDictionary* parent_dict_;
+ // The static, global dictionary, at the top of the parent-dictionary chain
+ static GlobalDict* global_dict_;
+ static TemplateString* empty_string_; // what is returned on lookup misses
+
+ // The filename associated with this dictionary. If set, this declares
+ // what template the dictionary is supposed to be expanded with. Required
+ // for template-includes, optional (but useful) for 'normal' dicts.
+ const char* filename_;
+
+ private:
+ // Can't invoke copy constructor or assignment operator
+ TemplateDictionary(const TemplateDictionary&);
+ void operator=(const TemplateDictionary&);
+};
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_DICTIONARY_H_
diff --git a/src/windows/ctemplate/template_dictionary_interface.h b/src/windows/ctemplate/template_dictionary_interface.h
new file mode 100644
index 0000000..03bae41
--- /dev/null
+++ b/src/windows/ctemplate/template_dictionary_interface.h
@@ -0,0 +1,149 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: williasr@google.com (Scott Williams)
+//
+// This file implements the TemplateDictionaryInterface class. This interface
+// forms the root of the TemplateDictionary class tree, but the interface is
+// minimal enough to allow other sources of template data. Note that the
+// TemplateDictionaryInterface class enumerates the properties expected by
+// Template: it doesn't constrain how data gets into the
+// TemplateDictionaryInterface class to begin with. For these methods, see
+// TemplateDictionary.
+//
+
+#ifndef TEMPLATE_TEMPLATE_DICTIONARY_INTERFACE_H_
+#define TEMPLATE_TEMPLATE_DICTIONARY_INTERFACE_H_
+
+#include <stdlib.h>
+#include <string>
+#include <ctemplate/template_string.h>
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+const int kIndent = 2; // num spaces to indent each level -- used with dump
+
+// TemplateDictionaryInterface
+// The template data contains the associated values for
+// variables, the hidden/visible state for sections and included
+// templates, the associated set of dictionaries for sections and
+// included templates, and the template filenames to be expanded in
+// place of template-include nodes.
+class CTEMPLATE_DLL_DECL TemplateDictionaryInterface {
+ public:
+ // TemplateDictionaryInterface destructor
+ virtual ~TemplateDictionaryInterface() {}
+
+ protected:
+ // The interface as follows is used at expand-time by Expand.
+ friend class VariableTemplateNode;
+ friend class SectionTemplateNode;
+ friend class TemplateTemplateNode;
+ // This class reaches into our internals for testing.
+ friend class TemplateDictionaryPeer;
+ friend class TemplateDictionaryPeerIterator;
+
+ // GetSectionValue
+ // Returns the value of a variable.
+ virtual TemplateString GetValue(const TemplateString& variable) const = 0;
+
+ // IsHiddenSection
+ // A predicate to indicate the current hidden/visible state of a section
+ // whose name is passed to it.
+ virtual bool IsHiddenSection(const TemplateString& name) const = 0;
+
+ // Dump a string representation of this dictionary to the supplied string.
+ virtual void DumpToString(std::string* out, int level) const = 0;
+
+ // TemplateDictionaryInterface is an abstract class, so its constructor is
+ // only visible to its subclasses.
+ TemplateDictionaryInterface() {}
+
+ class Iterator {
+ protected:
+ Iterator() { }
+ public:
+ virtual ~Iterator() { }
+
+ // Returns false if the iterator is exhausted.
+ virtual bool HasNext() const = 0;
+
+ // Returns the current referent and increments the iterator to the next.
+ virtual const TemplateDictionaryInterface& Next() = 0;
+ };
+
+ // IsHiddenTemplate
+ // Returns true if the template include is hidden. This is analogous to
+ // IsHiddenSection, but for template nodes.
+ virtual bool IsHiddenTemplate(const TemplateString& name) const = 0;
+
+ // GetIncludeTemplateName
+ // Returns the name of the template associated with the given template
+ // include variable. If more than one dictionary is attached to the include
+ // symbol, dictnum can be used to disambiguate which include name you mean.
+ virtual const char* GetIncludeTemplateName(
+ const TemplateString& variable, int dictnum) const = 0;
+
+ // CreateTemplateIterator
+ // A factory method for constructing an iterator representing the
+ // subdictionaries of the given include node. The caller is
+ // responsible for deleting the return value when it's done with it.
+ virtual Iterator* CreateTemplateIterator(
+ const TemplateString& section) const = 0;
+
+ // CreateSectionIterator
+ // A factory method for constructing an iterator representing the
+ // subdictionaries of the given section node. The caller is
+ // responsible for deleting the return value when it's done with it.
+ virtual Iterator* CreateSectionIterator(
+ const TemplateString& section) const = 0;
+
+ // IsUnhiddenSection
+ // Returns true if the section has been marked visible and false otherwise.
+ virtual bool IsUnhiddenSection(
+ const TemplateString& name) const = 0;
+
+ private:
+ // Disallow copy and assign.
+ TemplateDictionaryInterface(const TemplateDictionaryInterface&);
+ void operator=(const TemplateDictionaryInterface&);
+};
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_DICTIONARY_INTERFACE_H_
diff --git a/src/windows/ctemplate/template_emitter.h b/src/windows/ctemplate/template_emitter.h
new file mode 100644
index 0000000..58d038a
--- /dev/null
+++ b/src/windows/ctemplate/template_emitter.h
@@ -0,0 +1,76 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// When we expand a template, we expand into an abstract "emitter".
+// This is typically a string, but could be a file-wrapper, or any
+// other data structure that supports this very simple "append" API.
+
+#ifndef TEMPLATE_TEMPLATE_EMITTER_H_
+#define TEMPLATE_TEMPLATE_EMITTER_H_
+
+#include <sys/types.h> // for size_t
+#include <string>
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+class CTEMPLATE_DLL_DECL ExpandEmitter {
+ public:
+ ExpandEmitter() {}
+ virtual ~ExpandEmitter() {}
+ virtual void Emit(char c) = 0;
+ virtual void Emit(const std::string& s) = 0;
+ virtual void Emit(const char* s) = 0;
+ virtual void Emit(const char* s, size_t slen) = 0;
+};
+
+
+class CTEMPLATE_DLL_DECL StringEmitter : public ExpandEmitter {
+ std::string* const outbuf_;
+ public:
+ StringEmitter(std::string* outbuf) : outbuf_(outbuf) {}
+ virtual void Emit(char c) { *outbuf_ += c; }
+ virtual void Emit(const std::string& s) { *outbuf_ += s; }
+ virtual void Emit(const char* s) { *outbuf_ += s; }
+ virtual void Emit(const char* s, size_t slen) { outbuf_->append(s, slen); }
+};
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_EMITTER_H_
diff --git a/src/windows/ctemplate/template_enums.h b/src/windows/ctemplate/template_enums.h
new file mode 100644
index 0000000..a240e75
--- /dev/null
+++ b/src/windows/ctemplate/template_enums.h
@@ -0,0 +1,47 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// Alas that we can't forward-declare enums! These are the ones
+// used by multiple files
+
+#ifndef TEMPLATE_TEMPLATE_ENUMS_H_
+#define TEMPLATE_TEMPLATE_ENUMS_H_
+
+namespace ctemplate {
+
+// Enums for GetTemplate flag values
+enum Strip { DO_NOT_STRIP, STRIP_BLANK_LINES, STRIP_WHITESPACE,
+ NUM_STRIPS }; // sentinel value
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_ENUMS_H_
diff --git a/src/windows/ctemplate/template_modifiers.h b/src/windows/ctemplate/template_modifiers.h
new file mode 100644
index 0000000..b981a60
--- /dev/null
+++ b/src/windows/ctemplate/template_modifiers.h
@@ -0,0 +1,357 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+//
+// We allow template variables to have modifiers, each possibly with a
+// value associated with it. Format is
+// {{VARNAME:modname[=modifier-value]:modname[=modifier-value]:...}}
+// Modname refers to a functor that takes the variable's value
+// and modifier-value (empty-string if no modifier-value was
+// specified), and returns a munged value. Modifiers are applied
+// left-to-right. We define the legal modnames here, and the
+// functors they refer to.
+//
+// Modifiers have a long-name, an optional short-name (one char;
+// may be \0 if you don't want a shortname), and a functor that's
+// applied to the variable.
+//
+// In addition to the list of modifiers hard-coded in the source code
+// here, it is possible to dynamicly register modifiers using a long
+// name starting with "x-". If you wish to define your own modifier
+// class, in your own source code, just subclass TemplateModifier --
+// see template_modifiers.cc for details of how to do that.
+//
+// Adding a new built-in modifier, to this file, takes several steps,
+// both in this .h file and in the corresponding .cc file:
+// 1) .h file: Define a struct for the modifier. It must subclass
+// TemplateModifier.
+// 2) .h file: declare a variable that's an instance of the struct.
+// This is used for people who want to modify the string themselves,
+// via TemplateDictionary::SetEscapedValue.
+// 5) .cc file: define the new modifier's Modify method.
+// 6) .cc file: give storage for the variable declared in the .h file (in 2).
+// 7) .cc file: add the modifier to the g_modifiers array.
+
+#ifndef TEMPLATE_TEMPLATE_MODIFIERS_H_
+#define TEMPLATE_TEMPLATE_MODIFIERS_H_
+
+#include <sys/types.h> // for size_t
+#include <string>
+#include <ctemplate/template_emitter.h> // so we can inline operator()
+#include <ctemplate/per_expand_data.h> // could probably just forward-declare
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+class Template;
+
+#define MODIFY_SIGNATURE_ \
+ public: \
+ virtual void Modify(const char* in, size_t inlen, \
+ const PerExpandData*, ExpandEmitter* outbuf, \
+ const std::string& arg) const
+
+// If you wish to write your own modifier, it should subclass this
+// method. Your subclass should only define Modify(); for efficiency,
+// we do not make operator() virtual.
+class CTEMPLATE_DLL_DECL TemplateModifier {
+ public:
+ // This function takes a string as input, a char*/size_t pair, and
+ // appends the modified version to the end of outbuf. In addition
+ // to the variable-value to modify (specified via in/inlen), each
+ // Modify passes in two pieces of user-supplied data:
+ // 1) arg: this is the modifier-value, for modifiers that take a
+ // value (e.g. "{{VAR:modifier=value}}"). This value
+ // comes from the template file. For modifiers that take
+ // no modval argument, arg will always be "". For modifiers
+ // that do take such an argument, arg will always start with "=".
+ // 2) per_expand_data: this is a set of data that the application can
+ // associate with a TemplateDictionary, and is passed in to
+ // every variable expanded using that dictionary. This value
+ // comes from the source code.
+ virtual void Modify(const char* in, size_t inlen,
+ const PerExpandData* per_expand_data,
+ ExpandEmitter* outbuf,
+ const std::string& arg) const = 0;
+
+ // This function can be used to speed up modification. If Modify()
+ // is often a noop, you can implement MightModify() to indicate
+ // situations where it's safe to avoid the call to Modify(), because
+ // Modify() won't do any modifications in this case. Note it's
+ // always safe to return true here; you should just return false if
+ // you're certain Modify() can be ignored. This function is
+ // advisory; the template system is not required to call
+ // MightModify() before Modify().
+ virtual bool MightModify(const PerExpandData* /*per_expand_data*/,
+ const std::string& /*arg*/) const {
+ return true;
+ }
+
+ // We support both modifiers that take an argument, and those that don't.
+ // We also support passing in a string, or a char*/int pair.
+ std::string operator()(const char* in, size_t inlen, const std::string& arg="") const {
+ std::string out;
+ // we'll reserve some space to account for minimal escaping: say 12%
+ out.reserve(inlen + inlen/8 + 16);
+ StringEmitter outbuf(&out);
+ Modify(in, inlen, NULL, &outbuf, arg);
+ return out;
+ }
+ std::string operator()(const std::string& in, const std::string& arg="") const {
+ return operator()(in.data(), in.size(), arg);
+ }
+
+ virtual ~TemplateModifier(); // always need a virtual destructor!
+};
+
+
+// Returns the input verbatim (for testing)
+class CTEMPLATE_DLL_DECL NullModifier : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL NullModifier null_modifier;
+
+// Escapes < > " ' & <non-space whitespace> to < > "
+// ' & <space>
+class CTEMPLATE_DLL_DECL HtmlEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL HtmlEscape html_escape;
+
+// Same as HtmlEscape but leaves all whitespace alone. Eg. for <pre>..</pre>
+class CTEMPLATE_DLL_DECL PreEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL PreEscape pre_escape;
+
+// Like HtmlEscape but allows HTML entities, <br> tags, <wbr> tags,
+// matched <b> and </b> tags, matched <i> and </i> tags, matched <em> and </em>
+// tags, and matched <span dir=(rtl|ltr)> tags.
+class CTEMPLATE_DLL_DECL SnippetEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL SnippetEscape snippet_escape;
+
+// Replaces characters not safe for an unquoted attribute with underscore.
+// Safe characters are alphanumeric, underscore, dash, period, and colon.
+// The equal sign is also considered safe unless it is at the start
+// or end of the input in which case it is replaced with underscore.
+//
+// We added the equal sign to the safe characters to allow this modifier
+// to be used on attribute name/value pairs in HTML tags such as
+// <div {{CLASS:H=attribute}}>
+// where CLASS is expanded to "class=bla".
+//
+// Note: The equal sign is replaced when found at either boundaries of the
+// string due to the concern it may be lead to XSS under some special
+// circumstances: Say, if this string is the value of an attribute in an
+// HTML tag and ends with an equal sign, a browser may possibly end up
+// interpreting the next token as the value of this string rather than
+// a new attribute (esoteric).
+class CTEMPLATE_DLL_DECL CleanseAttribute : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL CleanseAttribute cleanse_attribute;
+
+// Removes characters not safe for a CSS value. Safe characters are
+// alphanumeric, space, underscore, period, coma, exclamation mark,
+// pound, percent, and dash.
+class CTEMPLATE_DLL_DECL CleanseCss : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL CleanseCss cleanse_css;
+
+// Checks that a url is either an absolute http(s) URL or a relative
+// url that doesn't have a protocol hidden in it (ie [foo.html] is
+// fine, but not [javascript:foo]) and then performs another type of
+// escaping. Returns the url escaped with the specified modifier if
+// good, otherwise returns a safe replacement URL.
+// This is normally "#", but for <img> tags, it is not safe to set
+// the src attribute to "#". This is because this causes some browsers
+// to reload the page, which can cause a DoS.
+class CTEMPLATE_DLL_DECL ValidateUrl : public TemplateModifier {
+ public:
+ explicit ValidateUrl(const TemplateModifier& chained_modifier,
+ const char* unsafe_url_replacement)
+ : chained_modifier_(chained_modifier),
+ unsafe_url_replacement_(unsafe_url_replacement),
+ unsafe_url_replacement_length_(strlen(unsafe_url_replacement)) { }
+ MODIFY_SIGNATURE_;
+ static const char* const kUnsafeUrlReplacement;
+ static const char* const kUnsafeImgSrcUrlReplacement;
+ private:
+ const TemplateModifier& chained_modifier_;
+ const char* unsafe_url_replacement_;
+ int unsafe_url_replacement_length_;
+};
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_url_and_html_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_url_and_javascript_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_url_and_css_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_img_src_url_and_html_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_img_src_url_and_javascript_escape;
+extern CTEMPLATE_DLL_DECL ValidateUrl validate_img_src_url_and_css_escape;
+
+// Escapes < > & " ' to < > & " ' (same as in HtmlEscape).
+// If you use it within a CDATA section, you may be escaping more characters
+// than strictly necessary. If this turns out to be an issue, we will need
+// to add a variant just for CDATA.
+class CTEMPLATE_DLL_DECL XmlEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL XmlEscape xml_escape;
+
+// Escapes characters that cannot appear unescaped in a javascript string
+// assuming UTF-8 encoded input.
+// This does NOT escape all characters that cannot appear unescaped in a
+// javascript regular expression literal.
+class CTEMPLATE_DLL_DECL JavascriptEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL JavascriptEscape javascript_escape;
+
+// Checks that the input is a valid javascript non-string literal
+// meaning a boolean (true, false) or a numeric value (decimal, hex or octal).
+// If valid, we output the input as is, otherwise we output null instead.
+// Input of zero length is considered valid and nothing is output.
+//
+// The emphasis is on safety against injection of javascript code rather
+// than perfect validation, as such it is possible for non-valid literals to
+// pass through.
+//
+// You would use this modifier for javascript variables that are not
+// enclosed in quotes such as:
+// <script>var a = {{VALUE}};</script> OR
+// <a href="url" onclick="doSubmit({{ID}})">
+// For variables that are quoted (i.e. string literals) use javascript_escape.
+//
+// Limitations:
+// . NaN, +/-Infinity and null are not recognized.
+// . Output is not guaranteed to be a valid literal,
+// e.g: +55+-e34 will output as is.
+// e.g: trueeee will output nothing as it is not a valid boolean.
+//
+// Details:
+// . For Hex numbers, it checks for case-insensitive 0x[0-9A-F]+
+// that should be a proper check.
+// . For other numbers, it checks for case-insensitive [0-9eE+-.]*
+// so can also accept invalid numbers such as the number 5..45--10.
+// . "true" and "false" (without quotes) are also accepted and that's it.
+//
+class CTEMPLATE_DLL_DECL JavascriptNumber : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL JavascriptNumber javascript_number;
+
+// Escapes characters not in [0-9a-zA-Z.,_:*/~!()-] as %-prefixed hex.
+// Space is encoded as a +.
+class CTEMPLATE_DLL_DECL UrlQueryEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL UrlQueryEscape url_query_escape;
+
+// Escapes " \ / <FF> <CR> <LF> <BS> <TAB> to \" \\ \/ \f \r \n \b \t
+// Also escapes < > & to their corresponding \uXXXX representation
+// (\u003C, \u003E, \u0026 respectively).
+class CTEMPLATE_DLL_DECL JsonEscape : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL JsonEscape json_escape;
+
+// Inserts the given prefix (given as the argument to this modifier)
+// after every newline in the text. Note that it does *not* insert
+// prefix at the very beginning of the text -- in its expected use,
+// that prefix will already be present before this text, in the
+// template. This is meant to be used internally, and is not exported
+// via the g_modifiers list.
+class CTEMPLATE_DLL_DECL PrefixLine : public TemplateModifier {
+ MODIFY_SIGNATURE_;
+};
+extern CTEMPLATE_DLL_DECL PrefixLine prefix_line;
+
+
+#undef MODIFY_SIGNATURE_
+
+
+// Registers a new template modifier.
+// long_name must start with "x-".
+// If the modifier takes a value (eg "{{VAR:x-name=value}}"), then
+// long_name should end with "=". This is similar to getopt(3) syntax.
+// We also allow value-specializations, with specific values specified
+// as part of long-name. For instance:
+// AddModifier("x-mod=", &my_modifierA);
+// AddModifier("x-mod=bar", &my_modifierB);
+// AddModifier("x-mod2", &my_modifierC);
+// For the template
+// {{VAR1:x-mod=foo}} {{VAR2:x-mod=bar}} {{VAR3:x-mod=baz}} {{VAR4:x-mod2}}
+// VAR1 and VAR3 would get modified by my_modifierA, VAR2 by my_modifierB,
+// and VAR4 by my_modifierC. The order of the AddModifier calls is not
+// significant.
+extern CTEMPLATE_DLL_DECL
+bool AddModifier(const char* long_name, const TemplateModifier* modifier);
+
+// Same as AddModifier() above except that the modifier is considered
+// to produce safe output that can be inserted in any context without
+// the need for additional escaping. This difference only impacts
+// the Auto-Escape mode: In that mode, when a variable (or template-include)
+// has a modifier added via AddXssSafeModifier(), it is excluded from
+// further escaping, effectively treated as though it had the :none modifier.
+// Because Auto-Escape is disabled for any variable and template-include
+// that includes such a modifier, use this function with care and ensure
+// that it may not emit harmful output that could lead to XSS.
+//
+// Some valid uses of AddXssSafeModifier:
+// . A modifier that converts a string to an integer since
+// an integer is generally safe in any context.
+// . A modifier that returns one of a fixed number of safe values
+// depending on properties of the input.
+//
+// Some not recommended uses of AddXssSafeModifier:
+// . A modifier that applies some extra formatting to the input
+// before returning it since the output will still contain
+// harmful content if the input does.
+// . A modifier that applies one type of escaping to the input
+// (say HTML-escape). This may be dangerous when the modifier
+// is used in a different context (say Javascript) where this
+// escaping may be inadequate.
+extern CTEMPLATE_DLL_DECL
+bool AddXssSafeModifier(const char* long_name,
+ const TemplateModifier* modifier);
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_MODIFIERS_H_
diff --git a/src/windows/ctemplate/template_namelist.h b/src/windows/ctemplate/template_namelist.h
new file mode 100644
index 0000000..26bd03a
--- /dev/null
+++ b/src/windows/ctemplate/template_namelist.h
@@ -0,0 +1,169 @@
+// Copyright (c) 2006, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+//
+// This class implements some template helper classes, that manage
+// template files and make it easier to monitor them.
+//
+// For information about how to use these classes and macros, and to
+// write the templates it takes as input,
+// see the doc/ directory.
+
+#ifndef TEMPLATE_TEMPLATE_NAMELIST_H_
+#define TEMPLATE_TEMPLATE_NAMELIST_H_
+
+#include <time.h> // for time_t
+#include <hash_set>
+#include <string>
+#include <vector>
+#include <ctemplate/template_enums.h> // for Strip
+#include <ctemplate/template_string.h> // for StringHash
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+// RegisterTemplateFilename
+// Used to define a reference variable for the name of a template file. E.g:
+// RegisterTemplateFilename(EXAMPLE_FN, "example.tpl");
+// This should be used rather than the seemingly equivalent:
+// #define EXAMPLE_FN "example.tpl"
+// As in the latter, any call to GetTemplate may then reference the name
+// via the first argument. In the example, that would be:
+// Template::GetTemplate(EXAMPLE_FN, DO_NOT_STRIP);
+// By using this macro, rather than the #define, all templates can
+// later be tested for either existence or correct syntax after program
+// start-up.
+// TODO (we wish): Make this macro produce the #include for the auto-generated
+// header files, when and if the macro pre-processor supports that
+#define RegisterTemplateFilename(var, name) \
+ const char* const var = ctemplate::TemplateNamelist::RegisterTemplate(name);
+
+// Class: TemplateNamelist
+// Each time this class is instantiated, the name passed to
+// the constructor is added to the class's static list of names. The
+// entire list may be retrieved later by calling the GetList accessor
+// method. Or they may all be checked for existence or for correct
+// syntax via the other methods. We use this in our
+// sanity-checking code to make sure all the templates used by a program
+// exist and are syntactically correct.
+
+class CTEMPLATE_DLL_DECL TemplateNamelist {
+ friend class TemporaryRegisterTemplate;
+ public:
+ // These types should be taken as 'generic' containers. The only
+ // thing you should do with them is call size() and/or iterate
+ // between begin() and end(), and the only operations we promise
+ // the iterators will support are operator* and operator++.
+ typedef stdext::hash_set<std::string, StringHash> NameListType;
+ typedef std::vector<std::string> MissingListType;
+ typedef std::vector<std::string> SyntaxListType;
+
+ public:
+ // Takes a name and pushes it onto the static namelist
+ // Returns: a pointer to the entry in namelist which holds the name
+ static const char* RegisterTemplate(const char* name);
+
+ // GetList
+ // Description: Returns the collected list of names.
+ static const NameListType& GetList();
+
+ // GetMissingList
+ // If refresh is true or if it is the first time the function is called
+ // in the execution of the program, it creates (or clears) the missing
+ // list and then fills it with the list of
+ // templates that the program knows about but are missing from
+ // the template directory.
+ // If refresh is false and it is not the first time the function is
+ // called, it merely returns the list created in the
+ // call when the last refresh was done.
+ // NOTE: The templates are NOT read, parsed, or cached
+ // by this function.
+ static const MissingListType& GetMissingList(bool refresh);
+
+ // GetBadSyntaxList
+ // If refresh is true or if it is the first time the function is called
+ // in the execution of the program, it creates (or clears) the "bad
+ // syntax" list and then fills it with the list of
+ // templates that the program knows about but contain syntax errors.
+ // A missing file is not considered a syntax error, and thus is
+ // not included in this list.
+ // If refresh is false and it is not the first time the function is
+ // called, it merely returns the list created in the
+ // call when the last refresh was done.
+ // NOTE: The side effect of calling this the first time or
+ // with refresh equal true is that all templates are parsed and cached.
+ // Hence they need to be retrieved with the flags that
+ // the program needs them loaded with (i.e, the strip parameter
+ // passed to Template::GetTemplate.)
+ static const SyntaxListType& GetBadSyntaxList(bool refresh, Strip strip);
+
+ // GetLastmodTime
+ // Iterates through all non-missing templates, and returns the latest
+ // last-modification time for the template files, as returned by stat().
+ // This can be used to make sure template files are getting refreshed.
+ static time_t GetLastmodTime();
+
+ // AllDoExist
+ // Retrieves the missing list (always refreshing the list)
+ // and returns true if it contains any names.
+ // Else, returns false.
+ static bool AllDoExist();
+
+ // IsAllSyntaxOkay
+ // Retrieves the "bad syntax" list (always refreshing the list)
+ // and returns true if it contains any names.
+ // Else, returns false.
+ // NOTE: The side effect of calling this is that all templates are parsed
+ // and cached, hence they need to be retrieved with the flags that
+ // the program needs them loaded with. (I.e, the strip parameter
+ // ultimately passed to Template::GetTemplate.)
+ static bool IsAllSyntaxOkay(Strip strip);
+
+ protected:
+ // The static list of names
+ static NameListType *namelist_;
+ static MissingListType *missing_list_;
+ static SyntaxListType *bad_syntax_list_;
+
+ private:
+ TemplateNamelist(const TemplateNamelist&); // disallow copying
+ void operator=(const TemplateNamelist&);
+};
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_NAMELIST_H_
diff --git a/src/windows/ctemplate/template_pathops.h b/src/windows/ctemplate/template_pathops.h
new file mode 100644
index 0000000..79f7bf7
--- /dev/null
+++ b/src/windows/ctemplate/template_pathops.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2007, Google Inc.
+// 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 Google Inc. 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.
+
+// ---
+// Author: csilvers@google.com (Craig Silverstein)
+
+#ifndef TEMPLATE_TEMPLATE_PATHOPS_H_
+#define TEMPLATE_TEMPLATE_PATHOPS_H_
+
+#include <string>
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+extern CTEMPLATE_DLL_DECL
+const char kCWD[]; // a string that's equivalent to "./"
+extern CTEMPLATE_DLL_DECL
+const char kRootdir[]; // a string that's equivalent to "/"
+
+extern CTEMPLATE_DLL_DECL
+std::string PathJoin(const std::string& a, const std::string& b);
+
+extern CTEMPLATE_DLL_DECL
+bool IsAbspath(const std::string& path);
+
+extern CTEMPLATE_DLL_DECL
+bool IsDirectory(const std::string& path); // checks if path ends with /
+
+extern CTEMPLATE_DLL_DECL
+void NormalizeDirectory(std::string* dir); // adds trailing / if needed
+
+extern CTEMPLATE_DLL_DECL
+std::string Basename(const std::string& path); // everything after last /
+
+// Returns true iff text contains the word as a full word, i.e. delimited by one
+// of [.,_-#*?:] on both the sides.
+// This is used while loading a template, to check that the file's name matches
+// the auto-escape mode specified by it.
+// NOTE: This assumes that the word doesn't contain any of the delimiter
+// characters.
+extern CTEMPLATE_DLL_DECL
+bool ContainsFullWord(const std::string& text, const std::string& word);
+
+}
+
+#endif // TEMPLATE_TEMPLATE_PATHOPS_H_
diff --git a/src/windows/ctemplate/template_string.h b/src/windows/ctemplate/template_string.h
new file mode 100644
index 0000000..f1bd38b
--- /dev/null
+++ b/src/windows/ctemplate/template_string.h
@@ -0,0 +1,363 @@
+// Copyright (c) 2008, Google Inc.
+// 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 Google Inc. 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.
+//
+// ---
+// Author: csilvers@google.com (Craig Silerstein)
+
+#ifndef TEMPLATE_TEMPLATE_STRING_H_
+#define TEMPLATE_TEMPLATE_STRING_H_
+
+#include <string.h> // for memcmp() and size_t
+#include <hash_map>
+#include <string>
+#include <vector>
+
+#include <assert.h>
+#if 0
+#include <stdint.h> // one place @ac_cv_unit64@ might live
+#endif
+#if 0
+#include <inttypes.h> // another place @ac_cv_unit64@ might live
+#endif
+#include <sys/types.h> // final place @ac_cv_unit64@ might live
+
+class TemplateStringTest; // needed for friendship declaration
+class StaticTemplateStringTest;
+
+#if 0
+extern char _start[] __attribute__((weak)); // linker emits: start of .text
+extern char data_start[] __attribute__((weak)); // start of .data
+#endif
+
+// NOTE: if you are statically linking the template library into your binary
+// (rather than using the template .dll), set '/D CTEMPLATE_DLL_DECL='
+// as a compiler flag in your project file to turn off the dllimports.
+#ifndef CTEMPLATE_DLL_DECL
+# define CTEMPLATE_DLL_DECL __declspec(dllimport)
+#endif
+
+namespace ctemplate {
+
+// Most methods of TemplateDictionary take a TemplateString rather than a
+// C++ string. This is for efficiency: it can avoid extra string copies.
+// For any argument that takes a TemplateString, you can pass in any of:
+// * A C++ string
+// * A char*
+// * A StringPiece
+// * TemplateString(char*, length)
+// The last of these is the most efficient, though it requires more work
+// on the call site (you have to create the TemplateString explicitly).
+class TemplateString;
+
+// If you have a string constant (e.g. the string literal "foo") that
+// you need to pass into template routines repeatedly, it is more
+// efficient if you convert it into a TemplateString only once. The
+// way to do this is to use a global StaticTemplateString via STS_INIT
+// (note: do this at global scope *only*!):
+// static const StaticTemplateString kMyVar = STS_INIT(kMyVar, "MY_VALUE");
+struct StaticTemplateString;
+
+#define STS_INIT(name, str) STS_INIT_WITH_HASH(name, str, 0)
+
+// Let's define a convenient hash_compare function for hashing 'normal'
+// strings: char* and string. We'll use MurmurHash, which is probably
+// better than the STL default. We don't include TemplateString or
+// StaticTemplateString here, since they are hashed more efficiently
+// based on their id.
+struct CTEMPLATE_DLL_DECL StringHash {
+ inline size_t operator()(const char* s) const {
+ return Hash(s, strlen(s));
+ };
+
+ inline size_t operator()(const std::string& s) const {
+ return Hash(s.data(), s.size());
+ }
+
+ inline bool operator()(const char* a, const char* b) const {
+ return (a != b) && (strcmp(a, b) < 0); // <, for MSVC
+ }
+
+ inline bool operator()(const std::string& a, const std::string& b) const {
+ return a < b;
+ }
+
+ static const size_t bucket_size = 4; // These are required by MSVC
+ static const size_t min_buckets = 8; // 4 and 8 are the defaults
+ private:
+ size_t Hash(const char* s, size_t slen) const;
+};
+
+// ----------------------- THE CLASSES -------------------------------
+
+typedef unsigned __int64 TemplateId;
+
+const TemplateId kIllegalTemplateId = 0;
+
+struct CTEMPLATE_DLL_DECL StaticTemplateString {
+ // Do not define a constructor! We use only brace-initialization,
+ // so the data is constructed at static-initialization time.
+ // Anything you want to put in a constructor, put in
+ // StaticTemplateStringInitializer instead.
+
+ // These members shouldn't be accessed directly, except in the
+ // internals of the template code. They are public because that is
+ // the only way we can brace-initialize them. NOTE: MSVC (at least
+ // up to 8.0) has a bug where it ignores 'mutable' when it's buried
+ // in an internal struct. To fix that, we have to make this whole
+ // internal struct mutable. We only do this on MSVC, so on other
+ // compilers we get the full constness we want.
+#ifdef _MSC_VER
+ mutable
+#endif
+ struct {
+ const char* ptr_;
+ size_t length_;
+ mutable TemplateId id_; // sometimes lazily-initialized.
+ } do_not_use_directly_;
+
+ // This class is a good hash_compare functor to pass in as the third
+ // argument to stdext::hash_map<>, when creating a map whose keys are
+ // StaticTemplateString. NOTE: This class isn't that safe to use,
+ // because it requires that StaticTemplateStringInitializer has done
+ // its job. Unfortunately, even when you use the STS_INIT macro
+ // (which is always, right??), dynamic initialiation does not happen
+ // in a particular order, and objects in different .cc files may
+ // reference a StaticTemplateString before the corresponding
+ // StaticTemplateStringInitializer sets the id.
+ struct Hasher {
+ inline size_t operator()(const StaticTemplateString& sts) const;
+ inline bool operator()(const StaticTemplateString& a, // <, for MSVC
+ const StaticTemplateString& b) const;
+ static const size_t bucket_size = 4; // These are required by MSVC
+ static const size_t min_buckets = 8; // 4 and 8 are the defaults
+ };
+
+ inline bool empty() const {
+ return do_not_use_directly_.length_ == 0;
+ }
+
+ // Allows comparisons of StaticTemplateString objects as if they were
+ // strings. This is useful for STL.
+ inline bool operator==(const StaticTemplateString& x) const;
+};
+
+class CTEMPLATE_DLL_DECL TemplateString {
+ public:
+ TemplateString(const char* s)
+ : ptr_(s ? s : ""), length_(strlen(ptr_)),
+ is_immutable_(InTextSegment(ptr_)), id_(kIllegalTemplateId) {
+ }
+ TemplateString(const std::string& s)
+ : ptr_(s.data()), length_(s.size()),
+ is_immutable_(false), id_(kIllegalTemplateId) {
+ }
+ TemplateString(const char* s, size_t slen)
+ : ptr_(s), length_(slen),
+ is_immutable_(InTextSegment(s)), id_(kIllegalTemplateId) {
+ }
+ TemplateString(const StaticTemplateString& s)
+ : ptr_(s.do_not_use_directly_.ptr_),
+ length_(s.do_not_use_directly_.length_),
+ is_immutable_(true), id_(s.do_not_use_directly_.id_) {
+ }
+
+ const char* begin() const {
+ return ptr_;
+ }
+
+ const char* end() const {
+ return ptr_ + length_;
+ }
+
+ const char* data() const {
+ return ptr_;
+ }
+
+ size_t size() const {
+ return length_;
+ }
+
+ inline bool empty() const {
+ return length_ == 0;
+ };
+
+ inline bool is_immutable() const {
+ return is_immutable_;
+ }
+
+ // STL requires this to be public for hash_map, though I'd rather not.
+ inline bool operator==(const TemplateString& x) const {
+ return GetGlobalId() == x.GetGlobalId();
+ }
+
+ private:
+ // Only TemplateDictionaries and template expansion code can read these.
+ friend class TemplateDictionary;
+ friend class TemplateCache; // for GetGlobalId
+ friend class StaticTemplateStringInitializer; // for AddToGlo...
+ friend struct TemplateStringHasher; // for GetGlobalId
+ friend TemplateId GlobalIdForTest(const char* ptr, int len);
+ friend TemplateId GlobalIdForSTS_INIT(const TemplateString& s);
+
+ TemplateString(const char* s, size_t slen, bool is_immutable, TemplateId id)
+ : ptr_(s), length_(slen), is_immutable_(is_immutable), id_(id) {
+ }
+
+ // This returns true if s is in the .text segment of the binary.
+ // (Note this only checks .text of the main executable, not of
+ // shared libraries. So it may not be all that useful.)
+ // This requires the gnu linker (and probably elf), to define
+ // _start and data_start.
+ static bool InTextSegment(const char* s) {
+#if 0
+ return (s >= _start && s < data_start); // in .text
+#else
+ return false; // the conservative choice: assume it's not static memory
+#endif
+ }
+
+ protected:
+ inline void CacheGlobalId() { // used by HashedTemplateString
+ id_ = GetGlobalId();
+ };
+
+ private:
+ // Returns the global id, computing it for the first time if
+ // necessary. Note that since this is a const method, we don't
+ // store the computed value in id_, even if id_ is 0.
+ TemplateId GetGlobalId() const;
+ // Adds this TemplateString to the map from global-id to name.
+ void AddToGlobalIdToNameMap();
+
+ // Use sparingly. Converting to a string loses information about the
+ // id of the template string, making operations require extra hash_compare
+ // computations.
+ std::string ToString() const { return std::string(ptr_, length_); }
+
+ // Does the reverse map from TemplateId to TemplateString contents.
+ // Returns a TemplateString(kStsEmpty) if id isn't found. Note that
+ // the TemplateString returned is not necessarily NUL terminated.
+ static TemplateString IdToString(TemplateId id);
+
+ const char* ptr_;
+ size_t length_;
+ // Do we need to manage memory for this string?
+ bool is_immutable_;
+ // Id for hash_compare lookups. If 0, we don't have one and it should be
+ // computed as-needed.
+ TemplateId id_;
+};
+
+// ----------------------- THE CODE -------------------------------
+
+// Use the low-bit from TemplateId as the "initialized" flag. Note
+// that since all initialized TemplateId have the lower bit set, it's
+// safe to have used 0 for kIllegalTemplateId, as we did above.
+const TemplateId kTemplateStringInitializedFlag = 1;
+
+inline bool IsTemplateIdInitialized(TemplateId id) {
+ return id & kTemplateStringInitializedFlag;
+}
+
+// This is a helper struct used in TemplateString::Hasher/TemplateStringHasher
+struct TemplateIdHasher {
+ size_t operator()(TemplateId id) const {
+ // The shift has two effects: it randomizes the "initialized" flag,
+ // and slightly improves the randomness of the low bits. This is
+ // slightly useful when size_t is 32 bits, or when using a small
+ // hash_compare tables with power-of-2 sizes.
+ return static_cast<size_t>(id ^ (id >> 33));
+ }
+ bool operator()(TemplateId a, TemplateId b) const { // <, for MSVC
+ return a < b;
+ }
+ static const size_t bucket_size = 4; // These are required by MSVC
+ static const size_t min_buckets = 8; // 4 and 8 are the defaults
+};
+
+
+inline size_t StaticTemplateString::Hasher::operator()(
+ const StaticTemplateString& sts) const {
+ TemplateId id = sts.do_not_use_directly_.id_;
+ assert(IsTemplateIdInitialized(id));
+ return TemplateIdHasher()(id);
+}
+
+inline bool StaticTemplateString::Hasher::operator()(
+ const StaticTemplateString& a, const StaticTemplateString& b) const {
+ TemplateId id_a = a.do_not_use_directly_.id_;
+ TemplateId id_b = b.do_not_use_directly_.id_;
+ assert(IsTemplateIdInitialized(id_a));
+ assert(IsTemplateIdInitialized(id_b));
+ return TemplateIdHasher()(id_a, id_b);
+}
+
+inline bool StaticTemplateString::operator==(
+ const StaticTemplateString& x) const {
+ return (do_not_use_directly_.length_ == x.do_not_use_directly_.length_ &&
+ (do_not_use_directly_.ptr_ == x.do_not_use_directly_.ptr_ ||
+ memcmp(do_not_use_directly_.ptr_, x.do_not_use_directly_.ptr_,
+ do_not_use_directly_.length_) == 0));
+}
+
+// We set up as much of StaticTemplateString as we can at
+// static-initialization time (using brace-initialization), but some
+// things can't be set up then. This class is for those things; it
+// runs at dynamic-initialization time. If you add logic here, only
+// do so as an optimization: this may be called rather late (though
+// before main), so other code should not depend on this being called
+// before them.
+class CTEMPLATE_DLL_DECL StaticTemplateStringInitializer {
+ public:
+ // This constructor operates on a const StaticTemplateString - we should
+ // only change those things that are mutable.
+ explicit StaticTemplateStringInitializer(const StaticTemplateString* sts);
+};
+
+// Don't use this. This is used only in auto-generated .varnames.h files.
+#define STS_INIT_WITH_HASH(name, str, hash_compare) \
+ { { str, sizeof(""str"")-1, hash_compare } }; \
+ namespace ctemplate_sts_init { \
+ static const ctemplate::StaticTemplateStringInitializer name##_init(&name); \
+ }
+
+// We computed this hash_compare value for the empty string online. In debug
+// mode, we verify it's correct during runtime (that is, that we
+// verify the hash_compare function used by make_tpl_varnames_h hasn't changed
+// since we computed this number). Note this struct is logically
+// static, but since it's in a .h file, we don't say 'static' but
+// instead rely on the linker to provide the POD-with-internal-linkage
+// magic.
+const StaticTemplateString kStsEmpty =
+ STS_INIT_WITH_HASH(kStsEmpty, "", 1457976849674613049ULL);
+
+}
+
+
+#endif // TEMPLATE_TEMPLATE_STRING_H_
diff --git a/src/windows/port.cc b/src/windows/port.cc
new file mode 100644
index 0000000..73bb580
--- /dev/null
+++ b/src/windows/port.cc
@@ -0,0 +1,117 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ *
+ * ---
+ * Author: Craig Silverstein
+ */
+
+#include "windows/config.h"
+#ifndef _WIN32
+# error You should only be including windows/port.cc in a windows environment!
+#endif
+
+#include <stdarg.h> // for va_list, va_start, va_end
+#include <string.h> // for strstr()
+#include <assert.h>
+#include "port.h"
+
+// These call the windows _vsnprintf, but always NUL-terminate.
+#if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */
+int safe_vsnprintf(char *str, size_t size, const char *format, va_list ap) {
+ if (size == 0) // not even room for a \0?
+ return -1; // not what C99 says to do, but what windows does
+ str[size-1] = '\0';
+ return _vsnprintf(str, size-1, format, ap);
+}
+
+int snprintf(char *str, size_t size, const char *format, ...) {
+ int r;
+ va_list ap;
+ va_start(ap, format);
+ r = vsnprintf(str, size, format, ap);
+ va_end(ap);
+ return r;
+}
+#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */
+
+#ifdef __cplusplus
+#include <string>
+#include <vector>
+#include <ctemplate/template_pathops.h>
+
+using std::string;
+using std::vector;
+
+namespace ctemplate {
+
+// defined (for unix) in template_test_utils.cc
+string TmpFile(const char* basename) {
+ char tmppath_buffer[1024];
+ int tmppath_len = GetTempPathA(sizeof(tmppath_buffer), tmppath_buffer);
+ if (tmppath_len <= 0 || tmppath_len >= sizeof(tmppath_buffer)) {
+ return basename; // an error, so just bail on tmppath
+ }
+ assert(tmppath_buffer[tmppath_len - 1] == '\\'); // API guarantees it
+ return string(tmppath_buffer) + basename;
+}
+
+// A replacement for template_unittest.cc:CleanTestDir()
+void CreateOrCleanTestDir(const string& dirname) {
+ string glob(PathJoin(dirname, "*"));
+ WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode)
+ HANDLE hFind = FindFirstFileA(glob.c_str(), &found); // A is for Ansi
+ if (hFind == INVALID_HANDLE_VALUE) { // directory doesn't exist or some such
+ _mkdir(dirname.c_str());
+ hFind = FindFirstFileA(glob.c_str(), &found); // Try again...
+ }
+ if (hFind != INVALID_HANDLE_VALUE) {
+ do {
+ if (strstr(found.cFileName, "template"))
+ _unlink(PathJoin(dirname, found.cFileName).c_str());
+ } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi
+ FindClose(hFind);
+ }
+}
+
+}
+
+void GetNamelist(const char* testdata_dir, vector<string>* namelist) {
+ string glob(GOOGLE_NAMESPACE::PathJoin(testdata_dir,
+ "template_unittest_test*"));
+ WIN32_FIND_DATAA found; // that final A is for Ansi (as opposed to Unicode)
+ HANDLE hFind = FindFirstFileA(glob.c_str(), &found);
+ if (hFind == INVALID_HANDLE_VALUE) // no files matching the glob, probably
+ return; // if we don't find any files, nothing to add to namelist
+ do {
+ namelist->push_back(found.cFileName);
+ } while (FindNextFileA(hFind, &found) != FALSE); // A is for Ansi
+ FindClose(hFind);
+}
+
+#endif /* __cplusplus */
diff --git a/src/windows/port.h b/src/windows/port.h
new file mode 100644
index 0000000..7edc6f0
--- /dev/null
+++ b/src/windows/port.h
@@ -0,0 +1,140 @@
+/* Copyright (c) 2007, Google Inc.
+ * 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 Google Inc. 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.
+ *
+ * ---
+ * Author: Craig Silverstein
+ *
+ * These are some portability typedefs and defines to make it a bit
+ * easier to compile this code under VC++.
+ *
+ * Several of these are taken from glib:
+ * http://developer.gnome.org/doc/API/glib/glib-windows-compatability-functions.html
+ */
+
+#ifndef CTEMPLATE_WINDOWS_PORT_H_
+#define CTEMPLATE_WINDOWS_PORT_H_
+
+#include "windows/config.h"
+#ifdef _WIN32
+
+#define USING_PORT_CC
+
+#define WIN32_LEAN_AND_MEAN /* We always want minimal includes */
+#include <windows.h>
+#include <io.h> /* because we so often use open/close/etc */
+#include <direct.h> /* for _getcwd() */
+#include <sys/utime.h> /* for _utime() */
+#include <stdio.h> /* read in vsnprintf decl. before redifining it */
+#include <stdarg.h> /* template_dictionary.cc uses va_copy */
+#include <string.h> /* for _strnicmp */
+/* Note: the C++ #includes are all together at the bottom. This file is
+ * used by both C and C++ code, so we put all the C++ together.
+ */
+
+/* 4244: otherwise we get problems when substracting two size_t's to an int
+ * 4251: it's complaining about a private struct I've chosen not to dllexport
+ * 4355: we use this in a constructor, but we do it safely
+ * 4715: for some reason VC++ stopped realizing you can't return after abort()
+ * 4800: we know we're casting ints/char*'s to bools, and we're ok with that
+ * 4996: Yes, we're ok using "unsafe" functions like fopen() and strerror()
+ */
+#ifdef _MSC_VER
+#pragma warning(disable:4244 4251 4355 4715 4800 4996)
+#endif
+
+/* file I/O */
+#define PATH_MAX 1024
+#define access _access
+#define getcwd _getcwd
+#define open _open
+#define read _read
+#define write _write
+#define lseek _lseek
+#define close _close
+#define popen _popen
+#define pclose _pclose
+#ifndef R_OK /* mingw defines this, for instance */
+#define R_OK 04 /* read-only (for access()) */
+#endif
+#define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
+
+#define utime _utime
+#define utimbuf _utimbuf
+
+/* Not quite as lightweight as a hard-link, but more than good enough for us. */
+#define link(oldpath, newpath) (!CopyFileA(oldpath, newpath, false))
+
+#define strcasecmp _stricmp
+#define strncasecmp _strnicmp
+
+/* Sleep is in ms, on windows */
+#define sleep(secs) Sleep((secs) * 1000)
+
+/* We can't just use _vsnprintf and _snprintf as drop-in-replacements,
+ * because they don't always NUL-terminate. :-( We also can't use the
+ * name vsnprintf, since windows defines that (but not snprintf (!)).
+ */
+#if !defined(__MINGW32__) && !defined(__MINGW64__) /* mingw already defines */
+extern CTEMPLATE_DLL_DECL int snprintf(char *str, size_t size,
+ const char *format, ...);
+extern int CTEMPLATE_DLL_DECL safe_vsnprintf(char *str, size_t size,
+ const char *format, va_list ap);
+#define vsnprintf(str, size, format, ap) safe_vsnprintf(str, size, format, ap)
+#define va_copy(dst, src) (dst) = (src)
+#endif /* #if !defined(__MINGW32__) && !defined(__MINGW64__) */
+
+/* Windows doesn't support specifying the number of buckets as a
+ * hash_map constructor arg, so we leave this blank.
+ */
+#define CTEMPLATE_SMALL_HASHTABLE
+
+#define DEFAULT_TEMPLATE_ROOTDIR ".."
+
+
+/* These are functions we have to override because they're O/S-specific */
+#ifdef __cplusplus
+#include <string>
+#include <vector>
+
+namespace ctemplate {
+extern CTEMPLATE_DLL_DECL std::string TmpFile(const char* basename);
+void CTEMPLATE_DLL_DECL CreateOrCleanTestDir(const std::string& dirname);
+}
+void CTEMPLATE_DLL_DECL GetNamelist(const char* testdata_dir,
+ std::vector<std::string>* namelist);
+#endif /* __cplusplus */
+
+#ifndef __cplusplus
+/* I don't see how to get inlining for C code in MSVC. Ah well. */
+#define inline
+#endif
+
+#endif /* _WIN32 */
+
+#endif /* CTEMPLATE_WINDOWS_PORT_H_ */
diff --git a/src/windows/preprocess.sh b/src/windows/preprocess.sh
new file mode 100755
index 0000000..b089180
--- /dev/null
+++ b/src/windows/preprocess.sh
@@ -0,0 +1,118 @@
+#!/bin/sh
+
+# Copyright (c) 2007, Google Inc.
+# 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 Google Inc. 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.
+
+# ---
+# Author: Craig Silverstein
+#
+# This script is meant to be run at distribution-generation time, for
+# instance by autogen.sh. It does some of the work configure would
+# normally do, for windows systems. In particular, it expands all the
+# @...@ variables found in .in files, and puts them here, in the windows
+# directory.
+#
+# This script should be run before any new release.
+
+if [ -z "$1" ]; then
+ echo "USAGE: $0 <src/ directory>"
+ exit 1
+fi
+
+DLLDEF_MACRO_NAME="CTEMPLATE_DLL_DECL"
+
+# The text we put in every .h files we create. As a courtesy, we'll
+# include a helpful comment for windows users as to how to use
+# CTEMPLATE_DLL_DECL. Apparently sed expands \n into a newline. Good!
+DLLDEF_DEFINES="\
+// NOTE: if you are statically linking the template library into your binary\n\
+// (rather than using the template .dll), set '/D $DLLDEF_MACRO_NAME='\n\
+// as a compiler flag in your project file to turn off the dllimports.\n\
+#ifndef $DLLDEF_MACRO_NAME\n\
+# define $DLLDEF_MACRO_NAME __declspec(dllimport)\n\
+#endif"
+
+# template_cache.h gets a special DEFINE to work around the
+# difficulties in dll-exporting stl containers. Ugh.
+TEMPLATE_CACHE_DLLDEF_DEFINES="\
+// NOTE: if you are statically linking the template library into your binary\n\
+// (rather than using the template .dll), set '/D $DLLDEF_MACRO_NAME='\n\
+// as a compiler flag in your project file to turn off the dllimports.\n\
+#ifndef $DLLDEF_MACRO_NAME\n\
+# define $DLLDEF_MACRO_NAME __declspec(dllimport)\n\
+extern template class __declspec(dllimport) std::allocator<std::string>;\n\
+extern template class __declspec(dllimport) std::vector<std::string>;\n\
+#else\n\
+template class __declspec(dllexport) std::allocator<std::string>;\n\
+template class __declspec(dllexport) std::vector<std::string>;\n\
+#endif"
+
+# Read all the windows config info into variables
+# In order for the 'set' to take, this requires putting all in a subshell.
+(
+ while read define varname value; do
+ [ "$define" != "#define" ] && continue
+ eval "$varname='$value'"
+ done
+
+ # Process all the .in files in the "ctemplate" subdirectory
+ mkdir -p "$1/windows/ctemplate"
+ for file in "$1"/ctemplate/*.in; do
+ echo "Processing $file"
+ outfile="$1/windows/ctemplate/`basename $file .in`"
+
+ if test "`basename $file`" = template_cache.h.in; then
+ MY_DLLDEF_DEFINES=$TEMPLATE_CACHE_DLLDEF_DEFINES
+ else
+ MY_DLLDEF_DEFINES=$DLLDEF_DEFINES
+ fi
+
+ # Besides replacing @...@, we also need to turn on dllimport
+ # We also need to replace hash by hash_compare (annoying we hard-code :-( )
+ sed -e "s!@ac_windows_dllexport@!$DLLDEF_MACRO_NAME!g" \
+ -e "s!@ac_windows_dllexport_defines@!$MY_DLLDEF_DEFINES!g" \
+ -e "s!@ac_cv_cxx_hash_map@!$HASH_MAP_H!g" \
+ -e "s!@ac_cv_cxx_hash_set@!$HASH_SET_H!g" \
+ -e "s!@ac_cv_cxx_hash_map_class@!$HASH_NAMESPACE::hash_map!g" \
+ -e "s!@ac_cv_cxx_hash_set_class@!$HASH_NAMESPACE::hash_set!g" \
+ -e "s!@ac_google_attribute@!${HAVE___ATTRIBUTE__:-0}!g" \
+ -e "s!@ac_google_end_namespace@!$_END_GOOGLE_NAMESPACE_!g" \
+ -e "s!@ac_google_namespace@!$GOOGLE_NAMESPACE!g" \
+ -e "s!@ac_google_start_namespace@!$_START_GOOGLE_NAMESPACE_!g" \
+ -e "s!@ac_htmlparser_namespace@!$HTMLPARSER_NAMESPACE!g" \
+ -e "s!@ac_cv_uint64@!unsigned __int64!g" \
+ -e "s!@ac_cv_have_stdint_h@!0!g" \
+ -e "s!@ac_cv_have_inttypes_h@!0!g" \
+ -e "s!@ac_have_attribute_weak@!0!g" \
+ -e "s!\\bhash\\b!hash_compare!g" \
+ "$file" > "$outfile"
+ done
+) < "$1/windows/config.h"
+
+echo "DONE"
diff --git a/vsprojects/compile_test/compile_test.vcproj b/vsprojects/compile_test/compile_test.vcproj
new file mode 100644
index 0000000..7a89091
--- /dev/null
+++ b/vsprojects/compile_test/compile_test.vcproj
@@ -0,0 +1,180 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="compile_test"
+ ProjectGUID="{4B263748-5F0F-468C-8C5C-ED2682BB6BE3}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/compile_test.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/compile_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/compile_test.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\compile_test.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{AFC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_naamelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/diff_tpl_auto_escape/diff_tpl_auto_escape.vcproj b/vsprojects/diff_tpl_auto_escape/diff_tpl_auto_escape.vcproj
new file mode 100644
index 0000000..10d8048
--- /dev/null
+++ b/vsprojects/diff_tpl_auto_escape/diff_tpl_auto_escape.vcproj
@@ -0,0 +1,184 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="diff_tpl_auto_escape"
+ ProjectGUID="{72CD1C2A-56F6-4DDA-957B-BCF181BB558E}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/diff_tpl_auto_escape.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/diff_tpl_auto_escape.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/diff_tpl_auto_escape.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\diff_tpl_auto_escape.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/generate_fsm_c_test/generate_fsm_c_test.vcproj b/vsprojects/generate_fsm_c_test/generate_fsm_c_test.vcproj
new file mode 100644
index 0000000..b39ee57
--- /dev/null
+++ b/vsprojects/generate_fsm_c_test/generate_fsm_c_test.vcproj
@@ -0,0 +1,151 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="generate_fsm_c_test"
+ ProjectGUID="{8FB1935F-FC23-465D-8C18-C1466A99D08D}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/generate_fsm_c_test.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/generate_fsm_c_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/generate_fsm_c_test.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\generate_fsm_c_test.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\statemachine.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/htmlparser_test/htmlparser_test.vcproj b/vsprojects/htmlparser_test/htmlparser_test.vcproj
new file mode 100644
index 0000000..9df3cdb
--- /dev/null
+++ b/vsprojects/htmlparser_test/htmlparser_test.vcproj
@@ -0,0 +1,152 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="htmlparser_test"
+ ProjectGUID="{B105C0FF-C28A-480B-8298-A66AB4F1F0CD}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/htmlparser_test.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/htmlparser_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/htmlparser_test.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\htmlparser_cpp_test.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\htmlparser\htmlparser_cpp.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/libctemplate/libctemplate.vcproj b/vsprojects/libctemplate/libctemplate.vcproj
new file mode 100755
index 0000000..cd7ac2d
--- /dev/null
+++ b/vsprojects/libctemplate/libctemplate.vcproj
@@ -0,0 +1,432 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="libctemplate"
+ ProjectGUID="{FB27FBDB-E6C0-4D00-A7F8-1EEEF1B48ABC}"
+ RootNamespace="libctemplate"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;LIBCTEMPLATE_EXPORTS"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/libctemplate-debug.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/libctemplate-debug.pdb"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)/libctemplate-debug.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBCTEMPLATE_EXPORTS"
+ RuntimeLibrary="0"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/libctemplate.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)/libctemplate.lib"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\base\arena.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\per_expand_data.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_cache.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_dictionary.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_modifiers.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_annotator.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_namelist.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_pathops.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_string.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\htmlparser.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\jsparser.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\statemachine.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\manual_constructor.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\small_map.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\htmlparser.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\jsparser.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\statemachine.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\htmlparser_cpp.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_annotator.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/make_tpl_varname_h/make_tpl_varname_h.vcproj b/vsprojects/make_tpl_varname_h/make_tpl_varname_h.vcproj
new file mode 100755
index 0000000..3d7eace
--- /dev/null
+++ b/vsprojects/make_tpl_varname_h/make_tpl_varname_h.vcproj
@@ -0,0 +1,182 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="make_tpl_varname_h"
+ ProjectGUID="{CFD560F2-1B16-4CEE-985D-B19FDE74513F}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/make_tpl_varname_h.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/make_tpl_varname_h.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/make_tpl_varname_h.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\make_tpl_varnames_h.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/statemachine_test/statemachine_test.vcproj b/vsprojects/statemachine_test/statemachine_test.vcproj
new file mode 100644
index 0000000..aff3807
--- /dev/null
+++ b/vsprojects/statemachine_test/statemachine_test.vcproj
@@ -0,0 +1,186 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="statemachine_test"
+ ProjectGUID="{A105C0FF-C28A-480B-8298-A66AB4F1F0CD}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/statemachine_test.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/statemachine_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/statemachine_test.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\htmlparser\statemachine.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"
+ CompileAs="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"
+ CompileAs="1"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\statemachine_test.c">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"
+ CompileAs="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"
+ CompileAs="1"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"
+ CompileAs="1"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"
+ CompileAs="1"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\htmlparser\statemachine.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_cache_test/template_cache_test.vcproj b/vsprojects/template_cache_test/template_cache_test.vcproj
new file mode 100755
index 0000000..bfecbb6
--- /dev/null
+++ b/vsprojects/template_cache_test/template_cache_test.vcproj
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_cache_test"
+ ProjectGUID="{5105C0FF-C28A-480B-8298-A66AB4F1F0CD}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_cache_test.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_cache_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_cache_test.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_cache_test.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_dictionary_unittest/template_dictionary_unittest.vcproj b/vsprojects/template_dictionary_unittest/template_dictionary_unittest.vcproj
new file mode 100755
index 0000000..4c45ec6
--- /dev/null
+++ b/vsprojects/template_dictionary_unittest/template_dictionary_unittest.vcproj
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_dictionary_unittest"
+ ProjectGUID="{9160CC7F-3BC6-49F1-A158-70DF579376CA}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_dictionary_unittest.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_dictionary_unittest.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_dictionary_unittest.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\template_dictionary_unittest.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_modifiers_unittest/template_modifiers_unittest.vcproj b/vsprojects/template_modifiers_unittest/template_modifiers_unittest.vcproj
new file mode 100755
index 0000000..319f63a
--- /dev/null
+++ b/vsprojects/template_modifiers_unittest/template_modifiers_unittest.vcproj
@@ -0,0 +1,208 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_modifiers_unittest"
+ ProjectGUID="{D9E45FD2-07AC-4EE8-9DA4-26E0427D619E}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_modifiers_unittest.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_modifiers_unittest.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_modifiers_unittest.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\template_modifiers_unittest.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_regtest/template_regtest.vcproj b/vsprojects/template_regtest/template_regtest.vcproj
new file mode 100755
index 0000000..0cca7f4
--- /dev/null
+++ b/vsprojects/template_regtest/template_regtest.vcproj
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_regtest"
+ ProjectGUID="{0072B37E-DCDA-4128-BC12-7C0A7EF59016}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_regtest.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_regtest.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_regtest.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\template_regtest.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_setglobals_unittest/template_setglobals_unittest.vcproj b/vsprojects/template_setglobals_unittest/template_setglobals_unittest.vcproj
new file mode 100755
index 0000000..6183c9a
--- /dev/null
+++ b/vsprojects/template_setglobals_unittest/template_setglobals_unittest.vcproj
@@ -0,0 +1,203 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_setglobals_unittest"
+ ProjectGUID="{686099C0-A778-4D27-80B5-A7E051658D2F}"
+ RootNamespace="template_setglobals_unittest"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_setglobals_unittest.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_setglobals_unittest.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_setglobals_unittest.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\template_setglobals_unittest.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_test_util_test/template_test_util_test.vcproj b/vsprojects/template_test_util_test/template_test_util_test.vcproj
new file mode 100644
index 0000000..1949b23
--- /dev/null
+++ b/vsprojects/template_test_util_test/template_test_util_test.vcproj
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_test_util_test"
+ ProjectGUID="{87132061-D584-4388-A80B-D8560F8D0895}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_test_util_test.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_test_util_test.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_test_util_test.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util_test.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hpp;hxx;hm;inl;inc;xsd"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+ UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_unittest/template_unittest.vcproj b/vsprojects/template_unittest/template_unittest.vcproj
new file mode 100755
index 0000000..375f77f
--- /dev/null
+++ b/vsprojects/template_unittest/template_unittest.vcproj
@@ -0,0 +1,205 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_unittest"
+ ProjectGUID="{5105C0FF-C28A-480B-8298-A66AB4F1F0CD}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_unittest.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_unittest.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_unittest.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_unittest.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/vsprojects/template_unittest_static/template_unittest_static.vcproj b/vsprojects/template_unittest_static/template_unittest_static.vcproj
new file mode 100755
index 0000000..1b23cd3
--- /dev/null
+++ b/vsprojects/template_unittest_static/template_unittest_static.vcproj
@@ -0,0 +1,487 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="7.10"
+ Name="template_unittest_static"
+ ProjectGUID="{ED69C82B-F593-418A-8D17-C64CBB11E603}"
+ Keyword="Win32Proj">
+ <Platforms>
+ <Platform
+ Name="Win32"/>
+ </Platforms>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="TRUE"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="5"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_unittest_static.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="TRUE"
+ ProgramDatabaseFile="$(OutDir)/template_unittest_static.pdb"
+ SubSystem="1"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="2">
+ <Tool
+ Name="VCCLCompilerTool"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="4"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"/>
+ <Tool
+ Name="VCCustomBuildTool"/>
+ <Tool
+ Name="VCLinkerTool"
+ OutputFile="$(OutDir)/template_unittest_static.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="TRUE"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"/>
+ <Tool
+ Name="VCMIDLTool"/>
+ <Tool
+ Name="VCPostBuildEventTool"/>
+ <Tool
+ Name="VCPreBuildEventTool"/>
+ <Tool
+ Name="VCPreLinkEventTool"/>
+ <Tool
+ Name="VCResourceCompilerTool"/>
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"/>
+ <Tool
+ Name="VCXMLDataGeneratorTool"/>
+ <Tool
+ Name="VCWebDeploymentTool"/>
+ <Tool
+ Name="VCManagedWrapperGeneratorTool"/>
+ <Tool
+ Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files">
+ <File
+ RelativePath="..\..\src\base\arena.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\per_expand_data.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_cache.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_dictionary.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_modifiers.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_annotator.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_namelist.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_pathops.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\template_string.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_unittest.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/D CTEMPLATE_DLL_DECL="
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\htmlparser.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\jsparser.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\statemachine.cc">
+ <FileConfiguration
+ Name="Debug|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="3"/>
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Release|Win32">
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="..\..\src\windows; ..\..\src"
+ RuntimeLibrary="2"/>
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files">
+ <File
+ RelativePath="..\..\src\base\arena.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\manual_constructor.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\small_map.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\htmlparser.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\jsparser.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\statemachine.h">
+ </File>
+ <File
+ RelativePath="..\..\src\htmlparser\htmlparser_cpp.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\config.h">
+ </File>
+ <File
+ RelativePath="..\..\src\config_for_unittests.h">
+ </File>
+ <File
+ RelativePath="..\..\src\base\mutex.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\port.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_cache.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_annotator.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_dictionary_interface.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\per_expand_data.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_emitter.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_enums.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_from_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_string.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_modifiers.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_namelist.h">
+ </File>
+ <File
+ RelativePath="..\..\src\windows\ctemplate\template_pathops.h">
+ </File>
+ <File
+ RelativePath="..\..\src\tests\template_test_util.h">
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>