What's cooking
[git] / Make
1 #!/bin/sh
2
3 case "$(git version 2>/dev/null)" in
4 "git version"*)
5         GIT=git ;;
6 *)
7         echo >&2 "No git to bootstrap"
8         exit 1 ;;
9 esac
10
11 inst_prefix=$(
12         IFS=:
13         for p in $PATH
14         do
15                 probed=${p%/git-active/bin}
16                 if test "$probed" != "$p"
17                 then
18                         echo "$probed"
19                         exit
20                 fi
21         done
22         echo $HOME
23 )
24
25 LANG=C
26 old_style_def_fix=b79d18c92d9f4841a6a1a29b7b2373a8ff9871e1
27
28 : ${O=-O2}
29 Wall='-Wall -Wdeclaration-after-statement' tests= jobs=
30 while case $# in 0) break ;; esac
31 do 
32         case "$1" in
33         -pedantic | --pedantic)
34                 o= &&
35                 rev=$($GIT rev-parse HEAD) &&
36                 case "$($GIT merge-base "$old_style_def_fix" "$rev")" in
37                 $old_style_def_fix)
38                         o=-Wold-style-definition ;;
39                 esac
40                 O="$O -Werror $o -std=c99 -Wno-pointer-to-int-cast"
41                 # -Wvla
42                 # O="$O -fwrapv -fno-strict-overflow"
43                 ;;
44         -j*)
45                 jobs=$1
46                 ;;
47         -loose | --loose)
48                 Wall=
49                 ;;
50         --locale=*)
51                 LANG=${1#*=}
52                 ;;
53         --test=*)
54                 tests=$(
55                         cd t &&
56                         for t in ${1#*=}
57                         do
58                                 eval echo "t$t-*.sh"
59                         done | tr '\012' ' '
60                 )
61                 ;;
62         --)
63                 shift
64                 break
65                 ;;
66         -*)
67                 echo >&2 "Eh $1?"
68                 exit 1
69                 ;;
70         *)
71                 break
72                 ;;              
73         esac
74         shift
75 done
76
77 LC_ALL=$LANG
78 export LANG LC_ALL
79
80 head=`$GIT symbolic-ref HEAD 2>/dev/null` &&
81 branch=`expr "$head" : 'refs/heads/\(.*\)'` || branch=detached
82
83 case "$branch" in
84 next | maint | master | pu | jch)
85         prefix="$inst_prefix/git-$branch"
86         ;;
87 snap)
88         v=`$GIT describe HEAD`
89         expr "$v" : '.*-g[0-9a-f]*$' >/dev/null && {
90             echo >&2 "You are on 'snap' but $v is not an official version."
91             exit 1
92         }
93         prefix="$inst_prefix/git-snap-$v"
94         ;;
95 *)
96         prefix="$inst_prefix/git-test" ;;
97 esac
98 d="prefix=$prefix"
99
100 sh -c 'git describe --abbrev=4 HEAD' >/dev/null 2>&1 || {
101         $GIT describe --abbrev=4 HEAD | sed -e 's/-/./g' >version
102 }
103
104 d="$d ASCIIDOC_NO_ROFF=YesPlease ASCIIDOC8=YesPlease BLK_SHA1=YesPlease"
105
106 # Platform hack
107 if test -z "${make:+set}" && {
108         test -x /usr/local/bin/gmake ||
109         test -x /usr/bin/gmake
110 }
111 then
112         make=gmake
113 fi
114 if test -f /bin/ginstall
115 then
116         set INSTALL=ginstall "$@"
117 fi
118
119 CFLAGS="$O $Wall -g"
120 OK_TO_USE_CFLAGS=Yes
121 if test -n "${NO_CFLAGS+set}"
122 then
123         unset OK_TO_USE_CFLAGS
124 fi
125
126 ${make-make} $d \
127      ETC_GITCONFIG=$prefix/etc/gitconfig \
128      ${OK_TO_USE_CFLAGS+"CFLAGS=$CFLAGS"} \
129      ${tests:+"T=$tests"} \
130      $jobs \
131      "$@"
132 status=$?
133 rm -f version
134 exit $status