What's cooking (2013/01 #05)
[alt-git.git] / Make
blob21ad53c516edd7cf4ff89c7a3bbe216233d636b7
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 O="-fgnu89-inline"
63 skip="t9402"
65 NetBSD)
66 OLD_ICONV=YesPlease; export OLD_ICONV
67 skip="t5000 t9402"
69 FreeBSD)
70 OLD_ICONV=YesPlease; export OLD_ICONV
71 skip="t5560"
73 SunOS)
74 NEEDS_CRYPTO_WITH_SSL=YesPlease ; export NEEDS_CRYPTO_WITH_SSL
75 NO_PEDANTIC=CannotDo Wall=
77 esac
79 while case $# in 0) break ;; esac
80 do
81 case "$1" in
82 -pedantic | --pedantic)
83 o= &&
84 rev=$($GIT rev-parse HEAD) &&
85 case "$($GIT merge-base "$old_style_def_fix" "$rev")" in
86 $old_style_def_fix)
87 o=-Wold-style-definition ;;
88 esac
89 case "$NO_PEDANTIC" in
90 ?*) ;;
91 '')
92 O="$O -Werror $o -std=c99 -Wno-pointer-to-int-cast"
93 O="$O -Wpointer-arith -Woverflow -Wunused"
95 esac
96 # -Wvla
97 # O="$O -fwrapv -fno-strict-overflow"
99 -j*)
100 case "$NO_JOBS" in
101 ?*) jobs= ;;
102 '') jobs=$1 ;;
103 esac
105 -noprove | --noprove)
106 oldtest=t
108 -loose | --loose)
109 Wall=
111 --locale=*)
112 LANG=${1#*=}
114 --test=*)
115 tests=$(
116 cd t &&
117 for t in ${1#*=}
119 eval echo "t$t-*.sh"
120 done | tr '\012' ' '
124 shift
125 break
128 echo >&2 "Eh $1?"
129 exit 1
132 break
134 esac
135 shift
136 done
138 if test -z "$tests" && test -n "$skip"
139 then
140 GIT_SKIP_TESTS="${GIT_SKIP_TESTS:-$skip}"
141 export GIT_SKIP_TESTS
143 if test -z "$oldtest" &&
144 sh -c 'prove --version >/dev/null 2>&1' &&
145 sh -c 'prove --exec : >/dev/null 2>&1'
146 then
147 DEFAULT_TEST_TARGET=prove GIT_PROVE_OPTS="$jobs"
148 export DEFAULT_TEST_TARGET GIT_PROVE_OPTS
151 LC_ALL=$LANG
152 export LANG LC_ALL
154 head=`$GIT symbolic-ref HEAD 2>/dev/null` &&
155 branch=`expr "$head" : 'refs/heads/\(.*\)'` || branch=detached
157 case "$branch" in
158 next | maint | master | pu | jch)
159 prefix="$inst_prefix/git-$branch"
161 snap)
162 v=`$GIT describe HEAD`
163 expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
164 echo >&2 "You are on 'snap' but $v is not an official version."
165 exit 1
167 prefix="$inst_prefix/git-snap-$v"
170 prefix="$inst_prefix/git-test" ;;
171 esac
172 d="prefix=$prefix"
174 sh -c 'git describe --abbrev=4 HEAD' >/dev/null 2>&1 || {
175 $GIT describe --abbrev=4 HEAD | sed -e 's/-/./g' >version
178 d="$d "'
179 MAN_BASE_URL="http://www.kernel.org/pub/software/scm/git/docs/"
180 ASCIIDOC_NO_ROFF=YesPlease
181 ASCIIDOC8=YesPlease
182 BLK_SHA1=YesPlease
183 GNU_ROFF=YesPlease'
185 # Platform hack
186 if test -z "${make:+set}" && {
187 test -x /usr/local/bin/gmake ||
188 test -x /usr/pkg/bin/gmake ||
189 test -x /usr/bin/gmake
191 then
192 make=gmake
194 if test -f /bin/ginstall
195 then
196 set INSTALL=ginstall "$@"
199 CFLAGS="$O $Wall -g"
200 OK_TO_USE_CFLAGS=Yes
201 if test -n "${NO_CFLAGS+set}"
202 then
203 unset OK_TO_USE_CFLAGS
206 ${make-make} $d \
207 ETC_GITCONFIG=$prefix/etc/gitconfig \
208 ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
209 ${tests:+"T=$tests"} \
210 $jobs \
211 "$@"
212 status=$?
213 rm -f version
214 exit $status