summaryrefslogtreecommitdiffstats
path: root/scripts/poky-find-native-sysroot
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/poky-find-native-sysroot')
-rwxr-xr-xscripts/poky-find-native-sysroot77
1 files changed, 77 insertions, 0 deletions
diff --git a/scripts/poky-find-native-sysroot b/scripts/poky-find-native-sysroot
new file mode 100755
index 0000000000..fe36a2a932
--- /dev/null
+++ b/scripts/poky-find-native-sysroot
@@ -0,0 +1,77 @@
1#!/bin/bash
2#
3# Find a native sysroot to use - either from an in-tree Poky build or
4# from a toolchain installation in /opt/poky. It then sets the variables
5# $NATIVE_SYSROOT_DIR to the sysroot's base directory, $PSEUDO to the
6# path of the pseudo binary, and $SYSROOT_MODE is set to "in-tree" or
7# "toolchain".
8#
9# This script is intended to be run within other scripts by source'ing
10# it, e.g:
11#
12# SYSROOT_SETUP_SCRIPT=`which poky-find-native-sysroot`
13# . $SYSROOT_SETUP_SCRIPT
14#
15# This script will terminate execution of your calling program unless
16# you set a variable $SKIP_STRICT_SYSROOT_CHECK to a non-empty string
17# beforehand.
18#
19# Copyright (c) 2010 Intel Corp.
20#
21# This program is free software; you can redistribute it and/or modify
22# it under the terms of the GNU General Public License version 2 as
23# published by the Free Software Foundation.
24#
25# This program is distributed in the hope that it will be useful,
26# but WITHOUT ANY WARRANTY; without even the implied warranty of
27# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28# GNU General Public License for more details.
29#
30# You should have received a copy of the GNU General Public License along
31# with this program; if not, write to the Free Software Foundation, Inc.,
32# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
33
34BITBAKE=`which bitbake`
35if [ -z "$BITBAKE" ]; then
36 SYSROOT_MODE="toolchain"
37 NATIVE_SYSROOT_DIR=`find /opt/poky -name "tunctl" | sed 's/\/usr\/bin\/tunctl//'`
38else
39 SYSROOT_MODE="in-tree"
40 if [ "$UID" = "0" ]; then
41 # Root cannot run bitbake unless sanity checking is disabled
42 if [ ! -d "./conf" ]; then
43 echo "Error: root cannot run bitbake by default, and I cannot find a ./conf directory to be able to disable sanity checking"
44 exit 1
45 fi
46 touch conf/sanity.conf
47 NATIVE_SYSROOT_DIR=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '=' -f2 | cut -d '"' -f2`
48 rm -f conf/sanity.conf
49 else
50 NATIVE_SYSROOT_DIR=`bitbake -e | grep ^STAGING_DIR_NATIVE | cut -d '=' -f2 | cut -d '"' -f2`
51 fi
52fi
53
54if [ -z "$NATIVE_SYSROOT_DIR" ]; then
55 echo "Error: Unable to locate your native sysroot."
56 echo "Did you forget to source the Poky environment script?"
57
58 if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
59 exit 1
60 fi
61fi
62
63# Set up pseudo command
64if [ ! -e "$NATIVE_SYSROOT_DIR/usr/bin/pseudo" ]; then
65 echo "Error: Unable to find pseudo binary in $NATIVE_SYSROOT_DIR/usr/bin/"
66
67 if [ "$SYSROT_MODE" = "in-tree" ]; then
68 echo "Have you run 'bitbake pseudo-native'?"
69 else
70 echo "This shouldn't happen - something is wrong with your toolchain installation"
71 fi
72
73 if [ -z "$SKIP_STRICT_SYSROOT_CHECK" ]; then
74 exit 1
75 fi
76fi
77PSEUDO="$NATIVE_SYSROOT_DIR/usr/bin/pseudo"