build_oai 21.2 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
30 31
THIS_SCRIPT_PATH=$(dirname $(readlink -f "$0"))
source "$THIS_SCRIPT_PATH"/tools/build_helper
thomasl's avatar
thomasl committed
32

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

yilmazt's avatar
yilmazt committed
36
# Variables for UE data generation
Robert Schmidt's avatar
Robert Schmidt committed
37
gen_nvram_path=$OPENAIR_DIR/cmake_targets/ran_build/build
38 39
conf_nvram_path=$OPENAIR_DIR/openair3/NAS/TOOLS/ue_eurecom_test_sfr.conf

Robert Schmidt's avatar
Robert Schmidt committed
40
HW=""
41
VERBOSE_COMPILE=0
42 43
RUN_GROUP=0
TEST_CASE_GROUP=""
44
BUILD_DIR=ran_build
45
BUILD_DOXYGEN=0
Rohit Gupta's avatar
Rohit Gupta committed
46
DISABLE_HARDWARE_DEPENDENCY="False"
47
CMAKE_BUILD_TYPE="RelWithDebInfo"
48
CMAKE_CMD="$CMAKE"
49
OPTIONAL_LIBRARIES="telnetsrv enbscope uescope nrscope nrqtscope ldpc_cuda ldpc_t2 websrv oai_iqplayer"
Robert Schmidt's avatar
Robert Schmidt committed
50
TARGET_LIST=""
51

52
function print_help() {
Cedric Roux's avatar
Cedric Roux committed
53
  echo_info "
Robert Schmidt's avatar
Robert Schmidt committed
54 55 56 57 58
This script compiles OpenAirInterface Software, and can install dependencies
for a number of distributions (Ubuntu 18-22, Fedora, RHEL7/8).
Options:
--arch-native
   Passes -march=native to the compiler.
59
-c | --clean
Cedric Roux's avatar
Cedric Roux committed
60
   Erase all files to make a rebuild from start
61
-C | --clean-all
Cedric Roux's avatar
Cedric Roux committed
62
   Erase all files made by previous compilations, installations
63 64
--clean-kernel
   Erase previously installed features in kernel: iptables, drivers, ...
65 66
--cmake-opt
   Pass the supplied option verbatim to cmake.
67 68
-d | --build-dir
   Sets build directory (will be <oai-root>/cmake_targets/<build-dir>/build)
69 70
--build-e2
   Enable the the E2 Agent
Lionel Gauthier's avatar
Lionel Gauthier committed
71
-I | --install-external-packages
72
   Installs required packages such as LibXML, asn1.1 compiler, ...
73 74 75
   This option will require root password
--install-optional-packages
   Install useful but not mandatory packages such as valgrind
76 77 78 79 80
-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
81
--eNB
Guy De Souza's avatar
Guy De Souza committed
82
  Makes the LTE softmodem
Robert Schmidt's avatar
Robert Schmidt committed
83
--gNB
Guy De Souza's avatar
Guy De Souza committed
84
  Makes the NR softmodem
85
--RU
86
  Makes the OAI RRU
87
--UE
88
   Makes the UE specific parts (ue_ip, usim, nvram) from the given configuration file
Robert Schmidt's avatar
Robert Schmidt committed
89 90
--nrUE
  Makes the NR UE softmodem
Cedric Roux's avatar
Cedric Roux committed
91 92 93 94
--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\")
95
-w | --hardware
96
   USRP, BLADERF, LMSSDR, IRIS, SIMU, AW2SORI, None (Default)
97
   Adds this RF board support (in external packages installation and in compilation)
Robert Schmidt's avatar
Robert Schmidt committed
98
-t | --transport
99
   Selects the transport protocol type, options: None, Ethernet, benetel4g, benetel5g, oran_fhlib_5g
100
-P | --phy_simulators
101
   Makes the unitary tests Layer 1 simulators
102
-S | --core_simulators
103 104 105
   Makes the core security features unitary simulators
-s | --check
   runs a set of auto-tests based on simulators and several compilation tests
106 107
--run-group 
   runs only specified test cases specified here. This flag is only valid with -s
108 109
-V | --vcd
   Adds a debgging facility to the binary files: GUI with major internal synchronization events
Robert Schmidt's avatar
Robert Schmidt committed
110 111
-x | --xforms
   Will compile with software oscilloscope features
112 113
--verbose-compile
   Shows detailed compilation instructions in makefile
114 115
--build-doxygen
   Builds doxygen based documentation.
116 117
--build-coverity-scan
   Builds Coverity-Scan objects for upload
118
--disable-deadline
119
   Disables deadline scheduler of Linux kernel (>=3.14.x).
120 121
--trace-asn1c-enc-dec
   Output asn1c logging traces via OAI logging system.
122
--enable-deadline
laurent's avatar
laurent committed
123
   Enable deadline scheduler of Linux kernel (>=3.14.x). 
124
--disable-cpu-affinity
125
   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
126
--enable-cpu-affinity
127 128
--disable-T-Tracer
   Disables the T tracer.
Rohit Gupta's avatar
Rohit Gupta committed
129 130
--disable-hardware-dependency
   Disable HW dependency during installation
131
--ue-autotest-trace
132
   Enable specific traces for UE autotest framework
gabrielC's avatar
gabrielC committed
133
--ue-trace
134
   Enable traces for UE debugging
gabrielC's avatar
gabrielC committed
135
--ue-timing
136 137 138
   Enable traces for timing
--uhd-images-dir
   Download UHD images in the indicated location
139
--build-eclipse
140
   Build eclipse project files.
141
--build-lib <libraries>
142
   Build optional shared library, <libraries> can be one or several of $OPTIONAL_LIBRARIES or \"all\"
143
--noavx512
144 145
   Disable AVX512 intrinsics whatever processor capability is
--noavx2
146
   Disable AVX2 intrinsics whatever processor capability is
147 148
-k | --skip-shared-libraries
   Skip build for shared libraries to reduce compilation time when building frequently for debugging purposes
Robert Schmidt's avatar
Robert Schmidt committed
149 150
--ninja
  Tell cmake to use the Ninja build system. Without, will generate make files
151 152
--sanitize
  Shortcut for usage of --sanitize-address --sanitize-undefined
Robert Schmidt's avatar
Robert Schmidt committed
153
--sanitize-address | -fsanitize=address
154 155 156
  Enable the address sanitizer on all targets
--sanitize-undefined | -fsanitize=undefined
  Enable the undefined behavior sanitizer on all targets
157 158 159 160
--sanitize-memory | -fsanitize=memory
  Enable the memory sanitizer on all targets. Requires clang, and is
  incompatible with ASan/UBSan. To build, issue:
  CC=/usr/bin/clang CXX=/usr/bin/clang++ ./build_oai ... --sanitize-memory
161 162
--sanitize-thread | -fsanitize=thread
  Enable the thread sanitizer on all targets
163
-h | --help
Robert Schmidt's avatar
Robert Schmidt committed
164
   Print this help"
165 166 167 168
}


function main() {
169

170 171
  until [ -z "$1" ]
  do
172
    case "$1" in
173
       --arch-native)
174
            echo_fatal "Error: specify --arch-native on the command line to cmake directly: ./build_oai --cmake-opt \"-DCMAKE_C_FLAGS=-march=native -DCMAKE_CXX_FLAGS=-march=native\""
175
            shift;;
176 177 178 179 180
       -c | --clean)
            CLEAN=1
            shift;;
       -C | --clean-all)
            CLEAN_ALL=1
thomasl's avatar
thomasl committed
181
            shift;;
182 183 184
       --clean-kernel)
            clean_kernel
            echo_info "Erased iptables config and removed modules from kernel"
thomasl's avatar
thomasl committed
185
            shift;;
186 187 188
       --cmake-opt)
            CMAKE_CMD="$CMAKE_CMD $2"
            shift 2;;
189 190
       -d | --build-dir)
            BUILD_DIR=$2
191
            shift 2;;
192 193 194 195
       --build-e2 )
             CMAKE_CMD="$CMAKE_CMD -DE2_AGENT=ON"
             shift
             ;;
196
       -I | --install-external-packages)
197
            INSTALL_EXTERNAL=1
198
            echo_info "Will install external packages"
thomasl's avatar
thomasl committed
199
            shift;;
200
       --install-optional-packages)
thomasl's avatar
thomasl committed
201 202 203
            INSTALL_OPTIONAL=1
            echo_info "Will install optional packages"
            shift;;
204
       -g | --run-with-gdb)
205 206 207 208 209 210 211 212 213 214
            case "$2" in
                "Release")
                    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")
                    CMAKE_BUILD_TYPE="RelWithDebInfo"
                    echo_info "Will Compile with gdb symbols"
215
                    CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_EXPORT_COMPILE_COMMANDS=1"
216 217 218 219 220
                    shift
                    ;;
                "MinSizeRel")
                    CMAKE_BUILD_TYPE="MinSizeRel"
                    echo_info "Will Compile for minimal exec size"
221
                    CMAKE_CMD="$CMAKE_CMD -DCMAKE_BUILD_TYPE=MinSizeRel"
222
                    shift
223
                    ;;
224 225 226 227 228
                "Debug" | *)
                    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
229
                        shift
230 231 232
                    fi
                    ;;
            esac
thomasl's avatar
thomasl committed
233
            shift;;
234
       -G | --cmaketrace)
235
            CMAKE_CMD="$CMAKE_CMD --trace-expand"
thomasl's avatar
thomasl committed
236
            shift;;
237 238
       --eNB)
            eNB=1
Robert Schmidt's avatar
Robert Schmidt committed
239
            TARGET_LIST="$TARGET_LIST lte-softmodem"
240 241
            echo_info "Will compile eNB"
            shift;;
hardy's avatar
hardy committed
242
      --gNB)
Guy De Souza's avatar
Guy De Souza committed
243
            gNB=1
Robert Schmidt's avatar
Robert Schmidt committed
244
            TARGET_LIST="$TARGET_LIST nr-softmodem nr-cuup"
Guy De Souza's avatar
Guy De Souza committed
245 246
            echo_info "Will compile gNB"
            shift;;
247
       --RU)
248
            RU=1
Robert Schmidt's avatar
Robert Schmidt committed
249
            TARGET_LIST="$TARGET_LIST oairu"
250
            echo_info "Will compile RRU"
251
            shift;;
252 253
       --UE)
            UE=1
Robert Schmidt's avatar
Robert Schmidt committed
254
            TARGET_LIST="$TARGET_LIST lte-uesoftmodem"
255 256
            echo_info "Will compile UE"
            shift;;
Guy De Souza's avatar
Guy De Souza committed
257 258
       --nrUE)
            nrUE=1
Robert Schmidt's avatar
Robert Schmidt committed
259
            TARGET_LIST="$TARGET_LIST nr-uesoftmodem"
Guy De Souza's avatar
Guy De Souza committed
260 261
            echo_info "Will compile NR UE"
            shift;;
Xu Bo's avatar
Xu Bo committed
262
       --mu)
263
            CMAKE_CMD="$CMAKE_CMD -DUE_EXPANSION=True -DPRE_SCD_THREAD=True"
Xu Bo's avatar
Xu Bo committed
264 265
            echo_info "Will compile with UE_EXPANSION"
            shift;;
Cedric Roux's avatar
Cedric Roux committed
266
       --UE-conf-nvram)
267
            conf_nvram_path=$(readlink -f "$2")
Cedric Roux's avatar
Cedric Roux committed
268
            shift 2;;
269
       --UE-gen-nvram)
270
            gen_nvram_path=$(readlink -f "$2")
271
            shift 2;;
272
       --UE-ip)
Robert Schmidt's avatar
Robert Schmidt committed
273
            TARGET_LIST="$TARGET_LIST ue_ip"
274
            shift;;
thomasl's avatar
thomasl committed
275
       -w | --hardware)
276
            case "$2" in
277
                "USRP" | "BLADERF" | "LMSSDR" | "IRIS")
278
                    HW="OAI_"$2
Robert Schmidt's avatar
Robert Schmidt committed
279 280
                    TARGET_LIST="$TARGET_LIST oai_${2,,}devif" # ,, makes lowercase
                    CMAKE_CMD="$CMAKE_CMD -DOAI_$2=ON"
281 282 283 284 285
                    ;;
                "SIMU")
                    HW="OAI_"$2
                    TARGET_LIST="$TARGET_LIST rfsimulator"
                    CMAKE_CMD="$CMAKE_CMD -DOAI_$2=ON"
Robert Schmidt's avatar
Robert Schmidt committed
286 287
                    ;;
                "AW2SORI")
288
                    HW="OAI_"$2
Robert Schmidt's avatar
Robert Schmidt committed
289
                    TARGET_LIST="$TARGET_LIST aw2sori_transpro"
290
                    CMAKE_CMD="$CMAKE_CMD -DOAI_$2=ON"
291 292 293 294
                    ;;
                "None")
                    ;;
                *)
Robert Schmidt's avatar
Robert Schmidt committed
295 296
                    echo_fatal "Unknown hardware type $2: exit..."
                    ;;
297
            esac
thomasl's avatar
thomasl committed
298
            shift 2;;
299
       -t | --transport)
300
            case "$2" in
Robert Schmidt's avatar
Robert Schmidt committed
301 302 303 304
              "Ethernet")
                TARGET_LIST="$TARGET_LIST oai_eth_transpro"
                CMAKE_CMD="$CMAKE_CMD -DOAI_${2^^}=ON" # ^^ makes uppercase
                ;;
305
              "benetel4g" | "benetel5g" | "oran_fhlib_4g")
Robert Schmidt's avatar
Robert Schmidt committed
306
                TARGET_LIST="$TARGET_LIST $2"
307 308
                CMAKE_CMD="$CMAKE_CMD -DOAI_${2^^}=ON" # ^^ makes uppercase
                ;;
309 310 311 312
              "oran_fhlib_5g")
                TARGET_LIST="$TARGET_LIST $2"
                CMAKE_CMD="$CMAKE_CMD -DOAI_FHI72=ON"
                ;;
313 314 315
              "None")
                ;;
              *)
Robert Schmidt's avatar
Robert Schmidt committed
316 317
                echo_fatal "Unknown transport type $2; exit..."
                ;;
318
            esac
319
            shift 2;;
320
       -P | --phy_simulators)
thomasl's avatar
thomasl committed
321
            SIMUS_PHY=1
Robert Schmidt's avatar
Robert Schmidt committed
322 323
            # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim
            TARGET_LIST="$TARGET_LIST dlsim ulsim ldpctest polartest smallblocktest nr_pbchsim nr_dlschsim nr_ulschsim nr_dlsim nr_ulsim nr_pucchsim nr_prachsim"
324 325
            echo_info "Will compile dlsim, ulsim, ..."
            shift;;
thomasl's avatar
thomasl committed
326 327
       -s | --check)
            OAI_TEST=1
328
            echo_info "Will run auto-tests"
thomasl's avatar
thomasl committed
329
            shift;;
330 331 332 333 334
       --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
335
       -V | --vcd)
336
            echo_info "Setting gtk-wave output"
337
            CMAKE_CMD="$CMAKE_CMD -DENABLE_VCD_FIFO=True"
thomasl's avatar
thomasl committed
338
            shift;;
thomasl's avatar
thomasl committed
339
       -x | --xforms)
340
            echo_info "Will generate the software oscilloscope features"
thomasl's avatar
thomasl committed
341
            shift;;
342
       --verbose-compile)
343
            VERBOSE_COMPILE=1
344 345
            echo_info "Will compile with verbose instructions"
            shift;;
346
       --build-doxygen)
Laurent THOMAS's avatar
Laurent THOMAS committed
347 348 349 350 351
           CMAKE_CMD="$CMAKE_CMD -DGENERATE_DOXYGEN=ON"
	   TARGET_LIST="$TARGET_LIST doc"
           BUILD_DOXYGEN=1
           echo_info "Will build doxygen support"
           shift;;     
352
       --disable-T-Tracer)
353
            CMAKE_CMD="$CMAKE_CMD -DT_TRACER=False"
354
            echo_info "Disabling the T tracer"
355
            shift 1;;
356 357 358 359
       --disable-hardware-dependency)
            echo_info "Disabling hardware dependency for compiling software"
            DISABLE_HARDWARE_DEPENDENCY="True"
            shift 1;;
360
       --ue-autotest-trace)
361
            CMAKE_CMD="$CMAKE_CMD -DUE_AUTOTEST_TRACE=True"
362 363
            echo_info "Enabling autotest specific trace for UE"
            shift 1;;
364
       --ue-trace)
365
            CMAKE_CMD="$CMAKE_CMD -DUE_DEBUG_TRACE=False"
gabrielC's avatar
gabrielC committed
366 367
            echo_info "Enabling UE trace for debug"
            shift 1;;
368
       --ue-timing)
369
            CMAKE_CMD="$CMAKE_CMD -DUE_TIMING_TRACE=True"
gabrielC's avatar
gabrielC committed
370 371
            echo_info "Enabling UE timing trace"
            shift 1;;
372
       --uhd-images-dir)
373 374 375
            UHD_IMAGES_DIR=$2
            echo_info "Downloading UHD images in the indicated location"
            shift 2;;
376 377 378
       --build-eclipse)
            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
379
            shift 1;;
380
       --build-lib) 
381
            if [  "$2" == "all" ] ; then
Robert Schmidt's avatar
Robert Schmidt committed
382 383
              TARGET_LIST="$TARGET_LIST $OPTIONAL_LIBRARIES"
              for lib in $OPTIONAL_LIBRARIES; do CMAKE_CMD="$CMAKE_CMD -DENABLE_${lib^^}=ON"; done
384 385
              echo_info "Enabling build of all optional shared libraries ($OPTIONAL_LIBRARIES)" 
            else
Robert Schmidt's avatar
Robert Schmidt committed
386 387 388 389 390 391
              for reqlib in $2; do
                lib=$(echo $OPTIONAL_LIBRARIES | tr ' ' '\n' | grep -w $reqlib) # search given parameter in list
                [[ $? -ne 0 ]] && echo_fatal "Unknown optional library in $reqlib, valid libraries are $OPTIONAL_LIBRARIES"
                TARGET_LIST="$TARGET_LIST $lib" # will append the found library
                CMAKE_CMD="$CMAKE_CMD -DENABLE_${lib^^}=ON"
                echo_info "Enabling build of optional shared library $lib"
392
              done
393
            fi
394
            shift 2;;
395
        --noavx512)
396
            CMAKE_CMD="$CMAKE_CMD -DAVX512=OFF"
397 398 399
            echo_info "Disabling AVX512 instructions"
            shift 1;;
        --noavx2)
400
            CMAKE_CMD="$CMAKE_CMD -DAVX2=OFF"
401
            echo_info "Disabling AVX2 instructions"
402
            shift 1;;
403 404 405
        --ninja)
            CMAKE_CMD="$CMAKE_CMD -GNinja"
            shift;;
406 407 408
        --sanitize)
            CMAKE_CMD="$CMAKE_CMD -DSANITIZE_ADDRESS=True -DSANITIZE_UNDEFINED=True"
            shift;;
409
        --sanitize-address | -fsanitize=address)
410
            grep -sq "Ubuntu 18.04" /etc/os-release && echo_error "Bug in OS with this option, see CMakeLists.txt"
411 412
            CMAKE_CMD="$CMAKE_CMD -DSANITIZE_ADDRESS=True"
            shift;;
413 414 415
        --sanitize-undefined | -fundefined=address)
            CMAKE_CMD="$CMAKE_CMD -DSANITIZE_UNDEFINED=True"
            shift;;
416 417
        --sanitize-memory | -fsanitize=memory)
            echo_warning "Note: memory sanitizer\n* requires clang (tested: v17)\n* is incompatible with address/undefined behavior sanitizer\n* requires cmake_targets/tools/memsan.patch"
Robert Schmidt's avatar
Robert Schmidt committed
418
            sleep 2
419 420
            CMAKE_CMD="$CMAKE_CMD -DSANITIZE_MEMORY=ON -DSANITIZE_ADDRESS=OFF -DSANITIZE_UNDEFINED=OFF"
            shift;;
421 422 423 424
       --trace-asn1c-enc-dec)
            CMAKE_CMD="$CMAKE_CMD -DTRACE_ASN1C_ENC_DEC=ON"
            echo_info "Enabling asn1c internal traces via OAI logging system"
            shift 1;;
425 426 427
        --sanitize-thread | -fthread=address)
            CMAKE_CMD="$CMAKE_CMD -DSANITIZE_THREAD=True"
            shift;;
thomasl's avatar
thomasl committed
428 429 430
        -h | --help)
            print_help
            exit 1;;
431 432
        *)
            print_help
433
            echo_fatal "Unknown option $1"
thomasl's avatar
thomasl committed
434
            break;;
thomasl's avatar
thomasl committed
435
   esac
436
  done
437

yilmazt's avatar
yilmazt committed
438 439 440
  #######################################################
  # Setting and printing OAI envs, we should check here #
  #######################################################
Lionel Gauthier's avatar
Lionel Gauthier committed
441

442
  echo "OPENAIR_DIR    = $OPENAIR_DIR"
thomasl's avatar
thomasl committed
443

444 445
  if [ "$CLEAN_ALL" = "1" ] ; then
    clean_all_files
446
    echo "Erased all previously producted files"
447
  fi
448

449
  dlog=$OPENAIR_DIR/cmake_targets/log
Robert Schmidt's avatar
Robert Schmidt committed
450
  mkdir -p $dlog
451 452 453 454

  if [ "$INSTALL_EXTERNAL" = "1" ] ; then
    echo_info "Installing packages"
    check_install_oai_software
455 456 457
    if [ "$HW" == "OAI_USRP" ] ; then
      echo_info "installing packages for USRP support"
      check_install_usrp_uhd_driver
458
      if [ ! -v BUILD_UHD_FROM_SOURCE ] && [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
459
        install_usrp_uhd_driver $UHD_IMAGES_DIR
460
      fi
461
    fi
462
    if [ "$HW" == "OAI_BLADERF" ] ; then
463
      echo_info "installing packages for BLADERF support"
464
      check_install_bladerf_driver
465 466 467
      if [ ! "$DISABLE_HARDWARE_DEPENDENCY" == "True" ]; then
        flash_firmware_bladerf
      fi
468
    fi
469 470 471 472 473 474
    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
475
    fi
476 477 478 479 480 481 482
  fi

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

483 484 485
  DIR=$OPENAIR_DIR/cmake_targets

  [ "$CLEAN" = "1" ] && rm -rf $DIR/$BUILD_DIR/build
486

Robert Schmidt's avatar
Robert Schmidt committed
487 488 489 490 491
  if [[ $TARGET_LIST != "" ]]; then
    # add some default libraries that should always be built
    # for eNB, gNB, UEs, simulators
    if [[ $gNB == 1 || $eNB == 1 || $UE == 1 || $nrUE == 1 || $SIMUS_PHY == 1 || $RU == 1 ]]; then
      TARGET_LIST="$TARGET_LIST params_libconfig coding rfsimulator dfts"
492
    fi
493

Robert Schmidt's avatar
Robert Schmidt committed
494 495
    mkdir -p $DIR/$BUILD_DIR/build
    cd $DIR/$BUILD_DIR/build
yilmazt's avatar
yilmazt committed
496

Robert Schmidt's avatar
Robert Schmidt committed
497 498 499 500 501 502
    # for historical reasons we build in a subdirectory cmake_targets/XYZ/build,
    # e.g., cmake_targets/ran_build/build, hence the ../../..
    CMAKE_CMD="$CMAKE_CMD ../../.."
    echo_info "Running \"$CMAKE_CMD\""
    eval $CMAKE_CMD
    compilations $BUILD_DIR all.txt $TARGET_LIST
Laurent THOMAS's avatar
Laurent THOMAS committed
503 504 505 506 507 508
    ###################
    # Doxygen Support #
    ###################
    if [ "$BUILD_DOXYGEN" = "1" ] ; then
	echo_info "Built Doxygen based documentation. The documentation file is located here: $OPENAIR_DIR/$BUILD_DIR/build/html/index.html"
    fi
509

510 511 512 513 514 515
    # TODO: once we got the CMakeLists.txt file done for the ORAN files, remove the following lines
    if [[ $TARGET_LIST =~ "oran_fhlib_5g" ]]; then
      rm -f liboai_transpro.so
      ln -s liboran_fhlib_5g.so liboai_transpro.so
    fi

Robert Schmidt's avatar
Robert Schmidt committed
516
    if [ "$UE" = 1 ] ; then
yilmazt's avatar
yilmazt committed
517

Robert Schmidt's avatar
Robert Schmidt committed
518
      echo_info "Compiling UE specific part"
519

Robert Schmidt's avatar
Robert Schmidt committed
520 521 522
      [ "$CLEAN" = "1" ] && rm -rf $DIR/nas_sim_tools/build
      mkdir -p $DIR/nas_sim_tools/build
      cd $DIR/nas_sim_tools/build
523

Robert Schmidt's avatar
Robert Schmidt committed
524 525 526 527
      eval $CMAKE_CMD ..
      compilations nas_sim_tools usim.txt usim
      compilations nas_sim_tools nvram.txt nvram
      compilations nas_sim_tools conf2uedata.txt conf2uedata
528

Robert Schmidt's avatar
Robert Schmidt committed
529 530 531 532 533
      # generate USIM data
      if [ -f conf2uedata ]; then
        install_nas_tools $conf_nvram_path $DIR/$BUILD_DIR/build "$DIR/$BUILD_DIR/build/conf2uedata.txt"
      else
        echo_warning "not generated UE NAS files: binaries not found"
534
      fi
535
    fi
yilmazt's avatar
yilmazt committed
536
  fi
537 538


yilmazt's avatar
yilmazt committed
539 540 541 542
  ##############
  # Auto-tests #
  ##############
  if [ "$OAI_TEST" = "1" ] ; then
543 544 545 546
    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 "
547 548
    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
549
    echo_info "You can hit CTRL-C at any time to terminate the autotests..."
550 551 552
    echo "Current User Name: $USER"
    read -s -p "Enter Password: " mypassword
    echo -e "\n"
553 554
    rm -fr $OPENAIR_DIR/cmake_targets/autotests/log
    mkdir -p $OPENAIR_DIR/cmake_targets/autotests/log
555
    if [ "$RUN_GROUP" -eq "1" ]; then
556
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -g "$TEST_CASE_GROUP" -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
557
    else
558
        $OPENAIR_DIR/cmake_targets/autotests/run_exec_autotests.bash -p $mypassword >& $OPENAIR_DIR/cmake_targets/autotests/log/autotests.log &
559
    fi
560
    wait
Lionel Gauthier's avatar
Lionel Gauthier committed
561
  else
562
    echo_success "BUILD SHOULD BE SUCCESSFUL"
Lionel Gauthier's avatar
Lionel Gauthier committed
563
  fi
564

565 566 567
}

main "$@"