1 #!/bin/bash
2 # ******************************************************************************
3 # * FILE PURPOSE: Environment Setup for building PDK
4 # ******************************************************************************
5 # * FILE NAME: pdksetupenv.sh
6 # *
7 # * DESCRIPTION:
8 # * Configures and sets up the Build Environment for PDK.
9 # *
10 # * The batch file expects an optional argument:PDK_INSTALL_PATH: Location
11 # * of the PDK package. If the argument is not specified the batch file
12 # * assumes that the PDK is installed in the same location where the batch
13 # * file is located and is being executed.
14 # *
15 # * USAGE:
16 # * source ./pdksetupenv.sh ~/ti/pdk_<device>_<version>/packages
17 # * --- OR ---
18 # * source ./pdksetupenv.sh
19 # *
20 # * Copyright (C) 2012-2018, Texas Instruments, Inc.
21 # *****************************************************************************
23 # *******************************************************************************
24 # ******************* CHECK IF SCRIPT WAS SOURCED OR SIMPLY RUN ***************
25 # *******************************************************************************
26 # pdksetupenv.sh must always be sourced. Sometimes, peole forget this and can run
27 # it. We display and error and a prompt whe we detect this.
28 if [[ "$(basename -- "$0")" == "pdksetupenv.sh" ]]; then
29 echo "Error!! Don't run $0, source it" >&2
30 echo "USAGE:" >&2
31 echo " source $0" >&2
32 exit 1
33 fi
35 # *******************************************************************************
36 # ********************** GET PARAMETERS PASSED THROUGH ARGUMENT ***************
37 # *******************************************************************************
38 # Parameter Validation: Check if the argument was passed to the batch file and
39 # if so we use that else we default to the working directory where the batch
40 # file was invoked from
42 tempVar=$1
43 if [ ! -z $tempVar ];then
44 export PDK_INSTALL_PATH=$tempVar
45 else
46 export PDK_INSTALL_PATH=${PWD}
47 fi
49 # Derive PDK_SOC and PDK_VERSION from the directory name PWD
50 cd ..
51 CURDIR_LAST=${PWD##*/}
52 IFS='_' read -ra ADDR <<< "$CURDIR_LAST"
54 # When pdk folder represents a device family, set a default SOC for that family
55 if [ ${ADDR[1]} == "jacinto" ]; then
56 ADDR[1]="am65xx"
57 fi
58 if [ ${ADDR[1]} == "sitara" ]; then
59 ADDR[1]="am64x"
60 fi
62 if [ -z $PDK_SOC ]; then
63 export PDK_SOC=${ADDR[1]}
64 fi
66 if [ -z "${ADDR[2]}" ]; then
67 export PDK_VERSION=
68 else
69 export PDK_VERSION=${ADDR[2]}_${ADDR[3]}_${ADDR[4]}
70 fi
71 cd -
73 # TI SDK root directory. Derive from PDK INSTALL PATH
74 if [ -z $SDK_INSTALL_PATH ]; then
75 cd ../../
76 export SDK_INSTALL_PATH=${PWD}
77 cd -
78 fi
80 # *******************************************************************************
81 # ********************** CHECK REQUIRED ENVIRONMENT DEFINES BEGIN ***************
82 # *******************************************************************************
85 # Rules.make location.
86 export RULES_MAKE="${PDK_INSTALL_PATH}/ti/build/Rules.make"
89 echo "**************************************************************************"
90 echo "Environment Configuration:"
91 echo "**************************************************************************"
92 echo " SDK_INSTALL_PATH : $SDK_INSTALL_PATH"
93 echo " PDK_INSTALL_PATH : $PDK_INSTALL_PATH"
94 echo " PDK_SOC : $PDK_SOC"
95 echo " PDK_VERSION : $PDK_VERSION"
96 echo " RULES_MAKE : $RULES_MAKE"
97 echo "**************************************************************************"