* INTC Contribution to the O-RAN F Release for O-DU Low
[o-du/phy.git] / fapi_5g / build / makefile
1 ###############################################################################
2 #
3 #   Copyright (c) 2021 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 ifeq ($(WIRELESS_SDK_TOOLCHAIN),icc)
27 CC := icc
28 CPP := icpc
29 AS := as
30 AR := ar
31 LD := icc
32 else ifeq ($(WIRELESS_SDK_TOOLCHAIN),icx)
33     CC  := icx
34     CPP := icx
35     AS := as
36     AR := ar
37     LD := icx
38 else
39     $(error "Please define WIRELESS_SDK_TOOLCHAIN environment variable")
40 endif
41
42 ifeq ($(WIRELESS_SDK_TARGET_ISA),sse)
43     TARGET_PROCESSOR := -xSSE4.2
44 else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx2)
45     TARGET_PROCESSOR := -xCORE-AVX2
46 else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx512)
47     TARGET_PROCESSOR := -xCORE-AVX512
48 else ifeq ($(WIRELESS_SDK_TARGET_ISA),snc)
49     TARGET_PROCESSOR := -xicelake-server
50 else ifeq ($(WIRELESS_SDK_TARGET_ISA),spr)
51     TARGET_PROCESSOR := -march=sapphirerapids
52 endif
53
54 ifeq ($(TARGET_PROCESSOR),)
55     $(error "Please define valid WIRELESS_SDK_TARGET_ISA environment variable $(WIRELESS_SDK_TARGET_ISA)")
56 endif
57 OBJDUMP := objdump
58 MD := mkdir -p
59 CP := cp -f
60 RM := rm -rf
61
62 ##############################################################
63 # TARGET
64 ##############################################################
65 ifeq ($(RTE_SDK),)
66     $(error "Please define RTE_SDK environment variable")
67 endif
68
69 RTE_INC := $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --cflags-only-I libdpdk)
70
71 ##############################################################
72 # Projects folders
73 ##############################################################
74 FLEXRANDIR        := $(DIR_WIRELESS)
75 WLSDIR            := $(DIR_WIRELESS_WLS)
76 BUILDDIR          := ../build/make
77 SRCDIR            := $(CURDIR)
78
79 oran_5g_fapi_dep_file = $(BUILDDIR)/oran_5g_fapi_dep
80
81 APP := ../bin/oran_5g_fapi
82
83 INC := \
84  -I$(WLSDIR) \
85  -I$(SRCDIR)/../include \
86  -I$(SRCDIR)/common \
87  -I$(SRCDIR)/include \
88  -I$(SRCDIR)/framework/workers \
89  -I$(SRCDIR)/framework/wls/fapi2mac \
90  -I$(SRCDIR)/framework/wls/fapi2phy \
91  -I$(SRCDIR)/framework/wls/lib \
92  -I$(SRCDIR)/api/fapi2mac \
93  -I$(SRCDIR)/api/fapi2phy \
94  -I$(FLEXRANDIR)/l1/source/nr5g/api \
95  -I$(FLEXRANDIR)/l1/source/common \
96  -I$(SRCDIR)/api/fapi2phy/p5 \
97  -I$(SRCDIR)/api/fapi2phy/p7 \
98  -I$(SRCDIR)/api/fapi2mac/p5 \
99  -I$(SRCDIR)/api/fapi2mac/p7 \
100  -I$(SRCDIR)/utils \
101  $(RTE_INC) \
102  
103 DEFS := USE_WO_LOCK _GNU_SOURCE
104
105 ifneq ($(PRINTDBG),)
106 DEFS := $(DEFS) PRINTF_DBG_OK
107 endif
108
109 ifeq ($(DEBUG_MODE),true)
110 DEFS := $(DEFS) DEBUG_MODE
111 endif
112
113 ifeq ($(STATISTIC_MODE),true)
114 DEFS := $(DEFS) STATISTIC_MODE
115 endif
116
117 DEFS := $(addprefix -D,$(DEFS))
118
119 CFLAGS := -g -Wall -Wextra -Wunused -diag-disable9 -Wno-deprecated-declarations -Wimplicit-function-declaration -fasm-blocks -fstack-protector-strong -Wformat -Wformat-security -Werror=format-security -fwrapv -mssse3 $(DEFS) $(INC)
120
121 ifeq ($(PRINTDBG),)
122 CFLAGS := $(CFLAGS) -Werror
123 endif
124
125 RTE_LIBS := $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --static --libs libdpdk)
126 LDFLAGS := -z now -z relro -z noexecstack -g -Wl,-lrt -Wl,-lpthread -Wl,-lhugetlbfs -Wl,-lm -Wl,-lnuma -L $(WLSDIR) -lwls
127
128 LINUX_ORAN_5G_FAPI_SRC := \
129         $(SRCDIR)/nr5g_fapi.c \
130         $(SRCDIR)/utils/nr5g_fapi_args.c \
131         $(SRCDIR)/utils/nr5g_fapi_config_loader.c \
132         $(SRCDIR)/utils/nr5g_fapi_log.c \
133         $(SRCDIR)/utils/nr5g_fapi_stats.c \
134         $(SRCDIR)/utils/nr5g_fapi_memory.c \
135         $(SRCDIR)/utils/nr5g_fapi_cmd.c \
136         $(SRCDIR)/utils/nr5g_fapi_snr_conversion.c \
137         $(SRCDIR)/framework/workers/nr5g_fapi_mac2phy_thread.c \
138         $(SRCDIR)/framework/workers/nr5g_fapi_phy2mac_thread.c \
139         $(SRCDIR)//framework/workers/nr5g_fapi_urllc_phy2mac_thread.c \
140         $(SRCDIR)//framework/workers/nr5g_fapi_urllc_mac2phy_thread.c \
141         $(SRCDIR)/framework/nr5g_fapi_framework.c \
142         $(SRCDIR)/framework/wls/fapi2mac/nr5g_fapi_fapi2mac_wls.c \
143         $(SRCDIR)/framework/wls/fapi2phy/nr5g_fapi_fapi2phy_wls.c \
144         $(SRCDIR)/framework/wls/lib/nr5g_fapi_wls.c \
145         $(SRCDIR)/api/fapi2mac/nr5g_fapi_fapi2mac_api.c \
146         $(SRCDIR)/api/fapi2mac/nr5g_fapi_proc_error_ind.c \
147         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_config_resp.c \
148         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_start_resp.c \
149         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_stop_ind.c \
150         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_ul_iq_samples_resp.c \
151         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_dl_iq_samples_resp.c \
152         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_shutdown_resp.c \
153         $(SRCDIR)/api/fapi2mac/p5/nr5g_fapi_proc_fapi_msg_header.c \
154         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_slot_ind.c \
155         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_crc_ind.c \
156         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_rach_ind.c \
157     $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_rx_data_ind.c \
158         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_rx_data_uci_ind.c \
159         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_srs_ind.c \
160         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_uci_ind.c \
161         $(SRCDIR)/api/fapi2mac/p7/nr5g_fapi_proc_vendor_p7_msgs.c \
162         $(SRCDIR)/api/fapi2phy/nr5g_fapi_fapi2phy_api.c \
163         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_add_remove_core_msg.c \
164         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_config_req.c \
165         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_param_resp.c \
166         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_start_req.c \
167         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_stop_req.c \
168         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_shutdown_req.c \
169         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_dl_iq_samples_req.c \
170         $(SRCDIR)/api/fapi2phy/p5/nr5g_fapi_proc_ul_iq_samples_req.c \
171         $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_dl_tti_req.c \
172         $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_ul_tti_req.c \
173         $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_tti_req_common.c \
174     $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_tx_data_req.c \
175         $(SRCDIR)/api/fapi2phy/p7/nr5g_fapi_proc_ul_dci_req.c
176
177 OBJS := $(LINUX_ORAN_5G_FAPI_SRC:.c=.o)
178
179 PROJECT_OBJ_DIR = $(BUILDDIR)
180
181 OBJS := $(addprefix $(PROJECT_OBJ_DIR)/,$(OBJS))
182
183 DIRLIST := $(sort $(dir $(OBJS)))
184
185 CC_DEPS := $(addprefix __dep__,$(LINUX_ORAN_5G_FAPI_SRC))
186
187 GEN_DEP :=
188 ifeq ($(wildcard $(oran_5g_fapi_dep_file)),)
189 GEN_DEP := regenerate_dep
190 endif
191
192 .PHONY: $(APP)
193 $(APP): $(DIRLIST) echo_options $(GEN_DEP) $(OBJS)
194         @echo [LD] $(APP)
195         @$(CC) -o $(APP) $(OBJS) $(LDFLAGS) $(RTE_LIBS) -lstdc++ # stdc++ flag needed for RTE LIBS
196 #       $(OBJDUMP) -d $(APP) > $(APP).asm
197
198 .PHONY : echo_options
199 echo_options:
200         @echo [CFLAGS]  $(CFLAGS)
201         @echo [LDFAGS]  $(LDFLAGS)
202
203
204 ifneq ($(wildcard $(oran_5g_fapi_dep_file)),)
205 include $(oran_5g_fapi_dep_file)
206 endif
207
208 $(DIRLIST) :
209         -@$(MD) $@
210
211 .PHONY : regenerate_dep
212 regenerate_dep : clean_dep echo_regeenrate_dep  $(CC_DEPS)
213
214 .PHONY: clean_dep
215 clean_dep:
216         $(RM) $(oran_5g_fapi_dep_file)
217
218 .PHONY : echo_regeenrate_dep
219 echo_regeenrate_dep:
220         @echo regenerating dep files
221
222
223 .PHONY : CC_DEPS
224 $(CC_DEPS):
225         @$(CC) -MM $(subst __dep__,,$@) -MT $(addprefix $(PROJECT_OBJ_DIR)/,$(patsubst %.c,%.o,$(subst __dep__,,$@))) $(CFLAGS) >> $(oran_5g_fapi_dep_file)
226
227 $(OBJS) : $(PROJECT_OBJ_DIR)/%.o: %.c
228         @echo [CC]    $(subst $(PROJECT_OBJ_DIR)/,,$@)
229         @$(CC) -c $(CFLAGS) -o"$@" $(patsubst %.o,%.c,$(subst $(PROJECT_OBJ_DIR)/,,$@))
230
231
232 .PHONY: xclean
233 xclean : clean_dep
234         @$(RM) $(OBJS)
235         @$(RM) $(APP)
236         @$(RM) $(BUILDDIR)
237
238 .PHONY: clean
239 clean :
240         @$(RM) $(OBJS)
241         @$(RM) $(APP)
242