diff --git a/pgreplay/.gitignore b/pgreplay/.gitignore new file mode 100644 index 00000000000..d68dcd712cd --- /dev/null +++ b/pgreplay/.gitignore @@ -0,0 +1,33 @@ +# Object files +*.o +*.obj + +# Libraries +*.lib +*.a + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# build products +pgreplay +pgreplay.exe +Makefile +config.h +config.log +config.status + +# test subdirectory +test/ + +# other versioning systems +.svn +CVS + +# M4 cache +autom4te.cache/ +.vscode +devtest \ No newline at end of file diff --git a/pgreplay/CHANGELOG b/pgreplay/CHANGELOG new file mode 100644 index 00000000000..77782d3c532 --- /dev/null +++ b/pgreplay/CHANGELOG @@ -0,0 +1,98 @@ +Version 1.4.0 + +Enhancements: +- Add a replay option "-n" that provides a "dry run" without actually + connecting to the database. + Patch by Manuel Vives. + +Bugfixes: +- Fix Makefile to call "install" portably. + It used to call "$(INSTALL) -D", which works on some, but not all systems + (MAC OS X is an example where it doesn't work). + Report by Jeff Doering. +- Fix crash after replay of DEALLOCATE ALL. + This caused a crash the next time prepared statements were deleted, for + example at the end of the database session. + Reported by Wan Shen Lim. + +Version 1.3.0 Feb 20 2017 + +Enhancements: +- Accept CPPFLAGS from configure in Makefile.in. + Patch by Marko Kreen. +- Add command line option -X to specify extra connect string fragment. + Needed to specify unusual connect string options. + Patch by Marko Kreen. +- Introduce replay filter options with "-D database" and "-U username" + to filter for a database or user during parsing. + Patch by Gilles Darold. + +Version 1.2.0 Aug 17 2012 + +Enhancements: +- Introduce replay option "-j" to jump ahead when all connections are idle. + This can speed up replay. The statistics will not include the skipped time, + but delay warnings will work as expected. + Idea and original patch by John Lumby. + +Bugfixes: +- Fix failure to parse string constants like E'\\' where the backslash before + a quotation mark is backslash-quoted. + Bug discovered by Jeff Frost. + +Version 1.1.0 Feb 09 2012 + +Enhancements: +- Respect environment variable DESTDIR in Makefile for RPM packagers. +- Improve execution delay reporting by introducing more intelligent time + steps when a report is written; every 10 seconds is way too spammy. +- Add documentation for interaction with pgFouine to the README. + +Bugfixes: +- Fix incorrect assumption that everything that starts with a dollar + sign is a dollar quoted string. This used to trigger bogus "end of dollar + quote not found" error messages when $n placeholders are used in PREPARE + statements. Discovered and fixed by Todd Owen. +- When pgreplay waited for a response on a connection because it needed to + send the next command, it used to sleep for one millisecond before + polling the socket again. This proved to be too long on busy systems, + where replay started to lag behind. Now pgreplay will not sleep, + but keep polling until the response is there. + +Version 1.0.0 Jun 03 2011 + +Bugfixes: +- Fix a connection and memory leak introduced by the new handling of FATAL + connection errors in 0.9.1. + Discovered by Denis Kostin. + +Version 0.9.1 Feb 26 2011 + +Enhancements: +- Calculate parse and execution statistics and display them at the end + of the run. + +Bugfixes: +- Use "=" instead of "==" in "test" comparisons in configure. + This improves portability. +- Change replay file timestamp to seconds after midnight of 2000-01-01 + in local time. This makes the replay file format independent of time zones + and avoids problems with mktime(3) implementations that don't like + the UNIX epoch. +- Ignore string literals in filter_bad_statements during log file parsing. + This keeps the function from getting confused by the contents of the + string. Discovered by Josh Berkus. +- Correctly handle prepared statements without parameters. + Discovered by Grigorij Lipin. +- Fix a corner case bug in read_log_line that can cause data corruption + when parsing a stderr log. Discovered by Grigorij Lipin. +- Skip memory dumps in stderr log caused by "out of memory" errors + instead of gagging on them. Discovered by Grigorij Lipin. +- Don't gag if a connection attempt results in a FATAL error during replay. + This can for example happen if max_connections has been exceeded or if a + non-existant user is specified with "trust" authentication. + Discovered by Grigorij Lipin. + +Version 0.9.0 Mar 19 2010 + +- first release diff --git a/pgreplay/Dockerfile b/pgreplay/Dockerfile new file mode 100644 index 00000000000..a0c78e6f613 --- /dev/null +++ b/pgreplay/Dockerfile @@ -0,0 +1,16 @@ +FROM ubuntu:22.10 + +RUN TZ=UTC +RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone +RUN apt-get update && \ + apt-get install --no-install-recommends -y tzdata make gcc libc6-dev postgresql-14 libpq-dev postgresql-doc-14 git ca-certificates && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +WORKDIR /root +RUN git clone https://github.com/laurenz/pgreplay.git +WORKDIR /root/pgreplay +RUN ./configure --with-postgres=/usr/bin +RUN make +RUN make install +RUN ln -s /root/pgreplay/pgreplay /usr/local/bin + diff --git a/pgreplay/LICENSE b/pgreplay/LICENSE new file mode 100644 index 00000000000..8185f6d8b2f --- /dev/null +++ b/pgreplay/LICENSE @@ -0,0 +1,19 @@ +Portions Copyright (c) 2017-2023, CYBERTEC PostgreSQL International GmbH +Portions Copyright (c) 2010-2017, Magistrat der Stadt Wien + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose, without fee, and without a written agreement +is hereby granted, provided that the above copyright notice and this paragraph +and the following two paragraphs appear in all copies. + +IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR +DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING +LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, +EVEN IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGE. + +THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, +BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, +AND THE COPYRIGHT HOLDER HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, +SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. diff --git a/pgreplay/Makefile.in b/pgreplay/Makefile.in new file mode 100644 index 00000000000..c6d784c460a --- /dev/null +++ b/pgreplay/Makefile.in @@ -0,0 +1,64 @@ +CFLAGS = @CFLAGS@ +CPPFLAGS = @CPPFLAGS@ +LDFLAGS = @LDFLAGS@ +LIBS = @LIBS@ +CC = @CC@ +EXTRA_OBJS = @EXTRA_OBJS@ +prefix = @prefix@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +datarootdir = @datarootdir@ +datadir = @datadir@ +mandir = @mandir@ +docdir = @docdir@ +htmldir = @htmldir@ +INSTALL = @INSTALL@ +VERSION = @PACKAGE_VERSION@ +EXE = pgreplay +OBJS = parse.o replayitem.o main.o replayfile.o database.o $(EXTRA_OBJS) +HEADERS = config.h pgreplay.h + +.PHONY: clean distclean tarball test install install_bin install_man install_html + +.SUFFIXES: .o .c .h + +$(EXE): $(OBJS) $(HEADERS) + $(CC) -o $@ $(CFLAGS) $(CPPFLAGS) $(OBJS) $(LDFLAGS) $(LIBS) + +$(OBJS): $(HEADERS) + +clean: + rm -f $(OBJS) $(EXE) + +distclean: clean + rm -rf Makefile config.h config.h.in~ config.log config.cache config.status autom4te.cache test/runtest.sh pgreplay-$(VERSION).tar* + +tarball: distclean + if tar --version 2>/dev/null | grep -q GNU; then : ;else echo "this requires GNU tar" 1>&2; exit 1; fi + ln -s "`pwd`" /tmp/pgreplay-$(VERSION) + tar -cf pgreplay-$(VERSION).tar -h -C /tmp --exclude .svn --exclude CVS --exclude pgreplay-$(VERSION).tar pgreplay-$(VERSION) --exclude test/testrun.c + rm /tmp/pgreplay-$(VERSION) + gzip -9 pgreplay-$(VERSION).tar + +$(EXE).html: $(EXE).1 + groff -Thtml -mman $< > $@ + +test: $(EXE) test/runtest.sh + cd test && ./runtest.sh + +install: install_bin install_man + +install_bin: $(EXE) + $(INSTALL) -d $(DESTDIR)$(bindir) + $(INSTALL) -m 0755 $< $(DESTDIR)$(bindir)/$< + +install_man: $(EXE).1 + $(INSTALL) -d $(DESTDIR)$(mandir)/man1 + $(INSTALL) -m 0644 $< $(DESTDIR)$(mandir)/man1/$< + +install_html: $(EXE).html + $(INSTALL) -d $(DESTDIR)$(htmldir) + $(INSTALL) -m 0644 $< $(DESTDIR)$(htmldir)/$< + +.c.o: + $(CC) -c $(CFLAGS) -DVERSION='"$(VERSION)"' $< diff --git a/pgreplay/README.md b/pgreplay/README.md new file mode 100644 index 00000000000..a4ffb3596dc --- /dev/null +++ b/pgreplay/README.md @@ -0,0 +1,333 @@ +pgreplay - record and replay real-life database workloads +========================================================= + +pgreplay reads a PostgreSQL log file (*not* a WAL file), extracts the +SQL statements and executes them in the same order and with the original +timing against a PostgreSQL database. + +If the execution of statements gets behind schedule, warning messages +are issued that indicate that the server cannot handle the load in a +timely fashion. + +A final report gives you a useful statistical analysis of your workload +and its execution. + +The idea is to replay a real-world database workload as exactly as possible. + +This is useful for performance tests, particularly in the following +situations: +- You want to compare the performance of your PostgreSQL application + on different hardware or different operating systems. +- You want to upgrade your database and want to make sure that the new + database version does not suffer from performance regressions that + affect you. + +Moreover, pgreplay can give you some feeling as to how your application +*might* scale by allowing you to try to replay the workload at a higher +speed (if that is possible; see +[implementation details](#implementation-details) below). +Be warned, though, that 500 users working at double speed is not really +the same as 1000 users working at normal speed. + +While pgreplay will find out if your database application will encounter +performance problems, it does not provide a lot of help in the analysis of +the cause of these problems. Combine pgreplay with a specialized analysis +program like [pgBadger](https://pgbadger.darold.net/) for that. + +As an additional feature, pgreplay lets you split the replay in two +parts: you can parse the log file and create a "replay file", which +contains just the statements to be replayed and is hopefully much +smaller than the original log file. +Such a replay file can then be run against a database. + +pgreplay is written by Laurenz Albe and is inspired by "Playr" +which never made it out of Beta. + +Installation +============ + +pgreplay needs PostgreSQL 8.0 or better. + +It is supposed to compile without warnings and run on all platforms +supported by PostgreSQL. +Since I only got to test it on Linux, AIX, FreeBSD and Windows, there may be +problems with other platforms. I am interested in reports and fixes for +these platforms. +On Windows, only the MinGW build environment is supported (I have no +other compiler). That means that there is currently no 64-bit build +for Windows (but a 32-bit executable should work fine anywhere). + +To build pgreplay, you will need the `pg_config` utility. If you installed +PostgreSQL using installation packages, you will probably have to install +the development package that contains `pg_config` and the header files. + +If `pg_config` is on the `PATH`, the installation process will look like this: + +- unpack the tarball +- `./configure` +- `make` +- `make test` (optional, described below) +- `make install` (as superuser) + +If your PostgreSQL installation is in a nonstandard directory, you +will have to use the `--with-postgres=` +option of `configure`. + +Unless you link it statically, pgreplay requires the PostgreSQL client +shared library on the system where it is run. + +The following utilities are only necessary if you intend to develop pgreplay: +- autoconf 2.62 or better to generate `configure` +- GNU tar to `make tarball` (unless you want to roll it by hand) +- groff to make the HTML documentation with `make html` + +Docker +------ + +The `Dockerfile` provided with the software can be used as a starting +point for creating a container that runs pgreplay. Adapt is as necessary. + +Here are commands to build and run the container: + +``` +# build the image +docker build -t laurenz/pgreplay -f Dockerfile . + +# and run it +docker run --rm -ti -v $(pwd):/app -w /app laurenz/pgreplay pgreplay -h +``` + +Testing +------- + +You can run a test on pgreplay before installing by running `make test`. +This will parse sample log files and check that the result is as +expected. + +Then an attempt is made to replay the log files and check if that +works as expected. For this you need psql installed and a PostgreSQL server +running (on this or another machine) so that the following command +will succeed: + + psql -U postgres -d postgres -l + +You can set up the `PGPORT` and `PGHOST` environment variables and a password +file for the user if necessary. + +There have to be a login roles named `hansi` and `postgres` in the database, +and both users must be able to connect without a password. Only `postgres` +will be used to run actual SQL statements. The regression test will create +a table `runtest` and use it, and it will drop the table when it is done. + +Usage +===== + +First, you will need to record your real-life workload. +For that, set the following parameters in `postgresql.conf`: + +- `log_min_messages = error` (or more) + (if you know that you have no cancel requests, `log` will do) +- `log_min_error_statement = log` (or more) +- `log_connections = on` +- `log_disconnections = on` +- `log_line_prefix = '%m|%u|%d|%c|'` (if you don't use CSV logging) +- `log_statement = 'all'` +- `lc_messages` must be set to English (the encoding does not matter) +- `bytea_output = escape` (from version 9.0 on, only if you want to replay + the log on 8.4 or earlier) + +It is highly recommended that you use CSV logging, because anything that +the PostgreSQL server or any loaded modules write to standard error will +be written to the stderr log and might confuse the parser. + +Then let your users have their way with the database. + +Make sure that you have a `pg_dumpall` of the database cluster from the time +of the start of your log file (or use the `-b` option with the time of your +backup). Alternatively, you can use point-in-time-recovery to clone your +database at the appropriate time. + +When you are done, restore the database (in the "before" state) to the +machine where you want to perform the load test and run pgreplay against +that database. + +Try to create a scenario as similar to your production system as +possible (except for the change you want to test, of course). For example, +if your clients connect over the network, run pgreplay on a different +machine from where the database server is running. + +Since passwords are not logged (and pgreplay consequently has no way of +knowing them), you have two options: either change `pg_hba.conf` on the +test database to allow `trust` authentication or (if that is unacceptable) +create a password file as described by the PostgreSQL documentation. +Alternatively, you can change the passwords of all application users +to one single password that you supply to pgreplay with the `-W` option. + +Limitations +=========== + +pgreplay can only replay what is logged by PostgreSQL. +This leads to some limitations: + +- `COPY` statements will not be replayed, because the copy data are not logged. + I could have supported `COPY TO` statements, but that would have imposed a + requirement that the directory structure on the replay system must be + identical to the original machine. + And if your application runs on the same machine as your database and they + interact on the file system, pgreplay will probably not help you much + anyway. +- Fast-path API function calls are not logged and will not be replayed. + Unfortunately, this includes the Large Object API. +- Since the log file is always written in the database encoding (which you + can specify with the `-E` switch of pgreplay), all `SET client_encoding` + statements will be ignored. +- If your cluster contains databases with different encoding, the log file + will have mixed encoding as well. You cannot use pgreplay well in such + an environment, because many statements against databases whose + encoding does not match the `-E` switch will fail. +- Since the preparation time of prepared statements is not logged (unless + `log_min_messages` is `debug2` or more), these statements will be prepared + immediately before they are first executed during replay. +- All parameters of prepared statements are logged as strings, no matter + what type was originally specified during bind. + This can cause errors during replay with expressions like `$1 + $2`, + which will cause the error `operator is not unique: unknown + unknown`. + +While pgreplay makes sure that commands are sent to the server in the +order in which they were originally executed, there is no way to guarantee +that they will be executed in the same order during replay: Network +delay, processor contention and other factors may cause a later command +to "overtake" an earlier one. While this does not matter if the +commands don't affect each other, it can lead to SQL statements hitting +locks unexpectedly, causing replay to deadlock and "hang". +This is particularly likely if many different sessions change the same data +repeatedly in short intervals. + +You can work around this problem by canceling the waiting statement with +pg_cancel_backend. Replay should continue normally after that. + +Implementation details +====================== + +pgreplay will track the "session ID" associated with each log entry (the +session ID uniquely identifies a database connection). +For each new session ID, a new database connection will be opened during +replay. Each statement will be sent on the corresponding connection, so +transactions are preserved and concurrent sessions cannot get in each +other's way. + +The order of statements in the log file is strictly preserved, so there +cannot be any race conditions caused by different execution speeds on +separate connections. On the other hand, that means that long running +queries on one connection may stall execution on concurrent connections, +but that's all you can get if you want to reproduce the exact same +workload on a system that behaves differently. + +As an example, consider this (simplified) log file: + + session 1|connect + session 2|connect + session 1|statement: BEGIN + session 1|statement: SELECT something(1) + session 2|statement: BEGIN + session 2|statement: SELECT something(2) + session 1|statement: SELECT something(3) + session 2|statement: ROLLBACK + session 2|disconnect + session 1|statement: COMMIT + session 2|disconnect + +This will cause two database connections to be opened, so the `ROLLBACK` in +session 2 will not affect session 1. +If `SELECT something(2)` takes longer than expected (longer than it did in +the original), that will not stall the execution of `SELECT something(3)` +because it runs on a different connection. The `ROLLBACK`, however, has to +wait for the completion of the long statement. Since the order of statements +is preserved, the `COMMIT` on session 1 will have to wait until the `ROLLBACK` +on session 2 has started (but it does not have to wait for the completion of +the `ROLLBACK`). + +pgreplay is implemented in C and makes heavy use of asynchronous command +processing (which is the reason why it is implemented in C). +This way a single process can handle many concurrent connections, which +makes it possible to get away without multithreading or multiprocessing. + +This avoids the need for synchronization and many portability problems. +But since TINSTAAFL, the choice of C brings along its own portability +problems. Go figure. + +Replay file format +------------------ + +The replay file is a binary file, integer numbers are stored in network +byte order. + +Each record in the replay file corresponds to one database operation +and is constructed as follows: +- 4-byte `unsigned int`: log file timestamp in seconds since 2000-01-01 +- 4-byte `unsigned int`: fractional part of log file timestamp in microseconds +- 8-byte `unsigned int`: session id +- 1-byte `unsigned int`: type of the database action: + - 0 is connect + - 1 is disconnect + - 2 is simple statement execution + - 3 is statement preparation + - 4 is execution of a prepared statement + - 5 is cancel request +- The remainder of the record is specific to the action, strings are stored + with a preceeding 4-byte unsigned int that contains the length. + Read the source for details. +- Each record is terminated by a new-line character (byte 0x0A). + + +Using for polardb +====== +- make sure pg_stat_statements, plpgsql, system_stats was installed.system_stats install methods refer to https://github.com/EnterpriseDB/system_stats. +```sql +postgres=# create extension plpgsql; +postgres=# create extension pg_stat_statements; +postgres=# create extension system_stats; +postgres=# \dx + List of installed extensions + Name | Version | Schema | Description +--------------------+---------+------------+----------------------------------------------------------- + pg_stat_statements | 1.6 | public | track execution statistics of all SQL statements executed + plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language + system_stats | 1.0 | public | EnterpriseDB system statistics for PostgreSQL +(3 rows) +``` + +- postgres.conf configure +```sh +# log setting for gpreplay +log_min_messages = error +# (if you know that you have no cancel requests, log will do) +log_min_error_statement = log +log_connections = on +log_disconnections = on +log_line_prefix = '%t|%u|%d|%c|%N|%L|' +log_statement = 'all' +# lc_messages must be set to English (the encoding does not matter) +bytea_output = escape +# (from version 9.0 on, only if you want to replay the log on 8.4 or earlier) +# polar_auditlog_max_query_length = 49152 +polar_auditlog_max_query_length_limit = false +``` +- run read audit log from $PGDATA/log/replay_xxx.log and replay sql to databse, reporting monitor info every 3 seconds. +```sh +./pgreplay -P -m 3 -h 127.0.0.1 -p 5432 -W benchmarksql $PGDATA/log/replay_xxx.log +``` +Support +======= + +If you have a problem or question, the preferred option is to [open an +issue](https://github.com/laurenz/pgreplay/issues). +This requires a GitHub account. + +Professional support can be bought from +[CYBERTEC PostgreSQL International GmbH](https://www.cybertec-postgresql.com/). + +TODO list +========= + +Nothing currently. Tell me if you have good ideas. diff --git a/pgreplay/TODO b/pgreplay/TODO new file mode 100644 index 00000000000..37e54e61adb --- /dev/null +++ b/pgreplay/TODO @@ -0,0 +1,7 @@ +This is a list of things that could be improved. +Help is welcome! + +- Use "single-row mode" with PQsetSingleRowMode. + This would reduce the memory requirements for large result sets. + + Noted by Thomas Dziedzic in #15. diff --git a/pgreplay/config.guess b/pgreplay/config.guess new file mode 100755 index 00000000000..31e01efec3e --- /dev/null +++ b/pgreplay/config.guess @@ -0,0 +1,1463 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-11-07' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2017 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case "${UNAME_MACHINE_ARCH}" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + exit ;; + *:MidnightBSD:*:*) + echo ${UNAME_MACHINE}-unknown-midnightbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; + *:Redox:*:*) + echo ${UNAME_MACHINE}-unknown-redox + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31?) HP_ARCH=m68000 ;; + 9000/[34]??) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = hppa2.0w ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + k1om:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc + if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_PPC >/dev/null + then + UNAME_PROCESSOR=powerpc + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-*:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-*:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + NSX-*:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = 386; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; +esac + +echo "$0: unable to guess system type" >&2 + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}" in + mips:Linux | mips64:Linux) + # If we got here on MIPS GNU/Linux, output extra information. + cat >&2 <&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-functions 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/pgreplay/config.h.in b/pgreplay/config.h.in new file mode 100644 index 00000000000..a665811518b --- /dev/null +++ b/pgreplay/config.h.in @@ -0,0 +1,138 @@ +/* config.h.in. Generated from configure.in by autoheader. */ + +/* Define if building universal (internal helper macro) */ +#undef AC_APPLE_UNIVERSAL_BUILD + +/* Define to 1 if you have the header file. */ +#undef HAVE_FCNTL_H + +/* Define to 1 if you have the `gettimeofday' function. */ +#undef HAVE_GETTIMEOFDAY + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `pq' library (-lpq). */ +#undef HAVE_LIBPQ + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the `select' function. */ +#undef HAVE_SELECT + +/* Define to 1 if you have the `setenv' function. */ +#undef HAVE_SETENV + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the `strchr' function. */ +#undef HAVE_STRCHR + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the `strtoul' function. */ +#undef HAVE_STRTOUL + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TIME_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* The size of `unsigned int', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_INT + +/* The size of `unsigned long', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_LONG + +/* The size of `unsigned short', as computed by sizeof. */ +#undef SIZEOF_UNSIGNED_SHORT + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if you can safely include both and . */ +#undef TIME_WITH_SYS_TIME + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#if defined AC_APPLE_UNIVERSAL_BUILD +# if defined __BIG_ENDIAN__ +# define WORDS_BIGENDIAN 1 +# endif +#else +# ifndef WORDS_BIGENDIAN +# undef WORDS_BIGENDIAN +# endif +#endif + +/* Enable large inode numbers on Mac OS X 10.5. */ +#ifndef _DARWIN_USE_64_BIT_INODE +# define _DARWIN_USE_64_BIT_INODE 1 +#endif + +/* Number of bits in a file offset, on hosts where this is settable. */ +#undef _FILE_OFFSET_BITS + +/* Define for large files, on AIX-style hosts. */ +#undef _LARGE_FILES + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint64_t typedef from , + , or is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT64_T + +/* Define to `unsigned int' if does not define. */ +#undef size_t + +/* Define to `int' if does not define. */ +#undef ssize_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 64 bits if + such a type exists and the standard includes do not define it. */ +#undef uint64_t diff --git a/pgreplay/config.sub b/pgreplay/config.sub new file mode 100755 index 00000000000..00f68b8e5f3 --- /dev/null +++ b/pgreplay/config.sub @@ -0,0 +1,1848 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-11-23' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Options: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2017 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | wasm32 \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | wasm32-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2*) + basic_machine=m68k-bull + os=-sysv3 + ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + wasm32) + basic_machine=wasm32-unknown + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + x64) + basic_machine=x86_64-pc + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases that might get confused + # with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -pikeos*) + # Until real need of OS specific support for + # particular features comes up, bare metal + # configurations are quite functional. + case $basic_machine in + arm*) + os=-eabi + ;; + *) + os=-elf + ;; + esac + ;; + -nacl*) + ;; + -ios) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + pru-*) + os=-elf + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-functions 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/pgreplay/configure b/pgreplay/configure new file mode 100755 index 00000000000..60358dfbb7b --- /dev/null +++ b/pgreplay/configure @@ -0,0 +1,5806 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69 for pgreplay 1.4.0. +# +# Report bugs to . +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: https://github.com/laurenz/pgreplay/issues about your +$0: system, including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME='pgreplay' +PACKAGE_TARNAME='pgreplay' +PACKAGE_VERSION='1.4.0' +PACKAGE_STRING='pgreplay 1.4.0' +PACKAGE_BUGREPORT='https://github.com/laurenz/pgreplay/issues' +PACKAGE_URL='http://laurenz.github.io/pgreplay/' + +ac_unique_file="parse.c" +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +POW_LIB +EGREP +GREP +CPP +EXTRA_OBJS +ac_prefix_program +pgbindir +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +INSTALL_DATA +INSTALL_SCRIPT +INSTALL_PROGRAM +build_os +build_vendor +build_cpu +build +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +with_postgres +enable_largefile +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures pgreplay 1.4.0 to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/pgreplay] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF + +System types: + --build=BUILD configure for building on BUILD [guessed] +_ACEOF +fi + +if test -n "$ac_init_help"; then + case $ac_init_help in + short | recursive ) echo "Configuration of pgreplay 1.4.0:";; + esac + cat <<\_ACEOF + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --disable-largefile omit support for large files + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-postgres=DIR specify location of pg_config for your PostgreSQL + installation + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +pgreplay home page: . +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +pgreplay configure 1.4.0 +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## --------------------------------------------------------- ## +## Report this to https://github.com/laurenz/pgreplay/issues ## +## --------------------------------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_check_type LINENO TYPE VAR INCLUDES +# ------------------------------------------- +# Tests whether TYPE exists after having included INCLUDES, setting cache +# variable VAR accordingly. +ac_fn_c_check_type () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof ($2)) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +if (sizeof (($2))) + return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + eval "$3=yes" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_type + +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_uintX_t + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 &5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by pgreplay $as_me 1.4.0, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + + +ac_config_headers="$ac_config_headers config.h" + +ac_aux_dir= +for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi +done +if test -z "$ac_aux_dir"; then + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 +fi + +# These three variables are undocumented and unsupported, +# and are intended to be withdrawn in a future Autoconf release. +# They can cause serious problems if a builder's source tree is in a directory +# whose full name contains unusual characters. +ac_config_guess="$SHELL $ac_aux_dir/config.guess" # Please don't use this var. +ac_config_sub="$SHELL $ac_aux_dir/config.sub" # Please don't use this var. +ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. + + +# Make sure we can run config.sub. +$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 || + as_fn_error $? "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5 + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5 +$as_echo_n "checking build system type... " >&6; } +if ${ac_cv_build+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_build_alias=$build_alias +test "x$ac_build_alias" = x && + ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"` +test "x$ac_build_alias" = x && + as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5 +ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` || + as_fn_error $? "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5 + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5 +$as_echo "$ac_cv_build" >&6; } +case $ac_cv_build in +*-*-*) ;; +*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;; +esac +build=$ac_cv_build +ac_save_IFS=$IFS; IFS='-' +set x $ac_cv_build +shift +build_cpu=$1 +build_vendor=$2 +shift; shift +# Remember, the first character of IFS is used to create $*, +# except with old shells: +build_os=$* +IFS=$ac_save_IFS +case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac + + + +# Checks for programs. +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AmigaOS /C/install, which installs bootblocks on floppy discs +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# OS/2's system install, which has a completely different semantic +# ./install, which can be erroneously created by make from ./install.sh. +# Reject install programs that cannot install multiple files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 +$as_echo_n "checking for a BSD-compatible install... " >&6; } +if test -z "$INSTALL"; then +if ${ac_cv_path_install+:} false; then : + $as_echo_n "(cached) " >&6 +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ + /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ + /usr/ucb/* ) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then + if test $ac_prog = install && + grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + elif test $ac_prog = install && + grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then + # program-specific install script used by HP pwplus--don't use. + : + else + rm -rf conftest.one conftest.two conftest.dir + echo one > conftest.one + echo two > conftest.two + mkdir conftest.dir + if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" && + test -s conftest.one && test -s conftest.two && + test -s conftest.dir/conftest.one && + test -s conftest.dir/conftest.two + then + ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c" + break 3 + fi + fi + fi + done + done + ;; +esac + + done +IFS=$as_save_IFS + +rm -rf conftest.one conftest.two conftest.dir + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL=$ac_cv_path_install + else + # As a last resort, use the slow shell script. Don't cache a + # value for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the value is a relative name. + INSTALL=$ac_install_sh + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 +$as_echo "$INSTALL" >&6; } + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + for ac_prog in gcc cc + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in gcc cc +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + +# add -Wall to CFLAGS for gcc +if test "$GCC" = yes; then CFLAGS="-Wall $CFLAGS"; fi + +# check if ld supports -rpath +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker supports -rpath" >&5 +$as_echo_n "checking whether the linker supports -rpath... " >&6; } +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib" + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +main() {} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + rpath=yes +else + rpath=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LDFLAGS="$save_LDFLAGS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $rpath" >&5 +$as_echo "$rpath" >&6; } + + +# Check whether --with-postgres was given. +if test "${with_postgres+set}" = set; then : + withval=$with_postgres; if ! test -x "$with_postgres"/pg_config; then + echo "*** pg_config not found in '$with_postgres'" 1>&2 + exit 1 + fi + pgbindir=`"$with_postgres"/pg_config --bindir` + + if test $build_os = mingw32; then pglibdir="$pgbindir"; else pglibdir=`"$with_postgres"/pg_config --libdir`; fi + pgincludedir=`"$with_postgres"/pg_config --includedir` + LDFLAGS="$LDFLAGS -L$pglibdir" + if test $rpath = yes; then LDFLAGS="$LDFLAGS -Wl,-rpath,$pglibdir"; fi + CFLAGS="$CFLAGS -I$pgincludedir" + PATH=`"$with_postgres"/pg_config --bindir`:$PATH +fi + + +# Install with PostgreSQL by default +if test "x$prefix" = xNONE; then + $as_echo_n "checking for prefix by " >&6 + # Extract the first word of "pg_config", so it can be a program name with args. +set dummy pg_config; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_ac_prefix_program+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $ac_prefix_program in + [\\/]* | ?:[\\/]*) + ac_cv_path_ac_prefix_program="$ac_prefix_program" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_ac_prefix_program="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +ac_prefix_program=$ac_cv_path_ac_prefix_program +if test -n "$ac_prefix_program"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_prefix_program" >&5 +$as_echo "$ac_prefix_program" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test -n "$ac_prefix_program"; then + prefix=`$as_dirname -- "$ac_prefix_program" || +$as_expr X"$ac_prefix_program" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_prefix_program" : 'X\(//\)[^/]' \| \ + X"$ac_prefix_program" : 'X\(//\)$' \| \ + X"$ac_prefix_program" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_prefix_program" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + prefix=`$as_dirname -- "$prefix" || +$as_expr X"$prefix" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$prefix" : 'X\(//\)[^/]' \| \ + X"$prefix" : 'X\(//\)$' \| \ + X"$prefix" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$prefix" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + fi +fi + + +# Checks for libraries. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PQsendPrepare in -lpq" >&5 +$as_echo_n "checking for PQsendPrepare in -lpq... " >&6; } +if ${ac_cv_lib_pq_PQsendPrepare+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lpq $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char PQsendPrepare (); +int +main () +{ +return PQsendPrepare (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_pq_PQsendPrepare=yes +else + ac_cv_lib_pq_PQsendPrepare=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pq_PQsendPrepare" >&5 +$as_echo "$ac_cv_lib_pq_PQsendPrepare" >&6; } +if test "x$ac_cv_lib_pq_PQsendPrepare" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBPQ 1 +_ACEOF + + LIBS="-lpq $LIBS" + +else + as_fn_error $? " +*** cannot locate PostgreSQL client library +*** required is version 8.0 or better +" "$LINENO" 5 +fi + + +# special Windows settings +if test $build_os = mingw32; then + EXTRA_OBJS=windows.o + + # assume socks library is present + # we have a problem using AC_CHECK_LIB because the function is __stdcall + LIBS="$LIBS -lwsock32" +fi + +# Checks for header files. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 +$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } +if ${ac_cv_header_time+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_time=yes +else + ac_cv_header_time=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 +$as_echo "$ac_cv_header_time" >&6; } +if test $ac_cv_header_time = yes; then + +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in fcntl.h netinet/in.h stdint.h stdlib.h string.h sys/time.h unistd.h inttypes.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + +ac_fn_c_check_header_compile "$LINENO" "libpq-fe.h" "ac_cv_header_libpq_fe_h" "/* dummy */ +" +if test "x$ac_cv_header_libpq_fe_h" = xyes; then : + +else + as_fn_error $? "PostgreSQL header files not found" "$LINENO" 5 +fi + + + +# Checks for typedefs, structures, and compiler characteristics. +# Check whether --enable-largefile was given. +if test "${enable_largefile+set}" = set; then : + enableval=$enable_largefile; +fi + +if test "$enable_largefile" != no; then + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for special C compiler options needed for large files" >&5 +$as_echo_n "checking for special C compiler options needed for large files... " >&6; } +if ${ac_cv_sys_largefile_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_sys_largefile_CC=no + if test "$GCC" != yes; then + ac_save_CC=$CC + while :; do + # IRIX 6.2 and later do not support large files by default, + # so use the C compiler's -n32 option if that helps. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF + if ac_fn_c_try_compile "$LINENO"; then : + break +fi +rm -f core conftest.err conftest.$ac_objext + CC="$CC -n32" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_largefile_CC=' -n32'; break +fi +rm -f core conftest.err conftest.$ac_objext + break + done + CC=$ac_save_CC + rm -f conftest.$ac_ext + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_CC" >&5 +$as_echo "$ac_cv_sys_largefile_CC" >&6; } + if test "$ac_cv_sys_largefile_CC" != no; then + CC=$CC$ac_cv_sys_largefile_CC + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _FILE_OFFSET_BITS value needed for large files" >&5 +$as_echo_n "checking for _FILE_OFFSET_BITS value needed for large files... " >&6; } +if ${ac_cv_sys_file_offset_bits+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _FILE_OFFSET_BITS 64 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_file_offset_bits=64; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_file_offset_bits=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_file_offset_bits" >&5 +$as_echo "$ac_cv_sys_file_offset_bits" >&6; } +case $ac_cv_sys_file_offset_bits in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _FILE_OFFSET_BITS $ac_cv_sys_file_offset_bits +_ACEOF +;; +esac +rm -rf conftest* + if test $ac_cv_sys_file_offset_bits = unknown; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for _LARGE_FILES value needed for large files" >&5 +$as_echo_n "checking for _LARGE_FILES value needed for large files... " >&6; } +if ${ac_cv_sys_large_files+:} false; then : + $as_echo_n "(cached) " >&6 +else + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=no; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#define _LARGE_FILES 1 +#include + /* Check that off_t can represent 2**63 - 1 correctly. + We can't simply define LARGE_OFF_T to be 9223372036854775807, + since some C++ compilers masquerading as C compilers + incorrectly reject 9223372036854775807. */ +#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 + && LARGE_OFF_T % 2147483647 == 1) + ? 1 : -1]; +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_sys_large_files=1; break +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_cv_sys_large_files=unknown + break +done +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_large_files" >&5 +$as_echo "$ac_cv_sys_large_files" >&6; } +case $ac_cv_sys_large_files in #( + no | unknown) ;; + *) +cat >>confdefs.h <<_ACEOF +#define _LARGE_FILES $ac_cv_sys_large_files +_ACEOF +;; +esac +rm -rf conftest* + fi + + +fi + +ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" +if test "x$ac_cv_type_size_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define size_t unsigned int +_ACEOF + +fi + +ac_fn_c_check_type "$LINENO" "ssize_t" "ac_cv_type_ssize_t" "$ac_includes_default" +if test "x$ac_cv_type_ssize_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define ssize_t int +_ACEOF + +fi + +ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t" +case $ac_cv_c_uint64_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT64_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint64_t $ac_cv_c_uint64_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned int" >&5 +$as_echo_n "checking size of unsigned int... " >&6; } +if ${ac_cv_sizeof_unsigned_int+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned int))" "ac_cv_sizeof_unsigned_int" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_unsigned_int" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (unsigned int) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_unsigned_int=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_int" >&5 +$as_echo "$ac_cv_sizeof_unsigned_int" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UNSIGNED_INT $ac_cv_sizeof_unsigned_int +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned long" >&5 +$as_echo_n "checking size of unsigned long... " >&6; } +if ${ac_cv_sizeof_unsigned_long+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned long))" "ac_cv_sizeof_unsigned_long" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_unsigned_long" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (unsigned long) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_unsigned_long=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_long" >&5 +$as_echo "$ac_cv_sizeof_unsigned_long" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UNSIGNED_LONG $ac_cv_sizeof_unsigned_long +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of unsigned short" >&5 +$as_echo_n "checking size of unsigned short... " >&6; } +if ${ac_cv_sizeof_unsigned_short+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (unsigned short))" "ac_cv_sizeof_unsigned_short" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_unsigned_short" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (unsigned short) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_unsigned_short=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_unsigned_short" >&5 +$as_echo "$ac_cv_sizeof_unsigned_short" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UNSIGNED_SHORT $ac_cv_sizeof_unsigned_short +_ACEOF + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if ${ac_cv_c_bigendian+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error $? "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + + +# Checks for library functions. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working strtod" >&5 +$as_echo_n "checking for working strtod... " >&6; } +if ${ac_cv_func_strtod+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test "$cross_compiling" = yes; then : + ac_cv_func_strtod=no +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +$ac_includes_default +#ifndef strtod +double strtod (); +#endif +int +main() +{ + { + /* Some versions of Linux strtod mis-parse strings with leading '+'. */ + char *string = " +69"; + char *term; + double value; + value = strtod (string, &term); + if (value != 69 || term != (string + 4)) + return 1; + } + + { + /* Under Solaris 2.4, strtod returns the wrong value for the + terminating character under some conditions. */ + char *string = "NaN"; + char *term; + strtod (string, &term); + if (term != string && *(term - 1) == 0) + return 1; + } + return 0; +} + +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_func_strtod=yes +else + ac_cv_func_strtod=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_strtod" >&5 +$as_echo "$ac_cv_func_strtod" >&6; } +if test $ac_cv_func_strtod = no; then + case " $LIBOBJS " in + *" strtod.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strtod.$ac_objext" + ;; +esac + +ac_fn_c_check_func "$LINENO" "pow" "ac_cv_func_pow" +if test "x$ac_cv_func_pow" = xyes; then : + +fi + +if test $ac_cv_func_pow = no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pow in -lm" >&5 +$as_echo_n "checking for pow in -lm... " >&6; } +if ${ac_cv_lib_m_pow+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_check_lib_save_LIBS=$LIBS +LIBS="-lm $LIBS" +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char pow (); +int +main () +{ +return pow (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + ac_cv_lib_m_pow=yes +else + ac_cv_lib_m_pow=no +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +LIBS=$ac_check_lib_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_m_pow" >&5 +$as_echo "$ac_cv_lib_m_pow" >&6; } +if test "x$ac_cv_lib_m_pow" = xyes; then : + POW_LIB=-lm +else + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cannot find library containing definition of pow" >&5 +$as_echo "$as_me: WARNING: cannot find library containing definition of pow" >&2;} +fi + +fi + +fi + +for ac_func in gettimeofday select setenv strchr strtoul +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 +_ACEOF + +fi +done + + +ac_config_files="$ac_config_files Makefile test/runtest.sh" + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by pgreplay $as_me 1.4.0, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +case $ac_config_files in *" +"*) set x $ac_config_files; shift; ac_config_files=$*;; +esac + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_files="$ac_config_files" +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --file=FILE[:TEMPLATE] + instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration files: +$config_files + +Configuration headers: +$config_headers + +Report bugs to . +pgreplay home page: ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +pgreplay config.status 1.4.0 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +INSTALL='$INSTALL' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --file | --fil | --fi | --f ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; + esac + as_fn_append CONFIG_FILES " '$ac_optarg'" + ac_need_defaults=false;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; + "test/runtest.sh") CONFIG_FILES="$CONFIG_FILES test/runtest.sh" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_FILES section. +# No need to generate them if there are no CONFIG_FILES. +# This happens for instance with `./config.status config.h'. +if test -n "$CONFIG_FILES"; then + + +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi +ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` +if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then + ac_cs_awk_cr='\\r' +else + ac_cs_awk_cr=$ac_cr +fi + +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && +_ACEOF + + +{ + echo "cat >conf$$subs.awk <<_ACEOF" && + echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && + echo "_ACEOF" +} >conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` +ac_delim='%!_!# ' +for ac_last_try in false false false false false :; do + . ./conf$$subs.sh || + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + + ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` + if test $ac_delim_n = $ac_delim_num; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done +rm -f conf$$subs.sh + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && +_ACEOF +sed -n ' +h +s/^/S["/; s/!.*/"]=/ +p +g +s/^[^!]*!// +:repl +t repl +s/'"$ac_delim"'$// +t delim +:nl +h +s/\(.\{148\}\)..*/\1/ +t more1 +s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ +p +n +b repl +:more1 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t nl +:delim +h +s/\(.\{148\}\)..*/\1/ +t more2 +s/["\\]/\\&/g; s/^/"/; s/$/"/ +p +b +:more2 +s/["\\]/\\&/g; s/^/"/; s/$/"\\/ +p +g +s/.\{148\}// +t delim +' >$CONFIG_STATUS || ac_write_fail=1 +rm -f conf$$subs.awk +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACAWK +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && + for (key in S) S_is_set[key] = 1 + FS = "" + +} +{ + line = $ 0 + nfields = split(line, field, "@") + substed = 0 + len = length(field[1]) + for (i = 2; i < nfields; i++) { + key = field[i] + keylen = length(key) + if (S_is_set[key]) { + value = S[key] + line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3) + len += length(value) + length(field[++i]) + substed = 1 + } else + len += 1 + keylen + } + + print line +} + +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then + sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" +else + cat +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 +_ACEOF + +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and +# trailing colons and then remove the whole line if VPATH becomes empty +# (actually we leave an empty line to preserve line numbers). +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// +s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// +s/^[^=]*=[ ]*$// +}' +fi + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +fi # test -n "$CONFIG_FILES" + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + :F) + # + # CONFIG_FILE + # + + case $INSTALL in + [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;; + *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;; + esac +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# If the template does not know about datarootdir, expand it. +# FIXME: This hack should be removed a few years after 2.60. +ac_datarootdir_hack=; ac_datarootdir_seen= +ac_sed_dataroot=' +/datarootdir/ { + p + q +} +/@datadir@/p +/@docdir@/p +/@infodir@/p +/@localedir@/p +/@mandir@/p' +case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in +*datarootdir*) ac_datarootdir_seen=yes;; +*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 +$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + ac_datarootdir_hack=' + s&@datadir@&$datadir&g + s&@docdir@&$docdir&g + s&@infodir@&$infodir&g + s&@localedir@&$localedir&g + s&@mandir@&$mandir&g + s&\\\${datarootdir}&$datarootdir&g' ;; +esac +_ACEOF + +# Neutralize VPATH when `$srcdir' = `.'. +# Shell code in configure.ac might set extrasub. +# FIXME: do we really want to maintain this feature? +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_sed_extra="$ac_vpsub +$extrasub +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +:t +/@[a-zA-Z_][a-zA-Z_0-9]*@/!b +s|@configure_input@|$ac_sed_conf_input|;t t +s&@top_builddir@&$ac_top_builddir_sub&;t t +s&@top_build_prefix@&$ac_top_build_prefix&;t t +s&@srcdir@&$ac_srcdir&;t t +s&@abs_srcdir@&$ac_abs_srcdir&;t t +s&@top_srcdir@&$ac_top_srcdir&;t t +s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t +s&@builddir@&$ac_builddir&;t t +s&@abs_builddir@&$ac_abs_builddir&;t t +s&@abs_top_builddir@&$ac_abs_top_builddir&;t t +s&@INSTALL@&$ac_INSTALL&;t t +$ac_datarootdir_hack +" +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + +test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 +$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&2;} + + rm -f "$ac_tmp/stdin" + case $ac_file in + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; + esac \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + ;; + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + +chmod u+x test/runtest.sh diff --git a/pgreplay/configure.in b/pgreplay/configure.in new file mode 100644 index 00000000000..949e17c3a30 --- /dev/null +++ b/pgreplay/configure.in @@ -0,0 +1,79 @@ +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ([2.62]) +AC_INIT([pgreplay], [1.4.0], [https://github.com/laurenz/pgreplay/issues], [pgreplay], [http://laurenz.github.io/pgreplay/]) +AC_CONFIG_SRCDIR([parse.c]) +AC_CONFIG_HEADERS([config.h]) +AC_CANONICAL_BUILD + +# Checks for programs. +AC_PROG_INSTALL +AC_PROG_CC([gcc cc]) +# add -Wall to CFLAGS for gcc +if test "$GCC" = yes; then CFLAGS="-Wall $CFLAGS"; fi + +# check if ld supports -rpath +AC_MSG_CHECKING([whether the linker supports -rpath]) +save_LDFLAGS="$LDFLAGS" +LDFLAGS="$LDFLAGS -Wl,-rpath,/usr/lib" +AC_LINK_IFELSE([AC_LANG_SOURCE([[main() {}]])], [rpath=yes], [rpath=no]) +LDFLAGS="$save_LDFLAGS" +AC_MSG_RESULT([$rpath]) + +AC_ARG_WITH([postgres], + [AS_HELP_STRING([--with-postgres=DIR], + [specify location of pg_config for your PostgreSQL installation])], + [if ! test -x "$with_postgres"/pg_config; then + echo "*** pg_config not found in '$with_postgres'" 1>&2 + exit 1 + fi + pgbindir=`"$with_postgres"/pg_config --bindir` + AC_SUBST([pgbindir]) + if test $build_os = mingw32; then pglibdir="$pgbindir"; else pglibdir=`"$with_postgres"/pg_config --libdir`; fi + pgincludedir=`"$with_postgres"/pg_config --includedir` + LDFLAGS="$LDFLAGS -L$pglibdir" + if test $rpath = yes; then LDFLAGS="$LDFLAGS -Wl,-rpath,$pglibdir"; fi + CFLAGS="$CFLAGS -I$pgincludedir" + PATH=`"$with_postgres"/pg_config --bindir`:$PATH]) + +# Install with PostgreSQL by default +AC_PREFIX_PROGRAM(pg_config) + +# Checks for libraries. +AC_CHECK_LIB([pq], [PQsendPrepare], [], [AC_MSG_ERROR([ +*** cannot locate PostgreSQL client library +*** required is version 8.0 or better +])]) + +# special Windows settings +if test $build_os = mingw32; then + AC_SUBST([EXTRA_OBJS], [windows.o]) + # assume socks library is present + # we have a problem using AC_CHECK_LIB because the function is __stdcall + LIBS="$LIBS -lwsock32" +fi + +# Checks for header files. +AC_HEADER_TIME +AC_CHECK_HEADERS([fcntl.h netinet/in.h stdint.h stdlib.h string.h sys/time.h unistd.h inttypes.h]) +AC_CHECK_HEADER([libpq-fe.h], [], [AC_MSG_ERROR([PostgreSQL header files not found])], [/* dummy */]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_SYS_LARGEFILE +AC_TYPE_SIZE_T +AC_TYPE_SSIZE_T +AC_TYPE_UINT64_T +AC_TYPE_UINT32_T +AC_CHECK_SIZEOF(unsigned int) +AC_CHECK_SIZEOF(unsigned long) +AC_CHECK_SIZEOF(unsigned short) +AC_C_BIGENDIAN + +# Checks for library functions. +AC_FUNC_STRTOD +AC_CHECK_FUNCS([gettimeofday select setenv strchr strtoul]) + +AC_CONFIG_FILES([Makefile test/runtest.sh]) +AC_OUTPUT +chmod u+x test/runtest.sh diff --git a/pgreplay/database.c b/pgreplay/database.c new file mode 100644 index 00000000000..e7cac6504dd --- /dev/null +++ b/pgreplay/database.c @@ -0,0 +1,1172 @@ +#include "pgreplay.h" + +#include +#include +#include +#include +#ifdef HAVE_SYS_SELECT_H +# include +#else +# include +# include +#endif +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif +#ifdef WINDOWS +# include +#endif + +/* + * Utility macros to calculate with struct timeval. + * These are already defined on BSD type systems. + */ + +#ifndef timeradd +# define timeradd(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ + if ((result)->tv_usec >= 1000000) { \ + ++(result)->tv_sec; \ + (result)->tv_usec -= 1000000; \ + } \ + } while (0) +#endif + +#ifndef timersub +# define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) +#endif + +extern int monitor_connect_finish(void); + +/* connect string */ +static char *conn_string; + +/* speed factor for replay */ +static double replay_factor; + +/* possible stati a connection can have */ +typedef enum { + idle = 0, + conn_wait_write, + conn_wait_read, + wait_write, + wait_read, + closed +} connstatus; + +/* linked list element for list of open connections */ +struct dbconn { + uint64_t session_id; + PGconn *db_conn; + int socket; + connstatus status; + struct timeval session_start; + struct timeval stmt_start; + char *errmsg; + char *search_path; + struct dbconn *next; +}; +typedef struct dbconn dbconn; + +/* linked list of open connections */ +static struct dbconn *connections = NULL; + +/* linked list of open connections */ +PGconn *monitor_conn = NULL; + +/* remember timestamp of program start and stop */ +static struct timeval start_time; +static struct timeval stop_time; + +/* remember timestamp of first statement */ +static struct timeval first_stmt_time; +static struct timeval last_stmt_time; + +/* maximum seconds behind schedule */ +static time_t secs_behind = 0; + +/* time skipped instead of sleeping through it */ +static struct timeval jump_total = {0, 0}; + +/* statistics */ +static struct timeval stat_exec = {0, 0}; /* SQL statement execution time */ +static struct timeval stat_session = {0, 0}; /* session duration total */ +static struct timeval stat_longstmt = {0, 0}; /* session duration total */ +static unsigned long stat_stmt = 0; /* number of SQL statements */ +static unsigned long stat_prep = 0; /* number of preparations */ +static unsigned long stat_errors = 0; /* unsuccessful SQL statements and preparations */ +static unsigned long stat_actions = 0; /* client-server interactions */ +static unsigned long stat_statements = 0; /* number of concurrent statements */ +static unsigned long stat_stmtmax = 0; /* maximum concurrent statements */ +static unsigned long stat_sesscnt = 0; /* total number of sessions */ +static unsigned long stat_sessions = 0; /* number of concurrent sessions */ +static unsigned long stat_sessmax = 0; /* maximum concurrent sessions */ +static unsigned long stat_hist[5] = {0, 0, 0, 0, 0}; /* duration histogram */ +static unsigned long old_stat_hist[5] = {0, 0, 0, 0, 0}; /* segment duration histogram */ + +static PGresult* old_result = NULL; +static unsigned long old_stat_stmt = 0; +static unsigned long old_stat_errors = 0; + +#define NUM_DELAY_STEPS 11 + +/* steps for execution delay reports */ +static struct { + int seconds; + char *display; + short int shown; +} delay_steps[NUM_DELAY_STEPS] = { + {10, "10 seconds", 0}, + {30, "30 seconds", 0}, + {60, "1 minute", 0}, + {180, "3 minutes", 0}, + {600, "10 minutes", 0}, + {1800, "30 minutes", 0}, + {3600, "1 hour", 0}, + {7200, "2 hours", 0}, + {21600, "6 hours", 0}, + {43200, "12 hours", 0}, + {86400, "1 day", 0} +}; + +/* processes (ignores) notices from the server */ +static void ignore_notices(void *arg, const PGresult *res) { +} + +/* encapsulates "select" call and error handling */ + +static int do_select(int n, fd_set *rfds, fd_set *wfds, fd_set *xfds, struct timeval *timeout) { + int rc; + + rc = select(n, rfds, wfds, xfds, timeout); +#ifdef WINDOWS + if (SOCKET_ERROR == rc) { + win_perror("Error in select()", 1); + rc = -1; + } +#else + if (-1 == rc) { + perror("Error in select()"); + } +#endif + + return rc; +} + +/* checks if a certain socket can be read or written without blocking */ + +static int poll_socket(int socket, int for_read, char * const errmsg_prefix) { + fd_set fds; + struct timeval zero = { 0, 0 }; + + FD_ZERO(&fds); + FD_SET(socket, &fds); + return do_select(socket + 1, for_read ? &fds : NULL, for_read ? NULL : &fds, NULL, &zero); +} + +/* sleep routine that should work on all platforms */ + +static int do_sleep(struct timeval *delta) { + debug(2, "Napping for %lu.%06lu seconds\n", (unsigned long)delta->tv_sec, (unsigned long)delta->tv_usec); +#ifdef WINDOWS + Sleep((DWORD)delta->tv_sec * 1000 + (DWORD)(delta->tv_usec / 1000)); + return 0; +#else + return do_select(0, NULL, NULL, NULL, delta); +#endif +} + +/* +set search_path of the connection + */ +static int set_search_path(const char * search_path, PGconn * conn){ + char * set_path = malloc(strlen(search_path) + strlen("set search_path = ;") + 1); + PGresult* res = PQexec(conn, set_path); + + sprintf(set_path,"set search_path = %s;",search_path); + if(PQresultStatus(res) != PGRES_COMMAND_OK){ + fprintf(stderr, "set_search_path: Query execution failed search: %s\n", PQerrorMessage(conn)); + } + PQclear(res); + free(set_path); + return 0; +} + +static void print_replay_statistics(int dry_run) { + int hours, minutes; + double seconds, runtime, session_time, busy_time; + struct timeval delta; + unsigned long histtotal = + stat_hist[0] + stat_hist[1] + stat_hist[2] + stat_hist[3] + stat_hist[4]; + + if (dry_run) { + fprintf(sf, "\nReplay statistics (dry run)\n"); + fprintf(sf, "===========================\n\n"); + + /* calculate lengh of the recorded workload */ + timersub(&last_stmt_time, &first_stmt_time, &delta); + hours = delta.tv_sec / 3600; + delta.tv_sec -= hours * 3600; + minutes = delta.tv_sec / 60; + delta.tv_sec -= minutes * 60; + seconds = delta.tv_usec / 1000000.0 + delta.tv_sec; + + fprintf(sf, "Duration of recorded workload:"); + if (hours > 0) { + fprintf(sf, " %d hours", hours); + } + if (minutes > 0) { + fprintf(sf, " %d minutes", minutes); + } + fprintf(sf, " %.3f seconds\n", seconds); + fprintf(sf, "Calls to the server: %lu\n", stat_actions); + } else { + fprintf(sf, "\nReplay statistics\n"); + fprintf(sf, "=================\n\n"); + + /* calculate total run time */ + timersub(&stop_time, &start_time, &delta); + runtime = delta.tv_usec / 1000000.0 + delta.tv_sec; + /* calculate hours and minutes, subtract from delta */ + hours = delta.tv_sec / 3600; + delta.tv_sec -= hours * 3600; + minutes = delta.tv_sec / 60; + delta.tv_sec -= minutes * 60; + seconds = delta.tv_usec / 1000000.0 + delta.tv_sec; + /* calculate total busy time */ + busy_time = stat_exec.tv_usec / 1000000.0 + stat_exec.tv_sec; + /* calculate total session time */ + session_time = stat_session.tv_usec / 1000000.0 + stat_session.tv_sec; + + fprintf(sf, "Speed factor for replay: %.3f\n", replay_factor); + fprintf(sf, "Total run time:"); + if (hours > 0) { + fprintf(sf, " %d hours", hours); + } + if (minutes > 0) { + fprintf(sf, " %d minutes", minutes); + } + fprintf(sf, " %.3f seconds\n", seconds); + fprintf(sf, "Maximum lag behind schedule: %lu seconds\n", (unsigned long) secs_behind); + fprintf(sf, "Calls to the server: %lu\n", stat_actions); + if (runtime > 0.0) { + fprintf(sf, "(%.3f calls per second)\n", stat_actions / runtime); + } + } + + fprintf(sf, "Total number of connections: %lu\n", stat_sesscnt); + fprintf(sf, "Maximum number of concurrent connections: %lu\n", stat_sessmax); + if (!dry_run && runtime > 0.0) { + fprintf(sf, "Average number of concurrent connections: %.3f\n", session_time / runtime); + } + if (!dry_run && session_time > 0.0) { + fprintf(sf, "Average session idle percentage: %.3f%%\n", 100.0 * (session_time - busy_time) / session_time); + } + + fprintf(sf, "SQL statements executed: %lu\n", stat_stmt - stat_prep); + if (!dry_run && stat_stmt > stat_prep) { + fprintf(sf, "(%lu or %.3f%% of these completed with error)\n", + stat_errors, (100.0 * stat_errors) / (stat_stmt - stat_prep)); + fprintf(sf, "Maximum number of concurrent SQL statements: %lu\n", stat_stmtmax); + if (runtime > 0.0) { + fprintf(sf, "Average number of concurrent SQL statements: %.3f\n", busy_time / runtime); + } + fprintf(sf, "Average SQL statement duration: %.3f seconds\n", busy_time / stat_stmt); + fprintf(sf, "Maximum SQL statement duration: %.3f seconds\n", + stat_longstmt.tv_sec + stat_longstmt.tv_usec / 1000000.0); + fprintf(sf, "Statement duration histogram:\n"); + fprintf(sf, " 0 to 0.02 seconds: %.3f%%\n", 100.0 * stat_hist[0] / histtotal); + fprintf(sf, " 0.02 to 0.1 seconds: %.3f%%\n", 100.0 * stat_hist[1] / histtotal); + fprintf(sf, " 0.1 to 0.5 seconds: %.3f%%\n", 100.0 * stat_hist[2] / histtotal); + fprintf(sf, " 0.5 to 2 seconds: %.3f%%\n", 100.0 * stat_hist[3] / histtotal); + fprintf(sf, " over 2 seconds: %.3f%%\n", 100.0 * stat_hist[4] / histtotal); + } +} + +int database_consumer_init(const char *ignore, const char *host, int port, const char *passwd, double factor) { + int conn_string_len = 12; /* port and '\0' */ + const char *p; + char *p1; + + debug(3, "Entering database_consumer_init%s\n", ""); + + /* get time of program start */ + if (-1 == gettimeofday(&start_time, NULL)) { + perror("Error calling gettimeofday"); + return 0; + } + + replay_factor = factor; + + /* calculate length of connect string */ + if (host) { + conn_string_len += 8; + for (p=host; '\0'!=*p; ++p) { + if (('\'' == *p) || ('\\' == *p)) { + conn_string_len += 2; + } else { + ++conn_string_len; + } + } + } + if (passwd) { + conn_string_len += 12; + for (p=passwd; '\0'!=*p; ++p) { + if (('\'' == *p) || ('\\' == *p)) { + conn_string_len += 2; + } else { + ++conn_string_len; + } + } + } + + if (extra_connstr) + conn_string_len += strlen(extra_connstr); + + if (NULL == (conn_string = malloc(conn_string_len))) { + fprintf(stderr, "Cannot allocate %d bytes of memory\n", conn_string_len); + return 0; + } + /* write the port to the connection string if it is set */ + if (-1 == port) { + conn_string[0] = '\0'; + } else { + if (sprintf(conn_string, "port=%d", port) < 0) { + perror("Error writing connect string:"); + free(conn_string); + return 0; + } + } + for (p1=conn_string; '\0'!=*p1; ++p1) { + /* places p1 at the end of the string */ + } + + /* append host if necessary */ + if (host) { + *(p1++) = ' '; + *(p1++) = 'h'; + *(p1++) = 'o'; + *(p1++) = 's'; + *(p1++) = 't'; + *(p1++) = '='; + *(p1++) = '\''; + for (p=host; '\0'!=*p; ++p) { + if (('\'' == *p) || ('\\' == *p)) { + *(p1++) = '\\'; + } + *(p1++) = *p; + } + *(p1++) = '\''; + *p1 = '\0'; + } + + /* append password if necessary */ + if (passwd) { + *(p1++) = ' '; + *(p1++) = 'p'; + *(p1++) = 'a'; + *(p1++) = 's'; + *(p1++) = 's'; + *(p1++) = 'w'; + *(p1++) = 'o'; + *(p1++) = 'r'; + *(p1++) = 'd'; + *(p1++) = '='; + *(p1++) = '\''; + for (p=passwd; '\0'!=*p; ++p) { + if (('\'' == *p) || ('\\' == *p)) { + *(p1++) = '\\'; + } + *(p1++) = *p; + } + *(p1++) = '\''; + *p1 = '\0'; + } + + if (extra_connstr) { + *(p1++) = ' '; + strcpy(p1, extra_connstr); + } + + debug(2, "Database connect string: \"%s\"\n", conn_string); + + debug(3, "Leaving database_consumer_init%s\n", ""); + return 1; +} + +void database_consumer_finish(int dry_run) { + debug(3, "Entering database_consumer_finish%s\n", ""); + + free(conn_string); + + if (NULL != connections) { + fprintf(stderr, "Error: not all database connections closed\n"); + } + + if (-1 == gettimeofday(&stop_time, NULL)) { + perror("Error calling gettimeofday"); + } else if (sf) { + print_replay_statistics(dry_run); + } + + debug(3, "Leaving database_consumer_finish%s\n", ""); +} + +int database_consumer(replay_item *item) { + const uint64_t session_id = replay_get_session_id(item); + const replay_type type = replay_get_type(item); + int all_idle = 1, rc = 0, j; + struct dbconn *conn = connections, *found_conn = NULL, *prev_conn = NULL; + struct timeval target_time, now, delta; + const struct timeval *stmt_time; + static int fstmtm_set = 0; /* have we already collected first_statement_time */ + double d; + time_t i; + char *connstr, *p1, errbuf[256]; + const char *user, *database, *p; + PGcancel *cancel_request; + PGresult *result; + ExecStatusType result_status; + + debug(3, "Entering database_consumer%s\n", ""); + + /* loop through open connections and do what can be done */ + while ((-1 != rc) && (NULL != conn)) { + /* if we find the connection for the current statement, remember it */ + if (session_id == conn->session_id) { + found_conn = conn; + } + + /* handle each connection according to status */ + switch(conn->status) { + case idle: + case closed: + break; /* nothing to do */ + + case conn_wait_read: + case conn_wait_write: + /* in connection process */ + /* check if socket is still busy */ + switch (poll_socket(conn->socket, (conn_wait_read == conn->status), "Error polling socket during connect")) { + case 0: + /* socket still busy */ + debug(2, "Socket for session 0x" UINT64_FORMAT " busy for %s during connect\n", conn->session_id, (conn_wait_write == conn->status) ? "write" : "read"); + all_idle = 0; + break; + case 1: + /* socket not busy, continue connect process */ + switch(PQconnectPoll(conn->db_conn)) { + case PGRES_POLLING_WRITING: + conn->status = conn_wait_write; + all_idle = 0; + break; + case PGRES_POLLING_READING: + conn->status = conn_wait_read; + all_idle = 0; + break; + case PGRES_POLLING_OK: + debug(2, "Connection for session 0x" UINT64_FORMAT " established\n", conn->session_id); + conn->status = idle; + + /* get session start time */ + if (-1 == gettimeofday(&(conn->session_start), NULL)) { + perror("Error calling gettimeofday"); + rc = -1; + } + + /* count total and concurrent sessions */ + ++stat_sesscnt; + if (++stat_sessions > stat_sessmax) { + stat_sessmax = stat_sessions; + } + + break; + case PGRES_POLLING_FAILED: + /* If the connection fails because of a + FATAL error from the server, mark + connection "closed" and keep going. + The same thing probably happened in the + original run. + PostgreSQL logs no disconnection for this. + */ + p1 = PQerrorMessage(conn->db_conn); + if (0 == strncmp(p1, "FATAL: ", 8)) { + p1 += 8; + if (NULL == (conn->errmsg = malloc(strlen(p1) + 1))) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)(strlen(p1) + 1)); + rc = -1; + } else { + debug(2, "Connection for session 0x" UINT64_FORMAT " failed with FATAL error: %s\n", + conn->session_id, p1); + strcpy(conn->errmsg, p1); + conn->status = closed; + PQfinish(conn->db_conn); + } + + break; + } + /* else fall through */ + default: + fprintf(stderr, "Connection for session 0x" UINT64_FORMAT " failed: %s\n", conn->session_id, PQerrorMessage(conn->db_conn)); + rc = -1; + PQfinish(conn->db_conn); + } + break; + default: + /* error happened in select() */ + rc = -1; + } + break; + + case wait_write: + /* check if the socket is writable */ + switch (poll_socket(conn->socket, 0, "Error polling socket for write")) { + case 0: + /* socket still busy */ + debug(2, "Session 0x" UINT64_FORMAT " busy writing data\n", conn->session_id); + all_idle = 0; + break; + case 1: + /* try PQflush again */ + debug(2, "Session 0x" UINT64_FORMAT " flushing data\n", conn->session_id); + switch (PQflush(conn->db_conn)) { + case 0: + /* finished flushing all data */ + conn->status = wait_read; + all_idle = 0; + break; + case 1: + /* more data to flush */ + all_idle = 0; + break; + default: + fprintf(stderr, "Error flushing to database: %s\n", PQerrorMessage(conn->db_conn)); + rc = -1; + } + break; + default: + /* error in select() */ + rc = -1; + } + break; + + case wait_read: + /* check if the socket is readable */ + switch (poll_socket(conn->socket, 1, "Error polling socket for read")) { + case 0: + /* socket still busy */ + debug(2, "Session 0x" UINT64_FORMAT " waiting for data\n", conn->session_id); + all_idle = 0; + break; + case 1: + /* read input from connection */ + if (! PQconsumeInput(conn->db_conn)) { + fprintf(stderr, "Error reading from database: %s\n", PQerrorMessage(conn->db_conn)); + rc = -1; + } else { + /* check if we are done reading */ + if (PQisBusy(conn->db_conn)) { + /* more to read */ + all_idle = 0; + } else { + /* read and discard all results */ + while (NULL != (result = PQgetResult(conn->db_conn))) { + /* count statements and errors for statistics */ + ++stat_stmt; + result_status = PQresultStatus(result); + debug(2, "Session 0x" UINT64_FORMAT " got got query response (%s)\n", + conn->session_id, + (PGRES_TUPLES_OK == result_status) ? "PGRES_TUPLES_OK" : + ((PGRES_COMMAND_OK == result_status) ? "PGRES_COMMAND_OK" : + ((PGRES_FATAL_ERROR == result_status) ? "PGRES_FATAL_ERROR" : + ((PGRES_NONFATAL_ERROR == result_status) ? "PGRES_NONFATAL_ERROR" : + ((PGRES_EMPTY_QUERY == result_status) ? "PGRES_EMPTY_QUERY" : "unexpected status"))))); + + if ((PGRES_EMPTY_QUERY != result_status) + && (PGRES_COMMAND_OK != result_status) + && (PGRES_TUPLES_OK != result_status) + && (PGRES_NONFATAL_ERROR != result_status)) + { + ++stat_errors; + } + + PQclear(result); + } + + /* one less concurrent statement */ + --stat_statements; + + conn->status = idle; + + /* remember execution time for statistics */ + if (-1 == gettimeofday(&delta, NULL)) { + perror("Error calling gettimeofday"); + rc = -1; + } else { + /* subtract statement start time */ + timersub(&delta, &(conn->stmt_start), &delta); + + /* add to duration histogram */ + if (0 == delta.tv_sec) { + if (20000 >= delta.tv_usec) { + ++stat_hist[0]; + } else if (100000 >= delta.tv_usec) { + ++stat_hist[1]; + } else if (500000 >= delta.tv_usec) { + ++stat_hist[2]; + } else { + ++stat_hist[3]; + } + } else if (2 > delta.tv_sec) { + ++stat_hist[3]; + } else { + ++stat_hist[4]; + } + + /* remember longest statement */ + if ((delta.tv_sec > stat_longstmt.tv_sec) + || ((delta.tv_sec == stat_longstmt.tv_sec) + && (delta.tv_usec > stat_longstmt.tv_usec))) + { + stat_longstmt.tv_sec = delta.tv_sec; + stat_longstmt.tv_usec = delta.tv_usec; + } + + /* add to total */ + timeradd(&stat_exec, &delta, &stat_exec); + } + } + } + break; + default: + /* error during select() */ + rc = -1; + } + break; + } + + if (! found_conn) { + /* remember previous item in list, useful for removing an item */ + prev_conn = conn; + } + + conn = conn->next; + } + + /* make sure we found a connection above (except for connect items) */ + if (1 == rc) { + if ((pg_connect == type) && (NULL != found_conn)) { + fprintf(stderr, "Error: connection for session 0x" UINT64_FORMAT " already exists\n", replay_get_session_id(item)); + rc = -1; + } else if ((pg_connect != type) && (NULL == found_conn)) { + fprintf(stderr, "Error: no connection found for session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + rc = -1; + } + } + + /* time when the statement originally ran */ + stmt_time = replay_get_time(item); + last_stmt_time.tv_sec = stmt_time->tv_sec; + last_stmt_time.tv_usec = stmt_time->tv_usec; + + /* set first_stmt_time if it is not yet set */ + if (! fstmtm_set) { + first_stmt_time.tv_sec = stmt_time->tv_sec; + first_stmt_time.tv_usec = stmt_time->tv_usec; + + fstmtm_set = 1; + } + + /* get current time */ + if (-1 != rc) { + if (-1 == gettimeofday(&now, NULL)) { + fprintf(stderr, "Error: gettimeofday failed\n"); + rc = -1; + } + } + + /* determine if statement should already be consumed, sleep if necessary */ + if (-1 != rc) { + /* calculate "target time" when item should be replayed: + statement time - first statement time + program start time - skipped time + ------------------------------------- + replay factor */ + + /* timestamp of the statement */ + target_time.tv_sec = stmt_time->tv_sec; + target_time.tv_usec = stmt_time->tv_usec; + + /* subtract time of first statement */ + timersub(&target_time, &first_stmt_time, &target_time); + + /* subtract skipped time */ + if (jump_enabled) { + timersub(&target_time, &jump_total, &target_time); + } + + /* divide by replay_factor */ + if (replay_factor != 1.0) { + /* - divide the seconds part by the factor + - divide the microsecond part by the factor and add the + fractional part (times 10^6) of the previous division + - if the result exceeds 10^6, subtract the excess and + add its 10^6th to the seconds part. */ + d = target_time.tv_sec / replay_factor; + target_time.tv_sec = d; + target_time.tv_usec = target_time.tv_usec / replay_factor + + (d - target_time.tv_sec) * 1000000.0; + i = target_time.tv_usec / 1000000; + target_time.tv_usec -= i * 1000000; + target_time.tv_sec += i; + } + + /* add program start time */ + timeradd(&target_time, &start_time, &target_time); + + /* warn if we fall behind too much */ + if (secs_behind < now.tv_sec - target_time.tv_sec) { + secs_behind = now.tv_sec - target_time.tv_sec; + for (j=0; j now.tv_sec) || + ((target_time.tv_sec == now.tv_sec) && (target_time.tv_usec > now.tv_usec))) && + all_idle) { + /* sleep or jump if all is idle and the target time is in the future */ + + /* calculate time to sleep or jump (delta = target_time - now) */ + timersub(&target_time, &now, &delta); + + if (jump_enabled) { + /* add the sleep time to jump_total */ + timeradd(&jump_total, &delta, &jump_total); + debug(2, "Skipping %lu.%06lu seconds\n", (unsigned long)delta.tv_sec, (unsigned long)delta.tv_usec); + /* then consume item */ + rc = 1; + } else { + /* sleep */ + if (-1 == do_sleep(&delta)) { + rc = -1; + } else { + /* then consume item */ + rc = 1; + } + } + } else if (((target_time.tv_sec < now.tv_sec) || + ((target_time.tv_sec == now.tv_sec) && (target_time.tv_usec <= now.tv_usec))) && + ((pg_connect == type) || + ((pg_disconnect == type) && (closed == found_conn->status)) || + ((pg_cancel == type) && (wait_read == found_conn->status)) || + (idle == found_conn->status))) { + /* if the item is due and its connection is idle, consume it */ + /* cancel items will also be consumed if the connection is waiting for a resonse */ + rc = 1; + } else if (found_conn && (closed == found_conn->status)) { + fprintf(stderr, "Connection 0x" UINT64_FORMAT " failed with FATAL error: %s\n", + found_conn->session_id, found_conn->errmsg); + rc = -1; + } + } + + /* send statement */ + if (1 == rc) { + /* count for statistics */ + ++stat_actions; + + switch (type) { + case pg_connect: + debug(2, "Starting database connection for session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + + /* allocate a connect string */ + user = replay_get_user(item); + database = replay_get_database(item); + if (NULL == (connstr = malloc(strlen(conn_string) + 2 * strlen(user) + 2 * strlen(database) + 18))) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(conn_string) + 2 * strlen(user) + 2 * strlen(database) + 18); + rc = -1; + } else { + /* append user and password */ + strcpy(connstr, conn_string); + p1 = connstr + strlen(connstr); + *(p1++) = ' '; + *(p1++) = 'u'; + *(p1++) = 's'; + *(p1++) = 'e'; + *(p1++) = 'r'; + *(p1++) = '='; + *(p1++) = '\''; + for (p=user; '\0'!=*p; ++p) { + if (('\'' == *p) || ('\\' == *p)) { + *(p1++) = '\\'; + } + *(p1++) = *p; + } + *(p1++) = '\''; + *(p1++) = ' '; + *(p1++) = 'd'; + *(p1++) = 'b'; + *(p1++) = 'n'; + *(p1++) = 'a'; + *(p1++) = 'm'; + *(p1++) = 'e'; + *(p1++) = '='; + *(p1++) = '\''; + for (p=database; '\0'!=*p; ++p) { + if (('\'' == *p) || ('\\' == *p)) { + *(p1++) = '\\'; + } + *(p1++) = *p; + } + *(p1++) = '\''; + *p1 = '\0'; + + /* allocate a struct dbconn */ + if (NULL == (found_conn = malloc(sizeof(struct dbconn)))) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)sizeof(struct dbconn)); + rc = -1; + } else { + /* initialize a connection */ + if (NULL == (found_conn->db_conn = PQconnectStart(connstr))) { + fprintf(stderr, "Cannot allocate memory for database connection\n"); + rc = -1; + free(found_conn); + } else { + if (CONNECTION_BAD == PQstatus(found_conn->db_conn)) { + fprintf(stderr, "Error: connection to database failed: %s\n", PQerrorMessage(found_conn->db_conn)); + rc = -1; + PQfinish(found_conn->db_conn); + free(found_conn); + } else { + if (-1 == (found_conn->socket = PQsocket(found_conn->db_conn))) { + fprintf(stderr, "Error: cannot get socket for database connection\n"); + rc = -1; + PQfinish(found_conn->db_conn); + free(found_conn); + } else { + /* set values in struct dbconn */ + + found_conn->session_id = replay_get_session_id(item); + found_conn->status = conn_wait_write; + found_conn->errmsg = NULL; + found_conn->next = connections; + found_conn->search_path = malloc(POLARDBlEN); + connections = found_conn; + + /* do not display notices */ + PQsetNoticeReceiver(found_conn->db_conn, ignore_notices, NULL); + } + } + } + } + + /* free connection sting */ + free(connstr); + } + break; + case pg_disconnect: + /* dead connections need not be closed */ + if (closed == found_conn->status) { + debug(2, "Removing closed session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + } else { + debug(2, "Disconnecting database connection for session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + + PQfinish(found_conn->db_conn); + + /* remember session duration for statistics */ + if (-1 == gettimeofday(&delta, NULL)) { + perror("Error calling gettimeofday"); + rc = -1; + } else { + /* subtract session start time */ + timersub(&delta, &(found_conn->session_start), &delta); + + /* add to total */ + timeradd(&stat_session, &delta, &stat_session); + } + + /* one less concurrent session */ + --stat_sessions; + } + + /* remove struct dbconn from linked list */ + if (prev_conn) { + prev_conn->next = found_conn->next; + } else { + connections = found_conn->next; + } + if (found_conn->errmsg) { + free(found_conn->errmsg); + } + if (found_conn->search_path) { + free(found_conn->search_path); + } + free(found_conn); + + break; + case pg_execute: + debug(2, "Sending simple statement on session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + if(strcmp(item->search_path, found_conn->search_path) != 0){ + set_search_path(item->search_path, found_conn->db_conn); + strcpy(found_conn->search_path, item->search_path); + } + + if (! PQsendQuery(found_conn->db_conn, replay_get_statement(item))) { + fprintf(stderr, "Error sending simple statement: %s\n", PQerrorMessage(found_conn->db_conn)); + rc = -1; + } else { + found_conn->status = wait_write; + } + break; + case pg_prepare: + debug(2, "Sending prepare request on session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + if(strcmp(item->search_path, found_conn->search_path) != 0){ + set_search_path(item->search_path, found_conn->db_conn); + strcpy(found_conn->search_path, item->search_path); + } + + /* count preparations for statistics */ + ++stat_prep; + + if (! PQsendPrepare( + found_conn->db_conn, + replay_get_name(item), + replay_get_statement(item), + 0, + NULL)) { + fprintf(stderr, "Error sending prepare request: %s\n", PQerrorMessage(found_conn->db_conn)); + rc = -1; + } else { + found_conn->status = wait_write; + } + break; + case pg_exec_prepared: + debug(2, "Sending prepared statement execution on session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + if(strcmp(item->search_path, found_conn->search_path) != 0){ + set_search_path(item->search_path, found_conn->db_conn); + strcpy(found_conn->search_path, item->search_path); + } + + if (! PQsendQueryPrepared( + found_conn->db_conn, + replay_get_name(item), + replay_get_valuecount(item), + replay_get_values(item), + NULL, + NULL, + 0)) { + fprintf(stderr, "Error sending prepared statement execution: %s\n", PQerrorMessage(found_conn->db_conn)); + rc = -1; + } else { + found_conn->status = wait_write; + } + break; + case pg_cancel: + debug(2, "Sending cancel request on session 0x" UINT64_FORMAT "\n", replay_get_session_id(item)); + + if (NULL == (cancel_request = PQgetCancel(found_conn->db_conn))) { + fprintf(stderr, "Error creating cancel request\n"); + rc = -1; + } else { + if (! PQcancel(cancel_request, errbuf, 256)) { + fprintf(stderr, "Error sending cancel request: %s\n", errbuf); + rc = -1; + } + /* free cancel request */ + PQfreeCancel(cancel_request); + } + /* status remains unchanged */ + break; + } + + replay_free(item); + } + + /* try to flush the statement if necessary */ + if ((1 == rc) && (pg_disconnect != type) && (wait_write == found_conn->status)) { + switch (PQflush(found_conn->db_conn)) { + case 0: + /* complete request sent */ + found_conn->status = wait_read; + break; + case 1: + debug(2, "Session 0x" UINT64_FORMAT " needs to flush again\n", found_conn->session_id); + break; + default: + fprintf(stderr, "Error flushing to database: %s\n", PQerrorMessage(found_conn->db_conn)); + rc = -1; + } + + /* get statement start time */ + if (-1 == gettimeofday(&(found_conn->stmt_start), NULL)) { + perror("Error calling gettimeofday"); + rc = -1; + } + + /* count concurrent statements */ + if (++stat_statements > stat_stmtmax) { + stat_stmtmax = stat_statements; + } + } + + debug(3, "Leaving database_consumer%s\n", ""); + return rc; +} + +int database_consumer_dry_run(replay_item *item) { + const replay_type type = replay_get_type(item); + const struct timeval *stmt_time; + static int fstmt_set_dr = 0; + + debug(3, "Entering database_consumer_dry_run%s\n", ""); + + /* time when the statement originally ran */ + stmt_time = replay_get_time(item); + last_stmt_time.tv_sec = stmt_time->tv_sec; + last_stmt_time.tv_usec = stmt_time->tv_usec; + + /* set first_stmt_time if it is not yet set */ + if (! fstmt_set_dr) { + first_stmt_time.tv_sec = stmt_time->tv_sec; + first_stmt_time.tv_usec = stmt_time->tv_usec; + + fstmt_set_dr = 1; + } + + /* gather statistics */ + ++stat_actions; + + switch (type) { + case pg_connect: + ++stat_sesscnt; + if (++stat_sessions > stat_sessmax) { + stat_sessmax = stat_sessions; + } + break; + case pg_disconnect: + --stat_sessions; + break; + case pg_execute: + case pg_exec_prepared: + ++stat_stmt; + break; + case pg_prepare: + ++stat_prep; + break; + case pg_cancel: + break; + } + + replay_free(item); + debug(3, "Leaving database_consumer_dry_run%s\n", ""); + + return 1; +} + +/* +initailize connect for getting monitor info + */ +int monitor_connect_init(const char *host, int port, const char *passwd) { + // 建立连接 + // create connect to db server + char conn_info[100] = {'\0'}; + sprintf(conn_info,"dbname=postgres user=polardb password=%s hostaddr=%s port=%d ", passwd, host, port); + + monitor_conn = PQconnectdb(conn_info); + + // 检查连接是否成功 + // check if connect was success. + if (PQstatus(monitor_conn) != CONNECTION_OK) { + fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(monitor_conn)); + PQfinish(monitor_conn); + return 1; + } + return 0; +} + +/* +get once monitor info + */ +int monitor_connect_execute(const char* sql) { + + // execute sql + static int print_title = 0; + PGresult *result = PQexec(monitor_conn, sql); + if(!print_title){ + printf("cpu_use mem_use read_count write_count read_bytes write_bytes disk_space active_conn total_conn load5 load10 tps qps stat_correct stat_errors time0 time1 time2 time3 time4\n"); + print_title++; + } + + // check if sql execution was success + if (PQresultStatus(result) != PGRES_TUPLES_OK) { + fprintf(stderr, "Query execution failed: %s", PQerrorMessage(monitor_conn)); + PQclear(result); + PQfinish(monitor_conn); + return 1; + } + + if(old_result){ + printf("%s ",PQgetvalue(result, 0, 2)); + printf("%s ",PQgetvalue(result, 1, 2)); + printf("%ld ",atol(PQgetvalue(result, 2, 2)) - atol(PQgetvalue(old_result, 2, 2))); + printf("%ld ",atol(PQgetvalue(result, 3, 2)) - atol(PQgetvalue(old_result, 3, 2))); + printf("%ld ",atol(PQgetvalue(result, 4, 2)) - atol(PQgetvalue(old_result, 4, 2))); + printf("%ld ",atol(PQgetvalue(result, 5, 2)) - atol(PQgetvalue(old_result, 5, 2))); + printf("%s ",PQgetvalue(result, 6, 2)); + printf("%s ",PQgetvalue(result, 7, 2)); + printf("%s ",PQgetvalue(result, 8, 2)); + printf("%s ",PQgetvalue(result, 9, 2)); + printf("%s ",PQgetvalue(result, 10, 2)); + printf("%ld ",atol(PQgetvalue(result, 11, 2)) - atol(PQgetvalue(old_result, 11, 2))); + printf("%ld ",atol(PQgetvalue(result, 12, 2)) - atol(PQgetvalue(old_result, 12, 2))); + + printf("%lu ", (stat_stmt - stat_errors) - (old_stat_stmt - old_stat_errors) ); + printf("%lu ", stat_errors - old_stat_errors); + printf("%lu ", stat_hist[0] - old_stat_hist[0]); + printf("%lu ", stat_hist[1] - old_stat_hist[1]); + printf("%lu ", stat_hist[2] - old_stat_hist[2]); + printf("%lu ", stat_hist[3] - old_stat_hist[3]); + printf("%lu ", stat_hist[4] - old_stat_hist[4]); + printf("\n"); + } + + if(old_result){ + PQclear(old_result); + } + old_result = result; + old_stat_errors = stat_errors; + old_stat_stmt = stat_stmt; + memcpy(old_stat_hist, stat_hist, sizeof(stat_hist)); + + return 0; +} + +// close connect of monitor info +int monitor_connect_finish() { + // Release resources + PQclear(old_result); + PQfinish(monitor_conn); + + return 0; +} diff --git a/pgreplay/install-sh b/pgreplay/install-sh new file mode 100755 index 00000000000..6781b987bdb --- /dev/null +++ b/pgreplay/install-sh @@ -0,0 +1,520 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2009-04-28.21; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +nl=' +' +IFS=" "" $nl" + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit=${DOITPROG-} +if test -z "$doit"; then + doit_exec=exec +else + doit_exec=$doit +fi + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_glob='?' +initialize_posix_glob=' + test "$posix_glob" != "?" || { + if (set -f) 2>/dev/null; then + posix_glob= + else + posix_glob=: + fi + } +' + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +no_target_directory= + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *' '* | *' +'* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) dst_arg=$2 + shift;; + + -T) no_target_directory=true;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + trap '(exit $?); exit' 1 2 13 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dst_arg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + # Prefer dirname, but fall back on a substitute if dirname fails. + dstdir=` + (dirname "$dst") 2>/dev/null || + expr X"$dst" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$dst" : 'X\(//\)[^/]' \| \ + X"$dst" : 'X\(//\)$' \| \ + X"$dst" : 'X\(/\)' \| . 2>/dev/null || + echo X"$dst" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q' + ` + + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0 + + if (umask $mkdir_umask && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + ls_ld_tmpdir=`ls -ld "$tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/d" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + -*) prefix='./';; + *) prefix='';; + esac + + eval "$initialize_posix_glob" + + oIFS=$IFS + IFS=/ + $posix_glob set -f + set fnord $dstdir + shift + $posix_glob set +f + IFS=$oIFS + + prefixes= + + for d + do + test -z "$d" && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + + eval "$initialize_posix_glob" && + $posix_glob set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + $posix_glob set +f && + + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/pgreplay/main.c b/pgreplay/main.c new file mode 100644 index 00000000000..9f0a702d5a4 --- /dev/null +++ b/pgreplay/main.c @@ -0,0 +1,466 @@ +#include "pgreplay.h" + +#include +#include +#include +#include +#include +#ifdef WINDOWS +# include +#endif + +/* from getopt */ +extern char *optarg; + +int debug_level = 0; + +/* destination of statistics output */ +FILE *sf; + +/* if 1, backslash will escape the following single quote in string literal */ +int backslash_quote = 0; + +/* if 1, replay will skip idle intervals instead of sleeping */ +int jump_enabled = 0; + +/* extra connect options specified with the -X option */ +char *extra_connstr; +/* indicates whether input file is from polardb */ +int polardb_audit = 0; + +char monitor_sql[] = + " select 1 as id,'cpu_use' as monitor_name ,100 - split_part((select pg_sys_cpu_usage_info())::text,',', 4 )::decimal as num union" + " select 2,'mem_use' as monitor_name , (( split_part(replace((select pg_sys_memory_info())::text,'(','') , ',',1)::decimal - " + " split_part(replace((select pg_sys_memory_info())::text,'(','') , ',',7)::decimal )" + " / split_part(replace((select pg_sys_memory_info())::text,'(','') , ',',1)::decimal)::decimal(4,2)*100 as num union" + " select 3,'read_count' monitor_name, sum(io_count) num from (select split_part(pg_sys_io_analysis_info()::text,',',2)::bigint as io_count) as a union " + " select 4,'write_count' monitor_name, sum(io_count) num from (select split_part(pg_sys_io_analysis_info()::text,',',3)::bigint as io_count) as a union " + " select 5,'read_bytes' monitor_name, sum(io_count) num from (select split_part(pg_sys_io_analysis_info()::text,',',4)::bigint as io_count) as a union " + " select 6,'write_bytes' monitor_name, sum(io_count) num from (select split_part(pg_sys_io_analysis_info()::text,',',5)::bigint as io_count) as a union" + " select 7,'disk_space' monitor_name, sum(disk_space / 1024 / 1024) num from (select split_part(pg_sys_disk_info()::text,',',7)::bigint as disk_space) as a union" + " select 8,'active_conn' as monitor_name, count(query) as num from pg_stat_activity where state = 'active' and backend_type = 'client backend' union" + " select 9,'total_conn' as monitor_name, count(query) as num from pg_stat_activity union" + " select 10,'load5_value' monitor_name, split_part(pg_sys_load_avg_info()::text,',',2)::decimal as num union" + " select 11,'load10_value' monitor_name, split_part(pg_sys_load_avg_info()::text,',',3)::decimal as num union" + " select 12,'tps' as monitor_name,split_part(txid_current_snapshot()::text,':',1)::integer as num union" + " select 13,'qps' as monitor_name,sum(calls) as num from pg_stat_statements order by id;"; + +/* wrapper for setenv, returns 0 on success and -1 on error */ +static int do_setenv(const char *name, const char *value) { + int rc; + +#ifdef WINDOWS + if (0 == SetEnvironmentVariable(name, value)) { + win_perror("Error setting environment variable", 0); + rc = -1; + } else { + rc = 0; + } +#else + if (-1 == (rc = setenv(name, value, 1))) { + fprintf(stderr, "Error setting environment variable\n"); + } +#endif + + return rc; +} + +static void version(FILE *f) { + fprintf(f, "pgreplay %s\n", VERSION); +} + +static void help(FILE *f) { + fprintf(f, "\n"); + version(f); + fprintf(f, "==============\n"); + fprintf(f, "\nUsage: pgreplay [] [] []\n"); + fprintf(f, " pgreplay -f [] [-o ] []\n"); + fprintf(f, " pgreplay -r [] []\n\n"); + fprintf(f, " The first form parses a PostgreSQL log file and replays the\n"); + fprintf(f, "statements against a database.\n"); + fprintf(f, " The second form parses a PostgreSQL log file and writes the\n"); + fprintf(f, "contents to a \"replay file\" that can be replayed with -r.\n"); + fprintf(f, " The third form replays a file generated with -f.\n\n"); + fprintf(f, "Parse options:\n"); + fprintf(f, " -c (assume CSV logfile)\n"); + fprintf(f, " -P (assume Polardb11 adult logfile)\n"); + fprintf(f, " -m (print monitor info,only support for polardb)\n"); + fprintf(f, " -b (start time for parsing logfile)\n"); + fprintf(f, " -e (end time for parsing logfile)\n"); + fprintf(f, " -q ( \\' in string literal is a single quote)\n\n"); + fprintf(f, " -D (database name to use as filter for parsing logfile)\n"); + fprintf(f, " -U (username to use as filter for parsing logfile)\n"); + fprintf(f, "Replay options:\n"); + fprintf(f, " -h \n"); + fprintf(f, " -p \n"); + fprintf(f, " -W (must be the same for all users)\n"); + fprintf(f, " -s (speed factor for replay)\n"); + fprintf(f, " -E (server encoding)\n"); + fprintf(f, " -j (skip idle time during replay)\n"); + fprintf(f, " -X (extra libpq connect options)\n\n"); + fprintf(f, " -n (dry-run, will replay file without running queries)\n\n"); + fprintf(f, "Debugging:\n"); + fprintf(f, " -d (level between 1 and 3)\n"); + fprintf(f, " -v (prints version and exits)\n"); +} + +int main(int argc, char **argv) { + int arg, parse_only = 0, replay_only = 0, port = -1, csv = 0, + parse_opt = 0, replay_opt = 0, rc = 0, dry_run = 0, monitor_gap = 0, polardb_audit = 0; + double factor = 1.0; + char *host = NULL, *encoding = NULL, *endptr, *passwd = NULL, + *outfilename = NULL, *infilename = NULL, + *database_only = NULL, *username_only = NULL, *tmp = NULL, + start_time[24] = { '\0' }, end_time[24] = { '\0' }; + const char *errmsg; + unsigned long portnr = 0l, debug = 0l, length; + replay_item_provider *provider; + replay_item_provider_init *provider_init; + replay_item_provider_finish *provider_finish; + replay_item_consumer *consumer; + replay_item_consumer_init *consumer_init; + replay_item_consumer_finish *consumer_finish; + replay_item *item = NULL; + const struct timeval *tmp_time; + struct timeval monitor_time; + + /* initialize errno to avoid bogus error messages */ + errno = 0; + + /* parse arguments */ + opterr = 0; + while (-1 != (arg = getopt(argc, argv, "vfro:h:p:W:s:E:d:cb:e:qjnX:D:U:Pm:"))) { + switch (arg) { + case 'v': + version(stdout); + return 0; + break; + case 'f': + parse_only = 1; + if (replay_only) { + fprintf(stderr, "Error: options -p and -r are mutually exclusive\n"); + help(stderr); + return 1; + } + break; + case 'r': + replay_only = 1; + if (parse_only) { + fprintf(stderr, "Error: options -p and -r are mutually exclusive\n"); + help(stderr); + return 1; + } + break; + case 'o': + outfilename = ('\0' == *optarg) ? NULL : optarg; + break; + case 'h': + replay_opt = 1; + + host = ('\0' == *optarg) ? NULL : optarg; + break; + case 'p': + replay_opt = 1; + + portnr = strtoul(optarg, &endptr, 0); + if (('\0' == *optarg) || ('\0' != *endptr)) { + fprintf(stderr, "Not a valid port number: \"%s\"\n", optarg); + help(stderr); + return 1; + } + if ((portnr < 1) || (65535 < portnr)) { + fprintf(stderr, "Port number must be between 1 and 65535\n"); + help(stderr); + return 1; + } + port = (int)portnr; + break; + case 'W': + replay_opt = 1; + + passwd = ('\0' == *optarg) ? NULL : optarg; + break; + case 's': + replay_opt = 1; + + factor = strtod(optarg, &endptr); + if (('\0' == *optarg) || ('\0' != *endptr)) { + fprintf(stderr, "Not a valid floating point number: \"%s\"\n", optarg); + help(stderr); + return 1; + } + if (0 != errno) { + perror("Error converting speed factor"); + help(stderr); + return 1; + } + if (factor <= 0.0) { + fprintf(stderr, "Factor must be greater than 0\n"); + help(stderr); + return 1; + } + break; + case 'E': + replay_opt = 1; + + encoding = ('\0' == *optarg) ? NULL : optarg; + break; + case 'd': + debug = strtoul(optarg, &endptr, 0); + if (('\0' == *optarg) || ('\0' != *endptr)) { + fprintf(stderr, "Not a valid debug level: \"%s\"\n", optarg); + help(stderr); + return 1; + } + if ((debug < 0) || (3 < debug)) { + fprintf(stderr, "Debug level must be between 0 and 3\n"); + help(stderr); + return 1; + } + debug_level = (int)debug; + break; + case 'c': + parse_opt = 1; + + csv = 1; + break; + case 'P': + parse_opt = 1; + polardb_audit = 1; + break; + case 'm': + tmp = ('\0' == *optarg) ? NULL : optarg; + monitor_gap = atoi(tmp); + break; + case 'b': + parse_opt = 1; + + if (NULL == (errmsg = parse_time(optarg, NULL))) { + strncpy(start_time, optarg, 23); + } else { + fprintf(stderr, "Error in begin timestamp: %s\n", errmsg); + help(stderr); + return 1; + } + break; + case 'e': + parse_opt = 1; + + if (NULL == (errmsg = parse_time(optarg, NULL))) { + strncpy(end_time, optarg, 23); + } else { + fprintf(stderr, "Error in end timestamp: %s\n", errmsg); + help(stderr); + return 1; + } + break; + case 'q': + backslash_quote = 1; + break; + case 'j': + replay_opt = 1; + + jump_enabled = 1; + break; + case 'n': + replay_opt = 1; + + dry_run = 1; + break; + case 'X': + replay_opt = 1; + + extra_connstr = optarg; + break; + case 'D': + parse_opt = 1; + + if (NULL == database_only) { + length = strlen(optarg) + 3; + database_only = malloc(length); + if (NULL != database_only) + strcpy(database_only, "\\"); + } else { + length = strlen(database_only) + strlen(optarg) + 2; + database_only = realloc(database_only, length); + } + if (NULL == database_only) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", length); + return 1; + } + + strcat(database_only, optarg); + strcat(database_only, "\\"); + break; + case 'U': + parse_opt = 1; + + if (NULL == username_only) { + length = strlen(optarg) + 3; + username_only = malloc(length); + if (NULL != username_only) + strcpy(username_only, "\\"); + } else { + length = strlen(username_only) + strlen(optarg) + 2; + username_only = realloc(username_only, length); + } + if (NULL == username_only) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", length); + return 1; + } + + strcat(username_only, optarg); + strcat(username_only, "\\"); + break; + case '?': + if (('?' == optopt) || ('h' == optopt)) { + help(stdout); + return 0; + } else { + fprintf(stderr, "Error: unknown option -%c\n", optopt); + help(stderr); + return 1; + } + break; + } + } + + if (optind + 1 < argc) { + fprintf(stderr, "More than one argument given\n"); + help(stderr); + return 1; + } + + if (optind + 1 == argc) { + infilename = argv[optind]; + } + + if (parse_only && replay_opt) { + fprintf(stderr, "Error: cannot specify replay option with -f\n"); + help(stderr); + return 1; + } + + if (replay_only && parse_opt) { + fprintf(stderr, "Error: cannot specify parse option with -r\n"); + help(stderr); + return 1; + } + + if (NULL != outfilename) { + if (! parse_only) { + fprintf(stderr, "Error: option -o is only allowed with -f\n"); + help(stderr); + return 1; + } + } + + if(polardb_audit){ + if(parse_only || replay_only){ + fprintf(stderr,"only support fisrt pattern for polardb (combined parse and replay)"); + help(stderr); + return 1; + } + } + + /* set default encoding */ + if (NULL != encoding) { + if (-1 == do_setenv("PGCLIENTENCODING", encoding)) { + return 1; + } + } + + /* figure out destination for statistics output */ + if (parse_only && (NULL == outfilename)) { + sf = stderr; /* because replay file will go to stdout */ + } else { + sf = stdout; + } + + /* configure main loop */ + + if (replay_only) { + provider_init = &file_provider_init; + provider = &file_provider; + provider_finish = &file_provider_finish; + } else { + provider_init = &parse_provider_init; + provider = &parse_provider; + provider_finish = &parse_provider_finish; + } + + if (parse_only) { + consumer_init = &file_consumer_init; + consumer_finish = &file_consumer_finish; + consumer = &file_consumer; + } else { + consumer_init = &database_consumer_init; + consumer_finish = &database_consumer_finish; + if (0 == dry_run) { + consumer = &database_consumer; + } else { + consumer = &database_consumer_dry_run; + } + } + + /* main loop */ + + if (! (*provider_init)( + infilename, + csv, + (('\0' == start_time[0]) ? NULL : start_time), + (('\0' == end_time[0]) ? NULL : end_time), + database_only, + username_only + )) + { + rc = 1; + } + + if ((0 == rc) && (*consumer_init)(outfilename, host, port, passwd, factor)) { + /* try to get first item */ + if (! (item = (*provider)())) { + rc = 1; + } + } else { + rc = 1; + } + + tmp_time = replay_get_time(item); + monitor_time.tv_sec = tmp_time->tv_sec; + monitor_time.tv_usec = tmp_time->tv_usec; + if(polardb_audit && monitor_gap) + monitor_connect_init(host, port, passwd); + + while ((0 == rc) && (end_item != item)) { + + int n = (*consumer)(item); + + switch (n) { + case 0: /* item not consumed */ + break; + case 1: /* item consumed */ + if (! (item = (*provider)())) { + rc = 1; + } + break; + default: /* error occurred */ + rc = 1; + } + if(polardb_audit && monitor_gap && replay_get_time(item)->tv_sec - monitor_time.tv_sec >= monitor_gap){ + monitor_connect_execute(monitor_sql); + monitor_time.tv_sec = replay_get_time(item)->tv_sec; + } + } + + /* no statistics output if there was an error */ + if (1 == rc) { + sf = NULL; + } + + (*provider_finish)(); + (*consumer_finish)(dry_run); + monitor_connect_finish(); + + return rc; +} diff --git a/pgreplay/parse.c b/pgreplay/parse.c new file mode 100644 index 00000000000..f223153610b --- /dev/null +++ b/pgreplay/parse.c @@ -0,0 +1,1907 @@ +#include "pgreplay.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#ifdef TIME_WITH_SYS_TIME +# include +# include +#else +# ifdef HAVE_SYS_TIME_H +# include +# else +# include +# endif +#endif + +extern void parse_provider_finish(void); +extern replay_item * parse_provider(void); + +/* long enough to contain the beginning of a log line */ +#define BUFLEN 1024 +/* separates log line entries */ +#define SEPCHAR '|' + +/* types of log entries */ +typedef enum { + log_debug5, + log_debug4, + log_debug3, + log_debug2, + log_debug1, + log_info, + log_notice, + log_warning, + log_error, + log_log, + log_fatal, + log_panic, + log_unknown +} log_type; + +/* type for functions parsing the next log entry */ +typedef int (parse_log_entry_func)(struct timeval *, char *, char *, uint64_t *, log_type *, char **, char **); +/* functions for parsing stderr and CSV log entries */ +static parse_log_entry_func parse_errlog_entry; +static parse_log_entry_func parse_csvlog_entry; +static parse_log_entry_func * const parse_log_entry[2] = { + &parse_errlog_entry, + &parse_csvlog_entry +}; + +/* used to remember prepared statements */ +struct prep_stmt { + char *name; + struct prep_stmt *next; +}; +/* used to remember "open" connections */ +struct connection { + uint64_t session_id; + struct connection *next; + struct prep_stmt *statements; +}; +/* hash structure for "open" connections */ +static struct connection * open_conn[256] = { NULL }; + + + +/* indicates whether we are parsing a CSV file */ +static int csv; + +/* start and end timestamp for parsing log entries */ +static const char *start_time, *end_time; +/* database and username filters for parsing log entries */ +static const char *database_only, *username_only; +/* file which we parse */ +static int infile; +/* line number for error messages */ +static unsigned long lineno = 0; +/* offset for time values (what mktime(3) makes of 2000-01-01 00:00:00) + used to make timestamps independent of local time and broken mktime */ +static time_t epoch; +/* time of the first and last statement that we parse */ +static struct timeval first_stmt_time, last_stmt_time; + +/* statistics */ +static unsigned long stat_simple = 0; /* simple statements */ +static unsigned long stat_copy = 0; /* copy statements */ +static unsigned long stat_param = 0; /* parametrized statements */ +static unsigned long stat_named = 0; /* different named statements */ +static unsigned long stat_execnamed = 0; /* named statement executions */ +static unsigned long stat_fastpath = 0; /* fast-path function calls */ +static unsigned long stat_cancel = 0; /* cancel requests */ + +/* a version of strcpy that handles overlapping strings well */ +static char *overlap_strcpy(char *dest, const char *src) { + register char c; + + while((c = *(src++))) { + *(dest++) = c; + } + *dest = '\0'; + + return dest; +} + +/* convert a string to a log_type */ +static log_type to_log_type(const char* s) { + /* compare in order of expected likelyhood for performance */ + if (! strcmp(s, "LOG")) { + return log_log; + } else if (! strcmp(s, "ERROR")) { + return log_error; + } else if (! strcmp(s, "STATEMENT")) { + return log_unknown; + } else if (! strcmp(s, "DETAIL")) { + return log_unknown; + } else if (! strcmp(s, "HINT")) { + return log_unknown; + } else if (! strcmp(s, "FATAL")) { + return log_fatal; + } else if (! strcmp(s, "WARNING")) { + return log_warning; + } else if (! strcmp(s, "NOTICE")) { + return log_notice; + } else if (! strcmp(s, "INFO")) { + return log_info; + } else if (! strcmp(s, "PANIC")) { + return log_panic; + } else if (! strcmp(s, "DEBUG1")) { + return log_debug1; + } else if (! strcmp(s, "DEBUG2")) { + return log_debug2; + } else if (! strcmp(s, "DEBUG3")) { + return log_debug3; + } else if (! strcmp(s, "DEBUG4")) { + return log_debug4; + } else if (! strcmp(s, "DEBUG5")) { + return log_debug5; + } else { + return log_unknown; + } +} + +/* Parses a timestamp (ignoring the time zone part). + If "dest" is not null, the parsed time will be returned there. + Return value is NULL on success, else an error message */ + +const char * parse_time(const char *source, struct timeval *dest) { + int i; + static struct tm tm; /* initialize with zeros */ + char s[24] = { '\0' }; /* modifiable copy of source */ + static char errmsg[BUFLEN]; + /* format of timestamp part */ + static char format[] = "nnnn-nn-nn nn:nn:nn"; + + /* check timestamp for validity */ + if (!source) { + strcpy(errmsg, "NULL passed as timestamp string"); + return errmsg; + } + + if (strlen(source) < strlen(format)) { + sprintf(errmsg, "timestamp string is less than %lu characters long", (unsigned long)strlen(format)); + return errmsg; + } + + if (strlen(source) >= BUFLEN) { + sprintf(errmsg, "timestamp string is more than %d characters long", BUFLEN-1); + return errmsg; + } + + for (i=0; i '9')) { + sprintf(errmsg, "character %d in timestamp string is '%c', expected digit", i+1, source[i]); + return errmsg; + } else + s[i] = source[i]; + break; + default: + if (source[i] != format[i]) { + sprintf(errmsg, "character %d in timestamp string is '%c', expected '%c'", i+1, source[i], format[i]); + return errmsg; + } else + s[i] = '\0'; /* tokenize parts */ + } + } + + /* parse time into 'tm' */ + tm.tm_year = atoi(s) - 1900; + tm.tm_mon = atoi(s + 5) - 1; + tm.tm_mday = atoi(s + 8); + tm.tm_hour = atoi(s + 11); + tm.tm_min = atoi(s + 14); + tm.tm_sec = atoi(s + 17); + tm.tm_isdst = 0; /* ignore daylight savings time */ + + if (dest) { + dest->tv_sec = mktime(&tm) - epoch; + dest->tv_usec = atoi(s + 20) * 1000; + } + + return NULL; +} + +static char * parse_session(const char *source, uint64_t *dest) { + char s[BUFLEN]; /* modifiable copy of source */ + static char errmsg[BUFLEN]; + char *s1 = NULL, c; + uint32_t part1, part2; + int i; + + /* check input for validity */ + if (!source) { + strcpy(errmsg, "NULL passed as session id string"); + return errmsg; + } + + if (strlen(source) > BUFLEN -1) { + sprintf(errmsg, "session id string is more than %d characters long", BUFLEN); + return errmsg; + } + + for (i=0; i<=strlen(source); ++i) { + c = source[i]; + if (('.' == c) && (! s1)) { + s[i] = '\0'; + s1 = s + i + 1; + } else if (((c < '0') || (c > '9')) && ((c < 'a') || (c > 'f')) && ('\0' != c)) { + sprintf(errmsg, "character %d in session id string is '%c', expected hex digit", i+1, c); + return errmsg; + } else + s[i] = c; + } + + if (! s1) { + strcpy(errmsg, "Missing \".\" in session id string"); + return errmsg; + } + + if ((strlen(s) > 8) || (strlen(s1) > 8)) { + strcpy(errmsg, "none of the parts of a session id string may be longer than 8 hex digits"); + return errmsg; + } + + /* convert both parts */ + sscanf(s, UINT32_FORMAT, &part1); + sscanf(s1, UINT32_FORMAT, &part2); + *dest = (((uint64_t)part1) << 32) + part2; + + return NULL; +} + +/* reads one log entry from the input file + the result is a malloc'ed string that must be freed + a return value of NULL means that there was an error */ + +static char * read_log_line() { + char *line, buf[BUFLEN] = { '\0' }, *p; + int len, escaped = 0, nl_found = 0, line_size = 0, i, l; + ssize_t bytes_read; + /* this will contain stuff we have read from the file but not used yet */ + static char peekbuf[BUFLEN] = { '\0' }; + static int peeklen = 0; + + debug(3, "Entering read_log_line, current line number %lu\n", lineno+1); + + /* pre-allocate the result to length 1 */ + if (NULL == (line = malloc(1))) { + fprintf(stderr, "Cannot allocate 1 byte of memory\n"); + return NULL; + } + *line = '\0'; + + while (! nl_found) { + /* if there were any chars left from the last invokation, use them first */ + len = peeklen; + if (len) { + strcpy(buf, peekbuf); + peekbuf[0] = '\0'; + } + peeklen = 0; + + /* read from file until buf is full (at most) */ + if (len < BUFLEN - 1) { + if (-1 == (bytes_read = read(infile, buf + len, BUFLEN - 1 - len))) { + perror("Error reading from input file"); + return NULL; + } + len += bytes_read; + buf[len] = '\0'; + } + + /* if there is still nothing, we're done */ + if (0 == len) { + debug(2, "Encountered EOF%s\n", ""); + debug(3, "Leaving read_log_line%s\n", ""); + return line; + } + + /* search the string for unescaped newlines */ + for (p=buf; *p!='\0'; ++p) { + if (csv && ('"' == *p)) { + escaped = !escaped; + } + /* keep up with line count */ + lineno += ('\n' == *p); + + /* look for unescaped newline */ + if (!escaped && ('\n' == *p)) { + /* if a newline is found, truncate the string + and prepend the rest to peekbuf */ + l = len - (++p - buf); + /* right shift peekbuf by l */ + for (i=peeklen; i>=0; --i) { + peekbuf[l+i] = peekbuf[i]; + } + strncpy(peekbuf, p, l); + *p = '\0'; + peeklen += len - (p - buf); + len = p - buf; + if (csv) { + /* for a CSV file, this must be the end of the log entry */ + nl_found = 1; + break; /* out from the for loop */ + } else { + /* in a stderr log file, we must check for a + continuation line (newline + tab) */ + /* first, make sure there is something to peek at */ + if (0 == peeklen) { + /* try to read one more byte from the file */ + if (-1 == (bytes_read = read(infile, peekbuf, 1))) { + perror("Error reading from input file"); + return NULL; + } + if (0 == bytes_read) { + /* EOF means end of log entry */ + nl_found = 1; + break; /* out from the for loop */ + } else { + peeklen = bytes_read; + peekbuf[peeklen] = '\0'; + } + } + /* then check for a continuation tab */ + if ('\t' == *peekbuf) { + /* continuation line, remove tab + and copy peekbuf back to buf */ + strncpy(p--, peekbuf + 1, BUFLEN - 1 - len); + if (peeklen > BUFLEN - len) { + overlap_strcpy(peekbuf, peekbuf + (BUFLEN - len)); + peeklen = peeklen - BUFLEN + len; + len = BUFLEN - 1; + } else { + *peekbuf = '\0'; + len += peeklen - 1; + peeklen = 0; + } + buf[len] = '\0'; + } else { + /* end of log entry reached */ + nl_found = 1; + break; /* out from the for loop */ + } + } + } + } + /* extend result line and append buf */ + line_size += len; + if (NULL == (p = realloc(line, line_size+1))) { + fprintf(stderr, "Cannot allocate %d bytes of memory\n", line_size); + free(line); line = NULL; + return NULL; + } + line = p; + strcat(line, buf); + *buf = '\0'; + len = 0; + } + + /* remove trailing newline in result if present */ + if ('\n' == line[line_size - 1]) { + line[line_size - 1] = '\0'; + } + + debug(3, "Leaving read_log_line%s\n", ""); + + return line; +} + +/* parses the next stderr log entry (and maybe a detail message after that) + timestamp, user, database, session ID, log message type, log message + and detail message are returned in the respective parameters + "message" and "detail" are malloc'ed if they are not NULL + return values: -1 (error), 0 (end-of-file), or 1 (success) */ + +static int parse_errlog_entry(struct timeval *time, char *user, char *database, uint64_t *session_id, log_type *type, char **message, char **detail) { + char *line = NULL, *part2, *part3, *part4, *part5, *part6; + const char *errmsg; + int i, skip_line = 0; + static int dump_found = 0; + /* if not NULL, contains the next log entry to parse */ + static char* keepline = NULL; + + debug(3, "Entering parse_errlog_entry%s\n", ""); + + /* initialize message and detail with NULL */ + *message = NULL; + *detail = NULL; + + /* use cached line or read next line from log file */ + if (keepline) { + line = keepline; + keepline = NULL; + } else { + /* read lines until we are between start_time and end_time */ + do { + if (line) { + free(line); + } + if (NULL == (line = read_log_line())) { + return -1; + } + + /* is it the start of a memory dump? */ + if (0 == strncmp(line, "TopMemoryContext: ", 18)) { + fprintf(stderr, "Found memory dump in line %lu\n", lineno); + dump_found = 1; + skip_line = 1; + } else { + /* if there is a dump and the line starts blank, + assume the line is part of the dump + */ + if (dump_found && (' ' == *line)) { + skip_line = 1; + } else { + skip_line = 0; + } + } + } while (('\0' != *line) + && (skip_line + || (start_time && (strncmp(line, start_time, 23) < 0)))); + } + + /* check for EOF */ + if (('\0' == *line) || (end_time && (strncmp(line, end_time, 23) > 0))) { + free(line); + debug(3, "Leaving parse_errlog_entry%s\n", ""); + return 0; + } + + /* split line on | in six pieces: time, user, database, session ID, log entry type, rest */ + if (NULL == (part2 = strchr(line, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: no \"%c\" found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part2++) = '\0'; + } + + if (NULL == (part3 = strchr(part2, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: second \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part3++) = '\0'; + } + + if (NULL == (part4 = strchr(part3, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: third \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part4++) = '\0'; + } + + if (NULL == (part5 = strchr(part4, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: fourth \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part5++) = '\0'; + } + + if (NULL == (part6 = strstr(part5, ": "))) { + fprintf(stderr, "Error parsing line %lu: log message does not begin with a log type\n", lineno); + free(line); + return -1; + } else { + *part6 = '\0'; + part6 += 3; + } + + /* first part is the time, parse it into parameter */ + if ((errmsg = parse_time(line, time))) { + fprintf(stderr, "Error parsing line %lu: %s\n", lineno, errmsg); + free(line); + return -1; + } + + /* second part is the username, copy to parameter */ + if (NAMELEN < strlen(part2)) { + fprintf(stderr, "Error parsing line %lu: username exceeds %d characters\n", lineno, NAMELEN); + free(line); + return -1; + } else { + strcpy(user, part2); + } + + /* third part is the database, copy to parameter */ + if (NAMELEN < strlen(part3)) { + fprintf(stderr, "Error parsing line %lu: database name exceeds %d characters\n", lineno, NAMELEN); + free(line); + return -1; + } else { + strcpy(database, part3); + } + + /* fourth part is the session ID, copy to parameter */ + if ((errmsg = parse_session(part4, session_id))) { + fprintf(stderr, "Error parsing line %lu: %s\n", lineno, errmsg); + free(line); + return -1; + } + + /* fifth part is the log type, copy to parameter */ + *type = to_log_type(part5); + + /* sixth part is the log message */ + overlap_strcpy(line, part6); + *message = line; + + /* read the next log entry so that we can peek at it */ + line = NULL; + do { + if (NULL != line) { + free(line); + } + if (NULL == (line = read_log_line())) { + free(*message); + *message = NULL; + return -1; + } + + /* is it the start of a memory dump? */ + if (0 == strncmp(line, "TopMemoryContext: ", 18)) { + fprintf(stderr, "Found memory dump in line %lu\n", lineno); + dump_found = 1; + skip_line = 1; + } else { + /* if there is a dump and the line starts blank, + assume the line is part of the dump + */ + if (dump_found && (' ' == *line)) { + skip_line = 1; + } else { + skip_line = 0; + } + } + } while (('\0' != *line) && skip_line); + + if ('\0' == *line) { + /* EOF, that's ok */ + keepline = line; + } else { + /* skip four | to the fifth part */ + part2 = line; + for (i=0; i<4; ++i) { + if (NULL == (part2 = strchr(part2, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: only %d \"%c\" found - log_line_prefix may be wrong\n", lineno, i, SEPCHAR); + free(*message); + free(line); + *message = NULL; + return -1; + } else { + ++part2; + } + } + + /* check if it is a DETAIL */ + if (strncmp(part2, "DETAIL: ", 9)) { + /* if not, remember the line for the next pass */ + keepline = line; + } else { + debug(2, "Found a DETAIL message%s\n", ""); + + /* set the return parameter to the detail message */ + overlap_strcpy(line, part2 + 9); + *detail = line; + } + } + + debug(3, "Leaving parse_errlog_entry%s\n", ""); + return 1; +} + + +/* parses the next stderr log entry (and maybe a detail message after that) + timestamp, user, database, session ID, search_path,prepare_paramslog, message type, log message + and detail message are returned in the respective parameters + "message" and "detail" are malloc'ed if they are not NULL + return values: -1 (error), 0 (end-of-file), or 1 (success) +*/ + +static int parse_auditlog_entry_polardb11(struct timeval *time, char *user, char *database, uint64_t *session_id, log_type *type, char **message, char **detail, char* search_path, char* prepare_parse) { + char *line = NULL, *part2, *part3, *part4, *part5, *part6, *search_path_, *prepare_parse_; + const char *errmsg; + int i, skip_line = 0; + static int dump_found = 0; + /* if not NULL, contains the next log entry to parse */ + static char* keepline = NULL; + + debug(3, "Entering parse_errlog_entry%s\n", ""); + + /* initialize message and detail with NULL */ + *message = NULL; + *detail = NULL; + + /* use cached line or read next line from log file */ + if (keepline) { + line = keepline; + keepline = NULL; + } else { + /* read lines until we are between start_time and end_time */ + do { + if (line) { + free(line); + } + if (NULL == (line = read_log_line())) { + return -1; + } + + /* is it the start of a memory dump? */ + if (0 == strncmp(line, "TopMemoryContext: ", 18)) { + fprintf(stderr, "Found memory dump in line %lu\n", lineno); + dump_found = 1; + skip_line = 1; + } else { + /* if there is a dump and the line starts blank, + assume the line is part of the dump + */ + if (dump_found && (' ' == *line)) { + skip_line = 1; + } else { + skip_line = 0; + } + } + } while (('\0' != *line) + && (skip_line + || (start_time && (strncmp(line, start_time, 23) < 0)))); + } + + /* check for EOF */ + if (('\0' == *line) || (end_time && (strncmp(line, end_time, 23) > 0))) { + free(line); + debug(3, "Leaving parse_errlog_entry%s\n", ""); + return 0; + } + + /* split line on | in six pieces: time, user, database, session ID, log entry type, rest */ + // user + if (NULL == (part2 = strchr(line, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: no \"%c\" found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part2++) = '\0'; + } + // database + if (NULL == (part3 = strchr(part2, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: second \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part3++) = '\0'; + } + // session id + if (NULL == (part4 = strchr(part3, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: third \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part4++) = '\0'; + } + // search path + if (NULL == (search_path_ = strchr(part4, SEPCHAR))){ + fprintf(stderr, "Error parsing line %lu: search_path_ \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + }else { + *(search_path_++) = '\0'; + } + // prepare parse + if (NULL == (prepare_parse_ = strchr(search_path_, SEPCHAR))){ + fprintf(stderr, "Error parsing line %lu: prepare_parse_ \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + }else { + *(prepare_parse_++) = '\0'; + } + // log type + if (NULL == (part5 = strchr(prepare_parse_, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: fourth \"%c\" not found - log_line_prefix may be wrong\n", lineno, SEPCHAR); + free(line); + return -1; + } else { + *(part5++) = '\0'; + } + // log message + if (NULL == (part6 = strstr(part5, ": "))) { + fprintf(stderr, "Error parsing line %lu: log message does not begin with a log type\n", lineno); + free(line); + return -1; + } else { + *part6 = '\0'; + part6 += 3; + } + + /* first part is the time, parse it into parameter */ + if ((errmsg = parse_time(line, time))) { + fprintf(stderr, "Error parsing line %lu: %s\n", lineno, errmsg); + free(line); + return -1; + } + + /* second part is the username, copy to parameter */ + if (NAMELEN < strlen(part2)) { + fprintf(stderr, "Error parsing line %lu: username exceeds %d characters\n", lineno, NAMELEN); + free(line); + return -1; + } else { + strcpy(user, part2); + } + + /* third part is the database, copy to parameter */ + if (NAMELEN < strlen(part3)) { + fprintf(stderr, "Error parsing line %lu: database name exceeds %d characters\n", lineno, NAMELEN); + free(line); + return -1; + } else { + strcpy(database, part3); + } + + /* fourth part is the session ID, copy to parameter */ + if ((errmsg = parse_session(part4, session_id))) { + fprintf(stderr, "Error parsing line %lu: %s\n", lineno, errmsg); + free(line); + return -1; + } + /* search path copy to parameter */ + if (POLARDBlEN < strlen(search_path_)) { + fprintf(stderr, "Error parsing line %lu: database name exceeds %d characters\n", lineno, POLARDBlEN); + free(line); + return -1; + } else { + strcpy(search_path, search_path_); + // printf("search_path is %s, search_path_ is %s\n",search_path,search_path_); + } + /* prepare parse copy to parameter */ + if (POLARDBlEN < strlen(prepare_parse_)) { + fprintf(stderr, "Error parsing line %lu: database name exceeds %d characters\n", lineno, POLARDBlEN); + free(line); + return -1; + } else { + strcpy(prepare_parse, prepare_parse_); + } + + /* fifth part is the log type, copy to parameter */ + *type = to_log_type(part5); + + /* sixth part is the log message */ + overlap_strcpy(line, part6); + *message = line; + // printf("part2 is %s, part3 is %s, part4 is %s, part5 is %s, part6 is %s\n", part2, part3, part4, part5, part6); + + + /* read the next log entry so that we can peek at it */ + line = NULL; + do { + if (NULL != line) { + free(line); + } + if (NULL == (line = read_log_line())) { + free(*message); + *message = NULL; + return -1; + } + + /* is it the start of a memory dump? */ + if (0 == strncmp(line, "TopMemoryContext: ", 18)) { + fprintf(stderr, "Found memory dump in line %lu\n", lineno); + dump_found = 1; + skip_line = 1; + } else { + /* if there is a dump and the line starts blank, + assume the line is part of the dump + */ + if (dump_found && (' ' == *line)) { + skip_line = 1; + } else { + skip_line = 0; + } + } + } while (('\0' != *line) && skip_line); + + if ('\0' == *line) { + /* EOF, that's ok */ + keepline = line; + } else { + /* skip four | to the fifth part */ + part2 = line; + for (i=0; i<4; ++i) { + if (NULL == (part2 = strchr(part2, SEPCHAR))) { + fprintf(stderr, "Error parsing line %lu: only %d \"%c\" found - log_line_prefix may be wrong\n", lineno, i, SEPCHAR); + free(*message); + free(line); + *message = NULL; + return -1; + } else { + ++part2; + } + } + + /* check if it is a DETAIL */ + if (strncmp(part2, "DETAIL: ", 9)) { + /* if not, remember the line for the next pass */ + keepline = line; + } else { + debug(2, "Found a DETAIL message%s\n", ""); + + /* set the return parameter to the detail message */ + overlap_strcpy(line, part2 + 9); + *detail = line; + } + } + + debug(3, "Leaving parse_errlog_entry%s\n", ""); + return 1; +} + +/* parses the next CSV log entry + timestamp, user, database, session ID, log message type, log message + and detail message are returned in the respective parameters + "message" is malloc'ed, "detail" not + return values: -1 (error), 0 (end-of-file), or 1 (success) */ + +static int parse_csvlog_entry(struct timeval *time, char *user, char *database, uint64_t *session_id, log_type *type, char **message, char **detail) { + char *line = NULL, *part[16], *p1, *p2; + const char *errmsg; + int i, escaped = 0; + + debug(3, "Entering parse_csvlog_entry%s\n", ""); + + /* initialize message and detail with NULL */ + *message = NULL; + *detail = NULL; + + /* read next line after start timestamp from log file */ + do { + if (line) { + free(line); + } + if (NULL == (line = read_log_line())) { + return -1; + } + } while (('\0' != *line) + && (start_time && (strncmp(line, start_time, 23) < 0))); + + /* check for EOF */ + if (('\0' == *line) || (end_time && (strncmp(line, end_time, 23) > 0))) { + free(line); + debug(3, "Leaving parse_errlog_entry%s\n", ""); + return 0; + } + + /* parse first 15 parts from the CSV record */ + part[0] = p1 = line; + for (i=1; i<16; ++i) { + p2 = p1; + /* copy p1 to p2 until we hit an unescaped comma, + remove escaping double quotes */ + while (escaped || (',' != *p1)) { + switch (*p1) { + case '\0': + fprintf(stderr, "Error parsing line %lu: comma number %d not found (or unmatched quotes)\n", lineno, i); + free(line); + return -1; + case '"': + /* don't copy the first double quote */ + if (!escaped && (p1 != part[i-1])) { + *(p2++) = '"'; + } + ++p1; + escaped = !escaped; + break; + default: + *(p2++) = *(p1++); + } + } + *p2 = '\0'; + part[i] = ++p1; + } + + /* first part is the time, parse it into parameter */ + if ((errmsg = parse_time(part[0], time))) { + fprintf(stderr, "Error parsing line %lu: %s\n", lineno, errmsg); + free(line); + return -1; + } + + /* second part is the username, copy to parameter */ + if (NAMELEN < strlen(part[1])) { + fprintf(stderr, "Error parsing line %lu: username exceeds %d characters\n", lineno, NAMELEN); + free(line); + return -1; + } else { + strcpy(user, part[1]); + } + + /* third part is the database, copy to parameter */ + if (NAMELEN < strlen(part[2])) { + fprintf(stderr, "Error parsing line %lu: database name exceeds %d characters\n", lineno, NAMELEN); + free(line); + return -1; + } else { + strcpy(database, part[2]); + } + + /* sixth part is the session ID, copy to parameter */ + if ((errmsg = parse_session(part[5], session_id))) { + fprintf(stderr, "Error parsing line %lu: %s\n", lineno, errmsg); + free(line); + return -1; + } + + /* twelfth part is the log type, copy to parameter */ + *type = to_log_type(part[11]); + + /* fourteenth part is the message, assign to output parameter */ + overlap_strcpy(line, part[13]); + *message = line; + + /* detail is the fifteenth part of the line, if not empty */ + *detail = part[14]; + if ('\0' == **detail) { + *detail = NULL; + } + + debug(3, "Leaving parse_csvlog_entry%s\n", ""); + return 1; +} + +/* add (malloc) the prepared statement name to the list of + prepared statements for the connection + returns 0 if the statement already existed, 1 if it was added and -1 if there was an error */ + +static int add_pstmt(struct connection * conn, char const *name) { + struct prep_stmt *pstmt = conn->statements; + int rc; + + debug(3, "Entering add_pstmt for statement \"%s\"\n", name); + + if ('\0' == *name) { + /* the empty statement will never be stored, but should be prepared */ + rc = 1; + + /* count for statistics */ + ++stat_param; + } else { + while (pstmt && strcmp(pstmt->name, name)) { + pstmt = pstmt->next; + } + + if (pstmt) { + /* statement already prepared */ + debug(2, "Prepared statement is already in list%s\n", ""); + rc = 0; + } else { + debug(2, "Adding prepared statement to list%s\n", ""); + /* add statement name to linked list */ + if (NULL == (pstmt = malloc(sizeof(struct prep_stmt)))) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)sizeof(struct prep_stmt)); + return -1; + } + if (NULL == (pstmt->name = malloc(strlen(name) + 1))) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(name) + 1); + free(pstmt); + return -1; + } + strcpy(pstmt->name, name); + pstmt->next = conn->statements; + conn->statements = pstmt; + rc = 1; + + /* count for statistics */ + ++stat_named; + } + /* count for statistics */ + ++stat_execnamed; + } + + debug(3, "Leaving add_pstmt%s\n", ""); + return rc; +} + +/* remove (free) the prepared statement name to the list of + prepared statements for the connection */ + +static void remove_pstmt(struct connection * conn, char const *name) { + struct prep_stmt *pstmt = conn->statements, *pstmt2 = NULL; + + debug(3, "Entering remove_pstmt for statement \"%s\"\n", name); + + while (pstmt && strcmp(pstmt->name, name)) { + pstmt2 = pstmt; /*remember previous */ + pstmt = pstmt->next; + } + + if (pstmt) { + if (pstmt2) { + pstmt2->next = pstmt->next; + } else { + conn->statements = pstmt->next; + } + free(pstmt->name); + free(pstmt); + } else { + debug(2, "Prepared statement not found%s\n", ""); + } + + debug(3, "Leaving remove_pstmt%s\n", ""); + return; +} + +static void remove_all_pstmts(struct connection * conn) { + struct prep_stmt *pstmt = conn->statements, *pstmt2 = NULL; + + debug(3, "Entering remove_all_pstmts%s\n", ""); + + while(pstmt) { + pstmt2 = pstmt; + pstmt = pstmt->next; + free(pstmt2->name); + free(pstmt2); + } + conn->statements = NULL; + + debug(3, "Leaving remove_all_pstmts%s\n", ""); + return; +} + +/* remove all "COPY" and "SET client_encoding" statements; + for DEALLOCATE statements, try to remove prepared statement */ + +/* maximum number of tokens we need to analyze a statement */ +#define MAX_TOKENS 3 + +static int filter_bad_statements(char *line, struct connection *conn) { + char *statement = line, *p = line, token[MAX_TOKENS][NAMELEN + 1], + *q = NULL, *quote, *h; + int comment_depth, tokens = 0, ok = 1, i, nameindex, quotelen; + + debug(3, "Entering filter_bad_statements%s\n", ""); + + for (i=0; i 0) { + /* count parsed simple statements */ + ++stat_simple; + + /* remove statements that won't work */ + + if (! strcmp("copy", token[0])) { + fprintf(stderr, "Warning: COPY statement ignored in line %lu\n", lineno); + /* replace statement with blanks */ + while (statement < p) { + *(statement++) = ' '; + } + + /* count for statistics */ + ++stat_copy; + } else if ((tokens > 1) && (! strcmp("set", token[0])) && (! strcmp("client_encoding", token[1]))) { + fprintf(stderr, "Warning: \"SET client_encoding\" statement ignored in line %lu\n", lineno); + /* replace statement with blanks */ + while (statement < p) { + *(statement++) = ' '; + } + } else if (! strcmp("deallocate", token[0])) { + /* there coule be a "prepare" in the second token, should be ignored */ + if (strcmp("prepare", token[1])) { + nameindex = 1; + } else { + nameindex = 2; + } + if (strcmp("all", token[nameindex])) { + /* deallocate single statement */ + debug(2, "Deallocating prepared statement \"%s\"\n", token[nameindex]); + remove_pstmt(conn, token[nameindex]); + } else { + /* deallocate all prepared statements */ + debug(2, "Deallocating all prepared statements%s\n", ""); + remove_all_pstmts(conn); + } + } + } + + /* break out of loop if end-of-line is reached */ + if ('\0' == *p) { + break; + } + + /* else prepare for next statement */ + statement = ++p; + for (i=0; i *(p+1)) || (('9' < *(p+1))))) { + /* dollar quoted string constant; skip to end */ + quote = p++; + while (('$' != *p) && ('\0' != *p)) { + ++p; + } + if ('\0' == *p) { + fprintf(stderr, "Error: end of dollar quote not found in line %lu\n", lineno); + ok = 0; + } else { + quotelen = p - quote; + *p = '\0'; + h = p; + do { + h = strstr(++h, quote); + } while ((NULL != h) && ('$' != *(h + quotelen))); + *p = '$'; + if (NULL == h) { + fprintf(stderr, "Error: end of dollar quoted string found in line %lu\n", lineno); + ok = 0; + } else { + p = h + (quotelen + 1); + } + } + } else if (('-' == *p) && ('-' == p[1])) { + /* comment; skip to end of line or statement */ + while (('\n' != *p) && ('\0' != *p)) { + ++p; + } + } else if (('/' == *p) && ('*' == p[1])) { + /* comment, skip to matching end */ + p += 2; + comment_depth = 1; /* comments can be nested */ + while (0 != comment_depth) { + if ('\0' == *p) { + fprintf(stderr, "Error: comment not closed in line %lu\n", lineno); + ok = 0; + break; + } else if (('*' == *p) && ('/' == p[1])) { + --comment_depth; + p += 2; + } else if (('/' == *p) && ('*' == p[1])) { + ++comment_depth; + p += 2; + } else { + ++p; + } + } + } else if ('"' == *p) { + /* quoted identifier, copy to token if necessary */ + if (tokens < MAX_TOKENS) { + q = token[tokens]; + } + while (1) { + ++p; + if ('\0' == *p) { + fprintf(stderr, "Error: quoted identifier not closed in line %lu\n", lineno); + ok = 0; + break; + } else if ('"' == *p) { + if ('"' == p[1]) { + /* double " means a single " in a quoted identifier */ + if ((tokens < MAX_TOKENS) && (q - token[tokens] < NAMELEN)) { + *(q++) = '"'; + } + ++p; + } else { + /* end of token */ + if (tokens < MAX_TOKENS) { + *q = '\0'; + ++tokens; + } + ++p; + break; + } + } else { + /* normal character, copy to token */ + if ((tokens < MAX_TOKENS) && (q - token[tokens] < NAMELEN)) { + *(q++) = *p; + } + } + } + } else if ((('A' <= *p) && ('Z' >= *p)) + || (('a' <= *p) && ('z' >= *p)) + || (127 < (unsigned char)(*p)) /* consider > 127 as letter */ + || ('_' == *p)) { + /* normal identifier, copy to token if necessary */ + if (tokens < MAX_TOKENS) { + q = token[tokens]; + } + while ((('A' <= *p) && ('Z' >= *p)) + || (('a' <= *p) && ('z' >= *p)) + || (('0' <= *p) && ('9' >= *p)) + || (127 < (unsigned char)(*p)) /* consider > 127 as letter */ + || ('_' == *p) || ('$' == *p)) { + if ((tokens < MAX_TOKENS) && (q - token[tokens] < NAMELEN)) { + /* convert to lowercase */ + *(q++) = *p + ('a' - 'A') * ((*p >= 'A') && (*p <= 'Z')); + } + ++p; + } + *q = '\0'; + ++tokens; + } else { + /* everything else is considered unimportant */ + ++p; + } + } + + debug(3, "Leaving filter_bad_statements%s\n", ""); + return ok; +} + +/* check if there is a connection for this session_id + if not, a new connection replay_item is generated and returned in r + return values: found or created hash entry for success, NULL for failure */ + +static struct connection *add_connection(replay_item **r, struct timeval *time, const char *user, const char *database, uint64_t session_id) { + unsigned char hash; + struct connection *conn; + + hash = hash_session(session_id); + conn = open_conn[hash]; + + debug(3, "Entering add_connection for session 0x" UINT64_FORMAT "\n", session_id); + + while (conn && (conn->session_id != session_id)) { + conn = conn->next; + } + + if (conn) { + /* session already exists */ + *r = NULL; + } else { + /* session doesn't exist yet; create it and add it to hash table */ + if (NULL == (*r = replay_create_connect(time, session_id, user, database))) { + /* something went wrong */ + return NULL; + } else { + if ((conn = malloc(sizeof(struct connection)))) { + conn->next = open_conn[hash]; + conn->statements = NULL; + conn->session_id = session_id; + open_conn[hash] = conn; + } else { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)sizeof(struct connection)); + replay_free(*r); + return NULL; + } + } + } + + debug(3, "Leaving add_connection%s\n", ""); + return conn; +} + +/* remove a connection from the hash structure + returns 1 for success, 0 for failure */ + +static int remove_connection(uint64_t session_id) { + unsigned char hash; + struct connection *conn, *conn2 = NULL; + + hash = hash_session(session_id); + conn = open_conn[hash]; + + debug(3, "Entering remove_connection for session 0x" UINT64_FORMAT "\n", session_id); + + while (conn && (conn->session_id != session_id)) { + conn2 = conn; /* remember previous */ + conn = conn->next; + } + + if (conn) { + remove_all_pstmts(conn); + if (conn2) { + conn2->next = conn->next; + } else { + open_conn[hash] = conn->next; + } + free(conn); + } + + debug(3, "Leaving remove_connection%s\n", ""); + + return (NULL != conn); +} + +/* tokenizes the "line" into single arguments, pointers to which + are stored in "result" (which is malloc'ed and must be freed) + returns the number of arguments and -1 if there is an error + Note that the strings that "result" points to are *not* malloc'ed, + but part of "line" */ + +static int parse_bind_args(char *** const result, char *line) { + int count = 0; + char *p, *p1; + + *result = NULL; + + debug(3, "Entering parse_bind_args%s\n", ""); + + /* count the dollar signs in the line = upper limit for number of arguments */ + for (p=line; '\0'!=*p; ++p) { + if ('$' == *p) { + ++count; + } + } + /* if there is none, we are done */ + if (! count) { + return 0; + } + + /* allocate result */ + if (NULL == (*result = calloc(count, sizeof(char **)))) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)sizeof(char **)); + return -1; + } + + /* reset count - now we will really count */ + count = 0; + + /* loop until end of the line */ + p = line; + while ('\0' != *p) { + /* expect "$ = " */ + if ('$' != *(p++)) { + fprintf(stderr, "Error: no dollar sign found in argument %d in line %lu\n", count, lineno); + free(*result); + *result = NULL; + return -1; + } + while (('0' <= *p) && ('9' >= *p)) { + ++p; + } + if ((' ' != p[0]) || ('=' != p[1]) || (' ' != p[2])) { + fprintf(stderr, "Error: bad format in argument %d in line %lu\n", count, lineno); + free(*result); + *result = NULL; + return -1; + } + p += 3; + + if ('\'' == *p) { + /* normal argument in single quotes */ + (*result)[count] = p1 = ++p; + + /* eliminate double single quotes and search for ending single quote */ + while (*p1) { + if ('\0' == *p) { + fprintf(stderr, "Error: unexpected end of line in argument %d in line %lu\n", count, lineno); + free(*result); + *result = NULL; + return -1; + } + if ('\'' == *p) { + /* single quote encountered */ + if ('\'' == p[1]) { + /* double single quote, skip one */ + *(p1++) = '\''; + ++p; + } else { + /* end of argument */ + *p1 = '\0'; + } + } else { + /* normal character */ + *(p1++) = *p; + } + ++p; + } + } else { + /* must me NULL argument */ + if (('N' == p[0]) && ('U' == p[1]) && ('L' == p[2]) && ('L' == p[3])) { + (*result)[count] = NULL; + p += 4; + } else { + fprintf(stderr, "Error: expected NULL in argument %d in line %lu\n", count, lineno); + free(*result); + *result = NULL; + return -1; + } + } + + /* skip ", " if present */ + if ((',' == p[0]) && (' ' == p[1])) { + p += 2; + } + + ++count; + } + + debug(2, "Parsed %d arguments\n", count); + debug(3, "Leaving parse_bind_args%s\n", ""); + + return count; +} + +static void print_parse_statistics() { + int hours, minutes; + double seconds; + struct timeval delta; + + fprintf(sf, "\nParse statistics\n"); + fprintf(sf, "================\n\n"); + fprintf(sf, "Log lines read: %lu\n", lineno); + fprintf(sf, "Total SQL statements processed: %lu\n", stat_simple + stat_param + stat_execnamed); + fprintf(sf, "Simple SQL statements processed: %lu\n", stat_simple); + if (stat_copy) { + fprintf(sf, "(includes %lu ignored copy statements)\n", stat_copy); + } + fprintf(sf, "Parametrized SQL statements processed: %lu\n", stat_param); + fprintf(sf, "Named prepared SQL statements executions processed: %lu\n", stat_execnamed); + if (stat_named) { + fprintf(sf, "Different named prepared SQL statements processed: %lu\n", stat_named); + fprintf(sf, "(average reuse count %.3f)\n", (double)(stat_execnamed - stat_named) / stat_named); + } + fprintf(sf, "Cancel requests processed: %lu\n", stat_cancel); + fprintf(sf, "Fast-path function calls ignored: %lu\n", stat_fastpath); + + /* calculate lengh of the recorded workload */ + timersub(&last_stmt_time, &first_stmt_time, &delta); + hours = delta.tv_sec / 3600; + delta.tv_sec -= hours * 3600; + minutes = delta.tv_sec / 60; + delta.tv_sec -= minutes * 60; + seconds = delta.tv_usec / 1000000.0 + delta.tv_sec; + + fprintf(sf, "Duration of recorded workload:"); + if (hours > 0) { + fprintf(sf, " %d hours", hours); + } + if (minutes > 0) { + fprintf(sf, " %d minutes", minutes); + } + fprintf(sf, " %.3f seconds\n", seconds); +} + +int parse_provider_init(const char *in, int parse_csv, const char *begin, const char *end, const char *db_only, const char *usr_only) { + static struct tm tm; /* initialize with zeros */ + int rc = 1; + + debug(3, "Entering parse_provider_init%s\n", ""); + + if (NULL == in) { + infile = 0; + } else { + if (-1 == (infile = open(in, O_RDONLY))) { + perror("Error opening input file"); + rc = 0; + } + } + + csv = parse_csv; + start_time = begin; + end_time = end; + database_only = db_only; + username_only = usr_only; + + /* initialize epoch with 2000-01-01 00:00:00 */ + tm.tm_year = 2000 - 1900; + tm.tm_mon = 1 - 1; + tm.tm_mday = 1; + tm.tm_hour = 0; + tm.tm_min = 0; + tm.tm_sec = 0; + tm.tm_isdst = 0; /* ignore daylight savings time */ + epoch = mktime(&tm); + + debug(3, "Leaving parse_provider_init%s\n", ""); + + return rc; +} + +void parse_provider_finish() { + debug(3, "Entering parse_provider_finish%s\n", ""); + + if (0 != infile) { + if (close(infile)) { + perror("Error closing input file:"); + } + } + + if (sf) { + print_parse_statistics(); + } + + debug(3, "Leaving parse_provider_finish%s\n", ""); +} + +/* the replay_item is malloc'ed and must be freed with replay_free() + will return NULL if an error occurred */ + +replay_item * parse_provider() { + replay_item *r = NULL; + char *message = NULL, *detail = NULL, *statement = NULL, *namep = NULL, name[NAMELEN + 1], **args, user[NAMELEN + 1], database[NAMELEN + 1], quote_name[NAMELEN + 3], search_path[POLARDBlEN], prepare_parse[POLARDBlEN]; + log_type logtype; + uint64_t session_id; + int count, i; + /* possible stati: -1 = error, 0 = looking for log line, 1 = interesting line found + 2 = using cached value, 3 = EOF */ + int status = 0; + replay_type type = -1; /* -1 is an impossible value */ + struct timeval time; + /* remember time from last parsed line */ + static struct timeval oldtime = { 0, 0 }; + struct connection *conn = NULL; + /* queue of up to two replay items */ + static replay_item *queue[2] = { NULL, NULL }; + static int first_stmt_time_set = 0; + + debug(3, "Entering parse_provider%s\n", ""); + + if (queue[0]) { + /* if there is something in the queue, return it */ + debug(2, "Queue is not empty, returning top element%s\n", ""); + r = queue[0]; + queue[0] = queue[1]; + queue[1] = NULL; + + status = 2; + } + + /* read a log entry until we find an interesting one */ + while (0 == status) { + int n = 0; + if(polardb_audit){ + n = parse_auditlog_entry_polardb11(&time, user, database, &session_id, &logtype, &message, &detail, search_path, prepare_parse); + // printf("search_path is %s \n",search_path); + // printf("prepare_parse is %s \n",prepare_parse); + }else{ + n = (*parse_log_entry[csv])(&time, user, database, &session_id, &logtype, &message, &detail); + } + + switch (n) { + case 0: + /* EOF encountered */ + status = 3; + break; + case 1: + memset(quote_name, '\0', NAMELEN + 3); + if ('\0' != *database) { + quote_name[0] = '\\'; + strcat(quote_name, database); + strcat(quote_name, "\\"); + } + if ((NULL != database_only) && (NULL == strstr(database_only, quote_name))) { + debug(2, "Database \"%s\" does not match filter, skipped log entry\n", database); + free(message); + if (! csv && detail) { + free(detail); + } + break; + } + memset(quote_name, '\0', NAMELEN + 3); + if ('\0' != *user) { + quote_name[0] = '\\'; + strcat(quote_name, user); + strcat(quote_name, "\\"); + } + if ((NULL != username_only) && (NULL == strstr(username_only, quote_name))) { + debug(2, "User \"%s\" does not match filter, skipped log entry\n", user); + free(message); + if (! csv && detail) { + free(detail); + } + break; + } + + /* check line prefix to determine type */ + if ((log_log == logtype) && (! strncmp(message, "connection authorized: ", 23))) { + debug(2, "Connection 0x" UINT64_FORMAT " found\n", session_id); + type = pg_connect; + statement = message + 23; + status = 1; + } else if ((log_log == logtype) && (! strncmp(message, "disconnection: ", 15))) { + debug(2, "Disconnection found%s\n", ""); + type = pg_disconnect; + statement = message + 15; + status = 1; + } else if ((log_log == logtype) && (! strncmp(message, "statement: ", 11))) { + debug(2, "Simple statement found%s\n", ""); + type = pg_execute; + statement = message + 11; + status = 1; + } else if ((log_log == logtype) && (! strncmp(message, "execute ", 8))) { + debug(2, "Prepared statement execution found%s\n", ""); + type = pg_exec_prepared; + namep = message + 8; + if ((statement = strchr(namep, ':'))) { + /* split in name and statement */ + *(statement++) = '\0'; + ++statement; + /* check for unnamed statement, change name to empty string */ + if (! strcmp(namep, "")) { + *namep = '\0'; + } + status = 1; + } else { + fprintf(stderr, "Error: missing statement name in line %lu\n", lineno); + status = -1; + } + } else if ((log_error == logtype) && (! strncmp(message, "canceling statement due to user request", 39))) { + debug(2, "Cancel request found%s\n", ""); + type = pg_cancel; + status = 1; + } else if ((log_log == logtype) && (! strncmp(message, "fastpath function call: ", 24))) { + free(message); + if (! csv && detail) { + free(detail); + } + fprintf(stderr, "Warning: fast-path function call ignored in line %lu\n", lineno); + + /* count for statistics */ + ++stat_fastpath; + } else { + free(message); + if (! csv && detail) { + free(detail); + } + debug(2, "Skipped log entry%s\n", ""); + } + break; + default: + /* something went wrong */ + status = -1; + } + } + + /* if everything is ok so far, search for a connection in our list + add one if there is none so far, store the "connect" replay_item in r */ + if (1 == status) { + /* we need a connection in any case */ + if ((conn = add_connection(&r, &time, user, database, session_id))) { + if (r && (pg_connect != type)) { + debug(2, "Automatically generated connection%s\n", ""); + } + if ((!r) && (pg_connect == type)) { + /* if the connection already existed and we read + a connect line, that is an error */ + fprintf(stderr, "Error: duplicate session ID 0x" UINT64_FORMAT "\n", session_id); + status = -1; + } + } else { + /* error occurred */ + status = -1; + } + } + + /* if everything is ok so far, process line according to type + result will be stored in queue[0] and queue[1] */ + if (1 == status) { + switch (type) { + case pg_connect: + /* we are status! */ + break; + case pg_disconnect: + if (NULL == (queue[0] = replay_create_disconnect(&time, session_id))) { + status = -1; + } + /* remove connection from hash structure */ + if (! remove_connection(session_id)) { + /* can't happen */ + fprintf(stderr, "Error: cannot remove connection " UINT64_FORMAT " from hash table\n", session_id); + status = -1; + } + break; + case pg_execute: + if (filter_bad_statements(statement, conn)) { + if (NULL == (queue[0] = replay_create_execute(&time, session_id, statement))) { + status = -1; + } + } else { + status = -1; + } + break; + case pg_exec_prepared: + /* we don't need to filter, since it can only be a single statement + and neither COPY nor SET can be prepared statements */ + + /* make a persistent copy of the statement name */ + strcpy(name, namep); + + /* see if this is a new statement */ + switch (add_pstmt(conn, name)) { + case 1: /* new */ + if (NULL == (queue[0] = replay_create_prepare(&time, session_id, name, statement))) { + status = -1; + } + /* the detail message is read later */ + break; + case 0: /* statement already exists */ + /* the detail message is read later */ + break; + default: /* error */ + status = -1; + } + break; + case pg_cancel: + if (NULL == (queue[0] = replay_create_cancel(&time, session_id))) { + status = -1; + } + + /* count for statistics */ + ++stat_cancel; + + break; + default: + /* can't happen */ + fprintf(stderr, "Error: impossible type parsing line %lu\n", lineno); + status = -1; + } + } + + /* read and process the DETAIL message for a prepared statement */ + if ((1 == status) && (pg_exec_prepared == type)) { + + if (! detail) { + /* no DETAIL message --> statement has no parameters */ + debug(2, "Prepared statement \"%s\" has no bind arguments\n", name); + if (NULL == (queue[1] = replay_create_exec_prepared(&time, session_id, name, 0, NULL))) { + status = -1; + } + } else if (strncmp(detail, "parameters: ", 12)) { + fprintf(stderr, "Error: no parameters for prepared statement at line %lu\n", lineno); + status = -1; + } else { + debug(2, "Reading bind arguments for prepared statement \"%s\"\n", name); + statement = detail + 12; + if (-1 == (count = parse_bind_args(&args, statement))) { + status = -1; + } else { + if (NULL == (queue[1] = replay_create_exec_prepared(&time, session_id, name, count, args))) { + status = -1; + } + free(args); + } + } + } + + if (! csv && detail) { + free(detail); + } + if (message) { + free(message); + } + + /* if EOF, close all connections that are still open */ + if (3 == status) { + /* search for entry in connection hash table */ + for (i=0; i<256; ++i) { + if (open_conn[i]) { + /* entry found, create disconnect item */ + debug(2, "End-of-file encountered, creating disconnect item for session 0x" UINT64_FORMAT "\n", open_conn[i]->session_id); + if (NULL == (r = replay_create_disconnect(&oldtime, open_conn[i]->session_id))) { + status = -1; + } + remove_connection(open_conn[i]->session_id); + break; + } + } + + if ((! r) && (3 == status)) { + debug(2, "End-of-file encountered, signal end%s\n", ""); + r = end_item; + } + } + + if (1 == status) { + /* condense queue */ + if (! queue[0]) { + queue[0] = queue[1]; + queue[1] = NULL; + } + if (! r) { + r = queue[0]; + queue[0] = queue[1]; + queue[1] = NULL; + } + if (! queue[0]) { + queue[0] = queue[1]; + queue[1] = NULL; + } + + /* remember time */ + oldtime.tv_sec = replay_get_time(r)->tv_sec; + oldtime.tv_usec = replay_get_time(r)->tv_usec; + + last_stmt_time.tv_sec = replay_get_time(r)->tv_sec; + last_stmt_time.tv_usec = replay_get_time(r)->tv_usec; + if (! first_stmt_time_set) { + first_stmt_time.tv_sec = replay_get_time(r)->tv_sec; + first_stmt_time.tv_usec = replay_get_time(r)->tv_usec; + + first_stmt_time_set = 1; + } + } + + if (-1 == status) { + /* free items in queue */ + if (r) { + replay_free(r); + r = NULL; + } + if (queue[0]) { + replay_free(queue[0]); + queue[0] = NULL; + } + if (queue[1]) { + replay_free(queue[1]); + queue[1] = NULL; + } + } + + if (r && (1 <= debug_level) && (end_item != r)) { + replay_print_debug(r); + } + + if(polardb_audit){ + r->search_path = (char*)malloc(sizeof(search_path)); + strcpy(r->search_path,search_path); + r->prepare_parse = (char*)malloc(sizeof(prepare_parse)); + strcpy(r->prepare_parse,prepare_parse); + } + + debug(3, "Leaving parse_provider%s\n", ""); + return r; +} \ No newline at end of file diff --git a/pgreplay/pgreplay.1 b/pgreplay/pgreplay.1 new file mode 100644 index 00000000000..af155e90b29 --- /dev/null +++ b/pgreplay/pgreplay.1 @@ -0,0 +1,203 @@ +.TH pgreplay 1 "" "Jun 2011" "PostgreSQL Utilities" +.SH NAME +pgreplay \- PostgreSQL log file replayer for performance tests +.SH SYNOPSIS +\fBpgreplay\fP [\fIparse options\fR] [\fIreplay options\fR] +[\fB-d\fR \fIlevel\fR] [\fIinfile\fR] +.br +\fBpgreplay\fP \fB-f\fP [\fIparse options\fR] [\fB-o\fP \fIoutfile\fR] +[\fB-d\fR \fIlevel\fR] [\fIinfile\fR] +.br +\fBpgreplay\fP \fB-r\fP [\fIreplay options\fR] [\fB-d\fR \fIlevel\fR] +[\fIinfile\fR] +.SH DESCRIPTION +\fBpgreplay\fR reads a PostgreSQL log file (\fInot\fR a WAL file), extracts +the SQL statements and executes them in the same order and relative time +against a PostgreSQL database cluster. +A final report gives you a useful statistical analysis of your workload +and its execution. +.P +In the first form, the log file \fIinfile\fR is replayed at the time it is +read. +.P +With the \fB-f\fR option, \fBpgreplay\fR will not execute the statements, but +write them to a \(oqreplay file\(cq \fIoutfile\fR that can be replayed with +the third form. +.P +With the \fB-r\fP option, \fBpgreplay\fR will execute the statements in the +replay file \fIinfile\fR that was created by the second form. +.P +If the execution of statements gets behind schedule, warning messages +are issued that indicate that the server cannot handle the load in a +timely fashion. +The idea is to replay a real-world database workload as exactly as possible. +.P +To create a log file that can be parsed by \fBpgreplay\fR, you need to set the +following parameters in \fBpostgresql.conf\fR: +.IP +\fBlog_min_messages=error\fR (or more) +.br +\fBlog_min_error_statement=log\fR (or more) +.br +\fBlog_connections=on\fR +.br +\fBlog_disconnections=on\fR +.br +\fBlog_line_prefix=\(aq%m|%u|%d|%c|\(aq\fR (if you don\(aqt use CSV logging) +.br +\fBlog_statement=\(aqall\(aq\fR +.br +\fBlc_messages\fR must be set to English (encoding does not matter) +.br +\fBbytea_output=escape\fR +(from version 9.0 on, only if you want to replay the log on 8.4 or earlier) +.P +The database cluster against which you replay the SQL statements must be +a clone of the database cluster that generated the logs from the time +\fIimmediately before\fR the logs were generated. +.P +\fBpgreplay\fR is useful for performance tests, particularly in the following +situations: +.TP 4 +* +You want to compare the performance of your PostgreSQL application +on different hardware or different operating systems. +.TP 4 +* +You want to upgrade your database and want to make sure that the new +database version does not suffer from performance regressions that +affect you. +.P +Moreover, \fBpgreplay\fR can give you some feeling as to how your application +\fImight\fR scale by allowing you to try to replay the workload at a higher +speed. Be warned, though, that 500 users working at double speed is not really +the same as 1000 users working at normal speed. +.SH OPTIONS +.SS Parse options: +.TP +\fB-c\fR +Specifies that the log file is in \(aqcsvlog\(aq format (highly recommended) +and not in \(aqstderr\(aq format. +.TP +\fB-b\fR \fItimestamp\fR +Only log entries greater or equal to that timestamp will be parsed. +The format is \fBYYYY-MM-DD HH:MM:SS.FFF\fR like in the log file. +An optional time zone part will be ignored. +.TP +\fB-e\fR \fItimestamp\fR +Only log entries less or equal to that timestamp will be parsed. +The format is \fBYYYY-MM-DD HH:MM:SS.FFF\fR like in the log file. +An optional time zone part will be ignored. +.TP +\fB-q\fR +Specifies that a backslash in a simple string literal will escape +the following single quote. +This depends on configuration options like +\fBstandard_conforming_strings\fR and is the default for server +version 9.0 and less. +.TP +\fB-D\fR \fIdatabase\fR +Only log entries related to the specified database will be parsed +(this option can be specified multiple times for more than one database). +.TP +\fB-U\fR \fIusername\fR +Only log entries related to the specified username will be parsed +(this option can be specified multiple times for more than one user). +.SS Replay options: +.TP +\fB-h\fR \fIhostname\fR +Host name where the target database cluster is running (or directory where +the UNIX socket can be found). Defaults to local connections. +.br +This works just like the \fB-h\fR option of \fBpsql\fR. +.TP +\fB-p\fR \fIport\fR +TCP port where the target database cluster can be reached. +.TP +\fB-W\fR \fIpassword\fR +By default, \fBpgreplay\fR assumes that the target database cluster +is configured for \fItrust\fR authentication. With the \fB-W\fR option +you can specify a password that will be used for all users in the cluster. +.TP +\fB-s\fR \fIfactor\fR +Speed factor for replay, by default 1. This can be any valid positive +floating point number. A \fIfactor\fR less than 1 will replay the workload +in \(oqslow motion\(cq, while a \fIfactor\fR greater than 1 means +\(oqfast forward\(cq. +.TP +\fB-E\fR \fIencoding\fR +Specifies the encoding of the log file, which will be used as client +encoding during replay. If it is omitted, your default client encoding will +be used. +.TP +\fB-j\fR +If all connections are idle, jump ahead to the next request instead of +sleeping. This will speed up replay. Execution delays will still be reported +correctly, but replay statistics will not contain the idle time. +.TP +\fB-n\fR +Dry run mode. No connections to the server are made. +Useful for checking if the replay file is corrupt or to get statistics +about the replay file (number of statements, original duration, ...) +.TP +\fB-X\fR \fIoptions\fR +Extra connection options for replay connections. These must be libpq +connection options specified in the format \(oqoption=value [...]\(cq. +.SS Output options: +.TP +\fB-o\fP \fIoutfile\fR +specifies the replay file where the statements will be written +for later replay. +.SS Debug options: +.TP +\fB-d\fR \fIlevel\fR +Specifies the trace level (between 1 and 3). Increasing levels will produce +more detailed information about what \fBpgreplay\fR is doing. +.TP +\fB-v\fR +Prints the program version and exits. +.SH ENVIRONMENT +.TP +\fBPGHOST\fR +Specifies the default value for the \fB-h\fR option. +.TP +\fBPGPORT\fR +Specifies the default value for the \fB-p\fR option. +.TP +\fBPGCLIENTENCODING\fR +Specifies the default value for the \fB-E\fR option. +.SH LIMITATIONS +\fBpgreplay\fR can only replay what is logged by PostgreSQL. +This leads to some limitations: +.TP 4 +* +\fBCOPY\fR statements will not be replayed, because the copy data are not +logged. +.TP 4 +* +Fast-path API function calls are not logged and will not be replayed. +Unfortunately, this includes the Large Object API. +.TP 4 +* +Since the log file is always in the server encoding (which you can specify +with the \fB-E\fR switch of \fBpgreplay\fR), all +\fBSET client_encoding\fR statements will be ignored. +.TP 4 +* +Since the preparation time of prepared statements is not logged (unless +\fBlog_min_messages\fR is \fBdebug2\fR or more), these statements will be +prepared immediately before they are first executed during replay. +.TP 4 +* +Because the log file contains only text, query parameters and return values +will always be in text and never in binary format. If you use binary mode to, +say, transfer large binary data, \fBpgreplay\fR can cause significantly more +network traffic than the original run. +.TP 4 +* +Sometimes, if a connection takes longer to complete, the session ID +unexpectedly changes in the PostgreSQL log file. This causes \fBpgreplay\fR +to treat the session as two different ones, resulting in an additional +connection. This is arguably a bug in PostgreSQL. +.SH AUTHOR +Written by Laurenz Albe \fB\fR. diff --git a/pgreplay/pgreplay.h b/pgreplay/pgreplay.h new file mode 100644 index 00000000000..4db63df4118 --- /dev/null +++ b/pgreplay/pgreplay.h @@ -0,0 +1,186 @@ +#ifndef _PGREPLAY_H +#define _PGREPLAY_H 1 + +#include "config.h" + +/* safeguard against broken config.h */ +#ifndef SIZEOF_UNSIGNED_INT +# error SIZEOF_UNSIGNED_INT not defined in config.h. Please execute 'configure' first! +#endif + +#if defined(WIN32) || defined(WIN64) +# ifndef WINDOWS +# define WINDOWS +# endif +#endif + +#include +#include +#include + +/* maximum length of a name in PostgreSQL */ +#define NAMELEN 64 +#define POLARDBlEN 256 +/* types for replay items */ +typedef enum { + pg_connect = 0, + pg_disconnect, + pg_execute, + pg_prepare, + pg_exec_prepared, + pg_cancel +} replay_type; + +struct replay_item { + struct timeval time; + uint64_t session_id; + replay_type type; + uint16_t count; + char **data; + char *search_path; + char *prepare_parse; +}; + +/* one "command" parsed from a log file to be replayed + the definition is in replay_item.c */ +typedef struct replay_item replay_item; + +typedef int (replay_item_provider_init)(const char *, int, const char *, const char *, const char *, const char *); +typedef replay_item *(replay_item_provider)(); +typedef void (replay_item_provider_finish)(); + +typedef int (replay_item_consumer_init)(const char *, const char *, int, const char *, double); +typedef int (replay_item_consumer)(replay_item *); +typedef void (replay_item_consumer_finish)(int); + +/* hash value for session ID is computed as low byte of background PID */ +#define hash_session(x) (unsigned char)(x & 0xFF); + +/* printf/scanf formats for various data types */ +#if SIZEOF_UNSIGNED_INT == 4 +# define UINT32_FORMAT "%x" +#else +# define UINT32_FORMAT "%hx" +#endif + +#ifdef HAVE_INTTYPES_H +# include +# define UINT64_FORMAT "%" PRIx64 +#else +/* fall back to guessing */ +# ifdef WINDOWS +# define UINT64_FORMAT "%I64x" +# else +# if SIZEOF_UNSIGNED_LONG == 8 +# define UINT64_FORMAT "%lx" +# else +# define UINT64_FORMAT "%llx" +# endif +# endif +#endif + +/*********************/ +/* defined in main.c */ +/*********************/ + +extern int debug_level; + +/* destination of statistics output */ +extern FILE *sf; + +/* if 1, backslash will escape the following single quote in string literal */ +extern int backslash_quote; + +/* if 1, replay will skip idle intervals instead of sleeping */ +extern int jump_enabled; + +/* extra connect options specified with the -X option */ +extern char *extra_connstr; + +/* print debug messages */ +#define debug(level, format, ...) { \ + if (level <= debug_level) { \ + fprintf (stderr, format, __VA_ARGS__); \ + fflush(stderr); \ + } \ +} + +/***************************/ +/* defined in replayitem.c */ +/***************************/ + +/* functions to create replay items */ +extern replay_item *replay_create_connect(const struct timeval *time, uint64_t session_id, const char *user, const char *database); +extern replay_item *replay_create_disconnect(const struct timeval *time, uint64_t session_id); +extern replay_item *replay_create_execute(const struct timeval *time, uint64_t session_id, const char *statement); +extern replay_item *replay_create_prepare(const struct timeval *time, uint64_t session_id, const char *statement, const char *name); +extern replay_item *replay_create_exec_prepared(const struct timeval *time, uint64_t session_id, const char *name, uint16_t count, char * const *values); +extern replay_item *replay_create_cancel(const struct timeval *time, uint64_t session_id); + +/* free mamory of a replay_item */ +extern void replay_free(replay_item *r); + +/* get attributes of a replay item */ +extern replay_type replay_get_type(const replay_item *r); +extern uint64_t replay_get_session_id(const replay_item *r); +extern const struct timeval * replay_get_time(const replay_item *r); +extern const char * replay_get_statement(const replay_item *r); +extern const char * replay_get_name(const replay_item *r); +extern const char * replay_get_user(const replay_item *r); +extern const char * replay_get_database(const replay_item *r); +extern int replay_get_valuecount(const replay_item *r); +extern const char * const * replay_get_values(const replay_item *r); + +/* dump a replay item at debug level 3 */ +extern void replay_print_debug(const replay_item *r); + +/* special replay_item that signals end-of-file */ +extern replay_item * const end_item; + +/**********************/ +/* defined in parse.c */ +/**********************/ + +/* parse a timestamp (excluding time zone) */ +extern const char * parse_time(const char *, struct timeval *); + +extern replay_item_provider parse_provider; +extern replay_item_provider_init parse_provider_init; +extern replay_item_provider_finish parse_provider_finish; + +/***************************/ +/* defined in replayfile.c */ +/***************************/ + +extern replay_item_provider file_provider; +extern replay_item_provider_init file_provider_init; +extern replay_item_provider_finish file_provider_finish; + +extern replay_item_consumer file_consumer; +extern replay_item_consumer_init file_consumer_init; +extern replay_item_consumer_finish file_consumer_finish; + +/*************************/ +/* defined in database.c */ +/*************************/ + +extern replay_item_consumer database_consumer; +extern replay_item_consumer database_consumer_dry_run; +extern replay_item_consumer_init database_consumer_init; +extern replay_item_consumer_finish database_consumer_finish; + +#ifdef WINDOWS +/************************/ +/* defined in windows.c */ +/************************/ + +extern void win_perror(const char *prefix, int is_network_error); +#endif + +#endif + +#define MONITOR_RES_LEN 32 +extern int polardb_audit; +extern int monitor_connect_init(const char *host, int port, const char *passwd); +extern int monitor_connect_execute(const char* sql); +extern int monitor_connect_finish(); \ No newline at end of file diff --git a/pgreplay/pgreplay.html b/pgreplay/pgreplay.html new file mode 100644 index 00000000000..73c1cfd42db --- /dev/null +++ b/pgreplay/pgreplay.html @@ -0,0 +1,486 @@ + + + + + + + + + +pgreplay + + + + +

pgreplay

+ +NAME
+SYNOPSIS
+DESCRIPTION
+OPTIONS
+ENVIRONMENT
+LIMITATIONS
+AUTHOR
+ +
+ + +

NAME + +

+ + +

pgreplay +− PostgreSQL log file replayer for performance +tests

+ +

SYNOPSIS + +

+ + + +

pgreplay +[parse options] [replay options] [-d +level] [infile]
+pgreplay -f
[parse options] [-o +outfile] [-d level] [infile] +
+pgreplay -r
[replay options] [-d +level] [infile]

+ +

DESCRIPTION + +

+ + + +

pgreplay +reads a PostgreSQL log file (not a WAL file), +extracts the SQL statements and executes them in the same +order and relative time against a PostgreSQL database +cluster. A final report gives you a useful statistical +analysis of your workload and its execution.

+ +

In the first +form, the log file infile is replayed at the time it +is read.

+ +

With the +-f option, pgreplay will not execute the +statements, but write them to a ‘replay file’ +outfile that can be replayed with the third form.

+ +

With the +-r option, pgreplay will execute the +statements in the replay file infile that was created +by the second form.

+ +

If the +execution of statements gets behind schedule, warning +messages are issued that indicate that the server cannot +handle the load in a timely fashion. The idea is to replay a +real-world database workload as exactly as possible.

+ +

To create a log +file that can be parsed by pgreplay, you need to set +the following parameters in postgresql.conf:

+ + +

log_min_messages=error +(or more)
+log_min_error_statement=log
(or more)
+log_connections=on
+log_disconnections=on
+log_line_prefix='%m|%u|%d|%c|'
(if you don't use CSV +logging)
+log_statement='all'
+lc_messages
must be set to English (encoding does not +matter)
+bytea_output=escape
(from version 9.0 on, only if you +want to replay the log on 8.4 or earlier)

+ +

The database +cluster against which you replay the SQL statements must be +a clone of the database cluster that generated the logs from +the time immediately before the logs were +generated.

+ + +

pgreplay +is useful for performance tests, particularly in the +following situations:

+ + + + + + + + + + + + +
+ + +

*

+ + +

You want to compare the performance of your PostgreSQL +application on different hardware or different operating +systems.

+ + +

*

+ + +

You want to upgrade your database and want to make sure +that the new database version does not suffer from +performance regressions that affect you.

+ +

Moreover, +pgreplay can give you some feeling as to how your +application might scale by allowing you to try to +replay the workload at a higher speed. Be warned, though, +that 500 users working at double speed is not really the +same as 1000 users working at normal speed.

+ +

OPTIONS + +

+ + +

Parse +options:

+ + + + + + + +
+ + +

-c

+ + +

Specifies that the log file is +in 'csvlog' format (highly recommended) and not in 'stderr' +format.

+ +

-b timestamp

+ +

Only log entries greater or +equal to that timestamp will be parsed. The format is +YYYY-MM-DD HH:MM:SS.FFF like in the log file. An +optional time zone part will be ignored.

+ +

-e timestamp

+ +

Only log entries less or equal +to that timestamp will be parsed. The format is +YYYY-MM-DD HH:MM:SS.FFF like in the log file. An +optional time zone part will be ignored.

+ + + + + + + +
+ + +

-q

+ + +

Specifies that a backslash in a simple string literal +will escape the following single quote. This depends on +configuration options like +standard_conforming_strings and is the default for +server version 9.0 and less.

+ +

-D database

+ +

Only log entries related to the +specified database will be parsed (this option can be +specified multiple times for more than one database).

+ +

-U username

+ +

Only log entries related to the +specified username will be parsed (this option can be +specified multiple times for more than one user).

+ +

Replay +options:
+-h
hostname

+ +

Host name where the target +database cluster is running (or directory where the UNIX +socket can be found). Defaults to local connections.
+This works just like the -h option of +psql.

+ +

-p port

+ +

TCP port where the target +database cluster can be reached.

+ +

-W password

+ +

By default, pgreplay +assumes that the target database cluster is configured for +trust authentication. With the -W option you +can specify a password that will be used for all users in +the cluster.

+ +

-s factor

+ +

Speed factor for replay, by +default 1. This can be any valid positive floating point +number. A factor less than 1 will replay the workload +in ‘slow motion’, while a factor greater +than 1 means ‘fast forward’.

+ +

-E encoding

+ +

Specifies the encoding of the +log file, which will be used as client encoding during +replay. If it is omitted, your default client encoding will +be used.

+ + + + + + + + + + + + +
+ + +

-j

+ + +

If all connections are idle, jump ahead to the next +request instead of sleeping. This will speed up replay. +Execution delays will still be reported correctly, but +replay statistics will not contain the idle time.

+ + +

-n

+ + +

Dry run mode. No connections to the server are made. +Useful for checking if the replay file is corrupt or to get +statistics about the replay file (number of statements, +original duration, ...)

+ +

-X options

+ +

Extra connection options for +replay connections. These must be libpq connection options +specified in the format ‘option=value +[...]’.

+ +

Output +options:
+-o
outfile

+ +

specifies the replay file where +the statements will be written for later replay.

+ +

Debug +options:
+-d
level

+ +

Specifies the trace level +(between 1 and 3). Increasing levels will produce more +detailed information about what pgreplay is +doing.

+ + + + + + + + +
+ + +

-v

+ + +

Prints the program version and exits.

+
+ +

ENVIRONMENT + +

+ + + + + + + + + + + + + + + +
+ + +

PGHOST

+ + +

Specifies the default value for +the -h option.

+
+ + +

PGPORT

+ + +

Specifies the default value for the -p +option.

+
+ +

PGCLIENTENCODING

+ +

Specifies the default value for +the -E option.

+ +

LIMITATIONS + +

+ + + +

pgreplay +can only replay what is logged by PostgreSQL. This leads to +some limitations:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + +

*

+ + +

COPY statements will not be replayed, because the +copy data are not logged.

+ + +

*

+ + +

Fast-path API function calls are not logged and will not +be replayed. Unfortunately, this includes the Large Object +API.

+ + +

*

+ + +

Since the log file is always in the server encoding +(which you can specify with the -E switch of +pgreplay), all SET client_encoding statements +will be ignored.

+ + +

*

+ + +

Since the preparation time of prepared statements is not +logged (unless log_min_messages is debug2 or +more), these statements will be prepared immediately before +they are first executed during replay.

+ + +

*

+ + +

Because the log file contains only text, query +parameters and return values will always be in text and +never in binary format. If you use binary mode to, say, +transfer large binary data, pgreplay can cause +significantly more network traffic than the original +run.

+ + +

*

+ + +

Sometimes, if a connection takes longer to complete, the +session ID unexpectedly changes in the PostgreSQL log file. +This causes pgreplay to treat the session as two +different ones, resulting in an additional connection. This +is arguably a bug in PostgreSQL.

+ +

AUTHOR + +

+ + +

Written by +Laurenz Albe <laurenz.albe@cybertec.at>.

+
+ + diff --git a/pgreplay/replayfile.c b/pgreplay/replayfile.c new file mode 100644 index 00000000000..f74fb809119 --- /dev/null +++ b/pgreplay/replayfile.c @@ -0,0 +1,437 @@ +#include "pgreplay.h" + +#include +#include +#include +#include +#include +#include +#ifdef WINDOWS +# include +# include +# define FILE_MODE S_IRUSR | S_IWUSR +#else +# ifdef HAVE_NETINET_IN_H +# include +# endif +# define FILE_MODE S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH +#endif +#include +#include +#include + +/* input or output file */ +static int filed=0; + +/* functions to convert 64-bit integers between host and network byte order */ +#ifndef htonll +# ifdef WORDS_BIGENDIAN +# define htonll(x) (x) +# define ntohll(x) (x) +# else +# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32)) +# define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32)) +# endif +#endif + +/* this length indicates a null value */ +#define NULL_VALUE 0x80000000 + +/* wrapper functions for read and write */ +static int do_write(const void * const buf, size_t count) { + int rc = write(filed, buf, count); + + if (-1 == rc) { + perror("Error writing to output file"); + return 0; + } else if (count != rc) { + fprintf(stderr, "Error: not all bytes written to output file\n"); + return 0; + } + + return 1; +} + +static int do_read(void *buf, size_t count, int *eof_indicator) { + int rc = read(filed, buf, count); + + if (eof_indicator) { + *eof_indicator = 0; + } + + if (-1 == rc) { + perror("Error reading from input file"); + return 0; + } else if (eof_indicator && (0 == rc)) { + *eof_indicator = 1; + } else if (count != rc) { + fprintf(stderr, "Error: unexpected end of file on input file\n"); + return 0; + } + + return 1; +} + +/* write a string to the output file */ +static int write_string(char const * const s) { + uint32_t u32, len; + + /* write length + NULL indicator (4 byte) */ + if (NULL == s) { + len = NULL_VALUE; + } else { + len = strlen(s); + } + u32 = htonl(len); + if (! do_write(&u32, 4)) { + return 0; + } else if (NULL != s) { + /* write string */ + if (! do_write(s, len)) { + return 0; + } + } + + return 1; +} + +/* malloc and read a string from the input file */ +static int read_string(char ** const s) { + uint32_t u32, len; + + /* read length (4 byte) */ + if (! do_read(&u32, 4, NULL)) { + return 0; + } + len = ntohl(u32); + if (NULL_VALUE == len) { + *s = NULL; + } else { + /* allocate the string */ + if (! (*s = malloc(len + 1))) { + fprintf(stderr, "Cannot allocate %d bytes of memory\n", len + 1); + return 0; + } else { + /* read string */ + if (! do_read(*s, len, NULL)) { + return 0; + } + (*s)[len] = '\0'; + } + } + + return 1; +} + +int file_provider_init(const char *infile, int cvs, const char *begin_time, const char *end_time, const char *db_only, const char *usr_only) { + int rc = 1; + debug(3, "Entering file_provider_init%s\n", ""); + + if (NULL == infile) { + filed = 0; +#ifdef WINDOWS + setmode(filed, O_BINARY); +#endif + } else { + if (-1 == (filed = open(infile, O_RDONLY +#ifdef WINDOWS + | O_BINARY +#endif + ))) { + perror("Error opening input file:"); + rc = 0; + } + } + + debug(3, "Leaving file_provider_init%s\n", ""); + + return rc; +} + +void file_provider_finish() { + debug(3, "Entering file_provider_finish%s\n", ""); + + if (0 != filed) { + if (close(filed)) { + perror("Error closing input file:"); + } + } + + debug(3, "Leaving file_provider_finish%s\n", ""); +} + +replay_item * file_provider() { + replay_item *r = NULL; + uint16_t u16; + uint32_t u32; + uint64_t u64, session_id = 0; + struct timeval tv; + replay_type type = -1; + int ok = 1, i = 0, eof; + unsigned long count; + char *user, *database, *statement, *name, **values, nl; + + debug(3, "Entering file_provider%s\n", ""); + + /* read timestamp (8 byte) */ + if (! do_read(&u32, 4, &eof)) { + ok = 0; + } else { + /* handle expected end-of-file condition */ + if (eof) { + return end_item; + } + + tv.tv_sec = ntohl(u32); + if (! do_read(&u32, 4, NULL)) { + ok = 0; + } else { + tv.tv_usec = ntohl(u32); + } + } + + /* read session_id (8 byte) */ + if (ok && do_read(&u64, 8, NULL)) { + session_id = ntohll(u64); + } else { + ok = 0; + } + + /* read type (1 byte) */ + if (ok) { + u16 = 0; + if (! do_read((char *)(&u16) + 1, 1, NULL)) { + ok = 0; + } else { + type = ntohs(u16); + if ((type < pg_connect) || (type > pg_cancel)) { + fprintf(stderr, "Error: unknown type %u encountered\n", type); + ok = 0; + } + } + } + + /* read type specific stuff */ + if (ok) { + switch (type) { + case pg_connect: + if (read_string(&user)) { + if (read_string(&database)) { + r = replay_create_connect(&tv, session_id, user, database); + free(database); + } + free(user); + } + break; + case pg_disconnect: + r = replay_create_disconnect(&tv, session_id); + break; + case pg_execute: + if (read_string(&statement)) { + r = replay_create_execute(&tv, session_id, statement); + free(statement); + } + break; + case pg_prepare: + if (read_string(&statement)) { + if (read_string(&name)) { + r = replay_create_prepare(&tv, session_id, name, statement); + free(name); + } + free(statement); + } + break; + case pg_exec_prepared: + /* read statement name */ + if (read_string(&name)) { + /* number of bind arguments (2 byte) */ + if (do_read(&u16, 2, NULL)) { + count = ntohs(u16); + if (NULL == (values = calloc(count, sizeof(char *)))) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", count * sizeof(char *)); + } else { + /* read bind values */ + while (i < count) { + if (read_string(values + i)) { + ++i; + } else { + break; + } + } + if (i == count) { + r = replay_create_exec_prepared(&tv, session_id, name, count, values); + } + while (--i >= 0) { + if (values[i]) { + free(values[i]); + } + } + free(values); + } + } + free(name); + } + break; + case pg_cancel: + r = replay_create_cancel(&tv, session_id); + break; + } + } + + /* read new-line at the end of the record */ + if (r && do_read(&nl, 1, NULL) && ('\n' != nl)) { + fprintf(stderr, "Error: missing new-line at end of line\n"); + if (r) { + replay_free(r); + r = NULL; + } + } + + if (r && (1 <= debug_level) && (end_item != r)) { + replay_print_debug(r); + } + + debug(3, "Leaving file_provider%s\n", ""); + + return r; +} + +int file_consumer_init(const char *outfile, const char *host, int port, const char *passwd, double factor) { + debug(3, "Entering file_consumer_init%s\n", ""); + + if ((NULL == outfile) || ('\0' == outfile[0]) + || (('-' == outfile[0]) && ('\0' == outfile[1]))) { + filed = 1; +#ifdef WINDOWS + /* set stdout to binary mode */ + setmode(filed, O_BINARY); +#endif + } else { + if (-1 == (filed = open(outfile, O_WRONLY | O_CREAT | O_TRUNC +#ifdef WINDOWS + | O_BINARY +#endif + , FILE_MODE))) { + perror("Error opening output file:"); + return 0; + } + } + + debug(3, "Leaving file_consumer_init%s\n", ""); + return 1; +} + +void file_consumer_finish(int dry_run) { + debug(3, "Entering file_consumer_finish%s\n", ""); + + if (1 != filed) { + if (close(filed)) { + perror("Error closing output file:"); + } + } + + debug(3, "Leaving file_consumer_finish%s\n", ""); +} + +int file_consumer(replay_item *item) { + const struct timeval *tv = replay_get_time(item); + uint16_t count; + const replay_type type = replay_get_type(item); + uint16_t u16, i; + uint32_t u32; + uint64_t u64; + int rc = 1; + const char * const *values; + + debug(3, "Entering file_consumer%s\n", ""); + + /* write timestamp (8 byte) */ + u32 = htonl(tv->tv_sec); + if (! do_write(&u32, 4)) { + rc = -1; + } else { + u32 = htonl(tv->tv_usec); + if (! do_write(&u32, 4)) { + rc = -1; + } + } + + /* write session_id (8 byte) */ + if (1 == rc) { + u64 = htonll(replay_get_session_id(item)); + if (! do_write(&u64, 8)) { + rc = -1; + } + } + + /* write type (1 byte) */ + if (1 == rc) { + u16 = htons((uint16_t) type); + if (! do_write((char *)(&u16) + 1, 1)) { + rc = -1; + } + } + + /* write type specific stuff */ + if (1 == rc) { + switch (type) { + case pg_connect: + if (! write_string(replay_get_user(item))) { + rc = -1; + } else if (! write_string(replay_get_database(item))) { + rc = -1; + } + break; + case pg_disconnect: + break; + case pg_execute: + if (! write_string(replay_get_statement(item))) { + rc = -1; + } + break; + case pg_prepare: + if (! write_string(replay_get_statement(item))) { + rc = -1; + } else if (! write_string(replay_get_name(item))) { + rc = -1; + } + break; + case pg_exec_prepared: + count = replay_get_valuecount(item); + /* write statement name */ + if (! write_string(replay_get_name(item))) { + rc = -1; + } else { + /* write count (2 byte) */ + u16 = htons(count); + if (! do_write(&u16, 2)) { + rc = -1; + } else { + /* write values */ + values = replay_get_values(item); + for (i=0; i +#include +#include +#include +#include + +/* special replay_item that signals end-of-file */ +static replay_item end_replay_item = {{0, 0}, 0, -1, 0, NULL}; +replay_item * const end_item = &end_replay_item; + +/* create common part of a replay_item */ +static replay_item *replay_create(const struct timeval *time, uint64_t session_id, replay_type type, uint16_t count) { + replay_item *r; + + r = malloc(sizeof(struct replay_item)); + if (NULL == r) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)sizeof(struct replay_item)); + return NULL; + } + r->time.tv_sec = time->tv_sec; + r->time.tv_usec = time->tv_usec; + r->session_id = session_id; + r->type = type; + r->count = count; + if (0 == count) { + r->data = NULL; + } else { + r->data = calloc(count, sizeof(char *)); + if (NULL == r->data) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)count * sizeof(char *)); + free(r); + return NULL; + } + } + + return r; +} + +replay_item *replay_create_connect(const struct timeval *time, uint64_t session_id, const char *user, const char *database) { + replay_item *r; + + debug(3, "Entering replay_create_connect%s\n", ""); + + r = replay_create(time, session_id, pg_connect, 2); + if (NULL == r) { + return NULL; + } + + (r->data)[0] = malloc(strlen(user) + 1); + if (NULL == (r->data)[0]) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(user) + 1); + free(r->data); + free(r); + return NULL; + } + strcpy((r->data)[0], user); + + (r->data)[1] = malloc(strlen(database) + 1); + if (NULL == (r->data)[1]) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(user) + 1); + free((r->data)[0]); + free(r->data); + free(r); + return NULL; + } + strcpy((r->data)[1], database); + + debug(3, "Leaving replay_create_connect%s\n", ""); + return r; +} + +replay_item *replay_create_disconnect(const struct timeval *time, uint64_t session_id) { + replay_item *r; + + debug(3, "Entering replay_create_disconnect%s\n", ""); + + r = replay_create(time, session_id, pg_disconnect, 0); + if (NULL == r) { + return NULL; + } + debug(3, "Leaving replay_create_disconnect%s\n", ""); + return r; +} + +replay_item *replay_create_execute(const struct timeval *time, uint64_t session_id, const char *statement) { + replay_item *r; + + debug(3, "Entering replay_create_execute%s\n", ""); + + r = replay_create(time, session_id, pg_execute, 1); + if (NULL == r) { + return NULL; + } + + (r->data)[0] = malloc(strlen(statement) + 1); + if (NULL == (r->data)[0]) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(statement) + 1); + free(r->data); + free(r); + return NULL; + } + strcpy((r->data)[0], statement); + + debug(3, "Leaving replay_create_execute%s\n", ""); + return r; +} + +replay_item *replay_create_prepare(const struct timeval *time, uint64_t session_id, const char *name, const char *statement) { + replay_item *r; + + debug(3, "Entering replay_create_prepare%s\n", ""); + + r = replay_create(time, session_id, pg_prepare, 2); + if (NULL == r) { + return NULL; + } + + (r->data)[0] = malloc(strlen(statement) + 1); + if (NULL == (r->data)[0]) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(statement) + 1); + free(r->data); + free(r); + return NULL; + } + strcpy((r->data)[0], statement); + + (r->data)[1] = malloc(strlen(name) + 1); + if (NULL == (r->data)[1]) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(name) + 1); + free((r->data)[0]); + free(r->data); + free(r); + return NULL; + } + strcpy((r->data)[1], name); + + debug(3, "Leaving replay_create_prepare%s\n", ""); + return r; +} + +replay_item *replay_create_exec_prepared(const struct timeval *time, uint64_t session_id, const char*name, uint16_t count, char * const *values) { + replay_item *r; + int i; + + debug(3, "Entering replay_create_exec_prepared%s\n", ""); + + r = replay_create(time, session_id, pg_exec_prepared, count + 1); + if (NULL == r) { + return NULL; + } + + (r->data)[0] = malloc(strlen(name) + 1); + if (NULL == (r->data)[0]) { + free(r->data); + free(r); + return NULL; + } + strcpy((r->data)[0], name); + + for (i=1; idata)[i] = malloc(strlen(values[i-1]) + 1); + if (NULL == (r->data)[i]) { + fprintf(stderr, "Cannot allocate %lu bytes of memory\n", (unsigned long)strlen(values[i-1]) + 1); + for (--i; i>=0; --i) { + if ((r->data)[i]) { + free((r->data)[i]); + } + } + free(r->data); + free(r); + return NULL; + } + strcpy((r->data)[i], values[i-1]); + } else { + (r->data)[i] = NULL; + } + } + + debug(3, "Leaving replay_create_exec_prepared%s\n", ""); + return r; +} + +replay_item *replay_create_cancel(const struct timeval *time, uint64_t session_id) { + replay_item *r; + + debug(3, "Entering replay_create_cancel%s\n", ""); + + r = replay_create(time, session_id, pg_cancel, 0); + if (NULL == r) { + return NULL; + } + debug(3, "Leaving replay_create_cancel%s\n", ""); + return r; +} + +void replay_free(replay_item *r) { + int i; + + debug(3, "Entering replay_free%s\n", ""); + + assert((pg_connect == r->type) || (pg_disconnect == r->type) || (pg_execute == r->type) || (pg_prepare == r->type) || (pg_exec_prepared == r->type) || (pg_cancel == r->type)); + + for (i=0; icount; ++i) { + if ((r->data)[i]) { + free((r->data)[i]); + } + } + if (r->count) { + free(r->data); + } + + if(polardb_audit){ + free(r->search_path); + free(r->prepare_parse); + } + free(r); + + debug(3, "Leaving replay_free%s\n", ""); +} + +replay_type replay_get_type(const replay_item *r) { + return r->type; +} + +uint64_t replay_get_session_id(const replay_item *r) { + return r->session_id; +} + +const struct timeval * replay_get_time(const replay_item *r) { + return &(r->time); +} + +const char * replay_get_statement(const replay_item *r) { + assert((pg_execute == r->type) || (pg_prepare == r->type)); + + return (r->data)[0]; +} + +const char * replay_get_name(const replay_item *r) { + assert((pg_prepare == r->type) || (pg_exec_prepared == r->type)); + + return (pg_prepare == r->type) ? (r->data)[1] : (r->data)[0]; +} + +const char * replay_get_user(const replay_item *r) { + assert(pg_connect == r->type); + + return (r->data)[0]; +} + +const char * replay_get_database(const replay_item *r) { + assert(pg_connect == r->type); + + return (r->data)[1]; +} + +int replay_get_valuecount(const replay_item *r) { + assert(pg_exec_prepared == r->type); + + return r->count - 1; +} + +const char * const * replay_get_values(const replay_item *r) { + assert(pg_exec_prepared == r->type); + + return (const char * const *)((r->data) + 1); +} + +/* maximal part of a value for display */ +#define SAMPLE_SIZE 100 + +void replay_print_debug(const replay_item *r) { + replay_type type; + int i; + char valuepart[SAMPLE_SIZE+4], *p; + + valuepart[SAMPLE_SIZE] = '.'; + valuepart[SAMPLE_SIZE+1] = '.'; + valuepart[SAMPLE_SIZE+2] = '.'; + valuepart[SAMPLE_SIZE+3] = '\0'; + + debug(1, "---------------------------%s\n", ""); + debug(1, "Item: time = %lu.%06lu\n", (unsigned long)r->time.tv_sec, (unsigned long)r->time.tv_usec); + debug(1, " session id = 0x" UINT64_FORMAT "\n", r->session_id); + type = r->type; + debug(1, " type = %s\n", + (pg_connect == type) ? "connect" : + ((pg_disconnect == type) ? "disconnect" : + ((pg_execute == type) ? "execute" : + ((pg_prepare == type) ? "prepare" : + ((pg_exec_prepared == type) ? "exec_prepared" : + ((pg_cancel == type) ? "cancel" : "unknown") + ) + ) + ) + ) + ); + switch (type) { + case pg_connect: + debug(1, " user = %s\n", replay_get_user(r)); + debug(1, " database = %s\n", replay_get_database(r)); + case pg_disconnect: + case pg_cancel: + break; + case pg_prepare: + debug(1, " name = %s\n", replay_get_name(r)); + case pg_execute: + debug(1, " statement = %s\n", replay_get_statement(r)); + break; + case pg_exec_prepared: + debug(1, " name = %s\n", replay_get_name(r)); + for (i=0; i +#include + +/* gets the last error and prints an error message */ + +void win_perror(const char *prefix, int is_network_error) { + DWORD error_nr; + char *errmsg; + /* catalog of Windows socket error messages */ + static HMODULE sock_err_mod = NULL; + + /* get the message number */ + if (is_network_error) { + error_nr = WSAGetLastError(); + + if (NULL == sock_err_mod) { + /* try to load the Windows socket error message catalog */ + sock_err_mod = LoadLibraryEx( + "netmsg.dll", + NULL, + LOAD_LIBRARY_AS_DATAFILE + ); + } + } else { + error_nr = GetLastError(); + } + + /* get the error message text */ + if (FormatMessage( + FORMAT_MESSAGE_ALLOCATE_BUFFER + | FORMAT_MESSAGE_IGNORE_INSERTS + | FORMAT_MESSAGE_FROM_SYSTEM + | ((is_network_error && sock_err_mod) ? FORMAT_MESSAGE_FROM_HMODULE : 0), + sock_err_mod, + error_nr, + MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), + (LPSTR) &errmsg, + 0, + NULL)) { + fprintf(stderr, "%s: %s\n", prefix, errmsg); + + /* free the memory for the error message */ + LocalFree(errmsg); + } else { + fprintf(stderr, "%s: error number %ld\n", prefix, error_nr); + } +}