qt: playlist: use item title if available
[vlc.git] / extras / package / raspberry / build.sh
1 #!/bin/sh
2
3 set -e
4
5 info()
6 {
7     local green="\033[1;32m"
8     local normal="\033[0m"
9     echo "[${green}build${normal}] $1"
10 }
11
12 usage()
13 {
14 cat << EOF
15 usage: $0 [options]
16
17 Build vlc in the current directory
18
19 OPTIONS:
20    -h            Show some help
21    -r            Release mode (default is debug)
22    -a <arch>     Use the specified arch (default: arm, possible aarch64)
23    -p            Use a Prebuilt contrib package (speeds up compilation)
24    -c            Create a Prebuilt contrib package (rarely used)
25    -l            Enable translations (can be slow)
26    -s            Interactive shell (get correct environment variables for build)
27    -x            Add extra checks when compiling
28 EOF
29 }
30
31 ARCH="arm"
32 while getopts "hra:pcli:sdx" OPTION
33 do
34      case $OPTION in
35          h)
36              usage
37              exit 1
38          ;;
39          r)
40              RELEASE="yes"
41          ;;
42          a)
43              ARCH=$OPTARG
44          ;;
45          p)
46              PREBUILT="yes"
47          ;;
48          c)
49              PACKAGE="yes"
50          ;;
51          l)
52              I18N="yes"
53          ;;
54          s)
55              INTERACTIVE="yes"
56          ;;
57          x)
58              EXTRA_CHECKS="yes"
59          ;;
60      esac
61 done
62 shift $(($OPTIND - 1))
63
64 if [ "x$1" != "x" ]; then
65     usage
66     exit 1
67 fi
68
69 case $ARCH in
70     aarch64)
71         SHORTARCH="linuxarm64"
72         EABI="gnu"
73         ;;
74     arm)
75         SHORTARCH="linuxarm"
76         EABI="gnueabihf"
77         ;;
78     *)
79         usage
80         exit 1
81 esac
82
83 #####
84
85 SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )"
86
87 : ${JOBS:=$(getconf _NPROCESSORS_ONLN 2>&1)}
88 TRIPLET=$ARCH-linux-$EABI
89
90 info "Building extra tools"
91 mkdir -p extras/tools
92 cd extras/tools
93 export PATH="$PWD/build/bin":"$PATH"
94 if [ "$INTERACTIVE" != "yes" ] || [ ! -f ./Makefile ]; then
95     ${SCRIPT_PATH}/../../tools/bootstrap
96 fi
97 make -j$JOBS --output-sync=recurse
98 cd ../..
99
100 export USE_FFMPEG=1
101
102 if [ "$INTERACTIVE" = "yes" ]; then
103 if [ "x$SHELL" != "x" ]; then
104     exec $SHELL
105 else
106     exec /bin/sh
107 fi
108 fi
109
110 info "Building contribs"
111
112 mkdir -p contrib/contrib-$SHORTARCH && cd contrib/contrib-$SHORTARCH
113
114 # issue with arm detection of the target (detects i686)
115 CONTRIBFLAGS="$CONTRIBFLAGS --disable-x265"
116
117 ${SCRIPT_PATH}/../../../contrib/bootstrap --host=$TRIPLET $CONTRIBFLAGS
118
119 # use the system headers for the OS and firmware
120 export CFLAGS="$CFLAGS -g -mfpu=neon -isystem=/usr/lib/$TRIPLET -isystem=/opt/vc/include"
121 export CXXFLAGS="$CXXFLAGS -g -mfpu=neon -isystem=/usr/lib/$TRIPLET -isystem=/opt/vc/include"
122 export CPPFLAGS="$CPPFLAGS -g -mfpu=neon -isystem=/usr/lib/$TRIPLET -isystem=/opt/vc/include"
123 export LDFLAGS="$LDFLAGS -L/usr/$TRIPLET/lib -L/opt/vc/lib"
124
125 # Rebuild the contribs or use the prebuilt ones
126 if [ "$PREBUILT" != "yes" ]; then
127     make list
128     make -j$JOBS --output-sync=recurse fetch
129     make -j$JOBS --output-sync=recurse -k || make -j1
130     if [ "$PACKAGE" = "yes" ]; then
131         make package
132     fi
133 elif [ -n "$VLC_PREBUILT_CONTRIBS_URL" ]; then
134     make prebuilt PREBUILT_URL="$VLC_PREBUILT_CONTRIBS_URL"
135     make -j$JOBS --output-sync=recurse .luac
136 else
137     make prebuilt
138     make -j$JOBS --output-sync=recurse .luac
139 fi
140 cd ../..
141
142 info "Bootstrapping"
143 if ! [ -e ${SCRIPT_PATH}/../../../configure ]; then
144     echo "Bootstraping vlc"
145     ${SCRIPT_PATH}/../../../bootstrap
146 fi
147
148 info "Configuring VLC"
149 mkdir $SHORTARCH || true
150 cd $SHORTARCH
151
152 if [ "$RELEASE" != "yes" ]; then
153      CONFIGFLAGS="$CONFIGFLAGS --enable-debug"
154 else
155      CONFIGFLAGS="$CONFIGFLAGS --disable-debug"
156 fi
157 if [ "$I18N" != "yes" ]; then
158      CONFIGFLAGS="$CONFIGFLAGS --disable-nls"
159 fi
160 if [ ! -z "$EXTRA_CHECKS" ]; then
161     CFLAGS="$CFLAGS -Werror=incompatible-pointer-types -Werror=missing-field-initializers"
162 fi
163
164 ac_cv_path_MOC="qtchooser -qt=qt5-$TRIPLET -run-tool=moc" \
165 ac_cv_path_RCC="qtchooser -qt=qt5-$TRIPLET -run-tool=rcc" \
166 ac_cv_path_UIC="qtchooser -qt=qt5-$TRIPLET -run-tool=uic" \
167 ${SCRIPT_PATH}/configure.sh --host=$TRIPLET $CONFIGFLAGS
168
169 info "Compiling"
170 make -j$JOBS