Check-in Differences
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Difference From ecb04f64a999969e To 0e3a824d69673fe9

2012-05-05
10:53
fixing the build scripts supporting MSVC check-in: 7f9c0cc55f user: sandro tags: trunk
2012-05-04
17:08
fixing few GCC warnings check-in: 0e3a824d69 user: sandro tags: trunk
16:33
new generation OSM tools based on ReadOSM check-in: ab480ac8a1 user: sandro tags: trunk
2012-04-10
10:19
updating ./configure [supporting config.h and autoheader] check-in: ecb04f64a9 user: sandro tags: trunk
2012-04-06
15:44
enhancing spatialite_osm_net (--roads / --railways) check-in: d33a43d707 user: sandro tags: trunk

Changes to Makefile-static-Linux.

    64     64   ./static_bin/spatialite_osm_net: spatialite_osm_net.o
    65     65   	$(CC) spatialite_osm_net.o -o ./static_bin/spatialite_osm_net \
    66     66   	/usr/local/lib/libspatialite.a \
    67     67   	/usr/lib/libproj.a \
    68     68   	/usr/lib/libgeos_c.a \
    69     69   	/usr/lib/libgeos.a \
    70     70   	/usr/local/lib/libfreexl.a \
           71  +	/usr/local/lib/libreadosm.a \
           72  +	/usr/lib/libexpat.a \
           73  +	/usr/lib/libz.a \
    71     74   	-lstdc++ -lm -lpthread -ldl
    72     75   	strip --strip-all ./static_bin/spatialite_osm_net
    73     76   
    74     77   ./static_bin/spatialite_osm_map: spatialite_osm_map.o
    75     78   	$(CC) spatialite_osm_map.o -o ./static_bin/spatialite_osm_map \
    76     79   	/usr/local/lib/libspatialite.a \
    77     80   	/usr/lib/libproj.a \
    78     81   	/usr/lib/libgeos_c.a \
    79     82   	/usr/lib/libgeos.a \
    80     83   	/usr/local/lib/libfreexl.a \
           84  +	/usr/local/lib/libreadosm.a \
    81     85   	/usr/lib/libexpat.a \
           86  +	/usr/lib/libz.a \
    82     87   	-lstdc++ -lm -lpthread -ldl
    83     88   	strip --strip-all ./static_bin/spatialite_osm_map
    84     89   
    85     90   ./static_bin/spatialite_gml: spatialite_gml.o
    86     91   	$(CC) spatialite_gml.o -o ./static_bin/spatialite_gml \
    87     92   	/usr/local/lib/libspatialite.a \
    88     93   	/usr/lib/libproj.a \
................................................................................
    96    101   ./static_bin/spatialite_osm_raw: spatialite_osm_raw.o
    97    102   	$(CC) spatialite_osm_raw.o -o ./static_bin/spatialite_osm_raw \
    98    103   	/usr/local/lib/libspatialite.a \
    99    104   	/usr/lib/libproj.a \
   100    105   	/usr/lib/libgeos_c.a \
   101    106   	/usr/lib/libgeos.a \
   102    107   	/usr/local/lib/libfreexl.a \
          108  +	/usr/local/lib/libreadosm.a \
   103    109   	/usr/lib/libexpat.a \
          110  +	/usr/lib/libz.a \
   104    111   	-lstdc++ -lm -lpthread -ldl
   105    112   	strip --strip-all ./static_bin/spatialite_osm_raw
   106    113   
   107    114   ./static_bin/spatialite_osm_filter: spatialite_osm_filter.o
   108    115   	$(CC) spatialite_osm_filter.o -o ./static_bin/spatialite_osm_filter \
   109    116   	/usr/local/lib/libspatialite.a \
   110    117   	/usr/lib/libproj.a \
   111    118   	/usr/lib/libgeos_c.a \
   112    119   	/usr/lib/libgeos.a \
   113    120   	/usr/local/lib/libfreexl.a \
   114    121   	-lstdc++ -lm -lpthread -ldl
   115    122   	strip --strip-all ./static_bin/spatialite_osm_filter

Changes to Makefile-static-MacOsX.

    73     73   	
    74     74   ./static_bin/spatialite_osm_net: spatialite_osm_net.o
    75     75   	$(CC) spatialite_osm_net.o -o ./static_bin/spatialite_osm_net \
    76     76   	/usr/local/lib/libspatialite.a \
    77     77   	/opt/local/lib/libproj.a \
    78     78   	/opt/local/lib/libgeos_c.a \
    79     79   	/opt/local/lib/libgeos.a \
           80  +	/usr/local/lib/libfreexl.a \
           81  +	/usr/local/lib/libreadosm.a \
    80     82   	/opt/local/lib/libiconv.a \
    81     83   	/opt/local/lib/libcharset.a \
           84  +	/opt/local/lib/libexpat.a \
           85  +	/opt/local/lib/libz.a \
    82     86   	-lstdc++ -lm -lpthread -ldl
    83     87   	strip ./static_bin/spatialite_osm_net
    84     88   
    85     89   ./static_bin/spatialite_osm_map: spatialite_osm_map.o
    86     90   	$(CC) spatialite_osm_map.o -o ./static_bin/spatialite_osm_map \
    87     91   	/usr/local/lib/libspatialite.a \
    88     92   	/opt/local/lib/libproj.a \
    89     93   	/opt/local/lib/libgeos_c.a \
    90     94   	/opt/local/lib/libgeos.a \
    91     95   	/usr/local/lib/libfreexl.a \
           96  +	/usr/local/lib/libreadosm.a \
    92     97   	/opt/local/lib/libiconv.a \
    93     98   	/opt/local/lib/libcharset.a \
    94     99   	/opt/local/lib/libexpat.a \
          100  +	/opt/local/lib/libz.a \
    95    101   	-lstdc++ -lm -lpthread -ldl
    96    102   	strip ./static_bin/spatialite_osm_map
    97    103   
    98    104   ./static_bin/spatialite_gml: spatialite_gml.o
    99    105   	$(CC) spatialite_gml.o -o ./static_bin/spatialite_gml \
   100    106   	/usr/local/lib/libspatialite.a \
   101    107   	/opt/local/lib/libproj.a \
................................................................................
   111    117   ./static_bin/spatialite_osm_raw: spatialite_osm_raw.o
   112    118   	$(CC) spatialite_osm_raw.o -o ./static_bin/spatialite_osm_raw \
   113    119   	/usr/local/lib/libspatialite.a \
   114    120   	/opt/local/lib/libproj.a \
   115    121   	/opt/local/lib/libgeos_c.a \
   116    122   	/opt/local/lib/libgeos.a \
   117    123   	/usr/local/lib/libfreexl.a \
          124  +	/usr/local/lib/libreadosm.a \
   118    125   	/opt/local/lib/libiconv.a \
   119    126   	/opt/local/lib/libcharset.a \
   120    127   	/opt/local/lib/libexpat.a \
          128  +	/opt/local/lib/libz.a \
   121    129   	-lstdc++ -lm -lpthread -ldl
   122    130   	strip ./static_bin/spatialite_osm_raw
   123    131   
   124    132   ./static_bin/spatialite_osm_filter: spatialite_osm_filter.o
   125    133   	$(CC) spatialite_osm_filter.o -o ./static_bin/spatialite_osm_filter \
   126    134   	/usr/local/lib/libspatialite.a \
   127    135   	/opt/local/lib/libproj.a \

Changes to Makefile-static-MinGW.

    76     76   	$(GG) spatialite_osm_net.o -o ./static_bin/spatialite_osm_net.exe \
    77     77   	/usr/local/lib/libspatialite.a \
    78     78   	/usr/local/lib/libsqlite3.a \
    79     79   	/usr/local/lib/libproj.a \
    80     80   	/usr/local/lib/libgeos_c.a \
    81     81   	/usr/local/lib/libgeos.a \
    82     82   	/usr/local/lib/libfreexl.a \
           83  +	/usr/local/lib/libreadosm.a \
    83     84   	/usr/local/lib/libiconv.a \
           85  +	/usr/local/lib/libexpat.a \
           86  +	/usr/local/lib/libz.a \
    84     87   	-lm -static-libstdc++ -static-libgcc
    85     88   	strip --strip-all ./static_bin/spatialite_osm_net.exe
    86     89   
    87     90   ./static_bin/spatialite_osm_map.exe: spatialite_osm_map.o
    88     91   	$(GG) spatialite_osm_map.o -o ./static_bin/spatialite_osm_map.exe \
    89     92   	/usr/local/lib/libspatialite.a \
    90     93   	/usr/local/lib/libsqlite3.a \
    91     94   	/usr/local/lib/libproj.a \
    92     95   	/usr/local/lib/libgeos_c.a \
    93     96   	/usr/local/lib/libgeos.a \
    94     97   	/usr/local/lib/libiconv.a \
    95     98   	/usr/local/lib/libfreexl.a \
           99  +	/usr/local/lib/libreadosm.a \
    96    100   	/usr/local/lib/libexpat.a \
          101  +	/usr/local/lib/libz.a \
    97    102   	-lm -static-libstdc++ -static-libgcc
    98    103   	strip --strip-all ./static_bin/spatialite_osm_map.exe
    99    104   
   100    105   ./static_bin/spatialite_gml.exe: spatialite_gml.o
   101    106   	$(GG) spatialite_gml.o -o ./static_bin/spatialite_gml.exe \
   102    107   	/usr/local/lib/libspatialite.a \
   103    108   	/usr/local/lib/libsqlite3.a \
................................................................................
   114    119   	$(GG) spatialite_osm_raw.o -o ./static_bin/spatialite_osm_raw.exe \
   115    120   	/usr/local/lib/libspatialite.a \
   116    121   	/usr/local/lib/libsqlite3.a \
   117    122   	/usr/local/lib/libproj.a \
   118    123   	/usr/local/lib/libgeos_c.a \
   119    124   	/usr/local/lib/libgeos.a \
   120    125   	/usr/local/lib/libfreexl.a \
          126  +	/usr/local/lib/libreadosm.a \
   121    127   	/usr/local/lib/libiconv.a \
   122    128   	/usr/local/lib/libexpat.a \
          129  +	/usr/local/lib/libz.a \
   123    130   	-lm -static-libstdc++ -static-libgcc
   124    131   	strip --strip-all ./static_bin/spatialite_osm_raw.exe
   125    132   
   126    133   ./static_bin/spatialite_osm_filter.exe: spatialite_osm_filter.o
   127    134   	$(GG) spatialite_osm_filter.o -o ./static_bin/spatialite_osm_filter.exe \
   128    135   	/usr/local/lib/libspatialite.a \
   129    136   	/usr/local/lib/libsqlite3.a \

Changes to Makefile.am.

    22     22   spatialite_osm_net_SOURCES = spatialite_osm_net.c
    23     23   spatialite_osm_map_SOURCES = spatialite_osm_map.c
    24     24   spatialite_osm_raw_SOURCES = spatialite_osm_raw.c
    25     25   spatialite_osm_filter_SOURCES = spatialite_osm_filter.c
    26     26   spatialite_gml_SOURCES = spatialite_gml.c
    27     27   
    28     28   spatialite_osm_map_LDADD = @LIBSPATIALITE_LIBS@ \
    29         -	@LIBFREEXL_LIBS@ \
    30         -	-lexpat
           29  +	@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ 
    31     30   spatialite_osm_raw_LDADD = @LIBSPATIALITE_LIBS@ \
    32         -	@LIBFREEXL_LIBS@ \
    33         -	-lexpat
           31  +	@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@
           32  +spatialite_osm_net_LDADD = @LIBSPATIALITE_LIBS@ \
           33  +	@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@
    34     34   spatialite_gml_LDADD = @LIBSPATIALITE_LIBS@ \
    35     35   	@LIBFREEXL_LIBS@ \
    36     36   	-lexpat 
    37     37   spatialite_LDADD = @LIBSPATIALITE_LIBS@ \
    38     38   	@LIBFREEXL_LIBS@ \
    39     39   	@READLINE_LIBS@
    40     40   LDADD = @LIBSPATIALITE_LIBS@ \

Changes to Makefile.in.

    41     41   	spatialite_osm_filter$(EXEEXT) spatialite_gml$(EXEEXT)
    42     42   subdir = .
    43     43   DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
    44     44   	$(srcdir)/Makefile.in $(srcdir)/config.h.in \
    45     45   	$(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \
    46     46   	config.guess config.sub depcomp install-sh ltmain.sh missing
    47     47   ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
    48         -am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \
    49         -	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
    50         -	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
    51         -	$(top_srcdir)/configure.ac
           48  +am__aclocal_m4_deps = $(top_srcdir)/configure.ac
    52     49   am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
    53     50   	$(ACLOCAL_M4)
    54     51   am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
    55     52    configure.lineno config.status.lineno
    56     53   mkinstalldirs = $(install_sh) -d
    57     54   CONFIG_HEADER = config.h
    58     55   CONFIG_CLEAN_FILES =
................................................................................
    82     79   spatialite_osm_filter_LDADD = $(LDADD)
    83     80   spatialite_osm_filter_DEPENDENCIES =
    84     81   am_spatialite_osm_map_OBJECTS = spatialite_osm_map.$(OBJEXT)
    85     82   spatialite_osm_map_OBJECTS = $(am_spatialite_osm_map_OBJECTS)
    86     83   spatialite_osm_map_DEPENDENCIES =
    87     84   am_spatialite_osm_net_OBJECTS = spatialite_osm_net.$(OBJEXT)
    88     85   spatialite_osm_net_OBJECTS = $(am_spatialite_osm_net_OBJECTS)
    89         -spatialite_osm_net_LDADD = $(LDADD)
    90     86   spatialite_osm_net_DEPENDENCIES =
    91     87   am_spatialite_osm_raw_OBJECTS = spatialite_osm_raw.$(OBJEXT)
    92     88   spatialite_osm_raw_OBJECTS = $(am_spatialite_osm_raw_OBJECTS)
    93     89   spatialite_osm_raw_DEPENDENCIES =
    94     90   am_spatialite_tool_OBJECTS = spatialite_tool.$(OBJEXT)
    95     91   spatialite_tool_OBJECTS = $(am_spatialite_tool_OBJECTS)
    96     92   spatialite_tool_LDADD = $(LDADD)
................................................................................
   170    166   INSTALL_SCRIPT = @INSTALL_SCRIPT@
   171    167   INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
   172    168   LD = @LD@
   173    169   LDFLAGS = @LDFLAGS@
   174    170   LIBFREEXL_CFLAGS = @LIBFREEXL_CFLAGS@
   175    171   LIBFREEXL_LIBS = @LIBFREEXL_LIBS@
   176    172   LIBOBJS = @LIBOBJS@
          173  +LIBREADOSM_CFLAGS = @LIBREADOSM_CFLAGS@
          174  +LIBREADOSM_LIBS = @LIBREADOSM_LIBS@
   177    175   LIBS = @LIBS@
   178    176   LIBSPATIALITE_CFLAGS = @LIBSPATIALITE_CFLAGS@
   179    177   LIBSPATIALITE_LIBS = @LIBSPATIALITE_LIBS@
   180    178   LIBTOOL = @LIBTOOL@
   181    179   LIPO = @LIPO@
   182    180   LN_S = @LN_S@
   183    181   LTLIBOBJS = @LTLIBOBJS@
................................................................................
   271    269   exif_loader_SOURCES = exif_loader.c
   272    270   spatialite_osm_net_SOURCES = spatialite_osm_net.c
   273    271   spatialite_osm_map_SOURCES = spatialite_osm_map.c
   274    272   spatialite_osm_raw_SOURCES = spatialite_osm_raw.c
   275    273   spatialite_osm_filter_SOURCES = spatialite_osm_filter.c
   276    274   spatialite_gml_SOURCES = spatialite_gml.c
   277    275   spatialite_osm_map_LDADD = @LIBSPATIALITE_LIBS@ \
   278         -	@LIBFREEXL_LIBS@ \
   279         -	-lexpat
          276  +	@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@ 
   280    277   
   281    278   spatialite_osm_raw_LDADD = @LIBSPATIALITE_LIBS@ \
   282         -	@LIBFREEXL_LIBS@ \
   283         -	-lexpat
          279  +	@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@
          280  +
          281  +spatialite_osm_net_LDADD = @LIBSPATIALITE_LIBS@ \
          282  +	@LIBFREEXL_LIBS@ @LIBREADOSM_LIBS@
   284    283   
   285    284   spatialite_gml_LDADD = @LIBSPATIALITE_LIBS@ \
   286    285   	@LIBFREEXL_LIBS@ \
   287    286   	-lexpat 
   288    287   
   289    288   spatialite_LDADD = @LIBSPATIALITE_LIBS@ \
   290    289   	@LIBFREEXL_LIBS@ \
................................................................................
   306    305   .SUFFIXES: .c .lo .o .obj
   307    306   am--refresh:
   308    307   	@:
   309    308   $(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am  $(am__configure_deps)
   310    309   	@for dep in $?; do \
   311    310   	  case '$(am__configure_deps)' in \
   312    311   	    *$$dep*) \
   313         -	      echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \
   314         -	      $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \
          312  +	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
          313  +	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
   315    314   		&& exit 0; \
   316    315   	      exit 1;; \
   317    316   	  esac; \
   318    317   	done; \
   319         -	echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \
          318  +	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
   320    319   	$(am__cd) $(top_srcdir) && \
   321         -	  $(AUTOMAKE) --gnu Makefile
          320  +	  $(AUTOMAKE) --foreign Makefile
   322    321   .PRECIOUS: Makefile
   323    322   Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
   324    323   	@case '$?' in \
   325    324   	  *config.status*) \
   326    325   	    echo ' $(SHELL) ./config.status'; \
   327    326   	    $(SHELL) ./config.status;; \
   328    327   	  *) \

Changes to aclocal.m4.

    14     14   m4_ifndef([AC_AUTOCONF_VERSION],
    15     15     [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
    16     16   m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],,
    17     17   [m4_warning([this file was generated for autoconf 2.68.
    18     18   You have another version of autoconf.  It may work, but is not guaranteed to.
    19     19   If you have problems, you may need to regenerate the build system entirely.
    20     20   To do so, use the procedure documented by the package, typically `autoreconf'.])])
           21  +
           22  +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
           23  +#
           24  +#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
           25  +#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
           26  +#                 Inc.
           27  +#   Written by Gordon Matzigkeit, 1996
           28  +#
           29  +# This file is free software; the Free Software Foundation gives
           30  +# unlimited permission to copy and/or distribute it, with or without
           31  +# modifications, as long as this notice is preserved.
           32  +
           33  +m4_define([_LT_COPYING], [dnl
           34  +#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
           35  +#                 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
           36  +#                 Inc.
           37  +#   Written by Gordon Matzigkeit, 1996
           38  +#
           39  +#   This file is part of GNU Libtool.
           40  +#
           41  +# GNU Libtool is free software; you can redistribute it and/or
           42  +# modify it under the terms of the GNU General Public License as
           43  +# published by the Free Software Foundation; either version 2 of
           44  +# the License, or (at your option) any later version.
           45  +#
           46  +# As a special exception to the GNU General Public License,
           47  +# if you distribute this file as part of a program or library that
           48  +# is built using GNU Libtool, you may include this file under the
           49  +# same distribution terms that you use for the rest of that program.
           50  +#
           51  +# GNU Libtool is distributed in the hope that it will be useful,
           52  +# but WITHOUT ANY WARRANTY; without even the implied warranty of
           53  +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
           54  +# GNU General Public License for more details.
           55  +#
           56  +# You should have received a copy of the GNU General Public License
           57  +# along with GNU Libtool; see the file COPYING.  If not, a copy
           58  +# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
           59  +# obtained by writing to the Free Software Foundation, Inc.,
           60  +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
           61  +])
           62  +
           63  +# serial 57 LT_INIT
           64  +
           65  +
           66  +# LT_PREREQ(VERSION)
           67  +# ------------------
           68  +# Complain and exit if this libtool version is less that VERSION.
           69  +m4_defun([LT_PREREQ],
           70  +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1,
           71  +       [m4_default([$3],
           72  +		   [m4_fatal([Libtool version $1 or higher is required],
           73  +		             63)])],
           74  +       [$2])])
           75  +
           76  +
           77  +# _LT_CHECK_BUILDDIR
           78  +# ------------------
           79  +# Complain if the absolute build directory name contains unusual characters
           80  +m4_defun([_LT_CHECK_BUILDDIR],
           81  +[case `pwd` in
           82  +  *\ * | *\	*)
           83  +    AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;;
           84  +esac
           85  +])
           86  +
           87  +
           88  +# LT_INIT([OPTIONS])
           89  +# ------------------
           90  +AC_DEFUN([LT_INIT],
           91  +[AC_PREREQ([2.58])dnl We use AC_INCLUDES_DEFAULT
           92  +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
           93  +AC_BEFORE([$0], [LT_LANG])dnl
           94  +AC_BEFORE([$0], [LT_OUTPUT])dnl
           95  +AC_BEFORE([$0], [LTDL_INIT])dnl
           96  +m4_require([_LT_CHECK_BUILDDIR])dnl
           97  +
           98  +dnl Autoconf doesn't catch unexpanded LT_ macros by default:
           99  +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl
          100  +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl
          101  +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4
          102  +dnl unless we require an AC_DEFUNed macro:
          103  +AC_REQUIRE([LTOPTIONS_VERSION])dnl
          104  +AC_REQUIRE([LTSUGAR_VERSION])dnl
          105  +AC_REQUIRE([LTVERSION_VERSION])dnl
          106  +AC_REQUIRE([LTOBSOLETE_VERSION])dnl
          107  +m4_require([_LT_PROG_LTMAIN])dnl
          108  +
          109  +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}])
          110  +
          111  +dnl Parse OPTIONS
          112  +_LT_SET_OPTIONS([$0], [$1])
          113  +
          114  +# This can be used to rebuild libtool when needed
          115  +LIBTOOL_DEPS="$ltmain"
          116  +
          117  +# Always use our own libtool.
          118  +LIBTOOL='$(SHELL) $(top_builddir)/libtool'
          119  +AC_SUBST(LIBTOOL)dnl
          120  +
          121  +_LT_SETUP
          122  +
          123  +# Only expand once:
          124  +m4_define([LT_INIT])
          125  +])# LT_INIT
          126  +
          127  +# Old names:
          128  +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT])
          129  +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT])
          130  +dnl aclocal-1.4 backwards compatibility:
          131  +dnl AC_DEFUN([AC_PROG_LIBTOOL], [])
          132  +dnl AC_DEFUN([AM_PROG_LIBTOOL], [])
          133  +
          134  +
          135  +# _LT_CC_BASENAME(CC)
          136  +# -------------------
          137  +# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
          138  +m4_defun([_LT_CC_BASENAME],
          139  +[for cc_temp in $1""; do
          140  +  case $cc_temp in
          141  +    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
          142  +    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
          143  +    \-*) ;;
          144  +    *) break;;
          145  +  esac
          146  +done
          147  +cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
          148  +])
          149  +
          150  +
          151  +# _LT_FILEUTILS_DEFAULTS
          152  +# ----------------------
          153  +# It is okay to use these file commands and assume they have been set
          154  +# sensibly after `m4_require([_LT_FILEUTILS_DEFAULTS])'.
          155  +m4_defun([_LT_FILEUTILS_DEFAULTS],
          156  +[: ${CP="cp -f"}
          157  +: ${MV="mv -f"}
          158  +: ${RM="rm -f"}
          159  +])# _LT_FILEUTILS_DEFAULTS
          160  +
          161  +
          162  +# _LT_SETUP
          163  +# ---------
          164  +m4_defun([_LT_SETUP],
          165  +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
          166  +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
          167  +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl
          168  +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl
          169  +
          170  +_LT_DECL([], [host_alias], [0], [The host system])dnl
          171  +_LT_DECL([], [host], [0])dnl
          172  +_LT_DECL([], [host_os], [0])dnl
          173  +dnl
          174  +_LT_DECL([], [build_alias], [0], [The build system])dnl
          175  +_LT_DECL([], [build], [0])dnl
          176  +_LT_DECL([], [build_os], [0])dnl
          177  +dnl
          178  +AC_REQUIRE([AC_PROG_CC])dnl
          179  +AC_REQUIRE([LT_PATH_LD])dnl
          180  +AC_REQUIRE([LT_PATH_NM])dnl
          181  +dnl
          182  +AC_REQUIRE([AC_PROG_LN_S])dnl
          183  +test -z "$LN_S" && LN_S="ln -s"
          184  +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl
          185  +dnl
          186  +AC_REQUIRE([LT_CMD_MAX_LEN])dnl
          187  +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl
          188  +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl
          189  +dnl
          190  +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
          191  +m4_require([_LT_CHECK_SHELL_FEATURES])dnl
          192  +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
          193  +m4_require([_LT_CMD_RELOAD])dnl
          194  +m4_require([_LT_CHECK_MAGIC_METHOD])dnl
          195  +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
          196  +m4_require([_LT_CMD_OLD_ARCHIVE])dnl
          197  +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
          198  +m4_require([_LT_WITH_SYSROOT])dnl
          199  +
          200  +_LT_CONFIG_LIBTOOL_INIT([
          201  +# See if we are running on zsh, and set the options which allow our
          202  +# commands through without removal of \ escapes INIT.
          203  +if test -n "\${ZSH_VERSION+set}" ; then
          204  +   setopt NO_GLOB_SUBST
          205  +fi
          206  +])
          207  +if test -n "${ZSH_VERSION+set}" ; then
          208  +   setopt NO_GLOB_SUBST
          209  +fi
          210  +
          211  +_LT_CHECK_OBJDIR
          212  +
          213  +m4_require([_LT_TAG_COMPILER])dnl
          214  +
          215  +case $host_os in
          216  +aix3*)
          217  +  # AIX sometimes has problems with the GCC collect2 program.  For some
          218  +  # reason, if we set the COLLECT_NAMES environment variable, the problems
          219  +  # vanish in a puff of smoke.
          220  +  if test "X${COLLECT_NAMES+set}" != Xset; then
          221  +    COLLECT_NAMES=
          222  +    export COLLECT_NAMES
          223  +  fi
          224  +  ;;
          225  +esac
          226  +
          227  +# Global variables:
          228  +ofile=libtool
          229  +can_build_shared=yes
          230  +
          231  +# All known linkers require a `.a' archive for static linking (except MSVC,
          232  +# which needs '.lib').
          233  +libext=a
          234  +
          235  +with_gnu_ld="$lt_cv_prog_gnu_ld"
          236  +
          237  +old_CC="$CC"
          238  +old_CFLAGS="$CFLAGS"
          239  +
          240  +# Set sane defaults for various variables
          241  +test -z "$CC" && CC=cc
          242  +test -z "$LTCC" && LTCC=$CC
          243  +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
          244  +test -z "$LD" && LD=ld
          245  +test -z "$ac_objext" && ac_objext=o
          246  +
          247  +_LT_CC_BASENAME([$compiler])
          248  +
          249  +# Only perform the check for file, if the check method requires it
          250  +test -z "$MAGIC_CMD" && MAGIC_CMD=file
          251  +case $deplibs_check_method in
          252  +file_magic*)
          253  +  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
          254  +    _LT_PATH_MAGIC
          255  +  fi
          256  +  ;;
          257  +esac
          258  +
          259  +# Use C for the default configuration in the libtool script
          260  +LT_SUPPORTED_TAG([CC])
          261  +_LT_LANG_C_CONFIG
          262  +_LT_LANG_DEFAULT_CONFIG
          263  +_LT_CONFIG_COMMANDS
          264  +])# _LT_SETUP
          265  +
          266  +
          267  +# _LT_PREPARE_SED_QUOTE_VARS
          268  +# --------------------------
          269  +# Define a few sed substitution that help us do robust quoting.
          270  +m4_defun([_LT_PREPARE_SED_QUOTE_VARS],
          271  +[# Backslashify metacharacters that are still active within
          272  +# double-quoted strings.
          273  +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g'
          274  +
          275  +# Same as above, but do not quote variable references.
          276  +double_quote_subst='s/\([["`\\]]\)/\\\1/g'
          277  +
          278  +# Sed substitution to delay expansion of an escaped shell variable in a
          279  +# double_quote_subst'ed string.
          280  +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
          281  +
          282  +# Sed substitution to delay expansion of an escaped single quote.
          283  +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
          284  +
          285  +# Sed substitution to avoid accidental globbing in evaled expressions
          286  +no_glob_subst='s/\*/\\\*/g'
          287  +])
          288  +
          289  +# _LT_PROG_LTMAIN
          290  +# ---------------
          291  +# Note that this code is called both from `configure', and `config.status'
          292  +# now that we use AC_CONFIG_COMMANDS to generate libtool.  Notably,
          293  +# `config.status' has no value for ac_aux_dir unless we are using Automake,
          294  +# so we pass a copy along to make sure it has a sensible value anyway.
          295  +m4_defun([_LT_PROG_LTMAIN],
          296  +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl
          297  +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir'])
          298  +ltmain="$ac_aux_dir/ltmain.sh"
          299  +])# _LT_PROG_LTMAIN
          300  +
          301  +
          302  +
          303  +# So that we can recreate a full libtool script including additional
          304  +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS
          305  +# in macros and then make a single call at the end using the `libtool'
          306  +# label.
          307  +
          308  +
          309  +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS])
          310  +# ----------------------------------------
          311  +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later.
          312  +m4_define([_LT_CONFIG_LIBTOOL_INIT],
          313  +[m4_ifval([$1],
          314  +          [m4_append([_LT_OUTPUT_LIBTOOL_INIT],
          315  +                     [$1
          316  +])])])
          317  +
          318  +# Initialize.
          319  +m4_define([_LT_OUTPUT_LIBTOOL_INIT])
          320  +
          321  +
          322  +# _LT_CONFIG_LIBTOOL([COMMANDS])
          323  +# ------------------------------
          324  +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later.
          325  +m4_define([_LT_CONFIG_LIBTOOL],
          326  +[m4_ifval([$1],
          327  +          [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS],
          328  +                     [$1
          329  +])])])
          330  +
          331  +# Initialize.
          332  +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS])
          333  +
          334  +
          335  +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS])
          336  +# -----------------------------------------------------
          337  +m4_defun([_LT_CONFIG_SAVE_COMMANDS],
          338  +[_LT_CONFIG_LIBTOOL([$1])
          339  +_LT_CONFIG_LIBTOOL_INIT([$2])
          340  +])
          341  +
          342  +
          343  +# _LT_FORMAT_COMMENT([COMMENT])
          344  +# -----------------------------
          345  +# Add leading comment marks to the start of each line, and a trailing
          346  +# full-stop to the whole comment if one is not present already.
          347  +m4_define([_LT_FORMAT_COMMENT],
          348  +[m4_ifval([$1], [
          349  +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])],
          350  +              [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.])
          351  +)])
          352  +
          353  +
          354  +
          355  +
          356  +
          357  +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?])
          358  +# -------------------------------------------------------------------
          359  +# CONFIGNAME is the name given to the value in the libtool script.
          360  +# VARNAME is the (base) name used in the configure script.
          361  +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on
          362  +# VARNAME.  Any other value will be used directly.
          363  +m4_define([_LT_DECL],
          364  +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ],
          365  +    [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name],
          366  +	[m4_ifval([$1], [$1], [$2])])
          367  +    lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3])
          368  +    m4_ifval([$4],
          369  +	[lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])])
          370  +    lt_dict_add_subkey([lt_decl_dict], [$2],
          371  +	[tagged?], [m4_ifval([$5], [yes], [no])])])
          372  +])
          373  +
          374  +
          375  +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION])
          376  +# --------------------------------------------------------
          377  +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])])
          378  +
          379  +
          380  +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...])
          381  +# ------------------------------------------------
          382  +m4_define([lt_decl_tag_varnames],
          383  +[_lt_decl_filter([tagged?], [yes], $@)])
          384  +
          385  +
          386  +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..])
          387  +# ---------------------------------------------------------
          388  +m4_define([_lt_decl_filter],
          389  +[m4_case([$#],
          390  +  [0], [m4_fatal([$0: too few arguments: $#])],
          391  +  [1], [m4_fatal([$0: too few arguments: $#: $1])],
          392  +  [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)],
          393  +  [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)],
          394  +  [lt_dict_filter([lt_decl_dict], $@)])[]dnl
          395  +])
          396  +
          397  +
          398  +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...])
          399  +# --------------------------------------------------
          400  +m4_define([lt_decl_quote_varnames],
          401  +[_lt_decl_filter([value], [1], $@)])
          402  +
          403  +
          404  +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...])
          405  +# ---------------------------------------------------
          406  +m4_define([lt_decl_dquote_varnames],
          407  +[_lt_decl_filter([value], [2], $@)])
          408  +
          409  +
          410  +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...])
          411  +# ---------------------------------------------------
          412  +m4_define([lt_decl_varnames_tagged],
          413  +[m4_assert([$# <= 2])dnl
          414  +_$0(m4_quote(m4_default([$1], [[, ]])),
          415  +    m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]),
          416  +    m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))])
          417  +m4_define([_lt_decl_varnames_tagged],
          418  +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])])
          419  +
          420  +
          421  +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...])
          422  +# ------------------------------------------------
          423  +m4_define([lt_decl_all_varnames],
          424  +[_$0(m4_quote(m4_default([$1], [[, ]])),
          425  +     m4_if([$2], [],
          426  +	   m4_quote(lt_decl_varnames),
          427  +	m4_quote(m4_shift($@))))[]dnl
          428  +])
          429  +m4_define([_lt_decl_all_varnames],
          430  +[lt_join($@, lt_decl_varnames_tagged([$1],
          431  +			lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl
          432  +])
          433  +
          434  +
          435  +# _LT_CONFIG_STATUS_DECLARE([VARNAME])
          436  +# ------------------------------------
          437  +# Quote a variable value, and forward it to `config.status' so that its
          438  +# declaration there will have the same value as in `configure'.  VARNAME
          439  +# must have a single quote delimited value for this to work.
          440  +m4_define([_LT_CONFIG_STATUS_DECLARE],
          441  +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`'])
          442  +
          443  +
          444  +# _LT_CONFIG_STATUS_DECLARATIONS
          445  +# ------------------------------
          446  +# We delimit libtool config variables with single quotes, so when
          447  +# we write them to config.status, we have to be sure to quote all
          448  +# embedded single quotes properly.  In configure, this macro expands
          449  +# each variable declared with _LT_DECL (and _LT_TAGDECL) into:
          450  +#
          451  +#    <var>='`$ECHO "$<var>" | $SED "$delay_single_quote_subst"`'
          452  +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS],
          453  +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames),
          454  +    [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])])
          455  +
          456  +
          457  +# _LT_LIBTOOL_TAGS
          458  +# ----------------
          459  +# Output comment and list of tags supported by the script
          460  +m4_defun([_LT_LIBTOOL_TAGS],
          461  +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl
          462  +available_tags="_LT_TAGS"dnl
          463  +])
          464  +
          465  +
          466  +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG])
          467  +# -----------------------------------
          468  +# Extract the dictionary values for VARNAME (optionally with TAG) and
          469  +# expand to a commented shell variable setting:
          470  +#
          471  +#    # Some comment about what VAR is for.
          472  +#    visible_name=$lt_internal_name
          473  +m4_define([_LT_LIBTOOL_DECLARE],
          474  +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1],
          475  +					   [description])))[]dnl
          476  +m4_pushdef([_libtool_name],
          477  +    m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl
          478  +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])),
          479  +    [0], [_libtool_name=[$]$1],
          480  +    [1], [_libtool_name=$lt_[]$1],
          481  +    [2], [_libtool_name=$lt_[]$1],
          482  +    [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl
          483  +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl
          484  +])
          485  +
          486  +
          487  +# _LT_LIBTOOL_CONFIG_VARS
          488  +# -----------------------
          489  +# Produce commented declarations of non-tagged libtool config variables
          490  +# suitable for insertion in the LIBTOOL CONFIG section of the `libtool'
          491  +# script.  Tagged libtool config variables (even for the LIBTOOL CONFIG
          492  +# section) are produced by _LT_LIBTOOL_TAG_VARS.
          493  +m4_defun([_LT_LIBTOOL_CONFIG_VARS],
          494  +[m4_foreach([_lt_var],
          495  +    m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)),
          496  +    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])])
          497  +
          498  +
          499  +# _LT_LIBTOOL_TAG_VARS(TAG)
          500  +# -------------------------
          501  +m4_define([_LT_LIBTOOL_TAG_VARS],
          502  +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames),
          503  +    [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])])
          504  +
          505  +
          506  +# _LT_TAGVAR(VARNAME, [TAGNAME])
          507  +# ------------------------------
          508  +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])])
          509  +
          510  +
          511  +# _LT_CONFIG_COMMANDS
          512  +# -------------------
          513  +# Send accumulated output to $CONFIG_STATUS.  Thanks to the lists of
          514  +# variables for single and double quote escaping we saved from calls
          515  +# to _LT_DECL, we can put quote escaped variables declarations
          516  +# into `config.status', and then the shell code to quote escape them in
          517  +# for loops in `config.status'.  Finally, any additional code accumulated
          518  +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded.
          519  +m4_defun([_LT_CONFIG_COMMANDS],
          520  +[AC_PROVIDE_IFELSE([LT_OUTPUT],
          521  +	dnl If the libtool generation code has been placed in $CONFIG_LT,
          522  +	dnl instead of duplicating it all over again into config.status,
          523  +	dnl then we will have config.status run $CONFIG_LT later, so it
          524  +	dnl needs to know what name is stored there:
          525  +        [AC_CONFIG_COMMANDS([libtool],
          526  +            [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])],
          527  +    dnl If the libtool generation code is destined for config.status,
          528  +    dnl expand the accumulated commands and init code now:
          529  +    [AC_CONFIG_COMMANDS([libtool],
          530  +        [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])])
          531  +])#_LT_CONFIG_COMMANDS
          532  +
          533  +
          534  +# Initialize.
          535  +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT],
          536  +[
          537  +
          538  +# The HP-UX ksh and POSIX shell print the target directory to stdout
          539  +# if CDPATH is set.
          540  +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
          541  +
          542  +sed_quote_subst='$sed_quote_subst'
          543  +double_quote_subst='$double_quote_subst'
          544  +delay_variable_subst='$delay_variable_subst'
          545  +_LT_CONFIG_STATUS_DECLARATIONS
          546  +LTCC='$LTCC'
          547  +LTCFLAGS='$LTCFLAGS'
          548  +compiler='$compiler_DEFAULT'
          549  +
          550  +# A function that is used when there is no print builtin or printf.
          551  +func_fallback_echo ()
          552  +{
          553  +  eval 'cat <<_LTECHO_EOF
          554  +\$[]1
          555  +_LTECHO_EOF'
          556  +}
          557  +
          558  +# Quote evaled strings.
          559  +for var in lt_decl_all_varnames([[ \
          560  +]], lt_decl_quote_varnames); do
          561  +    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
          562  +    *[[\\\\\\\`\\"\\\$]]*)
          563  +      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
          564  +      ;;
          565  +    *)
          566  +      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
          567  +      ;;
          568  +    esac
          569  +done
          570  +
          571  +# Double-quote double-evaled strings.
          572  +for var in lt_decl_all_varnames([[ \
          573  +]], lt_decl_dquote_varnames); do
          574  +    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
          575  +    *[[\\\\\\\`\\"\\\$]]*)
          576  +      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
          577  +      ;;
          578  +    *)
          579  +      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
          580  +      ;;
          581  +    esac
          582  +done
          583  +
          584  +_LT_OUTPUT_LIBTOOL_INIT
          585  +])
          586  +
          587  +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT])
          588  +# ------------------------------------
          589  +# Generate a child script FILE with all initialization necessary to
          590  +# reuse the environment learned by the parent script, and make the
          591  +# file executable.  If COMMENT is supplied, it is inserted after the
          592  +# `#!' sequence but before initialization text begins.  After this
          593  +# macro, additional text can be appended to FILE to form the body of
          594  +# the child script.  The macro ends with non-zero status if the
          595  +# file could not be fully written (such as if the disk is full).
          596  +m4_ifdef([AS_INIT_GENERATED],
          597  +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])],
          598  +[m4_defun([_LT_GENERATED_FILE_INIT],
          599  +[m4_require([AS_PREPARE])]dnl
          600  +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl
          601  +[lt_write_fail=0
          602  +cat >$1 <<_ASEOF || lt_write_fail=1
          603  +#! $SHELL
          604  +# Generated by $as_me.
          605  +$2
          606  +SHELL=\${CONFIG_SHELL-$SHELL}
          607  +export SHELL
          608  +_ASEOF
          609  +cat >>$1 <<\_ASEOF || lt_write_fail=1
          610  +AS_SHELL_SANITIZE
          611  +_AS_PREPARE
          612  +exec AS_MESSAGE_FD>&1
          613  +_ASEOF
          614  +test $lt_write_fail = 0 && chmod +x $1[]dnl
          615  +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT
          616  +
          617  +# LT_OUTPUT
          618  +# ---------
          619  +# This macro allows early generation of the libtool script (before
          620  +# AC_OUTPUT is called), incase it is used in configure for compilation
          621  +# tests.
          622  +AC_DEFUN([LT_OUTPUT],
          623  +[: ${CONFIG_LT=./config.lt}
          624  +AC_MSG_NOTICE([creating $CONFIG_LT])
          625  +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"],
          626  +[# Run this file to recreate a libtool stub with the current configuration.])
          627  +
          628  +cat >>"$CONFIG_LT" <<\_LTEOF
          629  +lt_cl_silent=false
          630  +exec AS_MESSAGE_LOG_FD>>config.log
          631  +{
          632  +  echo
          633  +  AS_BOX([Running $as_me.])
          634  +} >&AS_MESSAGE_LOG_FD
          635  +
          636  +lt_cl_help="\
          637  +\`$as_me' creates a local libtool stub from the current configuration,
          638  +for use in further configure time tests before the real libtool is
          639  +generated.
          640  +
          641  +Usage: $[0] [[OPTIONS]]
          642  +
          643  +  -h, --help      print this help, then exit
          644  +  -V, --version   print version number, then exit
          645  +  -q, --quiet     do not print progress messages
          646  +  -d, --debug     don't remove temporary files
          647  +
          648  +Report bugs to <bug-libtool@gnu.org>."
          649  +
          650  +lt_cl_version="\
          651  +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl
          652  +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION])
          653  +configured by $[0], generated by m4_PACKAGE_STRING.
          654  +
          655  +Copyright (C) 2010 Free Software Foundation, Inc.
          656  +This config.lt script is free software; the Free Software Foundation
          657  +gives unlimited permision to copy, distribute and modify it."
          658  +
          659  +while test $[#] != 0
          660  +do
          661  +  case $[1] in
          662  +    --version | --v* | -V )
          663  +      echo "$lt_cl_version"; exit 0 ;;
          664  +    --help | --h* | -h )
          665  +      echo "$lt_cl_help"; exit 0 ;;
          666  +    --debug | --d* | -d )
          667  +      debug=: ;;
          668  +    --quiet | --q* | --silent | --s* | -q )
          669  +      lt_cl_silent=: ;;
          670  +
          671  +    -*) AC_MSG_ERROR([unrecognized option: $[1]
          672  +Try \`$[0] --help' for more information.]) ;;
          673  +
          674  +    *) AC_MSG_ERROR([unrecognized argument: $[1]
          675  +Try \`$[0] --help' for more information.]) ;;
          676  +  esac
          677  +  shift
          678  +done
          679  +
          680  +if $lt_cl_silent; then
          681  +  exec AS_MESSAGE_FD>/dev/null
          682  +fi
          683  +_LTEOF
          684  +
          685  +cat >>"$CONFIG_LT" <<_LTEOF
          686  +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT
          687  +_LTEOF
          688  +
          689  +cat >>"$CONFIG_LT" <<\_LTEOF
          690  +AC_MSG_NOTICE([creating $ofile])
          691  +_LT_OUTPUT_LIBTOOL_COMMANDS
          692  +AS_EXIT(0)
          693  +_LTEOF
          694  +chmod +x "$CONFIG_LT"
          695  +
          696  +# configure is writing to config.log, but config.lt does its own redirection,
          697  +# appending to config.log, which fails on DOS, as config.log is still kept
          698  +# open by configure.  Here we exec the FD to /dev/null, effectively closing
          699  +# config.log, so it can be properly (re)opened and appended to by config.lt.
          700  +lt_cl_success=:
          701  +test "$silent" = yes &&
          702  +  lt_config_lt_args="$lt_config_lt_args --quiet"
          703  +exec AS_MESSAGE_LOG_FD>/dev/null
          704  +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
          705  +exec AS_MESSAGE_LOG_FD>>config.log
          706  +$lt_cl_success || AS_EXIT(1)
          707  +])# LT_OUTPUT
          708  +
          709  +
          710  +# _LT_CONFIG(TAG)
          711  +# ---------------
          712  +# If TAG is the built-in tag, create an initial libtool script with a
          713  +# default configuration from the untagged config vars.  Otherwise add code
          714  +# to config.status for appending the configuration named by TAG from the
          715  +# matching tagged config vars.
          716  +m4_defun([_LT_CONFIG],
          717  +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
          718  +_LT_CONFIG_SAVE_COMMANDS([
          719  +  m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl
          720  +  m4_if(_LT_TAG, [C], [
          721  +    # See if we are running on zsh, and set the options which allow our
          722  +    # commands through without removal of \ escapes.
          723  +    if test -n "${ZSH_VERSION+set}" ; then
          724  +      setopt NO_GLOB_SUBST
          725  +    fi
          726  +
          727  +    cfgfile="${ofile}T"
          728  +    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
          729  +    $RM "$cfgfile"
          730  +
          731  +    cat <<_LT_EOF >> "$cfgfile"
          732  +#! $SHELL
          733  +
          734  +# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
          735  +# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
          736  +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
          737  +# NOTE: Changes made to this file will be lost: look at ltmain.sh.
          738  +#
          739  +_LT_COPYING
          740  +_LT_LIBTOOL_TAGS
          741  +
          742  +# ### BEGIN LIBTOOL CONFIG
          743  +_LT_LIBTOOL_CONFIG_VARS
          744  +_LT_LIBTOOL_TAG_VARS
          745  +# ### END LIBTOOL CONFIG
          746  +
          747  +_LT_EOF
          748  +
          749  +  case $host_os in
          750  +  aix3*)
          751  +    cat <<\_LT_EOF >> "$cfgfile"
          752  +# AIX sometimes has problems with the GCC collect2 program.  For some
          753  +# reason, if we set the COLLECT_NAMES environment variable, the problems
          754  +# vanish in a puff of smoke.
          755  +if test "X${COLLECT_NAMES+set}" != Xset; then
          756  +  COLLECT_NAMES=
          757  +  export COLLECT_NAMES
          758  +fi
          759  +_LT_EOF
          760  +    ;;
          761  +  esac
          762  +
          763  +  _LT_PROG_LTMAIN
          764  +
          765  +  # We use sed instead of cat because bash on DJGPP gets confused if
          766  +  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
          767  +  # text mode, it properly converts lines to CR/LF.  This bash problem
          768  +  # is reportedly fixed, but why not run on old versions too?
          769  +  sed '$q' "$ltmain" >> "$cfgfile" \
          770  +     || (rm -f "$cfgfile"; exit 1)
          771  +
          772  +  _LT_PROG_REPLACE_SHELLFNS
          773  +
          774  +   mv -f "$cfgfile" "$ofile" ||
          775  +    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
          776  +  chmod +x "$ofile"
          777  +],
          778  +[cat <<_LT_EOF >> "$ofile"
          779  +
          780  +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded
          781  +dnl in a comment (ie after a #).
          782  +# ### BEGIN LIBTOOL TAG CONFIG: $1
          783  +_LT_LIBTOOL_TAG_VARS(_LT_TAG)
          784  +# ### END LIBTOOL TAG CONFIG: $1
          785  +_LT_EOF
          786  +])dnl /m4_if
          787  +],
          788  +[m4_if([$1], [], [
          789  +    PACKAGE='$PACKAGE'
          790  +    VERSION='$VERSION'
          791  +    TIMESTAMP='$TIMESTAMP'
          792  +    RM='$RM'
          793  +    ofile='$ofile'], [])
          794  +])dnl /_LT_CONFIG_SAVE_COMMANDS
          795  +])# _LT_CONFIG
          796  +
          797  +
          798  +# LT_SUPPORTED_TAG(TAG)
          799  +# ---------------------
          800  +# Trace this macro to discover what tags are supported by the libtool
          801  +# --tag option, using:
          802  +#    autoconf --trace 'LT_SUPPORTED_TAG:$1'
          803  +AC_DEFUN([LT_SUPPORTED_TAG], [])
          804  +
          805  +
          806  +# C support is built-in for now
          807  +m4_define([_LT_LANG_C_enabled], [])
          808  +m4_define([_LT_TAGS], [])
          809  +
          810  +
          811  +# LT_LANG(LANG)
          812  +# -------------
          813  +# Enable libtool support for the given language if not already enabled.
          814  +AC_DEFUN([LT_LANG],
          815  +[AC_BEFORE([$0], [LT_OUTPUT])dnl
          816  +m4_case([$1],
          817  +  [C],			[_LT_LANG(C)],
          818  +  [C++],		[_LT_LANG(CXX)],
          819  +  [Java],		[_LT_LANG(GCJ)],
          820  +  [Fortran 77],		[_LT_LANG(F77)],
          821  +  [Fortran],		[_LT_LANG(FC)],
          822  +  [Windows Resource],	[_LT_LANG(RC)],
          823  +  [m4_ifdef([_LT_LANG_]$1[_CONFIG],
          824  +    [_LT_LANG($1)],
          825  +    [m4_fatal([$0: unsupported language: "$1"])])])dnl
          826  +])# LT_LANG
          827  +
          828  +
          829  +# _LT_LANG(LANGNAME)
          830  +# ------------------
          831  +m4_defun([_LT_LANG],
          832  +[m4_ifdef([_LT_LANG_]$1[_enabled], [],
          833  +  [LT_SUPPORTED_TAG([$1])dnl
          834  +  m4_append([_LT_TAGS], [$1 ])dnl
          835  +  m4_define([_LT_LANG_]$1[_enabled], [])dnl
          836  +  _LT_LANG_$1_CONFIG($1)])dnl
          837  +])# _LT_LANG
          838  +
          839  +
          840  +# _LT_LANG_DEFAULT_CONFIG
          841  +# -----------------------
          842  +m4_defun([_LT_LANG_DEFAULT_CONFIG],
          843  +[AC_PROVIDE_IFELSE([AC_PROG_CXX],
          844  +  [LT_LANG(CXX)],
          845  +  [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])])
          846  +
          847  +AC_PROVIDE_IFELSE([AC_PROG_F77],
          848  +  [LT_LANG(F77)],
          849  +  [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])])
          850  +
          851  +AC_PROVIDE_IFELSE([AC_PROG_FC],
          852  +  [LT_LANG(FC)],
          853  +  [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])])
          854  +
          855  +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal
          856  +dnl pulling things in needlessly.
          857  +AC_PROVIDE_IFELSE([AC_PROG_GCJ],
          858  +  [LT_LANG(GCJ)],
          859  +  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
          860  +    [LT_LANG(GCJ)],
          861  +    [AC_PROVIDE_IFELSE([LT_PROG_GCJ],
          862  +      [LT_LANG(GCJ)],
          863  +      [m4_ifdef([AC_PROG_GCJ],
          864  +	[m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])])
          865  +       m4_ifdef([A][M_PROG_GCJ],
          866  +	[m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])])
          867  +       m4_ifdef([LT_PROG_GCJ],
          868  +	[m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])])
          869  +
          870  +AC_PROVIDE_IFELSE([LT_PROG_RC],
          871  +  [LT_LANG(RC)],
          872  +  [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])])
          873  +])# _LT_LANG_DEFAULT_CONFIG
          874  +
          875  +# Obsolete macros:
          876  +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)])
          877  +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)])
          878  +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)])
          879  +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)])
          880  +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)])
          881  +dnl aclocal-1.4 backwards compatibility:
          882  +dnl AC_DEFUN([AC_LIBTOOL_CXX], [])
          883  +dnl AC_DEFUN([AC_LIBTOOL_F77], [])
          884  +dnl AC_DEFUN([AC_LIBTOOL_FC], [])
          885  +dnl AC_DEFUN([AC_LIBTOOL_GCJ], [])
          886  +dnl AC_DEFUN([AC_LIBTOOL_RC], [])
          887  +
          888  +
          889  +# _LT_TAG_COMPILER
          890  +# ----------------
          891  +m4_defun([_LT_TAG_COMPILER],
          892  +[AC_REQUIRE([AC_PROG_CC])dnl
          893  +
          894  +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl
          895  +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl
          896  +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl
          897  +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl
          898  +
          899  +# If no C compiler was specified, use CC.
          900  +LTCC=${LTCC-"$CC"}
          901  +
          902  +# If no C compiler flags were specified, use CFLAGS.
          903  +LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
          904  +
          905  +# Allow CC to be a program name with arguments.
          906  +compiler=$CC
          907  +])# _LT_TAG_COMPILER
          908  +
          909  +
          910  +# _LT_COMPILER_BOILERPLATE
          911  +# ------------------------
          912  +# Check for compiler boilerplate output or warnings with
          913  +# the simple compiler test code.
          914  +m4_defun([_LT_COMPILER_BOILERPLATE],
          915  +[m4_require([_LT_DECL_SED])dnl
          916  +ac_outfile=conftest.$ac_objext
          917  +echo "$lt_simple_compile_test_code" >conftest.$ac_ext
          918  +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
          919  +_lt_compiler_boilerplate=`cat conftest.err`
          920  +$RM conftest*
          921  +])# _LT_COMPILER_BOILERPLATE
          922  +
          923  +
          924  +# _LT_LINKER_BOILERPLATE
          925  +# ----------------------
          926  +# Check for linker boilerplate output or warnings with
          927  +# the simple link test code.
          928  +m4_defun([_LT_LINKER_BOILERPLATE],
          929  +[m4_require([_LT_DECL_SED])dnl
          930  +ac_outfile=conftest.$ac_objext
          931  +echo "$lt_simple_link_test_code" >conftest.$ac_ext
          932  +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
          933  +_lt_linker_boilerplate=`cat conftest.err`
          934  +$RM -r conftest*
          935  +])# _LT_LINKER_BOILERPLATE
          936  +
          937  +# _LT_REQUIRED_DARWIN_CHECKS
          938  +# -------------------------
          939  +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[
          940  +  case $host_os in
          941  +    rhapsody* | darwin*)
          942  +    AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:])
          943  +    AC_CHECK_TOOL([NMEDIT], [nmedit], [:])
          944  +    AC_CHECK_TOOL([LIPO], [lipo], [:])
          945  +    AC_CHECK_TOOL([OTOOL], [otool], [:])
          946  +    AC_CHECK_TOOL([OTOOL64], [otool64], [:])
          947  +    _LT_DECL([], [DSYMUTIL], [1],
          948  +      [Tool to manipulate archived DWARF debug symbol files on Mac OS X])
          949  +    _LT_DECL([], [NMEDIT], [1],
          950  +      [Tool to change global to local symbols on Mac OS X])
          951  +    _LT_DECL([], [LIPO], [1],
          952  +      [Tool to manipulate fat objects and archives on Mac OS X])
          953  +    _LT_DECL([], [OTOOL], [1],
          954  +      [ldd/readelf like tool for Mach-O binaries on Mac OS X])
          955  +    _LT_DECL([], [OTOOL64], [1],
          956  +      [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4])
          957  +
          958  +    AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod],
          959  +      [lt_cv_apple_cc_single_mod=no
          960  +      if test -z "${LT_MULTI_MODULE}"; then
          961  +	# By default we will add the -single_module flag. You can override
          962  +	# by either setting the environment variable LT_MULTI_MODULE
          963  +	# non-empty at configure time, or by adding -multi_module to the
          964  +	# link flags.
          965  +	rm -rf libconftest.dylib*
          966  +	echo "int foo(void){return 1;}" > conftest.c
          967  +	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
          968  +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD
          969  +	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
          970  +	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
          971  +        _lt_result=$?
          972  +	if test -f libconftest.dylib && test ! -s conftest.err && test $_lt_result = 0; then
          973  +	  lt_cv_apple_cc_single_mod=yes
          974  +	else
          975  +	  cat conftest.err >&AS_MESSAGE_LOG_FD
          976  +	fi
          977  +	rm -rf libconftest.dylib*
          978  +	rm -f conftest.*
          979  +      fi])
          980  +    AC_CACHE_CHECK([for -exported_symbols_list linker flag],
          981  +      [lt_cv_ld_exported_symbols_list],
          982  +      [lt_cv_ld_exported_symbols_list=no
          983  +      save_LDFLAGS=$LDFLAGS
          984  +      echo "_main" > conftest.sym
          985  +      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
          986  +      AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
          987  +	[lt_cv_ld_exported_symbols_list=yes],
          988  +	[lt_cv_ld_exported_symbols_list=no])
          989  +	LDFLAGS="$save_LDFLAGS"
          990  +    ])
          991  +    AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load],
          992  +      [lt_cv_ld_force_load=no
          993  +      cat > conftest.c << _LT_EOF
          994  +int forced_loaded() { return 2;}
          995  +_LT_EOF
          996  +      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD
          997  +      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD
          998  +      echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD
          999  +      $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD
         1000  +      echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD
         1001  +      $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD
         1002  +      cat > conftest.c << _LT_EOF
         1003  +int main() { return 0;}
         1004  +_LT_EOF
         1005  +      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD
         1006  +      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
         1007  +      _lt_result=$?
         1008  +      if test -f conftest && test ! -s conftest.err && test $_lt_result = 0 && $GREP forced_load conftest 2>&1 >/dev/null; then
         1009  +	lt_cv_ld_force_load=yes
         1010  +      else
         1011  +	cat conftest.err >&AS_MESSAGE_LOG_FD
         1012  +      fi
         1013  +        rm -f conftest.err libconftest.a conftest conftest.c
         1014  +        rm -rf conftest.dSYM
         1015  +    ])
         1016  +    case $host_os in
         1017  +    rhapsody* | darwin1.[[012]])
         1018  +      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
         1019  +    darwin1.*)
         1020  +      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
         1021  +    darwin*) # darwin 5.x on
         1022  +      # if running on 10.5 or later, the deployment target defaults
         1023  +      # to the OS version, if on x86, and 10.4, the deployment
         1024  +      # target defaults to 10.4. Don't you love it?
         1025  +      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
         1026  +	10.0,*86*-darwin8*|10.0,*-darwin[[91]]*)
         1027  +	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
         1028  +	10.[[012]]*)
         1029  +	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
         1030  +	10.*)
         1031  +	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
         1032  +      esac
         1033  +    ;;
         1034  +  esac
         1035  +    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
         1036  +      _lt_dar_single_mod='$single_module'
         1037  +    fi
         1038  +    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
         1039  +      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
         1040  +    else
         1041  +      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
         1042  +    fi
         1043  +    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
         1044  +      _lt_dsymutil='~$DSYMUTIL $lib || :'
         1045  +    else
         1046  +      _lt_dsymutil=
         1047  +    fi
         1048  +    ;;
         1049  +  esac
         1050  +])
         1051  +
         1052  +
         1053  +# _LT_DARWIN_LINKER_FEATURES
         1054  +# --------------------------
         1055  +# Checks for linker and compiler features on darwin
         1056  +m4_defun([_LT_DARWIN_LINKER_FEATURES],
         1057  +[
         1058  +  m4_require([_LT_REQUIRED_DARWIN_CHECKS])
         1059  +  _LT_TAGVAR(archive_cmds_need_lc, $1)=no
         1060  +  _LT_TAGVAR(hardcode_direct, $1)=no
         1061  +  _LT_TAGVAR(hardcode_automatic, $1)=yes
         1062  +  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
         1063  +  if test "$lt_cv_ld_force_load" = "yes"; then
         1064  +    _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
         1065  +  else
         1066  +    _LT_TAGVAR(whole_archive_flag_spec, $1)=''
         1067  +  fi
         1068  +  _LT_TAGVAR(link_all_deplibs, $1)=yes
         1069  +  _LT_TAGVAR(allow_undefined_flag, $1)="$_lt_dar_allow_undefined"
         1070  +  case $cc_basename in
         1071  +     ifort*) _lt_dar_can_shared=yes ;;
         1072  +     *) _lt_dar_can_shared=$GCC ;;
         1073  +  esac
         1074  +  if test "$_lt_dar_can_shared" = "yes"; then
         1075  +    output_verbose_link_cmd=func_echo_all
         1076  +    _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}"
         1077  +    _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
         1078  +    _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}"
         1079  +    _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}"
         1080  +    m4_if([$1], [CXX],
         1081  +[   if test "$lt_cv_apple_cc_single_mod" != "yes"; then
         1082  +      _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}"
         1083  +      _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}"
         1084  +    fi
         1085  +],[])
         1086  +  else
         1087  +  _LT_TAGVAR(ld_shlibs, $1)=no
         1088  +  fi
         1089  +])
         1090  +
         1091  +# _LT_SYS_MODULE_PATH_AIX([TAGNAME])
         1092  +# ----------------------------------
         1093  +# Links a minimal program and checks the executable
         1094  +# for the system default hardcoded library path. In most cases,
         1095  +# this is /usr/lib:/lib, but when the MPI compilers are used
         1096  +# the location of the communication and MPI libs are included too.
         1097  +# If we don't find anything, use the default library path according
         1098  +# to the aix ld manual.
         1099  +# Store the results from the different compilers for each TAGNAME.
         1100  +# Allow to override them for all tags through lt_cv_aix_libpath.
         1101  +m4_defun([_LT_SYS_MODULE_PATH_AIX],
         1102  +[m4_require([_LT_DECL_SED])dnl
         1103  +if test "${lt_cv_aix_libpath+set}" = set; then
         1104  +  aix_libpath=$lt_cv_aix_libpath
         1105  +else
         1106  +  AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])],
         1107  +  [AC_LINK_IFELSE([AC_LANG_PROGRAM],[
         1108  +  lt_aix_libpath_sed='[
         1109  +      /Import File Strings/,/^$/ {
         1110  +	  /^0/ {
         1111  +	      s/^0  *\([^ ]*\) *$/\1/
         1112  +	      p
         1113  +	  }
         1114  +      }]'
         1115  +  _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
         1116  +  # Check for a 64-bit object if we didn't find anything.
         1117  +  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
         1118  +    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
         1119  +  fi],[])
         1120  +  if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then
         1121  +    _LT_TAGVAR([lt_cv_aix_libpath_], [$1])="/usr/lib:/lib"
         1122  +  fi
         1123  +  ])
         1124  +  aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])
         1125  +fi
         1126  +])# _LT_SYS_MODULE_PATH_AIX
         1127  +
         1128  +
         1129  +# _LT_SHELL_INIT(ARG)
         1130  +# -------------------
         1131  +m4_define([_LT_SHELL_INIT],
         1132  +[m4_divert_text([M4SH-INIT], [$1
         1133  +])])# _LT_SHELL_INIT
         1134  +
         1135  +
         1136  +
         1137  +# _LT_PROG_ECHO_BACKSLASH
         1138  +# -----------------------
         1139  +# Find how we can fake an echo command that does not interpret backslash.
         1140  +# In particular, with Autoconf 2.60 or later we add some code to the start
         1141  +# of the generated configure script which will find a shell with a builtin
         1142  +# printf (which we can use as an echo command).
         1143  +m4_defun([_LT_PROG_ECHO_BACKSLASH],
         1144  +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
         1145  +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
         1146  +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
         1147  +
         1148  +AC_MSG_CHECKING([how to print strings])
         1149  +# Test print first, because it will be a builtin if present.
         1150  +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
         1151  +   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
         1152  +  ECHO='print -r --'
         1153  +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
         1154  +  ECHO='printf %s\n'
         1155  +else
         1156  +  # Use this function as a fallback that always works.
         1157  +  func_fallback_echo ()
         1158  +  {
         1159  +    eval 'cat <<_LTECHO_EOF
         1160  +$[]1
         1161  +_LTECHO_EOF'
         1162  +  }
         1163  +  ECHO='func_fallback_echo'
         1164  +fi
         1165  +
         1166  +# func_echo_all arg...
         1167  +# Invoke $ECHO with all args, space-separated.
         1168  +func_echo_all ()
         1169  +{
         1170  +    $ECHO "$*" 
         1171  +}
         1172  +
         1173  +case "$ECHO" in
         1174  +  printf*) AC_MSG_RESULT([printf]) ;;
         1175  +  print*) AC_MSG_RESULT([print -r]) ;;
         1176  +  *) AC_MSG_RESULT([cat]) ;;
         1177  +esac
         1178  +
         1179  +m4_ifdef([_AS_DETECT_SUGGESTED],
         1180  +[_AS_DETECT_SUGGESTED([
         1181  +  test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || (
         1182  +    ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
         1183  +    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
         1184  +    ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
         1185  +    PATH=/empty FPATH=/empty; export PATH FPATH
         1186  +    test "X`printf %s $ECHO`" = "X$ECHO" \
         1187  +      || test "X`print -r -- $ECHO`" = "X$ECHO" )])])
         1188  +
         1189  +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts])
         1190  +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes])
         1191  +])# _LT_PROG_ECHO_BACKSLASH
         1192  +
         1193  +
         1194  +# _LT_WITH_SYSROOT
         1195  +# ----------------
         1196  +AC_DEFUN([_LT_WITH_SYSROOT],
         1197  +[AC_MSG_CHECKING([for sysroot])
         1198  +AC_ARG_WITH([sysroot],
         1199  +[  --with-sysroot[=DIR] Search for dependent libraries within DIR
         1200  +                        (or the compiler's sysroot if not specified).],
         1201  +[], [with_sysroot=no])
         1202  +
         1203  +dnl lt_sysroot will always be passed unquoted.  We quote it here
         1204  +dnl in case the user passed a directory name.
         1205  +lt_sysroot=
         1206  +case ${with_sysroot} in #(
         1207  + yes)
         1208  +   if test "$GCC" = yes; then
         1209  +     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
         1210  +   fi
         1211  +   ;; #(
         1212  + /*)
         1213  +   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
         1214  +   ;; #(
         1215  + no|'')
         1216  +   ;; #(
         1217  + *)
         1218  +   AC_MSG_RESULT([${with_sysroot}])
         1219  +   AC_MSG_ERROR([The sysroot must be an absolute path.])
         1220  +   ;;
         1221  +esac
         1222  +
         1223  + AC_MSG_RESULT([${lt_sysroot:-no}])
         1224  +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl
         1225  +[dependent libraries, and in which our libraries should be installed.])])
         1226  +
         1227  +# _LT_ENABLE_LOCK
         1228  +# ---------------
         1229  +m4_defun([_LT_ENABLE_LOCK],
         1230  +[AC_ARG_ENABLE([libtool-lock],
         1231  +  [AS_HELP_STRING([--disable-libtool-lock],
         1232  +    [avoid locking (might break parallel builds)])])
         1233  +test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
         1234  +
         1235  +# Some flags need to be propagated to the compiler or linker for good
         1236  +# libtool support.
         1237  +case $host in
         1238  +ia64-*-hpux*)
         1239  +  # Find out which ABI we are using.
         1240  +  echo 'int i;' > conftest.$ac_ext
         1241  +  if AC_TRY_EVAL(ac_compile); then
         1242  +    case `/usr/bin/file conftest.$ac_objext` in
         1243  +      *ELF-32*)
         1244  +	HPUX_IA64_MODE="32"
         1245  +	;;
         1246  +      *ELF-64*)
         1247  +	HPUX_IA64_MODE="64"
         1248  +	;;
         1249  +    esac
         1250  +  fi
         1251  +  rm -rf conftest*
         1252  +  ;;
         1253  +*-*-irix6*)
         1254  +  # Find out which ABI we are using.
         1255  +  echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext
         1256  +  if AC_TRY_EVAL(ac_compile); then
         1257  +    if test "$lt_cv_prog_gnu_ld" = yes; then
         1258  +      case `/usr/bin/file conftest.$ac_objext` in
         1259  +	*32-bit*)
         1260  +	  LD="${LD-ld} -melf32bsmip"
         1261  +	  ;;
         1262  +	*N32*)
         1263  +	  LD="${LD-ld} -melf32bmipn32"
         1264  +	  ;;
         1265  +	*64-bit*)
         1266  +	  LD="${LD-ld} -melf64bmip"
         1267  +	;;
         1268  +      esac
         1269  +    else
         1270  +      case `/usr/bin/file conftest.$ac_objext` in
         1271  +	*32-bit*)
         1272  +	  LD="${LD-ld} -32"
         1273  +	  ;;
         1274  +	*N32*)
         1275  +	  LD="${LD-ld} -n32"
         1276  +	  ;;
         1277  +	*64-bit*)
         1278  +	  LD="${LD-ld} -64"
         1279  +	  ;;
         1280  +      esac
         1281  +    fi
         1282  +  fi
         1283  +  rm -rf conftest*
         1284  +  ;;
         1285  +
         1286  +x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
         1287  +s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
         1288  +  # Find out which ABI we are using.
         1289  +  echo 'int i;' > conftest.$ac_ext
         1290  +  if AC_TRY_EVAL(ac_compile); then
         1291  +    case `/usr/bin/file conftest.o` in
         1292  +      *32-bit*)
         1293  +	case $host in
         1294  +	  x86_64-*kfreebsd*-gnu)
         1295  +	    LD="${LD-ld} -m elf_i386_fbsd"
         1296  +	    ;;
         1297  +	  x86_64-*linux*)
         1298  +	    LD="${LD-ld} -m elf_i386"
         1299  +	    ;;
         1300  +	  ppc64-*linux*|powerpc64-*linux*)
         1301  +	    LD="${LD-ld} -m elf32ppclinux"
         1302  +	    ;;
         1303  +	  s390x-*linux*)
         1304  +	    LD="${LD-ld} -m elf_s390"
         1305  +	    ;;
         1306  +	  sparc64-*linux*)
         1307  +	    LD="${LD-ld} -m elf32_sparc"
         1308  +	    ;;
         1309  +	esac
         1310  +	;;
         1311  +      *64-bit*)
         1312  +	case $host in
         1313  +	  x86_64-*kfreebsd*-gnu)
         1314  +	    LD="${LD-ld} -m elf_x86_64_fbsd"
         1315  +	    ;;
         1316  +	  x86_64-*linux*)
         1317  +	    LD="${LD-ld} -m elf_x86_64"
         1318  +	    ;;
         1319  +	  ppc*-*linux*|powerpc*-*linux*)
         1320  +	    LD="${LD-ld} -m elf64ppc"
         1321  +	    ;;
         1322  +	  s390*-*linux*|s390*-*tpf*)
         1323  +	    LD="${LD-ld} -m elf64_s390"
         1324  +	    ;;
         1325  +	  sparc*-*linux*)
         1326  +	    LD="${LD-ld} -m elf64_sparc"
         1327  +	    ;;
         1328  +	esac
         1329  +	;;
         1330  +    esac
         1331  +  fi
         1332  +  rm -rf conftest*
         1333  +  ;;
         1334  +
         1335  +*-*-sco3.2v5*)
         1336  +  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
         1337  +  SAVE_CFLAGS="$CFLAGS"
         1338  +  CFLAGS="$CFLAGS -belf"
         1339  +  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
         1340  +    [AC_LANG_PUSH(C)
         1341  +     AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
         1342  +     AC_LANG_POP])
         1343  +  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
         1344  +    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
         1345  +    CFLAGS="$SAVE_CFLAGS"
         1346  +  fi
         1347  +  ;;
         1348  +sparc*-*solaris*)
         1349  +  # Find out which ABI we are using.
         1350  +  echo 'int i;' > conftest.$ac_ext
         1351  +  if AC_TRY_EVAL(ac_compile); then
         1352  +    case `/usr/bin/file conftest.o` in
         1353  +    *64-bit*)
         1354  +      case $lt_cv_prog_gnu_ld in
         1355  +      yes*) LD="${LD-ld} -m elf64_sparc" ;;
         1356  +      *)
         1357  +	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
         1358  +	  LD="${LD-ld} -64"
         1359  +	fi
         1360  +	;;
         1361  +      esac
         1362  +      ;;
         1363  +    esac
         1364  +  fi
         1365  +  rm -rf conftest*
         1366  +  ;;
         1367  +esac
         1368  +
         1369  +need_locks="$enable_libtool_lock"
         1370  +])# _LT_ENABLE_LOCK
         1371  +
         1372  +
         1373  +# _LT_PROG_AR
         1374  +# -----------
         1375  +m4_defun([_LT_PROG_AR],
         1376  +[AC_CHECK_TOOLS(AR, [ar], false)
         1377  +: ${AR=ar}
         1378  +: ${AR_FLAGS=cru}
         1379  +_LT_DECL([], [AR], [1], [The archiver])
         1380  +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive])
         1381  +
         1382  +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file],
         1383  +  [lt_cv_ar_at_file=no
         1384  +   AC_COMPILE_IFELSE([AC_LANG_PROGRAM],
         1385  +     [echo conftest.$ac_objext > conftest.lst
         1386  +      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD'
         1387  +      AC_TRY_EVAL([lt_ar_try])
         1388  +      if test "$ac_status" -eq 0; then
         1389  +	# Ensure the archiver fails upon bogus file names.
         1390  +	rm -f conftest.$ac_objext libconftest.a
         1391  +	AC_TRY_EVAL([lt_ar_try])
         1392  +	if test "$ac_status" -ne 0; then
         1393  +          lt_cv_ar_at_file=@
         1394  +        fi
         1395  +      fi
         1396  +      rm -f conftest.* libconftest.a
         1397  +     ])
         1398  +  ])
         1399  +
         1400  +if test "x$lt_cv_ar_at_file" = xno; then
         1401  +  archiver_list_spec=
         1402  +else
         1403  +  archiver_list_spec=$lt_cv_ar_at_file
         1404  +fi
         1405  +_LT_DECL([], [archiver_list_spec], [1],
         1406  +  [How to feed a file listing to the archiver])
         1407  +])# _LT_PROG_AR
         1408  +
         1409  +
         1410  +# _LT_CMD_OLD_ARCHIVE
         1411  +# -------------------
         1412  +m4_defun([_LT_CMD_OLD_ARCHIVE],
         1413  +[_LT_PROG_AR
         1414  +
         1415  +AC_CHECK_TOOL(STRIP, strip, :)
         1416  +test -z "$STRIP" && STRIP=:
         1417  +_LT_DECL([], [STRIP], [1], [A symbol stripping program])
         1418  +
         1419  +AC_CHECK_TOOL(RANLIB, ranlib, :)
         1420  +test -z "$RANLIB" && RANLIB=:
         1421  +_LT_DECL([], [RANLIB], [1],
         1422  +    [Commands used to install an old-style archive])
         1423  +
         1424  +# Determine commands to create old-style static archives.
         1425  +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
         1426  +old_postinstall_cmds='chmod 644 $oldlib'
         1427  +old_postuninstall_cmds=
         1428  +
         1429  +if test -n "$RANLIB"; then
         1430  +  case $host_os in
         1431  +  openbsd*)
         1432  +    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$oldlib"
         1433  +    ;;
         1434  +  *)
         1435  +    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$oldlib"
         1436  +    ;;
         1437  +  esac
         1438  +  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
         1439  +fi
         1440  +
         1441  +case $host_os in
         1442  +  darwin*)
         1443  +    lock_old_archive_extraction=yes ;;
         1444  +  *)
         1445  +    lock_old_archive_extraction=no ;;
         1446  +esac
         1447  +_LT_DECL([], [old_postinstall_cmds], [2])
         1448  +_LT_DECL([], [old_postuninstall_cmds], [2])
         1449  +_LT_TAGDECL([], [old_archive_cmds], [2],
         1450  +    [Commands used to build an old-style archive])
         1451  +_LT_DECL([], [lock_old_archive_extraction], [0],
         1452  +    [Whether to use a lock for old archive extraction])
         1453  +])# _LT_CMD_OLD_ARCHIVE
         1454  +
         1455  +
         1456  +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
         1457  +#		[OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
         1458  +# ----------------------------------------------------------------
         1459  +# Check whether the given compiler option works
         1460  +AC_DEFUN([_LT_COMPILER_OPTION],
         1461  +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         1462  +m4_require([_LT_DECL_SED])dnl
         1463  +AC_CACHE_CHECK([$1], [$2],
         1464  +  [$2=no
         1465  +   m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
         1466  +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
         1467  +   lt_compiler_flag="$3"
         1468  +   # Insert the option either (1) after the last *FLAGS variable, or
         1469  +   # (2) before a word containing "conftest.", or (3) at the end.
         1470  +   # Note that $ac_compile itself does not contain backslashes and begins
         1471  +   # with a dollar sign (not a hyphen), so the echo should work correctly.
         1472  +   # The option is referenced via a variable to avoid confusing sed.
         1473  +   lt_compile=`echo "$ac_compile" | $SED \
         1474  +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
         1475  +   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
         1476  +   -e 's:$: $lt_compiler_flag:'`
         1477  +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
         1478  +   (eval "$lt_compile" 2>conftest.err)
         1479  +   ac_status=$?
         1480  +   cat conftest.err >&AS_MESSAGE_LOG_FD
         1481  +   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
         1482  +   if (exit $ac_status) && test -s "$ac_outfile"; then
         1483  +     # The compiler can only warn and ignore the option if not recognized
         1484  +     # So say no if there are warnings other than the usual output.
         1485  +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
         1486  +     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
         1487  +     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
         1488  +       $2=yes
         1489  +     fi
         1490  +   fi
         1491  +   $RM conftest*
         1492  +])
         1493  +
         1494  +if test x"[$]$2" = xyes; then
         1495  +    m4_if([$5], , :, [$5])
         1496  +else
         1497  +    m4_if([$6], , :, [$6])
         1498  +fi
         1499  +])# _LT_COMPILER_OPTION
         1500  +
         1501  +# Old name:
         1502  +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION])
         1503  +dnl aclocal-1.4 backwards compatibility:
         1504  +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], [])
         1505  +
         1506  +
         1507  +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
         1508  +#                  [ACTION-SUCCESS], [ACTION-FAILURE])
         1509  +# ----------------------------------------------------
         1510  +# Check whether the given linker option works
         1511  +AC_DEFUN([_LT_LINKER_OPTION],
         1512  +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         1513  +m4_require([_LT_DECL_SED])dnl
         1514  +AC_CACHE_CHECK([$1], [$2],
         1515  +  [$2=no
         1516  +   save_LDFLAGS="$LDFLAGS"
         1517  +   LDFLAGS="$LDFLAGS $3"
         1518  +   echo "$lt_simple_link_test_code" > conftest.$ac_ext
         1519  +   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
         1520  +     # The linker can only warn and ignore the option if not recognized
         1521  +     # So say no if there are warnings
         1522  +     if test -s conftest.err; then
         1523  +       # Append any errors to the config.log.
         1524  +       cat conftest.err 1>&AS_MESSAGE_LOG_FD
         1525  +       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
         1526  +       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
         1527  +       if diff conftest.exp conftest.er2 >/dev/null; then
         1528  +         $2=yes
         1529  +       fi
         1530  +     else
         1531  +       $2=yes
         1532  +     fi
         1533  +   fi
         1534  +   $RM -r conftest*
         1535  +   LDFLAGS="$save_LDFLAGS"
         1536  +])
         1537  +
         1538  +if test x"[$]$2" = xyes; then
         1539  +    m4_if([$4], , :, [$4])
         1540  +else
         1541  +    m4_if([$5], , :, [$5])
         1542  +fi
         1543  +])# _LT_LINKER_OPTION
         1544  +
         1545  +# Old name:
         1546  +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION])
         1547  +dnl aclocal-1.4 backwards compatibility:
         1548  +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], [])
         1549  +
         1550  +
         1551  +# LT_CMD_MAX_LEN
         1552  +#---------------
         1553  +AC_DEFUN([LT_CMD_MAX_LEN],
         1554  +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
         1555  +# find the maximum length of command line arguments
         1556  +AC_MSG_CHECKING([the maximum length of command line arguments])
         1557  +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
         1558  +  i=0
         1559  +  teststring="ABCD"
         1560  +
         1561  +  case $build_os in
         1562  +  msdosdjgpp*)
         1563  +    # On DJGPP, this test can blow up pretty badly due to problems in libc
         1564  +    # (any single argument exceeding 2000 bytes causes a buffer overrun
         1565  +    # during glob expansion).  Even if it were fixed, the result of this
         1566  +    # check would be larger than it should be.
         1567  +    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
         1568  +    ;;
         1569  +
         1570  +  gnu*)
         1571  +    # Under GNU Hurd, this test is not required because there is
         1572  +    # no limit to the length of command line arguments.
         1573  +    # Libtool will interpret -1 as no limit whatsoever
         1574  +    lt_cv_sys_max_cmd_len=-1;
         1575  +    ;;
         1576  +
         1577  +  cygwin* | mingw* | cegcc*)
         1578  +    # On Win9x/ME, this test blows up -- it succeeds, but takes
         1579  +    # about 5 minutes as the teststring grows exponentially.
         1580  +    # Worse, since 9x/ME are not pre-emptively multitasking,
         1581  +    # you end up with a "frozen" computer, even though with patience
         1582  +    # the test eventually succeeds (with a max line length of 256k).
         1583  +    # Instead, let's just punt: use the minimum linelength reported by
         1584  +    # all of the supported platforms: 8192 (on NT/2K/XP).
         1585  +    lt_cv_sys_max_cmd_len=8192;
         1586  +    ;;
         1587  +
         1588  +  mint*)
         1589  +    # On MiNT this can take a long time and run out of memory.
         1590  +    lt_cv_sys_max_cmd_len=8192;
         1591  +    ;;
         1592  +
         1593  +  amigaos*)
         1594  +    # On AmigaOS with pdksh, this test takes hours, literally.
         1595  +    # So we just punt and use a minimum line length of 8192.
         1596  +    lt_cv_sys_max_cmd_len=8192;
         1597  +    ;;
         1598  +
         1599  +  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
         1600  +    # This has been around since 386BSD, at least.  Likely further.
         1601  +    if test -x /sbin/sysctl; then
         1602  +      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
         1603  +    elif test -x /usr/sbin/sysctl; then
         1604  +      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
         1605  +    else
         1606  +      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
         1607  +    fi
         1608  +    # And add a safety zone
         1609  +    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
         1610  +    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
         1611  +    ;;
         1612  +
         1613  +  interix*)
         1614  +    # We know the value 262144 and hardcode it with a safety zone (like BSD)
         1615  +    lt_cv_sys_max_cmd_len=196608
         1616  +    ;;
         1617  +
         1618  +  osf*)
         1619  +    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
         1620  +    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
         1621  +    # nice to cause kernel panics so lets avoid the loop below.
         1622  +    # First set a reasonable default.
         1623  +    lt_cv_sys_max_cmd_len=16384
         1624  +    #
         1625  +    if test -x /sbin/sysconfig; then
         1626  +      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
         1627  +        *1*) lt_cv_sys_max_cmd_len=-1 ;;
         1628  +      esac
         1629  +    fi
         1630  +    ;;
         1631  +  sco3.2v5*)
         1632  +    lt_cv_sys_max_cmd_len=102400
         1633  +    ;;
         1634  +  sysv5* | sco5v6* | sysv4.2uw2*)
         1635  +    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
         1636  +    if test -n "$kargmax"; then
         1637  +      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[	 ]]//'`
         1638  +    else
         1639  +      lt_cv_sys_max_cmd_len=32768
         1640  +    fi
         1641  +    ;;
         1642  +  *)
         1643  +    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
         1644  +    if test -n "$lt_cv_sys_max_cmd_len"; then
         1645  +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
         1646  +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
         1647  +    else
         1648  +      # Make teststring a little bigger before we do anything with it.
         1649  +      # a 1K string should be a reasonable start.
         1650  +      for i in 1 2 3 4 5 6 7 8 ; do
         1651  +        teststring=$teststring$teststring
         1652  +      done
         1653  +      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
         1654  +      # If test is not a shell built-in, we'll probably end up computing a
         1655  +      # maximum length that is only half of the actual maximum length, but
         1656  +      # we can't tell.
         1657  +      while { test "X"`func_fallback_echo "$teststring$teststring" 2>/dev/null` \
         1658  +	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
         1659  +	      test $i != 17 # 1/2 MB should be enough
         1660  +      do
         1661  +        i=`expr $i + 1`
         1662  +        teststring=$teststring$teststring
         1663  +      done
         1664  +      # Only check the string length outside the loop.
         1665  +      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
         1666  +      teststring=
         1667  +      # Add a significant safety factor because C++ compilers can tack on
         1668  +      # massive amounts of additional arguments before passing them to the
         1669  +      # linker.  It appears as though 1/2 is a usable value.
         1670  +      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
         1671  +    fi
         1672  +    ;;
         1673  +  esac
         1674  +])
         1675  +if test -n $lt_cv_sys_max_cmd_len ; then
         1676  +  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
         1677  +else
         1678  +  AC_MSG_RESULT(none)
         1679  +fi
         1680  +max_cmd_len=$lt_cv_sys_max_cmd_len
         1681  +_LT_DECL([], [max_cmd_len], [0],
         1682  +    [What is the maximum length of a command?])
         1683  +])# LT_CMD_MAX_LEN
         1684  +
         1685  +# Old name:
         1686  +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN])
         1687  +dnl aclocal-1.4 backwards compatibility:
         1688  +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], [])
         1689  +
         1690  +
         1691  +# _LT_HEADER_DLFCN
         1692  +# ----------------
         1693  +m4_defun([_LT_HEADER_DLFCN],
         1694  +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl
         1695  +])# _LT_HEADER_DLFCN
         1696  +
         1697  +
         1698  +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
         1699  +#                      ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
         1700  +# ----------------------------------------------------------------
         1701  +m4_defun([_LT_TRY_DLOPEN_SELF],
         1702  +[m4_require([_LT_HEADER_DLFCN])dnl
         1703  +if test "$cross_compiling" = yes; then :
         1704  +  [$4]
         1705  +else
         1706  +  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
         1707  +  lt_status=$lt_dlunknown
         1708  +  cat > conftest.$ac_ext <<_LT_EOF
         1709  +[#line $LINENO "configure"
         1710  +#include "confdefs.h"
         1711  +
         1712  +#if HAVE_DLFCN_H
         1713  +#include <dlfcn.h>
         1714  +#endif
         1715  +
         1716  +#include <stdio.h>
         1717  +
         1718  +#ifdef RTLD_GLOBAL
         1719  +#  define LT_DLGLOBAL		RTLD_GLOBAL
         1720  +#else
         1721  +#  ifdef DL_GLOBAL
         1722  +#    define LT_DLGLOBAL		DL_GLOBAL
         1723  +#  else
         1724  +#    define LT_DLGLOBAL		0
         1725  +#  endif
         1726  +#endif
         1727  +
         1728  +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
         1729  +   find out it does not work in some platform. */
         1730  +#ifndef LT_DLLAZY_OR_NOW
         1731  +#  ifdef RTLD_LAZY
         1732  +#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
         1733  +#  else
         1734  +#    ifdef DL_LAZY
         1735  +#      define LT_DLLAZY_OR_NOW		DL_LAZY
         1736  +#    else
         1737  +#      ifdef RTLD_NOW
         1738  +#        define LT_DLLAZY_OR_NOW	RTLD_NOW
         1739  +#      else
         1740  +#        ifdef DL_NOW
         1741  +#          define LT_DLLAZY_OR_NOW	DL_NOW
         1742  +#        else
         1743  +#          define LT_DLLAZY_OR_NOW	0
         1744  +#        endif
         1745  +#      endif
         1746  +#    endif
         1747  +#  endif
         1748  +#endif
         1749  +
         1750  +/* When -fvisbility=hidden is used, assume the code has been annotated
         1751  +   correspondingly for the symbols needed.  */
         1752  +#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
         1753  +int fnord () __attribute__((visibility("default")));
         1754  +#endif
         1755  +
         1756  +int fnord () { return 42; }
         1757  +int main ()
         1758  +{
         1759  +  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
         1760  +  int status = $lt_dlunknown;
         1761  +
         1762  +  if (self)
         1763  +    {
         1764  +      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
         1765  +      else
         1766  +        {
         1767  +	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
         1768  +          else puts (dlerror ());
         1769  +	}
         1770  +      /* dlclose (self); */
         1771  +    }
         1772  +  else
         1773  +    puts (dlerror ());
         1774  +
         1775  +  return status;
         1776  +}]
         1777  +_LT_EOF
         1778  +  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
         1779  +    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
         1780  +    lt_status=$?
         1781  +    case x$lt_status in
         1782  +      x$lt_dlno_uscore) $1 ;;
         1783  +      x$lt_dlneed_uscore) $2 ;;
         1784  +      x$lt_dlunknown|x*) $3 ;;
         1785  +    esac
         1786  +  else :
         1787  +    # compilation failed
         1788  +    $3
         1789  +  fi
         1790  +fi
         1791  +rm -fr conftest*
         1792  +])# _LT_TRY_DLOPEN_SELF
         1793  +
         1794  +
         1795  +# LT_SYS_DLOPEN_SELF
         1796  +# ------------------
         1797  +AC_DEFUN([LT_SYS_DLOPEN_SELF],
         1798  +[m4_require([_LT_HEADER_DLFCN])dnl
         1799  +if test "x$enable_dlopen" != xyes; then
         1800  +  enable_dlopen=unknown
         1801  +  enable_dlopen_self=unknown
         1802  +  enable_dlopen_self_static=unknown
         1803  +else
         1804  +  lt_cv_dlopen=no
         1805  +  lt_cv_dlopen_libs=
         1806  +
         1807  +  case $host_os in
         1808  +  beos*)
         1809  +    lt_cv_dlopen="load_add_on"
         1810  +    lt_cv_dlopen_libs=
         1811  +    lt_cv_dlopen_self=yes
         1812  +    ;;
         1813  +
         1814  +  mingw* | pw32* | cegcc*)
         1815  +    lt_cv_dlopen="LoadLibrary"
         1816  +    lt_cv_dlopen_libs=
         1817  +    ;;
         1818  +
         1819  +  cygwin*)
         1820  +    lt_cv_dlopen="dlopen"
         1821  +    lt_cv_dlopen_libs=
         1822  +    ;;
         1823  +
         1824  +  darwin*)
         1825  +  # if libdl is installed we need to link against it
         1826  +    AC_CHECK_LIB([dl], [dlopen],
         1827  +		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
         1828  +    lt_cv_dlopen="dyld"
         1829  +    lt_cv_dlopen_libs=
         1830  +    lt_cv_dlopen_self=yes
         1831  +    ])
         1832  +    ;;
         1833  +
         1834  +  *)
         1835  +    AC_CHECK_FUNC([shl_load],
         1836  +	  [lt_cv_dlopen="shl_load"],
         1837  +      [AC_CHECK_LIB([dld], [shl_load],
         1838  +	    [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"],
         1839  +	[AC_CHECK_FUNC([dlopen],
         1840  +	      [lt_cv_dlopen="dlopen"],
         1841  +	  [AC_CHECK_LIB([dl], [dlopen],
         1842  +		[lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
         1843  +	    [AC_CHECK_LIB([svld], [dlopen],
         1844  +		  [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
         1845  +	      [AC_CHECK_LIB([dld], [dld_link],
         1846  +		    [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"])
         1847  +	      ])
         1848  +	    ])
         1849  +	  ])
         1850  +	])
         1851  +      ])
         1852  +    ;;
         1853  +  esac
         1854  +
         1855  +  if test "x$lt_cv_dlopen" != xno; then
         1856  +    enable_dlopen=yes
         1857  +  else
         1858  +    enable_dlopen=no
         1859  +  fi
         1860  +
         1861  +  case $lt_cv_dlopen in
         1862  +  dlopen)
         1863  +    save_CPPFLAGS="$CPPFLAGS"
         1864  +    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
         1865  +
         1866  +    save_LDFLAGS="$LDFLAGS"
         1867  +    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
         1868  +
         1869  +    save_LIBS="$LIBS"
         1870  +    LIBS="$lt_cv_dlopen_libs $LIBS"
         1871  +
         1872  +    AC_CACHE_CHECK([whether a program can dlopen itself],
         1873  +	  lt_cv_dlopen_self, [dnl
         1874  +	  _LT_TRY_DLOPEN_SELF(
         1875  +	    lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
         1876  +	    lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
         1877  +    ])
         1878  +
         1879  +    if test "x$lt_cv_dlopen_self" = xyes; then
         1880  +      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
         1881  +      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
         1882  +	  lt_cv_dlopen_self_static, [dnl
         1883  +	  _LT_TRY_DLOPEN_SELF(
         1884  +	    lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
         1885  +	    lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
         1886  +      ])
         1887  +    fi
         1888  +
         1889  +    CPPFLAGS="$save_CPPFLAGS"
         1890  +    LDFLAGS="$save_LDFLAGS"
         1891  +    LIBS="$save_LIBS"
         1892  +    ;;
         1893  +  esac
         1894  +
         1895  +  case $lt_cv_dlopen_self in
         1896  +  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
         1897  +  *) enable_dlopen_self=unknown ;;
         1898  +  esac
         1899  +
         1900  +  case $lt_cv_dlopen_self_static in
         1901  +  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
         1902  +  *) enable_dlopen_self_static=unknown ;;
         1903  +  esac
         1904  +fi
         1905  +_LT_DECL([dlopen_support], [enable_dlopen], [0],
         1906  +	 [Whether dlopen is supported])
         1907  +_LT_DECL([dlopen_self], [enable_dlopen_self], [0],
         1908  +	 [Whether dlopen of programs is supported])
         1909  +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0],
         1910  +	 [Whether dlopen of statically linked programs is supported])
         1911  +])# LT_SYS_DLOPEN_SELF
         1912  +
         1913  +# Old name:
         1914  +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF])
         1915  +dnl aclocal-1.4 backwards compatibility:
         1916  +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], [])
         1917  +
         1918  +
         1919  +# _LT_COMPILER_C_O([TAGNAME])
         1920  +# ---------------------------
         1921  +# Check to see if options -c and -o are simultaneously supported by compiler.
         1922  +# This macro does not hard code the compiler like AC_PROG_CC_C_O.
         1923  +m4_defun([_LT_COMPILER_C_O],
         1924  +[m4_require([_LT_DECL_SED])dnl
         1925  +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         1926  +m4_require([_LT_TAG_COMPILER])dnl
         1927  +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
         1928  +  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
         1929  +  [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
         1930  +   $RM -r conftest 2>/dev/null
         1931  +   mkdir conftest
         1932  +   cd conftest
         1933  +   mkdir out
         1934  +   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
         1935  +
         1936  +   lt_compiler_flag="-o out/conftest2.$ac_objext"
         1937  +   # Insert the option either (1) after the last *FLAGS variable, or
         1938  +   # (2) before a word containing "conftest.", or (3) at the end.
         1939  +   # Note that $ac_compile itself does not contain backslashes and begins
         1940  +   # with a dollar sign (not a hyphen), so the echo should work correctly.
         1941  +   lt_compile=`echo "$ac_compile" | $SED \
         1942  +   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
         1943  +   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
         1944  +   -e 's:$: $lt_compiler_flag:'`
         1945  +   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
         1946  +   (eval "$lt_compile" 2>out/conftest.err)
         1947  +   ac_status=$?
         1948  +   cat out/conftest.err >&AS_MESSAGE_LOG_FD
         1949  +   echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
         1950  +   if (exit $ac_status) && test -s out/conftest2.$ac_objext
         1951  +   then
         1952  +     # The compiler can only warn and ignore the option if not recognized
         1953  +     # So say no if there are warnings
         1954  +     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
         1955  +     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
         1956  +     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
         1957  +       _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
         1958  +     fi
         1959  +   fi
         1960  +   chmod u+w . 2>&AS_MESSAGE_LOG_FD
         1961  +   $RM conftest*
         1962  +   # SGI C++ compiler will create directory out/ii_files/ for
         1963  +   # template instantiation
         1964  +   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
         1965  +   $RM out/* && rmdir out
         1966  +   cd ..
         1967  +   $RM -r conftest
         1968  +   $RM conftest*
         1969  +])
         1970  +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1],
         1971  +	[Does compiler simultaneously support -c and -o options?])
         1972  +])# _LT_COMPILER_C_O
         1973  +
         1974  +
         1975  +# _LT_COMPILER_FILE_LOCKS([TAGNAME])
         1976  +# ----------------------------------
         1977  +# Check to see if we can do hard links to lock some files if needed
         1978  +m4_defun([_LT_COMPILER_FILE_LOCKS],
         1979  +[m4_require([_LT_ENABLE_LOCK])dnl
         1980  +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         1981  +_LT_COMPILER_C_O([$1])
         1982  +
         1983  +hard_links="nottested"
         1984  +if test "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
         1985  +  # do not overwrite the value of need_locks provided by the user
         1986  +  AC_MSG_CHECKING([if we can lock with hard links])
         1987  +  hard_links=yes
         1988  +  $RM conftest*
         1989  +  ln conftest.a conftest.b 2>/dev/null && hard_links=no
         1990  +  touch conftest.a
         1991  +  ln conftest.a conftest.b 2>&5 || hard_links=no
         1992  +  ln conftest.a conftest.b 2>/dev/null && hard_links=no
         1993  +  AC_MSG_RESULT([$hard_links])
         1994  +  if test "$hard_links" = no; then
         1995  +    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
         1996  +    need_locks=warn
         1997  +  fi
         1998  +else
         1999  +  need_locks=no
         2000  +fi
         2001  +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?])
         2002  +])# _LT_COMPILER_FILE_LOCKS
         2003  +
         2004  +
         2005  +# _LT_CHECK_OBJDIR
         2006  +# ----------------
         2007  +m4_defun([_LT_CHECK_OBJDIR],
         2008  +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
         2009  +[rm -f .libs 2>/dev/null
         2010  +mkdir .libs 2>/dev/null
         2011  +if test -d .libs; then
         2012  +  lt_cv_objdir=.libs
         2013  +else
         2014  +  # MS-DOS does not allow filenames that begin with a dot.
         2015  +  lt_cv_objdir=_libs
         2016  +fi
         2017  +rmdir .libs 2>/dev/null])
         2018  +objdir=$lt_cv_objdir
         2019  +_LT_DECL([], [objdir], [0],
         2020  +         [The name of the directory that contains temporary libtool files])dnl
         2021  +m4_pattern_allow([LT_OBJDIR])dnl
         2022  +AC_DEFINE_UNQUOTED(LT_OBJDIR, "$lt_cv_objdir/",
         2023  +  [Define to the sub-directory in which libtool stores uninstalled libraries.])
         2024  +])# _LT_CHECK_OBJDIR
         2025  +
         2026  +
         2027  +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME])
         2028  +# --------------------------------------
         2029  +# Check hardcoding attributes.
         2030  +m4_defun([_LT_LINKER_HARDCODE_LIBPATH],
         2031  +[AC_MSG_CHECKING([how to hardcode library paths into programs])
         2032  +_LT_TAGVAR(hardcode_action, $1)=
         2033  +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" ||
         2034  +   test -n "$_LT_TAGVAR(runpath_var, $1)" ||
         2035  +   test "X$_LT_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
         2036  +
         2037  +  # We can hardcode non-existent directories.
         2038  +  if test "$_LT_TAGVAR(hardcode_direct, $1)" != no &&
         2039  +     # If the only mechanism to avoid hardcoding is shlibpath_var, we
         2040  +     # have to relink, otherwise we might link with an installed library
         2041  +     # when we should be linking with a yet-to-be-installed one
         2042  +     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
         2043  +     test "$_LT_TAGVAR(hardcode_minus_L, $1)" != no; then
         2044  +    # Linking always hardcodes the temporary library directory.
         2045  +    _LT_TAGVAR(hardcode_action, $1)=relink
         2046  +  else
         2047  +    # We can link without hardcoding, and we can hardcode nonexisting dirs.
         2048  +    _LT_TAGVAR(hardcode_action, $1)=immediate
         2049  +  fi
         2050  +else
         2051  +  # We cannot hardcode anything, or else we can only hardcode existing
         2052  +  # directories.
         2053  +  _LT_TAGVAR(hardcode_action, $1)=unsupported
         2054  +fi
         2055  +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)])
         2056  +
         2057  +if test "$_LT_TAGVAR(hardcode_action, $1)" = relink ||
         2058  +   test "$_LT_TAGVAR(inherit_rpath, $1)" = yes; then
         2059  +  # Fast installation is not supported
         2060  +  enable_fast_install=no
         2061  +elif test "$shlibpath_overrides_runpath" = yes ||
         2062  +     test "$enable_shared" = no; then
         2063  +  # Fast installation is not necessary
         2064  +  enable_fast_install=needless
         2065  +fi
         2066  +_LT_TAGDECL([], [hardcode_action], [0],
         2067  +    [How to hardcode a shared library path into an executable])
         2068  +])# _LT_LINKER_HARDCODE_LIBPATH
         2069  +
         2070  +
         2071  +# _LT_CMD_STRIPLIB
         2072  +# ----------------
         2073  +m4_defun([_LT_CMD_STRIPLIB],
         2074  +[m4_require([_LT_DECL_EGREP])
         2075  +striplib=
         2076  +old_striplib=
         2077  +AC_MSG_CHECKING([whether stripping libraries is possible])
         2078  +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
         2079  +  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
         2080  +  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
         2081  +  AC_MSG_RESULT([yes])
         2082  +else
         2083  +# FIXME - insert some real tests, host_os isn't really good enough
         2084  +  case $host_os in
         2085  +  darwin*)
         2086  +    if test -n "$STRIP" ; then
         2087  +      striplib="$STRIP -x"
         2088  +      old_striplib="$STRIP -S"
         2089  +      AC_MSG_RESULT([yes])
         2090  +    else
         2091  +      AC_MSG_RESULT([no])
         2092  +    fi
         2093  +    ;;
         2094  +  *)
         2095  +    AC_MSG_RESULT([no])
         2096  +    ;;
         2097  +  esac
         2098  +fi
         2099  +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries])
         2100  +_LT_DECL([], [striplib], [1])
         2101  +])# _LT_CMD_STRIPLIB
         2102  +
         2103  +
         2104  +# _LT_SYS_DYNAMIC_LINKER([TAG])
         2105  +# -----------------------------
         2106  +# PORTME Fill in your ld.so characteristics
         2107  +m4_defun([_LT_SYS_DYNAMIC_LINKER],
         2108  +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
         2109  +m4_require([_LT_DECL_EGREP])dnl
         2110  +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         2111  +m4_require([_LT_DECL_OBJDUMP])dnl
         2112  +m4_require([_LT_DECL_SED])dnl
         2113  +m4_require([_LT_CHECK_SHELL_FEATURES])dnl
         2114  +AC_MSG_CHECKING([dynamic linker characteristics])
         2115  +m4_if([$1],
         2116  +	[], [
         2117  +if test "$GCC" = yes; then
         2118  +  case $host_os in
         2119  +    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
         2120  +    *) lt_awk_arg="/^libraries:/" ;;
         2121  +  esac
         2122  +  case $host_os in
         2123  +    mingw* | cegcc*) lt_sed_strip_eq="s,=\([[A-Za-z]]:\),\1,g" ;;
         2124  +    *) lt_sed_strip_eq="s,=/,/,g" ;;
         2125  +  esac
         2126  +  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
         2127  +  case $lt_search_path_spec in
         2128  +  *\;*)
         2129  +    # if the path contains ";" then we assume it to be the separator
         2130  +    # otherwise default to the standard path separator (i.e. ":") - it is
         2131  +    # assumed that no part of a normal pathname contains ";" but that should
         2132  +    # okay in the real world where ";" in dirpaths is itself problematic.
         2133  +    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
         2134  +    ;;
         2135  +  *)
         2136  +    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
         2137  +    ;;
         2138  +  esac
         2139  +  # Ok, now we have the path, separated by spaces, we can step through it
         2140  +  # and add multilib dir if necessary.
         2141  +  lt_tmp_lt_search_path_spec=
         2142  +  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
         2143  +  for lt_sys_path in $lt_search_path_spec; do
         2144  +    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
         2145  +      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
         2146  +    else
         2147  +      test -d "$lt_sys_path" && \
         2148  +	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
         2149  +    fi
         2150  +  done
         2151  +  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
         2152  +BEGIN {RS=" "; FS="/|\n";} {
         2153  +  lt_foo="";
         2154  +  lt_count=0;
         2155  +  for (lt_i = NF; lt_i > 0; lt_i--) {
         2156  +    if ($lt_i != "" && $lt_i != ".") {
         2157  +      if ($lt_i == "..") {
         2158  +        lt_count++;
         2159  +      } else {
         2160  +        if (lt_count == 0) {
         2161  +          lt_foo="/" $lt_i lt_foo;
         2162  +        } else {
         2163  +          lt_count--;
         2164  +        }
         2165  +      }
         2166  +    }
         2167  +  }
         2168  +  if (lt_foo != "") { lt_freq[[lt_foo]]++; }
         2169  +  if (lt_freq[[lt_foo]] == 1) { print lt_foo; }
         2170  +}'`
         2171  +  # AWK program above erroneously prepends '/' to C:/dos/paths
         2172  +  # for these hosts.
         2173  +  case $host_os in
         2174  +    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
         2175  +      $SED 's,/\([[A-Za-z]]:\),\1,g'` ;;
         2176  +  esac
         2177  +  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
         2178  +else
         2179  +  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
         2180  +fi])
         2181  +library_names_spec=
         2182  +libname_spec='lib$name'
         2183  +soname_spec=
         2184  +shrext_cmds=".so"
         2185  +postinstall_cmds=
         2186  +postuninstall_cmds=
         2187  +finish_cmds=
         2188  +finish_eval=
         2189  +shlibpath_var=
         2190  +shlibpath_overrides_runpath=unknown
         2191  +version_type=none
         2192  +dynamic_linker="$host_os ld.so"
         2193  +sys_lib_dlsearch_path_spec="/lib /usr/lib"
         2194  +need_lib_prefix=unknown
         2195  +hardcode_into_libs=no
         2196  +
         2197  +# when you set need_version to no, make sure it does not cause -set_version
         2198  +# flags to be left without arguments
         2199  +need_version=unknown
         2200  +
         2201  +case $host_os in
         2202  +aix3*)
         2203  +  version_type=linux
         2204  +  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
         2205  +  shlibpath_var=LIBPATH
         2206  +
         2207  +  # AIX 3 has no versioning support, so we append a major version to the name.
         2208  +  soname_spec='${libname}${release}${shared_ext}$major'
         2209  +  ;;
         2210  +
         2211  +aix[[4-9]]*)
         2212  +  version_type=linux
         2213  +  need_lib_prefix=no
         2214  +  need_version=no
         2215  +  hardcode_into_libs=yes
         2216  +  if test "$host_cpu" = ia64; then
         2217  +    # AIX 5 supports IA64
         2218  +    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
         2219  +    shlibpath_var=LD_LIBRARY_PATH
         2220  +  else
         2221  +    # With GCC up to 2.95.x, collect2 would create an import file
         2222  +    # for dependence libraries.  The import file would start with
         2223  +    # the line `#! .'.  This would cause the generated library to
         2224  +    # depend on `.', always an invalid library.  This was fixed in
         2225  +    # development snapshots of GCC prior to 3.0.
         2226  +    case $host_os in
         2227  +      aix4 | aix4.[[01]] | aix4.[[01]].*)
         2228  +      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
         2229  +	   echo ' yes '
         2230  +	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
         2231  +	:
         2232  +      else
         2233  +	can_build_shared=no
         2234  +      fi
         2235  +      ;;
         2236  +    esac
         2237  +    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
         2238  +    # soname into executable. Probably we can add versioning support to
         2239  +    # collect2, so additional links can be useful in future.
         2240  +    if test "$aix_use_runtimelinking" = yes; then
         2241  +      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
         2242  +      # instead of lib<name>.a to let people know that these are not
         2243  +      # typical AIX shared libraries.
         2244  +      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2245  +    else
         2246  +      # We preserve .a as extension for shared libraries through AIX4.2
         2247  +      # and later when we are not doing run time linking.
         2248  +      library_names_spec='${libname}${release}.a $libname.a'
         2249  +      soname_spec='${libname}${release}${shared_ext}$major'
         2250  +    fi
         2251  +    shlibpath_var=LIBPATH
         2252  +  fi
         2253  +  ;;
         2254  +
         2255  +amigaos*)
         2256  +  case $host_cpu in
         2257  +  powerpc)
         2258  +    # Since July 2007 AmigaOS4 officially supports .so libraries.
         2259  +    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
         2260  +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2261  +    ;;
         2262  +  m68k)
         2263  +    library_names_spec='$libname.ixlibrary $libname.a'
         2264  +    # Create ${libname}_ixlibrary.a entries in /sys/libs.
         2265  +    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''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'
         2266  +    ;;
         2267  +  esac
         2268  +  ;;
         2269  +
         2270  +beos*)
         2271  +  library_names_spec='${libname}${shared_ext}'
         2272  +  dynamic_linker="$host_os ld.so"
         2273  +  shlibpath_var=LIBRARY_PATH
         2274  +  ;;
         2275  +
         2276  +bsdi[[45]]*)
         2277  +  version_type=linux
         2278  +  need_version=no
         2279  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2280  +  soname_spec='${libname}${release}${shared_ext}$major'
         2281  +  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
         2282  +  shlibpath_var=LD_LIBRARY_PATH
         2283  +  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
         2284  +  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
         2285  +  # the default ld.so.conf also contains /usr/contrib/lib and
         2286  +  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
         2287  +  # libtool to hard-code these into programs
         2288  +  ;;
         2289  +
         2290  +cygwin* | mingw* | pw32* | cegcc*)
         2291  +  version_type=windows
         2292  +  shrext_cmds=".dll"
         2293  +  need_version=no
         2294  +  need_lib_prefix=no
         2295  +
         2296  +  case $GCC,$cc_basename in
         2297  +  yes,*)
         2298  +    # gcc
         2299  +    library_names_spec='$libname.dll.a'
         2300  +    # DLL is installed to $(libdir)/../bin by postinstall_cmds
         2301  +    postinstall_cmds='base_file=`basename \${file}`~
         2302  +      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
         2303  +      dldir=$destdir/`dirname \$dlpath`~
         2304  +      test -d \$dldir || mkdir -p \$dldir~
         2305  +      $install_prog $dir/$dlname \$dldir/$dlname~
         2306  +      chmod a+x \$dldir/$dlname~
         2307  +      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
         2308  +        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
         2309  +      fi'
         2310  +    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
         2311  +      dlpath=$dir/\$dldll~
         2312  +       $RM \$dlpath'
         2313  +    shlibpath_overrides_runpath=yes
         2314  +
         2315  +    case $host_os in
         2316  +    cygwin*)
         2317  +      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
         2318  +      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
         2319  +m4_if([$1], [],[
         2320  +      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"])
         2321  +      ;;
         2322  +    mingw* | cegcc*)
         2323  +      # MinGW DLLs use traditional 'lib' prefix
         2324  +      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
         2325  +      ;;
         2326  +    pw32*)
         2327  +      # pw32 DLLs use 'pw' prefix rather than 'lib'
         2328  +      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
         2329  +      ;;
         2330  +    esac
         2331  +    dynamic_linker='Win32 ld.exe'
         2332  +    ;;
         2333  +
         2334  +  *,cl*)
         2335  +    # Native MSVC
         2336  +    libname_spec='$name'
         2337  +    soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
         2338  +    library_names_spec='${libname}.dll.lib'
         2339  +
         2340  +    case $build_os in
         2341  +    mingw*)
         2342  +      sys_lib_search_path_spec=
         2343  +      lt_save_ifs=$IFS
         2344  +      IFS=';'
         2345  +      for lt_path in $LIB
         2346  +      do
         2347  +        IFS=$lt_save_ifs
         2348  +        # Let DOS variable expansion print the short 8.3 style file name.
         2349  +        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
         2350  +        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
         2351  +      done
         2352  +      IFS=$lt_save_ifs
         2353  +      # Convert to MSYS style.
         2354  +      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'`
         2355  +      ;;
         2356  +    cygwin*)
         2357  +      # Convert to unix form, then to dos form, then back to unix form
         2358  +      # but this time dos style (no spaces!) so that the unix form looks
         2359  +      # like /cygdrive/c/PROGRA~1:/cygdr...
         2360  +      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
         2361  +      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
         2362  +      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
         2363  +      ;;
         2364  +    *)
         2365  +      sys_lib_search_path_spec="$LIB"
         2366  +      if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then
         2367  +        # It is most probably a Windows format PATH.
         2368  +        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
         2369  +      else
         2370  +        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
         2371  +      fi
         2372  +      # FIXME: find the short name or the path components, as spaces are
         2373  +      # common. (e.g. "Program Files" -> "PROGRA~1")
         2374  +      ;;
         2375  +    esac
         2376  +
         2377  +    # DLL is installed to $(libdir)/../bin by postinstall_cmds
         2378  +    postinstall_cmds='base_file=`basename \${file}`~
         2379  +      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
         2380  +      dldir=$destdir/`dirname \$dlpath`~
         2381  +      test -d \$dldir || mkdir -p \$dldir~
         2382  +      $install_prog $dir/$dlname \$dldir/$dlname'
         2383  +    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
         2384  +      dlpath=$dir/\$dldll~
         2385  +       $RM \$dlpath'
         2386  +    shlibpath_overrides_runpath=yes
         2387  +    dynamic_linker='Win32 link.exe'
         2388  +    ;;
         2389  +
         2390  +  *)
         2391  +    # Assume MSVC wrapper
         2392  +    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
         2393  +    dynamic_linker='Win32 ld.exe'
         2394  +    ;;
         2395  +  esac
         2396  +  # FIXME: first we should search . and the directory the executable is in
         2397  +  shlibpath_var=PATH
         2398  +  ;;
         2399  +
         2400  +darwin* | rhapsody*)
         2401  +  dynamic_linker="$host_os dyld"
         2402  +  version_type=darwin
         2403  +  need_lib_prefix=no
         2404  +  need_version=no
         2405  +  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
         2406  +  soname_spec='${libname}${release}${major}$shared_ext'
         2407  +  shlibpath_overrides_runpath=yes
         2408  +  shlibpath_var=DYLD_LIBRARY_PATH
         2409  +  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
         2410  +m4_if([$1], [],[
         2411  +  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"])
         2412  +  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
         2413  +  ;;
         2414  +
         2415  +dgux*)
         2416  +  version_type=linux
         2417  +  need_lib_prefix=no
         2418  +  need_version=no
         2419  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
         2420  +  soname_spec='${libname}${release}${shared_ext}$major'
         2421  +  shlibpath_var=LD_LIBRARY_PATH
         2422  +  ;;
         2423  +
         2424  +freebsd1*)
         2425  +  dynamic_linker=no
         2426  +  ;;
         2427  +
         2428  +freebsd* | dragonfly*)
         2429  +  # DragonFly does not have aout.  When/if they implement a new
         2430  +  # versioning mechanism, adjust this.
         2431  +  if test -x /usr/bin/objformat; then
         2432  +    objformat=`/usr/bin/objformat`
         2433  +  else
         2434  +    case $host_os in
         2435  +    freebsd[[123]]*) objformat=aout ;;
         2436  +    *) objformat=elf ;;
         2437  +    esac
         2438  +  fi
         2439  +  version_type=freebsd-$objformat
         2440  +  case $version_type in
         2441  +    freebsd-elf*)
         2442  +      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
         2443  +      need_version=no
         2444  +      need_lib_prefix=no
         2445  +      ;;
         2446  +    freebsd-*)
         2447  +      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
         2448  +      need_version=yes
         2449  +      ;;
         2450  +  esac
         2451  +  shlibpath_var=LD_LIBRARY_PATH
         2452  +  case $host_os in
         2453  +  freebsd2*)
         2454  +    shlibpath_overrides_runpath=yes
         2455  +    ;;
         2456  +  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
         2457  +    shlibpath_overrides_runpath=yes
         2458  +    hardcode_into_libs=yes
         2459  +    ;;
         2460  +  freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \
         2461  +  freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1)
         2462  +    shlibpath_overrides_runpath=no
         2463  +    hardcode_into_libs=yes
         2464  +    ;;
         2465  +  *) # from 4.6 on, and DragonFly
         2466  +    shlibpath_overrides_runpath=yes
         2467  +    hardcode_into_libs=yes
         2468  +    ;;
         2469  +  esac
         2470  +  ;;
         2471  +
         2472  +gnu*)
         2473  +  version_type=linux
         2474  +  need_lib_prefix=no
         2475  +  need_version=no
         2476  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
         2477  +  soname_spec='${libname}${release}${shared_ext}$major'
         2478  +  shlibpath_var=LD_LIBRARY_PATH
         2479  +  hardcode_into_libs=yes
         2480  +  ;;
         2481  +
         2482  +haiku*)
         2483  +  version_type=linux
         2484  +  need_lib_prefix=no
         2485  +  need_version=no
         2486  +  dynamic_linker="$host_os runtime_loader"
         2487  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
         2488  +  soname_spec='${libname}${release}${shared_ext}$major'
         2489  +  shlibpath_var=LIBRARY_PATH
         2490  +  shlibpath_overrides_runpath=yes
         2491  +  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
         2492  +  hardcode_into_libs=yes
         2493  +  ;;
         2494  +
         2495  +hpux9* | hpux10* | hpux11*)
         2496  +  # Give a soname corresponding to the major version so that dld.sl refuses to
         2497  +  # link against other versions.
         2498  +  version_type=sunos
         2499  +  need_lib_prefix=no
         2500  +  need_version=no
         2501  +  case $host_cpu in
         2502  +  ia64*)
         2503  +    shrext_cmds='.so'
         2504  +    hardcode_into_libs=yes
         2505  +    dynamic_linker="$host_os dld.so"
         2506  +    shlibpath_var=LD_LIBRARY_PATH
         2507  +    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
         2508  +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2509  +    soname_spec='${libname}${release}${shared_ext}$major'
         2510  +    if test "X$HPUX_IA64_MODE" = X32; then
         2511  +      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
         2512  +    else
         2513  +      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
         2514  +    fi
         2515  +    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
         2516  +    ;;
         2517  +  hppa*64*)
         2518  +    shrext_cmds='.sl'
         2519  +    hardcode_into_libs=yes
         2520  +    dynamic_linker="$host_os dld.sl"
         2521  +    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
         2522  +    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
         2523  +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2524  +    soname_spec='${libname}${release}${shared_ext}$major'
         2525  +    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
         2526  +    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
         2527  +    ;;
         2528  +  *)
         2529  +    shrext_cmds='.sl'
         2530  +    dynamic_linker="$host_os dld.sl"
         2531  +    shlibpath_var=SHLIB_PATH
         2532  +    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
         2533  +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2534  +    soname_spec='${libname}${release}${shared_ext}$major'
         2535  +    ;;
         2536  +  esac
         2537  +  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
         2538  +  postinstall_cmds='chmod 555 $lib'
         2539  +  # or fails outright, so override atomically:
         2540  +  install_override_mode=555
         2541  +  ;;
         2542  +
         2543  +interix[[3-9]]*)
         2544  +  version_type=linux
         2545  +  need_lib_prefix=no
         2546  +  need_version=no
         2547  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
         2548  +  soname_spec='${libname}${release}${shared_ext}$major'
         2549  +  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
         2550  +  shlibpath_var=LD_LIBRARY_PATH
         2551  +  shlibpath_overrides_runpath=no
         2552  +  hardcode_into_libs=yes
         2553  +  ;;
         2554  +
         2555  +irix5* | irix6* | nonstopux*)
         2556  +  case $host_os in
         2557  +    nonstopux*) version_type=nonstopux ;;
         2558  +    *)
         2559  +	if test "$lt_cv_prog_gnu_ld" = yes; then
         2560  +		version_type=linux
         2561  +	else
         2562  +		version_type=irix
         2563  +	fi ;;
         2564  +  esac
         2565  +  need_lib_prefix=no
         2566  +  need_version=no
         2567  +  soname_spec='${libname}${release}${shared_ext}$major'
         2568  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
         2569  +  case $host_os in
         2570  +  irix5* | nonstopux*)
         2571  +    libsuff= shlibsuff=
         2572  +    ;;
         2573  +  *)
         2574  +    case $LD in # libtool.m4 will add one of these switches to LD
         2575  +    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
         2576  +      libsuff= shlibsuff= libmagic=32-bit;;
         2577  +    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
         2578  +      libsuff=32 shlibsuff=N32 libmagic=N32;;
         2579  +    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
         2580  +      libsuff=64 shlibsuff=64 libmagic=64-bit;;
         2581  +    *) libsuff= shlibsuff= libmagic=never-match;;
         2582  +    esac
         2583  +    ;;
         2584  +  esac
         2585  +  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
         2586  +  shlibpath_overrides_runpath=no
         2587  +  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
         2588  +  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
         2589  +  hardcode_into_libs=yes
         2590  +  ;;
         2591  +
         2592  +# No shared lib support for Linux oldld, aout, or coff.
         2593  +linux*oldld* | linux*aout* | linux*coff*)
         2594  +  dynamic_linker=no
         2595  +  ;;
         2596  +
         2597  +# This must be Linux ELF.
         2598  +linux* | k*bsd*-gnu | kopensolaris*-gnu)
         2599  +  version_type=linux
         2600  +  need_lib_prefix=no
         2601  +  need_version=no
         2602  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2603  +  soname_spec='${libname}${release}${shared_ext}$major'
         2604  +  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
         2605  +  shlibpath_var=LD_LIBRARY_PATH
         2606  +  shlibpath_overrides_runpath=no
         2607  +
         2608  +  # Some binutils ld are patched to set DT_RUNPATH
         2609  +  AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath],
         2610  +    [lt_cv_shlibpath_overrides_runpath=no
         2611  +    save_LDFLAGS=$LDFLAGS
         2612  +    save_libdir=$libdir
         2613  +    eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \
         2614  +	 LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\""
         2615  +    AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])],
         2616  +      [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null],
         2617  +	 [lt_cv_shlibpath_overrides_runpath=yes])])
         2618  +    LDFLAGS=$save_LDFLAGS
         2619  +    libdir=$save_libdir
         2620  +    ])
         2621  +  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
         2622  +
         2623  +  # This implies no fast_install, which is unacceptable.
         2624  +  # Some rework will be needed to allow for fast_install
         2625  +  # before this can be enabled.
         2626  +  hardcode_into_libs=yes
         2627  +
         2628  +  # Add ABI-specific directories to the system library path.
         2629  +  sys_lib_dlsearch_path_spec="/lib64 /usr/lib64 /lib /usr/lib"
         2630  +
         2631  +  # Append ld.so.conf contents to the search path
         2632  +  if test -f /etc/ld.so.conf; then
         2633  +    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;s/"//g;/^$/d' | tr '\n' ' '`
         2634  +    sys_lib_dlsearch_path_spec="$sys_lib_dlsearch_path_spec $lt_ld_extra"
         2635  +
         2636  +  fi
         2637  +
         2638  +  # We used to test for /lib/ld.so.1 and disable shared libraries on
         2639  +  # powerpc, because MkLinux only supported shared libraries with the
         2640  +  # GNU dynamic linker.  Since this was broken with cross compilers,
         2641  +  # most powerpc-linux boxes support dynamic linking these days and
         2642  +  # people can always --disable-shared, the test was removed, and we
         2643  +  # assume the GNU/Linux dynamic linker is in use.
         2644  +  dynamic_linker='GNU/Linux ld.so'
         2645  +  ;;
         2646  +
         2647  +netbsd*)
         2648  +  version_type=sunos
         2649  +  need_lib_prefix=no
         2650  +  need_version=no
         2651  +  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
         2652  +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
         2653  +    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
         2654  +    dynamic_linker='NetBSD (a.out) ld.so'
         2655  +  else
         2656  +    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
         2657  +    soname_spec='${libname}${release}${shared_ext}$major'
         2658  +    dynamic_linker='NetBSD ld.elf_so'
         2659  +  fi
         2660  +  shlibpath_var=LD_LIBRARY_PATH
         2661  +  shlibpath_overrides_runpath=yes
         2662  +  hardcode_into_libs=yes
         2663  +  ;;
         2664  +
         2665  +newsos6)
         2666  +  version_type=linux
         2667  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2668  +  shlibpath_var=LD_LIBRARY_PATH
         2669  +  shlibpath_overrides_runpath=yes
         2670  +  ;;
         2671  +
         2672  +*nto* | *qnx*)
         2673  +  version_type=qnx
         2674  +  need_lib_prefix=no
         2675  +  need_version=no
         2676  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2677  +  soname_spec='${libname}${release}${shared_ext}$major'
         2678  +  shlibpath_var=LD_LIBRARY_PATH
         2679  +  shlibpath_overrides_runpath=no
         2680  +  hardcode_into_libs=yes
         2681  +  dynamic_linker='ldqnx.so'
         2682  +  ;;
         2683  +
         2684  +openbsd*)
         2685  +  version_type=sunos
         2686  +  sys_lib_dlsearch_path_spec="/usr/lib"
         2687  +  need_lib_prefix=no
         2688  +  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
         2689  +  case $host_os in
         2690  +    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
         2691  +    *)				need_version=no  ;;
         2692  +  esac
         2693  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
         2694  +  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
         2695  +  shlibpath_var=LD_LIBRARY_PATH
         2696  +  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
         2697  +    case $host_os in
         2698  +      openbsd2.[[89]] | openbsd2.[[89]].*)
         2699  +	shlibpath_overrides_runpath=no
         2700  +	;;
         2701  +      *)
         2702  +	shlibpath_overrides_runpath=yes
         2703  +	;;
         2704  +      esac
         2705  +  else
         2706  +    shlibpath_overrides_runpath=yes
         2707  +  fi
         2708  +  ;;
         2709  +
         2710  +os2*)
         2711  +  libname_spec='$name'
         2712  +  shrext_cmds=".dll"
         2713  +  need_lib_prefix=no
         2714  +  library_names_spec='$libname${shared_ext} $libname.a'
         2715  +  dynamic_linker='OS/2 ld.exe'
         2716  +  shlibpath_var=LIBPATH
         2717  +  ;;
         2718  +
         2719  +osf3* | osf4* | osf5*)
         2720  +  version_type=osf
         2721  +  need_lib_prefix=no
         2722  +  need_version=no
         2723  +  soname_spec='${libname}${release}${shared_ext}$major'
         2724  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2725  +  shlibpath_var=LD_LIBRARY_PATH
         2726  +  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
         2727  +  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
         2728  +  ;;
         2729  +
         2730  +rdos*)
         2731  +  dynamic_linker=no
         2732  +  ;;
         2733  +
         2734  +solaris*)
         2735  +  version_type=linux
         2736  +  need_lib_prefix=no
         2737  +  need_version=no
         2738  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2739  +  soname_spec='${libname}${release}${shared_ext}$major'
         2740  +  shlibpath_var=LD_LIBRARY_PATH
         2741  +  shlibpath_overrides_runpath=yes
         2742  +  hardcode_into_libs=yes
         2743  +  # ldd complains unless libraries are executable
         2744  +  postinstall_cmds='chmod +x $lib'
         2745  +  ;;
         2746  +
         2747  +sunos4*)
         2748  +  version_type=sunos
         2749  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
         2750  +  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
         2751  +  shlibpath_var=LD_LIBRARY_PATH
         2752  +  shlibpath_overrides_runpath=yes
         2753  +  if test "$with_gnu_ld" = yes; then
         2754  +    need_lib_prefix=no
         2755  +  fi
         2756  +  need_version=yes
         2757  +  ;;
         2758  +
         2759  +sysv4 | sysv4.3*)
         2760  +  version_type=linux
         2761  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2762  +  soname_spec='${libname}${release}${shared_ext}$major'
         2763  +  shlibpath_var=LD_LIBRARY_PATH
         2764  +  case $host_vendor in
         2765  +    sni)
         2766  +      shlibpath_overrides_runpath=no
         2767  +      need_lib_prefix=no
         2768  +      runpath_var=LD_RUN_PATH
         2769  +      ;;
         2770  +    siemens)
         2771  +      need_lib_prefix=no
         2772  +      ;;
         2773  +    motorola)
         2774  +      need_lib_prefix=no
         2775  +      need_version=no
         2776  +      shlibpath_overrides_runpath=no
         2777  +      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
         2778  +      ;;
         2779  +  esac
         2780  +  ;;
         2781  +
         2782  +sysv4*MP*)
         2783  +  if test -d /usr/nec ;then
         2784  +    version_type=linux
         2785  +    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
         2786  +    soname_spec='$libname${shared_ext}.$major'
         2787  +    shlibpath_var=LD_LIBRARY_PATH
         2788  +  fi
         2789  +  ;;
         2790  +
         2791  +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
         2792  +  version_type=freebsd-elf
         2793  +  need_lib_prefix=no
         2794  +  need_version=no
         2795  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
         2796  +  soname_spec='${libname}${release}${shared_ext}$major'
         2797  +  shlibpath_var=LD_LIBRARY_PATH
         2798  +  shlibpath_overrides_runpath=yes
         2799  +  hardcode_into_libs=yes
         2800  +  if test "$with_gnu_ld" = yes; then
         2801  +    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
         2802  +  else
         2803  +    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
         2804  +    case $host_os in
         2805  +      sco3.2v5*)
         2806  +        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
         2807  +	;;
         2808  +    esac
         2809  +  fi
         2810  +  sys_lib_dlsearch_path_spec='/usr/lib'
         2811  +  ;;
         2812  +
         2813  +tpf*)
         2814  +  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
         2815  +  version_type=linux
         2816  +  need_lib_prefix=no
         2817  +  need_version=no
         2818  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2819  +  shlibpath_var=LD_LIBRARY_PATH
         2820  +  shlibpath_overrides_runpath=no
         2821  +  hardcode_into_libs=yes
         2822  +  ;;
         2823  +
         2824  +uts4*)
         2825  +  version_type=linux
         2826  +  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
         2827  +  soname_spec='${libname}${release}${shared_ext}$major'
         2828  +  shlibpath_var=LD_LIBRARY_PATH
         2829  +  ;;
         2830  +
         2831  +*)
         2832  +  dynamic_linker=no
         2833  +  ;;
         2834  +esac
         2835  +AC_MSG_RESULT([$dynamic_linker])
         2836  +test "$dynamic_linker" = no && can_build_shared=no
         2837  +
         2838  +variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
         2839  +if test "$GCC" = yes; then
         2840  +  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
         2841  +fi
         2842  +
         2843  +if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
         2844  +  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
         2845  +fi
         2846  +if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
         2847  +  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
         2848  +fi
         2849  +
         2850  +_LT_DECL([], [variables_saved_for_relink], [1],
         2851  +    [Variables whose values should be saved in libtool wrapper scripts and
         2852  +    restored at link time])
         2853  +_LT_DECL([], [need_lib_prefix], [0],
         2854  +    [Do we need the "lib" prefix for modules?])
         2855  +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?])
         2856  +_LT_DECL([], [version_type], [0], [Library versioning type])
         2857  +_LT_DECL([], [runpath_var], [0],  [Shared library runtime path variable])
         2858  +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable])
         2859  +_LT_DECL([], [shlibpath_overrides_runpath], [0],
         2860  +    [Is shlibpath searched before the hard-coded library search path?])
         2861  +_LT_DECL([], [libname_spec], [1], [Format of library name prefix])
         2862  +_LT_DECL([], [library_names_spec], [1],
         2863  +    [[List of archive names.  First name is the real one, the rest are links.
         2864  +    The last name is the one that the linker finds with -lNAME]])
         2865  +_LT_DECL([], [soname_spec], [1],
         2866  +    [[The coded name of the library, if different from the real name]])
         2867  +_LT_DECL([], [install_override_mode], [1],
         2868  +    [Permission mode override for installation of shared libraries])
         2869  +_LT_DECL([], [postinstall_cmds], [2],
         2870  +    [Command to use after installation of a shared archive])
         2871  +_LT_DECL([], [postuninstall_cmds], [2],
         2872  +    [Command to use after uninstallation of a shared archive])
         2873  +_LT_DECL([], [finish_cmds], [2],
         2874  +    [Commands used to finish a libtool library installation in a directory])
         2875  +_LT_DECL([], [finish_eval], [1],
         2876  +    [[As "finish_cmds", except a single script fragment to be evaled but
         2877  +    not shown]])
         2878  +_LT_DECL([], [hardcode_into_libs], [0],
         2879  +    [Whether we should hardcode library paths into libraries])
         2880  +_LT_DECL([], [sys_lib_search_path_spec], [2],
         2881  +    [Compile-time system search path for libraries])
         2882  +_LT_DECL([], [sys_lib_dlsearch_path_spec], [2],
         2883  +    [Run-time system search path for libraries])
         2884  +])# _LT_SYS_DYNAMIC_LINKER
         2885  +
         2886  +
         2887  +# _LT_PATH_TOOL_PREFIX(TOOL)
         2888  +# --------------------------
         2889  +# find a file program which can recognize shared library
         2890  +AC_DEFUN([_LT_PATH_TOOL_PREFIX],
         2891  +[m4_require([_LT_DECL_EGREP])dnl
         2892  +AC_MSG_CHECKING([for $1])
         2893  +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
         2894  +[case $MAGIC_CMD in
         2895  +[[\\/*] |  ?:[\\/]*])
         2896  +  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
         2897  +  ;;
         2898  +*)
         2899  +  lt_save_MAGIC_CMD="$MAGIC_CMD"
         2900  +  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
         2901  +dnl $ac_dummy forces splitting on constant user-supplied paths.
         2902  +dnl POSIX.2 word splitting is done only on the output of word expansions,
         2903  +dnl not every word.  This closes a longstanding sh security hole.
         2904  +  ac_dummy="m4_if([$2], , $PATH, [$2])"
         2905  +  for ac_dir in $ac_dummy; do
         2906  +    IFS="$lt_save_ifs"
         2907  +    test -z "$ac_dir" && ac_dir=.
         2908  +    if test -f $ac_dir/$1; then
         2909  +      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
         2910  +      if test -n "$file_magic_test_file"; then
         2911  +	case $deplibs_check_method in
         2912  +	"file_magic "*)
         2913  +	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
         2914  +	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
         2915  +	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
         2916  +	    $EGREP "$file_magic_regex" > /dev/null; then
         2917  +	    :
         2918  +	  else
         2919  +	    cat <<_LT_EOF 1>&2
         2920  +
         2921  +*** Warning: the command libtool uses to detect shared libraries,
         2922  +*** $file_magic_cmd, produces output that libtool cannot recognize.
         2923  +*** The result is that libtool may fail to recognize shared libraries
         2924  +*** as such.  This will affect the creation of libtool libraries that
         2925  +*** depend on shared libraries, but programs linked with such libtool
         2926  +*** libraries will work regardless of this problem.  Nevertheless, you
         2927  +*** may want to report the problem to your system manager and/or to
         2928  +*** bug-libtool@gnu.org
         2929  +
         2930  +_LT_EOF
         2931  +	  fi ;;
         2932  +	esac
         2933  +      fi
         2934  +      break
         2935  +    fi
         2936  +  done
         2937  +  IFS="$lt_save_ifs"
         2938  +  MAGIC_CMD="$lt_save_MAGIC_CMD"
         2939  +  ;;
         2940  +esac])
         2941  +MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
         2942  +if test -n "$MAGIC_CMD"; then
         2943  +  AC_MSG_RESULT($MAGIC_CMD)
         2944  +else
         2945  +  AC_MSG_RESULT(no)
         2946  +fi
         2947  +_LT_DECL([], [MAGIC_CMD], [0],
         2948  +	 [Used to examine libraries when file_magic_cmd begins with "file"])dnl
         2949  +])# _LT_PATH_TOOL_PREFIX
         2950  +
         2951  +# Old name:
         2952  +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX])
         2953  +dnl aclocal-1.4 backwards compatibility:
         2954  +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], [])
         2955  +
         2956  +
         2957  +# _LT_PATH_MAGIC
         2958  +# --------------
         2959  +# find a file program which can recognize a shared library
         2960  +m4_defun([_LT_PATH_MAGIC],
         2961  +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
         2962  +if test -z "$lt_cv_path_MAGIC_CMD"; then
         2963  +  if test -n "$ac_tool_prefix"; then
         2964  +    _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
         2965  +  else
         2966  +    MAGIC_CMD=:
         2967  +  fi
         2968  +fi
         2969  +])# _LT_PATH_MAGIC
         2970  +
         2971  +
         2972  +# LT_PATH_LD
         2973  +# ----------
         2974  +# find the pathname to the GNU or non-GNU linker
         2975  +AC_DEFUN([LT_PATH_LD],
         2976  +[AC_REQUIRE([AC_PROG_CC])dnl
         2977  +AC_REQUIRE([AC_CANONICAL_HOST])dnl
         2978  +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
         2979  +m4_require([_LT_DECL_SED])dnl
         2980  +m4_require([_LT_DECL_EGREP])dnl
         2981  +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl
         2982  +
         2983  +AC_ARG_WITH([gnu-ld],
         2984  +    [AS_HELP_STRING([--with-gnu-ld],
         2985  +	[assume the C compiler uses GNU ld @<:@default=no@:>@])],
         2986  +    [test "$withval" = no || with_gnu_ld=yes],
         2987  +    [with_gnu_ld=no])dnl
         2988  +
         2989  +ac_prog=ld
         2990  +if test "$GCC" = yes; then
         2991  +  # Check if gcc -print-prog-name=ld gives a path.
         2992  +  AC_MSG_CHECKING([for ld used by $CC])
         2993  +  case $host in
         2994  +  *-*-mingw*)
         2995  +    # gcc leaves a trailing carriage return which upsets mingw
         2996  +    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
         2997  +  *)
         2998  +    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
         2999  +  esac
         3000  +  case $ac_prog in
         3001  +    # Accept absolute paths.
         3002  +    [[\\/]]* | ?:[[\\/]]*)
         3003  +      re_direlt='/[[^/]][[^/]]*/\.\./'
         3004  +      # Canonicalize the pathname of ld
         3005  +      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
         3006  +      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
         3007  +	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
         3008  +      done
         3009  +      test -z "$LD" && LD="$ac_prog"
         3010  +      ;;
         3011  +  "")
         3012  +    # If it fails, then pretend we aren't using GCC.
         3013  +    ac_prog=ld
         3014  +    ;;
         3015  +  *)
         3016  +    # If it is relative, then search for the first ld in PATH.
         3017  +    with_gnu_ld=unknown
         3018  +    ;;
         3019  +  esac
         3020  +elif test "$with_gnu_ld" = yes; then
         3021  +  AC_MSG_CHECKING([for GNU ld])
         3022  +else
         3023  +  AC_MSG_CHECKING([for non-GNU ld])
         3024  +fi
         3025  +AC_CACHE_VAL(lt_cv_path_LD,
         3026  +[if test -z "$LD"; then
         3027  +  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
         3028  +  for ac_dir in $PATH; do
         3029  +    IFS="$lt_save_ifs"
         3030  +    test -z "$ac_dir" && ac_dir=.
         3031  +    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
         3032  +      lt_cv_path_LD="$ac_dir/$ac_prog"
         3033  +      # Check to see if the program is GNU ld.  I'd rather use --version,
         3034  +      # but apparently some variants of GNU ld only accept -v.
         3035  +      # Break only if it was the GNU/non-GNU ld that we prefer.
         3036  +      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
         3037  +      *GNU* | *'with BFD'*)
         3038  +	test "$with_gnu_ld" != no && break
         3039  +	;;
         3040  +      *)
         3041  +	test "$with_gnu_ld" != yes && break
         3042  +	;;
         3043  +      esac
         3044  +    fi
         3045  +  done
         3046  +  IFS="$lt_save_ifs"
         3047  +else
         3048  +  lt_cv_path_LD="$LD" # Let the user override the test with a path.
         3049  +fi])
         3050  +LD="$lt_cv_path_LD"
         3051  +if test -n "$LD"; then
         3052  +  AC_MSG_RESULT($LD)
         3053  +else
         3054  +  AC_MSG_RESULT(no)
         3055  +fi
         3056  +test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
         3057  +_LT_PATH_LD_GNU
         3058  +AC_SUBST([LD])
         3059  +
         3060  +_LT_TAGDECL([], [LD], [1], [The linker used to build libraries])
         3061  +])# LT_PATH_LD
         3062  +
         3063  +# Old names:
         3064  +AU_ALIAS([AM_PROG_LD], [LT_PATH_LD])
         3065  +AU_ALIAS([AC_PROG_LD], [LT_PATH_LD])
         3066  +dnl aclocal-1.4 backwards compatibility:
         3067  +dnl AC_DEFUN([AM_PROG_LD], [])
         3068  +dnl AC_DEFUN([AC_PROG_LD], [])
         3069  +
         3070  +
         3071  +# _LT_PATH_LD_GNU
         3072  +#- --------------
         3073  +m4_defun([_LT_PATH_LD_GNU],
         3074  +[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
         3075  +[# I'd rather use --version here, but apparently some GNU lds only accept -v.
         3076  +case `$LD -v 2>&1 </dev/null` in
         3077  +*GNU* | *'with BFD'*)
         3078  +  lt_cv_prog_gnu_ld=yes
         3079  +  ;;
         3080  +*)
         3081  +  lt_cv_prog_gnu_ld=no
         3082  +  ;;
         3083  +esac])
         3084  +with_gnu_ld=$lt_cv_prog_gnu_ld
         3085  +])# _LT_PATH_LD_GNU
         3086  +
         3087  +
         3088  +# _LT_CMD_RELOAD
         3089  +# --------------
         3090  +# find reload flag for linker
         3091  +#   -- PORTME Some linkers may need a different reload flag.
         3092  +m4_defun([_LT_CMD_RELOAD],
         3093  +[AC_CACHE_CHECK([for $LD option to reload object files],
         3094  +  lt_cv_ld_reload_flag,
         3095  +  [lt_cv_ld_reload_flag='-r'])
         3096  +reload_flag=$lt_cv_ld_reload_flag
         3097  +case $reload_flag in
         3098  +"" | " "*) ;;
         3099  +*) reload_flag=" $reload_flag" ;;
         3100  +esac
         3101  +reload_cmds='$LD$reload_flag -o $output$reload_objs'
         3102  +case $host_os in
         3103  +  cygwin* | mingw* | pw32* | cegcc*)
         3104  +    if test "$GCC" != yes; then
         3105  +      reload_cmds=false
         3106  +    fi
         3107  +    ;;
         3108  +  darwin*)
         3109  +    if test "$GCC" = yes; then
         3110  +      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
         3111  +    else
         3112  +      reload_cmds='$LD$reload_flag -o $output$reload_objs'
         3113  +    fi
         3114  +    ;;
         3115  +esac
         3116  +_LT_TAGDECL([], [reload_flag], [1], [How to create reloadable object files])dnl
         3117  +_LT_TAGDECL([], [reload_cmds], [2])dnl
         3118  +])# _LT_CMD_RELOAD
         3119  +
         3120  +
         3121  +# _LT_CHECK_MAGIC_METHOD
         3122  +# ----------------------
         3123  +# how to check for library dependencies
         3124  +#  -- PORTME fill in with the dynamic library characteristics
         3125  +m4_defun([_LT_CHECK_MAGIC_METHOD],
         3126  +[m4_require([_LT_DECL_EGREP])
         3127  +m4_require([_LT_DECL_OBJDUMP])
         3128  +AC_CACHE_CHECK([how to recognize dependent libraries],
         3129  +lt_cv_deplibs_check_method,
         3130  +[lt_cv_file_magic_cmd='$MAGIC_CMD'
         3131  +lt_cv_file_magic_test_file=
         3132  +lt_cv_deplibs_check_method='unknown'
         3133  +# Need to set the preceding variable on all platforms that support
         3134  +# interlibrary dependencies.
         3135  +# 'none' -- dependencies not supported.
         3136  +# `unknown' -- same as none, but documents that we really don't know.
         3137  +# 'pass_all' -- all dependencies passed with no checks.
         3138  +# 'test_compile' -- check by making test program.
         3139  +# 'file_magic [[regex]]' -- check by looking for files in library path
         3140  +# which responds to the $file_magic_cmd with a given extended regex.
         3141  +# If you have `file' or equivalent on your system and you're not sure
         3142  +# whether `pass_all' will *always* work, you probably want this one.
         3143  +
         3144  +case $host_os in
         3145  +aix[[4-9]]*)
         3146  +  lt_cv_deplibs_check_method=pass_all
         3147  +  ;;
         3148  +
         3149  +beos*)
         3150  +  lt_cv_deplibs_check_method=pass_all
         3151  +  ;;
         3152  +
         3153  +bsdi[[45]]*)
         3154  +  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
         3155  +  lt_cv_file_magic_cmd='/usr/bin/file -L'
         3156  +  lt_cv_file_magic_test_file=/shlib/libc.so
         3157  +  ;;
         3158  +
         3159  +cygwin*)
         3160  +  # func_win32_libid is a shell function defined in ltmain.sh
         3161  +  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
         3162  +  lt_cv_file_magic_cmd='func_win32_libid'
         3163  +  ;;
         3164  +
         3165  +mingw* | pw32*)
         3166  +  # Base MSYS/MinGW do not provide the 'file' command needed by
         3167  +  # func_win32_libid shell function, so use a weaker test based on 'objdump',
         3168  +  # unless we find 'file', for example because we are cross-compiling.
         3169  +  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
         3170  +  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
         3171  +    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
         3172  +    lt_cv_file_magic_cmd='func_win32_libid'
         3173  +  else
         3174  +    # Keep this pattern in sync with the one in func_win32_libid.
         3175  +    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
         3176  +    lt_cv_file_magic_cmd='$OBJDUMP -f'
         3177  +  fi
         3178  +  ;;
         3179  +
         3180  +cegcc*)
         3181  +  # use the weaker test based on 'objdump'. See mingw*.
         3182  +  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
         3183  +  lt_cv_file_magic_cmd='$OBJDUMP -f'
         3184  +  ;;
         3185  +
         3186  +darwin* | rhapsody*)
         3187  +  lt_cv_deplibs_check_method=pass_all
         3188  +  ;;
         3189  +
         3190  +freebsd* | dragonfly*)
         3191  +  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
         3192  +    case $host_cpu in
         3193  +    i*86 )
         3194  +      # Not sure whether the presence of OpenBSD here was a mistake.
         3195  +      # Let's accept both of them until this is cleared up.
         3196  +      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
         3197  +      lt_cv_file_magic_cmd=/usr/bin/file
         3198  +      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
         3199  +      ;;
         3200  +    esac
         3201  +  else
         3202  +    lt_cv_deplibs_check_method=pass_all
         3203  +  fi
         3204  +  ;;
         3205  +
         3206  +gnu*)
         3207  +  lt_cv_deplibs_check_method=pass_all
         3208  +  ;;
         3209  +
         3210  +haiku*)
         3211  +  lt_cv_deplibs_check_method=pass_all
         3212  +  ;;
         3213  +
         3214  +hpux10.20* | hpux11*)
         3215  +  lt_cv_file_magic_cmd=/usr/bin/file
         3216  +  case $host_cpu in
         3217  +  ia64*)
         3218  +    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
         3219  +    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
         3220  +    ;;
         3221  +  hppa*64*)
         3222  +    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]']
         3223  +    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
         3224  +    ;;
         3225  +  *)
         3226  +    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library'
         3227  +    lt_cv_file_magic_test_file=/usr/lib/libc.sl
         3228  +    ;;
         3229  +  esac
         3230  +  ;;
         3231  +
         3232  +interix[[3-9]]*)
         3233  +  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
         3234  +  lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$'
         3235  +  ;;
         3236  +
         3237  +irix5* | irix6* | nonstopux*)
         3238  +  case $LD in
         3239  +  *-32|*"-32 ") libmagic=32-bit;;
         3240  +  *-n32|*"-n32 ") libmagic=N32;;
         3241  +  *-64|*"-64 ") libmagic=64-bit;;
         3242  +  *) libmagic=never-match;;
         3243  +  esac
         3244  +  lt_cv_deplibs_check_method=pass_all
         3245  +  ;;
         3246  +
         3247  +# This must be Linux ELF.
         3248  +linux* | k*bsd*-gnu | kopensolaris*-gnu)
         3249  +  lt_cv_deplibs_check_method=pass_all
         3250  +  ;;
         3251  +
         3252  +netbsd*)
         3253  +  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
         3254  +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
         3255  +  else
         3256  +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
         3257  +  fi
         3258  +  ;;
         3259  +
         3260  +newos6*)
         3261  +  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
         3262  +  lt_cv_file_magic_cmd=/usr/bin/file
         3263  +  lt_cv_file_magic_test_file=/usr/lib/libnls.so
         3264  +  ;;
         3265  +
         3266  +*nto* | *qnx*)
         3267  +  lt_cv_deplibs_check_method=pass_all
         3268  +  ;;
         3269  +
         3270  +openbsd*)
         3271  +  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
         3272  +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
         3273  +  else
         3274  +    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
         3275  +  fi
         3276  +  ;;
         3277  +
         3278  +osf3* | osf4* | osf5*)
         3279  +  lt_cv_deplibs_check_method=pass_all
         3280  +  ;;
         3281  +
         3282  +rdos*)
         3283  +  lt_cv_deplibs_check_method=pass_all
         3284  +  ;;
         3285  +
         3286  +solaris*)
         3287  +  lt_cv_deplibs_check_method=pass_all
         3288  +  ;;
         3289  +
         3290  +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
         3291  +  lt_cv_deplibs_check_method=pass_all
         3292  +  ;;
         3293  +
         3294  +sysv4 | sysv4.3*)
         3295  +  case $host_vendor in
         3296  +  motorola)
         3297  +    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]]'
         3298  +    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
         3299  +    ;;
         3300  +  ncr)
         3301  +    lt_cv_deplibs_check_method=pass_all
         3302  +    ;;
         3303  +  sequent)
         3304  +    lt_cv_file_magic_cmd='/bin/file'
         3305  +    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
         3306  +    ;;
         3307  +  sni)
         3308  +    lt_cv_file_magic_cmd='/bin/file'
         3309  +    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
         3310  +    lt_cv_file_magic_test_file=/lib/libc.so
         3311  +    ;;
         3312  +  siemens)
         3313  +    lt_cv_deplibs_check_method=pass_all
         3314  +    ;;
         3315  +  pc)
         3316  +    lt_cv_deplibs_check_method=pass_all
         3317  +    ;;
         3318  +  esac
         3319  +  ;;
         3320  +
         3321  +tpf*)
         3322  +  lt_cv_deplibs_check_method=pass_all
         3323  +  ;;
         3324  +esac
         3325  +])
         3326  +
         3327  +file_magic_glob=
         3328  +want_nocaseglob=no
         3329  +if test "$build" = "$host"; then
         3330  +  case $host_os in
         3331  +  mingw* | pw32*)
         3332  +    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
         3333  +      want_nocaseglob=yes
         3334  +    else
         3335  +      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"`
         3336  +    fi
         3337  +    ;;
         3338  +  esac
         3339  +fi
         3340  +
         3341  +file_magic_cmd=$lt_cv_file_magic_cmd
         3342  +deplibs_check_method=$lt_cv_deplibs_check_method
         3343  +test -z "$deplibs_check_method" && deplibs_check_method=unknown
         3344  +
         3345  +_LT_DECL([], [deplibs_check_method], [1],
         3346  +    [Method to check whether dependent libraries are shared objects])
         3347  +_LT_DECL([], [file_magic_cmd], [1],
         3348  +    [Command to use when deplibs_check_method = "file_magic"])
         3349  +_LT_DECL([], [file_magic_glob], [1],
         3350  +    [How to find potential files when deplibs_check_method = "file_magic"])
         3351  +_LT_DECL([], [want_nocaseglob], [1],
         3352  +    [Find potential files using nocaseglob when deplibs_check_method = "file_magic"])
         3353  +])# _LT_CHECK_MAGIC_METHOD
         3354  +
         3355  +
         3356  +# LT_PATH_NM
         3357  +# ----------
         3358  +# find the pathname to a BSD- or MS-compatible name lister
         3359  +AC_DEFUN([LT_PATH_NM],
         3360  +[AC_REQUIRE([AC_PROG_CC])dnl
         3361  +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM,
         3362  +[if test -n "$NM"; then
         3363  +  # Let the user override the test.
         3364  +  lt_cv_path_NM="$NM"
         3365  +else
         3366  +  lt_nm_to_check="${ac_tool_prefix}nm"
         3367  +  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
         3368  +    lt_nm_to_check="$lt_nm_to_check nm"
         3369  +  fi
         3370  +  for lt_tmp_nm in $lt_nm_to_check; do
         3371  +    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
         3372  +    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
         3373  +      IFS="$lt_save_ifs"
         3374  +      test -z "$ac_dir" && ac_dir=.
         3375  +      tmp_nm="$ac_dir/$lt_tmp_nm"
         3376  +      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
         3377  +	# Check to see if the nm accepts a BSD-compat flag.
         3378  +	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
         3379  +	#   nm: unknown option "B" ignored
         3380  +	# Tru64's nm complains that /dev/null is an invalid object file
         3381  +	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
         3382  +	*/dev/null* | *'Invalid file or object type'*)
         3383  +	  lt_cv_path_NM="$tmp_nm -B"
         3384  +	  break
         3385  +	  ;;
         3386  +	*)
         3387  +	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
         3388  +	  */dev/null*)
         3389  +	    lt_cv_path_NM="$tmp_nm -p"
         3390  +	    break
         3391  +	    ;;
         3392  +	  *)
         3393  +	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
         3394  +	    continue # so that we can try to find one that supports BSD flags
         3395  +	    ;;
         3396  +	  esac
         3397  +	  ;;
         3398  +	esac
         3399  +      fi
         3400  +    done
         3401  +    IFS="$lt_save_ifs"
         3402  +  done
         3403  +  : ${lt_cv_path_NM=no}
         3404  +fi])
         3405  +if test "$lt_cv_path_NM" != "no"; then
         3406  +  NM="$lt_cv_path_NM"
         3407  +else
         3408  +  # Didn't find any BSD compatible name lister, look for dumpbin.
         3409  +  if test -n "$DUMPBIN"; then :
         3410  +    # Let the user override the test.
         3411  +  else
         3412  +    AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :)
         3413  +    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
         3414  +    *COFF*)
         3415  +      DUMPBIN="$DUMPBIN -symbols"
         3416  +      ;;
         3417  +    *)
         3418  +      DUMPBIN=:
         3419  +      ;;
         3420  +    esac
         3421  +  fi
         3422  +  AC_SUBST([DUMPBIN])
         3423  +  if test "$DUMPBIN" != ":"; then
         3424  +    NM="$DUMPBIN"
         3425  +  fi
         3426  +fi
         3427  +test -z "$NM" && NM=nm
         3428  +AC_SUBST([NM])
         3429  +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl
         3430  +
         3431  +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface],
         3432  +  [lt_cv_nm_interface="BSD nm"
         3433  +  echo "int some_variable = 0;" > conftest.$ac_ext
         3434  +  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD)
         3435  +  (eval "$ac_compile" 2>conftest.err)
         3436  +  cat conftest.err >&AS_MESSAGE_LOG_FD
         3437  +  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD)
         3438  +  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
         3439  +  cat conftest.err >&AS_MESSAGE_LOG_FD
         3440  +  (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD)
         3441  +  cat conftest.out >&AS_MESSAGE_LOG_FD
         3442  +  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
         3443  +    lt_cv_nm_interface="MS dumpbin"
         3444  +  fi
         3445  +  rm -f conftest*])
         3446  +])# LT_PATH_NM
         3447  +
         3448  +# Old names:
         3449  +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM])
         3450  +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM])
         3451  +dnl aclocal-1.4 backwards compatibility:
         3452  +dnl AC_DEFUN([AM_PROG_NM], [])
         3453  +dnl AC_DEFUN([AC_PROG_NM], [])
         3454  +
         3455  +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
         3456  +# --------------------------------
         3457  +# how to determine the name of the shared library
         3458  +# associated with a specific link library.
         3459  +#  -- PORTME fill in with the dynamic library characteristics
         3460  +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB],
         3461  +[m4_require([_LT_DECL_EGREP])
         3462  +m4_require([_LT_DECL_OBJDUMP])
         3463  +m4_require([_LT_DECL_DLLTOOL])
         3464  +AC_CACHE_CHECK([how to associate runtime and link libraries],
         3465  +lt_cv_sharedlib_from_linklib_cmd,
         3466  +[lt_cv_sharedlib_from_linklib_cmd='unknown'
         3467  +
         3468  +case $host_os in
         3469  +cygwin* | mingw* | pw32* | cegcc*)
         3470  +  # two different shell functions defined in ltmain.sh
         3471  +  # decide which to use based on capabilities of $DLLTOOL
         3472  +  case `$DLLTOOL --help 2>&1` in
         3473  +  *--identify-strict*)
         3474  +    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
         3475  +    ;;
         3476  +  *)
         3477  +    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
         3478  +    ;;
         3479  +  esac
         3480  +  ;;
         3481  +*)
         3482  +  # fallback: assume linklib IS sharedlib
         3483  +  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
         3484  +  ;;
         3485  +esac
         3486  +])
         3487  +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
         3488  +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
         3489  +
         3490  +_LT_DECL([], [sharedlib_from_linklib_cmd], [1],
         3491  +    [Command to associate shared and link libraries])
         3492  +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB
         3493  +
         3494  +
         3495  +# _LT_PATH_MANIFEST_TOOL
         3496  +# ----------------------
         3497  +# locate the manifest tool
         3498  +m4_defun([_LT_PATH_MANIFEST_TOOL],
         3499  +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :)
         3500  +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
         3501  +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool],
         3502  +  [lt_cv_path_mainfest_tool=no
         3503  +  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD
         3504  +  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
         3505  +  cat conftest.err >&AS_MESSAGE_LOG_FD
         3506  +  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
         3507  +    lt_cv_path_mainfest_tool=yes
         3508  +  fi
         3509  +  rm -f conftest*])
         3510  +if test "x$lt_cv_path_mainfest_tool" != xyes; then
         3511  +  MANIFEST_TOOL=:
         3512  +fi
         3513  +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl
         3514  +])# _LT_PATH_MANIFEST_TOOL
         3515  +
         3516  +
         3517  +# LT_LIB_M
         3518  +# --------
         3519  +# check for math library
         3520  +AC_DEFUN([LT_LIB_M],
         3521  +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
         3522  +LIBM=
         3523  +case $host in
         3524  +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*)
         3525  +  # These system don't have libm, or don't need it
         3526  +  ;;
         3527  +*-ncr-sysv4.3*)
         3528  +  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
         3529  +  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
         3530  +  ;;
         3531  +*)
         3532  +  AC_CHECK_LIB(m, cos, LIBM="-lm")
         3533  +  ;;
         3534  +esac
         3535  +AC_SUBST([LIBM])
         3536  +])# LT_LIB_M
         3537  +
         3538  +# Old name:
         3539  +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M])
         3540  +dnl aclocal-1.4 backwards compatibility:
         3541  +dnl AC_DEFUN([AC_CHECK_LIBM], [])
         3542  +
         3543  +
         3544  +# _LT_COMPILER_NO_RTTI([TAGNAME])
         3545  +# -------------------------------
         3546  +m4_defun([_LT_COMPILER_NO_RTTI],
         3547  +[m4_require([_LT_TAG_COMPILER])dnl
         3548  +
         3549  +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
         3550  +
         3551  +if test "$GCC" = yes; then
         3552  +  case $cc_basename in
         3553  +  nvcc*)
         3554  +    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;;
         3555  +  *)
         3556  +    _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;;
         3557  +  esac
         3558  +
         3559  +  _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
         3560  +    lt_cv_prog_compiler_rtti_exceptions,
         3561  +    [-fno-rtti -fno-exceptions], [],
         3562  +    [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
         3563  +fi
         3564  +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1],
         3565  +	[Compiler flag to turn off builtin functions])
         3566  +])# _LT_COMPILER_NO_RTTI
         3567  +
         3568  +
         3569  +# _LT_CMD_GLOBAL_SYMBOLS
         3570  +# ----------------------
         3571  +m4_defun([_LT_CMD_GLOBAL_SYMBOLS],
         3572  +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
         3573  +AC_REQUIRE([AC_PROG_CC])dnl
         3574  +AC_REQUIRE([AC_PROG_AWK])dnl
         3575  +AC_REQUIRE([LT_PATH_NM])dnl
         3576  +AC_REQUIRE([LT_PATH_LD])dnl
         3577  +m4_require([_LT_DECL_SED])dnl
         3578  +m4_require([_LT_DECL_EGREP])dnl
         3579  +m4_require([_LT_TAG_COMPILER])dnl
         3580  +
         3581  +# Check for command to grab the raw symbol name followed by C symbol from nm.
         3582  +AC_MSG_CHECKING([command to parse $NM output from $compiler object])
         3583  +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
         3584  +[
         3585  +# These are sane defaults that work on at least a few old systems.
         3586  +# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
         3587  +
         3588  +# Character class describing NM global symbol codes.
         3589  +symcode='[[BCDEGRST]]'
         3590  +
         3591  +# Regexp to match symbols that can be accessed directly from C.
         3592  +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
         3593  +
         3594  +# Define system-specific variables.
         3595  +case $host_os in
         3596  +aix*)
         3597  +  symcode='[[BCDT]]'
         3598  +  ;;
         3599  +cygwin* | mingw* | pw32* | cegcc*)
         3600  +  symcode='[[ABCDGISTW]]'
         3601  +  ;;
         3602  +hpux*)
         3603  +  if test "$host_cpu" = ia64; then
         3604  +    symcode='[[ABCDEGRST]]'
         3605  +  fi
         3606  +  ;;
         3607  +irix* | nonstopux*)
         3608  +  symcode='[[BCDEGRST]]'
         3609  +  ;;
         3610  +osf*)
         3611  +  symcode='[[BCDEGQRST]]'
         3612  +  ;;
         3613  +solaris*)
         3614  +  symcode='[[BDRT]]'
         3615  +  ;;
         3616  +sco3.2v5*)
         3617  +  symcode='[[DT]]'
         3618  +  ;;
         3619  +sysv4.2uw2*)
         3620  +  symcode='[[DT]]'
         3621  +  ;;
         3622  +sysv5* | sco5v6* | unixware* | OpenUNIX*)
         3623  +  symcode='[[ABDT]]'
         3624  +  ;;
         3625  +sysv4)
         3626  +  symcode='[[DFNSTU]]'
         3627  +  ;;
         3628  +esac
         3629  +
         3630  +# If we're using GNU nm, then use its standard symbol codes.
         3631  +case `$NM -V 2>&1` in
         3632  +*GNU* | *'with BFD'*)
         3633  +  symcode='[[ABCDGIRSTW]]' ;;
         3634  +esac
         3635  +
         3636  +# Transform an extracted symbol line into a proper C declaration.
         3637  +# Some systems (esp. on ia64) link data and code symbols differently,
         3638  +# so use this general approach.
         3639  +lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
         3640  +
         3641  +# Transform an extracted symbol line into symbol name and symbol address
         3642  +lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\)[[ ]]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (void *) \&\2},/p'"
         3643  +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'"
         3644  +
         3645  +# Handle CRLF in mingw tool chain
         3646  +opt_cr=
         3647  +case $build_os in
         3648  +mingw*)
         3649  +  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
         3650  +  ;;
         3651  +esac
         3652  +
         3653  +# Try without a prefix underscore, then with it.
         3654  +for ac_symprfx in "" "_"; do
         3655  +
         3656  +  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
         3657  +  symxfrm="\\1 $ac_symprfx\\2 \\2"
         3658  +
         3659  +  # Write the raw and C identifiers.
         3660  +  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
         3661  +    # Fake it for dumpbin and say T for any non-static function
         3662  +    # and D for any global variable.
         3663  +    # Also find C++ and __fastcall symbols from MSVC++,
         3664  +    # which start with @ or ?.
         3665  +    lt_cv_sys_global_symbol_pipe="$AWK ['"\
         3666  +"     {last_section=section; section=\$ 3};"\
         3667  +"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
         3668  +"     \$ 0!~/External *\|/{next};"\
         3669  +"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
         3670  +"     {if(hide[section]) next};"\
         3671  +"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
         3672  +"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
         3673  +"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
         3674  +"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
         3675  +"     ' prfx=^$ac_symprfx]"
         3676  +  else
         3677  +    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[	 ]]\($symcode$symcode*\)[[	 ]][[	 ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
         3678  +  fi
         3679  +  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
         3680  +
         3681  +  # Check to see that the pipe works correctly.
         3682  +  pipe_works=no
         3683  +
         3684  +  rm -f conftest*
         3685  +  cat > conftest.$ac_ext <<_LT_EOF
         3686  +#ifdef __cplusplus
         3687  +extern "C" {
         3688  +#endif
         3689  +char nm_test_var;
         3690  +void nm_test_func(void);
         3691  +void nm_test_func(void){}
         3692  +#ifdef __cplusplus
         3693  +}
         3694  +#endif
         3695  +int main(){nm_test_var='a';nm_test_func();return(0);}
         3696  +_LT_EOF
         3697  +
         3698  +  if AC_TRY_EVAL(ac_compile); then
         3699  +    # Now try to grab the symbols.
         3700  +    nlist=conftest.nm
         3701  +    if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then
         3702  +      # Try sorting and uniquifying the output.
         3703  +      if sort "$nlist" | uniq > "$nlist"T; then
         3704  +	mv -f "$nlist"T "$nlist"
         3705  +      else
         3706  +	rm -f "$nlist"T
         3707  +      fi
         3708  +
         3709  +      # Make sure that we snagged all the symbols we need.
         3710  +      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
         3711  +	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
         3712  +	  cat <<_LT_EOF > conftest.$ac_ext
         3713  +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
         3714  +#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
         3715  +/* DATA imports from DLLs on WIN32 con't be const, because runtime
         3716  +   relocations are performed -- see ld's documentation on pseudo-relocs.  */
         3717  +# define LT@&t@_DLSYM_CONST
         3718  +#elif defined(__osf__)
         3719  +/* This system does not cope well with relocations in const data.  */
         3720  +# define LT@&t@_DLSYM_CONST
         3721  +#else
         3722  +# define LT@&t@_DLSYM_CONST const
         3723  +#endif
         3724  +
         3725  +#ifdef __cplusplus
         3726  +extern "C" {
         3727  +#endif
         3728  +
         3729  +_LT_EOF
         3730  +	  # Now generate the symbol file.
         3731  +	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
         3732  +
         3733  +	  cat <<_LT_EOF >> conftest.$ac_ext
         3734  +
         3735  +/* The mapping between symbol names and symbols.  */
         3736  +LT@&t@_DLSYM_CONST struct {
         3737  +  const char *name;
         3738  +  void       *address;
         3739  +}
         3740  +lt__PROGRAM__LTX_preloaded_symbols[[]] =
         3741  +{
         3742  +  { "@PROGRAM@", (void *) 0 },
         3743  +_LT_EOF
         3744  +	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
         3745  +	  cat <<\_LT_EOF >> conftest.$ac_ext
         3746  +  {0, (void *) 0}
         3747  +};
         3748  +
         3749  +/* This works around a problem in FreeBSD linker */
         3750  +#ifdef FREEBSD_WORKAROUND
         3751  +static const void *lt_preloaded_setup() {
         3752  +  return lt__PROGRAM__LTX_preloaded_symbols;
         3753  +}
         3754  +#endif
         3755  +
         3756  +#ifdef __cplusplus
         3757  +}
         3758  +#endif
         3759  +_LT_EOF
         3760  +	  # Now try linking the two files.
         3761  +	  mv conftest.$ac_objext conftstm.$ac_objext
         3762  +	  lt_globsym_save_LIBS=$LIBS
         3763  +	  lt_globsym_save_CFLAGS=$CFLAGS
         3764  +	  LIBS="conftstm.$ac_objext"
         3765  +	  CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
         3766  +	  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
         3767  +	    pipe_works=yes
         3768  +	  fi
         3769  +	  LIBS=$lt_globsym_save_LIBS
         3770  +	  CFLAGS=$lt_globsym_save_CFLAGS
         3771  +	else
         3772  +	  echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
         3773  +	fi
         3774  +      else
         3775  +	echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
         3776  +      fi
         3777  +    else
         3778  +      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
         3779  +    fi
         3780  +  else
         3781  +    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
         3782  +    cat conftest.$ac_ext >&5
         3783  +  fi
         3784  +  rm -rf conftest* conftst*
         3785  +
         3786  +  # Do not use the global_symbol_pipe unless it works.
         3787  +  if test "$pipe_works" = yes; then
         3788  +    break
         3789  +  else
         3790  +    lt_cv_sys_global_symbol_pipe=
         3791  +  fi
         3792  +done
         3793  +])
         3794  +if test -z "$lt_cv_sys_global_symbol_pipe"; then
         3795  +  lt_cv_sys_global_symbol_to_cdecl=
         3796  +fi
         3797  +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
         3798  +  AC_MSG_RESULT(failed)
         3799  +else
         3800  +  AC_MSG_RESULT(ok)
         3801  +fi
         3802  +
         3803  +# Response file support.
         3804  +if test "$lt_cv_nm_interface" = "MS dumpbin"; then
         3805  +  nm_file_list_spec='@'
         3806  +elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then
         3807  +  nm_file_list_spec='@'
         3808  +fi
         3809  +
         3810  +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1],
         3811  +    [Take the output of nm and produce a listing of raw symbols and C names])
         3812  +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1],
         3813  +    [Transform the output of nm in a proper C declaration])
         3814  +_LT_DECL([global_symbol_to_c_name_address],
         3815  +    [lt_cv_sys_global_symbol_to_c_name_address], [1],
         3816  +    [Transform the output of nm in a C name address pair])
         3817  +_LT_DECL([global_symbol_to_c_name_address_lib_prefix],
         3818  +    [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1],
         3819  +    [Transform the output of nm in a C name address pair when lib prefix is needed])
         3820  +_LT_DECL([], [nm_file_list_spec], [1],
         3821  +    [Specify filename containing input files for $NM])
         3822  +]) # _LT_CMD_GLOBAL_SYMBOLS
         3823  +
         3824  +
         3825  +# _LT_COMPILER_PIC([TAGNAME])
         3826  +# ---------------------------
         3827  +m4_defun([_LT_COMPILER_PIC],
         3828  +[m4_require([_LT_TAG_COMPILER])dnl
         3829  +_LT_TAGVAR(lt_prog_compiler_wl, $1)=
         3830  +_LT_TAGVAR(lt_prog_compiler_pic, $1)=
         3831  +_LT_TAGVAR(lt_prog_compiler_static, $1)=
         3832  +
         3833  +m4_if([$1], [CXX], [
         3834  +  # C++ specific cases for pic, static, wl, etc.
         3835  +  if test "$GXX" = yes; then
         3836  +    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         3837  +    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         3838  +
         3839  +    case $host_os in
         3840  +    aix*)
         3841  +      # All AIX code is PIC.
         3842  +      if test "$host_cpu" = ia64; then
         3843  +	# AIX 5 now supports IA64 processor
         3844  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         3845  +      fi
         3846  +      ;;
         3847  +
         3848  +    amigaos*)
         3849  +      case $host_cpu in
         3850  +      powerpc)
         3851  +            # see comment about AmigaOS4 .so support
         3852  +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         3853  +        ;;
         3854  +      m68k)
         3855  +            # FIXME: we need at least 68020 code to build shared libraries, but
         3856  +            # adding the `-m68020' flag to GCC prevents building anything better,
         3857  +            # like `-m68040'.
         3858  +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         3859  +        ;;
         3860  +      esac
         3861  +      ;;
         3862  +
         3863  +    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
         3864  +      # PIC is the default for these OSes.
         3865  +      ;;
         3866  +    mingw* | cygwin* | os2* | pw32* | cegcc*)
         3867  +      # This hack is so that the source file can tell whether it is being
         3868  +      # built for inclusion in a dll (and should export symbols for example).
         3869  +      # Although the cygwin gcc ignores -fPIC, still need this for old-style
         3870  +      # (--disable-auto-import) libraries
         3871  +      m4_if([$1], [GCJ], [],
         3872  +	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
         3873  +      ;;
         3874  +    darwin* | rhapsody*)
         3875  +      # PIC is the default on this platform
         3876  +      # Common symbols not allowed in MH_DYLIB files
         3877  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
         3878  +      ;;
         3879  +    *djgpp*)
         3880  +      # DJGPP does not support shared libraries at all
         3881  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)=
         3882  +      ;;
         3883  +    haiku*)
         3884  +      # PIC is the default for Haiku.
         3885  +      # The "-static" flag exists, but is broken.
         3886  +      _LT_TAGVAR(lt_prog_compiler_static, $1)=
         3887  +      ;;
         3888  +    interix[[3-9]]*)
         3889  +      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
         3890  +      # Instead, we relocate shared libraries at runtime.
         3891  +      ;;
         3892  +    sysv4*MP*)
         3893  +      if test -d /usr/nec; then
         3894  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
         3895  +      fi
         3896  +      ;;
         3897  +    hpux*)
         3898  +      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
         3899  +      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
         3900  +      # sets the default TLS model and affects inlining.
         3901  +      case $host_cpu in
         3902  +      hppa*64*)
         3903  +	;;
         3904  +      *)
         3905  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         3906  +	;;
         3907  +      esac
         3908  +      ;;
         3909  +    *qnx* | *nto*)
         3910  +      # QNX uses GNU C++, but need to define -shared option too, otherwise
         3911  +      # it will coredump.
         3912  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
         3913  +      ;;
         3914  +    *)
         3915  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         3916  +      ;;
         3917  +    esac
         3918  +  else
         3919  +    case $host_os in
         3920  +      aix[[4-9]]*)
         3921  +	# All AIX code is PIC.
         3922  +	if test "$host_cpu" = ia64; then
         3923  +	  # AIX 5 now supports IA64 processor
         3924  +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         3925  +	else
         3926  +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
         3927  +	fi
         3928  +	;;
         3929  +      chorus*)
         3930  +	case $cc_basename in
         3931  +	cxch68*)
         3932  +	  # Green Hills C++ Compiler
         3933  +	  # _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"
         3934  +	  ;;
         3935  +	esac
         3936  +	;;
         3937  +      mingw* | cygwin* | os2* | pw32* | cegcc*)
         3938  +	# This hack is so that the source file can tell whether it is being
         3939  +	# built for inclusion in a dll (and should export symbols for example).
         3940  +	m4_if([$1], [GCJ], [],
         3941  +	  [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
         3942  +	;;
         3943  +      dgux*)
         3944  +	case $cc_basename in
         3945  +	  ec++*)
         3946  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         3947  +	    ;;
         3948  +	  ghcx*)
         3949  +	    # Green Hills C++ Compiler
         3950  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
         3951  +	    ;;
         3952  +	  *)
         3953  +	    ;;
         3954  +	esac
         3955  +	;;
         3956  +      freebsd* | dragonfly*)
         3957  +	# FreeBSD uses GNU C++
         3958  +	;;
         3959  +      hpux9* | hpux10* | hpux11*)
         3960  +	case $cc_basename in
         3961  +	  CC*)
         3962  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         3963  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
         3964  +	    if test "$host_cpu" != ia64; then
         3965  +	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
         3966  +	    fi
         3967  +	    ;;
         3968  +	  aCC*)
         3969  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         3970  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
         3971  +	    case $host_cpu in
         3972  +	    hppa*64*|ia64*)
         3973  +	      # +Z the default
         3974  +	      ;;
         3975  +	    *)
         3976  +	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
         3977  +	      ;;
         3978  +	    esac
         3979  +	    ;;
         3980  +	  *)
         3981  +	    ;;
         3982  +	esac
         3983  +	;;
         3984  +      interix*)
         3985  +	# This is c89, which is MS Visual C++ (no shared libs)
         3986  +	# Anyone wants to do a port?
         3987  +	;;
         3988  +      irix5* | irix6* | nonstopux*)
         3989  +	case $cc_basename in
         3990  +	  CC*)
         3991  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         3992  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         3993  +	    # CC pic flag -KPIC is the default.
         3994  +	    ;;
         3995  +	  *)
         3996  +	    ;;
         3997  +	esac
         3998  +	;;
         3999  +      linux* | k*bsd*-gnu | kopensolaris*-gnu)
         4000  +	case $cc_basename in
         4001  +	  KCC*)
         4002  +	    # KAI C++ Compiler
         4003  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
         4004  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         4005  +	    ;;
         4006  +	  ecpc* )
         4007  +	    # old Intel C++ for x86_64 which still supported -KPIC.
         4008  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4009  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4010  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         4011  +	    ;;
         4012  +	  icpc* )
         4013  +	    # Intel C++, used to be incompatible with GCC.
         4014  +	    # ICC 10 doesn't accept -KPIC any more.
         4015  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4016  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         4017  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         4018  +	    ;;
         4019  +	  pgCC* | pgcpp*)
         4020  +	    # Portland Group C++ compiler
         4021  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4022  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
         4023  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4024  +	    ;;
         4025  +	  cxx*)
         4026  +	    # Compaq C++
         4027  +	    # Make sure the PIC flag is empty.  It appears that all Alpha
         4028  +	    # Linux and Compaq Tru64 Unix objects are PIC.
         4029  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
         4030  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         4031  +	    ;;
         4032  +	  xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*)
         4033  +	    # IBM XL 8.0, 9.0 on PPC and BlueGene
         4034  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4035  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
         4036  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
         4037  +	    ;;
         4038  +	  *)
         4039  +	    case `$CC -V 2>&1 | sed 5q` in
         4040  +	    *Sun\ C*)
         4041  +	      # Sun C++ 5.9
         4042  +	      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4043  +	      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4044  +	      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
         4045  +	      ;;
         4046  +	    esac
         4047  +	    ;;
         4048  +	esac
         4049  +	;;
         4050  +      lynxos*)
         4051  +	;;
         4052  +      m88k*)
         4053  +	;;
         4054  +      mvs*)
         4055  +	case $cc_basename in
         4056  +	  cxx*)
         4057  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
         4058  +	    ;;
         4059  +	  *)
         4060  +	    ;;
         4061  +	esac
         4062  +	;;
         4063  +      netbsd*)
         4064  +	;;
         4065  +      *qnx* | *nto*)
         4066  +        # QNX uses GNU C++, but need to define -shared option too, otherwise
         4067  +        # it will coredump.
         4068  +        _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
         4069  +        ;;
         4070  +      osf3* | osf4* | osf5*)
         4071  +	case $cc_basename in
         4072  +	  KCC*)
         4073  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
         4074  +	    ;;
         4075  +	  RCC*)
         4076  +	    # Rational C++ 2.4.1
         4077  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
         4078  +	    ;;
         4079  +	  cxx*)
         4080  +	    # Digital/Compaq C++
         4081  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4082  +	    # Make sure the PIC flag is empty.  It appears that all Alpha
         4083  +	    # Linux and Compaq Tru64 Unix objects are PIC.
         4084  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
         4085  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         4086  +	    ;;
         4087  +	  *)
         4088  +	    ;;
         4089  +	esac
         4090  +	;;
         4091  +      psos*)
         4092  +	;;
         4093  +      solaris*)
         4094  +	case $cc_basename in
         4095  +	  CC* | sunCC*)
         4096  +	    # Sun C++ 4.2, 5.x and Centerline C++
         4097  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4098  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4099  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
         4100  +	    ;;
         4101  +	  gcx*)
         4102  +	    # Green Hills C++ Compiler
         4103  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
         4104  +	    ;;
         4105  +	  *)
         4106  +	    ;;
         4107  +	esac
         4108  +	;;
         4109  +      sunos4*)
         4110  +	case $cc_basename in
         4111  +	  CC*)
         4112  +	    # Sun C++ 4.x
         4113  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
         4114  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4115  +	    ;;
         4116  +	  lcc*)
         4117  +	    # Lucid
         4118  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
         4119  +	    ;;
         4120  +	  *)
         4121  +	    ;;
         4122  +	esac
         4123  +	;;
         4124  +      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
         4125  +	case $cc_basename in
         4126  +	  CC*)
         4127  +	    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4128  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4129  +	    _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4130  +	    ;;
         4131  +	esac
         4132  +	;;
         4133  +      tandem*)
         4134  +	case $cc_basename in
         4135  +	  NCC*)
         4136  +	    # NonStop-UX NCC 3.20
         4137  +	    _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4138  +	    ;;
         4139  +	  *)
         4140  +	    ;;
         4141  +	esac
         4142  +	;;
         4143  +      vxworks*)
         4144  +	;;
         4145  +      *)
         4146  +	_LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
         4147  +	;;
         4148  +    esac
         4149  +  fi
         4150  +],
         4151  +[
         4152  +  if test "$GCC" = yes; then
         4153  +    _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4154  +    _LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         4155  +
         4156  +    case $host_os in
         4157  +      aix*)
         4158  +      # All AIX code is PIC.
         4159  +      if test "$host_cpu" = ia64; then
         4160  +	# AIX 5 now supports IA64 processor
         4161  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4162  +      fi
         4163  +      ;;
         4164  +
         4165  +    amigaos*)
         4166  +      case $host_cpu in
         4167  +      powerpc)
         4168  +            # see comment about AmigaOS4 .so support
         4169  +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         4170  +        ;;
         4171  +      m68k)
         4172  +            # FIXME: we need at least 68020 code to build shared libraries, but
         4173  +            # adding the `-m68020' flag to GCC prevents building anything better,
         4174  +            # like `-m68040'.
         4175  +            _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
         4176  +        ;;
         4177  +      esac
         4178  +      ;;
         4179  +
         4180  +    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
         4181  +      # PIC is the default for these OSes.
         4182  +      ;;
         4183  +
         4184  +    mingw* | cygwin* | pw32* | os2* | cegcc*)
         4185  +      # This hack is so that the source file can tell whether it is being
         4186  +      # built for inclusion in a dll (and should export symbols for example).
         4187  +      # Although the cygwin gcc ignores -fPIC, still need this for old-style
         4188  +      # (--disable-auto-import) libraries
         4189  +      m4_if([$1], [GCJ], [],
         4190  +	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
         4191  +      ;;
         4192  +
         4193  +    darwin* | rhapsody*)
         4194  +      # PIC is the default on this platform
         4195  +      # Common symbols not allowed in MH_DYLIB files
         4196  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
         4197  +      ;;
         4198  +
         4199  +    haiku*)
         4200  +      # PIC is the default for Haiku.
         4201  +      # The "-static" flag exists, but is broken.
         4202  +      _LT_TAGVAR(lt_prog_compiler_static, $1)=
         4203  +      ;;
         4204  +
         4205  +    hpux*)
         4206  +      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
         4207  +      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
         4208  +      # sets the default TLS model and affects inlining.
         4209  +      case $host_cpu in
         4210  +      hppa*64*)
         4211  +	# +Z the default
         4212  +	;;
         4213  +      *)
         4214  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         4215  +	;;
         4216  +      esac
         4217  +      ;;
         4218  +
         4219  +    interix[[3-9]]*)
         4220  +      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
         4221  +      # Instead, we relocate shared libraries at runtime.
         4222  +      ;;
         4223  +
         4224  +    msdosdjgpp*)
         4225  +      # Just because we use GCC doesn't mean we suddenly get shared libraries
         4226  +      # on systems that don't support them.
         4227  +      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
         4228  +      enable_shared=no
         4229  +      ;;
         4230  +
         4231  +    *nto* | *qnx*)
         4232  +      # QNX uses GNU C++, but need to define -shared option too, otherwise
         4233  +      # it will coredump.
         4234  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
         4235  +      ;;
         4236  +
         4237  +    sysv4*MP*)
         4238  +      if test -d /usr/nec; then
         4239  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
         4240  +      fi
         4241  +      ;;
         4242  +
         4243  +    *)
         4244  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         4245  +      ;;
         4246  +    esac
         4247  +
         4248  +    case $cc_basename in
         4249  +    nvcc*) # Cuda Compiler Driver 2.2
         4250  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker '
         4251  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Xcompiler -fPIC'
         4252  +      ;;
         4253  +    esac
         4254  +  else
         4255  +    # PORTME Check for flag to pass linker flags through the system compiler.
         4256  +    case $host_os in
         4257  +    aix*)
         4258  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4259  +      if test "$host_cpu" = ia64; then
         4260  +	# AIX 5 now supports IA64 processor
         4261  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4262  +      else
         4263  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
         4264  +      fi
         4265  +      ;;
         4266  +
         4267  +    mingw* | cygwin* | pw32* | os2* | cegcc*)
         4268  +      # This hack is so that the source file can tell whether it is being
         4269  +      # built for inclusion in a dll (and should export symbols for example).
         4270  +      m4_if([$1], [GCJ], [],
         4271  +	[_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'])
         4272  +      ;;
         4273  +
         4274  +    hpux9* | hpux10* | hpux11*)
         4275  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4276  +      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
         4277  +      # not for PA HP-UX.
         4278  +      case $host_cpu in
         4279  +      hppa*64*|ia64*)
         4280  +	# +Z the default
         4281  +	;;
         4282  +      *)
         4283  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
         4284  +	;;
         4285  +      esac
         4286  +      # Is there a better lt_prog_compiler_static that works with the bundled CC?
         4287  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
         4288  +      ;;
         4289  +
         4290  +    irix5* | irix6* | nonstopux*)
         4291  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4292  +      # PIC (with -KPIC) is the default.
         4293  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         4294  +      ;;
         4295  +
         4296  +    linux* | k*bsd*-gnu | kopensolaris*-gnu)
         4297  +      case $cc_basename in
         4298  +      # old Intel for x86_64 which still supported -KPIC.
         4299  +      ecc*)
         4300  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4301  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4302  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         4303  +        ;;
         4304  +      # icc used to be incompatible with GCC.
         4305  +      # ICC 10 doesn't accept -KPIC any more.
         4306  +      icc* | ifort*)
         4307  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4308  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
         4309  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-static'
         4310  +        ;;
         4311  +      # Lahey Fortran 8.1.
         4312  +      lf95*)
         4313  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4314  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared'
         4315  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='--static'
         4316  +	;;
         4317  +      nagfor*)
         4318  +	# NAG Fortran compiler
         4319  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,'
         4320  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
         4321  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4322  +	;;
         4323  +      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
         4324  +        # Portland Group compilers (*not* the Pentium gcc compiler,
         4325  +	# which looks to be a dead project)
         4326  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4327  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
         4328  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4329  +        ;;
         4330  +      ccc*)
         4331  +        _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4332  +        # All Alpha code is PIC.
         4333  +        _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         4334  +        ;;
         4335  +      xl* | bgxl* | bgf* | mpixl*)
         4336  +	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
         4337  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4338  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic'
         4339  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink'
         4340  +	;;
         4341  +      *)
         4342  +	case `$CC -V 2>&1 | sed 5q` in
         4343  +	*Sun\ F* | *Sun*Fortran*)
         4344  +	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
         4345  +	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4346  +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4347  +	  _LT_TAGVAR(lt_prog_compiler_wl, $1)=''
         4348  +	  ;;
         4349  +	*Sun\ C*)
         4350  +	  # Sun C 5.9
         4351  +	  _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4352  +	  _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4353  +	  _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4354  +	  ;;
         4355  +	esac
         4356  +	;;
         4357  +      esac
         4358  +      ;;
         4359  +
         4360  +    newsos6)
         4361  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4362  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4363  +      ;;
         4364  +
         4365  +    *nto* | *qnx*)
         4366  +      # QNX uses GNU C++, but need to define -shared option too, otherwise
         4367  +      # it will coredump.
         4368  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared'
         4369  +      ;;
         4370  +
         4371  +    osf3* | osf4* | osf5*)
         4372  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4373  +      # All OSF/1 code is PIC.
         4374  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         4375  +      ;;
         4376  +
         4377  +    rdos*)
         4378  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
         4379  +      ;;
         4380  +
         4381  +    solaris*)
         4382  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4383  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4384  +      case $cc_basename in
         4385  +      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
         4386  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
         4387  +      *)
         4388  +	_LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
         4389  +      esac
         4390  +      ;;
         4391  +
         4392  +    sunos4*)
         4393  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
         4394  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
         4395  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4396  +      ;;
         4397  +
         4398  +    sysv4 | sysv4.2uw2* | sysv4.3*)
         4399  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4400  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4401  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4402  +      ;;
         4403  +
         4404  +    sysv4*MP*)
         4405  +      if test -d /usr/nec ;then
         4406  +	_LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
         4407  +	_LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4408  +      fi
         4409  +      ;;
         4410  +
         4411  +    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
         4412  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4413  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
         4414  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4415  +      ;;
         4416  +
         4417  +    unicos*)
         4418  +      _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
         4419  +      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
         4420  +      ;;
         4421  +
         4422  +    uts4*)
         4423  +      _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
         4424  +      _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
         4425  +      ;;
         4426  +
         4427  +    *)
         4428  +      _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
         4429  +      ;;
         4430  +    esac
         4431  +  fi
         4432  +])
         4433  +case $host_os in
         4434  +  # For platforms which do not support PIC, -DPIC is meaningless:
         4435  +  *djgpp*)
         4436  +    _LT_TAGVAR(lt_prog_compiler_pic, $1)=
         4437  +    ;;
         4438  +  *)
         4439  +    _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])"
         4440  +    ;;
         4441  +esac
         4442  +
         4443  +AC_CACHE_CHECK([for $compiler option to produce PIC],
         4444  +  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)],
         4445  +  [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)])
         4446  +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)
         4447  +
         4448  +#
         4449  +# Check to make sure the PIC flag actually works.
         4450  +#
         4451  +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then
         4452  +  _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works],
         4453  +    [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)],
         4454  +    [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [],
         4455  +    [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in
         4456  +     "" | " "*) ;;
         4457  +     *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;;
         4458  +     esac],
         4459  +    [_LT_TAGVAR(lt_prog_compiler_pic, $1)=
         4460  +     _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
         4461  +fi
         4462  +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1],
         4463  +	[Additional compiler flags for building library objects])
         4464  +
         4465  +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1],
         4466  +	[How to pass a linker flag through the compiler])
         4467  +#
         4468  +# Check to make sure the static flag actually works.
         4469  +#
         4470  +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\"
         4471  +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works],
         4472  +  _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1),
         4473  +  $lt_tmp_static_flag,
         4474  +  [],
         4475  +  [_LT_TAGVAR(lt_prog_compiler_static, $1)=])
         4476  +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1],
         4477  +	[Compiler flag to prevent dynamic linking])
         4478  +])# _LT_COMPILER_PIC
         4479  +
         4480  +
         4481  +# _LT_LINKER_SHLIBS([TAGNAME])
         4482  +# ----------------------------
         4483  +# See if the linker supports building shared libraries.
         4484  +m4_defun([_LT_LINKER_SHLIBS],
         4485  +[AC_REQUIRE([LT_PATH_LD])dnl
         4486  +AC_REQUIRE([LT_PATH_NM])dnl
         4487  +m4_require([_LT_PATH_MANIFEST_TOOL])dnl
         4488  +m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         4489  +m4_require([_LT_DECL_EGREP])dnl
         4490  +m4_require([_LT_DECL_SED])dnl
         4491  +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl
         4492  +m4_require([_LT_TAG_COMPILER])dnl
         4493  +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
         4494  +m4_if([$1], [CXX], [
         4495  +  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
         4496  +  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
         4497  +  case $host_os in
         4498  +  aix[[4-9]]*)
         4499  +    # If we're using GNU nm, then we don't want the "-C" option.
         4500  +    # -C means demangle to AIX nm, but means don't demangle with GNU nm
         4501  +    # Also, AIX nm treats weak defined symbols like other global defined
         4502  +    # symbols, whereas GNU nm marks them as "W".
         4503  +    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
         4504  +      _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
         4505  +    else
         4506  +      _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'
         4507  +    fi
         4508  +    ;;
         4509  +  pw32*)
         4510  +    _LT_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
         4511  +    ;;
         4512  +  cygwin* | mingw* | cegcc*)
         4513  +    case $cc_basename in
         4514  +    cl*) ;;
         4515  +    *)
         4516  +      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
         4517  +      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
         4518  +      ;;
         4519  +    esac
         4520  +    ;;
         4521  +  *)
         4522  +    _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
         4523  +    ;;
         4524  +  esac
         4525  +], [
         4526  +  runpath_var=
         4527  +  _LT_TAGVAR(allow_undefined_flag, $1)=
         4528  +  _LT_TAGVAR(always_export_symbols, $1)=no
         4529  +  _LT_TAGVAR(archive_cmds, $1)=
         4530  +  _LT_TAGVAR(archive_expsym_cmds, $1)=
         4531  +  _LT_TAGVAR(compiler_needs_object, $1)=no
         4532  +  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
         4533  +  _LT_TAGVAR(export_dynamic_flag_spec, $1)=
         4534  +  _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
         4535  +  _LT_TAGVAR(hardcode_automatic, $1)=no
         4536  +  _LT_TAGVAR(hardcode_direct, $1)=no
         4537  +  _LT_TAGVAR(hardcode_direct_absolute, $1)=no
         4538  +  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
         4539  +  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
         4540  +  _LT_TAGVAR(hardcode_libdir_separator, $1)=
         4541  +  _LT_TAGVAR(hardcode_minus_L, $1)=no
         4542  +  _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
         4543  +  _LT_TAGVAR(inherit_rpath, $1)=no
         4544  +  _LT_TAGVAR(link_all_deplibs, $1)=unknown
         4545  +  _LT_TAGVAR(module_cmds, $1)=
         4546  +  _LT_TAGVAR(module_expsym_cmds, $1)=
         4547  +  _LT_TAGVAR(old_archive_from_new_cmds, $1)=
         4548  +  _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)=
         4549  +  _LT_TAGVAR(thread_safe_flag_spec, $1)=
         4550  +  _LT_TAGVAR(whole_archive_flag_spec, $1)=
         4551  +  # include_expsyms should be a list of space-separated symbols to be *always*
         4552  +  # included in the symbol list
         4553  +  _LT_TAGVAR(include_expsyms, $1)=
         4554  +  # exclude_expsyms can be an extended regexp of symbols to exclude
         4555  +  # it will be wrapped by ` (' and `)$', so one must not match beginning or
         4556  +  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
         4557  +  # as well as any symbol that contains `d'.
         4558  +  _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*']
         4559  +  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
         4560  +  # platforms (ab)use it in PIC code, but their linkers get confused if
         4561  +  # the symbol is explicitly referenced.  Since portable code cannot
         4562  +  # rely on this symbol name, it's probably fine to never include it in
         4563  +  # preloaded symbol tables.
         4564  +  # Exclude shared library initialization/finalization symbols.
         4565  +dnl Note also adjust exclude_expsyms for C++ above.
         4566  +  extract_expsyms_cmds=
         4567  +
         4568  +  case $host_os in
         4569  +  cygwin* | mingw* | pw32* | cegcc*)
         4570  +    # FIXME: the MSVC++ port hasn't been tested in a loooong time
         4571  +    # When not using gcc, we currently assume that we are using
         4572  +    # Microsoft Visual C++.
         4573  +    if test "$GCC" != yes; then
         4574  +      with_gnu_ld=no
         4575  +    fi
         4576  +    ;;
         4577  +  interix*)
         4578  +    # we just hope/assume this is gcc and not c89 (= MSVC++)
         4579  +    with_gnu_ld=yes
         4580  +    ;;
         4581  +  openbsd*)
         4582  +    with_gnu_ld=no
         4583  +    ;;
         4584  +  esac
         4585  +
         4586  +  _LT_TAGVAR(ld_shlibs, $1)=yes
         4587  +
         4588  +  # On some targets, GNU ld is compatible enough with the native linker
         4589  +  # that we're better off using the native interface for both.
         4590  +  lt_use_gnu_ld_interface=no
         4591  +  if test "$with_gnu_ld" = yes; then
         4592  +    case $host_os in
         4593  +      aix*)
         4594  +	# The AIX port of GNU ld has always aspired to compatibility
         4595  +	# with the native linker.  However, as the warning in the GNU ld
         4596  +	# block says, versions before 2.19.5* couldn't really create working
         4597  +	# shared libraries, regardless of the interface used.
         4598  +	case `$LD -v 2>&1` in
         4599  +	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
         4600  +	  *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;;
         4601  +	  *\ \(GNU\ Binutils\)\ [[3-9]]*) ;;
         4602  +	  *)
         4603  +	    lt_use_gnu_ld_interface=yes
         4604  +	    ;;
         4605  +	esac
         4606  +	;;
         4607  +      *)
         4608  +	lt_use_gnu_ld_interface=yes
         4609  +	;;
         4610  +    esac
         4611  +  fi
         4612  +
         4613  +  if test "$lt_use_gnu_ld_interface" = yes; then
         4614  +    # If archive_cmds runs LD, not CC, wlarc should be empty
         4615  +    wlarc='${wl}'
         4616  +
         4617  +    # Set some defaults for GNU ld with shared library support. These
         4618  +    # are reset later if shared libraries are not supported. Putting them
         4619  +    # here allows them to be overridden if necessary.
         4620  +    runpath_var=LD_RUN_PATH
         4621  +    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         4622  +    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
         4623  +    # ancient GNU ld didn't support --whole-archive et. al.
         4624  +    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
         4625  +      _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
         4626  +    else
         4627  +      _LT_TAGVAR(whole_archive_flag_spec, $1)=
         4628  +    fi
         4629  +    supports_anon_versioning=no
         4630  +    case `$LD -v 2>&1` in
         4631  +      *GNU\ gold*) supports_anon_versioning=yes ;;
         4632  +      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
         4633  +      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
         4634  +      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
         4635  +      *\ 2.11.*) ;; # other 2.11 versions
         4636  +      *) supports_anon_versioning=yes ;;
         4637  +    esac
         4638  +
         4639  +    # See if GNU ld supports shared libraries.
         4640  +    case $host_os in
         4641  +    aix[[3-9]]*)
         4642  +      # On AIX/PPC, the GNU linker is very broken
         4643  +      if test "$host_cpu" != ia64; then
         4644  +	_LT_TAGVAR(ld_shlibs, $1)=no
         4645  +	cat <<_LT_EOF 1>&2
         4646  +
         4647  +*** Warning: the GNU linker, at least up to release 2.19, is reported
         4648  +*** to be unable to reliably create shared libraries on AIX.
         4649  +*** Therefore, libtool is disabling shared libraries support.  If you
         4650  +*** really care for shared libraries, you may want to install binutils
         4651  +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
         4652  +*** You will then need to restart the configuration process.
         4653  +
         4654  +_LT_EOF
         4655  +      fi
         4656  +      ;;
         4657  +
         4658  +    amigaos*)
         4659  +      case $host_cpu in
         4660  +      powerpc)
         4661  +            # see comment about AmigaOS4 .so support
         4662  +            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4663  +            _LT_TAGVAR(archive_expsym_cmds, $1)=''
         4664  +        ;;
         4665  +      m68k)
         4666  +            _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)'
         4667  +            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         4668  +            _LT_TAGVAR(hardcode_minus_L, $1)=yes
         4669  +        ;;
         4670  +      esac
         4671  +      ;;
         4672  +
         4673  +    beos*)
         4674  +      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
         4675  +	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         4676  +	# Joseph Beckenbach <jrb3@best.com> says some releases of gcc
         4677  +	# support --undefined.  This deserves some investigation.  FIXME
         4678  +	_LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4679  +      else
         4680  +	_LT_TAGVAR(ld_shlibs, $1)=no
         4681  +      fi
         4682  +      ;;
         4683  +
         4684  +    cygwin* | mingw* | pw32* | cegcc*)
         4685  +      # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
         4686  +      # as there is no search path for DLLs.
         4687  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         4688  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
         4689  +      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         4690  +      _LT_TAGVAR(always_export_symbols, $1)=no
         4691  +      _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
         4692  +      _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols'
         4693  +      _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname']
         4694  +
         4695  +      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
         4696  +        _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'
         4697  +	# If the export-symbols file already is a .def file (1st line
         4698  +	# is EXPORTS), use it as is; otherwise, prepend...
         4699  +	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
         4700  +	  cp $export_symbols $output_objdir/$soname.def;
         4701  +	else
         4702  +	  echo EXPORTS > $output_objdir/$soname.def;
         4703  +	  cat $export_symbols >> $output_objdir/$soname.def;
         4704  +	fi~
         4705  +	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
         4706  +      else
         4707  +	_LT_TAGVAR(ld_shlibs, $1)=no
         4708  +      fi
         4709  +      ;;
         4710  +
         4711  +    haiku*)
         4712  +      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4713  +      _LT_TAGVAR(link_all_deplibs, $1)=yes
         4714  +      ;;
         4715  +
         4716  +    interix[[3-9]]*)
         4717  +      _LT_TAGVAR(hardcode_direct, $1)=no
         4718  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         4719  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         4720  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         4721  +      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
         4722  +      # Instead, shared libraries are loaded at an image base (0x10000000 by
         4723  +      # default) and relocated if they conflict, which is a slow very memory
         4724  +      # consuming and fragmenting process.  To avoid this, we pick a random,
         4725  +      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
         4726  +      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
         4727  +      _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'
         4728  +      _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'
         4729  +      ;;
         4730  +
         4731  +    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
         4732  +      tmp_diet=no
         4733  +      if test "$host_os" = linux-dietlibc; then
         4734  +	case $cc_basename in
         4735  +	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
         4736  +	esac
         4737  +      fi
         4738  +      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
         4739  +	 && test "$tmp_diet" = no
         4740  +      then
         4741  +	tmp_addflag=' $pic_flag'
         4742  +	tmp_sharedflag='-shared'
         4743  +	case $cc_basename,$host_cpu in
         4744  +        pgcc*)				# Portland Group C compiler
         4745  +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
         4746  +	  tmp_addflag=' $pic_flag'
         4747  +	  ;;
         4748  +	pgf77* | pgf90* | pgf95* | pgfortran*)
         4749  +					# Portland Group f77 and f90 compilers
         4750  +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
         4751  +	  tmp_addflag=' $pic_flag -Mnomain' ;;
         4752  +	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
         4753  +	  tmp_addflag=' -i_dynamic' ;;
         4754  +	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
         4755  +	  tmp_addflag=' -i_dynamic -nofor_main' ;;
         4756  +	ifc* | ifort*)			# Intel Fortran compiler
         4757  +	  tmp_addflag=' -nofor_main' ;;
         4758  +	lf95*)				# Lahey Fortran 8.1
         4759  +	  _LT_TAGVAR(whole_archive_flag_spec, $1)=
         4760  +	  tmp_sharedflag='--shared' ;;
         4761  +	xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below)
         4762  +	  tmp_sharedflag='-qmkshrobj'
         4763  +	  tmp_addflag= ;;
         4764  +	nvcc*)	# Cuda Compiler Driver 2.2
         4765  +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
         4766  +	  _LT_TAGVAR(compiler_needs_object, $1)=yes
         4767  +	  ;;
         4768  +	esac
         4769  +	case `$CC -V 2>&1 | sed 5q` in
         4770  +	*Sun\ C*)			# Sun C 5.9
         4771  +	  _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; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
         4772  +	  _LT_TAGVAR(compiler_needs_object, $1)=yes
         4773  +	  tmp_sharedflag='-G' ;;
         4774  +	*Sun\ F*)			# Sun Fortran 8.3
         4775  +	  tmp_sharedflag='-G' ;;
         4776  +	esac
         4777  +	_LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4778  +
         4779  +        if test "x$supports_anon_versioning" = xyes; then
         4780  +          _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
         4781  +	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
         4782  +	    echo "local: *; };" >> $output_objdir/$libname.ver~
         4783  +	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
         4784  +        fi
         4785  +
         4786  +	case $cc_basename in
         4787  +	xlf* | bgf* | bgxlf* | mpixlf*)
         4788  +	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
         4789  +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive'
         4790  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
         4791  +	  _LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
         4792  +	  _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
         4793  +	  if test "x$supports_anon_versioning" = xyes; then
         4794  +	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
         4795  +	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
         4796  +	      echo "local: *; };" >> $output_objdir/$libname.ver~
         4797  +	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
         4798  +	  fi
         4799  +	  ;;
         4800  +	esac
         4801  +      else
         4802  +        _LT_TAGVAR(ld_shlibs, $1)=no
         4803  +      fi
         4804  +      ;;
         4805  +
         4806  +    netbsd*)
         4807  +      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
         4808  +	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
         4809  +	wlarc=
         4810  +      else
         4811  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4812  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
         4813  +      fi
         4814  +      ;;
         4815  +
         4816  +    solaris*)
         4817  +      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
         4818  +	_LT_TAGVAR(ld_shlibs, $1)=no
         4819  +	cat <<_LT_EOF 1>&2
         4820  +
         4821  +*** Warning: The releases 2.8.* of the GNU linker cannot reliably
         4822  +*** create shared libraries on Solaris systems.  Therefore, libtool
         4823  +*** is disabling shared libraries support.  We urge you to upgrade GNU
         4824  +*** binutils to release 2.9.1 or newer.  Another option is to modify
         4825  +*** your PATH or compiler configuration so that the native linker is
         4826  +*** used, and then restart.
         4827  +
         4828  +_LT_EOF
         4829  +      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
         4830  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4831  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
         4832  +      else
         4833  +	_LT_TAGVAR(ld_shlibs, $1)=no
         4834  +      fi
         4835  +      ;;
         4836  +
         4837  +    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
         4838  +      case `$LD -v 2>&1` in
         4839  +        *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*)
         4840  +	_LT_TAGVAR(ld_shlibs, $1)=no
         4841  +	cat <<_LT_EOF 1>&2
         4842  +
         4843  +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
         4844  +*** reliably create shared libraries on SCO systems.  Therefore, libtool
         4845  +*** is disabling shared libraries support.  We urge you to upgrade GNU
         4846  +*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
         4847  +*** your PATH or compiler configuration so that the native linker is
         4848  +*** used, and then restart.
         4849  +
         4850  +_LT_EOF
         4851  +	;;
         4852  +	*)
         4853  +	  # For security reasons, it is highly recommended that you always
         4854  +	  # use absolute paths for naming shared libraries, and exclude the
         4855  +	  # DT_RUNPATH tag from executables and libraries.  But doing so
         4856  +	  # requires that you compile everything twice, which is a pain.
         4857  +	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
         4858  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         4859  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4860  +	    _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'
         4861  +	  else
         4862  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         4863  +	  fi
         4864  +	;;
         4865  +      esac
         4866  +      ;;
         4867  +
         4868  +    sunos4*)
         4869  +      _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
         4870  +      wlarc=
         4871  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         4872  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         4873  +      ;;
         4874  +
         4875  +    *)
         4876  +      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
         4877  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         4878  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
         4879  +      else
         4880  +	_LT_TAGVAR(ld_shlibs, $1)=no
         4881  +      fi
         4882  +      ;;
         4883  +    esac
         4884  +
         4885  +    if test "$_LT_TAGVAR(ld_shlibs, $1)" = no; then
         4886  +      runpath_var=
         4887  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
         4888  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)=
         4889  +      _LT_TAGVAR(whole_archive_flag_spec, $1)=
         4890  +    fi
         4891  +  else
         4892  +    # PORTME fill in a description of your system's linker (not GNU ld)
         4893  +    case $host_os in
         4894  +    aix3*)
         4895  +      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         4896  +      _LT_TAGVAR(always_export_symbols, $1)=yes
         4897  +      _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'
         4898  +      # Note: this linker hardcodes the directories in LIBPATH if there
         4899  +      # are no directories specified by -L.
         4900  +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
         4901  +      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
         4902  +	# Neither direct hardcoding nor static linking is supported with a
         4903  +	# broken collect2.
         4904  +	_LT_TAGVAR(hardcode_direct, $1)=unsupported
         4905  +      fi
         4906  +      ;;
         4907  +
         4908  +    aix[[4-9]]*)
         4909  +      if test "$host_cpu" = ia64; then
         4910  +	# On IA64, the linker does run time linking by default, so we don't
         4911  +	# have to do anything special.
         4912  +	aix_use_runtimelinking=no
         4913  +	exp_sym_flag='-Bexport'
         4914  +	no_entry_flag=""
         4915  +      else
         4916  +	# If we're using GNU nm, then we don't want the "-C" option.
         4917  +	# -C means demangle to AIX nm, but means don't demangle with GNU nm
         4918  +	# Also, AIX nm treats weak defined symbols like other global
         4919  +	# defined symbols, whereas GNU nm marks them as "W".
         4920  +	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
         4921  +	  _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
         4922  +	else
         4923  +	  _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'
         4924  +	fi
         4925  +	aix_use_runtimelinking=no
         4926  +
         4927  +	# Test if we are trying to use run time linking or normal
         4928  +	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
         4929  +	# need to do runtime linking.
         4930  +	case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
         4931  +	  for ld_flag in $LDFLAGS; do
         4932  +	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
         4933  +	    aix_use_runtimelinking=yes
         4934  +	    break
         4935  +	  fi
         4936  +	  done
         4937  +	  ;;
         4938  +	esac
         4939  +
         4940  +	exp_sym_flag='-bexport'
         4941  +	no_entry_flag='-bnoentry'
         4942  +      fi
         4943  +
         4944  +      # When large executables or shared objects are built, AIX ld can
         4945  +      # have problems creating the table of contents.  If linking a library
         4946  +      # or program results in "error TOC overflow" add -mminimal-toc to
         4947  +      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
         4948  +      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
         4949  +
         4950  +      _LT_TAGVAR(archive_cmds, $1)=''
         4951  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         4952  +      _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         4953  +      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         4954  +      _LT_TAGVAR(link_all_deplibs, $1)=yes
         4955  +      _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
         4956  +
         4957  +      if test "$GCC" = yes; then
         4958  +	case $host_os in aix4.[[012]]|aix4.[[012]].*)
         4959  +	# We only want to do this on AIX 4.2 and lower, the check
         4960  +	# below for broken collect2 doesn't work under 4.3+
         4961  +	  collect2name=`${CC} -print-prog-name=collect2`
         4962  +	  if test -f "$collect2name" &&
         4963  +	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
         4964  +	  then
         4965  +	  # We have reworked collect2
         4966  +	  :
         4967  +	  else
         4968  +	  # We have old collect2
         4969  +	  _LT_TAGVAR(hardcode_direct, $1)=unsupported
         4970  +	  # It fails to find uninstalled libraries when the uninstalled
         4971  +	  # path is not listed in the libpath.  Setting hardcode_minus_L
         4972  +	  # to unsupported forces relinking
         4973  +	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
         4974  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         4975  +	  _LT_TAGVAR(hardcode_libdir_separator, $1)=
         4976  +	  fi
         4977  +	  ;;
         4978  +	esac
         4979  +	shared_flag='-shared'
         4980  +	if test "$aix_use_runtimelinking" = yes; then
         4981  +	  shared_flag="$shared_flag "'${wl}-G'
         4982  +	fi
         4983  +      else
         4984  +	# not using gcc
         4985  +	if test "$host_cpu" = ia64; then
         4986  +	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
         4987  +	# chokes on -Wl,-G. The following line is correct:
         4988  +	  shared_flag='-G'
         4989  +	else
         4990  +	  if test "$aix_use_runtimelinking" = yes; then
         4991  +	    shared_flag='${wl}-G'
         4992  +	  else
         4993  +	    shared_flag='${wl}-bM:SRE'
         4994  +	  fi
         4995  +	fi
         4996  +      fi
         4997  +
         4998  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
         4999  +      # It seems that -bexpall does not export symbols beginning with
         5000  +      # underscore (_), so it is better to generate a list of symbols to export.
         5001  +      _LT_TAGVAR(always_export_symbols, $1)=yes
         5002  +      if test "$aix_use_runtimelinking" = yes; then
         5003  +	# Warning - without using the other runtime loading flags (-brtl),
         5004  +	# -berok will link without error, but may produce a broken library.
         5005  +	_LT_TAGVAR(allow_undefined_flag, $1)='-berok'
         5006  +        # Determine the default libpath from the value encoded in an
         5007  +        # empty executable.
         5008  +        _LT_SYS_MODULE_PATH_AIX([$1])
         5009  +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
         5010  +        _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 func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
         5011  +      else
         5012  +	if test "$host_cpu" = ia64; then
         5013  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
         5014  +	  _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
         5015  +	  _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"
         5016  +	else
         5017  +	 # Determine the default libpath from the value encoded in an
         5018  +	 # empty executable.
         5019  +	 _LT_SYS_MODULE_PATH_AIX([$1])
         5020  +	 _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
         5021  +	  # Warning - without using the other run time loading flags,
         5022  +	  # -berok will link without error, but may produce a broken library.
         5023  +	  _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
         5024  +	  _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
         5025  +	  if test "$with_gnu_ld" = yes; then
         5026  +	    # We only use this code for GNU lds that support --whole-archive.
         5027  +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
         5028  +	  else
         5029  +	    # Exported symbols can be pulled into shared objects from archives
         5030  +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
         5031  +	  fi
         5032  +	  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
         5033  +	  # This is similar to how AIX traditionally builds its shared libraries.
         5034  +	  _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'
         5035  +	fi
         5036  +      fi
         5037  +      ;;
         5038  +
         5039  +    amigaos*)
         5040  +      case $host_cpu in
         5041  +      powerpc)
         5042  +            # see comment about AmigaOS4 .so support
         5043  +            _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         5044  +            _LT_TAGVAR(archive_expsym_cmds, $1)=''
         5045  +        ;;
         5046  +      m68k)
         5047  +            _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)'
         5048  +            _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         5049  +            _LT_TAGVAR(hardcode_minus_L, $1)=yes
         5050  +        ;;
         5051  +      esac
         5052  +      ;;
         5053  +
         5054  +    bsdi[[45]]*)
         5055  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
         5056  +      ;;
         5057  +
         5058  +    cygwin* | mingw* | pw32* | cegcc*)
         5059  +      # When not using gcc, we currently assume that we are using
         5060  +      # Microsoft Visual C++.
         5061  +      # hardcode_libdir_flag_spec is actually meaningless, as there is
         5062  +      # no search path for DLLs.
         5063  +      case $cc_basename in
         5064  +      cl*)
         5065  +	# Native MSVC
         5066  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
         5067  +	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         5068  +	_LT_TAGVAR(always_export_symbols, $1)=yes
         5069  +	_LT_TAGVAR(file_list_spec, $1)='@'
         5070  +	# Tell ltmain to make .lib files, not .a files.
         5071  +	libext=lib
         5072  +	# Tell ltmain to make .dll files, not .so files.
         5073  +	shrext_cmds=".dll"
         5074  +	# FIXME: Setting linknames here is a bad hack.
         5075  +	_LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
         5076  +	_LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
         5077  +	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
         5078  +	  else
         5079  +	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
         5080  +	  fi~
         5081  +	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
         5082  +	  linknames='
         5083  +	# The linker will not automatically build a static lib if we build a DLL.
         5084  +	# _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
         5085  +	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
         5086  +	_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'
         5087  +	# Don't use ranlib
         5088  +	_LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
         5089  +	_LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
         5090  +	  lt_tool_outputfile="@TOOL_OUTPUT@"~
         5091  +	  case $lt_outputfile in
         5092  +	    *.exe|*.EXE) ;;
         5093  +	    *)
         5094  +	      lt_outputfile="$lt_outputfile.exe"
         5095  +	      lt_tool_outputfile="$lt_tool_outputfile.exe"
         5096  +	      ;;
         5097  +	  esac~
         5098  +	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
         5099  +	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
         5100  +	    $RM "$lt_outputfile.manifest";
         5101  +	  fi'
         5102  +	;;
         5103  +      *)
         5104  +	# Assume MSVC wrapper
         5105  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
         5106  +	_LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         5107  +	# Tell ltmain to make .lib files, not .a files.
         5108  +	libext=lib
         5109  +	# Tell ltmain to make .dll files, not .so files.
         5110  +	shrext_cmds=".dll"
         5111  +	# FIXME: Setting linknames here is a bad hack.
         5112  +	_LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
         5113  +	# The linker will automatically build a .lib file if we build a DLL.
         5114  +	_LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
         5115  +	# FIXME: Should let the user specify the lib program.
         5116  +	_LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs'
         5117  +	_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
         5118  +	;;
         5119  +      esac
         5120  +      ;;
         5121  +
         5122  +    darwin* | rhapsody*)
         5123  +      _LT_DARWIN_LINKER_FEATURES($1)
         5124  +      ;;
         5125  +
         5126  +    dgux*)
         5127  +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5128  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         5129  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5130  +      ;;
         5131  +
         5132  +    freebsd1*)
         5133  +      _LT_TAGVAR(ld_shlibs, $1)=no
         5134  +      ;;
         5135  +
         5136  +    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
         5137  +    # support.  Future versions do this automatically, but an explicit c++rt0.o
         5138  +    # does not break anything, and helps significantly (at the cost of a little
         5139  +    # extra space).
         5140  +    freebsd2.2*)
         5141  +      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
         5142  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         5143  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         5144  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5145  +      ;;
         5146  +
         5147  +    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
         5148  +    freebsd2*)
         5149  +      _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
         5150  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         5151  +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
         5152  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5153  +      ;;
         5154  +
         5155  +    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
         5156  +    freebsd* | dragonfly*)
         5157  +      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
         5158  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         5159  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         5160  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5161  +      ;;
         5162  +
         5163  +    hpux9*)
         5164  +      if test "$GCC" = yes; then
         5165  +	_LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
         5166  +      else
         5167  +	_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'
         5168  +      fi
         5169  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
         5170  +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         5171  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         5172  +
         5173  +      # hardcode_minus_L: Not really in the search PATH,
         5174  +      # but as the default location of the library.
         5175  +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
         5176  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         5177  +      ;;
         5178  +
         5179  +    hpux10*)
         5180  +      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
         5181  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
         5182  +      else
         5183  +	_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
         5184  +      fi
         5185  +      if test "$with_gnu_ld" = no; then
         5186  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
         5187  +	_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
         5188  +	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
         5189  +	_LT_TAGVAR(hardcode_direct, $1)=yes
         5190  +	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         5191  +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         5192  +	# hardcode_minus_L: Not really in the search PATH,
         5193  +	# but as the default location of the library.
         5194  +	_LT_TAGVAR(hardcode_minus_L, $1)=yes
         5195  +      fi
         5196  +      ;;
         5197  +
         5198  +    hpux11*)
         5199  +      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
         5200  +	case $host_cpu in
         5201  +	hppa*64*)
         5202  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
         5203  +	  ;;
         5204  +	ia64*)
         5205  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
         5206  +	  ;;
         5207  +	*)
         5208  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
         5209  +	  ;;
         5210  +	esac
         5211  +      else
         5212  +	case $host_cpu in
         5213  +	hppa*64*)
         5214  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
         5215  +	  ;;
         5216  +	ia64*)
         5217  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
         5218  +	  ;;
         5219  +	*)
         5220  +	m4_if($1, [], [
         5221  +	  # Older versions of the 11.00 compiler do not understand -b yet
         5222  +	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
         5223  +	  _LT_LINKER_OPTION([if $CC understands -b],
         5224  +	    _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b],
         5225  +	    [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'],
         5226  +	    [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])],
         5227  +	  [_LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'])
         5228  +	  ;;
         5229  +	esac
         5230  +      fi
         5231  +      if test "$with_gnu_ld" = no; then
         5232  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
         5233  +	_LT_TAGVAR(hardcode_libdir_separator, $1)=:
         5234  +
         5235  +	case $host_cpu in
         5236  +	hppa*64*|ia64*)
         5237  +	  _LT_TAGVAR(hardcode_direct, $1)=no
         5238  +	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5239  +	  ;;
         5240  +	*)
         5241  +	  _LT_TAGVAR(hardcode_direct, $1)=yes
         5242  +	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         5243  +	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         5244  +
         5245  +	  # hardcode_minus_L: Not really in the search PATH,
         5246  +	  # but as the default location of the library.
         5247  +	  _LT_TAGVAR(hardcode_minus_L, $1)=yes
         5248  +	  ;;
         5249  +	esac
         5250  +      fi
         5251  +      ;;
         5252  +
         5253  +    irix5* | irix6* | nonstopux*)
         5254  +      if test "$GCC" = yes; then
         5255  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
         5256  +	# Try to use the -exported_symbol ld option, if it does not
         5257  +	# work, assume that -exports_file does not work either and
         5258  +	# implicitly export all symbols.
         5259  +	# This should be the same for all languages, so no per-tag cache variable.
         5260  +	AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol],
         5261  +	  [lt_cv_irix_exported_symbol],
         5262  +	  [save_LDFLAGS="$LDFLAGS"
         5263  +	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
         5264  +	   AC_LINK_IFELSE(
         5265  +	     [AC_LANG_SOURCE(
         5266  +	        [AC_LANG_CASE([C], [[int foo (void) { return 0; }]],
         5267  +			      [C++], [[int foo (void) { return 0; }]],
         5268  +			      [Fortran 77], [[
         5269  +      subroutine foo
         5270  +      end]],
         5271  +			      [Fortran], [[
         5272  +      subroutine foo
         5273  +      end]])])],
         5274  +	      [lt_cv_irix_exported_symbol=yes],
         5275  +	      [lt_cv_irix_exported_symbol=no])
         5276  +           LDFLAGS="$save_LDFLAGS"])
         5277  +	if test "$lt_cv_irix_exported_symbol" = yes; then
         5278  +          _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
         5279  +	fi
         5280  +      else
         5281  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
         5282  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
         5283  +      fi
         5284  +      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
         5285  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         5286  +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         5287  +      _LT_TAGVAR(inherit_rpath, $1)=yes
         5288  +      _LT_TAGVAR(link_all_deplibs, $1)=yes
         5289  +      ;;
         5290  +
         5291  +    netbsd*)
         5292  +      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
         5293  +	_LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
         5294  +      else
         5295  +	_LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
         5296  +      fi
         5297  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         5298  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         5299  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5300  +      ;;
         5301  +
         5302  +    newsos6)
         5303  +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5304  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         5305  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         5306  +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         5307  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5308  +      ;;
         5309  +
         5310  +    *nto* | *qnx*)
         5311  +      ;;
         5312  +
         5313  +    openbsd*)
         5314  +      if test -f /usr/libexec/ld.so; then
         5315  +	_LT_TAGVAR(hardcode_direct, $1)=yes
         5316  +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5317  +	_LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         5318  +	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
         5319  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
         5320  +	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
         5321  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         5322  +	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         5323  +	else
         5324  +	  case $host_os in
         5325  +	   openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
         5326  +	     _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
         5327  +	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         5328  +	     ;;
         5329  +	   *)
         5330  +	     _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
         5331  +	     _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         5332  +	     ;;
         5333  +	  esac
         5334  +	fi
         5335  +      else
         5336  +	_LT_TAGVAR(ld_shlibs, $1)=no
         5337  +      fi
         5338  +      ;;
         5339  +
         5340  +    os2*)
         5341  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         5342  +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
         5343  +      _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         5344  +      _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'
         5345  +      _LT_TAGVAR(old_archive_from_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
         5346  +      ;;
         5347  +
         5348  +    osf3*)
         5349  +      if test "$GCC" = yes; then
         5350  +	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
         5351  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
         5352  +      else
         5353  +	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
         5354  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
         5355  +      fi
         5356  +      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
         5357  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         5358  +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         5359  +      ;;
         5360  +
         5361  +    osf4* | osf5*)	# as osf3* with the addition of -msym flag
         5362  +      if test "$GCC" = yes; then
         5363  +	_LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
         5364  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
         5365  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         5366  +      else
         5367  +	_LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
         5368  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
         5369  +	_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~
         5370  +	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
         5371  +
         5372  +	# Both c and cxx compiler support -rpath directly
         5373  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
         5374  +      fi
         5375  +      _LT_TAGVAR(archive_cmds_need_lc, $1)='no'
         5376  +      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         5377  +      ;;
         5378  +
         5379  +    solaris*)
         5380  +      _LT_TAGVAR(no_undefined_flag, $1)=' -z defs'
         5381  +      if test "$GCC" = yes; then
         5382  +	wlarc='${wl}'
         5383  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
         5384  +	_LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
         5385  +	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
         5386  +      else
         5387  +	case `$CC -V 2>&1` in
         5388  +	*"Compilers 5.0"*)
         5389  +	  wlarc=''
         5390  +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5391  +	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
         5392  +	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
         5393  +	  ;;
         5394  +	*)
         5395  +	  wlarc='${wl}'
         5396  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
         5397  +	  _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
         5398  +	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
         5399  +	  ;;
         5400  +	esac
         5401  +      fi
         5402  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         5403  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5404  +      case $host_os in
         5405  +      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
         5406  +      *)
         5407  +	# The compiler driver will combine and reorder linker options,
         5408  +	# but understands `-z linker_flag'.  GCC discards it without `$wl',
         5409  +	# but is careful enough not to reorder.
         5410  +	# Supported since Solaris 2.6 (maybe 2.5.1?)
         5411  +	if test "$GCC" = yes; then
         5412  +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
         5413  +	else
         5414  +	  _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
         5415  +	fi
         5416  +	;;
         5417  +      esac
         5418  +      _LT_TAGVAR(link_all_deplibs, $1)=yes
         5419  +      ;;
         5420  +
         5421  +    sunos4*)
         5422  +      if test "x$host_vendor" = xsequent; then
         5423  +	# Use $CC to link under sequent, because it throws in some extra .o
         5424  +	# files that make .init and .fini sections work.
         5425  +	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
         5426  +      else
         5427  +	_LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
         5428  +      fi
         5429  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         5430  +      _LT_TAGVAR(hardcode_direct, $1)=yes
         5431  +      _LT_TAGVAR(hardcode_minus_L, $1)=yes
         5432  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5433  +      ;;
         5434  +
         5435  +    sysv4)
         5436  +      case $host_vendor in
         5437  +	sni)
         5438  +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5439  +	  _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true???
         5440  +	;;
         5441  +	siemens)
         5442  +	  ## LD is ld it makes a PLAMLIB
         5443  +	  ## CC just makes a GrossModule.
         5444  +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
         5445  +	  _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
         5446  +	  _LT_TAGVAR(hardcode_direct, $1)=no
         5447  +        ;;
         5448  +	motorola)
         5449  +	  _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5450  +	  _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
         5451  +	;;
         5452  +      esac
         5453  +      runpath_var='LD_RUN_PATH'
         5454  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5455  +      ;;
         5456  +
         5457  +    sysv4.3*)
         5458  +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5459  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5460  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
         5461  +      ;;
         5462  +
         5463  +    sysv4*MP*)
         5464  +      if test -d /usr/nec; then
         5465  +	_LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5466  +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5467  +	runpath_var=LD_RUN_PATH
         5468  +	hardcode_runpath_var=yes
         5469  +	_LT_TAGVAR(ld_shlibs, $1)=yes
         5470  +      fi
         5471  +      ;;
         5472  +
         5473  +    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
         5474  +      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
         5475  +      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
         5476  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5477  +      runpath_var='LD_RUN_PATH'
         5478  +
         5479  +      if test "$GCC" = yes; then
         5480  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5481  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5482  +      else
         5483  +	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5484  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5485  +      fi
         5486  +      ;;
         5487  +
         5488  +    sysv5* | sco3.2v5* | sco5v6*)
         5489  +      # Note: We can NOT use -z defs as we might desire, because we do not
         5490  +      # link with -lc, and that would cause any symbols used from libc to
         5491  +      # always be unresolved, which means just about no library would
         5492  +      # ever link correctly.  If we're not using GNU ld we use -z text
         5493  +      # though, which does catch some bad symbols but isn't as heavy-handed
         5494  +      # as -z defs.
         5495  +      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
         5496  +      _LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
         5497  +      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
         5498  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5499  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
         5500  +      _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         5501  +      _LT_TAGVAR(link_all_deplibs, $1)=yes
         5502  +      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
         5503  +      runpath_var='LD_RUN_PATH'
         5504  +
         5505  +      if test "$GCC" = yes; then
         5506  +	_LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5507  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5508  +      else
         5509  +	_LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5510  +	_LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         5511  +      fi
         5512  +      ;;
         5513  +
         5514  +    uts4*)
         5515  +      _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
         5516  +      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         5517  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         5518  +      ;;
         5519  +
         5520  +    *)
         5521  +      _LT_TAGVAR(ld_shlibs, $1)=no
         5522  +      ;;
         5523  +    esac
         5524  +
         5525  +    if test x$host_vendor = xsni; then
         5526  +      case $host in
         5527  +      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
         5528  +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Blargedynsym'
         5529  +	;;
         5530  +      esac
         5531  +    fi
         5532  +  fi
         5533  +])
         5534  +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
         5535  +test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
         5536  +
         5537  +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld
         5538  +
         5539  +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl
         5540  +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl
         5541  +_LT_DECL([], [extract_expsyms_cmds], [2],
         5542  +    [The commands to extract the exported symbol list from a shared archive])
         5543  +
         5544  +#
         5545  +# Do we need to explicitly link libc?
         5546  +#
         5547  +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in
         5548  +x|xyes)
         5549  +  # Assume -lc should be added
         5550  +  _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
         5551  +
         5552  +  if test "$enable_shared" = yes && test "$GCC" = yes; then
         5553  +    case $_LT_TAGVAR(archive_cmds, $1) in
         5554  +    *'~'*)
         5555  +      # FIXME: we may have to deal with multi-command sequences.
         5556  +      ;;
         5557  +    '$CC '*)
         5558  +      # Test whether the compiler implicitly links with -lc since on some
         5559  +      # systems, -lgcc has to come before -lc. If gcc already passes -lc
         5560  +      # to ld, don't add -lc before -lgcc.
         5561  +      AC_CACHE_CHECK([whether -lc should be explicitly linked in],
         5562  +	[lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1),
         5563  +	[$RM conftest*
         5564  +	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
         5565  +
         5566  +	if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
         5567  +	  soname=conftest
         5568  +	  lib=conftest
         5569  +	  libobjs=conftest.$ac_objext
         5570  +	  deplibs=
         5571  +	  wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1)
         5572  +	  pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1)
         5573  +	  compiler_flags=-v
         5574  +	  linker_flags=-v
         5575  +	  verstring=
         5576  +	  output_objdir=.
         5577  +	  libname=conftest
         5578  +	  lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1)
         5579  +	  _LT_TAGVAR(allow_undefined_flag, $1)=
         5580  +	  if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1)
         5581  +	  then
         5582  +	    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no
         5583  +	  else
         5584  +	    lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes
         5585  +	  fi
         5586  +	  _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
         5587  +	else
         5588  +	  cat conftest.err 1>&5
         5589  +	fi
         5590  +	$RM conftest*
         5591  +	])
         5592  +      _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)
         5593  +      ;;
         5594  +    esac
         5595  +  fi
         5596  +  ;;
         5597  +esac
         5598  +
         5599  +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0],
         5600  +    [Whether or not to add -lc for building shared libraries])
         5601  +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes],
         5602  +    [enable_shared_with_static_runtimes], [0],
         5603  +    [Whether or not to disallow shared libs when runtime libs are static])
         5604  +_LT_TAGDECL([], [export_dynamic_flag_spec], [1],
         5605  +    [Compiler flag to allow reflexive dlopens])
         5606  +_LT_TAGDECL([], [whole_archive_flag_spec], [1],
         5607  +    [Compiler flag to generate shared objects directly from archives])
         5608  +_LT_TAGDECL([], [compiler_needs_object], [1],
         5609  +    [Whether the compiler copes with passing no objects directly])
         5610  +_LT_TAGDECL([], [old_archive_from_new_cmds], [2],
         5611  +    [Create an old-style archive from a shared archive])
         5612  +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2],
         5613  +    [Create a temporary old-style archive to link instead of a shared archive])
         5614  +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive])
         5615  +_LT_TAGDECL([], [archive_expsym_cmds], [2])
         5616  +_LT_TAGDECL([], [module_cmds], [2],
         5617  +    [Commands used to build a loadable module if different from building
         5618  +    a shared archive.])
         5619  +_LT_TAGDECL([], [module_expsym_cmds], [2])
         5620  +_LT_TAGDECL([], [with_gnu_ld], [1],
         5621  +    [Whether we are building with GNU ld or not])
         5622  +_LT_TAGDECL([], [allow_undefined_flag], [1],
         5623  +    [Flag that allows shared libraries with undefined symbols to be built])
         5624  +_LT_TAGDECL([], [no_undefined_flag], [1],
         5625  +    [Flag that enforces no undefined symbols])
         5626  +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1],
         5627  +    [Flag to hardcode $libdir into a binary during linking.
         5628  +    This must work even if $libdir does not exist])
         5629  +_LT_TAGDECL([], [hardcode_libdir_flag_spec_ld], [1],
         5630  +    [[If ld is used when linking, flag to hardcode $libdir into a binary
         5631  +    during linking.  This must work even if $libdir does not exist]])
         5632  +_LT_TAGDECL([], [hardcode_libdir_separator], [1],
         5633  +    [Whether we need a single "-rpath" flag with a separated argument])
         5634  +_LT_TAGDECL([], [hardcode_direct], [0],
         5635  +    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
         5636  +    DIR into the resulting binary])
         5637  +_LT_TAGDECL([], [hardcode_direct_absolute], [0],
         5638  +    [Set to "yes" if using DIR/libNAME${shared_ext} during linking hardcodes
         5639  +    DIR into the resulting binary and the resulting library dependency is
         5640  +    "absolute", i.e impossible to change by setting ${shlibpath_var} if the
         5641  +    library is relocated])
         5642  +_LT_TAGDECL([], [hardcode_minus_L], [0],
         5643  +    [Set to "yes" if using the -LDIR flag during linking hardcodes DIR
         5644  +    into the resulting binary])
         5645  +_LT_TAGDECL([], [hardcode_shlibpath_var], [0],
         5646  +    [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
         5647  +    into the resulting binary])
         5648  +_LT_TAGDECL([], [hardcode_automatic], [0],
         5649  +    [Set to "yes" if building a shared library automatically hardcodes DIR
         5650  +    into the library and all subsequent libraries and executables linked
         5651  +    against it])
         5652  +_LT_TAGDECL([], [inherit_rpath], [0],
         5653  +    [Set to yes if linker adds runtime paths of dependent libraries
         5654  +    to runtime path list])
         5655  +_LT_TAGDECL([], [link_all_deplibs], [0],
         5656  +    [Whether libtool must link a program against all its dependency libraries])
         5657  +_LT_TAGDECL([], [always_export_symbols], [0],
         5658  +    [Set to "yes" if exported symbols are required])
         5659  +_LT_TAGDECL([], [export_symbols_cmds], [2],
         5660  +    [The commands to list exported symbols])
         5661  +_LT_TAGDECL([], [exclude_expsyms], [1],
         5662  +    [Symbols that should not be listed in the preloaded symbols])
         5663  +_LT_TAGDECL([], [include_expsyms], [1],
         5664  +    [Symbols that must always be exported])
         5665  +_LT_TAGDECL([], [prelink_cmds], [2],
         5666  +    [Commands necessary for linking programs (against libraries) with templates])
         5667  +_LT_TAGDECL([], [postlink_cmds], [2],
         5668  +    [Commands necessary for finishing linking programs])
         5669  +_LT_TAGDECL([], [file_list_spec], [1],
         5670  +    [Specify filename containing input files])
         5671  +dnl FIXME: Not yet implemented
         5672  +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1],
         5673  +dnl    [Compiler flag to generate thread safe objects])
         5674  +])# _LT_LINKER_SHLIBS
         5675  +
         5676  +
         5677  +# _LT_LANG_C_CONFIG([TAG])
         5678  +# ------------------------
         5679  +# Ensure that the configuration variables for a C compiler are suitably
         5680  +# defined.  These variables are subsequently used by _LT_CONFIG to write
         5681  +# the compiler configuration to `libtool'.
         5682  +m4_defun([_LT_LANG_C_CONFIG],
         5683  +[m4_require([_LT_DECL_EGREP])dnl
         5684  +lt_save_CC="$CC"
         5685  +AC_LANG_PUSH(C)
         5686  +
         5687  +# Source file extension for C test sources.
         5688  +ac_ext=c
         5689  +
         5690  +# Object file extension for compiled C test sources.
         5691  +objext=o
         5692  +_LT_TAGVAR(objext, $1)=$objext
         5693  +
         5694  +# Code to be used in simple compile tests
         5695  +lt_simple_compile_test_code="int some_variable = 0;"
         5696  +
         5697  +# Code to be used in simple link tests
         5698  +lt_simple_link_test_code='int main(){return(0);}'
         5699  +
         5700  +_LT_TAG_COMPILER
         5701  +# Save the default compiler, since it gets overwritten when the other
         5702  +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
         5703  +compiler_DEFAULT=$CC
         5704  +
         5705  +# save warnings/boilerplate of simple test code
         5706  +_LT_COMPILER_BOILERPLATE
         5707  +_LT_LINKER_BOILERPLATE
         5708  +
         5709  +if test -n "$compiler"; then
         5710  +  _LT_COMPILER_NO_RTTI($1)
         5711  +  _LT_COMPILER_PIC($1)
         5712  +  _LT_COMPILER_C_O($1)
         5713  +  _LT_COMPILER_FILE_LOCKS($1)
         5714  +  _LT_LINKER_SHLIBS($1)
         5715  +  _LT_SYS_DYNAMIC_LINKER($1)
         5716  +  _LT_LINKER_HARDCODE_LIBPATH($1)
         5717  +  LT_SYS_DLOPEN_SELF
         5718  +  _LT_CMD_STRIPLIB
         5719  +
         5720  +  # Report which library types will actually be built
         5721  +  AC_MSG_CHECKING([if libtool supports shared libraries])
         5722  +  AC_MSG_RESULT([$can_build_shared])
         5723  +
         5724  +  AC_MSG_CHECKING([whether to build shared libraries])
         5725  +  test "$can_build_shared" = "no" && enable_shared=no
         5726  +
         5727  +  # On AIX, shared libraries and static libraries use the same namespace, and
         5728  +  # are all built from PIC.
         5729  +  case $host_os in
         5730  +  aix3*)
         5731  +    test "$enable_shared" = yes && enable_static=no
         5732  +    if test -n "$RANLIB"; then
         5733  +      archive_cmds="$archive_cmds~\$RANLIB \$lib"
         5734  +      postinstall_cmds='$RANLIB $lib'
         5735  +    fi
         5736  +    ;;
         5737  +
         5738  +  aix[[4-9]]*)
         5739  +    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
         5740  +      test "$enable_shared" = yes && enable_static=no
         5741  +    fi
         5742  +    ;;
         5743  +  esac
         5744  +  AC_MSG_RESULT([$enable_shared])
         5745  +
         5746  +  AC_MSG_CHECKING([whether to build static libraries])
         5747  +  # Make sure either enable_shared or enable_static is yes.
         5748  +  test "$enable_shared" = yes || enable_static=yes
         5749  +  AC_MSG_RESULT([$enable_static])
         5750  +
         5751  +  _LT_CONFIG($1)
         5752  +fi
         5753  +AC_LANG_POP
         5754  +CC="$lt_save_CC"
         5755  +])# _LT_LANG_C_CONFIG
         5756  +
         5757  +
         5758  +# _LT_LANG_CXX_CONFIG([TAG])
         5759  +# --------------------------
         5760  +# Ensure that the configuration variables for a C++ compiler are suitably
         5761  +# defined.  These variables are subsequently used by _LT_CONFIG to write
         5762  +# the compiler configuration to `libtool'.
         5763  +m4_defun([_LT_LANG_CXX_CONFIG],
         5764  +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         5765  +m4_require([_LT_DECL_EGREP])dnl
         5766  +m4_require([_LT_PATH_MANIFEST_TOOL])dnl
         5767  +if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
         5768  +    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
         5769  +    (test "X$CXX" != "Xg++"))) ; then
         5770  +  AC_PROG_CXXCPP
         5771  +else
         5772  +  _lt_caught_CXX_error=yes
         5773  +fi
         5774  +
         5775  +AC_LANG_PUSH(C++)
         5776  +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
         5777  +_LT_TAGVAR(allow_undefined_flag, $1)=
         5778  +_LT_TAGVAR(always_export_symbols, $1)=no
         5779  +_LT_TAGVAR(archive_expsym_cmds, $1)=
         5780  +_LT_TAGVAR(compiler_needs_object, $1)=no
         5781  +_LT_TAGVAR(export_dynamic_flag_spec, $1)=
         5782  +_LT_TAGVAR(hardcode_direct, $1)=no
         5783  +_LT_TAGVAR(hardcode_direct_absolute, $1)=no
         5784  +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
         5785  +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
         5786  +_LT_TAGVAR(hardcode_libdir_separator, $1)=
         5787  +_LT_TAGVAR(hardcode_minus_L, $1)=no
         5788  +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
         5789  +_LT_TAGVAR(hardcode_automatic, $1)=no
         5790  +_LT_TAGVAR(inherit_rpath, $1)=no
         5791  +_LT_TAGVAR(module_cmds, $1)=
         5792  +_LT_TAGVAR(module_expsym_cmds, $1)=
         5793  +_LT_TAGVAR(link_all_deplibs, $1)=unknown
         5794  +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
         5795  +_LT_TAGVAR(reload_flag, $1)=$reload_flag
         5796  +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
         5797  +_LT_TAGVAR(no_undefined_flag, $1)=
         5798  +_LT_TAGVAR(whole_archive_flag_spec, $1)=
         5799  +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
         5800  +
         5801  +# Source file extension for C++ test sources.
         5802  +ac_ext=cpp
         5803  +
         5804  +# Object file extension for compiled C++ test sources.
         5805  +objext=o
         5806  +_LT_TAGVAR(objext, $1)=$objext
         5807  +
         5808  +# No sense in running all these tests if we already determined that
         5809  +# the CXX compiler isn't working.  Some variables (like enable_shared)
         5810  +# are currently assumed to apply to all compilers on this platform,
         5811  +# and will be corrupted by setting them based on a non-working compiler.
         5812  +if test "$_lt_caught_CXX_error" != yes; then
         5813  +  # Code to be used in simple compile tests
         5814  +  lt_simple_compile_test_code="int some_variable = 0;"
         5815  +
         5816  +  # Code to be used in simple link tests
         5817  +  lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }'
         5818  +
         5819  +  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
         5820  +  _LT_TAG_COMPILER
         5821  +
         5822  +  # save warnings/boilerplate of simple test code
         5823  +  _LT_COMPILER_BOILERPLATE
         5824  +  _LT_LINKER_BOILERPLATE
         5825  +
         5826  +  # Allow CC to be a program name with arguments.
         5827  +  lt_save_CC=$CC
         5828  +  lt_save_CFLAGS=$CFLAGS
         5829  +  lt_save_LD=$LD
         5830  +  lt_save_GCC=$GCC
         5831  +  GCC=$GXX
         5832  +  lt_save_with_gnu_ld=$with_gnu_ld
         5833  +  lt_save_path_LD=$lt_cv_path_LD
         5834  +  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
         5835  +    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
         5836  +  else
         5837  +    $as_unset lt_cv_prog_gnu_ld
         5838  +  fi
         5839  +  if test -n "${lt_cv_path_LDCXX+set}"; then
         5840  +    lt_cv_path_LD=$lt_cv_path_LDCXX
         5841  +  else
         5842  +    $as_unset lt_cv_path_LD
         5843  +  fi
         5844  +  test -z "${LDCXX+set}" || LD=$LDCXX
         5845  +  CC=${CXX-"c++"}
         5846  +  CFLAGS=$CXXFLAGS
         5847  +  compiler=$CC
         5848  +  _LT_TAGVAR(compiler, $1)=$CC
         5849  +  _LT_CC_BASENAME([$compiler])
         5850  +
         5851  +  if test -n "$compiler"; then
         5852  +    # We don't want -fno-exception when compiling C++ code, so set the
         5853  +    # no_builtin_flag separately
         5854  +    if test "$GXX" = yes; then
         5855  +      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
         5856  +    else
         5857  +      _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
         5858  +    fi
         5859  +
         5860  +    if test "$GXX" = yes; then
         5861  +      # Set up default GNU C++ configuration
         5862  +
         5863  +      LT_PATH_LD
         5864  +
         5865  +      # Check if GNU C++ uses GNU ld as the underlying linker, since the
         5866  +      # archiving commands below assume that GNU ld is being used.
         5867  +      if test "$with_gnu_ld" = yes; then
         5868  +        _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
         5869  +        _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
         5870  +
         5871  +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         5872  +        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
         5873  +
         5874  +        # If archive_cmds runs LD, not CC, wlarc should be empty
         5875  +        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
         5876  +        #     investigate it a little bit more. (MM)
         5877  +        wlarc='${wl}'
         5878  +
         5879  +        # ancient GNU ld didn't support --whole-archive et. al.
         5880  +        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
         5881  +	  $GREP 'no-whole-archive' > /dev/null; then
         5882  +          _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
         5883  +        else
         5884  +          _LT_TAGVAR(whole_archive_flag_spec, $1)=
         5885  +        fi
         5886  +      else
         5887  +        with_gnu_ld=no
         5888  +        wlarc=
         5889  +
         5890  +        # A generic and very simple default shared library creation
         5891  +        # command for GNU C++ for the case where it uses the native
         5892  +        # linker, instead of GNU ld.  If possible, this setting should
         5893  +        # overridden to take advantage of the native linker features on
         5894  +        # the platform it is being used on.
         5895  +        _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
         5896  +      fi
         5897  +
         5898  +      # Commands to make compiler produce verbose output that lists
         5899  +      # what "hidden" libraries, object files and flags are used when
         5900  +      # linking a shared library.
         5901  +      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
         5902  +
         5903  +    else
         5904  +      GXX=no
         5905  +      with_gnu_ld=no
         5906  +      wlarc=
         5907  +    fi
         5908  +
         5909  +    # PORTME: fill in a description of your system's C++ link characteristics
         5910  +    AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
         5911  +    _LT_TAGVAR(ld_shlibs, $1)=yes
         5912  +    case $host_os in
         5913  +      aix3*)
         5914  +        # FIXME: insert proper C++ library support
         5915  +        _LT_TAGVAR(ld_shlibs, $1)=no
         5916  +        ;;
         5917  +      aix[[4-9]]*)
         5918  +        if test "$host_cpu" = ia64; then
         5919  +          # On IA64, the linker does run time linking by default, so we don't
         5920  +          # have to do anything special.
         5921  +          aix_use_runtimelinking=no
         5922  +          exp_sym_flag='-Bexport'
         5923  +          no_entry_flag=""
         5924  +        else
         5925  +          aix_use_runtimelinking=no
         5926  +
         5927  +          # Test if we are trying to use run time linking or normal
         5928  +          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
         5929  +          # need to do runtime linking.
         5930  +          case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*)
         5931  +	    for ld_flag in $LDFLAGS; do
         5932  +	      case $ld_flag in
         5933  +	      *-brtl*)
         5934  +	        aix_use_runtimelinking=yes
         5935  +	        break
         5936  +	        ;;
         5937  +	      esac
         5938  +	    done
         5939  +	    ;;
         5940  +          esac
         5941  +
         5942  +          exp_sym_flag='-bexport'
         5943  +          no_entry_flag='-bnoentry'
         5944  +        fi
         5945  +
         5946  +        # When large executables or shared objects are built, AIX ld can
         5947  +        # have problems creating the table of contents.  If linking a library
         5948  +        # or program results in "error TOC overflow" add -mminimal-toc to
         5949  +        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
         5950  +        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
         5951  +
         5952  +        _LT_TAGVAR(archive_cmds, $1)=''
         5953  +        _LT_TAGVAR(hardcode_direct, $1)=yes
         5954  +        _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         5955  +        _LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         5956  +        _LT_TAGVAR(link_all_deplibs, $1)=yes
         5957  +        _LT_TAGVAR(file_list_spec, $1)='${wl}-f,'
         5958  +
         5959  +        if test "$GXX" = yes; then
         5960  +          case $host_os in aix4.[[012]]|aix4.[[012]].*)
         5961  +          # We only want to do this on AIX 4.2 and lower, the check
         5962  +          # below for broken collect2 doesn't work under 4.3+
         5963  +	  collect2name=`${CC} -print-prog-name=collect2`
         5964  +	  if test -f "$collect2name" &&
         5965  +	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
         5966  +	  then
         5967  +	    # We have reworked collect2
         5968  +	    :
         5969  +	  else
         5970  +	    # We have old collect2
         5971  +	    _LT_TAGVAR(hardcode_direct, $1)=unsupported
         5972  +	    # It fails to find uninstalled libraries when the uninstalled
         5973  +	    # path is not listed in the libpath.  Setting hardcode_minus_L
         5974  +	    # to unsupported forces relinking
         5975  +	    _LT_TAGVAR(hardcode_minus_L, $1)=yes
         5976  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         5977  +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=
         5978  +	  fi
         5979  +          esac
         5980  +          shared_flag='-shared'
         5981  +	  if test "$aix_use_runtimelinking" = yes; then
         5982  +	    shared_flag="$shared_flag "'${wl}-G'
         5983  +	  fi
         5984  +        else
         5985  +          # not using gcc
         5986  +          if test "$host_cpu" = ia64; then
         5987  +	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
         5988  +	  # chokes on -Wl,-G. The following line is correct:
         5989  +	  shared_flag='-G'
         5990  +          else
         5991  +	    if test "$aix_use_runtimelinking" = yes; then
         5992  +	      shared_flag='${wl}-G'
         5993  +	    else
         5994  +	      shared_flag='${wl}-bM:SRE'
         5995  +	    fi
         5996  +          fi
         5997  +        fi
         5998  +
         5999  +        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-bexpall'
         6000  +        # It seems that -bexpall does not export symbols beginning with
         6001  +        # underscore (_), so it is better to generate a list of symbols to
         6002  +	# export.
         6003  +        _LT_TAGVAR(always_export_symbols, $1)=yes
         6004  +        if test "$aix_use_runtimelinking" = yes; then
         6005  +          # Warning - without using the other runtime loading flags (-brtl),
         6006  +          # -berok will link without error, but may produce a broken library.
         6007  +          _LT_TAGVAR(allow_undefined_flag, $1)='-berok'
         6008  +          # Determine the default libpath from the value encoded in an empty
         6009  +          # executable.
         6010  +          _LT_SYS_MODULE_PATH_AIX([$1])
         6011  +          _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
         6012  +
         6013  +          _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 func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
         6014  +        else
         6015  +          if test "$host_cpu" = ia64; then
         6016  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
         6017  +	    _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
         6018  +	    _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"
         6019  +          else
         6020  +	    # Determine the default libpath from the value encoded in an
         6021  +	    # empty executable.
         6022  +	    _LT_SYS_MODULE_PATH_AIX([$1])
         6023  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
         6024  +	    # Warning - without using the other run time loading flags,
         6025  +	    # -berok will link without error, but may produce a broken library.
         6026  +	    _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
         6027  +	    _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
         6028  +	    if test "$with_gnu_ld" = yes; then
         6029  +	      # We only use this code for GNU lds that support --whole-archive.
         6030  +	      _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
         6031  +	    else
         6032  +	      # Exported symbols can be pulled into shared objects from archives
         6033  +	      _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience'
         6034  +	    fi
         6035  +	    _LT_TAGVAR(archive_cmds_need_lc, $1)=yes
         6036  +	    # This is similar to how AIX traditionally builds its shared
         6037  +	    # libraries.
         6038  +	    _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'
         6039  +          fi
         6040  +        fi
         6041  +        ;;
         6042  +
         6043  +      beos*)
         6044  +	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
         6045  +	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         6046  +	  # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
         6047  +	  # support --undefined.  This deserves some investigation.  FIXME
         6048  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         6049  +	else
         6050  +	  _LT_TAGVAR(ld_shlibs, $1)=no
         6051  +	fi
         6052  +	;;
         6053  +
         6054  +      chorus*)
         6055  +        case $cc_basename in
         6056  +          *)
         6057  +	  # FIXME: insert proper C++ library support
         6058  +	  _LT_TAGVAR(ld_shlibs, $1)=no
         6059  +	  ;;
         6060  +        esac
         6061  +        ;;
         6062  +
         6063  +      cygwin* | mingw* | pw32* | cegcc*)
         6064  +	case $GXX,$cc_basename in
         6065  +	,cl* | no,cl*)
         6066  +	  # Native MSVC
         6067  +	  # hardcode_libdir_flag_spec is actually meaningless, as there is
         6068  +	  # no search path for DLLs.
         6069  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
         6070  +	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         6071  +	  _LT_TAGVAR(always_export_symbols, $1)=yes
         6072  +	  _LT_TAGVAR(file_list_spec, $1)='@'
         6073  +	  # Tell ltmain to make .lib files, not .a files.
         6074  +	  libext=lib
         6075  +	  # Tell ltmain to make .dll files, not .so files.
         6076  +	  shrext_cmds=".dll"
         6077  +	  # FIXME: Setting linknames here is a bad hack.
         6078  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
         6079  +	  _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
         6080  +	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
         6081  +	    else
         6082  +	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
         6083  +	    fi~
         6084  +	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
         6085  +	    linknames='
         6086  +	  # The linker will not automatically build a static lib if we build a DLL.
         6087  +	  # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true'
         6088  +	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
         6089  +	  # Don't use ranlib
         6090  +	  _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib'
         6091  +	  _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~
         6092  +	    lt_tool_outputfile="@TOOL_OUTPUT@"~
         6093  +	    case $lt_outputfile in
         6094  +	      *.exe|*.EXE) ;;
         6095  +	      *)
         6096  +		lt_outputfile="$lt_outputfile.exe"
         6097  +		lt_tool_outputfile="$lt_tool_outputfile.exe"
         6098  +		;;
         6099  +	    esac~
         6100  +	    func_to_tool_file "$lt_outputfile"~
         6101  +	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
         6102  +	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
         6103  +	      $RM "$lt_outputfile.manifest";
         6104  +	    fi'
         6105  +	  ;;
         6106  +	*)
         6107  +	  # g++
         6108  +	  # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
         6109  +	  # as there is no search path for DLLs.
         6110  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
         6111  +	  _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-all-symbols'
         6112  +	  _LT_TAGVAR(allow_undefined_flag, $1)=unsupported
         6113  +	  _LT_TAGVAR(always_export_symbols, $1)=no
         6114  +	  _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
         6115  +
         6116  +	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
         6117  +	    _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'
         6118  +	    # If the export-symbols file already is a .def file (1st line
         6119  +	    # is EXPORTS), use it as is; otherwise, prepend...
         6120  +	    _LT_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
         6121  +	      cp $export_symbols $output_objdir/$soname.def;
         6122  +	    else
         6123  +	      echo EXPORTS > $output_objdir/$soname.def;
         6124  +	      cat $export_symbols >> $output_objdir/$soname.def;
         6125  +	    fi~
         6126  +	    $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'
         6127  +	  else
         6128  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6129  +	  fi
         6130  +	  ;;
         6131  +	esac
         6132  +	;;
         6133  +      darwin* | rhapsody*)
         6134  +        _LT_DARWIN_LINKER_FEATURES($1)
         6135  +	;;
         6136  +
         6137  +      dgux*)
         6138  +        case $cc_basename in
         6139  +          ec++*)
         6140  +	    # FIXME: insert proper C++ library support
         6141  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6142  +	    ;;
         6143  +          ghcx*)
         6144  +	    # Green Hills C++ Compiler
         6145  +	    # FIXME: insert proper C++ library support
         6146  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6147  +	    ;;
         6148  +          *)
         6149  +	    # FIXME: insert proper C++ library support
         6150  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6151  +	    ;;
         6152  +        esac
         6153  +        ;;
         6154  +
         6155  +      freebsd[[12]]*)
         6156  +        # C++ shared libraries reported to be fairly broken before
         6157  +	# switch to ELF
         6158  +        _LT_TAGVAR(ld_shlibs, $1)=no
         6159  +        ;;
         6160  +
         6161  +      freebsd-elf*)
         6162  +        _LT_TAGVAR(archive_cmds_need_lc, $1)=no
         6163  +        ;;
         6164  +
         6165  +      freebsd* | dragonfly*)
         6166  +        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
         6167  +        # conventions
         6168  +        _LT_TAGVAR(ld_shlibs, $1)=yes
         6169  +        ;;
         6170  +
         6171  +      gnu*)
         6172  +        ;;
         6173  +
         6174  +      haiku*)
         6175  +        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         6176  +        _LT_TAGVAR(link_all_deplibs, $1)=yes
         6177  +        ;;
         6178  +
         6179  +      hpux9*)
         6180  +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
         6181  +        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         6182  +        _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         6183  +        _LT_TAGVAR(hardcode_direct, $1)=yes
         6184  +        _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
         6185  +				             # but as the default
         6186  +				             # location of the library.
         6187  +
         6188  +        case $cc_basename in
         6189  +          CC*)
         6190  +            # FIXME: insert proper C++ library support
         6191  +            _LT_TAGVAR(ld_shlibs, $1)=no
         6192  +            ;;
         6193  +          aCC*)
         6194  +            _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'
         6195  +            # Commands to make compiler produce verbose output that lists
         6196  +            # what "hidden" libraries, object files and flags are used when
         6197  +            # linking a shared library.
         6198  +            #
         6199  +            # There doesn't appear to be a way to prevent this compiler from
         6200  +            # explicitly linking system object files so we need to strip them
         6201  +            # from the output so that they don't get included in the library
         6202  +            # dependencies.
         6203  +            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; func_echo_all "$list"'
         6204  +            ;;
         6205  +          *)
         6206  +            if test "$GXX" = yes; then
         6207  +              _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${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'
         6208  +            else
         6209  +              # FIXME: insert proper C++ library support
         6210  +              _LT_TAGVAR(ld_shlibs, $1)=no
         6211  +            fi
         6212  +            ;;
         6213  +        esac
         6214  +        ;;
         6215  +
         6216  +      hpux10*|hpux11*)
         6217  +        if test $with_gnu_ld = no; then
         6218  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
         6219  +	  _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         6220  +
         6221  +          case $host_cpu in
         6222  +            hppa*64*|ia64*)
         6223  +              ;;
         6224  +            *)
         6225  +	      _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         6226  +              ;;
         6227  +          esac
         6228  +        fi
         6229  +        case $host_cpu in
         6230  +          hppa*64*|ia64*)
         6231  +            _LT_TAGVAR(hardcode_direct, $1)=no
         6232  +            _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         6233  +            ;;
         6234  +          *)
         6235  +            _LT_TAGVAR(hardcode_direct, $1)=yes
         6236  +            _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         6237  +            _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
         6238  +					         # but as the default
         6239  +					         # location of the library.
         6240  +            ;;
         6241  +        esac
         6242  +
         6243  +        case $cc_basename in
         6244  +          CC*)
         6245  +	    # FIXME: insert proper C++ library support
         6246  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6247  +	    ;;
         6248  +          aCC*)
         6249  +	    case $host_cpu in
         6250  +	      hppa*64*)
         6251  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
         6252  +	        ;;
         6253  +	      ia64*)
         6254  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
         6255  +	        ;;
         6256  +	      *)
         6257  +	        _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'
         6258  +	        ;;
         6259  +	    esac
         6260  +	    # Commands to make compiler produce verbose output that lists
         6261  +	    # what "hidden" libraries, object files and flags are used when
         6262  +	    # linking a shared library.
         6263  +	    #
         6264  +	    # There doesn't appear to be a way to prevent this compiler from
         6265  +	    # explicitly linking system object files so we need to strip them
         6266  +	    # from the output so that they don't get included in the library
         6267  +	    # dependencies.
         6268  +	    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; func_echo_all "$list"'
         6269  +	    ;;
         6270  +          *)
         6271  +	    if test "$GXX" = yes; then
         6272  +	      if test $with_gnu_ld = no; then
         6273  +	        case $host_cpu in
         6274  +	          hppa*64*)
         6275  +	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
         6276  +	            ;;
         6277  +	          ia64*)
         6278  +	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
         6279  +	            ;;
         6280  +	          *)
         6281  +	            _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
         6282  +	            ;;
         6283  +	        esac
         6284  +	      fi
         6285  +	    else
         6286  +	      # FIXME: insert proper C++ library support
         6287  +	      _LT_TAGVAR(ld_shlibs, $1)=no
         6288  +	    fi
         6289  +	    ;;
         6290  +        esac
         6291  +        ;;
         6292  +
         6293  +      interix[[3-9]]*)
         6294  +	_LT_TAGVAR(hardcode_direct, $1)=no
         6295  +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         6296  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         6297  +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         6298  +	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
         6299  +	# Instead, shared libraries are loaded at an image base (0x10000000 by
         6300  +	# default) and relocated if they conflict, which is a slow very memory
         6301  +	# consuming and fragmenting process.  To avoid this, we pick a random,
         6302  +	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
         6303  +	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
         6304  +	_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'
         6305  +	_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'
         6306  +	;;
         6307  +      irix5* | irix6*)
         6308  +        case $cc_basename in
         6309  +          CC*)
         6310  +	    # SGI C++
         6311  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
         6312  +
         6313  +	    # Archives containing C++ object files must be created using
         6314  +	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
         6315  +	    # necessary to make sure instantiated templates are included
         6316  +	    # in the archive.
         6317  +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
         6318  +	    ;;
         6319  +          *)
         6320  +	    if test "$GXX" = yes; then
         6321  +	      if test "$with_gnu_ld" = no; then
         6322  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
         6323  +	      else
         6324  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
         6325  +	      fi
         6326  +	    fi
         6327  +	    _LT_TAGVAR(link_all_deplibs, $1)=yes
         6328  +	    ;;
         6329  +        esac
         6330  +        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         6331  +        _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         6332  +        _LT_TAGVAR(inherit_rpath, $1)=yes
         6333  +        ;;
         6334  +
         6335  +      linux* | k*bsd*-gnu | kopensolaris*-gnu)
         6336  +        case $cc_basename in
         6337  +          KCC*)
         6338  +	    # Kuck and Associates, Inc. (KAI) C++ Compiler
         6339  +
         6340  +	    # KCC will only create a shared library if the output file
         6341  +	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
         6342  +	    # to its proper name (with version) after linking.
         6343  +	    _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'
         6344  +	    _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'
         6345  +	    # Commands to make compiler produce verbose output that lists
         6346  +	    # what "hidden" libraries, object files and flags are used when
         6347  +	    # linking a shared library.
         6348  +	    #
         6349  +	    # There doesn't appear to be a way to prevent this compiler from
         6350  +	    # explicitly linking system object files so we need to strip them
         6351  +	    # from the output so that they don't get included in the library
         6352  +	    # dependencies.
         6353  +	    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; func_echo_all "$list"'
         6354  +
         6355  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         6356  +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
         6357  +
         6358  +	    # Archives containing C++ object files must be created using
         6359  +	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
         6360  +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
         6361  +	    ;;
         6362  +	  icpc* | ecpc* )
         6363  +	    # Intel C++
         6364  +	    with_gnu_ld=yes
         6365  +	    # version 8.0 and above of icpc choke on multiply defined symbols
         6366  +	    # if we add $predep_objects and $postdep_objects, however 7.1 and
         6367  +	    # earlier do not add the objects themselves.
         6368  +	    case `$CC -V 2>&1` in
         6369  +	      *"Version 7."*)
         6370  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
         6371  +		_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'
         6372  +		;;
         6373  +	      *)  # Version 8.0 or newer
         6374  +	        tmp_idyn=
         6375  +	        case $host_cpu in
         6376  +		  ia64*) tmp_idyn=' -i_dynamic';;
         6377  +		esac
         6378  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         6379  +		_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'
         6380  +		;;
         6381  +	    esac
         6382  +	    _LT_TAGVAR(archive_cmds_need_lc, $1)=no
         6383  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         6384  +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
         6385  +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
         6386  +	    ;;
         6387  +          pgCC* | pgcpp*)
         6388  +            # Portland Group C++ compiler
         6389  +	    case `$CC -V` in
         6390  +	    *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*)
         6391  +	      _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~
         6392  +		rm -rf $tpldir~
         6393  +		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
         6394  +		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
         6395  +	      _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~
         6396  +		rm -rf $tpldir~
         6397  +		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
         6398  +		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
         6399  +		$RANLIB $oldlib'
         6400  +	      _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~
         6401  +		rm -rf $tpldir~
         6402  +		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
         6403  +		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
         6404  +	      _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~
         6405  +		rm -rf $tpldir~
         6406  +		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
         6407  +		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
         6408  +	      ;;
         6409  +	    *) # Version 6 and above use weak symbols
         6410  +	      _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
         6411  +	      _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'
         6412  +	      ;;
         6413  +	    esac
         6414  +
         6415  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
         6416  +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
         6417  +	    _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
         6418  +            ;;
         6419  +	  cxx*)
         6420  +	    # Compaq C++
         6421  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
         6422  +	    _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'
         6423  +
         6424  +	    runpath_var=LD_RUN_PATH
         6425  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
         6426  +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         6427  +
         6428  +	    # Commands to make compiler produce verbose output that lists
         6429  +	    # what "hidden" libraries, object files and flags are used when
         6430  +	    # linking a shared library.
         6431  +	    #
         6432  +	    # There doesn't appear to be a way to prevent this compiler from
         6433  +	    # explicitly linking system object files so we need to strip them
         6434  +	    # from the output so that they don't get included in the library
         6435  +	    # dependencies.
         6436  +	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
         6437  +	    ;;
         6438  +	  xl* | mpixl* | bgxl*)
         6439  +	    # IBM XL 8.0 on PPC, with GNU ld
         6440  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         6441  +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
         6442  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
         6443  +	    if test "x$supports_anon_versioning" = xyes; then
         6444  +	      _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~
         6445  +		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
         6446  +		echo "local: *; };" >> $output_objdir/$libname.ver~
         6447  +		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
         6448  +	    fi
         6449  +	    ;;
         6450  +	  *)
         6451  +	    case `$CC -V 2>&1 | sed 5q` in
         6452  +	    *Sun\ C*)
         6453  +	      # Sun C++ 5.9
         6454  +	      _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
         6455  +	      _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
         6456  +	      _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'
         6457  +	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         6458  +	      _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; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
         6459  +	      _LT_TAGVAR(compiler_needs_object, $1)=yes
         6460  +
         6461  +	      # Not sure whether something based on
         6462  +	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
         6463  +	      # would be better.
         6464  +	      output_verbose_link_cmd='func_echo_all'
         6465  +
         6466  +	      # Archives containing C++ object files must be created using
         6467  +	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
         6468  +	      # necessary to make sure instantiated templates are included
         6469  +	      # in the archive.
         6470  +	      _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
         6471  +	      ;;
         6472  +	    esac
         6473  +	    ;;
         6474  +	esac
         6475  +	;;
         6476  +
         6477  +      lynxos*)
         6478  +        # FIXME: insert proper C++ library support
         6479  +	_LT_TAGVAR(ld_shlibs, $1)=no
         6480  +	;;
         6481  +
         6482  +      m88k*)
         6483  +        # FIXME: insert proper C++ library support
         6484  +        _LT_TAGVAR(ld_shlibs, $1)=no
         6485  +	;;
         6486  +
         6487  +      mvs*)
         6488  +        case $cc_basename in
         6489  +          cxx*)
         6490  +	    # FIXME: insert proper C++ library support
         6491  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6492  +	    ;;
         6493  +	  *)
         6494  +	    # FIXME: insert proper C++ library support
         6495  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6496  +	    ;;
         6497  +	esac
         6498  +	;;
         6499  +
         6500  +      netbsd*)
         6501  +        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
         6502  +	  _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
         6503  +	  wlarc=
         6504  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         6505  +	  _LT_TAGVAR(hardcode_direct, $1)=yes
         6506  +	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         6507  +	fi
         6508  +	# Workaround some broken pre-1.5 toolchains
         6509  +	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
         6510  +	;;
         6511  +
         6512  +      *nto* | *qnx*)
         6513  +        _LT_TAGVAR(ld_shlibs, $1)=yes
         6514  +	;;
         6515  +
         6516  +      openbsd2*)
         6517  +        # C++ shared libraries are fairly broken
         6518  +	_LT_TAGVAR(ld_shlibs, $1)=no
         6519  +	;;
         6520  +
         6521  +      openbsd*)
         6522  +	if test -f /usr/libexec/ld.so; then
         6523  +	  _LT_TAGVAR(hardcode_direct, $1)=yes
         6524  +	  _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         6525  +	  _LT_TAGVAR(hardcode_direct_absolute, $1)=yes
         6526  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
         6527  +	  _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         6528  +	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
         6529  +	    _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'
         6530  +	    _LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
         6531  +	    _LT_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
         6532  +	  fi
         6533  +	  output_verbose_link_cmd=func_echo_all
         6534  +	else
         6535  +	  _LT_TAGVAR(ld_shlibs, $1)=no
         6536  +	fi
         6537  +	;;
         6538  +
         6539  +      osf3* | osf4* | osf5*)
         6540  +        case $cc_basename in
         6541  +          KCC*)
         6542  +	    # Kuck and Associates, Inc. (KAI) C++ Compiler
         6543  +
         6544  +	    # KCC will only create a shared library if the output file
         6545  +	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
         6546  +	    # to its proper name (with version) after linking.
         6547  +	    _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'
         6548  +
         6549  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
         6550  +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         6551  +
         6552  +	    # Archives containing C++ object files must be created using
         6553  +	    # the KAI C++ compiler.
         6554  +	    case $host in
         6555  +	      osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;;
         6556  +	      *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;;
         6557  +	    esac
         6558  +	    ;;
         6559  +          RCC*)
         6560  +	    # Rational C++ 2.4.1
         6561  +	    # FIXME: insert proper C++ library support
         6562  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6563  +	    ;;
         6564  +          cxx*)
         6565  +	    case $host in
         6566  +	      osf3*)
         6567  +	        _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
         6568  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
         6569  +	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         6570  +		;;
         6571  +	      *)
         6572  +	        _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
         6573  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
         6574  +	        _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
         6575  +	          echo "-hidden">> $lib.exp~
         6576  +	          $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 "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
         6577  +	          $RM $lib.exp'
         6578  +	        _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
         6579  +		;;
         6580  +	    esac
         6581  +
         6582  +	    _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         6583  +
         6584  +	    # Commands to make compiler produce verbose output that lists
         6585  +	    # what "hidden" libraries, object files and flags are used when
         6586  +	    # linking a shared library.
         6587  +	    #
         6588  +	    # There doesn't appear to be a way to prevent this compiler from
         6589  +	    # explicitly linking system object files so we need to strip them
         6590  +	    # from the output so that they don't get included in the library
         6591  +	    # dependencies.
         6592  +	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
         6593  +	    ;;
         6594  +	  *)
         6595  +	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
         6596  +	      _LT_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
         6597  +	      case $host in
         6598  +	        osf3*)
         6599  +	          _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" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
         6600  +		  ;;
         6601  +	        *)
         6602  +	          _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
         6603  +		  ;;
         6604  +	      esac
         6605  +
         6606  +	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
         6607  +	      _LT_TAGVAR(hardcode_libdir_separator, $1)=:
         6608  +
         6609  +	      # Commands to make compiler produce verbose output that lists
         6610  +	      # what "hidden" libraries, object files and flags are used when
         6611  +	      # linking a shared library.
         6612  +	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
         6613  +
         6614  +	    else
         6615  +	      # FIXME: insert proper C++ library support
         6616  +	      _LT_TAGVAR(ld_shlibs, $1)=no
         6617  +	    fi
         6618  +	    ;;
         6619  +        esac
         6620  +        ;;
         6621  +
         6622  +      psos*)
         6623  +        # FIXME: insert proper C++ library support
         6624  +        _LT_TAGVAR(ld_shlibs, $1)=no
         6625  +        ;;
         6626  +
         6627  +      sunos4*)
         6628  +        case $cc_basename in
         6629  +          CC*)
         6630  +	    # Sun C++ 4.x
         6631  +	    # FIXME: insert proper C++ library support
         6632  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6633  +	    ;;
         6634  +          lcc*)
         6635  +	    # Lucid
         6636  +	    # FIXME: insert proper C++ library support
         6637  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6638  +	    ;;
         6639  +          *)
         6640  +	    # FIXME: insert proper C++ library support
         6641  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6642  +	    ;;
         6643  +        esac
         6644  +        ;;
         6645  +
         6646  +      solaris*)
         6647  +        case $cc_basename in
         6648  +          CC* | sunCC*)
         6649  +	    # Sun C++ 4.2, 5.x and Centerline C++
         6650  +            _LT_TAGVAR(archive_cmds_need_lc,$1)=yes
         6651  +	    _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs'
         6652  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
         6653  +	    _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
         6654  +	      $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'
         6655  +
         6656  +	    _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
         6657  +	    _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         6658  +	    case $host_os in
         6659  +	      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
         6660  +	      *)
         6661  +		# The compiler driver will combine and reorder linker options,
         6662  +		# but understands `-z linker_flag'.
         6663  +	        # Supported since Solaris 2.6 (maybe 2.5.1?)
         6664  +		_LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract'
         6665  +	        ;;
         6666  +	    esac
         6667  +	    _LT_TAGVAR(link_all_deplibs, $1)=yes
         6668  +
         6669  +	    output_verbose_link_cmd='func_echo_all'
         6670  +
         6671  +	    # Archives containing C++ object files must be created using
         6672  +	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
         6673  +	    # necessary to make sure instantiated templates are included
         6674  +	    # in the archive.
         6675  +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
         6676  +	    ;;
         6677  +          gcx*)
         6678  +	    # Green Hills C++ Compiler
         6679  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
         6680  +
         6681  +	    # The C++ compiler must be used to create the archive.
         6682  +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
         6683  +	    ;;
         6684  +          *)
         6685  +	    # GNU C++ compiler with Solaris linker
         6686  +	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
         6687  +	      _LT_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
         6688  +	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
         6689  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
         6690  +	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
         6691  +		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
         6692  +
         6693  +	        # Commands to make compiler produce verbose output that lists
         6694  +	        # what "hidden" libraries, object files and flags are used when
         6695  +	        # linking a shared library.
         6696  +	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
         6697  +	      else
         6698  +	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
         6699  +	        # platform.
         6700  +	        _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
         6701  +	        _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
         6702  +		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
         6703  +
         6704  +	        # Commands to make compiler produce verbose output that lists
         6705  +	        # what "hidden" libraries, object files and flags are used when
         6706  +	        # linking a shared library.
         6707  +	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
         6708  +	      fi
         6709  +
         6710  +	      _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
         6711  +	      case $host_os in
         6712  +		solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
         6713  +		*)
         6714  +		  _LT_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
         6715  +		  ;;
         6716  +	      esac
         6717  +	    fi
         6718  +	    ;;
         6719  +        esac
         6720  +        ;;
         6721  +
         6722  +    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*)
         6723  +      _LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
         6724  +      _LT_TAGVAR(archive_cmds_need_lc, $1)=no
         6725  +      _LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         6726  +      runpath_var='LD_RUN_PATH'
         6727  +
         6728  +      case $cc_basename in
         6729  +        CC*)
         6730  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6731  +	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6732  +	  ;;
         6733  +	*)
         6734  +	  _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6735  +	  _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6736  +	  ;;
         6737  +      esac
         6738  +      ;;
         6739  +
         6740  +      sysv5* | sco3.2v5* | sco5v6*)
         6741  +	# Note: We can NOT use -z defs as we might desire, because we do not
         6742  +	# link with -lc, and that would cause any symbols used from libc to
         6743  +	# always be unresolved, which means just about no library would
         6744  +	# ever link correctly.  If we're not using GNU ld we use -z text
         6745  +	# though, which does catch some bad symbols but isn't as heavy-handed
         6746  +	# as -z defs.
         6747  +	_LT_TAGVAR(no_undefined_flag, $1)='${wl}-z,text'
         6748  +	_LT_TAGVAR(allow_undefined_flag, $1)='${wl}-z,nodefs'
         6749  +	_LT_TAGVAR(archive_cmds_need_lc, $1)=no
         6750  +	_LT_TAGVAR(hardcode_shlibpath_var, $1)=no
         6751  +	_LT_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R,$libdir'
         6752  +	_LT_TAGVAR(hardcode_libdir_separator, $1)=':'
         6753  +	_LT_TAGVAR(link_all_deplibs, $1)=yes
         6754  +	_LT_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
         6755  +	runpath_var='LD_RUN_PATH'
         6756  +
         6757  +	case $cc_basename in
         6758  +          CC*)
         6759  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6760  +	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6761  +	    _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~
         6762  +	      '"$_LT_TAGVAR(old_archive_cmds, $1)"
         6763  +	    _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~
         6764  +	      '"$_LT_TAGVAR(reload_cmds, $1)"
         6765  +	    ;;
         6766  +	  *)
         6767  +	    _LT_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6768  +	    _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
         6769  +	    ;;
         6770  +	esac
         6771  +      ;;
         6772  +
         6773  +      tandem*)
         6774  +        case $cc_basename in
         6775  +          NCC*)
         6776  +	    # NonStop-UX NCC 3.20
         6777  +	    # FIXME: insert proper C++ library support
         6778  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6779  +	    ;;
         6780  +          *)
         6781  +	    # FIXME: insert proper C++ library support
         6782  +	    _LT_TAGVAR(ld_shlibs, $1)=no
         6783  +	    ;;
         6784  +        esac
         6785  +        ;;
         6786  +
         6787  +      vxworks*)
         6788  +        # FIXME: insert proper C++ library support
         6789  +        _LT_TAGVAR(ld_shlibs, $1)=no
         6790  +        ;;
         6791  +
         6792  +      *)
         6793  +        # FIXME: insert proper C++ library support
         6794  +        _LT_TAGVAR(ld_shlibs, $1)=no
         6795  +        ;;
         6796  +    esac
         6797  +
         6798  +    AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)])
         6799  +    test "$_LT_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
         6800  +
         6801  +    _LT_TAGVAR(GCC, $1)="$GXX"
         6802  +    _LT_TAGVAR(LD, $1)="$LD"
         6803  +
         6804  +    ## CAVEAT EMPTOR:
         6805  +    ## There is no encapsulation within the following macros, do not change
         6806  +    ## the running order or otherwise move them around unless you know exactly
         6807  +    ## what you are doing...
         6808  +    _LT_SYS_HIDDEN_LIBDEPS($1)
         6809  +    _LT_COMPILER_PIC($1)
         6810  +    _LT_COMPILER_C_O($1)
         6811  +    _LT_COMPILER_FILE_LOCKS($1)
         6812  +    _LT_LINKER_SHLIBS($1)
         6813  +    _LT_SYS_DYNAMIC_LINKER($1)
         6814  +    _LT_LINKER_HARDCODE_LIBPATH($1)
         6815  +
         6816  +    _LT_CONFIG($1)
         6817  +  fi # test -n "$compiler"
         6818  +
         6819  +  CC=$lt_save_CC
         6820  +  CFLAGS=$lt_save_CFLAGS
         6821  +  LDCXX=$LD
         6822  +  LD=$lt_save_LD
         6823  +  GCC=$lt_save_GCC
         6824  +  with_gnu_ld=$lt_save_with_gnu_ld
         6825  +  lt_cv_path_LDCXX=$lt_cv_path_LD
         6826  +  lt_cv_path_LD=$lt_save_path_LD
         6827  +  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
         6828  +  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
         6829  +fi # test "$_lt_caught_CXX_error" != yes
         6830  +
         6831  +AC_LANG_POP
         6832  +])# _LT_LANG_CXX_CONFIG
         6833  +
         6834  +
         6835  +# _LT_FUNC_STRIPNAME_CNF
         6836  +# ----------------------
         6837  +# func_stripname_cnf prefix suffix name
         6838  +# strip PREFIX and SUFFIX off of NAME.
         6839  +# PREFIX and SUFFIX must not contain globbing or regex special
         6840  +# characters, hashes, percent signs, but SUFFIX may contain a leading
         6841  +# dot (in which case that matches only a dot).
         6842  +#
         6843  +# This function is identical to the (non-XSI) version of func_stripname,
         6844  +# except this one can be used by m4 code that may be executed by configure,
         6845  +# rather than the libtool script.
         6846  +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl
         6847  +AC_REQUIRE([_LT_DECL_SED])
         6848  +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])
         6849  +func_stripname_cnf ()
         6850  +{
         6851  +  case ${2} in
         6852  +  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
         6853  +  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
         6854  +  esac
         6855  +} # func_stripname_cnf
         6856  +])# _LT_FUNC_STRIPNAME_CNF
         6857  +
         6858  +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME])
         6859  +# ---------------------------------
         6860  +# Figure out "hidden" library dependencies from verbose
         6861  +# compiler output when linking a shared library.
         6862  +# Parse the compiler output and extract the necessary
         6863  +# objects, libraries and library flags.
         6864  +m4_defun([_LT_SYS_HIDDEN_LIBDEPS],
         6865  +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl
         6866  +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl
         6867  +# Dependencies to place before and after the object being linked:
         6868  +_LT_TAGVAR(predep_objects, $1)=
         6869  +_LT_TAGVAR(postdep_objects, $1)=
         6870  +_LT_TAGVAR(predeps, $1)=
         6871  +_LT_TAGVAR(postdeps, $1)=
         6872  +_LT_TAGVAR(compiler_lib_search_path, $1)=
         6873  +
         6874  +dnl we can't use the lt_simple_compile_test_code here,
         6875  +dnl because it contains code intended for an executable,
         6876  +dnl not a library.  It's possible we should let each
         6877  +dnl tag define a new lt_????_link_test_code variable,
         6878  +dnl but it's only used here...
         6879  +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF
         6880  +int a;
         6881  +void foo (void) { a = 0; }
         6882  +_LT_EOF
         6883  +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF
         6884  +class Foo
         6885  +{
         6886  +public:
         6887  +  Foo (void) { a = 0; }
         6888  +private:
         6889  +  int a;
         6890  +};
         6891  +_LT_EOF
         6892  +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF
         6893  +      subroutine foo
         6894  +      implicit none
         6895  +      integer*4 a
         6896  +      a=0
         6897  +      return
         6898  +      end
         6899  +_LT_EOF
         6900  +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF
         6901  +      subroutine foo
         6902  +      implicit none
         6903  +      integer a
         6904  +      a=0
         6905  +      return
         6906  +      end
         6907  +_LT_EOF
         6908  +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF
         6909  +public class foo {
         6910  +  private int a;
         6911  +  public void bar (void) {
         6912  +    a = 0;
         6913  +  }
         6914  +};
         6915  +_LT_EOF
         6916  +])
         6917  +
         6918  +_lt_libdeps_save_CFLAGS=$CFLAGS
         6919  +case "$CC $CFLAGS " in #(
         6920  +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
         6921  +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
         6922  +esac
         6923  +
         6924  +dnl Parse the compiler output and extract the necessary
         6925  +dnl objects, libraries and library flags.
         6926  +if AC_TRY_EVAL(ac_compile); then
         6927  +  # Parse the compiler output and extract the necessary
         6928  +  # objects, libraries and library flags.
         6929  +
         6930  +  # Sentinel used to keep track of whether or not we are before
         6931  +  # the conftest object file.
         6932  +  pre_test_object_deps_done=no
         6933  +
         6934  +  for p in `eval "$output_verbose_link_cmd"`; do
         6935  +    case ${prev}${p} in
         6936  +
         6937  +    -L* | -R* | -l*)
         6938  +       # Some compilers place space between "-{L,R}" and the path.
         6939  +       # Remove the space.
         6940  +       if test $p = "-L" ||
         6941  +          test $p = "-R"; then
         6942  +	 prev=$p
         6943  +	 continue
         6944  +       fi
         6945  +
         6946  +       # Expand the sysroot to ease extracting the directories later.
         6947  +       if test -z "$prev"; then
         6948  +         case $p in
         6949  +         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
         6950  +         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
         6951  +         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
         6952  +         esac
         6953  +       fi
         6954  +       case $p in
         6955  +       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
         6956  +       esac
         6957  +       if test "$pre_test_object_deps_done" = no; then
         6958  +	 case ${prev} in
         6959  +	 -L | -R)
         6960  +	   # Internal compiler library paths should come after those
         6961  +	   # provided the user.  The postdeps already come after the
         6962  +	   # user supplied libs so there is no need to process them.
         6963  +	   if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then
         6964  +	     _LT_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
         6965  +	   else
         6966  +	     _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
         6967  +	   fi
         6968  +	   ;;
         6969  +	 # The "-l" case would never come before the object being
         6970  +	 # linked, so don't bother handling this case.
         6971  +	 esac
         6972  +       else
         6973  +	 if test -z "$_LT_TAGVAR(postdeps, $1)"; then
         6974  +	   _LT_TAGVAR(postdeps, $1)="${prev}${p}"
         6975  +	 else
         6976  +	   _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} ${prev}${p}"
         6977  +	 fi
         6978  +       fi
         6979  +       prev=
         6980  +       ;;
         6981  +
         6982  +    *.lto.$objext) ;; # Ignore GCC LTO objects
         6983  +    *.$objext)
         6984  +       # This assumes that the test object file only shows up
         6985  +       # once in the compiler output.
         6986  +       if test "$p" = "conftest.$objext"; then
         6987  +	 pre_test_object_deps_done=yes
         6988  +	 continue
         6989  +       fi
         6990  +
         6991  +       if test "$pre_test_object_deps_done" = no; then
         6992  +	 if test -z "$_LT_TAGVAR(predep_objects, $1)"; then
         6993  +	   _LT_TAGVAR(predep_objects, $1)="$p"
         6994  +	 else
         6995  +	   _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p"
         6996  +	 fi
         6997  +       else
         6998  +	 if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then
         6999  +	   _LT_TAGVAR(postdep_objects, $1)="$p"
         7000  +	 else
         7001  +	   _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p"
         7002  +	 fi
         7003  +       fi
         7004  +       ;;
         7005  +
         7006  +    *) ;; # Ignore the rest.
         7007  +
         7008  +    esac
         7009  +  done
         7010  +
         7011  +  # Clean up.
         7012  +  rm -f a.out a.exe
         7013  +else
         7014  +  echo "libtool.m4: error: problem compiling $1 test program"
         7015  +fi
         7016  +
         7017  +$RM -f confest.$objext
         7018  +CFLAGS=$_lt_libdeps_save_CFLAGS
         7019  +
         7020  +# PORTME: override above test on systems where it is broken
         7021  +m4_if([$1], [CXX],
         7022  +[case $host_os in
         7023  +interix[[3-9]]*)
         7024  +  # Interix 3.5 installs completely hosed .la files for C++, so rather than
         7025  +  # hack all around it, let's just trust "g++" to DTRT.
         7026  +  _LT_TAGVAR(predep_objects,$1)=
         7027  +  _LT_TAGVAR(postdep_objects,$1)=
         7028  +  _LT_TAGVAR(postdeps,$1)=
         7029  +  ;;
         7030  +
         7031  +linux*)
         7032  +  case `$CC -V 2>&1 | sed 5q` in
         7033  +  *Sun\ C*)
         7034  +    # Sun C++ 5.9
         7035  +
         7036  +    # The more standards-conforming stlport4 library is
         7037  +    # incompatible with the Cstd library. Avoid specifying
         7038  +    # it if it's in CXXFLAGS. Ignore libCrun as
         7039  +    # -library=stlport4 depends on it.
         7040  +    case " $CXX $CXXFLAGS " in
         7041  +    *" -library=stlport4 "*)
         7042  +      solaris_use_stlport4=yes
         7043  +      ;;
         7044  +    esac
         7045  +
         7046  +    if test "$solaris_use_stlport4" != yes; then
         7047  +      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
         7048  +    fi
         7049  +    ;;
         7050  +  esac
         7051  +  ;;
         7052  +
         7053  +solaris*)
         7054  +  case $cc_basename in
         7055  +  CC* | sunCC*)
         7056  +    # The more standards-conforming stlport4 library is
         7057  +    # incompatible with the Cstd library. Avoid specifying
         7058  +    # it if it's in CXXFLAGS. Ignore libCrun as
         7059  +    # -library=stlport4 depends on it.
         7060  +    case " $CXX $CXXFLAGS " in
         7061  +    *" -library=stlport4 "*)
         7062  +      solaris_use_stlport4=yes
         7063  +      ;;
         7064  +    esac
         7065  +
         7066  +    # Adding this requires a known-good setup of shared libraries for
         7067  +    # Sun compiler versions before 5.6, else PIC objects from an old
         7068  +    # archive will be linked into the output, leading to subtle bugs.
         7069  +    if test "$solaris_use_stlport4" != yes; then
         7070  +      _LT_TAGVAR(postdeps,$1)='-library=Cstd -library=Crun'
         7071  +    fi
         7072  +    ;;
         7073  +  esac
         7074  +  ;;
         7075  +esac
         7076  +])
         7077  +
         7078  +case " $_LT_TAGVAR(postdeps, $1) " in
         7079  +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;;
         7080  +esac
         7081  + _LT_TAGVAR(compiler_lib_search_dirs, $1)=
         7082  +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then
         7083  + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
         7084  +fi
         7085  +_LT_TAGDECL([], [compiler_lib_search_dirs], [1],
         7086  +    [The directories searched by this compiler when creating a shared library])
         7087  +_LT_TAGDECL([], [predep_objects], [1],
         7088  +    [Dependencies to place before and after the objects being linked to
         7089  +    create a shared library])
         7090  +_LT_TAGDECL([], [postdep_objects], [1])
         7091  +_LT_TAGDECL([], [predeps], [1])
         7092  +_LT_TAGDECL([], [postdeps], [1])
         7093  +_LT_TAGDECL([], [compiler_lib_search_path], [1],
         7094  +    [The library search path used internally by the compiler when linking
         7095  +    a shared library])
         7096  +])# _LT_SYS_HIDDEN_LIBDEPS
         7097  +
         7098  +
         7099  +# _LT_LANG_F77_CONFIG([TAG])
         7100  +# --------------------------
         7101  +# Ensure that the configuration variables for a Fortran 77 compiler are
         7102  +# suitably defined.  These variables are subsequently used by _LT_CONFIG
         7103  +# to write the compiler configuration to `libtool'.
         7104  +m4_defun([_LT_LANG_F77_CONFIG],
         7105  +[AC_LANG_PUSH(Fortran 77)
         7106  +if test -z "$F77" || test "X$F77" = "Xno"; then
         7107  +  _lt_disable_F77=yes
         7108  +fi
         7109  +
         7110  +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
         7111  +_LT_TAGVAR(allow_undefined_flag, $1)=
         7112  +_LT_TAGVAR(always_export_symbols, $1)=no
         7113  +_LT_TAGVAR(archive_expsym_cmds, $1)=
         7114  +_LT_TAGVAR(export_dynamic_flag_spec, $1)=
         7115  +_LT_TAGVAR(hardcode_direct, $1)=no
         7116  +_LT_TAGVAR(hardcode_direct_absolute, $1)=no
         7117  +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
         7118  +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
         7119  +_LT_TAGVAR(hardcode_libdir_separator, $1)=
         7120  +_LT_TAGVAR(hardcode_minus_L, $1)=no
         7121  +_LT_TAGVAR(hardcode_automatic, $1)=no
         7122  +_LT_TAGVAR(inherit_rpath, $1)=no
         7123  +_LT_TAGVAR(module_cmds, $1)=
         7124  +_LT_TAGVAR(module_expsym_cmds, $1)=
         7125  +_LT_TAGVAR(link_all_deplibs, $1)=unknown
         7126  +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
         7127  +_LT_TAGVAR(reload_flag, $1)=$reload_flag
         7128  +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
         7129  +_LT_TAGVAR(no_undefined_flag, $1)=
         7130  +_LT_TAGVAR(whole_archive_flag_spec, $1)=
         7131  +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
         7132  +
         7133  +# Source file extension for f77 test sources.
         7134  +ac_ext=f
         7135  +
         7136  +# Object file extension for compiled f77 test sources.
         7137  +objext=o
         7138  +_LT_TAGVAR(objext, $1)=$objext
         7139  +
         7140  +# No sense in running all these tests if we already determined that
         7141  +# the F77 compiler isn't working.  Some variables (like enable_shared)
         7142  +# are currently assumed to apply to all compilers on this platform,
         7143  +# and will be corrupted by setting them based on a non-working compiler.
         7144  +if test "$_lt_disable_F77" != yes; then
         7145  +  # Code to be used in simple compile tests
         7146  +  lt_simple_compile_test_code="\
         7147  +      subroutine t
         7148  +      return
         7149  +      end
         7150  +"
         7151  +
         7152  +  # Code to be used in simple link tests
         7153  +  lt_simple_link_test_code="\
         7154  +      program t
         7155  +      end
         7156  +"
         7157  +
         7158  +  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
         7159  +  _LT_TAG_COMPILER
         7160  +
         7161  +  # save warnings/boilerplate of simple test code
         7162  +  _LT_COMPILER_BOILERPLATE
         7163  +  _LT_LINKER_BOILERPLATE
         7164  +
         7165  +  # Allow CC to be a program name with arguments.
         7166  +  lt_save_CC="$CC"
         7167  +  lt_save_GCC=$GCC
         7168  +  lt_save_CFLAGS=$CFLAGS
         7169  +  CC=${F77-"f77"}
         7170  +  CFLAGS=$FFLAGS
         7171  +  compiler=$CC
         7172  +  _LT_TAGVAR(compiler, $1)=$CC
         7173  +  _LT_CC_BASENAME([$compiler])
         7174  +  GCC=$G77
         7175  +  if test -n "$compiler"; then
         7176  +    AC_MSG_CHECKING([if libtool supports shared libraries])
         7177  +    AC_MSG_RESULT([$can_build_shared])
         7178  +
         7179  +    AC_MSG_CHECKING([whether to build shared libraries])
         7180  +    test "$can_build_shared" = "no" && enable_shared=no
         7181  +
         7182  +    # On AIX, shared libraries and static libraries use the same namespace, and
         7183  +    # are all built from PIC.
         7184  +    case $host_os in
         7185  +      aix3*)
         7186  +        test "$enable_shared" = yes && enable_static=no
         7187  +        if test -n "$RANLIB"; then
         7188  +          archive_cmds="$archive_cmds~\$RANLIB \$lib"
         7189  +          postinstall_cmds='$RANLIB $lib'
         7190  +        fi
         7191  +        ;;
         7192  +      aix[[4-9]]*)
         7193  +	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
         7194  +	  test "$enable_shared" = yes && enable_static=no
         7195  +	fi
         7196  +        ;;
         7197  +    esac
         7198  +    AC_MSG_RESULT([$enable_shared])
         7199  +
         7200  +    AC_MSG_CHECKING([whether to build static libraries])
         7201  +    # Make sure either enable_shared or enable_static is yes.
         7202  +    test "$enable_shared" = yes || enable_static=yes
         7203  +    AC_MSG_RESULT([$enable_static])
         7204  +
         7205  +    _LT_TAGVAR(GCC, $1)="$G77"
         7206  +    _LT_TAGVAR(LD, $1)="$LD"
         7207  +
         7208  +    ## CAVEAT EMPTOR:
         7209  +    ## There is no encapsulation within the following macros, do not change
         7210  +    ## the running order or otherwise move them around unless you know exactly
         7211  +    ## what you are doing...
         7212  +    _LT_COMPILER_PIC($1)
         7213  +    _LT_COMPILER_C_O($1)
         7214  +    _LT_COMPILER_FILE_LOCKS($1)
         7215  +    _LT_LINKER_SHLIBS($1)
         7216  +    _LT_SYS_DYNAMIC_LINKER($1)
         7217  +    _LT_LINKER_HARDCODE_LIBPATH($1)
         7218  +
         7219  +    _LT_CONFIG($1)
         7220  +  fi # test -n "$compiler"
         7221  +
         7222  +  GCC=$lt_save_GCC
         7223  +  CC="$lt_save_CC"
         7224  +  CFLAGS="$lt_save_CFLAGS"
         7225  +fi # test "$_lt_disable_F77" != yes
         7226  +
         7227  +AC_LANG_POP
         7228  +])# _LT_LANG_F77_CONFIG
         7229  +
         7230  +
         7231  +# _LT_LANG_FC_CONFIG([TAG])
         7232  +# -------------------------
         7233  +# Ensure that the configuration variables for a Fortran compiler are
         7234  +# suitably defined.  These variables are subsequently used by _LT_CONFIG
         7235  +# to write the compiler configuration to `libtool'.
         7236  +m4_defun([_LT_LANG_FC_CONFIG],
         7237  +[AC_LANG_PUSH(Fortran)
         7238  +
         7239  +if test -z "$FC" || test "X$FC" = "Xno"; then
         7240  +  _lt_disable_FC=yes
         7241  +fi
         7242  +
         7243  +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
         7244  +_LT_TAGVAR(allow_undefined_flag, $1)=
         7245  +_LT_TAGVAR(always_export_symbols, $1)=no
         7246  +_LT_TAGVAR(archive_expsym_cmds, $1)=
         7247  +_LT_TAGVAR(export_dynamic_flag_spec, $1)=
         7248  +_LT_TAGVAR(hardcode_direct, $1)=no
         7249  +_LT_TAGVAR(hardcode_direct_absolute, $1)=no
         7250  +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)=
         7251  +_LT_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
         7252  +_LT_TAGVAR(hardcode_libdir_separator, $1)=
         7253  +_LT_TAGVAR(hardcode_minus_L, $1)=no
         7254  +_LT_TAGVAR(hardcode_automatic, $1)=no
         7255  +_LT_TAGVAR(inherit_rpath, $1)=no
         7256  +_LT_TAGVAR(module_cmds, $1)=
         7257  +_LT_TAGVAR(module_expsym_cmds, $1)=
         7258  +_LT_TAGVAR(link_all_deplibs, $1)=unknown
         7259  +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
         7260  +_LT_TAGVAR(reload_flag, $1)=$reload_flag
         7261  +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
         7262  +_LT_TAGVAR(no_undefined_flag, $1)=
         7263  +_LT_TAGVAR(whole_archive_flag_spec, $1)=
         7264  +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no
         7265  +
         7266  +# Source file extension for fc test sources.
         7267  +ac_ext=${ac_fc_srcext-f}
         7268  +
         7269  +# Object file extension for compiled fc test sources.
         7270  +objext=o
         7271  +_LT_TAGVAR(objext, $1)=$objext
         7272  +
         7273  +# No sense in running all these tests if we already determined that
         7274  +# the FC compiler isn't working.  Some variables (like enable_shared)
         7275  +# are currently assumed to apply to all compilers on this platform,
         7276  +# and will be corrupted by setting them based on a non-working compiler.
         7277  +if test "$_lt_disable_FC" != yes; then
         7278  +  # Code to be used in simple compile tests
         7279  +  lt_simple_compile_test_code="\
         7280  +      subroutine t
         7281  +      return
         7282  +      end
         7283  +"
         7284  +
         7285  +  # Code to be used in simple link tests
         7286  +  lt_simple_link_test_code="\
         7287  +      program t
         7288  +      end
         7289  +"
         7290  +
         7291  +  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
         7292  +  _LT_TAG_COMPILER
         7293  +
         7294  +  # save warnings/boilerplate of simple test code
         7295  +  _LT_COMPILER_BOILERPLATE
         7296  +  _LT_LINKER_BOILERPLATE
         7297  +
         7298  +  # Allow CC to be a program name with arguments.
         7299  +  lt_save_CC="$CC"
         7300  +  lt_save_GCC=$GCC
         7301  +  lt_save_CFLAGS=$CFLAGS
         7302  +  CC=${FC-"f95"}
         7303  +  CFLAGS=$FCFLAGS
         7304  +  compiler=$CC
         7305  +  GCC=$ac_cv_fc_compiler_gnu
         7306  +
         7307  +  _LT_TAGVAR(compiler, $1)=$CC
         7308  +  _LT_CC_BASENAME([$compiler])
         7309  +
         7310  +  if test -n "$compiler"; then
         7311  +    AC_MSG_CHECKING([if libtool supports shared libraries])
         7312  +    AC_MSG_RESULT([$can_build_shared])
         7313  +
         7314  +    AC_MSG_CHECKING([whether to build shared libraries])
         7315  +    test "$can_build_shared" = "no" && enable_shared=no
         7316  +
         7317  +    # On AIX, shared libraries and static libraries use the same namespace, and
         7318  +    # are all built from PIC.
         7319  +    case $host_os in
         7320  +      aix3*)
         7321  +        test "$enable_shared" = yes && enable_static=no
         7322  +        if test -n "$RANLIB"; then
         7323  +          archive_cmds="$archive_cmds~\$RANLIB \$lib"
         7324  +          postinstall_cmds='$RANLIB $lib'
         7325  +        fi
         7326  +        ;;
         7327  +      aix[[4-9]]*)
         7328  +	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
         7329  +	  test "$enable_shared" = yes && enable_static=no
         7330  +	fi
         7331  +        ;;
         7332  +    esac
         7333  +    AC_MSG_RESULT([$enable_shared])
         7334  +
         7335  +    AC_MSG_CHECKING([whether to build static libraries])
         7336  +    # Make sure either enable_shared or enable_static is yes.
         7337  +    test "$enable_shared" = yes || enable_static=yes
         7338  +    AC_MSG_RESULT([$enable_static])
         7339  +
         7340  +    _LT_TAGVAR(GCC, $1)="$ac_cv_fc_compiler_gnu"
         7341  +    _LT_TAGVAR(LD, $1)="$LD"
         7342  +
         7343  +    ## CAVEAT EMPTOR:
         7344  +    ## There is no encapsulation within the following macros, do not change
         7345  +    ## the running order or otherwise move them around unless you know exactly
         7346  +    ## what you are doing...
         7347  +    _LT_SYS_HIDDEN_LIBDEPS($1)
         7348  +    _LT_COMPILER_PIC($1)
         7349  +    _LT_COMPILER_C_O($1)
         7350  +    _LT_COMPILER_FILE_LOCKS($1)
         7351  +    _LT_LINKER_SHLIBS($1)
         7352  +    _LT_SYS_DYNAMIC_LINKER($1)
         7353  +    _LT_LINKER_HARDCODE_LIBPATH($1)
         7354  +
         7355  +    _LT_CONFIG($1)
         7356  +  fi # test -n "$compiler"
         7357  +
         7358  +  GCC=$lt_save_GCC
         7359  +  CC=$lt_save_CC
         7360  +  CFLAGS=$lt_save_CFLAGS
         7361  +fi # test "$_lt_disable_FC" != yes
         7362  +
         7363  +AC_LANG_POP
         7364  +])# _LT_LANG_FC_CONFIG
         7365  +
         7366  +
         7367  +# _LT_LANG_GCJ_CONFIG([TAG])
         7368  +# --------------------------
         7369  +# Ensure that the configuration variables for the GNU Java Compiler compiler
         7370  +# are suitably defined.  These variables are subsequently used by _LT_CONFIG
         7371  +# to write the compiler configuration to `libtool'.
         7372  +m4_defun([_LT_LANG_GCJ_CONFIG],
         7373  +[AC_REQUIRE([LT_PROG_GCJ])dnl
         7374  +AC_LANG_SAVE
         7375  +
         7376  +# Source file extension for Java test sources.
         7377  +ac_ext=java
         7378  +
         7379  +# Object file extension for compiled Java test sources.
         7380  +objext=o
         7381  +_LT_TAGVAR(objext, $1)=$objext
         7382  +
         7383  +# Code to be used in simple compile tests
         7384  +lt_simple_compile_test_code="class foo {}"
         7385  +
         7386  +# Code to be used in simple link tests
         7387  +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }'
         7388  +
         7389  +# ltmain only uses $CC for tagged configurations so make sure $CC is set.
         7390  +_LT_TAG_COMPILER
         7391  +
         7392  +# save warnings/boilerplate of simple test code
         7393  +_LT_COMPILER_BOILERPLATE
         7394  +_LT_LINKER_BOILERPLATE
         7395  +
         7396  +# Allow CC to be a program name with arguments.
         7397  +lt_save_CC=$CC
         7398  +lt_save_CFLAGS=$CFLAGS
         7399  +lt_save_GCC=$GCC
         7400  +GCC=yes
         7401  +CC=${GCJ-"gcj"}
         7402  +CFLAGS=$GCJFLAGS
         7403  +compiler=$CC
         7404  +_LT_TAGVAR(compiler, $1)=$CC
         7405  +_LT_TAGVAR(LD, $1)="$LD"
         7406  +_LT_CC_BASENAME([$compiler])
         7407  +
         7408  +# GCJ did not exist at the time GCC didn't implicitly link libc in.
         7409  +_LT_TAGVAR(archive_cmds_need_lc, $1)=no
         7410  +
         7411  +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
         7412  +_LT_TAGVAR(reload_flag, $1)=$reload_flag
         7413  +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds
         7414  +
         7415  +if test -n "$compiler"; then
         7416  +  _LT_COMPILER_NO_RTTI($1)
         7417  +  _LT_COMPILER_PIC($1)
         7418  +  _LT_COMPILER_C_O($1)
         7419  +  _LT_COMPILER_FILE_LOCKS($1)
         7420  +  _LT_LINKER_SHLIBS($1)
         7421  +  _LT_LINKER_HARDCODE_LIBPATH($1)
         7422  +
         7423  +  _LT_CONFIG($1)
         7424  +fi
         7425  +
         7426  +AC_LANG_RESTORE
         7427  +
         7428  +GCC=$lt_save_GCC
         7429  +CC=$lt_save_CC
         7430  +CFLAGS=$lt_save_CFLAGS
         7431  +])# _LT_LANG_GCJ_CONFIG
         7432  +
         7433  +
         7434  +# _LT_LANG_RC_CONFIG([TAG])
         7435  +# -------------------------
         7436  +# Ensure that the configuration variables for the Windows resource compiler
         7437  +# are suitably defined.  These variables are subsequently used by _LT_CONFIG
         7438  +# to write the compiler configuration to `libtool'.
         7439  +m4_defun([_LT_LANG_RC_CONFIG],
         7440  +[AC_REQUIRE([LT_PROG_RC])dnl
         7441  +AC_LANG_SAVE
         7442  +
         7443  +# Source file extension for RC test sources.
         7444  +ac_ext=rc
         7445  +
         7446  +# Object file extension for compiled RC test sources.
         7447  +objext=o
         7448  +_LT_TAGVAR(objext, $1)=$objext
         7449  +
         7450  +# Code to be used in simple compile tests
         7451  +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'
         7452  +
         7453  +# Code to be used in simple link tests
         7454  +lt_simple_link_test_code="$lt_simple_compile_test_code"
         7455  +
         7456  +# ltmain only uses $CC for tagged configurations so make sure $CC is set.
         7457  +_LT_TAG_COMPILER
         7458  +
         7459  +# save warnings/boilerplate of simple test code
         7460  +_LT_COMPILER_BOILERPLATE
         7461  +_LT_LINKER_BOILERPLATE
         7462  +
         7463  +# Allow CC to be a program name with arguments.
         7464  +lt_save_CC="$CC"
         7465  +lt_save_CFLAGS=$CFLAGS
         7466  +lt_save_GCC=$GCC
         7467  +GCC=
         7468  +CC=${RC-"windres"}
         7469  +CFLAGS=
         7470  +compiler=$CC
         7471  +_LT_TAGVAR(compiler, $1)=$CC
         7472  +_LT_CC_BASENAME([$compiler])
         7473  +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
         7474  +
         7475  +if test -n "$compiler"; then
         7476  +  :
         7477  +  _LT_CONFIG($1)
         7478  +fi
         7479  +
         7480  +GCC=$lt_save_GCC
         7481  +AC_LANG_RESTORE
         7482  +CC=$lt_save_CC
         7483  +CFLAGS=$lt_save_CFLAGS
         7484  +])# _LT_LANG_RC_CONFIG
         7485  +
         7486  +
         7487  +# LT_PROG_GCJ
         7488  +# -----------
         7489  +AC_DEFUN([LT_PROG_GCJ],
         7490  +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ],
         7491  +  [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ],
         7492  +    [AC_CHECK_TOOL(GCJ, gcj,)
         7493  +      test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
         7494  +      AC_SUBST(GCJFLAGS)])])[]dnl
         7495  +])
         7496  +
         7497  +# Old name:
         7498  +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ])
         7499  +dnl aclocal-1.4 backwards compatibility:
         7500  +dnl AC_DEFUN([LT_AC_PROG_GCJ], [])
         7501  +
         7502  +
         7503  +# LT_PROG_RC
         7504  +# ----------
         7505  +AC_DEFUN([LT_PROG_RC],
         7506  +[AC_CHECK_TOOL(RC, windres,)
         7507  +])
         7508  +
         7509  +# Old name:
         7510  +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC])
         7511  +dnl aclocal-1.4 backwards compatibility:
         7512  +dnl AC_DEFUN([LT_AC_PROG_RC], [])
         7513  +
         7514  +
         7515  +# _LT_DECL_EGREP
         7516  +# --------------
         7517  +# If we don't have a new enough Autoconf to choose the best grep
         7518  +# available, choose the one first in the user's PATH.
         7519  +m4_defun([_LT_DECL_EGREP],
         7520  +[AC_REQUIRE([AC_PROG_EGREP])dnl
         7521  +AC_REQUIRE([AC_PROG_FGREP])dnl
         7522  +test -z "$GREP" && GREP=grep
         7523  +_LT_DECL([], [GREP], [1], [A grep program that handles long lines])
         7524  +_LT_DECL([], [EGREP], [1], [An ERE matcher])
         7525  +_LT_DECL([], [FGREP], [1], [A literal string matcher])
         7526  +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too
         7527  +AC_SUBST([GREP])
         7528  +])
         7529  +
         7530  +
         7531  +# _LT_DECL_OBJDUMP
         7532  +# --------------
         7533  +# If we don't have a new enough Autoconf to choose the best objdump
         7534  +# available, choose the one first in the user's PATH.
         7535  +m4_defun([_LT_DECL_OBJDUMP],
         7536  +[AC_CHECK_TOOL(OBJDUMP, objdump, false)
         7537  +test -z "$OBJDUMP" && OBJDUMP=objdump
         7538  +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper])
         7539  +AC_SUBST([OBJDUMP])
         7540  +])
         7541  +
         7542  +# _LT_DECL_DLLTOOL
         7543  +# ----------------
         7544  +# Ensure DLLTOOL variable is set.
         7545  +m4_defun([_LT_DECL_DLLTOOL],
         7546  +[AC_CHECK_TOOL(DLLTOOL, dlltool, false)
         7547  +test -z "$DLLTOOL" && DLLTOOL=dlltool
         7548  +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])
         7549  +AC_SUBST([DLLTOOL])
         7550  +])
         7551  +
         7552  +# _LT_DECL_SED
         7553  +# ------------
         7554  +# Check for a fully-functional sed program, that truncates
         7555  +# as few characters as possible.  Prefer GNU sed if found.
         7556  +m4_defun([_LT_DECL_SED],
         7557  +[AC_PROG_SED
         7558  +test -z "$SED" && SED=sed
         7559  +Xsed="$SED -e 1s/^X//"
         7560  +_LT_DECL([], [SED], [1], [A sed program that does not truncate output])
         7561  +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"],
         7562  +    [Sed that helps us avoid accidentally triggering echo(1) options like -n])
         7563  +])# _LT_DECL_SED
         7564  +
         7565  +m4_ifndef([AC_PROG_SED], [
         7566  +# NOTE: This macro has been submitted for inclusion into   #
         7567  +#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
         7568  +#  a released version of Autoconf we should remove this    #
         7569  +#  macro and use it instead.                               #
         7570  +
         7571  +m4_defun([AC_PROG_SED],
         7572  +[AC_MSG_CHECKING([for a sed that does not truncate output])
         7573  +AC_CACHE_VAL(lt_cv_path_SED,
         7574  +[# Loop through the user's path and test for sed and gsed.
         7575  +# Then use that list of sed's as ones to test for truncation.
         7576  +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
         7577  +for as_dir in $PATH
         7578  +do
         7579  +  IFS=$as_save_IFS
         7580  +  test -z "$as_dir" && as_dir=.
         7581  +  for lt_ac_prog in sed gsed; do
         7582  +    for ac_exec_ext in '' $ac_executable_extensions; do
         7583  +      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
         7584  +        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
         7585  +      fi
         7586  +    done
         7587  +  done
         7588  +done
         7589  +IFS=$as_save_IFS
         7590  +lt_ac_max=0
         7591  +lt_ac_count=0
         7592  +# Add /usr/xpg4/bin/sed as it is typically found on Solaris
         7593  +# along with /bin/sed that truncates output.
         7594  +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
         7595  +  test ! -f $lt_ac_sed && continue
         7596  +  cat /dev/null > conftest.in
         7597  +  lt_ac_count=0
         7598  +  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
         7599  +  # Check for GNU sed and select it if it is found.
         7600  +  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
         7601  +    lt_cv_path_SED=$lt_ac_sed
         7602  +    break
         7603  +  fi
         7604  +  while true; do
         7605  +    cat conftest.in conftest.in >conftest.tmp
         7606  +    mv conftest.tmp conftest.in
         7607  +    cp conftest.in conftest.nl
         7608  +    echo >>conftest.nl
         7609  +    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
         7610  +    cmp -s conftest.out conftest.nl || break
         7611  +    # 10000 chars as input seems more than enough
         7612  +    test $lt_ac_count -gt 10 && break
         7613  +    lt_ac_count=`expr $lt_ac_count + 1`
         7614  +    if test $lt_ac_count -gt $lt_ac_max; then
         7615  +      lt_ac_max=$lt_ac_count
         7616  +      lt_cv_path_SED=$lt_ac_sed
         7617  +    fi
         7618  +  done
         7619  +done
         7620  +])
         7621  +SED=$lt_cv_path_SED
         7622  +AC_SUBST([SED])
         7623  +AC_MSG_RESULT([$SED])
         7624  +])#AC_PROG_SED
         7625  +])#m4_ifndef
         7626  +
         7627  +# Old name:
         7628  +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED])
         7629  +dnl aclocal-1.4 backwards compatibility:
         7630  +dnl AC_DEFUN([LT_AC_PROG_SED], [])
         7631  +
         7632  +
         7633  +# _LT_CHECK_SHELL_FEATURES
         7634  +# ------------------------
         7635  +# Find out whether the shell is Bourne or XSI compatible,
         7636  +# or has some other useful features.
         7637  +m4_defun([_LT_CHECK_SHELL_FEATURES],
         7638  +[AC_MSG_CHECKING([whether the shell understands some XSI constructs])
         7639  +# Try some XSI features
         7640  +xsi_shell=no
         7641  +( _lt_dummy="a/b/c"
         7642  +  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
         7643  +      = c,a/b,b/c, \
         7644  +    && eval 'test $(( 1 + 1 )) -eq 2 \
         7645  +    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
         7646  +  && xsi_shell=yes
         7647  +AC_MSG_RESULT([$xsi_shell])
         7648  +_LT_CONFIG_LIBTOOL_INIT([xsi_shell='$xsi_shell'])
         7649  +
         7650  +AC_MSG_CHECKING([whether the shell understands "+="])
         7651  +lt_shell_append=no
         7652  +( foo=bar; set foo baz; eval "$[1]+=\$[2]" && test "$foo" = barbaz ) \
         7653  +    >/dev/null 2>&1 \
         7654  +  && lt_shell_append=yes
         7655  +AC_MSG_RESULT([$lt_shell_append])
         7656  +_LT_CONFIG_LIBTOOL_INIT([lt_shell_append='$lt_shell_append'])
         7657  +
         7658  +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
         7659  +  lt_unset=unset
         7660  +else
         7661  +  lt_unset=false
         7662  +fi
         7663  +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl
         7664  +
         7665  +# test EBCDIC or ASCII
         7666  +case `echo X|tr X '\101'` in
         7667  + A) # ASCII based system
         7668  +    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
         7669  +  lt_SP2NL='tr \040 \012'
         7670  +  lt_NL2SP='tr \015\012 \040\040'
         7671  +  ;;
         7672  + *) # EBCDIC based system
         7673  +  lt_SP2NL='tr \100 \n'
         7674  +  lt_NL2SP='tr \r\n \100\100'
         7675  +  ;;
         7676  +esac
         7677  +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl
         7678  +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl
         7679  +])# _LT_CHECK_SHELL_FEATURES
         7680  +
         7681  +
         7682  +# _LT_PROG_FUNCTION_REPLACE (FUNCNAME, REPLACEMENT-BODY)
         7683  +# ------------------------------------------------------
         7684  +# In `$cfgfile', look for function FUNCNAME delimited by `^FUNCNAME ()$' and
         7685  +# '^} FUNCNAME ', and replace its body with REPLACEMENT-BODY.
         7686  +m4_defun([_LT_PROG_FUNCTION_REPLACE],
         7687  +[dnl {
         7688  +sed -e '/^$1 ()$/,/^} # $1 /c\
         7689  +$1 ()\
         7690  +{\
         7691  +m4_bpatsubsts([$2], [$], [\\], [^\([	 ]\)], [\\\1])
         7692  +} # Extended-shell $1 implementation' "$cfgfile" > $cfgfile.tmp \
         7693  +  && mv -f "$cfgfile.tmp" "$cfgfile" \
         7694  +    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
         7695  +test 0 -eq $? || _lt_function_replace_fail=:
         7696  +])
         7697  +
         7698  +
         7699  +# _LT_PROG_REPLACE_SHELLFNS
         7700  +# -------------------------
         7701  +# Replace existing portable implementations of several shell functions with
         7702  +# equivalent extended shell implementations where those features are available..
         7703  +m4_defun([_LT_PROG_REPLACE_SHELLFNS],
         7704  +[if test x"$xsi_shell" = xyes; then
         7705  +  _LT_PROG_FUNCTION_REPLACE([func_dirname], [dnl
         7706  +    case ${1} in
         7707  +      */*) func_dirname_result="${1%/*}${2}" ;;
         7708  +      *  ) func_dirname_result="${3}" ;;
         7709  +    esac])
         7710  +
         7711  +  _LT_PROG_FUNCTION_REPLACE([func_basename], [dnl
         7712  +    func_basename_result="${1##*/}"])
         7713  +
         7714  +  _LT_PROG_FUNCTION_REPLACE([func_dirname_and_basename], [dnl
         7715  +    case ${1} in
         7716  +      */*) func_dirname_result="${1%/*}${2}" ;;
         7717  +      *  ) func_dirname_result="${3}" ;;
         7718  +    esac
         7719  +    func_basename_result="${1##*/}"])
         7720  +
         7721  +  _LT_PROG_FUNCTION_REPLACE([func_stripname], [dnl
         7722  +    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
         7723  +    # positional parameters, so assign one to ordinary parameter first.
         7724  +    func_stripname_result=${3}
         7725  +    func_stripname_result=${func_stripname_result#"${1}"}
         7726  +    func_stripname_result=${func_stripname_result%"${2}"}])
         7727  +
         7728  +  _LT_PROG_FUNCTION_REPLACE([func_split_long_opt], [dnl
         7729  +    func_split_long_opt_name=${1%%=*}
         7730  +    func_split_long_opt_arg=${1#*=}])
         7731  +
         7732  +  _LT_PROG_FUNCTION_REPLACE([func_split_short_opt], [dnl
         7733  +    func_split_short_opt_arg=${1#??}
         7734  +    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}])
         7735  +
         7736  +  _LT_PROG_FUNCTION_REPLACE([func_lo2o], [dnl
         7737  +    case ${1} in
         7738  +      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;
         7739  +      *)    func_lo2o_result=${1} ;;
         7740  +    esac])
         7741  +
         7742  +  _LT_PROG_FUNCTION_REPLACE([func_xform], [    func_xform_result=${1%.*}.lo])
         7743  +
         7744  +  _LT_PROG_FUNCTION_REPLACE([func_arith], [    func_arith_result=$(( $[*] ))])
         7745  +
         7746  +  _LT_PROG_FUNCTION_REPLACE([func_len], [    func_len_result=${#1}])
         7747  +fi
         7748  +
         7749  +if test x"$lt_shell_append" = xyes; then
         7750  +  _LT_PROG_FUNCTION_REPLACE([func_append], [    eval "${1}+=\\${2}"])
         7751  +
         7752  +  _LT_PROG_FUNCTION_REPLACE([func_append_quoted], [dnl
         7753  +    func_quote_for_eval "${2}"
         7754  +dnl m4 expansion turns \\\\ into \\, and then the shell eval turns that into \
         7755  +    eval "${1}+=\\\\ \\$func_quote_for_eval_result"])
         7756  +
         7757  +  # Save a `func_append' function call where possible by direct use of '+='
         7758  +  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
         7759  +    && mv -f "$cfgfile.tmp" "$cfgfile" \
         7760  +      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
         7761  +  test 0 -eq $? || _lt_function_replace_fail=:
         7762  +else
         7763  +  # Save a `func_append' function call even when '+=' is not available
         7764  +  sed -e 's%func_append \([[a-zA-Z_]]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
         7765  +    && mv -f "$cfgfile.tmp" "$cfgfile" \
         7766  +      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
         7767  +  test 0 -eq $? || _lt_function_replace_fail=:
         7768  +fi
         7769  +
         7770  +if test x"$_lt_function_replace_fail" = x":"; then
         7771  +  AC_MSG_WARN([Unable to substitute extended shell functions in $ofile])
         7772  +fi
         7773  +])
         7774  +
         7775  +# _LT_PATH_CONVERSION_FUNCTIONS
         7776  +# -----------------------------
         7777  +# Determine which file name conversion functions should be used by
         7778  +# func_to_host_file (and, implicitly, by func_to_host_path).  These are needed
         7779  +# for certain cross-compile configurations and native mingw.
         7780  +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS],
         7781  +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
         7782  +AC_REQUIRE([AC_CANONICAL_BUILD])dnl
         7783  +AC_MSG_CHECKING([how to convert $build file names to $host format])
         7784  +AC_CACHE_VAL(lt_cv_to_host_file_cmd,
         7785  +[case $host in
         7786  +  *-*-mingw* )
         7787  +    case $build in
         7788  +      *-*-mingw* ) # actually msys
         7789  +        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
         7790  +        ;;
         7791  +      *-*-cygwin* )
         7792  +        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
         7793  +        ;;
         7794  +      * ) # otherwise, assume *nix
         7795  +        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
         7796  +        ;;
         7797  +    esac
         7798  +    ;;
         7799  +  *-*-cygwin* )
         7800  +    case $build in
         7801  +      *-*-mingw* ) # actually msys
         7802  +        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
         7803  +        ;;
         7804  +      *-*-cygwin* )
         7805  +        lt_cv_to_host_file_cmd=func_convert_file_noop
         7806  +        ;;
         7807  +      * ) # otherwise, assume *nix
         7808  +        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
         7809  +        ;;
         7810  +    esac
         7811  +    ;;
         7812  +  * ) # unhandled hosts (and "normal" native builds)
         7813  +    lt_cv_to_host_file_cmd=func_convert_file_noop
         7814  +    ;;
         7815  +esac
         7816  +])
         7817  +to_host_file_cmd=$lt_cv_to_host_file_cmd
         7818  +AC_MSG_RESULT([$lt_cv_to_host_file_cmd])
         7819  +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd],
         7820  +         [0], [convert $build file names to $host format])dnl
         7821  +
         7822  +AC_MSG_CHECKING([how to convert $build file names to toolchain format])
         7823  +AC_CACHE_VAL(lt_cv_to_tool_file_cmd,
         7824  +[#assume ordinary cross tools, or native build.
         7825  +lt_cv_to_tool_file_cmd=func_convert_file_noop
         7826  +case $host in
         7827  +  *-*-mingw* )
         7828  +    case $build in
         7829  +      *-*-mingw* ) # actually msys
         7830  +        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
         7831  +        ;;
         7832  +    esac
         7833  +    ;;
         7834  +esac
         7835  +])
         7836  +to_tool_file_cmd=$lt_cv_to_tool_file_cmd
         7837  +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
         7838  +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
         7839  +         [0], [convert $build files to toolchain format])dnl
         7840  +])# _LT_PATH_CONVERSION_FUNCTIONS
         7841  +
         7842  +# Helper functions for option handling.                    -*- Autoconf -*-
         7843  +#
         7844  +#   Copyright (C) 2004, 2005, 2007, 2008, 2009 Free Software Foundation,
         7845  +#   Inc.
         7846  +#   Written by Gary V. Vaughan, 2004
         7847  +#
         7848  +# This file is free software; the Free Software Foundation gives
         7849  +# unlimited permission to copy and/or distribute it, with or without
         7850  +# modifications, as long as this notice is preserved.
         7851  +
         7852  +# serial 7 ltoptions.m4
         7853  +
         7854  +# This is to help aclocal find these macros, as it can't see m4_define.
         7855  +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
         7856  +
         7857  +
         7858  +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME)
         7859  +# ------------------------------------------
         7860  +m4_define([_LT_MANGLE_OPTION],
         7861  +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])])
         7862  +
         7863  +
         7864  +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME)
         7865  +# ---------------------------------------
         7866  +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a
         7867  +# matching handler defined, dispatch to it.  Other OPTION-NAMEs are
         7868  +# saved as a flag.
         7869  +m4_define([_LT_SET_OPTION],
         7870  +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl
         7871  +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]),
         7872  +        _LT_MANGLE_DEFUN([$1], [$2]),
         7873  +    [m4_warning([Unknown $1 option `$2'])])[]dnl
         7874  +])
         7875  +
         7876  +
         7877  +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET])
         7878  +# ------------------------------------------------------------
         7879  +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
         7880  +m4_define([_LT_IF_OPTION],
         7881  +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])])
         7882  +
         7883  +
         7884  +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET)
         7885  +# -------------------------------------------------------
         7886  +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME
         7887  +# are set.
         7888  +m4_define([_LT_UNLESS_OPTIONS],
         7889  +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
         7890  +	    [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option),
         7891  +		      [m4_define([$0_found])])])[]dnl
         7892  +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3
         7893  +])[]dnl
         7894  +])
         7895  +
         7896  +
         7897  +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST)
         7898  +# ----------------------------------------
         7899  +# OPTION-LIST is a space-separated list of Libtool options associated
         7900  +# with MACRO-NAME.  If any OPTION has a matching handler declared with
         7901  +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about
         7902  +# the unknown option and exit.
         7903  +m4_defun([_LT_SET_OPTIONS],
         7904  +[# Set options
         7905  +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])),
         7906  +    [_LT_SET_OPTION([$1], _LT_Option)])
         7907  +
         7908  +m4_if([$1],[LT_INIT],[
         7909  +  dnl
         7910  +  dnl Simply set some default values (i.e off) if boolean options were not
         7911  +  dnl specified:
         7912  +  _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no
         7913  +  ])
         7914  +  _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no
         7915  +  ])
         7916  +  dnl
         7917  +  dnl If no reference was made to various pairs of opposing options, then
         7918  +  dnl we run the default mode handler for the pair.  For example, if neither
         7919  +  dnl `shared' nor `disable-shared' was passed, we enable building of shared
         7920  +  dnl archives by default:
         7921  +  _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED])
         7922  +  _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC])
         7923  +  _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC])
         7924  +  _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install],
         7925  +  		   [_LT_ENABLE_FAST_INSTALL])
         7926  +  ])
         7927  +])# _LT_SET_OPTIONS
         7928  +
         7929  +
         7930  +
         7931  +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME)
         7932  +# -----------------------------------------
         7933  +m4_define([_LT_MANGLE_DEFUN],
         7934  +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])])
         7935  +
         7936  +
         7937  +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE)
         7938  +# -----------------------------------------------
         7939  +m4_define([LT_OPTION_DEFINE],
         7940  +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl
         7941  +])# LT_OPTION_DEFINE
         7942  +
         7943  +
         7944  +# dlopen
         7945  +# ------
         7946  +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes
         7947  +])
         7948  +
         7949  +AU_DEFUN([AC_LIBTOOL_DLOPEN],
         7950  +[_LT_SET_OPTION([LT_INIT], [dlopen])
         7951  +AC_DIAGNOSE([obsolete],
         7952  +[$0: Remove this warning and the call to _LT_SET_OPTION when you
         7953  +put the `dlopen' option into LT_INIT's first parameter.])
         7954  +])
         7955  +
         7956  +dnl aclocal-1.4 backwards compatibility:
         7957  +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], [])
         7958  +
         7959  +
         7960  +# win32-dll
         7961  +# ---------
         7962  +# Declare package support for building win32 dll's.
         7963  +LT_OPTION_DEFINE([LT_INIT], [win32-dll],
         7964  +[enable_win32_dll=yes
         7965  +
         7966  +case $host in
         7967  +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
         7968  +  AC_CHECK_TOOL(AS, as, false)
         7969  +  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
         7970  +  AC_CHECK_TOOL(OBJDUMP, objdump, false)
         7971  +  ;;
         7972  +esac
         7973  +
         7974  +test -z "$AS" && AS=as
         7975  +_LT_DECL([], [AS],      [1], [Assembler program])dnl
         7976  +
         7977  +test -z "$DLLTOOL" && DLLTOOL=dlltool
         7978  +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl
         7979  +
         7980  +test -z "$OBJDUMP" && OBJDUMP=objdump
         7981  +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl
         7982  +])# win32-dll
         7983  +
         7984  +AU_DEFUN([AC_LIBTOOL_WIN32_DLL],
         7985  +[AC_REQUIRE([AC_CANONICAL_HOST])dnl
         7986  +_LT_SET_OPTION([LT_INIT], [win32-dll])
         7987  +AC_DIAGNOSE([obsolete],
         7988  +[$0: Remove this warning and the call to _LT_SET_OPTION when you
         7989  +put the `win32-dll' option into LT_INIT's first parameter.])
         7990  +])
         7991  +
         7992  +dnl aclocal-1.4 backwards compatibility:
         7993  +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], [])
         7994  +
         7995  +
         7996  +# _LT_ENABLE_SHARED([DEFAULT])
         7997  +# ----------------------------
         7998  +# implement the --enable-shared flag, and supports the `shared' and
         7999  +# `disable-shared' LT_INIT options.
         8000  +# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
         8001  +m4_define([_LT_ENABLE_SHARED],
         8002  +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl
         8003  +AC_ARG_ENABLE([shared],
         8004  +    [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
         8005  +	[build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])],
         8006  +    [p=${PACKAGE-default}
         8007  +    case $enableval in
         8008  +    yes) enable_shared=yes ;;
         8009  +    no) enable_shared=no ;;
         8010  +    *)
         8011  +      enable_shared=no
         8012  +      # Look at the argument we got.  We use all the common list separators.
         8013  +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
         8014  +      for pkg in $enableval; do
         8015  +	IFS="$lt_save_ifs"
         8016  +	if test "X$pkg" = "X$p"; then
         8017  +	  enable_shared=yes
         8018  +	fi
         8019  +      done
         8020  +      IFS="$lt_save_ifs"
         8021  +      ;;
         8022  +    esac],
         8023  +    [enable_shared=]_LT_ENABLE_SHARED_DEFAULT)
         8024  +
         8025  +    _LT_DECL([build_libtool_libs], [enable_shared], [0],
         8026  +	[Whether or not to build shared libraries])
         8027  +])# _LT_ENABLE_SHARED
         8028  +
         8029  +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])])
         8030  +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])])
         8031  +
         8032  +# Old names:
         8033  +AC_DEFUN([AC_ENABLE_SHARED],
         8034  +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared])
         8035  +])
         8036  +
         8037  +AC_DEFUN([AC_DISABLE_SHARED],
         8038  +[_LT_SET_OPTION([LT_INIT], [disable-shared])
         8039  +])
         8040  +
         8041  +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)])
         8042  +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
         8043  +
         8044  +dnl aclocal-1.4 backwards compatibility:
         8045  +dnl AC_DEFUN([AM_ENABLE_SHARED], [])
         8046  +dnl AC_DEFUN([AM_DISABLE_SHARED], [])
         8047  +
         8048  +
         8049  +
         8050  +# _LT_ENABLE_STATIC([DEFAULT])
         8051  +# ----------------------------
         8052  +# implement the --enable-static flag, and support the `static' and
         8053  +# `disable-static' LT_INIT options.
         8054  +# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
         8055  +m4_define([_LT_ENABLE_STATIC],
         8056  +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl
         8057  +AC_ARG_ENABLE([static],
         8058  +    [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@],
         8059  +	[build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])],
         8060  +    [p=${PACKAGE-default}
         8061  +    case $enableval in
         8062  +    yes) enable_static=yes ;;
         8063  +    no) enable_static=no ;;
         8064  +    *)
         8065  +     enable_static=no
         8066  +      # Look at the argument we got.  We use all the common list separators.
         8067  +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
         8068  +      for pkg in $enableval; do
         8069  +	IFS="$lt_save_ifs"
         8070  +	if test "X$pkg" = "X$p"; then
         8071  +	  enable_static=yes
         8072  +	fi
         8073  +      done
         8074  +      IFS="$lt_save_ifs"
         8075  +      ;;
         8076  +    esac],
         8077  +    [enable_static=]_LT_ENABLE_STATIC_DEFAULT)
         8078  +
         8079  +    _LT_DECL([build_old_libs], [enable_static], [0],
         8080  +	[Whether or not to build static libraries])
         8081  +])# _LT_ENABLE_STATIC
         8082  +
         8083  +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])])
         8084  +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])])
         8085  +
         8086  +# Old names:
         8087  +AC_DEFUN([AC_ENABLE_STATIC],
         8088  +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static])
         8089  +])
         8090  +
         8091  +AC_DEFUN([AC_DISABLE_STATIC],
         8092  +[_LT_SET_OPTION([LT_INIT], [disable-static])
         8093  +])
         8094  +
         8095  +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)])
         8096  +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
         8097  +
         8098  +dnl aclocal-1.4 backwards compatibility:
         8099  +dnl AC_DEFUN([AM_ENABLE_STATIC], [])
         8100  +dnl AC_DEFUN([AM_DISABLE_STATIC], [])
         8101  +
         8102  +
         8103  +
         8104  +# _LT_ENABLE_FAST_INSTALL([DEFAULT])
         8105  +# ----------------------------------
         8106  +# implement the --enable-fast-install flag, and support the `fast-install'
         8107  +# and `disable-fast-install' LT_INIT options.
         8108  +# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
         8109  +m4_define([_LT_ENABLE_FAST_INSTALL],
         8110  +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl
         8111  +AC_ARG_ENABLE([fast-install],
         8112  +    [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
         8113  +    [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
         8114  +    [p=${PACKAGE-default}
         8115  +    case $enableval in
         8116  +    yes) enable_fast_install=yes ;;
         8117  +    no) enable_fast_install=no ;;
         8118  +    *)
         8119  +      enable_fast_install=no
         8120  +      # Look at the argument we got.  We use all the common list separators.
         8121  +      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
         8122  +      for pkg in $enableval; do
         8123  +	IFS="$lt_save_ifs"
         8124  +	if test "X$pkg" = "X$p"; then
         8125  +	  enable_fast_install=yes
         8126  +	fi
         8127  +      done
         8128  +      IFS="$lt_save_ifs"
         8129  +      ;;
         8130  +    esac],
         8131  +    [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT)
         8132  +
         8133  +_LT_DECL([fast_install], [enable_fast_install], [0],
         8134  +	 [Whether or not to optimize for fast installation])dnl
         8135  +])# _LT_ENABLE_FAST_INSTALL
         8136  +
         8137  +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])])
         8138  +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])])
         8139  +
         8140  +# Old names:
         8141  +AU_DEFUN([AC_ENABLE_FAST_INSTALL],
         8142  +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install])
         8143  +AC_DIAGNOSE([obsolete],
         8144  +[$0: Remove this warning and the call to _LT_SET_OPTION when you put
         8145  +the `fast-install' option into LT_INIT's first parameter.])
         8146  +])
         8147  +
         8148  +AU_DEFUN([AC_DISABLE_FAST_INSTALL],
         8149  +[_LT_SET_OPTION([LT_INIT], [disable-fast-install])
         8150  +AC_DIAGNOSE([obsolete],
         8151  +[$0: Remove this warning and the call to _LT_SET_OPTION when you put
         8152  +the `disable-fast-install' option into LT_INIT's first parameter.])
         8153  +])
         8154  +
         8155  +dnl aclocal-1.4 backwards compatibility:
         8156  +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], [])
         8157  +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
         8158  +
         8159  +
         8160  +# _LT_WITH_PIC([MODE])
         8161  +# --------------------
         8162  +# implement the --with-pic flag, and support the `pic-only' and `no-pic'
         8163  +# LT_INIT options.
         8164  +# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
         8165  +m4_define([_LT_WITH_PIC],
         8166  +[AC_ARG_WITH([pic],
         8167  +    [AS_HELP_STRING([--with-pic],
         8168  +	[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
         8169  +    [pic_mode="$withval"],
         8170  +    [pic_mode=default])
         8171  +
         8172  +test -z "$pic_mode" && pic_mode=m4_default([$1], [default])
         8173  +
         8174  +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
         8175  +])# _LT_WITH_PIC
         8176  +
         8177  +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])])
         8178  +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])])
         8179  +
         8180  +# Old name:
         8181  +AU_DEFUN([AC_LIBTOOL_PICMODE],
         8182  +[_LT_SET_OPTION([LT_INIT], [pic-only])
         8183  +AC_DIAGNOSE([obsolete],
         8184  +[$0: Remove this warning and the call to _LT_SET_OPTION when you
         8185  +put the `pic-only' option into LT_INIT's first parameter.])
         8186  +])
         8187  +
         8188  +dnl aclocal-1.4 backwards compatibility:
         8189  +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], [])
         8190  +
         8191  +
         8192  +m4_define([_LTDL_MODE], [])
         8193  +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive],
         8194  +		 [m4_define([_LTDL_MODE], [nonrecursive])])
         8195  +LT_OPTION_DEFINE([LTDL_INIT], [recursive],
         8196  +		 [m4_define([_LTDL_MODE], [recursive])])
         8197  +LT_OPTION_DEFINE([LTDL_INIT], [subproject],
         8198  +		 [m4_define([_LTDL_MODE], [subproject])])
         8199  +
         8200  +m4_define([_LTDL_TYPE], [])
         8201  +LT_OPTION_DEFINE([LTDL_INIT], [installable],
         8202  +		 [m4_define([_LTDL_TYPE], [installable])])
         8203  +LT_OPTION_DEFINE([LTDL_INIT], [convenience],
         8204  +		 [m4_define([_LTDL_TYPE], [convenience])])
         8205  +
         8206  +# ltsugar.m4 -- libtool m4 base layer.                         -*-Autoconf-*-
         8207  +#
         8208  +# Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc.
         8209  +# Written by Gary V. Vaughan, 2004
         8210  +#
         8211  +# This file is free software; the Free Software Foundation gives
         8212  +# unlimited permission to copy and/or distribute it, with or without
         8213  +# modifications, as long as this notice is preserved.
         8214  +
         8215  +# serial 6 ltsugar.m4
         8216  +
         8217  +# This is to help aclocal find these macros, as it can't see m4_define.
         8218  +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])])
         8219  +
         8220  +
         8221  +# lt_join(SEP, ARG1, [ARG2...])
         8222  +# -----------------------------
         8223  +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their
         8224  +# associated separator.
         8225  +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier
         8226  +# versions in m4sugar had bugs.
         8227  +m4_define([lt_join],
         8228  +[m4_if([$#], [1], [],
         8229  +       [$#], [2], [[$2]],
         8230  +       [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])])
         8231  +m4_define([_lt_join],
         8232  +[m4_if([$#$2], [2], [],
         8233  +       [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])])
         8234  +
         8235  +
         8236  +# lt_car(LIST)
         8237  +# lt_cdr(LIST)
         8238  +# ------------
         8239  +# Manipulate m4 lists.
         8240  +# These macros are necessary as long as will still need to support
         8241  +# Autoconf-2.59 which quotes differently.
         8242  +m4_define([lt_car], [[$1]])
         8243  +m4_define([lt_cdr],
         8244  +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])],
         8245  +       [$#], 1, [],
         8246  +       [m4_dquote(m4_shift($@))])])
         8247  +m4_define([lt_unquote], $1)
         8248  +
         8249  +
         8250  +# lt_append(MACRO-NAME, STRING, [SEPARATOR])
         8251  +# ------------------------------------------
         8252  +# Redefine MACRO-NAME to hold its former content plus `SEPARATOR'`STRING'.
         8253  +# Note that neither SEPARATOR nor STRING are expanded; they are appended
         8254  +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked).
         8255  +# No SEPARATOR is output if MACRO-NAME was previously undefined (different
         8256  +# than defined and empty).
         8257  +#
         8258  +# This macro is needed until we can rely on Autoconf 2.62, since earlier
         8259  +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING.
         8260  +m4_define([lt_append],
         8261  +[m4_define([$1],
         8262  +	   m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])])
         8263  +
         8264  +
         8265  +
         8266  +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...])
         8267  +# ----------------------------------------------------------
         8268  +# Produce a SEP delimited list of all paired combinations of elements of
         8269  +# PREFIX-LIST with SUFFIX1 through SUFFIXn.  Each element of the list
         8270  +# has the form PREFIXmINFIXSUFFIXn.
         8271  +# Needed until we can rely on m4_combine added in Autoconf 2.62.
         8272  +m4_define([lt_combine],
         8273  +[m4_if(m4_eval([$# > 3]), [1],
         8274  +       [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl
         8275  +[[m4_foreach([_Lt_prefix], [$2],
         8276  +	     [m4_foreach([_Lt_suffix],
         8277  +		]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[,
         8278  +	[_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])])
         8279  +
         8280  +
         8281  +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ])
         8282  +# -----------------------------------------------------------------------
         8283  +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited
         8284  +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ.
         8285  +m4_define([lt_if_append_uniq],
         8286  +[m4_ifdef([$1],
         8287  +	  [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1],
         8288  +		 [lt_append([$1], [$2], [$3])$4],
         8289  +		 [$5])],
         8290  +	  [lt_append([$1], [$2], [$3])$4])])
         8291  +
         8292  +
         8293  +# lt_dict_add(DICT, KEY, VALUE)
         8294  +# -----------------------------
         8295  +m4_define([lt_dict_add],
         8296  +[m4_define([$1($2)], [$3])])
         8297  +
         8298  +
         8299  +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE)
         8300  +# --------------------------------------------
         8301  +m4_define([lt_dict_add_subkey],
         8302  +[m4_define([$1($2:$3)], [$4])])
         8303  +
         8304  +
         8305  +# lt_dict_fetch(DICT, KEY, [SUBKEY])
         8306  +# ----------------------------------
         8307  +m4_define([lt_dict_fetch],
         8308  +[m4_ifval([$3],
         8309  +	m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]),
         8310  +    m4_ifdef([$1($2)], [m4_defn([$1($2)])]))])
         8311  +
         8312  +
         8313  +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE])
         8314  +# -----------------------------------------------------------------
         8315  +m4_define([lt_if_dict_fetch],
         8316  +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4],
         8317  +	[$5],
         8318  +    [$6])])
         8319  +
         8320  +
         8321  +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...])
         8322  +# --------------------------------------------------------------
         8323  +m4_define([lt_dict_filter],
         8324  +[m4_if([$5], [], [],
         8325  +  [lt_join(m4_quote(m4_default([$4], [[, ]])),
         8326  +           lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]),
         8327  +		      [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl
         8328  +])
         8329  +
         8330  +# ltversion.m4 -- version numbers			-*- Autoconf -*-
         8331  +#
         8332  +#   Copyright (C) 2004 Free Software Foundation, Inc.
         8333  +#   Written by Scott James Remnant, 2004
         8334  +#
         8335  +# This file is free software; the Free Software Foundation gives
         8336  +# unlimited permission to copy and/or distribute it, with or without
         8337  +# modifications, as long as this notice is preserved.
         8338  +
         8339  +# @configure_input@
         8340  +
         8341  +# serial 3293 ltversion.m4
         8342  +# This file is part of GNU Libtool
         8343  +
         8344  +m4_define([LT_PACKAGE_VERSION], [2.4])
         8345  +m4_define([LT_PACKAGE_REVISION], [1.3293])
         8346  +
         8347  +AC_DEFUN([LTVERSION_VERSION],
         8348  +[macro_version='2.4'
         8349  +macro_revision='1.3293'
         8350  +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
         8351  +_LT_DECL(, macro_revision, 0)
         8352  +])
         8353  +
         8354  +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions.    -*-Autoconf-*-
         8355  +#
         8356  +#   Copyright (C) 2004, 2005, 2007, 2009 Free Software Foundation, Inc.
         8357  +#   Written by Scott James Remnant, 2004.
         8358  +#
         8359  +# This file is free software; the Free Software Foundation gives
         8360  +# unlimited permission to copy and/or distribute it, with or without
         8361  +# modifications, as long as this notice is preserved.
         8362  +
         8363  +# serial 5 lt~obsolete.m4
         8364  +
         8365  +# These exist entirely to fool aclocal when bootstrapping libtool.
         8366  +#
         8367  +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN)
         8368  +# which have later been changed to m4_define as they aren't part of the
         8369  +# exported API, or moved to Autoconf or Automake where they belong.
         8370  +#
         8371  +# The trouble is, aclocal is a bit thick.  It'll see the old AC_DEFUN
         8372  +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us
         8373  +# using a macro with the same name in our local m4/libtool.m4 it'll
         8374  +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define
         8375  +# and doesn't know about Autoconf macros at all.)
         8376  +#
         8377  +# So we provide this file, which has a silly filename so it's always
         8378  +# included after everything else.  This provides aclocal with the
         8379  +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything
         8380  +# because those macros already exist, or will be overwritten later.
         8381  +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. 
         8382  +#
         8383  +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here.
         8384  +# Yes, that means every name once taken will need to remain here until
         8385  +# we give up compatibility with versions before 1.7, at which point
         8386  +# we need to keep only those names which we still refer to.
         8387  +
         8388  +# This is to help aclocal find these macros, as it can't see m4_define.
         8389  +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])])
         8390  +
         8391  +m4_ifndef([AC_LIBTOOL_LINKER_OPTION],	[AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])])
         8392  +m4_ifndef([AC_PROG_EGREP],		[AC_DEFUN([AC_PROG_EGREP])])
         8393  +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])])
         8394  +m4_ifndef([_LT_AC_SHELL_INIT],		[AC_DEFUN([_LT_AC_SHELL_INIT])])
         8395  +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX],	[AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])])
         8396  +m4_ifndef([_LT_PROG_LTMAIN],		[AC_DEFUN([_LT_PROG_LTMAIN])])
         8397  +m4_ifndef([_LT_AC_TAGVAR],		[AC_DEFUN([_LT_AC_TAGVAR])])
         8398  +m4_ifndef([AC_LTDL_ENABLE_INSTALL],	[AC_DEFUN([AC_LTDL_ENABLE_INSTALL])])
         8399  +m4_ifndef([AC_LTDL_PREOPEN],		[AC_DEFUN([AC_LTDL_PREOPEN])])
         8400  +m4_ifndef([_LT_AC_SYS_COMPILER],	[AC_DEFUN([_LT_AC_SYS_COMPILER])])
         8401  +m4_ifndef([_LT_AC_LOCK],		[AC_DEFUN([_LT_AC_LOCK])])
         8402  +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE],	[AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])])
         8403  +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF],	[AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])])
         8404  +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O],	[AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])])
         8405  +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])])
         8406  +m4_ifndef([AC_LIBTOOL_OBJDIR],		[AC_DEFUN([AC_LIBTOOL_OBJDIR])])
         8407  +m4_ifndef([AC_LTDL_OBJDIR],		[AC_DEFUN([AC_LTDL_OBJDIR])])
         8408  +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])])
         8409  +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP],	[AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])])
         8410  +m4_ifndef([AC_PATH_MAGIC],		[AC_DEFUN([AC_PATH_MAGIC])])
         8411  +m4_ifndef([AC_PROG_LD_GNU],		[AC_DEFUN([AC_PROG_LD_GNU])])
         8412  +m4_ifndef([AC_PROG_LD_RELOAD_FLAG],	[AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])])
         8413  +m4_ifndef([AC_DEPLIBS_CHECK_METHOD],	[AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])])
         8414  +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])])
         8415  +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])])
         8416  +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])])
         8417  +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS],	[AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])])
         8418  +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP],	[AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])])
         8419  +m4_ifndef([LT_AC_PROG_EGREP],		[AC_DEFUN([LT_AC_PROG_EGREP])])
         8420  +m4_ifndef([LT_AC_PROG_SED],		[AC_DEFUN([LT_AC_PROG_SED])])
         8421  +m4_ifndef([_LT_CC_BASENAME],		[AC_DEFUN([_LT_CC_BASENAME])])
         8422  +m4_ifndef([_LT_COMPILER_BOILERPLATE],	[AC_DEFUN([_LT_COMPILER_BOILERPLATE])])
         8423  +m4_ifndef([_LT_LINKER_BOILERPLATE],	[AC_DEFUN([_LT_LINKER_BOILERPLATE])])
         8424  +m4_ifndef([_AC_PROG_LIBTOOL],		[AC_DEFUN([_AC_PROG_LIBTOOL])])
         8425  +m4_ifndef([AC_LIBTOOL_SETUP],		[AC_DEFUN([AC_LIBTOOL_SETUP])])
         8426  +m4_ifndef([_LT_AC_CHECK_DLFCN],		[AC_DEFUN([_LT_AC_CHECK_DLFCN])])
         8427  +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER],	[AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])])
         8428  +m4_ifndef([_LT_AC_TAGCONFIG],		[AC_DEFUN([_LT_AC_TAGCONFIG])])
         8429  +m4_ifndef([AC_DISABLE_FAST_INSTALL],	[AC_DEFUN([AC_DISABLE_FAST_INSTALL])])
         8430  +m4_ifndef([_LT_AC_LANG_CXX],		[AC_DEFUN([_LT_AC_LANG_CXX])])
         8431  +m4_ifndef([_LT_AC_LANG_F77],		[AC_DEFUN([_LT_AC_LANG_F77])])
         8432  +m4_ifndef([_LT_AC_LANG_GCJ],		[AC_DEFUN([_LT_AC_LANG_GCJ])])
         8433  +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])])
         8434  +m4_ifndef([_LT_AC_LANG_C_CONFIG],	[AC_DEFUN([_LT_AC_LANG_C_CONFIG])])
         8435  +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])])
         8436  +m4_ifndef([_LT_AC_LANG_CXX_CONFIG],	[AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])])
         8437  +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])])
         8438  +m4_ifndef([_LT_AC_LANG_F77_CONFIG],	[AC_DEFUN([_LT_AC_LANG_F77_CONFIG])])
         8439  +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])])
         8440  +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG],	[AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])])
         8441  +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG],	[AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])])
         8442  +m4_ifndef([_LT_AC_LANG_RC_CONFIG],	[AC_DEFUN([_LT_AC_LANG_RC_CONFIG])])
         8443  +m4_ifndef([AC_LIBTOOL_CONFIG],		[AC_DEFUN([AC_LIBTOOL_CONFIG])])
         8444  +m4_ifndef([_LT_AC_FILE_LTDLL_C],	[AC_DEFUN([_LT_AC_FILE_LTDLL_C])])
         8445  +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS],	[AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])])
         8446  +m4_ifndef([_LT_AC_PROG_CXXCPP],		[AC_DEFUN([_LT_AC_PROG_CXXCPP])])
         8447  +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS],	[AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])])
         8448  +m4_ifndef([_LT_PROG_ECHO_BACKSLASH],	[AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])])
         8449  +m4_ifndef([_LT_PROG_F77],		[AC_DEFUN([_LT_PROG_F77])])
         8450  +m4_ifndef([_LT_PROG_FC],		[AC_DEFUN([_LT_PROG_FC])])
         8451  +m4_ifndef([_LT_PROG_CXX],		[AC_DEFUN([_LT_PROG_CXX])])
    21   8452   
    22   8453   # pkg.m4 - Macros to locate and utilise pkg-config.            -*- Autoconf -*-
    23   8454   # serial 1 (pkg-config-0.24)
    24   8455   # 
    25   8456   # Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
    26   8457   #
    27   8458   # This program is free software; you can redistribute it and/or modify
................................................................................
  1155   9586   
  1156   9587   AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
  1157   9588   AC_MSG_RESULT([$am_cv_prog_tar_$1])])
  1158   9589   AC_SUBST([am__tar])
  1159   9590   AC_SUBST([am__untar])
  1160   9591   ]) # _AM_PROG_TAR
  1161   9592   
  1162         -m4_include([m4/libtool.m4])
  1163         -m4_include([m4/ltoptions.m4])
  1164         -m4_include([m4/ltsugar.m4])
  1165         -m4_include([m4/ltversion.m4])
  1166         -m4_include([m4/lt~obsolete.m4])

Changes to config.h.

     1      1   /* config.h.  Generated from config.h.in by configure.  */
     2      2   /* config.h.in.  Generated from configure.ac by autoheader.  */
     3      3   
     4      4   /* Define to 1 if you have the <dlfcn.h> header file. */
     5      5   #define HAVE_DLFCN_H 1
     6      6   
     7         -/* Define to 1 if you have the <expat.h> header file. */
     8         -#define HAVE_EXPAT_H 1
     9         -
    10      7   /* Define to 1 if you have the <fcntl.h> header file. */
    11      8   #define HAVE_FCNTL_H 1
    12      9   
    13     10   /* Define to 1 if you have the `fdatasync' function. */
    14     11   #define HAVE_FDATASYNC 1
    15     12   
    16     13   /* Define to 1 if you have the <float.h> header file. */
................................................................................
   125    122   /* Define to the address where bug reports for this package should be sent. */
   126    123   #define PACKAGE_BUGREPORT "a.furieri@lqt.it"
   127    124   
   128    125   /* Define to the full name of this package. */
   129    126   #define PACKAGE_NAME "spatialite-tools"
   130    127   
   131    128   /* Define to the full name and version of this package. */
   132         -#define PACKAGE_STRING "spatialite-tools 3.0.1"
          129  +#define PACKAGE_STRING "spatialite-tools 3.1.0"
   133    130   
   134    131   /* Define to the one symbol short name of this package. */
   135    132   #define PACKAGE_TARNAME "spatialite-tools"
   136    133   
   137    134   /* Define to the home page for this package. */
   138    135   #define PACKAGE_URL ""
   139    136   
   140    137   /* Define to the version of this package. */
   141         -#define PACKAGE_VERSION "3.0.1"
          138  +#define PACKAGE_VERSION "3.1.0"
   142    139   
   143    140   /* Define to 1 if you have the ANSI C header files. */
   144    141   #define STDC_HEADERS 1
   145    142   
   146    143   /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
   147    144   #define TIME_WITH_SYS_TIME 1
   148    145   
   149    146   /* Define to 1 if your <sys/time.h> declares `struct tm'. */
   150    147   /* #undef TM_IN_SYS_TIME */
   151    148   
   152    149   /* Version number of package */
   153         -#define VERSION "3.0.1"
          150  +#define VERSION "3.1.0"
   154    151   
   155    152   /* Define to empty if `const' does not conform to ANSI C. */
   156    153   /* #undef const */
   157    154   
   158    155   /* Define to `long int' if <sys/types.h> does not define. */
   159    156   /* #undef off_t */
   160    157   
   161    158   /* Define to `unsigned int' if <sys/types.h> does not define. */
   162    159   /* #undef size_t */
   163    160   
   164    161   /* Define to empty if the keyword `volatile' does not work. Warning: valid
   165    162      code using `volatile' can become incorrect without. Disable with care. */
   166    163   /* #undef volatile */

Changes to config.h.in.

     1      1   /* config.h.in.  Generated from configure.ac by autoheader.  */
     2      2   
     3      3   /* Define to 1 if you have the <dlfcn.h> header file. */
     4      4   #undef HAVE_DLFCN_H
     5      5   
     6         -/* Define to 1 if you have the <expat.h> header file. */
     7         -#undef HAVE_EXPAT_H
     8         -
     9      6   /* Define to 1 if you have the <fcntl.h> header file. */
    10      7   #undef HAVE_FCNTL_H
    11      8   
    12      9   /* Define to 1 if you have the `fdatasync' function. */
    13     10   #undef HAVE_FDATASYNC
    14     11   
    15     12   /* Define to 1 if you have the <float.h> header file. */

Changes to configure.

     1      1   #! /bin/sh
     2      2   # Guess values for system-dependent variables and create Makefiles.
     3         -# Generated by GNU Autoconf 2.68 for spatialite-tools 3.0.1.
            3  +# Generated by GNU Autoconf 2.68 for spatialite-tools 3.1.0.
     4      4   #
     5      5   # Report bugs to <a.furieri@lqt.it>.
     6      6   #
     7      7   #
     8      8   # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
     9      9   # 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software
    10     10   # Foundation, Inc.
................................................................................
   566    566   subdirs=
   567    567   MFLAGS=
   568    568   MAKEFLAGS=
   569    569   
   570    570   # Identity of this package.
   571    571   PACKAGE_NAME='spatialite-tools'
   572    572   PACKAGE_TARNAME='spatialite-tools'
   573         -PACKAGE_VERSION='3.0.1'
   574         -PACKAGE_STRING='spatialite-tools 3.0.1'
          573  +PACKAGE_VERSION='3.1.0'
          574  +PACKAGE_STRING='spatialite-tools 3.1.0'
   575    575   PACKAGE_BUGREPORT='a.furieri@lqt.it'
   576    576   PACKAGE_URL=''
   577    577   
   578    578   # Factoring default headers for most tests.
   579    579   ac_includes_default="\
   580    580   #include <stdio.h>
   581    581   #ifdef HAVE_SYS_TYPES_H
................................................................................
   610    610   #ifdef HAVE_UNISTD_H
   611    611   # include <unistd.h>
   612    612   #endif"
   613    613   
   614    614   ac_subst_vars='am__EXEEXT_FALSE
   615    615   am__EXEEXT_TRUE
   616    616   LTLIBOBJS
          617  +LIBREADOSM_CFLAGS
          618  +LIBREADOSM_LIBS
   617    619   LIBFREEXL_LIBS
   618    620   LIBFREEXL_CFLAGS
   619    621   LIBSPATIALITE_LIBS
   620    622   LIBSPATIALITE_CFLAGS
   621    623   PKG_CONFIG_LIBDIR
   622    624   PKG_CONFIG_PATH
   623    625   PKG_CONFIG
................................................................................
   774    776   CXXCPP
   775    777   PKG_CONFIG
   776    778   PKG_CONFIG_PATH
   777    779   PKG_CONFIG_LIBDIR
   778    780   LIBSPATIALITE_CFLAGS
   779    781   LIBSPATIALITE_LIBS
   780    782   LIBFREEXL_CFLAGS
   781         -LIBFREEXL_LIBS'
          783  +LIBFREEXL_LIBS
          784  +LIBREADOSM_CFLAGS
          785  +LIBREADOSM_LIBS'
   782    786   
   783    787   
   784    788   # Initialize some variables set by options.
   785    789   ac_init_help=
   786    790   ac_init_version=false
   787    791   ac_unrecognized_opts=
   788    792   ac_unrecognized_sep=
................................................................................
  1317   1321   #
  1318   1322   # Report the --help message.
  1319   1323   #
  1320   1324   if test "$ac_init_help" = "long"; then
  1321   1325     # Omit some internal or obsolete options to make the list less imposing.
  1322   1326     # This message is too long to be a string in the A/UX 3.1 sh.
  1323   1327     cat <<_ACEOF
  1324         -\`configure' configures spatialite-tools 3.0.1 to adapt to many kinds of systems.
         1328  +\`configure' configures spatialite-tools 3.1.0 to adapt to many kinds of systems.
  1325   1329   
  1326   1330   Usage: $0 [OPTION]... [VAR=VALUE]...
  1327   1331   
  1328   1332   To assign environment variables (e.g., CC, CFLAGS...), specify them as
  1329   1333   VAR=VALUE.  See below for descriptions of some of the useful variables.
  1330   1334   
  1331   1335   Defaults for the options are specified in brackets.
................................................................................
  1388   1392     --build=BUILD     configure for building on BUILD [guessed]
  1389   1393     --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  1390   1394   _ACEOF
  1391   1395   fi
  1392   1396   
  1393   1397   if test -n "$ac_init_help"; then
  1394   1398     case $ac_init_help in
  1395         -     short | recursive ) echo "Configuration of spatialite-tools 3.0.1:";;
         1399  +     short | recursive ) echo "Configuration of spatialite-tools 3.1.0:";;
  1396   1400      esac
  1397   1401     cat <<\_ACEOF
  1398   1402   
  1399   1403   Optional Features:
  1400   1404     --disable-option-checking  ignore unrecognized --enable/--with options
  1401   1405     --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  1402   1406     --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
................................................................................
  1442   1446                 C compiler flags for LIBSPATIALITE, overriding pkg-config
  1443   1447     LIBSPATIALITE_LIBS
  1444   1448                 linker flags for LIBSPATIALITE, overriding pkg-config
  1445   1449     LIBFREEXL_CFLAGS
  1446   1450                 C compiler flags for LIBFREEXL, overriding pkg-config
  1447   1451     LIBFREEXL_LIBS
  1448   1452                 linker flags for LIBFREEXL, overriding pkg-config
         1453  +  LIBREADOSM_CFLAGS
         1454  +              C compiler flags for LIBREADOSM, overriding pkg-config
         1455  +  LIBREADOSM_LIBS
         1456  +              linker flags for LIBREADOSM, overriding pkg-config
  1449   1457   
  1450   1458   Use these variables to override the choices made by `configure' or to help
  1451   1459   it to find libraries and programs with nonstandard names/locations.
  1452   1460   
  1453   1461   Report bugs to <a.furieri@lqt.it>.
  1454   1462   _ACEOF
  1455   1463   ac_status=$?
................................................................................
  1509   1517       cd "$ac_pwd" || { ac_status=$?; break; }
  1510   1518     done
  1511   1519   fi
  1512   1520   
  1513   1521   test -n "$ac_init_help" && exit $ac_status
  1514   1522   if $ac_init_version; then
  1515   1523     cat <<\_ACEOF
  1516         -spatialite-tools configure 3.0.1
         1524  +spatialite-tools configure 3.1.0
  1517   1525   generated by GNU Autoconf 2.68
  1518   1526   
  1519   1527   Copyright (C) 2010 Free Software Foundation, Inc.
  1520   1528   This configure script is free software; the Free Software Foundation
  1521   1529   gives unlimited permission to copy, distribute and modify it.
  1522   1530   _ACEOF
  1523   1531     exit
................................................................................
  2053   2061     eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
  2054   2062   
  2055   2063   } # ac_fn_c_check_type
  2056   2064   cat >config.log <<_ACEOF
  2057   2065   This file contains any messages produced by compilers while
  2058   2066   running configure, to aid debugging if configure makes a mistake.
  2059   2067   
  2060         -It was created by spatialite-tools $as_me 3.0.1, which was
         2068  +It was created by spatialite-tools $as_me 3.1.0, which was
  2061   2069   generated by GNU Autoconf 2.68.  Invocation command line was
  2062   2070   
  2063   2071     $ $0 $@
  2064   2072   
  2065   2073   _ACEOF
  2066   2074   exec 5>>config.log
  2067   2075   {
................................................................................
  2876   2884       CYGPATH_W=echo
  2877   2885     fi
  2878   2886   fi
  2879   2887   
  2880   2888   
  2881   2889   # Define the identity of the package.
  2882   2890    PACKAGE='spatialite-tools'
  2883         - VERSION='3.0.1'
         2891  + VERSION='3.1.0'
  2884   2892   
  2885   2893   
  2886   2894   cat >>confdefs.h <<_ACEOF
  2887   2895   #define PACKAGE "$PACKAGE"
  2888   2896   _ACEOF
  2889   2897   
  2890   2898   
................................................................................
  4486   4494   #define HAVE_UNISTD_H 1
  4487   4495   _ACEOF
  4488   4496   
  4489   4497   else
  4490   4498     as_fn_error $? "cannot find unistd.h, bailing out" "$LINENO" 5
  4491   4499   fi
  4492   4500   
  4493         -done
  4494         -
  4495         -for ac_header in expat.h
  4496         -do :
  4497         -  ac_fn_c_check_header_mongrel "$LINENO" "expat.h" "ac_cv_header_expat_h" "$ac_includes_default"
  4498         -if test "x$ac_cv_header_expat_h" = xyes; then :
  4499         -  cat >>confdefs.h <<_ACEOF
  4500         -#define HAVE_EXPAT_H 1
  4501         -_ACEOF
  4502         -
  4503         -else
  4504         -  as_fn_error $? "cannot find expat.h, bailing out" "$LINENO" 5
  4505         -fi
  4506         -
  4507   4501   done
  4508   4502   
  4509   4503   
  4510   4504   # Checks for programs.
  4511   4505   ac_ext=cpp
  4512   4506   ac_cpp='$CXXCPP $CPPFLAGS'
  4513   4507   ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
................................................................................
  9623   9617   ac_outfile=conftest.$ac_objext
  9624   9618   echo "$lt_simple_link_test_code" >conftest.$ac_ext
  9625   9619   eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
  9626   9620   _lt_linker_boilerplate=`cat conftest.err`
  9627   9621   $RM -r conftest*
  9628   9622   
  9629   9623   
  9630         -## CAVEAT EMPTOR:
  9631         -## There is no encapsulation within the following macros, do not change
  9632         -## the running order or otherwise move them around unless you know exactly
  9633         -## what you are doing...
  9634   9624   if test -n "$compiler"; then
  9635   9625   
  9636   9626   lt_prog_compiler_no_builtin_flag=
  9637   9627   
  9638   9628   if test "$GCC" = yes; then
  9639   9629     case $cc_basename in
  9640   9630     nvcc*)
................................................................................
 17572  17562   	LIBFREEXL_LIBS=$pkg_cv_LIBFREEXL_LIBS
 17573  17563           { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 17574  17564   $as_echo "yes" >&6; }
 17575  17565   
 17576  17566   fi
 17577  17567   
 17578  17568   
        17569  +pkg_failed=no
        17570  +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for LIBREADOSM" >&5
        17571  +$as_echo_n "checking for LIBREADOSM... " >&6; }
        17572  +
        17573  +if test -n "$LIBREADOSM_CFLAGS"; then
        17574  +    pkg_cv_LIBREADOSM_CFLAGS="$LIBREADOSM_CFLAGS"
        17575  + elif test -n "$PKG_CONFIG"; then
        17576  +    if test -n "$PKG_CONFIG" && \
        17577  +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"readosm\""; } >&5
        17578  +  ($PKG_CONFIG --exists --print-errors "readosm") 2>&5
        17579  +  ac_status=$?
        17580  +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
        17581  +  test $ac_status = 0; }; then
        17582  +  pkg_cv_LIBREADOSM_CFLAGS=`$PKG_CONFIG --cflags "readosm" 2>/dev/null`
        17583  +else
        17584  +  pkg_failed=yes
        17585  +fi
        17586  + else
        17587  +    pkg_failed=untried
        17588  +fi
        17589  +if test -n "$LIBREADOSM_LIBS"; then
        17590  +    pkg_cv_LIBREADOSM_LIBS="$LIBREADOSM_LIBS"
        17591  + elif test -n "$PKG_CONFIG"; then
        17592  +    if test -n "$PKG_CONFIG" && \
        17593  +    { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"readosm\""; } >&5
        17594  +  ($PKG_CONFIG --exists --print-errors "readosm") 2>&5
        17595  +  ac_status=$?
        17596  +  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
        17597  +  test $ac_status = 0; }; then
        17598  +  pkg_cv_LIBREADOSM_LIBS=`$PKG_CONFIG --libs "readosm" 2>/dev/null`
        17599  +else
        17600  +  pkg_failed=yes
        17601  +fi
        17602  + else
        17603  +    pkg_failed=untried
        17604  +fi
        17605  +
        17606  +
        17607  +
        17608  +if test $pkg_failed = yes; then
        17609  +   	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
        17610  +$as_echo "no" >&6; }
        17611  +
        17612  +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
        17613  +        _pkg_short_errors_supported=yes
        17614  +else
        17615  +        _pkg_short_errors_supported=no
        17616  +fi
        17617  +        if test $_pkg_short_errors_supported = yes; then
        17618  +	        LIBREADOSM_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "readosm" 2>&1`
        17619  +        else
        17620  +	        LIBREADOSM_PKG_ERRORS=`$PKG_CONFIG --print-errors "readosm" 2>&1`
        17621  +        fi
        17622  +	# Put the nasty error message in config.log where it belongs
        17623  +	echo "$LIBREADOSM_PKG_ERRORS" >&5
        17624  +
        17625  +	as_fn_error $? "'libreadosm' is required but it doesn't seem to be installed on this system." "$LINENO" 5
        17626  +elif test $pkg_failed = untried; then
        17627  +     	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
        17628  +$as_echo "no" >&6; }
        17629  +	as_fn_error $? "'libreadosm' is required but it doesn't seem to be installed on this system." "$LINENO" 5
        17630  +else
        17631  +	LIBREADOSM_CFLAGS=$pkg_cv_LIBREADOSM_CFLAGS
        17632  +	LIBREADOSM_LIBS=$pkg_cv_LIBREADOSM_LIBS
        17633  +        { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
        17634  +$as_echo "yes" >&6; }
        17635  +
        17636  +fi
        17637  +
        17638  +
 17579  17639   
 17580  17640   cat >confcache <<\_ACEOF
 17581  17641   # This file is a shell script that caches the results of configure
 17582  17642   # tests run on this system so they can be shared between configure
 17583  17643   # scripts and configure runs, see configure's option --config-cache.
 17584  17644   # It is not useful on other systems.  If it contains results you don't
 17585  17645   # want to keep, you may remove or edit it.
................................................................................
 18119  18179   test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
 18120  18180   
 18121  18181   cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 18122  18182   # Save the log message, to keep $0 and so on meaningful, and to
 18123  18183   # report actual input values of CONFIG_FILES etc. instead of their
 18124  18184   # values after options handling.
 18125  18185   ac_log="
 18126         -This file was extended by spatialite-tools $as_me 3.0.1, which was
        18186  +This file was extended by spatialite-tools $as_me 3.1.0, which was
 18127  18187   generated by GNU Autoconf 2.68.  Invocation command line was
 18128  18188   
 18129  18189     CONFIG_FILES    = $CONFIG_FILES
 18130  18190     CONFIG_HEADERS  = $CONFIG_HEADERS
 18131  18191     CONFIG_LINKS    = $CONFIG_LINKS
 18132  18192     CONFIG_COMMANDS = $CONFIG_COMMANDS
 18133  18193     $ $0 $@
................................................................................
 18185  18245   
 18186  18246   Report bugs to <a.furieri@lqt.it>."
 18187  18247   
 18188  18248   _ACEOF
 18189  18249   cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 18190  18250   ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 18191  18251   ac_cs_version="\\
 18192         -spatialite-tools config.status 3.0.1
        18252  +spatialite-tools config.status 3.1.0
 18193  18253   configured by $0, generated by GNU Autoconf 2.68,
 18194  18254     with options \\"\$ac_cs_config\\"
 18195  18255   
 18196  18256   Copyright (C) 2010 Free Software Foundation, Inc.
 18197  18257   This config.status script is free software; the Free Software Foundation
 18198  18258   gives unlimited permission to copy, distribute and modify it."
 18199  18259   

Changes to configure.ac.

     1      1   #                                               -*- Autoconf -*-
     2      2   # Process this file with autoconf to produce a configure script.
     3      3   
     4      4   AC_PREREQ(2.61)
     5         -AC_INIT(spatialite-tools, 3.0.1, a.furieri@lqt.it)
            5  +AC_INIT(spatialite-tools, 3.1.0, a.furieri@lqt.it)
     6      6   AC_LANG(C)
     7      7   AC_CONFIG_MACRO_DIR([m4])
     8      8   
     9      9   AM_INIT_AUTOMAKE
    10     10   AM_MAINTAINER_MODE
    11     11   AM_CONFIG_HEADER(config.h)
    12     12   
................................................................................
    19     19   AC_CHECK_HEADERS(float.h,, [AC_MSG_ERROR([cannot find float.h, bailing out])])
    20     20   AC_CHECK_HEADERS(fcntl.h,, [AC_MSG_ERROR([cannot find fcntl.h, bailing out])])
    21     21   AC_CHECK_HEADERS(inttypes.h,, [AC_MSG_ERROR([cannot find inttypes.h, bailing out])])
    22     22   AC_CHECK_HEADERS(stddef.h,, [AC_MSG_ERROR([cannot find stddef.h, bailing out])])
    23     23   AC_CHECK_HEADERS(stdint.h,, [AC_MSG_ERROR([cannot find stdint.h, bailing out])])
    24     24   AC_CHECK_HEADERS(sys/time.h,, [AC_MSG_ERROR([cannot find sys/time.h, bailing out])])
    25     25   AC_CHECK_HEADERS(unistd.h,, [AC_MSG_ERROR([cannot find unistd.h, bailing out])])
    26         -AC_CHECK_HEADERS(expat.h,, [AC_MSG_ERROR([cannot find expat.h, bailing out])])
    27     26   
    28     27   # Checks for programs.
    29     28   AC_PROG_CXX
    30     29   AC_PROG_CC
    31     30   AC_PROG_CPP
    32     31   AC_PROG_INSTALL
    33     32   AC_PROG_LN_S
................................................................................
   116    115   LIBS="$LIBS_SAVE"
   117    116   
   118    117   PKG_CHECK_MODULES([LIBSPATIALITE], [spatialite], , AC_MSG_ERROR(['libspatialite' is required but it doesn't seem to be installed on this system.]))
   119    118   AC_SUBST(LIBSPATIALITE_CFLAGS)
   120    119   AC_SUBST(LIBSPATIALITE_LIBS)
   121    120   PKG_CHECK_MODULES([LIBFREEXL], [freexl], , AC_MSG_ERROR(['libfreexl' is required but it doesn't seem to be installed on this system.]))
   122    121   AC_SUBST(LIBFREEXL_CFLAGS)
   123         -AC_SUBST(LIBFREEXL_LIBS)
          122  +AC_SUBST(LIBREADOSM_LIBS)PKG_CHECK_MODULES([LIBREADOSM], [readosm], , AC_MSG_ERROR(['libreadosm' is required but it doesn't seem to be installed on this system.]))
          123  +AC_SUBST(LIBREADOSM_CFLAGS)
          124  +AC_SUBST(LIBREADOSM_LIBS)
   124    125   
   125    126   AC_OUTPUT

Changes to makefile.vc.

    88     88   	if exist $(SPATIALITE_GML_EXE).manifest mt -manifest \
    89     89   		$(SPATIALITE_GML_EXE).manifest \
    90     90   		-outputresource:$(SPATIALITE_GML_EXE);1
    91     91   
    92     92   $(SPATIALITE_OSM_RAW_EXE):	spatialite_osm_raw.obj
    93     93   	cl spatialite_osm_raw.obj C:\OSGeo4W\lib\proj_i.lib \
    94     94   		C:\OSGeo4W\lib\iconv.lib \
           95  +		C:\OSGeo4W\lib\libreadosm.lib \
    95     96   		C:\OSGeo4W\lib\libexpat.lib \
           97  +		C:\OSGeo4W\lib\libz.lib \
    96     98   		C:\OSGeo4W\lib\spatialite_i.lib
    97     99   	if exist $(SPATIALITE_OSM_RAW_EXE).manifest mt -manifest \
    98    100   		$(SPATIALITE_OSM_RAW_EXE).manifest \
    99    101   		-outputresource:$(SPATIALITE_OSM_RAW_EXE);1
   100    102   
   101    103   $(SPATIALITE_OSM_FILTER_EXE):	spatialite_osm_filter.obj
   102    104   	cl spatialite_osm_filter.obj C:\OSGeo4W\lib\proj_i.lib \

Changes to spatialite_osm_filter.c.

  1561   1561       fprintf (stderr,
  1562   1562   	     "==============================================================\n");
  1563   1563       fprintf (stderr,
  1564   1564   	     "-h or --help                    print this help message\n");
  1565   1565       fprintf (stderr,
  1566   1566   	     "-o or --osm-path pathname       the OSM-XML [output] file path\n");
  1567   1567       fprintf (stderr,
  1568         -	     "-w or --wkt-mask-path pathname       path of text file [WKT mask]\n");
         1568  +	     "-w or --wkt-mask-path pathname  path of text file [WKT mask]\n");
  1569   1569       fprintf (stderr,
  1570   1570   	     "-d or --db-path  pathname       the SpatiaLite DB path\n\n");
  1571   1571       fprintf (stderr, "you can specify the following options as well\n");
  1572   1572       fprintf (stderr,
  1573   1573   	     "-cs or --cache-size    num      DB cache size (how many pages)\n");
  1574   1574       fprintf (stderr,
  1575   1575   	     "-m or --in-memory               using IN-MEMORY database\n");
         1576  +    fprintf (stderr,
         1577  +	     "-jo or --journal-off            unsafe [but faster] mode\n");
  1576   1578   }
  1577   1579   
  1578   1580   int
  1579   1581   main (int argc, char *argv[])
  1580   1582   {
  1581   1583   /* the MAIN function simply perform arguments checking */
  1582   1584       sqlite3 *handle;
................................................................................
  1583   1585       int i;
  1584   1586       int next_arg = ARG_NONE;
  1585   1587       const char *osm_path = NULL;
  1586   1588       const char *wkt_path = NULL;
  1587   1589       const char *db_path = NULL;
  1588   1590       int in_memory = 0;
  1589   1591       int cache_size = 0;
         1592  +    int journal_off = 0;
  1590   1593       int error = 0;
  1591   1594       void *mask = NULL;
  1592   1595       int mask_len = 0;
  1593   1596       FILE *out = NULL;
         1597  +    char *sql_err = NULL;
         1598  +    int ret;
  1594   1599   
  1595   1600       for (i = 1; i < argc; i++)
  1596   1601         {
  1597   1602   	  /* parsing the invocation arguments */
  1598   1603   	  if (next_arg != ARG_NONE)
  1599   1604   	    {
  1600   1605   		switch (next_arg)
................................................................................
  1659   1664   	    }
  1660   1665   	  if (strcasecmp (argv[i], "-m") == 0)
  1661   1666   	    {
  1662   1667   		in_memory = 1;
  1663   1668   		next_arg = ARG_NONE;
  1664   1669   		continue;
  1665   1670   	    }
  1666         -	  if (strcasecmp (argv[i], "-in-memory") == 0)
         1671  +	  if (strcasecmp (argv[i], "--in-memory") == 0)
  1667   1672   	    {
  1668   1673   		in_memory = 1;
  1669   1674   		next_arg = ARG_NONE;
  1670   1675   		continue;
         1676  +	    }
         1677  +	  if (strcasecmp (argv[i], "-jo") == 0)
         1678  +	    {
         1679  +		journal_off = 1;
         1680  +		next_arg = ARG_NONE;
         1681  +		continue;
         1682  +	    }
         1683  +	  if (strcasecmp (argv[i], "--journal-off") == 0)
         1684  +	    {
         1685  +		journal_off = 1;
         1686  +		next_arg = ARG_NONE;
         1687  +		continue;
  1671   1688   	    }
  1672   1689   	  fprintf (stderr, "unknown argument: %s\n", argv[i]);
  1673   1690   	  error = 1;
  1674   1691         }
  1675   1692       if (error)
  1676   1693         {
  1677   1694   	  do_help ();
................................................................................
  1717   1734       if (!handle)
  1718   1735   	return -1;
  1719   1736       if (in_memory)
  1720   1737         {
  1721   1738   	  /* loading the DB in-memory */
  1722   1739   	  sqlite3 *mem_db_handle;
  1723   1740   	  sqlite3_backup *backup;
  1724         -	  int ret;
  1725   1741   	  ret =
  1726   1742   	      sqlite3_open_v2 (":memory:", &mem_db_handle,
  1727   1743   			       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
  1728   1744   			       NULL);
  1729   1745   	  if (ret != SQLITE_OK)
  1730   1746   	    {
  1731   1747   		fprintf (stderr, "cannot open 'MEMORY-DB': %s\n",
................................................................................
  1753   1769   	  printf ("\nusing IN-MEMORY database\n");
  1754   1770         }
  1755   1771   
  1756   1772       out = fopen (osm_path, "wb");
  1757   1773       if (out == NULL)
  1758   1774   	goto stop;
  1759   1775   
  1760         -    fprintf (stderr, "Evvai reset\n");
         1776  +    if (journal_off)
         1777  +      {
         1778  +	  /* disabling the journal: unsafe but faster */
         1779  +	  ret =
         1780  +	      sqlite3_exec (handle, "PRAGMA journal_mode = OFF", NULL, NULL,
         1781  +			    &sql_err);
         1782  +	  if (ret != SQLITE_OK)
         1783  +	    {
         1784  +		fprintf (stderr, "PRAGMA journal_mode=OFF error: %s\n",
         1785  +			 sql_err);
         1786  +		sqlite3_free (sql_err);
         1787  +		goto stop;
         1788  +	    }
         1789  +      }
         1790  +
  1761   1791   /* resetting filtered nodes, ways and relations */
  1762   1792       if (!reset_filtered (handle))
  1763   1793   	goto stop;
  1764   1794   
  1765         -    fprintf (stderr, "Evvai nodes\n");
  1766   1795   /* identifying filtered nodes */
  1767   1796       if (!filter_nodes (handle, mask, mask_len))
  1768   1797   	goto stop;
  1769   1798   
  1770         -    fprintf (stderr, "Evvai rel-rels\n");
  1771   1799   /* identifying relations depending on other relations */
  1772   1800       if (!filter_rel_relations (handle))
  1773   1801   	goto stop;
  1774   1802   
  1775         -    fprintf (stderr, "Evvai way-rels\n");
  1776   1803   /* identifying ways depending on relations */
  1777   1804       if (!filter_way_relations (handle))
  1778   1805   	goto stop;
  1779   1806   
  1780         -    fprintf (stderr, "Evvai node-rels\n");
  1781   1807   /* identifying nodes depending on relations */
  1782   1808       if (!filter_node_relations (handle))
  1783   1809   	goto stop;
  1784   1810   
  1785         -    fprintf (stderr, "Evvai node-ways\n");
  1786   1811   /* identifying nodes depending on ways */
  1787   1812       if (!filter_node_ways (handle))
  1788   1813   	goto stop;
  1789   1814   
  1790   1815   /* writing the OSM header */
  1791   1816       fprintf (out, "<?xml version='1.0' encoding='UTF-8'?>\n");
  1792   1817       fprintf (out, "<osm version=\"0.6\" generator=\"splite2osm\">\n");

Changes to spatialite_osm_map.c.

    30     30   #endif
    31     31   
    32     32   #include <stdlib.h>
    33     33   #include <stdio.h>
    34     34   #include <string.h>
    35     35   #include <float.h>
    36     36   
    37         -#include <expat.h>
    38         -
    39     37   #include "config.h"
    40     38   
    41     39   #ifdef SPATIALITE_AMALGAMATION
    42     40   #include <spatialite/sqlite3.h>
    43     41   #else
    44     42   #include <sqlite3.h>
    45     43   #endif
    46     44   
    47     45   #include <spatialite/gaiageo.h>
    48     46   #include <spatialite.h>
           47  +#include <readosm.h>
    49     48   
    50     49   #define ARG_NONE		0
    51     50   #define ARG_OSM_PATH	1
    52     51   #define ARG_DB_PATH		2
    53     52   #define ARG_CACHE_SIZE	3
    54     53   
    55         -#define MAX_TAG		16
    56         -
    57         -#if defined(_WIN32) && !defined(__MINGW32__)
    58         -#define strcasecmp	_stricmp
    59         -#endif /* not WIN32 */
    60         -
    61         -#if defined(_WIN32)
    62         -#define atol_64		_atoi64
    63         -#else
    64         -#define atol_64		atoll
    65         -#endif
    66         -
    67         -#define BUFFSIZE	8192
    68         -
    69         -#define CURRENT_TAG_UNKNOWN	0
    70         -#define CURRENT_TAG_IS_NODE	1
    71         -#define CURRENT_TAG_IS_WAY	2
    72         -#define CURRENT_TAG_IS_RELATION	3
    73         -
    74     54   struct aux_params
    75     55   {
    76     56   /* an auxiliary struct used for XML parsing */
    77     57       sqlite3 *db_handle;
    78     58       sqlite3_stmt *ins_tmp_nodes_stmt;
    79     59       sqlite3_stmt *ins_tmp_ways_stmt;
    80     60       sqlite3_stmt *ins_generic_point_stmt;
    81     61       sqlite3_stmt *ins_addresses_stmt;
    82     62       sqlite3_stmt *ins_generic_linestring_stmt;
    83     63       sqlite3_stmt *ins_generic_polygon_stmt;
    84         -    int current_tag;
    85     64   };
    86     65   
    87     66   struct layers
    88     67   {
    89     68       const char *name;
    90     69       int ok_point;
    91     70       int ok_linestring;
................................................................................
   160    139       {
   161    140       "building", 0, 0, 0, NULL, NULL, NULL},
   162    141       {
   163    142       "parking", 0, 0, 0, NULL, NULL, NULL},
   164    143       {
   165    144   NULL, 0, 0, 0, NULL, NULL, NULL},};
   166    145   
   167         -struct tag
          146  +struct node_refs
   168    147   {
   169         -    char *k;
   170         -    char *v;
   171         -    struct tag *next;
          148  +    int count;
          149  +    sqlite3_int64 *id;
          150  +    char *found;
   172    151   };
   173    152   
   174         -struct node
          153  +struct way_refs
   175    154   {
   176         -    sqlite3_int64 id;
   177         -    double lat;
   178         -    double lon;
   179         -    struct tag *first;
   180         -    struct tag *last;
   181         -} glob_node;
   182         -
   183         -struct nd
   184         -{
   185         -    sqlite3_int64 ref;
   186         -    char found;
   187         -    struct nd *next;
          155  +    int count;
          156  +    sqlite3_int64 *id;
          157  +    char *found;
   188    158   };
   189    159   
   190         -struct way
          160  +struct ring_refs
   191    161   {
   192         -    sqlite3_int64 id;
   193         -    struct nd *first_nd;
   194         -    struct nd *last_nd;
   195         -    struct tag *first;
   196         -    struct tag *last;
   197         -} glob_way;
   198         -
   199         -struct member
   200         -{
   201         -    sqlite3_int64 ref;
   202         -    int is_node;
   203         -    int is_way;
   204         -    char found;
   205         -    char *role;
   206         -    gaiaGeomCollPtr geom;
   207         -    struct member *next;
          162  +    int count;
          163  +    sqlite3_int64 *id;
          164  +    gaiaGeomCollPtr *geom;
          165  +    char *outer;
          166  +    char *found;
   208    167   };
   209    168   
   210         -struct relation
   211         -{
   212         -    sqlite3_int64 id;
   213         -    struct member *first_member;
   214         -    struct member *last_member;
   215         -    struct tag *first;
   216         -    struct tag *last;
   217         -} glob_relation;
   218         -
   219    169   static void
   220    170   create_point_table (struct aux_params *params, struct layers *layer)
   221    171   {
   222    172       int ret;
   223    173       char *err_msg = NULL;
   224    174       char sql[1024];
   225    175       sqlite3_stmt *stmt;
................................................................................
   356    306   	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
   357    307   		   sqlite3_errmsg (params->db_handle));
   358    308   	  return;
   359    309         }
   360    310       layer->ins_polygon_stmt = stmt;
   361    311   }
   362    312   
   363         -static void
   364         -free_tag (struct tag *p)
   365         -{
   366         -    if (p->k)
   367         -	free (p->k);
   368         -    if (p->v)
   369         -	free (p->v);
   370         -    free (p);
   371         -}
   372         -
   373         -static void
   374         -free_member (struct member *p)
   375         -{
   376         -    if (p->role)
   377         -	free (p->role);
   378         -    free (p);
   379         -}
   380         -
   381         -static void
   382         -start_node (struct aux_params *params, const char **attr)
   383         -{
   384         -    int i;
   385         -    glob_node.id = -1;
   386         -    glob_node.lat = DBL_MAX;
   387         -    glob_node.lon = DBL_MAX;
   388         -    glob_node.first = NULL;
   389         -    glob_node.last = NULL;
   390         -    for (i = 0; attr[i]; i += 2)
   391         -      {
   392         -	  if (strcmp (attr[i], "id") == 0)
   393         -	      glob_node.id = atol_64 (attr[i + 1]);
   394         -	  if (strcmp (attr[i], "lat") == 0)
   395         -	      glob_node.lat = atof (attr[i + 1]);
   396         -	  if (strcmp (attr[i], "lon") == 0)
   397         -	      glob_node.lon = atof (attr[i + 1]);
   398         -      }
   399         -    params->current_tag = CURRENT_TAG_IS_NODE;
   400         -}
   401         -
   402         -static void
          313  +static int
   403    314   point_layer_insert (struct aux_params *params, const char *layer_name,
   404         -		    sqlite3_int64 id, double lat, double lon,
   405         -		    const char *sub_type, const char *name)
          315  +		    const readosm_node * node, const char *sub_type,
          316  +		    const char *name)
   406    317   {
   407    318       struct layers *layer;
   408    319       int i = 0;
   409    320       while (1)
   410    321         {
   411    322   	  layer = &(base_layers[i++]);
   412    323   	  if (layer->name == NULL)
   413         -	      return;
          324  +	      return 1;
   414    325   	  if (strcmp (layer->name, layer_name) == 0)
   415    326   	    {
   416    327   		if (layer->ok_point == 0)
   417    328   		  {
   418    329   		      layer->ok_point = 1;
   419    330   		      create_point_table (params, layer);
   420    331   		  }
................................................................................
   421    332   		if (layer->ins_point_stmt)
   422    333   		  {
   423    334   		      int ret;
   424    335   		      unsigned char *blob;
   425    336   		      int blob_size;
   426    337   		      gaiaGeomCollPtr geom = gaiaAllocGeomColl ();
   427    338   		      geom->Srid = 4326;
   428         -		      gaiaAddPointToGeomColl (geom, lon, lat);
          339  +		      gaiaAddPointToGeomColl (geom, node->longitude,
          340  +					      node->latitude);
   429    341   		      sqlite3_reset (layer->ins_point_stmt);
   430    342   		      sqlite3_clear_bindings (layer->ins_point_stmt);
   431         -		      sqlite3_bind_int64 (layer->ins_point_stmt, 1, id);
          343  +		      sqlite3_bind_int64 (layer->ins_point_stmt, 1, node->id);
   432    344   		      if (sub_type == NULL)
   433    345   			  sqlite3_bind_null (layer->ins_point_stmt, 2);
   434    346   		      else
   435    347   			  sqlite3_bind_text (layer->ins_point_stmt, 2,
   436    348   					     sub_type, strlen (sub_type),
   437    349   					     SQLITE_STATIC);
   438    350   		      if (name == NULL)
................................................................................
   442    354   					     strlen (name), SQLITE_STATIC);
   443    355   		      gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
   444    356   		      gaiaFreeGeomColl (geom);
   445    357   		      sqlite3_bind_blob (layer->ins_point_stmt, 4, blob,
   446    358   					 blob_size, free);
   447    359   		      ret = sqlite3_step (layer->ins_point_stmt);
   448    360   		      if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   449         -			  return;
          361  +			  return 1;
   450    362   		      fprintf (stderr, "sqlite3_step() error: INS_POINT %s\n",
   451    363   			       layer_name);
   452    364   		      sqlite3_finalize (layer->ins_point_stmt);
   453    365   		      layer->ins_point_stmt = NULL;
          366  +		      return 0;
   454    367   		  }
   455         -		return;
          368  +		return 1;
   456    369   	    }
   457    370         }
          371  +    return 1;
   458    372   }
   459    373   
   460         -static void
   461         -point_generic_insert (struct aux_params *params, sqlite3_int64 id, double lat,
   462         -		      double lon, const char *name)
          374  +static int
          375  +point_generic_insert (struct aux_params *params, const readosm_node * node,
          376  +		      const char *name)
   463    377   {
   464    378       if (params->ins_generic_point_stmt)
   465    379         {
   466    380   	  int ret;
   467    381   	  unsigned char *blob;
   468    382   	  int blob_size;
   469    383   	  gaiaGeomCollPtr geom = gaiaAllocGeomColl ();
   470    384   	  geom->Srid = 4326;
   471         -	  gaiaAddPointToGeomColl (geom, lon, lat);
          385  +	  gaiaAddPointToGeomColl (geom, node->longitude, node->latitude);
   472    386   	  sqlite3_reset (params->ins_generic_point_stmt);
   473    387   	  sqlite3_clear_bindings (params->ins_generic_point_stmt);
   474         -	  sqlite3_bind_int64 (params->ins_generic_point_stmt, 1, id);
          388  +	  sqlite3_bind_int64 (params->ins_generic_point_stmt, 1, node->id);
   475    389   	  if (name == NULL)
   476    390   	      sqlite3_bind_null (params->ins_generic_point_stmt, 2);
   477    391   	  else
   478    392   	      sqlite3_bind_text (params->ins_generic_point_stmt, 2, name,
   479    393   				 strlen (name), SQLITE_STATIC);
   480    394   	  gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
   481    395   	  gaiaFreeGeomColl (geom);
   482    396   	  sqlite3_bind_blob (params->ins_generic_point_stmt, 3, blob,
   483    397   			     blob_size, free);
   484    398   	  ret = sqlite3_step (params->ins_generic_point_stmt);
   485    399   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   486         -	      return;
          400  +	      return 1;
   487    401   	  fprintf (stderr, "sqlite3_step() error: INS_GENERIC_POINT\n");
   488    402   	  sqlite3_finalize (params->ins_generic_point_stmt);
   489    403   	  params->ins_generic_point_stmt = NULL;
          404  +	  return 0;
   490    405         }
          406  +    return 1;
   491    407   }
   492    408   
   493         -static void
   494         -address_insert (struct aux_params *params, sqlite3_int64 id, double lat,
   495         -		double lon, const char *country, const char *city,
   496         -		const char *postcode,
   497         -		const char *street,
   498         -		const char *housename, const char *housenumber)
          409  +static int
          410  +address_insert (struct aux_params *params, const readosm_node * node,
          411  +		const char *country, const char *city, const char *postcode,
          412  +		const char *street, const char *housename,
          413  +		const char *housenumber)
   499    414   {
   500    415       if (params->ins_addresses_stmt)
   501    416         {
   502    417   	  int ret;
   503    418   	  unsigned char *blob;
   504    419   	  int blob_size;
   505    420   	  gaiaGeomCollPtr geom = gaiaAllocGeomColl ();
   506    421   	  geom->Srid = 4326;
   507         -	  gaiaAddPointToGeomColl (geom, lon, lat);
          422  +	  gaiaAddPointToGeomColl (geom, node->longitude, node->latitude);
   508    423   	  sqlite3_reset (params->ins_addresses_stmt);
   509    424   	  sqlite3_clear_bindings (params->ins_addresses_stmt);
   510         -	  sqlite3_bind_int64 (params->ins_addresses_stmt, 1, id);
          425  +	  sqlite3_bind_int64 (params->ins_addresses_stmt, 1, node->id);
   511    426   	  if (country == NULL)
   512    427   	      sqlite3_bind_null (params->ins_addresses_stmt, 2);
   513    428   	  else
   514    429   	      sqlite3_bind_text (params->ins_addresses_stmt, 2, country,
   515    430   				 strlen (country), SQLITE_STATIC);
   516    431   	  if (city == NULL)
   517    432   	      sqlite3_bind_null (params->ins_addresses_stmt, 3);
................................................................................
   540    455   				 strlen (housenumber), SQLITE_STATIC);
   541    456   	  gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
   542    457   	  gaiaFreeGeomColl (geom);
   543    458   	  sqlite3_bind_blob (params->ins_addresses_stmt, 8, blob, blob_size,
   544    459   			     free);
   545    460   	  ret = sqlite3_step (params->ins_addresses_stmt);
   546    461   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   547         -	      return;
          462  +	      return 1;
   548    463   	  fprintf (stderr, "sqlite3_step() error: INS_ADDRESSES\n");
   549    464   	  sqlite3_finalize (params->ins_addresses_stmt);
   550    465   	  params->ins_addresses_stmt = NULL;
          466  +	  return 0;
   551    467         }
          468  +    return 1;
   552    469   }
   553    470   
   554         -static void
   555         -eval_node (struct aux_params *params)
          471  +static int
          472  +tmp_nodes_insert (struct aux_params *params, const readosm_node * node)
   556    473   {
   557         -    struct tag *p_tag;
          474  +    int ret;
          475  +    if (params->ins_tmp_nodes_stmt == NULL)
          476  +	return 1;
          477  +    sqlite3_reset (params->ins_tmp_nodes_stmt);
          478  +    sqlite3_clear_bindings (params->ins_tmp_nodes_stmt);
          479  +    sqlite3_bind_int64 (params->ins_tmp_nodes_stmt, 1, node->id);
          480  +    sqlite3_bind_double (params->ins_tmp_nodes_stmt, 2, node->latitude);
          481  +    sqlite3_bind_double (params->ins_tmp_nodes_stmt, 3, node->longitude);
          482  +    ret = sqlite3_step (params->ins_tmp_nodes_stmt);
          483  +    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          484  +	return 1;
          485  +    fprintf (stderr, "sqlite3_step() error: INS_TMP_NODES\n");
          486  +    sqlite3_finalize (params->ins_tmp_nodes_stmt);
          487  +    params->ins_tmp_nodes_stmt = NULL;
          488  +    return 0;
          489  +}
          490  +
          491  +static int
          492  +consume_node (const void *user_data, const readosm_node * node)
          493  +{
          494  +/* processing an OSM Node (ReadOSM callback function) */
          495  +    struct aux_params *params = (struct aux_params *) user_data;
          496  +    const readosm_tag *p_tag;
          497  +    int i_tag;
   558    498       const char *p;
   559         -    int i = 0;
          499  +    int i_lyr = 0;
          500  +    int ret;
   560    501       const char *layer_name = NULL;
   561         -    char *sub_type = NULL;
   562         -    char *name = NULL;
   563         -    char *country = NULL;
   564         -    char *city = NULL;
   565         -    char *postcode = NULL;
   566         -    char *street = NULL;
   567         -    char *housename = NULL;
   568         -    char *housenumber = NULL;
   569         -    if (glob_node.first == NULL)
   570         -	return;
          502  +    const char *sub_type = NULL;
          503  +    const char *name = NULL;
          504  +    const char *country = NULL;
          505  +    const char *city = NULL;
          506  +    const char *postcode = NULL;
          507  +    const char *street = NULL;
          508  +    const char *housename = NULL;
          509  +    const char *housenumber = NULL;
          510  +
          511  +    if (!tmp_nodes_insert (params, node))
          512  +	return READOSM_ABORT;
          513  +
   571    514       while (1)
   572    515         {
   573         -	  p = base_layers[i++].name;
          516  +	  p = base_layers[i_lyr++].name;
   574    517   	  if (!p)
   575    518   	      break;
   576         -	  p_tag = glob_node.first;
   577         -	  while (p_tag)
          519  +	  for (i_tag = 0; i_tag < node->tag_count; i_tag++)
   578    520   	    {
   579         -		if (strcmp (p_tag->k, p) == 0)
          521  +		p_tag = node->tags + i_tag;
          522  +		if (strcmp (p_tag->key, p) == 0)
   580    523   		  {
   581    524   		      layer_name = p;
   582         -		      sub_type = p_tag->v;
          525  +		      sub_type = p_tag->value;
   583    526   		  }
   584         -		if (strcmp (p_tag->k, "name") == 0)
   585         -		    name = p_tag->v;
   586         -		p_tag = p_tag->next;
          527  +		if (strcmp (p_tag->key, "name") == 0)
          528  +		    name = p_tag->value;
   587    529   	    }
   588    530   	  if (layer_name)
   589    531   	      break;
   590    532         }
          533  +
   591    534       if (layer_name)
   592    535         {
   593         -	  point_layer_insert (params, layer_name, glob_node.id, glob_node.lat,
   594         -			      glob_node.lon, sub_type, name);
   595         -	  return;
          536  +	  ret = point_layer_insert (params, layer_name, node, sub_type, name);
          537  +	  if (ret)
          538  +	      return READOSM_OK;
          539  +	  return READOSM_ABORT;
   596    540         }
   597    541       else if (name != NULL)
   598    542         {
   599         -	  point_generic_insert (params, glob_node.id, glob_node.lat,
   600         -				glob_node.lon, name);
   601         -	  return;
          543  +	  ret = point_generic_insert (params, node, name);
          544  +	  if (ret)
          545  +	      return READOSM_OK;
          546  +	  return READOSM_ABORT;
   602    547         }
   603    548   
   604    549   /* may be an house address */
   605         -    p_tag = glob_node.first;
   606         -    while (p_tag)
          550  +    for (i_tag = 0; i_tag < node->tag_count; i_tag++)
   607    551         {
   608         -	  if (strcmp (p_tag->k, "addr:country") == 0)
   609         -	      country = p_tag->v;
   610         -	  if (strcmp (p_tag->k, "addr:city") == 0)
   611         -	      city = p_tag->v;
   612         -	  if (strcmp (p_tag->k, "addr:postcode") == 0)
   613         -	      postcode = p_tag->v;
   614         -	  if (strcmp (p_tag->k, "addr:street") == 0)
   615         -	      street = p_tag->v;
   616         -	  if (strcmp (p_tag->k, "addr:housename") == 0)
   617         -	      housename = p_tag->v;
   618         -	  if (strcmp (p_tag->k, "addr:housenumber") == 0)
   619         -	      housenumber = p_tag->v;
   620         -	  p_tag = p_tag->next;
          552  +	  p_tag = node->tags + i_tag;
          553  +	  if (strcmp (p_tag->key, "addr:country") == 0)
          554  +	      country = p_tag->value;
          555  +	  if (strcmp (p_tag->key, "addr:city") == 0)
          556  +	      city = p_tag->value;
          557  +	  if (strcmp (p_tag->key, "addr:postcode") == 0)
          558  +	      postcode = p_tag->value;
          559  +	  if (strcmp (p_tag->key, "addr:street") == 0)
          560  +	      street = p_tag->value;
          561  +	  if (strcmp (p_tag->key, "addr:housename") == 0)
          562  +	      housename = p_tag->value;
          563  +	  if (strcmp (p_tag->key, "addr:housenumber") == 0)
          564  +	      housenumber = p_tag->value;
   621    565         }
   622    566       if (country || city || postcode || street || housename || housenumber)
   623         -	address_insert (params, glob_node.id, glob_node.lat, glob_node.lon,
   624         -			country, city, postcode, street, housename,
   625         -			housenumber);
   626         -}
   627         -
   628         -static void
   629         -tmp_nodes_insert (struct aux_params *params, sqlite3_int64 id, double lat,
   630         -		  double lon)
   631         -{
   632         -    int ret;
   633         -    if (params->ins_tmp_nodes_stmt == NULL)
   634         -	return;
   635         -    sqlite3_reset (params->ins_tmp_nodes_stmt);
   636         -    sqlite3_clear_bindings (params->ins_tmp_nodes_stmt);
   637         -    sqlite3_bind_int64 (params->ins_tmp_nodes_stmt, 1, id);
   638         -    sqlite3_bind_double (params->ins_tmp_nodes_stmt, 2, lat);
   639         -    sqlite3_bind_double (params->ins_tmp_nodes_stmt, 3, lon);
   640         -    ret = sqlite3_step (params->ins_tmp_nodes_stmt);
   641         -    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          567  +      {
          568  +	  ret = address_insert (params, node, country, city, postcode, street,
          569  +				housename, housenumber);
          570  +	  if (ret)
          571  +	      return READOSM_OK;
          572  +	  return READOSM_ABORT;
          573  +      }
          574  +    return READOSM_OK;
          575  +}
          576  +
          577  +static struct node_refs *
          578  +create_node_refs (const readosm_way * way)
          579  +{
          580  +/* creating and initializing the node_refs helper struct */
          581  +    int i_ref;
          582  +    struct node_refs *refs = malloc (sizeof (struct node_refs));
          583  +    if (refs == NULL)
          584  +	return NULL;
          585  +    refs->count = way->node_ref_count;
          586  +    refs->id = malloc (sizeof (sqlite3_int64) * refs->count);
          587  +    if (refs->id == NULL)
          588  +      {
          589  +	  free (refs);
          590  +	  return NULL;
          591  +      }
          592  +    refs->found = malloc (refs->count);
          593  +    if (refs->found == NULL)
          594  +      {
          595  +	  free (refs->id);
          596  +	  free (refs);
          597  +	  return NULL;
          598  +      }
          599  +    for (i_ref = 0; i_ref < way->node_ref_count; i_ref++)
          600  +      {
          601  +	  *(refs->id + i_ref) = *(way->node_refs + i_ref);
          602  +	  *(refs->found + i_ref) = 'N';
          603  +      }
          604  +    return refs;
          605  +}
          606  +
          607  +static void
          608  +update_node_refs (struct node_refs *nodes, gaiaLinestringPtr ln,
          609  +		  sqlite3_int64 id, double lat, double lon)
          610  +{
          611  +/* updating the node_refs helper struct */
          612  +    int i_ref;
          613  +    for (i_ref = 0; i_ref < nodes->count; i_ref++)
          614  +      {
          615  +	  if (*(nodes->id + i_ref) == id)
          616  +	    {
          617  +		*(nodes->found + i_ref) = 'Y';
          618  +		gaiaSetPoint (ln->Coords, i_ref, lon, lat);
          619  +	    }
          620  +      }
          621  +}
          622  +
          623  +static void
          624  +destroy_node_refs (struct node_refs *nodes)
          625  +{
          626  +/* destroying the node_refs helper struct */
          627  +    if (nodes == NULL)
   642    628   	return;
   643         -    fprintf (stderr, "sqlite3_step() error: INS_TMP_NODES\n");
   644         -    sqlite3_finalize (params->ins_tmp_nodes_stmt);
   645         -    params->ins_tmp_nodes_stmt = NULL;
   646         -}
   647         -
   648         -static void
   649         -end_node (struct aux_params *params)
   650         -{
   651         -    struct tag *p_tag;
   652         -    struct tag *p_tag2;
   653         -
   654         -    tmp_nodes_insert (params, glob_node.id, glob_node.lat, glob_node.lon);
   655         -    eval_node (params);
   656         -    p_tag = glob_node.first;
   657         -    while (p_tag)
   658         -      {
   659         -	  p_tag2 = p_tag->next;
   660         -	  free_tag (p_tag);
   661         -	  p_tag = p_tag2;
   662         -      }
   663         -    glob_node.id = -1;
   664         -    glob_node.lat = DBL_MAX;
   665         -    glob_node.lon = DBL_MAX;
   666         -    glob_node.first = NULL;
   667         -    glob_node.last = NULL;
   668         -    params->current_tag = CURRENT_TAG_UNKNOWN;
   669         -}
   670         -
   671         -static void
   672         -start_way (struct aux_params *params, const char **attr)
   673         -{
   674         -    int i;
   675         -    glob_way.id = -1;
   676         -    glob_way.first_nd = NULL;
   677         -    glob_way.last_nd = NULL;
   678         -    glob_way.first = NULL;
   679         -    glob_way.last = NULL;
   680         -    for (i = 0; attr[i]; i += 2)
   681         -      {
   682         -	  if (strcmp (attr[i], "id") == 0)
   683         -	      glob_way.id = atol_64 (attr[i + 1]);
   684         -      }
   685         -    params->current_tag = CURRENT_TAG_IS_WAY;
          629  +    if (nodes->id != NULL)
          630  +	free (nodes->id);
          631  +    if (nodes->found != NULL)
          632  +	free (nodes->found);
          633  +    free (nodes);
   686    634   }
   687    635   
   688    636   static gaiaGeomCollPtr
   689         -build_linestring (sqlite3 * db_handle)
          637  +build_linestring (sqlite3 * db_handle, const readosm_way * way)
   690    638   {
   691    639       gaiaGeomCollPtr geom;
   692    640       gaiaLinestringPtr ln;
   693    641       int points = 0;
   694    642       int tbd;
   695    643       int block = 128;
   696    644       int base = 0;
................................................................................
   699    647       int ret;
   700    648       int count;
   701    649       char sql[8192];
   702    650       sqlite3_stmt *stmt;
   703    651       sqlite3_int64 id;
   704    652       double lat;
   705    653       double lon;
   706         -    struct nd *p_nd = glob_way.first_nd;
   707         -    while (p_nd)
   708         -      {
   709         -	  points++;
   710         -	  p_nd = p_nd->next;
   711         -      }
          654  +    int i_ref;
          655  +    struct node_refs *refs = NULL;
          656  +
          657  +    points = way->node_ref_count;
   712    658       if (!points)
          659  +	return NULL;
          660  +    refs = create_node_refs (way);
          661  +    if (refs == NULL)
   713    662   	return NULL;
   714    663       geom = gaiaAllocGeomColl ();
   715    664       geom->Srid = 4326;
   716    665       ln = gaiaAddLinestringToGeomColl (geom, points);
   717    666       tbd = points;
   718    667       while (tbd > 0)
   719    668         {
................................................................................
   742    691   			 sqlite3_errmsg (db_handle));
   743    692   		gaiaFreeGeomColl (geom);
   744    693   		return NULL;
   745    694   	    }
   746    695   	  sqlite3_reset (stmt);
   747    696   	  sqlite3_clear_bindings (stmt);
   748    697   	  ind = 1;
   749         -	  count = 0;
   750         -	  p_nd = glob_way.first_nd;
   751         -	  while (p_nd)
          698  +	  for (i_ref = 0; i_ref < refs->count; i_ref++)
   752    699   	    {
   753         -		if (count < base)
   754         -		  {
   755         -		      count++;
   756         -		      p_nd = p_nd->next;
   757         -		      continue;
   758         -		  }
   759         -		if (count >= (base + how_many))
          700  +		if (i_ref < base)
          701  +		    continue;
          702  +		if (i_ref >= (base + how_many))
   760    703   		    break;
   761         -		sqlite3_bind_int64 (stmt, ind, p_nd->ref);
          704  +		sqlite3_bind_int64 (stmt, ind, *(refs->id + i_ref));
   762    705   		ind++;
   763    706   		count++;
   764         -		p_nd = p_nd->next;
   765    707   	    }
   766    708   	  while (1)
   767    709   	    {
   768    710   		/* scrolling the result set */
   769    711   		ret = sqlite3_step (stmt);
   770    712   		if (ret == SQLITE_DONE)
   771    713   		  {
................................................................................
   774    716   		  }
   775    717   		if (ret == SQLITE_ROW)
   776    718   		  {
   777    719   		      /* ok, we've just fetched a valid row */
   778    720   		      id = sqlite3_column_int64 (stmt, 0);
   779    721   		      lat = sqlite3_column_double (stmt, 1);
   780    722   		      lon = sqlite3_column_double (stmt, 2);
   781         -		      p_nd = glob_way.first_nd;
   782         -		      count = 0;
   783         -		      while (p_nd)
   784         -			{
   785         -			    if (p_nd->ref == id)
   786         -			      {
   787         -				  p_nd->found = 1;
   788         -				  gaiaSetPoint (ln->Coords, count, lon, lat);
   789         -			      }
   790         -			    count++;
   791         -			    p_nd = p_nd->next;
   792         -			}
          723  +		      update_node_refs (refs, ln, id, lat, lon);
   793    724   		  }
   794    725   		else
   795    726   		  {
   796    727   		      /* some unexpected error occurred */
   797    728   		      fprintf (stderr, "sqlite3_step() error: %s\n",
   798    729   			       sqlite3_errmsg (db_handle));
   799    730   		      sqlite3_finalize (stmt);
................................................................................
   802    733   	    }
   803    734   	  sqlite3_finalize (stmt);
   804    735   	  tbd -= how_many;
   805    736   	  base += how_many;
   806    737         }
   807    738   
   808    739   /* final checkout */
   809         -    p_nd = glob_way.first_nd;
   810         -    while (p_nd)
          740  +    for (i_ref = 0; i_ref < refs->count; i_ref++)
   811    741         {
   812         -	  if (p_nd->found == 0)
          742  +	  if (*(refs->found + i_ref) == 'N')
   813    743   	    {
   814    744   #if defined(_WIN32) || defined(__MINGW32__)
   815    745   		/* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */
   816         -		fprintf (stderr, "UNRESOLVED-NODE %I64d\n", p_nd->ref);
          746  +		fprintf (stderr, "UNRESOLVED-NODE %I64d\n",
          747  +			 *(refs->id + i_ref));
   817    748   #else
   818         -		fprintf (stderr, "UNRESOLVED-NODE %lld\n", p_nd->ref);
          749  +		fprintf (stderr, "UNRESOLVED-NODE %lld\n", *(refs->id + i_ref));
   819    750   #endif
   820    751   		gaiaFreeGeomColl (geom);
          752  +		destroy_node_refs (refs);
   821    753   		return NULL;
   822    754   	    }
   823         -	  p_nd = p_nd->next;
   824    755         }
          756  +    destroy_node_refs (refs);
   825    757       return geom;
   826    758   }
   827    759   
   828         -static void
          760  +static int
   829    761   line_layer_insert (struct aux_params *params, const char *layer_name,
   830    762   		   sqlite3_int64 id, unsigned char *blob, int blob_size,
   831    763   		   const char *sub_type, const char *name)
   832    764   {
   833    765       struct layers *layer;
   834    766       int i = 0;
   835    767       while (1)
   836    768         {
   837    769   	  layer = &(base_layers[i++]);
   838    770   	  if (layer->name == NULL)
   839         -	      return;
          771  +	      return 1;
   840    772   	  if (strcmp (layer->name, layer_name) == 0)
   841    773   	    {
   842    774   		if (layer->ok_linestring == 0)
   843    775   		  {
   844    776   		      layer->ok_linestring = 1;
   845    777   		      create_linestring_table (params, layer);
   846    778   		  }
................................................................................
   862    794   			  sqlite3_bind_text (layer->ins_linestring_stmt, 3,
   863    795   					     name, strlen (name),
   864    796   					     SQLITE_STATIC);
   865    797   		      sqlite3_bind_blob (layer->ins_linestring_stmt, 4, blob,
   866    798   					 blob_size, SQLITE_STATIC);
   867    799   		      ret = sqlite3_step (layer->ins_linestring_stmt);
   868    800   		      if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   869         -			  return;
          801  +			  return 1;
   870    802   		      fprintf (stderr,
   871    803   			       "sqlite3_step() error: INS_LINESTRING %s\n",
   872    804   			       layer_name);
   873    805   		      sqlite3_finalize (layer->ins_linestring_stmt);
   874    806   		      layer->ins_linestring_stmt = NULL;
          807  +		      return 0;
   875    808   		  }
   876         -		return;
          809  +		return 1;
   877    810   	    }
   878    811         }
          812  +    return 1;
   879    813   }
   880    814   
   881         -static void
          815  +static int
   882    816   polygon_layer_insert (struct aux_params *params, const char *layer_name,
   883    817   		      sqlite3_int64 id, unsigned char *blob, int blob_size,
   884    818   		      const char *sub_type, const char *name)
   885    819   {
   886    820       struct layers *layer;
   887    821       int i = 0;
   888    822       while (1)
   889    823         {
   890    824   	  layer = &(base_layers[i++]);
   891    825   	  if (layer->name == NULL)
   892         -	      return;
          826  +	      return 1;
   893    827   	  if (strcmp (layer->name, layer_name) == 0)
   894    828   	    {
   895    829   		if (layer->ok_polygon == 0)
   896    830   		  {
   897    831   		      layer->ok_polygon = 1;
   898    832   		      create_polygon_table (params, layer);
   899    833   		  }
................................................................................
   914    848   		      else
   915    849   			  sqlite3_bind_text (layer->ins_polygon_stmt, 3, name,
   916    850   					     strlen (name), SQLITE_STATIC);
   917    851   		      sqlite3_bind_blob (layer->ins_polygon_stmt, 4, blob,
   918    852   					 blob_size, SQLITE_STATIC);
   919    853   		      ret = sqlite3_step (layer->ins_polygon_stmt);
   920    854   		      if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   921         -			  return;
          855  +			  return 1;
   922    856   		      fprintf (stderr,
   923    857   			       "sqlite3_step() error: INS_POLYGON %s\n",
   924    858   			       layer_name);
   925    859   		      sqlite3_finalize (layer->ins_polygon_stmt);
   926    860   		      layer->ins_polygon_stmt = NULL;
          861  +		      return 0;
   927    862   		  }
   928         -		return;
          863  +		return 1;
   929    864   	    }
   930    865         }
          866  +    return 1;
   931    867   }
   932    868   
   933         -static void
          869  +static int
   934    870   line_generic_insert (struct aux_params *params, sqlite3_int64 id,
   935    871   		     unsigned char *blob, int blob_size, const char *name)
   936    872   {
   937    873       if (params->ins_generic_linestring_stmt)
   938    874         {
   939    875   	  int ret;
   940    876   	  sqlite3_reset (params->ins_generic_linestring_stmt);
................................................................................
   945    881   	  else
   946    882   	      sqlite3_bind_text (params->ins_generic_linestring_stmt, 2, name,
   947    883   				 strlen (name), SQLITE_STATIC);
   948    884   	  sqlite3_bind_blob (params->ins_generic_linestring_stmt, 3, blob,
   949    885   			     blob_size, SQLITE_STATIC);
   950    886   	  ret = sqlite3_step (params->ins_generic_linestring_stmt);
   951    887   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   952         -	      return;
          888  +	      return 1;
   953    889   	  fprintf (stderr, "sqlite3_step() error: INS_GENERIC_LINESTRING\n");
   954    890   	  sqlite3_finalize (params->ins_generic_linestring_stmt);
   955    891   	  params->ins_generic_linestring_stmt = NULL;
          892  +	  return 0;
   956    893         }
          894  +    return 1;
   957    895   }
   958    896   
   959         -static void
          897  +static int
   960    898   polygon_generic_insert (struct aux_params *params, sqlite3_int64 id,
   961    899   			unsigned char *blob, int blob_size, const char *name)
   962    900   {
   963    901       if (params->ins_generic_polygon_stmt)
   964    902         {
   965    903   	  int ret;
   966    904   	  sqlite3_reset (params->ins_generic_polygon_stmt);
................................................................................
   971    909   	  else
   972    910   	      sqlite3_bind_text (params->ins_generic_polygon_stmt, 2, name,
   973    911   				 strlen (name), SQLITE_STATIC);
   974    912   	  sqlite3_bind_blob (params->ins_generic_polygon_stmt, 3, blob,
   975    913   			     blob_size, SQLITE_STATIC);
   976    914   	  ret = sqlite3_step (params->ins_generic_polygon_stmt);
   977    915   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   978         -	      return;
          916  +	      return 1;
   979    917   	  fprintf (stderr, "sqlite3_step() error: INS_GENERIC_POLYGON\n");
   980    918   	  sqlite3_finalize (params->ins_generic_polygon_stmt);
   981    919   	  params->ins_generic_polygon_stmt = NULL;
          920  +	  return 0;
   982    921         }
          922  +    return 1;
   983    923   }
   984    924   
   985         -static void
          925  +static int
   986    926   tmp_ways_insert (struct aux_params *params, sqlite3_int64 id, int area,
   987    927   		 unsigned char *blob, int blob_size)
   988    928   {
   989    929       int ret;
   990    930       if (params->ins_tmp_ways_stmt == NULL)
   991         -	return;
          931  +	return 1;
   992    932       sqlite3_reset (params->ins_tmp_ways_stmt);
   993    933       sqlite3_clear_bindings (params->ins_tmp_ways_stmt);
   994    934       sqlite3_bind_int64 (params->ins_tmp_ways_stmt, 1, id);
   995    935       sqlite3_bind_int (params->ins_tmp_ways_stmt, 2, area);
   996    936       sqlite3_bind_blob (params->ins_tmp_ways_stmt, 3, blob, blob_size,
   997    937   		       SQLITE_STATIC);
   998    938       ret = sqlite3_step (params->ins_tmp_ways_stmt);
   999    939   
  1000    940       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1001         -	return;
          941  +	return 1;
  1002    942       fprintf (stderr, "sqlite3_step() error: INS_TMP_WAYS\n");
  1003    943       sqlite3_finalize (params->ins_tmp_ways_stmt);
  1004    944       params->ins_tmp_ways_stmt = NULL;
          945  +    return 0;
  1005    946   }
  1006    947   
  1007         -static void
  1008         -eval_way (struct aux_params *params, int area, unsigned char *blob,
  1009         -	  int blob_size)
          948  +static int
          949  +eval_way (struct aux_params *params, const readosm_way * way, int area,
          950  +	  unsigned char *blob, int blob_size)
  1010    951   {
  1011         -    struct tag *p_tag;
          952  +    int i_tag;
          953  +    const readosm_tag *p_tag;
  1012    954       const char *p;
  1013    955       int i = 0;
  1014    956       const char *layer_name = NULL;
  1015         -    char *sub_type = NULL;
  1016         -    char *name = NULL;
  1017         -    if (glob_way.first == NULL)
  1018         -	return;
          957  +    const char *sub_type = NULL;
          958  +    const char *name = NULL;
          959  +    int ret;
          960  +    if (way->tag_count == 0)
          961  +	return 1;
  1019    962       while (1)
  1020    963         {
  1021    964   	  p = base_layers[i++].name;
  1022    965   	  if (!p)
  1023    966   	      break;
  1024         -	  p_tag = glob_way.first;
  1025         -	  while (p_tag)
          967  +	  for (i_tag = 0; i_tag < way->tag_count; i_tag++)
  1026    968   	    {
  1027         -		if (strcmp (p_tag->k, p) == 0)
          969  +		p_tag = way->tags + i_tag;
          970  +		if (strcmp (p_tag->key, p) == 0)
  1028    971   		  {
  1029    972   		      layer_name = p;
  1030         -		      sub_type = p_tag->v;
          973  +		      sub_type = p_tag->value;
  1031    974   		  }
  1032         -		if (strcmp (p_tag->k, "name") == 0)
  1033         -		    name = p_tag->v;
  1034         -		p_tag = p_tag->next;
          975  +		if (strcmp (p_tag->key, "name") == 0)
          976  +		    name = p_tag->value;
  1035    977   	    }
  1036    978   	  if (layer_name)
  1037    979   	      break;
  1038    980         }
  1039    981       if (layer_name)
  1040    982         {
  1041    983   	  if (area)
  1042         -	      polygon_layer_insert (params, layer_name, glob_way.id, blob,
  1043         -				    blob_size, sub_type, name);
          984  +	      ret = polygon_layer_insert (params, layer_name, way->id, blob,
          985  +					  blob_size, sub_type, name);
  1044    986   	  else
  1045         -	      line_layer_insert (params, layer_name, glob_way.id, blob,
  1046         -				 blob_size, sub_type, name);
  1047         -	  return;
          987  +	      ret = line_layer_insert (params, layer_name, way->id, blob,
          988  +				       blob_size, sub_type, name);
          989  +	  return ret;
  1048    990         }
  1049    991       else if (name != NULL)
  1050    992         {
  1051    993   	  if (area)
  1052         -	      polygon_generic_insert (params, glob_way.id, blob, blob_size,
  1053         -				      name);
          994  +	      ret = polygon_generic_insert (params, way->id, blob, blob_size,
          995  +					    name);
  1054    996   	  else
  1055         -	      line_generic_insert (params, glob_way.id, blob, blob_size, name);
  1056         -	  return;
          997  +	      ret =
          998  +		  line_generic_insert (params, way->id, blob, blob_size, name);
          999  +	  return ret;
  1057   1000         }
         1001  +    return 1;
  1058   1002   }
  1059   1003   
  1060   1004   static int
  1061         -is_areal_layer ()
         1005  +is_areal_layer (const readosm_way * way)
  1062   1006   {
  1063         -    struct tag *p_tag;
         1007  +    int i_tag;
         1008  +    const readosm_tag *p_tag;
  1064   1009       const char *p;
  1065         -    int i = 0;
  1066   1010       const char *layer_name = NULL;
  1067         -    if (glob_way.first == NULL)
  1068         -	return;
         1011  +    int i = 0;
         1012  +    if (way->tag_count == 0)
         1013  +	return 0;
  1069   1014       while (1)
  1070   1015         {
  1071   1016   	  p = base_layers[i++].name;
  1072   1017   	  if (!p)
  1073   1018   	      break;
  1074         -	  p_tag = glob_way.first;
  1075         -	  while (p_tag)
         1019  +	  for (i_tag = 0; i_tag < way->tag_count; i_tag++)
  1076   1020   	    {
  1077         -		if (strcmp (p_tag->k, p) == 0)
         1021  +		p_tag = way->tags + i_tag;
         1022  +		if (strcmp (p_tag->key, p) == 0)
  1078   1023   		    layer_name = p;
  1079         -		p_tag = p_tag->next;
  1080   1024   	    }
  1081   1025   	  if (layer_name)
  1082   1026   	      break;
  1083   1027         }
  1084   1028       if (layer_name)
  1085   1029         {
  1086   1030   	  /* possible "areal" layers */
................................................................................
  1146   1090   	  gaiaGetPoint (ln->Coords, iv, &x, &y);
  1147   1091   	  gaiaSetPoint (rng->Coords, iv, x, y);
  1148   1092         }
  1149   1093       gaiaFreeGeomColl (old);
  1150   1094       return geom;
  1151   1095   }
  1152   1096   
  1153         -static void
  1154         -end_way (struct aux_params *params)
         1097  +static int
         1098  +consume_way (const void *user_data, const readosm_way * way)
  1155   1099   {
  1156         -    struct tag *p_tag;
  1157         -    struct tag *p_tag2;
  1158         -    struct nd *p_nd;
  1159         -    struct nd *p_nd2;
         1100  +/* processing an OSM Way (ReadOSM callback function) */
         1101  +    struct aux_params *params = (struct aux_params *) user_data;
         1102  +    const readosm_tag *p_tag;
         1103  +    int i_tag;
  1160   1104       unsigned char *blob;
  1161   1105       int blob_size;
  1162   1106       int area = 0;
         1107  +    int ret;
  1163   1108   
  1164         -    gaiaGeomCollPtr geom = build_linestring (params->db_handle);
         1109  +    gaiaGeomCollPtr geom = build_linestring (params->db_handle, way);
  1165   1110       if (geom)
  1166   1111         {
  1167   1112   	  geom->DeclaredType = GAIA_MULTILINESTRING;
  1168   1113   	  gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
  1169         -	  tmp_ways_insert (params, glob_way.id, area, blob, blob_size);
         1114  +	  if (!tmp_ways_insert (params, way->id, area, blob, blob_size))
         1115  +	      return READOSM_ABORT;
  1170   1116   	  area = 0;
  1171         -	  p_tag = glob_way.first;
  1172         -	  while (p_tag)
         1117  +	  for (i_tag = 0; i_tag < way->tag_count; i_tag++)
  1173   1118   	    {
  1174         -		if (strcmp (p_tag->k, "area") == 0
  1175         -		    && strcmp (p_tag->v, "yes") == 0)
         1119  +		p_tag = way->tags + i_tag;
         1120  +		if (strcmp (p_tag->key, "area") == 0
         1121  +		    && strcmp (p_tag->value, "yes") == 0)
  1176   1122   		    area = 1;
  1177         -		p_tag = p_tag->next;
  1178   1123   	    }
  1179   1124   
  1180   1125   	  /* attempting to recover undeclared areas */
  1181         -	  if (is_areal_layer () && is_closed (geom))
         1126  +	  if (is_areal_layer (way) && is_closed (geom))
  1182   1127   	      area = 1;
  1183   1128   
  1184   1129   	  if (area)
  1185   1130   	    {
  1186   1131   		free (blob);
  1187   1132   		geom = convert_to_polygon (geom);
  1188   1133   		gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
  1189   1134   	    }
  1190   1135   	  gaiaFreeGeomColl (geom);
  1191         -	  eval_way (params, area, blob, blob_size);
         1136  +	  ret = eval_way (params, way, area, blob, blob_size);
  1192   1137   	  free (blob);
  1193         -      }
  1194         -    p_tag = glob_way.first;
  1195         -    while (p_tag)
  1196         -      {
  1197         -	  p_tag2 = p_tag->next;
  1198         -	  free_tag (p_tag);
  1199         -	  p_tag = p_tag2;
  1200         -      }
  1201         -    p_nd = glob_way.first_nd;
  1202         -    while (p_nd)
  1203         -      {
  1204         -	  p_nd2 = p_nd->next;
  1205         -	  free (p_nd);
  1206         -	  p_nd = p_nd2;
  1207         -      }
  1208         -    glob_way.id = -1;
  1209         -    glob_way.first_nd = NULL;
  1210         -    glob_way.last_nd = NULL;
  1211         -    glob_way.first = NULL;
  1212         -    glob_way.last = NULL;
  1213         -    params->current_tag = CURRENT_TAG_UNKNOWN;
  1214         -}
  1215         -
  1216         -static void
  1217         -start_nd (const char **attr)
  1218         -{
  1219         -    struct nd *p_nd = malloc (sizeof (struct nd));
  1220         -    int i;
  1221         -    p_nd->ref = -1;
  1222         -    p_nd->found = 0;
  1223         -    p_nd->next = NULL;
  1224         -    for (i = 0; attr[i]; i += 2)
  1225         -      {
  1226         -	  if (strcmp (attr[i], "ref") == 0)
  1227         -	      p_nd->ref = atol_64 (attr[i + 1]);
  1228         -      }
  1229         -    if (glob_way.first_nd == NULL)
  1230         -	glob_way.first_nd = p_nd;
  1231         -    if (glob_way.last_nd != NULL)
  1232         -	glob_way.last_nd->next = p_nd;
  1233         -    glob_way.last_nd = p_nd;
  1234         -}
  1235         -
  1236         -static void
  1237         -start_xtag (struct aux_params *params, const char **attr)
  1238         -{
  1239         -    struct tag *p_tag = malloc (sizeof (struct tag));
  1240         -    int i;
  1241         -    int len;
  1242         -    p_tag->k = NULL;
  1243         -    p_tag->v = NULL;
  1244         -    p_tag->next = NULL;
  1245         -    for (i = 0; attr[i]; i += 2)
  1246         -      {
  1247         -	  if (strcmp (attr[i], "k") == 0)
  1248         -	    {
  1249         -		len = strlen (attr[i + 1]);
  1250         -		p_tag->k = malloc (len + 1);
  1251         -		strcpy (p_tag->k, attr[i + 1]);
  1252         -	    }
  1253         -	  if (strcmp (attr[i], "v") == 0)
  1254         -	    {
  1255         -		len = strlen (attr[i + 1]);
  1256         -		p_tag->v = malloc (len + 1);
  1257         -		strcpy (p_tag->v, attr[i + 1]);
  1258         -	    }
  1259         -      }
  1260         -    if (params->current_tag == CURRENT_TAG_IS_NODE)
  1261         -      {
  1262         -	  if (glob_node.first == NULL)
  1263         -	      glob_node.first = p_tag;
  1264         -	  if (glob_node.last != NULL)
  1265         -	      glob_node.last->next = p_tag;
  1266         -	  glob_node.last = p_tag;
  1267         -      }
  1268         -    if (params->current_tag == CURRENT_TAG_IS_WAY)
  1269         -      {
  1270         -	  if (glob_way.first == NULL)
  1271         -	      glob_way.first = p_tag;
  1272         -	  if (glob_way.last != NULL)
  1273         -	      glob_way.last->next = p_tag;
  1274         -	  glob_way.last = p_tag;
  1275         -      }
  1276         -    if (params->current_tag == CURRENT_TAG_IS_RELATION)
  1277         -      {
  1278         -	  if (glob_relation.first == NULL)
  1279         -	      glob_relation.first = p_tag;
  1280         -	  if (glob_relation.last != NULL)
  1281         -	      glob_relation.last->next = p_tag;
  1282         -	  glob_relation.last = p_tag;
  1283         -      }
  1284         -}
  1285         -
  1286         -static void
  1287         -start_member (const char **attr)
  1288         -{
  1289         -    struct member *p_member = malloc (sizeof (struct member));
  1290         -    int i;
  1291         -    int len;
  1292         -    p_member->ref = -1;
  1293         -    p_member->is_node = 0;
  1294         -    p_member->is_way = 0;
  1295         -    p_member->found = 0;
  1296         -    p_member->role = NULL;
  1297         -    p_member->next = NULL;
  1298         -    for (i = 0; attr[i]; i += 2)
  1299         -      {
  1300         -	  if (strcmp (attr[i], "type") == 0)
  1301         -	    {
  1302         -		if (strcmp (attr[i + 1], "node") == 0)
  1303         -		  {
  1304         -		      p_member->is_node = 1;
  1305         -		      p_member->is_way = 0;
  1306         -		  }
  1307         -		else if (strcmp (attr[i + 1], "way") == 0)
  1308         -		  {
  1309         -		      p_member->is_node = 0;
  1310         -		      p_member->is_way = 1;
  1311         -		  }
  1312         -		else
  1313         -		  {
  1314         -		      p_member->is_node = 0;
  1315         -		      p_member->is_way = 0;
  1316         -		  }
  1317         -	    }
  1318         -	  if (strcmp (attr[i], "ref") == 0)
  1319         -	      p_member->ref = atol_64 (attr[i + 1]);
  1320         -	  if (strcmp (attr[i], "role") == 0)
  1321         -	    {
  1322         -		len = strlen (attr[i + 1]);
  1323         -		p_member->role = malloc (len + 1);
  1324         -		strcpy (p_member->role, attr[i + 1]);
  1325         -	    }
  1326         -      }
  1327         -    if (glob_relation.first_member == NULL)
  1328         -	glob_relation.first_member = p_member;
  1329         -    if (glob_relation.last_member != NULL)
  1330         -	glob_relation.last_member->next = p_member;
  1331         -    glob_relation.last_member = p_member;
  1332         -}
  1333         -
  1334         -static void
  1335         -start_relation (struct aux_params *params, const char **attr)
  1336         -{
  1337         -    int i;
  1338         -    glob_relation.id = -1;
  1339         -    glob_relation.first_member = NULL;
  1340         -    glob_relation.last_member = NULL;
  1341         -    glob_relation.first = NULL;
  1342         -    glob_relation.last = NULL;
  1343         -    for (i = 0; attr[i]; i += 2)
  1344         -      {
  1345         -	  if (strcmp (attr[i], "id") == 0)
  1346         -	      glob_relation.id = atol_64 (attr[i + 1]);
  1347         -      }
  1348         -    params->current_tag = CURRENT_TAG_IS_RELATION;
         1138  +	  if (ret)
         1139  +	      return READOSM_OK;
         1140  +	  return READOSM_ABORT;
         1141  +      }
         1142  +    return READOSM_OK;
         1143  +}
         1144  +
         1145  +static struct way_refs *
         1146  +create_way_refs (const readosm_relation * relation)
         1147  +{
         1148  +/* creating and initializing the way_refs helper struct */
         1149  +    int i_member;
         1150  +    const readosm_member *p_member;
         1151  +    struct way_refs *refs = NULL;
         1152  +    int count = 0;
         1153  +
         1154  +    for (i_member = 0; i_member < relation->member_count; i_member++)
         1155  +      {
         1156  +	  p_member = relation->members + i_member;
         1157  +	  if (p_member->member_type == READOSM_MEMBER_WAY)
         1158  +	      count++;
         1159  +      }
         1160  +    if (!count)
         1161  +	return NULL;
         1162  +    refs = malloc (sizeof (struct way_refs));
         1163  +    if (refs == NULL)
         1164  +	return NULL;
         1165  +    refs->count = count;
         1166  +    refs->id = malloc (sizeof (sqlite3_int64) * refs->count);
         1167  +    if (refs->id == NULL)
         1168  +      {
         1169  +	  free (refs);
         1170  +	  return NULL;
         1171  +      }
         1172  +    refs->found = malloc (refs->count);
         1173  +    if (refs->found == NULL)
         1174  +      {
         1175  +	  free (refs->id);
         1176  +	  free (refs);
         1177  +	  return NULL;
         1178  +      }
         1179  +    count = 0;
         1180  +    for (i_member = 0; i_member < relation->member_count; i_member++)
         1181  +      {
         1182  +	  p_member = relation->members + i_member;
         1183  +	  if (p_member->member_type == READOSM_MEMBER_WAY)
         1184  +	    {
         1185  +		*(refs->id + count) = p_member->id;
         1186  +		*(refs->found + count) = 'N';
         1187  +		count++;
         1188  +	    }
         1189  +      }
         1190  +    return refs;
         1191  +}
         1192  +
         1193  +static void
         1194  +update_way_refs (struct way_refs *ways, sqlite3_int64 id, gaiaGeomCollPtr geom,
         1195  +		 gaiaGeomCollPtr org_geom)
         1196  +{
         1197  +/* updating the way_refs helper struct */
         1198  +    int i_ref;
         1199  +    gaiaLinestringPtr ln1;
         1200  +    for (i_ref = 0; i_ref < ways->count; i_ref++)
         1201  +      {
         1202  +	  if (*(ways->id + i_ref) == id)
         1203  +	    {
         1204  +		*(ways->found + i_ref) = 'Y';
         1205  +		ln1 = org_geom->FirstLinestring;
         1206  +		while (ln1)
         1207  +		  {
         1208  +		      int iv;
         1209  +		      gaiaLinestringPtr ln2 =
         1210  +			  gaiaAddLinestringToGeomColl (geom, ln1->Points);
         1211  +		      for (iv = 0; iv < ln1->Points; iv++)
         1212  +			{
         1213  +			    double x;
         1214  +			    double y;
         1215  +			    gaiaGetPoint (ln1->Coords, iv, &x, &y);
         1216  +			    gaiaSetPoint (ln2->Coords, iv, x, y);
         1217  +			}
         1218  +		      ln1 = ln1->Next;
         1219  +		  }
         1220  +	    }
         1221  +      }
         1222  +}
         1223  +
         1224  +static void
         1225  +destroy_way_refs (struct way_refs *ways)
         1226  +{
         1227  +/* destroying the way_refs helper struct */
         1228  +    if (ways == NULL)
         1229  +	return;
         1230  +    if (ways->id != NULL)
         1231  +	free (ways->id);
         1232  +    if (ways->found != NULL)
         1233  +	free (ways->found);
         1234  +    free (ways);
  1349   1235   }
  1350   1236   
  1351   1237   static gaiaGeomCollPtr
  1352         -build_multilinestring (sqlite3 * db_handle)
         1238  +build_multilinestring (sqlite3 * db_handle, const readosm_relation * relation)
  1353   1239   {
  1354   1240       gaiaGeomCollPtr geom;
  1355   1241       int lines = 0;
  1356   1242       int tbd;
  1357   1243       int block = 128;
  1358   1244       int base = 0;
  1359   1245       int how_many;
  1360   1246       int ind;
  1361   1247       int ret;
  1362         -    int count;
  1363   1248       char sql[8192];
  1364   1249       sqlite3_stmt *stmt;
  1365   1250       sqlite3_int64 id;
  1366   1251       const unsigned char *blob = NULL;
  1367   1252       int blob_size;
  1368   1253       gaiaGeomCollPtr org_geom;
  1369         -    struct member *p_member = glob_relation.first_member;
  1370         -    while (p_member)
  1371         -      {
  1372         -	  lines++;
  1373         -	  p_member = p_member->next;
  1374         -      }
         1254  +    static struct way_refs *refs = NULL;
         1255  +    int i_member;
         1256  +
         1257  +    refs = create_way_refs (relation);
         1258  +    if (refs == NULL)
         1259  +	return NULL;
         1260  +    lines = refs->count;
  1375   1261       if (!lines)
  1376   1262   	return NULL;
  1377   1263       geom = gaiaAllocGeomColl ();
  1378   1264       geom->Srid = 4326;
  1379   1265       geom->DeclaredType = GAIA_MULTILINESTRING;
  1380   1266       tbd = lines;
  1381   1267       while (tbd > 0)
  1382   1268         {
  1383   1269   	  /* 
  1384   1270   	     / fetching ways
  1385         -	     / requesting max 128 points at each time 
         1271  +	     / requesting max 128 ways at each time 
  1386   1272   	   */
  1387   1273   	  if (tbd < block)
  1388   1274   	      how_many = tbd;
  1389   1275   	  else
  1390   1276   	      how_many = block;
  1391   1277   	  strcpy (sql, "SELECT id, Geometry FROM osm_tmp_ways ");
  1392   1278   	  strcat (sql, "WHERE id IN (");
................................................................................
  1405   1291   			 sqlite3_errmsg (db_handle));
  1406   1292   		gaiaFreeGeomColl (geom);
  1407   1293   		return NULL;
  1408   1294   	    }
  1409   1295   	  sqlite3_reset (stmt);
  1410   1296   	  sqlite3_clear_bindings (stmt);
  1411   1297   	  ind = 1;
  1412         -	  count = 0;
  1413         -	  p_member = glob_relation.first_member;
  1414         -	  while (p_member)
         1298  +	  for (i_member = 0; i_member < refs->count; i_member++)
  1415   1299   	    {
  1416         -		if (count < base)
  1417         -		  {
  1418         -		      count++;
  1419         -		      p_member = p_member->next;
  1420         -		      continue;
  1421         -		  }
  1422         -		if (count >= (base + how_many))
         1300  +		if (i_member < base)
         1301  +		    continue;
         1302  +		if (i_member >= (base + how_many))
  1423   1303   		    break;
  1424         -		sqlite3_bind_int64 (stmt, ind, p_member->ref);
         1304  +		sqlite3_bind_int64 (stmt, ind, *(refs->id + i_member));
  1425   1305   		ind++;
  1426         -		count++;
  1427         -		p_member = p_member->next;
  1428   1306   	    }
  1429   1307   	  while (1)
  1430   1308   	    {
  1431   1309   		/* scrolling the result set */
  1432   1310   		ret = sqlite3_step (stmt);
  1433   1311   		if (ret == SQLITE_DONE)
  1434   1312   		  {
................................................................................
  1441   1319   		      id = sqlite3_column_int64 (stmt, 0);
  1442   1320   		      blob = sqlite3_column_blob (stmt, 1);
  1443   1321   		      blob_size = sqlite3_column_bytes (stmt, 1);
  1444   1322   		      org_geom = gaiaFromSpatiaLiteBlobWkb (blob, blob_size);
  1445   1323   
  1446   1324   		      if (org_geom)
  1447   1325   			{
  1448         -			    p_member = glob_relation.first_member;
  1449         -			    count = 0;
  1450         -			    while (p_member)
  1451         -			      {
  1452         -				  if (p_member->ref == id)
  1453         -				    {
  1454         -					gaiaLinestringPtr ln1;
  1455         -					p_member->found = 1;
  1456         -					ln1 = org_geom->FirstLinestring;
  1457         -					while (ln1)
  1458         -					  {
  1459         -					      int iv;
  1460         -					      gaiaLinestringPtr ln2 =
  1461         -						  gaiaAddLinestringToGeomColl
  1462         -						  (geom, ln1->Points);
  1463         -					      for (iv = 0; iv < ln2->Points;
  1464         -						   iv++)
  1465         -						{
  1466         -						    double x;
  1467         -						    double y;
  1468         -						    gaiaGetPoint (ln1->Coords,
  1469         -								  iv, &x, &y);
  1470         -						    gaiaSetPoint (ln2->Coords,
  1471         -								  iv, x, y);
  1472         -						}
  1473         -					      ln1 = ln1->Next;
  1474         -					  }
  1475         -				    }
  1476         -				  count++;
  1477         -				  p_member = p_member->next;
  1478         -			      }
         1326  +			    update_way_refs (refs, id, geom, org_geom);
  1479   1327   			    gaiaFreeGeomColl (org_geom);
  1480   1328   			}
  1481   1329   		  }
  1482   1330   		else
  1483   1331   		  {
  1484   1332   		      /* some unexpected error occurred */
  1485   1333   		      fprintf (stderr, "sqlite3_step() error: %s\n",
................................................................................
  1490   1338   	    }
  1491   1339   	  sqlite3_finalize (stmt);
  1492   1340   	  tbd -= how_many;
  1493   1341   	  base += how_many;
  1494   1342         }
  1495   1343   
  1496   1344   /* final checkout */
  1497         -    p_member = glob_relation.first_member;
  1498         -    while (p_member)
         1345  +    for (ind = 0; ind < refs->count; ind++)
  1499   1346         {
  1500         -	  if (p_member->found == 0)
         1347  +	  if (*(refs->found + ind) == 'N')
  1501   1348   	    {
  1502   1349   #if defined(_WIN32) || defined(__MINGW32__)
  1503   1350   		/* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */
  1504         -		fprintf (stderr, "UNRESOLVED-WAY %I64d\n", p_member->ref);
         1351  +		fprintf (stderr, "UNRESOLVED-WAY %I64d\n", *(refs->id + ind));
  1505   1352   #else
  1506         -		fprintf (stderr, "UNRESOLVED-WAY %lld\n", p_member->ref);
         1353  +		fprintf (stderr, "UNRESOLVED-WAY %lld\n", *(refs->id + ind));
  1507   1354   #endif
  1508   1355   		gaiaFreeGeomColl (geom);
         1356  +		destroy_way_refs (refs);
  1509   1357   		return NULL;
  1510   1358   	    }
  1511         -	  p_member = p_member->next;
  1512   1359         }
         1360  +    destroy_way_refs (refs);
  1513   1361       return geom;
  1514   1362   }
  1515   1363   
  1516         -static void
         1364  +static int
  1517   1365   multiline_layer_insert (struct aux_params *params, const char *layer_name,
  1518         -			const char *sub_type, const char *name)
         1366  +			const char *sub_type, const readosm_relation * relation,
         1367  +			const char *name)
  1519   1368   {
  1520   1369       gaiaGeomCollPtr geom;
  1521   1370       unsigned char *blob = NULL;
  1522   1371       int blob_size;
  1523   1372       struct layers *layer;
  1524   1373       int i = 0;
  1525   1374       while (1)
  1526   1375         {
  1527   1376   	  layer = &(base_layers[i++]);
  1528   1377   	  if (layer->name == NULL)
  1529         -	      return;
         1378  +	      return 1;
  1530   1379   	  if (strcmp (layer->name, layer_name) == 0)
  1531   1380   	    {
  1532   1381   		if (layer->ok_linestring == 0)
  1533   1382   		  {
  1534   1383   		      layer->ok_linestring = 1;
  1535   1384   		      create_linestring_table (params, layer);
  1536   1385   		  }
  1537         -		geom = build_multilinestring (params->db_handle);
         1386  +		geom = build_multilinestring (params->db_handle, relation);
  1538   1387   		if (geom)
  1539   1388   		  {
  1540   1389   		      gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
  1541   1390   		      gaiaFreeGeomColl (geom);
  1542   1391   		  }
  1543   1392   		if (layer->ins_linestring_stmt && blob)
  1544   1393   		  {
  1545   1394   		      int ret;
  1546   1395   		      sqlite3_reset (layer->ins_linestring_stmt);
  1547   1396   		      sqlite3_clear_bindings (layer->ins_linestring_stmt);
  1548   1397   		      sqlite3_bind_int64 (layer->ins_linestring_stmt, 1,
  1549         -					  glob_relation.id);
         1398  +					  relation->id);
  1550   1399   		      if (sub_type == NULL)
  1551   1400   			  sqlite3_bind_null (layer->ins_linestring_stmt, 2);
  1552   1401   		      else
  1553   1402   			  sqlite3_bind_text (layer->ins_linestring_stmt, 2,
  1554   1403   					     sub_type, strlen (sub_type),
  1555   1404   					     SQLITE_STATIC);
  1556   1405   		      if (name == NULL)
................................................................................
  1559   1408   			  sqlite3_bind_text (layer->ins_linestring_stmt, 3,
  1560   1409   					     name, strlen (name),
  1561   1410   					     SQLITE_STATIC);
  1562   1411   		      sqlite3_bind_blob (layer->ins_linestring_stmt, 4, blob,
  1563   1412   					 blob_size, free);
  1564   1413   		      ret = sqlite3_step (layer->ins_linestring_stmt);
  1565   1414   		      if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1566         -			  return;
         1415  +			  return 1;
  1567   1416   		      fprintf (stderr,
  1568   1417   			       "sqlite3_step() error: INS_MULTILINESTRING %s\n",
  1569   1418   			       layer_name);
  1570   1419   		      sqlite3_finalize (layer->ins_linestring_stmt);
  1571   1420   		      layer->ins_linestring_stmt = NULL;
         1421  +		      return 0;
         1422  +		  }
         1423  +		return 1;
         1424  +	    }
         1425  +      }
         1426  +    return 1;
         1427  +}
         1428  +
         1429  +static struct ring_refs *
         1430  +create_ring_refs (const readosm_relation * relation)
         1431  +{
         1432  +/* creating and initializing the ring_refs helper struct */
         1433  +    int i_member;
         1434  +    const readosm_member *p_member;
         1435  +    struct ring_refs *refs = NULL;
         1436  +    int count = 0;
         1437  +
         1438  +    for (i_member = 0; i_member < relation->member_count; i_member++)
         1439  +      {
         1440  +	  p_member = relation->members + i_member;
         1441  +	  if (p_member->member_type == READOSM_MEMBER_WAY)
         1442  +	    {
         1443  +		if (p_member->role)
         1444  +		  {
         1445  +		      if (strcmp (p_member->role, "inner") == 0
         1446  +			  || strcmp (p_member->role, "outer") == 0)
         1447  +			  count++;
         1448  +		  }
         1449  +	    }
         1450  +      }
         1451  +    if (!count)
         1452  +	return NULL;
         1453  +    refs = malloc (sizeof (struct ring_refs));
         1454  +    if (refs == NULL)
         1455  +	return NULL;
         1456  +    refs->count = count;
         1457  +    refs->id = malloc (sizeof (sqlite3_int64) * refs->count);
         1458  +    if (refs->id == NULL)
         1459  +      {
         1460  +	  free (refs);
         1461  +	  return NULL;
         1462  +      }
         1463  +    refs->found = malloc (refs->count);
         1464  +    if (refs->found == NULL)
         1465  +      {
         1466  +	  free (refs->id);
         1467  +	  free (refs);
         1468  +	  return NULL;
         1469  +      }
         1470  +    refs->geom = malloc (sizeof (gaiaGeomCollPtr) * refs->count);
         1471  +    if (refs->geom == NULL)
         1472  +      {
         1473  +	  free (refs->id);
         1474  +	  free (refs->found);
         1475  +	  free (refs);
         1476  +	  return NULL;
         1477  +      }
         1478  +    refs->outer = malloc (refs->count);
         1479  +    if (refs->outer == NULL)
         1480  +      {
         1481  +	  free (refs->id);
         1482  +	  free (refs->found);
         1483  +	  free (refs->geom);
         1484  +	  free (refs);
         1485  +	  return NULL;
         1486  +      }
         1487  +    memset (refs->outer, 'N', refs->count);
         1488  +    memset (refs->found, 'N', refs->count);
         1489  +    count = 0;
         1490  +    for (i_member = 0; i_member < relation->member_count; i_member++)
         1491  +      {
         1492  +	  p_member = relation->members + i_member;
         1493  +	  if (p_member->member_type == READOSM_MEMBER_WAY)
         1494  +	    {
         1495  +		int is_outer = 0;
         1496  +		int ok = 0;
         1497  +		if (p_member->role)
         1498  +		  {
         1499  +		      if (strcmp (p_member->role, "inner") == 0)
         1500  +			  ok = 1;
         1501  +		      if (strcmp (p_member->role, "outer") == 0)
         1502  +			{
         1503  +			    is_outer = 1;
         1504  +			    ok = 1;
         1505  +			}
  1572   1506   		  }
  1573         -		return;
         1507  +		if (!ok)
         1508  +		    continue;
         1509  +		*(refs->id + count) = p_member->id;
         1510  +		*(refs->geom + count) = NULL;
         1511  +		if (is_outer)
         1512  +		    *(refs->outer + count) = 'Y';
         1513  +		count++;
  1574   1514   	    }
  1575   1515         }
         1516  +    return refs;
         1517  +}
         1518  +
         1519  +static void
         1520  +update_ring_refs (struct ring_refs *rings, sqlite3_int64 id,
         1521  +		  gaiaGeomCollPtr geom)
         1522  +{
         1523  +/* updating the ring_refs helper struct */
         1524  +    int i_ref;
         1525  +    for (i_ref = 0; i_ref < rings->count; i_ref++)
         1526  +      {
         1527  +	  if (*(rings->id + i_ref) == id)
         1528  +	    {
         1529  +		*(rings->found + i_ref) = 'Y';
         1530  +		*(rings->geom + i_ref) = geom;
         1531  +	    }
         1532  +      }
         1533  +}
         1534  +
         1535  +static void
         1536  +destroy_ring_refs (struct ring_refs *rings)
         1537  +{
         1538  +/* destroying the ring_refs helper struct */
         1539  +    int i;
         1540  +    gaiaGeomCollPtr g;
         1541  +
         1542  +    if (rings == NULL)
         1543  +	return;
         1544  +    if (rings->id != NULL)
         1545  +	free (rings->id);
         1546  +    if (rings->found != NULL)
         1547  +	free (rings->found);
         1548  +    if (rings->outer != NULL)
         1549  +	free (rings->outer);
         1550  +    if (rings->geom != NULL)
         1551  +      {
         1552  +	  for (i = 0; i < rings->count; i++)
         1553  +	    {
         1554  +		g = *(rings->geom + i);
         1555  +		if (g)
         1556  +		    gaiaFreeGeomColl (g);
         1557  +	    }
         1558  +	  free (rings->geom);
         1559  +      }
         1560  +    free (rings);
  1576   1561   }
  1577   1562   
  1578   1563   static gaiaGeomCollPtr
  1579         -build_multipolygon (sqlite3 * db_handle)
         1564  +build_multipolygon (sqlite3 * db_handle, const readosm_relation * relation)
  1580   1565   {
  1581   1566       gaiaGeomCollPtr geom;
  1582         -    gaiaPolygonPtr pg2 = NULL;
         1567  +    gaiaPolygonPtr pg = NULL;
  1583   1568       int rings = 0;
  1584   1569       int interiors = 0;
  1585   1570       int exteriors = 0;
  1586   1571       int ext_pts;
  1587   1572       int ib = 0;
  1588   1573       int tbd;
  1589   1574       int block = 128;
  1590   1575       int base = 0;
  1591   1576       int how_many;
  1592   1577       int ind;
  1593   1578       int ret;
  1594         -    int count;
  1595   1579       char sql[8192];
  1596   1580       sqlite3_stmt *stmt;
  1597   1581       sqlite3_int64 id;
  1598   1582   
  1599   1583       const unsigned char *blob = NULL;
  1600   1584       int blob_size;
  1601   1585       gaiaGeomCollPtr org_geom;
  1602         -    struct member *p_member = glob_relation.first_member;
  1603         -    while (p_member)
         1586  +    int i_member;
         1587  +    const readosm_member *p_member;
         1588  +    struct ring_refs *refs = NULL;
         1589  +
         1590  +    for (i_member = 0; i_member < relation->member_count; i_member++)
  1604   1591         {
  1605         -	  rings++;
  1606         -	  if (p_member->role)
         1592  +	  p_member = relation->members + i_member;
         1593  +	  if (p_member->member_type == READOSM_MEMBER_WAY)
  1607   1594   	    {
  1608         -		if (strcmp (p_member->role, "inner") == 0)
  1609         -		    interiors++;
  1610         -		if (strcmp (p_member->role, "outer") == 0)
  1611         -		    exteriors++;
         1595  +		rings++;
         1596  +		if (p_member->role)
         1597  +		  {
         1598  +		      if (strcmp (p_member->role, "inner") == 0)
         1599  +			  interiors++;
         1600  +		      if (strcmp (p_member->role, "outer") == 0)
         1601  +			  exteriors++;
         1602  +		  }
  1612   1603   	    }
  1613         -	  p_member = p_member->next;
  1614   1604         }
  1615   1605       if (!rings)
  1616   1606   	return NULL;
  1617   1607       if (exteriors != 1)
  1618   1608   	return NULL;
  1619   1609       if (interiors + 1 != rings)
  1620   1610   	return NULL;
         1611  +    refs = create_ring_refs (relation);
  1621   1612       geom = gaiaAllocGeomColl ();
  1622   1613       geom->Srid = 4326;
  1623   1614       geom->DeclaredType = GAIA_MULTIPOLYGON;
  1624   1615       tbd = rings;
  1625   1616       while (tbd > 0)
  1626   1617         {
  1627   1618   	  /* 
................................................................................
  1649   1640   			 sqlite3_errmsg (db_handle));
  1650   1641   		gaiaFreeGeomColl (geom);
  1651   1642   		return NULL;
  1652   1643   	    }
  1653   1644   	  sqlite3_reset (stmt);
  1654   1645   	  sqlite3_clear_bindings (stmt);
  1655   1646   	  ind = 1;
  1656         -	  count = 0;
  1657         -	  p_member = glob_relation.first_member;
  1658         -	  while (p_member)
         1647  +
         1648  +	  for (i_member = 0; i_member < refs->count; i_member++)
  1659   1649   	    {
  1660         -		if (count < base)
  1661         -		  {
  1662         -		      count++;
  1663         -		      p_member = p_member->next;
  1664         -		      continue;
  1665         -		  }
  1666         -		if (count >= (base + how_many))
         1650  +		if (i_member < base)
         1651  +		    continue;
         1652  +		if (i_member >= (base + how_many))
  1667   1653   		    break;
  1668         -		sqlite3_bind_int64 (stmt, ind, p_member->ref);
         1654  +		sqlite3_bind_int64 (stmt, ind, *(refs->id + i_member));
  1669   1655   		ind++;
  1670         -		count++;
  1671         -		p_member = p_member->next;
  1672   1656   	    }
  1673   1657   	  while (1)
  1674   1658   	    {
  1675   1659   		/* scrolling the result set */
  1676   1660   		ret = sqlite3_step (stmt);
  1677   1661   		if (ret == SQLITE_DONE)
  1678   1662   		  {
................................................................................
  1683   1667   		  {
  1684   1668   		      /* ok, we've just fetched a valid row */
  1685   1669   		      id = sqlite3_column_int64 (stmt, 0);
  1686   1670   		      blob = sqlite3_column_blob (stmt, 2);
  1687   1671   		      blob_size = sqlite3_column_bytes (stmt, 2);
  1688   1672   		      org_geom = gaiaFromSpatiaLiteBlobWkb (blob, blob_size);
  1689   1673   		      if (org_geom)
  1690         -			{
  1691         -			    while (p_member)
  1692         -			      {
  1693         -				  if (p_member->ref == id)
  1694         -				    {
  1695         -					p_member->geom = org_geom;
  1696         -					p_member->found = 1;
  1697         -				    }
  1698         -				  p_member = p_member->next;
  1699         -			      }
  1700         -			}
         1674  +			  update_ring_refs (refs, id, org_geom);
  1701   1675   		  }
  1702   1676   		else
  1703   1677   		  {
  1704   1678   		      /* some unexpected error occurred */
  1705   1679   		      fprintf (stderr, "sqlite3_step() error: %s\n",
  1706   1680   			       sqlite3_errmsg (db_handle));
  1707   1681   		      sqlite3_finalize (stmt);
................................................................................
  1711   1685   	  sqlite3_finalize (stmt);
  1712   1686   	  tbd -= how_many;
  1713   1687   	  base += how_many;
  1714   1688         }
  1715   1689   
  1716   1690   /* final checkout */
  1717   1691       ext_pts = 0;
  1718         -    p_member = glob_relation.first_member;
  1719         -    while (p_member)
         1692  +    for (i_member = 0; i_member < refs->count; i_member++)
  1720   1693         {
  1721         -	  if (p_member->found == 0)
         1694  +	  if (*(refs->found + i_member) == 'N')
  1722   1695   	    {
         1696  +		id = *(refs->id + i_member);
  1723   1697   #if defined(_WIN32) || defined(__MINGW32__)
  1724   1698   		/* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */
  1725         -		fprintf (stderr, "UNRESOLVED-WAY %I64d\n", p_member->ref);
         1699  +		fprintf (stderr, "UNRESOLVED-WAY %I64d\n", id);
  1726   1700   #else
  1727         -		fprintf (stderr, "UNRESOLVED-WAY %lld\n", p_member->ref);
         1701  +		fprintf (stderr, "UNRESOLVED-WAY %lld\n", id);
  1728   1702   #endif
  1729   1703   		gaiaFreeGeomColl (geom);
         1704  +		destroy_ring_refs (refs);
  1730   1705   		return NULL;
  1731   1706   	    }
  1732         -	  if (strcmp (p_member->role, "outer") == 0)
         1707  +	  if (*(refs->outer + i_member) == 'Y')
  1733   1708   	    {
  1734         -		if (p_member->geom)
         1709  +		gaiaGeomCollPtr g = *(refs->geom + i_member);
         1710  +		if (g)
  1735   1711   		  {
  1736         -		      if (p_member->geom->FirstPolygon)
  1737         -			  ext_pts =
  1738         -			      p_member->geom->FirstPolygon->Exterior->Points;
         1712  +		      if (g->FirstLinestring)
         1713  +			  ext_pts = g->FirstLinestring->Points;
  1739   1714   		  }
  1740   1715   	    }
  1741         -	  p_member = p_member->next;
  1742   1716         }
  1743   1717       if (!ext_pts)
  1744   1718         {
  1745   1719   #if defined(_WIN32) || defined(__MINGW32__)
  1746   1720   	  /* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */
  1747         -	  fprintf (stderr, "ILLEGAL MULTIPOLYGON %I64d\n", p_member->ref);
         1721  +	  fprintf (stderr, "ILLEGAL MULTIPOLYGON %I64d\n", id);
  1748   1722   #else
  1749         -	  fprintf (stderr, "ILLEGAL MULTIPOLYGON %lld\n", p_member->ref);
         1723  +	  fprintf (stderr, "ILLEGAL MULTIPOLYGON %lld\n", id);
  1750   1724   #endif
  1751   1725   	  gaiaFreeGeomColl (geom);
         1726  +	  destroy_ring_refs (refs);
  1752   1727   	  return NULL;
  1753   1728         }
  1754   1729   
  1755         -    pg2 = gaiaAddPolygonToGeomColl (geom, ext_pts, interiors);
  1756         -    p_member = glob_relation.first_member;
  1757         -    while (p_member)
  1758         -      {
  1759         -	  gaiaPolygonPtr pg1;
  1760         -	  pg1 = org_geom->FirstPolygon;
  1761         -	  while (pg1)
  1762         -	    {
  1763         -		int iv;
  1764         -		gaiaRingPtr rng1 = pg1->Exterior;
  1765         -		gaiaRingPtr rng2;
  1766         -		if (strcmp (p_member->role, "outer") == 0)
  1767         -		    rng2 = pg2->Exterior;
  1768         -		else
  1769         -		    rng2 = pg2->Interiors + ib++;
  1770         -		for (iv = 0; iv < rng2->Points; iv++)
  1771         -		  {
  1772         -		      double x;
  1773         -		      double y;
  1774         -		      gaiaGetPoint (rng1->Coords, iv, &x, &y);
  1775         -		      gaiaSetPoint (rng2->Coords, iv, x, y);
  1776         -		  }
  1777         -		pg1 = pg1->Next;
  1778         -	    }
  1779         -	  p_member = p_member->next;
  1780         -      }
         1730  +    pg = gaiaAddPolygonToGeomColl (geom, ext_pts, interiors);
         1731  +    for (i_member = 0; i_member < refs->count; i_member++)
         1732  +      {
         1733  +	  gaiaLinestringPtr ln;
         1734  +	  int iv;
         1735  +	  gaiaRingPtr rng;
         1736  +	  org_geom = *(refs->geom + i_member);
         1737  +	  ln = org_geom->FirstLinestring;
         1738  +	  if (*(refs->outer + i_member) == 'Y')
         1739  +	      rng = pg->Exterior;
         1740  +	  else
         1741  +	      rng = gaiaAddInteriorRing (pg, ib++, ln->Points);
         1742  +	  for (iv = 0; iv < ln->Points; iv++)
         1743  +	    {
         1744  +		double x;
         1745  +		double y;
         1746  +		gaiaGetPoint (ln->Coords, iv, &x, &y);
         1747  +		gaiaSetPoint (rng->Coords, iv, x, y);
         1748  +	    }
         1749  +      }
         1750  +    destroy_ring_refs (refs);
  1781   1751       return geom;
  1782   1752   }
  1783   1753   
  1784         -static void
         1754  +static int
  1785   1755   multipolygon_layer_insert (struct aux_params *params, const char *layer_name,
  1786         -			   const char *sub_type, const char *name)
         1756  +			   const char *sub_type,
         1757  +			   const readosm_relation * relation, const char *name)
  1787   1758   {
  1788   1759       gaiaGeomCollPtr geom;
  1789   1760       unsigned char *blob = NULL;
  1790   1761       int blob_size;
  1791   1762       struct layers *layer;
  1792   1763       int i = 0;
  1793   1764       while (1)
  1794   1765         {
  1795   1766   	  layer = &(base_layers[i++]);
  1796   1767   	  if (layer->name == NULL)
  1797         -	      return;
         1768  +	      return 1;
  1798   1769   	  if (strcmp (layer->name, layer_name) == 0)
  1799   1770   	    {
  1800   1771   		if (layer->ok_polygon == 0)
  1801   1772   		  {
  1802   1773   		      layer->ok_polygon = 1;
  1803   1774   		      create_polygon_table (params, layer);
  1804   1775   		  }
  1805         -		geom = build_multipolygon (params->db_handle);
         1776  +		geom = build_multipolygon (params->db_handle, relation);
  1806   1777   		if (geom)
  1807   1778   		  {
  1808   1779   		      gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
  1809   1780   		      gaiaFreeGeomColl (geom);
  1810   1781   		  }
  1811   1782   		if (layer->ins_polygon_stmt)
  1812   1783   		  {
  1813   1784   		      int ret;
  1814   1785   		      sqlite3_reset (layer->ins_polygon_stmt);
  1815   1786   		      sqlite3_clear_bindings (layer->ins_polygon_stmt);
  1816   1787   		      sqlite3_bind_int64 (layer->ins_polygon_stmt, 1,
  1817         -					  glob_relation.id);
         1788  +					  relation->id);
  1818   1789   		      if (sub_type == NULL)
  1819   1790   			  sqlite3_bind_null (layer->ins_polygon_stmt, 2);
  1820   1791   		      else
  1821   1792   			  sqlite3_bind_text (layer->ins_polygon_stmt, 2,
  1822   1793   					     sub_type, strlen (sub_type),
  1823   1794   					     SQLITE_STATIC);
  1824   1795   		      if (name == NULL)
................................................................................
  1826   1797   		      else
  1827   1798   			  sqlite3_bind_text (layer->ins_polygon_stmt, 3, name,
  1828   1799   					     strlen (name), SQLITE_STATIC);
  1829   1800   		      sqlite3_bind_blob (layer->ins_polygon_stmt, 4, blob,
  1830   1801   					 blob_size, SQLITE_STATIC);
  1831   1802   		      ret = sqlite3_step (layer->ins_polygon_stmt);
  1832   1803   		      if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1833         -			  return;
         1804  +			  return 1;
  1834   1805   		      fprintf (stderr,
  1835   1806   			       "sqlite3_step() error: INS_MULTIPOLYGON %s\n",
  1836   1807   			       layer_name);
  1837   1808   		      sqlite3_finalize (layer->ins_polygon_stmt);
  1838   1809   		      layer->ins_polygon_stmt = NULL;
         1810  +		      return 0;
  1839   1811   		  }
  1840         -		return;
         1812  +		return 1;
  1841   1813   	    }
  1842   1814         }
         1815  +    return 1;
  1843   1816   }
  1844   1817   
  1845         -static void
  1846         -multiline_generic_insert (struct aux_params *params, const char *name)
         1818  +static int
         1819  +multiline_generic_insert (struct aux_params *params,
         1820  +			  const readosm_relation * relation, const char *name)
  1847   1821   {
  1848   1822       gaiaGeomCollPtr geom;
  1849   1823       unsigned char *blob = NULL;
  1850   1824       int blob_size;
  1851         -    geom = build_multilinestring (params->db_handle);
         1825  +    geom = build_multilinestring (params->db_handle, relation);
  1852   1826       if (geom)
  1853   1827         {
  1854   1828   	  gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
  1855   1829   	  gaiaFreeGeomColl (geom);
  1856   1830         }
  1857   1831       if (params->ins_generic_linestring_stmt && blob)
  1858   1832         {
  1859   1833   	  int ret;
  1860   1834   	  sqlite3_reset (params->ins_generic_linestring_stmt);
  1861   1835   	  sqlite3_clear_bindings (params->ins_generic_linestring_stmt);
  1862   1836   	  sqlite3_bind_int64 (params->ins_generic_linestring_stmt, 1,
  1863         -			      glob_relation.id);
         1837  +			      relation->id);
  1864   1838   	  if (name == NULL)
  1865   1839   	      sqlite3_bind_null (params->ins_generic_linestring_stmt, 2);
  1866   1840   	  else
  1867   1841   	      sqlite3_bind_text (params->ins_generic_linestring_stmt, 2, name,
  1868   1842   				 strlen (name), SQLITE_STATIC);
  1869   1843   	  sqlite3_bind_blob (params->ins_generic_linestring_stmt, 3, blob,
  1870   1844   			     blob_size, SQLITE_STATIC);
  1871   1845   	  ret = sqlite3_step (params->ins_generic_linestring_stmt);
  1872   1846   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1873         -	      return;
         1847  +	      return 1;
  1874   1848   	  fprintf (stderr,
  1875   1849   		   "sqlite3_step() error: INS_GENERIC_MULTILINESTRING\n");
  1876   1850   	  sqlite3_finalize (params->ins_generic_linestring_stmt);
  1877   1851   	  params->ins_generic_linestring_stmt = NULL;
         1852  +	  return 0;
  1878   1853         }
         1854  +    return 1;
  1879   1855   }
  1880   1856   
  1881         -static void
  1882         -multipolygon_generic_insert (struct aux_params *params, const char *name)
         1857  +static int
         1858  +multipolygon_generic_insert (struct aux_params *params,
         1859  +			     const readosm_relation * relation,
         1860  +			     const char *name)
  1883   1861   {
  1884   1862       gaiaGeomCollPtr geom;
  1885   1863       unsigned char *blob = NULL;
  1886   1864       int blob_size;
  1887         -    geom = build_multipolygon (params->db_handle);
         1865  +    geom = build_multipolygon (params->db_handle, relation);
  1888   1866       if (geom)
  1889   1867         {
  1890   1868   	  gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
  1891   1869   	  gaiaFreeGeomColl (geom);
  1892   1870         }
  1893   1871       if (params->ins_generic_polygon_stmt && blob)
  1894   1872         {
  1895   1873   	  int ret;
  1896   1874   	  sqlite3_reset (params->ins_generic_polygon_stmt);
  1897   1875   	  sqlite3_clear_bindings (params->ins_generic_polygon_stmt);
  1898   1876   	  sqlite3_bind_int64 (params->ins_generic_polygon_stmt, 1,
  1899         -			      glob_relation.id);
         1877  +			      relation->id);
  1900   1878   	  if (name == NULL)
  1901   1879   	      sqlite3_bind_null (params->ins_generic_polygon_stmt, 2);
  1902   1880   	  else
  1903   1881   	      sqlite3_bind_text (params->ins_generic_polygon_stmt, 2, name,
  1904   1882   				 strlen (name), SQLITE_STATIC);
  1905   1883   	  sqlite3_bind_blob (params->ins_generic_polygon_stmt, 3, blob,
  1906   1884   			     blob_size, SQLITE_STATIC);
  1907   1885   	  ret = sqlite3_step (params->ins_generic_polygon_stmt);
  1908   1886   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1909         -	      return;
         1887  +	      return 1;
  1910   1888   	  fprintf (stderr, "sqlite3_step() error: INS_GENERIC_MULTIPOLYGON\n");
  1911   1889   	  sqlite3_finalize (params->ins_generic_polygon_stmt);
  1912   1890   	  params->ins_generic_polygon_stmt = NULL;
         1891  +	  return 0;
  1913   1892         }
         1893  +    return 1;
  1914   1894   }
  1915   1895   
  1916         -static void
  1917         -eval_relation (struct aux_params *params)
         1896  +static int
         1897  +consume_relation (const void *user_data, const readosm_relation * relation)
  1918   1898   {
  1919         -    struct tag *p_tag;
         1899  +/* processing an OSM Relation (ReadOSM callback function) */
         1900  +    struct aux_params *params = (struct aux_params *) user_data;
         1901  +    const readosm_tag *p_tag;
  1920   1902       const char *p;
  1921         -    int i = 0;
         1903  +    int i_tag = 0;
         1904  +    int i_lyr = 0;
         1905  +    int ret;
  1922   1906       const char *layer_name = NULL;
  1923         -    char *sub_type = NULL;
  1924         -    char *name = NULL;
         1907  +    const char *sub_type = NULL;
         1908  +    const char *name = NULL;
  1925   1909       int multipolygon = 0;
  1926         -    if (glob_relation.first == NULL)
  1927         -	return;
         1910  +
  1928   1911       while (1)
  1929   1912         {
  1930         -	  p = base_layers[i++].name;
         1913  +	  p = base_layers[i_lyr++].name;
  1931   1914   	  if (!p)
  1932   1915   	      break;
  1933         -	  p_tag = glob_relation.first;
  1934         -	  while (p_tag)
         1916  +	  for (i_tag = 0; i_tag < relation->tag_count; i_tag++)
  1935   1917   	    {
  1936         -		if (strcmp (p_tag->k, p) == 0)
         1918  +		p_tag = relation->tags + i_tag;
         1919  +		if (strcmp (p_tag->key, p) == 0)
  1937   1920   		  {
  1938   1921   		      layer_name = p;
  1939         -		      sub_type = p_tag->v;
         1922  +		      sub_type = p_tag->value;
  1940   1923   		  }
  1941         -		if (strcmp (p_tag->k, "name") == 0)
  1942         -		    name = p_tag->v;
  1943         -		if (strcmp (p_tag->k, "type") == 0
  1944         -		    && strcmp (p_tag->v, "multipolygon") == 0)
         1924  +		if (strcmp (p_tag->key, "name") == 0)
         1925  +		    name = p_tag->value;
         1926  +		if (strcmp (p_tag->key, "type") == 0
         1927  +		    && strcmp (p_tag->value, "multipolygon") == 0)
  1945   1928   		    multipolygon = 1;
  1946         -		p_tag = p_tag->next;
  1947   1929   	    }
  1948   1930   	  if (layer_name)
  1949   1931   	      break;
  1950   1932         }
         1933  +
  1951   1934       if (layer_name)
  1952   1935         {
  1953   1936   	  if (multipolygon)
  1954         -	      multipolygon_layer_insert (params, layer_name, sub_type, name);
         1937  +	      ret =
         1938  +		  multipolygon_layer_insert (params, layer_name, sub_type,
         1939  +					     relation, name);
  1955   1940   	  else
  1956         -	      multiline_layer_insert (params, layer_name, sub_type, name);
  1957         -	  return;
         1941  +	      ret =
         1942  +		  multiline_layer_insert (params, layer_name, sub_type,
         1943  +					  relation, name);
         1944  +	  if (ret)
         1945  +	      return READOSM_OK;
         1946  +	  return READOSM_ABORT;
  1958   1947         }
  1959   1948       else if (name != NULL)
  1960   1949         {
  1961   1950   	  if (multipolygon)
  1962         -	      multipolygon_generic_insert (params, name);
         1951  +	      ret = multipolygon_generic_insert (params, relation, name);
  1963   1952   	  else
  1964         -	      multiline_generic_insert (params, name);
  1965         -	  return;
         1953  +	      ret = multiline_generic_insert (params, relation, name);
         1954  +	  if (ret)
         1955  +	      return READOSM_OK;
         1956  +	  return READOSM_ABORT;
  1966   1957         }
  1967         -}
  1968         -
  1969         -static void
  1970         -end_relation (struct aux_params *params)
  1971         -{
  1972         -    struct tag *p_tag;
  1973         -    struct tag *p_tag2;
  1974         -    struct member *p_member;
  1975         -    struct member *p_member2;
  1976         -    eval_relation (params);
  1977         -    p_tag = glob_relation.first;
  1978         -    while (p_tag)
  1979         -      {
  1980         -	  p_tag2 = p_tag->next;
  1981         -	  free_tag (p_tag);
  1982         -	  p_tag = p_tag2;
  1983         -      }
  1984         -    p_member = glob_relation.first_member;
  1985         -    while (p_member)
  1986         -      {
  1987         -	  p_member2 = p_member->next;
  1988         -	  free_member (p_member);
  1989         -	  p_member = p_member2;
  1990         -      }
  1991         -    glob_relation.id = -1;
  1992         -    glob_relation.first_member = NULL;
  1993         -    glob_relation.last_member = NULL;
  1994         -    glob_relation.first = NULL;
  1995         -    glob_relation.last = NULL;
  1996         -    params->current_tag = CURRENT_TAG_UNKNOWN;
  1997         -}
  1998         -
  1999         -static void
  2000         -start_tag (void *data, const char *el, const char **attr)
  2001         -{
  2002         -    struct aux_params *params = (struct aux_params *) data;
  2003         -    if (strcmp (el, "node") == 0)
  2004         -	start_node (params, attr);
  2005         -    if (strcmp (el, "tag") == 0)
  2006         -	start_xtag (params, attr);
  2007         -    if (strcmp (el, "way") == 0)
  2008         -	start_way (params, attr);
  2009         -    if (strcmp (el, "nd") == 0)
  2010         -	start_nd (attr);
  2011         -    if (strcmp (el, "relation") == 0)
  2012         -	start_relation (params, attr);
  2013         -    if (strcmp (el, "member") == 0)
  2014         -	start_member (attr);
  2015         -}
  2016         -
  2017         -static void
  2018         -end_tag (void *data, const char *el)
  2019         -{
  2020         -    struct aux_params *params = (struct aux_params *) data;
  2021         -    if (strcmp (el, "node") == 0)
  2022         -	end_node (params);
  2023         -    if (strcmp (el, "way") == 0)
  2024         -	end_way (params);
  2025         -    if (strcmp (el, "relation") == 0)
  2026         -	end_relation (params);
         1958  +    return READOSM_OK;
  2027   1959   }
  2028   1960   
  2029   1961   static void
  2030   1962   db_vacuum (sqlite3 * db_handle)
  2031   1963   {
  2032   1964       int ret;
  2033   1965       char *sql_err = NULL;
................................................................................
  2380   2312   	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
  2381   2313   	  sqlite3_free (sql_err);
  2382   2314   	  return;
  2383   2315         }
  2384   2316   }
  2385   2317   
  2386   2318   static void
  2387         -create_sql_stmts (struct aux_params *params)
         2319  +create_sql_stmts (struct aux_params *params, int journal_off)
  2388   2320   {
  2389   2321       sqlite3_stmt *ins_tmp_nodes_stmt;
  2390   2322       sqlite3_stmt *ins_tmp_ways_stmt;
  2391   2323       sqlite3_stmt *ins_generic_point_stmt;
  2392   2324       sqlite3_stmt *ins_addresses_stmt;
  2393   2325       sqlite3_stmt *ins_generic_linestring_stmt;
  2394   2326       sqlite3_stmt *ins_generic_polygon_stmt;
  2395   2327       char sql[1024];
  2396   2328       int ret;
  2397   2329       char *sql_err = NULL;
         2330  +
         2331  +    if (journal_off)
         2332  +      {
         2333  +	  /* disabling the journal: unsafe but faster */
         2334  +	  ret =
         2335  +	      sqlite3_exec (params->db_handle, "PRAGMA journal_mode = OFF",
         2336  +			    NULL, NULL, &sql_err);
         2337  +	  if (ret != SQLITE_OK)
         2338  +	    {
         2339  +		fprintf (stderr, "PRAGMA journal_mode=OFF error: %s\n",
         2340  +			 sql_err);
         2341  +		sqlite3_free (sql_err);
         2342  +		return;
         2343  +	    }
         2344  +      }
  2398   2345   
  2399   2346   /* the complete operation is handled as an unique SQL Transaction */
  2400   2347       ret = sqlite3_exec (params->db_handle, "BEGIN", NULL, NULL, &sql_err);
  2401   2348       if (ret != SQLITE_OK)
  2402   2349         {
  2403   2350   	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
  2404   2351   	  sqlite3_free (sql_err);
................................................................................
  2581   2528       fprintf (stderr, "\n\nusage: spatialite_osm_map ARGLIST\n");
  2582   2529       fprintf (stderr,
  2583   2530   	     "==============================================================\n");
  2584   2531       fprintf (stderr,
  2585   2532   	     "-h or --help                    print this help message\n");
  2586   2533       fprintf (stderr, "-o or --osm-path pathname       the OSM-XML file path\n");
  2587   2534       fprintf (stderr,
         2535  +	     "                 both OSM-XML (*.osm) and OSM-ProtoBuf\n");
         2536  +    fprintf (stderr,
         2537  +	     "                 (*.osm.pbf) are indifferenctly supported.\n\n");
         2538  +    fprintf (stderr,
  2588   2539   	     "-d or --db-path  pathname       the SpatiaLite DB path\n\n");
  2589   2540       fprintf (stderr, "you can specify the following options as well\n");
  2590   2541       fprintf (stderr,
  2591   2542   	     "-cs or --cache-size    num      DB cache size (how many pages)\n");
  2592   2543       fprintf (stderr,
  2593   2544   	     "-m or --in-memory               using IN-MEMORY database\n");
  2594   2545       fprintf (stderr,
  2595   2546   	     "-n or --no-spatial-index        suppress R*Trees generation\n");
         2547  +    fprintf (stderr,
         2548  +	     "-jo or --journal-off            unsafe [but faster] mode\n");
  2596   2549   }
  2597   2550   
  2598   2551   int
  2599   2552   main (int argc, char *argv[])
  2600   2553   {
  2601   2554   /* the MAIN function simply perform arguments checking */
  2602   2555       sqlite3 *handle;
  2603   2556       int i;
  2604   2557       int next_arg = ARG_NONE;
  2605   2558       const char *osm_path = NULL;
  2606   2559       const char *db_path = NULL;
  2607   2560       int in_memory = 0;
  2608   2561       int cache_size = 0;
         2562  +    int journal_off = 0;
  2609   2563       int spatial_index = 1;
  2610   2564       int error = 0;
  2611         -    char Buff[BUFFSIZE];
  2612         -    int done = 0;
  2613         -    int len;
  2614         -    XML_Parser parser;
  2615   2565       struct aux_params params;
  2616         -    FILE *xml_file;
  2617         -    int last_line_no = 0;
  2618         -    int curr_line_no = 0;
         2566  +    const void *osm_handle;
  2619   2567   
  2620   2568   /* initializing the aux-struct */
  2621   2569       params.db_handle = NULL;
  2622   2570       params.ins_tmp_nodes_stmt = NULL;
  2623   2571       params.ins_tmp_ways_stmt = NULL;
  2624   2572       params.ins_generic_point_stmt = NULL;
  2625   2573       params.ins_addresses_stmt = NULL;
  2626   2574       params.ins_generic_linestring_stmt = NULL;
  2627   2575       params.ins_generic_polygon_stmt = NULL;
  2628         -    params.current_tag = CURRENT_TAG_UNKNOWN;
         2576  +
  2629   2577   
  2630   2578       for (i = 1; i < argc; i++)
  2631   2579         {
  2632   2580   	  /* parsing the invocation arguments */
  2633   2581   	  if (next_arg != ARG_NONE)
  2634   2582   	    {
  2635   2583   		switch (next_arg)
................................................................................
  2681   2629   	    }
  2682   2630   	  if (strcasecmp (argv[i], "-m") == 0)
  2683   2631   	    {
  2684   2632   		in_memory = 1;
  2685   2633   		next_arg = ARG_NONE;
  2686   2634   		continue;
  2687   2635   	    }
  2688         -	  if (strcasecmp (argv[i], "-in-memory") == 0)
         2636  +	  if (strcasecmp (argv[i], "--in-memory") == 0)
  2689   2637   	    {
  2690   2638   		in_memory = 1;
  2691   2639   		next_arg = ARG_NONE;
  2692   2640   		continue;
         2641  +	    }
         2642  +	  if (strcasecmp (argv[i], "-jo") == 0)
         2643  +	    {
         2644  +		journal_off = 1;
         2645  +		next_arg = ARG_NONE;
         2646  +		continue;
         2647  +	    }
         2648  +	  if (strcasecmp (argv[i], "--journal-off") == 0)
         2649  +	    {
         2650  +		journal_off = 1;
         2651  +		next_arg = ARG_NONE;
         2652  +		continue;
  2693   2653   	    }
  2694   2654   	  if (strcasecmp (argv[i], "-n") == 0)
  2695   2655   	    {
  2696   2656   		spatial_index = 0;
  2697   2657   		next_arg = ARG_NONE;
  2698   2658   		continue;
  2699   2659   	    }
................................................................................
  2772   2732   	  sqlite3_close (handle);
  2773   2733   	  handle = mem_db_handle;
  2774   2734   	  printf ("\nusing IN-MEMORY database\n");
  2775   2735         }
  2776   2736       params.db_handle = handle;
  2777   2737   
  2778   2738   /* creating SQL prepared statements */
  2779         -    create_sql_stmts (&params);
         2739  +    create_sql_stmts (&params, journal_off);
  2780   2740   
  2781         -/* XML parsing */
  2782         -    xml_file = fopen (osm_path, "rb");
  2783         -    if (!xml_file)
         2741  +/* parsing the input OSM-file */
         2742  +    if (readosm_open (osm_path, &osm_handle) != READOSM_OK)
  2784   2743         {
  2785   2744   	  fprintf (stderr, "cannot open %s\n", osm_path);
         2745  +	  finalize_sql_stmts (&params);
  2786   2746   	  sqlite3_close (handle);
         2747  +	  readosm_close (osm_handle);
  2787   2748   	  return -1;
  2788   2749         }
  2789         -    parser = XML_ParserCreate (NULL);
  2790         -    if (!parser)
         2750  +    if (readosm_parse
         2751  +	(osm_handle, &params, consume_node, consume_way,
         2752  +	 consume_relation) != READOSM_OK)
  2791   2753         {
  2792         -	  fprintf (stderr, "Couldn't allocate memory for parser\n");
         2754  +	  fprintf (stderr, "unrecoverable error while parsing %s\n", osm_path);
         2755  +	  finalize_sql_stmts (&params);
  2793   2756   	  sqlite3_close (handle);
         2757  +	  readosm_close (osm_handle);
  2794   2758   	  return -1;
  2795   2759         }
  2796         -    XML_SetUserData (parser, &params);
  2797         -    XML_SetElementHandler (parser, start_tag, end_tag);
  2798         -    while (!done)
  2799         -      {
  2800         -	  len = fread (Buff, 1, BUFFSIZE, xml_file);
  2801         -	  if (ferror (xml_file))
  2802         -	    {
  2803         -		fprintf (stderr, "XML Read error\n");
  2804         -		sqlite3_close (handle);
  2805         -		return -1;
  2806         -	    }
  2807         -	  done = feof (xml_file);
  2808         -	  if (!XML_Parse (parser, Buff, len, done))
  2809         -	    {
  2810         -		fprintf (stderr, "Parse error at line %d:\n%s\n",
  2811         -			 (int) XML_GetCurrentLineNumber (parser),
  2812         -			 XML_ErrorString (XML_GetErrorCode (parser)));
  2813         -		sqlite3_close (handle);
  2814         -		return -1;
  2815         -	    }
  2816         -	  curr_line_no = (int) XML_GetCurrentLineNumber (parser);
  2817         -	  if ((curr_line_no - last_line_no) > 1000)
  2818         -	    {
  2819         -		last_line_no = curr_line_no;
  2820         -		printf ("Parsing XML line: %d\r", curr_line_no);
  2821         -		fflush (stdout);
  2822         -	    }
  2823         -      }
  2824         -    XML_ParserFree (parser);
  2825         -    fclose (xml_file);
  2826         -    printf ("                                                         \r");
         2760  +    readosm_close (osm_handle);
  2827   2761   
  2828   2762   /* finalizing SQL prepared statements */
  2829   2763       finalize_sql_stmts (&params);
  2830   2764   
  2831   2765   /* dropping the OSM_TMP_xx tables */
  2832   2766       db_cleanup (handle);
  2833   2767   

Changes to spatialite_osm_net.c.

    39     39   #include <spatialite/sqlite3.h>
    40     40   #else
    41     41   #include <sqlite3.h>
    42     42   #endif
    43     43   
    44     44   #include <spatialite/gaiageo.h>
    45     45   #include <spatialite.h>
           46  +#include <readosm.h>
    46     47   
    47     48   #define ARG_NONE		0
    48     49   #define ARG_OSM_PATH	1
    49     50   #define ARG_DB_PATH		2
    50     51   #define ARG_TABLE		3
    51     52   #define ARG_CACHE_SIZE	4
           53  +#define ARG_TEMPLATE_PATH	5
    52     54   
    53         -#define MAX_TAG		16
           55  +#define NODE_STRAT_NONE	0
           56  +#define NODE_STRAT_ALL	1
           57  +#define NODE_STRAT_ENDS	2
           58  +#define ONEWAY_STRAT_NONE	0
           59  +#define ONEWAY_STRAT_FULL	1
           60  +#define ONEWAY_STRAT_NO_ROUND	2
           61  +#define ONEWAY_STRAT_NO_MOTOR	3
           62  +#define ONEWAY_STRAT_NO_BOTH	4
    54     63   
    55         -#if defined(_WIN32) && !defined(__MINGW32__)
    56         -#define strcasecmp	_stricmp
    57         -#endif /* not WIN32 */
    58         -
    59         -#if defined(_WIN32)
    60         -#define atol_64		_atoi64
    61         -#else
    62         -#define atol_64		atoll
    63         -#endif
    64         -
    65         -struct dup_node_id
           64  +struct aux_speed
    66     65   {
    67         -    sqlite3_int64 id;
    68         -    struct dup_node_id *next;
           66  +/* an auxiliary struct for Speeds */
           67  +    char *class_name;
           68  +    double speed;
           69  +    struct aux_speed *next;
    69     70   };
    70     71   
    71         -struct dup_node
           72  +struct aux_class
    72     73   {
    73         -    double lon;
    74         -    double lat;
    75         -    int refcount;
    76         -    struct dup_node_id *first;
    77         -    struct dup_node_id *last;
    78         -    struct dup_node *next;
           74  +/* an auxiliary struct for road Classes */
           75  +    char *class_name;
           76  +    char *sub_class;
           77  +    struct aux_class *next;
    79     78   };
    80     79   
    81         -struct kv
    82         -{
    83         -    char *k;
    84         -    char *v;
    85         -    struct kv *next;
    86         -};
    87         -
    88         -struct node_ref
    89         -{
    90         -    sqlite3_int64 id;
    91         -    sqlite3_int64 alias;
    92         -    double lat;
    93         -    double lon;
    94         -    int refcount;
    95         -    int ignore;
    96         -    struct node_ref *next;
    97         -};
    98         -
    99         -struct arc
   100         -{
   101         -    sqlite3_int64 from;
   102         -    sqlite3_int64 to;
   103         -    gaiaDynamicLinePtr dyn;
   104         -    gaiaGeomCollPtr geom;
   105         -    double length;
   106         -    double cost;
   107         -    struct arc *next;
   108         -};
   109         -
   110         -struct way
   111         -{
   112         -    sqlite3_int64 id;
   113         -    char *class;
   114         -    char *name;
   115         -    int oneway;
   116         -    int reverse;
   117         -    struct node_ref *first;
   118         -    struct node_ref *last;
   119         -    struct kv *first_kv;
   120         -    struct kv *last_kv;
   121         -    struct arc *first_arc;
   122         -    struct arc *last_arc;
   123         -};
   124         -
   125         -struct check_tag
   126         -{
   127         -    char buf[MAX_TAG + 1];
   128         -    int pos;
   129         -    int max;
           80  +struct aux_params
           81  +{
           82  +/* an auxiliary struct used for OSM parsing */
           83  +    sqlite3 *db_handle;
           84  +    const char *table;
           85  +    int noding_strategy;
           86  +    int oneway_strategy;
           87  +    struct aux_speed *first_speed;
           88  +    struct aux_speed *last_speed;
           89  +    double default_speed;
           90  +    struct aux_class *first_include;
           91  +    struct aux_class *last_include;
           92  +    struct aux_class *first_ignore;
           93  +    struct aux_class *last_ignore;
           94  +    sqlite3_stmt *ins_tmp_nodes_stmt;
           95  +    sqlite3_stmt *upd_tmp_nodes_stmt;
           96  +    sqlite3_stmt *rd_tmp_nodes_stmt;
           97  +    sqlite3_stmt *ins_arcs_stmt;
   130     98   };
   131     99   
   132    100   static void
   133         -init_tag (struct check_tag *tag, int max)
   134         -{
   135         -    tag->pos = 0;
   136         -    tag->max = max;
   137         -    memset (tag->buf, '\0', MAX_TAG + 1);
   138         -}
   139         -
   140         -static void
   141         -update_tag (struct check_tag *tag, const char c)
   142         -{
   143         -/* updating the tag control struct */
   144         -    int i;
   145         -    if (tag->pos == (tag->max - 1))
   146         -      {
   147         -	  for (i = 0; i < tag->max; i++)
   148         -	    {
   149         -		/* rotating the buffer */
   150         -		*(tag->buf + i) = *(tag->buf + i + 1);
   151         -	    }
   152         -	  *(tag->buf + tag->pos) = c;
   153         -	  return;
   154         -      }
   155         -    *(tag->buf + tag->pos) = c;
   156         -    tag->pos++;
          101  +save_current_line (gaiaGeomCollPtr geom, gaiaDynamicLinePtr dyn)
          102  +{
          103  +/* inserting a GraphArc from a splitted Way */
          104  +    gaiaPointPtr pt;
          105  +    gaiaLinestringPtr ln;
          106  +    int iv;
          107  +    int points = 0;
          108  +
          109  +    pt = dyn->First;
          110  +    while (pt)
          111  +      {
          112  +	  /* counting how many points are there */
          113  +	  points++;
          114  +	  pt = pt->Next;
          115  +      }
          116  +    if (points < 2)
          117  +	return;
          118  +    ln = gaiaAddLinestringToGeomColl (geom, points);
          119  +    iv = 0;
          120  +    pt = dyn->First;
          121  +    while (pt)
          122  +      {
          123  +	  gaiaSetPoint (ln->Coords, iv, pt->X, pt->Y);
          124  +	  iv++;
          125  +	  pt = pt->Next;
          126  +      }
          127  +}
          128  +
          129  +static gaiaGeomCollPtr
          130  +build_linestrings (struct aux_params *params, const readosm_way * way)
          131  +{
          132  +/* building the Arcs of the Graph [may be, splitting a Way in more Arcs] */
          133  +    int i_ref;
          134  +    int ret;
          135  +    gaiaGeomCollPtr geom;
          136  +    gaiaDynamicLinePtr dyn = gaiaAllocDynamicLine ();
          137  +    gaiaPointPtr pt;
          138  +
          139  +    geom = gaiaAllocGeomColl ();
          140  +    geom->Srid = 4326;
          141  +
          142  +    for (i_ref = 0; i_ref < way->node_ref_count; i_ref++)
          143  +      {
          144  +	  /* fetching point coords */
          145  +	  sqlite3_int64 id = *(way->node_refs + i_ref);
          146  +	  double x;
          147  +	  double y;
          148  +	  int ref_count;
          149  +
          150  +	  sqlite3_reset (params->rd_tmp_nodes_stmt);
          151  +	  sqlite3_clear_bindings (params->rd_tmp_nodes_stmt);
          152  +	  sqlite3_bind_int64 (params->rd_tmp_nodes_stmt, 1, id);
          153  +
          154  +	  /* scrolling the result set */
          155  +	  ret = sqlite3_step (params->rd_tmp_nodes_stmt);
          156  +	  if (ret == SQLITE_DONE)
          157  +	    {
          158  +		/* empty resultset - no coords !!! */
          159  +#if defined(_WIN32) || defined(__MINGW32__)
          160  +		/* CAVEAT - M$ runtime doesn't supports %lld for 64 bits */
          161  +		fprintf (stderr, "UNRESOLVED-NODE %I64d\n", id);
          162  +#else
          163  +		fprintf (stderr, "UNRESOLVED-NODE %lld\n", id);
          164  +#endif
          165  +		gaiaFreeDynamicLine (dyn);
          166  +		gaiaFreeGeomColl (geom);
          167  +		return NULL;
          168  +	    }
          169  +	  else if (ret == SQLITE_ROW)
          170  +	    {
          171  +		/* ok, we've just fetched a valid row */
          172  +		x = sqlite3_column_double (params->rd_tmp_nodes_stmt, 0);
          173  +		y = sqlite3_column_double (params->rd_tmp_nodes_stmt, 1);
          174  +		ref_count = sqlite3_column_int (params->rd_tmp_nodes_stmt, 2);
          175  +
          176  +		pt = dyn->Last;
          177  +		if (pt)
          178  +		  {
          179  +		      if (pt->X == x && pt->Y == y)
          180  +			{
          181  +			    /* skipping any repeated point */
          182  +			    continue;
          183  +			}
          184  +		  }
          185  +
          186  +		/* appending the point to the current line anyway */
          187  +		gaiaAppendPointToDynamicLine (dyn, x, y);
          188  +		if (params->noding_strategy != NODE_STRAT_NONE)
          189  +		  {
          190  +		      /* attempting to renode the Graph */
          191  +		      int limit = 1;
          192  +		      if (params->noding_strategy == NODE_STRAT_ENDS)
          193  +			{
          194  +			    /* renoding each Way terminal point */
          195  +			    limit = 0;
          196  +			}
          197  +		      if ((ref_count > limit)
          198  +			  && (i_ref > 0 && i_ref < (way->node_ref_count - 1)))
          199  +			{
          200  +			    /* found an internal Node: saving the current line */
          201  +			    save_current_line (geom, dyn);
          202  +			    /* starting a further line */
          203  +			    gaiaFreeDynamicLine (dyn);
          204  +			    dyn = gaiaAllocDynamicLine ();
          205  +			    /* inserting the current point in the new line */
          206  +			    gaiaAppendPointToDynamicLine (dyn, x, y);
          207  +			}
          208  +		  }
          209  +	    }
          210  +	  else
          211  +	    {
          212  +		/* some unexpected error occurred */
          213  +		fprintf (stderr, "sqlite3_step() error: %s\n",
          214  +			 sqlite3_errmsg (params->db_handle));
          215  +		sqlite3_finalize (params->rd_tmp_nodes_stmt);
          216  +		gaiaFreeGeomColl (geom);
          217  +		gaiaFreeDynamicLine (dyn);
          218  +		return NULL;
          219  +	    }
          220  +      }
          221  +/* saving the last line */
          222  +    save_current_line (geom, dyn);
          223  +    gaiaFreeDynamicLine (dyn);
          224  +
          225  +    if (geom->FirstLinestring == NULL)
          226  +      {
          227  +	  /* invalid geometry: no lines */
          228  +	  gaiaFreeGeomColl (geom);
          229  +	  return NULL;
          230  +      }
          231  +    return geom;
          232  +}
          233  +
          234  +static int
          235  +arcs_insert (struct aux_params *params, sqlite3_int64 id, const char *class,
          236  +	     const char *name, int oneway, unsigned char *blob, int blob_size)
          237  +{
          238  +/* Inserts an Arc into the Graph */
          239  +    int ret;
          240  +    if (params->ins_arcs_stmt == NULL)
          241  +	return 1;
          242  +    sqlite3_reset (params->ins_arcs_stmt);
          243  +    sqlite3_clear_bindings (params->ins_arcs_stmt);
          244  +    sqlite3_bind_int64 (params->ins_arcs_stmt, 1, id);
          245  +    sqlite3_bind_text (params->ins_arcs_stmt, 2, class, strlen (class),
          246  +		       SQLITE_STATIC);
          247  +    sqlite3_bind_text (params->ins_arcs_stmt, 3, name, strlen (name),
          248  +		       SQLITE_STATIC);
          249  +    if (oneway > 0)
          250  +      {
          251  +	  sqlite3_bind_int (params->ins_arcs_stmt, 4, 1);
          252  +	  sqlite3_bind_int (params->ins_arcs_stmt, 5, 0);
          253  +      }
          254  +    else if (oneway < 0)
          255  +      {
          256  +	  sqlite3_bind_int (params->ins_arcs_stmt, 4, 0);
          257  +	  sqlite3_bind_int (params->ins_arcs_stmt, 5, 1);
          258  +      }
          259  +    else
          260  +      {
          261  +	  sqlite3_bind_int (params->ins_arcs_stmt, 4, 1);
          262  +	  sqlite3_bind_int (params->ins_arcs_stmt, 5, 1);
          263  +      }
          264  +    sqlite3_bind_blob (params->ins_arcs_stmt, 6, blob, blob_size, free);
          265  +    ret = sqlite3_step (params->ins_arcs_stmt);
          266  +
          267  +    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          268  +	return 1;
          269  +    fprintf (stderr, "sqlite3_step() error: INS_ARCS\n");
          270  +    sqlite3_finalize (params->ins_arcs_stmt);
          271  +    params->ins_arcs_stmt = NULL;
          272  +    return 0;
          273  +}
          274  +
          275  +static int
          276  +find_include_class (struct aux_params *params, const char *class,
          277  +		    const char *sub_class)
          278  +{
          279  +/* testing if this Way belongs to some class to be Included */
          280  +    struct aux_class *pc = params->first_include;
          281  +    while (pc)
          282  +      {
          283  +	  if (strcmp (pc->class_name, class) == 0)
          284  +	    {
          285  +		if (pc->sub_class == NULL)
          286  +		    return 1;
          287  +		if (strcmp (pc->sub_class, sub_class) == 0)
          288  +		    return 1;
          289  +	    }
          290  +	  pc = pc->next;
          291  +      }
          292  +    return 0;
          293  +}
          294  +
          295  +static int
          296  +find_ignore_class (struct aux_params *params, const char *class,
          297  +		   const char *sub_class)
          298  +{
          299  +/* testing if this Way belongs to some class to be Ignored */
          300  +    struct aux_class *pc = params->first_ignore;
          301  +    while (pc)
          302  +      {
          303  +	  if (strcmp (pc->class_name, class) == 0)
          304  +	    {
          305  +		if (strcmp (pc->sub_class, sub_class) == 0)
          306  +		    return 1;
          307  +	    }
          308  +	  pc = pc->next;
          309  +      }
          310  +    return 0;
          311  +}
          312  +
          313  +static int
          314  +consume_way_1 (const void *user_data, const readosm_way * way)
          315  +{
          316  +/* processing an OSM Way - Pass#1 (ReadOSM callback function) */
          317  +    struct aux_params *params = (struct aux_params *) user_data;
          318  +    const readosm_tag *p_tag;
          319  +    int i_tag;
          320  +    int i_ref;
          321  +    int ret;
          322  +    sqlite3_int64 id;
          323  +    int include = 0;
          324  +    int ignore = 0;
          325  +
          326  +    if (params->noding_strategy == NODE_STRAT_NONE)
          327  +      {
          328  +	  /* renoding the graph isn't required, we can skip all this */
          329  +	  return READOSM_OK;
          330  +      }
          331  +
          332  +    for (i_tag = 0; i_tag < way->tag_count; i_tag++)
          333  +      {
          334  +	  p_tag = way->tags + i_tag;
          335  +	  if (find_include_class (params, p_tag->key, p_tag->value))
          336  +	      include = 1;
          337  +	  if (find_ignore_class (params, p_tag->key, p_tag->value))
          338  +	      ignore = 1;
          339  +      }
          340  +    if (!include || ignore)
          341  +	return READOSM_OK;
          342  +
          343  +    for (i_ref = 0; i_ref < way->node_ref_count; i_ref++)
          344  +      {
          345  +	  if (params->noding_strategy == NODE_STRAT_ENDS)
          346  +	    {
          347  +		/* checking only the Way extreme points */
          348  +		if (i_ref == 0 || i_ref == (way->node_ref_count - 1))
          349  +		    ;
          350  +		else
          351  +		    continue;
          352  +	    }
          353  +	  id = *(way->node_refs + i_ref);
          354  +	  sqlite3_reset (params->upd_tmp_nodes_stmt);
          355  +	  sqlite3_clear_bindings (params->upd_tmp_nodes_stmt);
          356  +	  sqlite3_bind_int64 (params->upd_tmp_nodes_stmt, 1, id);
          357  +	  ret = sqlite3_step (params->upd_tmp_nodes_stmt);
          358  +	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          359  +	      ;
          360  +	  else
          361  +	    {
          362  +		fprintf (stderr, "sqlite3_step() error: %s\n",
          363  +			 sqlite3_errmsg (params->db_handle));
          364  +		sqlite3_finalize (params->upd_tmp_nodes_stmt);
          365  +		return READOSM_ABORT;
          366  +	    }
          367  +      }
          368  +
          369  +    return READOSM_OK;
          370  +}
          371  +
          372  +static int
          373  +consume_way_2 (const void *user_data, const readosm_way * way)
          374  +{
          375  +/* processing an OSM Way - Pass#2 (ReadOSM callback function) */
          376  +    struct aux_params *params = (struct aux_params *) user_data;
          377  +    const readosm_tag *p_tag;
          378  +    int i_tag;
          379  +    unsigned char *blob;
          380  +    int blob_size;
          381  +    const char *class = NULL;
          382  +    const char *name = "*** Unknown ****";
          383  +    int oneway = 0;
          384  +    int ret;
          385  +    int include = 0;
          386  +    int ignore = 0;
          387  +    gaiaGeomCollPtr geom;
          388  +
          389  +    for (i_tag = 0; i_tag < way->tag_count; i_tag++)
          390  +      {
          391  +	  p_tag = way->tags + i_tag;
          392  +	  if (find_include_class (params, p_tag->key, p_tag->value))
          393  +	    {
          394  +		include = 1;
          395  +		class = p_tag->value;
          396  +	    }
          397  +	  if (find_ignore_class (params, p_tag->key, p_tag->value))
          398  +	      ignore = 1;
          399  +      }
          400  +    if (!include || ignore)
          401  +	return READOSM_OK;
          402  +
          403  +    for (i_tag = 0; i_tag < way->tag_count; i_tag++)
          404  +      {
          405  +	  /* retrieving the road name */
          406  +	  p_tag = way->tags + i_tag;
          407  +	  if (strcmp (p_tag->key, "name") == 0)
          408  +	    {
          409  +		name = p_tag->value;
          410  +		break;
          411  +	    }
          412  +      }
          413  +
          414  +    if (params->oneway_strategy != ONEWAY_STRAT_NONE)
          415  +      {
          416  +	  /* checking for Oneeays */
          417  +	  for (i_tag = 0; i_tag < way->tag_count; i_tag++)
          418  +	    {
          419  +		/* checking for one-ways */
          420  +		p_tag = way->tags + i_tag;
          421  +		if (strcmp (p_tag->key, "oneway") == 0)
          422  +		  {
          423  +		      if (strcmp (p_tag->value, "yes") == 0
          424  +			  || strcmp (p_tag->value, "true") == 0
          425  +			  || strcmp (p_tag->value, "1") == 0)
          426  +			  oneway = 1;
          427  +		      if (strcmp (p_tag->value, "-1") == 0
          428  +			  || strcmp (p_tag->value, "reverse") == 0)
          429  +			  oneway = -1;
          430  +		  }
          431  +		if (params->oneway_strategy != ONEWAY_STRAT_NO_BOTH
          432  +		    && params->oneway_strategy != ONEWAY_STRAT_NO_ROUND)
          433  +		  {
          434  +		      /* testing for junction:roundabout */
          435  +		      if (strcmp (p_tag->key, "junction") == 0)
          436  +			{
          437  +			    if (strcmp (p_tag->value, "roundabout") == 0)
          438  +				oneway = 1;
          439  +			}
          440  +		  }
          441  +		if (params->oneway_strategy != ONEWAY_STRAT_NO_BOTH
          442  +		    && params->oneway_strategy != ONEWAY_STRAT_NO_MOTOR)
          443  +		  {
          444  +		      /* testing for highway_motorway or highway_motorway_link */
          445  +		      if (strcmp (p_tag->key, "highway") == 0)
          446  +			{
          447  +			    if (strcmp (p_tag->value, "motorway") == 0
          448  +				|| strcmp (p_tag->value, "motorway_link") == 0)
          449  +				oneway = 1;
          450  +			}
          451  +		  }
          452  +	    }
          453  +      }
          454  +
          455  +    geom = build_linestrings (params, way);
          456  +    if (geom)
          457  +      {
          458  +	  gaiaLinestringPtr ln = geom->FirstLinestring;
          459  +	  while (ln)
          460  +	    {
          461  +		/* inserting any splitted Arc */
          462  +		gaiaGeomCollPtr g;
          463  +		gaiaLinestringPtr ln2;
          464  +		int iv;
          465  +		if (gaiaIsClosed (ln))
          466  +		  {
          467  +		      ln = ln->Next;
          468  +		      continue;
          469  +		  }
          470  +		/* building a new Geometry - simple line */
          471  +		g = gaiaAllocGeomColl ();
          472  +		g->Srid = 4326;
          473  +		ln2 = gaiaAddLinestringToGeomColl (g, ln->Points);
          474  +		for (iv = 0; iv < ln->Points; iv++)
          475  +		  {
          476  +		      /* copying line's points */
          477  +		      double x;
          478  +		      double y;
          479  +		      gaiaGetPoint (ln->Coords, iv, &x, &y);
          480  +		      gaiaSetPoint (ln2->Coords, iv, x, y);
          481  +		  }
          482  +		gaiaToSpatiaLiteBlobWkb (g, &blob, &blob_size);
          483  +		ret =
          484  +		    arcs_insert (params, way->id, class, name, oneway, blob,
          485  +				 blob_size);
          486  +		gaiaFreeGeomColl (g);
          487  +		if (!ret)
          488  +		    return READOSM_ABORT;
          489  +		ln = ln->Next;
          490  +	    }
          491  +	  gaiaFreeGeomColl (geom);
          492  +      }
          493  +    return READOSM_OK;
   157    494   }
   158    495   
   159    496   static int
   160         -parse_node_id (const char *buf, sqlite3_int64 * id)
          497  +tmp_nodes_insert (struct aux_params *params, const readosm_node * node)
   161    498   {
   162         -/* parsing <node id="value" > */
   163         -    char value[128];
   164         -    char *out = value;
   165         -    const char *p = buf;
   166         -    struct check_tag tag;
   167         -    init_tag (&tag, 4);
   168         -    while (*p != '\0')
   169         -      {
   170         -	  update_tag (&tag, *p);
   171         -	  p++;
   172         -	  if (strncmp (tag.buf, "id=\"", 4) == 0)
   173         -	    {
   174         -		while (*p != '\"')
   175         -		  {
   176         -		      *out++ = *p++;
   177         -		  }
   178         -		*out = '\0';
   179         -		*id = atol_64 (value);
   180         -		return 1;
   181         -	    }
   182         -      }
          499  +/* inserts a node into the corresponding temporary table */
          500  +    int ret;
          501  +    if (params->ins_tmp_nodes_stmt == NULL)
          502  +	return 1;
          503  +    sqlite3_reset (params->ins_tmp_nodes_stmt);
          504  +    sqlite3_clear_bindings (params->ins_tmp_nodes_stmt);
          505  +    sqlite3_bind_int64 (params->ins_tmp_nodes_stmt, 1, node->id);
          506  +    sqlite3_bind_double (params->ins_tmp_nodes_stmt, 2, node->latitude);
          507  +    sqlite3_bind_double (params->ins_tmp_nodes_stmt, 3, node->longitude);
          508  +    ret = sqlite3_step (params->ins_tmp_nodes_stmt);
          509  +    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          510  +	return 1;
          511  +    fprintf (stderr, "sqlite3_step() error: INS_TMP_NODES\n");
          512  +    sqlite3_finalize (params->ins_tmp_nodes_stmt);
          513  +    params->ins_tmp_nodes_stmt = NULL;
   183    514       return 0;
   184    515   }
   185    516   
   186    517   static int
   187         -parse_node_lat (const char *buf, double *lat)
          518  +consume_node (const void *user_data, const readosm_node * node)
   188    519   {
   189         -/* parsing <node lat="value" >*/
   190         -    char value[128];
   191         -    char *out = value;
   192         -    const char *p = buf;
   193         -    struct check_tag tag;
   194         -    init_tag (&tag, 5);
   195         -    while (*p != '\0')
   196         -      {
   197         -	  update_tag (&tag, *p);
   198         -	  p++;
   199         -	  if (strncmp (tag.buf, "lat=\"", 5) == 0)
   200         -	    {
   201         -		while (*p != '\"')
   202         -		  {
   203         -		      *out++ = *p++;
   204         -		  }
   205         -		*out = '\0';
   206         -		*lat = atof (value);
   207         -		return 1;
   208         -	    }
   209         -      }
   210         -    return 0;
          520  +/* processing an OSM Node (ReadOSM callback function) */
          521  +    struct aux_params *params = (struct aux_params *) user_data;
          522  +
          523  +    if (!tmp_nodes_insert (params, node))
          524  +	return READOSM_ABORT;
          525  +    return READOSM_OK;
   211    526   }
   212    527   
   213    528   static int
   214         -parse_node_lon (const char *buf, double *lon)
          529  +populate_graph_nodes (sqlite3 * handle, const char *table)
   215    530   {
   216         -/* parsing <node lon="value" >*/
   217         -    char value[128];
   218         -    char *out = value;
   219         -    const char *p = buf;
   220         -    struct check_tag tag;
   221         -    init_tag (&tag, 5);
   222         -    while (*p != '\0')
   223         -      {
   224         -	  update_tag (&tag, *p);
   225         -	  p++;
   226         -	  if (strncmp (tag.buf, "lon=\"", 5) == 0)
   227         -	    {
   228         -		while (*p != '\"')
   229         -		  {
   230         -		      *out++ = *p++;
   231         -		  }
   232         -		*out = '\0';
   233         -		*lon = atof (value);
   234         -		return 1;
   235         -	    }
   236         -      }
   237         -    return 0;
   238         -}
   239         -
   240         -static int
   241         -parse_node_tag (const char *buf, sqlite3_int64 * id, double *lat, double *lon)
   242         -{
   243         -/* parsing a <node> tag */
   244         -    if (!parse_node_id (buf, id))
   245         -	return 0;
   246         -    if (!parse_node_lat (buf, lat))
   247         -	return 0;
   248         -    if (!parse_node_lon (buf, lon))
   249         -	return 0;
   250         -    return 1;
   251         -}
   252         -
   253         -static int
   254         -insert_node (sqlite3 * handle, sqlite3_stmt * stmt, sqlite3_int64 id,
   255         -	     double lat, double lon)
   256         -{
   257         -/* inserting a temporary node into the DB */
   258         -    int ret;
   259         -    sqlite3_reset (stmt);
   260         -    sqlite3_clear_bindings (stmt);
   261         -    sqlite3_bind_int64 (stmt, 1, id);
   262         -    sqlite3_bind_int64 (stmt, 2, id);
   263         -    sqlite3_bind_double (stmt, 3, lat);
   264         -    sqlite3_bind_double (stmt, 4, lon);
   265         -    sqlite3_bind_int (stmt, 5, 0);
   266         -    ret = sqlite3_step (stmt);
   267         -    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   268         -	return 1;
   269         -    fprintf (stderr, "sqlite3_step() error: %s\n", sqlite3_errmsg (handle));
   270         -    sqlite3_finalize (stmt);
   271         -    return 0;
   272         -}
   273         -
   274         -static int
   275         -parse_nodes (FILE * xml, sqlite3 * handle)
   276         -{
   277         -/* parsing <node> tags from XML file */
   278         -    sqlite3_stmt *stmt;
   279    531       int ret;
   280    532       char *sql_err = NULL;
   281         -    sqlite3_int64 id;
   282         -    double lat;
   283         -    double lon;
   284         -    int opened;
   285         -    int count = 0;
   286         -    int node = 0;
   287         -    int c;
   288         -    int last_c;
   289         -    char value[65536];
   290         -    char *p;
   291         -    struct check_tag tag;
   292         -    init_tag (&tag, 6);
          533  +    char sql[8192];
          534  +    char sql2[1024];
          535  +    sqlite3_stmt *query_stmt = NULL;
          536  +    sqlite3_stmt *update_stmt = NULL;
   293    537   
   294         -/* the complete operation is handled as an unique SQL Transaction */
          538  +/* populating GRAPH_NODES */
          539  +    strcpy (sql, "INSERT OR IGNORE INTO graph_nodes (lon, lat) ");
          540  +    strcat (sql, "SELECT ST_X(ST_StartPoint(Geometry)), ");
          541  +    strcat (sql, "ST_Y(ST_StartPoint(Geometry)) ");
          542  +    sprintf (sql2, "FROM \"%s\" ", table);
          543  +    strcat (sql, sql2);
          544  +    strcat (sql, "UNION ");
          545  +    strcat (sql, "SELECT ST_X(ST_EndPoint(Geometry)), ");
          546  +    strcat (sql, "ST_Y(ST_EndPoint(Geometry)) ");
          547  +    sprintf (sql2, "FROM \"%s\"", table);
          548  +    strcat (sql, sql2);
          549  +
          550  +    ret = sqlite3_exec (handle, sql, NULL, NULL, &sql_err);
          551  +    if (ret != SQLITE_OK)
          552  +      {
          553  +	  fprintf (stderr, "GraphNodes SQL error: %s\n", sql_err);
          554  +	  sqlite3_free (sql_err);
          555  +	  return 0;
          556  +      }
          557  +
          558  +/* setting OSM-IDs to graph-nodes */
          559  +/* the complete operation is handled as a unique SQL Transaction */
   295    560       ret = sqlite3_exec (handle, "BEGIN", NULL, NULL, &sql_err);
   296    561       if (ret != SQLITE_OK)
   297    562         {
   298    563   	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
   299    564   	  sqlite3_free (sql_err);
   300         -	  return -1;
   301         -      }
   302         -/* preparing the SQL statement */
   303         -    strcpy (value,
   304         -	    "INSERT INTO osm_tmp_nodes (id, alias, lat, lon, refcount) ");
   305         -    strcat (value, "VALUES (?, ?, ?, ?, ?)");
   306         -    ret = sqlite3_prepare_v2 (handle, value, strlen (value), &stmt, NULL);
   307         -    if (ret != SQLITE_OK)
   308         -      {
   309         -	  fprintf (stderr, "SQL error: %s\n%s\n", value,
   310         -		   sqlite3_errmsg (handle));
   311         -	  return -1;
   312         -      }
   313         -
   314         -    while ((c = getc (xml)) != EOF)
   315         -      {
   316         -	  if (node)
   317         -	    {
   318         -		/* we are inside a <node> tag */
   319         -		*p++ = c;
   320         -		if (c == '<')
   321         -		    opened++;
   322         -		if (!opened && c == '>' && last_c == '/')
   323         -		  {
   324         -		      /* closing a <node /> tag */
   325         -		      *p = '\0';
   326         -		      if (!parse_node_tag (value, &id, &lat, &lon))
   327         -			{
   328         -			    fprintf (stderr, "ERROR: invalid <node>\n");
   329         -			    return -1;
   330         -			}
   331         -		      else
   332         -			{
   333         -			    if (!insert_node (handle, stmt, id, lat, lon))
   334         -				return -1;
   335         -			    count++;
   336         -			}
   337         -		      node = 0;
   338         -		      continue;
   339         -		  }
   340         -		last_c = c;
   341         -	    }
   342         -	  update_tag (&tag, c);
   343         -	  if (strncmp (tag.buf, "<node ", 6) == 0)
   344         -	    {
   345         -		/* opening a <node> tag */
   346         -		node = 1;
   347         -		last_c = '\0';
   348         -		opened = 0;
   349         -		strcpy (value, "<node ");
   350         -		p = value + 6;
   351         -		continue;
   352         -	    }
   353         -	  if (strncmp (tag.buf, "</node", 6) == 0)
   354         -	    {
   355         -		/* closing a <node> tag */
   356         -		*p = '\0';
   357         -		if (!parse_node_tag (value, &id, &lat, &lon))
   358         -		  {
   359         -		      fprintf (stderr, "ERROR: invalid <node>\n");
   360         -		      return -1;
   361         -		  }
          565  +	  return 0;
          566  +      }
          567  +
          568  +    strcpy (sql, "SELECT n.ROWID, t.id FROM osm_tmp_nodes AS t ");
          569  +    strcat (sql, "JOIN graph_nodes AS n ON (t.lon = n.lon AND t.lat = n.lat)");
          570  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &query_stmt, NULL);
          571  +    if (ret != SQLITE_OK)
          572  +      {
          573  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
          574  +	  goto error;
          575  +      }
          576  +
          577  +    strcpy (sql, "UPDATE graph_nodes SET osm_id = ? ");
          578  +    strcat (sql, "WHERE ROWID = ?");
          579  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &update_stmt, NULL);
          580  +    if (ret != SQLITE_OK)
          581  +      {
          582  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
          583  +	  goto error;
          584  +      }
          585  +
          586  +    while (1)
          587  +      {
          588  +	  ret = sqlite3_step (query_stmt);
          589  +	  if (ret == SQLITE_DONE)
          590  +	      break;
          591  +	  if (ret == SQLITE_ROW)
          592  +	    {
          593  +		sqlite3_int64 id = sqlite3_column_int64 (query_stmt, 0);
          594  +		sqlite3_int64 osm_id = sqlite3_column_int64 (query_stmt, 1);
          595  +
          596  +		/* udating the GraphNote */
          597  +		sqlite3_reset (update_stmt);
          598  +		sqlite3_clear_bindings (update_stmt);
          599  +		sqlite3_bind_int64 (update_stmt, 1, osm_id);
          600  +		sqlite3_bind_int64 (update_stmt, 2, id);
          601  +		ret = sqlite3_step (update_stmt);
          602  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          603  +		    ;
   362    604   		else
   363    605   		  {
   364         -		      if (!insert_node (handle, stmt, id, lat, lon))
   365         -			  return -1;
   366         -		      count++;
          606  +		      printf ("sqlite3_step() error: %s\n",
          607  +			      sqlite3_errmsg (handle));
          608  +		      goto error;
   367    609   		  }
   368         -		node = 0;
   369         -		continue;
          610  +	    }
          611  +	  else
          612  +	    {
          613  +		printf ("sqlite3_step() error: %s\n", sqlite3_errmsg (handle));
          614  +		goto error;
   370    615   	    }
   371    616         }
   372         -/* finalizing the INSERT INTO prepared statement */
   373         -    sqlite3_finalize (stmt);
          617  +
          618  +    if (query_stmt != NULL)
          619  +	sqlite3_finalize (query_stmt);
          620  +    if (update_stmt != NULL)
          621  +	sqlite3_finalize (update_stmt);
   374    622   
   375    623   /* committing the still pending SQL Transaction */
   376    624       ret = sqlite3_exec (handle, "COMMIT", NULL, NULL, &sql_err);
   377    625       if (ret != SQLITE_OK)
   378    626         {
   379    627   	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
   380    628   	  sqlite3_free (sql_err);
   381         -	  return -1;
   382    629         }
   383         -    return count;
          630  +    return 1;
          631  +
          632  +  error:
          633  +    if (query_stmt != NULL)
          634  +	sqlite3_finalize (query_stmt);
          635  +    if (update_stmt != NULL)
          636  +	sqlite3_finalize (update_stmt);
          637  +
          638  +    ret = sqlite3_exec (handle, "ROLLBACK", NULL, NULL, &sql_err);
          639  +    if (ret != SQLITE_OK)
          640  +      {
          641  +	  fprintf (stderr, "ROLLBACK TRANSACTION error: %s\n", sql_err);
          642  +	  sqlite3_free (sql_err);
          643  +      }
          644  +    return 0;
   384    645   }
   385    646   
   386    647   static int
   387         -disambiguate_nodes (sqlite3 * handle)
          648  +set_node_ids (sqlite3 * handle, const char *table)
   388    649   {
   389         -/* disambiguating duplicate NODEs */
          650  +/* assigning IDs to Nodes of the Graph */
   390    651       int ret;
   391         -    sqlite3_stmt *stmt;
   392         -    sqlite3_int64 id;
   393         -    int refcount;
   394         -    double lon;
   395         -    double lat;
          652  +    char *sql_err = NULL;
   396    653       char sql[8192];
   397         -    int count = 0;
   398         -    struct dup_node *first = NULL;
   399         -    struct dup_node *last = NULL;
   400         -    struct dup_node *p;
   401         -    struct dup_node *pn;
   402         -    struct dup_node_id *pid;
   403         -    struct dup_node_id *pidn;
   404         -    char *sql_err = NULL;
   405         -/* creating an index */
   406         -    strcpy (sql, "CREATE INDEX latlon ON osm_tmp_nodes (lat, lon)");
   407         -    ret = sqlite3_exec (handle, sql, NULL, NULL, &sql_err);
   408         -    if (ret != SQLITE_OK)
   409         -      {
   410         -	  fprintf (stderr, "CREATE INDEX latlon: %s\n", sql_err);
   411         -	  sqlite3_free (sql_err);
   412         -	  return -1;
   413         -      }
   414         -/* identifying the duplicate nodes by coords */
   415         -    strcpy (sql, "SELECT lat, lon, Sum(refcount) FROM osm_tmp_nodes ");
   416         -    strcat (sql, "WHERE refcount > 0 GROUP BY lat, lon ");
   417         -    strcat (sql, "HAVING count(*) > 1");
   418         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
   419         -    if (ret != SQLITE_OK)
   420         -      {
   421         -	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
   422         -	  return -1;
   423         -      }
   424         -    while (1)
   425         -      {
   426         -	  /* scrolling the result set */
   427         -	  ret = sqlite3_step (stmt);
   428         -	  if (ret == SQLITE_DONE)
   429         -	    {
   430         -		/* there are no more rows to fetch - we can stop looping */
   431         -		break;
   432         -	    }
   433         -	  if (ret == SQLITE_ROW)
   434         -	    {
   435         -		/* ok, we've just fetched a valid row */
   436         -		lat = sqlite3_column_double (stmt, 0);
   437         -		lon = sqlite3_column_double (stmt, 1);
   438         -		refcount = sqlite3_column_int (stmt, 2);
   439         -		p = malloc (sizeof (struct dup_node));
   440         -		p->lat = lat;
   441         -		p->lon = lon;
   442         -		p->refcount = refcount;
   443         -		p->first = NULL;
   444         -		p->last = NULL;
   445         -		p->next = NULL;
   446         -		if (!first)
   447         -		    first = p;
   448         -		if (last)
   449         -		    last->next = p;
   450         -		last = p;
   451         -	    }
   452         -	  else
   453         -	    {
   454         -		/* some unexpected error occurred */
   455         -		fprintf (stderr, "sqlite3_step() error: %s\n",
   456         -			 sqlite3_errmsg (handle));
   457         -		sqlite3_finalize (stmt);
   458         -		return -1;
   459         -	    }
   460         -      }
   461         -    sqlite3_finalize (stmt);
   462         -/* retrieving the dup-nodes IDs */
   463         -    p = first;
   464         -    while (p)
   465         -      {
   466         -	  strcpy (sql, "SELECT id FROM osm_tmp_nodes ");
   467         -	  strcat (sql, "WHERE lat = ? AND lon = ?");
   468         -	  ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
   469         -	  if (ret != SQLITE_OK)
   470         -	    {
   471         -		fprintf (stderr, "SQL error: %s\n%s\n", sql,
   472         -			 sqlite3_errmsg (handle));
   473         -		return -1;
   474         -	    }
   475         -	  sqlite3_reset (stmt);
   476         -	  sqlite3_clear_bindings (stmt);
   477         -	  sqlite3_bind_double (stmt, 1, p->lat);
   478         -	  sqlite3_bind_double (stmt, 2, p->lon);
   479         -	  while (1)
   480         -	    {
   481         -		/* scrolling the result set */
   482         -		ret = sqlite3_step (stmt);
   483         -		if (ret == SQLITE_DONE)
   484         -		  {
   485         -		      /* there are no more rows to fetch - we can stop looping */
   486         -		      break;
   487         -		  }
   488         -		if (ret == SQLITE_ROW)
   489         -		  {
   490         -		      /* ok, we've just fetched a valid row */
   491         -		      id = sqlite3_column_int64 (stmt, 0);
   492         -		      pid = malloc (sizeof (struct dup_node_id));
   493         -		      pid->id = id;
   494         -		      pid->next = NULL;
   495         -		      if (p->first == NULL)
   496         -			  p->first = pid;
   497         -		      if (p->last != NULL)
   498         -			  p->last->next = pid;
   499         -		      p->last = pid;
   500         -		  }
   501         -		else
   502         -		  {
   503         -		      /* some unexpected error occurred */
   504         -		      fprintf (stderr, "sqlite3_step() error: %s\n",
   505         -			       sqlite3_errmsg (handle));
   506         -		      sqlite3_finalize (stmt);
   507         -		      return -1;
   508         -		  }
   509         -	    }
   510         -	  sqlite3_finalize (stmt);
   511         -	  p = p->next;
   512         -      }
   513         -
   514         -/* the complete operation is handled as an unique SQL Transaction */
          654  +    char sql2[1024];
          655  +    sqlite3_stmt *query_stmt = NULL;
          656  +    sqlite3_stmt *update_stmt = NULL;
          657  +
          658  +/* the complete operation is handled as a unique SQL Transaction */
   515    659       ret = sqlite3_exec (handle, "BEGIN", NULL, NULL, &sql_err);
   516    660       if (ret != SQLITE_OK)
   517    661         {
   518    662   	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
   519    663   	  sqlite3_free (sql_err);
   520         -	  return -1;
          664  +	  return 0;
   521    665         }
   522         -/* preparing the SQL statement */
   523         -    strcpy (sql, "UPDATE osm_tmp_nodes SET alias = ?, refcount = ? ");
          666  +
          667  +/* querying NodeIds */
          668  +    strcpy (sql, "SELECT w.id, n1.ROWID, n2.ROWID ");
          669  +    sprintf (sql2, "FROM \"%s\" AS w, ", table);
          670  +    strcat (sql, sql2);
          671  +    strcat (sql, "graph_nodes AS n1, graph_nodes AS n2 ");
          672  +    strcat (sql, "WHERE n1.lon = ST_X(ST_StartPoint(w.Geometry)) ");
          673  +    strcat (sql, "AND n1.lat = ST_Y(ST_StartPoint(w.Geometry)) ");
          674  +    strcat (sql, "AND n2.lon = ST_X(ST_EndPoint(w.Geometry)) ");
          675  +    strcat (sql, "AND n2.lat = ST_Y(ST_EndPoint(w.Geometry))");
          676  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &query_stmt, NULL);
          677  +    if (ret != SQLITE_OK)
          678  +      {
          679  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
          680  +	  goto error;
          681  +      }
          682  +
          683  +/* updating Arcs */
          684  +    sprintf (sql, "UPDATE \"%s\" SET node_from = ?, node_to = ? ", table);
   524    685       strcat (sql, "WHERE id = ?");
   525         -    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
          686  +    ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &update_stmt, NULL);
   526    687       if (ret != SQLITE_OK)
   527    688         {
   528    689   	  fprintf (stderr, "SQL error: %s\n%s\n", sql, sqlite3_errmsg (handle));
   529         -	  return -1;
   530         -      }
   531         -
   532         -    p = first;
   533         -    while (p)
   534         -      {
   535         -	  pid = p->first;
   536         -	  while (pid)
   537         -	    {
   538         -		if (pid == p->first)
   539         -		  {
   540         -		      /* fixing the master node */
   541         -		      sqlite3_reset (stmt);
   542         -		      sqlite3_clear_bindings (stmt);
   543         -		      sqlite3_bind_int64 (stmt, 1, pid->id);
   544         -		      sqlite3_bind_int (stmt, 2, p->refcount);
   545         -		      sqlite3_bind_int64 (stmt, 3, pid->id);
   546         -		      ret = sqlite3_step (stmt);
   547         -		      if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   548         -			  count++;
   549         -		      else
   550         -			{
   551         -			    fprintf (stderr, "sqlite3_step() error: %s\n",
   552         -				     sqlite3_errmsg (handle));
   553         -			    sqlite3_finalize (stmt);
   554         -			    return -1;
   555         -			}
   556         -		  }
          690  +	  goto error;
          691  +      }
          692  +
          693  +    while (1)
          694  +      {
          695  +	  ret = sqlite3_step (query_stmt);
          696  +	  if (ret == SQLITE_DONE)
          697  +	      break;
          698  +	  if (ret == SQLITE_ROW)
          699  +	    {
          700  +		sqlite3_int64 id = sqlite3_column_int64 (query_stmt, 0);
          701  +		sqlite3_int64 node_from = sqlite3_column_int64 (query_stmt, 1);
          702  +		sqlite3_int64 node_to = sqlite3_column_int64 (query_stmt, 2);
          703  +
          704  +		/* udating the Arc */
          705  +		sqlite3_reset (update_stmt);
          706  +		sqlite3_clear_bindings (update_stmt);
          707  +		sqlite3_bind_int64 (update_stmt, 1, node_from);
          708  +		sqlite3_bind_int64 (update_stmt, 2, node_to);
          709  +		sqlite3_bind_int64 (update_stmt, 3, id);
          710  +		ret = sqlite3_step (update_stmt);
          711  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          712  +		    ;
   557    713   		else
   558    714   		  {
   559         -		      /* disambiguating the node */
   560         -		      sqlite3_reset (stmt);
   561         -		      sqlite3_clear_bindings (stmt);
   562         -		      sqlite3_bind_int64 (stmt, 1, p->first->id);
   563         -		      sqlite3_bind_int (stmt, 2, p->refcount);
   564         -		      sqlite3_bind_int64 (stmt, 3, pid->id);
   565         -		      ret = sqlite3_step (stmt);
   566         -		      if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   567         -			  count++;
   568         -		      else
   569         -			{
   570         -			    fprintf (stderr, "sqlite3_step() error: %s\n",
   571         -				     sqlite3_errmsg (handle));
   572         -			    sqlite3_finalize (stmt);
   573         -			    return -1;
   574         -			}
          715  +		      printf ("sqlite3_step() error: %s\n",
          716  +			      sqlite3_errmsg (handle));
          717  +		      goto error;
   575    718   		  }
   576         -		pid = pid->next;
   577    719   	    }
   578         -	  p = p->next;
          720  +	  else
          721  +	    {
          722  +		printf ("sqlite3_step() error: %s\n", sqlite3_errmsg (handle));
          723  +		goto error;
          724  +	    }
   579    725         }
   580         -/* finalizing the INSERT INTO prepared statement */
   581         -    sqlite3_finalize (stmt);
          726  +
          727  +    if (query_stmt != NULL)
          728  +	sqlite3_finalize (query_stmt);
          729  +    if (update_stmt != NULL)
          730  +	sqlite3_finalize (update_stmt);
   582    731   
   583    732   /* committing the still pending SQL Transaction */
   584    733       ret = sqlite3_exec (handle, "COMMIT", NULL, NULL, &sql_err);
   585    734       if (ret != SQLITE_OK)
   586    735         {
   587    736   	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
   588    737   	  sqlite3_free (sql_err);
   589         -	  return -1;
   590         -      }
   591         -
   592         -/* freeing the dup-nodes list */
   593         -    p = first;
   594         -    while (p)
   595         -      {
   596         -	  pn = p->next;
   597         -	  pid = p->first;
   598         -	  while (pid)
   599         -	    {
   600         -		pidn = pid->next;
   601         -		free (pid);
   602         -		pid = pidn;
   603         -	    }
   604         -	  free (p);
   605         -	  p = pn;
   606         -      }
   607         -    return count;
   608         -}
   609         -
   610         -static int
   611         -parse_way_id (const char *buf, sqlite3_int64 * id)
   612         -{
   613         -/* parsing <way id="value" > */
   614         -    char value[128];
   615         -    char *out = value;
   616         -    const char *p = buf;
   617         -    struct check_tag tag;
   618         -    init_tag (&tag, 4);
   619         -    while (*p != '\0')
   620         -      {
   621         -	  update_tag (&tag, *p);
   622         -	  p++;
   623         -	  if (strncmp (tag.buf, "id=\"", 4) == 0)
   624         -	    {
   625         -		while (*p != '\"')
   626         -		  {
   627         -		      *out++ = *p++;
   628         -		  }
   629         -		*out = '\0';
   630         -		*id = atol_64 (value);
   631         -		return 1;
   632         -	    }
          738  +      }
          739  +    return 1;
          740  +
          741  +  error:
          742  +    if (query_stmt != NULL)
          743  +	sqlite3_finalize (query_stmt);
          744  +    if (update_stmt != NULL)
          745  +	sqlite3_finalize (update_stmt);
          746  +
          747  +    ret = sqlite3_exec (handle, "ROLLBACK", NULL, NULL, &sql_err);
          748  +    if (ret != SQLITE_OK)
          749  +      {
          750  +	  fprintf (stderr, "ROLLBACK TRANSACTION error: %s\n", sql_err);
          751  +	  sqlite3_free (sql_err);
   633    752         }
   634    753       return 0;
   635    754   }
   636    755   
   637         -static int
   638         -parse_nd_id (const char *buf, sqlite3_int64 * id)
          756  +static double
          757  +compute_cost (struct aux_params *params, const char *class, double length)
   639    758   {
   640         -/* parsing <nd ref="value" > */
   641         -    char value[128];
   642         -    char *out = value;
   643         -    const char *p = buf;
   644         -    struct check_tag tag;
   645         -    init_tag (&tag, 5);
   646         -    while (*p != '\0')
          759  +/* computing the travel time [cost] */
          760  +    double speed = params->default_speed;	/* speed, in Km/h */
          761  +    double msec;
          762  +
          763  +    if (class != NULL)
   647    764         {
   648         -	  update_tag (&tag, *p);
   649         -	  p++;
   650         -	  if (strncmp (tag.buf, "ref=\"", 5) == 0)
          765  +	  struct aux_speed *ps = params->first_speed;
          766  +	  while (ps)
   651    767   	    {
   652         -		while (*p != '\"')
          768  +		if (strcmp (ps->class_name, class) == 0)
   653    769   		  {
   654         -		      *out++ = *p++;
          770  +		      speed = ps->speed;
          771  +		      break;
   655    772   		  }
   656         -		*out = '\0';
   657         -		*id = atol_64 (value);
   658         -		return 1;
          773  +		ps = ps->next;
   659    774   	    }
   660    775         }
   661         -    return 0;
          776  +
          777  +    msec = speed * 1000.0 / 3600.0;	/* transforming speed in m/sec */
          778  +    return length / msec;
   662    779   }
   663    780   
   664    781   static int
   665         -parse_tag_k (const char *buf, char *k)
   666         -{
   667         -/* parsing <tag k="value" > */
   668         -    char value[128];
   669         -    char *out = value;
   670         -    const char *p = buf;
   671         -    struct check_tag tag;
   672         -    init_tag (&tag, 3);
   673         -    while (*p != '\0')
   674         -      {
   675         -	  update_tag (&tag, *p);
   676         -	  p++;
   677         -	  if (strncmp (tag.buf, "k=\"", 3) == 0)
   678         -	    {
   679         -		while (*p != '\"')
   680         -		  {
   681         -		      *out++ = *p++;
   682         -		  }
   683         -		*out = '\0';
   684         -		strcpy (k, value);
   685         -		return 1;
   686         -	    }
   687         -      }
   688         -    return 0;
   689         -}
   690         -
   691         -static void
   692         -from_xml_string (const char *xml, char *clean)
   693         -{
   694         -/* cleans XML markers */
   695         -    char marker[16];
   696         -    char *pm;
   697         -    int is_marker = 0;
   698         -    const char *in = xml;
   699         -    char *out = clean;
   700         -    while (*in != '\0')
   701         -      {
   702         -	  if (is_marker)
   703         -	    {
   704         -		if (*in == ';')
   705         -		  {
   706         -		      /* closing an XML marker */
   707         -		      in++;
   708         -		      is_marker = 0;
   709         -		      *pm = '\0';
   710         -		      if (strcmp (marker, "&amp") == 0)
   711         -			  *out++ = '&';
   712         -		      if (strcmp (marker, "&lt") == 0)
   713         -			  *out++ = '<';
   714         -		      if (strcmp (marker, "&gt") == 0)
   715         -			  *out++ = '>';
   716         -		      if (strcmp (marker, "&quot") == 0)
   717         -			  *out++ = '"';
   718         -		      if (strcmp (marker, "&apos") == 0)
   719         -			  *out++ = '\'';
   720         -		  }
          782  +set_lengths_costs (struct aux_params *params, const char *table)
          783  +{
          784  +/* assigning lengths and costs to each Arc of the Graph */
          785  +    int ret;
          786  +    char *sql_err = NULL;
          787  +    char sql[8192];
          788  +    char sql2[1024];
          789  +    sqlite3_stmt *query_stmt = NULL;
          790  +    sqlite3_stmt *update_stmt = NULL;
          791  +
          792  +/* the complete operation is handled as a unique SQL Transaction */
          793  +    ret = sqlite3_exec (params->db_handle, "BEGIN", NULL, NULL, &sql_err);
          794  +    if (ret != SQLITE_OK)
          795  +      {
          796  +	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
          797  +	  sqlite3_free (sql_err);
          798  +	  return 0;
          799  +      }
          800  +
          801  +/* querying Arcs */
          802  +    strcpy (sql, "SELECT id, class, GreatCircleLength(Geometry) ");
          803  +    sprintf (sql2, "FROM \"%s\"", table);
          804  +    strcat (sql, sql2);
          805  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
          806  +			      &query_stmt, NULL);
          807  +    if (ret != SQLITE_OK)
          808  +      {
          809  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
          810  +		   sqlite3_errmsg (params->db_handle));
          811  +	  goto error;
          812  +      }
          813  +
          814  +/* updating Arcs */
          815  +    sprintf (sql, "UPDATE \"%s\" SET length = ?, cost = ? ", table);
          816  +    strcat (sql, "WHERE id = ?");
          817  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
          818  +			      &update_stmt, NULL);
          819  +    if (ret != SQLITE_OK)
          820  +      {
          821  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
          822  +		   sqlite3_errmsg (params->db_handle));
          823  +	  goto error;
          824  +      }
          825  +
          826  +    while (1)
          827  +      {
          828  +	  ret = sqlite3_step (query_stmt);
          829  +	  if (ret == SQLITE_DONE)
          830  +	      break;
          831  +	  if (ret == SQLITE_ROW)
          832  +	    {
          833  +		sqlite3_int64 id = sqlite3_column_int64 (query_stmt, 0);
          834  +		const char *class =
          835  +		    (const char *) sqlite3_column_text (query_stmt, 1);
          836  +		double length = sqlite3_column_double (query_stmt, 2);
          837  +		double cost = compute_cost (params, class, length);
          838  +
          839  +		/* udating the Arc */
          840  +		sqlite3_reset (update_stmt);
          841  +		sqlite3_clear_bindings (update_stmt);
          842  +		sqlite3_bind_double (update_stmt, 1, length);
          843  +		sqlite3_bind_double (update_stmt, 2, cost);
          844  +		sqlite3_bind_int64 (update_stmt, 3, id);
          845  +		ret = sqlite3_step (update_stmt);
          846  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          847  +		    ;
   721    848   		else
   722         -		    *pm++ = *in++;
   723         -		continue;
   724         -	    }
   725         -	  if (*in == '&')
   726         -	    {
   727         -		/* found an XML marker */
   728         -		in++;
   729         -		is_marker = 1;
   730         -		pm = marker;
   731         -		*pm++ = '&';
   732         -		continue;
   733         -	    }
   734         -	  *out++ = *in++;
   735         -      }
   736         -    *out = '\0';
   737         -}
   738         -
   739         -static int
   740         -parse_tag_v (const char *buf, char *v)
   741         -{
   742         -/* parsing <tag v="value" > */
   743         -    char value[8192];
   744         -    char *out = value;
   745         -    const char *p = buf;
   746         -    struct check_tag tag;
   747         -    init_tag (&tag, 3);
   748         -    while (*p != '\0')
   749         -      {
   750         -	  update_tag (&tag, *p);
   751         -	  p++;
   752         -	  if (strncmp (tag.buf, "v=\"", 3) == 0)
   753         -	    {
   754         -		while (*p != '\"')
   755    849   		  {
   756         -		      *out++ = *p++;
          850  +		      printf ("sqlite3_step() error: %s\n",
          851  +			      sqlite3_errmsg (params->db_handle));
          852  +		      goto error;
   757    853   		  }
   758         -		*out = '\0';
   759         -		from_xml_string (value, v);
   760         -		return 1;
   761    854   	    }
          855  +	  else
          856  +	    {
          857  +		printf ("sqlite3_step() error: %s\n",
          858  +			sqlite3_errmsg (params->db_handle));
          859  +		goto error;
          860  +	    }
          861  +      }
          862  +
          863  +    if (query_stmt != NULL)
          864  +	sqlite3_finalize (query_stmt);
          865  +    if (update_stmt != NULL)
          866  +	sqlite3_finalize (update_stmt);
          867  +
          868  +/* committing the still pending SQL Transaction */
          869  +    ret = sqlite3_exec (params->db_handle, "COMMIT", NULL, NULL, &sql_err);
          870  +    if (ret != SQLITE_OK)
          871  +      {
          872  +	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
          873  +	  sqlite3_free (sql_err);
          874  +      }
          875  +    return 1;
          876  +
          877  +  error:
          878  +    if (query_stmt != NULL)
          879  +	sqlite3_finalize (query_stmt);
          880  +    if (update_stmt != NULL)
          881  +	sqlite3_finalize (update_stmt);
          882  +
          883  +    ret = sqlite3_exec (params->db_handle, "ROLLBACK", NULL, NULL, &sql_err);
          884  +    if (ret != SQLITE_OK)
          885  +      {
          886  +	  fprintf (stderr, "ROLLBACK TRANSACTION error: %s\n", sql_err);
          887  +	  sqlite3_free (sql_err);
   762    888         }
   763    889       return 0;
   764    890   }
   765    891   
   766    892   static int
   767         -parse_tag_kv (const char *buf, char *k, char *v)
   768         -{
   769         -/* parsing a <tag> tag */
   770         -    if (!parse_tag_k (buf, k))
   771         -	return 0;
   772         -    if (!parse_tag_v (buf, v))
   773         -	return 0;
   774         -    return 1;
   775         -}
   776         -
   777         -static int
   778         -parse_way_tag (const char *buf, struct way *xway)
   779         -{
   780         -/* parsing a <way> tag */
   781         -    int nd = 0;
   782         -    int tg = 0;
   783         -    const char *in;
   784         -    char value[65536];
   785         -    char k[8192];
   786         -    char v[8192];
   787         -    char *p;
   788         -    char c;
   789         -    int opened;
   790         -    int last_c;
   791         -    sqlite3_int64 id;
   792         -    struct check_tag tag;
   793         -    if (!parse_way_id (buf, &(xway->id)))
   794         -	return 0;
   795         -/* parsing the <nd> list */
   796         -    in = buf;
   797         -    init_tag (&tag, 4);
   798         -    while (*in != '\0')
   799         -      {
   800         -	  c = *in++;
   801         -	  if (nd)
   802         -	    {
   803         -		/* we are inside a <nd> tag */
   804         -		*p++ = c;
   805         -		if (c == '<')
   806         -		    opened++;
   807         -		if (!opened && c == '>' && last_c == '/')
          893  +create_qualified_nodes (struct aux_params *params, const char *table)
          894  +{
          895  +/* creating and feeding the helper table representing Nodes of the Graph */
          896  +    int ret;
          897  +    char *sql_err = NULL;
          898  +    char sql[8192];
          899  +    char sql2[1024];
          900  +    sqlite3_stmt *query_stmt = NULL;
          901  +    sqlite3_stmt *insert_stmt = NULL;
          902  +    sqlite3_stmt *update_stmt = NULL;
          903  +    char *err_msg = NULL;
          904  +
          905  +    printf ("\nCreating helper table '%s_nodes' ... wait please ...\n", table);
          906  +    sprintf (sql, "CREATE TABLE \"%s_nodes\" (\n", table);
          907  +    strcat (sql, "node_id INTEGER NOT NULL PRIMARY KEY,\n");
          908  +    strcat (sql, "osm_id INTEGER,\n");
          909  +    strcat (sql, "cardinality INTEGER NOT NULL)\n");
          910  +    ret = sqlite3_exec (params->db_handle, sql, NULL, NULL, &err_msg);
          911  +    if (ret != SQLITE_OK)
          912  +      {
          913  +	  fprintf (stderr, "CREATE TABLE '%s_nodes' error: %s\n", table,
          914  +		   err_msg);
          915  +	  sqlite3_free (err_msg);
          916  +	  sqlite3_close (params->db_handle);
          917  +	  return 0;
          918  +      }
          919  +
          920  +    sprintf (sql, "SELECT AddGeometryColumn('%s_nodes', 'geometry', ", table);
          921  +    strcat (sql, " 4326, 'POINT', 'XY')");
          922  +    ret = sqlite3_exec (params->db_handle, sql, NULL, NULL, &err_msg);
          923  +    if (ret != SQLITE_OK)
          924  +      {
          925  +	  fprintf (stderr, "AddGeometryColumn() error: %s\n", err_msg);
          926  +	  sqlite3_free (err_msg);
          927  +	  sqlite3_close (params->db_handle);
          928  +	  return 0;
          929  +      }
          930  +
          931  +/* the complete operation is handled as a unique SQL Transaction */
          932  +    ret = sqlite3_exec (params->db_handle, "BEGIN", NULL, NULL, &sql_err);
          933  +    if (ret != SQLITE_OK)
          934  +      {
          935  +	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
          936  +	  sqlite3_free (sql_err);
          937  +	  return 0;
          938  +      }
          939  +
          940  +/* querying Arcs */
          941  +    strcpy (sql, "SELECT node_from, ST_StartPoint(Geometry), ");
          942  +    strcat (sql, "node_to, ST_EndPoint(Geometry) ");
          943  +    sprintf (sql2, "FROM \"%s\"", table);
          944  +    strcat (sql, sql2);
          945  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
          946  +			      &query_stmt, NULL);
          947  +    if (ret != SQLITE_OK)
          948  +      {
          949  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
          950  +		   sqlite3_errmsg (params->db_handle));
          951  +	  goto error;
          952  +      }
          953  +
          954  +/* Inserting Nodes */
          955  +    sprintf (sql,
          956  +	     "INSERT OR IGNORE INTO \"%s_nodes\" (node_id, cardinality, geometry) ",
          957  +	     table);
          958  +    strcat (sql, "VALUES (?, 0, ?)");
          959  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
          960  +			      &insert_stmt, NULL);
          961  +    if (ret != SQLITE_OK)
          962  +      {
          963  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
          964  +		   sqlite3_errmsg (params->db_handle));
          965  +	  goto error;
          966  +      }
          967  +
          968  +    while (1)
          969  +      {
          970  +	  ret = sqlite3_step (query_stmt);
          971  +	  if (ret == SQLITE_DONE)
          972  +	      break;
          973  +	  if (ret == SQLITE_ROW)
          974  +	    {
          975  +		sqlite3_int64 id1 = sqlite3_column_int64 (query_stmt, 0);
          976  +		const void *blob1 = sqlite3_column_blob (query_stmt, 1);
          977  +		int len1 = sqlite3_column_bytes (query_stmt, 1);
          978  +		sqlite3_int64 id2 = sqlite3_column_int64 (query_stmt, 2);
          979  +		const void *blob2 = sqlite3_column_blob (query_stmt, 3);
          980  +		int len2 = sqlite3_column_bytes (query_stmt, 3);
          981  +
          982  +		/* inserting the Node (from) */
          983  +		sqlite3_reset (insert_stmt);
          984  +		sqlite3_clear_bindings (insert_stmt);
          985  +		sqlite3_bind_int64 (insert_stmt, 1, id1);
          986  +		sqlite3_bind_blob (insert_stmt, 2, blob1, len1, SQLITE_STATIC);
          987  +		ret = sqlite3_step (insert_stmt);
          988  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
          989  +		    ;
          990  +		else
          991  +		  {
          992  +		      printf ("sqlite3_step() error: %s\n",
          993  +			      sqlite3_errmsg (params->db_handle));
          994  +		      goto error;
          995  +		  }
          996  +
          997  +		/* inserting the Node (to) */
          998  +		sqlite3_reset (insert_stmt);
          999  +		sqlite3_clear_bindings (insert_stmt);
         1000  +		sqlite3_bind_int64 (insert_stmt, 1, id2);
         1001  +		sqlite3_bind_blob (insert_stmt, 2, blob2, len2, SQLITE_STATIC);
         1002  +		ret = sqlite3_step (insert_stmt);
         1003  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
         1004  +		    ;
         1005  +		else
         1006  +		  {
         1007  +		      printf ("sqlite3_step() error: %s\n",
         1008  +			      sqlite3_errmsg (params->db_handle));
         1009  +		      goto error;
         1010  +		  }
         1011  +	    }
         1012  +	  else
         1013  +	    {
         1014  +		printf ("sqlite3_step() error: %s\n",
         1015  +			sqlite3_errmsg (params->db_handle));
         1016  +		goto error;
         1017  +	    }
         1018  +      }
         1019  +
         1020  +    if (query_stmt != NULL)
         1021  +	sqlite3_finalize (query_stmt);
         1022  +    if (insert_stmt != NULL)
         1023  +	sqlite3_finalize (insert_stmt);
         1024  +
         1025  +/* committing the still pending SQL Transaction */
         1026  +    ret = sqlite3_exec (params->db_handle, "COMMIT", NULL, NULL, &sql_err);
         1027  +    if (ret != SQLITE_OK)
         1028  +      {
         1029  +	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
         1030  +	  sqlite3_free (sql_err);
         1031  +      }
         1032  +/* re-opening a Transaction */
         1033  +    ret = sqlite3_exec (params->db_handle, "BEGIN", NULL, NULL, &sql_err);
         1034  +    if (ret != SQLITE_OK)
         1035  +      {
         1036  +	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
         1037  +	  sqlite3_free (sql_err);
         1038  +	  return 0;
         1039  +      }
         1040  +
         1041  +/* re-querying Arcs */
         1042  +    strcpy (sql, "SELECT node_from, node_to ");
         1043  +    sprintf (sql2, "FROM \"%s\"", table);
         1044  +    strcat (sql, sql2);
         1045  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1046  +			      &query_stmt, NULL);
         1047  +    if (ret != SQLITE_OK)
         1048  +      {
         1049  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1050  +		   sqlite3_errmsg (params->db_handle));
         1051  +	  goto error;
         1052  +      }
         1053  +
         1054  +/* Updating Nodes */
         1055  +    sprintf (sql, "UPDATE \"%s_nodes\" SET cardinality = (cardinality + 1) ",
         1056  +	     table);
         1057  +    strcat (sql, "WHERE node_id = ?");
         1058  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1059  +			      &update_stmt, NULL);
         1060  +    if (ret != SQLITE_OK)
         1061  +      {
         1062  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1063  +		   sqlite3_errmsg (params->db_handle));
         1064  +	  goto error;
         1065  +      }
         1066  +
         1067  +    while (1)
         1068  +      {
         1069  +	  ret = sqlite3_step (query_stmt);
         1070  +	  if (ret == SQLITE_DONE)
         1071  +	      break;
         1072  +	  if (ret == SQLITE_ROW)
         1073  +	    {
         1074  +		sqlite3_int64 id1 = sqlite3_column_int64 (query_stmt, 0);
         1075  +		sqlite3_int64 id2 = sqlite3_column_int64 (query_stmt, 1);
         1076  +
         1077  +		/* udating the Node (from) */
         1078  +		sqlite3_reset (update_stmt);
         1079  +		sqlite3_clear_bindings (update_stmt);
         1080  +		sqlite3_bind_double (update_stmt, 1, id1);
         1081  +		ret = sqlite3_step (update_stmt);
         1082  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
         1083  +		    ;
         1084  +		else
   808   1085   		  {
   809         -		      /* closing a <nd /> tag */
   810         -		      *p = '\0';
   811         -		      if (!parse_nd_id (value, &id))
   812         -			{
   813         -			    fprintf (stderr, "ERROR: invalid <nd>\n");
   814         -			    return 0;
   815         -			}
   816         -		      else
   817         -			{
   818         -			    struct node_ref *node =
   819         -				malloc (sizeof (struct node_ref));
   820         -			    node->id = id;
   821         -			    node->ignore = 1;
   822         -			    node->next = NULL;
   823         -			    if (xway->first == NULL)
   824         -				xway->first = node;
   825         -			    if (xway->last != NULL)
   826         -				xway->last->next = node;
   827         -			    xway->last = node;
   828         -			}
   829         -		      nd = 0;
   830         -		      continue;
         1086  +		      printf ("sqlite3_step() error: %s\n",
         1087  +			      sqlite3_errmsg (params->db_handle));
         1088  +		      goto error;
   831   1089   		  }
   832         -		last_c = c;
   833         -	    }
   834         -	  update_tag (&tag, c);
   835         -	  if (strncmp (tag.buf, "<nd ", 4) == 0)
   836         -	    {
   837         -		/* opening a <nd> tag */
   838         -		nd = 1;
   839         -		last_c = '\0';
   840         -		opened = 0;
   841         -		strcpy (value, "<nd ");
   842         -		p = value + 4;
   843         -		continue;
   844         -	    }
   845         -      }
   846         -/* parsing the <tag> list */
   847         -    in = buf;
   848         -    init_tag (&tag, 5);
   849         -    while (*in != '\0')
   850         -      {
   851         -	  c = *in++;
   852         -	  if (tg)
   853         -	    {
   854         -		/* we are inside a <tag> tag */
   855         -		*p++ = c;
   856         -		if (c == '<')
   857         -		    opened++;
   858         -		if (!opened && c == '>' && last_c == '/')
         1090  +
         1091  +		/* udating the Node (to) */
         1092  +		sqlite3_reset (update_stmt);
         1093  +		sqlite3_clear_bindings (update_stmt);
         1094  +		sqlite3_bind_double (update_stmt, 1, id2);
         1095  +		ret = sqlite3_step (update_stmt);
         1096  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
         1097  +		    ;
         1098  +		else
   859   1099   		  {
   860         -		      /* closing a <tag /> tag */
   861         -		      *p = '\0';
   862         -		      if (!parse_tag_kv (value, k, v))
   863         -			{
   864         -			    fprintf (stderr, "ERROR: invalid <tag>\n");
   865         -			    return 0;
   866         -			}
   867         -		      else
   868         -			{
   869         -			    struct kv *key_value = malloc (sizeof (struct kv));
   870         -			    key_value->k = malloc (strlen (k) + 1);
   871         -			    strcpy (key_value->k, k);
   872         -			    key_value->v = malloc (strlen (v) + 1);
   873         -			    strcpy (key_value->v, v);
   874         -			    key_value->next = NULL;
   875         -			    if (xway->first_kv == NULL)
   876         -				xway->first_kv = key_value;
   877         -			    if (xway->last_kv != NULL)
   878         -				xway->last_kv->next = key_value;
   879         -			    xway->last_kv = key_value;
   880         -			}
   881         -		      tg = 0;
   882         -		      continue;
         1100  +		      printf ("sqlite3_step() error: %s\n",
         1101  +			      sqlite3_errmsg (params->db_handle));
         1102  +		      goto error;
   883   1103   		  }
   884         -		last_c = c;
   885         -	    }
   886         -	  update_tag (&tag, c);
   887         -	  if (strncmp (tag.buf, "<tag ", 5) == 0)
   888         -	    {
   889         -		/* opening a <tag> tag */
   890         -		tg = 1;
   891         -		last_c = '\0';
   892         -		opened = 0;
   893         -		strcpy (value, "<tag ");
   894         -		p = value + 5;
   895         -		continue;
   896         -	    }
   897         -      }
   898         -    return 1;
   899         -}
   900         -
   901         -static void
   902         -clean_way (struct way *xway)
   903         -{
   904         -/* memory clean up */
   905         -    struct node_ref *p;
   906         -    struct node_ref *pn;
   907         -    struct kv *pkv;
   908         -    struct kv *pkvn;
   909         -    struct arc *pa;
   910         -    struct arc *pan;
   911         -    p = xway->first;
   912         -    while (p)
   913         -      {
   914         -	  pn = p->next;
   915         -	  free (p);
   916         -	  p = pn;
   917         -      }
   918         -    xway->first = NULL;
   919         -    xway->last = NULL;
   920         -    pkv = xway->first_kv;
   921         -    while (pkv)
   922         -      {
   923         -	  pkvn = pkv->next;
   924         -	  free (pkv->k);
   925         -	  free (pkv->v);
   926         -	  free (pkv);
   927         -	  pkv = pkvn;
   928         -      }
   929         -    xway->first_kv = NULL;
   930         -    xway->last_kv = NULL;
   931         -    pa = xway->first_arc;
   932         -    while (pa)
   933         -      {
   934         -	  pan = pa->next;
   935         -	  if (pa->dyn)
   936         -	      gaiaFreeDynamicLine (pa->dyn);
   937         -	  if (pa->geom)
   938         -	      gaiaFreeGeomColl (pa->geom);
   939         -	  free (pa);
   940         -	  pa = pan;
   941         -      }
   942         -    xway->first_arc = NULL;
   943         -    xway->last_arc = NULL;
   944         -    if (xway->class)
   945         -	free (xway->class);
   946         -    xway->class = NULL;
   947         -    if (xway->name)
   948         -	free (xway->name);
   949         -    xway->name = NULL;
   950         -}
   951         -
   952         -static void
   953         -set_way_name (struct way *xway)
   954         -{
   955         -/* trying to fetch the road name */
   956         -    struct kv *pkv;
   957         -    pkv = xway->first_kv;
   958         -    while (pkv)
   959         -      {
   960         -	  if (strcmp (pkv->k, "name") == 0)
   961         -	    {
   962         -		if (xway->name)
   963         -		    free (xway->name);
   964         -		xway->name = malloc (strlen (pkv->v) + 1);
   965         -		strcpy (xway->name, pkv->v);
   966         -		return;
   967         -	    }
   968         -	  if (strcmp (pkv->k, "ref") == 0)
   969         -	    {
   970         -		if (xway->name == NULL)
         1104  +	    }
         1105  +	  else
         1106  +	    {
         1107  +		printf ("sqlite3_step() error: %s\n",
         1108  +			sqlite3_errmsg (params->db_handle));
         1109  +		goto error;
         1110  +	    }
         1111  +      }
         1112  +
         1113  +    if (query_stmt != NULL)
         1114  +	sqlite3_finalize (query_stmt);
         1115  +    if (update_stmt != NULL)
         1116  +	sqlite3_finalize (update_stmt);
         1117  +
         1118  +/* committing the still pending SQL Transaction */
         1119  +    ret = sqlite3_exec (params->db_handle, "COMMIT", NULL, NULL, &sql_err);
         1120  +    if (ret != SQLITE_OK)
         1121  +      {
         1122  +	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
         1123  +	  sqlite3_free (sql_err);
         1124  +      }
         1125  +/* re-opening a Transaction */
         1126  +    ret = sqlite3_exec (params->db_handle, "BEGIN", NULL, NULL, &sql_err);
         1127  +    if (ret != SQLITE_OK)
         1128  +      {
         1129  +	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
         1130  +	  sqlite3_free (sql_err);
         1131  +	  return 0;
         1132  +      }
         1133  +
         1134  +/* querying Nodes */
         1135  +    strcpy (sql, "SELECT n.node_id, t.osm_id ");
         1136  +    sprintf (sql2, "FROM \"%s_nodes\" AS n ", table);
         1137  +    strcat (sql, sql2);
         1138  +    strcat (sql, "JOIN graph_nodes AS t ON (");
         1139  +    strcat (sql, "ST_X(n.Geometry) = t.lon AND ");
         1140  +    strcat (sql, "ST_Y(n.Geometry) = t.lat)");
         1141  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1142  +			      &query_stmt, NULL);
         1143  +    if (ret != SQLITE_OK)
         1144  +      {
         1145  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1146  +		   sqlite3_errmsg (params->db_handle));
         1147  +	  goto error;
         1148  +      }
         1149  +
         1150  +/* Updating Nodes */
         1151  +    sprintf (sql, "UPDATE \"%s_nodes\" SET osm_id = ? ", table);
         1152  +    strcat (sql, "WHERE node_id = ?");
         1153  +    ret = sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1154  +			      &update_stmt, NULL);
         1155  +    if (ret != SQLITE_OK)
         1156  +      {
         1157  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1158  +		   sqlite3_errmsg (params->db_handle));
         1159  +	  goto error;
         1160  +      }
         1161  +
         1162  +    while (1)
         1163  +      {
         1164  +	  ret = sqlite3_step (query_stmt);
         1165  +	  if (ret == SQLITE_DONE)
         1166  +	      break;
         1167  +	  if (ret == SQLITE_ROW)
         1168  +	    {
         1169  +		sqlite3_int64 id = sqlite3_column_int64 (query_stmt, 0);
         1170  +		sqlite3_int64 osm_id = sqlite3_column_int64 (query_stmt, 1);
         1171  +
         1172  +		/* udating the Node OSM-ID */
         1173  +		sqlite3_reset (update_stmt);
         1174  +		sqlite3_clear_bindings (update_stmt);
         1175  +		sqlite3_bind_int64 (update_stmt, 1, osm_id);
         1176  +		sqlite3_bind_int64 (update_stmt, 2, id);
         1177  +		ret = sqlite3_step (update_stmt);
         1178  +		if (ret == SQLITE_DONE || ret == SQLITE_ROW)
         1179  +		    ;
         1180  +		else
   971   1181   		  {
   972         -		      xway->name = malloc (strlen (pkv->v) + 1);
   973         -		      strcpy (xway->name, pkv->v);
   974         -		      return;
         1182  +		      printf ("sqlite3_step() error: %s\n",
         1183  +			      sqlite3_errmsg (params->db_handle));
         1184  +		      goto error;
   975   1185   		  }
   976   1186   	    }
   977         -	  pkv = pkv->next;
   978         -      }
   979         -}
   980         -
   981         -static int
   982         -is_valid_way (const char *key, const char *class, int railways)
   983         -{
   984         -/* checks if this one is an valid road to be included into the network */
   985         -    if (strcmp (key, "highway") == 0 && !railways)
   986         -      {
   987         -	  if (strcmp (class, "pedestrian") == 0)
   988         -	      return 0;
   989         -	  if (strcmp (class, "track") == 0)
   990         -	      return 0;
   991         -	  if (strcmp (class, "services") == 0)
   992         -	      return 0;
   993         -	  if (strcmp (class, "bus_guideway") == 0)
   994         -	      return 0;
   995         -	  if (strcmp (class, "path") == 0)
   996         -	      return 0;
   997         -	  if (strcmp (class, "cycleway") == 0)
   998         -	      return 0;
   999         -	  if (strcmp (class, "footway") == 0)
  1000         -	      return 0;
  1001         -	  if (strcmp (class, "bridleway") == 0)
  1002         -	      return 0;
  1003         -	  if (strcmp (class, "byway") == 0)
  1004         -	      return 0;
  1005         -	  if (strcmp (class, "steps") == 0)
  1006         -	      return 0;
  1007         -	  return 1;
  1008         -      }
  1009         -    if (strcmp (key, "railway") == 0 && railways)
  1010         -      {
  1011         -	  return 1;
         1187  +	  else
         1188  +	    {
         1189  +		printf ("sqlite3_step() error: %s\n",
         1190  +			sqlite3_errmsg (params->db_handle));
         1191  +		goto error;
         1192  +	    }
         1193  +      }
         1194  +/* committing the still pending SQL Transaction */
         1195  +    ret = sqlite3_exec (params->db_handle, "COMMIT", NULL, NULL, &sql_err);
         1196  +    if (ret != SQLITE_OK)
         1197  +      {
         1198  +	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
         1199  +	  sqlite3_free (sql_err);
         1200  +      }
         1201  +    printf ("\tHelper table '%s_nodes' succesfully created\n", table);
         1202  +    return 1;
         1203  +
         1204  +  error:
         1205  +    if (query_stmt != NULL)
         1206  +	sqlite3_finalize (query_stmt);
         1207  +    if (insert_stmt != NULL)
         1208  +	sqlite3_finalize (insert_stmt);
         1209  +    if (update_stmt != NULL)
         1210  +	sqlite3_finalize (update_stmt);
         1211  +
         1212  +    ret = sqlite3_exec (params->db_handle, "ROLLBACK", NULL, NULL, &sql_err);
         1213  +    if (ret != SQLITE_OK)
         1214  +      {
         1215  +	  fprintf (stderr, "ROLLBACK TRANSACTION error: %s\n", sql_err);
         1216  +	  sqlite3_free (sql_err);
  1012   1217         }
  1013   1218       return 0;
  1014   1219   }
  1015   1220   
  1016   1221   static void
  1017         -set_oneway (struct way *xway)
         1222  +finalize_sql_stmts (struct aux_params *params)
  1018   1223   {
  1019         -/* setting up the oneway markers */
  1020         -    struct kv *pkv;
  1021         -    xway->oneway = 0;
  1022         -    xway->reverse = 0;
  1023         -    pkv = xway->first_kv;
  1024         -    while (pkv)
  1025         -      {
  1026         -	  if (strcmp (pkv->k, "oneway") == 0)
  1027         -	    {
  1028         -		if (strcmp (pkv->v, "yes") == 0 || strcmp (pkv->v, "yes") == 0
  1029         -		    || strcmp (pkv->v, "1") == 0)
  1030         -		  {
  1031         -		      xway->oneway = 1;
  1032         -		      xway->reverse = 0;
  1033         -		  }
  1034         -		if (strcmp (pkv->v, "-1") == 0)
  1035         -		  {
  1036         -		      xway->oneway = 1;
  1037         -		      xway->reverse = 1;
  1038         -		  }
  1039         -	    }
  1040         -	  pkv = pkv->next;
  1041         -      }
  1042         -}
  1043         -
  1044         -static int
  1045         -check_way (struct way *xway, int railways)
  1046         -{
  1047         -/* checks if <way> is interesting to build the road network */
  1048         -    struct kv *pkv;
  1049         -    pkv = xway->first_kv;
  1050         -    while (pkv)
  1051         -      {
  1052         -	  if (is_valid_way (pkv->k, pkv->v, railways))
  1053         -	    {
  1054         -		xway->class = malloc (strlen (pkv->v) + 1);
  1055         -		strcpy (xway->class, pkv->v);
  1056         -		set_way_name (xway);
  1057         -		set_oneway (xway);
  1058         -		return 1;
  1059         -	    }
  1060         -	  pkv = pkv->next;
  1061         -      }
  1062         -    return 0;
  1063         -}
  1064         -
  1065         -static sqlite3_int64
  1066         -find_node (struct way *xway, double lon, double lat)
  1067         -{
  1068         -/* finding a node by coords */
  1069         -    struct node_ref *p = xway->first;
  1070         -    while (p)
  1071         -      {
  1072         -	  if (p->ignore == 0)
  1073         -	    {
  1074         -		if (p->lon == lon && p->lat == lat)
  1075         -		    return p->alias;
  1076         -	    }
  1077         -	  p = p->next;
  1078         -      }
  1079         -    return 0;
  1080         -}
  1081         -
  1082         -static double
  1083         -compute_time (const char *class, double length)
  1084         -{
  1085         -/* computing traval time */
  1086         -    double speed = 30.0;	/* speed, in Km/h */
  1087         -    double msec;
  1088         -    if (strcmp (class, "motorway") == 0 || strcmp (class, "trunk") == 0)
  1089         -	speed = 110;
  1090         -    if (strcmp (class, "primary") == 0)
  1091         -	speed = 90;
  1092         -    if (strcmp (class, "secondary") == 0)
  1093         -	speed = 70;
  1094         -    if (strcmp (class, "tertiary") == 0)
  1095         -	speed = 50;
  1096         -    msec = speed * 1000.0 / 3600.0;	/* transforming speed in m/sec */
  1097         -    return length / msec;
  1098         -}
  1099         -
  1100         -static int
  1101         -build_geometry (sqlite3 * handle, struct way *xway)
  1102         -{
  1103         -/* building geometry representing an ARC */
         1224  +/* memory cleanup - prepared statements */
  1104   1225       int ret;
  1105         -    sqlite3_stmt *stmt;
  1106         -    sqlite3_int64 id;
  1107         -    sqlite3_int64 alias;
  1108         -    int refcount;
  1109         -    double lon;
  1110         -    double lat;
  1111         -    char sql[8192];
  1112         -    int ind;
  1113         -    int points = 0;
  1114         -    int tbd;
  1115         -    int count;
  1116         -    int base = 0;
  1117         -    int block = 128;
  1118         -    int how_many;
  1119         -    struct node_ref *p;
  1120         -    struct node_ref *prev;
  1121         -    struct arc *pa;
  1122         -    gaiaLinestringPtr line;
  1123         -    double a;
  1124         -    double b;
  1125         -    double rf;
  1126         -    p = xway->first;
  1127         -    while (p)
  1128         -      {
  1129         -	  points++;
  1130         -	  p = p->next;
  1131         -      }
  1132         -    if (points < 2)
  1133         -      {
  1134         -	  /* discarding stupid degenerated lines - oh yes, there are lots of them !!! */
  1135         -	  return -1;
  1136         -      }
  1137         -    tbd = points;
  1138         -    while (tbd > 0)
  1139         -      {
  1140         -	  /* 
  1141         -	     / fetching node coords
  1142         -	     / requesting max 128 points at each time 
  1143         -	   */
  1144         -	  if (tbd < block)
  1145         -	      how_many = tbd;
  1146         -	  else
  1147         -	      how_many = block;
  1148         -	  strcpy (sql,
  1149         -		  "SELECT id, alias, lat, lon, refcount FROM osm_tmp_nodes ");
  1150         -	  strcat (sql, "WHERE id IN (");
  1151         -	  for (ind = 0; ind < how_many; ind++)
  1152         -	    {
  1153         -		if (ind == 0)
  1154         -		    strcat (sql, "?");
  1155         -		else
  1156         -		    strcat (sql, ",?");
  1157         -	    }
  1158         -	  strcat (sql, ")");
  1159         -	  ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  1160         -	  if (ret != SQLITE_OK)
  1161         -	    {
  1162         -		fprintf (stderr, "SQL error: %s\n%s\n", sql,
  1163         -			 sqlite3_errmsg (handle));
  1164         -		return 0;
  1165         -	    }
  1166         -	  sqlite3_reset (stmt);
  1167         -	  sqlite3_clear_bindings (stmt);
  1168         -	  ind = 1;
  1169         -	  count = 0;
  1170         -	  p = xway->first;
  1171         -	  while (p)
  1172         -	    {
  1173         -		if (count < base)
  1174         -		  {
  1175         -		      count++;
  1176         -		      p = p->next;
  1177         -		      continue;
  1178         -		  }
  1179         -		if (count >= (base + how_many))
  1180         -		    break;
  1181         -		sqlite3_bind_int64 (stmt, ind, p->id);
  1182         -		ind++;
  1183         -		count++;
  1184         -		p = p->next;
  1185         -	    }
  1186         -	  while (1)
  1187         -	    {
  1188         -		/* scrolling the result set */
  1189         -		ret = sqlite3_step (stmt);
  1190         -		if (ret == SQLITE_DONE)
  1191         -		  {
  1192         -		      /* there are no more rows to fetch - we can stop looping */
  1193         -		      break;
  1194         -		  }
  1195         -		if (ret == SQLITE_ROW)
  1196         -		  {
  1197         -		      /* ok, we've just fetched a valid row */
  1198         -		      id = sqlite3_column_int64 (stmt, 0);
  1199         -		      alias = sqlite3_column_int64 (stmt, 1);
  1200         -		      lat = sqlite3_column_double (stmt, 2);
  1201         -		      lon = sqlite3_column_double (stmt, 3);
  1202         -		      refcount = sqlite3_column_int (stmt, 4);
  1203         -		      p = xway->first;
  1204         -		      while (p)
  1205         -			{
  1206         -			    if (p->id == id)
  1207         -			      {
  1208         -				  p->lat = lat;
  1209         -				  p->lon = lon;
  1210         -				  p->alias = alias;
  1211         -				  p->refcount = refcount;
  1212         -				  p->ignore = 0;
  1213         -			      }
  1214         -			    p = p->next;
  1215         -			}
  1216         -		  }
  1217         -		else
  1218         -		  {
  1219         -		      /* some unexpected error occurred */
  1220         -		      fprintf (stderr, "sqlite3_step() error: %s\n",
  1221         -			       sqlite3_errmsg (handle));
  1222         -		      sqlite3_finalize (stmt);
  1223         -		      return 0;
  1224         -		  }
  1225         -	    }
  1226         -	  sqlite3_finalize (stmt);
  1227         -	  tbd -= how_many;
  1228         -	  base += how_many;
  1229         -      }
  1230         -    prev = NULL;
  1231         -    p = xway->first;
  1232         -    while (p)
  1233         -      {
  1234         -	  /* marking repeated points as invalid */
  1235         -	  if (p->ignore)
  1236         -	    {
  1237         -		p = p->next;
  1238         -		continue;
  1239         -	    }
  1240         -	  if (prev)
  1241         -	    {
  1242         -		if (p->lon == prev->lon && p->lat == prev->lat)
  1243         -		    p->ignore = 1;
  1244         -	    }
  1245         -	  prev = p;
  1246         -	  p = p->next;
  1247         -      }
  1248         -    points = 0;
  1249         -    p = xway->first;
  1250         -    while (p)
  1251         -      {
  1252         -	  if (p->ignore == 0)
  1253         -	      points++;
  1254         -	  p = p->next;
  1255         -      }
  1256         -    if (points < 2)
  1257         -      {
  1258         -	  /* discarding stupid degenerated lines - oh yes, there are lots of them !!! */
  1259         -	  return -1;
  1260         -      }
  1261         -/* creating a new ARC */
  1262         -    pa = malloc (sizeof (struct arc));
  1263         -    pa->geom = NULL;
  1264         -    pa->next = NULL;
  1265         -    xway->first_arc = pa;
  1266         -    xway->last_arc = pa;
  1267         -    pa->dyn = gaiaAllocDynamicLine ();
  1268         -    p = xway->first;
  1269         -    while (p)
  1270         -      {
  1271         -	  /* setting up dynamic lines */
  1272         -	  if (p->ignore)
  1273         -	    {
  1274         -		/* skipping invalid points */
  1275         -		p = p->next;
  1276         -		continue;
  1277         -	    }
  1278         -	  if (pa->dyn->First == NULL)
  1279         -	      pa->from = p->alias;
  1280         -	  gaiaAppendPointToDynamicLine (pa->dyn, p->lon, p->lat);
  1281         -	  pa->to = p->alias;
  1282         -	  if (p != xway->first && p != xway->last)
  1283         -	    {
  1284         -		if (p->refcount > 1)
  1285         -		  {
  1286         -		      /* found a graph NODE: creating a new ARC */
  1287         -		      pa = malloc (sizeof (struct arc));
  1288         -		      pa->geom = NULL;
  1289         -		      pa->next = NULL;
  1290         -		      xway->last_arc->next = pa;
  1291         -		      xway->last_arc = pa;
  1292         -		      pa->from = p->alias;
  1293         -		      pa->to = p->alias;
  1294         -		      pa->dyn = gaiaAllocDynamicLine ();
  1295         -		      gaiaAppendPointToDynamicLine (pa->dyn, p->lon, p->lat);
  1296         -		  }
  1297         -	    }
  1298         -	  p = p->next;
  1299         -      }
  1300         -    pa = xway->first_arc;
  1301         -    while (pa)
  1302         -      {
  1303         -	  /* splitting self-closed arcs [rings] */
  1304         -	  if (pa->dyn->First == NULL)
  1305         -	    {
  1306         -		/* skipping empty lines */
  1307         -		pa = pa->next;
  1308         -		continue;
  1309         -	    }
  1310         -	  if (pa->dyn->First == pa->dyn->Last)
  1311         -	    {
  1312         -		/* skipping one-point-only lines */
  1313         -		pa = pa->next;
  1314         -		continue;
  1315         -	    }
  1316         -	  if (pa->dyn->First->X == pa->dyn->Last->X
  1317         -	      && pa->dyn->First->Y == pa->dyn->Last->Y)
  1318         -	    {
  1319         -		/* found a self-closure */
  1320         -		gaiaDynamicLinePtr saved = pa->dyn;
  1321         -		struct arc *pbis;
  1322         -		gaiaPointPtr pt;
  1323         -		int limit;
  1324         -		sqlite3_int64 node_id;
  1325         -		points = 0;
  1326         -		pt = saved->First;
  1327         -		while (pt)
  1328         -		  {
  1329         -		      /* counting how many points are there */
  1330         -		      points++;
  1331         -		      pt = pt->Next;
  1332         -		  }
  1333         -		limit = points / 2;
  1334         -		/* appending a new arc */
  1335         -		pbis = malloc (sizeof (struct arc));
  1336         -		pbis->geom = NULL;
  1337         -		pbis->next = NULL;
  1338         -		xway->last_arc->next = pbis;
  1339         -		xway->last_arc = pbis;
  1340         -		pbis->to = pa->to;
  1341         -		pbis->dyn = gaiaAllocDynamicLine ();
  1342         -		pa->dyn = gaiaAllocDynamicLine ();
  1343         -		ind = 0;
  1344         -		pt = saved->First;
  1345         -		while (pt)
  1346         -		  {
  1347         -		      /* appending points */
  1348         -		      if (ind < limit)
  1349         -			  gaiaAppendPointToDynamicLine (pa->dyn, pt->X, pt->Y);
  1350         -		      else if (ind == limit)
  1351         -			{
  1352         -			    gaiaAppendPointToDynamicLine (pa->dyn, pt->X,
  1353         -							  pt->Y);
  1354         -			    gaiaAppendPointToDynamicLine (pbis->dyn, pt->X,
  1355         -							  pt->Y);
  1356         -			    node_id = find_node (xway, pt->X, pt->Y);
  1357         -			}
  1358         -		      else
  1359         -			  gaiaAppendPointToDynamicLine (pbis->dyn, pt->X,
  1360         -							pt->Y);
  1361         -		      ind++;
  1362         -		      pt = pt->Next;
  1363         -		  }
  1364         -		/* adjusting the node */
  1365         -		pa->to = node_id;
  1366         -		pbis->from = node_id;
  1367         -		gaiaFreeDynamicLine (saved);
  1368         -	    }
  1369         -	  pa = pa->next;
  1370         -      }
  1371         -    gaiaEllipseParams ("WGS84", &a, &b, &rf);
  1372         -    pa = xway->first_arc;
  1373         -    while (pa)
  1374         -      {
  1375         -	  /* setting up geometries */
  1376         -	  gaiaPointPtr pt;
  1377         -	  if (pa->dyn->First == NULL)
  1378         -	    {
  1379         -		/* skipping empty lines */
  1380         -		pa = pa->next;
  1381         -		continue;
  1382         -	    }
  1383         -	  if (pa->dyn->First == pa->dyn->Last)
  1384         -	    {
  1385         -		/* skipping one-point-only lines */
  1386         -		pa = pa->next;
  1387         -		continue;
  1388         -	    }
  1389         -	  points = 0;
  1390         -	  pt = pa->dyn->First;
  1391         -	  while (pt)
  1392         -	    {
  1393         -		/* counting how many points are there */
  1394         -		points++;
  1395         -		pt = pt->Next;
  1396         -	    }
  1397         -	  pa->geom = gaiaAllocGeomColl ();
  1398         -	  pa->geom->Srid = 4326;
  1399         -	  line = gaiaAddLinestringToGeomColl (pa->geom, points);
  1400         -	  ind = 0;
  1401         -	  pt = pa->dyn->First;
  1402         -	  while (pt)
  1403         -	    {
  1404         -		/* setting up linestring coords */
  1405         -		gaiaSetPoint (line->Coords, ind, pt->X, pt->Y);
  1406         -		ind++;
  1407         -		pt = pt->Next;
  1408         -	    }
  1409         -	  gaiaFreeDynamicLine (pa->dyn);
  1410         -	  pa->dyn = NULL;
  1411         -	  pa->length =
  1412         -	      gaiaGreatCircleTotalLength (a, b,
  1413         -					  pa->geom->FirstLinestring->
  1414         -					  DimensionModel,
  1415         -					  pa->geom->FirstLinestring->Coords,
  1416         -					  pa->geom->FirstLinestring->Points);
  1417         -	  pa->cost = compute_time (xway->class, pa->length);
  1418         -	  pa = pa->next;
  1419         -      }
  1420         -    return 1;
  1421         -}
  1422         -
  1423         -static int
  1424         -insert_arc_bidir (sqlite3 * handle, sqlite3_stmt * stmt, struct way *xway,
  1425         -		  struct arc *xarc)
  1426         -{
  1427         -/* inserting a bidirectional ARC [OSM road] into the DB */
  1428         -    int ret;
  1429         -    unsigned char *blob;
  1430         -    int blob_size;
  1431         -    const char *unknown = "unknown";
  1432         -    sqlite3_reset (stmt);
  1433         -    sqlite3_clear_bindings (stmt);
  1434         -    sqlite3_bind_int64 (stmt, 1, xway->id);
  1435         -    sqlite3_bind_text (stmt, 2, xway->class, strlen (xway->class),
  1436         -		       SQLITE_STATIC);
  1437         -    sqlite3_bind_int64 (stmt, 3, xarc->from);
  1438         -    sqlite3_bind_int64 (stmt, 4, xarc->to);
  1439         -    if (xway->name)
  1440         -	sqlite3_bind_text (stmt, 5, xway->name, strlen (xway->name),
  1441         -			   SQLITE_STATIC);
  1442         -    else
  1443         -	sqlite3_bind_text (stmt, 5, unknown, strlen (unknown), SQLITE_STATIC);
  1444         -    if (xway->oneway)
  1445         -      {
  1446         -	  /* oneway arc */
  1447         -	  if (xway->reverse)
  1448         -	    {
  1449         -		/* reverse */
  1450         -		sqlite3_bind_int (stmt, 6, 0);
  1451         -		sqlite3_bind_int (stmt, 7, 1);
  1452         -	    }
  1453         -	  else
  1454         -	    {
  1455         -		/* conformant */
  1456         -		sqlite3_bind_int (stmt, 6, 1);
  1457         -		sqlite3_bind_int (stmt, 7, 0);
  1458         -	    }
  1459         -      }
  1460         -    else
  1461         -      {
  1462         -	  /* bidirectional arc */
  1463         -	  sqlite3_bind_int (stmt, 6, 1);
  1464         -	  sqlite3_bind_int (stmt, 7, 1);
  1465         -      }
  1466         -    sqlite3_bind_double (stmt, 8, xarc->length);
  1467         -    sqlite3_bind_double (stmt, 9, xarc->cost);
  1468         -    gaiaToSpatiaLiteBlobWkb (xarc->geom, &blob, &blob_size);
  1469         -    sqlite3_bind_blob (stmt, 10, blob, blob_size, free);
  1470         -    ret = sqlite3_step (stmt);
  1471         -    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1472         -	return 1;
  1473         -    fprintf (stderr, "sqlite3_step() error: %s\n", sqlite3_errmsg (handle));
  1474         -    sqlite3_finalize (stmt);
  1475         -    return 0;
  1476         -}
  1477         -
  1478         -static int
  1479         -insert_arc_unidir (sqlite3 * handle, sqlite3_stmt * stmt, struct way *xway,
  1480         -		   struct arc *xarc)
  1481         -{
  1482         -/* inserting an unidirectional ARC [OSM road] into the DB */
  1483         -    int ret;
  1484         -    unsigned char *blob;
  1485         -    int blob_size;
  1486         -    const char *unknown = "unknown";
  1487         -    int straight = 0;
  1488         -    int reverse = 0;
  1489         -    int count = 0;
  1490         -    if (xway->oneway)
  1491         -      {
  1492         -	  /* oneway arc */
  1493         -	  if (xway->reverse)
  1494         -	    {
  1495         -		/* reverse */
  1496         -		reverse = 1;
  1497         -	    }
  1498         -	  else
  1499         -	    {
  1500         -		/* conformant */
  1501         -		straight = 1;
  1502         -	    }
  1503         -      }
  1504         -    else
  1505         -      {
  1506         -	  /* bidirectional arc */
  1507         -	  straight = 1;
  1508         -	  reverse = 1;
  1509         -      }
  1510         -    if (straight)
  1511         -      {
  1512         -	  /* inserting to FromTo arc */
  1513         -	  sqlite3_reset (stmt);
  1514         -	  sqlite3_clear_bindings (stmt);
  1515         -	  sqlite3_bind_int64 (stmt, 1, xway->id);
  1516         -	  sqlite3_bind_text (stmt, 2, xway->class, strlen (xway->class),
  1517         -			     SQLITE_STATIC);
  1518         -	  sqlite3_bind_int64 (stmt, 3, xarc->from);
  1519         -	  sqlite3_bind_int64 (stmt, 4, xarc->to);
  1520         -	  if (xway->name)
  1521         -	      sqlite3_bind_text (stmt, 5, xway->name, strlen (xway->name),
  1522         -				 SQLITE_STATIC);
  1523         -	  else
  1524         -	      sqlite3_bind_text (stmt, 5, unknown, strlen (unknown),
  1525         -				 SQLITE_STATIC);
  1526         -	  sqlite3_bind_double (stmt, 6, xarc->length);
  1527         -	  sqlite3_bind_double (stmt, 7, xarc->cost);
  1528         -	  gaiaToSpatiaLiteBlobWkb (xarc->geom, &blob, &blob_size);
  1529         -	  sqlite3_bind_blob (stmt, 8, blob, blob_size, free);
  1530         -	  ret = sqlite3_step (stmt);
  1531         -	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1532         -	      count++;
  1533         -	  else
  1534         -	    {
  1535         -		fprintf (stderr, "sqlite3_step() error: %s\n",
  1536         -			 sqlite3_errmsg (handle));
  1537         -		sqlite3_finalize (stmt);
  1538         -		return 0;
  1539         -	    }
  1540         -      }
  1541         -    if (reverse)
  1542         -      {
  1543         -	  /* inserting to ToFrom arc */
  1544         -	  gaiaLinestringPtr ln1;
  1545         -	  gaiaLinestringPtr ln2;
  1546         -	  int iv;
  1547         -	  int iv2;
  1548         -	  double x;
  1549         -	  double y;
  1550         -	  sqlite3_reset (stmt);
  1551         -	  sqlite3_clear_bindings (stmt);
  1552         -	  sqlite3_bind_int64 (stmt, 1, xway->id);
  1553         -	  sqlite3_bind_text (stmt, 2, xway->class, strlen (xway->class),
  1554         -			     SQLITE_STATIC);
  1555         -	  sqlite3_bind_int64 (stmt, 3, xarc->to);
  1556         -	  sqlite3_bind_int64 (stmt, 4, xarc->from);
  1557         -	  if (xway->name)
  1558         -	      sqlite3_bind_text (stmt, 5, xway->name, strlen (xway->name),
  1559         -				 SQLITE_STATIC);
  1560         -	  else
  1561         -	      sqlite3_bind_text (stmt, 5, unknown, strlen (unknown),
  1562         -				 SQLITE_STATIC);
  1563         -	  /* reversing the linestring */
  1564         -	  ln1 = xarc->geom->FirstLinestring;
  1565         -	  ln2 = gaiaAllocLinestring (ln1->Points);
  1566         -	  xarc->geom->FirstLinestring = ln2;
  1567         -	  iv2 = 0;
  1568         -	  for (iv = ln1->Points - 1; iv >= 0; iv--)
  1569         -	    {
  1570         -		gaiaGetPoint (ln1->Coords, iv, &x, &y);
  1571         -		gaiaSetPoint (ln2->Coords, iv2, x, y);
  1572         -		iv2++;
  1573         -	    }
  1574         -	  gaiaFreeLinestring (ln1);
  1575         -	  sqlite3_bind_double (stmt, 6, xarc->length);
  1576         -	  sqlite3_bind_double (stmt, 7, xarc->cost);
  1577         -	  gaiaToSpatiaLiteBlobWkb (xarc->geom, &blob, &blob_size);
  1578         -	  sqlite3_bind_blob (stmt, 8, blob, blob_size, free);
  1579         -	  ret = sqlite3_step (stmt);
  1580         -	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1581         -	      count++;
  1582         -	  else
  1583         -	    {
  1584         -		fprintf (stderr, "sqlite3_step() error: %s\n",
  1585         -			 sqlite3_errmsg (handle));
  1586         -		sqlite3_finalize (stmt);
  1587         -		return 0;
  1588         -	    }
  1589         -      }
  1590         -    return count;
  1591         -}
  1592         -
  1593         -static int
  1594         -parse_ways_pass_2 (FILE * xml, sqlite3 * handle, const char *table,
  1595         -		   int double_arcs, char *value, int railways)
  1596         -{
  1597         -/* parsing <way> tags from XML file - Step II */
  1598         -    sqlite3_stmt *stmt;
         1226  +    char *sql_err = NULL;
         1227  +
         1228  +    if (params->ins_tmp_nodes_stmt != NULL)
         1229  +	sqlite3_finalize (params->ins_tmp_nodes_stmt);
         1230  +    if (params->upd_tmp_nodes_stmt != NULL)
         1231  +	sqlite3_finalize (params->upd_tmp_nodes_stmt);
         1232  +    if (params->rd_tmp_nodes_stmt != NULL)
         1233  +	sqlite3_finalize (params->rd_tmp_nodes_stmt);
         1234  +    if (params->ins_arcs_stmt != NULL)
         1235  +	sqlite3_finalize (params->ins_arcs_stmt);
         1236  +
         1237  +/* committing the still pending SQL Transaction */
         1238  +    ret = sqlite3_exec (params->db_handle, "COMMIT", NULL, NULL, &sql_err);
         1239  +    if (ret != SQLITE_OK)
         1240  +      {
         1241  +	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
         1242  +	  sqlite3_free (sql_err);
         1243  +	  return;
         1244  +      }
         1245  +}
         1246  +
         1247  +static void
         1248  +create_sql_stmts (struct aux_params *params)
         1249  +{
         1250  +/* creating prepared SQL statements */
         1251  +    sqlite3_stmt *ins_tmp_nodes_stmt;
         1252  +    sqlite3_stmt *upd_tmp_nodes_stmt;
         1253  +    sqlite3_stmt *rd_tmp_nodes_stmt;
         1254  +    sqlite3_stmt *ins_arcs_stmt;
         1255  +    char sql[1024];
  1599   1256       int ret;
  1600   1257       char *sql_err = NULL;
  1601         -    struct way xway;
  1602         -    int way = 0;
  1603         -    int count = 0;
  1604         -    int c;
  1605         -    char *p;
  1606         -    struct check_tag tag;
  1607         -    struct arc *xarc;
  1608         -    init_tag (&tag, 5);
  1609         -    xway.first = NULL;
  1610         -    xway.last = NULL;
  1611         -    xway.first_kv = NULL;
  1612         -    xway.last_kv = NULL;
  1613         -    xway.first_arc = NULL;
  1614         -    xway.last_arc = NULL;
  1615         -    xway.class = NULL;
  1616         -    xway.name = NULL;
  1617   1258   
  1618         -/* the complete operation is handled as an unique SQL Transaction */
  1619         -    ret = sqlite3_exec (handle, "BEGIN", NULL, NULL, &sql_err);
         1259  +/* the complete operation is handled as a unique SQL Transaction */
         1260  +    ret = sqlite3_exec (params->db_handle, "BEGIN", NULL, NULL, &sql_err);
  1620   1261       if (ret != SQLITE_OK)
  1621   1262         {
  1622   1263   	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
  1623   1264   	  sqlite3_free (sql_err);
  1624         -	  return -1;
  1625         -      }
  1626         -
  1627         -/* preparing the SQL statement */
  1628         -    if (double_arcs)
  1629         -      {
  1630         -	  /* unidirectional arcs */
  1631         -	  sprintf (value, "INSERT OR IGNORE INTO \"%s\" ", table);
  1632         -	  strcat (value, "(id, osm_id, class, node_from, node_to, name, ");
  1633         -	  strcat (value, "length, cost, geometry) VALUES ");
  1634         -	  strcat (value, "(NULL, ?, ?, ?, ?, ?, ?, ?, ?)");
  1635         -      }
  1636         -    else
  1637         -      {
  1638         -	  /* bidirectional arcs */
  1639         -	  sprintf (value, "INSERT OR IGNORE INTO \"%s\" ", table);
  1640         -	  strcat (value, "(id, osm_id, class, node_from, node_to, name, ");
  1641         -	  strcat (value,
  1642         -		  "oneway_fromto, oneway_tofrom, length, cost, geometry) ");
  1643         -	  strcat (value, "VALUES (NULL, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
  1644         -      }
  1645         -    ret = sqlite3_prepare_v2 (handle, value, strlen (value), &stmt, NULL);
  1646         -    if (ret != SQLITE_OK)
  1647         -      {
  1648         -	  fprintf (stderr, "SQL error: %s\n%s\n", value,
  1649         -		   sqlite3_errmsg (handle));
  1650         -	  return -1;
  1651         -      }
  1652         -
  1653         -    while ((c = getc (xml)) != EOF)
  1654         -      {
  1655         -	  if (way)
  1656         -	    {
  1657         -		/* we are inside a <way> tag */
  1658         -		*p++ = c;
  1659         -	    }
  1660         -	  update_tag (&tag, c);
  1661         -	  if (strncmp (tag.buf, "<way ", 5) == 0)
  1662         -	    {
  1663         -		/* opening a <way> tag */
  1664         -		way = 1;
  1665         -		strcpy (value, "<way ");
  1666         -		p = value + 5;
  1667         -		continue;
  1668         -	    }
  1669         -	  if (strncmp (tag.buf, "</way", 5) == 0)
  1670         -	    {
  1671         -		/* closing a <way> tag */
  1672         -		*p = '\0';
  1673         -		if (!parse_way_tag (value, &xway))
  1674         -		  {
  1675         -		      clean_way (&xway);
  1676         -		      fprintf (stderr, "ERROR: invalid <way>\n");
  1677         -		      sqlite3_finalize (stmt);
  1678         -		      return -1;
  1679         -		  }
  1680         -		else
  1681         -		  {
  1682         -		      if (check_way (&xway, railways))
  1683         -			{
  1684         -			    ret = build_geometry (handle, &xway);
  1685         -			    if (ret == 0)
  1686         -			      {
  1687         -				  fprintf (stderr,
  1688         -					   "ERROR: invalid geometry <way>\n");
  1689         -				  clean_way (&xway);
  1690         -				  sqlite3_finalize (stmt);
  1691         -				  return -1;
  1692         -			      }
  1693         -			    else if (ret < 0)
  1694         -				;
  1695         -			    else
  1696         -			      {
  1697         -				  xarc = xway.first_arc;
  1698         -				  while (xarc)
  1699         -				    {
  1700         -					if (xarc->geom == NULL)
  1701         -					  {
  1702         -					      /* skipping empty geometries */
  1703         -					      xarc = xarc->next;
  1704         -					      continue;
  1705         -					  }
  1706         -					if (double_arcs)
  1707         -					    ret =
  1708         -						insert_arc_unidir (handle, stmt,
  1709         -								   &xway, xarc);
  1710         -					else
  1711         -					    ret =
  1712         -						insert_arc_bidir (handle, stmt,
  1713         -								  &xway, xarc);
  1714         -					if (!ret)
  1715         -					  {
  1716         -					      clean_way (&xway);
  1717         -					      sqlite3_finalize (stmt);
  1718         -					      return -1;
  1719         -					  }
  1720         -					count += ret;
  1721         -					xarc = xarc->next;
  1722         -				    }
  1723         -			      }
  1724         -			}
  1725         -		      clean_way (&xway);
  1726         -		  }
  1727         -		way = 0;
  1728         -		continue;
  1729         -	    }
  1730         -      }
  1731         -/* finalizing the INSERT INTO prepared statement */
  1732         -    sqlite3_finalize (stmt);
  1733         -
  1734         -/* committing the still pending SQL Transaction */
  1735         -    ret = sqlite3_exec (handle, "COMMIT", NULL, NULL, &sql_err);
  1736         -    if (ret != SQLITE_OK)
  1737         -      {
  1738         -	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
  1739         -	  sqlite3_free (sql_err);
  1740         -	  return -1;
  1741         -      }
  1742         -    return count;
  1743         -}
  1744         -
  1745         -static int
  1746         -pre_check_way (struct way *xway, int railways)
  1747         -{
  1748         -/* checks if <way> is interesting to build the road network */
  1749         -    struct kv *pkv;
  1750         -    pkv = xway->first_kv;
  1751         -    while (pkv)
  1752         -      {
  1753         -	  if (is_valid_way (pkv->k, pkv->v, railways))
  1754         -	      return 1;
  1755         -	  pkv = pkv->next;
  1756         -      }
  1757         -    return 0;
  1758         -}
  1759         -
  1760         -static int
  1761         -update_node (sqlite3 * handle, sqlite3_stmt * stmt, sqlite3_int64 id)
  1762         -{
  1763         -/* updating the node reference count */
  1764         -    int ret;
  1765         -    sqlite3_reset (stmt);
  1766         -    sqlite3_clear_bindings (stmt);
  1767         -    sqlite3_bind_int64 (stmt, 1, id);
  1768         -    ret = sqlite3_step (stmt);
  1769         -    if (ret == SQLITE_DONE || ret == SQLITE_ROW)
  1770         -	return 1;
  1771         -    fprintf (stderr, "sqlite3_step() error: %s\n", sqlite3_errmsg (handle));
  1772         -    sqlite3_finalize (stmt);
  1773         -    return 0;
  1774         -}
  1775         -
  1776         -static int
  1777         -mark_nodes (sqlite3 * handle, sqlite3_stmt * stmt_upd, struct way *xway)
  1778         -{
  1779         -/* examining the node-reference list representing an ARC */
  1780         -    int ret;
  1781         -    sqlite3_stmt *stmt;
  1782         -    sqlite3_int64 id;
  1783         -    double lon;
  1784         -    double lat;
  1785         -    char sql[8192];
  1786         -    int ind;
  1787         -    int points = 0;
  1788         -    int tbd;
  1789         -    int count;
  1790         -    int base = 0;
  1791         -    int block = 128;
  1792         -    int how_many;
  1793         -    struct node_ref *p;
  1794         -    p = xway->first;
  1795         -    while (p)
  1796         -      {
  1797         -	  points++;
  1798         -	  p = p->next;
  1799         -      }
  1800         -    tbd = points;
  1801         -    while (tbd > 0)
  1802         -      {
  1803         -	  /* requesting max 128 points at each time */
  1804         -	  if (tbd < block)
  1805         -	      how_many = tbd;
  1806         -	  else
  1807         -	      how_many = block;
  1808         -	  strcpy (sql, "SELECT id, lat, lon FROM osm_tmp_nodes ");
  1809         -	  strcat (sql, "WHERE id IN (");
  1810         -	  for (ind = 0; ind < how_many; ind++)
  1811         -	    {
  1812         -		if (ind == 0)
  1813         -		    strcat (sql, "?");
  1814         -		else
  1815         -		    strcat (sql, ",?");
  1816         -	    }
  1817         -	  strcat (sql, ")");
  1818         -	  ret = sqlite3_prepare_v2 (handle, sql, strlen (sql), &stmt, NULL);
  1819         -	  if (ret != SQLITE_OK)
  1820         -	    {
  1821         -		fprintf (stderr, "SQL error: %s\n%s\n", sql,
  1822         -			 sqlite3_errmsg (handle));
  1823         -		return 0;
  1824         -	    }
  1825         -	  sqlite3_reset (stmt);
  1826         -	  sqlite3_clear_bindings (stmt);
  1827         -	  ind = 1;
  1828         -	  count = 0;
  1829         -	  p = xway->first;
  1830         -	  while (p)
  1831         -	    {
  1832         -		if (count < base)
  1833         -		  {
  1834         -		      count++;
  1835         -		      p = p->next;
  1836         -		      continue;
  1837         -		  }
  1838         -		if (count >= (base + how_many))
  1839         -		    break;
  1840         -		sqlite3_bind_int64 (stmt, ind, p->id);
  1841         -		ind++;
  1842         -		count++;
  1843         -		p = p->next;
  1844         -	    }
  1845         -	  while (1)
  1846         -	    {
  1847         -		/* scrolling the result set */
  1848         -		ret = sqlite3_step (stmt);
  1849         -		if (ret == SQLITE_DONE)
  1850         -		  {
  1851         -		      /* there are no more rows to fetch - we can stop looping */
  1852         -		      break;
  1853         -		  }
  1854         -		if (ret == SQLITE_ROW)
  1855         -		  {
  1856         -		      /* ok, we've just fetched a valid row */
  1857         -		      id = sqlite3_column_int (stmt, 0);
  1858         -		      lat = sqlite3_column_double (stmt, 1);
  1859         -		      lon = sqlite3_column_double (stmt, 2);
  1860         -		      p = xway->first;
  1861         -		      while (p)
  1862         -			{
  1863         -			    if (p->id == id)
  1864         -			      {
  1865         -				  p->lat = lat;
  1866         -				  p->lon = lon;
  1867         -				  p->ignore = 0;
  1868         -			      }
  1869         -			    p = p->next;
  1870         -			}
  1871         -		  }
  1872         -		else
  1873         -		  {
  1874         -		      /* some unexpected error occurred */
  1875         -		      fprintf (stderr, "sqlite3_step() error: %s\n",
  1876         -			       sqlite3_errmsg (handle));
  1877         -		      sqlite3_finalize (stmt);
  1878         -		      return 0;
  1879         -		  }
  1880         -	    }
  1881         -	  sqlite3_finalize (stmt);
  1882         -	  tbd -= how_many;
  1883         -	  base += how_many;
  1884         -      }
  1885         -    p = xway->first;
  1886         -    while (p)
  1887         -      {
  1888         -	  /* updating nodes ref-count */
  1889         -	  if (p->ignore == 0)
  1890         -	      update_node (handle, stmt_upd, p->id);
  1891         -	  p = p->next;
  1892         -      }
  1893         -    return 1;
  1894         -}
  1895         -
  1896         -static int
  1897         -parse_ways_pass_1 (FILE * xml, sqlite3 * handle, char *value, int railways)
  1898         -{
  1899         -/* parsing <way> tags from XML file - Pass I */
  1900         -    sqlite3_stmt *stmt;
  1901         -    int ret;
  1902         -    char *sql_err = NULL;
  1903         -    struct way xway;
  1904         -    int way = 0;
  1905         -    int count = 0;
  1906         -    int c;
  1907         -    char *p;
  1908         -    struct check_tag tag;
  1909         -    init_tag (&tag, 5);
  1910         -    xway.first = NULL;
  1911         -    xway.last = NULL;
  1912         -    xway.first_kv = NULL;
  1913         -    xway.last_kv = NULL;
  1914         -    xway.first_arc = NULL;
  1915         -    xway.last_arc = NULL;
  1916         -    xway.class = NULL;
  1917         -    xway.name = NULL;
  1918         -
  1919         -/* the complete operation is handled as an unique SQL Transaction */
  1920         -    ret = sqlite3_exec (handle, "BEGIN", NULL, NULL, &sql_err);
  1921         -    if (ret != SQLITE_OK)
  1922         -      {
  1923         -	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
  1924         -	  sqlite3_free (sql_err);
  1925         -	  return -1;
  1926         -      }
  1927         -/* preparing the SQL statement */
  1928         -    strcpy (value, "UPDATE osm_tmp_nodes SET refcount = refcount + 1 ");
  1929         -    strcat (value, "WHERE id = ?");
  1930         -    ret = sqlite3_prepare_v2 (handle, value, strlen (value), &stmt, NULL);
  1931         -    if (ret != SQLITE_OK)
  1932         -      {
  1933         -	  fprintf (stderr, "SQL error: %s\n%s\n", value,
  1934         -		   sqlite3_errmsg (handle));
  1935         -	  return -1;
  1936         -      }
  1937         -
  1938         -    while ((c = getc (xml)) != EOF)
  1939         -      {
  1940         -	  if (way)
  1941         -	    {
  1942         -		/* we are inside a <way> tag */
  1943         -		*p++ = c;
  1944         -	    }
  1945         -	  update_tag (&tag, c);
  1946         -	  if (strncmp (tag.buf, "<way ", 5) == 0)
  1947         -	    {
  1948         -		/* opening a <way> tag */
  1949         -		way = 1;
  1950         -		strcpy (value, "<way ");
  1951         -		p = value + 5;
  1952         -		continue;
  1953         -	    }
  1954         -	  if (strncmp (tag.buf, "</way", 5) == 0)
  1955         -	    {
  1956         -		/* closing a <way> tag */
  1957         -		*p = '\0';
  1958         -		if (!parse_way_tag (value, &xway))
  1959         -		  {
  1960         -		      clean_way (&xway);
  1961         -		      fprintf (stderr, "ERROR: invalid <way>\n");
  1962         -		      return -1;
  1963         -		  }
  1964         -		else
  1965         -		  {
  1966         -		      if (pre_check_way (&xway, railways))
  1967         -			{
  1968         -			    if (!mark_nodes (handle, stmt, &xway))
  1969         -			      {
  1970         -				  fprintf (stderr,
  1971         -					   "ERROR: invalid node-reference list: <way>\n");
  1972         -				  clean_way (&xway);
  1973         -				  return -1;
  1974         -			      }
  1975         -			    count++;
  1976         -			}
  1977         -		      clean_way (&xway);
  1978         -		  }
  1979         -		way = 0;
  1980         -		continue;
  1981         -	    }
  1982         -      }
  1983         -/* finalizing the INSERT INTO prepared statement */
  1984         -    sqlite3_finalize (stmt);
  1985         -
  1986         -/* committing the still pending SQL Transaction */
  1987         -    ret = sqlite3_exec (handle, "COMMIT", NULL, NULL, &sql_err);
  1988         -    if (ret != SQLITE_OK)
  1989         -      {
  1990         -	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
  1991         -	  sqlite3_free (sql_err);
  1992         -	  return -1;
  1993         -      }
  1994         -    return count;
  1995         -}
  1996         -
  1997         -static void
  1998         -db_cleanup (sqlite3 * handle)
  1999         -{
  2000         -    int ret;
  2001         -    char *sql_err = NULL;
  2002         -/* dropping the OSM_TMP_NODES table */
  2003         -    printf ("\nDropping temporary table 'osm_tmp_nodes' ... wait please ...\n");
         1265  +	  return;
         1266  +      }
         1267  +    strcpy (sql, "INSERT INTO osm_tmp_nodes (id, lat, lon, ref_count) ");
         1268  +    strcat (sql, "VALUES (?, ?, ?, 0)");
         1269  +    ret =
         1270  +	sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1271  +			    &ins_tmp_nodes_stmt, NULL);
         1272  +    if (ret != SQLITE_OK)
         1273  +      {
         1274  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1275  +		   sqlite3_errmsg (params->db_handle));
         1276  +	  finalize_sql_stmts (params);
         1277  +	  return;
         1278  +      }
         1279  +    strcpy (sql, "UPDATE osm_tmp_nodes SET ref_count = (ref_count + 1) ");
         1280  +    strcat (sql, "WHERE id = ?");
         1281  +    ret =
         1282  +	sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1283  +			    &upd_tmp_nodes_stmt, NULL);
         1284  +    if (ret != SQLITE_OK)
         1285  +      {
         1286  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1287  +		   sqlite3_errmsg (params->db_handle));
         1288  +	  finalize_sql_stmts (params);
         1289  +	  return;
         1290  +      }
         1291  +    strcpy (sql, "SELECT lon, lat, ref_count FROM osm_tmp_nodes ");
         1292  +    strcat (sql, "WHERE id = ?");
         1293  +    ret =
         1294  +	sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1295  +			    &rd_tmp_nodes_stmt, NULL);
         1296  +    if (ret != SQLITE_OK)
         1297  +      {
         1298  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1299  +		   sqlite3_errmsg (params->db_handle));
         1300  +	  finalize_sql_stmts (params);
         1301  +	  return;
         1302  +      }
         1303  +    sprintf (sql, "INSERT INTO \"%s\" ", params->table);
         1304  +    strcat (sql, "(id, osm_id, node_from, node_to, class, ");
         1305  +    strcat (sql,
         1306  +	    "name, oneway_fromto, oneway_tofrom, length, cost, geometry) ");
         1307  +    strcat (sql, "VALUES (NULL, ?, -1, -1, ?, ?, ?, ?, -1, -1, ?)");
  2004   1308       ret =
  2005         -	sqlite3_exec (handle, "DROP TABLE osm_tmp_nodes", NULL, NULL, &sql_err);
         1309  +	sqlite3_prepare_v2 (params->db_handle, sql, strlen (sql),
         1310  +			    &ins_arcs_stmt, NULL);
  2006   1311       if (ret != SQLITE_OK)
  2007   1312         {
  2008         -	  fprintf (stderr, "'DROP TABLE osm_tmp_nodes' error: %s\n", sql_err);
  2009         -	  sqlite3_free (sql_err);
         1313  +	  fprintf (stderr, "SQL error: %s\n%s\n", sql,
         1314  +		   sqlite3_errmsg (params->db_handle));
         1315  +	  finalize_sql_stmts (params);
  2010   1316   	  return;
  2011   1317         }
  2012         -    printf ("\tDropped table 'osm_tmp_nodes'\n");
  2013         -/* dropping the 'from_to' index */
  2014         -    printf ("\nDropping index 'from_to' ... wait please ...\n");
  2015         -    ret = sqlite3_exec (handle, "DROP INDEX from_to", NULL, NULL, &sql_err);
  2016         -    if (ret != SQLITE_OK)
  2017         -      {
  2018         -	  fprintf (stderr, "'DROP INDEX from_to' error: %s\n", sql_err);
  2019         -	  sqlite3_free (sql_err);
  2020         -	  return;
  2021         -      }
  2022         -    printf ("\tDropped index 'from_to'\n");
  2023         -}
  2024   1318   
  2025         -static void
  2026         -db_vacuum (sqlite3 * handle)
  2027         -{
  2028         -    int ret;
  2029         -    char *sql_err = NULL;
  2030         -/* VACUUMing the DB */
  2031         -    printf ("\nVACUUMing the DB ... wait please ...\n");
  2032         -    ret = sqlite3_exec (handle, "VACUUM", NULL, NULL, &sql_err);
  2033         -    if (ret != SQLITE_OK)
  2034         -      {
  2035         -	  fprintf (stderr, "VACUUM error: %s\n", sql_err);
  2036         -	  sqlite3_free (sql_err);
  2037         -	  return;
  2038         -      }
  2039         -    printf ("\tAll done: OSM graph was succesfully loaded\n");
         1319  +    params->ins_tmp_nodes_stmt = ins_tmp_nodes_stmt;
         1320  +    params->upd_tmp_nodes_stmt = upd_tmp_nodes_stmt;
         1321  +    params->rd_tmp_nodes_stmt = rd_tmp_nodes_stmt;
         1322  +    params->ins_arcs_stmt = ins_arcs_stmt;
  2040   1323   }
  2041   1324   
  2042   1325   static void
  2043   1326   spatialite_autocreate (sqlite3 * db)
  2044   1327   {
  2045   1328   /* attempting to perform self-initialization for a newly created DB */
  2046   1329       int ret;
................................................................................
  2192   1475   	;
  2193   1476       else
  2194   1477   	goto unknown;
  2195   1478   
  2196   1479   /* creating the OSM related tables */
  2197   1480       strcpy (sql, "CREATE TABLE osm_tmp_nodes (\n");
  2198   1481       strcat (sql, "id INTEGER NOT NULL PRIMARY KEY,\n");
  2199         -    strcat (sql, "alias INTEGER NOT NULL,\n");
  2200   1482       strcat (sql, "lat DOUBLE NOT NULL,\n");
  2201   1483       strcat (sql, "lon DOUBLE NOT NULL,\n");
  2202         -    strcat (sql, "refcount INTEGER NOT NULL)\n");
         1484  +    strcat (sql, "ref_count INTEGER NOT NULL)\n");
  2203   1485       ret = sqlite3_exec (handle, sql, NULL, NULL, &err_msg);
  2204   1486       if (ret != SQLITE_OK)
  2205   1487         {
  2206   1488   	  fprintf (stderr, "CREATE TABLE 'osm_tmp_nodes' error: %s\n", err_msg);
  2207   1489   	  sqlite3_free (err_msg);
  2208   1490   	  sqlite3_close (handle);
  2209   1491   	  return NULL;
         1492  +      }
         1493  +/* creating the GRAPH temporary nodes */
         1494  +    strcpy (sql, "CREATE TABLE graph_nodes (\n");
         1495  +    strcat (sql, "lon DOUBLE NOT NULL,\n");
         1496  +    strcat (sql, "lat DOUBLE NOT NULL,\n");
         1497  +    strcat (sql, "osm_id INTEGER,\n");
         1498  +    strcat (sql, "CONSTRAINT pk_nodes PRIMARY KEY (lon, lat))\n");
         1499  +    ret = sqlite3_exec (handle, sql, NULL, NULL, &err_msg);
         1500  +    if (ret != SQLITE_OK)
         1501  +      {
         1502  +	  fprintf (stderr, "CREATE TABLE 'graph_nodes' error: %s\n", err_msg);
         1503  +	  sqlite3_free (err_msg);
         1504  +	  sqlite3_close (handle);
         1505  +	  return NULL;
  2210   1506         }
  2211   1507   
  2212   1508       if (double_arcs)
  2213   1509         {
  2214   1510   	  /* unidirectional arcs */
  2215   1511   	  sprintf (sql, "CREATE TABLE \"%s\" (\n", table);
  2216   1512   	  strcat (sql, "id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n");
................................................................................
  2253   1549         {
  2254   1550   	  fprintf (stderr, "AddGeometryColumn() error: %s\n", err_msg);
  2255   1551   	  sqlite3_free (err_msg);
  2256   1552   	  sqlite3_close (handle);
  2257   1553   	  return NULL;
  2258   1554         }
  2259   1555   
  2260         -    sprintf (sql,
  2261         -	     "CREATE UNIQUE INDEX from_to ON \"%s\" (node_from, node_to, length, cost)",
  2262         -	     table);
  2263         -    ret = sqlite3_exec (handle, sql, NULL, NULL, &err_msg);
  2264         -    if (ret != SQLITE_OK)
  2265         -      {
  2266         -	  fprintf (stderr, "CREATE INDEX 'from_to' error: %s\n", err_msg);
  2267         -	  sqlite3_free (err_msg);
  2268         -	  sqlite3_close (handle);
  2269         -	  return NULL;
  2270         -      }
  2271         -
  2272   1556       return handle;
  2273   1557   
  2274   1558     unknown:
  2275   1559       if (handle)
  2276   1560   	sqlite3_close (handle);
  2277   1561       fprintf (stderr, "DB '%s'\n", path);
  2278   1562       fprintf (stderr, "doesn't seems to contain valid Spatial Metadata ...\n\n");
  2279   1563       fprintf (stderr, "Please, run the 'spatialite-init' SQL script \n");
  2280   1564       fprintf (stderr, "in order to initialize Spatial Metadata\n\n");
  2281   1565       return NULL;
  2282   1566   }
         1567  +
         1568  +static void
         1569  +db_cleanup (sqlite3 * handle)
         1570  +{
         1571  +    int ret;
         1572  +    char *sql_err = NULL;
         1573  +/* dropping the OSM_TMP_NODES table */
         1574  +    printf ("\nDropping temporary table 'osm_tmp_nodes' ... wait please ...\n");
         1575  +    ret =
         1576  +	sqlite3_exec (handle, "DROP TABLE osm_tmp_nodes", NULL, NULL, &sql_err);
         1577  +    if (ret != SQLITE_OK)
         1578  +      {
         1579  +	  fprintf (stderr, "'DROP TABLE osm_tmp_nodes' error: %s\n", sql_err);
         1580  +	  sqlite3_free (sql_err);
         1581  +	  return;
         1582  +      }
         1583  +    printf ("\tDropped table 'osm_tmp_nodes'\n");
         1584  +/* dropping the GRAPH_NODES table */
         1585  +    printf ("\nDropping temporary table 'graph_nodes' ... wait please ...\n");
         1586  +    ret = sqlite3_exec (handle, "DROP TABLE graph_nodes", NULL, NULL, &sql_err);
         1587  +    if (ret != SQLITE_OK)
         1588  +      {
         1589  +	  fprintf (stderr, "'DROP TABLE graph_nodes' error: %s\n", sql_err);
         1590  +	  sqlite3_free (sql_err);
         1591  +	  return;
         1592  +      }
         1593  +    printf ("\tDropped table 'graph_nodes'\n");
         1594  +}
         1595  +
         1596  +static void
         1597  +db_vacuum (sqlite3 * handle)
         1598  +{
         1599  +    int ret;
         1600  +    char *sql_err = NULL;
         1601  +/* VACUUMing the DB */
         1602  +    printf ("\nVACUUMing the DB ... wait please ...\n");
         1603  +    ret = sqlite3_exec (handle, "VACUUM", NULL, NULL, &sql_err);
         1604  +    if (ret != SQLITE_OK)
         1605  +      {
         1606  +	  fprintf (stderr, "VACUUM error: %s\n", sql_err);
         1607  +	  sqlite3_free (sql_err);
         1608  +	  return;
         1609  +      }
         1610  +    printf ("\tAll done: OSM graph was succesfully loaded\n");
         1611  +}
         1612  +
         1613  +static int
         1614  +parse_kv (char *line, const char **k, const char **v)
         1615  +{
         1616  +/* splitting two tokens separated by a colon ':' */
         1617  +    int i;
         1618  +    int cnt = 0;
         1619  +    int pos = -1;
         1620  +    int len = strlen (line);
         1621  +    for (i = 0; i < len; i++)
         1622  +      {
         1623  +	  if (line[i] == ':')
         1624  +	    {
         1625  +		/* delimiter found */
         1626  +		cnt++;
         1627  +		pos = i;
         1628  +	    }
         1629  +      }
         1630  +    if (cnt != 1)
         1631  +      {
         1632  +	  /* illegal string */
         1633  +	  return 0;
         1634  +      }
         1635  +    line[pos] = '\0';
         1636  +    *k = line;
         1637  +    *v = line + pos + 1;
         1638  +    return 1;
         1639  +}
         1640  +
         1641  +static void
         1642  +free_params (struct aux_params *params)
         1643  +{
         1644  +/* memory cleanup - aux params linked lists */
         1645  +    struct aux_speed *ps;
         1646  +    struct aux_speed *ps_n;
         1647  +    struct aux_class *pc;
         1648  +    struct aux_class *pc_n;
         1649  +    ps = params->first_speed;
         1650  +    while (ps)
         1651  +      {
         1652  +	  ps_n = ps->next;
         1653  +	  free (ps->class_name);
         1654  +	  free (ps);
         1655  +	  ps = ps_n;
         1656  +      }
         1657  +    params->first_speed = NULL;
         1658  +    params->last_speed = NULL;
         1659  +    pc = params->first_include;
         1660  +    while (pc)
         1661  +      {
         1662  +	  pc_n = pc->next;
         1663  +	  free (pc->class_name);
         1664  +	  if (pc->sub_class != NULL)
         1665  +	      free (pc->sub_class);
         1666  +	  free (pc);
         1667  +	  pc = pc_n;
         1668  +      }
         1669  +    params->first_include = NULL;
         1670  +    params->last_include = NULL;
         1671  +    pc = params->first_ignore;
         1672  +    while (pc)
         1673  +      {
         1674  +	  pc_n = pc->next;
         1675  +	  free (pc->class_name);
         1676  +	  if (pc->sub_class != NULL)
         1677  +	      free (pc->sub_class);
         1678  +	  free (pc);
         1679  +	  pc = pc_n;
         1680  +      }
         1681  +    params->first_ignore = NULL;
         1682  +    params->last_ignore = NULL;
         1683  +}
         1684  +
         1685  +static void
         1686  +add_speed_class (struct aux_params *params, const char *class, double speed)
         1687  +{
         1688  +/* inserting a class speed into the linked list */
         1689  +    int len = strlen (class);
         1690  +    struct aux_speed *p = malloc (sizeof (struct aux_speed));
         1691  +    p->class_name = malloc (len + 1);
         1692  +    strcpy (p->class_name, class);
         1693  +    p->speed = speed;
         1694  +    p->next = NULL;
         1695  +    if (params->first_speed == NULL)
         1696  +	params->first_speed = p;
         1697  +    if (params->last_speed != NULL)
         1698  +	params->last_speed->next = p;
         1699  +    params->last_speed = p;
         1700  +}
         1701  +
         1702  +static void
         1703  +add_include_class (struct aux_params *params, const char *class,
         1704  +		   const char *sub_class)
         1705  +{
         1706  +/* inserting an Include class into the linked list */
         1707  +    int len1 = strlen (class);
         1708  +    int len2 = strlen (sub_class);
         1709  +    struct aux_class *p = malloc (sizeof (struct aux_class));
         1710  +    p->class_name = malloc (len1 + 1);
         1711  +    strcpy (p->class_name, class);
         1712  +    if (len2 == 0)
         1713  +	p->sub_class = NULL;
         1714  +    else
         1715  +      {
         1716  +	  p->sub_class = malloc (len2 + 1);
         1717  +	  strcpy (p->sub_class, sub_class);
         1718  +      }
         1719  +    p->next = NULL;
         1720  +    if (params->first_include == NULL)
         1721  +	params->first_include = p;
         1722  +    if (params->last_include != NULL)
         1723  +	params->last_include->next = p;
         1724  +    params->last_include = p;
         1725  +}
         1726  +
         1727  +static void
         1728  +add_ignore_class (struct aux_params *params, const char *class,
         1729  +		  const char *sub_class)
         1730  +{
         1731  +/* inserting an Ignore class into the linked list */
         1732  +    int len1 = strlen (class);
         1733  +    int len2 = strlen (sub_class);
         1734  +    struct aux_class *p = malloc (sizeof (struct aux_class));
         1735  +    p->class_name = malloc (len1 + 1);
         1736  +    strcpy (p->class_name, class);
         1737  +    p->sub_class = malloc (len2 + 1);
         1738  +    strcpy (p->sub_class, sub_class);
         1739  +    p->next = NULL;
         1740  +    if (params->first_ignore == NULL)
         1741  +	params->first_ignore = p;
         1742  +    if (params->last_ignore != NULL)
         1743  +	params->last_ignore->next = p;
         1744  +    params->last_ignore = p;
         1745  +}
  2283   1746   
  2284   1747   static int
  2285         -check_osm_xml (FILE * xml)
         1748  +parse_template_line (struct aux_params *params, const char *line)
  2286   1749   {
  2287         -/* check if the file contains OSM XML */
  2288         -    int xml_open = 0;
  2289         -    int xml_close = 0;
  2290         -    int osm_open = 0;
  2291         -    int osm_close = 0;
  2292         -    int ok_xml = 0;
  2293         -    int ok_osm = 0;
  2294         -    char tag[512];
  2295         -    char *p;
  2296         -    int c;
  2297         -    int count = 0;
  2298         -    while ((c = getc (xml)) != EOF)
         1750  +/* parsing a template line */
         1751  +    char clean[8192];
         1752  +    char *out = clean;
         1753  +    const char *in = line;
         1754  +    int i;
         1755  +
         1756  +    *out = '\0';
         1757  +    while (1)
  2299   1758         {
  2300         -	  count++;
  2301         -	  if (count > 512)
         1759  +	  if (*in == '\0' || *in == '#')
         1760  +	    {
         1761  +		*out = '\0';
         1762  +		break;
         1763  +	    }
         1764  +	  *out++ = *in++;
         1765  +      }
         1766  +    for (i = (int) strlen (clean) - 1; i >= 0; i--)
         1767  +      {
         1768  +	  /* cleaning any tralining space/tab */
         1769  +	  if (clean[i] == ' ' || clean[i] == '\t')
         1770  +	      clean[i] = '\0';
         1771  +	  else
  2302   1772   	      break;
  2303         -	  if (!xml_open && c == '<')
  2304         -	    {
  2305         -		xml_open = 1;
  2306         -		p = tag;
  2307         -		*p = '\0';
  2308         -		continue;
  2309         -	    }
  2310         -	  if (!osm_open && c == '<')
  2311         -	    {
  2312         -		osm_open = 1;
  2313         -		p = tag;
  2314         -		*p = '\0';
  2315         -		continue;
  2316         -	    }
  2317         -	  if (!xml_close && c == '>')
  2318         -	    {
  2319         -		xml_close = 1;
  2320         -		*p = '\0';
  2321         -		if (strncmp (tag, "?xml", 4) == 0)
  2322         -		    ok_xml = 1;
  2323         -		continue;
  2324         -	    }
  2325         -	  if (!osm_close && c == '>')
  2326         -	    {
  2327         -		osm_close = 1;
  2328         -		*p = '\0';
  2329         -		if (strncmp (tag, "osm", 3) == 0)
  2330         -		    ok_osm = 1;
  2331         -		continue;
  2332         -	    }
  2333         -	  if (xml_open && !xml_close)
  2334         -	      *p++ = c;
  2335         -	  if (osm_open && !osm_close)
  2336         -	      *p++ = c;
  2337         -      }
  2338         -    if (ok_xml && ok_osm)
  2339         -	return 1;
         1773  +      }
         1774  +    if (*clean == '\0')
         1775  +	return 1;		/* ignoring empty lines */
         1776  +    if (strncmp (clean, "NodingStrategy:", 15) == 0)
         1777  +      {
         1778  +	  if (strcmp (clean + 15, "way-ends") == 0)
         1779  +	    {
         1780  +		params->noding_strategy = NODE_STRAT_ENDS;
         1781  +		return 1;
         1782  +	    }
         1783  +	  else if (strcmp (clean + 15, "none") == 0)
         1784  +	    {
         1785  +		params->noding_strategy = NODE_STRAT_NONE;
         1786  +		return 1;
         1787  +	    }
         1788  +	  else if (strcmp (clean + 15, "all") == 0)
         1789  +	    {
         1790  +		params->noding_strategy = NODE_STRAT_ALL;
         1791  +		return 1;
         1792  +	    }
         1793  +	  else
         1794  +	      return 0;
         1795  +      }
         1796  +    else if (strncmp (clean, "OnewayStrategy:", 15) == 0)
         1797  +      {
         1798  +	  if (strcmp (clean + 15, "full") == 0)
         1799  +	    {
         1800  +		params->oneway_strategy = ONEWAY_STRAT_FULL;
         1801  +		return 1;
         1802  +	    }
         1803  +	  else if (strcmp (clean + 15, "none") == 0)
         1804  +	    {
         1805  +		params->oneway_strategy = ONEWAY_STRAT_NONE;
         1806  +		return 1;
         1807  +	    }
         1808  +	  else if (strcmp (clean + 15, "ignore-roundabout") == 0)
         1809  +	    {
         1810  +		params->oneway_strategy = ONEWAY_STRAT_NO_ROUND;
         1811  +		return 1;
         1812  +	    }
         1813  +	  else if (strcmp (clean + 15, "ignore-motorway") == 0)
         1814  +	    {
         1815  +		params->oneway_strategy = ONEWAY_STRAT_NO_MOTOR;
         1816  +		return 1;
         1817  +	    }
         1818  +	  else if (strcmp (clean + 15, "ignore-both-roundabout-and-motorway") ==
         1819  +		   0)
         1820  +	    {
         1821  +		params->oneway_strategy = ONEWAY_STRAT_NO_BOTH;
         1822  +		return 1;
         1823  +	    }
         1824  +	  else
         1825  +	      return 0;
         1826  +      }
         1827  +    else if (strncmp (clean, "ClassInclude:", 13) == 0)
         1828  +      {
         1829  +	  const char *k;
         1830  +	  const char *v;
         1831  +	  if (parse_kv (clean + 13, &k, &v))
         1832  +	    {
         1833  +		if (strlen (k) > 0)
         1834  +		    add_include_class (params, k, v);
         1835  +		return 1;
         1836  +	    }
         1837  +	  else
         1838  +	      return 0;
         1839  +      }
         1840  +    else if (strncmp (clean, "ClassIgnore:", 12) == 0)
         1841  +      {
         1842  +	  const char *k;
         1843  +	  const char *v;
         1844  +	  if (parse_kv (clean + 12, &k, &v))
         1845  +	    {
         1846  +		if (strlen (k) > 0 && strlen (v) > 0)
         1847  +		    add_ignore_class (params, k, v);
         1848  +		return 1;
         1849  +	    }
         1850  +	  else
         1851  +	      return 0;
         1852  +      }
         1853  +    else if (strncmp (clean, "SpeedClass:", 11) == 0)
         1854  +      {
         1855  +	  const char *k;
         1856  +	  const char *v;
         1857  +	  if (parse_kv (clean + 11, &k, &v))
         1858  +	    {
         1859  +		if (*k == '\0')
         1860  +		    params->default_speed = atof (v);
         1861  +		else
         1862  +		    add_speed_class (params, k, atof (v));
         1863  +		return 1;
         1864  +	    }
         1865  +	  else
         1866  +	      return 0;
         1867  +      }
         1868  +/* some illegal expression found */
  2340   1869       return 0;
  2341   1870   }
         1871  +
         1872  +static int
         1873  +parse_template (struct aux_params *params, const char *template_path)
         1874  +{
         1875  +/* parsing a template-file */
         1876  +    char line[8192];
         1877  +    char *p = line;
         1878  +    int c;
         1879  +    int lineno = 0;
         1880  +    FILE *in = fopen (template_path, "rb");
         1881  +    if (in == NULL)
         1882  +      {
         1883  +	  fprintf (stderr, "Unable to open template-file \"%s\"\n",
         1884  +		   template_path);
         1885  +	  return 0;
         1886  +      }
         1887  +
         1888  +    while ((c = getc (in)) != EOF)
         1889  +      {
         1890  +
         1891  +	  if (c == '\r')
         1892  +	      continue;
         1893  +	  if (c == '\n')
         1894  +	    {
         1895  +		*p = '\0';
         1896  +		lineno++;
         1897  +		if (!parse_template_line (params, line))
         1898  +		  {
         1899  +		      fprintf (stderr,
         1900  +			       "Template-file \"%s\"\nParsing error on line %d\n\n",
         1901  +			       template_path, lineno);
         1902  +		      free_params (params);
         1903  +		      return 0;
         1904  +		  }
         1905  +		p = line;
         1906  +		continue;
         1907  +	    }
         1908  +	  *p++ = c;
         1909  +      }
         1910  +
         1911  +    fclose (in);
         1912  +    return 1;
         1913  +}
         1914  +
         1915  +static int
         1916  +print_template (const char *template_path, int railways)
         1917  +{
         1918  +/* printing a default template-file */
         1919  +    FILE *out = fopen (template_path, "w");
         1920  +    if (out == NULL)
         1921  +      {
         1922  +	  fprintf (stderr, "Unable to create template-file \"%s\"\n",
         1923  +		   template_path);
         1924  +	  return 0;
         1925  +      }
         1926  +
         1927  +    fprintf (out,
         1928  +	     "###############################################################\n");
         1929  +    fprintf (out, "#\n");
         1930  +    fprintf (out, "# the '#' char represents a comment marker:\n");
         1931  +    fprintf (out, "# any text until the next new-line (NL) char will\n");
         1932  +    fprintf (out, "# be ignored at all.\n");
         1933  +    fprintf (out, "#\n\n");
         1934  +
         1935  +    fprintf (out,
         1936  +	     "###############################################################\n");
         1937  +    fprintf (out, "#\n");
         1938  +    fprintf (out, "# NodingStrategy section\n");
         1939  +    fprintf (out, "#\n");
         1940  +    fprintf (out, "# - NodingStrategy:way-ends\n");
         1941  +    fprintf (out,
         1942  +	     "#   any Way end-point (both extremities) is assumed to represent\n");
         1943  +    fprintf (out, "#   a Node into the Graph [network] to be built.\n");
         1944  +    fprintf (out, "# - NodingStrategy:none\n");
         1945  +    fprintf (out,
         1946  +	     "#   any Way is assumed to directly represent an Arc into the Graph\n");
         1947  +    fprintf (out,
         1948  +	     "#   [network] to be built. No attempt to split and renode the\n");
         1949  +    fprintf (out, "#   Graph's Arcs will be performed.\n");
         1950  +    fprintf (out, "# - NodingStrategy:all\n");
         1951  +    fprintf (out,
         1952  +	     "#   any Way point is assumed to represent a Node into the Graph\n");
         1953  +    fprintf (out,
         1954  +	     "#   [network] to be built, if it's shared by two or more Ways.\n");
         1955  +    fprintf (out, "#\n\n");
         1956  +    if (railways)
         1957  +      {
         1958  +	  fprintf (out, "NodingStrategy:all # default value for Railway\n");
         1959  +	  fprintf (out, "# NodingStrategy:none\n");
         1960  +	  fprintf (out, "# NodingStrategy:way-ends\n\n\n");
         1961  +      }
         1962  +    else
         1963  +      {
         1964  +	  fprintf (out, "NodingStrategy:way-ends # default value\n");
         1965  +	  fprintf (out, "# NodingStrategy:none\n");
         1966  +	  fprintf (out, "# NodingStrategy:all\n\n\n");
         1967  +      }
         1968  +
         1969  +    fprintf (out,
         1970  +	     "###############################################################\n");
         1971  +    fprintf (out, "#\n");
         1972  +    fprintf (out, "# OnewayStrategy section\n");
         1973  +    fprintf (out, "#\n");
         1974  +    fprintf (out, "# - OnewayStrategy:full\n");
         1975  +    fprintf (out,
         1976  +	     "#   the following OSM tags will be assumed to identify oneways:\n");
         1977  +    fprintf (out,
         1978  +	     "#   * oneway:1, oneway:true or oneway:yes [oneway, normal direction]\n");
         1979  +    fprintf (out,
         1980  +	     "#   * oneway:-1 or oneway:reverse [oneway, reverse direction]\n");
         1981  +    fprintf (out,
         1982  +	     "#   * junction:roundabout, highway:motorway or highway:motorway_link\n");
         1983  +    fprintf (out, "#   * [implicit oneway, normal direction]\n");
         1984  +    fprintf (out, "# - OnewayStrategy:none\n");
         1985  +    fprintf (out,
         1986  +	     "#   all Arcs will be assumed to be bidirectional (no oneway at all).\n");
         1987  +    fprintf (out, "# - OnewayStrategy:ignore-roundabout\n");
         1988  +    fprintf (out,
         1989  +	     "#   any junction:roundabout tag will not be assumed to mark an oneway.\n");
         1990  +    fprintf (out, "# - OnewayStrategy:ignore-motorway\n");
         1991  +    fprintf (out,
         1992  +	     "#   any highway:motorway or highway:motorway_link tag will not be \n");
         1993  +    fprintf (out, "#   assumed to mark an oneway.\n");
         1994  +    fprintf (out, "# - OnewayStrategy:ignore-both-roundabout-and-motorway\n");
         1995  +    fprintf (out,
         1996  +	     "#   any junction:roundabout, highway:motorway or highway:motorway_link\n");
         1997  +    fprintf (out, "#   tag will not be assumed to mark an oneway.\n");
         1998  +    fprintf (out, "#\n\n");
         1999  +    if (railways)
         2000  +      {
         2001  +	  fprintf (out, "OnewayStrategy:none # default value for Railways\n");
         2002  +	  fprintf (out, "# OnewayStrategy:full\n");
         2003  +	  fprintf (out, "# OnewayStrategy:ignore-roundabout\n");
         2004  +	  fprintf (out, "# OnewayStrategy:ignore-motorway\n");
         2005  +	  fprintf (out,
         2006  +		   "# OnewayStrategy:ignore-both-roundabout-and-motorway\n\n\n");
         2007  +      }
         2008  +    else
         2009  +      {
         2010  +	  fprintf (out, "OnewayStrategy:full # default value\n");
         2011  +	  fprintf (out, "# OnewayStrategy:none\n");
         2012  +	  fprintf (out, "# OnewayStrategy:ignore-roundabout\n");
         2013  +	  fprintf (out, "# OnewayStrategy:ignore-motorway\n");
         2014  +	  fprintf (out,
         2015  +		   "# OnewayStrategy:ignore-both-roundabout-and-motorway\n\n\n");
         2016  +      }
         2017  +
         2018  +    fprintf (out,
         2019  +	     "###############################################################\n");
         2020  +    fprintf (out, "#\n");
         2021  +    fprintf (out, "# ClassInclude section\n");
         2022  +    fprintf (out, "#\n");
         2023  +    fprintf (out, "# - tokens are delimited by colons ':'\n");
         2024  +    fprintf (out,
         2025  +	     "# - the second and third tokens represents a Class-name tag\n");
         2026  +    fprintf (out,
         2027  +	     "#   identifying the Arcs of the Graph: i.e. any Way exposing\n");
         2028  +    fprintf (out, "#   this tag will be processed.\n");
         2029  +    fprintf (out,
         2030  +	     "# - special case: suppressing the third token selects any\n");
         2031  +    fprintf (out, "#   generic main-class tag to be processed\n");
         2032  +    fprintf (out, "#\n\n");
         2033  +    if (railways)
         2034  +	fprintf (out,
         2035  +		 "ClassInclude:railway:rail # default value for Railways\n\n\n");
         2036  +    else
         2037  +	fprintf (out,
         2038  +		 "ClassInclude:highway: # default value (all kind of highway)\n\n\n");
         2039  +
         2040  +    fprintf (out,
         2041  +	     "###############################################################\n");
         2042  +    fprintf (out, "#\n");
         2043  +    fprintf (out, "# ClassIgnore section\n");
         2044  +    fprintf (out, "#\n");
         2045  +    fprintf (out, "# - tokens are delimited by colons ':'\n");
         2046  +    fprintf (out,
         2047  +	     "# - the second and third tokens represents a Class-name tag\n");
         2048  +    fprintf (out, "#   identifying Ways to be completely ignored.\n");
         2049  +    fprintf (out, "#\n\n");
         2050  +    if (railways)
         2051  +	fprintf (out, "# none for Railways\n\n\n");
         2052  +    else
         2053  +      {
         2054  +	  fprintf (out, "ClassIgnore:highway:pedestrian\n");
         2055  +	  fprintf (out, "ClassIgnore:highway:track\n");
         2056  +	  fprintf (out, "ClassIgnore:highway:services\n");
         2057  +	  fprintf (out, "ClassIgnore:highway:bus_guideway\n");
         2058  +	  fprintf (out, "ClassIgnore:highway:path\n");
         2059  +	  fprintf (out, "ClassIgnore:highway:cycleway\n");
         2060  +	  fprintf (out, "ClassIgnore:highway:footway\n");
         2061  +	  fprintf (out, "ClassIgnore:highway:byway\n");
         2062  +	  fprintf (out, "ClassIgnore:highway:steps\n\n\n");
         2063  +      }
         2064  +
         2065  +    fprintf (out,
         2066  +	     "###############################################################\n");
         2067  +    fprintf (out, "#\n");
         2068  +    fprintf (out, "# SpeedClass section\n");
         2069  +    fprintf (out, "#\n");
         2070  +    fprintf (out, "# - tokens are delimited by colons ':'\n");
         2071  +    fprintf (out, "# - the second token represents the Road Class-name\n");
         2072  +    fprintf (out, "#   [no name, i.e. '::' identifies the defaul value\n");
         2073  +    fprintf (out, "#   to be applied when no specific class match is found]\n");
         2074  +    fprintf (out, "# - the third token represents the corresponding speed\n");
         2075  +    fprintf (out, "#   [expressed in Km/h]\n");
         2076  +    fprintf (out, "#\n\n");
         2077  +    if (railways)
         2078  +	fprintf (out, "SpeedClass:rail:60.0\n\n\n");
         2079  +    else
         2080  +      {
         2081  +	  fprintf (out, "SpeedClass::30.0 # default value\n");
         2082  +	  fprintf (out, "SpeedClass:motorway:110.0\n");
         2083  +	  fprintf (out, "SpeedClass:trunk:110.0\n");
         2084  +	  fprintf (out, "SpeedClass:primary:90.0\n");
         2085  +	  fprintf (out, "SpeedClass:secondary:70.0\n");
         2086  +	  fprintf (out, "SpeedClass:tertiary:50.0\n");
         2087  +	  fprintf (out, "# SpeedClass:yet_anotherclass_1:1.0\n");
         2088  +	  fprintf (out, "# SpeedClass:yet_anotherclass_2:2.0\n");
         2089  +	  fprintf (out, "# SpeedClass:yet_anotherclass_3:3.0\n\n\n");
         2090  +      }
         2091  +
         2092  +    fclose (out);
         2093  +    return 1;
         2094  +}
  2342   2095   
  2343   2096   static void
  2344   2097   do_help ()
  2345   2098   {
  2346   2099   /* printing the argument list */
  2347   2100       fprintf (stderr, "\n\nusage: spatialite_osm_net ARGLIST\n");
  2348   2101       fprintf (stderr,
  2349   2102   	     "==============================================================\n");
  2350   2103       fprintf (stderr,
  2351   2104   	     "-h or --help                    print this help message\n");
  2352   2105       fprintf (stderr, "-o or --osm-path pathname       the OSM-XML file path\n");
  2353   2106       fprintf (stderr,
         2107  +	     "                 both OSM-XML (*.osm) and OSM-ProtoBuf\n");
         2108  +    fprintf (stderr,
         2109  +	     "                 (*.osm.pbf) are indifferenctly supported.\n\n");
         2110  +    fprintf (stderr,
  2354   2111   	     "-d or --db-path  pathname       the SpatiaLite DB path\n");
  2355   2112       fprintf (stderr,
  2356   2113   	     "-T or --table    table_name     the db table to be feeded\n\n");
  2357   2114       fprintf (stderr, "you can specify the following options as well\n");
  2358   2115       fprintf (stderr,
  2359   2116   	     "-cs or --cache-size    num      DB cache size (how many pages)\n");
  2360   2117       fprintf (stderr,
................................................................................
  2361   2118   	     "-m or --in-memory               using IN-MEMORY database\n");
  2362   2119       fprintf (stderr, "-2 or --undirectional           double arcs\n\n");
  2363   2120       fprintf (stderr,
  2364   2121   	     "--roads                         extract roads [default]\n");
  2365   2122       fprintf (stderr, "--railways                      extract railways\n");
  2366   2123       fprintf (stderr,
  2367   2124   	     "                                [mutually exclusive]\n\n");
         2125  +    fprintf (stderr, "template-file specific options:\n");
         2126  +    fprintf (stderr,
         2127  +	     "-ot or --out-template  path     creates a default template-file\n");
         2128  +    fprintf (stderr,
         2129  +	     "-tf or --template-file path     using a template-file\n\n");
  2368   2130   }
  2369   2131   
  2370   2132   int
  2371   2133   main (int argc, char *argv[])
  2372   2134   {
  2373   2135   /* the MAIN function simply perform arguments checking */
  2374   2136       int i;
................................................................................
  2376   2138       const char *osm_path = NULL;
  2377   2139       const char *db_path = NULL;
  2378   2140       const char *table = NULL;
  2379   2141       int in_memory = 0;
  2380   2142       int cache_size = 0;
  2381   2143       int double_arcs = 0;
  2382   2144       int railways = 0;
         2145  +    int out_template = 0;
         2146  +    int use_template = 0;
         2147  +    const char *template_path = NULL;
  2383   2148       int error = 0;
  2384   2149       sqlite3 *handle;
  2385         -    FILE *xml;
  2386         -    int nodes;
  2387         -    int ways;
  2388         -    char *big_buffer;
         2150  +    struct aux_params params;
         2151  +    const void *osm_handle;
         2152  +
         2153  +/* initializing the aux-struct */
         2154  +    params.db_handle = NULL;
         2155  +    params.ins_tmp_nodes_stmt = NULL;
         2156  +    params.upd_tmp_nodes_stmt = NULL;
         2157  +    params.rd_tmp_nodes_stmt = NULL;
         2158  +    params.ins_arcs_stmt = NULL;
         2159  +    params.noding_strategy = NODE_STRAT_ENDS;
         2160  +    params.oneway_strategy = ONEWAY_STRAT_FULL;
         2161  +    params.default_speed = 30.0;
         2162  +    params.first_speed = NULL;
         2163  +    params.last_speed = NULL;
         2164  +    params.first_include = NULL;
         2165  +    params.last_include = NULL;
         2166  +    params.first_ignore = NULL;
         2167  +    params.last_ignore = NULL;
         2168  +
  2389   2169       for (i = 1; i < argc; i++)
  2390   2170         {
  2391   2171   	  /* parsing the invocation arguments */
  2392   2172   	  if (next_arg != ARG_NONE)
  2393   2173   	    {
  2394   2174   		switch (next_arg)
  2395   2175   		  {
................................................................................
  2398   2178   		      break;
  2399   2179   		  case ARG_DB_PATH:
  2400   2180   		      db_path = argv[i];
  2401   2181   		      break;
  2402   2182   		  case ARG_TABLE:
  2403   2183   		      table = argv[i];
  2404   2184   		      break;
         2185  +		  case ARG_TEMPLATE_PATH:
         2186  +		      template_path = argv[i];
         2187  +		      break;
  2405   2188   		  case ARG_CACHE_SIZE:
  2406   2189   		      cache_size = atoi (argv[i]);
  2407   2190   		      break;
  2408   2191   		  };
  2409   2192   		next_arg = ARG_NONE;
  2410   2193   		continue;
  2411   2194   	    }
................................................................................
  2446   2229   		continue;
  2447   2230   	    }
  2448   2231   	  if (strcasecmp (argv[i], "--cache-size") == 0
  2449   2232   	      || strcmp (argv[i], "-cs") == 0)
  2450   2233   	    {
  2451   2234   		next_arg = ARG_CACHE_SIZE;
  2452   2235   		continue;
         2236  +	    }
         2237  +	  if (strcmp (argv[i], "-ot") == 0)
         2238  +	    {
         2239  +		out_template = 1;
         2240  +		use_template = 0;
         2241  +		next_arg = ARG_TEMPLATE_PATH;
         2242  +		continue;
         2243  +	    }
         2244  +	  if (strcasecmp (argv[i], "--out-template") == 0)
         2245  +	    {
         2246  +		out_template = 1;
         2247  +		use_template = 0;
         2248  +		next_arg = ARG_TEMPLATE_PATH;
         2249  +		continue;
         2250  +	    }
         2251  +	  if (strcmp (argv[i], "-tf") == 0)
         2252  +	    {
         2253  +		out_template = 0;
         2254  +		use_template = 1;
         2255  +		next_arg = ARG_TEMPLATE_PATH;
         2256  +		continue;
         2257  +	    }
         2258  +	  if (strcasecmp (argv[i], "--template-file") == 0)
         2259  +	    {
         2260  +		out_template = 0;
         2261  +		use_template = 1;
         2262  +		next_arg = ARG_TEMPLATE_PATH;
         2263  +		continue;
  2453   2264   	    }
  2454   2265   	  if (strcasecmp (argv[i], "-m") == 0)
  2455   2266   	    {
  2456   2267   		in_memory = 1;
  2457   2268   		next_arg = ARG_NONE;
  2458   2269   		continue;
  2459   2270   	    }
................................................................................
  2492   2303         }
  2493   2304       if (error)
  2494   2305         {
  2495   2306   	  do_help ();
  2496   2307   	  return -1;
  2497   2308         }
  2498   2309   /* checking the arguments */
         2310  +    if (out_template)
         2311  +      {
         2312  +	  /* if out-template is set this one the unique option to be honored */
         2313  +	  if (!template_path)
         2314  +	    {
         2315  +		fprintf (stderr,
         2316  +			 "did you forget setting the --out-template path argument ?\n");
         2317  +		error = 1;
         2318  +	    }
         2319  +	  if (print_template (template_path, railways))
         2320  +	      printf ("template-file \"%s\" succesfully created\n\n",
         2321  +		      template_path);
         2322  +	  return 0;
         2323  +      }
  2499   2324       if (!osm_path)
  2500   2325         {
  2501   2326   	  fprintf (stderr,
  2502   2327   		   "did you forget setting the --osm-path argument ?\n");
  2503   2328   	  error = 1;
  2504   2329         }
  2505   2330       if (!db_path)
................................................................................
  2508   2333   	  error = 1;
  2509   2334         }
  2510   2335       if (!table)
  2511   2336         {
  2512   2337   	  fprintf (stderr, "did you forget setting the --table argument ?\n");
  2513   2338   	  error = 1;
  2514   2339         }
         2340  +    if (railways)
         2341  +      {
         2342  +	  /* Railways default settings */
         2343  +	  params.noding_strategy = NODE_STRAT_ALL;
         2344  +	  params.oneway_strategy = ONEWAY_STRAT_NONE;
         2345  +	  params.default_speed = 60.0;
         2346  +      }
         2347  +    if (use_template)
         2348  +      {
         2349  +	  /* use-template is set */
         2350  +	  if (!template_path)
         2351  +	    {
         2352  +		fprintf (stderr,
         2353  +			 "did you forget setting the --template-file path argument ?\n");
         2354  +		error = 1;
         2355  +	    }
         2356  +	  if (parse_template (&params, template_path))
         2357  +	      printf ("template-file \"%s\" succesfully acquired\n\n",
         2358  +		      template_path);
         2359  +	  else
         2360  +	      return -1;
         2361  +      }
  2515   2362       if (error)
  2516   2363         {
  2517   2364   	  do_help ();
  2518         -	  return -1;
  2519         -      }
  2520         -/* opening the OSM-XML file */
  2521         -    xml = fopen (osm_path, "rb");
  2522         -    if (!xml)
  2523         -      {
  2524         -	  fprintf (stderr, "cannot open %s\n", osm_path);
         2365  +	  free_params (&params);
  2525   2366   	  return -1;
  2526   2367         }
  2527         -/* checking if really is OSM XML */
  2528         -    if (!check_osm_xml (xml))
  2529         -      {
  2530         -	  fprintf (stderr, "'%s' doesn't seems to contain OSM XML !!!\n",
  2531         -		   osm_path);
  2532         -	  return -1;
  2533         -      }
  2534         -/* repositioning XML from beginning */
  2535         -    rewind (xml);
         2368  +
  2536   2369   /* opening the DB */
  2537   2370       if (in_memory)
  2538   2371   	cache_size = 0;
  2539   2372       handle = open_db (db_path, table, double_arcs, cache_size);
  2540   2373       if (!handle)
  2541         -	return -1;
         2374  +      {
         2375  +	  free_params (&params);
         2376  +	  return -1;
         2377  +      }
  2542   2378       if (in_memory)
  2543   2379         {
  2544   2380   	  /* loading the DB in-memory */
  2545   2381   	  sqlite3 *mem_handle;
  2546   2382   	  sqlite3_backup *backup;
  2547   2383   	  int ret;
  2548   2384   	  ret =
................................................................................
  2550   2386   			       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
  2551   2387   			       NULL);
  2552   2388   	  if (ret != SQLITE_OK)
  2553   2389   	    {
  2554   2390   		fprintf (stderr, "cannot open 'MEMORY-DB': %s\n",
  2555   2391   			 sqlite3_errmsg (mem_handle));
  2556   2392   		sqlite3_close (mem_handle);
         2393  +		free_params (&params);
  2557   2394   		return -1;
  2558   2395   	    }
  2559   2396   	  backup = sqlite3_backup_init (mem_handle, "main", handle, "main");
  2560   2397   	  if (!backup)
  2561   2398   	    {
  2562   2399   		fprintf (stderr, "cannot load 'MEMORY-DB'\n");
  2563   2400   		sqlite3_close (handle);
  2564   2401   		sqlite3_close (mem_handle);
         2402  +		free_params (&params);
  2565   2403   		return -1;
  2566   2404   	    }
  2567   2405   	  while (1)
  2568   2406   	    {
  2569   2407   		ret = sqlite3_backup_step (backup, 1024);
  2570   2408   		if (ret == SQLITE_DONE)
  2571   2409   		    break;
  2572   2410   	    }
  2573   2411   	  ret = sqlite3_backup_finish (backup);
  2574   2412   	  sqlite3_close (handle);
  2575   2413   	  handle = mem_handle;
  2576   2414   	  printf ("\nusing IN-MEMORY database\n");
  2577   2415         }
  2578         -/* extracting <node> tags form XML file */
  2579         -    printf ("\nLoading OSM nodes ... wait please ...\n");
  2580         -    nodes = parse_nodes (xml, handle);
  2581         -    if (nodes < 0)
         2416  +    params.db_handle = handle;
         2417  +    params.table = table;
         2418  +    if (use_template == 0)
         2419  +      {
         2420  +	  /* not using template: setting default params */
         2421  +	  if (railways == 1)
         2422  +	      add_include_class (&params, "railway", "rail");
         2423  +	  else
         2424  +	      add_include_class (&params, "highway", "");
         2425  +	  if (railways == 0)
         2426  +	    {
         2427  +		/* setting default Road Ignore classes */
         2428  +		add_ignore_class (&params, "highway", "pedestrian");
         2429  +		add_ignore_class (&params, "highway", "track");
         2430  +		add_ignore_class (&params, "highway", "services");
         2431  +		add_ignore_class (&params, "highway", "bus_guideway");
         2432  +		add_ignore_class (&params, "highway", "path");
         2433  +		add_ignore_class (&params, "highway", "cycleway");
         2434  +		add_ignore_class (&params, "highway", "footway");
         2435  +		add_ignore_class (&params, "highway", "bridleway");
         2436  +		add_ignore_class (&params, "highway", "byway");
         2437  +		add_ignore_class (&params, "highway", "steps");
         2438  +	    }
         2439  +	  if (railways == 0)
         2440  +	    {
         2441  +		/* setting default Road Speeds */
         2442  +		add_speed_class (&params, "motorway", 110.0);
         2443  +		add_speed_class (&params, "trunk", 110.0);
         2444  +		add_speed_class (&params, "primary", 90.0);
         2445  +		add_speed_class (&params, "secondary", 70.0);
         2446  +		add_speed_class (&params, "tertiary", 50.0);
         2447  +	    }
         2448  +      }
         2449  +
         2450  +/* creating SQL prepared statements */
         2451  +    create_sql_stmts (&params);
         2452  +
         2453  +    printf ("\nParsing input: Pass 1 [Nodes and Ways] ...\n");
         2454  +/* parsing the input OSM-file [Pass 1] */
         2455  +    if (readosm_open (osm_path, &osm_handle) != READOSM_OK)
         2456  +      {
         2457  +	  fprintf (stderr, "cannot open %s\n", osm_path);
         2458  +	  finalize_sql_stmts (&params);
         2459  +	  sqlite3_close (handle);
         2460  +	  readosm_close (osm_handle);
         2461  +	  free_params (&params);
         2462  +	  return -1;
         2463  +      }
         2464  +    if (readosm_parse (osm_handle, &params, consume_node, consume_way_1, NULL)
         2465  +	!= READOSM_OK)
         2466  +      {
         2467  +	  fprintf (stderr, "unrecoverable error while parsing %s\n", osm_path);
         2468  +	  finalize_sql_stmts (&params);
         2469  +	  sqlite3_close (handle);
         2470  +	  readosm_close (osm_handle);
         2471  +	  free_params (&params);
         2472  +	  return -1;
         2473  +      }
         2474  +    readosm_close (osm_handle);
         2475  +
         2476  +    printf ("Parsing input: Pass 2 [Arcs of the Graph] ...\n");
         2477  +/* parsing the input OSM-file [Pass 2] */
         2478  +    if (readosm_open (osm_path, &osm_handle) != READOSM_OK)
         2479  +      {
         2480  +	  fprintf (stderr, "cannot open %s\n", osm_path);
         2481  +	  finalize_sql_stmts (&params);
         2482  +	  sqlite3_close (handle);
         2483  +	  readosm_close (osm_handle);
         2484  +	  free_params (&params);
         2485  +	  return -1;
         2486  +      }
         2487  +    if (readosm_parse (osm_handle, &params, NULL, consume_way_2, NULL) !=
         2488  +	READOSM_OK)
         2489  +      {
         2490  +	  fprintf (stderr, "unrecoverable error while parsing %s\n", osm_path);
         2491  +	  finalize_sql_stmts (&params);
         2492  +	  sqlite3_close (handle);
         2493  +	  readosm_close (osm_handle);
         2494  +	  free_params (&params);
         2495  +	  return -1;
         2496  +      }
         2497  +    readosm_close (osm_handle);
         2498  +
         2499  +/* finalizing SQL prepared statements */
         2500  +    finalize_sql_stmts (&params);
         2501  +
         2502  +/* populating the GRAPH_NODES table */
         2503  +    if (!populate_graph_nodes (handle, table))
         2504  +      {
         2505  +	  fprintf (stderr,
         2506  +		   "unrecoverable error while extracting GRAPH_NODES\n");
         2507  +	  sqlite3_close (handle);
         2508  +	  goto quit;
         2509  +      }
         2510  +
         2511  +/* assigning NodeIds to Arcs */
         2512  +    if (!set_node_ids (handle, table))
  2582   2513         {
  2583         -	  fclose (xml);
         2514  +	  fprintf (stderr,
         2515  +		   "unrecoverable error while assignign NODE-IDs to Arcs\n");
  2584   2516   	  sqlite3_close (handle);
  2585         -	  fprintf (stderr, "Sorry, I'm quitting ... UNRECOVERABLE ERROR\n");
  2586         -	  return 1;
         2517  +	  goto quit;
  2587   2518         }
  2588         -    printf ("\tLoaded %d OSM nodes\n", nodes);
  2589         -/* repositioning XML from beginning */
  2590         -    rewind (xml);
  2591         -/* extracting <way> tags form XML file - Pass I */
  2592         -    printf ("\nVerifying OSM ways ... wait please ...\n");
  2593         -    big_buffer = malloc (4 * 1024 * 1024);
  2594         -    ways = parse_ways_pass_1 (xml, handle, big_buffer, railways);
  2595         -    free (big_buffer);
  2596         -    if (ways < 0)
         2519  +
         2520  +/* computing Length and Cost for each Arc */
         2521  +    if (!set_lengths_costs (&params, table))
  2597   2522         {
  2598         -	  fclose (xml);
         2523  +	  fprintf (stderr,
         2524  +		   "unrecoverable error while assignign Length and Cost to Arcs\n");
  2599   2525   	  sqlite3_close (handle);
  2600         -	  fprintf (stderr, "Sorry, I'm quitting ... UNRECOVERABLE ERROR\n");
  2601         -	  return 1;
         2526  +	  goto quit;
  2602   2527         }
  2603         -    printf ("\tVerified %d OSM ways\n", ways);
  2604         -/* disambiguating nodes - oh yes, there lots of stupid duplicates using different IDs !!! */
  2605         -    printf ("\nDisambiguating OSM nodes ... wait please ...\n");
  2606         -    nodes = disambiguate_nodes (handle);
  2607         -    if (nodes < 0)
         2528  +
         2529  +/* extracting qualified Nodes */
         2530  +    if (!create_qualified_nodes (&params, table))
  2608   2531         {
  2609         -	  fclose (xml);
         2532  +	  fprintf (stderr,
         2533  +		   "unrecoverable error while extracting qualified Nodes\n");
  2610   2534   	  sqlite3_close (handle);
  2611         -	  fprintf (stderr, "Sorry, I'm quitting ... UNRECOVERABLE ERROR\n");
  2612         -	  return 1;
         2535  +	  goto quit;
  2613   2536         }
  2614         -    if (nodes == 0)
  2615         -	printf ("\tNo duplicate OSM nodes found - fine ...\n");
  2616         -    else
  2617         -	printf ("\tFound %d duplicate OSM nodes - fixed !!!\n", nodes);
  2618         -/* repositioning XML from beginning */
  2619         -    rewind (xml);
  2620         -/* extracting <way> tags form XML file - Pass II */
  2621         -    printf ("\nLoading network ARCs ... wait please ...\n");
  2622         -    big_buffer = malloc (4 * 1024 * 1024);
  2623         -    ways =
  2624         -	parse_ways_pass_2 (xml, handle, table, double_arcs, big_buffer,
  2625         -			   railways);
  2626   2537   
  2627         -    if (ways < 0)
  2628         -      {
  2629         -	  fclose (xml);
  2630         -	  sqlite3_close (handle);
  2631         -	  fprintf (stderr, "Sorry, I'm quitting ... UNRECOVERABLE ERROR\n");
  2632         -	  return 1;
  2633         -      }
  2634         -    printf ("\tLoaded %d network ARCs\n", ways);
  2635         -    fclose (xml);
  2636         -/* dropping the OSM_TMP_NODES table */
         2538  +  quit:
         2539  +/* dropping the temporary tables */
  2637   2540       db_cleanup (handle);
         2541  +
  2638   2542       if (in_memory)
  2639   2543         {
  2640   2544   	  /* exporting the in-memory DB to filesystem */
  2641   2545   	  sqlite3 *disk_handle;
  2642   2546   	  sqlite3_backup *backup;
  2643   2547   	  int ret;
  2644   2548   	  printf ("\nexporting IN_MEMORY database ... wait please ...\n");
................................................................................
  2647   2551   			       SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
  2648   2552   			       NULL);
  2649   2553   	  if (ret != SQLITE_OK)
  2650   2554   	    {
  2651   2555   		fprintf (stderr, "cannot open '%s': %s\n", db_path,
  2652   2556   			 sqlite3_errmsg (disk_handle));
  2653   2557   		sqlite3_close (disk_handle);
         2558  +		free_params (&params);
  2654   2559   		return -1;
  2655   2560   	    }
  2656   2561   	  backup = sqlite3_backup_init (disk_handle, "main", handle, "main");
  2657   2562   	  if (!backup)
  2658   2563   	    {
  2659   2564   		fprintf (stderr, "Backup failure: 'MEMORY-DB' wasn't saved\n");
  2660   2565   		sqlite3_close (handle);
  2661   2566   		sqlite3_close (disk_handle);
         2567  +		free_params (&params);
  2662   2568   		return -1;
  2663   2569   	    }
  2664   2570   	  while (1)
  2665   2571   	    {
  2666   2572   		ret = sqlite3_backup_step (backup, 1024);
  2667   2573   		if (ret == SQLITE_DONE)
  2668   2574   		    break;
................................................................................
  2671   2577   	  sqlite3_close (handle);
  2672   2578   	  handle = disk_handle;
  2673   2579   	  printf ("\tIN_MEMORY database succesfully exported\n");
  2674   2580         }
  2675   2581   /* VACUUMing */
  2676   2582       db_vacuum (handle);
  2677   2583       sqlite3_close (handle);
         2584  +    free_params (&params);
  2678   2585       return 0;
  2679   2586   }

Changes to spatialite_osm_raw.c.

     1      1   /* 
     2      2   / spatialite_osm_raw
     3      3   /
     4         -/ a tool loading "raw" OSM-XML maps into a SpatiaLite DB
            4  +/ a tool loading "raw" OSM maps into a SpatiaLite DB
     5      5   /
     6      6   / version 1.0, 2010 September 13
     7      7   /
     8      8   / Author: Sandro Furieri a.furieri@lqt.it
     9      9   /
    10     10   / Copyright (C) 2010  Alessandro Furieri
    11     11   /
................................................................................
    30     30   #endif
    31     31   
    32     32   #include <stdlib.h>
    33     33   #include <stdio.h>
    34     34   #include <string.h>
    35     35   #include <float.h>
    36     36   
    37         -#include <expat.h>
    38         -
    39     37   #include "config.h"
    40     38   
    41     39   #ifdef SPATIALITE_AMALGAMATION
    42     40   #include <spatialite/sqlite3.h>
    43     41   #else
    44     42   #include <sqlite3.h>
    45     43   #endif
    46     44   
    47     45   #include <spatialite/gaiageo.h>
    48     46   #include <spatialite.h>
           47  +#include <readosm.h>
    49     48   
    50     49   #define ARG_NONE		0
    51     50   #define ARG_OSM_PATH	1
    52     51   #define ARG_DB_PATH		2
    53     52   #define ARG_CACHE_SIZE	3
    54     53   
    55         -#define MAX_TAG		16
    56         -
    57         -#if defined(_WIN32) && !defined(__MINGW32__)
    58         -#define strcasecmp	_stricmp
    59         -#endif /* not WIN32 */
    60         -
    61         -#if defined(_WIN32)
    62         -#define atol_64		_atoi64
    63         -#else
    64         -#define atol_64		atoll
    65         -#endif
    66         -
    67         -#define BUFFSIZE	8192
    68         -
    69         -#define CURRENT_TAG_UNKNOWN	0
    70         -#define CURRENT_TAG_IS_NODE	1
    71         -#define CURRENT_TAG_IS_WAY	2
    72         -#define CURRENT_TAG_IS_RELATION	3
    73         -
    74     54   struct aux_params
    75     55   {
    76     56   /* an auxiliary struct used for XML parsing */
    77     57       sqlite3 *db_handle;
    78     58       sqlite3_stmt *ins_nodes_stmt;
    79     59       sqlite3_stmt *ins_node_tags_stmt;
    80     60       sqlite3_stmt *ins_ways_stmt;
................................................................................
    87     67       int wr_node_tags;
    88     68       int wr_ways;
    89     69       int wr_way_tags;
    90     70       int wr_way_refs;
    91     71       int wr_relations;
    92     72       int wr_rel_tags;
    93     73       int wr_rel_refs;
    94         -    int current_tag;
    95     74   };
    96     75   
    97         -struct tag
    98         -{
    99         -    char *k;
   100         -    char *v;
   101         -    struct tag *next;
   102         -};
   103         -
   104         -struct node
   105         -{
   106         -    sqlite3_int64 id;
   107         -    sqlite3_int64 version;
   108         -    char *timestamp;
   109         -    sqlite3_int64 uid;
   110         -    char *user;
   111         -    sqlite3_int64 changeset;
   112         -    double lat;
   113         -    double lon;
   114         -    struct tag *first;
   115         -    struct tag *last;
   116         -} glob_node;
   117         -
   118         -struct node_ref
   119         -{
   120         -    sqlite3_int64 node_id;
   121         -    char *role;
   122         -    struct node_ref *next;
   123         -};
   124         -
   125         -struct way
   126         -{
   127         -    sqlite3_int64 id;
   128         -    sqlite3_int64 version;
   129         -    char *timestamp;
   130         -    sqlite3_int64 uid;
   131         -    char *user;
   132         -    sqlite3_int64 changeset;
   133         -    struct tag *first;
   134         -    struct tag *last;
   135         -    struct node_ref *first_node;
   136         -    struct node_ref *last_node;
   137         -} glob_way;
   138         -
   139         -struct multi_ref
   140         -{
   141         -    sqlite3_int64 id;
   142         -    char type;
   143         -    char *role;
   144         -    struct multi_ref *next;
   145         -};
   146         -
   147         -struct relation
   148         -{
   149         -    sqlite3_int64 id;
   150         -    sqlite3_int64 version;
   151         -    char *timestamp;
   152         -    sqlite3_int64 uid;
   153         -    char *user;
   154         -    sqlite3_int64 changeset;
   155         -    struct tag *first;
   156         -    struct tag *last;
   157         -    struct multi_ref *first_rel;
   158         -    struct multi_ref *last_rel;
   159         -} glob_relation;
   160         -
   161         -static void
   162         -insert_node (struct aux_params *params)
           76  +static int
           77  +insert_node (struct aux_params *params, const readosm_node * node)
   163     78   {
   164     79       int ret;
   165     80       unsigned char *blob;
   166     81       int blob_size;
   167         -    int sub = 0;
   168         -    struct tag *p_tag;
   169         -    gaiaGeomCollPtr geom = gaiaAllocGeomColl ();
   170         -    geom->Srid = 4326;
   171         -    gaiaAddPointToGeomColl (geom, glob_node.lon, glob_node.lat);
           82  +    int i_tag;
           83  +    const readosm_tag *p_tag;
           84  +    gaiaGeomCollPtr geom = NULL;
           85  +    if (node->longitude != READOSM_UNDEFINED
           86  +	&& node->latitude != READOSM_UNDEFINED)
           87  +      {
           88  +	  geom = gaiaAllocGeomColl ();
           89  +	  geom->Srid = 4326;
           90  +	  gaiaAddPointToGeomColl (geom, node->longitude, node->latitude);
           91  +      }
   172     92       sqlite3_reset (params->ins_nodes_stmt);
   173     93       sqlite3_clear_bindings (params->ins_nodes_stmt);
   174         -    sqlite3_bind_int64 (params->ins_nodes_stmt, 1, glob_node.id);
   175         -    sqlite3_bind_int64 (params->ins_nodes_stmt, 2, glob_node.version);
   176         -    if (glob_node.timestamp == NULL)
           94  +    sqlite3_bind_int64 (params->ins_nodes_stmt, 1, node->id);
           95  +    if (node->version == READOSM_UNDEFINED)
           96  +	sqlite3_bind_null (params->ins_nodes_stmt, 2);
           97  +    else
           98  +	sqlite3_bind_int64 (params->ins_nodes_stmt, 2, node->version);
           99  +    if (node->timestamp == NULL)
   177    100   	sqlite3_bind_null (params->ins_nodes_stmt, 3);
   178    101       else
   179         -	sqlite3_bind_text (params->ins_nodes_stmt, 3, glob_node.timestamp,
   180         -			   strlen (glob_node.timestamp), SQLITE_STATIC);
   181         -    sqlite3_bind_int64 (params->ins_nodes_stmt, 4, glob_node.uid);
   182         -    if (glob_node.user == NULL)
          102  +	sqlite3_bind_text (params->ins_nodes_stmt, 3, node->timestamp,
          103  +			   strlen (node->timestamp), SQLITE_STATIC);
          104  +    if (node->uid == READOSM_UNDEFINED)
          105  +	sqlite3_bind_null (params->ins_nodes_stmt, 4);
          106  +    else
          107  +	sqlite3_bind_int64 (params->ins_nodes_stmt, 4, node->uid);
          108  +    if (node->user == NULL)
   183    109   	sqlite3_bind_null (params->ins_nodes_stmt, 5);
   184    110       else
   185         -	sqlite3_bind_text (params->ins_nodes_stmt, 5, glob_node.user,
   186         -			   strlen (glob_node.user), SQLITE_STATIC);
   187         -    sqlite3_bind_int64 (params->ins_nodes_stmt, 6, glob_node.changeset);
   188         -    gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
   189         -    gaiaFreeGeomColl (geom);
   190         -    sqlite3_bind_blob (params->ins_nodes_stmt, 7, blob, blob_size, free);
          111  +	sqlite3_bind_text (params->ins_nodes_stmt, 5, node->user,
          112  +			   strlen (node->user), SQLITE_STATIC);
          113  +    if (node->changeset == READOSM_UNDEFINED)
          114  +	sqlite3_bind_null (params->ins_nodes_stmt, 6);
          115  +    else
          116  +	sqlite3_bind_int64 (params->ins_nodes_stmt, 6, node->changeset);
          117  +    if (!geom)
          118  +	sqlite3_bind_null (params->ins_nodes_stmt, 7);
          119  +    else
          120  +      {
          121  +	  gaiaToSpatiaLiteBlobWkb (geom, &blob, &blob_size);
          122  +	  gaiaFreeGeomColl (geom);
          123  +	  sqlite3_bind_blob (params->ins_nodes_stmt, 7, blob, blob_size, free);
          124  +      }
   191    125       ret = sqlite3_step (params->ins_nodes_stmt);
   192    126       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   193    127   	;
   194    128       else
   195    129         {
   196    130   	  fprintf (stderr, "sqlite3_step() error: INSERT INTO osm_nodes\n");
   197         -	  return;
          131  +	  return 0;
   198    132         }
   199    133       params->wr_nodes += 1;
   200    134   
   201         -    p_tag = glob_node.first;
   202         -    while (p_tag)
          135  +    for (i_tag = 0; i_tag < node->tag_count; i_tag++)
   203    136         {
          137  +	  p_tag = node->tags + i_tag;
   204    138   	  sqlite3_reset (params->ins_node_tags_stmt);
   205    139   	  sqlite3_clear_bindings (params->ins_node_tags_stmt);
   206         -	  sqlite3_bind_int64 (params->ins_node_tags_stmt, 1, glob_node.id);
   207         -	  sqlite3_bind_int (params->ins_node_tags_stmt, 2, sub);
   208         -	  sub++;
   209         -	  if (p_tag->k == NULL)
          140  +	  sqlite3_bind_int64 (params->ins_node_tags_stmt, 1, node->id);
          141  +	  sqlite3_bind_int (params->ins_node_tags_stmt, 2, i_tag);
          142  +	  if (p_tag->key == NULL)
   210    143   	      sqlite3_bind_null (params->ins_node_tags_stmt, 3);
   211    144   	  else
   212         -	      sqlite3_bind_text (params->ins_node_tags_stmt, 3, p_tag->k,
   213         -				 strlen (p_tag->k), SQLITE_STATIC);
   214         -	  if (p_tag->k == NULL)
          145  +	      sqlite3_bind_text (params->ins_node_tags_stmt, 3, p_tag->key,
          146  +				 strlen (p_tag->key), SQLITE_STATIC);
          147  +	  if (p_tag->value == NULL)
   215    148   	      sqlite3_bind_null (params->ins_node_tags_stmt, 4);
   216    149   	  else
   217         -	      sqlite3_bind_text (params->ins_node_tags_stmt, 4, p_tag->v,
   218         -				 strlen (p_tag->v), SQLITE_STATIC);
          150  +	      sqlite3_bind_text (params->ins_node_tags_stmt, 4, p_tag->value,
          151  +				 strlen (p_tag->value), SQLITE_STATIC);
   219    152   	  ret = sqlite3_step (params->ins_node_tags_stmt);
   220    153   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   221    154   	      ;
   222    155   	  else
   223    156   	    {
   224    157   		fprintf (stderr,
   225    158   			 "sqlite3_step() error: INSERT INTO osm_node_tags\n");
   226         -		return;
          159  +		return 0;
   227    160   	    }
   228    161   	  params->wr_node_tags += 1;
   229         -	  p_tag = p_tag->next;
   230    162         }
          163  +    return 1;
   231    164   }
   232    165   
   233         -static void
   234         -insert_way (struct aux_params *params)
          166  +static int
          167  +insert_way (struct aux_params *params, const readosm_way * way)
   235    168   {
   236    169       int ret;
   237         -    int sub = 0;
   238         -    struct tag *p_tag;
   239         -    struct node_ref *nr;
          170  +    int i_tag;
          171  +    int i_ref;
          172  +    const readosm_tag *p_tag;
   240    173       sqlite3_reset (params->ins_ways_stmt);
   241    174       sqlite3_clear_bindings (params->ins_ways_stmt);
   242         -    sqlite3_bind_int64 (params->ins_ways_stmt, 1, glob_way.id);
   243         -    sqlite3_bind_int64 (params->ins_ways_stmt, 2, glob_way.version);
   244         -    if (glob_way.timestamp == NULL)
          175  +    sqlite3_bind_int64 (params->ins_ways_stmt, 1, way->id);
          176  +    if (way->version == READOSM_UNDEFINED)
          177  +	sqlite3_bind_null (params->ins_ways_stmt, 2);
          178  +    else
          179  +	sqlite3_bind_int64 (params->ins_ways_stmt, 2, way->version);
          180  +    if (way->timestamp == NULL)
   245    181   	sqlite3_bind_null (params->ins_ways_stmt, 3);
   246    182       else
   247         -	sqlite3_bind_text (params->ins_ways_stmt, 3, glob_way.timestamp,
   248         -			   strlen (glob_way.timestamp), SQLITE_STATIC);
   249         -    sqlite3_bind_int64 (params->ins_ways_stmt, 4, glob_way.uid);
   250         -    if (glob_way.user == NULL)
          183  +	sqlite3_bind_text (params->ins_ways_stmt, 3, way->timestamp,
          184  +			   strlen (way->timestamp), SQLITE_STATIC);
          185  +    if (way->uid == READOSM_UNDEFINED)
          186  +	sqlite3_bind_null (params->ins_ways_stmt, 4);
          187  +    else
          188  +	sqlite3_bind_int64 (params->ins_ways_stmt, 4, way->uid);
          189  +    if (way->user == NULL)
   251    190   	sqlite3_bind_null (params->ins_ways_stmt, 5);
   252    191       else
   253         -	sqlite3_bind_text (params->ins_ways_stmt, 5, glob_way.user,
   254         -			   strlen (glob_way.user), SQLITE_STATIC);
   255         -    sqlite3_bind_int64 (params->ins_ways_stmt, 6, glob_way.changeset);
          192  +	sqlite3_bind_text (params->ins_ways_stmt, 5, way->user,
          193  +			   strlen (way->user), SQLITE_STATIC);
          194  +    if (way->changeset == READOSM_UNDEFINED)
          195  +	sqlite3_bind_null (params->ins_ways_stmt, 6);
          196  +    else
          197  +	sqlite3_bind_int64 (params->ins_ways_stmt, 6, way->changeset);
   256    198       ret = sqlite3_step (params->ins_ways_stmt);
   257    199       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   258    200   	;
   259    201       else
   260    202         {
   261    203   	  fprintf (stderr, "sqlite3_step() error: INSERT INTO osm_ways\n");
   262         -	  return;
          204  +	  return 0;
   263    205         }
   264    206       params->wr_ways += 1;
   265    207   
   266         -    p_tag = glob_way.first;
   267         -    while (p_tag)
          208  +    for (i_tag = 0; i_tag < way->tag_count; i_tag++)
   268    209         {
          210  +	  p_tag = way->tags + i_tag;
   269    211   	  sqlite3_reset (params->ins_way_tags_stmt);
   270    212   	  sqlite3_clear_bindings (params->ins_way_tags_stmt);
   271         -	  sqlite3_bind_int64 (params->ins_way_tags_stmt, 1, glob_way.id);
   272         -	  sqlite3_bind_int (params->ins_way_tags_stmt, 2, sub);
   273         -	  sub++;
   274         -	  if (p_tag->k == NULL)
          213  +	  sqlite3_bind_int64 (params->ins_way_tags_stmt, 1, way->id);
          214  +	  sqlite3_bind_int (params->ins_way_tags_stmt, 2, i_tag);
          215  +	  if (p_tag->key == NULL)
   275    216   	      sqlite3_bind_null (params->ins_way_tags_stmt, 3);
   276    217   	  else
   277         -	      sqlite3_bind_text (params->ins_way_tags_stmt, 3, p_tag->k,
   278         -				 strlen (p_tag->k), SQLITE_STATIC);
   279         -	  if (p_tag->v == NULL)
          218  +	      sqlite3_bind_text (params->ins_way_tags_stmt, 3, p_tag->key,
          219  +				 strlen (p_tag->key), SQLITE_STATIC);
          220  +	  if (p_tag->value == NULL)
   280    221   	      sqlite3_bind_null (params->ins_way_tags_stmt, 4);
   281    222   	  else
   282         -	      sqlite3_bind_text (params->ins_way_tags_stmt, 4, p_tag->v,
   283         -				 strlen (p_tag->v), SQLITE_STATIC);
          223  +	      sqlite3_bind_text (params->ins_way_tags_stmt, 4, p_tag->value,
          224  +				 strlen (p_tag->value), SQLITE_STATIC);
   284    225   	  ret = sqlite3_step (params->ins_way_tags_stmt);
   285    226   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   286    227   	      ;
   287    228   	  else
   288    229   	    {
   289    230   		fprintf (stderr,
   290    231   			 "sqlite3_step() error: INSERT INTO osm_way_tags\n");
   291         -		return;
          232  +		return 0;
   292    233   	    }
   293    234   	  params->wr_way_tags += 1;
   294         -	  p_tag = p_tag->next;
   295    235         }
   296    236   
   297         -    sub = 0;
   298         -    nr = glob_way.first_node;
   299         -    while (nr)
          237  +    for (i_ref = 0; i_ref < way->node_ref_count; i_ref++)
   300    238         {
          239  +	  sqlite3_int64 node_id = *(way->node_refs + i_ref);
   301    240   	  sqlite3_reset (params->ins_way_refs_stmt);
   302    241   	  sqlite3_clear_bindings (params->ins_way_refs_stmt);
   303         -	  sqlite3_bind_int64 (params->ins_way_refs_stmt, 1, glob_way.id);
   304         -	  sqlite3_bind_int (params->ins_way_refs_stmt, 2, sub);
   305         -	  sub++;
   306         -	  sqlite3_bind_int64 (params->ins_way_refs_stmt, 3, nr->node_id);
          242  +	  sqlite3_bind_int64 (params->ins_way_refs_stmt, 1, way->id);
          243  +	  sqlite3_bind_int (params->ins_way_refs_stmt, 2, i_ref);
          244  +	  sqlite3_bind_int64 (params->ins_way_refs_stmt, 3, node_id);
   307    245   	  ret = sqlite3_step (params->ins_way_refs_stmt);
   308    246   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   309    247   	      ;
   310    248   	  else
   311    249   	    {
   312    250   		fprintf (stderr,
   313    251   			 "sqlite3_step() error: INSERT INTO osm_way_refs\n");
   314         -		return;
          252  +		return 0;
   315    253   	    }
   316    254   	  params->wr_way_refs += 1;
   317         -	  nr = nr->next;
   318    255         }
          256  +    return 1;
   319    257   }
   320    258   
   321         -static void
   322         -insert_relation (struct aux_params *params)
          259  +static int
          260  +insert_relation (struct aux_params *params, const readosm_relation * relation)
   323    261   {
   324    262       int ret;
   325         -    int sub = 0;
   326         -    struct tag *p_tag;
   327         -    struct multi_ref *mr;
          263  +    int i_tag;
          264  +    int i_member;
          265  +    const readosm_tag *p_tag;
          266  +    const readosm_member *p_member;
   328    267       sqlite3_reset (params->ins_relations_stmt);
   329    268       sqlite3_clear_bindings (params->ins_relations_stmt);
   330         -    sqlite3_bind_int64 (params->ins_relations_stmt, 1, glob_relation.id);
   331         -    sqlite3_bind_int64 (params->ins_relations_stmt, 2, glob_relation.version);
   332         -    if (glob_relation.timestamp == NULL)
          269  +    sqlite3_bind_int64 (params->ins_relations_stmt, 1, relation->id);
          270  +    if (relation->version == READOSM_UNDEFINED)
          271  +	sqlite3_bind_null (params->ins_relations_stmt, 2);
          272  +    else
          273  +	sqlite3_bind_int64 (params->ins_relations_stmt, 2, relation->version);
          274  +    if (relation->timestamp == NULL)
   333    275   	sqlite3_bind_null (params->ins_relations_stmt, 3);
   334    276       else
   335         -	sqlite3_bind_text (params->ins_relations_stmt, 3,
   336         -			   glob_relation.timestamp,
   337         -			   strlen (glob_relation.timestamp), SQLITE_STATIC);
   338         -    sqlite3_bind_int64 (params->ins_relations_stmt, 4, glob_relation.uid);
   339         -    if (glob_relation.user == NULL)
          277  +	sqlite3_bind_text (params->ins_relations_stmt, 3, relation->timestamp,
          278  +			   strlen (relation->timestamp), SQLITE_STATIC);
          279  +    if (relation->uid == READOSM_UNDEFINED)
          280  +	sqlite3_bind_null (params->ins_relations_stmt, 4);
          281  +    else
          282  +	sqlite3_bind_int64 (params->ins_relations_stmt, 4, relation->uid);
          283  +    if (relation->user == NULL)
   340    284   	sqlite3_bind_null (params->ins_relations_stmt, 5);
   341    285       else
   342         -	sqlite3_bind_text (params->ins_relations_stmt, 5, glob_relation.user,
   343         -			   strlen (glob_relation.user), SQLITE_STATIC);
   344         -    sqlite3_bind_int64 (params->ins_relations_stmt, 6, glob_relation.changeset);
          286  +	sqlite3_bind_text (params->ins_relations_stmt, 5, relation->user,
          287  +			   strlen (relation->user), SQLITE_STATIC);
          288  +    if (relation->changeset == READOSM_UNDEFINED)
          289  +	sqlite3_bind_null (params->ins_relations_stmt, 6);
          290  +    else
          291  +	sqlite3_bind_int64 (params->ins_relations_stmt, 6, relation->changeset);
   345    292       ret = sqlite3_step (params->ins_relations_stmt);
   346    293       if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   347    294   	;
   348    295       else
   349    296         {
   350    297   	  fprintf (stderr, "sqlite3_step() error: INSERT INTO osm_relations\n");
   351         -	  return;
          298  +	  return 0;
   352    299         }
   353    300       params->wr_relations += 1;
   354    301   
   355         -    p_tag = glob_relation.first;
   356         -    while (p_tag)
          302  +    for (i_tag = 0; i_tag < relation->tag_count; i_tag++)
   357    303         {
          304  +	  p_tag = relation->tags + i_tag;
   358    305   	  sqlite3_reset (params->ins_relation_tags_stmt);
   359    306   	  sqlite3_clear_bindings (params->ins_relation_tags_stmt);
   360         -	  sqlite3_bind_int64 (params->ins_relation_tags_stmt, 1,
   361         -			      glob_relation.id);
   362         -	  sqlite3_bind_int (params->ins_relation_tags_stmt, 2, sub);
   363         -	  sub++;
   364         -	  if (p_tag->k == NULL)
          307  +	  sqlite3_bind_int64 (params->ins_relation_tags_stmt, 1, relation->id);
          308  +	  sqlite3_bind_int (params->ins_relation_tags_stmt, 2, i_tag);
          309  +	  if (p_tag->key == NULL)
   365    310   	      sqlite3_bind_null (params->ins_relation_tags_stmt, 3);
   366    311   	  else
   367         -	      sqlite3_bind_text (params->ins_relation_tags_stmt, 3, p_tag->k,
   368         -				 strlen (p_tag->k), SQLITE_STATIC);
   369         -	  if (p_tag->v == NULL)
          312  +	      sqlite3_bind_text (params->ins_relation_tags_stmt, 3, p_tag->key,
          313  +				 strlen (p_tag->key), SQLITE_STATIC);
          314  +	  if (p_tag->value == NULL)
   370    315   	      sqlite3_bind_null (params->ins_relation_tags_stmt, 4);
   371    316   	  else
   372         -	      sqlite3_bind_text (params->ins_relation_tags_stmt, 4, p_tag->v,
   373         -				 strlen (p_tag->v), SQLITE_STATIC);
          317  +	      sqlite3_bind_text (params->ins_relation_tags_stmt, 4,
          318  +				 p_tag->value, strlen (p_tag->value),
          319  +				 SQLITE_STATIC);
   374    320   	  ret = sqlite3_step (params->ins_relation_tags_stmt);
   375    321   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   376    322   	      ;
   377    323   	  else
   378    324   	    {
   379    325   		fprintf (stderr,
   380    326   			 "sqlite3_step() error: INSERT INTO osm_relation_tags\n");
   381         -		return;
          327  +		return 0;
   382    328   	    }
   383    329   	  params->wr_rel_tags += 1;
   384         -	  p_tag = p_tag->next;
   385    330         }
   386    331   
   387         -    sub = 0;
   388         -    mr = glob_relation.first_rel;
   389         -    while (mr)
          332  +    for (i_member = 0; i_member < relation->member_count; i_member++)
   390    333         {
          334  +	  p_member = relation->members + i_member;
   391    335   	  sqlite3_reset (params->ins_relation_refs_stmt);
   392    336   	  sqlite3_clear_bindings (params->ins_relation_refs_stmt);
   393         -	  sqlite3_bind_int64 (params->ins_relation_refs_stmt, 1,
   394         -			      glob_relation.id);
   395         -	  sqlite3_bind_int (params->ins_relation_refs_stmt, 2, sub);
   396         -	  sub++;
   397         -	  if (mr->type == 'N')
          337  +	  sqlite3_bind_int64 (params->ins_relation_refs_stmt, 1, relation->id);
          338  +	  sqlite3_bind_int (params->ins_relation_refs_stmt, 2, i_member);
          339  +	  if (p_member->member_type == READOSM_MEMBER_NODE)
   398    340   	      sqlite3_bind_text (params->ins_relation_refs_stmt, 3, "N", 1,
   399    341   				 SQLITE_STATIC);
   400         -	  else if (mr->type == 'W')
          342  +	  else if (p_member->member_type == READOSM_MEMBER_WAY)
   401    343   	      sqlite3_bind_text (params->ins_relation_refs_stmt, 3, "W", 1,
   402    344   				 SQLITE_STATIC);
   403         -	  else if (mr->type == 'R')
          345  +	  else if (p_member->member_type == READOSM_MEMBER_RELATION)
   404    346   	      sqlite3_bind_text (params->ins_relation_refs_stmt, 3, "R", 1,
   405    347   				 SQLITE_STATIC);
   406    348   	  else
   407    349   	      sqlite3_bind_text (params->ins_relation_refs_stmt, 3, "?", 1,
   408    350   				 SQLITE_STATIC);
   409         -	  sqlite3_bind_int64 (params->ins_relation_refs_stmt, 4, mr->id);
   410         -	  if (mr->role == NULL)
          351  +	  sqlite3_bind_int64 (params->ins_relation_refs_stmt, 4, p_member->id);
          352  +	  if (p_member->role == NULL)
   411    353   	      sqlite3_bind_null (params->ins_relation_refs_stmt, 5);
   412    354   	  else
   413    355   	      sqlite3_bind_text (params->ins_relation_refs_stmt, 5,
   414         -				 mr->role, strlen (mr->role), SQLITE_STATIC);
          356  +				 p_member->role, strlen (p_member->role),
          357  +				 SQLITE_STATIC);
   415    358   	  ret = sqlite3_step (params->ins_relation_refs_stmt);
   416    359   	  if (ret == SQLITE_DONE || ret == SQLITE_ROW)
   417    360   	      ;
   418    361   	  else
   419    362   	    {
   420    363   		fprintf (stderr,
   421    364   			 "sqlite3_step() error: INSERT INTO osm_relation_refs\n");
   422         -		return;
          365  +		return 0;
   423    366   	    }
   424    367   	  params->wr_rel_refs += 1;
   425         -	  mr = mr->next;
   426    368         }
          369  +    return 1;
          370  +}
          371  +
          372  +static int
          373  +consume_node (const void *user_data, const readosm_node * node)
          374  +{
          375  +/* processing an OSM Node (ReadOSM callback function) */
          376  +    struct aux_params *params = (struct aux_params *) user_data;
          377  +    if (!insert_node (params, node))
          378  +	return READOSM_ABORT;
          379  +    return READOSM_OK;
   427    380   }
   428    381   
   429         -static void
   430         -clean_node ()
          382  +static int
          383  +consume_way (const void *user_data, const readosm_way * way)
   431    384   {
   432         -/* cleaning the current node */
   433         -    struct tag *pt;
   434         -    struct tag *ptn;
   435         -    if (glob_node.timestamp)
   436         -	free (glob_node.timestamp);
   437         -    if (glob_node.user)
   438         -	free (glob_node.user);
   439         -    pt = glob_node.first;
   440         -    while (pt)
   441         -      {
   442         -	  ptn = pt->next;
   443         -	  if (pt->k)
   444         -	      free (pt->k);
   445         -	  if (pt->v)
   446         -	      free (pt->v);
   447         -	  free (pt);
   448         -	  pt = ptn;
   449         -      }
   450         -    glob_node.timestamp = NULL;
   451         -    glob_node.user = NULL;
   452         -    glob_node.first = NULL;
   453         -    glob_node.last = NULL;
          385  +/* processing an OSM Way (ReadOSM callback function) */
          386  +    struct aux_params *params = (struct aux_params *) user_data;
          387  +    if (!insert_way (params, way))
          388  +	return READOSM_ABORT;
          389  +    return READOSM_OK;
   454    390   }
   455    391   
   456         -static void
   457         -clean_way ()
          392  +static int
          393  +consume_relation (const void *user_data, const readosm_relation * relation)
   458    394   {
   459         -/* cleaning the current way */
   460         -    struct tag *pt;
   461         -    struct tag *ptn;
   462         -    struct node_ref *nr;
   463         -    struct node_ref *nrn;
   464         -    if (glob_way.timestamp)
   465         -	free (glob_way.timestamp);
   466         -    if (glob_way.user)
   467         -	free (glob_way.user);
   468         -    pt = glob_way.first;
   469         -    while (pt)
   470         -      {
   471         -	  ptn = pt->next;
   472         -	  if (pt->k)
   473         -	      free (pt->k);
   474         -	  if (pt->v)
   475         -	      free (pt->v);
   476         -	  free (pt);
   477         -	  pt = ptn;
   478         -      }
   479         -    nr = glob_way.first_node;
   480         -    while (nr)
   481         -      {
   482         -	  nrn = nr->next;
   483         -	  free (nr);
   484         -	  nr = nrn;
   485         -      }
   486         -    glob_way.timestamp = NULL;
   487         -    glob_way.user = NULL;
   488         -    glob_way.first = NULL;
   489         -    glob_way.last = NULL;
   490         -    glob_way.first_node = NULL;
   491         -    glob_way.last_node = NULL;
   492         -}
   493         -
   494         -static void
   495         -clean_relation ()
   496         -{
   497         -/* cleaning the current relation */
   498         -    struct tag *pt;
   499         -    struct tag *ptn;
   500         -    struct multi_ref *mr;
   501         -    struct multi_ref *mrn;
   502         -    if (glob_relation.timestamp)
   503         -	free (glob_relation.timestamp);
   504         -    if (glob_relation.user)
   505         -	free (glob_relation.user);
   506         -    pt = glob_relation.first;
   507         -    while (pt)
   508         -      {
   509         -	  ptn = pt->next;
   510         -	  if (pt->k)
   511         -	      free (pt->k);
   512         -	  if (pt->v)
   513         -	      free (pt->v);
   514         -	  free (pt);
   515         -	  pt = ptn;
   516         -      }
   517         -    mr = glob_relation.first_rel;
   518         -    while (mr)
   519         -      {
   520         -	  mrn = mr->next;
   521         -	  if (mr->role)
   522         -	      free (mr->role);
   523         -	  free (mr);
   524         -	  mr = mrn;
   525         -      }
   526         -    glob_relation.timestamp = NULL;
   527         -    glob_relation.user = NULL;
   528         -    glob_relation.first = NULL;
   529         -    glob_relation.last = NULL;
   530         -    glob_relation.first_rel = NULL;
   531         -    glob_relation.last_rel = NULL;
   532         -}
   533         -
   534         -static void
   535         -start_node (struct aux_params *params, const char **attr)
   536         -{
   537         -    int i;
   538         -    int len;
   539         -    for (i = 0; attr[i]; i += 2)
   540         -      {
   541         -	  if (strcmp (attr[i], "id") == 0)
   542         -	      glob_node.id = atol_64 (attr[i + 1]);
   543         -	  if (strcmp (attr[i], "version") == 0)
   544         -	      glob_node.version = atol_64 (attr[i + 1]);
   545         -	  if (strcmp (attr[i], "timestamp") == 0)
   546         -	    {
   547         -		if (glob_node.timestamp)
   548         -		    free (glob_node.timestamp);
   549         -		len = strlen (attr[i + 1]);
   550         -		glob_node.timestamp = malloc (len + 1);
   551         -		strcpy (glob_node.timestamp, attr[i + 1]);
   552         -	    }
   553         -	  if (strcmp (attr[i], "uid") == 0)
   554         -	      glob_node.uid = atol_64 (attr[i + 1]);
   555         -	  if (strcmp (attr[i], "user") == 0)
   556         -	    {
   557         -		if (glob_node.user)
   558         -		    free (glob_node.user);
   559         -		len = strlen (attr[i + 1]);
   560         -		glob_node.user = malloc (len + 1);
   561         -		strcpy (glob_node.user, attr[i + 1]);
   562         -	    }
   563         -	  if (strcmp (attr[i], "changeset") == 0)
   564         -	      glob_node.changeset = atol_64 (attr[i + 1]);
   565         -	  if (strcmp (attr[i], "lat") == 0)
   566         -	      glob_node.lat = atof (attr[i + 1]);
   567         -	  if (strcmp (attr[i], "lon") == 0)
   568         -	      glob_node.lon = atof (attr[i + 1]);
   569         -      }
   570         -    params->current_tag = CURRENT_TAG_IS_NODE;
   571         -}
   572         -
   573         -static void
   574         -end_node (struct aux_params *params)
   575         -{
   576         -    insert_node (params);
   577         -    clean_node ();
   578         -    params->current_tag = CURRENT_TAG_UNKNOWN;
   579         -}
   580         -
   581         -static void
   582         -start_way (struct aux_params *params, const char **attr)
   583         -{
   584         -    int i;
   585         -    int len;
   586         -    for (i = 0; attr[i]; i += 2)
   587         -      {
   588         -	  if (strcmp (attr[i], "id") == 0)
   589         -	      glob_way.id = atol_64 (attr[i + 1]);
   590         -	  if (strcmp (attr[i], "version") == 0)
   591         -	      glob_way.version = atol_64 (attr[i + 1]);
   592         -	  if (strcmp (attr[i], "timestamp") == 0)
   593         -	    {
   594         -		if (glob_way.timestamp)
   595         -		    free (glob_way.timestamp);
   596         -		len = strlen (attr[i + 1]);
   597         -		glob_way.timestamp = malloc (len + 1);
   598         -		strcpy (glob_way.timestamp, attr[i + 1]);
   599         -	    }
   600         -	  if (strcmp (attr[i], "uid") == 0)
   601         -	      glob_way.uid = atol_64 (attr[i + 1]);
   602         -	  if (strcmp (attr[i], "user") == 0)
   603         -	    {
   604         -		if (glob_way.user)
   605         -		    free (glob_way.user);
   606         -		len = strlen (attr[i + 1]);
   607         -		glob_way.user = malloc (len + 1);
   608         -		strcpy (glob_way.user, attr[i + 1]);
   609         -	    }
   610         -	  if (strcmp (attr[i], "changeset") == 0)
   611         -	      glob_way.changeset = atol_64 (attr[i + 1]);
   612         -      }
   613         -    params->current_tag = CURRENT_TAG_IS_WAY;
   614         -}
   615         -
   616         -static void
   617         -end_way (struct aux_params *params)
   618         -{
   619         -    insert_way (params);
   620         -    clean_way ();
   621         -    params->current_tag = CURRENT_TAG_UNKNOWN;
   622         -}
   623         -
   624         -static void
   625         -start_relation (struct aux_params *params, const char **attr)
   626         -{
   627         -    int i;
   628         -    int len;
   629         -    for (i = 0; attr[i]; i += 2)
   630         -      {
   631         -	  if (strcmp (attr[i], "id") == 0)
   632         -	      glob_relation.id = atol_64 (attr[i + 1]);
   633         -	  if (strcmp (attr[i], "version") == 0)
   634         -	      glob_relation.version = atol_64 (attr[i + 1]);
   635         -	  if (strcmp (attr[i], "timestamp") == 0)
   636         -	    {
   637         -		if (glob_relation.timestamp)
   638         -		    free (glob_relation.timestamp);
   639         -		len = strlen (attr[i + 1]);
   640         -		glob_relation.timestamp = malloc (len + 1);
   641         -		strcpy (glob_relation.timestamp, attr[i + 1]);
   642         -	    }
   643         -	  if (strcmp (attr[i], "uid") == 0)
   644         -	      glob_relation.uid = atol_64 (attr[i + 1]);
   645         -	  if (strcmp (attr[i], "user") == 0)
   646         -	    {
   647         -		if (glob_relation.user)
   648         -		    free (glob_relation.user);
   649         -		len = strlen (attr[i + 1]);
   650         -		glob_relation.user = malloc (len + 1);
   651         -		strcpy (glob_relation.user, attr[i + 1]);
   652         -	    }
   653         -	  if (strcmp (attr[i], "changeset") == 0)
   654         -	      glob_relation.changeset = atol_64 (attr[i + 1]);
   655         -      }
   656         -    params->current_tag = CURRENT_TAG_IS_RELATION;
   657         -}
   658         -
   659         -static void
   660         -end_relation (struct aux_params *params)
   661         -{
   662         -    insert_relation (params);
   663         -    clean_relation ();
   664         -    params->current_tag = CURRENT_TAG_UNKNOWN;
   665         -}
   666         -
   667         -static void
   668         -start_xtag (struct aux_params *params, const char **attr)
   669         -{
   670         -    int i;
   671         -    int len;
   672         -    const char *k = NULL;
   673         -    const char *v = NULL;
   674         -    struct tag *p_tag;
   675         -    for (i = 0; attr[i]; i += 2)
   676         -      {
   677         -	  if (strcmp (attr[i], "k") == 0)
   678         -	      k = attr[i + 1];
   679         -	  if (strcmp (attr[i], "v") == 0)
   680         -	      v = attr[i + 1];
   681         -      }
   682         -
   683         -/* appending a new tag to the current item */
   684         -    if (params->current_tag == CURRENT_TAG_IS_NODE)
   685         -      {
   686         -	  p_tag = malloc (sizeof (struct tag));
   687         -	  if (glob_node.first == NULL)
   688         -	      glob_node.first = p_tag;
   689         -	  if (glob_node.last != NULL)
   690         -	      glob_node.last->next = p_tag;
   691         -	  glob_node.last = p_tag;
   692         -	  p_tag->next = NULL;
   693         -	  len = strlen (k);
   694         -	  p_tag->k = malloc (len + 1);
   695         -	  strcpy (p_tag->k, k);
   696         -	  len = strlen (v);
   697         -	  p_tag->v = malloc (len + 1);
   698         -	  strcpy (p_tag->v, v);
   699         -      }
   700         -    if (params->current_tag == CURRENT_TAG_IS_WAY)
   701         -      {
   702         -	  p_tag = malloc (sizeof (struct tag));
   703         -	  if (glob_way.first == NULL)
   704         -	      glob_way.first = p_tag;
   705         -	  if (glob_way.last != NULL)
   706         -	      glob_way.last->next = p_tag;
   707         -	  glob_way.last = p_tag;
   708         -	  p_tag->next = NULL;
   709         -	  len = strlen (k);
   710         -	  p_tag->k = malloc (len + 1);
   711         -	  strcpy (p_tag->k, k);
   712         -	  len = strlen (v);
   713         -	  p_tag->v = malloc (len + 1);
   714         -	  strcpy (p_tag->v, v);
   715         -      }
   716         -    if (params->current_tag == CURRENT_TAG_IS_RELATION)
   717         -      {
   718         -	  p_tag = malloc (sizeof (struct tag));
   719         -	  if (glob_relation.first == NULL)
   720         -	      glob_relation.first = p_tag;
   721         -	  if (glob_relation.last != NULL)
   722         -	      glob_relation.last->next = p_tag;
   723         -	  glob_relation.last = p_tag;
   724         -	  p_tag->next = NULL;
   725         -	  len = strlen (k);
   726         -	  p_tag->k = malloc (len + 1);
   727         -	  strcpy (p_tag->k, k);
   728         -	  len = strlen (v);
   729         -	  p_tag->v = malloc (len + 1);
   730         -	  strcpy (p_tag->v, v);
   731         -      }
   732         -}
   733         -
   734         -static void
   735         -start_nd (struct aux_params *params, const char **attr)
   736         -{
   737         -    int i;
   738         -    sqlite3_int64 node_id;
   739         -    struct node_ref *nr;
   740         -    for (i = 0; attr[i]; i += 2)
   741         -      {
   742         -	  if (strcmp (attr[i], "ref") == 0)
   743         -	      node_id = atol_64 (attr[i + 1]);
   744         -      }
   745         -/* appending a new node-ref-id to the current item */
   746         -    if (params->current_tag == CURRENT_TAG_IS_WAY)
   747         -      {
   748         -	  nr = malloc (sizeof (struct node_ref));
   749         -	  if (glob_way.first_node == NULL)
   750         -	      glob_way.first_node = nr;
   751         -	  if (glob_way.last_node != NULL)
   752         -	      glob_way.last_node->next = nr;
   753         -	  glob_way.last_node = nr;
   754         -	  nr->next = NULL;
   755         -	  nr->node_id = node_id;
   756         -      }
   757         -}
   758         -
   759         -static void
   760         -start_member (struct aux_params *params, const char **attr)
   761         -{
   762         -    int i;
   763         -    sqlite3_int64 id;
   764         -    const char *role = NULL;
   765         -    int len;
   766         -    int is_way = 0;
   767         -    int is_node = 0;
   768         -    int is_rel = 0;
   769         -    struct multi_ref *mr;
   770         -    for (i = 0; attr[i]; i += 2)
   771         -      {
   772         -	  if (strcmp (attr[i], "type") == 0)
   773         -	    {
   774         -		if (strcmp (attr[i + 1], "way") == 0)
   775         -		    is_way = 1;
   776         -		if (strcmp (attr[i + 1], "node") == 0)
   777         -		    is_node = 1;
   778         -		if (strcmp (attr[i + 1], "relation") == 0)
   779         -		    is_rel = 1;
   780         -	    }
   781         -	  if (strcmp (attr[i], "ref") == 0)
   782         -	      id = atol_64 (attr[i + 1]);
   783         -	  if (strcmp (attr[i], "role") == 0)
   784         -	      role = attr[i + 1];
   785         -      }
   786         -
   787         -    if (params->current_tag == CURRENT_TAG_IS_RELATION)
   788         -      {
   789         -	  /* appending a new relation-ref-id to the current item */
   790         -	  mr = malloc (sizeof (struct multi_ref));
   791         -	  if (glob_relation.first_rel == NULL)
   792         -	      glob_relation.first_rel = mr;
   793         -	  if (glob_relation.last_rel != NULL)
   794         -	      glob_relation.last_rel->next = mr;
   795         -	  glob_relation.last_rel = mr;
   796         -	  mr->next = NULL;
   797         -	  mr->type = '?';
   798         -	  if (is_node)
   799         -	      mr->type = 'N';
   800         -	  if (is_way)
   801         -	      mr->type = 'W';
   802         -	  if (is_rel)
   803         -	      mr->type = 'R';
   804         -	  mr->id = id;
   805         -	  mr->role = NULL;
   806         -	  if (role)
   807         -	    {
   808         -		len = strlen (role);
   809         -		mr->role = malloc (len + 1);
   810         -		strcpy (mr->role, role);
   811         -	    }
   812         -      }
   813         -}
   814         -
   815         -static void
   816         -start_tag (void *data, const char *el, const char **attr)
   817         -{
   818         -    struct aux_params *params = (struct aux_params *) data;
   819         -    if (strcmp (el, "node") == 0)
   820         -	start_node (params, attr);
   821         -    if (strcmp (el, "way") == 0)
   822         -	start_way (params, attr);
   823         -    if (strcmp (el, "relation") == 0)
   824         -	start_relation (params, attr);
   825         -    if (strcmp (el, "tag") == 0)
   826         -	start_xtag (params, attr);
   827         -    if (strcmp (el, "nd") == 0)
   828         -	start_nd (params, attr);
   829         -    if (strcmp (el, "member") == 0)
   830         -	start_member (params, attr);
   831         -}
   832         -
   833         -static void
   834         -end_tag (void *data, const char *el)
   835         -{
   836         -    struct aux_params *params = (struct aux_params *) data;
   837         -    if (strcmp (el, "node") == 0)
   838         -	end_node (params);
   839         -    if (strcmp (el, "way") == 0)
   840         -	end_way (params);
   841         -    if (strcmp (el, "relation") == 0)
   842         -	end_relation (params);
          395  +/* processing an OSM Relation (ReadOSM callback function) */
          396  +    struct aux_params *params = (struct aux_params *) user_data;
          397  +    if (!insert_relation (params, relation))
          398  +	return READOSM_ABORT;
          399  +    return READOSM_OK;
   843    400   }
   844    401   
   845    402   static void
   846    403   finalize_sql_stmts (struct aux_params *params)
   847    404   {
   848    405       int ret;
   849    406       char *sql_err = NULL;
................................................................................
   872    429   	  fprintf (stderr, "COMMIT TRANSACTION error: %s\n", sql_err);
   873    430   	  sqlite3_free (sql_err);
   874    431   	  return;
   875    432         }
   876    433   }
   877    434   
   878    435   static void
   879         -create_sql_stmts (struct aux_params *params)
          436  +create_sql_stmts (struct aux_params *params, int journal_off)
   880    437   {
   881    438       sqlite3_stmt *ins_nodes_stmt;
   882    439       sqlite3_stmt *ins_node_tags_stmt;
   883    440       sqlite3_stmt *ins_ways_stmt;
   884    441       sqlite3_stmt *ins_way_tags_stmt;
   885    442       sqlite3_stmt *ins_way_refs_stmt;
   886    443       sqlite3_stmt *ins_relations_stmt;
   887    444       sqlite3_stmt *ins_relation_tags_stmt;
   888    445       sqlite3_stmt *ins_relation_refs_stmt;
   889    446       char sql[1024];
   890    447       int ret;
   891    448       char *sql_err = NULL;
          449  +
          450  +    if (journal_off)
          451  +      {
          452  +	  /* disabling the journal: unsafe but faster */
          453  +	  ret =
          454  +	      sqlite3_exec (params->db_handle, "PRAGMA journal_mode = OFF",
          455  +			    NULL, NULL, &sql_err);
          456  +	  if (ret != SQLITE_OK)
          457  +	    {
          458  +		fprintf (stderr, "PRAGMA journal_mode=OFF error: %s\n",
          459  +			 sql_err);
          460  +		sqlite3_free (sql_err);
          461  +		return;
          462  +	    }
          463  +      }
   892    464   
   893    465   /* the complete operation is handled as an unique SQL Transaction */
   894    466       ret = sqlite3_exec (params->db_handle, "BEGIN", NULL, NULL, &sql_err);
   895    467       if (ret != SQLITE_OK)
   896    468         {
   897    469   	  fprintf (stderr, "BEGIN TRANSACTION error: %s\n", sql_err);
   898    470   	  sqlite3_free (sql_err);
................................................................................
  1163    735   	;
  1164    736       else
  1165    737   	goto unknown;
  1166    738   
  1167    739   /* creating the OSM "raw" nodes */
  1168    740       strcpy (sql, "CREATE TABLE osm_nodes (\n");
  1169    741       strcat (sql, "node_id INTEGER NOT NULL PRIMARY KEY,\n");
  1170         -    strcat (sql, "version INTEGER NOT NULL,\n");
          742  +    strcat (sql, "version INTEGER,\n");
  1171    743       strcat (sql, "timestamp TEXT,\n");
  1172         -    strcat (sql, "uid INTEGER NOT NULL,\n");
          744  +    strcat (sql, "uid INTEGER,\n");
  1173    745       strcat (sql, "user TEXT,\n");
  1174         -    strcat (sql, "changeset INTEGER NOT NULL,\n");
          746  +    strcat (sql, "changeset INTEGER,\n");
  1175    747       strcat (sql, "filtered INTEGER NOT NULL)\n");
  1176    748       ret = sqlite3_exec (db_handle, sql, NULL, NULL, &err_msg);
  1177    749       if (ret != SQLITE_OK)
  1178    750         {
  1179    751   	  fprintf (stderr, "CREATE TABLE 'osm_nodes' error: %s\n", err_msg);
  1180    752   	  sqlite3_free (err_msg);
  1181    753   	  sqlite3_close (db_handle);
................................................................................
  1207    779   	  sqlite3_free (err_msg);
  1208    780   	  sqlite3_close (db_handle);
  1209    781   	  return;
  1210    782         }
  1211    783   /* creating the OSM "raw" ways */
  1212    784       strcpy (sql, "CREATE TABLE osm_ways (\n");
  1213    785       strcat (sql, "way_id INTEGER NOT NULL PRIMARY KEY,\n");
  1214         -    strcat (sql, "version INTEGER NOT NULL,\n");
          786  +    strcat (sql, "version INTEGER,\n");
  1215    787       strcat (sql, "timestamp TEXT,\n");
  1216         -    strcat (sql, "uid INTEGER NOT NULL,\n");
          788  +    strcat (sql, "uid INTEGER,\n");
  1217    789       strcat (sql, "user TEXT,\n");
  1218         -    strcat (sql, "changeset INTEGER NOT NULL,\n");
          790  +    strcat (sql, "changeset INTEGER,\n");
  1219    791       strcat (sql, "filtered INTEGER NOT NULL)\n");
  1220    792       ret = sqlite3_exec (db_handle, sql, NULL, NULL, &err_msg);
  1221    793       if (ret != SQLITE_OK)
  1222    794         {
  1223    795   	  fprintf (stderr, "CREATE TABLE 'osm_ways' error: %s\n", err_msg);
  1224    796   	  sqlite3_free (err_msg);
  1225    797   	  sqlite3_close (db_handle);
................................................................................
  1268    840   	  sqlite3_free (err_msg);
  1269    841   	  sqlite3_close (db_handle);
  1270    842   	  return;
  1271    843         }
  1272    844   /* creating the OSM "raw" relations */
  1273    845       strcpy (sql, "CREATE TABLE osm_relations (\n");
  1274    846       strcat (sql, "rel_id INTEGER NOT NULL PRIMARY KEY,\n");
  1275         -    strcat (sql, "version INTEGER NOT NULL,\n");
          847  +    strcat (sql, "version INTEGER,\n");
  1276    848       strcat (sql, "timestamp TEXT,\n");
  1277         -    strcat (sql, "uid INTEGER NOT NULL,\n");
          849  +    strcat (sql, "uid INTEGER,\n");
  1278    850       strcat (sql, "user TEXT,\n");
  1279         -    strcat (sql, "changeset INTEGER NOT NULL,\n");
          851  +    strcat (sql, "changeset INTEGER,\n");
  1280    852       strcat (sql, "filtered INTEGER NOT NULL)\n");
  1281    853       ret = sqlite3_exec (db_handle, sql, NULL, NULL, &err_msg);
  1282    854       if (ret != SQLITE_OK)
  1283    855         {
  1284    856   	  fprintf (stderr, "CREATE TABLE 'osm_relations' error: %s\n", err_msg);
  1285    857   	  sqlite3_free (err_msg);
  1286    858   	  sqlite3_close (db_handle);
................................................................................
  1353    925   {
  1354    926   /* printing the argument list */
  1355    927       fprintf (stderr, "\n\nusage: spatialite_osm_raw ARGLIST\n");
  1356    928       fprintf (stderr,
  1357    929   	     "==============================================================\n");
  1358    930       fprintf (stderr,
  1359    931   	     "-h or --help                    print this help message\n");
  1360         -    fprintf (stderr, "-o or --osm-path pathname       the OSM-XML file path\n");
          932  +    fprintf (stderr, "-o or --osm-path pathname       the OSM-file path\n");
          933  +    fprintf (stderr,
          934  +	     "                 both OSM-XML (*.osm) and OSM-ProtoBuf\n");
          935  +    fprintf (stderr,
          936  +	     "                 (*.osm.pbf) are indifferenctly supported.\n\n");
  1361    937       fprintf (stderr,
  1362    938   	     "-d or --db-path  pathname       the SpatiaLite DB path\n\n");
  1363    939       fprintf (stderr, "you can specify the following options as well\n");
  1364    940       fprintf (stderr,
  1365    941   	     "-cs or --cache-size    num      DB cache size (how many pages)\n");
  1366    942       fprintf (stderr,
  1367    943   	     "-m or --in-memory               using IN-MEMORY database\n");
          944  +    fprintf (stderr,
          945  +	     "-jo or --journal-off            unsafe [but faster] mode\n");
  1368    946   }
  1369    947   
  1370    948   int
  1371    949   main (int argc, char *argv[])
  1372    950   {
  1373    951   /* the MAIN function simply perform arguments checking */
  1374    952       sqlite3 *handle;
  1375    953       int i;
  1376    954       int next_arg = ARG_NONE;
  1377    955       const char *osm_path = NULL;
  1378    956       const char *db_path = NULL;
  1379    957       int in_memory = 0;
  1380    958       int cache_size = 0;
          959  +    int journal_off = 0;
  1381    960       int error = 0;
  1382         -    char Buff[BUFFSIZE];
  1383         -    int done = 0;
  1384         -    int len;
  1385         -    XML_Parser parser;
  1386    961       struct aux_params params;
  1387         -    FILE *xml_file;
          962  +    const void *osm_handle;
  1388    963   
  1389    964   /* initializing the aux-structs */
  1390    965       params.db_handle = NULL;
  1391    966       params.ins_nodes_stmt = NULL;
  1392    967       params.ins_node_tags_stmt = NULL;
  1393    968       params.ins_ways_stmt = NULL;
  1394    969       params.ins_way_tags_stmt = NULL;
................................................................................
  1400    975       params.wr_node_tags = 0;
  1401    976       params.wr_ways = 0;
  1402    977       params.wr_way_tags = 0;
  1403    978       params.wr_way_refs = 0;
  1404    979       params.wr_relations = 0;
  1405    980       params.wr_rel_tags = 0;
  1406    981       params.wr_rel_refs = 0;
  1407         -    params.current_tag = CURRENT_TAG_UNKNOWN;
  1408         -
  1409         -    glob_node.timestamp = NULL;
  1410         -    glob_node.user = NULL;
  1411         -    glob_node.first = NULL;
  1412         -    glob_node.last = NULL;
  1413         -
  1414         -    glob_way.timestamp = NULL;
  1415         -    glob_way.user = NULL;
  1416         -    glob_way.first = NULL;
  1417         -    glob_way.last = NULL;
  1418         -    glob_way.first_node = NULL;
  1419         -    glob_way.last_node = NULL;
  1420         -
  1421         -    glob_relation.timestamp = NULL;
  1422         -    glob_relation.user = NULL;
  1423         -    glob_relation.first = NULL;
  1424         -    glob_relation.last = NULL;
  1425         -    glob_relation.first_rel = NULL;
  1426         -    glob_relation.last_rel = NULL;
  1427    982   
  1428    983       for (i = 1; i < argc; i++)
  1429    984         {
  1430    985   	  /* parsing the invocation arguments */
  1431    986   	  if (next_arg != ARG_NONE)
  1432    987   	    {
  1433    988   		switch (next_arg)
................................................................................
  1479   1034   	    }
  1480   1035   	  if (strcasecmp (argv[i], "-m") == 0)
  1481   1036   	    {
  1482   1037   		in_memory = 1;
  1483   1038   		next_arg = ARG_NONE;
  1484   1039   		continue;
  1485   1040   	    }
  1486         -	  if (strcasecmp (argv[i], "-in-memory") == 0)
         1041  +	  if (strcasecmp (argv[i], "--in-memory") == 0)
  1487   1042   	    {
  1488   1043   		in_memory = 1;
  1489   1044   		next_arg = ARG_NONE;
  1490   1045   		continue;
         1046  +	    }
         1047  +	  if (strcasecmp (argv[i], "-jo") == 0)
         1048  +	    {
         1049  +		journal_off = 1;
         1050  +		next_arg = ARG_NONE;
         1051  +		continue;
         1052  +	    }
         1053  +	  if (strcasecmp (argv[i], "--journal-off") == 0)
         1054  +	    {
         1055  +		journal_off = 1;
         1056  +		next_arg = ARG_NONE;
         1057  +		continue;
  1491   1058   	    }
  1492   1059   	  fprintf (stderr, "unknown argument: %s\n", argv[i]);
  1493   1060   	  error = 1;
  1494   1061         }
  1495   1062       if (error)
  1496   1063         {
  1497   1064   	  do_help ();
................................................................................
  1519   1086   
  1520   1087   /* opening the DB */
  1521   1088       if (in_memory)
  1522   1089   	cache_size = 0;
  1523   1090       open_db (db_path, &handle, cache_size);
  1524   1091       if (!handle)
  1525   1092   	return -1;
  1526         -    params.db_handle = handle;
  1527   1093       if (in_memory)
  1528   1094         {
  1529   1095   	  /* loading the DB in-memory */
  1530   1096   	  sqlite3 *mem_db_handle;
  1531   1097   	  sqlite3_backup *backup;
  1532   1098   	  int ret;
  1533   1099   	  ret =
................................................................................
  1556   1122   		    break;
  1557   1123   	    }
  1558   1124   	  ret = sqlite3_backup_finish (backup);
  1559   1125   	  sqlite3_close (handle);
  1560   1126   	  handle = mem_db_handle;
  1561   1127   	  printf ("\nusing IN-MEMORY database\n");
  1562   1128         }
         1129  +    params.db_handle = handle;
  1563   1130   
  1564   1131   /* creating SQL prepared statements */
  1565         -    create_sql_stmts (&params);
         1132  +    create_sql_stmts (&params, journal_off);
  1566   1133   
  1567         -/* XML parsing */
  1568         -    xml_file = fopen (osm_path, "rb");
  1569         -    if (!xml_file)
         1134  +/* parsing the input OSM-file */
         1135  +    if (readosm_open (osm_path, &osm_handle) != READOSM_OK)
  1570   1136         {
  1571   1137   	  fprintf (stderr, "cannot open %s\n", osm_path);
         1138  +	  finalize_sql_stmts (&params);
  1572   1139   	  sqlite3_close (handle);
         1140  +	  readosm_close (osm_handle);
  1573   1141   	  return -1;
  1574   1142         }
  1575         -    parser = XML_ParserCreate (NULL);
  1576         -    if (!parser)
         1143  +    if (readosm_parse
         1144  +	(osm_handle, &params, consume_node, consume_way,
         1145  +	 consume_relation) != READOSM_OK)
  1577   1146         {
  1578         -	  fprintf (stderr, "Couldn't allocate memory for parser\n");
         1147  +	  fprintf (stderr, "unrecoverable error while parsing %s\n", osm_path);
         1148  +	  finalize_sql_stmts (&params);
  1579   1149   	  sqlite3_close (handle);
         1150  +	  readosm_close (osm_handle);
  1580   1151   	  return -1;
  1581   1152         }
  1582         -    XML_SetUserData (parser, &params);
  1583         -    XML_SetElementHandler (parser, start_tag, end_tag);
  1584         -    while (!done)
  1585         -      {
  1586         -	  len = fread (Buff, 1, BUFFSIZE, xml_file);
  1587         -	  if (ferror (xml_file))
  1588         -	    {
  1589         -		fprintf (stderr, "XML Read error\n");
  1590         -		sqlite3_close (handle);
  1591         -		return -1;
  1592         -	    }
  1593         -	  done = feof (xml_file);
  1594         -	  if (!XML_Parse (parser, Buff, len, done))
  1595         -	    {
  1596         -		fprintf (stderr, "Parse error at line %d:\n%s\n",
  1597         -			 (int) XML_GetCurrentLineNumber (parser),
  1598         -			 XML_ErrorString (XML_GetErrorCode (parser)));
  1599         -		sqlite3_close (handle);
  1600         -		return -1;
  1601         -	    }
  1602         -      }
  1603         -    XML_ParserFree (parser);
  1604         -    fclose (xml_file);
         1153  +    readosm_close (osm_handle);
  1605   1154   
  1606   1155   /* finalizing SQL prepared statements */
  1607   1156       finalize_sql_stmts (&params);
  1608   1157   
  1609   1158   /* printing out statistics */
  1610   1159       printf ("inserted %d nodes\n", params.wr_nodes);
  1611   1160       printf ("\t%d tags\n", params.wr_node_tags);