What's cooking (2012/11 #04)
[alt-git.git] / Make
blob9ea81abbab955ea347f11430a8e091be770e45f2
1 #!/bin/sh
3 if test -z "$GIT"
4 then
5 case "$(git version 2>/dev/null)" in
6 "git version"*)
7 GIT=git ;;
8 *)
9 echo >&2 "No git to bootstrap"
10 exit 1 ;;
11 esac
14 inst_prefix=$(
15 IFS=:
16 for p in $PATH
18 probed=${p%/git-active/bin}
19 if test "$probed" != "$p"
20 then
21 echo "$probed"
22 exit
24 done
25 echo $HOME
28 LANG=C
29 old_style_def_fix=b79d18c92d9f4841a6a1a29b7b2373a8ff9871e1
31 : ${O=-O2}
33 for cv in PYTHON_PATH=python TCL_PATH=tclsh TCLTKPATH=wish
35 cmd=${cv#*=}
36 var=${cv%=*}
37 eval $(
38 if test -f "/usr/bin/$cmd"
39 then
40 break
42 for p in /usr/bin /usr/local/bin
44 if test -f "$p/$cmd"
45 then
46 echo "$var=$p/$cmd; export $var"
47 break
49 found=$(find "$p/$cmd"* -type f 2>/dev/null | head -n 1)
50 if test -f "$found"
51 then
52 echo "$var=$found; export $var"
53 break
55 done
57 done
59 Wall='-Wall -Wdeclaration-after-statement' tests= jobs= skip= oldtest=
60 case `uname` in
61 OpenBSD)
62 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
63 skip="t9200 t9502"
64 SHELL_PATH=/usr/local/bin/bash; export SHELL_PATH
65 NO_PEDANTIC=CannotDo NO_JOBS=CannotDo
66 Wall=
68 FreeBSD)
69 OLD_ICONV=YesPlease; export OLD_ICONV
70 skip="t5560"
72 SunOS)
73 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
74 NO_PEDANTIC=CannotDo Wall=
76 esac
78 while case $# in 0) break ;; esac
79 do
80 case "$1" in
81 -pedantic | --pedantic)
82 o= &&
83 rev=$($GIT rev-parse HEAD) &&
84 case "$($GIT merge-base "$old_style_def_fix" "$rev")" in
85 $old_style_def_fix)
86 o=-Wold-style-definition ;;
87 esac
88 case "$NO_PEDANTIC" in
89 ?*) ;;
90 '')
91 O="$O -Werror $o -std=c99 -Wno-pointer-to-int-cast"
92 O="$O -Wpointer-arith -Woverflow -Wunused"
94 esac
95 # -Wvla
96 # O="$O -fwrapv -fno-strict-overflow"
98 -j*)
99 case "$NO_JOBS" in
100 ?*) jobs= ;;
101 '') jobs=$1 ;;
102 esac
104 -noprove | --noprove)
105 oldtest=t
107 -loose | --loose)
108 Wall=
110 --locale=*)
111 LANG=${1#*=}
113 --test=*)
114 tests=$(
115 cd t &&
116 for t in ${1#*=}
118 eval echo "t$t-*.sh"
119 done | tr '\012' ' '
123 shift
124 break
127 echo >&2 "Eh $1?"
128 exit 1
131 break
133 esac
134 shift
135 done
137 if test -z "$tests" && test -n "$skip"
138 then
139 : GIT_SKIP_TESTS="${GIT_SKIP_TESTS:-$skip}"
141 if test -z "$oldtest" &&
142 sh -c 'prove --version >/dev/null 2>&1' &&
143 sh -c 'prove --exec : >/dev/null 2>&1'
144 then
145 DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$jobs"
146 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
149 LC_ALL=$LANG
150 export LANG LC_ALL
152 head=`$GIT symbolic-ref HEAD 2>/dev/null` &&
153 branch=`expr "$head" : 'refs/heads/\(.*\)'` || branch=detached
155 case "$branch" in
156 next | maint | master | pu | jch)
157 prefix="$inst_prefix/git-$branch"
159 snap)
160 v=`$GIT describe HEAD`
161 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
162 echo >&2 "You are on 'snap' but $v is not an official version."
163 exit 1
165 prefix="$inst_prefix/git-snap-$v"
168 prefix="$inst_prefix/git-test" ;;
169 esac
170 d="prefix=$prefix"
172 sh -c 'git describe --abbrev=4 HEAD' >/dev/null 2>&1 || {
173 $GIT describe --abbrev=4 HEAD | sed -e 's/-/./g' >version
176 d="$d "'
177 MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
178 ASCIIDOC_NO_ROFF=YesPlease
179 ASCIIDOC8=YesPlease
180 BLK_SHA1=YesPlease
181 GNU_ROFF=YesPlease'
183 # Platform hack
184 if test -z "${make:+set}" && {
185 test -x /usr/local/bin/gmake ||
186 test -x /usr/bin/gmake
188 then
189 make=gmake
191 if test -f /bin/ginstall
192 then
193 set INSTALL=ginstall "$@"
196 CFLAGS="$O $Wall -g"
197 OK_TO_USE_CFLAGS=Yes
198 if test -n "${NO_CFLAGS+set}"
199 then
200 unset OK_TO_USE_CFLAGS
203 ${make-make} $d \
204 ETC_GITCONFIG=$prefix/etc/gitconfig \
205 ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
206 ${tests:+"T=$tests"} \
207 $jobs \
208 "$@"
209 status=$?
210 rm -f version
211 exit $status