f54657d701fbd68e68fc8b3cfd4276aff2afe639
[o-du/phy.git] / fapi_5g / build / makefile
1 ###############################################################################
2 #
3 #   Copyright (c) 2019 Intel.
4 #
5 #   Licensed under the Apache License, Version 2.0 (the "License");
6 #   you may not use this file except in compliance with the License.
7 #   You may obtain a copy of the License at
8 #
9 #       http://www.apache.org/licenses/LICENSE-2.0
10 #
11 #   Unless required by applicable law or agreed to in writing, software
12 #   distributed under the License is distributed on an "AS IS" BASIS,
13 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 #   See the License for the specific language governing permissions and
15 #   limitations under the License.
16 #
17 ###############################################################################
18
19 .SUFFIXES: .o .c .s .i .cpp
20
21 # Makefile to build TestMac application
22
23 ##############################################################
24 #  Tools configuration
25 ##############################################################
26 CC := icc
27 CPP := icpc
28 AS := as
29 AR := ar
30 LD := icc
31 OBJDUMP := objdump
32
33 ifeq ($(SHELL),cmd.exe)
34 MD := mkdir.exe -p
35 RM := rm.exe -rf
36 else
37 MD := mkdir -p
38 RM := rm -rf
39 endif
40
41 ##############################################################
42 # TARGET
43 ##############################################################
44 ifeq ($(RTE_TARGET),)
45     RTE_TARGET :=x86_64-native-linuxapp-icc
46 endif
47 ##############################################################
48 # DPDK
49 ##############################################################
50 ifeq ($(RTE_SDK),)
51 $(info Please make sure RTE_SDK points to DPDK folder (current version of DPDK is 18.08))
52     RTE_SDK := /opt/dpdk-18.08
53 endif
54
55 ##############################################################
56 # Projects folders
57 ##############################################################
58 FLEXRANDIR        := $(DIR_WIRELESS)
59 WLSDIR            := $(DIR_WIRELESS_WLS)
60 BUILDDIR          := ../build/make
61 SRCDIR            := $(CURDIR)
62
63 oran_5g_fapi_dep_file = $(BUILDDIR)/oran_5g_fapi_dep
64
65 APP := ../bin/oran_5g_fapi
66
67 INC := \
68  $(WLSDIR) \
69  $(SRCDIR)/../include \
70  $(SRCDIR)/common \
71  $(SRCDIR)/include \
72  $(SRCDIR)/framework/workers \
73  $(SRCDIR)/framework/wls/fapi2mac \
74  $(SRCDIR)/framework/wls/fapi2phy \
75  $(SRCDIR)/framework/wls/lib \
76  $(SRCDIR)/api/fapi2mac \
77  $(SRCDIR)/api/fapi2phy \
78  $(FLEXRANDIR)/source/nr5g/api \
79  $(FLEXRANDIR)/source/common \
80  $(RTE_SDK)/$(RTE_TARGET)/include \
81  $(SRCDIR)/api/fapi2phy/p5 \
82  $(SRCDIR)/api/fapi2phy/p7 \
83  $(SRCDIR)/api/fapi2mac/p5 \
84  $(SRCDIR)/api/fapi2mac/p7 \
85  $(SRCDIR)/utils \
86
87 INC := $(addprefix -I,$(INC))
88  
89 DEFS := USE_WO_LOCK _GNU_SOURCE
90
91 ifneq ($(PRINTDBG),)
92 DEFS := $(DEFS) PRINTF_DBG_OK
93 endif
94
95 ifeq ($(DEBUG_MODE),true)
96 DEFS := $(DEFS) DEBUG_MODE
97 endif
98
99 DEFS := $(addprefix -D,$(DEFS))
100
101 CFLAGS := -g -Wall -Wextra -Wunused -wd9 -Wno-deprecated-declarations -Wimplicit-function-declaration -fasm-blocks -fstack-protector-strong -z,now, -z,relro -z noexecstack -Wformat -Wformat-security -Werror=format-security -fno-strict-overflow -fwrapv $(DEFS) $(INC)
102
103 ifeq ($(PRINTDBG),)
104 CFLAGS := $(CFLAGS) -Werror
105 endif
106
107 RTE_LIBS := -L$(RTE_SDK)/$(RTE_TARGET)/lib -Wl,--whole-archive -Wl,-lrte_distributor -Wl,-lrte_kni -Wl,-lrte_pipeline -Wl,-lrte_table -Wl,-lrte_port -Wl,-lrte_timer -Wl,-lrte_hash -Wl,-lrte_lpm -Wl,-lrte_power -Wl,-lrte_acl -Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lm -Wl,-lrt -Wl,--start-group -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_ip_frag -Wl,-lrte_ethdev -Wl,-lrte_mempool -Wl,-lrte_mempool_ring -Wl,-lrte_ring -Wl,-lrte_bus_pci -Wl,-lrte_bus_vdev -Wl,-lrte_pci -Wl,-lrte_net -Wl,-lrte_eal -Wl,-lrte_cmdline -Wl,-lrte_cfgfile -Wl,-lrte_pmd_bond -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ring -Wl,-lrt -Wl,-lm -Wl,-ldl -Wl,--end-group -Wl,--no-whole-archive
108 LDFLAGS := -g -Wl,-lrt -Wl,-lpthread -Wl,-lhugetlbfs -Wl,-lm -Wl,-lnuma -L $(WLSDIR) -lwls
109
110 LINUX_ORAN_5G_FAPI_SRC := \
111         $(SRCDIR)/nr5g_fapi.c \
112         $(SRCDIR)/utils/nr5g_fapi_args.c \
113         $(SRCDIR)/utils/nr5g_fapi_config_loader.c \
114         $(SRCDIR)/utils/nr5g_fapi_log.c \
115         $(SRCDIR)/utils/nr5g_fapi_stats.c \
116         $(SRCDIR)/utils/nr5g_fapi_memory.c \
117         $(SRCDIR)/utils/nr5g_fapi_cmd.c \
118         $(SRCDIR)/framework/workers/nr5g_fapi_mac2phy_thread.c \
119         $(SRCDIR)/framework/workers/nr5g_fapi_phy2mac_thread.c \
120         $(SRCDIR)/framework/nr5g_fapi_framework.c \
121         $(SRCDIR)/framework/wls/fapi2mac/nr5g_fapi_fapi2mac_wls.c \
122         $(SRCDIR)/framework/wls/fapi2phy/nr5g_fapi_fapi2phy_wls.c \
123         $(SRCDIR)/framework/wls/lib/nr5g_fapi_wls.c \
124         $(SRCDIR)/api/fapi2mac/nr5g_fapi_fapi2mac_api.c \
125         $(SRCDIR)/api/fapi2mac/nr5g_fapi_proc_error_ind.c \
126         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_config_resp.c \
127         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_start_resp.c \
128         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_stop_ind.c \
129         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_ul_iq_samples_resp.c \
130         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_dl_iq_samples_resp.c \
131         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_shutdown_resp.c \
132         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_fapi_msg_header.c \
133         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_slot_ind.c \
134         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_crc_ind.c \
135         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_rach_ind.c \
136     $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_rx_data_ind.c \
137         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_srs_ind.c \
138         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_uci_ind.c \
139         $(SRCDIR)/api/fapi2phy/nr5g_fapi_fapi2phy_api.c \
140         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_config_req.c \
141         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_start_req.c \
142         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_stop_req.c \
143         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_shutdown_req.c \
144         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_dl_iq_samples_req.c \
145         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_ul_iq_samples_req.c \
146         $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_dl_tti_req.c \
147         $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_ul_tti_req.c \
148     $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_tx_data_req.c \
149         $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_ul_dci_req.c
150
151 OBJS := $(LINUX_ORAN_5G_FAPI_SRC:.c=.o)
152
153 PROJECT_OBJ_DIR = $(BUILDDIR)
154
155 OBJS := $(addprefix $(PROJECT_OBJ_DIR)/,$(OBJS))
156
157 DIRLIST := $(sort $(dir $(OBJS)))
158
159 CC_DEPS := $(addprefix __dep__,$(LINUX_ORAN_5G_FAPI_SRC))
160
161 GEN_DEP :=
162 ifeq ($(wildcard $(oran_5g_fapi_dep_file)),)
163 GEN_DEP := regenerate_dep
164 endif
165
166 .PHONY: $(APP)
167 $(APP): $(DIRLIST) echo_options $(GEN_DEP) $(OBJS)
168         @echo [LD] $(APP)
169         @$(CC) -o $(APP) $(OBJS) $(RTE_LIBS) $(LDFLAGS)
170 #       $(OBJDUMP) -d $(APP) > $(APP).asm
171
172 .PHONY : echo_options
173 echo_options:
174         @echo [CFLAGS]  $(CFLAGS)
175         @echo [LDFAGS]  $(LDFLAGS)
176
177
178 ifneq ($(wildcard $(oran_5g_fapi_dep_file)),)
179 include $(oran_5g_fapi_dep_file)
180 endif
181
182 $(DIRLIST) :
183         -@$(MD) $@
184
185 .PHONY : regenerate_dep
186 regenerate_dep : clean_dep echo_regeenrate_dep  $(CC_DEPS)
187
188 .PHONY: clean_dep
189 clean_dep:
190         $(RM) $(oran_5g_fapi_dep_file)
191
192 .PHONY : echo_regeenrate_dep
193 echo_regeenrate_dep:
194         @echo regenerating dep files
195
196
197 .PHONY : CC_DEPS
198 $(CC_DEPS):
199         @$(CC) -MM $(subst __dep__,,$@) -MT $(addprefix $(PROJECT_OBJ_DIR)/,$(patsubst %.c,%.o,$(subst __dep__,,$@))) $(CFLAGS) >> $(oran_5g_fapi_dep_file)
200
201 $(OBJS) : $(PROJECT_OBJ_DIR)/%.o: %.c
202         @echo [CC]    $(subst $(PROJECT_OBJ_DIR)/,,$@)
203         @$(CC) -c $(CFLAGS) -o"$@" $(patsubst %.o,%.c,$(subst $(PROJECT_OBJ_DIR)/,,$@))
204
205
206 .PHONY: xclean
207 xclean : clean_dep
208         @$(RM) $(OBJS)
209         @$(RM) $(APP)
210         @$(RM) $(BUILDDIR)
211
212 .PHONY: clean
213 clean :
214         @$(RM) $(OBJS)
215         @$(RM) $(APP)
216