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 #include #include +#include #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 #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 #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 #include #include -#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 #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 . -# -# 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 . - -# 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 or send patches to -# . - -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 . -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 . - -# 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 . - -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 . -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 - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -## The second -e expression handles DOS-style file names with drive letters. - sed -e 's/^[^:]*: / /' \ - -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" -## This next piece of magic avoids the "deleted header file" problem. -## The problem is that when a header file which appears in a .P file -## is deleted, the dependency causes make to die (because there is -## typically no way to rebuild the header). We avoid this by adding -## dummy dependencies for each header file. Too bad gcc doesn't do -## this for us directly. - tr ' ' "$nl" < "$tmpdepfile" | -## Some versions of gcc put a space before the ':'. On the theory -## that the space means something, we add a space to the output as -## well. hp depmode also adds that space, but also prefixes the VPATH -## to the object. Take care to not repeat it in the output. -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ - | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -sgi) - if test "$libtool" = yes; then - "$@" "-Wp,-MDupdate,$tmpdepfile" - else - "$@" -MDupdate "$tmpdepfile" - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - - if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files - echo "$object : \\" > "$depfile" - - # Clip off the initial element (the dependent). Don't try to be - # clever and replace this with sed code, as IRIX sed won't handle - # lines with more than a fixed number of characters (4096 in - # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; - # the IRIX cc adds comments like '#:fec' to the end of the - # dependency line. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ - tr "$nl" ' ' >> "$depfile" - echo >> "$depfile" - - # The second pass generates a dummy entry for each header file. - tr ' ' "$nl" < "$tmpdepfile" \ - | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ - >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -xlc) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -aix) - # The C for AIX Compiler uses -M and outputs the dependencies - # in a .u file. In older versions, this file always lives in the - # current directory. Also, the AIX compiler puts '$object:' at the - # start of each line; $object doesn't have directory information. - # Version 6 uses the directory in both cases. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.u - tmpdepfile2=$base.u - tmpdepfile3=$dir.libs/$base.u - "$@" -Wc,-M - else - tmpdepfile1=$dir$base.u - tmpdepfile2=$dir$base.u - tmpdepfile3=$dir$base.u - "$@" -M - fi - stat=$? - - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - # Each line is of the form 'foo.o: dependent.h'. - # Do two passes, one to just change these to - # '$object: dependent.h' and one to simply 'dependent.h:'. - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - # The sourcefile does not contain any dependencies, so just - # store a dummy comment line, to avoid errors with the Makefile - # "include basename.Plo" scheme. - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -icc) - # Intel's C compiler anf tcc (Tiny C Compiler) understand '-MD -MF file'. - # However on - # $CC -MD -MF foo.d -c -o sub/foo.o sub/foo.c - # ICC 7.0 will fill foo.d with something like - # foo.o: sub/foo.c - # foo.o: sub/foo.h - # which is wrong. We want - # sub/foo.o: sub/foo.c - # sub/foo.o: sub/foo.h - # sub/foo.c: - # sub/foo.h: - # ICC 7.1 will output - # foo.o: sub/foo.c sub/foo.h - # and will wrap long lines using '\': - # foo.o: sub/foo.c ... \ - # sub/foo.h ... \ - # ... - # tcc 0.9.26 (FIXME still under development at the moment of writing) - # will emit a similar output, but also prepend the continuation lines - # with horizontal tabulation characters. - "$@" -MD -MF "$tmpdepfile" - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - # Each line is of the form 'foo.o: dependent.h', - # or 'foo.o: dep1.h dep2.h \', or ' dep3.h dep4.h \'. - # Do two passes, one to just change these to - # '$object: dependent.h' and one to simply 'dependent.h:'. - sed -e "s/^[ $tab][ $tab]*/ /" -e "s,^[^:]*:,$object :," \ - < "$tmpdepfile" > "$depfile" - sed ' - s/[ '"$tab"'][ '"$tab"']*/ /g - s/^ *// - s/ *\\*$// - s/^[^:]*: *// - /^$/d - /:$/d - s/$/ :/ - ' < "$tmpdepfile" >> "$depfile" - rm -f "$tmpdepfile" - ;; - -hp2) - # The "hp" stanza above does not work with aCC (C++) and HP's ia64 - # compilers, which have integrated preprocessors. The correct option - # to use with these is +Maked; it writes dependencies to a file named - # 'foo.d', which lands next to the object file, wherever that - # happens to be. - # Much of this is similar to the tru64 case; see comments there. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - if test "$libtool" = yes; then - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir.libs/$base.d - "$@" -Wc,+Maked - else - tmpdepfile1=$dir$base.d - tmpdepfile2=$dir$base.d - "$@" +Maked - fi - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" - # Add 'dependent.h:' lines. - sed -ne '2,${ - s/^ *// - s/ \\*$// - s/$/:/ - p - }' "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" "$tmpdepfile2" - ;; - -tru64) - # The Tru64 compiler uses -MD to generate dependencies as a side - # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. - # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put - # dependencies in 'foo.d' instead, so we check for that too. - # Subdirectories are respected. - dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` - test "x$dir" = "x$object" && dir= - base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` - - if test "$libtool" = yes; then - # With Tru64 cc, shared objects can also be used to make a - # static library. This mechanism is used in libtool 1.4 series to - # handle both shared and static libraries in a single compilation. - # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. - # - # With libtool 1.5 this exception was removed, and libtool now - # generates 2 separate objects for the 2 libraries. These two - # compilations output dependencies in $dir.libs/$base.o.d and - # in $dir$base.o.d. We have to check for both files, because - # one of the two compilations can be disabled. We should prefer - # $dir$base.o.d over $dir.libs/$base.o.d because the latter is - # automatically cleaned when .libs/ is deleted, while ignoring - # the former would cause a distcleancheck panic. - tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 - tmpdepfile2=$dir$base.o.d # libtool 1.5 - tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 - tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 - "$@" -Wc,-MD - else - tmpdepfile1=$dir$base.o.d - tmpdepfile2=$dir$base.d - tmpdepfile3=$dir$base.d - tmpdepfile4=$dir$base.d - "$@" -MD - fi - - stat=$? - if test $stat -eq 0; then : - else - rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - exit $stat - fi - - for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" - do - test -f "$tmpdepfile" && break - done - if test -f "$tmpdepfile"; then - sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" - sed -e 's,^.*\.[a-z]*:['"$tab"' ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" - else - echo "#dummy" > "$depfile" - fi - rm -f "$tmpdepfile" - ;; - -msvc7) - if test "$libtool" = yes; then - showIncludes=-Wc,-showIncludes - else - showIncludes=-showIncludes - fi - "$@" $showIncludes > "$tmpdepfile" - stat=$? - grep -v '^Note: including file: ' "$tmpdepfile" - if test "$stat" = 0; then : - else - rm -f "$tmpdepfile" - exit $stat - fi - rm -f "$depfile" - echo "$object : \\" > "$depfile" - # The first sed program below extracts the file names and escapes - # backslashes for cygpath. The second sed program outputs the file - # name when reading, but also accumulates all include files in the - # hold buffer in order to output them again at the end. This only - # works with sed implementations that can handle large buffers. - sed < "$tmpdepfile" -n ' -/^Note: including file: *\(.*\)/ { - s//\1/ - s/\\/\\\\/g - p -}' | $cygpath_u | sort -u | sed -n ' -s/ /\\ /g -s/\(.*\)/'"$tab"'\1 \\/p -s/.\(.*\) \\/\1:/ -H -$ { - s/.*/'"$tab"'/ - G - p -}' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvc7msys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -#nosideeffect) - # This comment above is used by automake to tell side-effect - # dependency tracking mechanisms from slower ones. - -dashmstdout) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout, regardless of -o. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - test -z "$dashmflag" && dashmflag=-M - # Require at least two characters before searching for ':' - # in the target name. This is to cope with DOS-style filenames: - # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. - "$@" $dashmflag | - sed 's:^['"$tab"' ]*[^:'"$tab"' ][^:][^:]*\:['"$tab"' ]*:'"$object"'\: :' > "$tmpdepfile" - rm -f "$depfile" - cat < "$tmpdepfile" > "$depfile" - tr ' ' "$nl" < "$tmpdepfile" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -dashXmstdout) - # This case only exists to satisfy depend.m4. It is never actually - # run, as this mode is specially recognized in the preamble. - exit 1 - ;; - -makedepend) - "$@" || exit $? - # Remove any Libtool call - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - # X makedepend - shift - cleared=no eat=no - for arg - do - case $cleared in - no) - set ""; shift - cleared=yes ;; - esac - if test $eat = yes; then - eat=no - continue - fi - case "$arg" in - -D*|-I*) - set fnord "$@" "$arg"; shift ;; - # Strip any option that makedepend may not understand. Remove - # the object too, otherwise makedepend will parse it as a source file. - -arch) - eat=yes ;; - -*|$object) - ;; - *) - set fnord "$@" "$arg"; shift ;; - esac - done - obj_suffix=`echo "$object" | sed 's/^.*\././'` - touch "$tmpdepfile" - ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" - rm -f "$depfile" - # makedepend may prepend the VPATH from the source file name to the object. - # No need to regex-escape $object, excess matching of '.' is harmless. - sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" - sed '1,2d' "$tmpdepfile" | tr ' ' "$nl" | \ -## Some versions of the HPUX 10.20 sed can't process this invocation -## correctly. Breaking it into two sed invocations is a workaround. - sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" "$tmpdepfile".bak - ;; - -cpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - # Remove '-o $object'. - IFS=" " - for arg - do - case $arg in - -o) - shift - ;; - $object) - shift - ;; - *) - set fnord "$@" "$arg" - shift # fnord - shift # $arg - ;; - esac - done - - "$@" -E | - sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ - -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | - sed '$ s: \\$::' > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - cat < "$tmpdepfile" >> "$depfile" - sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvisualcpp) - # Important note: in order to support this mode, a compiler *must* - # always write the preprocessed file to stdout. - "$@" || exit $? - - # Remove the call to Libtool. - if test "$libtool" = yes; then - while test "X$1" != 'X--mode=compile'; do - shift - done - shift - fi - - IFS=" " - for arg - do - case "$arg" in - -o) - shift - ;; - $object) - shift - ;; - "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") - set fnord "$@" - shift - shift - ;; - *) - set fnord "$@" "$arg" - shift - shift - ;; - esac - done - "$@" -E 2>/dev/null | - sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" - rm -f "$depfile" - echo "$object : \\" > "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" - echo "$tab" >> "$depfile" - sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" - rm -f "$tmpdepfile" - ;; - -msvcmsys) - # This case exists only to let depend.m4 do its work. It works by - # looking at the text of this script. This case will never be run, - # since it is checked for above. - exit 1 - ;; - -none) - exec "$@" - ;; - -*) - echo "Unknown depmode $depmode" 1>&2 - exit 1 - ;; -esac - -exit 0 - -# Local Variables: -# mode: shell-script -# sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/config/install-sh b/config/install-sh deleted file mode 100755 index a9244eb0..00000000 --- a/config/install-sh +++ /dev/null @@ -1,527 +0,0 @@ -#!/bin/sh -# install - install a program, script, or datafile - -scriptversion=2011-01-19.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 - # Protect names problematic for `test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - 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 - # Protect names problematic for `test' and other utilities. - case $dst_arg in - -* | [=\(\)!]) dst_arg=./$dst_arg;; - esac - 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 - do_exit='(exit $ret); exit $ret' - trap "ret=129; $do_exit" 1 - trap "ret=130; $do_exit" 2 - trap "ret=141; $do_exit" 13 - trap "ret=143; $do_exit" 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 problematic for `test' and other utilities. - 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 - - # 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 X"$d" = X && 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/config/m4/.gitignore b/config/m4/.gitignore new file mode 100644 index 00000000..60355628 --- /dev/null +++ b/config/m4/.gitignore @@ -0,0 +1,2 @@ +libtool.m4 +lt*.m4 \ No newline at end of file diff --git a/config/missing b/config/missing deleted file mode 100755 index 86a8fc31..00000000 --- a/config/missing +++ /dev/null @@ -1,331 +0,0 @@ -#! /bin/sh -# Common stub for a few missing GNU programs while installing. - -scriptversion=2012-01-06.13; # UTC - -# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, -# 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. -# Originally by Fran,cois Pinard , 1996. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program. If not, 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. - -if test $# -eq 0; then - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 -fi - -run=: -sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' -sed_minuso='s/.* -o \([^ ]*\).*/\1/p' - -# In the cases where this matters, `missing' is being run in the -# srcdir already. -if test -f configure.ac; then - configure_ac=configure.ac -else - configure_ac=configure.in -fi - -msg="missing on your system" - -case $1 in ---run) - # Try to run requested program, and just exit if it succeeds. - run= - shift - "$@" && exit 0 - # Exit code 63 means version mismatch. This often happens - # when the user try to use an ancient version of a tool on - # a file that requires a minimum version. In this case we - # we should proceed has if the program had been absent, or - # if --run hadn't been passed. - if test $? = 63; then - run=: - msg="probably too old" - fi - ;; - - -h|--h|--he|--hel|--help) - echo "\ -$0 [OPTION]... PROGRAM [ARGUMENT]... - -Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an -error status if there is no known handling for PROGRAM. - -Options: - -h, --help display this help and exit - -v, --version output version information and exit - --run try to run the given command, and emulate it if it fails - -Supported PROGRAM values: - aclocal touch file \`aclocal.m4' - autoconf touch file \`configure' - autoheader touch file \`config.h.in' - autom4te touch the output file, or create a stub one - automake touch all \`Makefile.in' files - bison create \`y.tab.[ch]', if possible, from existing .[ch] - flex create \`lex.yy.c', if possible, from existing .c - help2man touch the output file - lex create \`lex.yy.c', if possible, from existing .c - makeinfo touch the output file - yacc create \`y.tab.[ch]', if possible, from existing .[ch] - -Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and -\`g' are ignored when checking the name. - -Send bug reports to ." - exit $? - ;; - - -v|--v|--ve|--ver|--vers|--versi|--versio|--version) - echo "missing $scriptversion (GNU Automake)" - exit $? - ;; - - -*) - echo 1>&2 "$0: Unknown \`$1' option" - echo 1>&2 "Try \`$0 --help' for more information" - exit 1 - ;; - -esac - -# normalize program name to check for. -program=`echo "$1" | sed ' - s/^gnu-//; t - s/^gnu//; t - s/^g//; t'` - -# Now exit if we have it, but it failed. Also exit now if we -# don't have it and --version was passed (most likely to detect -# the program). This is about non-GNU programs, so use $1 not -# $program. -case $1 in - lex*|yacc*) - # Not GNU programs, they don't have --version. - ;; - - *) - if test -z "$run" && ($1 --version) > /dev/null 2>&1; then - # We have it, but it failed. - exit 1 - elif test "x$2" = "x--version" || test "x$2" = "x--help"; then - # Could not run --version or --help. This is probably someone - # running `$TOOL --version' or `$TOOL --help' to check whether - # $TOOL exists and not knowing $TOOL uses missing. - exit 1 - fi - ;; -esac - -# If it does not exist, or fails to run (possibly an outdated version), -# try to emulate it. -case $program in - aclocal*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acinclude.m4' or \`${configure_ac}'. You might want - to install the \`Automake' and \`Perl' packages. Grab them from - any GNU archive site." - touch aclocal.m4 - ;; - - autoconf*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`${configure_ac}'. You might want to install the - \`Autoconf' and \`GNU m4' packages. Grab them from any GNU - archive site." - touch configure - ;; - - autoheader*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`acconfig.h' or \`${configure_ac}'. You might want - to install the \`Autoconf' and \`GNU m4' packages. Grab them - from any GNU archive site." - files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` - test -z "$files" && files="config.h" - touch_files= - for f in $files; do - case $f in - *:*) touch_files="$touch_files "`echo "$f" | - sed -e 's/^[^:]*://' -e 's/:.*//'`;; - *) touch_files="$touch_files $f.in";; - esac - done - touch $touch_files - ;; - - automake*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. - You might want to install the \`Automake' and \`Perl' packages. - Grab them from any GNU archive site." - find . -type f -name Makefile.am -print | - sed 's/\.am$/.in/' | - while read f; do touch "$f"; done - ;; - - autom4te*) - echo 1>&2 "\ -WARNING: \`$1' is needed, but is $msg. - You might have modified some files without having the - proper tools for further handling them. - You can get \`$1' as part of \`Autoconf' from any GNU - archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo "#! /bin/sh" - echo "# Created by GNU Automake missing as a replacement of" - echo "# $ $@" - echo "exit 0" - chmod +x $file - exit 1 - fi - ;; - - bison*|yacc*) - echo 1>&2 "\ -WARNING: \`$1' $msg. You should only need it if - you modified a \`.y' file. You may need the \`Bison' package - in order for those modifications to take effect. You can get - \`Bison' from any GNU archive site." - rm -f y.tab.c y.tab.h - if test $# -ne 1; then - eval LASTARG=\${$#} - case $LASTARG in - *.y) - SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.c - fi - SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" y.tab.h - fi - ;; - esac - fi - if test ! -f y.tab.h; then - echo >y.tab.h - fi - if test ! -f y.tab.c; then - echo 'main() { return 0; }' >y.tab.c - fi - ;; - - lex*|flex*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.l' file. You may need the \`Flex' package - in order for those modifications to take effect. You can get - \`Flex' from any GNU archive site." - rm -f lex.yy.c - if test $# -ne 1; then - eval LASTARG=\${$#} - case $LASTARG in - *.l) - SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` - if test -f "$SRCFILE"; then - cp "$SRCFILE" lex.yy.c - fi - ;; - esac - fi - if test ! -f lex.yy.c; then - echo 'main() { return 0; }' >lex.yy.c - fi - ;; - - help2man*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a dependency of a manual page. You may need the - \`Help2man' package in order for those modifications to take - effect. You can get \`Help2man' from any GNU archive site." - - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -f "$file"; then - touch $file - else - test -z "$file" || exec >$file - echo ".ab help2man is required to generate this page" - exit $? - fi - ;; - - makeinfo*) - echo 1>&2 "\ -WARNING: \`$1' is $msg. You should only need it if - you modified a \`.texi' or \`.texinfo' file, or any other file - indirectly affecting the aspect of the manual. The spurious - call might also be the consequence of using a buggy \`make' (AIX, - DU, IRIX). You might want to install the \`Texinfo' package or - the \`GNU make' package. Grab either from any GNU archive site." - # The file to touch is that specified with -o ... - file=`echo "$*" | sed -n "$sed_output"` - test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` - if test -z "$file"; then - # ... or it is the one specified with @setfilename ... - infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` - file=`sed -n ' - /^@setfilename/{ - s/.* \([^ ]*\) *$/\1/ - p - q - }' $infile` - # ... or it is derived from the source name (dir/f.texi becomes f.info) - test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info - fi - # If the file does not exist, the user really needs makeinfo; - # let's fail without touching anything. - test -f $file || exit 1 - touch $file - ;; - - *) - echo 1>&2 "\ -WARNING: \`$1' is needed, and is $msg. - You might have modified some files without having the - proper tools for further handling them. Check the \`README' file, - it often tells you about the needed prerequisites for installing - this package. You may also peek at any GNU archive site, in case - some other package would contain this missing \`$1' program." - exit 1 - ;; -esac - -exit 0 - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/config/ylwrap b/config/ylwrap deleted file mode 100755 index 92536350..00000000 --- a/config/ylwrap +++ /dev/null @@ -1,226 +0,0 @@ -#! /bin/sh -# ylwrap - wrapper for lex/yacc invocations. - -scriptversion=2011-08-25.18; # UTC - -# Copyright (C) 1996, 1997, 1998, 1999, 2001, 2002, 2003, 2004, 2005, -# 2007, 2009, 2010, 2011 Free Software Foundation, Inc. -# -# Written by Tom Tromey . -# -# 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 . - -# 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 or send patches to -# . - -case "$1" in - '') - echo "$0: No files given. Try \`$0 --help' for more information." 1>&2 - exit 1 - ;; - --basedir) - basedir=$2 - shift 2 - ;; - -h|--h*) - cat <<\EOF -Usage: ylwrap [--help|--version] INPUT [OUTPUT DESIRED]... -- PROGRAM [ARGS]... - -Wrapper for lex/yacc invocations, renaming files as desired. - - INPUT is the input file - OUTPUT is one file PROG generates - DESIRED is the file we actually want instead of OUTPUT - PROGRAM is program to run - ARGS are passed to PROG - -Any number of OUTPUT,DESIRED pairs may be used. - -Report bugs to . -EOF - exit $? - ;; - -v|--v*) - echo "ylwrap $scriptversion" - exit $? - ;; -esac - - -# The input. -input="$1" -shift -case "$input" in - [\\/]* | ?:[\\/]*) - # Absolute path; do nothing. - ;; - *) - # Relative path. Make it absolute. - input="`pwd`/$input" - ;; -esac - -pairlist= -while test "$#" -ne 0; do - if test "$1" = "--"; then - shift - break - fi - pairlist="$pairlist $1" - shift -done - -# The program to run. -prog="$1" -shift -# Make any relative path in $prog absolute. -case "$prog" in - [\\/]* | ?:[\\/]*) ;; - *[\\/]*) prog="`pwd`/$prog" ;; -esac - -# FIXME: add hostname here for parallel makes that run commands on -# other machines. But that might take us over the 14-char limit. -dirname=ylwrap$$ -do_exit="cd '`pwd`' && rm -rf $dirname > /dev/null 2>&1;"' (exit $ret); exit $ret' -trap "ret=129; $do_exit" 1 -trap "ret=130; $do_exit" 2 -trap "ret=141; $do_exit" 13 -trap "ret=143; $do_exit" 15 -mkdir $dirname || exit 1 - -cd $dirname - -case $# in - 0) "$prog" "$input" ;; - *) "$prog" "$@" "$input" ;; -esac -ret=$? - -if test $ret -eq 0; then - set X $pairlist - shift - first=yes - # Since DOS filename conventions don't allow two dots, - # the DOS version of Bison writes out y_tab.c instead of y.tab.c - # and y_tab.h instead of y.tab.h. Test to see if this is the case. - y_tab_nodot="no" - if test -f y_tab.c || test -f y_tab.h; then - y_tab_nodot="yes" - fi - - # The directory holding the input. - input_dir=`echo "$input" | sed -e 's,\([\\/]\)[^\\/]*$,\1,'` - # Quote $INPUT_DIR so we can use it in a regexp. - # FIXME: really we should care about more than `.' and `\'. - input_rx=`echo "$input_dir" | sed 's,\\\\,\\\\\\\\,g;s,\\.,\\\\.,g'` - - while test "$#" -ne 0; do - from="$1" - # Handle y_tab.c and y_tab.h output by DOS - if test $y_tab_nodot = "yes"; then - if test $from = "y.tab.c"; then - from="y_tab.c" - else - if test $from = "y.tab.h"; then - from="y_tab.h" - fi - fi - fi - if test -f "$from"; then - # If $2 is an absolute path name, then just use that, - # otherwise prepend `../'. - case "$2" in - [\\/]* | ?:[\\/]*) target="$2";; - *) target="../$2";; - esac - - # We do not want to overwrite a header file if it hasn't - # changed. This avoid useless recompilations. However the - # parser itself (the first file) should always be updated, - # because it is the destination of the .y.c rule in the - # Makefile. Divert the output of all other files to a temporary - # file so we can compare them to existing versions. - if test $first = no; then - realtarget="$target" - target="tmp-`echo $target | sed s/.*[\\/]//g`" - fi - # Edit out `#line' or `#' directives. - # - # We don't want the resulting debug information to point at - # an absolute srcdir; it is better for it to just mention the - # .y file with no path. - # - # We want to use the real output file name, not yy.lex.c for - # instance. - # - # We want the include guards to be adjusted too. - FROM=`echo "$from" | sed \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ - -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` - TARGET=`echo "$2" | sed \ - -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'\ - -e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'` - - sed -e "/^#/!b" -e "s,$input_rx,," -e "s,$from,$2," \ - -e "s,$FROM,$TARGET," "$from" >"$target" || ret=$? - - # Check whether header files must be updated. - if test $first = no; then - if test -f "$realtarget" && cmp -s "$realtarget" "$target"; then - echo "$2" is unchanged - rm -f "$target" - else - echo updating "$2" - mv -f "$target" "$realtarget" - fi - fi - else - # A missing file is only an error for the first file. This - # is a blatant hack to let us support using "yacc -d". If -d - # is not specified, we don't want an error when the header - # file is "missing". - if test $first = yes; then - ret=1 - fi - fi - shift - shift - first=no - done -else - ret=$? -fi - -# Remove the directory. -cd .. -rm -rf $dirname - -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/configure.ac b/configure.ac index d6d2d386..2f777af4 100644 --- a/configure.ac +++ b/configure.ac @@ -10,7 +10,9 @@ AC_PROG_CC AC_PROG_CC_STDC AC_PROG_CPP_WERROR AC_PROG_YACC - +AC_OBJEXT +AC_EXEEXT +LT_INIT([shared static win32-dll]) AM_PROG_CC_C_O dnl couldn't use AM_PROG_LEX as it doesn't support header files like the @@ -64,8 +66,7 @@ EOF AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno]) AC_SUBST([BUNDLER], ["$bundle_cmd"]) -dnl AC_CONFIG_MACRO_DIR([m4]) -AC_CONFIG_HEADERS(config.h) +AC_CONFIG_MACRO_DIR([config/m4]) AC_CONFIG_FILES([Makefile]) AC_OUTPUT diff --git a/execute.c b/execute.c index 3a5512aa..4b05d793 100644 --- a/execute.c +++ b/execute.c @@ -3,17 +3,14 @@ #include #include -#include "execute.h" - #include "exec_stack.h" -#include "opcode.h" #include "bytecode.h" #include "jv_alloc.h" #include "jq_parser.h" #include "locfile.h" #include "jv.h" -#include "jv_aux.h" +#include "jq.h" #include "parser.h" #include "builtin.h" @@ -242,6 +239,8 @@ static void jq_reset(jq_state *jq) { } + + void print_error(jv value) { assert(!jv_is_valid(value)); jv msg = jv_invalid_get_msg(value); @@ -602,12 +601,26 @@ jv jq_next(jq_state *jq) { case CALL_BUILTIN: { int nargs = *pc++; jv top = stack_pop(jq); - cfunc_input[0] = top; + jv* in = cfunc_input; + in[0] = top; for (int i = 1; i < nargs; i++) { - cfunc_input[i] = stack_pop(jq); + in[i] = stack_pop(jq); } - struct cfunction* func = &frame_current(jq)->bc->globals->cfunctions[*pc++]; - top = cfunction_invoke(func, cfunc_input); + struct cfunction* function = &frame_current(jq)->bc->globals->cfunctions[*pc++]; + 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); + switch (function->nargs) { + case 1: top = ((func_1)function->fptr)(in[0]); break; + case 2: top = ((func_2)function->fptr)(in[0], in[1]); break; + case 3: top = ((func_3)function->fptr)(in[0], in[1], in[2]); break; + case 4: top = ((func_4)function->fptr)(in[0], in[1], in[2], in[3]); break; + case 5: top = ((func_5)function->fptr)(in[0], in[1], in[2], in[3], in[4]); break; + default: return jv_invalid_with_msg(jv_string("Function takes too many arguments")); + } + if (jv_is_valid(top)) { stack_push(jq, top); } else { diff --git a/execute.h b/jq.h similarity index 71% rename from execute.h rename to jq.h index 0cb0b36c..e35845c6 100644 --- a/execute.h +++ b/jq.h @@ -1,21 +1,18 @@ -#ifndef EXECUTE_H -#define EXECUTE_H -#include "bytecode.h" +#ifndef _JQ_H_ +#define _JQ_H_ -typedef struct jq_state jq_state; - -int jq_compile(jq_state *, const char* str); - -/* args must be an array of the form [{name:"foo", value:"thing"}, {name:"bar",value:3}] */ -int jq_compile_args(jq_state *, const char* str, jv args); +#include enum {JQ_DEBUG_TRACE = 1}; +typedef struct jq_state jq_state; jq_state *jq_init(void); void jq_set_nomem_handler(jq_state *, void (*)(void *), void *); +int jq_compile(jq_state *, const char* str); +int jq_compile_args(jq_state *, const char* str, jv args); +void jq_dump_disassembly(jq_state *, int); void jq_start(jq_state *, jv value, int flags); jv jq_next(jq_state *); void jq_teardown(jq_state **); -void jq_dump_disassembly(jq_state *, int); -#endif +#endif /* !_JQ_H_ */ diff --git a/jq_parser.h b/jq_parser.h index 8dc37163..809ace06 100644 --- a/jq_parser.h +++ b/jq_parser.h @@ -1,5 +1,7 @@ #ifndef JQ_PARSER_H #define JQ_PARSER_H +#include "locfile.h" +#include "compile.h" int jq_parse(struct locfile* source, block* answer); int jq_parse_library(struct locfile* locations, block* answer); diff --git a/jq_test.c b/jq_test.c index f84cea9f..f10a258a 100644 --- a/jq_test.c +++ b/jq_test.c @@ -3,7 +3,7 @@ #include #include #include "jv.h" -#include "execute.h" +#include "jq.h" static void jv_test(); static void run_jq_tests(); @@ -125,9 +125,9 @@ static void jv_test() { jv_free(a2); - assert(a.val.nontrivial.ptr->count == 1); + assert(jv_get_refcnt(a) == 1); a = jv_array_append(a, jv_copy(a)); - assert(a.val.nontrivial.ptr->count == 1); + assert(jv_get_refcnt(a) == 1); assert(jv_array_length(jv_copy(a)) == 2); assert(jv_number_value(jv_array_get(jv_copy(a), 0)) == 42); diff --git a/jv.c b/jv.c index 0c69a568..3197f313 100644 --- a/jv.c +++ b/jv.c @@ -14,6 +14,11 @@ * Internal refcounting helpers */ +typedef struct jv_refcnt { + size_t count; +} jv_refcnt; + + static void jvp_refcnt_init(jv_nontrivial* c) { c->ptr->count = 1; } @@ -576,7 +581,7 @@ int jv_string_length_codepoints(jv j) { return len; } -uint32_t jv_string_hash(jv j) { +unsigned long jv_string_hash(jv j) { assert(jv_get_kind(j) == JV_KIND_STRING); uint32_t hash = jvp_string_hash(jvp_string_ptr(&j.val.nontrivial)); jv_free(j); diff --git a/jv.h b/jv.h index 47da5d9d..a9010211 100644 --- a/jv.h +++ b/jv.h @@ -1,12 +1,6 @@ #ifndef JV_H #define JV_H -#include -#include -#include - - - typedef enum { JV_KIND_INVALID, JV_KIND_NULL, @@ -18,12 +12,9 @@ typedef enum { JV_KIND_OBJECT } jv_kind; -typedef struct { - size_t count; -} jv_refcnt; - +struct jv_refcnt; typedef struct{ - jv_refcnt* ptr; + struct jv_refcnt* ptr; int i[2]; } jv_nontrivial; @@ -47,6 +38,8 @@ static int jv_is_valid(jv x) { return jv_get_kind(x) != JV_KIND_INVALID; } jv jv_copy(jv); void jv_free(jv); +int jv_get_refcnt(jv); + int jv_equal(jv, jv); int jv_contains(jv, jv); @@ -84,7 +77,7 @@ jv jv_string(const char*); jv jv_string_sized(const char*, int); int jv_string_length_bytes(jv); int jv_string_length_codepoints(jv); -uint32_t jv_string_hash(jv); +unsigned long jv_string_hash(jv); const char* jv_string_value(jv); jv jv_string_concat(jv, jv); jv jv_string_fmt(const char*, ...); @@ -124,13 +117,27 @@ jv jv_dump_string(jv, int flags); jv jv_parse(const char* string); jv jv_parse_sized(const char* string, int length); +typedef void (*jv_nomem_handler_f)(void *); +void jv_nomem_handler(jv_nomem_handler_f, void *); +jv jv_load_file(const char *, int); +struct jv_parser; +struct jv_parser* jv_parser_new(); +void jv_parser_set_buf(struct jv_parser*, const char*, int, int); +jv jv_parser_next(struct jv_parser*); +void jv_parser_free(struct jv_parser*); - - - - +jv jv_get(jv, jv); +jv jv_set(jv, jv, jv); +jv jv_has(jv, jv); +jv jv_setpath(jv, jv, jv); +jv jv_getpath(jv, jv); +jv jv_delpaths(jv, jv); +jv jv_keys(jv /*object or array*/); +int jv_cmp(jv, jv); +jv jv_group(jv, jv); +jv jv_sort(jv, jv); #endif diff --git a/jv_alloc.h b/jv_alloc.h index cbcf9548..91190825 100644 --- a/jv_alloc.h +++ b/jv_alloc.h @@ -2,6 +2,7 @@ #define JV_ALLOC_H #include +#include "jv.h" #ifndef NDEBUG extern volatile char jv_mem_uninitialised; @@ -14,8 +15,6 @@ static void jv_mem_invalidate(void* mem, size_t n) { #endif } -typedef void (*jv_nomem_handler_f)(void *); -void jv_nomem_handler(jv_nomem_handler_f, void *); void* jv_mem_alloc(size_t); void* jv_mem_alloc_unguarded(size_t); void jv_mem_free(void*); diff --git a/jv_aux.c b/jv_aux.c index 0c8cd8b7..b73c9057 100644 --- a/jv_aux.c +++ b/jv_aux.c @@ -1,6 +1,6 @@ -#include "jv_aux.h" #include #include +#include #include "jv_alloc.h" static int parse_slice(jv array, jv slice, int* pstart, int* pend) { diff --git a/jv_aux.h b/jv_aux.h deleted file mode 100644 index 5a47b70c..00000000 --- a/jv_aux.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef JV_AUX_H -#define JV_AUX_H - -#include "jv.h" - -jv jv_get(jv t, jv k); -jv jv_set(jv t, jv k, jv v); -jv jv_has(jv t, jv k); -jv jv_setpath(jv root, jv path, jv value); -jv jv_getpath(jv root, jv path); -jv jv_delpaths(jv root, jv paths); - -jv jv_keys(jv /*object or array*/); -int jv_cmp(jv, jv); - -jv jv_group(jv objects, jv keys); -jv jv_sort(jv objects, jv keys); - - -#endif diff --git a/jv_file.c b/jv_file.c index 7532a025..54ed36be 100644 --- a/jv_file.c +++ b/jv_file.c @@ -4,12 +4,10 @@ #include #include #include "jv.h" -#include "jv_aux.h" -#include "jv_parse.h" jv jv_load_file(const char* filename, int raw) { FILE* file = fopen(filename, "r"); - struct jv_parser parser; + struct jv_parser* parser; jv data; if (!file) { return jv_invalid_with_msg(jv_string_fmt("Could not open %s: %s", @@ -20,7 +18,7 @@ jv jv_load_file(const char* filename, int raw) { data = jv_string(""); } else { data = jv_array(); - jv_parser_init(&parser); + parser = jv_parser_new(); } while (!feof(file) && !ferror(file)) { char buf[4096]; @@ -28,15 +26,15 @@ jv jv_load_file(const char* filename, int raw) { if (raw) { data = jv_string_concat(data, jv_string_sized(buf, (int)n)); } else { - jv_parser_set_buf(&parser, buf, n, !feof(file)); + jv_parser_set_buf(parser, buf, n, !feof(file)); jv value; - while (jv_is_valid((value = jv_parser_next(&parser)))) + while (jv_is_valid((value = jv_parser_next(parser)))) data = jv_array_append(data, value); jv_free(value); } } if (!raw) - jv_parser_free(&parser); + jv_parser_free(parser); int badread = ferror(file); fclose(file); if (badread) { diff --git a/jv_file.h b/jv_file.h deleted file mode 100644 index a4ae76c9..00000000 --- a/jv_file.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef JV_FILE_H -#define JV_FILE_H - -#include "jv.h" - -jv jv_load_file(const char *, int); - -#endif diff --git a/jv_parse.c b/jv_parse.c index a8617e06..cc1e7b96 100644 --- a/jv_parse.c +++ b/jv_parse.c @@ -1,11 +1,12 @@ #include #include #include +#include #include "jv.h" #include "jv_dtoa.h" -#include "jv_parse.h" #include "jv_unicode.h" #include "jv_alloc.h" +#include "jv_dtoa.h" typedef const char* presult; @@ -16,7 +17,35 @@ typedef const char* presult; #define pfunc presult #endif -void jv_parser_init(struct jv_parser* p) { +struct jv_parser { + const char* curr_buf; + int curr_buf_length; + int curr_buf_pos; + int curr_buf_is_partial; + unsigned bom_strip_position; + + jv* stack; + int stackpos; + int stacklen; + jv next; + + char* tokenbuf; + int tokenpos; + int tokenlen; + + int line, column; + + struct dtoa_context dtoa; + + enum { + JV_PARSER_NORMAL, + JV_PARSER_STRING, + JV_PARSER_STRING_ESCAPE + } st; +}; + + +static void parser_init(struct jv_parser* p) { p->stack = 0; p->stacklen = p->stackpos = 0; p->next = jv_invalid(); @@ -31,7 +60,7 @@ void jv_parser_init(struct jv_parser* p) { jvp_dtoa_context_init(&p->dtoa); } -void jv_parser_free(struct jv_parser* p) { +static void parser_free(struct jv_parser* p) { jv_free(p->next); for (int i=0; istackpos; i++) jv_free(p->stack[i]); @@ -341,6 +370,17 @@ static pfunc scan(struct jv_parser* p, char ch, jv* out) { return answer; } +struct jv_parser* jv_parser_new() { + struct jv_parser* p = jv_mem_alloc(sizeof(struct jv_parser)); + parser_init(p); + return p; +} + +void jv_parser_free(struct jv_parser* p) { + parser_free(p); + jv_mem_free(p); +} + static const unsigned char UTF8_BOM[] = {0xEF,0xBB,0xBF}; void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial) { @@ -404,7 +444,7 @@ jv jv_parser_next(struct jv_parser* p) { jv jv_parse_sized(const char* string, int length) { struct jv_parser parser; - jv_parser_init(&parser); + parser_init(&parser); jv_parser_set_buf(&parser, string, length, 0); jv value = jv_parser_next(&parser); if (jv_is_valid(value)) { @@ -429,7 +469,7 @@ jv jv_parse_sized(const char* string, int length) { jv_free(value); value = jv_invalid_with_msg(jv_string("Expected JSON value")); } - jv_parser_free(&parser); + parser_free(&parser); if (!jv_is_valid(value) && jv_invalid_has_msg(jv_copy(value))) { jv msg = jv_invalid_get_msg(value); diff --git a/jv_parse.h b/jv_parse.h deleted file mode 100644 index 1d538c12..00000000 --- a/jv_parse.h +++ /dev/null @@ -1,37 +0,0 @@ -#ifndef JV_PARSE_H -#define JV_PARSE_H -#include "jv_dtoa.h" -struct jv_parser { - const char* curr_buf; - int curr_buf_length; - int curr_buf_pos; - int curr_buf_is_partial; - unsigned bom_strip_position; - - jv* stack; - int stackpos; - int stacklen; - jv next; - - char* tokenbuf; - int tokenpos; - int tokenlen; - - int line, column; - - struct dtoa_context dtoa; - - enum { - JV_PARSER_NORMAL, - JV_PARSER_STRING, - JV_PARSER_STRING_ESCAPE - } st; -}; - -void jv_parser_init(struct jv_parser* p); -void jv_parser_free(struct jv_parser* p); - -void jv_parser_set_buf(struct jv_parser* p, const char* buf, int length, int is_partial); - -jv jv_parser_next(struct jv_parser* p); -#endif diff --git a/jv_print.c b/jv_print.c index f8edf335..da90abfb 100644 --- a/jv_print.c +++ b/jv_print.c @@ -2,10 +2,10 @@ #include #include #include +#include #include "jv_dtoa.h" #include "jv_unicode.h" -#include "jv_aux.h" #define ESC "\033" #define COL(c) (ESC "[" c "m") diff --git a/lexer.l b/lexer.l index 16d0505b..3c318bce 100644 --- a/lexer.l +++ b/lexer.l @@ -1,4 +1,5 @@ %{ +#include #include "jv_alloc.h" #include "compile.h" diff --git a/main.c b/main.c index 3f82b460..c365a3c2 100644 --- a/main.c +++ b/main.c @@ -6,10 +6,7 @@ #include #include "compile.h" #include "jv.h" -#include "jv_file.h" -#include "jv_parse.h" -#include "execute.h" -#include "config.h" /* Autoconf generated header file */ +#include "jq.h" #include "jv_alloc.h" #include "version.h" @@ -260,8 +257,7 @@ int main(int argc, char* argv[]) { slurped = jv_array(); } } - struct jv_parser parser; - jv_parser_init(&parser); + struct jv_parser* parser = jv_parser_new(); char buf[4096]; while (read_more(buf, sizeof(buf))) { if (options & RAW_INPUT) { @@ -275,9 +271,9 @@ int main(int argc, char* argv[]) { } } } else { - jv_parser_set_buf(&parser, buf, strlen(buf), !feof(stdin)); + jv_parser_set_buf(parser, buf, strlen(buf), !feof(stdin)); jv value; - while (jv_is_valid((value = jv_parser_next(&parser)))) { + while (jv_is_valid((value = jv_parser_next(parser)))) { if (options & SLURP) { slurped = jv_array_append(slurped, value); } else { @@ -295,7 +291,7 @@ int main(int argc, char* argv[]) { } } } - jv_parser_free(&parser); + jv_parser_free(parser); if (ret != 0) goto out; if (options & SLURP) { diff --git a/opcode.c b/opcode.c deleted file mode 100644 index 4e785b8f..00000000 --- a/opcode.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "opcode.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; - } -} diff --git a/opcode.h b/opcode.h deleted file mode 100644 index ee956e27..00000000 --- a/opcode.h +++ /dev/null @@ -1,41 +0,0 @@ -#ifndef OPCODE_H -#define OPCODE_H -#include - -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); - -#endif diff --git a/parser.y b/parser.y index 8d3be642..5bcaf8d1 100644 --- a/parser.y +++ b/parser.y @@ -1,6 +1,7 @@ %{ #include #include +#include #include "compile.h" #include "jv_alloc.h" #define YYMALLOC jv_mem_alloc diff --git a/gen_utf8_tables.py b/scripts/gen_utf8_tables.py similarity index 100% rename from gen_utf8_tables.py rename to scripts/gen_utf8_tables.py diff --git a/setup.sh b/setup.sh index 50cc4eea..c63fc9cd 100755 --- a/setup.sh +++ b/setup.sh @@ -26,6 +26,7 @@ else autoreconf --install ./configure --prefix=/opt/junk make check + [ -d tmp ] && mv tmp tmp- mkdir tmp make DESTDIR=./tmp install make distcheck