]> git.sesse.net Git - vlc/blob - contrib/bootstrap
contribs: add vorbis(enc)
[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 }
28
29 BUILD=
30 HOST=
31 PREFIX=
32
33 if test ! -f "../src/main.mak"
34 then
35         echo "$0 must be run from a subdirectory"
36         exit 1
37 fi
38
39 while test -n "$1"
40 do
41         case "$1" in
42                 --build=*)
43                         BUILD="${1#--build=}"
44                         ;;
45                 --help|-h)
46                         usage
47                         exit 0
48                         ;;
49                 --host=*)
50                         HOST="${1#--host=}"
51                         ;;
52                 --prefix=*)
53                         PREFIX="${1#--prefix=}"
54                         ;;
55                 *)
56                         echo "Unrecognized options $1"
57                         usage
58                         exit 1
59                         ;;
60         esac
61         shift
62 done
63
64 if test -z "$BUILD"
65 then
66         echo -n "Guessing build system... "
67         BUILD="`cc -dumpmachine`"
68         if test -z "$BUILD"; then
69                 echo "FAIL!"
70                 exit 1
71         fi
72         echo "$BUILD"
73 fi
74
75 if test -z "$HOST"
76 then
77         echo -n "Guessing host system...  "
78         HOST="$BUILD"
79         echo "$HOST"
80 fi
81
82 if test "$PREFIX"
83 then
84         # strip trailing slash
85         PREFIX="${PREFIX%/}"
86 else
87         PREFIX="../hosts/$HOST"
88 fi
89
90 #
91 # Prepare files
92 #
93 echo "Creating prefix... $PREFIX"
94 mkdir -p -- "$PREFIX" || exit $?
95 mkdir -p -- "$PREFIX/share/aclocal" || exit $?
96
97 echo "Creating configuration file... config.mak"
98 exec 3>config.mak
99 cat >&3 << EOF
100 # This file was automatically generated.
101 # Any change will be overwritten if ../bootstrap is run again.
102 BUILD := $BUILD
103 HOST := $HOST
104 PREFIX := $PREFIX
105 EOF
106
107 add_make()
108 {
109         while test -n "$1"
110         do
111                 echo "$1" >&3
112                 shift
113         done
114 }
115
116 add_make_enabled()
117 {
118         while test -n "$1"
119         do
120                 add_make "$1 := 1"
121                 shift
122         done
123 }
124
125 #
126 # Checks
127 #
128 OS="${HOST#*-}" # strip architecture
129 case "${OS}" in
130         apple-darwin*)
131                 add_make_enabled "HAVE_MACOSX" "HAVE_DARWIN_OS" "HAVE_BSD"
132                 ;;
133         *darwin*)
134                 add_make_enabled "HAVE_DARWIN_OS" "HAVE_BSD"
135                 ;;
136         *bsd*)
137                 add_make_enabled "HAVE_BSD"
138                 ;;
139         *linux*)
140                 add_make_enabled "HAVE_LINUX"
141                 ;;
142         *mingw*)
143                 add_make_enabled "HAVE_WIN32"
144                 ;;
145         *wince*)
146                 add_make_enabled "HAVE_WINCE"
147                 ;;
148 esac
149 add_make_enabled "BUILD_ENCODERS"
150
151 #
152 # Results output
153 #
154 test -e Makefile && unlink Makefile
155 ln -sf ../src/main.mak Makefile
156 cat << EOF
157 Bootstrap completed.
158
159 The following packages were selected:
160 $PKGS
161
162 Run "make" to start compilation.
163
164 Other targets:
165  * make install      same as "make"
166  * make fetch        fetch required source tarballs
167  * make fetch-all    fetch all source tarballs
168  * make distclean    clean everything and undo bootstrap
169  * make clean        clean everything
170  * make mostlyclean  clean everything except source tarballs
171 EOF