#!/bin/sh # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # # Copyright (C) 2012, 2013, 2016 O.S. Systems Software LTDA. # Authored-by: Otavio Salvador # Copyright (C) 2018 kernel concepts GmbH # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License version 2 as # published by the Free Software Foundation. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # Add options for the script # Copyright (C) 2013 Freescale Semiconductor, Inc. CWD=`pwd` PROGNAME="setup-environment" usage() { echo -e " Usage: MACHINE= DISTRO= source $PROGNAME Usage: source $PROGNAME machine name distro name build directory The first usage is for creating a new build directory. In this case, the script creates the build directory , configures it for the specified and , and prepares the calling shell for running bitbake on the build directory. The second usage is for using an existing build directory. In this case, the script prepares the calling shell for running bitbake on the build directory . The build directory configuration is unchanged. " ls yocto/*/conf/machine/*.conf > /dev/null 2>&1 # ls sources/meta-freescale-distro/conf/distro/fslc-*.conf > /dev/null 2>&1 if [ $? -eq 0 ]; then echo -e " Supported machines: `echo; ls conf/*/conf/machine/*.conf \ | sed s/\.conf//g | sed -r 's/^.+\///' | xargs -I% echo -e "\t%"` Available Poky's distros: `echo; ls yocto/poky/meta-poky/conf/distro/*.conf \ | sed s/\.conf//g | sed -r 's/^.+\///' | xargs -I% echo -e "\t%"` Examples: - To create a new Yocto build directory: $ MACHINE=tx6q-xxxx DISTRO=poky . $PROGNAME build - To use an existing Yocto build directory: $ . $PROGNAME build " fi } clean_up() { unset LIST_MACHINES VALID_MACHINE unset CWD TEMPLATES SHORTOPTS LONGOPTS ARGS PROGNAME unset generated_config updated unset MACHINE SDKMACHINE DISTRO OEROOT } # source default sdk configuration if [ -e sdkdefaults.conf ]; then . sdkdefaults.conf fi # get command line options SHORTOPTS="h" LONGOPTS="help" ARGS=$(getopt --options $SHORTOPTS \ --longoptions $LONGOPTS --name $PROGNAME -- "$@" ) # Print the usage menu if invalid options are specified if [ $? != 0 -o $# -lt 1 ]; then usage && clean_up return 1 fi eval set -- "$ARGS" while true; do case $1 in -h|--help) usage clean_up return 0 ;; --) shift break ;; esac done if [ "$(whoami)" = "root" ]; then echo "ERROR: do not use the BSP as root. Exiting..." fi if [ ! -e $1/conf/local.conf.sample ]; then build_dir_setup_enabled="true" else build_dir_setup_enabled="false" fi if [ "$build_dir_setup_enabled" = "true" ] && [ -z "$MACHINE" ]; then usage echo -e "ERROR: You must set MACHINE when creating a new build directory." clean_up return 1 fi if [ -z "$SDKMACHINE" ]; then SDKMACHINE='i686' fi if [ "$build_dir_setup_enabled" = "true" ] && [ -z "$DISTRO" ]; then usage echo -e "ERROR: You must set DISTRO when creating a new build directory." clean_up return 1 fi OEROOT=$PWD/yocto/poky if [ -e $PWD/yocto/oe-core ]; then OEROOT=$PWD/yocto/oe-core fi . $OEROOT/oe-init-build-env $CWD/$1 > /dev/null # if conf/local.conf not generated, no need to go further if [ ! -e conf/local.conf ]; then clean_up && return 1 fi # Clean up PATH, because if it includes tokens to current directories somehow, # wrong binaries can be used instead of the expected ones during task execution export PATH="`echo $PATH | sed 's/\(:.\|:\)*:/:/g;s/^.\?://;s/:.\?$//'`" generated_config= if [ "$build_dir_setup_enabled" = "true" ]; then mv conf/local.conf conf/local.conf.sample # Generate the local.conf based on the Yocto defaults TEMPLATES=$CWD/yocto/meta-kc-bsp/conf grep -v '^#\|^$' conf/local.conf.sample > conf/local.conf cat >> conf/local.conf <' Common targets are: EOF if [ -z "$COMMON_TARGETS" ]; then echo core-image-minimal echo meta-toolchain else echo "$COMMON_TARGETS" fi if [ -n "$generated_config" ]; then cat <