What's cooking (2013/05 #08)
[git.git] / Make
blob11fb5520b4bcc1e257aa0932305e30dfbb70c9e7
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'
60 tests= jobs= skip= oldtest=
62 case `uname` in
63 OpenBSD)
64 O="-fgnu89-inline"
65 skip="t9402"
67 NetBSD)
68 OLD_ICONV=YesPlease; export OLD_ICONV
69 skip="t5000 t9402"
71 FreeBSD)
72 OLD_ICONV=YesPlease; export OLD_ICONV
73 skip="t5560"
75 SunOS)
76 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
77 NO_PEDANTIC=CannotDo Wall=
79 esac
81 old_style_def_fix () {
82 rev=$($GIT rev-parse HEAD 2>/dev/null) &&
83 case "$($GIT merge-base "$old_style_def_fix" "$rev")" in
84 $old_style_def_fix)
85 printf "%s\n" "-Wold-style-definition"
87 esac
90 determine_branch () {
91 expr "$($GIT symbolic-ref HEAD 2>/dev/null)" : 'refs/heads/\(.*\)' ||
92 echo detached
95 determine_version () {
96 v=`$GIT describe HEAD`
97 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
98 echo >&2 "You are on 'snap' but $v is not an official version."
99 exit 1
101 echo "$v"
104 determine_long_version () {
105 $GIT describe HEAD 2>/dev/null || echo unknown-g00000000 |
106 sed -e 's/-/./g'
109 while case $# in 0) break ;; esac
111 case "$1" in
112 -pedantic | --pedantic)
113 case "$NO_PEDANTIC" in
114 ?*) ;;
116 O="$O -Werror $(old_style_def_fix) -std=c99"
117 O="$O -Wno-pointer-to-int-cast"
118 O="$O -Wpointer-arith -Woverflow -Wunused"
120 esac
121 # -Wvla
122 # O="$O -fwrapv -fno-strict-overflow"
124 -j*)
125 case "$NO_JOBS" in
126 ?*) jobs= ;;
127 '') jobs=$1 ;;
128 esac
130 -noprove | --noprove)
131 oldtest=t
133 -loose | --loose)
134 Wall=
136 --locale=*)
137 LANG=${1#*=}
139 --test=*)
140 tests=$(
141 cd t &&
142 for t in ${1#*=}
144 eval echo "t$t-*.sh"
145 done | tr '\012' ' '
149 shift
150 break
153 echo >&2 "Eh $1?"
154 exit 1
157 break
159 esac
160 shift
161 done
163 if test -z "$tests" && test -n "$skip"
164 then
165 GIT_SKIP_TESTS="${GIT_SKIP_TESTS:-$skip}"
166 export GIT_SKIP_TESTS
168 if test -z "$oldtest" &&
169 sh -c 'prove --version >/dev/null 2>&1' &&
170 sh -c 'prove --exec : >/dev/null 2>&1'
171 then
172 DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$jobs"
173 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
176 LC_ALL=$LANG
177 export LANG LC_ALL
179 branch=$(determine_branch)
181 case "$branch" in
182 next | maint | master | pu | jch)
183 prefix="$inst_prefix/git-$branch"
185 snap)
186 v=$(determine_version)
187 prefix="$inst_prefix/git-snap-$v"
190 prefix="$inst_prefix/git-test" ;;
191 esac
192 d="prefix=$prefix"
194 determine_long_version >version
196 d="$d "'
197 MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
198 ASCIIDOC_NO_ROFF=YesPlease
199 ASCIIDOC8=YesPlease
200 BLK_SHA1=YesPlease
201 GNU_ROFF=YesPlease'
203 # Platform hack
204 if test -z "${make:+set}" && {
205 test -x /usr/local/bin/gmake ||
206 test -x /usr/pkg/bin/gmake ||
207 test -x /usr/bin/gmake
209 then
210 make=gmake
212 if test -f /bin/ginstall
213 then
214 set INSTALL=ginstall "$@"
217 CFLAGS="$O $Wall -g"
218 OK_TO_USE_CFLAGS=Yes
219 if test -n "${NO_CFLAGS+set}"
220 then
221 unset OK_TO_USE_CFLAGS
224 ${make-make} $d \
225 ETC_GITCONFIG=$prefix/etc/gitconfig \
226 ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
227 ${tests:+"T=$tests"} \
228 $jobs \
229 "$@"
230 status=$?
231 rm -f version
232 exit $status