├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── LICENSE ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── aclocal.m4 ├── conf2lib ├── config.h.in ├── configure ├── configure.ac ├── install-sh ├── missing ├── priv ├── csv_example.erl └── gen_set.pl ├── src ├── csv.erl └── csv_util.erl └── test ├── Makefile.am ├── Makefile.in └── csv_tests.erl /.gitignore: -------------------------------------------------------------------------------- 1 | *.*~ 2 | *.log 3 | *.status 4 | *.aux 5 | *.beam 6 | *.dump 7 | *.tag.gz 8 | *.tgz 9 | *.conf 10 | *.gnuweb 11 | priv/set-*.txt 12 | ebin/ 13 | Makefile 14 | autom4te.cache/ 15 | *.config 16 | config.h 17 | eunit 18 | init.erlang 19 | stamp-h1 20 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fogfish/csv/608fa2037b9037f27de91e00e068308679f315e3/AUTHORS -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Dmitry Kolesnikov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of author nor the names of its contributors 15 | may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fogfish/csv/608fa2037b9037f27de91e00e068308679f315e3/ChangeLog -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994-1996, 1999-2002, 2004-2011 Free Software Foundation, 5 | Inc. 6 | 7 | Copying and distribution of this file, with or without modification, 8 | are permitted in any medium without royalty provided the copyright 9 | notice and this notice are preserved. This file is offered as-is, 10 | without warranty of any kind. 11 | 12 | Basic Installation 13 | ================== 14 | 15 | Briefly, the shell commands `./configure; make; make install' should 16 | configure, build, and install this package. The following 17 | more-detailed instructions are generic; see the `README' file for 18 | instructions specific to this package. Some packages provide this 19 | `INSTALL' file but do not implement all of the features documented 20 | below. The lack of an optional feature in a given package is not 21 | necessarily a bug. More recommendations for GNU packages can be found 22 | in *note Makefile Conventions: (standards)Makefile Conventions. 23 | 24 | The `configure' shell script attempts to guess correct values for 25 | various system-dependent variables used during compilation. It uses 26 | those values to create a `Makefile' in each directory of the package. 27 | It may also create one or more `.h' files containing system-dependent 28 | definitions. Finally, it creates a shell script `config.status' that 29 | you can run in the future to recreate the current configuration, and a 30 | file `config.log' containing compiler output (useful mainly for 31 | debugging `configure'). 32 | 33 | It can also use an optional file (typically called `config.cache' 34 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 35 | the results of its tests to speed up reconfiguring. Caching is 36 | disabled by default to prevent problems with accidental use of stale 37 | cache files. 38 | 39 | If you need to do unusual things to compile the package, please try 40 | to figure out how `configure' could check whether to do them, and mail 41 | diffs or instructions to the address given in the `README' so they can 42 | be considered for the next release. If you are using the cache, and at 43 | some point `config.cache' contains results you don't want to keep, you 44 | may remove or edit it. 45 | 46 | The file `configure.ac' (or `configure.in') is used to create 47 | `configure' by a program called `autoconf'. You need `configure.ac' if 48 | you want to change it or regenerate `configure' using a newer version 49 | of `autoconf'. 50 | 51 | The simplest way to compile this package is: 52 | 53 | 1. `cd' to the directory containing the package's source code and type 54 | `./configure' to configure the package for your system. 55 | 56 | Running `configure' might take a while. While running, it prints 57 | some messages telling which features it is checking for. 58 | 59 | 2. Type `make' to compile the package. 60 | 61 | 3. Optionally, type `make check' to run any self-tests that come with 62 | the package, generally using the just-built uninstalled binaries. 63 | 64 | 4. Type `make install' to install the programs and any data files and 65 | documentation. When installing into a prefix owned by root, it is 66 | recommended that the package be configured and built as a regular 67 | user, and only the `make install' phase executed with root 68 | privileges. 69 | 70 | 5. Optionally, type `make installcheck' to repeat any self-tests, but 71 | this time using the binaries in their final installed location. 72 | This target does not install anything. Running this target as a 73 | regular user, particularly if the prior `make install' required 74 | root privileges, verifies that the installation completed 75 | correctly. 76 | 77 | 6. You can remove the program binaries and object files from the 78 | source code directory by typing `make clean'. To also remove the 79 | files that `configure' created (so you can compile the package for 80 | a different kind of computer), type `make distclean'. There is 81 | also a `make maintainer-clean' target, but that is intended mainly 82 | for the package's developers. If you use it, you may have to get 83 | all sorts of other programs in order to regenerate files that came 84 | with the distribution. 85 | 86 | 7. Often, you can also type `make uninstall' to remove the installed 87 | files again. In practice, not all packages have tested that 88 | uninstallation works correctly, even though it is required by the 89 | GNU Coding Standards. 90 | 91 | 8. Some packages, particularly those that use Automake, provide `make 92 | distcheck', which can by used by developers to test that all other 93 | targets like `make install' and `make uninstall' work correctly. 94 | This target is generally not run by end users. 95 | 96 | Compilers and Options 97 | ===================== 98 | 99 | Some systems require unusual options for compilation or linking that 100 | the `configure' script does not know about. Run `./configure --help' 101 | for details on some of the pertinent environment variables. 102 | 103 | You can give `configure' initial values for configuration parameters 104 | by setting variables in the command line or in the environment. Here 105 | is an example: 106 | 107 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 108 | 109 | *Note Defining Variables::, for more details. 110 | 111 | Compiling For Multiple Architectures 112 | ==================================== 113 | 114 | You can compile the package for more than one kind of computer at the 115 | same time, by placing the object files for each architecture in their 116 | own directory. To do this, you can use GNU `make'. `cd' to the 117 | directory where you want the object files and executables to go and run 118 | the `configure' script. `configure' automatically checks for the 119 | source code in the directory that `configure' is in and in `..'. This 120 | is known as a "VPATH" build. 121 | 122 | With a non-GNU `make', it is safer to compile the package for one 123 | architecture at a time in the source code directory. After you have 124 | installed the package for one architecture, use `make distclean' before 125 | reconfiguring for another architecture. 126 | 127 | On MacOS X 10.5 and later systems, you can create libraries and 128 | executables that work on multiple system types--known as "fat" or 129 | "universal" binaries--by specifying multiple `-arch' options to the 130 | compiler but only a single `-arch' option to the preprocessor. Like 131 | this: 132 | 133 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 134 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 135 | CPP="gcc -E" CXXCPP="g++ -E" 136 | 137 | This is not guaranteed to produce working output in all cases, you 138 | may have to build one architecture at a time and combine the results 139 | using the `lipo' tool if you have problems. 140 | 141 | Installation Names 142 | ================== 143 | 144 | By default, `make install' installs the package's commands under 145 | `/usr/local/bin', include files under `/usr/local/include', etc. You 146 | can specify an installation prefix other than `/usr/local' by giving 147 | `configure' the option `--prefix=PREFIX', where PREFIX must be an 148 | absolute file name. 149 | 150 | You can specify separate installation prefixes for 151 | architecture-specific files and architecture-independent files. If you 152 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 153 | PREFIX as the prefix for installing programs and libraries. 154 | Documentation and other data files still use the regular prefix. 155 | 156 | In addition, if you use an unusual directory layout you can give 157 | options like `--bindir=DIR' to specify different values for particular 158 | kinds of files. Run `configure --help' for a list of the directories 159 | you can set and what kinds of files go in them. In general, the 160 | default for these options is expressed in terms of `${prefix}', so that 161 | specifying just `--prefix' will affect all of the other directory 162 | specifications that were not explicitly provided. 163 | 164 | The most portable way to affect installation locations is to pass the 165 | correct locations to `configure'; however, many packages provide one or 166 | both of the following shortcuts of passing variable assignments to the 167 | `make install' command line to change installation locations without 168 | having to reconfigure or recompile. 169 | 170 | The first method involves providing an override variable for each 171 | affected directory. For example, `make install 172 | prefix=/alternate/directory' will choose an alternate location for all 173 | directory configuration variables that were expressed in terms of 174 | `${prefix}'. Any directories that were specified during `configure', 175 | but not in terms of `${prefix}', must each be overridden at install 176 | time for the entire installation to be relocated. The approach of 177 | makefile variable overrides for each directory variable is required by 178 | the GNU Coding Standards, and ideally causes no recompilation. 179 | However, some platforms have known limitations with the semantics of 180 | shared libraries that end up requiring recompilation when using this 181 | method, particularly noticeable in packages that use GNU Libtool. 182 | 183 | The second method involves providing the `DESTDIR' variable. For 184 | example, `make install DESTDIR=/alternate/directory' will prepend 185 | `/alternate/directory' before all installation names. The approach of 186 | `DESTDIR' overrides is not required by the GNU Coding Standards, and 187 | does not work on platforms that have drive letters. On the other hand, 188 | it does better at avoiding recompilation issues, and works well even 189 | when some directory options were not specified in terms of `${prefix}' 190 | at `configure' time. 191 | 192 | Optional Features 193 | ================= 194 | 195 | If the package supports it, you can cause programs to be installed 196 | with an extra prefix or suffix on their names by giving `configure' the 197 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 198 | 199 | Some packages pay attention to `--enable-FEATURE' options to 200 | `configure', where FEATURE indicates an optional part of the package. 201 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 202 | is something like `gnu-as' or `x' (for the X Window System). The 203 | `README' should mention any `--enable-' and `--with-' options that the 204 | package recognizes. 205 | 206 | For packages that use the X Window System, `configure' can usually 207 | find the X include and library files automatically, but if it doesn't, 208 | you can use the `configure' options `--x-includes=DIR' and 209 | `--x-libraries=DIR' to specify their locations. 210 | 211 | Some packages offer the ability to configure how verbose the 212 | execution of `make' will be. For these packages, running `./configure 213 | --enable-silent-rules' sets the default to minimal output, which can be 214 | overridden with `make V=1'; while running `./configure 215 | --disable-silent-rules' sets the default to verbose, which can be 216 | overridden with `make V=0'. 217 | 218 | Particular systems 219 | ================== 220 | 221 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU 222 | CC is not installed, it is recommended to use the following options in 223 | order to use an ANSI C compiler: 224 | 225 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 226 | 227 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 228 | 229 | HP-UX `make' updates targets which have the same time stamps as 230 | their prerequisites, which makes it generally unusable when shipped 231 | generated files such as `configure' are involved. Use GNU `make' 232 | instead. 233 | 234 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 235 | parse its `' header file. The option `-nodtk' can be used as 236 | a workaround. If GNU CC is not installed, it is therefore recommended 237 | to try 238 | 239 | ./configure CC="cc" 240 | 241 | and if that doesn't work, try 242 | 243 | ./configure CC="cc -nodtk" 244 | 245 | On Solaris, don't put `/usr/ucb' early in your `PATH'. This 246 | directory contains several dysfunctional programs; working variants of 247 | these programs are available in `/usr/bin'. So, if you need `/usr/ucb' 248 | in your `PATH', put it _after_ `/usr/bin'. 249 | 250 | On Haiku, software installed for all users goes in `/boot/common', 251 | not `/usr/local'. It is recommended to use the following options: 252 | 253 | ./configure --prefix=/boot/common 254 | 255 | Specifying the System Type 256 | ========================== 257 | 258 | There may be some features `configure' cannot figure out 259 | automatically, but needs to determine by the type of machine the package 260 | will run on. Usually, assuming the package is built to be run on the 261 | _same_ architectures, `configure' can figure that out, but if it prints 262 | a message saying it cannot guess the machine type, give it the 263 | `--build=TYPE' option. TYPE can either be a short name for the system 264 | type, such as `sun4', or a canonical name which has the form: 265 | 266 | CPU-COMPANY-SYSTEM 267 | 268 | where SYSTEM can have one of these forms: 269 | 270 | OS 271 | KERNEL-OS 272 | 273 | See the file `config.sub' for the possible values of each field. If 274 | `config.sub' isn't included in this package, then this package doesn't 275 | need to know the machine type. 276 | 277 | If you are _building_ compiler tools for cross-compiling, you should 278 | use the option `--target=TYPE' to select the type of system they will 279 | produce code for. 280 | 281 | If you want to _use_ a cross compiler, that generates code for a 282 | platform different from the build platform, you should specify the 283 | "host" platform (i.e., that on which the generated programs will 284 | eventually be run) with `--host=TYPE'. 285 | 286 | Sharing Defaults 287 | ================ 288 | 289 | If you want to set default values for `configure' scripts to share, 290 | you can create a site shell script called `config.site' that gives 291 | default values for variables like `CC', `cache_file', and `prefix'. 292 | `configure' looks for `PREFIX/share/config.site' if it exists, then 293 | `PREFIX/etc/config.site' if it exists. Or, you can set the 294 | `CONFIG_SITE' environment variable to the location of the site script. 295 | A warning: not all `configure' scripts look for a site script. 296 | 297 | Defining Variables 298 | ================== 299 | 300 | Variables not defined in a site shell script can be set in the 301 | environment passed to `configure'. However, some packages may run 302 | configure again during the build, and the customized values of these 303 | variables may be lost. In order to avoid this problem, you should set 304 | them in the `configure' command line, using `VAR=value'. For example: 305 | 306 | ./configure CC=/usr/local2/bin/gcc 307 | 308 | causes the specified `gcc' to be used as the C compiler (unless it is 309 | overridden in the site shell script). 310 | 311 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to 312 | an Autoconf bug. Until the bug is fixed you can use this workaround: 313 | 314 | CONFIG_SHELL=/bin/bash /bin/bash ./configure CONFIG_SHELL=/bin/bash 315 | 316 | `configure' Invocation 317 | ====================== 318 | 319 | `configure' recognizes the following options to control how it 320 | operates. 321 | 322 | `--help' 323 | `-h' 324 | Print a summary of all of the options to `configure', and exit. 325 | 326 | `--help=short' 327 | `--help=recursive' 328 | Print a summary of the options unique to this package's 329 | `configure', and exit. The `short' variant lists options used 330 | only in the top level, while the `recursive' variant lists options 331 | also present in any nested packages. 332 | 333 | `--version' 334 | `-V' 335 | Print the version of Autoconf used to generate the `configure' 336 | script, and exit. 337 | 338 | `--cache-file=FILE' 339 | Enable the cache: use and save the results of the tests in FILE, 340 | traditionally `config.cache'. FILE defaults to `/dev/null' to 341 | disable caching. 342 | 343 | `--config-cache' 344 | `-C' 345 | Alias for `--cache-file=config.cache'. 346 | 347 | `--quiet' 348 | `--silent' 349 | `-q' 350 | Do not print messages saying which checks are being made. To 351 | suppress all normal output, redirect it to `/dev/null' (any error 352 | messages will still be shown). 353 | 354 | `--srcdir=DIR' 355 | Look for the package's source code in directory DIR. Usually 356 | `configure' can determine that directory automatically. 357 | 358 | `--prefix=DIR' 359 | Use DIR as the installation prefix. *note Installation Names:: 360 | for more details, including other options available for fine-tuning 361 | the installation locations. 362 | 363 | `--no-create' 364 | `-n' 365 | Run the configure checks, but stop before creating any output 366 | files. 367 | 368 | `configure' also accepts some other, not widely useful, options. Run 369 | `configure --help' for more details. 370 | 371 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2012, Dmitry Kolesnikov 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions 6 | are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above copyright 11 | notice, this list of conditions and the following disclaimer in 12 | the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of author nor the names of its contributors 15 | may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 20 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 21 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 22 | COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 23 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 28 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 29 | EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2012, Dmitry Kolesnikov 3 | # All Rights Reserved. 4 | # 5 | # Licensed under the 3-clause BSD License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | # 17 | SUBDIRS = test 18 | 19 | csv_SRC = \ 20 | src/csv.erl \ 21 | src/csv_util.erl 22 | 23 | nobase_pkgliberl_SCRIPTS = \ 24 | ebin/csv.app \ 25 | $(csv_BEAM) 26 | 27 | SET = \ 28 | priv/set-300K-8.txt \ 29 | priv/set-300K-24.txt \ 30 | priv/set-300K-40.txt 31 | 32 | CLEANFILES = $(nobase_pkgliberl_SCRIPTS) $(SET) 33 | EXTRA_DIST = $(csv_SRC) 34 | 35 | example: priv/csv_example.beam $(SET) 36 | 37 | priv/set-%: 38 | $(AM_V_GEN)n=`echo "$@" | sed -n -e 's|.*-\([0-9]*\)K-.*|\1|p'`; \ 39 | t=`echo "$@" | sed -n -e 's|.*-[0-9]*K-\(.*\)\..*|\1|p'`; \ 40 | $(PERL) priv/gen_set.pl $$n $$t > $@ 41 | 42 | smp: 43 | $(ERL) -pa ./ebin -pa ../*/ebin -pa ./priv -pa ../*/priv -smp +A 1024 +h 10240 44 | 45 | @MAKE_GNUWEB@ 46 | 47 | -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.11.3 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software 6 | # Foundation, Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | 18 | VPATH = @srcdir@ 19 | pkgdatadir = $(datadir)/@PACKAGE@ 20 | pkgincludedir = $(includedir)/@PACKAGE@ 21 | pkglibdir = $(libdir)/@PACKAGE@ 22 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 23 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 24 | install_sh_DATA = $(install_sh) -c -m 644 25 | install_sh_PROGRAM = $(install_sh) -c 26 | install_sh_SCRIPT = $(install_sh) -c 27 | INSTALL_HEADER = $(INSTALL_DATA) 28 | transform = $(program_transform_name) 29 | NORMAL_INSTALL = : 30 | PRE_INSTALL = : 31 | POST_INSTALL = : 32 | NORMAL_UNINSTALL = : 33 | PRE_UNINSTALL = : 34 | POST_UNINSTALL = : 35 | subdir = . 36 | DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ 37 | $(srcdir)/Makefile.in $(srcdir)/config.h.in \ 38 | $(top_srcdir)/configure AUTHORS COPYING ChangeLog INSTALL NEWS \ 39 | install-sh missing 40 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 41 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 42 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 43 | $(ACLOCAL_M4) 44 | am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \ 45 | configure.lineno config.status.lineno 46 | mkinstalldirs = $(install_sh) -d 47 | CONFIG_HEADER = config.h 48 | CONFIG_CLEAN_FILES = 49 | CONFIG_CLEAN_VPATH_FILES = 50 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 51 | am__vpath_adj = case $$p in \ 52 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 53 | *) f=$$p;; \ 54 | esac; 55 | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 56 | am__install_max = 40 57 | am__nobase_strip_setup = \ 58 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 59 | am__nobase_strip = \ 60 | for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 61 | am__nobase_list = $(am__nobase_strip_setup); \ 62 | for p in $$list; do echo "$$p $$p"; done | \ 63 | sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 64 | $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 65 | if (++n[$$2] == $(am__install_max)) \ 66 | { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 67 | END { for (dir in files) print dir, files[dir] }' 68 | am__base_list = \ 69 | sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 70 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 71 | am__uninstall_files_from_dir = { \ 72 | test -z "$$files" \ 73 | || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 74 | || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 75 | $(am__cd) "$$dir" && rm -f $$files; }; \ 76 | } 77 | am__installdirs = "$(DESTDIR)$(pkgliberldir)" 78 | SCRIPTS = $(nobase_pkgliberl_SCRIPTS) 79 | AM_V_GEN = $(am__v_GEN_@AM_V@) 80 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 81 | am__v_GEN_0 = @echo " GEN " $@; 82 | AM_V_at = $(am__v_at_@AM_V@) 83 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 84 | am__v_at_0 = @ 85 | SOURCES = 86 | DIST_SOURCES = 87 | RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \ 88 | html-recursive info-recursive install-data-recursive \ 89 | install-dvi-recursive install-exec-recursive \ 90 | install-html-recursive install-info-recursive \ 91 | install-pdf-recursive install-ps-recursive install-recursive \ 92 | installcheck-recursive installdirs-recursive pdf-recursive \ 93 | ps-recursive uninstall-recursive 94 | RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \ 95 | distclean-recursive maintainer-clean-recursive 96 | AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \ 97 | $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \ 98 | distdir dist dist-all distcheck 99 | ETAGS = etags 100 | CTAGS = ctags 101 | DIST_SUBDIRS = $(SUBDIRS) 102 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 103 | distdir = $(PACKAGE)-$(VERSION) 104 | top_distdir = $(distdir) 105 | am__remove_distdir = \ 106 | if test -d "$(distdir)"; then \ 107 | find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \ 108 | && rm -rf "$(distdir)" \ 109 | || { sleep 5 && rm -rf "$(distdir)"; }; \ 110 | else :; fi 111 | am__relativize = \ 112 | dir0=`pwd`; \ 113 | sed_first='s,^\([^/]*\)/.*$$,\1,'; \ 114 | sed_rest='s,^[^/]*/*,,'; \ 115 | sed_last='s,^.*/\([^/]*\)$$,\1,'; \ 116 | sed_butlast='s,/*[^/]*$$,,'; \ 117 | while test -n "$$dir1"; do \ 118 | first=`echo "$$dir1" | sed -e "$$sed_first"`; \ 119 | if test "$$first" != "."; then \ 120 | if test "$$first" = ".."; then \ 121 | dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \ 122 | dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \ 123 | else \ 124 | first2=`echo "$$dir2" | sed -e "$$sed_first"`; \ 125 | if test "$$first2" = "$$first"; then \ 126 | dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \ 127 | else \ 128 | dir2="../$$dir2"; \ 129 | fi; \ 130 | dir0="$$dir0"/"$$first"; \ 131 | fi; \ 132 | fi; \ 133 | dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \ 134 | done; \ 135 | reldir="$$dir2" 136 | DIST_ARCHIVES = $(distdir).tar.gz 137 | GZIP_ENV = --best 138 | distuninstallcheck_listfiles = find . -type f -print 139 | am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \ 140 | | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$' 141 | distcleancheck_listfiles = find . -type f -print 142 | ACLOCAL = @ACLOCAL@ 143 | AMTAR = @AMTAR@ 144 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 145 | AM_V_ERL = @AM_V_ERL@ 146 | AM_V_TAR = @AM_V_TAR@ 147 | AUTOCONF = @AUTOCONF@ 148 | AUTOHEADER = @AUTOHEADER@ 149 | AUTOMAKE = @AUTOMAKE@ 150 | AWK = @AWK@ 151 | CONF2LIB = @CONF2LIB@ 152 | CYGPATH_W = @CYGPATH_W@ 153 | DEFS = @DEFS@ 154 | ECHO_C = @ECHO_C@ 155 | ECHO_N = @ECHO_N@ 156 | ECHO_T = @ECHO_T@ 157 | ERL = @ERL@ 158 | ERLANG_APPS = @ERLANG_APPS@ 159 | ERLANG_LIBS = @ERLANG_LIBS@ 160 | ERLC = @ERLC@ 161 | ERLCFLAGS = @ERLCFLAGS@ 162 | INSTALL = @INSTALL@ 163 | INSTALL_DATA = @INSTALL_DATA@ 164 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 165 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 166 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 167 | LIBOBJS = @LIBOBJS@ 168 | LIBS = @LIBS@ 169 | LTLIBOBJS = @LTLIBOBJS@ 170 | MAKEINFO = @MAKEINFO@ 171 | MAKE_GNUWEB = @MAKE_GNUWEB@ 172 | MKDIR_P = @MKDIR_P@ 173 | PACKAGE = @PACKAGE@ 174 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 175 | PACKAGE_NAME = @PACKAGE_NAME@ 176 | PACKAGE_STRING = @PACKAGE_STRING@ 177 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 178 | PACKAGE_URL = @PACKAGE_URL@ 179 | PACKAGE_VERSION = @PACKAGE_VERSION@ 180 | PATH_SEPARATOR = @PATH_SEPARATOR@ 181 | PERL = @PERL@ 182 | SET_MAKE = @SET_MAKE@ 183 | SHELL = @SHELL@ 184 | STRIP = @STRIP@ 185 | VERSION = @VERSION@ 186 | abs_builddir = @abs_builddir@ 187 | abs_srcdir = @abs_srcdir@ 188 | abs_top_builddir = @abs_top_builddir@ 189 | abs_top_srcdir = @abs_top_srcdir@ 190 | am__leading_dot = @am__leading_dot@ 191 | am__tar = @am__tar@ 192 | am__untar = @am__untar@ 193 | am__v_ERL_ = @am__v_ERL_@ 194 | am__v_ERL_0 = @am__v_ERL_0@ 195 | am__v_TAR_ = @am__v_TAR_@ 196 | am__v_TAR_0 = @am__v_TAR_0@ 197 | bindir = @bindir@ 198 | build_alias = @build_alias@ 199 | builddir = @builddir@ 200 | datadir = @datadir@ 201 | datarootdir = @datarootdir@ 202 | docdir = @docdir@ 203 | dvidir = @dvidir@ 204 | exec_prefix = @exec_prefix@ 205 | have_erts = @have_erts@ 206 | have_kernel = @have_kernel@ 207 | have_stdlib = @have_stdlib@ 208 | host_alias = @host_alias@ 209 | htmldir = @htmldir@ 210 | includedir = @includedir@ 211 | infodir = @infodir@ 212 | install_sh = @install_sh@ 213 | libdir = @libdir@ 214 | liberldir = @liberldir@ 215 | libexecdir = @libexecdir@ 216 | localedir = @localedir@ 217 | localstatedir = @localstatedir@ 218 | mandir = @mandir@ 219 | mkdir_p = @mkdir_p@ 220 | oldincludedir = @oldincludedir@ 221 | pdfdir = @pdfdir@ 222 | pkgliberldir = @pkgliberldir@ 223 | prefix = @prefix@ 224 | program_transform_name = @program_transform_name@ 225 | psdir = @psdir@ 226 | sbindir = @sbindir@ 227 | sharedstatedir = @sharedstatedir@ 228 | srcdir = @srcdir@ 229 | sysconfdir = @sysconfdir@ 230 | target_alias = @target_alias@ 231 | top_build_prefix = @top_build_prefix@ 232 | top_builddir = @top_builddir@ 233 | top_srcdir = @top_srcdir@ 234 | 235 | # 236 | # Copyright (c) 2012, Dmitry Kolesnikov 237 | # All Rights Reserved. 238 | # 239 | # Licensed under the 3-clause BSD License (the "License"); 240 | # you may not use this file except in compliance with the License. 241 | # You may obtain a copy of the License at 242 | # 243 | # http://www.opensource.org/licenses/BSD-3-Clause 244 | # 245 | # Unless required by applicable law or agreed to in writing, software 246 | # distributed under the License is distributed on an "AS IS" BASIS, 247 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 248 | # See the License for the specific language governing permissions and 249 | # limitations under the License 250 | # 251 | SUBDIRS = test 252 | csv_SRC = \ 253 | src/csv.erl \ 254 | src/csv_util.erl 255 | 256 | nobase_pkgliberl_SCRIPTS = \ 257 | ebin/csv.app \ 258 | $(csv_BEAM) 259 | 260 | SET = \ 261 | priv/set-300K-8.txt \ 262 | priv/set-300K-24.txt \ 263 | priv/set-300K-40.txt 264 | 265 | CLEANFILES = $(nobase_pkgliberl_SCRIPTS) $(SET) 266 | EXTRA_DIST = $(csv_SRC) 267 | all: config.h 268 | $(MAKE) $(AM_MAKEFLAGS) all-recursive 269 | 270 | .SUFFIXES: 271 | am--refresh: Makefile 272 | @: 273 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 274 | @for dep in $?; do \ 275 | case '$(am__configure_deps)' in \ 276 | *$$dep*) \ 277 | echo ' cd $(srcdir) && $(AUTOMAKE) --gnu'; \ 278 | $(am__cd) $(srcdir) && $(AUTOMAKE) --gnu \ 279 | && exit 0; \ 280 | exit 1;; \ 281 | esac; \ 282 | done; \ 283 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Makefile'; \ 284 | $(am__cd) $(top_srcdir) && \ 285 | $(AUTOMAKE) --gnu Makefile 286 | .PRECIOUS: Makefile 287 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 288 | @case '$?' in \ 289 | *config.status*) \ 290 | echo ' $(SHELL) ./config.status'; \ 291 | $(SHELL) ./config.status;; \ 292 | *) \ 293 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \ 294 | cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \ 295 | esac; 296 | 297 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 298 | $(SHELL) ./config.status --recheck 299 | 300 | $(top_srcdir)/configure: $(am__configure_deps) 301 | $(am__cd) $(srcdir) && $(AUTOCONF) 302 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 303 | $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) 304 | $(am__aclocal_m4_deps): 305 | 306 | config.h: stamp-h1 307 | @if test ! -f $@; then rm -f stamp-h1; else :; fi 308 | @if test ! -f $@; then $(MAKE) $(AM_MAKEFLAGS) stamp-h1; else :; fi 309 | 310 | stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status 311 | @rm -f stamp-h1 312 | cd $(top_builddir) && $(SHELL) ./config.status config.h 313 | $(srcdir)/config.h.in: $(am__configure_deps) 314 | ($(am__cd) $(top_srcdir) && $(AUTOHEADER)) 315 | rm -f stamp-h1 316 | touch $@ 317 | 318 | distclean-hdr: 319 | -rm -f config.h stamp-h1 320 | install-nobase_pkgliberlSCRIPTS: $(nobase_pkgliberl_SCRIPTS) 321 | @$(NORMAL_INSTALL) 322 | test -z "$(pkgliberldir)" || $(MKDIR_P) "$(DESTDIR)$(pkgliberldir)" 323 | @list='$(nobase_pkgliberl_SCRIPTS)'; test -n "$(pkgliberldir)" || list=; \ 324 | $(am__nobase_strip_setup); \ 325 | for p in $$list; do \ 326 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 327 | if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \ 328 | done | \ 329 | sed -e 'p;s,.*/,,;n' \ 330 | -e "s|$$srcdirstrip/||" -e 'h;s|[^/]*$$||; s|^$$|.|' \ 331 | -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \ 332 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \ 333 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 334 | if ($$2 == $$4) { files[d] = files[d] " " $$1; \ 335 | if (++n[d] == $(am__install_max)) { \ 336 | print "f", d, files[d]; n[d] = 0; files[d] = "" } } \ 337 | else { print "f", d "/" $$4, $$1 } } \ 338 | END { for (d in files) print "f", d, files[d] }' | \ 339 | while read type dir files; do \ 340 | case $$type in \ 341 | d) echo " $(MKDIR_P) '$(DESTDIR)$(pkgliberldir)/$$dir'"; \ 342 | $(MKDIR_P) "$(DESTDIR)$(pkgliberldir)/$$dir" || exit $$?;; \ 343 | f) \ 344 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 345 | test -z "$$files" || { \ 346 | echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(pkgliberldir)$$dir'"; \ 347 | $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(pkgliberldir)$$dir" || exit $$?; \ 348 | } \ 349 | ;; esac \ 350 | ; done 351 | 352 | uninstall-nobase_pkgliberlSCRIPTS: 353 | @$(NORMAL_UNINSTALL) 354 | @list='$(nobase_pkgliberl_SCRIPTS)'; test -n "$(pkgliberldir)" || exit 0; \ 355 | $(am__nobase_strip_setup); \ 356 | files=`$(am__nobase_strip) \ 357 | -e 'h;s,.*/,,;$(transform);x;s|[^/]*$$||;G;s,\n,,'`; \ 358 | dir='$(DESTDIR)$(pkgliberldir)'; $(am__uninstall_files_from_dir) 359 | 360 | # This directory's subdirectories are mostly independent; you can cd 361 | # into them and run `make' without going through this Makefile. 362 | # To change the values of `make' variables: instead of editing Makefiles, 363 | # (1) if the variable is set in `config.status', edit `config.status' 364 | # (which will cause the Makefiles to be regenerated when you run `make'); 365 | # (2) otherwise, pass the desired values on the `make' command line. 366 | $(RECURSIVE_TARGETS): 367 | @fail= failcom='exit 1'; \ 368 | for f in x $$MAKEFLAGS; do \ 369 | case $$f in \ 370 | *=* | --[!k]*);; \ 371 | *k*) failcom='fail=yes';; \ 372 | esac; \ 373 | done; \ 374 | dot_seen=no; \ 375 | target=`echo $@ | sed s/-recursive//`; \ 376 | list='$(SUBDIRS)'; for subdir in $$list; do \ 377 | echo "Making $$target in $$subdir"; \ 378 | if test "$$subdir" = "."; then \ 379 | dot_seen=yes; \ 380 | local_target="$$target-am"; \ 381 | else \ 382 | local_target="$$target"; \ 383 | fi; \ 384 | ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ 385 | || eval $$failcom; \ 386 | done; \ 387 | if test "$$dot_seen" = "no"; then \ 388 | $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \ 389 | fi; test -z "$$fail" 390 | 391 | $(RECURSIVE_CLEAN_TARGETS): 392 | @fail= failcom='exit 1'; \ 393 | for f in x $$MAKEFLAGS; do \ 394 | case $$f in \ 395 | *=* | --[!k]*);; \ 396 | *k*) failcom='fail=yes';; \ 397 | esac; \ 398 | done; \ 399 | dot_seen=no; \ 400 | case "$@" in \ 401 | distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \ 402 | *) list='$(SUBDIRS)' ;; \ 403 | esac; \ 404 | rev=''; for subdir in $$list; do \ 405 | if test "$$subdir" = "."; then :; else \ 406 | rev="$$subdir $$rev"; \ 407 | fi; \ 408 | done; \ 409 | rev="$$rev ."; \ 410 | target=`echo $@ | sed s/-recursive//`; \ 411 | for subdir in $$rev; do \ 412 | echo "Making $$target in $$subdir"; \ 413 | if test "$$subdir" = "."; then \ 414 | local_target="$$target-am"; \ 415 | else \ 416 | local_target="$$target"; \ 417 | fi; \ 418 | ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \ 419 | || eval $$failcom; \ 420 | done && test -z "$$fail" 421 | tags-recursive: 422 | list='$(SUBDIRS)'; for subdir in $$list; do \ 423 | test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \ 424 | done 425 | ctags-recursive: 426 | list='$(SUBDIRS)'; for subdir in $$list; do \ 427 | test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \ 428 | done 429 | 430 | ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) 431 | list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ 432 | unique=`for i in $$list; do \ 433 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 434 | done | \ 435 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 436 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 437 | mkid -fID $$unique 438 | tags: TAGS 439 | 440 | TAGS: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ 441 | $(TAGS_FILES) $(LISP) 442 | set x; \ 443 | here=`pwd`; \ 444 | if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \ 445 | include_option=--etags-include; \ 446 | empty_fix=.; \ 447 | else \ 448 | include_option=--include; \ 449 | empty_fix=; \ 450 | fi; \ 451 | list='$(SUBDIRS)'; for subdir in $$list; do \ 452 | if test "$$subdir" = .; then :; else \ 453 | test ! -f $$subdir/TAGS || \ 454 | set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \ 455 | fi; \ 456 | done; \ 457 | list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ 458 | unique=`for i in $$list; do \ 459 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 460 | done | \ 461 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 462 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 463 | shift; \ 464 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 465 | test -n "$$unique" || unique=$$empty_fix; \ 466 | if test $$# -gt 0; then \ 467 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 468 | "$$@" $$unique; \ 469 | else \ 470 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 471 | $$unique; \ 472 | fi; \ 473 | fi 474 | ctags: CTAGS 475 | CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ 476 | $(TAGS_FILES) $(LISP) 477 | list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ 478 | unique=`for i in $$list; do \ 479 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 480 | done | \ 481 | $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ 482 | END { if (nonempty) { for (i in files) print i; }; }'`; \ 483 | test -z "$(CTAGS_ARGS)$$unique" \ 484 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 485 | $$unique 486 | 487 | GTAGS: 488 | here=`$(am__cd) $(top_builddir) && pwd` \ 489 | && $(am__cd) $(top_srcdir) \ 490 | && gtags -i $(GTAGS_ARGS) "$$here" 491 | 492 | distclean-tags: 493 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 494 | 495 | distdir: $(DISTFILES) 496 | $(am__remove_distdir) 497 | test -d "$(distdir)" || mkdir "$(distdir)" 498 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 499 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 500 | list='$(DISTFILES)'; \ 501 | dist_files=`for file in $$list; do echo $$file; done | \ 502 | sed -e "s|^$$srcdirstrip/||;t" \ 503 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 504 | case $$dist_files in \ 505 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 506 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 507 | sort -u` ;; \ 508 | esac; \ 509 | for file in $$dist_files; do \ 510 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 511 | if test -d $$d/$$file; then \ 512 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 513 | if test -d "$(distdir)/$$file"; then \ 514 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 515 | fi; \ 516 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 517 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 518 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 519 | fi; \ 520 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 521 | else \ 522 | test -f "$(distdir)/$$file" \ 523 | || cp -p $$d/$$file "$(distdir)/$$file" \ 524 | || exit 1; \ 525 | fi; \ 526 | done 527 | @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ 528 | if test "$$subdir" = .; then :; else \ 529 | test -d "$(distdir)/$$subdir" \ 530 | || $(MKDIR_P) "$(distdir)/$$subdir" \ 531 | || exit 1; \ 532 | fi; \ 533 | done 534 | @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \ 535 | if test "$$subdir" = .; then :; else \ 536 | dir1=$$subdir; dir2="$(distdir)/$$subdir"; \ 537 | $(am__relativize); \ 538 | new_distdir=$$reldir; \ 539 | dir1=$$subdir; dir2="$(top_distdir)"; \ 540 | $(am__relativize); \ 541 | new_top_distdir=$$reldir; \ 542 | echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \ 543 | echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \ 544 | ($(am__cd) $$subdir && \ 545 | $(MAKE) $(AM_MAKEFLAGS) \ 546 | top_distdir="$$new_top_distdir" \ 547 | distdir="$$new_distdir" \ 548 | am__remove_distdir=: \ 549 | am__skip_length_check=: \ 550 | am__skip_mode_fix=: \ 551 | distdir) \ 552 | || exit 1; \ 553 | fi; \ 554 | done 555 | -test -n "$(am__skip_mode_fix)" \ 556 | || find "$(distdir)" -type d ! -perm -755 \ 557 | -exec chmod u+rwx,go+rx {} \; -o \ 558 | ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ 559 | ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ 560 | ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \ 561 | || chmod -R a+r "$(distdir)" 562 | dist-gzip: distdir 563 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 564 | $(am__remove_distdir) 565 | 566 | dist-bzip2: distdir 567 | tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2 568 | $(am__remove_distdir) 569 | 570 | dist-lzip: distdir 571 | tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz 572 | $(am__remove_distdir) 573 | 574 | dist-lzma: distdir 575 | tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma 576 | $(am__remove_distdir) 577 | 578 | dist-xz: distdir 579 | tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz 580 | $(am__remove_distdir) 581 | 582 | dist-tarZ: distdir 583 | tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z 584 | $(am__remove_distdir) 585 | 586 | dist-shar: distdir 587 | shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz 588 | $(am__remove_distdir) 589 | 590 | dist-zip: distdir 591 | -rm -f $(distdir).zip 592 | zip -rq $(distdir).zip $(distdir) 593 | $(am__remove_distdir) 594 | 595 | dist dist-all: distdir 596 | tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz 597 | $(am__remove_distdir) 598 | 599 | # This target untars the dist file and tries a VPATH configuration. Then 600 | # it guarantees that the distribution is self-contained by making another 601 | # tarfile. 602 | distcheck: dist 603 | case '$(DIST_ARCHIVES)' in \ 604 | *.tar.gz*) \ 605 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).tar.gz | $(am__untar) ;;\ 606 | *.tar.bz2*) \ 607 | bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\ 608 | *.tar.lzma*) \ 609 | lzma -dc $(distdir).tar.lzma | $(am__untar) ;;\ 610 | *.tar.lz*) \ 611 | lzip -dc $(distdir).tar.lz | $(am__untar) ;;\ 612 | *.tar.xz*) \ 613 | xz -dc $(distdir).tar.xz | $(am__untar) ;;\ 614 | *.tar.Z*) \ 615 | uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ 616 | *.shar.gz*) \ 617 | GZIP=$(GZIP_ENV) gzip -dc $(distdir).shar.gz | unshar ;;\ 618 | *.zip*) \ 619 | unzip $(distdir).zip ;;\ 620 | esac 621 | chmod -R a-w $(distdir); chmod a+w $(distdir) 622 | mkdir $(distdir)/_build 623 | mkdir $(distdir)/_inst 624 | chmod a-w $(distdir) 625 | test -d $(distdir)/_build || exit 0; \ 626 | dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \ 627 | && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \ 628 | && am__cwd=`pwd` \ 629 | && $(am__cd) $(distdir)/_build \ 630 | && ../configure --srcdir=.. --prefix="$$dc_install_base" \ 631 | $(AM_DISTCHECK_CONFIGURE_FLAGS) \ 632 | $(DISTCHECK_CONFIGURE_FLAGS) \ 633 | && $(MAKE) $(AM_MAKEFLAGS) \ 634 | && $(MAKE) $(AM_MAKEFLAGS) dvi \ 635 | && $(MAKE) $(AM_MAKEFLAGS) check \ 636 | && $(MAKE) $(AM_MAKEFLAGS) install \ 637 | && $(MAKE) $(AM_MAKEFLAGS) installcheck \ 638 | && $(MAKE) $(AM_MAKEFLAGS) uninstall \ 639 | && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \ 640 | distuninstallcheck \ 641 | && chmod -R a-w "$$dc_install_base" \ 642 | && ({ \ 643 | (cd ../.. && umask 077 && mkdir "$$dc_destdir") \ 644 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \ 645 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \ 646 | && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \ 647 | distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \ 648 | } || { rm -rf "$$dc_destdir"; exit 1; }) \ 649 | && rm -rf "$$dc_destdir" \ 650 | && $(MAKE) $(AM_MAKEFLAGS) dist \ 651 | && rm -rf $(DIST_ARCHIVES) \ 652 | && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \ 653 | && cd "$$am__cwd" \ 654 | || exit 1 655 | $(am__remove_distdir) 656 | @(echo "$(distdir) archives ready for distribution: "; \ 657 | list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \ 658 | sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x' 659 | distuninstallcheck: 660 | @test -n '$(distuninstallcheck_dir)' || { \ 661 | echo 'ERROR: trying to run $@ with an empty' \ 662 | '$$(distuninstallcheck_dir)' >&2; \ 663 | exit 1; \ 664 | }; \ 665 | $(am__cd) '$(distuninstallcheck_dir)' || { \ 666 | echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \ 667 | exit 1; \ 668 | }; \ 669 | test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \ 670 | || { echo "ERROR: files left after uninstall:" ; \ 671 | if test -n "$(DESTDIR)"; then \ 672 | echo " (check DESTDIR support)"; \ 673 | fi ; \ 674 | $(distuninstallcheck_listfiles) ; \ 675 | exit 1; } >&2 676 | distcleancheck: distclean 677 | @if test '$(srcdir)' = . ; then \ 678 | echo "ERROR: distcleancheck can only run from a VPATH build" ; \ 679 | exit 1 ; \ 680 | fi 681 | @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \ 682 | || { echo "ERROR: files left in build directory after distclean:" ; \ 683 | $(distcleancheck_listfiles) ; \ 684 | exit 1; } >&2 685 | check-am: all-am 686 | check: check-recursive 687 | all-am: Makefile $(SCRIPTS) config.h 688 | installdirs: installdirs-recursive 689 | installdirs-am: 690 | for dir in "$(DESTDIR)$(pkgliberldir)"; do \ 691 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 692 | done 693 | install: install-recursive 694 | install-exec: install-exec-recursive 695 | install-data: install-data-recursive 696 | uninstall: uninstall-recursive 697 | 698 | install-am: all-am 699 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 700 | 701 | installcheck: installcheck-recursive 702 | install-strip: 703 | if test -z '$(STRIP)'; then \ 704 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 705 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 706 | install; \ 707 | else \ 708 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 709 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 710 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 711 | fi 712 | mostlyclean-generic: 713 | 714 | clean-generic: 715 | -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) 716 | 717 | distclean-generic: 718 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 719 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 720 | 721 | maintainer-clean-generic: 722 | @echo "This command is intended for maintainers to use" 723 | @echo "it deletes files that may require special tools to rebuild." 724 | clean: clean-recursive 725 | 726 | clean-am: clean-generic mostlyclean-am 727 | 728 | distclean: distclean-recursive 729 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 730 | -rm -f Makefile 731 | distclean-am: clean-am distclean-generic distclean-hdr distclean-tags 732 | 733 | dvi: dvi-recursive 734 | 735 | dvi-am: 736 | 737 | html: html-recursive 738 | 739 | html-am: 740 | 741 | info: info-recursive 742 | 743 | info-am: 744 | 745 | install-data-am: install-nobase_pkgliberlSCRIPTS 746 | 747 | install-dvi: install-dvi-recursive 748 | 749 | install-dvi-am: 750 | 751 | install-exec-am: 752 | 753 | install-html: install-html-recursive 754 | 755 | install-html-am: 756 | 757 | install-info: install-info-recursive 758 | 759 | install-info-am: 760 | 761 | install-man: 762 | 763 | install-pdf: install-pdf-recursive 764 | 765 | install-pdf-am: 766 | 767 | install-ps: install-ps-recursive 768 | 769 | install-ps-am: 770 | 771 | installcheck-am: 772 | 773 | maintainer-clean: maintainer-clean-recursive 774 | -rm -f $(am__CONFIG_DISTCLEAN_FILES) 775 | -rm -rf $(top_srcdir)/autom4te.cache 776 | -rm -f Makefile 777 | maintainer-clean-am: distclean-am maintainer-clean-generic 778 | 779 | mostlyclean: mostlyclean-recursive 780 | 781 | mostlyclean-am: mostlyclean-generic 782 | 783 | pdf: pdf-recursive 784 | 785 | pdf-am: 786 | 787 | ps: ps-recursive 788 | 789 | ps-am: 790 | 791 | uninstall-am: uninstall-nobase_pkgliberlSCRIPTS 792 | 793 | .MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \ 794 | ctags-recursive install-am install-strip tags-recursive 795 | 796 | .PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \ 797 | all all-am am--refresh check check-am clean clean-generic \ 798 | ctags ctags-recursive dist dist-all dist-bzip2 dist-gzip \ 799 | dist-lzip dist-lzma dist-shar dist-tarZ dist-xz dist-zip \ 800 | distcheck distclean distclean-generic distclean-hdr \ 801 | distclean-tags distcleancheck distdir distuninstallcheck dvi \ 802 | dvi-am html html-am info info-am install install-am \ 803 | install-data install-data-am install-dvi install-dvi-am \ 804 | install-exec install-exec-am install-html install-html-am \ 805 | install-info install-info-am install-man \ 806 | install-nobase_pkgliberlSCRIPTS install-pdf install-pdf-am \ 807 | install-ps install-ps-am install-strip installcheck \ 808 | installcheck-am installdirs installdirs-am maintainer-clean \ 809 | maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ 810 | pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \ 811 | uninstall-nobase_pkgliberlSCRIPTS 812 | 813 | 814 | example: priv/csv_example.beam $(SET) 815 | 816 | priv/set-%: 817 | $(AM_V_GEN)n=`echo "$@" | sed -n -e 's|.*-\([0-9]*\)K-.*|\1|p'`; \ 818 | t=`echo "$@" | sed -n -e 's|.*-[0-9]*K-\(.*\)\..*|\1|p'`; \ 819 | $(PERL) priv/gen_set.pl $$n $$t > $@ 820 | 821 | smp: 822 | $(ERL) -pa ./ebin -pa ../*/ebin -pa ./priv -pa ../*/priv -smp +A 1024 +h 10240 823 | 824 | @MAKE_GNUWEB@ 825 | 826 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 827 | # Otherwise a system limit (for SysV at least) may be exceeded. 828 | .NOEXPORT: 829 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fogfish/csv/608fa2037b9037f27de91e00e068308679f315e3/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | CSV-file parser 2 | *************** 3 | 4 | Copyright (C) 2012, Dmitry Kolesnikov 5 | 6 | This file is free documentation; unlimited permisions are give to copy, 7 | distribute and modify the documentation. 8 | 9 | 10 | This library is free software; you can redistribute it and/or modify 11 | it under the terms of the the 3-clause BSD License (the "License"); 12 | as published by http://www.opensource.org/licenses/BSD-3-Clause. 13 | 14 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 15 | !!! !!! 16 | !!! WARNING !!! 17 | !!! The library is not supported. !!! 18 | !!! Use CSV feature of https://github.com/fogfish/feta !!! 19 | !!! !!! 20 | !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 21 | 22 | 23 | Introduction 24 | ============ 25 | 26 | The simple CSV-file parser based on event model. The parser generates an 27 | event/callback when the CSV line is parsed. The parser supports both 28 | sequential and parallel parsing. The major goal is an performance of 29 | intake procedure with an parsing target of 3 - 4 micro seconds pr line on 30 | the reference hardware. 31 | 32 | Acc 33 | +--------+ 34 | | | 35 | V | 36 | +---------+ | 37 | ----Input---->| Parser |--------> AccN 38 | + +---------+ 39 | Acc0 | 40 | V 41 | Event Line 42 | 43 | The parser takes as input binary stream, event handler function and 44 | initial state/accumulator. Event function is evaluated agains current 45 | accumulator and parsed line of csv-file. Note: The accumaltor allows to 46 | carry-on application specific state throught event functions. 47 | 48 | Compile and build 49 | ================= 50 | 51 | The library source code is available at git repository 52 | 53 | git clone https://github.com/fogfish/pts.git 54 | 55 | Briefly, the shell command `./configure; make; make install' should 56 | configure, build, and assembly distribution package. The following 57 | instructions are specific to this package; see the `INSTALL' file for 58 | instructions specific to GNU build tools. 59 | 60 | The `configure' shell script attempts to guess dependencies and system 61 | configuration required to build library, the following build time dependencies exists: 62 | 63 | --with-erlang={prefix_to_otp} supplied to `./configure' binds the library 64 | with chosen Erlang runtime, if you have 65 | multiple Erlang environments available at 66 | build machine 67 | 68 | High performance version of library shall be build with native targets 69 | 70 | make BUILD=native 71 | 72 | Interface 73 | ========= 74 | Briefly, the sequence of operations for data parse/intake is following; 75 | see the src/csv.erl file for detailed interface specification and/or 76 | example parser at priv/csv_example.erl 77 | 78 | %% define an event funtion that takes two arguments line value and 79 | %% accumulator. The function shall return a new accumulator state. 80 | %% The structure of accumulator is an application specific, that might 81 | %% vary from integer to comprex record. 82 | Fun = fun({line, L}, #my_record{count = C} = Acc0) -> 83 | do_my_intake_to_somewhere(lists:reverse(L)), 84 | Acc0#my_record{count = C + 1} 85 | end 86 | 87 | %% 88 | %% A sequential parse, parses whole data stream in client process 89 | csv:parse(CSV, Fun, #myrecord{}) 90 | 91 | %% 92 | %% a parallel parse splits the CSV into multiple chunks; 93 | %% spawns multiple processes (process per chunk) 94 | %% results agregated in the client process. 95 | csv:parse(CSV, 20, Fun, #myrecord{}) 96 | 97 | Performance 98 | =========== 99 | 100 | Reference platform: 101 | * MacMini, Lion Server, 102 | * 1x Intel Core i7 (2 GHz), 4x cores 103 | * L2 Cache 256KB per core 104 | * L3 Cache 6MB 105 | * Memory 4GB 1333 MHZ DDR3 106 | * Disk 750GB 7200rpm WDC WD7500BTKT-40MD3T0 107 | * erlang R15B + native build of the library 108 | 109 | The data set is has following patterns: key, date, time, float numbers and 110 | zz suffix 111 | * key{1..300 000},2012-03-25,23:26:15.543,166.280,...,zz 112 | 113 | The numbers of keys is 300.000, and number of float fields varies from 8, 114 | 24 and 40 in reference data. Reference data set is generated by command 115 | 116 | make example or perl priv/gen_set.pl 300 40 > priv/set-300K-40.txt 117 | 118 | 119 | version 0.0.1 120 | 121 | E/Parse Size (MB) Read (ms) Handle (ms) Per Line (us) 122 | ------------------------------------------------------------------- 123 | 300K, 8 flds 23.41 91.722 350.000 1.16 124 | 300K, 24 flds 50.42 489.303 697.739 2.33 125 | 300K, 40 flds 77.43 780.296 946.003 3.15 126 | 127 | 128 | ET/hash Size (MB) Read (ms) Handle (ms) Per Line (us) 129 | ------------------------------------------------------------------- 130 | 300K, 8 flds 23.41 91.722 384.598 1.28 131 | 300K, 24 flds 50.42 489.303 761.414 2.54 132 | 300K, 40 flds 77.43 780.296 1047.329 3.49 133 | 134 | 135 | ET/tuple Size (MB) Read (ms) Handle (ms) Per Line (us) 136 | ------------------------------------------------------------------- 137 | 300K, 8 flds 23.41 91.722 228.306 0.76 138 | 300K, 24 flds 50.42 489.303 601.025 2.00 139 | 300K, 40 flds 77.43 780.296 984.676 3.28 140 | 141 | ETL/ets Size (MB) Read (ms) Handle (ms) Per Line (us) 142 | ------------------------------------------------------------------- 143 | 300K, 8 flds 23.41 91.722 1489.543 4.50 144 | 300K, 24 flds 50.42 489.303 2249.689 7.50 145 | 300K, 40 flds 77.43 780.296 2519.401 8.39 146 | 147 | ETL/pts Size (MB) Read (ms) Handle (ms) Per Line (us) 148 | ------------------------------------------------------------------- 149 | 300K, 8 flds 23.41 91.722 592.886 1.98 150 | 300K, 24 flds 50.42 489.303 1190.745 3.97 151 | 300K, 40 flds 77.43 780.296 1734.898 5.78 152 | 153 | 154 | -------------------------------------------------------------------------------- /aclocal.m4: -------------------------------------------------------------------------------- 1 | # generated automatically by aclocal 1.11.3 -*- Autoconf -*- 2 | 3 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 4 | # 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, 5 | # Inc. 6 | # This file is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | m4_ifndef([AC_AUTOCONF_VERSION], 16 | [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl 17 | m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.68],, 18 | [m4_warning([this file was generated for autoconf 2.68. 19 | You have another version of autoconf. It may work, but is not guaranteed to. 20 | If you have problems, you may need to regenerate the build system entirely. 21 | To do so, use the procedure documented by the package, typically `autoreconf'.])]) 22 | 23 | # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008, 2011 Free Software 24 | # Foundation, Inc. 25 | # 26 | # This file is free software; the Free Software Foundation 27 | # gives unlimited permission to copy and/or distribute it, 28 | # with or without modifications, as long as this notice is preserved. 29 | 30 | # serial 1 31 | 32 | # AM_AUTOMAKE_VERSION(VERSION) 33 | # ---------------------------- 34 | # Automake X.Y traces this macro to ensure aclocal.m4 has been 35 | # generated from the m4 files accompanying Automake X.Y. 36 | # (This private macro should not be called outside this file.) 37 | AC_DEFUN([AM_AUTOMAKE_VERSION], 38 | [am__api_version='1.11' 39 | dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to 40 | dnl require some minimum version. Point them to the right macro. 41 | m4_if([$1], [1.11.3], [], 42 | [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl 43 | ]) 44 | 45 | # _AM_AUTOCONF_VERSION(VERSION) 46 | # ----------------------------- 47 | # aclocal traces this macro to find the Autoconf version. 48 | # This is a private macro too. Using m4_define simplifies 49 | # the logic in aclocal, which can simply ignore this definition. 50 | m4_define([_AM_AUTOCONF_VERSION], []) 51 | 52 | # AM_SET_CURRENT_AUTOMAKE_VERSION 53 | # ------------------------------- 54 | # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. 55 | # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. 56 | AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], 57 | [AM_AUTOMAKE_VERSION([1.11.3])dnl 58 | m4_ifndef([AC_AUTOCONF_VERSION], 59 | [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl 60 | _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) 61 | 62 | # AM_AUX_DIR_EXPAND -*- Autoconf -*- 63 | 64 | # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. 65 | # 66 | # This file is free software; the Free Software Foundation 67 | # gives unlimited permission to copy and/or distribute it, 68 | # with or without modifications, as long as this notice is preserved. 69 | 70 | # serial 1 71 | 72 | # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets 73 | # $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to 74 | # `$srcdir', `$srcdir/..', or `$srcdir/../..'. 75 | # 76 | # Of course, Automake must honor this variable whenever it calls a 77 | # tool from the auxiliary directory. The problem is that $srcdir (and 78 | # therefore $ac_aux_dir as well) can be either absolute or relative, 79 | # depending on how configure is run. This is pretty annoying, since 80 | # it makes $ac_aux_dir quite unusable in subdirectories: in the top 81 | # source directory, any form will work fine, but in subdirectories a 82 | # relative path needs to be adjusted first. 83 | # 84 | # $ac_aux_dir/missing 85 | # fails when called from a subdirectory if $ac_aux_dir is relative 86 | # $top_srcdir/$ac_aux_dir/missing 87 | # fails if $ac_aux_dir is absolute, 88 | # fails when called from a subdirectory in a VPATH build with 89 | # a relative $ac_aux_dir 90 | # 91 | # The reason of the latter failure is that $top_srcdir and $ac_aux_dir 92 | # are both prefixed by $srcdir. In an in-source build this is usually 93 | # harmless because $srcdir is `.', but things will broke when you 94 | # start a VPATH build or use an absolute $srcdir. 95 | # 96 | # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, 97 | # iff we strip the leading $srcdir from $ac_aux_dir. That would be: 98 | # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` 99 | # and then we would define $MISSING as 100 | # MISSING="\${SHELL} $am_aux_dir/missing" 101 | # This will work as long as MISSING is not called from configure, because 102 | # unfortunately $(top_srcdir) has no meaning in configure. 103 | # However there are other variables, like CC, which are often used in 104 | # configure, and could therefore not use this "fixed" $ac_aux_dir. 105 | # 106 | # Another solution, used here, is to always expand $ac_aux_dir to an 107 | # absolute PATH. The drawback is that using absolute paths prevent a 108 | # configured tree to be moved without reconfiguration. 109 | 110 | AC_DEFUN([AM_AUX_DIR_EXPAND], 111 | [dnl Rely on autoconf to set up CDPATH properly. 112 | AC_PREREQ([2.50])dnl 113 | # expand $ac_aux_dir to an absolute path 114 | am_aux_dir=`cd $ac_aux_dir && pwd` 115 | ]) 116 | 117 | # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005 118 | # Free Software Foundation, Inc. 119 | # 120 | # This file is free software; the Free Software Foundation 121 | # gives unlimited permission to copy and/or distribute it, 122 | # with or without modifications, as long as this notice is preserved. 123 | 124 | # serial 8 125 | 126 | # AM_CONFIG_HEADER is obsolete. It has been replaced by AC_CONFIG_HEADERS. 127 | AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)]) 128 | 129 | # Do all the work for Automake. -*- Autoconf -*- 130 | 131 | # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 132 | # 2005, 2006, 2008, 2009 Free Software Foundation, Inc. 133 | # 134 | # This file is free software; the Free Software Foundation 135 | # gives unlimited permission to copy and/or distribute it, 136 | # with or without modifications, as long as this notice is preserved. 137 | 138 | # serial 16 139 | 140 | # This macro actually does too much. Some checks are only needed if 141 | # your package does certain things. But this isn't really a big deal. 142 | 143 | # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) 144 | # AM_INIT_AUTOMAKE([OPTIONS]) 145 | # ----------------------------------------------- 146 | # The call with PACKAGE and VERSION arguments is the old style 147 | # call (pre autoconf-2.50), which is being phased out. PACKAGE 148 | # and VERSION should now be passed to AC_INIT and removed from 149 | # the call to AM_INIT_AUTOMAKE. 150 | # We support both call styles for the transition. After 151 | # the next Automake release, Autoconf can make the AC_INIT 152 | # arguments mandatory, and then we can depend on a new Autoconf 153 | # release and drop the old call support. 154 | AC_DEFUN([AM_INIT_AUTOMAKE], 155 | [AC_PREREQ([2.62])dnl 156 | dnl Autoconf wants to disallow AM_ names. We explicitly allow 157 | dnl the ones we care about. 158 | m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl 159 | AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl 160 | AC_REQUIRE([AC_PROG_INSTALL])dnl 161 | if test "`cd $srcdir && pwd`" != "`pwd`"; then 162 | # Use -I$(srcdir) only when $(srcdir) != ., so that make's output 163 | # is not polluted with repeated "-I." 164 | AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl 165 | # test to see if srcdir already configured 166 | if test -f $srcdir/config.status; then 167 | AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) 168 | fi 169 | fi 170 | 171 | # test whether we have cygpath 172 | if test -z "$CYGPATH_W"; then 173 | if (cygpath --version) >/dev/null 2>/dev/null; then 174 | CYGPATH_W='cygpath -w' 175 | else 176 | CYGPATH_W=echo 177 | fi 178 | fi 179 | AC_SUBST([CYGPATH_W]) 180 | 181 | # Define the identity of the package. 182 | dnl Distinguish between old-style and new-style calls. 183 | m4_ifval([$2], 184 | [m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl 185 | AC_SUBST([PACKAGE], [$1])dnl 186 | AC_SUBST([VERSION], [$2])], 187 | [_AM_SET_OPTIONS([$1])dnl 188 | dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. 189 | m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,, 190 | [m4_fatal([AC_INIT should be called with package and version arguments])])dnl 191 | AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl 192 | AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl 193 | 194 | _AM_IF_OPTION([no-define],, 195 | [AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package]) 196 | AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl 197 | 198 | # Some tools Automake needs. 199 | AC_REQUIRE([AM_SANITY_CHECK])dnl 200 | AC_REQUIRE([AC_ARG_PROGRAM])dnl 201 | AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version}) 202 | AM_MISSING_PROG(AUTOCONF, autoconf) 203 | AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version}) 204 | AM_MISSING_PROG(AUTOHEADER, autoheader) 205 | AM_MISSING_PROG(MAKEINFO, makeinfo) 206 | AC_REQUIRE([AM_PROG_INSTALL_SH])dnl 207 | AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl 208 | AC_REQUIRE([AM_PROG_MKDIR_P])dnl 209 | # We need awk for the "check" target. The system "awk" is bad on 210 | # some platforms. 211 | AC_REQUIRE([AC_PROG_AWK])dnl 212 | AC_REQUIRE([AC_PROG_MAKE_SET])dnl 213 | AC_REQUIRE([AM_SET_LEADING_DOT])dnl 214 | _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], 215 | [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], 216 | [_AM_PROG_TAR([v7])])]) 217 | _AM_IF_OPTION([no-dependencies],, 218 | [AC_PROVIDE_IFELSE([AC_PROG_CC], 219 | [_AM_DEPENDENCIES(CC)], 220 | [define([AC_PROG_CC], 221 | defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl 222 | AC_PROVIDE_IFELSE([AC_PROG_CXX], 223 | [_AM_DEPENDENCIES(CXX)], 224 | [define([AC_PROG_CXX], 225 | defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl 226 | AC_PROVIDE_IFELSE([AC_PROG_OBJC], 227 | [_AM_DEPENDENCIES(OBJC)], 228 | [define([AC_PROG_OBJC], 229 | defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl 230 | ]) 231 | _AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl 232 | dnl The `parallel-tests' driver may need to know about EXEEXT, so add the 233 | dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro 234 | dnl is hooked onto _AC_COMPILER_EXEEXT early, see below. 235 | AC_CONFIG_COMMANDS_PRE(dnl 236 | [m4_provide_if([_AM_COMPILER_EXEEXT], 237 | [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl 238 | ]) 239 | 240 | dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not 241 | dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further 242 | dnl mangled by Autoconf and run in a shell conditional statement. 243 | m4_define([_AC_COMPILER_EXEEXT], 244 | m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) 245 | 246 | 247 | # When config.status generates a header, we must update the stamp-h file. 248 | # This file resides in the same directory as the config header 249 | # that is generated. The stamp files are numbered to have different names. 250 | 251 | # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the 252 | # loop where config.status creates the headers, so we can generate 253 | # our stamp files there. 254 | AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], 255 | [# Compute $1's index in $config_headers. 256 | _am_arg=$1 257 | _am_stamp_count=1 258 | for _am_header in $config_headers :; do 259 | case $_am_header in 260 | $_am_arg | $_am_arg:* ) 261 | break ;; 262 | * ) 263 | _am_stamp_count=`expr $_am_stamp_count + 1` ;; 264 | esac 265 | done 266 | echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) 267 | 268 | # Copyright (C) 2001, 2003, 2005, 2008, 2011 Free Software Foundation, 269 | # Inc. 270 | # 271 | # This file is free software; the Free Software Foundation 272 | # gives unlimited permission to copy and/or distribute it, 273 | # with or without modifications, as long as this notice is preserved. 274 | 275 | # serial 1 276 | 277 | # AM_PROG_INSTALL_SH 278 | # ------------------ 279 | # Define $install_sh. 280 | AC_DEFUN([AM_PROG_INSTALL_SH], 281 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl 282 | if test x"${install_sh}" != xset; then 283 | case $am_aux_dir in 284 | *\ * | *\ *) 285 | install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; 286 | *) 287 | install_sh="\${SHELL} $am_aux_dir/install-sh" 288 | esac 289 | fi 290 | AC_SUBST(install_sh)]) 291 | 292 | # Copyright (C) 2003, 2005 Free Software Foundation, Inc. 293 | # 294 | # This file is free software; the Free Software Foundation 295 | # gives unlimited permission to copy and/or distribute it, 296 | # with or without modifications, as long as this notice is preserved. 297 | 298 | # serial 2 299 | 300 | # Check whether the underlying file-system supports filenames 301 | # with a leading dot. For instance MS-DOS doesn't. 302 | AC_DEFUN([AM_SET_LEADING_DOT], 303 | [rm -rf .tst 2>/dev/null 304 | mkdir .tst 2>/dev/null 305 | if test -d .tst; then 306 | am__leading_dot=. 307 | else 308 | am__leading_dot=_ 309 | fi 310 | rmdir .tst 2>/dev/null 311 | AC_SUBST([am__leading_dot])]) 312 | 313 | # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- 314 | 315 | # Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008 316 | # Free Software Foundation, Inc. 317 | # 318 | # This file is free software; the Free Software Foundation 319 | # gives unlimited permission to copy and/or distribute it, 320 | # with or without modifications, as long as this notice is preserved. 321 | 322 | # serial 6 323 | 324 | # AM_MISSING_PROG(NAME, PROGRAM) 325 | # ------------------------------ 326 | AC_DEFUN([AM_MISSING_PROG], 327 | [AC_REQUIRE([AM_MISSING_HAS_RUN]) 328 | $1=${$1-"${am_missing_run}$2"} 329 | AC_SUBST($1)]) 330 | 331 | 332 | # AM_MISSING_HAS_RUN 333 | # ------------------ 334 | # Define MISSING if not defined so far and test if it supports --run. 335 | # If it does, set am_missing_run to use it, otherwise, to nothing. 336 | AC_DEFUN([AM_MISSING_HAS_RUN], 337 | [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl 338 | AC_REQUIRE_AUX_FILE([missing])dnl 339 | if test x"${MISSING+set}" != xset; then 340 | case $am_aux_dir in 341 | *\ * | *\ *) 342 | MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; 343 | *) 344 | MISSING="\${SHELL} $am_aux_dir/missing" ;; 345 | esac 346 | fi 347 | # Use eval to expand $SHELL 348 | if eval "$MISSING --run true"; then 349 | am_missing_run="$MISSING --run " 350 | else 351 | am_missing_run= 352 | AC_MSG_WARN([`missing' script is too old or missing]) 353 | fi 354 | ]) 355 | 356 | # Copyright (C) 2003, 2004, 2005, 2006, 2011 Free Software Foundation, 357 | # Inc. 358 | # 359 | # This file is free software; the Free Software Foundation 360 | # gives unlimited permission to copy and/or distribute it, 361 | # with or without modifications, as long as this notice is preserved. 362 | 363 | # serial 1 364 | 365 | # AM_PROG_MKDIR_P 366 | # --------------- 367 | # Check for `mkdir -p'. 368 | AC_DEFUN([AM_PROG_MKDIR_P], 369 | [AC_PREREQ([2.60])dnl 370 | AC_REQUIRE([AC_PROG_MKDIR_P])dnl 371 | dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P, 372 | dnl while keeping a definition of mkdir_p for backward compatibility. 373 | dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile. 374 | dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of 375 | dnl Makefile.ins that do not define MKDIR_P, so we do our own 376 | dnl adjustment using top_builddir (which is defined more often than 377 | dnl MKDIR_P). 378 | AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl 379 | case $mkdir_p in 380 | [[\\/$]]* | ?:[[\\/]]*) ;; 381 | */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;; 382 | esac 383 | ]) 384 | 385 | # Helper functions for option handling. -*- Autoconf -*- 386 | 387 | # Copyright (C) 2001, 2002, 2003, 2005, 2008, 2010 Free Software 388 | # Foundation, Inc. 389 | # 390 | # This file is free software; the Free Software Foundation 391 | # gives unlimited permission to copy and/or distribute it, 392 | # with or without modifications, as long as this notice is preserved. 393 | 394 | # serial 5 395 | 396 | # _AM_MANGLE_OPTION(NAME) 397 | # ----------------------- 398 | AC_DEFUN([_AM_MANGLE_OPTION], 399 | [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) 400 | 401 | # _AM_SET_OPTION(NAME) 402 | # -------------------- 403 | # Set option NAME. Presently that only means defining a flag for this option. 404 | AC_DEFUN([_AM_SET_OPTION], 405 | [m4_define(_AM_MANGLE_OPTION([$1]), 1)]) 406 | 407 | # _AM_SET_OPTIONS(OPTIONS) 408 | # ------------------------ 409 | # OPTIONS is a space-separated list of Automake options. 410 | AC_DEFUN([_AM_SET_OPTIONS], 411 | [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) 412 | 413 | # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) 414 | # ------------------------------------------- 415 | # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. 416 | AC_DEFUN([_AM_IF_OPTION], 417 | [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) 418 | 419 | # Check to make sure that the build environment is sane. -*- Autoconf -*- 420 | 421 | # Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008 422 | # Free Software Foundation, Inc. 423 | # 424 | # This file is free software; the Free Software Foundation 425 | # gives unlimited permission to copy and/or distribute it, 426 | # with or without modifications, as long as this notice is preserved. 427 | 428 | # serial 5 429 | 430 | # AM_SANITY_CHECK 431 | # --------------- 432 | AC_DEFUN([AM_SANITY_CHECK], 433 | [AC_MSG_CHECKING([whether build environment is sane]) 434 | # Just in case 435 | sleep 1 436 | echo timestamp > conftest.file 437 | # Reject unsafe characters in $srcdir or the absolute working directory 438 | # name. Accept space and tab only in the latter. 439 | am_lf=' 440 | ' 441 | case `pwd` in 442 | *[[\\\"\#\$\&\'\`$am_lf]]*) 443 | AC_MSG_ERROR([unsafe absolute working directory name]);; 444 | esac 445 | case $srcdir in 446 | *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) 447 | AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);; 448 | esac 449 | 450 | # Do `set' in a subshell so we don't clobber the current shell's 451 | # arguments. Must try -L first in case configure is actually a 452 | # symlink; some systems play weird games with the mod time of symlinks 453 | # (eg FreeBSD returns the mod time of the symlink's containing 454 | # directory). 455 | if ( 456 | set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` 457 | if test "$[*]" = "X"; then 458 | # -L didn't work. 459 | set X `ls -t "$srcdir/configure" conftest.file` 460 | fi 461 | rm -f conftest.file 462 | if test "$[*]" != "X $srcdir/configure conftest.file" \ 463 | && test "$[*]" != "X conftest.file $srcdir/configure"; then 464 | 465 | # If neither matched, then we have a broken ls. This can happen 466 | # if, for instance, CONFIG_SHELL is bash and it inherits a 467 | # broken ls alias from the environment. This has actually 468 | # happened. Such a system could not be considered "sane". 469 | AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken 470 | alias in your environment]) 471 | fi 472 | 473 | test "$[2]" = conftest.file 474 | ) 475 | then 476 | # Ok. 477 | : 478 | else 479 | AC_MSG_ERROR([newly created file is older than distributed files! 480 | Check your system clock]) 481 | fi 482 | AC_MSG_RESULT(yes)]) 483 | 484 | # Copyright (C) 2009, 2011 Free Software Foundation, Inc. 485 | # 486 | # This file is free software; the Free Software Foundation 487 | # gives unlimited permission to copy and/or distribute it, 488 | # with or without modifications, as long as this notice is preserved. 489 | 490 | # serial 2 491 | 492 | # AM_SILENT_RULES([DEFAULT]) 493 | # -------------------------- 494 | # Enable less verbose build rules; with the default set to DEFAULT 495 | # (`yes' being less verbose, `no' or empty being verbose). 496 | AC_DEFUN([AM_SILENT_RULES], 497 | [AC_ARG_ENABLE([silent-rules], 498 | [ --enable-silent-rules less verbose build output (undo: `make V=1') 499 | --disable-silent-rules verbose build output (undo: `make V=0')]) 500 | case $enable_silent_rules in 501 | yes) AM_DEFAULT_VERBOSITY=0;; 502 | no) AM_DEFAULT_VERBOSITY=1;; 503 | *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; 504 | esac 505 | dnl 506 | dnl A few `make' implementations (e.g., NonStop OS and NextStep) 507 | dnl do not support nested variable expansions. 508 | dnl See automake bug#9928 and bug#10237. 509 | am_make=${MAKE-make} 510 | AC_CACHE_CHECK([whether $am_make supports nested variables], 511 | [am_cv_make_support_nested_variables], 512 | [if AS_ECHO([['TRUE=$(BAR$(V)) 513 | BAR0=false 514 | BAR1=true 515 | V=1 516 | am__doit: 517 | @$(TRUE) 518 | .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then 519 | am_cv_make_support_nested_variables=yes 520 | else 521 | am_cv_make_support_nested_variables=no 522 | fi]) 523 | if test $am_cv_make_support_nested_variables = yes; then 524 | dnl Using `$V' instead of `$(V)' breaks IRIX make. 525 | AM_V='$(V)' 526 | AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' 527 | else 528 | AM_V=$AM_DEFAULT_VERBOSITY 529 | AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY 530 | fi 531 | AC_SUBST([AM_V])dnl 532 | AM_SUBST_NOTMAKE([AM_V])dnl 533 | AC_SUBST([AM_DEFAULT_V])dnl 534 | AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl 535 | AC_SUBST([AM_DEFAULT_VERBOSITY])dnl 536 | AM_BACKSLASH='\' 537 | AC_SUBST([AM_BACKSLASH])dnl 538 | _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl 539 | ]) 540 | 541 | # Copyright (C) 2001, 2003, 2005, 2011 Free Software Foundation, Inc. 542 | # 543 | # This file is free software; the Free Software Foundation 544 | # gives unlimited permission to copy and/or distribute it, 545 | # with or without modifications, as long as this notice is preserved. 546 | 547 | # serial 1 548 | 549 | # AM_PROG_INSTALL_STRIP 550 | # --------------------- 551 | # One issue with vendor `install' (even GNU) is that you can't 552 | # specify the program used to strip binaries. This is especially 553 | # annoying in cross-compiling environments, where the build's strip 554 | # is unlikely to handle the host's binaries. 555 | # Fortunately install-sh will honor a STRIPPROG variable, so we 556 | # always use install-sh in `make install-strip', and initialize 557 | # STRIPPROG with the value of the STRIP variable (set by the user). 558 | AC_DEFUN([AM_PROG_INSTALL_STRIP], 559 | [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl 560 | # Installed binaries are usually stripped using `strip' when the user 561 | # run `make install-strip'. However `strip' might not be the right 562 | # tool to use in cross-compilation environments, therefore Automake 563 | # will honor the `STRIP' environment variable to overrule this program. 564 | dnl Don't test for $cross_compiling = yes, because it might be `maybe'. 565 | if test "$cross_compiling" != no; then 566 | AC_CHECK_TOOL([STRIP], [strip], :) 567 | fi 568 | INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" 569 | AC_SUBST([INSTALL_STRIP_PROGRAM])]) 570 | 571 | # Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. 572 | # 573 | # This file is free software; the Free Software Foundation 574 | # gives unlimited permission to copy and/or distribute it, 575 | # with or without modifications, as long as this notice is preserved. 576 | 577 | # serial 3 578 | 579 | # _AM_SUBST_NOTMAKE(VARIABLE) 580 | # --------------------------- 581 | # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. 582 | # This macro is traced by Automake. 583 | AC_DEFUN([_AM_SUBST_NOTMAKE]) 584 | 585 | # AM_SUBST_NOTMAKE(VARIABLE) 586 | # -------------------------- 587 | # Public sister of _AM_SUBST_NOTMAKE. 588 | AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) 589 | 590 | # Check how to create a tarball. -*- Autoconf -*- 591 | 592 | # Copyright (C) 2004, 2005, 2012 Free Software Foundation, Inc. 593 | # 594 | # This file is free software; the Free Software Foundation 595 | # gives unlimited permission to copy and/or distribute it, 596 | # with or without modifications, as long as this notice is preserved. 597 | 598 | # serial 2 599 | 600 | # _AM_PROG_TAR(FORMAT) 601 | # -------------------- 602 | # Check how to create a tarball in format FORMAT. 603 | # FORMAT should be one of `v7', `ustar', or `pax'. 604 | # 605 | # Substitute a variable $(am__tar) that is a command 606 | # writing to stdout a FORMAT-tarball containing the directory 607 | # $tardir. 608 | # tardir=directory && $(am__tar) > result.tar 609 | # 610 | # Substitute a variable $(am__untar) that extract such 611 | # a tarball read from stdin. 612 | # $(am__untar) < result.tar 613 | AC_DEFUN([_AM_PROG_TAR], 614 | [# Always define AMTAR for backward compatibility. Yes, it's still used 615 | # in the wild :-( We should find a proper way to deprecate it ... 616 | AC_SUBST([AMTAR], ['$${TAR-tar}']) 617 | m4_if([$1], [v7], 618 | [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], 619 | [m4_case([$1], [ustar],, [pax],, 620 | [m4_fatal([Unknown tar format])]) 621 | AC_MSG_CHECKING([how to create a $1 tar archive]) 622 | # Loop over all known methods to create a tar archive until one works. 623 | _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' 624 | _am_tools=${am_cv_prog_tar_$1-$_am_tools} 625 | # Do not fold the above two line into one, because Tru64 sh and 626 | # Solaris sh will not grok spaces in the rhs of `-'. 627 | for _am_tool in $_am_tools 628 | do 629 | case $_am_tool in 630 | gnutar) 631 | for _am_tar in tar gnutar gtar; 632 | do 633 | AM_RUN_LOG([$_am_tar --version]) && break 634 | done 635 | am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' 636 | am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' 637 | am__untar="$_am_tar -xf -" 638 | ;; 639 | plaintar) 640 | # Must skip GNU tar: if it does not support --format= it doesn't create 641 | # ustar tarball either. 642 | (tar --version) >/dev/null 2>&1 && continue 643 | am__tar='tar chf - "$$tardir"' 644 | am__tar_='tar chf - "$tardir"' 645 | am__untar='tar xf -' 646 | ;; 647 | pax) 648 | am__tar='pax -L -x $1 -w "$$tardir"' 649 | am__tar_='pax -L -x $1 -w "$tardir"' 650 | am__untar='pax -r' 651 | ;; 652 | cpio) 653 | am__tar='find "$$tardir" -print | cpio -o -H $1 -L' 654 | am__tar_='find "$tardir" -print | cpio -o -H $1 -L' 655 | am__untar='cpio -i -H $1 -d' 656 | ;; 657 | none) 658 | am__tar=false 659 | am__tar_=false 660 | am__untar=false 661 | ;; 662 | esac 663 | 664 | # If the value was cached, stop now. We just wanted to have am__tar 665 | # and am__untar set. 666 | test -n "${am_cv_prog_tar_$1}" && break 667 | 668 | # tar/untar a dummy directory, and stop if the command works 669 | rm -rf conftest.dir 670 | mkdir conftest.dir 671 | echo GrepMe > conftest.dir/file 672 | AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) 673 | rm -rf conftest.dir 674 | if test -s conftest.tar; then 675 | AM_RUN_LOG([$am__untar /dev/null 2>&1 && break 677 | fi 678 | done 679 | rm -rf conftest.dir 680 | 681 | AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) 682 | AC_MSG_RESULT([$am_cv_prog_tar_$1])]) 683 | AC_SUBST([am__tar]) 684 | AC_SUBST([am__untar]) 685 | ]) # _AM_PROG_TAR 686 | 687 | dnl @synopsis AX_CHECK_ERLANG_LIB(lib, [,action-if-found], [,action-if-not-found]) 688 | dnl 689 | dnl @category erlang 690 | dnl @author Mobilana 691 | dnl @version: 0.9 692 | dnl @license AllPermissive 693 | dnl 694 | AC_DEFUN([ACX_CHECK_ERLANG_LIB],[ 695 | m4_pushdef([LIB], $1) 696 | AC_MSG_CHECKING([for Erlang $1]) 697 | 698 | AC_LANG_PUSH(Erlang) 699 | AC_RUN_IFELSE( 700 | [AC_LANG_PROGRAM([],[ 701 | case code:lib_dir("[$1]") of 702 | {error, bad_name} -> 703 | halt(1); 704 | Lib -> 705 | Root = code:lib_dir(), 706 | Name = string:sub_string(Lib, length(Root) + 2), 707 | file:write_file("conftest.out", Name), 708 | halt(0) 709 | end] 710 | )], 711 | [ 712 | dnl erlang lib is found 713 | libpath=`cat conftest.out` 714 | have_[]LIB[]="yes" 715 | AC_SUBST(have_[]LIB[]) 716 | dnl check is the application or library 717 | if [[ -f $liberldir/$libpath/ebin/$1.app ]]; then 718 | ERLANG_APPS="$ERLANG_APPS $libpath" 719 | AC_SUBST(ERLANG_APPS) 720 | else 721 | ERLANG_LIBS="$ERLANG_LIBS $libpath" 722 | AC_SUBST(ERLANG_LIBS) 723 | fi 724 | rm -f conftest.out 725 | 726 | dnl check is this is an application or library 727 | dnl AC_RUN_IFELSE( 728 | dnl [AC_LANG_PROGRAM([], [ 729 | dnl Start = fun(A, S) -> 730 | dnl case application:start(A) of 731 | dnl ok -> true; 732 | dnl {error, {already_started, _}} -> true; 733 | dnl {error, {not_started, D}} -> 734 | dnl case S(D,S) of 735 | dnl true -> S(A,S); 736 | dnl false -> false 737 | dnl end; 738 | dnl _ -> false 739 | dnl end 740 | dnl end, 741 | dnl case Start([$1], Start) of 742 | dnl true -> halt(0); 743 | dnl false -> halt(1) 744 | dnl end] 745 | dnl )], 746 | dnl [ 747 | dnl dnl this is an application 748 | dnl ERLANG_APPS="$ERLANG_APPS $libpath" 749 | dnl AC_SUBST(ERLANG_APPS) 750 | dnl ], 751 | dnl [ 752 | dnl dnl this is an library 753 | dnl ERLANG_LIBS="$ERLANG_LIBS $libpath" 754 | dnl AC_SUBST(ERLANG_LIBS) 755 | dnl ] 756 | dnl ) 757 | AC_MSG_RESULT([yes]) 758 | ifelse([$2], , :, [$2]) 759 | ], 760 | [ 761 | dnl erlang lib is not found 762 | have_[]LIB[]="no" 763 | rm -f conftest.out 764 | AC_MSG_RESULT([no]) 765 | ifelse([$2], , AC_ERROR($1 not found), [$3]) 766 | ] 767 | ) 768 | AC_LANG_POP(Erlang) 769 | m4_popdef([LIB]) 770 | ]) 771 | 772 | dnl @synopsis ACX_CHECK_PROG(prog, [,progs list] [, action-if-found] [, action if-not-found]) 773 | dnl 774 | dnl Defines Makefile variable with name prog in upper case 775 | dnl Checks presence of program and its alternatives in PATH environment 776 | dnl The defined variable is set to absolute path of found program 777 | dnl 778 | dnl ACX_CHECK_PROG([javac], [gcj jikes guavac]) 779 | dnl defines JAVAC variable and set path to found program 780 | dnl 781 | dnl @depends on AC_PATH_PROGS 782 | dnl 783 | dnl @category common 784 | dnl @author Mobilana 785 | dnl @version: 0.9 786 | dnl @license AllPermissive 787 | dnl 788 | AC_DEFUN([ACX_CHECK_PROG],[ 789 | m4_pushdef([PROG], translit([$1], `0-9a-z-', `0-9A-Z_')) 790 | 791 | AC_PATH_PROGS([]PROG[], $1 $2, []) 792 | if test "x$[]PROG[]" == "x" ; then 793 | ifelse([$4], , :, [$4]) 794 | else 795 | ifelse([$3], , :, [$3]) 796 | fi 797 | m4_popdef([PROG]) 798 | ]) 799 | 800 | dnl @synopsis ACX_DEFINE_DIR(dir, parent [,subpath]) 801 | dnl 802 | dnl Defines new automake dir target 803 | dnl Sets its value to expanded parent dir 804 | dnl Allows to define dir target from ./configure commandline 805 | dnl Summarize defined dir at end of configuration 806 | dnl 807 | dnl e.g. ACX_DEFINE_DIR(target, $libdir, [/test]) 808 | dnl defines target=$libdir/test, where $libdir is expanded to its absolute path 809 | dnl 810 | dnl @category common 811 | dnl @author Mobilana 812 | dnl @version: 0.9 813 | dnl @license AllPermissive 814 | dnl 815 | AC_DEFUN([ACX_DEFINE_DIR],[ 816 | m4_pushdef([DIR], [$1]) 817 | AC_MSG_CHECKING([for $1]) 818 | 819 | AC_ARG_VAR([]DIR[], [folder $3: $4]) 820 | if test -z $[]DIR[] ; then 821 | __dd__=$2 822 | dnl expand variable (remove ${prefix}) 823 | while [ expr "$__dd__" : ".*}.*" >/dev/null ]; do 824 | __dd__=`eval echo $__dd__` 825 | done 826 | []DIR[]=$__dd__/$3 827 | fi 828 | AC_SUBST([]DIR[]) 829 | AC_MSG_RESULT($[]DIR[]) 830 | __report_dirs__="$__report_dirs__ 831 | []DIR[]:\t $[]DIR[]" 832 | 833 | m4_popdef([DIR]) 834 | ]) 835 | 836 | dnl @synopsis AMX_DONE 837 | dnl 838 | dnl Finalizes configuration. 839 | dnl Summarize defined dirs and features 840 | dnl 841 | dnl @category common 842 | dnl @author Mobilana 843 | dnl @version: 0.9 844 | dnl @license AllPermissive 845 | dnl 846 | dnl 847 | AC_DEFUN([ACX_DONE], [ 848 | 849 | ACX_SECTION([Config is done!]) 850 | echo "----------------------------------------------------------------" 851 | if ! test -z "$__report_dirs__" ; then 852 | echo "$__report_dirs__" 853 | fi 854 | if ! test -z "$__report_features__" ; then 855 | echo "\n Features:\n$__report_features__" 856 | fi 857 | if ! test -z "$1" ; then 858 | echo " $1\n" 859 | fi 860 | echo "\t\t\t\t -- $PACKAGE_BUGREPORT" 861 | echo "----------------------------------------------------------------" 862 | 863 | ]) 864 | 865 | dnl @synopsis ACX_ERLANG 866 | dnl 867 | dnl Setup Erlang development 868 | dnl 869 | dnl @category erlang 870 | dnl @author Mobilana 871 | dnl @version: 0.9 872 | dnl @license AllPermissive 873 | dnl 874 | AC_DEFUN([ACX_ERLANG],[ 875 | ACX_PREFIX 876 | 877 | ACX_SECTION([Erlang development runtime]) 878 | AC_ARG_WITH(erlang, [ --with-erlang=PREFIX path to erlang runtime]) 879 | 880 | if test -f conf2lib ; then 881 | CONF2LIB="\$(top_builddir)/conf2lib" 882 | else 883 | ACX_CHECK_PROG([conf2lib]) 884 | cp $CONF2LIB conf2lib 885 | chmod 777 conf2lib 886 | CONF2LIB="\$(top_builddir)/conf2lib" 887 | fi 888 | AC_SUBST(CONF2LIB) 889 | 890 | erlang_path=$with_erlang:$with_erlang/bin:$PATH 891 | AC_PATH_PROG([ERLC], [erlc], [], [$erlang_path]) 892 | AC_PATH_PROG([ERL], [erl], [], [$erlang_path]) 893 | 894 | if test "x$ERLC" == "x" ; then 895 | AC_ERROR("Erlang runtime not found.") 896 | fi 897 | if test "x$ERL" == "x" ; then 898 | AC_ERROR("Erlang runtime not found.") 899 | fi 900 | 901 | AC_MSG_CHECKING([Erlang lib path]) 902 | liberlroot=`$ERL -noshell -eval 'io:format("~s", [[code:lib_dir()]]),halt(0)'` 903 | if [[ "$?" -ne 0 ]] ; then 904 | AC_ERROR("Unable to resolve path.") 905 | fi 906 | AC_MSG_RESULT([$liberlroot]) 907 | 908 | ACX_DEFINE_DIR([liberldir], $liberlroot, []) 909 | ACX_DEFINE_DIR([pkgliberldir], $liberlroot, [$PACKAGE]-[$VERSION]) 910 | 911 | 912 | ACX_CHECK_ERLANG_LIB([erts]) 913 | ACX_CHECK_ERLANG_LIB([kernel]) 914 | ACX_CHECK_ERLANG_LIB([stdlib]) 915 | 916 | ACX_SILENT_V([ERL]) 917 | 918 | AMX_ERLANG 919 | ACX_INIT_SCRIPT 920 | ACX_EUNIT 921 | ]) 922 | 923 | dnl @synopsis ACX_EUNIT 924 | dnl 925 | dnl Integrates EUNIT with GNU Make test framework 926 | dnl 927 | dnl 928 | dnl @category erlang 929 | dnl @author Mobilana 930 | dnl @version 0.9 931 | dnl @license AllPermissive 932 | dnl 933 | AC_DEFUN([ACX_EUNIT],[ 934 | printf " 935 | 936 | TEST=\`basename \$\x31\` 937 | FILE=\${TEST\x25.*} 938 | $ERLC \$\x31 && \ 939 | $ERL -sname eunit@localhost -pa ../../*/ebin \\ 940 | -eval \"R = case eunit:test(\$FILE, [[verbose]]) of ok -> 0; _ -> 1 end, timer:apply_after(100, erlang, halt, [[R]]).\" 941 | RET=\$\x3F 942 | rm \$FILE.beam 943 | exit \$RET 944 | 945 | " > eunit 946 | chmod u+x eunit 947 | ]) 948 | 949 | dnl @synopsis ACX_INIT_GNUWEB 950 | dnl 951 | dnl Initializes GNU WEB 952 | dnl 953 | dnl @category common 954 | dnl @author Mobilana 955 | dnl @version 0.9 956 | dnl @license AllPermissive 957 | dnl 958 | AC_DEFUN([ACX_INIT_GNUWEB],[ 959 | printf "# automatically generated by Gnu Web\n" > Makefile.gnuweb 960 | MAKE_GNUWEB="include \$(top_builddir)/Makefile.gnuweb" 961 | AC_SUBST(MAKE_GNUWEB) 962 | 963 | AMX_COMMON 964 | 965 | ]) 966 | 967 | dnl @synopsis ACX_INIT_SCRIPT 968 | dnl 969 | dnl Generates a INIT SCRIPT file 970 | dnl 971 | dnl 972 | dnl @category erlang 973 | dnl @author Mobilana 974 | dnl @version 0.9 975 | dnl @license AllPermissive 976 | dnl 977 | AC_DEFUN([ACX_INIT_SCRIPT],[ 978 | printf " 979 | ROOT=\`pwd\` 980 | ERTS=\`ls \$ROOT | grep erts\` 981 | ERL=\$ROOT/\$ERTS/bin/erl 982 | RUN=\$ROOT/\$ERTS/bin/run_erl 983 | CON=\$ROOT/\$ERTS/bin/to_erl 984 | sed s,\x25FINAL_ROOTDIR\x25,\$ROOT, \$ROOT/\$ERTS/bin/erl.src > \$ROOT/\$ERTS/bin/erl 985 | 986 | LOGDIR=\$ROOT/var/log 987 | test -d \$LOGDIR || mkdir -p \$LOGDIR 988 | 989 | RUNDIR=\$ROOT/var/run 990 | test -d \$RUNDIR || mkdir -p \$RUNDIR 991 | 992 | NODE=\`ls releases/*.rel | sed -n \"s,releases/\\(.*\\)\\.rel,\x5c\x31,p\"\` 993 | LIVE=\`echo \'erlang:now().\' | \$CON \$RUNDIR/ 2>/dev/null \&\& echo live\` 994 | 995 | case \"\$\x31\" in 996 | start) 997 | if [[ \"x\$LIVE\" == \"xlive\" ]]; then 998 | echo \"Node \$NODE is already running\" 999 | else 1000 | \$RUN -daemon \$RUNDIR/ \$LOGDIR/ \ 1001 | \"\$ERL -sname \$NODE \ 1002 | -boot \$ROOT/releases/@VSN@/start \ 1003 | -config \$ROOT/releases/@VSN@/sys\" 1004 | echo \"Node \$NODE is started\" 1005 | fi 1006 | ;; 1007 | 1008 | stop) 1009 | if [[ \"x\$LIVE\" == \"xlive\" ]]; then 1010 | echo \'q().\' | \$CON \$RUNDIR/ 2>/dev/null 1011 | echo \"Node \$NODE is terminated.\" 1012 | else 1013 | echo \"Node \$NODE is not alive\" 1014 | fi 1015 | ;; 1016 | 1017 | attach) 1018 | if [[ \"x\$LIVE\" == \"xlive\" ]]; then 1019 | exec \$CON \$RUNDIR/ 1020 | else 1021 | echo \"Node \$NODE is not alive\" 1022 | fi 1023 | ;; 1024 | 1025 | *) 1026 | SCRIPT=\`basename \$\x30\` 1027 | echo \"Usage: \$SCRIPT {start|stop|attach}\" 1028 | exit 1 1029 | ;; 1030 | esac 1031 | exit 0 1032 | 1033 | " > init.erlang 1034 | 1035 | 1036 | ]) 1037 | 1038 | dnl @synopsis AC_PREFIX 1039 | dnl 1040 | dnl Expands $prefix to $ac_default prefix 1041 | dnl 1042 | dnl @category common 1043 | dnl @author Mobilana 1044 | dnl @version: 0.9 1045 | dnl @license AllPermissive 1046 | dnl 1047 | AC_DEFUN([ACX_PREFIX],[ 1048 | test "$prefix" = "NONE" && prefix=${ac_default_prefix} 1049 | test "$exec_prefix" = "NONE" && exec_prefix=$prefix 1050 | ]) 1051 | 1052 | dnl @synopsis AMX_SECTION(title) 1053 | dnl 1054 | dnl Prints name of configuration section 1055 | dnl 1056 | dnl @category common 1057 | dnl @author Mobilana 1058 | dnl @version 0.9 1059 | dnl @license AllPermissive 1060 | dnl 1061 | AC_DEFUN([ACX_SECTION],[ 1062 | AC_MSG_RESULT() 1063 | AC_MSG_RESULT([$1]) 1064 | ]) 1065 | 1066 | dnl @synopsis ACX_SILENT_V 1067 | dnl 1068 | dnl helper macro to device silencer 1069 | dnl 1070 | dnl @depend 1071 | dnl @category common 1072 | dnl @author Mobilana 1073 | dnl @version: 0.9 1074 | dnl @license AllPermissive 1075 | dnl 1076 | AC_DEFUN([ACX_SILENT_V],[ 1077 | m4_pushdef([T], $1) 1078 | dnl TODO: fix an issue if silent rule is not enabled 1079 | [AM_V_][]T[]='$(am__v_[]T[]_$(V))' 1080 | am__v_[]T[]_='$(am__v_[]T[]_$(AM_DEFAULT_VERBOSITY))' 1081 | am__v_[]T[]_0='@echo " []T[] [\t]" $[@]$$[@];' 1082 | AC_SUBST([AM_V_][]T[]) 1083 | AC_SUBST(am__v_[]T[]_) 1084 | AC_SUBST(am__v_[]T[]_0) 1085 | m4_popdef([T]) 1086 | ]) 1087 | 1088 | dnl @synopsis AMX_COMMON 1089 | dnl 1090 | dnl Creates common rule 1091 | dnl 1092 | dnl @depends AX_ADD_AM_MACRO 1093 | dnl @category common 1094 | dnl @author Mobilana 1095 | dnl @version: 0.9 1096 | dnl @license AllPermissive 1097 | dnl 1098 | AC_DEFUN([AMX_COMMON],[ 1099 | ACX_SILENT_V([TAR]) 1100 | 1101 | printf " 1102 | CONFED = \\ 1103 | -e 's|@prefix[@]|\$(prefix)|g' \\ 1104 | -e 's|@bindir[@]|\$(bindir)|g' \\ 1105 | -e 's|@libdir[@]|\$(libdir)|g' \\ 1106 | -e 's|@datadir[@]|\$(datadir)|g' \\ 1107 | -e 's|@sysconfdir[@]|\$(sysconfdir)|g' \\ 1108 | -e 's|@pkgdatadir[@]|\$(pkgdatadir)|g' \\ 1109 | -e 's|@pkglibdir[@]|\$(pkglibdir)|g' \\ 1110 | -e 's|@PACKAGE[@]|\$(PACKAGE)|g' \\ 1111 | -e 's|@VERSION[@]|\$(VERSION)|g' 1112 | 1113 | tarball: \$(distdir).build.tgz 1114 | 1115 | \$(distdir).build.tgz: 1116 | \$(AM_V_TAR)rm -f -R /tmp/make/\$(distdir) 1117 | @\$(MAKE) install DESTDIR=/tmp/make/\$(distdir) > /dev/null 1118 | @cd /tmp/make/\$(distdir);tar --no-recursion -czvf \$(distdir).build.tgz \`find . -type f -print\` > /dev/null 1119 | @mv /tmp/make/\$(distdir)/\$(distdir).build.tgz \$(top_builddir) 1120 | @rm -f -R /tmp/make/\$(distdir) 1121 | 1122 | " >> Makefile.gnuweb 1123 | ]) 1124 | 1125 | dnl @synopsis AMX_ERLANG 1126 | dnl 1127 | dnl Inject Erlang processing rules to Makefile.gnuweb 1128 | dnl 1129 | dnl @category php 1130 | dnl @author Mobilana 1131 | dnl @version 0.9 1132 | dnl @license AllPermissive 1133 | dnl 1134 | AC_DEFUN([AMX_ERLANG], [ 1135 | 1136 | printf " 1137 | 1138 | ifndef CONFED 1139 | CONFED = 1140 | endif 1141 | 1142 | CONFED += \\ 1143 | -e 's|@liberldir[@]|\$(liberldir)|g' \\ 1144 | -e 's|@pkgliberldir[@]|\$(pkgliberldir)|g' 1145 | 1146 | ifndef ERL_CFLAGS 1147 | ERL_CFLAGS = 1148 | endif 1149 | 1150 | ifeq (\$(BUILD),native) 1151 | ERL_CFLAGS += +native 1152 | endif 1153 | 1154 | ifeq (\$(BUILD),debug) 1155 | ERL_CFLAGS += +debug_info -DDEBUG 1156 | endif 1157 | 1158 | ERL_PATH = -pa ../*/ebin -pa ./*/ebin 1159 | 1160 | ebin/%%.beam : src/%%.erl 1161 | \$(AM_V_ERL)test -d ebin || mkdir ebin; \$(ERLC) \$(ERL_CFLAGS) -I ./include -b beam -o ebin \$< 1162 | 1163 | priv/%%.beam : priv/%%.erl 1164 | \$(AM_V_ERL)\$(ERLC) \$(ERL_CFLAGS) -I ./include -b beam -o priv \$< 1165 | 1166 | ebin/%%.config : src/%%.config.in 1167 | \$(AM_V_ERL)cat \x24^ | sed \$(CONFED) > \x24@ 1168 | 1169 | ebin/%%.rel: ebin/%%.app 1170 | \$(AM_V_ERL)n=\`echo \$< | sed -n -e 's|ebin/\\(.*\\)\\.app|\x5c1|p'\` ; \\ 1171 | \$(ERL) \$(ERL_PATH) -eval \"{ok,[[{_,_,L}]]}=file:consult(\x5c\"\x24^\x5c\"), file:write_file(\x5c\"app.out\x5c\", [[ atom_to_list(X) ++ \x5c\" \x5c\" || X <- proplists:get_value(applications, L) ]]), timer:apply_after(100, erlang, halt, [[0]]).\" > /dev/null ; \\ 1172 | for l in \`cat app.out\` ; do \\ 1173 | \$(ERL) \$(ERL_PATH) -eval \"{ok,[[{_,_,L}]]}=file:consult(code:lib_dir(\x5c\"\x24\x24l\x5c\") ++ \x5c\"/ebin/\x24\x24l.app\x5c\"), file:write_file(\x5c\"vsn.out\x5c\", list_to_binary(proplists:get_value(vsn, L, \x5c\"\x5c\"))), timer:apply_after(100, erlang, halt, [[0]]).\" > /dev/null ; \\ 1174 | v=\`cat vsn.out\`; \\ 1175 | e=\"\x24\x24e \x24\x24l-\x24\x24v\"; \\ 1176 | rm vsn.out ; \\ 1177 | done ; rm app.out ; \\ 1178 | d=\`echo \"\$(ERLANG_LIBS) \x24\x24e\" | sed 's| \\([[a-zA-Z]]\\)| -U \x5c1|g'\`; \\ 1179 | \$(CONF2LIB) -r erel -l \x24\x24n -o \x24@ -U \x24\x24d \$(top_builddir)/config.h 1180 | 1181 | ebin/%%.boot: ebin/%%.rel 1182 | \$(AM_V_ERL)\$(ERLC) -pa ./ebin -pa ./*/ebin -o ebin \$^ 1183 | 1184 | ebin/%%.tar.gz: ebin/%%.boot 1185 | \$(AM_V_ERL)n=\`echo \$< | sed -n -e 's|ebin/\\(.*\\).boot|\"ebin/\x5c1\"|p'\` ; \ 1186 | \$(ERL) -noshell -pa ./ebin -eval \"systools:make_tar(\x24\x24n, [[{dirs, [src]}, {erts, code:root_dir()}]]),halt(0)\" > /dev/null ; 1187 | 1188 | %%.\$(VERSION).tgz: ebin/%%.tar.gz ebin/sys.config .force 1189 | \$(AM_V_ERL)n=\`echo \$< | sed -n -e 's|ebin/\\(.*\\).tar.gz|\x5c1|p'\` ; \\ 1190 | mkdir -p /tmp/rel/bin ; \\ 1191 | tar -C /tmp/rel -xf \x24< ; \\ 1192 | cp \$(top_builddir)/init.erlang /tmp/rel/bin/init ; \\ 1193 | chmod ugo+x /tmp/rel/bin/init ; \\ 1194 | cp ebin/sys.config /tmp/rel/releases/\$(VERSION)/sys.config ; \\ 1195 | tar -C /tmp/rel -czpf \x24@ \`ls /tmp/rel\` ; \\ 1196 | rm -R /tmp/rel 1197 | 1198 | debug: 1199 | \$(MAKE) BUILD=debug 1200 | 1201 | run: 1202 | \$(ERL) -pa ./ebin -pa ../*/ebin -pa ./priv -pa ../*/priv 1203 | 1204 | .force: 1205 | 1206 | ifndef nobase_pkgliberl_SCRIPTS 1207 | nobase_pkgliberl_SCRIPTS = 1208 | endif 1209 | 1210 | define rules_BEAM 1211 | \$(1)_BEAM=\$(subst .in,,\$(addprefix ebin/, \$(notdir \$(\$(1)_SRC:.erl=.beam)))) 1212 | nobase_pkgliberl_SCRIPTS += \$(\$(1)_BEAM) 1213 | 1214 | \$(1): \$\$(\$(1)_BEAM) 1215 | endef 1216 | 1217 | 1218 | define rules_ERLAPP 1219 | \$(1)_BEAM=\$(subst .in,,\$(addprefix ebin/, \$(notdir \$(\$(1)_SRC:.erl=.beam)))) 1220 | nobase_pkgliberl_SCRIPTS += \$(\$(1)_BEAM) 1221 | 1222 | ebin/\$(1).app: \$\$(\$(1)_BEAM) 1223 | \$(AM_V_ERL)m=\`echo \$\$(\$(1)_SRC) | sed 's| | -I |g'\`; \\ 1224 | e=\"\$\$(ERLANG_APPS) \$(\$(1)_USE)\"; \\ 1225 | v=\`test \$(\$(1)_VSN) && echo \"-v \$(\$(1)_VSN)\"\`; \\ 1226 | d=\`echo \"\x24\x24\x24\x24e\" | sed 's| \\([[a-zA-Z]]\\)| -U \x5c1|g'\`; \\ 1227 | \$\$(CONF2LIB) -r eapp -l \$(1) -o \x24\x24@ -I \x24\x24\x24\x24m \x24\x24\x24\x24v -U \x24\x24\x24\x24d \$(top_builddir)/config.h 1228 | 1229 | endef 1230 | 1231 | dnl Erlang app should deliver bin/.app file to nobase_pkgliberl_SCRIPTS 1232 | \$(foreach erlapp, \\ 1233 | \$(subst .app, ,\$(notdir \\ 1234 | \$(filter %%.app, \$(nobase_pkgliberl_SCRIPTS)) \\ 1235 | )), \\ 1236 | \$(eval \\ 1237 | \$(call rules_ERLAPP,\$(erlapp)) \\ 1238 | ) \\ 1239 | ) 1240 | 1241 | 1242 | \$(foreach liberl, \\ 1243 | \$(pkgliberl_SCRIPTS), \\ 1244 | \$(eval \\ 1245 | \$(call rules_BEAM,\$(liberl)) \\ 1246 | ) \\ 1247 | ) 1248 | 1249 | dnl define rules_ERLANGLIB 1250 | dnl \$(1)_ESRC=\$(filter %%.erl, \$(\$(1)_SRC)) 1251 | dnl \$(1)_EBIN=\$(addprefix ebin/, \$(notdir \$(filter %%.beam, \$(\$(1)_SRC:.erl=.beam)))) 1252 | dnl EBIN += \$\$(\$(1)_EBIN) 1253 | dnl 1254 | dnl ebin/%%.beam : src/\$(1)/%%.erl 1255 | dnl \$(CC) \$(CCFLAGS) -I ./include -b beam -o ebin \$\$^ 1256 | dnl endef 1257 | dnl 1258 | dnl 1259 | dnl define ERL_APP_template 1260 | dnl \$(1)_ESRC=\$(filter %%.erl, \$(\$(1)_SRC)) 1261 | dnl EBIN += ebin/\$(1).app \$(1).boot \$(1).script \$(1).rel \$(1) 1262 | dnl 1263 | dnl \$(1): \$\$(\$(1)_EBIN) ebin/\$(1).app \$(1).rel \$(1).boot 1264 | dnl \$(am_v_erl)echo \"\$(ERL) -noshell \\\\x24@ -boot \$(1) \" > \$${sym_d}@ ; \\ 1265 | dnl chmod ugo+x \$${sym_d}@ 1266 | dnl 1267 | dnl ebin/\$(1).app: 1268 | dnl \$(am_v_erl)erlapp --app -l \$(1) -v \$(VERSION) \$(EAPPFLAGS) \$\$(\$(1)_ESRC) > \$${sym_d}@ 1269 | dnl 1270 | dnl \$(1).rel: ebin/\$(1).app 1271 | dnl \$(am_v_erl)erlapp --rel -l \$(1) -v \$(VERSION) --erts \'\$(erts_term)\' \$(ERELFLAGS) > \$${sym_d}@ 1272 | dnl 1273 | dnl \$(1).boot: ebin/\$(1).app \$(1).rel 1274 | dnl \$(am_v_erl)\$(ERL) --noshell -pa ./ebin -s systools make_script \$(1) -s init stop > /dev/null 1275 | dnl 1276 | dnl endef 1277 | dnl 1278 | dnl \$(foreach app, \\ 1279 | dnl \$(LIBS), \\ 1280 | dnl \$(eval \\ 1281 | dnl \$(call ERL_LIB_template,\$(app)) \\ 1282 | dnl ) \\ 1283 | dnl ) 1284 | dnl \$(foreach app, \\ 1285 | dnl \$(APPS), \\ 1286 | dnl \$(eval \\ 1287 | dnl \$(call ERL_LIB_template,\$(app)) \\ 1288 | dnl ) \\ 1289 | dnl ) 1290 | dnl \$(foreach app, \\ 1291 | dnl \$(APPS), \\ 1292 | dnl \$(eval \\ 1293 | dnl \$(call ERL_APP_template,\$(app)) \\ 1294 | dnl ) \\ 1295 | dnl ) 1296 | dnl 1297 | dnl 1298 | dnl 1299 | dnl %%: %%.pl 1300 | dnl \$(am_v_erl)echo \"#!\$(PERL)\" > ${sym_d}@; \\ 1301 | dnl cat \$^ | sed -e \"s,@ERL[@],\$(ERL),\" \\ 1302 | dnl -e \"s,@pkgliberldir[@],\$(pkgliberldir),\" \\ 1303 | dnl -e \"s,@prefix[@],\$(prefix),\" \\ 1304 | dnl >> ${sym_d}@ ; \\ 1305 | dnl chmod ugo+x ${sym_d}@ 1306 | 1307 | " >> Makefile.gnuweb 1308 | 1309 | ]) 1310 | 1311 | -------------------------------------------------------------------------------- /conf2lib: -------------------------------------------------------------------------------- 1 | #!/usr/local/macports/bin/perl 2 | # 3 | # GNU Web: conf2lib - converts config.h into syntax complient 4 | # with non-native runtimes 5 | # 6 | # @author Mobilana 7 | # @license AllPermissive 8 | # 9 | 10 | ############################################################################### 11 | # 12 | # generic run-time 13 | # 14 | ############################################################################### 15 | { 16 | package SModule; 17 | 18 | sub new 19 | { 20 | my ($class, $name) = @_; 21 | $self = {}; 22 | $self->{'name'} = $name; 23 | $self->{'classes'} = (); 24 | $self->{'include'} = (); 25 | $self->{'uses'} = (); 26 | 27 | bless($self, $class); 28 | return ($self); 29 | } 30 | 31 | sub addClass 32 | { 33 | my ($self, $class) = @_; 34 | my $arr = $self->{'classes'}; 35 | push(@$arr, $class); 36 | $self->{'classes'} = $arr; 37 | } 38 | 39 | sub include 40 | { 41 | my ($self, $inc) = @_; 42 | my $arr = $self->{'include'}; 43 | push(@$arr, $inc); 44 | $self->{'include'} = $arr; 45 | } 46 | 47 | sub uses 48 | { 49 | my ($self, $dep) = @_; 50 | my $arr = $self->{'uses'}; 51 | push(@$arr, $dep); 52 | $self->{'uses'} = $arr; 53 | } 54 | } 55 | 56 | { 57 | package SClass; 58 | 59 | sub new 60 | { 61 | my ($class, $name) = @_; 62 | $self = {}; 63 | $self->{'name'} = $name; 64 | $self->{'static'} = {}; 65 | 66 | bless($self, $class); 67 | return ($self); 68 | } 69 | 70 | # 71 | # Add new static field 72 | # 73 | sub static 74 | { 75 | my ($self, $name, $value) = @_; 76 | $self->{'static'}{$name} = $value; 77 | } 78 | } 79 | 80 | ############################################################################### 81 | # 82 | # erlang application run-time 83 | # 84 | ############################################################################### 85 | { 86 | package EappModule; 87 | our @ISA = qw(SModule); 88 | 89 | sub toString 90 | { 91 | my ($self) = @_; 92 | # package name and version 93 | my $klass = $self->{'classes'}[0]; 94 | my $name = $self->{'name'}; 95 | my $vsn = $klass->{'static'}{'VERSION'}; 96 | $vsn =~ s,",,g; 97 | 98 | # list of modules (includes) 99 | my @mods = (); 100 | my $include = $self->{'include'}; 101 | foreach my $i (@$include) 102 | { 103 | $i =~ s,^(.*/)?(.+)$,$2,; # basename 104 | push(@mods, $1) if ($i =~ /(.*)\.erl/); # only erl files and no .erl extension 105 | } 106 | # list of dependencies 107 | my @apps = (); 108 | my $uses = $self->{'uses'}; 109 | foreach my $d (@$uses) 110 | { 111 | $d =~ s|(.*)-([0-9]+\.?){0,4}|$1|; 112 | push(@apps, $d); 113 | } 114 | #push(@apps, $name); 115 | 116 | # classes (converted into env) 117 | my $classes = $self->{'classes'}; 118 | $env = ''; 119 | foreach my $c (@$classes) 120 | { 121 | $env .= $c->toString(); 122 | } 123 | 124 | my $boot = ""; 125 | if (grep {$_ eq "${name}_app"} @mods) { 126 | $boot = "{mod, {${name}_app, \[\]}},"; 127 | } 128 | 129 | $result = " 130 | {application, $name, 131 | \[ 132 | {description, \"$name\"}, 133 | {vsn, \"$vsn\"}, 134 | {modules, \[" . join(",", @mods). "\]}, 135 | {registered, \[\]}, 136 | {applications,\[" . join(",", @apps). "\]}, 137 | $boot 138 | {env, [ 139 | $env 140 | ]} 141 | \] 142 | }. 143 | \n"; 144 | return $result; 145 | } 146 | } 147 | 148 | { 149 | package EappClass; 150 | our @ISA = qw(SClass); 151 | 152 | # 153 | # Converts class to valid erlang syntax 154 | # 155 | sub toString 156 | { 157 | my ($self) = @_; 158 | $result = ""; 159 | my $attrs = $self->{'static'}; 160 | my @tuples = (); 161 | while( my($name, $value) = each(%$attrs) ) 162 | { 163 | push(@tuples, "\t{'$name', $value}"); 164 | } 165 | return $result . join(",\n", @tuples); 166 | } 167 | } 168 | 169 | ############################################################################### 170 | # 171 | # erlang release 172 | # 173 | ############################################################################### 174 | { 175 | package ErelModule; 176 | our @ISA = qw(SModule); 177 | 178 | sub toString 179 | { 180 | my ($self) = @_; 181 | # package name and version 182 | my $klass = $self->{'classes'}[0]; 183 | my $name = $self->{'name'}; 184 | my $vsn = $klass->{'static'}{'VERSION'}; 185 | $vsn =~ s,",,g; 186 | 187 | # list of dependencies 188 | my $erts_vsn = ''; 189 | my @deps = (); 190 | my $uses = $self->{'uses'}; 191 | foreach my $d (@$uses) 192 | { 193 | if ($d =~ /erts-(.*)/) 194 | { 195 | $erts_vsn = $1 196 | } elsif ($d =~ /(.*)-(.*)/) { 197 | push(@deps, "{$1, \"$2\"}"); 198 | } 199 | } 200 | push(@deps, "{$name, \"$vsn\"}"); 201 | 202 | 203 | # classes (converted into env) 204 | my $classes = $self->{'classes'}; 205 | $env = ''; 206 | foreach my $c (@$classes) 207 | { 208 | $env .= $c->toString(); 209 | } 210 | 211 | $result = " 212 | {release, 213 | {\"$name\", \"$vsn\"}, 214 | {erts, \"$erts_vsn\"}, 215 | [\n\t" . join(",\n\t", @deps) . " 216 | ] 217 | }. 218 | \n"; 219 | return $result; 220 | } 221 | 222 | } 223 | 224 | { 225 | package ErelClass; 226 | our @ISA = qw(SClass); 227 | 228 | # 229 | # Converts class to valid php syntax 230 | # 231 | sub toString 232 | { 233 | my ($self) = @_; 234 | $result = ""; 235 | my $attrs = $self->{'static'}; 236 | while( my($name, $value) = each(%$attrs) ) 237 | { 238 | } 239 | return ""; 240 | } 241 | } 242 | 243 | ############################################################################### 244 | # 245 | # javascript runtime 246 | # 247 | ############################################################################### 248 | { 249 | package JSModule; 250 | our @ISA = qw(SModule); 251 | 252 | sub toString 253 | { 254 | my ($self) = @_; 255 | 256 | #classes 257 | my $classes = $self->{'classes'}; 258 | foreach my $c (@$classes) 259 | { 260 | $result .= $c->toString(); 261 | } 262 | 263 | return $result; 264 | } 265 | } 266 | 267 | { 268 | package JSClass; 269 | our @ISA = qw(SClass); 270 | 271 | # 272 | # Converts class to valid php syntax 273 | # 274 | sub toString 275 | { 276 | my ($self) = @_; 277 | $result = "(function(ns){ ns.config = {\n"; 278 | my $attrs = $self->{'static'}; 279 | while( my($name, $value) = each(%$attrs) ) 280 | { 281 | $result .= "\t$name : $value,\n"; 282 | } 283 | $result =~ s/,\n$//; 284 | $result .= "\n}\n}(typeof window.$self->{'name'} == 'object' ? window.$self->{'name'} : window.$self->{'name'} = {}));\n"; 285 | return $result; 286 | } 287 | } 288 | 289 | ############################################################################### 290 | # 291 | # perl runtime 292 | # 293 | ############################################################################### 294 | { 295 | package PerlModule; 296 | our @ISA = qw(SModule); 297 | 298 | sub toString 299 | { 300 | my ($self) = @_; 301 | $result = "package $self->{'name'};\n"; 302 | 303 | #includes 304 | my $include = $self->{'include'}; 305 | foreach my $i (@$include) 306 | { 307 | $i =~ s/\//::/g; 308 | $i =~ s/.pm//g; 309 | $result .= "use $i;\n"; 310 | } 311 | $result .= "\n"; 312 | 313 | #classes 314 | my $classes = $self->{'classes'}; 315 | foreach my $c (@$classes) 316 | { 317 | $result .= $c->toString(); 318 | } 319 | $result .= "1;\n"; 320 | 321 | return $result; 322 | } 323 | } 324 | 325 | { 326 | package PerlClass; 327 | our @ISA = qw(SClass); 328 | 329 | # 330 | # Converts class to valid php syntax 331 | # 332 | sub toString 333 | { 334 | my ($self) = @_; 335 | # $result = "package $self->{'name'};\n"; 336 | $result = "\n"; 337 | my $attrs = $self->{'static'}; 338 | while( my($name, $value) = each(%$attrs) ) 339 | { 340 | $result .= "use constant $name => $value;\n"; 341 | } 342 | $result .= "\n"; 343 | return $result; 344 | } 345 | } 346 | 347 | ############################################################################### 348 | # 349 | # php runtime 350 | # 351 | ############################################################################### 352 | { 353 | package PhpModule; 354 | our @ISA = qw(SModule); 355 | 356 | sub toString 357 | { 358 | my ($self) = @_; 359 | $result = "{'include'}; 363 | foreach my $i (@$include) 364 | { 365 | $result .= "require_once \"$i\";\n"; 366 | } 367 | $result .= "\n"; 368 | 369 | #classes 370 | my $classes = $self->{'classes'}; 371 | foreach my $c (@$classes) 372 | { 373 | $result .= $c->toString(); 374 | } 375 | $result .= "?>\n"; 376 | 377 | return $result; 378 | } 379 | } 380 | 381 | { 382 | package PhpClass; 383 | our @ISA = qw(SClass); 384 | 385 | # 386 | # Converts class to valid php syntax 387 | # 388 | sub toString 389 | { 390 | my ($self) = @_; 391 | $result = "class $self->{'name'}\n{\n"; 392 | my $attrs = $self->{'static'}; 393 | while( my($name, $value) = each(%$attrs) ) 394 | { 395 | $result .= "\tstatic public \$$name = $value;\n"; 396 | } 397 | # 398 | # version validator 399 | #$result .= "\tstatic function version(\$version)\n\t{\n"; 400 | #$result .= "\t\t\@list(\$v1, \$v2, \$v3) = explode('.', $self->{'name'}::\$VERSION);\n"; 401 | #$result .= "\t\t\@list(\$q1, \$q2, \$q3) = explode('.', \$version);\n"; 402 | #$result .= "\t\treturn ( (\$v1 < \$q1) && (\$v2 < \$q2) && (\$v3 < \$q3) ) ? -1 : 0;\n"; 403 | #$result .= "\t}\n"; 404 | $result .= "}\n"; 405 | return $result; 406 | } 407 | } 408 | 409 | ############################################################################### 410 | # 411 | # command line utility 412 | # 413 | ############################################################################### 414 | use Getopt::Long; 415 | 416 | sub usage 417 | { 418 | print STDERR << "EOF"; 419 | 420 | Converts config.h into static class of chosen runtime, optionally include extra files 421 | 422 | usage $0 [OPTIONS] 423 | 424 | MANDATORY: 425 | -l library name 426 | -v library version overwrite config.h 427 | -r destination runtime (php, js, eapp, erel) 428 | 429 | OPTIONAL: 430 | -D define extra macros 431 | -E exclude macro definition 432 | -I include file 433 | -U uses library 434 | -o output file 435 | -h help 436 | EOF 437 | exit; 438 | } 439 | 440 | $result = GetOptions( 441 | "h" => \$help, 442 | "r=s" => \$runtime, 443 | "D=s" => \@defines, 444 | "E=s" => \@excludes, 445 | "I=s" => \@includes, 446 | "U=s" => \@uses, 447 | "o=s" => \$output, 448 | "l=s" => \$lib, 449 | "v=s" => \$version 450 | ); 451 | usage() if ($help || !defined $lib || !defined $runtime || !defined @ARGV[0]); 452 | 453 | 454 | 455 | open(IN, @ARGV[0]) || die("Could not open file:".@ARGV[0]); 456 | @config=; 457 | close(IN); 458 | shift @ARGV; 459 | 460 | $lib =~ s/-/_/g; 461 | 462 | if ($runtime eq "php") 463 | { 464 | $mod = PhpModule->new("$lib"); 465 | } elsif ($runtime eq "perl") { 466 | $mod = PerlModule->new("$lib"); 467 | } elsif ($runtime eq "js") { 468 | $mod = JSModule->new("$lib"); 469 | } elsif ($runtime eq "eapp") { 470 | $mod = EappModule->new("$lib"); 471 | } elsif ($runtime eq "erel") { 472 | $mod = ErelModule->new("$lib"); 473 | } else { 474 | die("Runtime is not supported."); 475 | } 476 | foreach my $inc (@includes) 477 | { 478 | $mod->include($inc); 479 | } 480 | foreach my $dep (@uses) 481 | { 482 | $mod->uses($dep); 483 | } 484 | 485 | if ($runtime eq "php") 486 | { 487 | $cls = PhpClass->new("$lib"); 488 | } elsif ($runtime eq "perl") { 489 | $cls = PerlClass->new("$lib"); 490 | } elsif ($runtime eq "js") { 491 | $cls = JSClass->new("$lib"); 492 | } elsif ($runtime eq "eapp") { 493 | $cls = EappClass->new("$lib"); 494 | } elsif ($runtime eq "erel") { 495 | $cls = ErelClass->new("$lib"); 496 | } else { 497 | die("Runtime is not supported."); 498 | } 499 | foreach my $line (@config) 500 | { 501 | if ($line =~ /#define\s+([^\s]+)\s+(.*)/) 502 | { 503 | my $def = $1; 504 | my $val = $2; 505 | if ( grep { $_ eq $def} @excludes ) 506 | { 507 | } else { 508 | $cls->static($1, $2); 509 | } 510 | } 511 | if ($line =~ /.*#undef\s+([^\s]+).*/) 512 | { 513 | $cls->static($1, 'null'); 514 | } 515 | }#foreach 516 | foreach my $def (@defines) 517 | { 518 | my($var, $val) = split('/=/', $def); 519 | $cls->static($var, $val); 520 | } 521 | # overwrite default version if this is desired 522 | $cls->static('VERSION', "\"$version\"") if defined($version); 523 | 524 | $mod->addClass($cls); 525 | 526 | if (defined $output) 527 | { 528 | open(OUT, ">$output"); 529 | print OUT $mod->toString(); 530 | close(OUT); 531 | exit(0); 532 | } 533 | 534 | print STDOUT $mod->toString(); 535 | 536 | 537 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Name of package */ 4 | #undef PACKAGE 5 | 6 | /* Define to the address where bug reports for this package should be sent. */ 7 | #undef PACKAGE_BUGREPORT 8 | 9 | /* Define to the full name of this package. */ 10 | #undef PACKAGE_NAME 11 | 12 | /* Define to the full name and version of this package. */ 13 | #undef PACKAGE_STRING 14 | 15 | /* Define to the one symbol short name of this package. */ 16 | #undef PACKAGE_TARNAME 17 | 18 | /* Define to the home page for this package. */ 19 | #undef PACKAGE_URL 20 | 21 | /* Define to the version of this package. */ 22 | #undef PACKAGE_VERSION 23 | 24 | /* Version number of package */ 25 | #undef VERSION 26 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl Copyright (c) 2012, Dmitry Kolesnikov 3 | dnl All Rights Reserved. 4 | dnl 5 | dnl Licensed under the 3-clause BSD License (the "License"); 6 | dnl you may not use this file except in compliance with the License. 7 | dnl You may obtain a copy of the License at 8 | dnl 9 | dnl http://www.opensource.org/licenses/BSD-3-Clause 10 | dnl 11 | dnl Unless required by applicable law or agreed to in writing, software 12 | dnl distributed under the License is distributed on an "AS IS" BASIS, 13 | dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | dnl See the License for the specific language governing permissions and 15 | dnl limitations under the License 16 | dnl 17 | AC_INIT([csv], [0.0.1], [dmkolesnikov@gmail.com]) 18 | AM_INIT_AUTOMAKE([silent-rules]) 19 | AM_SILENT_RULES([yes]) 20 | ACX_INIT_GNUWEB 21 | 22 | ACX_CHECK_PROG([perl]) 23 | ACX_ERLANG 24 | 25 | AM_CONFIG_HEADER(config.h) 26 | AC_OUTPUT( 27 | Makefile \ 28 | test/Makefile \ 29 | ) 30 | ACX_DONE 31 | 32 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2011-01-19.21; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # `make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | nl=' 45 | ' 46 | IFS=" "" $nl" 47 | 48 | # set DOITPROG to echo to test this script 49 | 50 | # Don't use :- since 4.3BSD and earlier shells don't like it. 51 | doit=${DOITPROG-} 52 | if test -z "$doit"; then 53 | doit_exec=exec 54 | else 55 | doit_exec=$doit 56 | fi 57 | 58 | # Put in absolute file names if you don't have them in your path; 59 | # or use environment vars. 60 | 61 | chgrpprog=${CHGRPPROG-chgrp} 62 | chmodprog=${CHMODPROG-chmod} 63 | chownprog=${CHOWNPROG-chown} 64 | cmpprog=${CMPPROG-cmp} 65 | cpprog=${CPPROG-cp} 66 | mkdirprog=${MKDIRPROG-mkdir} 67 | mvprog=${MVPROG-mv} 68 | rmprog=${RMPROG-rm} 69 | stripprog=${STRIPPROG-strip} 70 | 71 | posix_glob='?' 72 | initialize_posix_glob=' 73 | test "$posix_glob" != "?" || { 74 | if (set -f) 2>/dev/null; then 75 | posix_glob= 76 | else 77 | posix_glob=: 78 | fi 79 | } 80 | ' 81 | 82 | posix_mkdir= 83 | 84 | # Desired mode of installed file. 85 | mode=0755 86 | 87 | chgrpcmd= 88 | chmodcmd=$chmodprog 89 | chowncmd= 90 | mvcmd=$mvprog 91 | rmcmd="$rmprog -f" 92 | stripcmd= 93 | 94 | src= 95 | dst= 96 | dir_arg= 97 | dst_arg= 98 | 99 | copy_on_change=false 100 | no_target_directory= 101 | 102 | usage="\ 103 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 104 | or: $0 [OPTION]... SRCFILES... DIRECTORY 105 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 106 | or: $0 [OPTION]... -d DIRECTORIES... 107 | 108 | In the 1st form, copy SRCFILE to DSTFILE. 109 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 110 | In the 4th, create DIRECTORIES. 111 | 112 | Options: 113 | --help display this help and exit. 114 | --version display version info and exit. 115 | 116 | -c (ignored) 117 | -C install only if different (preserve the last data modification time) 118 | -d create directories instead of installing files. 119 | -g GROUP $chgrpprog installed files to GROUP. 120 | -m MODE $chmodprog installed files to MODE. 121 | -o USER $chownprog installed files to USER. 122 | -s $stripprog installed files. 123 | -t DIRECTORY install into DIRECTORY. 124 | -T report an error if DSTFILE is a directory. 125 | 126 | Environment variables override the default commands: 127 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 128 | RMPROG STRIPPROG 129 | " 130 | 131 | while test $# -ne 0; do 132 | case $1 in 133 | -c) ;; 134 | 135 | -C) copy_on_change=true;; 136 | 137 | -d) dir_arg=true;; 138 | 139 | -g) chgrpcmd="$chgrpprog $2" 140 | shift;; 141 | 142 | --help) echo "$usage"; exit $?;; 143 | 144 | -m) mode=$2 145 | case $mode in 146 | *' '* | *' '* | *' 147 | '* | *'*'* | *'?'* | *'['*) 148 | echo "$0: invalid mode: $mode" >&2 149 | exit 1;; 150 | esac 151 | shift;; 152 | 153 | -o) chowncmd="$chownprog $2" 154 | shift;; 155 | 156 | -s) stripcmd=$stripprog;; 157 | 158 | -t) dst_arg=$2 159 | # Protect names problematic for `test' and other utilities. 160 | case $dst_arg in 161 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 162 | esac 163 | shift;; 164 | 165 | -T) no_target_directory=true;; 166 | 167 | --version) echo "$0 $scriptversion"; exit $?;; 168 | 169 | --) shift 170 | break;; 171 | 172 | -*) echo "$0: invalid option: $1" >&2 173 | exit 1;; 174 | 175 | *) break;; 176 | esac 177 | shift 178 | done 179 | 180 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 181 | # When -d is used, all remaining arguments are directories to create. 182 | # When -t is used, the destination is already specified. 183 | # Otherwise, the last argument is the destination. Remove it from $@. 184 | for arg 185 | do 186 | if test -n "$dst_arg"; then 187 | # $@ is not empty: it contains at least $arg. 188 | set fnord "$@" "$dst_arg" 189 | shift # fnord 190 | fi 191 | shift # arg 192 | dst_arg=$arg 193 | # Protect names problematic for `test' and other utilities. 194 | case $dst_arg in 195 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 196 | esac 197 | done 198 | fi 199 | 200 | if test $# -eq 0; then 201 | if test -z "$dir_arg"; then 202 | echo "$0: no input file specified." >&2 203 | exit 1 204 | fi 205 | # It's OK to call `install-sh -d' without argument. 206 | # This can happen when creating conditional directories. 207 | exit 0 208 | fi 209 | 210 | if test -z "$dir_arg"; then 211 | do_exit='(exit $ret); exit $ret' 212 | trap "ret=129; $do_exit" 1 213 | trap "ret=130; $do_exit" 2 214 | trap "ret=141; $do_exit" 13 215 | trap "ret=143; $do_exit" 15 216 | 217 | # Set umask so as not to create temps with too-generous modes. 218 | # However, 'strip' requires both read and write access to temps. 219 | case $mode in 220 | # Optimize common cases. 221 | *644) cp_umask=133;; 222 | *755) cp_umask=22;; 223 | 224 | *[0-7]) 225 | if test -z "$stripcmd"; then 226 | u_plus_rw= 227 | else 228 | u_plus_rw='% 200' 229 | fi 230 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 231 | *) 232 | if test -z "$stripcmd"; then 233 | u_plus_rw= 234 | else 235 | u_plus_rw=,u+rw 236 | fi 237 | cp_umask=$mode$u_plus_rw;; 238 | esac 239 | fi 240 | 241 | for src 242 | do 243 | # Protect names problematic for `test' and other utilities. 244 | case $src in 245 | -* | [=\(\)!]) src=./$src;; 246 | esac 247 | 248 | if test -n "$dir_arg"; then 249 | dst=$src 250 | dstdir=$dst 251 | test -d "$dstdir" 252 | dstdir_status=$? 253 | else 254 | 255 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 256 | # might cause directories to be created, which would be especially bad 257 | # if $src (and thus $dsttmp) contains '*'. 258 | if test ! -f "$src" && test ! -d "$src"; then 259 | echo "$0: $src does not exist." >&2 260 | exit 1 261 | fi 262 | 263 | if test -z "$dst_arg"; then 264 | echo "$0: no destination specified." >&2 265 | exit 1 266 | fi 267 | dst=$dst_arg 268 | 269 | # If destination is a directory, append the input filename; won't work 270 | # if double slashes aren't ignored. 271 | if test -d "$dst"; then 272 | if test -n "$no_target_directory"; then 273 | echo "$0: $dst_arg: Is a directory" >&2 274 | exit 1 275 | fi 276 | dstdir=$dst 277 | dst=$dstdir/`basename "$src"` 278 | dstdir_status=0 279 | else 280 | # Prefer dirname, but fall back on a substitute if dirname fails. 281 | dstdir=` 282 | (dirname "$dst") 2>/dev/null || 283 | expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ 284 | X"$dst" : 'X\(//\)[^/]' \| \ 285 | X"$dst" : 'X\(//\)$' \| \ 286 | X"$dst" : 'X\(/\)' \| . 2>/dev/null || 287 | echo X"$dst" | 288 | sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ 289 | s//\1/ 290 | q 291 | } 292 | /^X\(\/\/\)[^/].*/{ 293 | s//\1/ 294 | q 295 | } 296 | /^X\(\/\/\)$/{ 297 | s//\1/ 298 | q 299 | } 300 | /^X\(\/\).*/{ 301 | s//\1/ 302 | q 303 | } 304 | s/.*/./; q' 305 | ` 306 | 307 | test -d "$dstdir" 308 | dstdir_status=$? 309 | fi 310 | fi 311 | 312 | obsolete_mkdir_used=false 313 | 314 | if test $dstdir_status != 0; then 315 | case $posix_mkdir in 316 | '') 317 | # Create intermediate dirs using mode 755 as modified by the umask. 318 | # This is like FreeBSD 'install' as of 1997-10-28. 319 | umask=`umask` 320 | case $stripcmd.$umask in 321 | # Optimize common cases. 322 | *[2367][2367]) mkdir_umask=$umask;; 323 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 324 | 325 | *[0-7]) 326 | mkdir_umask=`expr $umask + 22 \ 327 | - $umask % 100 % 40 + $umask % 20 \ 328 | - $umask % 10 % 4 + $umask % 2 329 | `;; 330 | *) mkdir_umask=$umask,go-w;; 331 | esac 332 | 333 | # With -d, create the new directory with the user-specified mode. 334 | # Otherwise, rely on $mkdir_umask. 335 | if test -n "$dir_arg"; then 336 | mkdir_mode=-m$mode 337 | else 338 | mkdir_mode= 339 | fi 340 | 341 | posix_mkdir=false 342 | case $umask in 343 | *[123567][0-7][0-7]) 344 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 345 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 346 | ;; 347 | *) 348 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 349 | trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 350 | 351 | if (umask $mkdir_umask && 352 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 353 | then 354 | if test -z "$dir_arg" || { 355 | # Check for POSIX incompatibilities with -m. 356 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 357 | # other-writeable bit of parent directory when it shouldn't. 358 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 359 | ls_ld_tmpdir=`ls -ld "$tmpdir"` 360 | case $ls_ld_tmpdir in 361 | d????-?r-*) different_mode=700;; 362 | d????-?--*) different_mode=755;; 363 | *) false;; 364 | esac && 365 | $mkdirprog -m$different_mode -p -- "$tmpdir" && { 366 | ls_ld_tmpdir_1=`ls -ld "$tmpdir"` 367 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 368 | } 369 | } 370 | then posix_mkdir=: 371 | fi 372 | rmdir "$tmpdir/d" "$tmpdir" 373 | else 374 | # Remove any dirs left behind by ancient mkdir implementations. 375 | rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null 376 | fi 377 | trap '' 0;; 378 | esac;; 379 | esac 380 | 381 | if 382 | $posix_mkdir && ( 383 | umask $mkdir_umask && 384 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 385 | ) 386 | then : 387 | else 388 | 389 | # The umask is ridiculous, or mkdir does not conform to POSIX, 390 | # or it failed possibly due to a race condition. Create the 391 | # directory the slow way, step by step, checking for races as we go. 392 | 393 | case $dstdir in 394 | /*) prefix='/';; 395 | [-=\(\)!]*) prefix='./';; 396 | *) prefix='';; 397 | esac 398 | 399 | eval "$initialize_posix_glob" 400 | 401 | oIFS=$IFS 402 | IFS=/ 403 | $posix_glob set -f 404 | set fnord $dstdir 405 | shift 406 | $posix_glob set +f 407 | IFS=$oIFS 408 | 409 | prefixes= 410 | 411 | for d 412 | do 413 | test X"$d" = X && continue 414 | 415 | prefix=$prefix$d 416 | if test -d "$prefix"; then 417 | prefixes= 418 | else 419 | if $posix_mkdir; then 420 | (umask=$mkdir_umask && 421 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 422 | # Don't fail if two instances are running concurrently. 423 | test -d "$prefix" || exit 1 424 | else 425 | case $prefix in 426 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 427 | *) qprefix=$prefix;; 428 | esac 429 | prefixes="$prefixes '$qprefix'" 430 | fi 431 | fi 432 | prefix=$prefix/ 433 | done 434 | 435 | if test -n "$prefixes"; then 436 | # Don't fail if two instances are running concurrently. 437 | (umask $mkdir_umask && 438 | eval "\$doit_exec \$mkdirprog $prefixes") || 439 | test -d "$dstdir" || exit 1 440 | obsolete_mkdir_used=true 441 | fi 442 | fi 443 | fi 444 | 445 | if test -n "$dir_arg"; then 446 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 447 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 448 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 449 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 450 | else 451 | 452 | # Make a couple of temp file names in the proper directory. 453 | dsttmp=$dstdir/_inst.$$_ 454 | rmtmp=$dstdir/_rm.$$_ 455 | 456 | # Trap to clean up those temp files at exit. 457 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 458 | 459 | # Copy the file name to the temp name. 460 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 461 | 462 | # and set any options; do chmod last to preserve setuid bits. 463 | # 464 | # If any of these fail, we abort the whole thing. If we want to 465 | # ignore errors from any of these, just make sure not to ignore 466 | # errors from the above "$doit $cpprog $src $dsttmp" command. 467 | # 468 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 469 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 470 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 471 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 472 | 473 | # If -C, don't bother to copy if it wouldn't change the file. 474 | if $copy_on_change && 475 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 476 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 477 | 478 | eval "$initialize_posix_glob" && 479 | $posix_glob set -f && 480 | set X $old && old=:$2:$4:$5:$6 && 481 | set X $new && new=:$2:$4:$5:$6 && 482 | $posix_glob set +f && 483 | 484 | test "$old" = "$new" && 485 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 486 | then 487 | rm -f "$dsttmp" 488 | else 489 | # Rename the file to the real destination. 490 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 491 | 492 | # The rename failed, perhaps because mv can't rename something else 493 | # to itself, or perhaps because mv is so ancient that it does not 494 | # support -f. 495 | { 496 | # Now remove or move aside any old file at destination location. 497 | # We try this two ways since rm can't unlink itself on some 498 | # systems and the destination file might be busy for other 499 | # reasons. In this case, the final cleanup might fail but the new 500 | # file should still install successfully. 501 | { 502 | test ! -f "$dst" || 503 | $doit $rmcmd -f "$dst" 2>/dev/null || 504 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 505 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 506 | } || 507 | { echo "$0: cannot unlink or rename $dst" >&2 508 | (exit 1); exit 1 509 | } 510 | } && 511 | 512 | # Now rename the file to the real destination. 513 | $doit $mvcmd "$dsttmp" "$dst" 514 | } 515 | fi || exit 1 516 | 517 | trap '' 0 518 | fi 519 | done 520 | 521 | # Local variables: 522 | # eval: (add-hook 'write-file-hooks 'time-stamp) 523 | # time-stamp-start: "scriptversion=" 524 | # time-stamp-format: "%:y-%02m-%02d.%02H" 525 | # time-stamp-time-zone: "UTC" 526 | # time-stamp-end: "; # UTC" 527 | # End: 528 | -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common stub for a few missing GNU programs while installing. 3 | 4 | scriptversion=2012-01-06.13; # UTC 5 | 6 | # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, 7 | # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. 8 | # Originally by Fran,cois Pinard , 1996. 9 | 10 | # This program is free software; you can redistribute it and/or modify 11 | # it under the terms of the GNU General Public License as published by 12 | # the Free Software Foundation; either version 2, or (at your option) 13 | # any later version. 14 | 15 | # This program is distributed in the hope that it will be useful, 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | # GNU General Public License for more details. 19 | 20 | # You should have received a copy of the GNU General Public License 21 | # along with this program. If not, see . 22 | 23 | # As a special exception to the GNU General Public License, if you 24 | # distribute this file as part of a program that contains a 25 | # configuration script generated by Autoconf, you may include it under 26 | # the same distribution terms that you use for the rest of that program. 27 | 28 | if test $# -eq 0; then 29 | echo 1>&2 "Try \`$0 --help' for more information" 30 | exit 1 31 | fi 32 | 33 | run=: 34 | sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' 35 | sed_minuso='s/.* -o \([^ ]*\).*/\1/p' 36 | 37 | # In the cases where this matters, `missing' is being run in the 38 | # srcdir already. 39 | if test -f configure.ac; then 40 | configure_ac=configure.ac 41 | else 42 | configure_ac=configure.in 43 | fi 44 | 45 | msg="missing on your system" 46 | 47 | case $1 in 48 | --run) 49 | # Try to run requested program, and just exit if it succeeds. 50 | run= 51 | shift 52 | "$@" && exit 0 53 | # Exit code 63 means version mismatch. This often happens 54 | # when the user try to use an ancient version of a tool on 55 | # a file that requires a minimum version. In this case we 56 | # we should proceed has if the program had been absent, or 57 | # if --run hadn't been passed. 58 | if test $? = 63; then 59 | run=: 60 | msg="probably too old" 61 | fi 62 | ;; 63 | 64 | -h|--h|--he|--hel|--help) 65 | echo "\ 66 | $0 [OPTION]... PROGRAM [ARGUMENT]... 67 | 68 | Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an 69 | error status if there is no known handling for PROGRAM. 70 | 71 | Options: 72 | -h, --help display this help and exit 73 | -v, --version output version information and exit 74 | --run try to run the given command, and emulate it if it fails 75 | 76 | Supported PROGRAM values: 77 | aclocal touch file \`aclocal.m4' 78 | autoconf touch file \`configure' 79 | autoheader touch file \`config.h.in' 80 | autom4te touch the output file, or create a stub one 81 | automake touch all \`Makefile.in' files 82 | bison create \`y.tab.[ch]', if possible, from existing .[ch] 83 | flex create \`lex.yy.c', if possible, from existing .c 84 | help2man touch the output file 85 | lex create \`lex.yy.c', if possible, from existing .c 86 | makeinfo touch the output file 87 | yacc create \`y.tab.[ch]', if possible, from existing .[ch] 88 | 89 | Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and 90 | \`g' are ignored when checking the name. 91 | 92 | Send bug reports to ." 93 | exit $? 94 | ;; 95 | 96 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 97 | echo "missing $scriptversion (GNU Automake)" 98 | exit $? 99 | ;; 100 | 101 | -*) 102 | echo 1>&2 "$0: Unknown \`$1' option" 103 | echo 1>&2 "Try \`$0 --help' for more information" 104 | exit 1 105 | ;; 106 | 107 | esac 108 | 109 | # normalize program name to check for. 110 | program=`echo "$1" | sed ' 111 | s/^gnu-//; t 112 | s/^gnu//; t 113 | s/^g//; t'` 114 | 115 | # Now exit if we have it, but it failed. Also exit now if we 116 | # don't have it and --version was passed (most likely to detect 117 | # the program). This is about non-GNU programs, so use $1 not 118 | # $program. 119 | case $1 in 120 | lex*|yacc*) 121 | # Not GNU programs, they don't have --version. 122 | ;; 123 | 124 | *) 125 | if test -z "$run" && ($1 --version) > /dev/null 2>&1; then 126 | # We have it, but it failed. 127 | exit 1 128 | elif test "x$2" = "x--version" || test "x$2" = "x--help"; then 129 | # Could not run --version or --help. This is probably someone 130 | # running `$TOOL --version' or `$TOOL --help' to check whether 131 | # $TOOL exists and not knowing $TOOL uses missing. 132 | exit 1 133 | fi 134 | ;; 135 | esac 136 | 137 | # If it does not exist, or fails to run (possibly an outdated version), 138 | # try to emulate it. 139 | case $program in 140 | aclocal*) 141 | echo 1>&2 "\ 142 | WARNING: \`$1' is $msg. You should only need it if 143 | you modified \`acinclude.m4' or \`${configure_ac}'. You might want 144 | to install the \`Automake' and \`Perl' packages. Grab them from 145 | any GNU archive site." 146 | touch aclocal.m4 147 | ;; 148 | 149 | autoconf*) 150 | echo 1>&2 "\ 151 | WARNING: \`$1' is $msg. You should only need it if 152 | you modified \`${configure_ac}'. You might want to install the 153 | \`Autoconf' and \`GNU m4' packages. Grab them from any GNU 154 | archive site." 155 | touch configure 156 | ;; 157 | 158 | autoheader*) 159 | echo 1>&2 "\ 160 | WARNING: \`$1' is $msg. You should only need it if 161 | you modified \`acconfig.h' or \`${configure_ac}'. You might want 162 | to install the \`Autoconf' and \`GNU m4' packages. Grab them 163 | from any GNU archive site." 164 | files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` 165 | test -z "$files" && files="config.h" 166 | touch_files= 167 | for f in $files; do 168 | case $f in 169 | *:*) touch_files="$touch_files "`echo "$f" | 170 | sed -e 's/^[^:]*://' -e 's/:.*//'`;; 171 | *) touch_files="$touch_files $f.in";; 172 | esac 173 | done 174 | touch $touch_files 175 | ;; 176 | 177 | automake*) 178 | echo 1>&2 "\ 179 | WARNING: \`$1' is $msg. You should only need it if 180 | you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. 181 | You might want to install the \`Automake' and \`Perl' packages. 182 | Grab them from any GNU archive site." 183 | find . -type f -name Makefile.am -print | 184 | sed 's/\.am$/.in/' | 185 | while read f; do touch "$f"; done 186 | ;; 187 | 188 | autom4te*) 189 | echo 1>&2 "\ 190 | WARNING: \`$1' is needed, but is $msg. 191 | You might have modified some files without having the 192 | proper tools for further handling them. 193 | You can get \`$1' as part of \`Autoconf' from any GNU 194 | archive site." 195 | 196 | file=`echo "$*" | sed -n "$sed_output"` 197 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 198 | if test -f "$file"; then 199 | touch $file 200 | else 201 | test -z "$file" || exec >$file 202 | echo "#! /bin/sh" 203 | echo "# Created by GNU Automake missing as a replacement of" 204 | echo "# $ $@" 205 | echo "exit 0" 206 | chmod +x $file 207 | exit 1 208 | fi 209 | ;; 210 | 211 | bison*|yacc*) 212 | echo 1>&2 "\ 213 | WARNING: \`$1' $msg. You should only need it if 214 | you modified a \`.y' file. You may need the \`Bison' package 215 | in order for those modifications to take effect. You can get 216 | \`Bison' from any GNU archive site." 217 | rm -f y.tab.c y.tab.h 218 | if test $# -ne 1; then 219 | eval LASTARG=\${$#} 220 | case $LASTARG in 221 | *.y) 222 | SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` 223 | if test -f "$SRCFILE"; then 224 | cp "$SRCFILE" y.tab.c 225 | fi 226 | SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` 227 | if test -f "$SRCFILE"; then 228 | cp "$SRCFILE" y.tab.h 229 | fi 230 | ;; 231 | esac 232 | fi 233 | if test ! -f y.tab.h; then 234 | echo >y.tab.h 235 | fi 236 | if test ! -f y.tab.c; then 237 | echo 'main() { return 0; }' >y.tab.c 238 | fi 239 | ;; 240 | 241 | lex*|flex*) 242 | echo 1>&2 "\ 243 | WARNING: \`$1' is $msg. You should only need it if 244 | you modified a \`.l' file. You may need the \`Flex' package 245 | in order for those modifications to take effect. You can get 246 | \`Flex' from any GNU archive site." 247 | rm -f lex.yy.c 248 | if test $# -ne 1; then 249 | eval LASTARG=\${$#} 250 | case $LASTARG in 251 | *.l) 252 | SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` 253 | if test -f "$SRCFILE"; then 254 | cp "$SRCFILE" lex.yy.c 255 | fi 256 | ;; 257 | esac 258 | fi 259 | if test ! -f lex.yy.c; then 260 | echo 'main() { return 0; }' >lex.yy.c 261 | fi 262 | ;; 263 | 264 | help2man*) 265 | echo 1>&2 "\ 266 | WARNING: \`$1' is $msg. You should only need it if 267 | you modified a dependency of a manual page. You may need the 268 | \`Help2man' package in order for those modifications to take 269 | effect. You can get \`Help2man' from any GNU archive site." 270 | 271 | file=`echo "$*" | sed -n "$sed_output"` 272 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 273 | if test -f "$file"; then 274 | touch $file 275 | else 276 | test -z "$file" || exec >$file 277 | echo ".ab help2man is required to generate this page" 278 | exit $? 279 | fi 280 | ;; 281 | 282 | makeinfo*) 283 | echo 1>&2 "\ 284 | WARNING: \`$1' is $msg. You should only need it if 285 | you modified a \`.texi' or \`.texinfo' file, or any other file 286 | indirectly affecting the aspect of the manual. The spurious 287 | call might also be the consequence of using a buggy \`make' (AIX, 288 | DU, IRIX). You might want to install the \`Texinfo' package or 289 | the \`GNU make' package. Grab either from any GNU archive site." 290 | # The file to touch is that specified with -o ... 291 | file=`echo "$*" | sed -n "$sed_output"` 292 | test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` 293 | if test -z "$file"; then 294 | # ... or it is the one specified with @setfilename ... 295 | infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` 296 | file=`sed -n ' 297 | /^@setfilename/{ 298 | s/.* \([^ ]*\) *$/\1/ 299 | p 300 | q 301 | }' $infile` 302 | # ... or it is derived from the source name (dir/f.texi becomes f.info) 303 | test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info 304 | fi 305 | # If the file does not exist, the user really needs makeinfo; 306 | # let's fail without touching anything. 307 | test -f $file || exit 1 308 | touch $file 309 | ;; 310 | 311 | *) 312 | echo 1>&2 "\ 313 | WARNING: \`$1' is needed, and is $msg. 314 | You might have modified some files without having the 315 | proper tools for further handling them. Check the \`README' file, 316 | it often tells you about the needed prerequisites for installing 317 | this package. You may also peek at any GNU archive site, in case 318 | some other package would contain this missing \`$1' program." 319 | exit 1 320 | ;; 321 | esac 322 | 323 | exit 0 324 | 325 | # Local variables: 326 | # eval: (add-hook 'write-file-hooks 'time-stamp) 327 | # time-stamp-start: "scriptversion=" 328 | # time-stamp-format: "%:y-%02m-%02d.%02H" 329 | # time-stamp-time-zone: "UTC" 330 | # time-stamp-end: "; # UTC" 331 | # End: 332 | -------------------------------------------------------------------------------- /priv/csv_example.erl: -------------------------------------------------------------------------------- 1 | %% @author Dmitry Kolesnikov, 2 | %% @copyright (c) 2012 Dmitry Kolesnikov. All Rights Reserved 3 | %% 4 | %% Licensed under the 3-clause BSD License (the "License"); 5 | %% you may not use this file except in compliance with the License. 6 | %% You may obtain a copy of the License at 7 | %% 8 | %% http://www.opensource.org/licenses/BSD-3-Clause 9 | %% 10 | %% Unless required by applicable law or agreed to in writing, software 11 | %% distributed under the License is distributed on an "AS IS" BASIS, 12 | %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | %% See the License for the specific language governing permissions and 14 | %% limitations under the License 15 | %% 16 | %% @description 17 | %% csv file parser example 18 | -module(csv_example). 19 | 20 | -export([run/1, extract/2, transform_hash/2, transform_tuple/2, load_ets/2, load_pts/2]). 21 | 22 | -define(SET, ["priv/set-300K-8.txt","priv/set-300K-24.txt", "priv/set-300K-40.txt"]). 23 | 24 | run(N) -> 25 | lists:foreach(fun(X) -> extract(X, N) end, ?SET), 26 | lists:foreach(fun(X) -> transform_hash(X, N) end, ?SET), 27 | lists:foreach(fun(X) -> transform_tuple(X, N) end, ?SET), 28 | lists:foreach(fun(X) -> load_ets(X, N) end, ?SET), 29 | lists:foreach(fun(X) -> load_pts(X, N) end, ?SET). 30 | 31 | %% 32 | %% validates performance of extract=parse operation 33 | %% parser event function does not do anything else, except line counting 34 | extract(Filename, N) -> 35 | %% event function, line counter 36 | Evt = fun({line, _Line}, X) -> X + 1 end, 37 | {Tread, {ok, Bin}} = timer:tc(file, read_file, [Filename]), 38 | {Textr, R} = timer:tc(csv, pparse, [Bin, N, Evt, 0]), 39 | L = lists:foldl(fun(X, A) -> A + X end, 0, R), 40 | error_logger:info_report([ 41 | extract, 42 | {file, Filename}, 43 | {lines, L}, 44 | {size_MB, size(Bin) / (1024 * 1024)}, 45 | {read_ms, Tread / 1000}, 46 | {parse_ms, Textr / 1000}, 47 | {per_line_us, Textr / L} 48 | ]). 49 | 50 | %% 51 | %% validate performance of extract and transform operation 52 | %% parser event function calculates a rolling hash of each parsed line 53 | transform_hash(Filename, N) -> 54 | %% event function, line counter 55 | Evt = fun({line, Line}, X) -> erlang:phash2({X, Line}) end, 56 | {Tread, {ok, Bin}} = timer:tc(file, read_file, [Filename]), 57 | {Textr, R} = timer:tc(csv, pparse, [Bin, N, Evt, 0]), 58 | H = lists:foldl(fun(X, A) -> erlang:phash2({A, X}) end, 0, R), 59 | error_logger:info_report([ 60 | {transform, hash}, 61 | {file, Filename}, 62 | {hash, H}, 63 | {size_MB, size(Bin) / (1024 * 1024)}, 64 | {read_ms, Tread / 1000}, 65 | {parse_ms, Textr / 1000}, 66 | {per_line_us, Textr / 300000} 67 | ]). 68 | 69 | %% 70 | %% validate performance of extract and transform operation 71 | %% parser event function calculates a rolling hash of each parsed line 72 | transform_tuple(Filename, N) -> 73 | %% event function, line counter 74 | Evt = fun({line, Line}, X) -> 75 | T = list_to_tuple(lists:reverse(Line)), 76 | X + 1 77 | end, 78 | {Tread, {ok, Bin}} = timer:tc(file, read_file, [Filename]), 79 | {Textr, R} = timer:tc(csv, pparse, [Bin, N, Evt, 0]), 80 | L = lists:foldl(fun(X, A) -> A + X end, 0, R), 81 | error_logger:info_report([ 82 | {transform, tuple}, 83 | {file, Filename}, 84 | {size_MB, size(Bin) / (1024 * 1024)}, 85 | {read_ms, Tread / 1000}, 86 | {parse_ms, Textr / 1000}, 87 | {per_line_us, Textr / L} 88 | ]). 89 | 90 | %% 91 | %% parses and imports a csv file, transforms each line into tuple and 92 | %% load data into ets table 93 | load_ets(Filename, N) -> 94 | T = list_to_atom(Filename), 95 | ets:new(T, [public, named_table, {write_concurrency, true}]), 96 | {Tread, {ok, Bin}} = timer:tc(file, read_file, [Filename]), 97 | {Textr, R} = timer:tc(csv, pparse, [ 98 | Bin, N, fun csv_util:import/2, {ets, T} 99 | ]), 100 | error_logger:info_report([ 101 | {load, ets}, 102 | {file, Filename}, 103 | {size_MB, size(Bin) / (1024 * 1024)}, 104 | {read_ms, Tread / 1000}, 105 | {parse_ms, Textr / 1000}, 106 | {per_line_us, Textr / 300000} 107 | ]), 108 | ets:delete(T). 109 | 110 | 111 | %% 112 | %% parses and imports a csv file, transforms each line into tuple and 113 | %% load data into process term storage 114 | load_pts(Filename, N) -> 115 | % spawn process term storage 116 | Pts = list_to_tuple( 117 | lists:map( 118 | fun(_) -> spawn(fun() -> pts([]) end) end, 119 | lists:seq(1,N) 120 | ) 121 | ), 122 | % event function 123 | Evt = fun({line, Line}, X) -> 124 | T = list_to_tuple(lists:reverse(Line)), 125 | Key = (erlang:phash2(erlang:element(1, T)) rem (N - 1)) + 1, 126 | %io:format('~p~n', [Key]), 127 | erlang:send(erlang:element(Key, Pts), {put, T}), 128 | X + 1 129 | end, 130 | {Tread, {ok, Bin}} = timer:tc(file, read_file, [Filename]), 131 | {Textr, R} = timer:tc(csv, pparse, [Bin, N, Evt, 0]), 132 | L = lists:foldl(fun(X, A) -> A + X end, 0, R), 133 | error_logger:info_report([ 134 | {load, pts}, 135 | {file, Filename}, 136 | {size_MB, size(Bin) / (1024 * 1024)}, 137 | {read_ms, Tread / 1000}, 138 | {parse_ms, Textr / 1000}, 139 | {per_line_us, Textr / L} 140 | ]), 141 | lists:map( 142 | fun(X) -> erlang:send(X, shutdown) end, 143 | tuple_to_list(Pts) 144 | ). 145 | 146 | 147 | pts(S) -> 148 | receive 149 | {put, T} -> pts([T | S]); 150 | {get, P} -> P ! S, pts(S); 151 | shutdown -> ok 152 | end. 153 | -------------------------------------------------------------------------------- /priv/gen_set.pl: -------------------------------------------------------------------------------- 1 | use POSIX qw/strftime/; 2 | 3 | my $n=@ARGV[0] * 1000; # number of lines 4 | my $d=@ARGV[1]; # number of fields 5 | 6 | my $t = time(); 7 | 8 | while ($n > 0) 9 | { 10 | $t++; 11 | print join(",", ( 12 | "key$n", 13 | strftime('%Y%m%d', localtime($t)), 14 | strftime('%H:%M:%S.543', localtime($t)), 15 | map { sprintf("\%.2f", rand(100)) } (1..$d) 16 | )) . ",zz\n"; 17 | $n--; 18 | } 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/csv.erl: -------------------------------------------------------------------------------- 1 | %% @author Dmitry Kolesnikov, 2 | %% @copyright (c) 2012 Dmitry Kolesnikov. All Rights Reserved 3 | %% 4 | %% Licensed under the 3-clause BSD License (the "License"); 5 | %% you may not use this file except in compliance with the License. 6 | %% You may obtain a copy of the License at 7 | %% 8 | %% http://www.opensource.org/licenses/BSD-3-Clause 9 | %% 10 | %% Unless required by applicable law or agreed to in writing, software 11 | %% distributed under the License is distributed on an "AS IS" BASIS, 12 | %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | %% See the License for the specific language governing permissions and 14 | %% limitations under the License 15 | %% 16 | %% @description 17 | %% The simple CSV-file parser based on event model. The parser generates an 18 | %% event/callback when the CSV line is parsed. The parser supports both 19 | %% sequential and parallel parsing. 20 | %% 21 | %% Acc 22 | %% +--------+ 23 | %% | | 24 | %% V | 25 | %% +---------+ | 26 | %% ----Input---->| Parser |--------> AccN 27 | %% + +---------+ 28 | %% Acc0 | 29 | %% V 30 | %% Event Line 31 | %% 32 | %% The parser takes as input binary stream, event handler function and 33 | %% initial state/accumulator. Event function is evaluated agains current 34 | %% accumulator and parsed line of csv-file. Note: The accumaltor allows to 35 | %% carry-on application specific state throught event functions. 36 | %% 37 | -module(csv). 38 | -author("Dmitry Kolesnikov "). 39 | -export([parse/3, split/4, pparse/4]). 40 | 41 | %% 42 | %% 43 | -define(QUOTE, $"). 44 | -define(FIELD_BY, $,). 45 | -define(LINE_BY, $\n). 46 | 47 | %% 48 | %% parse(In, Fun, Acc0) -> Acc 49 | %% In = binary(), input csv data to parse 50 | %% Fun = fun({line, Line}, Acc0) -> Acc, 51 | %% Line - list() list of parsed fields in reverse order 52 | %% Acc0 = term() application specific state/term carried throught 53 | %% parser event hadlers 54 | %% 55 | %% sequentially parses csv file 56 | %% 57 | parse(In, Fun, Acc0) -> 58 | parse(In, 0, 0, [], Fun, Acc0). 59 | 60 | parse(In, Pos, Len, Line, Fun, Acc0) when Pos + Len < size(In) -> 61 | case In of 62 | <<_:Pos/binary, _Tkn:Len/binary, ?QUOTE, _/binary>> -> 63 | % start field 64 | parse_quoted(In, Pos + Len + 1, 0, Line, Fun, Acc0); 65 | <<_:Pos/binary, Tkn:Len/binary, ?FIELD_BY, _/binary>> -> 66 | % field match 67 | parse(In, Pos + Len + 1, 0, [Tkn | Line], Fun, Acc0); 68 | <<_:Pos/binary, Tkn:Len/binary, ?LINE_BY>> -> 69 | % last line match 70 | Fun(eof, Fun({line, [Tkn | Line]}, Acc0)); 71 | <<_:Pos/binary, Tkn:Len/binary, ?LINE_BY, _/binary>> -> 72 | % line match 73 | parse(In, Pos + Len + 1, 0, [], 74 | Fun, Fun({line, [Tkn | Line]}, Acc0)); 75 | _ -> 76 | % no match increase token 77 | parse(In, Pos, Len + 1, Line, Fun, Acc0) 78 | end; 79 | parse(In, Pos, Len, Line, Fun, Acc0) -> 80 | <<_:Pos/binary, Tkn:Len/binary, _/binary>> = In, 81 | Fun(eof, Fun({line, [Tkn | Line]}, Acc0)). 82 | 83 | parse_quoted(In, Pos, Len, Line, Fun, Acc0) -> 84 | case In of 85 | <<_:Pos/binary, Tkn:Len/binary, ?QUOTE, ?QUOTE, _/binary>> -> 86 | parse_quoted(In, Pos, Len + 2, Line, Fun, Acc0); 87 | <<_:Pos/binary, Tkn:Len/binary, ?QUOTE, ?FIELD_BY, _/binary>> -> 88 | % field match 89 | parse(In, Pos + Len + 2, 0, [unescape(Tkn) | Line], Fun, Acc0); 90 | <<_:Pos/binary, Tkn:Len/binary, ?QUOTE, ?LINE_BY, _/binary>> -> 91 | % field match 92 | parse(In, Pos + Len + 2, 0, [], Fun, 93 | Fun({line, [unescape(Tkn) | Line]}, Acc0)); 94 | _ -> 95 | parse_quoted(In, Pos, Len + 1, Line, Fun, Acc0) 96 | end. 97 | 98 | %% 99 | %% unescape 100 | unescape(In) -> 101 | unescape(In, 0, 0, <<>>). 102 | 103 | unescape(In, I, Len, Acc) when I + Len < size(In) -> 104 | case In of 105 | <<_:I/binary, Tkn:Len/binary, ?QUOTE, ?QUOTE, _/binary>> -> 106 | unescape(In, I + Len + 2, 0, <>); 107 | _ -> 108 | unescape(In, I, Len + 1, Acc) 109 | end; 110 | unescape(In, I, Len, Acc) -> 111 | <<_:I/binary, Tkn:Len/binary>> = In, 112 | <>. 113 | 114 | %% 115 | %% split(In, Count, Fun, Acc0) -> Acc0 116 | %% In = binary(), input csv data to split 117 | %% Count = integer(), number of shard to produce 118 | %% Fun = fun({shard, Shard}, Acc0) -> Acc, 119 | %% Shard - binary() chunk of csv data 120 | %% Acc0 = term() application specific state/term carried throught 121 | %% parser event hadlers 122 | %% 123 | %% split csv file on chunks 124 | %% 125 | split(In, Count, Fun, Acc0) -> 126 | Size = erlang:round(size(In) / Count), % approximate a shard size 127 | split(In, 0, Size, Size, Fun, Acc0). 128 | 129 | split(In, Pos, Size, Size0, Fun, Acc0) when Pos + Size < size(In) -> 130 | case In of 131 | <<_:Pos/binary, Shard:Size/binary, ?LINE_BY>> -> 132 | Fun({shard, Shard}, Acc0); 133 | <<_:Pos/binary, Shard:Size/binary, ?LINE_BY, _/binary>> -> 134 | split(In, Pos + Size + 1, Size0, Size0, Fun, 135 | Fun({shard, Shard}, Acc0) 136 | ); 137 | _ -> 138 | split(In, Pos, Size + 1, Size0, Fun, Acc0) 139 | end; 140 | split(In, Pos, _Size, _Size0, Fun, Acc0) -> 141 | <<_:Pos/binary, Shard/binary>> = In, 142 | Fun({shard, Shard}, Acc0). 143 | 144 | %% 145 | %% pparse(In, Count, Fun, App) -> NApp 146 | %% In = binary(), input csv data to parse 147 | %% Count = integers(), defines a number of worker processes 148 | %% Fun = fun({line, Line}, Acc0) -> Acc, 149 | %% Line - list() list of parsed fields in reverse order 150 | %% Acc0 = term() application specific state/term carried throught 151 | %% parser event hadlers 152 | %% 153 | %% parallel parse csv file, the function shards the input csv data and 154 | %% parses each chunk in own process. 155 | %% 156 | pparse(In, Count, Fun, Acc0) -> 157 | Wrk = fun({shard, Shard}, Id) -> 158 | Pid = self(), 159 | spawn( 160 | fun() -> 161 | 162 | R = parse(Shard, Fun, Fun({shard, Shard}, Acc0)), 163 | Pid ! {shard, Id, R} 164 | end 165 | ), 166 | Id + 1 167 | end, 168 | N = split(In, Count, Wrk, 1), 169 | join(lists:seq(1,N - 1), []). 170 | 171 | 172 | join([H | T], Acc) -> 173 | receive 174 | {shard, H, R} when is_list(R) -> join(T, Acc ++ R); 175 | {shard, H, R} -> join(T, [R|Acc]) 176 | end; 177 | join([], Acc) -> 178 | Acc. 179 | -------------------------------------------------------------------------------- /src/csv_util.erl: -------------------------------------------------------------------------------- 1 | %% @author Dmitry Kolesnikov, 2 | %% @copyright (c) 2012 Dmitry Kolesnikov. All Rights Reserved 3 | %% 4 | %% Licensed under the 3-clause BSD License (the "License"); 5 | %% you may not use this file except in compliance with the License. 6 | %% You may obtain a copy of the License at 7 | %% 8 | %% http://www.opensource.org/licenses/BSD-3-Clause 9 | %% 10 | %% Unless required by applicable law or agreed to in writing, software 11 | %% distributed under the License is distributed on an "AS IS" BASIS, 12 | %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | %% See the License for the specific language governing permissions and 14 | %% limitations under the License 15 | %% 16 | %% @description 17 | %% 18 | -module(csv_util). 19 | -author("Dmitry Kolesnikov "). 20 | 21 | -export([import/2]). 22 | 23 | %% 24 | %% 25 | import({line, Line}, {ets, Id} = Acc) -> 26 | ets:insert(Id, list_to_tuple(lists:reverse(Line))), 27 | Acc. -------------------------------------------------------------------------------- /test/Makefile.am: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2012, Dmitry Kolesnikov 3 | # All Rights Reserved. 4 | # 5 | # Licensed under the 3-clause BSD License (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.opensource.org/licenses/BSD-3-Clause 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License 16 | # 17 | TESTS_ENVIRONMENT = $(top_builddir)/eunit 18 | TESTS = csv_tests.erl 19 | 20 | @MAKE_GNUWEB@ 21 | -------------------------------------------------------------------------------- /test/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.11.3 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 5 | # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software 6 | # Foundation, Inc. 7 | # This Makefile.in is free software; the Free Software Foundation 8 | # gives unlimited permission to copy and/or distribute it, 9 | # with or without modifications, as long as this notice is preserved. 10 | 11 | # This program is distributed in the hope that it will be useful, 12 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 13 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 14 | # PARTICULAR PURPOSE. 15 | 16 | @SET_MAKE@ 17 | VPATH = @srcdir@ 18 | pkgdatadir = $(datadir)/@PACKAGE@ 19 | pkgincludedir = $(includedir)/@PACKAGE@ 20 | pkglibdir = $(libdir)/@PACKAGE@ 21 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 22 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 23 | install_sh_DATA = $(install_sh) -c -m 644 24 | install_sh_PROGRAM = $(install_sh) -c 25 | install_sh_SCRIPT = $(install_sh) -c 26 | INSTALL_HEADER = $(INSTALL_DATA) 27 | transform = $(program_transform_name) 28 | NORMAL_INSTALL = : 29 | PRE_INSTALL = : 30 | POST_INSTALL = : 31 | NORMAL_UNINSTALL = : 32 | PRE_UNINSTALL = : 33 | POST_UNINSTALL = : 34 | subdir = test 35 | DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in 36 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 37 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 38 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 39 | $(ACLOCAL_M4) 40 | mkinstalldirs = $(install_sh) -d 41 | CONFIG_HEADER = $(top_builddir)/config.h 42 | CONFIG_CLEAN_FILES = 43 | CONFIG_CLEAN_VPATH_FILES = 44 | AM_V_GEN = $(am__v_GEN_@AM_V@) 45 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 46 | am__v_GEN_0 = @echo " GEN " $@; 47 | AM_V_at = $(am__v_at_@AM_V@) 48 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 49 | am__v_at_0 = @ 50 | SOURCES = 51 | DIST_SOURCES = 52 | am__tty_colors = \ 53 | red=; grn=; lgn=; blu=; std= 54 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 55 | ACLOCAL = @ACLOCAL@ 56 | AMTAR = @AMTAR@ 57 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 58 | AM_V_ERL = @AM_V_ERL@ 59 | AM_V_TAR = @AM_V_TAR@ 60 | AUTOCONF = @AUTOCONF@ 61 | AUTOHEADER = @AUTOHEADER@ 62 | AUTOMAKE = @AUTOMAKE@ 63 | AWK = @AWK@ 64 | CONF2LIB = @CONF2LIB@ 65 | CYGPATH_W = @CYGPATH_W@ 66 | DEFS = @DEFS@ 67 | ECHO_C = @ECHO_C@ 68 | ECHO_N = @ECHO_N@ 69 | ECHO_T = @ECHO_T@ 70 | ERL = @ERL@ 71 | ERLANG_APPS = @ERLANG_APPS@ 72 | ERLANG_LIBS = @ERLANG_LIBS@ 73 | ERLC = @ERLC@ 74 | ERLCFLAGS = @ERLCFLAGS@ 75 | INSTALL = @INSTALL@ 76 | INSTALL_DATA = @INSTALL_DATA@ 77 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 78 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 79 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 80 | LIBOBJS = @LIBOBJS@ 81 | LIBS = @LIBS@ 82 | LTLIBOBJS = @LTLIBOBJS@ 83 | MAKEINFO = @MAKEINFO@ 84 | MAKE_GNUWEB = @MAKE_GNUWEB@ 85 | MKDIR_P = @MKDIR_P@ 86 | PACKAGE = @PACKAGE@ 87 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 88 | PACKAGE_NAME = @PACKAGE_NAME@ 89 | PACKAGE_STRING = @PACKAGE_STRING@ 90 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 91 | PACKAGE_URL = @PACKAGE_URL@ 92 | PACKAGE_VERSION = @PACKAGE_VERSION@ 93 | PATH_SEPARATOR = @PATH_SEPARATOR@ 94 | PERL = @PERL@ 95 | SET_MAKE = @SET_MAKE@ 96 | SHELL = @SHELL@ 97 | STRIP = @STRIP@ 98 | VERSION = @VERSION@ 99 | abs_builddir = @abs_builddir@ 100 | abs_srcdir = @abs_srcdir@ 101 | abs_top_builddir = @abs_top_builddir@ 102 | abs_top_srcdir = @abs_top_srcdir@ 103 | am__leading_dot = @am__leading_dot@ 104 | am__tar = @am__tar@ 105 | am__untar = @am__untar@ 106 | am__v_ERL_ = @am__v_ERL_@ 107 | am__v_ERL_0 = @am__v_ERL_0@ 108 | am__v_TAR_ = @am__v_TAR_@ 109 | am__v_TAR_0 = @am__v_TAR_0@ 110 | bindir = @bindir@ 111 | build_alias = @build_alias@ 112 | builddir = @builddir@ 113 | datadir = @datadir@ 114 | datarootdir = @datarootdir@ 115 | docdir = @docdir@ 116 | dvidir = @dvidir@ 117 | exec_prefix = @exec_prefix@ 118 | have_erts = @have_erts@ 119 | have_kernel = @have_kernel@ 120 | have_stdlib = @have_stdlib@ 121 | host_alias = @host_alias@ 122 | htmldir = @htmldir@ 123 | includedir = @includedir@ 124 | infodir = @infodir@ 125 | install_sh = @install_sh@ 126 | libdir = @libdir@ 127 | liberldir = @liberldir@ 128 | libexecdir = @libexecdir@ 129 | localedir = @localedir@ 130 | localstatedir = @localstatedir@ 131 | mandir = @mandir@ 132 | mkdir_p = @mkdir_p@ 133 | oldincludedir = @oldincludedir@ 134 | pdfdir = @pdfdir@ 135 | pkgliberldir = @pkgliberldir@ 136 | prefix = @prefix@ 137 | program_transform_name = @program_transform_name@ 138 | psdir = @psdir@ 139 | sbindir = @sbindir@ 140 | sharedstatedir = @sharedstatedir@ 141 | srcdir = @srcdir@ 142 | sysconfdir = @sysconfdir@ 143 | target_alias = @target_alias@ 144 | top_build_prefix = @top_build_prefix@ 145 | top_builddir = @top_builddir@ 146 | top_srcdir = @top_srcdir@ 147 | 148 | # 149 | # Copyright (c) 2012, Dmitry Kolesnikov 150 | # All Rights Reserved. 151 | # 152 | # Licensed under the 3-clause BSD License (the "License"); 153 | # you may not use this file except in compliance with the License. 154 | # You may obtain a copy of the License at 155 | # 156 | # http://www.opensource.org/licenses/BSD-3-Clause 157 | # 158 | # Unless required by applicable law or agreed to in writing, software 159 | # distributed under the License is distributed on an "AS IS" BASIS, 160 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 161 | # See the License for the specific language governing permissions and 162 | # limitations under the License 163 | # 164 | TESTS_ENVIRONMENT = $(top_builddir)/eunit 165 | TESTS = csv_tests.erl 166 | all: all-am 167 | 168 | .SUFFIXES: 169 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 170 | @for dep in $?; do \ 171 | case '$(am__configure_deps)' in \ 172 | *$$dep*) \ 173 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 174 | && { if test -f $@; then exit 0; else break; fi; }; \ 175 | exit 1;; \ 176 | esac; \ 177 | done; \ 178 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu test/Makefile'; \ 179 | $(am__cd) $(top_srcdir) && \ 180 | $(AUTOMAKE) --gnu test/Makefile 181 | .PRECIOUS: Makefile 182 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 183 | @case '$?' in \ 184 | *config.status*) \ 185 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 186 | *) \ 187 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 188 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 189 | esac; 190 | 191 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 192 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 193 | 194 | $(top_srcdir)/configure: $(am__configure_deps) 195 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 196 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 197 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 198 | $(am__aclocal_m4_deps): 199 | tags: TAGS 200 | TAGS: 201 | 202 | ctags: CTAGS 203 | CTAGS: 204 | 205 | 206 | check-TESTS: $(TESTS) 207 | @failed=0; all=0; xfail=0; xpass=0; skip=0; \ 208 | srcdir=$(srcdir); export srcdir; \ 209 | list=' $(TESTS) '; \ 210 | $(am__tty_colors); \ 211 | if test -n "$$list"; then \ 212 | for tst in $$list; do \ 213 | if test -f ./$$tst; then dir=./; \ 214 | elif test -f $$tst; then dir=; \ 215 | else dir="$(srcdir)/"; fi; \ 216 | if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \ 217 | all=`expr $$all + 1`; \ 218 | case " $(XFAIL_TESTS) " in \ 219 | *[\ \ ]$$tst[\ \ ]*) \ 220 | xpass=`expr $$xpass + 1`; \ 221 | failed=`expr $$failed + 1`; \ 222 | col=$$red; res=XPASS; \ 223 | ;; \ 224 | *) \ 225 | col=$$grn; res=PASS; \ 226 | ;; \ 227 | esac; \ 228 | elif test $$? -ne 77; then \ 229 | all=`expr $$all + 1`; \ 230 | case " $(XFAIL_TESTS) " in \ 231 | *[\ \ ]$$tst[\ \ ]*) \ 232 | xfail=`expr $$xfail + 1`; \ 233 | col=$$lgn; res=XFAIL; \ 234 | ;; \ 235 | *) \ 236 | failed=`expr $$failed + 1`; \ 237 | col=$$red; res=FAIL; \ 238 | ;; \ 239 | esac; \ 240 | else \ 241 | skip=`expr $$skip + 1`; \ 242 | col=$$blu; res=SKIP; \ 243 | fi; \ 244 | echo "$${col}$$res$${std}: $$tst"; \ 245 | done; \ 246 | if test "$$all" -eq 1; then \ 247 | tests="test"; \ 248 | All=""; \ 249 | else \ 250 | tests="tests"; \ 251 | All="All "; \ 252 | fi; \ 253 | if test "$$failed" -eq 0; then \ 254 | if test "$$xfail" -eq 0; then \ 255 | banner="$$All$$all $$tests passed"; \ 256 | else \ 257 | if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \ 258 | banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \ 259 | fi; \ 260 | else \ 261 | if test "$$xpass" -eq 0; then \ 262 | banner="$$failed of $$all $$tests failed"; \ 263 | else \ 264 | if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \ 265 | banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \ 266 | fi; \ 267 | fi; \ 268 | dashes="$$banner"; \ 269 | skipped=""; \ 270 | if test "$$skip" -ne 0; then \ 271 | if test "$$skip" -eq 1; then \ 272 | skipped="($$skip test was not run)"; \ 273 | else \ 274 | skipped="($$skip tests were not run)"; \ 275 | fi; \ 276 | test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \ 277 | dashes="$$skipped"; \ 278 | fi; \ 279 | report=""; \ 280 | if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \ 281 | report="Please report to $(PACKAGE_BUGREPORT)"; \ 282 | test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \ 283 | dashes="$$report"; \ 284 | fi; \ 285 | dashes=`echo "$$dashes" | sed s/./=/g`; \ 286 | if test "$$failed" -eq 0; then \ 287 | col="$$grn"; \ 288 | else \ 289 | col="$$red"; \ 290 | fi; \ 291 | echo "$${col}$$dashes$${std}"; \ 292 | echo "$${col}$$banner$${std}"; \ 293 | test -z "$$skipped" || echo "$${col}$$skipped$${std}"; \ 294 | test -z "$$report" || echo "$${col}$$report$${std}"; \ 295 | echo "$${col}$$dashes$${std}"; \ 296 | test "$$failed" -eq 0; \ 297 | else :; fi 298 | 299 | distdir: $(DISTFILES) 300 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 301 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 302 | list='$(DISTFILES)'; \ 303 | dist_files=`for file in $$list; do echo $$file; done | \ 304 | sed -e "s|^$$srcdirstrip/||;t" \ 305 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 306 | case $$dist_files in \ 307 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 308 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 309 | sort -u` ;; \ 310 | esac; \ 311 | for file in $$dist_files; do \ 312 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 313 | if test -d $$d/$$file; then \ 314 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 315 | if test -d "$(distdir)/$$file"; then \ 316 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 317 | fi; \ 318 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 319 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 320 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 321 | fi; \ 322 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 323 | else \ 324 | test -f "$(distdir)/$$file" \ 325 | || cp -p $$d/$$file "$(distdir)/$$file" \ 326 | || exit 1; \ 327 | fi; \ 328 | done 329 | check-am: all-am 330 | $(MAKE) $(AM_MAKEFLAGS) check-TESTS 331 | check: check-am 332 | all-am: Makefile 333 | installdirs: 334 | install: install-am 335 | install-exec: install-exec-am 336 | install-data: install-data-am 337 | uninstall: uninstall-am 338 | 339 | install-am: all-am 340 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 341 | 342 | installcheck: installcheck-am 343 | install-strip: 344 | if test -z '$(STRIP)'; then \ 345 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 346 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 347 | install; \ 348 | else \ 349 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 350 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 351 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 352 | fi 353 | mostlyclean-generic: 354 | 355 | clean-generic: 356 | 357 | distclean-generic: 358 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 359 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 360 | 361 | maintainer-clean-generic: 362 | @echo "This command is intended for maintainers to use" 363 | @echo "it deletes files that may require special tools to rebuild." 364 | clean: clean-am 365 | 366 | clean-am: clean-generic mostlyclean-am 367 | 368 | distclean: distclean-am 369 | -rm -f Makefile 370 | distclean-am: clean-am distclean-generic 371 | 372 | dvi: dvi-am 373 | 374 | dvi-am: 375 | 376 | html: html-am 377 | 378 | html-am: 379 | 380 | info: info-am 381 | 382 | info-am: 383 | 384 | install-data-am: 385 | 386 | install-dvi: install-dvi-am 387 | 388 | install-dvi-am: 389 | 390 | install-exec-am: 391 | 392 | install-html: install-html-am 393 | 394 | install-html-am: 395 | 396 | install-info: install-info-am 397 | 398 | install-info-am: 399 | 400 | install-man: 401 | 402 | install-pdf: install-pdf-am 403 | 404 | install-pdf-am: 405 | 406 | install-ps: install-ps-am 407 | 408 | install-ps-am: 409 | 410 | installcheck-am: 411 | 412 | maintainer-clean: maintainer-clean-am 413 | -rm -f Makefile 414 | maintainer-clean-am: distclean-am maintainer-clean-generic 415 | 416 | mostlyclean: mostlyclean-am 417 | 418 | mostlyclean-am: mostlyclean-generic 419 | 420 | pdf: pdf-am 421 | 422 | pdf-am: 423 | 424 | ps: ps-am 425 | 426 | ps-am: 427 | 428 | uninstall-am: 429 | 430 | .MAKE: check-am install-am install-strip 431 | 432 | .PHONY: all all-am check check-TESTS check-am clean clean-generic \ 433 | distclean distclean-generic distdir dvi dvi-am html html-am \ 434 | info info-am install install-am install-data install-data-am \ 435 | install-dvi install-dvi-am install-exec install-exec-am \ 436 | install-html install-html-am install-info install-info-am \ 437 | install-man install-pdf install-pdf-am install-ps \ 438 | install-ps-am install-strip installcheck installcheck-am \ 439 | installdirs maintainer-clean maintainer-clean-generic \ 440 | mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ 441 | uninstall-am 442 | 443 | 444 | @MAKE_GNUWEB@ 445 | 446 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 447 | # Otherwise a system limit (for SysV at least) may be exceeded. 448 | .NOEXPORT: 449 | -------------------------------------------------------------------------------- /test/csv_tests.erl: -------------------------------------------------------------------------------- 1 | %% @author Dmitry Kolesnikov, 2 | %% @copyright (c) 2012 Dmitry Kolesnikov. All Rights Reserved 3 | %% 4 | %% Licensed under the 3-clause BSD License (the "License"); 5 | %% you may not use this file except in compliance with the License. 6 | %% You may obtain a copy of the License at 7 | %% 8 | %% http://www.opensource.org/licenses/BSD-3-Clause 9 | %% 10 | %% Unless required by applicable law or agreed to in writing, software 11 | %% distributed under the License is distributed on an "AS IS" BASIS, 12 | %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | %% See the License for the specific language governing permissions and 14 | %% limitations under the License 15 | %% 16 | -module(csv_tests). 17 | -author("Dmitry Kolesnikov "). 18 | -include_lib("eunit/include/eunit.hrl"). 19 | 20 | -define(CSV, <<"a,b,c\n1,2,3\nd,e,f\n4,5,6\n">>). 21 | -define(QCSV, <<"\"a\",\"b\",\"c\"\n\"1\",\"2\",\"3\"\n">>). 22 | 23 | 24 | parse_test() -> 25 | Fun = fun({line, X}, A) -> [lists:reverse(X) | A] end, 26 | Acc = csv:parse(?CSV, Fun, []), 27 | ?assert(lists:member([<<"a">>, <<"b">>, <<"c">>], Acc)), 28 | ?assert(lists:member([<<"1">>, <<"2">>, <<"3">>], Acc)), 29 | ?assert(lists:member([<<"d">>, <<"e">>, <<"f">>], Acc)), 30 | ?assert(lists:member([<<"4">>, <<"5">>, <<"6">>], Acc)). 31 | 32 | parse_quoted_test() -> 33 | Fun = fun({line, X}, A) -> [lists:reverse(X) | A] end, 34 | Acc = csv:parse(?QCSV, Fun, []), 35 | error_logger:error_report([{a, Acc}]), 36 | ?assert(lists:member([<<"a">>, <<"b">>, <<"c">>], Acc)), 37 | ?assert(lists:member([<<"1">>, <<"2">>, <<"3">>], Acc)). 38 | 39 | pparse_test() -> 40 | Fun = fun({line, X}, A) -> [lists:reverse(X) | A] end, 41 | Acc = csv:pparse(?CSV, 3, Fun, []), 42 | ?assert(lists:member([<<"a">>, <<"b">>, <<"c">>], Acc)), 43 | ?assert(lists:member([<<"1">>, <<"2">>, <<"3">>], Acc)), 44 | ?assert(lists:member([<<"d">>, <<"e">>, <<"f">>], Acc)), 45 | ?assert(lists:member([<<"4">>, <<"5">>, <<"6">>], Acc)). 46 | --------------------------------------------------------------------------------