80a53c6c1825fac21401bd36a85a6bfbbcd17ab4
[sim/e2-interface.git] / e2sim / previous / e2apv1sim / e2sim / build_e2sim
1 #!/bin/bash
2 #/*****************************************************************************
3 #                                                                            *
4 # Copyright 2019 AT&T Intellectual Property                                  *
5 # Copyright 2019 Nokia                                                       *
6 #                                                                            *
7 # Licensed under the Apache License, Version 2.0 (the "License");            *
8 # you may not use this file except in compliance with the License.           *
9 # You may obtain a copy of the License at                                    *
10 #                                                                            *
11 #      http://www.apache.org/licenses/LICENSE-2.0                            *
12 #                                                                            *
13 # Unless required by applicable law or agreed to in writing, software        *
14 # distributed under the License is distributed on an "AS IS" BASIS,          *
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
16 # See the License for the specific language governing permissions and        *
17 # limitations under the License.                                             *
18 #                                                                            *
19 #******************************************************************************/
20
21 set -e
22
23 E2SIM_VERSION='1.4.0'
24 export E2SIM_DIR=$PWD
25 source $E2SIM_DIR/tools/build_helper.bash
26 DOCKER_IMAGE='e2sim'
27
28 print_help() {
29   echo "
30     This program installs E2 Simulator
31     You should have ubuntu 14.xx, updated, and the Linux kernel >= 3.14
32     The program is run by default with no option
33
34     USAGE:
35       ./build_e2sim [OPTIONS]
36
37     OPTIONS:
38     --clean
39        Erase all files to make a rebuild from start
40     --docker
41        Build docker image
42     -h
43        Print this help
44     "
45 }
46
47 function main(){
48   case "$1" in
49     --clean)
50       echo_info "Will clean all previously producted files under build/"
51       rm -rf $E2SIM_DIR/build
52       echo_success "Clean Done"
53       exit
54       ;;
55
56     --docker)
57       echo "Will build docker image ${DOCKER_IMAGE}:${E2SIM_VERSION}"
58       sudo docker build -f docker/Dockerfile -t $DOCKER_IMAGE:$E2SIM_VERSION .
59       exit
60       ;;
61
62     "")
63       ;;
64
65     -h)
66       print_help
67       exit 1;;
68
69     *)
70       echo_error "Unknown option $1"
71       exit
72   esac
73
74   BUILD_DIR=$E2SIM_DIR/build
75   mkdir -p $BUILD_DIR
76
77   echo_info "Will build e2sim"
78   cd $BUILD_DIR
79   rm -rf CMakeCache.txt
80   cmake ..
81   make -j`nproc`
82
83   echo_success "e2sim compiled"
84 }
85
86 main "$@"