build_oai 37.4 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
heshanyun's avatar
heshanyun committed
69
ITTI_SIM="False"
70
RFSIM_NAS="False"
71
SANITIZE_ADDRESS="False"
72
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc"
73 74
trap handle_ctrl_c INT

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

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


function main() {
179

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

yilmazt's avatar
yilmazt committed
446 447 448
  ###################################
  # Check if cov-build is installed #
  ###################################
449 450 451 452 453 454 455 456 457 458
  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

459 460
  CMAKE_CMD="$CMAKE_CMD .."
  echo_info "CMAKE_CMD=$CMAKE_CMD"
Guy De Souza's avatar
Guy De Souza committed
461

yilmazt's avatar
yilmazt committed
462 463 464
  ########################################################
  # Check validity of HW and TP parameters for eNB / gNB #
  ########################################################
Aikaterini's avatar
Aikaterini committed
465
  # to be discussed
466
  
hardy's avatar
hardy committed
467
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" ] ; then
468
      if [ "$HW" = "None" -a  "$TP" = "None" ] ; then
yilmazt's avatar
yilmazt committed
469
	      echo_info "No local radio head and no transport protocol selected"
470
      fi
471
      if [ "$HW" = "None" ] ; then 
yilmazt's avatar
yilmazt committed
472
	      echo_info "No radio head has been selected (HW set to $HW)"	
473
      fi
474
      if [ "$TP" = "None" ] ; then
yilmazt's avatar
yilmazt committed
475
	      echo_info "No transport protocol has been selected (TP set to $TP)"	
476 477 478
      fi
  fi
  
root's avatar
root committed
479 480
  if [ "$HWLAT" = "1" ] ; then
      if [ "$HW" = "None" ] ; then
yilmazt's avatar
yilmazt committed
481
          echo_info "No radio head has been selected (HW set to $HW)" 
root's avatar
root committed
482 483 484
      fi
  fi

485
  echo_info "RF HW set to $HW" 
486 487
  # 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
488
      case "$HW" in
489
          "EXMIMO")
yilmazt's avatar
yilmazt committed
490 491
		      DEADLINE_SCHEDULER_FLAG_USER="True"
		      ;;
492
          *)
yilmazt's avatar
yilmazt committed
493 494 495
		      DEADLINE_SCHEDULER_FLAG_USER="False"
		      ;;
      esac
496 497
  fi

498
  #Disable CPU Affinity for deadline scheduler
laurent's avatar
laurent committed
499
  if [ "$DEADLINE_SCHEDULER_FLAG_USER" = "True" ] ; then 
500 501
     CPU_AFFINITY_FLAG_USER="False"
  fi
502

laurent's avatar
laurent committed
503
  echo_info "Flags for Deadline scheduler: $DEADLINE_SCHEDULER_FLAG_USER"
504
  echo_info "Flags for CPU Affinity: $CPU_AFFINITY_FLAG_USER"
Aikaterini's avatar
Aikaterini committed
505

yilmazt's avatar
yilmazt committed
506 507 508
  #######################################################
  # Setting and printing OAI envs, we should check here #
  #######################################################
Lionel Gauthier's avatar
Lionel Gauthier committed
509

510
  echo_info "2. Setting the OAI PATHS ..."
thomasl's avatar
thomasl committed
511

512
  cecho "OPENAIR_DIR    = $OPENAIR_DIR" $green
thomasl's avatar
thomasl committed
513

514 515 516 517 518 519 520 521 522 523
  # 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
524

525 526 527 528
  if [ "$CLEAN_ALL" = "1" ] ; then
    clean_all_files
    echo_info "Erased all previously producted files"
  fi
529

530 531 532 533 534 535 536
  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
537 538 539
    if [ "$HW" == "OAI_USRP" ] ; then
      echo_info "installing packages for USRP support"
      check_install_usrp_uhd_driver
540
      if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
541
        install_usrp_uhd_driver $UHD_IMAGES_DIR
542
      fi
543
    fi 
frobinet's avatar
frobinet committed
544 545 546 547
#    if [ "$HW" == "OAI_ADRV9371_ZC706" ] ; then
#      echo_info "\nInstalling packages for ADRV9371_ZC706 support"
#      check_install_libiio_driver
#    fi 
548
    if [ "$HW" == "OAI_BLADERF" ] ; then
549
      echo_info "installing packages for BLADERF support"
550
      check_install_bladerf_driver
551 552 553
      if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
        flash_firmware_bladerf
      fi
554
    fi
555 556 557 558 559 560
    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
561
    fi
562
    echo_info "Installing protobuf/protobuf-c for flexran agent support"
563 564
    install_protobuf_from_source
    install_protobuf_c_from_source
565
    echo_success "protobuf/protobuf-c installation successful"
566 567 568 569 570 571 572
  fi

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

573 574
  
  
575 576 577
  echo_info "3. building the compilation directives ..."

  DIR=$OPENAIR_DIR/cmake_targets
578 579
  if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
    build_dir=phy_simulators
580
  else
581
    if [ "$T_TRACER" =  "False" ] ; then
582
      build_dir=ran_build_noLOG
583
    else
yilmazt's avatar
yilmazt committed
584
      build_dir=ran_build  
585
    fi
586
  fi
587 588
  [ "$CLEAN" = "1" ] && rm -rf $DIR/$build_dir/build
  mkdir -p $DIR/$build_dir/build
589

590 591 592
# configuration module libraries, one currently available, using libconfig 
  config_libconfig_shlib=params_libconfig
  
593
  # first generate the CMakefile in the right directory
594
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$nrUE" = "1" -o "$HW" = "EXMIMO" -o "$ittiSIM" = "1" -o "$rfsimNas" = "1" ] ; then
595

Guy De Souza's avatar
Guy De Souza committed
596
    # softmodem compilation
597

Guy De Souza's avatar
Guy De Souza committed
598
    cmake_file=$DIR/$build_dir/CMakeLists.txt
yilmazt's avatar
yilmazt committed
599
    echo "cmake_minimum_required(VERSION 2.8)"                             >  $cmake_file
Laurent's avatar
Laurent committed
600
    echo "project (OpenAirInterface)"                                    >> $cmake_file
601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
    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
617
    echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )"             >> $cmake_file
heshanyun's avatar
heshanyun committed
618
    echo "set ( ITTI_SIM $ITTI_SIM )"                                     >> $cmake_file
619
    echo "set ( RFSIM_NAS $RFSIM_NAS )"                                   >> $cmake_file
620
    echo "set ( SANITIZE_ADDRESS $SANITIZE_ADDRESS )"                     >> $cmake_file
621
    echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)'         >> $cmake_file
Guy De Souza's avatar
Guy De Souza committed
622
    cd  $DIR/$build_dir/build
623
    eval $CMAKE_CMD
624

625 626 627 628
    execlist=""
    if [ "$eNB" = "1" ] ; then
      execlist="$execlist lte-softmodem"
    fi
hardy's avatar
hardy committed
629 630 631
    if [ "$eNBocp" = "1" ] ; then
      execlist="$execlist ocp-enb"
    fi
632 633 634 635 636 637 638 639 640
    if [ "$gNB" = "1" ] ; then
      execlist="$execlist nr-softmodem"
    fi
    if [ "$UE" = 1 ] ; then
      execlist="$execlist lte-uesoftmodem"
    fi
    if [ "$nrUE" = 1 ] ; then
      execlist="$execlist nr-uesoftmodem"
    fi
641

heshanyun's avatar
heshanyun committed
642 643 644 645
    if [ "$ittiSIM" = "1" ] ; then
      execlist="$execlist nr-ittisim"
    fi

646 647
    for f in $execlist ; do
      echo_info "Compiling $f..."
648
      compilations \
649 650 651
        $build_dir $f \
        $f $dbin/$f.$REL
    done
652

653

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

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

659 660 661
      compilations \
        $build_dir $config_libconfig_shlib \
        lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
662

663 664 665
      compilations \
        $build_dir coding \
        libcoding.so $dbin/libcoding.so
yilmazt's avatar
yilmazt committed
666

667

668 669 670 671 672 673 674 675 676 677 678 679 680
      #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

        compilations \
          $build_dir rb_tool \
          rb_tool $dbin/rb_tool

681 682
        cp $OPENAIR_DIR/cmake_targets/tools/init_nas_nos1 $dbin
      fi #IS_CONTAINER
683
    fi
yilmazt's avatar
yilmazt committed
684

685
  fi
686

yilmazt's avatar
yilmazt committed
687
  if [ "$UE" = 1 ] ; then
688

689
    echo_info "Compiling UE specific part"
690 691 692 693 694 695 696 697 698 699

    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
700

Lionel Gauthier's avatar
Lionel Gauthier committed
701 702
#    mkdir -p $DIR/at_commands/build
#    cd $DIR/at_commands/build
703
#    eval $CMAKE_CMD
Lionel Gauthier's avatar
Lionel Gauthier committed
704 705 706
#    compilations \
#      at_commands at_nas_ue \
#      at_nas_ue $dbin/at_nas_ue
707

Lionel Gauthier's avatar
Lionel Gauthier committed
708
    [ "$CLEAN" = "1" ] && rm -rf $DIR/nas_sim_tools/build
709 710
    mkdir -p $DIR/nas_sim_tools/build
    cd $DIR/nas_sim_tools/build
711

712
    eval $CMAKE_CMD
thomasl's avatar
thomasl committed
713
    compilations \
714 715
      nas_sim_tools usim \
      usim $dbin/usim
thomasl's avatar
thomasl committed
716
    compilations \
717 718
      nas_sim_tools nvram \
      nvram $dbin/nvram
thomasl's avatar
thomasl committed
719
    compilations \
720 721
      nas_sim_tools conf2uedata \
      conf2uedata $dbin/conf2uedata
722 723

    # generate USIM data
724 725
    if [ -f $dbin/conf2uedata ]; then
      install_nas_tools $conf_nvram_path $gen_nvram_path
Guy De Souza's avatar
Guy De Souza committed
726 727 728 729
      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
730 731 732
    else
      echo_warning "not generated UE NAS files: binaries not found"
    fi
733
  fi
thomasl's avatar
thomasl committed
734

735
  if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
736
    cd  $DIR/$build_dir/build
737
    eval $CMAKE_CMD
738
  fi
739

yilmazt's avatar
yilmazt committed
740 741 742
  ##################
  # PHY simulators #
  ##################
743
  if [ "$SIMUS_PHY" = "1" ] ; then
yilmazt's avatar
yilmazt committed
744
    echo_info "Compiling physical unitary tests simulators"
745
    # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
746
    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
747
	# simlist="ldpctest"
748 749
    for f in $simlist ; do
      compilations \
yilmazt's avatar
yilmazt committed
750 751
        phy_simulators $f \
	    $f $dbin/$f.$REL
752
    done
753
    compilations \
yilmazt's avatar
yilmazt committed
754 755
      phy_simulators coding \
      libcoding.so $dbin/libcoding.so
756
#    compilations \
yilmazt's avatar
yilmazt committed
757 758
#	   lte-simulators $config_libconfig_shlib \
#	   lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
759
  fi
thomasl's avatar
thomasl committed
760

yilmazt's avatar
yilmazt committed
761 762 763
  ###################
  # Core simulators #
  ###################
764
  if [ "$SIMUS_CORE" = "1" ] ; then
yilmazt's avatar
yilmazt committed
765
    echo_info "Compiling security unitary tests simulators"
766 767 768
    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
769 770
	    phy_simulators test_$f \
	    test_$f $dbin/test_$f.$REL
771 772
    done
  fi
thomasl's avatar
thomasl committed
773

yilmazt's avatar
yilmazt committed
774 775 776
  ####################################
  # EXMIMO drivers & firmware loader #
  ####################################
777
  if [ "$HW" = "EXMIMO" ] ; then
778 779
    echo_info "Compiling Express MIMO 2 board drivers"
    compilations \
yilmazt's avatar
yilmazt committed
780 781
      $build_dir openair_rf \
      CMakeFiles/openair_rf/openair_rf.ko $dbin/openair_rf.ko
782
    compilations \
Guy De Souza's avatar
Guy De Souza committed
783
	  $build_dir updatefw \
Lionel Gauthier's avatar
Lionel Gauthier committed
784
	  updatefw $dbin/updatefw
785
    echo_info "Compiling oarf tools. The logfile for compilation is here: $dlog/oarf.txt"
Guy De Souza's avatar
Guy De Souza committed
786 787
    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
788
    if [ -s $dbin/oarf_config_exmimo.oct ] ; then
yilmazt's avatar
yilmazt committed
789
	  echo_success "oarf tools compiled"
790
    else
yilmazt's avatar
yilmazt committed
791
	  echo_error "oarf tools compilation failed"
792
    fi
793
    cp $OPENAIR_DIR/cmake_targets/tools/init_exmimo2 $dbin
794
  fi
795
  
yilmazt's avatar
yilmazt committed
796 797 798
  ######################
  # Optional libraries #
  ######################
799 800 801
  if [ ! -z "$BUILD_OPTLIB" ] ; then 
     for oklib in $BUILD_OPTLIB ; do
         compilations \
yilmazt's avatar
yilmazt committed
802
             $build_dir $oklib \
803
             lib${oklib}.so $dbin/lib${oklib}.so
804
     done
yilmazt's avatar
yilmazt committed
805
  fi
thomasl's avatar
thomasl committed
806

807
  #####################
yilmazt's avatar
yilmazt committed
808
  # HWLAT compilation #
root's avatar
root committed
809 810 811
  #####################
  if [ "$HWLAT" = "1" ] ; then

yilmazt's avatar
yilmazt committed
812 813
      hwlat_exec=lte-hwlat
      hwlat_build_dir=lte-hwlat
root's avatar
root committed
814
     
yilmazt's avatar
yilmazt committed
815
      echo_info "Compiling $hwlat_exec ..."
root's avatar
root committed
816
    
yilmazt's avatar
yilmazt committed
817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832
      [ "$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
833 834
  fi  
 
yilmazt's avatar
yilmazt committed
835 836 837
  ##########################
  # HWLAT_TEST compilation #
  ##########################
root's avatar
root committed
838 839
  if [ "$HWLAT_TEST" = "1" ] ; then

yilmazt's avatar
yilmazt committed
840 841
      hwlat_test_exec=lte-hwlat-test
      hwlat_test_build_dir=lte-hwlat-test
root's avatar
root committed
842
     
yilmazt's avatar
yilmazt committed
843
      echo_info "Compiling $hwlat_test_exec ..."
root's avatar
root committed
844
    
yilmazt's avatar
yilmazt committed
845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860
      [ "$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
861
  fi
yilmazt's avatar
yilmazt committed
862 863 864 865
  
  ####################################################
  # Build RF device and transport protocol libraries #
  ####################################################
Raphael Defosseux's avatar
Raphael Defosseux committed
866
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$nrUE" = "1" -o "$HWLAT" = "1" ] ; then
867

868
      # build RF device libraries
869
      if [ "$HW" != "None" ] ; then
yilmazt's avatar
yilmazt committed
870 871 872 873 874
          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
875
              compilations \
yilmazt's avatar
yilmazt committed
876
                  $build_dir oai_exmimodevif \
877
                  liboai_exmimodevif.so $dbin/liboai_exmimodevif.so.$REL
yilmazt's avatar
yilmazt committed
878

879 880 881 882
              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
883 884 885
              compilations \
                  $build_dir oai_usrpdevif \
                  liboai_usrpdevif.so $dbin/liboai_usrpdevif.so.$REL
886

yilmazt's avatar
yilmazt committed
887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
              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"	 
          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
906

yilmazt's avatar
yilmazt committed
907 908 909
              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"	 
910
          elif [ "$HW" == "OAI_IRIS" ] ; then
yilmazt's avatar
yilmazt committed
911 912 913
              compilations \
                  $build_dir oai_irisdevif \
                  liboai_irisdevif.so $dbin/liboai_irisdevif.so.$REL
914 915 916 917

              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
918 919 920 921 922 923 924 925 926 927 928 929
          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"
930 931 932
          else
              echo_info "liboai_device.so is not linked to any device library"
          fi
933
      fi
934

yilmazt's avatar
yilmazt committed
935
      #build simulators devices
936
      if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then
937 938 939 940 941
          echo_info "Compiling rfsimulator"
          compilations \
              $build_dir rfsimulator \
              librfsimulator.so $dbin/librfsimulator.so.$REL

942
          echo_info "Compiling tcp_bridge_oai"
943 944 945
          compilations \
              $build_dir tcp_bridge_oai \
              libtcp_bridge_oai.so $dbin/libtcp_bridge_oai.so.$REL
946
      fi
947

yilmazt's avatar
yilmazt committed
948
      #build transport protocol libraries (currently only ETHERNET is available)
949
      if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then
950 951 952
          echo_info "Building transport protocol libraries"
          rm -f liboai_transpro.so
          rm -f $dbin/liboai_transpro.so
953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976
	  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
977
      fi
yilmazt's avatar
yilmazt committed
978
  fi
979

yilmazt's avatar
yilmazt committed
980 981 982 983
  ###################
  # Doxygen Support #
  ###################
  if [ "$BUILD_DOXYGEN" = "1" ] ; then
984
    doxygen_log=$OPENAIR_DIR/cmake_targets/log/doxygen.log
yilmazt's avatar
yilmazt committed
985 986 987
    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"
988 989 990 991
    (
    [ "$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
992
    eval $CMAKE_CMD
993 994
    make doc
    ) >& $doxygen_log
995 996
  fi

yilmazt's avatar
yilmazt committed
997 998 999 1000
  ##############
  # Auto-tests #
  ##############
  if [ "$OAI_TEST" = "1" ] ; then
thomasl's avatar
thomasl committed
1001
    echo_info "10. Running OAI pre commit tests (pre-ci) ..."
1002 1003 1004 1005
    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 "
1006 1007
    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
1008
    echo_info "You can hit CTRL-C at any time to terminate the autotests..."
1009 1010 1011
    echo "Current User Name: $USER"
    read -s -p "Enter Password: " mypassword
    echo -e "\n"
1012 1013
    rm -fr $OPENAIR_DIR/cmake_targets/autotests/log
    mkdir -p $OPENAIR_DIR/cmake_targets/autotests/log
1014
    if [ "$RUN_GROUP" -eq "1" ]; then
1015
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -g "$TEST_CASE_GROUP" -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
1016
    else
1017
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
1018
    fi
1019
    wait
Lionel Gauthier's avatar
Lionel Gauthier committed
1020
  else
thomasl's avatar
thomasl committed
1021
    echo_info "10. Bypassing the Tests ..."
1022
    echo_success "BUILD SHOULD BE SUCCESSFUL"
Lionel Gauthier's avatar
Lionel Gauthier committed
1023
  fi
1024

1025 1026 1027
}

main "$@"