build_oai 36.3 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="None"
Lionel Gauthier's avatar
Lionel Gauthier committed
52
EPC=0
53
VERBOSE_COMPILE=0
54
CFLAGS_PROCESSOR_USER=""
55 56
RUN_GROUP=0
TEST_CASE_GROUP=""
57
BUILD_DOXYGEN=0
58
BUILD_COVERITY_SCAN=0
59
T_TRACER="True"
Rohit Gupta's avatar
Rohit Gupta committed
60
DISABLE_HARDWARE_DEPENDENCY="False"
61
CMAKE_BUILD_TYPE=""
62
CMAKE_CMD="$CMAKE"
63
UE_AUTOTEST_TRACE="False"
gabrielC's avatar
gabrielC committed
64 65
UE_DEBUG_TRACE="False"
UE_TIMING_TRACE="False"
66
USRP_REC_PLAY="False"
67
BUILD_ECLIPSE=0
Guy De Souza's avatar
Guy De Souza committed
68
NR="False"
heshanyun's avatar
heshanyun committed
69
ITTI_SIM="False"
70
RFSIM_NAS="False"
71
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope msc"
72 73
trap handle_ctrl_c INT

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

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


function main() {
178

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

yilmazt's avatar
yilmazt committed
437 438 439
  ###################################
  # Check if cov-build is installed #
  ###################################
440 441 442 443 444 445 446 447 448 449
  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

450 451
  CMAKE_CMD="$CMAKE_CMD .."
  echo_info "CMAKE_CMD=$CMAKE_CMD"
Guy De Souza's avatar
Guy De Souza committed
452

yilmazt's avatar
yilmazt committed
453 454 455
  ########################################################
  # Check validity of HW and TP parameters for eNB / gNB #
  ########################################################
Aikaterini's avatar
Aikaterini committed
456
  # to be discussed
457
  
hardy's avatar
hardy committed
458
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$gNB" = "1" ] ; then
459
      if [ "$HW" = "None" -a  "$TP" = "None" ] ; then
yilmazt's avatar
yilmazt committed
460
	      echo_info "No local radio head and no transport protocol selected"
461
      fi
462
      if [ "$HW" = "None" ] ; then 
yilmazt's avatar
yilmazt committed
463
	      echo_info "No radio head has been selected (HW set to $HW)"	
464
      fi
465
      if [ "$TP" = "None" ] ; then
yilmazt's avatar
yilmazt committed
466
	      echo_info "No transport protocol has been selected (TP set to $TP)"	
467 468 469
      fi
  fi
  
root's avatar
root committed
470 471
  if [ "$HWLAT" = "1" ] ; then
      if [ "$HW" = "None" ] ; then
yilmazt's avatar
yilmazt committed
472
          echo_info "No radio head has been selected (HW set to $HW)" 
root's avatar
root committed
473 474 475
      fi
  fi

476
  echo_info "RF HW set to $HW" 
477 478
  # 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
479
      case "$HW" in
480
          "EXMIMO")
yilmazt's avatar
yilmazt committed
481 482
		      DEADLINE_SCHEDULER_FLAG_USER="True"
		      ;;
483
          *)
yilmazt's avatar
yilmazt committed
484 485 486
		      DEADLINE_SCHEDULER_FLAG_USER="False"
		      ;;
      esac
487 488
  fi

489
  #Disable CPU Affinity for deadline scheduler
laurent's avatar
laurent committed
490
  if [ "$DEADLINE_SCHEDULER_FLAG_USER" = "True" ] ; then 
491 492
     CPU_AFFINITY_FLAG_USER="False"
  fi
493

laurent's avatar
laurent committed
494
  echo_info "Flags for Deadline scheduler: $DEADLINE_SCHEDULER_FLAG_USER"
495
  echo_info "Flags for CPU Affinity: $CPU_AFFINITY_FLAG_USER"
Aikaterini's avatar
Aikaterini committed
496

yilmazt's avatar
yilmazt committed
497 498 499
  #######################################################
  # Setting and printing OAI envs, we should check here #
  #######################################################
Lionel Gauthier's avatar
Lionel Gauthier committed
500

501
  echo_info "2. Setting the OAI PATHS ..."
thomasl's avatar
thomasl committed
502

503
  cecho "OPENAIR_DIR    = $OPENAIR_DIR" $green
thomasl's avatar
thomasl committed
504

505 506 507 508 509 510 511 512 513 514
  # 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
515

516 517 518 519
  if [ "$CLEAN_ALL" = "1" ] ; then
    clean_all_files
    echo_info "Erased all previously producted files"
  fi
520

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

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

564 565
  
  
566 567 568
  echo_info "3. building the compilation directives ..."

  DIR=$OPENAIR_DIR/cmake_targets
569 570
  if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
    build_dir=phy_simulators
571
  else
572
    if [ "$T_TRACER" =  "False" ] ; then
573
      build_dir=ran_build_noLOG
574
    else
yilmazt's avatar
yilmazt committed
575
      build_dir=ran_build  
576
    fi
577
  fi
578 579
  [ "$CLEAN" = "1" ] && rm -rf $DIR/$build_dir/build
  mkdir -p $DIR/$build_dir/build
580

581 582 583
# configuration module libraries, one currently available, using libconfig 
  config_libconfig_shlib=params_libconfig
  
584
  # first generate the CMakefile in the right directory
585
  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
586

Guy De Souza's avatar
Guy De Souza committed
587
    # softmodem compilation
588

Guy De Souza's avatar
Guy De Souza committed
589
    cmake_file=$DIR/$build_dir/CMakeLists.txt
yilmazt's avatar
yilmazt committed
590
    echo "cmake_minimum_required(VERSION 2.8)"                             >  $cmake_file
Laurent's avatar
Laurent committed
591
    echo "project (OpenAirInterface)"                                    >> $cmake_file
592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607
    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
608
    echo "set ( SKIP_SHARED_LIB_FLAG $SKIP_SHARED_LIB_FLAG )"             >> $cmake_file
heshanyun's avatar
heshanyun committed
609
    echo "set ( ITTI_SIM $ITTI_SIM )"                                     >> $cmake_file
610
    echo "set ( RFSIM_NAS $RFSIM_NAS )"                                   >> $cmake_file
611
    echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)'         >> $cmake_file
Guy De Souza's avatar
Guy De Souza committed
612
    cd  $DIR/$build_dir/build
613
    eval $CMAKE_CMD
614

615 616 617 618
    execlist=""
    if [ "$eNB" = "1" ] ; then
      execlist="$execlist lte-softmodem"
    fi
hardy's avatar
hardy committed
619 620 621
    if [ "$eNBocp" = "1" ] ; then
      execlist="$execlist ocp-enb"
    fi
622 623 624 625 626 627 628 629 630
    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
631

heshanyun's avatar
heshanyun committed
632 633 634 635
    if [ "$ittiSIM" = "1" ] ; then
      execlist="$execlist nr-ittisim"
    fi

636 637
    for f in $execlist ; do
      echo_info "Compiling $f..."
638
      compilations \
639 640 641
        $build_dir $f \
        $f $dbin/$f.$REL
    done
642

643

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

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

649 650 651
      compilations \
        $build_dir $config_libconfig_shlib \
        lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
652

653 654 655
      compilations \
        $build_dir coding \
        libcoding.so $dbin/libcoding.so
yilmazt's avatar
yilmazt committed
656

657

658 659 660 661 662 663 664 665 666 667 668 669 670
      #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

671 672
        cp $OPENAIR_DIR/cmake_targets/tools/init_nas_nos1 $dbin
      fi #IS_CONTAINER
673
    fi
yilmazt's avatar
yilmazt committed
674

675
  fi
676

yilmazt's avatar
yilmazt committed
677
  if [ "$UE" = 1 ] ; then
678

679
    echo_info "Compiling UE specific part"
680 681 682 683 684 685 686 687 688 689

    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
690

Lionel Gauthier's avatar
Lionel Gauthier committed
691 692
#    mkdir -p $DIR/at_commands/build
#    cd $DIR/at_commands/build
693
#    eval $CMAKE_CMD
Lionel Gauthier's avatar
Lionel Gauthier committed
694 695 696
#    compilations \
#      at_commands at_nas_ue \
#      at_nas_ue $dbin/at_nas_ue
697

Lionel Gauthier's avatar
Lionel Gauthier committed
698
    [ "$CLEAN" = "1" ] && rm -rf $DIR/nas_sim_tools/build
699 700
    mkdir -p $DIR/nas_sim_tools/build
    cd $DIR/nas_sim_tools/build
701

702
    eval $CMAKE_CMD
thomasl's avatar
thomasl committed
703
    compilations \
704 705
      nas_sim_tools usim \
      usim $dbin/usim
thomasl's avatar
thomasl committed
706
    compilations \
707 708
      nas_sim_tools nvram \
      nvram $dbin/nvram
thomasl's avatar
thomasl committed
709
    compilations \
710 711
      nas_sim_tools conf2uedata \
      conf2uedata $dbin/conf2uedata
712 713

    # generate USIM data
714 715
    if [ -f $dbin/conf2uedata ]; then
      install_nas_tools $conf_nvram_path $gen_nvram_path
Guy De Souza's avatar
Guy De Souza committed
716 717 718 719
      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
720 721 722
    else
      echo_warning "not generated UE NAS files: binaries not found"
    fi
723
  fi
thomasl's avatar
thomasl committed
724

725
  if [ "$SIMUS_PHY" = "1" -o "$SIMUS_CORE" = "1" ] ; then
726
    cd  $DIR/$build_dir/build
727
    eval $CMAKE_CMD
728
  fi
729

yilmazt's avatar
yilmazt committed
730 731 732
  ##################
  # PHY simulators #
  ##################
733
  if [ "$SIMUS_PHY" = "1" ] ; then
yilmazt's avatar
yilmazt committed
734
    echo_info "Compiling physical unitary tests simulators"
735
    # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
736
    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
737
	# simlist="ldpctest"
738 739
    for f in $simlist ; do
      compilations \
yilmazt's avatar
yilmazt committed
740 741
        phy_simulators $f \
	    $f $dbin/$f.$REL
742
    done
743
    compilations \
yilmazt's avatar
yilmazt committed
744 745
      phy_simulators coding \
      libcoding.so $dbin/libcoding.so
746
#    compilations \
yilmazt's avatar
yilmazt committed
747 748
#	   lte-simulators $config_libconfig_shlib \
#	   lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so
749
  fi
thomasl's avatar
thomasl committed
750

yilmazt's avatar
yilmazt committed
751 752 753
  ###################
  # Core simulators #
  ###################
754
  if [ "$SIMUS_CORE" = "1" ] ; then
yilmazt's avatar
yilmazt committed
755
    echo_info "Compiling security unitary tests simulators"
756 757 758
    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
759 760
	    phy_simulators test_$f \
	    test_$f $dbin/test_$f.$REL
761 762
    done
  fi
thomasl's avatar
thomasl committed
763

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

797
  #####################
yilmazt's avatar
yilmazt committed
798
  # HWLAT compilation #
root's avatar
root committed
799 800 801
  #####################
  if [ "$HWLAT" = "1" ] ; then

yilmazt's avatar
yilmazt committed
802 803
      hwlat_exec=lte-hwlat
      hwlat_build_dir=lte-hwlat
root's avatar
root committed
804
     
yilmazt's avatar
yilmazt committed
805
      echo_info "Compiling $hwlat_exec ..."
root's avatar
root committed
806
    
yilmazt's avatar
yilmazt committed
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822
      [ "$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
823 824
  fi  
 
yilmazt's avatar
yilmazt committed
825 826 827
  ##########################
  # HWLAT_TEST compilation #
  ##########################
root's avatar
root committed
828 829
  if [ "$HWLAT_TEST" = "1" ] ; then

yilmazt's avatar
yilmazt committed
830 831
      hwlat_test_exec=lte-hwlat-test
      hwlat_test_build_dir=lte-hwlat-test
root's avatar
root committed
832
     
yilmazt's avatar
yilmazt committed
833
      echo_info "Compiling $hwlat_test_exec ..."
root's avatar
root committed
834
    
yilmazt's avatar
yilmazt committed
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850
      [ "$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
851
  fi
yilmazt's avatar
yilmazt committed
852 853 854 855
  
  ####################################################
  # Build RF device and transport protocol libraries #
  ####################################################
Raphael Defosseux's avatar
Raphael Defosseux committed
856
  if [ "$eNB" = "1" -o "$eNBocp" = "1" -o "$UE" = "1" -o "$gNB" = "1" -o "$nrUE" = "1" -o "$HWLAT" = "1" ] ; then
857

858
      # build RF device libraries
859
      if [ "$HW" != "None" ] ; then
yilmazt's avatar
yilmazt committed
860 861 862 863 864
          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
865
              compilations \
yilmazt's avatar
yilmazt committed
866
                  $build_dir oai_exmimodevif \
867
                  liboai_exmimodevif.so $dbin/liboai_exmimodevif.so.$REL
yilmazt's avatar
yilmazt committed
868

869 870 871 872
              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
873 874 875
              compilations \
                  $build_dir oai_usrpdevif \
                  liboai_usrpdevif.so $dbin/liboai_usrpdevif.so.$REL
876

yilmazt's avatar
yilmazt committed
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895
              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
896

yilmazt's avatar
yilmazt committed
897 898 899
              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"	 
900
          elif [ "$HW" == "OAI_IRIS" ] ; then
yilmazt's avatar
yilmazt committed
901 902 903
              compilations \
                  $build_dir oai_irisdevif \
                  liboai_irisdevif.so $dbin/liboai_irisdevif.so.$REL
904 905 906 907

              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
908 909 910 911 912 913 914 915 916 917 918 919
          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"
920 921 922
          else
              echo_info "liboai_device.so is not linked to any device library"
          fi
923
      fi
924

yilmazt's avatar
yilmazt committed
925
      #build simulators devices
926
      if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then
927 928 929 930 931
          echo_info "Compiling rfsimulator"
          compilations \
              $build_dir rfsimulator \
              librfsimulator.so $dbin/librfsimulator.so.$REL

932
          echo_info "Compiling tcp_bridge_oai"
933 934 935
          compilations \
              $build_dir tcp_bridge_oai \
              libtcp_bridge_oai.so $dbin/libtcp_bridge_oai.so.$REL
936
      fi
937

yilmazt's avatar
yilmazt committed
938
      #build transport protocol libraries (currently only ETHERNET is available)
939
      if [ "$SKIP_SHARED_LIB_FLAG" = "False" ]; then
940 941 942 943 944 945 946 947 948
          echo_info "Building transport protocol libraries"
          rm -f liboai_transpro.so
          rm -f $dbin/liboai_transpro.so
          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"
949
      fi
yilmazt's avatar
yilmazt committed
950
  fi
951

yilmazt's avatar
yilmazt committed
952 953 954 955
  ###################
  # Doxygen Support #
  ###################
  if [ "$BUILD_DOXYGEN" = "1" ] ; then
956
    doxygen_log=$OPENAIR_DIR/cmake_targets/log/doxygen.log
yilmazt's avatar
yilmazt committed
957 958 959
    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"
960 961 962 963
    (
    [ "$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
964
    eval $CMAKE_CMD
965 966
    make doc
    ) >& $doxygen_log
967 968
  fi

yilmazt's avatar
yilmazt committed
969 970 971 972
  ##############
  # Auto-tests #
  ##############
  if [ "$OAI_TEST" = "1" ] ; then
thomasl's avatar
thomasl committed
973
    echo_info "10. Running OAI pre commit tests (pre-ci) ..."
974 975 976 977
    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 "
978 979
    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
980
    echo_info "You can hit CTRL-C at any time to terminate the autotests..."
981 982 983
    echo "Current User Name: $USER"
    read -s -p "Enter Password: " mypassword
    echo -e "\n"
984 985
    rm -fr $OPENAIR_DIR/cmake_targets/autotests/log
    mkdir -p $OPENAIR_DIR/cmake_targets/autotests/log
986
    if [ "$RUN_GROUP" -eq "1" ]; then
987
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -g "$TEST_CASE_GROUP" -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
988
    else
989
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
990
    fi
991
    wait
Lionel Gauthier's avatar
Lionel Gauthier committed
992
  else
thomasl's avatar
thomasl committed
993
    echo_info "10. Bypassing the Tests ..."
994
    echo_success "BUILD SHOULD BE SUCCESSFUL"
Lionel Gauthier's avatar
Lionel Gauthier committed
995
  fi
996

997 998 999
}

main "$@"