Merge "[JIRA ID - ODUHIGH-280] Changes in DU_CFG as per the TDD"
[o-du/l2.git] / build / o1 / makefile
1 ################################################################################
2 #   Copyright (c) [2017-2019] [Radisys]                                        #
3 #                                                                              #
4 #   Licensed under the Apache License, Version 2.0 (the "License");            #
5 #   you may not use this file except in compliance with the License.           #
6 #   You may obtain a copy of the License at                                    #
7 #                                                                              #
8 #       http://www.apache.org/licenses/LICENSE-2.0                             #
9 #                                                                              #
10 #   Unless required by applicable law or agreed to in writing, software        #
11 #   distributed under the License is distributed on an "AS IS" BASIS,          #
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
13 #   See the License for the specific language governing permissions and        #
14 #   limitations under the License.                                             #
15 ################################################################################
16
17 # Master makefile for O1 module
18
19 # Identify the location our software which is used by rest
20 # of the build scripts
21
22 include ../common/rsys_fancy.mak
23 include ../common/env.mak
24
25 ROOT_DIR=$(patsubst %/build/o1,%,$(BUILD_DIR))
26 RULE=$(COLOR_RED)
27 OPTS=$(COLOR_GREEN)
28 NORM=$(REVERT_COLOR)
29
30 # For improved speed
31 CPUINFO=`cat /proc/cpuinfo | grep processor| wc -l`
32 ifeq ($(CPUINFO), 1)
33    NUM_PARALLEL=1
34 else
35       NUM_PARALLEL=$(shell echo $(CPUINFO) - 1 |bc)
36 endif
37
38 ifeq ($(FAST), 1)
39       NUM_PARALLEL=$(shell echo $(CPUINFO) + 2 |bc)
40 endif
41
42 PARALLEL_COMP=-j $(NUM_PARALLEL)
43
44 # Different options to O1 build
45 # # Other apsects of tool chain set here
46 # # These should be made available appropriately to the builds
47 ifeq ($(MACHINE),BIT64)
48 CC          =gcc -m64
49 CCPP        =g++ -m64
50 else
51 CC          =gcc -m32
52 CCPP        =g++ -m32
53 endif
54
55 CC1= $(CC)
56 CCPP1= $(CCPP)
57
58
59 # The include options get merged with the options needed by
60 # # the called makefiles and hence we export these to make them
61 # # available to them.
62 BUILD=i686-linux
63
64 # The called makefiles depend on these macros and these need to be exported
65 export PLTFRM
66 export PLTFRM_FLAGS
67 export BUILD
68 export I_OPTS
69
70 # Add to the linker options the platform specific components
71 #L_OPTS+=-lnsl -lrt -lm -lpthread -lsctp
72 L_OPTS=-lsysrepo -lyang
73 L_OPTS+= -lsysrepo-cpp -lyang-cpp
74 L_OPTS+= -lm -lpthread
75
76 # Export some of the flags expected from the command line.
77 # # These macros are made available for the makefiles called from this makefile
78 export MACHINE
79
80 help:
81                 @echo -e "******************************************************************"
82                 @echo -e "BUILD COMMAND            DESCRIPTION                              "
83                 @echo -e "------------------------------------------------------------------"
84                 @echo -e "$(RULE)o1        - Builds all components of O1$(NORM)"
85                 @echo -e "$(RULE)clean_o1  - clean up O1$(NORM)"
86                 @echo -e "$(RULE)clean_all - cleanup O1 and all directories$(NORM)"
87                 @echo -e "$(OPTS)  options: $(NORM)"
88                 @echo -e "$(OPTS)    MACHINE=BIT64/BIT32  - Default is BIT32$(NORM)"
89                 @echo -e "******************************************************************"
90
91 prepare_dirs:
92         $(Q)echo -e "Preparing directories for build..."
93         $(Q)mkdir -p $(BUILD_DIR)/obj/o1
94         $(Q)mkdir -p $(LIB_ROOT)/o1
95         $(Q)mkdir -p $(BIN_DIR)/o1
96         $(Q)echo -e "Directories are successfully prepared"
97
98 o1_mod:
99                 $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak OBJ_DIR=$(OBJ_ROOT)/o1 LIB_DIR=$(LIB_ROOT)/o1 LOG_DIR=$(LOG_ROOT)/o1 CC='$(CCPP1)'
100
101 link_o1: o1_mod
102                 $(Q)$(CCPP1) -g -o $(OBJ_ROOT)/o1/o1 -Wl,-R../lib/:. $(OBJ_ROOT)/o1/*.o\
103                         $(L_OPTS) -L$(LIB_ROOT)/o1
104
105 clean_o1: 
106                 $(Q)$(MAKE) -f $(COM_BUILD_DIR)/o1.mak clean OBJ_DIR=$(OBJ_ROOT)/o1 LIB_DIR=$(LIB_ROOT)/o1 LOG_DIR=$(LOG_ROOT)/o1 CC='$(CC1)'
107                 $(Q)rm -rf $(OBJ_ROOT)/o1/*
108                 $(Q)rm -rf $(LIB_ROOT)/o1/*
109                 $(Q)rm -rf $(BIN_DIR)/o1/*
110                 $(Q)echo -e "***** O1 CLEAN COMPLETE *****"
111
112 clean_all: clean_o1
113                           $(Q)rm -rf $(OBJ_ROOT)
114                           $(Q)rm -rf $(LIB_ROOT)
115                           $(Q)rm -rf $(LOG_ROOT)
116                           $(Q)rm -rf $(BIN_DIR)
117
118 copy_build: link_o1
119                         $(Q)cp -f ./obj/o1/o1 ./bin/o1
120                         $(Q)echo -e "***** O1 BUILD COMPLETE *****"
121
122 o1: prepare_dirs copy_build
123
124 #**********************************************************************
125 #         End of file
126 #**********************************************************************