Add DragonBoard-410c as target board
[AGL/meta-agl.git] / scripts / envsetup.sh
1 #!/bin/bash
2
3 find_and_ack_eula() {
4     # Handle EULA , if needed. This is a generic method to handle BSPs
5     # that might (or not) come with a EULA. If a machine has a EULA, we
6     # assume that its corresponding layers has conf/EULA/$MACHINE file
7     # with the EULA text, which we will display to the user and request
8     # for acceptance. If accepted, the variable ACCEPT_EULA_$MACHINE is
9     # set to 1 in local.conf, which can later be used by the BSP.
10     # If the env variable EULA_$MACHINE is set it is used by default,
11     # without prompting the user.
12     # FIXME: there is a potential issue if the same $MACHINE is set in more than one layer.. but we should assert that earlier
13     EULA=$(find $1 -print | grep "conf/eula/$MACHINE" | grep -v scripts | grep -v openembedded-core || true)
14     if [ -n "$EULA" ]; then
15         # remove '-' since we are constructing a bash variable name here
16         EULA_MACHINE="EULA_$(echo $MACHINE | sed 's/-//g')"
17         # NOTE: indirect reference / dynamic variable
18         if [ -n "${!EULA_MACHINE}" ]; then
19             # the EULA_$MACHINE variable is set in the environment, so we just configure
20             # ACCEPT_EULA_$MACHINE in local.conf
21             EULA_ACCEPT=${!EULA_MACHINE}
22         else
23             # so we need to ask user if he/she accepts the EULA:
24             cat <<EOF
25 The BSP for $MACHINE depends on packages and firmware which are covered by an 
26 End User License Agreement (EULA). To have the right to use these binaries
27 in your images, you need to read and accept the following...
28
29 The firmware package can contains several types
30 of firmware (depending on BSP):
31
32 * bootloaders: the first stage bootloaders are proprietary for this
33   board, they are included in this firmware package.
34 * firmware for the power management 'companion' core: on QCOM SoC some
35   power management features are implemented in a companion core , called
36   RPM, and not on the main CPU.
37 * firmware for GPU, WLAN, DSP/GPS and video codecs. These firmware are
38   used by their respective linux drivers (DRM, wlan, v4l2, .. ) and are
39   loaded on-demand by the main CPU onto the various cores on the SoC.
40 EOF
41
42             echo
43             REPLY=
44             while [ -z "$REPLY" ]; do
45                 echo -n "Do you read the EULA ? (y/n) "
46                 read REPLY
47                 case "$REPLY" in
48                     y|Y)
49                         READ_EULA=1
50                         ;;
51                     n|N)
52                         READ_EULA=0
53                         ;;
54                     *)
55                         REPLY=
56                         ;;
57                 esac
58             done
59
60             if [ "$READ_EULA" == 1 ]; then
61                 more -d ${EULA}
62                 echo
63                 REPLY=
64                 while [ -z "$REPLY" ]; do
65                     echo -n "Do you accept the EULA you just read? (y/n) "
66                     read REPLY
67                     case "$REPLY" in
68                         y|Y)
69                             echo "EULA has been accepted."
70                             EULA_ACCEPT=1
71                             ;;
72                         n|N)
73                             echo "EULA has not been accepted."
74                             ;;
75                         *)
76                             REPLY=
77                             ;;
78                     esac
79                 done
80             fi
81         fi
82     fi
83 }
84
85 if [ -z $1 ]; then
86         echo -e "Usage: source envsetup.sh <board/device> [build dir]"
87         return 1
88 fi
89
90 MACHINE="$1"
91 echo "MACHINE=$MACHINE"
92
93 EULA_ACCEPT=0
94
95 case "$MACHINE" in
96         "porter")
97                 # setup proprietary gfx drivers and multimedia packages
98                 COPY_MM_SCRIPT=meta-renesas/meta-rcar-gen2/scripts/setup_mm_packages.sh
99                 if [ -f $COPY_MM_SCRIPT ]; then
100                         . $COPY_MM_SCRIPT
101                         copy_mm_packages $1
102                         if [ $? -ne 0 ]; then
103                                 echo "Copying gfx drivers and multimedia packages for '$1' failed."
104                                 return 1
105                         fi
106                 fi
107
108                 if [ ! -d "$TEMPLATECONF" ]; then
109                     # set template conf for R-Car2 M2 Porter board
110                     TEMPLATECONF="$PWD/meta-renesas/meta-rcar-gen2/conf"
111                 fi
112                 ;;
113         "porter-nogfx")
114                 MACHINE="porter"
115                 if [ ! -d "$TEMPLATECONF" ]; then
116                     # set template conf for R-Car2 M2 Porter board
117                     TEMPLATECONF="$PWD/meta-renesas/meta-rcar-gen2/conf"
118                 fi
119                 ;;
120         "raspberrypi3")
121                 ;;
122         "raspberrypi2")
123                 ;;
124         "intel-corei7-64")
125                 ;;
126         "minnowboard")
127                 # alias for minnowboardmax
128                 MACHINE="intel-corei7-64"
129                 ;;
130         "qemux86")
131                 ;;
132         "qemux86-64")
133                 ;;
134         "dra7xx-evm")
135                 ;;
136         "vayu")
137                 # nickname for dra7xx-evm
138                 MACHINE="dra7xx-evm"
139                 ;;
140         "wandboard")
141                 ;;
142         "dragonboard-410c")
143                 find_and_ack_eula meta-qcom
144                 ;;
145         *)
146                 # nothing to do here
147                 echo "WARN: '$MACHINE' is not tested by AGL Distro"
148                 ;;
149 esac
150
151 echo "TEMPALTECONF=$TEMPLATECONF"
152 # set template conf for each <board/device>
153 if [ -z "$TEMPLATECONF" ]; then
154     # lookup meta-agl-demo first
155     if [ -d "$PWD/meta-agl-demo/templates/$MACHINE/conf" ]; then
156         TEMPLATECONF="$PWD/meta-agl-demo/templates/$MACHINE/conf"
157     # lookup meta-agl 2nd
158     elif [ -d "$PWD/meta-agl/templates/$MACHINE/conf" ]; then
159         TEMPLATECONF="$PWD/meta-agl/templates/$MACHINE/conf"
160     fi
161 fi
162 echo "TEMPLATECONF=$TEMPLATECONF"
163
164 echo "envsetup: Set '$1' as MACHINE."
165 export MACHINE
166
167 # fallback
168 if [ ! -d "$TEMPLATECONF" ]; then
169    # Allow to use templates at meta-agl-demo/conf
170    TEMPLATECONF="$PWD/meta-agl-demo/conf"
171 fi
172
173 echo "envsetup: Using templates for local.conf & bblayers.conf from :"
174 echo "          '$TEMPLATECONF'"
175 export TEMPLATECONF
176
177 if [ -n "$2" ]; then
178   BUILD_DIR="$2"
179 else
180   BUILD_DIR=build
181 fi
182
183 echo "envsetup: Setup build environment for poky/oe."
184 echo -e
185
186 source poky/oe-init-build-env $BUILD_DIR
187
188 if [ -n "$DL_DIR" ]; then
189         BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE DL_DIR"
190 fi
191
192 if [ -n "$SSTATE_DIR" ]; then
193         BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE SSTATE_DIR"
194 fi
195
196 export BB_ENV_EXTRAWHITE
197
198 unset TEMPLATECONF
199
200 case "$EULA_ACCEPT" in
201     1)
202         echo "" >> conf/local.conf
203         echo "# EULA" >> conf/local.conf
204         echo "ACCEPT_EULA_$MACHINE = \"1\"" >> conf/local.conf
205         ;;
206     *)
207         ;;
208 esac