#!/bin/sh shopt -s xpg_echo # -*- mode: shell-script; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- # # Copyright (C) 2012, 2013 O.S. Systems Software LTDA. # Authored-by: Otavio Salvador # # 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. NCPU=`grep -c processor /proc/cpuinfo` CWD=`pwd` PROGNAME="setup-environment" usage() { echo "\nUsage: source $PROGNAME : required option; specifies build directory location By default the script will setup MACHINE to be imx6solo-3dr-1080p. Supported machines: `ls sources/*/conf/machine/*.conf \ | sed s/\.conf//g | sed -r 's/^.+\///' | xargs echo` To build for a machine listed above, run this script as: MACHINE= source $PROGNAME The script sets PARALLEL_MAKE & BB_NUMBER_THREADS to $NCPU " } clean_up() { unset EULA LIST_MACHINES VALID_MACHINE unset NCPU CWD TEMPLATES SHORTOPTS LONGOPTS ARGS PROGNAME } # 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 exit 1 fi eval set -- "$ARGS" while true; do case $1 in -h|--help) usage clean_up exit 0 ;; --) shift break ;; esac done if [ "$(whoami)" = "root" ]; then echo "\nERROR: do not use the BSP as root. Exiting..." exit 1 fi if [ -z "$MACHINE" ]; then MACHINE='imx6solo-3dr-1080p' fi # Check the machine type specified LIST_MACHINES=`ls -1 $CWD/sources/*/conf/machine` VALID_MACHINE=`echo -e "$LIST_MACHINES" | grep ${MACHINE}.conf$ | wc -l` if [ "x$MACHINE" = "x" ] || [ "$VALID_MACHINE" = "0" ]; then echo"\nERROR: Invalid machine type" usage && clean_up exit 1 else echo "Configuring for ${MACHINE}" fi if [ -z "$SDKMACHINE" ]; then SDKMACHINE='i686' fi if [ -z "$DISTRO" ]; then DISTRO='3dr' fi OEROOT=sources/poky if [ -e sources/oe-core ]; then OEROOT=sources/oe-core fi # Ensure all files in sources/base are kept in sync with project root updated= for f in $CWD/sources/base/*; do file="$(basename $f)" if [ "$file" = "conf" ] || echo $file | grep -q '~$'; then continue fi if ! cmp -s "$file" "$f"; then updated="true" [ -e $file ] && chmod u+w $file cp $f $file fi done if [ "$updated" = "true" ]; then echo "\nACTION REQUIRED: The project root content has been updated. Please run $0 again." exit 1 fi cd $OEROOT . ./oe-init-build-env $CWD/$1 > /dev/null # 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 [ ! -e conf/local.conf.sample ]; then mv conf/local.conf conf/local.conf.sample # Generate the local.conf based on the Yocto defaults TEMPLATES=$CWD/sources/base/conf grep -v '^#\|^$' conf/local.conf.sample > conf/local.conf cat >> conf/local.conf <' Common targets are: core-image-minimal meta-toolchain meta-toolchain-sdk adt-installer meta-ide-support EOF if [ -n "$generated_config" ]; then cat <