2 # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
4 # Copyright (C) 2012, 2013, 2016 O.S. Systems Software LTDA.
5 # Authored-by: Otavio Salvador <otavio@ossystems.com.br>
6 # Copyright (C) 2018 kernel concepts GmbH
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License version 2 as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 # Add options for the script
22 # Copyright (C) 2013 Freescale Semiconductor, Inc.
25 PROGNAME="setup-environment"
30 Usage: . $PROGNAME <build-dir>
31 Usage: MACHINE=<machine> DISTRO=<distro> source $PROGNAME <build-dir>
32 Usage: source $PROGNAME <build-dir>
33 <machine> machine name
34 <distro> distribution name
35 <build-dir> build directory
37 The first usage is for creating a new build directory. In this case, the
38 script creates the build directory <build-dir> and confgures it according
39 to the supplied sdkdefaults.conf. Optionally it configures it for the
40 specified <machine> and <distro>, and prepares the calling shell for running
41 bitbake on the build directory.
43 The second usage is for using an existing build directory. In this case,
44 the script prepares the calling shell for running bitbake on the build
45 directory <build-dir>. The build directory configuration is unchanged.
48 ls yocto/*/conf/machine/*.conf > /dev/null 2>&1
49 # ls sources/meta-freescale-distro/conf/distro/fslc-*.conf > /dev/null 2>&1
52 Supported machines: `echo; ls conf/*/conf/machine/*.conf \
53 | sed s/\.conf//g | sed -r 's/^.+\///' | xargs -I% echo -e "\t%"`
55 Available Poky's distros: `echo; ls yocto/poky/meta-poky/conf/distro/*.conf \
56 | sed s/\.conf//g | sed -r 's/^.+\///' | xargs -I% echo -e "\t%"`
60 - To use an existing Yocto build directory or create a new buil dir using
61 the supplied defaults.
64 - To create a new Yocto build directory:
65 $ MACHINE=tx6q-xxxx DISTRO=poky . $PROGNAME build
73 unset LIST_MACHINES VALID_MACHINE
74 unset CWD TEMPLATES SHORTOPTS LONGOPTS ARGS PROGNAME
75 unset generated_config updated
76 unset MACHINE SDKMACHINE DISTRO OEROOT
79 # source default sdk configuration
80 if [ -e sdkdefaults.conf ]; then
85 # get command line options
89 ARGS=$(getopt --options $SHORTOPTS \
90 --longoptions $LONGOPTS --name $PROGNAME -- "$@" )
91 # Print the usage menu if invalid options are specified
92 if [ $? != 0 -o $# -lt 1 ]; then
113 if [ "$(whoami)" = "root" ]; then
114 echo "ERROR: do not use the BSP as root. Exiting..."
117 if [ ! -e $1/conf/local.conf.sample ]; then
118 build_dir_setup_enabled="true"
120 build_dir_setup_enabled="false"
123 if [ "$build_dir_setup_enabled" = "true" ] && [ -z "$MACHINE" ]; then
125 echo -e "ERROR: You must set MACHINE when creating a new build directory."
130 if [ -z "$SDKMACHINE" ]; then
134 if [ "$build_dir_setup_enabled" = "true" ] && [ -z "$DISTRO" ]; then
136 echo -e "ERROR: You must set DISTRO when creating a new build directory."
142 OEROOT=$PWD/yocto/poky
143 if [ -e $PWD/yocto/oe-core ]; then
144 OEROOT=$PWD/yocto/oe-core
147 . $OEROOT/oe-init-build-env $CWD/$1 > /dev/null
149 # if conf/local.conf not generated, no need to go further
150 if [ ! -e conf/local.conf ]; then
154 # Clean up PATH, because if it includes tokens to current directories somehow,
155 # wrong binaries can be used instead of the expected ones during task execution
156 export PATH="`echo $PATH | sed 's/\(:.\|:\)*:/:/g;s/^.\?://;s/:.\?$//'`"
159 if [ "$build_dir_setup_enabled" = "true" ]; then
160 mv conf/local.conf conf/local.conf.sample
162 # Generate the local.conf based on the Yocto defaults
163 TEMPLATES=$CWD/yocto/meta-kc-bsp/conf
164 cat conf/local.conf.sample > conf/local.conf
165 cat >> conf/local.conf <<EOF
167 DL_DIR ?= "\${BSPDIR}/downloads/"
169 # Change settings according environment
170 sed -e "s,MACHINE ?=.*,MACHINE ?= '$MACHINE',g" \
171 -e "s,DISTRO ?=.*,DISTRO ?= '$DISTRO',g" \
174 cp $TEMPLATES/* conf/
176 for s in $HOME/.oe $HOME/.yocto; do
177 if [ -e $s/site.conf ]; then
178 echo "Linking $s/site.conf to conf/site.conf"
179 ln -s $s/site.conf conf
188 Welcome to kernel concepts custom BSP
190 The Yocto Project has extensive documentation about OE including a
191 reference manual which can be found at:
192 http://yoctoproject.org/documentation
194 For more information about OpenEmbedded see their website:
195 http://www.openembedded.org/
197 You can now run 'bitbake <target>'
203 if [ -z "$COMMON_TARGETS" ]; then
205 echo core-image-minimal
210 echo "$COMMON_TARGETS"
215 if [ -n "$generated_config" ]; then
217 Your build environment has been configured with:
224 echo "Your configuration files at $1 have not been touched."