Initial commit
[o-du/l2.git] / build / scripts / 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 #********************************************************************20**
18 #
19 #       Name:   gNodeB Sample Application
20 #
21 #       Type:   make file
22 #
23 #       Desc:   Compile, assemble and link product software for
24 #               various configurations. Further comments are
25 #               embedded in the file. 
26 #
27 #               This file supports a variety of environments and
28 #               build targets. The default build target will be the
29 #               portable target for the Linu 2.4.x with GNU C(gcc)
30 #
31 #       Env:    Linux 2.4.x with GNU C (gcc)
32 #
33 #               BUILD TARGETS:
34 #
35 #               clean            remove all object files
36 #   
37 #       File:  makefile
38 #
39 #********************************************************************21*/
40 #=======================================================================
41
42 # Identify the location our software which is used by rest
43 # of the build scripts
44 include ../common/rsys_fancy.mak
45 include ../common/env.mak
46
47 RULE=$(COLOR_RED)
48 OPTS=$(COLOR_GREEN)
49 NORM=$(REVERT_COLOR)
50
51 ROOT_DIR=$(ROOT_DIR_SCRIPTS)
52 export ROOT_DIR
53
54 # For improved speed
55 CPUINFO=`cat /proc/cpuinfo | grep processor| wc -l`
56 ifeq ($(CPUINFO), 1)
57    NUM_PARALLEL=1
58 else
59    NUM_PARALLEL=$(shell echo $(CPUINFO) - 1 |bc)
60 endif
61
62 ifeq ($(FAST), 1)
63    NUM_PARALLEL=$(shell echo $(CPUINFO) + 2 |bc)
64 endif
65
66 PARALLEL_COMP=-j $(NUM_PARALLEL) 
67 #PARALLEL_COMP=-j 1
68
69 # Different options to CPUH and CPUL builds
70 # Other apsects of tool chain set here
71 # These should be made available appropriately to the builds
72
73 ifeq ($(MACHINE),BIT64)
74 CC          =gcc -m64
75 CC_STRIP    =strip --strip-all
76 CC_LINKER   =gcc -m64
77 CCPP        =g++ -m64
78 CCPP_LINKER =g++ -m64
79 else
80 CC          =gcc -m32
81 CC_STRIP    =strip --strip-all
82 CC_LINKER   =gcc -m32
83 CCPP        =g++ -m32
84 CCPP_LINKER =g++ -m32
85 endif
86
87 CC1= $(CC)
88 CCPP1= $(CCPP)
89
90 ifeq ($(MODE),TDD)
91 CNM_ENABLE = YES
92 else
93 CNM_ENABLE=NO
94 endif
95
96 #-----------------------------------------------------------------------
97 # macro for output file name and makefile name
98 #
99 prepare_dirs:
100         $(Q)echo -e "Preparing directories for build..."
101         $(Q)mkdir -p $(BUILD_DIR)/obj
102         $(Q)mkdir -p $(LOG_ROOT)
103         $(Q)mkdir -p $(LIB_ROOT)
104         $(Q)echo -e "Directories are successfully prepared"
105
106
107 ifeq ($(CNM_ENABLE),YES) 
108 CNM_OPT = -DxENABLE_CNM -DREM_ENABLE -DCNM_DEBUG
109 else
110 CNM_OPT = -UENABLE_CNM -UREM_ENABLE
111 endif
112
113    PLTFRM_FLAGS= -UMSPD $(CNM_OPT)
114
115 ifeq ($(MODE),TDD) 
116    PLTFRM_FLAGS += -DMODE=TDD
117 endif
118 CA_ENABLE=YES
119 ifeq ($(CA_ENABLE),YES)
120    PLTFRM_FLAGS += -DCA_ENABLE=YES
121 endif
122
123 # The include options get merged with the options needed by
124 # the called makefiles and hence we export these to make them
125 # available to them.
126 PLTFRM=PAL
127 BUILD=i686-linux
128
129
130 # The called makefiles depend on these macros and these need to be exported
131 export PLTFRM
132 export PLTFRM_FLAGS
133 export BUILD
134 export I_OPTS
135
136 # Add to the linker options the platform specific components
137 L_OPTS+=-lnsl -lrt -lm -lpthread 
138
139
140 # Export some of the flags expected from the command line.
141 # These macros are made available for the makefiles called from this makefile
142 export MACHINE
143 export MODE
144 export CNM_ENABLE
145 export CA_ENABLE
146
147 ###################################################################################################
148 #       TeNB Compilation Options        - Help Menu
149 ###################################################################################################
150 help:
151         @echo -e "******************************************************************"
152         @echo -e "BUILD COMMAND            DESCRIPTION                              "
153         @echo -e "------------------------------------------------------------------"
154         @echo -e "$(RULE)tenb - Builds all components of TeNB$(NORM)"
155         @echo -e "$(OPTS)  options: $(NORM)"
156         @echo -e "$(OPTS)    MACHINE=BIT64/BIT32  - Default is BIT32$(NORM)"
157         @echo -e "$(OPTS)    MODE=TDD       - If not specified, MODE=FDD$(NORM)"
158         @echo -e "$(RULE)clean_all         tdd cleanup everything$(NORM)"
159         @echo -e "******************************************************************"
160
161
162 enb: 
163         $(Q)$(MAKE) -f $(COM_BUILD_DIR)/kw.mak OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC1)'
164         $(Q)$(MAKE) -f $(COM_BUILD_DIR)/pj.mak OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC1)'
165         $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rg.mak OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC1)'
166
167 clean_all:
168         $(Q)$(MAKE) -f $(COM_BUILD_DIR)/rg.mak clean OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC2)'
169         $(Q)$(MAKE) -f $(COM_BUILD_DIR)/kw.mak clean OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC2)'
170         $(Q)$(MAKE) -f $(COM_BUILD_DIR)/pj.mak clean OBJ_DIR=$(OBJ_ROOT) LIB_DIR=$(LIB_ROOT) LOG_DIR=$(LOG_ROOT) CC='$(CC2)'
171
172         
173 ###################################################################################################
174 #       TeNB Compilation
175 ###################################################################################################
176
177 tenb: prepare_dirs copy_build
178
179 copy_build: enb
180         $(Q)mkdir -p $(ROOT_DIR)/libs/
181         $(Q)cp -f ./lib/*.a $(ROOT_DIR)/libs/
182
183 ###################################################################################################
184 #                                                                                                       END OF MAKEFILE
185 ###################################################################################################