build_oai 28 KB
Newer Older
thomasl's avatar
thomasl committed
1
#!/bin/bash
2 3 4 5 6
#/*
# * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
# * contributor license agreements.  See the NOTICE file distributed with
# * this work for additional information regarding copyright ownership.
# * The OpenAirInterface Software Alliance licenses this file to You under
7
# * the OAI Public License, Version 1.1  (the "License"); you may not use this file
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
# * except in compliance with the License.
# * You may obtain a copy of the License at
# *
# *      http://www.openairinterface.org/?page_id=698
# *
# * Unless required by applicable law or agreed to in writing, software
# * distributed under the License is distributed on an "AS IS" BASIS,
# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# * See the License for the specific language governing permissions and
# * limitations under the License.
# *-------------------------------------------------------------------------------
# * For more information about the OpenAirInterface (OAI) Software Alliance:
# *      contact@openairinterface.org
# */

23
# file build_oai
thomasl's avatar
thomasl committed
24 25 26
# brief OAI automated build tool that can be used to install, compile, run OAI.
# author  Navid Nikaein, Lionel GAUTHIER, Laurent Thomas

27
set -e
thomasl's avatar
thomasl committed
28 29 30 31

################################
# include helper functions
################################
thomasl's avatar
thomasl committed
32
ORIGIN_PATH=$PWD
thomasl's avatar
thomasl committed
33
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
34
source $THIS_SCRIPT_PATH/tools/build_helper
thomasl's avatar
thomasl committed
35

36 37 38 39 40 41 42
# set environment variables (OPENAIR_HOME, ...)
set_openair_env

#variables for UE data generation
gen_nvram_path=$OPENAIR_DIR/targets/bin
conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf

43
MSC_GEN=0
44
XFORMS="True"
Xu Bo's avatar
Xu Bo committed
45
UE_EXPANSION="False"
46
UESIM_EXPANSION="False"
47
PRINT_STATS="False"
thomasl's avatar
thomasl committed
48
VCD_TIMING="False"
laurent's avatar
laurent committed
49 50
DEADLINE_SCHEDULER_FLAG_USER="False"
FORCE_DEADLINE_SCHEDULER_FLAG_USER=""
51
CPU_AFFINITY_FLAG_USER="False" #Only valid when lowlatecy flag is set to False
Cedric Roux's avatar
Cedric Roux committed
52
REL="Rel14"
53
HW="None"
54
TP="None"
Lionel Gauthier's avatar
Lionel Gauthier committed
55
EPC=0
56
VERBOSE_COMPILE=0
57
CFLAGS_PROCESSOR_USER=""
58 59
RUN_GROUP=0
TEST_CASE_GROUP=""
60
BUILD_DOXYGEN=0
61
T_TRACER="True"
Rohit Gupta's avatar
Rohit Gupta committed
62
DISABLE_HARDWARE_DEPENDENCY="False"
63
CMAKE_BUILD_TYPE=""
64
CMAKE_CMD="$CMAKE"
65
UE_AUTOTEST_TRACE="False"
gabrielC's avatar
gabrielC committed
66 67
UE_DEBUG_TRACE="False"
UE_TIMING_TRACE="False"
68
USRP_REC_PLAY="False"
69
BUILD_ECLIPSE=0
70
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope msc"
71 72
trap handle_ctrl_c INT

73
function print_help() {
Cedric Roux's avatar
Cedric Roux committed
74
  echo_info "
75
This program installs OpenAirInterface Software
76
You should have ubuntu 16.xx or 18.04 updated
77 78 79 80
Options
-h
   This help
-c | --clean
Cedric Roux's avatar
Cedric Roux committed
81
   Erase all files to make a rebuild from start
82
-C | --clean-all
Cedric Roux's avatar
Cedric Roux committed
83
   Erase all files made by previous compilations, installations
84 85
--clean-kernel
   Erase previously installed features in kernel: iptables, drivers, ...
Lionel Gauthier's avatar
Lionel Gauthier committed
86
-I | --install-external-packages
87 88 89 90 91
   Installs required packages such as LibXML, asn1.1 compiler, freediameter, ...
   This option will require root password
--install-optional-packages
   Install useful but not mandatory packages such as valgrind
-g | --run-with-gdb
92
   Add debugging symbols to compilation directives. It also disables any compiler optimization. Only for debugging. Do not use in normal operation!
93 94 95
-h | --help
   Print this help
--eNB
96
   Makes the LTE softmodem
97
--UE
98
   Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file
Cedric Roux's avatar
Cedric Roux committed
99 100 101 102
--UE-conf-nvram [configuration file]
   Specify conf_nvram_path (default \"$conf_nvram_path\")
--UE-gen-nvram [output path]
   Specify gen_nvram_path (default \"$gen_nvram_path\")
103 104
-a | --agent
   Enables agent for software-defined control of the eNB
105
-r | --3gpp-release
Cedric Roux's avatar
Cedric Roux committed
106
   default is Rel14,
107
   Rel8 limits the implementation to 3GPP Release 8 version
Cedric Roux's avatar
Cedric Roux committed
108
   Rel10 limits the implementation to 3GPP Release 10 version
109
-w | --hardware
110
   EXMIMO, USRP, BLADERF, LMSSDR, IRIS, None (Default)
111 112 113 114 115 116 117
   Adds this RF board support (in external packages installation and in compilation)
--phy_simulators
   Makes the unitary tests Layer 1 simulators
--core_simulators
   Makes the core security features unitary simulators
-s | --check
   runs a set of auto-tests based on simulators and several compilation tests
118 119
--run-group 
   runs only specified test cases specified here. This flag is only valid with -s
120 121 122
-V | --vcd
   Adds a debgging facility to the binary files: GUI with major internal synchronization events
--install-system-files
Lionel Gauthier's avatar
Lionel Gauthier committed
123
   Install OpenArInterface required files in Linux system
124
   (will ask root password)
125 126
--verbose-compile
   Shows detailed compilation instructions in makefile
127 128
--cflags_processor
   Manually Add CFLAGS of processor if they are not detected correctly by script. Only add these flags if you know your processor supports them. Example flags: -msse3 -msse4.1 -msse4.2 -mavx2
129 130
--build-doxygen
   Builds doxygen based documentation.
131
--disable-deadline
132 133
   Disables deadline scheduler of Linux kernel (>=3.14.x).
--enable-deadline
laurent's avatar
laurent committed
134
   Enable deadline scheduler of Linux kernel (>=3.14.x). 
135
--disable-cpu-affinity
136
   Disables CPU Affinity between UHD/TX/RX Threads (Valid only when deadline scheduler is disabled). By defaulT, CPU Affinity is enabled when not using deadline scheduler. It is enabled only with >2 CPUs. For eNB, CPU_0-> Device library (UHD), CPU_1->TX Threads, CPU_2...CPU_MAX->Rx Threads. For UE, CPU_0->Device Library(UHD), CPU_1..CPU_MAX -> All the UE threads
137 138
--disable-T-Tracer
   Disables the T tracer.
Rohit Gupta's avatar
Rohit Gupta committed
139 140
--disable-hardware-dependency
   Disable HW dependency during installation
141 142
--ue-autotest-trace
    Enable specific traces for UE autotest framework
gabrielC's avatar
gabrielC committed
143 144 145 146
--ue-trace
    Enable traces for UE debugging
--ue-timing
    Enable traces for timing
147 148
--build-eclipse
   Build eclipse project files. Paths are auto corrected by fixprj.sh
149 150
--build-lib <libraries>
   Build optional shared library, <libraries> can be one or several of $OPTIONAL_LIBRARIES
151 152
--usrp-recplay
   Build for I/Q record-playback modes
153

154
Usage (first build):
155
 NI/ETTUS B201  + COTS UE : ./build_oai -I  --eNB --install-system-files -w USRP
156
Usage (Regular):
157 158
 Eurecom EXMIMO + OAI ENB : ./build_oai --eNB  
 NI/ETTUS B201  + OAI ENB : ./build_oai --eNB -w USRP"
159 160 161 162
}


function main() {
163

164 165
  until [ -z "$1" ]
  do
166
    case "$1" in
167 168 169 170 171
       -c | --clean)
            CLEAN=1
            shift;;
       -C | --clean-all)
            CLEAN_ALL=1
thomasl's avatar
thomasl committed
172
            shift;;
173 174 175
       --clean-kernel)
            clean_kernel
            echo_info "Erased iptables config and removed modules from kernel"
thomasl's avatar
thomasl committed
176
            shift;;
177
       -I | --install-external-packages)
178
            INSTALL_EXTERNAL=1
179
            echo_info "Will install external packages"
thomasl's avatar
thomasl committed
180
            shift;;
181
       --install-optional-packages)
thomasl's avatar
thomasl committed
182 183 184
            INSTALL_OPTIONAL=1
            echo_info "Will install optional packages"
            shift;;
185
       -g | --run-with-gdb)
thomasl's avatar
thomasl committed
186
            GDB=1
187 188
            CMAKE_BUILD_TYPE="Debug"
            echo_info "Will Compile with gdb symbols and disable compiler optimization"
189
            CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug --trace-expand"
thomasl's avatar
thomasl committed
190
            shift;;
191 192 193 194
       --eNB)
            eNB=1
            echo_info "Will compile eNB"
            shift;;
195
       -a | --agent)
196
	    echo_info "FlexRAN support is always compiled into the eNB"
197
	    shift;;
198 199 200 201
       --UE)
            UE=1
            echo_info "Will compile UE"
            shift;;
Xu Bo's avatar
Xu Bo committed
202 203 204 205
       --mu)
            UE_EXPANSION="True"
            echo_info "Will compile with UE_EXPANSION"
            shift;;
206 207 208 209
       --musim)
            UESIM_EXPANSION="True"
            echo_info "Will compile with UESIM_EXPANSION"
            shift;;
Cedric Roux's avatar
Cedric Roux committed
210
       --UE-conf-nvram)
211
            conf_nvram_path=$(readlink -f $2)
Cedric Roux's avatar
Cedric Roux committed
212 213
            shift 2;;
        --UE-gen-nvram)
214 215
            gen_nvram_path=$(readlink -f $2)
            shift 2;;
thomasl's avatar
thomasl committed
216
       -r | --3gpp-release)
Lionel Gauthier's avatar
Lionel Gauthier committed
217
            REL=$2
218
            echo_info "Setting release to: $REL"
thomasl's avatar
thomasl committed
219 220
            shift 2;;
       -w | --hardware)
221
            # Use OAI_USRP  as the key word USRP is used inside UHD driver           
222 223 224 225 226 227 228 229 230 231 232 233 234
                case "$2" in
                    "EXMIMO")
                        HW="EXMIMO"
                        ;;
                    "USRP" | "BLADERF" | "LMSSDR" | "IRIS" | "SIMU")
                        HW="OAI_"$2
                        ;;
                    "None")
                        HW="None"
                        ;;
                    *)
                        echo_fatal "Unknown HW type $HW: exit..."
                esac
235
		echo_info "Setting hardware to: $HW"
thomasl's avatar
thomasl committed
236
            shift 2;;
237
       --phy_simulators)
thomasl's avatar
thomasl committed
238
            SIMUS_PHY=1
239 240 241 242 243 244
            echo_info "Will compile dlsim, ulsim, ..."
            shift;;
       --core_simulators)
            SIMUS_CORE=1
            echo_info "Will compile security unitary tests"
            shift;;
thomasl's avatar
thomasl committed
245 246
       -s | --check)
            OAI_TEST=1
247
            echo_info "Will run auto-tests"
thomasl's avatar
thomasl committed
248
            shift;;
249 250 251 252 253
       --run-group)
            RUN_GROUP=1
            TEST_CASE_GROUP=$2
            echo_info "executing test cases only in group: $TEST_CASE_GROUP"
            shift 2;;
thomasl's avatar
thomasl committed
254
       -V | --vcd)
255
            echo_info "Setting gtk-wave output"
thomasl's avatar
thomasl committed
256 257
            VCD_TIMING=1
            EXE_ARGUMENTS="$EXE_ARGUMENTS -V"
thomasl's avatar
thomasl committed
258
            shift;;
thomasl's avatar
thomasl committed
259
       -x | --xforms)
260
            XFORMS=1
thomasl's avatar
thomasl committed
261
            EXE_ARGUMENTS="$EXE_ARGUMENTS -d"
262
            echo_info "Will generate the software oscilloscope features"
thomasl's avatar
thomasl committed
263
            shift;;
264 265 266 267
       --install-system-files)
            INSTALL_SYSTEM_FILES=1
            echo_info "Will copy OpenAirInterface files in Linux directories"
            shift;;
268 269 270 271
       --verbose-compile)
	    VERBOSE_COMPILE=1
            echo_info "Will compile with verbose instructions"
            shift;;
272 273
       --cflags_processor)
            CFLAGS_PROCESSOR_USER=$2
274
            echo_info "Setting CPU FLAGS from USER to: $CFLAGS_PROCESSOR_USER"
275
            shift 2;;
276 277 278 279
       --build-doxygen)
	    BUILD_DOXYGEN=1
            echo_info "Will build doxygen support"
            shift;;     
280
       --disable-deadline)
laurent's avatar
laurent committed
281
            FORCE_DEADLINE_SCHEDULER_FLAG_USER="False"
282 283
            echo_info "Disabling the usage of deadline scheduler"
            shift 1;;
284
       --enable-deadline)
laurent's avatar
laurent committed
285
            FORCE_DEADLINE_SCHEDULER_FLAG_USER="True"
286 287
            echo_info "Enabling the usage of deadline scheduler"
            shift 1;;
288 289 290 291
       --disable-cpu-affinity)
            CPU_AFFINITY_FLAG_USER="False"
            echo_info "Disabling CPU Affinity (only valid when not using deadline scheduler)"
            shift 1;;
292 293 294
       --disable-T-Tracer)
            T_TRACER="False"
            echo_info "Disabling the T tracer"
295
            shift 1;;
296 297 298 299
       --disable-hardware-dependency)
            echo_info "Disabling hardware dependency for compiling software"
            DISABLE_HARDWARE_DEPENDENCY="True"
            shift 1;;
300 301 302 303
        --ue-autotest-trace)
            UE_AUTOTEST_TRACE="True"
            echo_info "Enabling autotest specific trace for UE"
            shift 1;;
gabrielC's avatar
gabrielC committed
304 305 306 307 308 309
        --ue-trace)
            UE_DEBUG_TRACE="True"
            echo_info "Enabling UE trace for debug"
            shift 1;;
        --ue-timing)
            UE_TIMING_TRACE="True"
310
 x           echo_info "Enabling UE timing trace"
Cedric Roux's avatar
Cedric Roux committed
311
            shift 1;;
312 313 314 315
        --uhd-images-dir)
            UHD_IMAGES_DIR=$2
            echo_info "Downloading UHD images in the indicated location"
            shift 2;;
316 317 318 319
       --build-eclipse)
            BUILD_ECLIPSE=1
            CMAKE_CMD="$CMAKE_CMD"' -DCMAKE_ECLIPSE_GENERATE_SOURCE_PROJECT=TRUE -G"Eclipse CDT4 - Unix Makefiles"'
            echo_info "Enabling build eclipse project support"
oai's avatar
oai committed
320
            shift 1;;
321 322 323 324 325 326 327 328 329 330 331 332 333 334
       --build-lib) 
            BUILD_OPTLIB="" 
            for alib in $2 ; do 
                for oklib in $OPTIONAL_LIBRARIES ; do
                     if [ "$alib" = "$oklib" ] ; then
                        BUILD_OPTLIB="$BUILD_OPTLIB $alib" 
                        echo_info "Enabling build of lib${alib}.so" 
                     fi   
                done
            done
	    if [ "${BUILD_OPTLIB## }" != "$2" ] ; then
               echo_fatal "Unknown optional library in $2, valid libraries are $OPTIONAL_LIBRARIES" 
            fi
            shift 2;;		
335 336 337 338
        --usrp-recplay)
            USRP_REC_PLAY="True"
            echo_info "Enabling USRP record playback mode"
            shift 1;;
thomasl's avatar
thomasl committed
339 340 341
        -h | --help)
            print_help
            exit 1;;
Lionel Gauthier's avatar
Lionel Gauthier committed
342
	*)
343 344
	    print_help
            echo_fatal "Unknown option $1"
thomasl's avatar
thomasl committed
345
            break;;
thomasl's avatar
thomasl committed
346
   esac
347
  done
348
  
349 350
  CMAKE_CMD="$CMAKE_CMD .."
  echo_info "CMAKE_CMD=$CMAKE_CMD"
351
  #########################################################
352
  # check validity of HW and TP parameters for eNB
353
  #########################################################
Aikaterini's avatar
Aikaterini committed
354
  # to be discussed
355
  
356
  if [ "$eNB" = "1" ] ; then
357
      if [ "$HW" = "None" -a  "$TP" = "None" ] ; then
358
	  echo_info "No local radio head and no transport protocol selected"
359
      fi
360 361
      if [ "$HW" = "None" ] ; then 
	  echo_info "No radio head has been selected (HW set to $HW)"	
362
      fi
363 364
      if [ "$TP" = "None" ] ; then
	  echo_info "No transport protocol has been selected (TP set to $TP)"	
365 366 367
      fi
  fi
  
368
  echo_info "RF HW set to $HW" 
369 370 371 372
    # If the user doesn't specify the Linux scheduler to use, we set a value
    if [ "$DEADLINE_SCHEDULER_FLAG_USER" = "" ]; then
      case "$HW" in
 	  "EXMIMO")
laurent's avatar
laurent committed
373
        DEADLINE_SCHEDULER_FLAG_USER="True"
374 375
              ;;
 	  *)
376
        DEADLINE_SCHEDULER_FLAG_USER="False"
377 378
              ;;
      esac
379
  fi
380
  #Disable CPU Affinity for deadline scheduler
laurent's avatar
laurent committed
381
  if [ "$DEADLINE_SCHEDULER_FLAG_USER" = "True" ] ; then 
382 383
     CPU_AFFINITY_FLAG_USER="False"
  fi
384

laurent's avatar
laurent committed
385
  echo_info "Flags for Deadline scheduler: $DEADLINE_SCHEDULER_FLAG_USER"
386
  echo_info "Flags for CPU Affinity: $CPU_AFFINITY_FLAG_USER"
Aikaterini's avatar
Aikaterini committed
387

388 389 390 391
  if [ -n "$UHD_IMAGES_DIR" ] && [ -z "$INSTALL_EXTERNAL" ]; then
    echo_error "UHD images download settings will not be applied without -I present"
    exit
  fi
392 393 394
  ############################################
  # setting and printing OAI envs, we should check here
  ############################################
Lionel Gauthier's avatar
Lionel Gauthier committed
395

396
  echo_info "2. Setting the OAI PATHS ..."
thomasl's avatar
thomasl committed
397

398
  cecho "OPENAIR_DIR    = $OPENAIR_DIR" $green
thomasl's avatar
thomasl committed
399

400 401 402 403 404 405 406 407 408 409
  # for conf files copy in this bash script
  if [ -d /usr/lib/freeDiameter ]; then
    export FREEDIAMETER_PREFIX=/usr
  else
    if [ -d /usr/local/lib/freeDiameter ]; then
      export FREEDIAMETER_PREFIX=/usr/local
    else
      echo_warning "FreeDiameter prefix not found, install freeDiameter if EPC, HSS"
    fi
  fi
thomasl's avatar
thomasl committed
410

411

412 413 414 415
  if [ "$CLEAN_ALL" = "1" ] ; then
    clean_all_files
    echo_info "Erased all previously producted files"
  fi
416

417 418 419 420 421 422
  dbin=$OPENAIR_DIR/targets/bin
  dlog=$OPENAIR_DIR/cmake_targets/log
  mkdir -p $dbin $dlog

  if [ "$INSTALL_EXTERNAL" = "1" ] ; then
    echo_info "Installing packages"
423
    check_install_oai_software
424 425 426
    if [ "$HW" == "OAI_USRP" ] ; then
      echo_info "installing packages for USRP support"
      check_install_usrp_uhd_driver
427
      if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
428
        install_usrp_uhd_driver $UHD_IMAGES_DIR
429
      fi
430 431
    fi 
    if [ "$HW" == "OAI_BLADERF" ] ; then
432
      echo_info "installing packages for BLADERF support"
433
      check_install_bladerf_driver
434 435 436
      if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
        flash_firmware_bladerf
      fi
437
    fi
438 439 440 441 442 443
    if [ "$HW" == "OAI_IRIS" ] ; then
      echo_info "installing packages for IRIS support"
      check_install_soapy
      #if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
      #  flash_firmware_iris
      #fi
444
    fi
445 446 447
    echo_info "installing protobuf/protobuf-c for flexran agent support"
    install_protobuf_from_source
    install_protobuf_c_from_source
448 449 450 451 452 453 454
  fi

  if [ "$INSTALL_OPTIONAL" = "1" ] ; then
    echo_info "Installing optional packages"
    check_install_additional_tools
  fi

455 456
  
  
457 458 459
  echo_info "3. building the compilation directives ..."

  DIR=$OPENAIR_DIR/cmake_targets
460 461 462
    
    if [ "$T_TRACER" =  "False" ] ; then
        noLOGDirsuffix="_noLOG"
463
      fi
464 465
    lte_build_dir=lte_build_oai
      bin_suffix=""
466

467
    lte_build_dir="lte_build_oai${noLOGDirsuffix}"
468 469 470
# configuration module libraries, one currently available, using libconfig 
  config_libconfig_shlib=params_libconfig
  
471 472
  # first generate the CMakefile in the right directory
  if [ "$eNB" = "1" -o "$UE" = "1" -o "$HW" = "EXMIMO" ] ; then
473

474
    # LTE softmodem compilation
475 476 477 478
    [ "$CLEAN" = "1" ] && rm -rf $DIR/$lte_build_dir/build
    mkdir -p $DIR/$lte_build_dir/build
    cmake_file=$DIR/$lte_build_dir/CMakeLists.txt
    echo "cmake_minimum_required(VERSION 2.8)"   >  $cmake_file
479
    echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )" >> $cmake_file
480
    echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )" >>  $cmake_file
Xu Bo's avatar
Xu Bo committed
481
    echo "set ( UE_EXPANSION $UE_EXPANSION )"      >>  $cmake_file
482
#    echo "set ( PHY_TX_THREAD $UE_EXPANSION )"     >>  $cmake_file
483
    echo "set ( PRE_SCD_THREAD $UE_EXPANSION )"    >>  $cmake_file
484
    echo "set ( UESIM_EXPANSION $UESIM_EXPANSION )"      >>  $cmake_file
485 486 487
    echo "set ( RRC_ASN1_VERSION \"${REL}\")"      >>  $cmake_file
    echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )"     >>  $cmake_file
    echo "set ( RF_BOARD \"${HW}\")"               >>  $cmake_file
488 489
    echo "set ( TRANSP_PRO \"${TP}\")"             >>  $cmake_file
    echo "set(PACKAGE_NAME \"${lte_exec}\")"       >>  $cmake_file
laurent's avatar
laurent committed
490
    echo "set (DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )"    >>$cmake_file
491
    echo "set (CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )"      >>$cmake_file
492
    echo "set ( T_TRACER $T_TRACER )"              >>  $cmake_file
493
    echo "set (UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE)"        >>  $cmake_file
gabrielC's avatar
gabrielC committed
494 495
    echo "set (UE_DEBUG_TRACE $UE_DEBUG_TRACE)"        >>  $cmake_file
    echo "set (UE_TIMING_TRACE $UE_TIMING_TRACE)"        >>  $cmake_file
496
    echo "set (USRP_REC_PLAY $USRP_REC_PLAY)"        >>  $cmake_file
497
    echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file
498
    cd  $DIR/$lte_build_dir/build
499
    eval $CMAKE_CMD
500 501
  fi

502 503
  if [ "$eNB" = "1" ] ; then
    lte_exec=lte-softmodem${bin_suffix}
504
    compilations \
505 506 507
	  $lte_build_dir $lte_exec \
	  $lte_exec $dbin/$lte_exec.$REL

508 509 510 511
# mandatory shared lib
    compilations \
	  $lte_build_dir $config_libconfig_shlib \
	  lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
512 513 514
    compilations \
          $lte_build_dir coding \
          libcoding.so $dbin/libcoding.so
515 516 517 518 519 520 521 522
# optional libs (used when noS1 with kernel modules 
    compilations \
          $lte_build_dir nasmesh \
          CMakeFiles/nasmesh/nasmesh.ko $dbin/nasmesh.ko
    compilations \
          $lte_build_dir rb_tool \
          rb_tool $dbin/rb_tool
          cp $OPENAIR_DIR/cmake_targets/tools/init_nas_nos1 $dbin	  
523
  fi
524

525
  if [ "$UE" = 1  ] ; then
526 527 528 529
    lte_exec=lte-uesoftmodem${bin_suffix}
    compilations \
        $lte_build_dir $lte_exec \
        $lte_exec $dbin/$lte_exec.$REL
530
        
531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
    # mandatory shared lib
    compilations \
        $lte_build_dir $config_libconfig_shlib \
        lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
    compilations \
        $lte_build_dir coding \
        libcoding.so $dbin/libcoding.so
# optional libs (used when noS1 with kernel modules
    compilations \
          $lte_build_dir nasmesh \
          CMakeFiles/nasmesh/nasmesh.ko $dbin/nasmesh.ko
    compilations \
          $lte_build_dir rb_tool \
          rb_tool $dbin/rb_tool
          cp $OPENAIR_DIR/cmake_targets/tools/init_nas_nos1 $dbin
546 547
    # ue_ip driver compilation
    compilations \
548 549
          $lte_build_dir ue_ip \
          CMakeFiles/ue_ip/ue_ip.ko $dbin/ue_ip.ko
550

Lionel Gauthier's avatar
Lionel Gauthier committed
551 552
#    mkdir -p $DIR/at_commands/build
#    cd $DIR/at_commands/build
553
#    eval $CMAKE_CMD
Lionel Gauthier's avatar
Lionel Gauthier committed
554 555 556
#    compilations \
#      at_commands at_nas_ue \
#      at_nas_ue $dbin/at_nas_ue
557
    
Lionel Gauthier's avatar
Lionel Gauthier committed
558
    [ "$CLEAN" = "1" ] && rm -rf $DIR/nas_sim_tools/build
559 560
    mkdir -p $DIR/nas_sim_tools/build
    cd $DIR/nas_sim_tools/build
Lionel Gauthier's avatar
Lionel Gauthier committed
561
    
562
    eval $CMAKE_CMD
thomasl's avatar
thomasl committed
563
    compilations \
564 565
      nas_sim_tools usim \
      usim $dbin/usim
thomasl's avatar
thomasl committed
566
    compilations \
567 568
      nas_sim_tools nvram \
      nvram $dbin/nvram
thomasl's avatar
thomasl committed
569
    compilations \
570 571
        nas_sim_tools conf2uedata \
        conf2uedata $dbin/conf2uedata
572 573

    # generate USIM data
574 575
    if [ -f $dbin/conf2uedata ]; then
      install_nas_tools $conf_nvram_path $gen_nvram_path
576
      echo_info "Copying UE specific part to $DIR/$lte_build_dir/build"
577 578 579
      cp -Rvf $dbin/.ue_emm.nvram0 $DIR/$lte_build_dir/build
      cp -Rvf $dbin/.ue.nvram0 $DIR/$lte_build_dir/build
      cp -Rvf $dbin/.usim.nvram0 $DIR/$lte_build_dir/build
580 581 582
    else
      echo_warning "not generated UE NAS files: binaries not found"
    fi
583
  fi
thomasl's avatar
thomasl committed
584

585
  if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
586 587 588 589 590
    cd $OPENAIR_DIR/cmake_targets/lte-simulators
    [ "$CLEAN" = "1" ] && rm -rf build
    mkdir -p build
    cd build
    rm -f *sim
591
    eval $CMAKE_CMD
592
  fi
593

594 595 596
  if [ "$SIMUS_PHY" = "1" ] ; then
    # lte unitary simulators compilation
    echo_info "Compiling unitary tests simulators"
597 598 599
    # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
    #simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim"
    simlist="dlsim ulsim"
600 601 602 603 604
    for f in $simlist ; do
      compilations \
      lte-simulators $f \
	  $f $dbin/$f.$REL
    done
605 606 607
    compilations \
          lte-simulators coding \
          libcoding.so $dbin/libcoding.so
608 609 610
#    compilations \
#	  lte-simulators $config_libconfig_shlib \
#	  lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
611
  fi
thomasl's avatar
thomasl committed
612

Lionel Gauthier's avatar
Lionel Gauthier committed
613
  # Core simulators
614 615 616 617 618 619 620 621 622 623 624
  #############
  if [ "$SIMUS_CORE" = "1" ] ; then
    # lte unitary simulators compilation
    echo_info "Compiling unitary tests simulators"
    simlist="secu_knas_encrypt_eia1 secu_kenb aes128_ctr_encrypt aes128_ctr_decrypt secu_knas_encrypt_eea2 secu_knas secu_knas_encrypt_eea1 kdf aes128_cmac_encrypt secu_knas_encrypt_eia2"
    for f in $simlist ; do
      compilations \
	  lte-simulators test_$f \
	  test_$f $dbin/test_$f.$REL
    done
  fi
thomasl's avatar
thomasl committed
625

626 627
  # EXMIMO drivers & firmware loader
  ###############
628
  if [ "$HW" = "EXMIMO" ] ; then
Lionel Gauthier's avatar
Lionel Gauthier committed
629
    
630 631
    echo_info "Compiling Express MIMO 2 board drivers"
    compilations \
632
        $lte_build_dir openair_rf \
thomasl's avatar
thomasl committed
633
        CMakeFiles/openair_rf/openair_rf.ko $dbin/openair_rf.ko
634
    compilations \
635
	  $lte_build_dir updatefw \
Lionel Gauthier's avatar
Lionel Gauthier committed
636
	  updatefw $dbin/updatefw
637
    echo_info "Compiling oarf tools. The logfile for compilation is here: $dlog/oarf.txt"
638 639 640 641 642 643 644
    make -C $OPENAIR_DIR/cmake_targets/$lte_build_dir/build oarf > $dlog/oarf.txt 2>&1
    cp $OPENAIR_DIR/cmake_targets/$lte_build_dir/build/*.oct $dbin
    if [ -s $dbin/oarf_config_exmimo.oct ] ; then
	echo_success "oarf tools compiled"
    else
	echo_error "oarf tools compilation failed"
    fi
645
    cp $OPENAIR_DIR/cmake_targets/tools/init_exmimo2 $dbin
646
  fi
647
  # optional libraries
648
  #####################
649 650 651 652 653 654
  if [ ! -z "$BUILD_OPTLIB" ] ; then 
     for oklib in $BUILD_OPTLIB ; do
         compilations \
            $lte_build_dir $oklib \
                  lib${oklib}.so $dbin/lib${oklib}.so
     done
655

656
  fi 
657
 
658 659
  # build RF device and transport protocol libraries
  #####################################
660
  if [ "$eNB" = "1" -o "$UE" = "1" ] ; then
661

662
      # build RF device libraries
663
      if [ "$HW" != "None" ] ; then
664
	  rm -f liboai_device.so
665
	  rm -f $dbin/liboai_device.so
666

667
	  # link liboai_device.so with the selected RF device library
668
	  if [ "$HW" == "EXMIMO" ] ; then
669
	      compilations \
670
                    $lte_build_dir oai_exmimodevif \
671
		  liboai_exmimodevif.so $dbin/liboai_exmimodevif.so.$REL
672 673 674

	      ln -sf liboai_exmimodevif.so liboai_device.so
	      ln -sf $dbin/liboai_exmimodevif.so.$REL $dbin/liboai_device.so
675 676
	      echo_info "liboai_device.so is linked to EXMIMO device library"       
	  elif [ "$HW" == "OAI_USRP" ] ; then
677
              compilations \
678
                    $lte_build_dir oai_usrpdevif \
679
                  liboai_usrpdevif.so $dbin/liboai_usrpdevif.so.$REL
680

681 682
	      ln -sf liboai_usrpdevif.so liboai_device.so
	      ln -sf $dbin/liboai_usrpdevif.so.$REL $dbin/liboai_device.so
683 684
	      echo_info "liboai_device.so is linked to USRP device library"        
	  elif [ "$HW" == "OAI_BLADERF" ] ; then
685 686
	      if [ -f "/usr/include/libbladeRF.h" ] ; then
		  compilations \
687
                        $lte_build_dir oai_bladerfdevif \
688 689 690
		      liboai_bladerfdevif.so $dbin/liboai_bladerfdevif.so.$REL
	      fi

691 692
	      ln -sf liboai_bladerfdevif.so liboai_device.so
	      ln -sf $dbin/liboai_bladerfdevif.so.$REL $dbin/liboai_device.so
693
	      echo_info "liboai_device.so is linked to BLADERF device library"	 
694
	  elif [ "$HW" == "OAI_LMSSDR" ] ; then
695
                #       if [ -f "/usr/include/libbladeRF.h" ] ; then
696
		  compilations \
697
                    $lte_build_dir oai_lmssdrdevif \
698
		      liboai_lmssdrdevif.so $dbin/liboai_lmssdrdevif.so.$REL
699
                #       fi
700

701 702
	      ln -sf liboai_lmssdrdevif.so liboai_device.so
	      ln -sf $dbin/liboai_lmssdrdevif.so.$REL $dbin/liboai_device.so
703
	      echo_info "liboai_device.so is linked to LMSSDR device library"	 
704 705
          elif [ "$HW" == "OAI_IRIS" ] ; then
                  compilations \
706
                    $lte_build_dir oai_irisdevif \
707 708 709 710 711
                      liboai_irisdevif.so $dbin/liboai_irisdevif.so.$REL

              ln -s liboai_irisdevif.so liboai_device.so
              ln -s $dbin/liboai_irisdevif.so.$REL $dbin/liboai_device.so
              echo_info "liboai_device.so is linked to IRIS device library"
712 713 714 715 716
	  else 
	      echo_info "liboai_device.so is not linked to any device library"	    
	  fi
      fi
      
717 718 719 720 721 722 723 724 725 726 727
        # build simulators devices
        echo_info "Compiling rfsimulator"
        compilations \
            $lte_build_dir rfsimulator \
            librfsimulator.so $dbin/librfsimulator.so.$REL
        echo_info "Compiling basicsimulator"
        compilations \
            $lte_build_dir tcp_bridge_oai \
            libtcp_bridge_oai.so $dbin/libtcp_bridge_oai.so.$REL
        # build transport protocol libraries (currently only ETHERNET is available)

728
	  rm -f liboai_transpro.so
729
	  rm -f $dbin/liboai_transpro.so
730
	      compilations \
731
            $lte_build_dir oai_eth_transpro \
732
		  liboai_eth_transpro.so $dbin/liboai_eth_transpro.so.$REL
733 734
	      ln -sf liboai_eth_transpro.so liboai_transpro.so
	      ln -sf $dbin/liboai_eth_transpro.so.$REL $dbin/liboai_transpro.so
735
        echo_info "liboai_transpro.so is linked to ETHERNET transport"
736 737
      fi

738 739 740 741 742 743
    if [ "$RFSIMULATOR" == "true" -o "$HW" == "OAI_SIMU" ] ; then
        echo_info "Compiling rfsimulator"
        compilations \
            $lte_build_dir rfsimulator \
            librfsimulator.so $dbin/librfsimulator.so.$REL
    fi
744

745 746 747 748 749 750 751 752 753 754 755
  # Doxygen Support
  #####################
  if [ "$BUILD_DOXYGEN" = "1" ] ;then
    doxygen_log=$OPENAIR_DIR/cmake_targets/log/doxygen.log
    echo_info "Building doxygen based documentation. The documentation file is located here: $OPENAIR_DIR/targets/DOCS/html/index.html"
    echo_info "Doxygen Generation log is located here: $doxygen_log"
    echo_info "Generating doxygen files....please wait"
    (
    [ "$CLEAN" = "1" ] && rm -rf $OPENAIR_DIR/cmake_targets/doxygen/build
    mkdir -p $OPENAIR_DIR/cmake_targets/doxygen/build
    cd $OPENAIR_DIR/cmake_targets/doxygen/build
756
    eval $CMAKE_CMD
757 758
    make doc
    ) >& $doxygen_log
759 760
  fi

Lionel Gauthier's avatar
Lionel Gauthier committed
761 762 763
  # Auto-tests
  #####################
  if [ "$OAI_TEST" = "1" ]; then
thomasl's avatar
thomasl committed
764
    echo_info "10. Running OAI pre commit tests (pre-ci) ..."
765 766 767 768
    echo_error "These scripts ASSUME that user is in /etc/sudoers and can execute commands without PASSWORD prompt"
    echo_error "Add the following lines in /etc/sudoers file to make your __user_name__ sudo without password prompt"
    echo_error " __your_user_name__ ALL = (ALL:ALL) NOPASSWD: ALL"
    echo_error " __your_user_name__ ALL = (ALL) NOPASSWD: ALL "
769 770
    echo_info "The log file for the autotest script for debugging is located here: $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log "
    echo_info "The results of autotests results is located here: $OPENAIR_DIR/cmake_targets/autotests/log/results_autotests.xml "
771
    echo_info "You can hit CTRL-C any time to terminate the autotests..."
772 773 774
    echo "Current User Name: $USER"
    read -s -p "Enter Password: " mypassword
    echo -e "\n"
775 776
    rm -fr $OPENAIR_DIR/cmake_targets/autotests/log
    mkdir -p $OPENAIR_DIR/cmake_targets/autotests/log
777
    if [ "$RUN_GROUP" -eq "1" ]; then
778
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -g "$TEST_CASE_GROUP" -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
779
    else
780
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
781
    fi
782
    wait
Lionel Gauthier's avatar
Lionel Gauthier committed
783
  else
thomasl's avatar
thomasl committed
784
    echo_info "10. Bypassing the Tests ..."
Lionel Gauthier's avatar
Lionel Gauthier committed
785
  fi
786

787 788 789
}

main "$@"