demux: avi: replace off_t (fix #19249)
[vlc.git] / extras / package / macosx / build.sh
blob832cc0325366651d124cbfd3b2adb65b52b45b15
1 #!/bin/sh
2 set -e
3 set -x
5 info()
7 local green="\033[1;32m"
8 local normal="\033[0m"
9 echo "[${green}build${normal}] $1"
12 ARCH="x86_64"
13 MINIMAL_OSX_VERSION="10.10"
14 OSX_VERSION=`xcrun --show-sdk-version`
15 OSX_KERNELVERSION=`uname -r | cut -d. -f1`
16 SDKROOT=`xcode-select -print-path`/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$OSX_VERSION.sdk
17 VLCBUILDDIR=""
19 CORE_COUNT=`getconf NPROCESSORS_ONLN 2>&1`
20 let JOBS=$CORE_COUNT+1
22 usage()
24 cat << EOF
25 usage: $0 [options]
27 Build vlc in the current directory
29 OPTIONS:
30 -h Show some help
31 -q Be quiet
32 -j Force number of cores to be used
33 -r Rebuild everything (tools, contribs, vlc)
34 -c Recompile contribs from sources
35 -p Build packages for all artifacts
36 -k <sdk> Use the specified sdk (default: $SDKROOT)
37 -a <arch> Use the specified arch (default: $ARCH)
38 -C Use the specified VLC build dir
39 EOF
43 spushd()
45 pushd "$1" > /dev/null
48 spopd()
50 popd > /dev/null
53 while getopts "hvrcpk:a:j:C:" OPTION
55 case $OPTION in
57 usage
58 exit 1
61 set +x
62 QUIET="yes"
65 REBUILD="yes"
68 CONTRIBFROMSOURCE="yes"
71 PACKAGE="yes"
74 ARCH=$OPTARG
77 SDKROOT=$OPTARG
80 JOBS=$OPTARG
83 VLCBUILDDIR=$OPTARG
85 esac
86 done
87 shift $(($OPTIND - 1))
89 if [ "x$1" != "x" ]; then
90 usage
91 exit 1
95 # Various initialization
98 out="/dev/stdout"
99 if [ "$QUIET" = "yes" ]; then
100 out="/dev/null"
103 info "Building VLC for the Mac OS X"
105 spushd `dirname $0`/../../..
106 vlcroot=`pwd`
107 spopd
109 builddir=`pwd`
111 info "Building in \"$builddir\""
113 TRIPLET=$ARCH-apple-darwin$OSX_KERNELVERSION
115 export CC="`xcrun --find clang`"
116 export CXX="`xcrun --find clang++`"
117 export OBJC="`xcrun --find clang`"
118 export OSX_VERSION
119 export SDKROOT
120 export PATH="${vlcroot}/extras/tools/build/bin:${vlcroot}/contrib/${TRIPLET}/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:${PATH}"
122 # Select avcodec flavor to compile contribs with
123 export USE_FFMPEG=1
125 # The following symbols do not exist on the minimal macOS version (10.7), so they are disabled
126 # here. This allows compilation also with newer macOS SDKs.
127 # Added symbols in 10.13
128 export ac_cv_func_open_wmemstream=no
129 export ac_cv_func_fmemopen=no
130 export ac_cv_func_open_memstream=no
131 export ac_cv_func_futimens=no
132 export ac_cv_func_utimensat=no
134 # Added symbols between 10.11 and 10.12
135 export ac_cv_func_basename_r=no
136 export ac_cv_func_clock_getres=no
137 export ac_cv_func_clock_gettime=no
138 export ac_cv_func_clock_settime=no
139 export ac_cv_func_dirname_r=no
140 export ac_cv_func_getentropy=no
141 export ac_cv_func_mkostemp=no
142 export ac_cv_func_mkostemps=no
144 # Added symbols between 10.7 and 10.11
145 export ac_cv_func_ffsll=no
146 export ac_cv_func_flsll=no
147 export ac_cv_func_fdopendir=no
148 export ac_cv_func_openat=no
149 export ac_cv_func_fstatat=no
150 export ac_cv_func_readlinkat=no
152 # libnetwork does not exist yet on 10.7 (used by libcddb)
153 export ac_cv_lib_network_connect=no
156 # vlc/extras/tools
159 info "Building building tools"
160 spushd "${vlcroot}/extras/tools"
161 ./bootstrap > $out
162 if [ "$REBUILD" = "yes" ]; then
163 make clean
165 make > $out
166 spopd
169 # vlc/contribs
172 # Usually, VLCs contrib libraries do not support partial availability at runtime.
173 # Forcing those errors has two reasons:
174 # - Some custom configure scripts include the right header for testing availability.
175 # Those configure checks fail (correctly) with those errors, and replacements are
176 # enabled. (e.g. ffmpeg)
177 # - This will fail the build if a partially available symbol is added later on
178 # in contribs and not mentioned in the list of symbols above.
179 export CFLAGS="-Werror=partial-availability"
180 export CXXFLAGS="-Werror=partial-availability"
181 export OBJCFLAGS="-Werror=partial-availability"
183 info "Building contribs"
184 spushd "${vlcroot}/contrib"
185 mkdir -p contrib-$TRIPLET && cd contrib-$TRIPLET
186 ../bootstrap --build=$TRIPLET --host=$TRIPLET > $out
187 if [ "$REBUILD" = "yes" ]; then
188 make clean
190 if [ "$CONTRIBFROMSOURCE" = "yes" ]; then
191 make fetch
192 make -j$JOBS .gettext
193 make -j$JOBS
195 if [ "$PACKAGE" = "yes" ]; then
196 make package
199 else
200 if [ ! -e "../$TRIPLET" ]; then
201 make prebuilt > $out
204 spopd
206 unset CFLAGS
207 unset CXXFLAGS
208 unset OBJCFLAGS
210 # Enable debug symbols by default
211 export CFLAGS="-g"
212 export CXXFLAGS="-g"
213 export OBJCFLAGS="-g"
216 # vlc/bootstrap
219 info "Bootstrap-ing configure"
220 spushd "${vlcroot}"
221 if ! [ -e "${vlcroot}/configure" ]; then
222 ${vlcroot}/bootstrap > $out
224 spopd
227 if [ ! -z "$VLCBUILDDIR" ];then
228 mkdir -p $VLCBUILDDIR
229 pushd $VLCBUILDDIR
232 # vlc/configure
235 if [ "${vlcroot}/configure" -nt Makefile ]; then
237 ${vlcroot}/extras/package/macosx/configure.sh \
238 --build=$TRIPLET \
239 --host=$TRIPLET \
240 --with-macosx-version-min=$MINIMAL_OSX_VERSION \
241 --with-macosx-sdk=$SDKROOT \
242 $VLC_CONFIGURE_ARGS > $out
247 # make
250 if [ "$REBUILD" = "yes" ]; then
251 info "Running make clean"
252 make clean
255 info "Running make -j$JOBS"
256 make -j$JOBS
258 info "Preparing VLC.app"
259 make VLC.app
262 if [ "$PACKAGE" = "yes" ]; then
263 info "Building VLC dmg package"
264 make package-macosx
267 if [ ! -z "$VLCBUILDDIR" ];then
268 popd