configure: detect toolchain if not specified
[profile/ivi/libvpx.git] / release.sh
1 #!/bin/bash
2 ##
3 ##  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
4 ##
5 ##  Use of this source code is governed by a BSD-style license and patent
6 ##  grant that can be found in the LICENSE file in the root of the source
7 ##  tree. All contributing project authors may be found in the AUTHORS
8 ##  file in the root of the source tree.
9 ##
10
11
12
13 self=$0
14
15 for opt; do
16     case $opt in
17         --clean) clean=yes;;
18         -j*) jopt=$opt;;
19         *) echo "Unsupported option $opt"; exit 1;;
20     esac
21 done
22
23 TAB=$'\t'
24 cat > release.mk << EOF
25 %\$(BUILD_SFX).tar.bz2: %/.done
26 ${TAB}@echo "\$(subst .tar.bz2,,\$@): tarball"
27 ${TAB}@cd \$(dir \$<); tar -cf - \$(subst .tar.bz2,,\$@) | bzip2 > ../\$@
28
29 %\$(BUILD_SFX).zip: %/.done
30 ${TAB}@echo "\$(subst .zip,,\$@): zip"
31 ${TAB}@rm -f \$@; cd \$(dir \$<); zip -rq ../\$@ \$(subst .zip,,\$@)
32
33 logs/%\$(BUILD_SFX).log.bz2: %/.done
34 ${TAB}@echo "\$(subst .log.bz2,,\$(notdir \$@)): tarlog"
35 ${TAB}@mkdir -p logs
36 ${TAB}@cat \$< | bzip2 > \$@
37
38 %/.done:
39 ${TAB}@mkdir -p \$(dir \$@)
40 ${TAB}@echo "\$(dir \$@): configure \$(CONFIG_OPTS) \$(EXTRA_PATH)"
41 ${TAB}@cd \$(dir \$@); export PATH=\$\$PATH\$(EXTRA_PATH); ../\$(SRC_ROOT)/configure \$(CONFIG_OPTS) >makelog.txt 2>&1
42 ${TAB}@echo "\$(dir \$@): make"
43 ${TAB}@cd \$(dir \$@); PATH=\$\$PATH\$(EXTRA_PATH) \$(MAKE) >>makelog.txt 2>&1
44 ${TAB}@echo "\$(dir \$@): test install"
45 ${TAB}@cd \$(dir \$@); PATH=\$\$PATH\$(EXTRA_PATH) \$(MAKE) install >>makelog.txt 2>&1
46 ${TAB}@cd \$(dir \$@)/dist/build; PATH=\$\$PATH\$(EXTRA_PATH) \$(MAKE) >>makelog.txt 2>&1
47 ${TAB}@echo "\$(dir \$@): install"
48 ${TAB}@cd \$(dir \$@); PATH=\$\$PATH\$(EXTRA_PATH) \$(MAKE) install DIST_DIR=\$(TGT) >>makelog.txt 2>&1
49 ${TAB}@touch \$@
50
51 #include release-deps.mk
52 EOF
53
54 #[ -f release-deps.mk ] || \
55 #    find ${self%/*} -name .git -prune -o -type f -print0 \
56 #    | xargs -0 -n1 echo \
57 #    | sed -e 's; ;\\ ;g' | awk '{print "$(TGT)/.done: "$0}' > release-deps.mk
58
59 build_config_list() {
60     for codec in $CODEC_LIST; do
61         for arch in $ARCH_LIST; do
62             if [ -n "$OS_LIST" ]; then
63                 for os in $OS_LIST; do
64                     CONFIGS="$CONFIGS vpx-${codec}-${arch}-${os}"
65                 done
66             else
67                 CONFIGS="$CONFIGS vpx-${codec}-${arch}"
68             fi
69         done
70     done
71 }
72
73 CODEC_LIST="vp8 vp8cx vp8dx"
74 case `uname` in
75     Linux*)
76         ARCH_LIST="x86 x86_64"
77         OS_LIST="linux"
78         build_config_list
79         ARCH_LIST="armv5te armv6 armv7"
80         OS_LIST="linux-gcc"
81
82         ;;
83     CYGWIN*)
84         TAR_SFX=.zip
85         for vs in vs7 vs8; do
86             for arch in x86-win32 x86_64-win64; do
87                 for msvcrt in md mt; do
88                     case $vs,$arch in
89                         vs7,x86_64-win64) continue ;;
90                     esac
91                     ARCH_LIST="$ARCH_LIST ${arch}${msvcrt}-${vs}"
92                 done
93             done
94         done
95         ;;
96     Darwin*)
97         ARCH_LIST="universal"
98         OS_LIST="darwin8 darwin9"
99         ;;
100     sun_os*)
101         ARCH_LIST="x86 x86_64"
102         OS_LIST="solaris"
103         ;;
104 esac
105 build_config_list
106
107 TAR_SFX=${TAR_SFX:-.tar.bz2}
108 ARM_TOOLCHAIN=/usr/local/google/csl-2009q3-67
109 for cfg in $CONFIGS; do
110     full_cfg=$cfg
111     cfg=${cfg#vpx-}
112     opts=
113     rm -f makelog.txt
114
115     case $cfg in
116         src-*)  opts="$opts --enable-codec-srcs"
117                 cfg=${cfg#src-}
118                 ;;
119         eval-*) opts="$opts --enable-eval-limit"
120                 cfg=${cfg#src-}
121                 ;;
122     esac
123
124     case $cfg in
125         #
126         # Linux
127         #
128         *x86-linux)
129             opts="$opts --target=x86-linux-gcc" ;;
130         *x86_64-linux)
131             opts="$opts --target=x86_64-linux-gcc" ;;
132         *arm*-linux-gcc)
133             armv=${cfg##*armv}
134             armv=${armv%%-*}
135             opts="$opts --target=armv${armv}-linux-gcc" ;;
136         *arm*-linux-rvct)
137             armv=${cfg##*armv}
138             armv=${armv%%-*}
139             opts="$opts --target=armv${armv}-linux-rvct"
140             opts="$opts --libc=${ARM_TOOLCHAIN}/arm-none-linux-gnueabi/libc" ;;
141
142
143         #
144         # Windows
145         #
146         # need --enable-debug-libs for now until we're smarter about
147         # building the debug/release from the customer installed
148         # environment
149         *-x86-win32*-vs*)
150             opts="$opts --target=x86-win32-vs${cfg##*-vs} --enable-debug-libs";;
151         *-x86_64-win64*-vs8)
152             opts="$opts --target=x86_64-win64-vs8 --enable-debug-libs" ;;
153
154         #
155         # Darwin
156         #
157         *-universal-darwin*)
158             opts="$opts --target=universal-darwin${cfg##*-darwin}-gcc" ;;
159
160         #
161         # Solaris
162         #
163         *x86-solaris)
164             opts="$opts --target=x86-solaris-gcc" ;;
165         *x86_64-solaris)
166             opts="$opts --target=x86_64-solaris-gcc" ;;
167     esac
168
169     case $cfg in
170         *x86-linux | *x86-solaris) opts="$opts --enable-pic" ;;
171     esac
172
173     case $cfg in
174         *-win[36][24]mt*)  opts="$opts --enable-static-msvcrt" ;;
175         *-win[36][24]md*)  opts="$opts --disable-static-msvcrt" ;;
176     esac
177
178     opts="$opts --disable-codecs"
179     case $cfg in
180         vp8*) opts="$opts --enable-vp8" ;;
181     esac
182     case $cfg in
183         *cx-*) opts="${opts}-encoder" ;;
184         *dx-*) opts="${opts}-decoder" ;;
185     esac
186     opts="$opts --enable-postproc"
187
188     [ "x${clean}" == "xyes" ] \
189         && rm -rf ${full_cfg}${BUILD_SFX}${TAR_SFX} \
190         && rm -rf logs/${full_cfg}${BUILD_SFX}.log.bz2
191
192     TGT=${full_cfg}${BUILD_SFX}
193     BUILD_TARGETS="logs/${TGT}.log.bz2 ${TGT}${TAR_SFX}"
194     echo "${BUILD_TARGETS}: CONFIG_OPTS=$opts" >>release.mk
195     echo "${BUILD_TARGETS}: TGT=${TGT}" >>release.mk
196     case $cfg in
197         *-arm*-linux-*)
198             echo "${BUILD_TARGETS}: EXTRA_PATH=:${ARM_TOOLCHAIN}/bin/" >>release.mk ;;
199         *-vs7)
200             echo "${BUILD_TARGETS}: EXTRA_PATH=:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ .NET\ 2003/Common7/IDE" >>release.mk ;;
201         *-vs8)
202             echo "${BUILD_TARGETS}: EXTRA_PATH=:/cygdrive/c/Program\ Files/Microsoft\ Visual\ Studio\ 8/Common7/IDE" >>release.mk ;;
203     esac
204     MAKE_TGTS="$MAKE_TGTS ${TGT}${TAR_SFX} logs/${TGT}.log.bz2"
205 done
206
207
208 ${MAKE:-make} ${jopt:--j3} -f release.mk  \
209     SRC_ROOT=${self%/*} BUILD_SFX=${BUILD_SFX} ${MAKE_TGTS}