1 AS_INIT[]dnl -*- shell-script -*-
2 m4_divert_push([HEADER-COPYRIGHT])dnl
4 # make-builder -- create PSPP build scripts
6 # Copyright (C) 1992, 1993, 1994, 1996, 1999, 2000, 2001, 2002, 2003,
7 # 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation,
10 # This program is free software: you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # This program is distributed in the hope that it will be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 # GNU General Public License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 m4_divert_pop([HEADER-COPYRIGHT])dnl back to BODY
27 Usage: $0 [OPTION]... REPOSITORY BRANCH
28 where REPO and BRANCH are a Git repository and branch to clone.
31 -h, --help Print this usage message and exit
32 -b, --build=NUMBER Set build number (default: next available)
33 -o, --output=DIRECTORY Set build directory (default: build\$BUILD_NUMBER)
34 -f, --force Overwrite files in existing directory
36 Report bugs to <bug-gnu-pspp@gnu.org>.
37 GNU PSPP: <http://www.gnu.org/software/pspp/>.
38 General help using GNU software: <http://www.gnu.org/gethelp/>."]
41 make-builder (@PACKAGE_NAME@) @VERSION@
42 Copyright (C) 2010 Free Software Foundation, Inc.
43 License GPLv3+/Autoconf: GNU GPL version 3 or later
44 <http://gnu.org/licenses/gpl.html>, <http://gnu.org/licenses/exceptions.html>
45 This is free software: you are free to change and redistribute it.
46 There is NO WARRANTY, to the extent permitted by law.
48 Written by Ben Pfaff."]
51 Try \`$as_me --help' for more information."
54 m4_bpatsubst([AS_ERROR([option `$[1]' requires an argument$as_nl$help])],
56 # restore font-lock: '
62 GNULIB_REPO=git://git.sv.gnu.org/gnulib.git
65 while test $# -gt 0 ; do
66 option=[`expr "x$1" : 'x\(--[^=]*\)' \| \
68 optarg=[`expr "x$1" : 'x--[^=]*=\(.*\)' \| \
72 echo "$version" ; exit ;;
74 AS_ECHO(["$usage"]); exit ;;
78 autom4te_options="$autom4te_options $1"; shift ;;
84 test $# = 1 && eval "$exit_missing_arg"
92 test $# = 1 && eval "$exit_missing_arg"
99 -- ) # Stop option processing
101 - ) # Use stdin as input.
105 AS_ERROR([invalid option `$[1]'$as_nl$help]) ;; #`
111 # Find the input file.
118 AS_ERROR([invalid number of arguments$as_nl$help]) ;;
121 # Choose build number.
122 if test "x$BUILD_NUMBER" = x; then
125 if ln $[1].$$ $[1].lock; then
137 until lock_file build_number; do
141 if test -e buildnr; then
142 BUILD_NUMBER=`cat buildnr`
146 echo `expr $BUILD_NUMBER + 1` > buildnr
151 # Check that build number is a number.
152 case $BUILD_NUMBER in # (
155 AS_ERROR([invalid build number `$BUILD_NUMBER'$as_nl$help]) #`
159 # Ensure that git repository exists.
160 GIT_DIR=$PWD/repo.git
162 if git init >/dev/null; then
166 AS_ERROR([initializing Git repository in $GIT_DIR failed])
170 if git fetch $PSPP_REPO +$PSPP_BRANCH:refs/builds/$BUILD_NUMBER/pspp >/dev/null 2>&1; then
174 AS_ERROR([failed to fetch branch $PSPP_BRANCH from $PSPP_REPO])
177 # Get PSPP commit number.
178 PSPP_COMMIT=`git rev-parse refs/builds/$BUILD_NUMBER/pspp`
180 # Get gnulib commit number.
182 git show refs/builds/$BUILD_NUMBER/pspp:README.Git | \
183 sed -n 's/^[[ ]]*commit \([[0-9a-fA-F]]\{8,\}\)$/\1/p' | \
186 # Fetch Gnulib source.
187 if git rev-parse --verify --quiet $GNULIB_COMMIT^0 > /dev/null; then
190 # We don't have the right commit yet, update Gnulib.
191 if git fetch $GNULIB_REPO '+refs/heads/*:refs/remotes/gnulib/*'; then
195 AS_ERROR([failed to fetch commit $GNULIB_COMMIT from $GNULIB_REPO])
198 git update-ref refs/builds/$BUILD_NUMBER/gnulib $GNULIB_COMMIT
200 # Choose and create output directory.
201 test -z "$outdir" && outdir=build$BUILD_NUMBER
202 if test -e "$outdir" && test $overwrite = false; then
204 AS_ERROR([$outdir exists and --force not specified$as_nl$help])
206 AS_MKDIR_P([$outdir])
208 # Make source tarballs.
210 git archive --format=tar --prefix=pspp-$PSPP_COMMIT/ $PSPP_COMMIT \
211 | gzip > $outdir/repo/pspp-$PSPP_COMMIT.tar.gz
212 git archive --format=tar --prefix=gnulib-$GNULIB_COMMIT/ $GNULIB_COMMIT \
213 | gzip > $outdir/repo/gnulib-$GNULIB_COMMIT.tar.gz
215 # Make build scripts.
216 for base in make-src-dist make-bin-dist; do
217 sed < $base.in > "$outdir/$base" "
218 s,[@]BUILD_NUMBER[@],$BUILD_NUMBER,g
219 s,[@]PSPP_REPO[@],$PSPP_REPO,g
220 s,[@]PSPP_BRANCH[@],$PSPP_BRANCH,g
221 s,[@]PSPP_COMMIT[@],$PSPP_COMMIT,g
222 s,[@]GNULIB_COMMIT[@],$GNULIB_COMMIT,g
223 s,[@]GNULIB_REPO[@],$GNULIB_REPO,g
225 chmod +x "$outdir/$base"
228 # Copy in auxiliary files.
229 mkdir "$outdir/build-aux"
230 for base in gendocs.sh gendocs_template gendocs_template_min; do
231 cp "build-aux/$base" "$outdir/build-aux/"
236 BUILD_NUMBER='$BUILD_NUMBER'
237 PSPP_REPO='$PSPP_REPO'
238 PSPP_BRANCH='$PSPP_BRANCH'
239 PSPP_COMMIT='$PSPP_COMMIT'
240 GNULIB_COMMIT='$GNULIB_COMMIT'
241 GNULIB_REPO='$GNULIB_REPO'