build_oai.bash 10.3 KB
Newer Older
1 2 3 4 5 6 7
################################################################################
#   OpenAirInterface
#   Copyright(c) 1999 - 2014 Eurecom
#
#    OpenAirInterface is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
nikaeinn's avatar
nikaeinn committed
8
#    (at your option) anylater version.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
#
#
#    OpenAirInterface 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 OpenAirInterface.The full GNU General Public License is
#    included in this distribution in the file called "COPYING". If not,
#    see <http://www.gnu.org/licenses/>.
#
#  Contact Information
#  OpenAirInterface Admin: openair_admin@eurecom.fr
#  OpenAirInterface Tech : openair_tech@eurecom.fr
#  OpenAirInterface Dev  : openair4g-devel@eurecom.fr
#
#  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
#
################################################################################
# file build_oai.bash
# brief
# author  Navid Nikaein 
# company Eurecom
# email:  navid.nikaein@eurecom.fr 
#

#!/bin/bash
################################
# include helper functions
################################
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
. $THIS_SCRIPT_PATH/build_helper.bash

43
check_for_root_rights
44 45

#######################################
46
# Default PARAMETERS
47 48 49
######################################

HW="EXMIMO" # EXMIMO, USRP, NONE
nikaeinn's avatar
nikaeinn committed
50 51
TARGET="ALL" # ALL, SOFTMODEM, OAISIM, UNISIM, NONE
ENB_S1=1
52 53 54 55 56
REL="REL8" # REL8, REL10
RT="RTAI" # RTAI, RT_PREMPT or RT_DISABLED
DEBUG=0

OAI_TEST=0
57
XFORMS=0
nikaeinn's avatar
nikaeinn committed
58

59
# script is not currently handling these params
nikaeinn's avatar
nikaeinn committed
60 61
EPC=0 # flag to build EPC

62 63 64 65
ITTI_ANALYZER=0
VCD_TIMING=0
WIRESHARK=0
TIME_MEAS=0
nikaeinn's avatar
nikaeinn committed
66
DEV=0
67 68 69 70 71

EMULATION_DEV_INTERFACE="eth0"
EMULATION_MULTICAST_GROUP=1
EMULATION_DEV_ADDRESS=`ifconfig $EMULATION_DEV_INTERFACE | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk '{ print $1}'`

nikaeinn's avatar
nikaeinn committed
72
############## script params #####################
73

nikaeinn's avatar
nikaeinn committed
74
if [ -f ./.lock_oaibuild ]; then 
75
    OAI_CLEAN=0
nikaeinn's avatar
nikaeinn committed
76
else 
77
    OAI_CLEAN=1
nikaeinn's avatar
nikaeinn committed
78 79
fi 
 
80 81 82 83 84
#for i in "$@"
#do 
#    echo "i is : $i"
#    case $i in

85
while getopts "bcdmsxzhe:w:r:t:" OPTION; do
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
   case "$OPTION" in
       b)
	   ENB_S1=1
	   echo "setting eNB S1 flag to: $ENB_S1"
	   ;;
       c)
	   rm -rf ./.lock_oaibuild
	   OAI_CLEAN=1
	   echo "setting clean flag to: $OAI_CLEAN"
	   ;;
       d)
	   DEBUG=1
	   echo "setting debug flag to: $DEBUG"
	   ;;
       e)
	   RT="$OPTARG"
	   echo "setting realtime flag to: $RT"
	   ;;
       h)
105 106
	   print_help
	   exit -1
107 108 109 110
	   ;;
       m)
	   BUILD_FROM_MAKEFILE=1
	   set_build_from_makefile $BUILD_FROM_MAKEFILE
111
	   echo "setting a flag to build from makefile to: $BUILD_FROM_MAKEFILE"
112 113 114 115 116 117 118 119 120 121 122 123 124
	   ;;
       r)
	   REL="$OPTARG" 
	   echo "setting release to: $REL"
	   ;;
       s)
	   OAI_TEST=1
	   echo "setting sanity check to: $OAI_TEST"
	   ;;
       t)
	   TARGET="$OPTARG" 
	   echo "setting target to: $TARGET"
	   ;;
125 126 127 128
       w)
	   HW="$OPTARG" #"${i#*=}"
	   echo "setting hardware to: $HW"
	   ;;
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
       x)
	   XFORMS=1
	   echo "setting xforms to: $XFORMS"
	   ;;
       z)
	   echo "setting all parameters to: default"
	   rm -rf ./.lock_oaibuild
	   OAI_CLEAN=1
	   HW="EXMIMO"
	   TARGET="ALL" 
	   ENB_S1=1
	   REL="REL8" 
	   RT="RTAI"
	   DEBUG=0
	   ENB_CONFIG_FILE=$OPENAIR_TARGETS/"PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.conf"
	   OAI_TEST=0
  	   ;;
       *)
nikaeinn's avatar
nikaeinn committed
147
            # unknown option
148 149
	   ;;
   esac
nikaeinn's avatar
nikaeinn committed
150 151
done

152 153 154 155 156 157 158 159 160 161
#####################
# create a bin dir
#####################
echo_info "3. Creating the bin dir ..." 
rm -rf bin
mkdir -m 777 -p bin 

build_date=`date +%Y_%m_%d`
oai_build_date="oai_built_${build_date}"
touch bin/${oai_build_date} 
nikaeinn's avatar
nikaeinn committed
162
touch bin/install_log.txt
163 164 165
################################
# cleanup first 
################################
166
#echo_info "3. Cleaning ..."
167

168 169 170 171
#$SUDO kill -9 `ps -ef | grep oaisim | awk '{print $2}'` 2>&1
#$SUDO kill -9 `ps -ef | grep lte-softmodem | awk '{print $2}'`  2>&1
#$SUDO kill -9 `ps -ef | grep dlsim | awk '{print $2}'`  2>&1
#$SUDO kill -9 `ps -ef | grep ulsim | awk '{print $2}'`  2>&1
nikaeinn's avatar
nikaeinn committed
172

173 174 175
##########################################
# process parameters
#########################################
nikaeinn's avatar
nikaeinn committed
176

177
echo_info "2. Process the parameters"
178 179

echo_info "User-defined Parameters :  HW=$HW, TARGET=$TARGET, ENB_S1=$ENB_S1, REL=$REL, RT=$RT, DEBUG=$DEBUG XFORMS=$XFORMS"
nikaeinn's avatar
nikaeinn committed
180

181 182
echo "User-defined Parameters :  HW=$HW, TARGET=$TARGET, ENB_S1=$ENB_S1, REL=$REL, RT=$RT, DEBUG=$DEBUG XFORMS=$XFORMS" >> bin/${oai_build_date}

183 184 185 186 187
 
############################################
# compilation directives 
############################################

188
echo_info "3. building the compilation directives ..."
189

nikaeinn's avatar
nikaeinn committed
190 191
SOFTMODEM_DIRECTIVES="ENB_S1=$ENB_S1 DEBUG=$DEBUG XFORMS=$XFORMS "
OAISIM_DIRECTIVES="ENB_S1=$ENB_S1 DEBUG=$DEBUG XFORMS=$XFORMS "
192 193
if [ $HW = "USRP" ]; then 
    SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES USRP=1 "
194 195 196 197
else 
    if [ $HW != "EXMIMO" ]; then 
	HW="NONE"
    fi
198
fi
nikaeinn's avatar
nikaeinn committed
199
if [ $ENB_S1 -eq 0 ]; then 
200 201 202 203 204 205 206 207 208 209 210
    SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES NAS=1 "
    OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES NAS=1 "
fi 
if [ $REL = "REL8" ]; then
    SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel8=1 "
    OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel8=1 "
else 
    SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES Rel10=1 "
    OAISIM_DIRECTIVES="$OAISIM_DIRECTIVES Rel10=1 "
fi
if [ $RT = "RTAI" ]; then 
211
    if [ ! -f /usr/realtime/modules/rtai_hal.ko ];   then
nikaeinn's avatar
nikaeinn committed
212
	echo_warning "RTAI doesn't seem to be installed"
nikaeinn's avatar
nikaeinn committed
213 214
	RT="RT_PREMPT"
	SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 "
215 216
    else 
	SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES HARD_RT=1 "
nikaeinn's avatar
nikaeinn committed
217
    fi
nikaeinn's avatar
nikaeinn committed
218 219 220 221
else 
    if [ $RT = "RT_PREEMPT" ]; then 
	SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES RTAI=0 "
    fi	
222 223
fi

nikaeinn's avatar
nikaeinn committed
224
if [ $TARGET != "ALL" ]; then 
225 226
    if [ $TARGET  != "SOFTMODEM" ]; then 
	HW="NONE"
nikaeinn's avatar
nikaeinn committed
227 228 229
    fi
fi

230 231 232 233 234 235 236
output=$(check_for_machine_type 2>&1) 
MACHINE_ARCH=$?
if [ $MACHINE_ARCH -eq 64 ]; then
    SOFTMODEM_DIRECTIVES="$SOFTMODEM_DIRECTIVES LIBCONFIG_LONG=1 "
    OAISIM_DIRECTIVES="$OASIM_DIRECTIVES LIBCONFIG_LONG=1 "
fi

nikaeinn's avatar
nikaeinn committed
237 238
echo_success "SOFTMODEM Compilation directives: $SOFTMODEM_DIRECTIVES"
echo_success "OAISIM Compilation directives:    $OAISIM_DIRECTIVES"
239

nikaeinn's avatar
nikaeinn committed
240
echo "SOFTMODEM Compilation directives: $SOFTMODEM_DIRECTIVES" >>  bin/${oai_build_date}
241 242 243
echo "OAISIM Compilation directive:    $OAISIM_DIRECTIVES" >>  bin/${oai_build_date}

############################################
244
# setting and printing OAI envs, we should check here
245 246
############################################

247 248
echo_info "3. Setting the OAI PATHS ..."

nikaeinn's avatar
nikaeinn committed
249
set_openair_env 
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
cecho "OPENAIR_HOME    = $OPENAIR_HOME" $green
cecho "OPENAIR1_DIR    = $OPENAIR1_DIR" $green
cecho "OPENAIR2_DIR    = $OPENAIR2_DIR" $green
cecho "OPENAIR3_DIR    = $OPENAIR3_DIR" $green
cecho "OPENAIRCN_DIR   = $OPENAIRCN_DIR" $green
cecho "OPENAIR_TARGETS = $OPENAIR_TARGETS" $green


echo "OPENAIR_HOME    = $OPENAIR_HOME" >>  bin/${oai_build_date}
echo "OPENAIR1_DIR    = $OPENAIR1_DIR"  >>  bin/${oai_build_date}
echo "OPENAIR2_DIR    = $OPENAIR2_DIR"  >>  bin/${oai_build_date}
echo "OPENAIR3_DIR    = $OPENAIR3_DIR"  >>  bin/${oai_build_date}
echo "OPENAIRCN_DIR   = $OPENAIRCN_DIR"  >>  bin/${oai_build_date}
echo "OPENAIR_TARGETS = $OPENAIR_TARGETS"  >>  bin/${oai_build_date}

############################################
# check the installation
############################################

nikaeinn's avatar
nikaeinn committed
269
echo_info "6. Checking the installation ..."
270

nikaeinn's avatar
nikaeinn committed
271
check_install_oai_software  
272 273 274 275 276

############################################
# compile 
############################################

nikaeinn's avatar
nikaeinn committed
277
echo_info "7. compiling and installing the OAI binaries ..."
278 279 280 281 282 283

softmodem_compiled=1
oaisim_compiled=1
unisim_compiled=1

if [ $TARGET = "ALL" ]; then
nikaeinn's avatar
nikaeinn committed
284 285
    echo "############# compile_ltesoftmodem #############" 
    output=$(compile_ltesoftmodem $OAI_CLEAN  )
286 287 288
    softmodem_compiled=$?
    check_for_ltesoftmodem_executable
    
nikaeinn's avatar
nikaeinn committed
289 290
    echo "################ compile_oaisim #################" 
    output=$(compile_oaisim   $OAI_CLEAN      )
291 292 293
    oaisim_compiled=$?
    check_for_oaisim_executable

nikaeinn's avatar
nikaeinn committed
294 295
    echo "################## compile_unisim ##################" 
    output=$(compile_unisim  $OAI_CLEAN      )
296 297 298 299 300 301 302 303 304 305 306 307
    unisim_compiled=$?
    check_for_dlsim_executable
    check_for_ulsim_executable
    check_for_pucchsim_executable
    check_for_prachsim_executable
    check_for_pdcchsim_executable
    check_for_pbchsim_executable
    check_for_mbmssim_executable
    
else
    
    if [ $TARGET = "SOFTMODEM" ]; then 
nikaeinn's avatar
nikaeinn committed
308 309
	echo "################ compile_ltesoftmodem #################" 
	output=$(compile_ltesoftmodem  $OAI_CLEAN  )
310 311 312 313
	softmodem_compiled=$?
	check_for_ltesoftmodem_executable
    fi
    if [ $TARGET = "OAISIM" ]; then 
nikaeinn's avatar
nikaeinn committed
314 315
	echo "################ compile_oaisim ###############" 
	output=$(compile_oaisim  $OAI_CLEAN )
316 317 318 319
	oaisim_compiled=$?	
	check_for_oaisim_executable
    fi
    if [ $TARGET = "UNISIM" ]; then 
nikaeinn's avatar
nikaeinn committed
320 321
	echo "################ compile_unisim ###############"
	output=$(compile_unisim  $OAI_CLEAN )
322 323 324 325 326 327 328 329 330 331 332 333 334
	unisim_compiled=$?
	check_for_dlsim_executable
	check_for_ulsim_executable
	check_for_pucchsim_executable
	check_for_prachsim_executable
	check_for_pdcchsim_executable
	check_for_pbchsim_executable
	check_for_mbmssim_executable
    fi
fi


############################################
nikaeinn's avatar
nikaeinn committed
335
# install 
336 337
############################################

nikaeinn's avatar
nikaeinn committed
338
echo_info "8. Installing ..."
339 340

if [ $softmodem_compiled = 0 ]; then 
nikaeinn's avatar
nikaeinn committed
341
    echo_success "target lte-softmodem built "
342
    echo "target lte-softmodem built "  >>  bin/${oai_build_date}
nikaeinn's avatar
nikaeinn committed
343
    output=$(install_ltesoftmodem $RT $HW $ENB_S1 )
344 345
fi
if [ $oaisim_compiled = 0 ]; then 
nikaeinn's avatar
nikaeinn committed
346
    echo_success "target oaisim built "
347
    echo "target oaisim built "  >>  bin/${oai_build_date}
nikaeinn's avatar
nikaeinn committed
348
    output=$(install_oaisim $ENB_S1 )
349 350
fi 
if [ $unisim_compiled =  0 ]; then 
nikaeinn's avatar
nikaeinn committed
351
    echo_success "target unisim built "
352 353 354
    echo "target unisim built "  >>  bin/${oai_build_date}
fi 

nikaeinn's avatar
nikaeinn committed
355 356
echo_info "build terminated, binaries are located in bin/"
echo_info "build terminated, logs are located in bin/${oai_build_date}"
357

nikaeinn's avatar
nikaeinn committed
358 359 360 361 362 363 364
   

############################################
# testing
############################################

if [ $OAI_TEST = 1 ]; then 
nikaeinn's avatar
nikaeinn committed
365
    echo_info "9. Testing ..."
nikaeinn's avatar
nikaeinn committed
366 367
    python $OPENAIR_TARGETS/TEST/OAI/test01.py
else 
nikaeinn's avatar
nikaeinn committed
368
    echo_info "9. Bypassing the Tests ..."
nikaeinn's avatar
nikaeinn committed
369
fi 
nikaeinn's avatar
nikaeinn committed
370