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: MACHINE=<machine> DISTRO=<distro> source $PROGNAME <build-dir>
31 Usage: source $PROGNAME <build-dir>
32 <machine> machine name
34 <build-dir> build directory
36 The first usage is for creating a new build directory. In this case, the
37 script creates the build directory <build-dir>, configures it for the
38 specified <machine> and <distro>, and prepares the calling shell for running
39 bitbake on the build directory.
41 The second usage is for using an existing build directory. In this case,
42 the script prepares the calling shell for running bitbake on the build
43 directory <build-dir>. The build directory configuration is unchanged.
46 ls yocto/*/conf/machine/*.conf > /dev/null 2>&1
47 # ls sources/meta-freescale-distro/conf/distro/fslc-*.conf > /dev/null 2>&1
50 Supported machines: `echo; ls conf/*/conf/machine/*.conf \
51 | sed s/\.conf//g | sed -r 's/^.+\///' | xargs -I% echo -e "\t%"`
53 Available Poky's distros: `echo; ls yocto/poky/meta-poky/conf/distro/*.conf \
54 | sed s/\.conf//g | sed -r 's/^.+\///' | xargs -I% echo -e "\t%"`
58 - To create a new Yocto build directory:
59 $ MACHINE=tx6q-xxxx DISTRO=poky . $PROGNAME build
61 - To use an existing Yocto build directory:
69 unset LIST_MACHINES VALID_MACHINE
70 unset CWD TEMPLATES SHORTOPTS LONGOPTS ARGS PROGNAME
71 unset generated_config updated
72 unset MACHINE SDKMACHINE DISTRO OEROOT
75 # source default sdk configuration
76 if [ -e sdkdefaults.conf ]; then
81 # get command line options
85 ARGS=$(getopt --options $SHORTOPTS \
86 --longoptions $LONGOPTS --name $PROGNAME -- "$@" )
87 # Print the usage menu if invalid options are specified
88 if [ $? != 0 -o $# -lt 1 ]; then
109 if [ "$(whoami)" = "root" ]; then
110 echo "ERROR: do not use the BSP as root. Exiting..."
113 if [ ! -e $1/conf/local.conf.sample ]; then
114 build_dir_setup_enabled="true"
116 build_dir_setup_enabled="false"
119 if [ "$build_dir_setup_enabled" = "true" ] && [ -z "$MACHINE" ]; then
121 echo -e "ERROR: You must set MACHINE when creating a new build directory."
126 if [ -z "$SDKMACHINE" ]; then
130 if [ "$build_dir_setup_enabled" = "true" ] && [ -z "$DISTRO" ]; then
132 echo -e "ERROR: You must set DISTRO when creating a new build directory."
138 OEROOT=$PWD/yocto/poky
139 if [ -e $PWD/yocto/oe-core ]; then
140 OEROOT=$PWD/yocto/oe-core
143 . $OEROOT/oe-init-build-env $CWD/$1 > /dev/null
145 # if conf/local.conf not generated, no need to go further
146 if [ ! -e conf/local.conf ]; then
150 # Clean up PATH, because if it includes tokens to current directories somehow,
151 # wrong binaries can be used instead of the expected ones during task execution
152 export PATH="`echo $PATH | sed 's/\(:.\|:\)*:/:/g;s/^.\?://;s/:.\?$//'`"
155 if [ "$build_dir_setup_enabled" = "true" ]; then
156 mv conf/local.conf conf/local.conf.sample
158 # Generate the local.conf based on the Yocto defaults
159 TEMPLATES=$CWD/yocto/meta-kc-bsp/conf
160 grep -v '^#\|^$' conf/local.conf.sample > conf/local.conf
161 cat >> conf/local.conf <<EOF
163 DL_DIR ?= "\${BSPDIR}/downloads/"
165 # Change settings according environment
166 sed -e "s,MACHINE ?=.*,MACHINE ?= '$MACHINE',g" \
167 -e "s,DISTRO ?=.*,DISTRO ?= '$DISTRO',g" \
170 cp $TEMPLATES/* conf/
172 for s in $HOME/.oe $HOME/.yocto; do
173 if [ -e $s/site.conf ]; then
174 echo "Linking $s/site.conf to conf/site.conf"
175 ln -s $s/site.conf conf
184 Welcome to kernel concepts custom BSP
186 The Yocto Project has extensive documentation about OE including a
187 reference manual which can be found at:
188 http://yoctoproject.org/documentation
190 For more information about OpenEmbedded see their website:
191 http://www.openembedded.org/
193 You can now run 'bitbake <target>'
199 if [ -z "$COMMON_TARGETS" ]; then
201 echo core-image-minimal
206 echo "$COMMON_TARGETS"
211 if [ -n "$generated_config" ]; then
213 Your build environment has been configured with:
220 echo "Your configuration files at $1 have not been touched."