diff options
author | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-11 15:21:23 +0100 |
---|---|---|
committer | Stephen Dolan <mu@netsoc.tcd.ie> | 2013-05-11 15:21:23 +0100 |
commit | 7ca5127fcc74ec2c58c1ad01de57d1c5ec00b827 (patch) | |
tree | 07985ebf2a44abb7dd0193e7a48e5c141f8004c4 | |
parent | 7813f363a20817c8b0429f53e4740d6ed852e527 (diff) | |
parent | 4b1b9c219a37488e4b113e87216da121671b2297 (diff) |
Merge branch 'autotools'
-rw-r--r-- | .gitignore | 27 | ||||
-rw-r--r-- | AUTHORS | 6 | ||||
-rw-r--r-- | Makefile | 142 | ||||
-rw-r--r-- | Makefile.am | 123 | ||||
l--------- | README | 1 | ||||
-rw-r--r-- | README.md | 15 | ||||
-rw-r--r-- | VERSION | 1 | ||||
-rw-r--r-- | build/.gitignore | 1 | ||||
-rw-r--r-- | builtin.c | 2 | ||||
-rw-r--r-- | config.h.in | 32 | ||||
-rwxr-xr-x | config/compile | 343 | ||||
-rwxr-xr-x | config/depcomp | 708 | ||||
-rwxr-xr-x | config/install-sh | 527 | ||||
-rwxr-xr-x | config/missing | 331 | ||||
-rwxr-xr-x | config/ylwrap | 226 | ||||
-rw-r--r-- | configure.ac | 66 | ||||
-rw-r--r-- | docs/README.md | 25 | ||||
-rw-r--r-- | docs/Rakefile | 35 | ||||
-rw-r--r-- | docs/content/3.manual/manual.yml | 4 | ||||
-rw-r--r-- | docs/default_manpage.md | 22 | ||||
-rw-r--r-- | docs/site.yml | 6 | ||||
-rw-r--r-- | execute.c | 3 | ||||
-rw-r--r-- | gen_utf8_tables.py | 2 | ||||
-rw-r--r-- | jq.1.default | 39 | ||||
-rw-r--r-- | jq.spec | 65 | ||||
-rw-r--r-- | jq_parser.h (renamed from parser.h) | 4 | ||||
-rw-r--r-- | jq_test.c | 21 | ||||
-rw-r--r-- | jv_unicode.c | 2 | ||||
-rw-r--r-- | jv_utf8_tables.h | 35 | ||||
-rw-r--r-- | lexer.l | 2 | ||||
-rw-r--r-- | main.c | 12 | ||||
-rw-r--r-- | parser.y | 2 | ||||
-rwxr-xr-x | scripts/crosscompile | 31 | ||||
-rwxr-xr-x | setup.sh | 32 | ||||
-rw-r--r-- | tests/all.test (renamed from testdata) | 0 | ||||
-rwxr-xr-x | tests/run | 3 |
36 files changed, 2710 insertions, 186 deletions
@@ -1,13 +1,28 @@ *.o *~ -# Autogenerated -*.gen.* - -jq_test -build jq jq.1 # Something delightfully recursive happens otherwise -docs/content/2.download/source/*
\ No newline at end of file +docs/content/2.download/source/* + +# Autogenerated +lexer.c +lexer.h +parser.c +parser.h + +# Autotools junk +.deps +*.log +stamp-h1 +config.log +config.status +autom4te.cache +config.h +Makefile +jq-*.tar.gz +configure +aclocal.m4 +Makefile.in diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 00000000..98fdf672 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,6 @@ +Created By: +Stephen Dolan <mu@netsoc.tcd.ie> + +Contributions by +Anthony Shortland <anthony.shortland@me.com> - rpmbuild target +Lee Thompson <stagr.lee@gmail.com> - autoconf stuff diff --git a/Makefile b/Makefile deleted file mode 100644 index 9b3b6631..00000000 --- a/Makefile +++ /dev/null @@ -1,142 +0,0 @@ -CC=gcc -CFLAGS=-Wextra -Wall -Wno-missing-field-initializers -Wno-unused-parameter -std=gnu99 -ggdb -Wno-unused-function $(EXTRA_CFLAGS) - -prefix=/usr/local -mandir=$(prefix)/share/man - - -.PHONY: all clean releasedep tarball install uninstall test releasetag -all: jq - -lexer.gen.c: lexer.l - flex -o lexer.gen.c --header-file=lexer.gen.h lexer.l -lexer.gen.h: lexer.gen.c - -parser.gen.c: parser.y lexer.gen.h - bison -W -d parser.y -v --report-file=parser.gen.info -o $@ -parser.gen.h: parser.gen.c - -jv_utf8_tables.gen.h: gen_utf8_tables.py - python $^ > $@ -jv_unicode.c: jv_utf8_tables.gen.h - -version.gen.h: VERSION - sed 's/.*/#define JQ_VERSION "&"/' $^ > $@ -main.c: version.gen.h - -JQ_SRC=parser.gen.c lexer.gen.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_alloc.c - - -jq: $(JQ_SRC) main.c jq_test.c - $(CC) $(CFLAGS) $(CFLAGS_OPT) -o $@ $^ - -test: jq - valgrind --error-exitcode=1 -q --leak-check=full ./jq --run-tests >/dev/null - -LIBRARIES=libjq -BINARIES=jq -PLATFORMS=linux32 linux64 osx32 osx64 win32 win64 - -build/linux32%: CC='x86_64-linux-gnu-gcc -m32' -build/linux64%: CC='x86_64-linux-gnu-gcc -m64' - -# OS X cross compilers can be gotten from -# https://launchpad.net/~flosoft/+archive/cross-apple -build/osx32%: CC='i686-apple-darwin10-gcc -m32' -build/osx64%: CC='i686-apple-darwin10-gcc -m64' - -# On Debian, you can get windows compilers in the -# gcc-mingw-w64-i686 and gcc-mingw-w64-x86-64 packages. -build/win32%: CC='i686-w64-mingw32-gcc -m32' EXTRA_CFLAGS=-DJQ_DEFAULT_ENABLE_COLOR=0 -build/win64%: CC='x86_64-w64-mingw32-gcc -m64' EXTRA_CFLAGS=-DJQ_DEFAULT_ENABLE_COLOR=0 - -BIN_SUFFIX_win32 = .exe -BIN_SUFFIX_win64 = .exe -LIB_SUFFIX_win32 = .dll -LIB_SUFFIX_win64 = .dll - -LIB_SUFFIX_linux32 = .so -LIB_SUFFIX_linux64 = .so - -LIB_SUFFIX_osx32 = .so -LIB_SUFFIX_osx64 = .so - -ALL_BINARIES=\ - $(foreach platform, $(PLATFORMS), \ - $(foreach binary, $(BINARIES), \ - build/$(platform)/$(binary)$(BIN_SUFFIX_$(platform)))) - -$(ALL_BINARIES): build/%: - mkdir -p $(@D) - echo $(dir $*) - make -B $(BINARIES) CC=$(CC) - $(foreach binary, $(BINARIES), cp $(binary) $(@D)/$(binary)$(suffix $*);) - -libjq: CFLAGS += -fPIC -libjq: $(JQ_SRC) - $(CC) -shared -Wl,-soname,libjq.so.1 $(CFLAGS) $(CFLAGS_OPT) -o $@ $^ - -ALL_LIBRARIES=\ - $(foreach platform, $(PLATFORMS), \ - $(foreach library, $(LIBRARIES), \ - build/$(platform)/$(library)$(LIB_SUFFIX_$(platform)))) - -$(ALL_LIBRARIES): build/%: - mkdir -p $(@D) - echo $(dir $*) - make -B $(LIBRARIES) CC=$(CC) - $(foreach library, $(LIBRARIES), cp $(library) $(@D)/$(library)$(suffix $*);) - -binaries: $(ALL_BINARIES) -libraries: $(ALL_LIBRARIES) - -clean: - rm -rf build - rm -f $(LIBRARIES) $(BINARIES) *.gen.* - -releasedep: lexer.gen.c parser.gen.c jv_utf8_tables.gen.h - -releasetag: - git tag -s "jq-$$(cat VERSION)" -m "jq release $$(cat VERSION)" - -docs/content/2.download/source/jq.tgz: jq - mkdir -p `dirname $@` - tar -czvf $@ `git ls-files; ls *.gen.*` - -tarball: docs/content/2.download/source/jq.tgz - -jq.1: docs/content/3.manual/manual.yml - ( cd docs; bundle exec rake manpage; ) > $@ - -install: jq jq.1 libjq - install -d -m 0755 $(prefix)/bin - install -d -m 0755 $(prefix)/lib - install -d -m 0755 $(prefix)/include - install -d -m 0755 $(prefix)/include/jq - install -m 0755 jq $(prefix)/bin - ln libjq libjq.so.1 - install -m 0755 execute.h $(prefix)/include/jq - install -m 0755 compile.h $(prefix)/include/jq - install -m 0755 jv.h $(prefix)/include/jq - install -m 0755 jv_parse.h $(prefix)/include/jq - install -m 0755 jv_alloc.h $(prefix)/include/jq - install -m 0755 libjq.so.1 $(prefix)/bin - install -m 0644 execute.h $(prefix)/bin - install -d -m 0755 $(mandir)/man1 - install -m 0644 jq.1 $(mandir)/man1 - -uninstall: - rm -vf $(prefix)/bin/jq - rm -vf $(prefix)/lib/libjq.so.1 - rm -vf $(mandir)/man1/jq.1 - - -www: docs/output www_binaries - -docs/output: - cd docs; rake build - -www_binaries: docs/output binaries - $(foreach platform, $(PLATFORMS), \ - mkdir -p docs/output/download/$(platform); \ - cp build/$(platform)/* docs/output/download/$(platform)/; ) diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..be8e9140 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,123 @@ +### C source files to be built and distributed. + +JQ_INCS = jq_parser.h builtin.h bytecode.h compile.h execute.h \ + forkable_stack.h frame_layout.h jv.h jv_alloc.h jv_aux.h jv_dtoa.h \ + jv_parse.h jv_unicode.h locfile.h opcode.h opcode_list.h parser.y \ + jv_utf8_tables.h lexer.l + +JQ_SRC = 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_alloc.c \ + jq_test.c ${JQ_INCS} + + +### C build options + +AM_CFLAGS = -Wextra -Wall -Wno-missing-field-initializers \ + -Wno-unused-parameter -Wno-unused-function + + +### Generating the lexer and parser + +# While there is some autoconf macro support for lex/flex, it doesn't support +# header file creation so we'll use good old make +BUILT_SOURCES = lexer.h lexer.c parser.h parser.c +lexer.c: lexer.l + flex -o lexer.c --header-file=lexer.h $< +lexer.h: lexer.c + +# Tell YACC (bison) autoconf macros that you want a header file created. +# If the --warnings=all fails, you probably have an old version of bison +# OSX ships an old bison, so update with homebrew or macports +AM_YFLAGS = --warnings=all -d + + +### Building the jq binary + +main.c: config.h + +bin_PROGRAMS = jq +jq_SOURCES = ${JQ_SRC} main.c + + +### Tests (make check) + +TESTS = tests/all.test +TEST_LOG_COMPILER = ${srcdir}/tests/run + + +### Building the manpage + +# If ENABLE_DOCS is not set, just copy jq.1.default to jq.1 +# The real_docs target succeeds (possibly after building jq.1) only if ENABLE_DOCS is set +# Thus, making "dist" depend on "real_docs" ensures that we never build a tarball with +# a stub manpage. + +man_MANS = jq.1 +.PHONY: real_docs +if ENABLE_DOCS +jq.1: $(srcdir)/docs/content/3.manual/manual.yml + ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage ) > $@ || { rm -f $@; false; } +jq.1.default: $(srcdir)/docs/default_manpage.md + ( cd ${abs_srcdir}/docs; '$(BUNDLER)' exec rake manpage_default ) > $@ || { rm -f $@; false; } +real_docs: jq.1 + if cmp jq.1 $(srcdir)/jq.1.default > /dev/null; then\ + rm -f jq.1; $(MAKE) $(AM_MAKEFLAGS) jq.1;\ + fi +else +jq.1: $(srcdir)/jq.1.default + cp $^ $@ +real_docs: + @echo "Ruby dependencies not found, cannot build manpage." > /dev/stderr + @echo "Follow the instructions in docs/README.md to install them" > /dev/stderr + @echo "and then rerun ./configure" > /dev/stderr + false +endif + + +### Packaging + +docs/site.yml: configure.ac + sed 's/^jq_version: .*/jq_version: $(VERSION)/' $@ > $@.new + mv $@.new $@ + +install-binaries: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) install-exec + +# Ensure "make dist" fails when we can't build the real manpage +dist-hook: real_docs + +DOC_FILES = docs/content docs/public docs/templates docs/site.yml \ + docs/Gemfile docs/Gemfile.lock docs/Rakefile docs/README.md \ + docs/default_manpage.md jq.1.default + +# 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 $(BUILT_SOURCES) $(man_MANS) $(TESTS) \ + $(TEST_LOG_COMPILER) gen_utf8_tables.py jq.spec \ + $(DOC_FILES) + +# 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. +docdir = ${datadir}/doc/${PACKAGE} +dist_doc_DATA = README.md COPYING AUTHORS README + +releasetag: + git tag -s "jq-$$(cat VERSION)" -m "jq release $$(cat VERSION)" + +RELEASE ?= 1 +rpm: jq + @echo "Packaging jq as an RPM ..." + mkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS + cp jq-$$(cat VERSION).tar.gz rpm/SOURCES/ + rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $$(cat VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$$(cat VERSION).tar.gz + find rpm/RPMS/ -name "*.rpm" -exec mv {} ./ \; + rm -rf rpm + +dist-clean-local: + rm -f ${BUILT_SOURCES} + +# Not sure why this doesn't get cleaned up automatically, guess +# automake used to man pages which are hand coded? +clean-local: + rm -f jq.1 @@ -0,0 +1 @@ +README.md
\ No newline at end of file @@ -8,7 +8,16 @@ If you want to learn to use jq, read the documentation at documentation is generated from the docs/ folder of this repository. If you want to hack on jq, feel free, but be warned that its internals -are not well-documented at the moment. Bring a hard hat and a shovel. +are not well-documented at the moment. Bring a hard hat and a +shovel. Also, read the wiki: http://github.com/stedolan/jq/wiki -You can find some basic build instructions at -[http://stedolan.github.com/jq/download](http://stedolan.github.com/jq/download) +To build jq, run + + ./configure + make + sudo make install (optionally) + +If you've just checked out the latest version from git (rather than +using a released source tarball) then you'll need to run this first: + + autoreconf diff --git a/VERSION b/VERSION deleted file mode 100644 index 5625e59d..00000000 --- a/VERSION +++ /dev/null @@ -1 +0,0 @@ -1.2 diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 00000000..f59ec20a --- /dev/null +++ b/build/.gitignore @@ -0,0 +1 @@ +*
\ No newline at end of file @@ -1,7 +1,7 @@ #include <string.h> #include "builtin.h" #include "compile.h" -#include "parser.h" +#include "jq_parser.h" #include "locfile.h" #include "jv_aux.h" #include "jv_unicode.h" diff --git a/config.h.in b/config.h.in new file mode 100644 index 00000000..46b33c08 --- /dev/null +++ b/config.h.in @@ -0,0 +1,32 @@ +/* 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/compile b/config/compile new file mode 100755 index 00000000..862a14e8 --- /dev/null +++ b/config/compile @@ -0,0 +1,343 @@ +#! /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 new file mode 100755 index 00000000..25a39e6c --- /dev/null +++ b/config/depcomp @@ -0,0 +1,708 @@ +#! /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 flag |