build_oai 38.6 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

yilmazt's avatar
yilmazt committed
29
# Include helper functions
thomasl's avatar
thomasl committed
30
ORIGIN_PATH=$PWD
thomasl's avatar
thomasl committed
31
THIS_SCRIPT_PATH=$(dirname $(readlink -f $0))
32
source $THIS_SCRIPT_PATH/tools/build_helper
thomasl's avatar
thomasl committed
33

yilmazt's avatar
yilmazt committed
34
# Set environment variables (OPENAIR_HOME, ...)
35 36
set_openair_env

yilmazt's avatar
yilmazt committed
37
# Variables for UE data generation
38 39 40
gen_nvram_path=$OPENAIR_DIR/targets/bin
conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf

41
MSC_GEN=0
42
XFORMS="True"
43
SKIP_SHARED_LIB_FLAG="False"
Xu Bo's avatar
Xu Bo committed
44
UE_EXPANSION="False"
45
PRINT_STATS="False"
thomasl's avatar
thomasl committed
46
VCD_TIMING="False"
laurent's avatar
laurent committed
47
DEADLINE_SCHEDULER_FLAG_USER=""
yilmazt's avatar
yilmazt committed
48
CPU_AFFINITY_FLAG_USER="False" #Only valid when low-latency flag is set to False
49
REL="Rel15"
50
HW="None"
51
TP="Ethernet"
Lionel Gauthier's avatar
Lionel Gauthier committed
52
EPC=0
53
VERBOSE_CI=0
54
VERBOSE_COMPILE=0
55
CFLAGS_PROCESSOR_USER=""
56 57
RUN_GROUP=0
TEST_CASE_GROUP=""
58
BUILD_DOXYGEN=0
59
BUILD_COVERITY_SCAN=0
60
T_TRACER="True"
Rohit Gupta's avatar
Rohit Gupta committed
61
DISABLE_HARDWARE_DEPENDENCY="False"
62
CMAKE_BUILD_TYPE=""
63
CMAKE_CMD="$CMAKE"
64
UE_AUTOTEST_TRACE="False"
gabrielC's avatar
gabrielC committed
65 66
UE_DEBUG_TRACE="False"
UE_TIMING_TRACE="False"
67
USRP_REC_PLAY="False"
68
BUILD_ECLIPSE=0
Guy De Souza's avatar
Guy De Souza committed
69
NR="False"
heshanyun's avatar
heshanyun committed
70
ITTI_SIM="False"
71
RFSIM_NAS="False"
72
SANITIZE_ADDRESS="False"
73
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc"
74
RU=0
75 76
trap handle_ctrl_c INT

77
function print_help() {
Cedric Roux's avatar
Cedric Roux committed
78
  echo_info "
79
This program installs OpenAirInterface Software
laurent's avatar
laurent committed
80
You should have ubuntu 16.xx or 18.04 updated
81 82
Options
-c | --clean
Cedric Roux's avatar
Cedric Roux committed
83
   Erase all files to make a rebuild from start
84
-C | --clean-all
Cedric Roux's avatar
Cedric Roux committed
85
   Erase all files made by previous compilations, installations
86 87
--clean-kernel
   Erase previously installed features in kernel: iptables, drivers, ...
Lionel Gauthier's avatar
Lionel Gauthier committed
88
-I | --install-external-packages
89 90 91 92
   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
93 94 95
-i | --install-system-files
   Install OpenAirInterface required files in Linux system
   This option will require root password
96 97 98 99 100
-g | --run-with-gdb <Release | RelWithDebInfo | MinSizeRel | Debug
  specify the build mode used by cmake. defaults to Debug mode if -g is used alone, with no mode parameter
  if -g is not specifies, Release mode is used.
-G | --cmaketrace
   enable cmake debugging messages
101
--eNB
Guy De Souza's avatar
Guy De Souza committed
102
  Makes the LTE softmodem
hardy's avatar
hardy committed
103 104 105
--eNBocp
  Makes the OCP LTE softmodem
-gNB
Guy De Souza's avatar
Guy De Souza committed
106 107 108
  Makes the NR softmodem
--nrUE
  Makes the NR UE softmodem
109
--RU
110
  Makes the OAI RRU (without full stack)
111
--UE
112
   Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file
Cedric Roux's avatar
Cedric Roux committed
113 114 115 116
--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\")
root's avatar
root committed
117 118
--HWLAT
    Makes test program for haw latency tests
119 120
-a | --agent
   Enables agent for software-defined control of the eNB
121
-w | --hardware
Fang-WANG's avatar
Fang-WANG committed
122
   EXMIMO, USRP, BLADERF, LMSSDR, IRIS, YUNSDR, ADRV9371_ZC706, SIMU, None (Default)
123
   Adds this RF board support (in external packages installation and in compilation)
124
-P | --phy_simulators
125
   Makes the unitary tests Layer 1 simulators
126
-S | --core_simulators
127 128 129
   Makes the core security features unitary simulators
-s | --check
   runs a set of auto-tests based on simulators and several compilation tests
130 131
--run-group 
   runs only specified test cases specified here. This flag is only valid with -s
132 133
-V | --vcd
   Adds a debgging facility to the binary files: GUI with major internal synchronization events
134 135
--verbose-compile
   Shows detailed compilation instructions in makefile
136 137
--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
138 139
--build-doxygen
   Builds doxygen based documentation.
140 141
--build-coverity-scan
   Builds Coverity-Scan objects for upload
142
--disable-deadline
143 144
   Disables deadline scheduler of Linux kernel (>=3.14.x).
--enable-deadline
laurent's avatar
laurent committed
145
   Enable deadline scheduler of Linux kernel (>=3.14.x). 
146
--disable-cpu-affinity
147
   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
148
--enable-cpu-affinity
149 150
--disable-T-Tracer
   Disables the T tracer.
Rohit Gupta's avatar
Rohit Gupta committed
151 152
--disable-hardware-dependency
   Disable HW dependency during installation
153
--ue-autotest-trace
154
   Enable specific traces for UE autotest framework
gabrielC's avatar
gabrielC committed
155
--ue-trace
156
   Enable traces for UE debugging
gabrielC's avatar
gabrielC committed
157
--ue-timing
158 159 160
   Enable traces for timing
--uhd-images-dir
   Download UHD images in the indicated location
161
--build-eclipse
162
   Build eclipse project files.
163
--build-lib <libraries>
164
   Build optional shared library, <libraries> can be one or several of $OPTIONAL_LIBRARIES or \"all\"
165 166
--usrp-recplay
   Build for I/Q record-playback modes
167 168
-k | --skip-shared-libraries
   Skip build for shared libraries to reduce compilation time when building frequently for debugging purposes
heshanyun's avatar
heshanyun committed
169 170
--ittiSIM
  Makes the itti simulator
171 172
-h | --help
   Print this help
173

174
Usage (first build):
yilmazt's avatar
yilmazt committed
175 176
 NI/ETTUS B201  + COTS UE : ./build_oai -I -i --eNB -w USRP
Usage (regular):
177 178
 Eurecom EXMIMO + OAI ENB : ./build_oai --eNB  
 NI/ETTUS B201  + OAI ENB : ./build_oai --eNB -w USRP"
179 180 181 182
}


function main() {
183

184 185
  until [ -z "$1" ]
  do
186
    case "$1" in
187 188 189 190 191
       -c | --clean)
            CLEAN=1
            shift;;
       -C | --clean-all)
            CLEAN_ALL=1
thomasl's avatar
thomasl committed
192
            shift;;
193 194 195
       --clean-kernel)
            clean_kernel
            echo_info "Erased iptables config and removed modules from kernel"
thomasl's avatar
thomasl committed
196
            shift;;
197
       -I | --install-external-packages)
198
            INSTALL_EXTERNAL=1
199
            echo_info "Will install external packages"
thomasl's avatar
thomasl committed
200
            shift;;
201
       --install-optional-packages)
thomasl's avatar
thomasl committed
202 203 204
            INSTALL_OPTIONAL=1
            echo_info "Will install optional packages"
            shift;;
205 206 207 208
       -i | --install-system-files)
            INSTALL_SYSTEM_FILES=1
            echo_info "Will copy OpenAirInterface files in Linux directories"
            shift;;
209
       -g | --run-with-gdb)
210 211 212 213 214 215 216 217 218 219 220 221
            case "$2" in
                "Release")
                    GDB=0
                    CMAKE_BUILD_TYPE="Release"
                    echo_info "Will Compile without gdb symbols and with compiler optimization"
                    CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Release"
                    shift
                    ;;
                "RelWithDebInfo")
                    GDB=0
                    CMAKE_BUILD_TYPE="RelWithDebInfo"
                    echo_info "Will Compile with gdb symbols"
222
                    CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=1"
223 224 225 226 227 228
                    shift
                    ;;
                "MinSizeRel")
                    GDB=0
                    CMAKE_BUILD_TYPE="MinSizeRel"
                    echo_info "Will Compile for minimal exec size"
229
                    CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=MinSizeRel"
230
                    shift
231
                    ;;
232 233 234 235 236 237
                "Debug" | *)
                    GDB=1
                    CMAKE_BUILD_TYPE="Debug"
                    echo_info "Will Compile with gdb symbols and disable compiler optimization"
                    CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=Debug"
                    if [ "$2" == "Debug" ] ; then
238
                        shift
239 240 241
                    fi
                    ;;
            esac
thomasl's avatar
thomasl committed
242
            shift;;
243
       -G | --cmaketrace)
244
            CMAKE_CMD="$CMAKE_CMD --trace-expand"
thomasl's avatar
thomasl committed
245
            shift;;
246 247
       --eNB)
            eNB=1
248
            RU=0
249 250
            echo_info "Will compile eNB"
            shift;;
hardy's avatar
hardy committed
251 252
       --eNBocp)
            eNBocp=1
Raymond Knopp's avatar
Raymond Knopp committed
253
            RU=0
hardy's avatar
hardy committed
254 255 256
            echo_info "Will compile OCP eNB"
            shift;;
      --gNB)
Guy De Souza's avatar
Guy De Souza committed
257
            gNB=1
258
            RU=0
Guy De Souza's avatar
Guy De Souza committed
259 260 261
            NR="True"
            echo_info "Will compile gNB"
            shift;;
262
       --RU)
263
	          RU=1
264 265
            echo_info "Will compile RRU"
	    shift;;
266
       -a | --agent)
Guy De Souza's avatar
Guy De Souza committed
267 268
            echo_info "FlexRAN support is always compiled into the eNB"
            shift;;
269
       --UE)
270
            RU=0
271 272 273
            UE=1
            echo_info "Will compile UE"
            shift;;
Guy De Souza's avatar
Guy De Souza committed
274
       --nrUE)
275
            RU=0
Guy De Souza's avatar
Guy De Souza committed
276
            nrUE=1
277 278
            rfsimNas=1
            RFSIM_NAS="True"
Guy De Souza's avatar
Guy De Souza committed
279 280 281
            NR="True"
            echo_info "Will compile NR UE"
            shift;;
Xu Bo's avatar
Xu Bo committed
282 283 284 285
       --mu)
            UE_EXPANSION="True"
            echo_info "Will compile with UE_EXPANSION"
            shift;;
Cedric Roux's avatar
Cedric Roux committed
286
       --UE-conf-nvram)
287
            conf_nvram_path=$(readlink -f $2)
Cedric Roux's avatar
Cedric Roux committed
288
            shift 2;;
289
       --UE-gen-nvram)
290 291
            gen_nvram_path=$(readlink -f $2)
            shift 2;;
thomasl's avatar
thomasl committed
292
       -w | --hardware)
293 294 295 296 297
            # Use OAI_USRP as the key word USRP is used inside UHD driver           
            case "$2" in
                "EXMIMO")
                    HW="EXMIMO"
                    ;;
Fang-WANG's avatar
Fang-WANG committed
298
                "USRP" | "BLADERF" | "LMSSDR" | "IRIS" | "ADRV9371_ZC706" | "SIMU" | "YUNSDR")
299 300 301 302 303 304 305
                    HW="OAI_"$2
                    ;;
                "None")
                    HW="None"
                    ;;
                *)
                    echo_fatal "Unknown HW type $HW: exit..."
306
            esac
307
			echo_info "Setting hardware to: $HW"
thomasl's avatar
thomasl committed
308
            shift 2;;
309 310 311
       -t | --transport)
	    TP=$2
            shift 2;;
312
       -P | --phy_simulators)
thomasl's avatar
thomasl committed
313
            SIMUS_PHY=1
314
	          RU=0
315 316
            echo_info "Will compile dlsim, ulsim, ..."
            shift;;
317
       -S | --core_simulators)
318 319 320
            SIMUS_CORE=1
            echo_info "Will compile security unitary tests"
            shift;;
thomasl's avatar
thomasl committed
321 322
       -s | --check)
            OAI_TEST=1
323
            echo_info "Will run auto-tests"
thomasl's avatar
thomasl committed
324
            shift;;
325 326 327 328 329
       --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
330
       -V | --vcd)
331
            echo_info "Setting gtk-wave output"
thomasl's avatar
thomasl committed
332 333
            VCD_TIMING=1
            EXE_ARGUMENTS="$EXE_ARGUMENTS -V"
thomasl's avatar
thomasl committed
334
            shift;;
thomasl's avatar
thomasl committed
335
       -x | --xforms)
336
            XFORMS=1
thomasl's avatar
thomasl committed
337
            EXE_ARGUMENTS="$EXE_ARGUMENTS -d"
338
            echo_info "Will generate the software oscilloscope features"
thomasl's avatar
thomasl committed
339
            shift;;
root's avatar
root committed
340 341 342 343 344 345 346 347
       --HWLAT)
            HWLAT=1
            echo_info "Will compile hw latency test program"
            shift;;
       --HWLAT_TEST)
            HWLAT_TEST=1
            echo_info "Will compile hw latency test program"
            shift;;
348 349 350 351
       --verbose-ci)
	        VERBOSE_CI=1
            echo_info "Will compile with verbose instructions in CI Docker env"
            shift;;
352
       --verbose-compile)
353
	        VERBOSE_COMPILE=1
354 355
            echo_info "Will compile with verbose instructions"
            shift;;
356 357
       --cflags_processor)
            CFLAGS_PROCESSOR_USER=$2
358
            echo_info "Setting CPU FLAGS from USER to: $CFLAGS_PROCESSOR_USER"
359
            shift 2;;
360
       --build-doxygen)
361
	        BUILD_DOXYGEN=1
362 363
            echo_info "Will build doxygen support"
            shift;;     
364
       --build-coverity-scan)
365
            BUILD_COVERITY_SCAN=1
366 367
            echo_info "Will build Coverity-Scan objects for upload"
            shift;;
368
       --disable-deadline)
369
            DEADLINE_SCHEDULER_FLAG_USER="False"
370 371
            echo_info "Disabling the usage of deadline scheduler"
            shift 1;;
372
       --enable-deadline)
373
            DEADLINE_SCHEDULER_FLAG_USER="True"
374 375
            echo_info "Enabling the usage of deadline scheduler"
            shift 1;;
Florian Kaltenberger's avatar
Florian Kaltenberger committed
376 377 378 379
       --enable-cpu-affinity)
            CPU_AFFINITY_FLAG_USER="True"
            echo_info "Enabling CPU Affinity (only valid when not using deadline scheduler)"
            shift 1;;
380 381 382 383
       --disable-cpu-affinity)
            CPU_AFFINITY_FLAG_USER="False"
            echo_info "Disabling CPU Affinity (only valid when not using deadline scheduler)"
            shift 1;;
384 385 386
       --disable-T-Tracer)
            T_TRACER="False"
            echo_info "Disabling the T tracer"
387
            shift 1;;
388 389 390 391
       --disable-hardware-dependency)
            echo_info "Disabling hardware dependency for compiling software"
            DISABLE_HARDWARE_DEPENDENCY="True"
            shift 1;;
392
       --ue-autotest-trace)
393 394 395
            UE_AUTOTEST_TRACE="True"
            echo_info "Enabling autotest specific trace for UE"
            shift 1;;
396
       --ue-trace)
gabrielC's avatar
gabrielC committed
397 398 399
            UE_DEBUG_TRACE="True"
            echo_info "Enabling UE trace for debug"
            shift 1;;
400
       --ue-timing)
gabrielC's avatar
gabrielC committed
401 402 403
            UE_TIMING_TRACE="True"
            echo_info "Enabling UE timing trace"
            shift 1;;
404
       --uhd-images-dir)
405 406 407
            UHD_IMAGES_DIR=$2
            echo_info "Downloading UHD images in the indicated location"
            shift 2;;
408 409 410 411
       --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
412
            shift 1;;
413 414
       --build-lib) 
            BUILD_OPTLIB="" 
415 416 417 418 419
            if [  "$2" == "all" ] ; then
              BUILD_OPTLIB="$OPTIONAL_LIBRARIES"
              echo_info "Enabling build of all optional shared libraries ($OPTIONAL_LIBRARIES)" 
            else
              for alib in $2 ; do 
420
                for oklib in $OPTIONAL_LIBRARIES ; do
421 422 423 424 425
                  if [ "$alib" = "$oklib" ] ; then
                    BUILD_OPTLIB="$BUILD_OPTLIB $alib" 
                    echo_info "Enabling build of lib${alib}.so" 
                    fi   
                  done
426
                done
427 428 429
	          if [ "${BUILD_OPTLIB## }" != "$2" ] ; then
                 echo_fatal "Unknown optional library in $2, valid libraries are $OPTIONAL_LIBRARIES" 
              fi
430 431
            fi
            shift 2;;		
432 433 434 435
        --usrp-recplay)
            USRP_REC_PLAY="True"
            echo_info "Enabling USRP record playback mode"
            shift 1;;
436 437
        -k | --skip-shared-libraries)
            SKIP_SHARED_LIB_FLAG="True"
438
            echo_info "Skipping build of shared libraries, rfsimulator and transport protocol libraries"
439
            shift;;
laurent's avatar
laurent committed
440 441 442 443
    --ninja)
        CMAKE_CMD="$CMAKE_CMD -GNinja"
	MAKE_CMD=ninja
	shift;;
444 445 446
    --sanitize-address | -fsanitize=address)
        SANITIZE_ADDRESS=True
        shift;;
heshanyun's avatar
heshanyun committed
447 448 449 450 451
      --ittiSIM)
            ittiSIM=1
            ITTI_SIM="True"
            echo_info "Will compile itti simulator"
            shift;;
thomasl's avatar
thomasl committed
452 453 454
        -h | --help)
            print_help
            exit 1;;
Lionel Gauthier's avatar
Lionel Gauthier committed
455
	*)
456 457
	    print_help
            echo_fatal "Unknown option $1"
thomasl's avatar
thomasl committed
458
            break;;
thomasl's avatar
thomasl committed
459
   esac
460
  done
461

yilmazt's avatar
yilmazt committed
462 463 464
  ###################################
  # Check if cov-build is installed #
  ###################################
465 466 467 468 469 470 471 472 473 474
  if [ "$BUILD_COVERITY_SCAN" == "1" ] ; then
      echo_info "Checking cov-build is installed"
      IS_INSTALLED=`which cov-build | grep -c cov-build || true`
      if [ $IS_INSTALLED -eq 1 ] ; then
          echo_info "Found cov-build"
      else
          echo_fatal "Did NOT find cov-build in PATH!"
      fi
  fi

475 476
  CMAKE_CMD="$CMAKE_CMD .."
  echo_info "CMAKE_CMD=$CMAKE_CMD"
Guy De Souza's avatar
Guy De Souza committed
477

yilmazt's avatar
yilmazt committed
478 479 480
  ########################################################
  # Check validity of HW and TP parameters for eNB / gNB #
  ########################################################
Aikaterini's avatar
Aikaterini committed
481
  # to be discussed
482
  
483
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" -o "$RU" = "1" ] ; then
484
      if [ "$HW" = "None" -a  "$TP" = "None" ] ; then
yilmazt's avatar
yilmazt committed
485
	      echo_info "No local radio head and no transport protocol selected"
486
      fi
487
      if [ "$HW" = "None" ] ; then 
yilmazt's avatar
yilmazt committed
488
	      echo_info "No radio head has been selected (HW set to $HW)"	
489
      fi
490
      if [ "$TP" = "None" ] ; then
yilmazt's avatar
yilmazt committed
491
	      echo_info "No transport protocol has been selected (TP set to $TP)"	
492 493 494
      fi
  fi
  
root's avatar
root committed
495 496
  if [ "$HWLAT" = "1" ] ; then
      if [ "$HW" = "None" ] ; then
yilmazt's avatar
yilmazt committed
497
          echo_info "No radio head has been selected (HW set to $HW)" 
root's avatar
root committed
498 499 500
      fi
  fi

501
  echo_info "RF HW set to $HW" 
502 503
  # If the user doesn't specify the Linux scheduler to use, we set a value
  if [ "$DEADLINE_SCHEDULER_FLAG_USER" = "" ]; then
yilmazt's avatar
yilmazt committed
504
      case "$HW" in
505
          "EXMIMO")
yilmazt's avatar
yilmazt committed
506 507
		      DEADLINE_SCHEDULER_FLAG_USER="True"
		      ;;
508
          *)
yilmazt's avatar
yilmazt committed
509 510 511
		      DEADLINE_SCHEDULER_FLAG_USER="False"
		      ;;
      esac
512 513
  fi

514
  #Disable CPU Affinity for deadline scheduler
laurent's avatar
laurent committed
515
  if [ "$DEADLINE_SCHEDULER_FLAG_USER" = "True" ] ; then 
516 517
     CPU_AFFINITY_FLAG_USER="False"
  fi
518

laurent's avatar
laurent committed
519
  echo_info "Flags for Deadline scheduler: $DEADLINE_SCHEDULER_FLAG_USER"
520
  echo_info "Flags for CPU Affinity: $CPU_AFFINITY_FLAG_USER"
Aikaterini's avatar
Aikaterini committed
521

yilmazt's avatar
yilmazt committed
522 523 524
  #######################################################
  # Setting and printing OAI envs, we should check here #
  #######################################################
Lionel Gauthier's avatar
Lionel Gauthier committed
525

526
  echo_info "2. Setting the OAI PATHS ..."
thomasl's avatar
thomasl committed
527

528
  cecho "OPENAIR_DIR    = $OPENAIR_DIR" $green
thomasl's avatar
thomasl committed
529

530 531 532 533 534 535 536 537 538 539
  # 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
540

541 542 543 544
  if [ "$CLEAN_ALL" = "1" ] ; then
    clean_all_files
    echo_info "Erased all previously producted files"
  fi
545

546 547 548 549 550 551 552
  dbin=$OPENAIR_DIR/targets/bin
  dlog=$OPENAIR_DIR/cmake_targets/log
  mkdir -p $dbin $dlog

  if [ "$INSTALL_EXTERNAL" = "1" ] ; then
    echo_info "Installing packages"
    check_install_oai_software
553 554 555
    if [ "$HW" == "OAI_USRP" ] ; then
      echo_info "installing packages for USRP support"
      check_install_usrp_uhd_driver
556
      if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
557
        install_usrp_uhd_driver $UHD_IMAGES_DIR
558
      fi
559
    fi 
frobinet's avatar
frobinet committed
560 561 562 563
#    if [ "$HW" == "OAI_ADRV9371_ZC706" ] ; then
#      echo_info "\nInstalling packages for ADRV9371_ZC706 support"
#      check_install_libiio_driver
#    fi 
564
    if [ "$HW" == "OAI_BLADERF" ] ; then
565
      echo_info "installing packages for BLADERF support"
566
      check_install_bladerf_driver
567 568 569
      if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
        flash_firmware_bladerf
      fi
570
    fi
Fang-WANG's avatar
Fang-WANG committed
571 572 573 574
    if [ "$HW" == "OAI_YUNSDR" ] ; then
      echo_info "installing packages for YUNSDR support"
      #check_install_yunsdr_driver
    fi
575 576 577 578 579 580
    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
581
    fi
582
    echo_info "Installing protobuf/protobuf-c for flexran agent support"
583 584
    install_protobuf_from_source
    install_protobuf_c_from_source
585
    echo_success "protobuf/protobuf-c installation successful"
586 587 588 589 590 591 592
  fi

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

593 594
  
  
595 596 597
  echo_info "3. building the compilation directives ..."

  DIR=$OPENAIR_DIR/cmake_targets
598 599
  if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
    build_dir=phy_simulators
600
  else
601
    if [ "$T_TRACER" =  "False" ] ; then
602
      build_dir=ran_build_noLOG
603
    else
yilmazt's avatar
yilmazt committed
604
      build_dir=ran_build  
605
    fi
606
  fi
607 608
  [ "$CLEAN" = "1" ] && rm -rf $DIR/$build_dir/build
  mkdir -p $DIR/$build_dir/build
609

610 611 612
# configuration module libraries, one currently available, using libconfig 
  config_libconfig_shlib=params_libconfig
  
613
  # first generate the CMakefile in the right directory
614
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$RU" = "1" -o "$nrUE" = "1" -o "$HW" = "EXMIMO" -o "$ittiSIM" = "1" -o "$rfsimNas" = "1" ] ; then
615

Guy De Souza's avatar
Guy De Souza committed
616
    # softmodem compilation
617

Guy De Souza's avatar
Guy De Souza committed
618
    cmake_file=$DIR/$build_dir/CMakeLists.txt
yilmazt's avatar
yilmazt committed
619
    echo "cmake_minimum_required(VERSION 2.8)"                             >  $cmake_file
Laurent's avatar
Laurent committed
620
    echo "project (OpenAirInterface)"                                    >> $cmake_file
621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636
    echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )"                     >> $cmake_file
    echo "set ( CFLAGS_PROCESSOR_USER \"$CFLAGS_PROCESSOR_USER\" )"       >> $cmake_file
    echo "set ( UE_EXPANSION $UE_EXPANSION )"                             >> $cmake_file
#    echo "set ( PHY_TX_THREAD $UE_EXPANSION )"                            >> $cmake_file
    echo "set ( PRE_SCD_THREAD $UE_EXPANSION )"                           >> $cmake_file
    echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )"                            >> $cmake_file
    echo "set ( RF_BOARD \"${HW}\")"                                      >> $cmake_file
    echo "set ( TRANSP_PRO \"${TP}\")"                                    >> $cmake_file
    echo "set ( PACKAGE_NAME \"${exec}\")"                                >> $cmake_file
    echo "set ( DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )" >> $cmake_file
    echo "set ( CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )"             >> $cmake_file
    echo "set ( T_TRACER $T_TRACER )"                                     >> $cmake_file
    echo "set ( UE_AUTOTEST_TRACE $UE_AUTOTEST_TRACE )"                   >> $cmake_file
    echo "set ( UE_DEBUG_TRACE $UE_DEBUG_TRACE )"                         >> $cmake_file
    echo "set ( UE_TIMING_TRACE $UE_TIMING_TRACE )"                       >> $cmake_file
    echo "set ( USRP_REC_PLAY $USRP_REC_PLAY )"                           >> $cmake_file
637
    echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )"             >> $cmake_file
638
    echo "set ( RU $RU )"                                                 >> $cmake_file
heshanyun's avatar
heshanyun committed
639
    echo "set ( ITTI_SIM $ITTI_SIM )"                                     >> $cmake_file
640
    echo "set ( RFSIM_NAS $RFSIM_NAS )"                                   >> $cmake_file
641
    echo "set ( SANITIZE_ADDRESS $SANITIZE_ADDRESS )"                     >> $cmake_file
642
    echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)'         >> $cmake_file
Guy De Souza's avatar
Guy De Souza committed
643
    cd  $DIR/$build_dir/build
644
    eval $CMAKE_CMD
645

646 647 648 649
    execlist=""
    if [ "$eNB" = "1" ] ; then
      execlist="$execlist lte-softmodem"
    fi
hardy's avatar
hardy committed
650 651 652
    if [ "$eNBocp" = "1" ] ; then
      execlist="$execlist ocp-enb"
    fi
653 654 655
    if [ "$gNB" = "1" ] ; then
      execlist="$execlist nr-softmodem"
    fi
656 657 658
    if [ "$RU" = "1" ] ; then
      execlist="$execlist oairu"
    fi
659 660 661 662 663 664
    if [ "$UE" = 1 ] ; then
      execlist="$execlist lte-uesoftmodem"
    fi
    if [ "$nrUE" = 1 ] ; then
      execlist="$execlist nr-uesoftmodem"
    fi
665

heshanyun's avatar
heshanyun committed
666 667 668 669
    if [ "$ittiSIM" = "1" ] ; then
      execlist="$execlist nr-ittisim"
    fi

670 671
    for f in $execlist ; do
      echo_info "Compiling $f..."
672
      compilations \
673 674 675
        $build_dir $f \
        $f $dbin/$f.$REL
    done
676

677

yilmazt's avatar
yilmazt committed
678 679
# mandatory shared libraries common to UE and (e/g)NB

680
    if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then
681
      echo_info "Building shared libraries common to UE and gNB"
yilmazt's avatar
yilmazt committed
682

683 684 685
      compilations \
        $build_dir $config_libconfig_shlib \
        lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
686

687
      if [ "$RU" = "0" ] ; then
688 689

        compilations \
690 691
          $build_dir coding \
          libcoding.so $dbin/libcoding.so
692

693 694 695 696 697 698 699 700
        #check if we run inside a container or not
        #IS_CONTAINER variable is defined in build_helper file
        #compile  nasmesh and rb_tool only if NOT running in a container
        if [ $IS_CONTAINER -eq 0 ]
        then
          compilations \
            $build_dir nasmesh \
            CMakeFiles/nasmesh/nasmesh.ko $dbin/nasmesh.ko
yilmazt's avatar
yilmazt committed
701

702 703 704 705 706 707
          compilations \
            $build_dir rb_tool \
            rb_tool $dbin/rb_tool

          cp $OPENAIR_DIR/cmake_targets/tools/init_nas_nos1 $dbin
        fi #IS_CONTAINER
708
      fi
709
    fi
710
  fi
711

yilmazt's avatar
yilmazt committed
712
  if [ "$UE" = 1 ] ; then
713

714
    echo_info "Compiling UE specific part"
715 716 717 718 719 720 721 722 723 724

    if [ $IS_CONTAINER -eq 0 ]
    then
      echo_info "Building ue_ip module"
      compilations \
        $build_dir ue_ip \
        CMakeFiles/ue_ip/ue_ip.ko $dbin/ue_ip.ko
    else
      echo_info "Bypassing ue_ip build"
    fi #IS_CONTAINER
725

Lionel Gauthier's avatar
Lionel Gauthier committed
726 727
#    mkdir -p $DIR/at_commands/build
#    cd $DIR/at_commands/build
728
#    eval $CMAKE_CMD
Lionel Gauthier's avatar
Lionel Gauthier committed
729 730 731
#    compilations \
#      at_commands at_nas_ue \
#      at_nas_ue $dbin/at_nas_ue
732

Lionel Gauthier's avatar
Lionel Gauthier committed
733
    [ "$CLEAN" = "1" ] && rm -rf $DIR/nas_sim_tools/build
734 735
    mkdir -p $DIR/nas_sim_tools/build
    cd $DIR/nas_sim_tools/build
736

737
    eval $CMAKE_CMD
thomasl's avatar
thomasl committed
738
    compilations \
739 740
      nas_sim_tools usim \
      usim $dbin/usim
thomasl's avatar
thomasl committed
741
    compilations \
742 743
      nas_sim_tools nvram \
      nvram $dbin/nvram
thomasl's avatar
thomasl committed
744
    compilations \
745 746
      nas_sim_tools conf2uedata \
      conf2uedata $dbin/conf2uedata
747 748

    # generate USIM data
749 750
    if [ -f $dbin/conf2uedata ]; then
      install_nas_tools $conf_nvram_path $gen_nvram_path
Guy De Souza's avatar
Guy De Souza committed
751 752 753 754
      echo_info "Copying UE specific part to $DIR/$build_dir/build"
      cp -Rvf $dbin/.ue_emm.nvram0 $DIR/$build_dir/build
      cp -Rvf $dbin/.ue.nvram0 $DIR/$build_dir/build
      cp -Rvf $dbin/.usim.nvram0 $DIR/$build_dir/build
755 756 757
    else
      echo_warning "not generated UE NAS files: binaries not found"
    fi
758
  fi
thomasl's avatar
thomasl committed
759

760
  if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
761
    cd  $DIR/$build_dir/build
762
    eval $CMAKE_CMD
763
  fi
764

yilmazt's avatar
yilmazt committed
765 766 767
  ##################
  # PHY simulators #
  ##################
768
  if [ "$SIMUS_PHY" = "1" ] ; then
yilmazt's avatar
yilmazt committed
769
    echo_info "Compiling physical unitary tests simulators"
770
    # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
771
    simlist="dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim"
WANG Tsu-Han's avatar
WANG Tsu-Han committed
772
	# simlist="ldpctest"
773 774
    for f in $simlist ; do
      compilations \
yilmazt's avatar
yilmazt committed
775 776
        phy_simulators $f \
	    $f $dbin/$f.$REL
777
    done
778
    compilations \
yilmazt's avatar
yilmazt committed
779 780
      phy_simulators coding \
      libcoding.so $dbin/libcoding.so
781
#    compilations \
yilmazt's avatar
yilmazt committed
782 783
#	   lte-simulators $config_libconfig_shlib \
#	   lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
784
  fi
thomasl's avatar
thomasl committed
785

yilmazt's avatar
yilmazt committed
786 787 788
  ###################
  # Core simulators #
  ###################
789
  if [ "$SIMUS_CORE" = "1" ] ; then
yilmazt's avatar
yilmazt committed
790
    echo_info "Compiling security unitary tests simulators"
791 792 793
    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 \
yilmazt's avatar
yilmazt committed
794 795
	    phy_simulators test_$f \
	    test_$f $dbin/test_$f.$REL
796 797
    done
  fi
thomasl's avatar
thomasl committed
798

yilmazt's avatar
yilmazt committed
799 800 801
  ####################################
  # EXMIMO drivers & firmware loader #
  ####################################
802
  if [ "$HW" = "EXMIMO" ] ; then
803 804
    echo_info "Compiling Express MIMO 2 board drivers"
    compilations \
yilmazt's avatar
yilmazt committed
805 806
      $build_dir openair_rf \
      CMakeFiles/openair_rf/openair_rf.ko $dbin/openair_rf.ko
807
    compilations \
Guy De Souza's avatar
Guy De Souza committed
808
	  $build_dir updatefw \
Lionel Gauthier's avatar
Lionel Gauthier committed
809
	  updatefw $dbin/updatefw
810
    echo_info "Compiling oarf tools. The logfile for compilation is here: $dlog/oarf.txt"
Guy De Souza's avatar
Guy De Souza committed
811 812
    make -C $OPENAIR_DIR/cmake_targets/$build_dir/build oarf > $dlog/oarf.txt 2>&1
    cp $OPENAIR_DIR/cmake_targets/$build_dir/build/*.oct $dbin
813
    if [ -s $dbin/oarf_config_exmimo.oct ] ; then
yilmazt's avatar
yilmazt committed
814
	  echo_success "oarf tools compiled"
815
    else
yilmazt's avatar
yilmazt committed
816
	  echo_error "oarf tools compilation failed"
817
    fi
818
    cp $OPENAIR_DIR/cmake_targets/tools/init_exmimo2 $dbin
819
  fi
820
  
yilmazt's avatar
yilmazt committed
821 822 823
  ######################
  # Optional libraries #
  ######################
824 825 826
  if [ ! -z "$BUILD_OPTLIB" ] ; then 
     for oklib in $BUILD_OPTLIB ; do
         compilations \
yilmazt's avatar
yilmazt committed
827
             $build_dir $oklib \
828
             lib${oklib}.so $dbin/lib${oklib}.so
829
     done
yilmazt's avatar
yilmazt committed
830
  fi
thomasl's avatar
thomasl committed
831

832
  #####################
yilmazt's avatar
yilmazt committed
833
  # HWLAT compilation #
root's avatar
root committed
834 835 836
  #####################
  if [ "$HWLAT" = "1" ] ; then

yilmazt's avatar
yilmazt committed
837 838
      hwlat_exec=lte-hwlat
      hwlat_build_dir=lte-hwlat
root's avatar
root committed
839
     
yilmazt's avatar
yilmazt committed
840
      echo_info "Compiling $hwlat_exec ..."
root's avatar
root committed
841
    
yilmazt's avatar
yilmazt committed
842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
      [ "$CLEAN" = "1" ] && rm -rf $DIR/lte-hwlat/build 
      mkdir -p $DIR/$hwlat_build_dir/build
      cmake_file=$DIR/$hwlat_build_dir/CMakeLists.txt
      echo "cmake_minimum_required(VERSION 2.8)"                             > $cmake_file
      echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )"                     >> $cmake_file
      echo "set ( RF_BOARD \"${HW}\")"                                      >> $cmake_file
      echo 'set ( PACKAGE_NAME "\"lte-hwlat\"")'                            >> $cmake_file
      echo "set ( DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )" >> $cmake_file
      echo "set ( CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )"             >> $cmake_file
      echo "set ( HWLAT \"${HWLAT}\" )"                                     >> $cmake_file
      echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)'         >> $cmake_file    
      cd $DIR/$hwlat_build_dir/build
      cmake ..
      compilations \
          lte-hwlat lte-hwlat \
          lte-hwlat $dbin/lte-hwlat
root's avatar
root committed
858 859
  fi  
 
yilmazt's avatar
yilmazt committed
860 861 862
  ##########################
  # HWLAT_TEST compilation #
  ##########################
root's avatar
root committed
863 864
  if [ "$HWLAT_TEST" = "1" ] ; then

yilmazt's avatar
yilmazt committed
865 866
      hwlat_test_exec=lte-hwlat-test
      hwlat_test_build_dir=lte-hwlat-test
root's avatar
root committed
867
     
yilmazt's avatar
yilmazt committed
868
      echo_info "Compiling $hwlat_test_exec ..."
root's avatar
root committed
869
    
yilmazt's avatar
yilmazt committed
870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885
      [ "$CLEAN" = "1" ] && rm -rf $DIR/lte-hwlat-test/build 
      mkdir -p $DIR/$hwlat_test_build_dir/build
      cmake_file=$DIR/$hwlat_test_build_dir/CMakeLists.txt
      echo "cmake_minimum_required(VERSION 2.8)"                             > $cmake_file
      echo "set ( CMAKE_BUILD_TYPE $CMAKE_BUILD_TYPE )"                     >> $cmake_file
      echo "set ( RF_BOARD \"${HW}\")"                                      >> $cmake_file
      echo 'set ( PACKAGE_NAME "\"lte-hwlat-test\"")'                       >> $cmake_file
      echo "set ( DEADLINE_SCHEDULER \"${DEADLINE_SCHEDULER_FLAG_USER}\" )" >> $cmake_file
      echo "set ( CPU_AFFINITY \"${CPU_AFFINITY_FLAG_USER}\" )"             >> $cmake_file
      echo "set ( HWLAT \"${HWLAT}\" )"                                     >> $cmake_file
      echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)'         >> $cmake_file    
      cd $DIR/$hwlat_test_build_dir/build
      cmake ..
      compilations \
          lte-hwlat-test lte-hwlat-test \
          lte-hwlat-test $dbin/lte-hwlat-test
886
  fi
yilmazt's avatar
yilmazt committed
887 888 889 890
  
  ####################################################
  # Build RF device and transport protocol libraries #
  ####################################################
891
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$RU" = "1"  -o "$nrUE" = "1" -o "$HWLAT" = "1" ] ; then
892

893
      # build RF device libraries
894
      if [ "$HW" != "None" ] ; then
yilmazt's avatar
yilmazt committed
895 896 897 898 899
          rm -f liboai_device.so
          rm -f $dbin/liboai_device.so

          # link liboai_device.so with the selected RF device library
          if [ "$HW" == "EXMIMO" ] ; then
900
              compilations \
yilmazt's avatar
yilmazt committed
901
                  $build_dir oai_exmimodevif \
902
                  liboai_exmimodevif.so $dbin/liboai_exmimodevif.so.$REL
yilmazt's avatar
yilmazt committed
903

904 905 906 907
              ln -sf liboai_exmimodevif.so liboai_device.so
              ln -sf $dbin/liboai_exmimodevif.so.$REL $dbin/liboai_device.so
              echo_info "liboai_device.so is linked to EXMIMO device library"
          elif [ "$HW" == "OAI_USRP" ] ; then
908 909 910
              compilations \
                  $build_dir oai_usrpdevif \
                  liboai_usrpdevif.so $dbin/liboai_usrpdevif.so.$REL
911

yilmazt's avatar
yilmazt committed
912 913 914 915 916 917 918 919 920 921 922 923 924
              ln -sf liboai_usrpdevif.so liboai_device.so
              ln -sf $dbin/liboai_usrpdevif.so.$REL $dbin/liboai_device.so
              echo_info "liboai_device.so is linked to USRP device library"        
          elif [ "$HW" == "OAI_BLADERF" ] ; then
              if [ -f "/usr/include/libbladeRF.h" ] ; then
                  compilations \
                      $build_dir oai_bladerfdevif \
                      liboai_bladerfdevif.so $dbin/liboai_bladerfdevif.so.$REL
              fi

              ln -sf liboai_bladerfdevif.so liboai_device.so
              ln -sf $dbin/liboai_bladerfdevif.so.$REL $dbin/liboai_device.so
              echo_info "liboai_device.so is linked to BLADERF device library"	 
Fang-WANG's avatar
Fang-WANG committed
925 926 927 928 929 930 931 932 933 934
          elif [ "$HW" == "OAI_YUNSDR" ] ; then
             if [ -f "/usr/local/include/yunsdr_api_ss.h" ] ; then
                 compilations \
                     $build_dir oai_yunsdrdevif \
                     liboai_yunsdrdevif.so $dbin/liboai_yunsdrdevif.so.$REL
             fi

             ln -sf liboai_yunsdrdevif.so liboai_device.so
             ln -sf $dbin/liboai_yunsdrdevif.so.$REL $dbin/liboai_device.so
             echo_info "liboai_device.so is linked to YUNSDR device library"
yilmazt's avatar
yilmazt committed
935 936 937 938 939 940
          elif [ "$HW" == "OAI_LMSSDR" ] ; then
#              if [ -f "/usr/include/libbladeRF.h" ] ; then
                  compilations \
                      $build_dir oai_lmssdrdevif \
                      liboai_lmssdrdevif.so $dbin/liboai_lmssdrdevif.so.$REL
#              fi
941

yilmazt's avatar
yilmazt committed
942 943 944
              ln -sf liboai_lmssdrdevif.so liboai_device.so
              ln -sf $dbin/liboai_lmssdrdevif.so.$REL $dbin/liboai_device.so
              echo_info "liboai_device.so is linked to LMSSDR device library"	 
945
          elif [ "$HW" == "OAI_IRIS" ] ; then
yilmazt's avatar
yilmazt committed
946 947 948
              compilations \
                  $build_dir oai_irisdevif \
                  liboai_irisdevif.so $dbin/liboai_irisdevif.so.$REL
949 950 951 952

              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"
yilmazt's avatar
yilmazt committed
953 954 955 956 957 958 959 960 961 962 963 964
          elif [ "$HW" == "OAI_ADRV9371_ZC706" ] ; then
              SYRIQ_KVER=$(uname -r)
              SYRIQ_KMAJ=$(echo $SYRIQ_KVER | sed -e 's/^\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*.*/\1/')
              SYRIQ_KMIN=$(echo $SYRIQ_KVER | sed -e 's/^[0-9][0-9]*\.\([0-9][0-9]*\)\.[0-9][0-9]*.*/\1/')
#              echo $SYRIQ_KMAJ$SYRIQ_KMIN
              if [ "$SYRIQ_KMAJ$SYRIQ_KMIN" == "319" ] || [ "$SYRIQ_KMAJ$SYRIQ_KMIN" == "410" ] || [ "$SYRIQ_KMAJ$SYRIQ_KMIN" == "415" ] ; then
#                  echo "Kernel $SYRIQ_KMAJ.$SYRIQ_KMIN detected"
                  ln -sf /usr/local/lib/syriq/libadrv9371zc706.so liboai_device.so
              else
                  echo_error "== FAILED == Unexpected Kernel $SYRIQ_KMAJ.$SYRIQ_KMIN"
              fi
              echo_info "liboai_device.so is linked to ADRV9371_ZC706 device library for Kernel $SYRIQ_KMAJ.$SYRIQ_KMIN"
965 966 967
          else
              echo_info "liboai_device.so is not linked to any device library"
          fi
968
      fi
969

yilmazt's avatar
yilmazt committed
970
      #build simulators devices
971
      if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then
972 973 974 975 976
          echo_info "Compiling rfsimulator"
          compilations \
              $build_dir rfsimulator \
              librfsimulator.so $dbin/librfsimulator.so.$REL

977
          echo_info "Compiling tcp_bridge_oai"
978 979 980
          compilations \
              $build_dir tcp_bridge_oai \
              libtcp_bridge_oai.so $dbin/libtcp_bridge_oai.so.$REL
981
      fi
982

yilmazt's avatar
yilmazt committed
983
      #build transport protocol libraries (currently only ETHERNET is available)
984
      if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then
985 986 987
          echo_info "Building transport protocol libraries"
          rm -f liboai_transpro.so
          rm -f $dbin/liboai_transpro.so
988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011
	  if [ "$TP" == "Ethernet" ]; then
              compilations \
		  $build_dir oai_eth_transpro \
		  liboai_eth_transpro.so $dbin/liboai_eth_transpro.so.$REL
              ln -sf liboai_eth_transpro.so liboai_transpro.so
              ln -sf $dbin/liboai_eth_transpro.so.$REL $dbin/liboai_transpro.so
              echo_info "liboai_transpro.so is linked to ETHERNET transport"
	  fi
	  if [ "$TP" == "benetel4g" ]; then
              compilations \
		  $build_dir benetel_4g \
		  libbenetel_4g.so $dbin/libbenetel_4g.$REL
              ln -sf libbenetel_4g.so liboai_transpro.so
              ln -sf $dbin/libbenetel_4g.so.$REL $dbin/liboai_transpro.so
              echo_info "liboai_transpro.so is linked to BENETEL4G transport"
	  fi
	  if [ "$TP" == "benetel5g" ]; then
              compilations \
		  $build_dir benetel_5g \
		  libbenetel_5g.so $dbin/libbenetel_5g.$REL
              ln -sf libbenetel_5g.so liboai_transpro.so
              ln -sf $dbin/libbenetel_5g.so.$REL $dbin/liboai_transpro.so
              echo_info "liboai_transpro.so is linked to BENETEL4G transport"
	  fi
1012
      fi
yilmazt's avatar
yilmazt committed
1013
  fi
1014

yilmazt's avatar
yilmazt committed
1015 1016 1017 1018
  ###################
  # Doxygen Support #
  ###################
  if [ "$BUILD_DOXYGEN" = "1" ] ; then
1019
    doxygen_log=$OPENAIR_DIR/cmake_targets/log/doxygen.log
yilmazt's avatar
yilmazt committed
1020 1021 1022
    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"
1023 1024 1025 1026
    (
    [ "$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
1027
    eval $CMAKE_CMD
1028 1029
    make doc
    ) >& $doxygen_log
1030 1031
  fi

yilmazt's avatar
yilmazt committed
1032 1033 1034 1035
  ##############
  # Auto-tests #
  ##############
  if [ "$OAI_TEST" = "1" ] ; then
thomasl's avatar
thomasl committed
1036
    echo_info "10. Running OAI pre commit tests (pre-ci) ..."
1037 1038 1039 1040
    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 "
1041 1042
    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 "
yilmazt's avatar
yilmazt committed
1043
    echo_info "You can hit CTRL-C at any time to terminate the autotests..."
1044 1045 1046
    echo "Current User Name: $USER"
    read -s -p "Enter Password: " mypassword
    echo -e "\n"
1047 1048
    rm -fr $OPENAIR_DIR/cmake_targets/autotests/log
    mkdir -p $OPENAIR_DIR/cmake_targets/autotests/log
1049
    if [ "$RUN_GROUP" -eq "1" ]; then
1050
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -g "$TEST_CASE_GROUP" -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
1051
    else
1052
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
1053
    fi
1054
    wait
Lionel Gauthier's avatar
Lionel Gauthier committed
1055
  else
thomasl's avatar
thomasl committed
1056
    echo_info "10. Bypassing the Tests ..."
1057
    echo_success "BUILD SHOULD BE SUCCESSFUL"
Lionel Gauthier's avatar
Lionel Gauthier committed
1058
  fi
1059

1060 1061 1062
}

main "$@"