]> git.sesse.net Git - vlc/blob - contrib/bootstrap
contrib: set android specifics
[vlc] / contrib / bootstrap
1 #! /bin/sh
2 # Copyright (C) 2003-2011 the VideoLAN team
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
17
18 #
19 # Command line handling
20 #
21 usage()
22 {
23         echo "Usage: $0 [--build=BUILD] [--host=HOST] [--prefix=PREFIX]"
24         echo "  --build=BUILD    configure for building on BUILD"
25         echo "  --host=HOST      cross-compile to build to run on HOST"
26         echo "  --prefix=PREFIX  install files in PREFIX"
27         echo "  --disable-FOO    configure to not build package FOO"
28         echo "  --enable-FOO     configure to build package FOO"
29         echo "  --disable-disc   configure to not build optical discs packages"
30         echo "  --disable-sout   configure to not build stream output packages"
31 }
32
33 BUILD=
34 HOST=
35 PREFIX=
36 PKGS_ENABLE=
37 PKGS_DISABLE=
38 BUILD_ENCODERS="1"
39 BUILD_DISCS="1"
40
41 if test ! -f "../../contrib/src/main.mak"
42 then
43         echo "$0 must be run from a subdirectory"
44         exit 1
45 fi
46
47 while test -n "$1"
48 do
49         case "$1" in
50                 --build=*)
51                         BUILD="${1#--build=}"
52                         ;;
53                 --help|-h)
54                         usage
55                         exit 0
56                         ;;
57                 --host=*)
58                         HOST="${1#--host=}"
59                         ;;
60                 --prefix=*)
61                         PREFIX="${1#--prefix=}"
62                         ;;
63                 --disable-disc)
64                         BUILD_DISCS=
65                         ;;
66                 --disable-sout)
67                         BUILD_ENCODERS=
68                         ;;
69                 --disable-*)
70                         PKGS_DISABLE="${PKGS_DISABLE} ${1#--disable-}"
71                         ;;
72                 --enable-*)
73                         PKGS_ENABLE="${PKGS_ENABLE} ${1#--enable-}"
74                         ;;
75                 *)
76                         echo "Unrecognized options $1"
77                         usage
78                         exit 1
79                         ;;
80         esac
81         shift
82 done
83
84 if test -z "$BUILD"
85 then
86         echo -n "Guessing build system... "
87         BUILD="`cc -dumpmachine`"
88         if test -z "$BUILD"; then
89                 echo "FAIL!"
90                 exit 1
91         fi
92         echo "$BUILD"
93 fi
94
95 if test -z "$HOST"
96 then
97         echo -n "Guessing host system...  "
98         HOST="$BUILD"
99         echo "$HOST"
100 fi
101
102 if test "$PREFIX"
103 then
104         # strip trailing slash
105         PREFIX="${PREFIX%/}"
106 fi
107
108 #
109 # Prepare files
110 #
111 echo "Creating configuration file... config.mak"
112 exec 3>config.mak
113 cat >&3 << EOF
114 # This file was automatically generated.
115 # Any change will be overwritten if ../bootstrap is run again.
116 BUILD := $BUILD
117 HOST := $HOST
118 PKGS_DISABLE := $PKGS_DISABLE
119 PKGS_ENABLE := $PKGS_ENABLE
120 EOF
121
122 add_make()
123 {
124         while test -n "$1"
125         do
126                 echo "$1" >&3
127                 shift
128         done
129 }
130
131 add_make_enabled()
132 {
133         while test -n "$1"
134         do
135                 add_make "$1 := 1"
136                 shift
137         done
138 }
139
140 check_macosx_sdk()
141 {
142    [ -z "${OSX_VERSION}" ] && echo "OSX_VERSION not specified, assuming 10.5" && OSX_VERSION=10.5
143    SDK="/Developer/SDKs/MacOSX${OSX_VERSION}.sdk"
144    if [ ! -d "${SDK}" ]
145    then
146            echo "
147 *** ${SDK} does not exist, please install required SDK, or use export OSX_VERSION=10.6 ***
148 "
149            exit 1
150    fi
151    add_make "OSX_VERSION ?= ${OSX_VERSION}"
152 }
153
154 check_android_sdk()
155 {
156         [ -z "${ANDROID_NDK}" ] && echo "You must set ANDROID_NDK environment variable" && exit 1
157         add_make "ANDROID_NDK := ${ANDROID_NDK}"
158         test -z "${NO_NEON}" && add_make_enabled "HAVE_NEON"
159 }
160
161 test -z "$PREFIX" || add_make "PREFIX := $PREFIX"
162 test -z "$BUILD_DISCS" || add_make_enabled "BUILD_DISCS"
163 test -z "$BUILD_ENCODERS" || add_make_enabled "BUILD_ENCODERS"
164
165 #
166 # Checks
167 #
168 OS="${HOST#*-}" # strip architecture
169 case "${OS}" in
170         apple-darwin*)
171                 check_macosx_sdk
172                 add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
173                 ;;
174         *darwin*)
175                 add_make_enabled "HAVE_DARWIN_OS" "HAVE_BSD"
176                 ;;
177         *bsd*)
178                 add_make_enabled "HAVE_BSD"
179                 ;;
180         linux-androideabi)
181                 check_android_sdk
182                 add_make_enabled "HAVE_LINUX" "HAVE_ANDROID"
183                 ;;
184         *linux*)
185                 add_make_enabled "HAVE_LINUX"
186                 ;;
187         *wince*)
188                 add_make_enabled "HAVE_WINCE"
189                 ;;
190         *mingw*)
191                 add_make_enabled "HAVE_WIN32"
192                 ;;
193 esac
194
195 #
196 # Results output
197 #
198 test -e Makefile && unlink Makefile
199 ln -sf ../../contrib/src/main.mak Makefile
200 cat << EOF
201 Bootstrap completed.
202
203 Run "make" to start compilation.
204
205 Other targets:
206  * make install      same as "make"
207  * make fetch        fetch required source tarballs
208  * make fetch-all    fetch all source tarballs
209  * make distclean    clean everything and undo bootstrap
210  * make mostlyclean  clean everything except source tarballs
211  * make clean        clean everything
212  * make list         list packages
213 EOF
214
215 mkdir -p ../../contrib/tarballs