summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2013-09-14 19:30:39 +0100
committerStephen Dolan <mu@netsoc.tcd.ie>2013-09-14 19:30:39 +0100
commitdae2422fd18487c89dd79dc54eb4345861ab7bdc (patch)
tree14f046128de9c35a57e3574a3a4365095b680d4f
parentf98e3e6c26b3b53701e1e6c2ff98ab6227cde3b8 (diff)
parent37cfc912c1f384d177162f8aa706452754d2c6ab (diff)
Merge branch 'libjq'
Conflicts: Makefile.am configure.ac
-rw-r--r--.gitignore10
-rw-r--r--Makefile.am35
-rw-r--r--README.md2
-rw-r--r--builtin.c21
-rw-r--r--builtin.h14
-rw-r--r--bytecode.c32
-rw-r--r--bytecode.h46
-rw-r--r--compile.c1
-rw-r--r--compile.h6
-rw-r--r--config.h.in32
-rw-r--r--config/.gitignore8
-rwxr-xr-xconfig/compile343
-rwxr-xr-xconfig/depcomp708
-rwxr-xr-xconfig/install-sh527
-rw-r--r--config/m4/.gitignore2
-rwxr-xr-xconfig/missing331
-rwxr-xr-xconfig/ylwrap226
-rw-r--r--configure.ac7
-rw-r--r--execute.c29
-rw-r--r--jq.h (renamed from execute.h)19
-rw-r--r--jq_parser.h2
-rw-r--r--jq_test.c6
-rw-r--r--jv.c7
-rw-r--r--jv.h45
-rw-r--r--jv_alloc.h3
-rw-r--r--jv_aux.c2
-rw-r--r--jv_aux.h20
-rw-r--r--jv_file.c12
-rw-r--r--jv_file.h8
-rw-r--r--jv_parse.c50
-rw-r--r--jv_parse.h37
-rw-r--r--jv_print.c2
-rw-r--r--lexer.l1
-rw-r--r--main.c14
-rw-r--r--opcode.c31
-rw-r--r--opcode.h41
-rw-r--r--parser.y1
-rw-r--r--scripts/gen_utf8_tables.py (renamed from gen_utf8_tables.py)0
-rwxr-xr-xsetup.sh1
39 files changed, 252 insertions, 2430 deletions
diff --git a/.gitignore b/.gitignore
index 8734c174..ffc9d46b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,10 @@
*.o
+*.a
+*.lo
+*.la
+*.lai
+*.so
+*.so.*
*~
.*.sw[a-p]
tags
@@ -16,13 +22,15 @@ parser.c
parser.h
# Autotools junk
+.libs
.deps
+libtool
*.log
stamp-h1
config.log
config.status
autom4te.cache
-config.h
+INSTALL
Makefile
jq-*.tar.gz
configure
diff --git a/Makefile.am b/Makefile.am
index e518485b..ce61a0c7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,13 +1,12 @@
### C source files to be built and distributed.
-JQ_INCS = jq_parser.h builtin.h bytecode.h compile.h execute.h \
- exec_stack.h jv.h jv_alloc.h jv_aux.h jv_dtoa.h \
- jv_file.h jv_parse.h jv_unicode.h locfile.h opcode.h opcode_list.h \
- parser.y jv_utf8_tables.h lexer.l
+LIBJQ_INCS = jq_parser.h builtin.h bytecode.h compile.h exec_stack.h \
+ jv_alloc.h jv_dtoa.h jv_unicode.h locfile.h \
+ opcode_list.h parser.y jv_utf8_tables.h lexer.l
-JQ_SRC = locfile.c opcode.c bytecode.c compile.c execute.c builtin.c \
- jv.c jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_file.c \
- jv_alloc.c jq_test.c ${JQ_INCS}
+LIBJQ_SRC = locfile.c bytecode.c compile.c execute.c builtin.c jv.c \
+ jv_parse.c jv_print.c jv_dtoa.c jv_unicode.c jv_aux.c jv_file.c \
+ jv_alloc.c jq_test.c ${LIBJQ_INCS}
### C build options
@@ -15,6 +14,7 @@ JQ_SRC = locfile.c opcode.c bytecode.c compile.c execute.c builtin.c \
AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \
-Wno-unused-parameter -Wno-unused-function
+ACLOCAL_AMFLAGS = -I config/m4
### Generating the lexer and parser
@@ -30,6 +30,15 @@ lexer.h: lexer.c
# OSX ships an old bison, so update with homebrew or macports
AM_YFLAGS = --warnings=all -d
+### libjq
+
+lib_LTLIBRARIES = libjq.la
+libjq_la_SOURCES = ${LIBJQ_SRC}
+libjq_la_LIBADD = -lm
+libjq_la_LDFLAGS = -export-symbols-regex '^j[qv]_' -version-info 1:4:0
+
+include_HEADERS = jv.h jq.h
+
### Building the jq binary
@@ -43,8 +52,9 @@ version.h: .remake-version-h
$(AM_V_GEN) $(generate_ver); echo "$$ver" > $@
bin_PROGRAMS = jq
-jq_SOURCES = ${JQ_SRC} main.c
-jq_LDADD = -lm
+jq_SOURCES = main.c
+jq_LDFLAGS = -static-libtool-libs
+jq_LDADD = libjq.la -lm
### Tests (make check)
@@ -100,10 +110,9 @@ DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
# setup is only used by distribution developers, not package developers.
# Still, as a matter of allowing patching, its not a bad idea to distribute
# the developer setup script in the tarball.
-EXTRA_DIST = config.h.in $(man_MANS) $(TESTS) \
- $(TEST_LOG_COMPILER) gen_utf8_tables.py jq.spec \
- $(DOC_FILES) scripts/version \
- parser.h parser.c lexer.h lexer.c
+EXTRA_DIST = $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) jq.spec \
+ $(DOC_FILES) scripts/version parser.h parser.c lexer.h \
+ lexer.c
# README.md is expected in Github projects, good stuff in it, so we'll
# distribute it and install it with the package in the doc directory.
diff --git a/README.md b/README.md
index df2b1e88..40a4cf87 100644
--- a/README.md
+++ b/README.md
@@ -14,7 +14,7 @@ shovel. Also, read the wiki: http://github.com/stedolan/jq/wiki
If you're building directly from the latest git, you'll need flex and
bison installed. To build, run:
- autoreconf
+ autoreconf -i
./configure
make
diff --git a/builtin.c b/builtin.c
index 0bdb9356..a61e8204 100644
--- a/builtin.c
+++ b/builtin.c
@@ -1,32 +1,15 @@
#include <math.h>
#include <stdlib.h>
#include <string.h>
+#include <assert.h>
#include "builtin.h"
#include "compile.h"
#include "jq_parser.h"
+#include "bytecode.h"
#include "locfile.h"
-#include "jv_aux.h"
-#include "jv_file.h"
#include "jv_unicode.h"
-
-typedef jv (*func_1)(jv);
-typedef jv (*func_2)(jv,jv);
-typedef jv (*func_3)(jv,jv,jv);
-typedef jv (*func_4)(jv,jv,jv,jv);
-typedef jv (*func_5)(jv,jv,jv,jv,jv);
-jv cfunction_invoke(struct cfunction* function, jv input[]) {
- switch (function->nargs) {
- case 1: return ((func_1)function->fptr)(input[0]);
- case 2: return ((func_2)function->fptr)(input[0], input[1]);
- case 3: return ((func_3)function->fptr)(input[0], input[1], input[2]);
- case 4: return ((func_4)function->fptr)(input[0], input[1], input[2], input[3]);
- case 5: return ((func_5)function->fptr)(input[0], input[1], input[2], input[3], input[4]);
- default: return jv_invalid_with_msg(jv_string("Function takes too many arguments"));
- }
-}
-
static jv type_error(jv bad, const char* msg) {
jv err = jv_invalid_with_msg(jv_string_fmt("%s %s",
jv_kind_name(jv_get_kind(bad)),
diff --git a/builtin.h b/builtin.h
index fdbce92a..1aab133f 100644
--- a/builtin.h
+++ b/builtin.h
@@ -1,21 +1,9 @@
#ifndef BUILTIN_H
#define BUILTIN_H
+#include "bytecode.h"
#include "compile.h"
int builtins_bind(block*);
-
-typedef void (*cfunction_ptr)(void);
-
-struct cfunction {
- cfunction_ptr fptr;
- const char* name;
- int nargs;
-};
-
-
-jv cfunction_invoke(struct cfunction* function, jv input[]);
-
-
#endif
diff --git a/bytecode.c b/bytecode.c
index 184cf983..1277fdc1 100644
--- a/bytecode.c
+++ b/bytecode.c
@@ -3,9 +3,39 @@
#include <stdlib.h>
#include "bytecode.h"
-#include "opcode.h"
#include "jv_alloc.h"
+// flags, length
+#define NONE 0, 1
+#define CONSTANT OP_HAS_CONSTANT, 2
+#define VARIABLE (OP_HAS_VARIABLE | OP_HAS_BINDING), 3
+#define BRANCH OP_HAS_BRANCH, 2
+#define CFUNC (OP_HAS_CFUNC | OP_HAS_BINDING), 3
+#define UFUNC (OP_HAS_UFUNC | OP_HAS_BINDING | OP_IS_CALL_PSEUDO), 4
+#define DEFINITION (OP_IS_CALL_PSEUDO | OP_HAS_BINDING), 0
+#define CLOSURE_REF_IMM (OP_IS_CALL_PSEUDO | OP_HAS_BINDING), 2
+
+#define OP(name, imm, in, out) \
+ {name, #name, imm, in, out},
+
+static const struct opcode_description opcode_descriptions[] = {
+#include "opcode_list.h"
+};
+
+static const struct opcode_description invalid_opcode_description = {
+ -1, "#INVALID", 0, 0, 0, 0
+};
+
+
+const struct opcode_description* opcode_describe(opcode op) {
+ if ((int)op >= 0 && (int)op < NUM_OPCODES) {
+ return &opcode_descriptions[op];
+ } else {
+ return &invalid_opcode_description;
+ }
+}
+
+
static int bytecode_operation_length(uint16_t* codeptr) {
int length = opcode_describe(*codeptr)->length;
if (*codeptr == CALL_JQ) {
diff --git a/bytecode.h b/bytecode.h
index 70929c91..b81e1478 100644
--- a/bytecode.h
+++ b/bytecode.h
@@ -3,10 +3,52 @@
#include <stdint.h>
#include "jv.h"
-#include "opcode.h"
-#include "builtin.h"
+
+typedef enum {
+#define OP(name, imm, in, out) name,
+#include "opcode_list.h"
+#undef OP
+} opcode;
+
+enum {
+ NUM_OPCODES =
+#define OP(name, imm, in, out) +1
+#include "opcode_list.h"
+#undef OP
+};
+
+enum {
+ OP_HAS_CONSTANT = 2,
+ OP_HAS_VARIABLE = 4,
+ OP_HAS_BRANCH = 8,
+ OP_HAS_CFUNC = 32,
+ OP_HAS_UFUNC = 64,
+ OP_IS_CALL_PSEUDO = 128,
+ OP_HAS_BINDING = 1024,
+};
+struct opcode_description {
+ opcode op;
+ const char* name;
+
+ int flags;
+
+ // length in 16-bit units
+ int length;
+
+ int stack_in, stack_out;
+};
+
+const struct opcode_description* opcode_describe(opcode op);
+
#define MAX_CFUNCTION_ARGS 10
+typedef void (*cfunction_ptr)();
+struct cfunction {
+ cfunction_ptr fptr;
+ const char* name;
+ int nargs;
+};
+
struct symbol_table {
struct cfunction* cfunctions;
int ncfunctions;
diff --git a/compile.c b/compile.c
index 4dda1011..248d363e 100644
--- a/compile.c
+++ b/compile.c
@@ -2,7 +2,6 @@
#include <assert.h>
#include <string.h>
#include <stdlib.h>
-#include "opcode.h"
#include "compile.h"
#include "bytecode.h"
#include "locfile.h"
diff --git a/compile.h b/compile.h
index 4ac7168b..531e853e 100644
--- a/compile.h
+++ b/compile.h
@@ -2,13 +2,9 @@
#define COMPILE_H
#include <stdint.h>
#include "jv.h"
-#include "opcode.h"
+#include "bytecode.h"
#include "locfile.h"
-struct bytecode;
-struct symbol_table;
-struct cfunction;
-
struct inst;
typedef struct inst inst;
diff --git a/config.h.in b/config.h.in
deleted file mode 100644
index 46b33c08..00000000
--- a/config.h.in
+++ /dev/null
@@ -1,32 +0,0 @@
-/* config.h.in. Generated from configure.ac by autoheader. */
-
-/* Define to 1 if your C compiler doesn't accept -c and -o together. */
-#undef NO_MINUS_C_MINUS_O
-
-/* Name of package */
-#undef PACKAGE
-
-/* Define to the address where bug reports for this package should be sent. */
-#undef PACKAGE_BUGREPORT
-
-/* Define to the full name of this package. */
-#undef PACKAGE_NAME
-
-/* Define to the full name and version of this package. */
-#undef PACKAGE_STRING
-
-/* Define to the one symbol short name of this package. */
-#undef PACKAGE_TARNAME
-
-/* Define to the home page for this package. */
-#undef PACKAGE_URL
-
-/* Define to the version of this package. */
-#undef PACKAGE_VERSION
-
-/* Version number of package */
-#undef VERSION
-
-/* Define to 1 if `lex' declares `yytext' as a `char *' by default, not a
- `char[]'. */
-#undef YYTEXT_POINTER
diff --git a/config/.gitignore b/config/.gitignore
new file mode 100644
index 00000000..d235f981
--- /dev/null
+++ b/config/.gitignore
@@ -0,0 +1,8 @@
+config.guess
+config.sub
+compile
+depcomp
+install-sh
+ltmain.sh
+missing
+ylwrap
diff --git a/config/compile b/config/compile
deleted file mode 100755
index 862a14e8..00000000
--- a/config/compile
+++ /dev/null
@@ -1,343 +0,0 @@
-#! /bin/sh
-# Wrapper for compilers which do not understand '-c -o'.
-
-scriptversion=2012-03-05.13; # UTC
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free
-# Software Foundation, Inc.
-# Written by Tom Tromey <tromey@cygnus.com>.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# This file is maintained in Automake, please report
-# bugs to <bug-automake@gnu.org> or send patches to
-# <automake-patches@gnu.org>.
-
-nl='
-'
-
-# We need space, tab and new line, in precisely that order. Quoting is
-# there to prevent tools from complaining about whitespace usage.
-IFS=" "" $nl"
-
-file_conv=
-
-# func_file_conv build_file lazy
-# Convert a $build file to $host form and store it in $file
-# Currently only supports Windows hosts. If the determined conversion
-# type is listed in (the comma separated) LAZY, no conversion will
-# take place.
-func_file_conv ()
-{
- file=$1
- case $file in
- / | /[!/]*) # absolute file, and not a UNC file
- if test -z "$file_conv"; then
- # lazily determine how to convert abs files
- case `uname -s` in
- MINGW*)
- file_conv=mingw
- ;;
- CYGWIN*)
- file_conv=cygwin
- ;;
- *)
- file_conv=wine
- ;;
- esac
- fi
- case $file_conv/,$2, in
- *,$file_conv,*)
- ;;
- mingw/*)
- file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
- ;;
- cygwin/*)
- file=`cygpath -m "$file" || echo "$file"`
- ;;
- wine/*)
- file=`winepath -w "$file" || echo "$file"`
- ;;
- esac
- ;;
- esac
-}
-
-# func_cl_dashL linkdir
-# Make cl look for libraries in LINKDIR
-func_cl_dashL ()
-{
- func_file_conv "$1"
- if test -z "$lib_path"; then
- lib_path=$file
- else
- lib_path="$lib_path;$file"
- fi
- linker_opts="$linker_opts -LIBPATH:$file"
-}
-
-# func_cl_dashl library
-# Do a library search-path lookup for cl
-func_cl_dashl ()
-{
- lib=$1
- found=no
- save_IFS=$IFS
- IFS=';'
- for dir in $lib_path $LIB
- do
- IFS=$save_IFS
- if $shared && test -f "$dir/$lib.dll.lib"; then
- found=yes
- lib=$dir/$lib.dll.lib
- break
- fi
- if test -f "$dir/$lib.lib"; then
- found=yes
- lib=$dir/$lib.lib
- break
- fi
- done
- IFS=$save_IFS
-
- if test "$found" != yes; then
- lib=$lib.lib
- fi
-}
-
-# func_cl_wrapper cl arg...
-# Adjust compile command to suit cl
-func_cl_wrapper ()
-{
- # Assume a capable shell
- lib_path=
- shared=:
- linker_opts=
- for arg
- do
- if test -n "$eat"; then
- eat=
- else
- case $1 in
- -o)
- # configure might choose to run compile as 'compile cc -o foo foo.c'.
- eat=1
- case $2 in
- *.o | *.[oO][bB][jJ])
- func_file_conv "$2"
- set x "$@" -Fo"$file"
- shift
- ;;
- *)
- func_file_conv "$2"
- set x "$@" -Fe"$file"
- shift
- ;;
- esac
- ;;
- -I)
- eat=1
- func_file_conv "$2" mingw
- set x "$@" -I"$file"
- shift
- ;;
- -I*)
- func_file_conv "${1#-I}" mingw
- set x "$@" -I"$file"
- shift
- ;;
- -l)
- eat=1
- func_cl_dashl "$2"
- set x "$@" "$lib"
- shift
- ;;
- -l*)
- func_cl_dashl "${1#-l}"
- set x "$@" "$lib"
- shift
- ;;
- -L)
- eat=1
- func_cl_dashL "$2"
- ;;
- -L*)
- func_cl_dashL "${1#-L}"
- ;;
- -static)
- shared=false
- ;;
- -Wl,*)
- arg=${1#-Wl,}
- save_ifs="$IFS"; IFS=','
- for flag in $arg; do
- IFS="$save_ifs"
- linker_opts="$linker_opts $flag"
- done
- IFS="$save_ifs"
- ;;
- -Xlinker)
- eat=1
- linker_opts="$linker_opts $2"
- ;;
- -*)
- set x "$@" "$1"
- shift
- ;;
- *.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
- func_file_conv "$1"
- set x "$@" -Tp"$file"
- shift
- ;;
- *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
- func_file_conv "$1" mingw
- set x "$@" "$file"
- shift
- ;;
- *)
- set x "$@" "$1"
- shift
- ;;
- esac
- fi
- shift
- done
- if test -n "$linker_opts"; then
- linker_opts="-link$linker_opts"
- fi
- exec "$@" $linker_opts
- exit 1
-}
-
-eat=
-
-case $1 in
- '')
- echo "$0: No command. Try '$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: compile [--help] [--version] PROGRAM [ARGS]
-
-Wrapper for compilers which do not understand '-c -o'.
-Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
-arguments, and rename the output as expected.
-
-If you are trying to build a whole package this is not the
-right script to run: please start by reading the file 'INSTALL'.
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "compile $scriptversion"
- exit $?
- ;;
- cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
- func_cl_wrapper "$@" # Doesn't return...
- ;;
-esac
-
-ofile=
-cfile=
-
-for arg
-do
- if test -n "$eat"; then
- eat=
- else
- case $1 in
- -o)
- # configure might choose to run compile as 'compile cc -o foo foo.c'.
- # So we strip '-o arg' only if arg is an object.
- eat=1
- case $2 in
- *.o | *.obj)
- ofile=$2
- ;;
- *)
- set x "$@" -o "$2"
- shift
- ;;
- esac
- ;;
- *.c)
- cfile=$1
- set x "$@" "$1"
- shift
- ;;
- *)
- set x "$@" "$1"
- shift
- ;;
- esac
- fi
- shift
-done
-
-if test -z "$ofile" || test -z "$cfile"; then
- # If no '-o' option was seen then we might have been invoked from a
- # pattern rule where we don't need one. That is ok -- this is a
- # normal compilation that the losing compiler can handle. If no
- # '.c' file was seen then we are probably linking. That is also
- # ok.
- exec "$@"
-fi
-
-# Name of file we expect compiler to create.
-cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
-
-# Create the lock directory.
-# Note: use '[/\\:.-]' here to ensure that we don't use the same name
-# that we are using for the .o file. Also, base the name on the expected
-# object file name, since that is what matters with a parallel build.
-lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
-while true; do
- if mkdir "$lockdir" >/dev/null 2>&1; then
- break
- fi
- sleep 1
-done
-# FIXME: race condition here if user kills between mkdir and trap.
-trap "rmdir '$lockdir'; exit 1" 1 2 15
-
-# Run the compile.
-"$@"
-ret=$?
-
-if test -f "$cofile"; then
- test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
-elif test -f "${cofile}bj"; then
- test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
-fi
-
-rmdir "$lockdir"
-exit $ret
-
-# Local Variables:
-# mode: shell-script
-# sh-indentation: 2
-# eval: (add-hook 'write-file-hooks 'time-stamp)
-# time-stamp-start: "scriptversion="
-# time-stamp-format: "%:y-%02m-%02d.%02H"
-# time-stamp-time-zone: "UTC"
-# time-stamp-end: "; # UTC"
-# End:
diff --git a/config/depcomp b/config/depcomp
deleted file mode 100755
index 25a39e6c..00000000
--- a/config/depcomp
+++ /dev/null
@@ -1,708 +0,0 @@
-#! /bin/sh
-# depcomp - compile a program generating dependencies as side-effects
-
-scriptversion=2012-03-27.16; # UTC
-
-# Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010,
-# 2011, 2012 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-# As a special exception to the GNU General Public License, if you
-# distribute this file as part of a program that contains a
-# configuration script generated by Autoconf, you may include it under
-# the same distribution terms that you use for the rest of that program.
-
-# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
-
-case $1 in
- '')
- echo "$0: No command. Try '$0 --help' for more information." 1>&2
- exit 1;
- ;;
- -h | --h*)
- cat <<\EOF
-Usage: depcomp [--help] [--version] PROGRAM [ARGS]
-
-Run PROGRAMS ARGS to compile a file, generating dependencies
-as side-effects.
-
-Environment variables:
- depmode Dependency tracking mode.
- source Source file read by 'PROGRAMS ARGS'.
- object Object file output by 'PROGRAMS ARGS'.
- DEPDIR directory where to store dependencies.
- depfile Dependency file to output.
- tmpdepfile Temporary file to use when outputting dependencies.
- libtool Whether libtool is used (yes/no).
-
-Report bugs to <bug-automake@gnu.org>.
-EOF
- exit $?
- ;;
- -v | --v*)
- echo "depcomp $scriptversion"
- exit $?
- ;;
-esac
-
-# A tabulation character.
-tab=' '
-# A newline character.
-nl='
-'
-
-if test -z "$depmode" || test -z "$source" || test -z "$object"; then
- echo "depcomp: Variables source, object and depmode must be set" 1>&2
- exit 1
-fi
-
-# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
-depfile=${depfile-`echo "$object" |
- sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
-tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
-
-rm -f "$tmpdepfile"
-
-# Some modes work just like other modes, but use different flags. We
-# parameterize here, but still list the modes in the big case below,
-# to make depend.m4 easier to write. Note that we *cannot* use a case
-# here, because this file can only contain one case statement.
-if test "$depmode" = hp; then
- # HP compiler uses -M and no extra arg.
- gccflag=-M
- depmode=gcc
-fi
-
-if test "$depmode" = dashXmstdout; then
- # This is just like dashmstdout with a different argument.
- dashmflag=-xM
- depmode=dashmstdout
-fi
-
-cygpath_u="cygpath -u -f -"
-if test "$depmode" = msvcmsys; then
- # This is just like msvisualcpp but w/o cygpath translation.
- # Just convert the backslash-escaped backslashes to single forward
- # slashes to satisfy depend.m4
- cygpath_u='sed s,\\\\,/,g'
- depmode=msvisualcpp
-fi
-
-if test "$depmode" = msvc7msys; then
- # This is just like msvc7 but w/o cygpath translation.
- # Just convert the backslash-escaped backslashes to single forward
- # slashes to satisfy depend.m4
- cygpath_u='sed s,\\\\,/,g'
- depmode=msvc7
-fi
-
-if test "$depmode" = xlc; then
- # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency informations.
- gccflag=-qmakedep=gcc,-MF
- depmode=gcc
-fi
-
-case "$depmode" in
-gcc3)
-## gcc 3 implements dependency tracking that does exactly what
-## we want. Yay! Note: for some reason libtool 1.4 doesn't like
-## it if -MD -MP comes after the -MF stuff. Hmm.
-## Unfortunately, FreeBSD c89 acceptance of flags depends upon
-## the command line argument order; so add the flags where they
-## appear in depend2.am. Note that the slowdown incurred here
-## affects only configure: in makefiles, %FASTDEP% shortcuts this.
- for arg
- do
- case $arg in
- -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;;
- *) set fnord "$@" "$arg" ;;
- esac
- shift # fnord
- shift # $arg
- done
- "$@"
- stat=$?
- if test $stat -eq 0; then :
- else
- rm -f "$tmpdepfile"
- exit $stat
- fi
- mv "$tmpdepfile" "$depfile"
- ;;
-
-gcc)
-## There are various ways to get dependency output from gcc. Here's
-## why we pick this rather obscure method:
-## - Don't want to use -MD because we'd like the dependencies to end
-## up in a subdir. Having to rename by hand is ugly.
-## (We might end up doing this anyway to support other compilers.)
-## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
-## -MM, not -M (despite what the docs say).
-## - Using -M directly means running the compiler twice (even worse
-## than renaming).
- if test -z "$gccflag"; then
- gccflag=-MD,
- fi
- "$@" -Wp,"$gccflag$tmpdepfile"
- stat=$?
- if test $stat -eq 0; then :
- else