1 #/******************************************************************************
3 #* Copyright (c) 2020 Intel.
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
9 #* http://www.apache.org/licenses/LICENSE-2.0
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.
17 #*******************************************************************************/
20 .SUFFIXES: .o .c .s .i .cpp
22 ##############################################################
24 ##############################################################
33 ifeq ($(SHELL),cmd.exe)
44 $(error "Please define RTE_SDK environment variable")
48 MLOG_DIR=$(XRAN_DIR)/../mlog
51 RTE_TARGET ?= x86_64-native-linuxapp-icc
53 RTE_LIBS = $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --static --libs libdpdk)
54 RTE_INC := $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --cflags-only-I libdpdk)
57 # Where to find user code.
58 COMMON_TEST_DIR = $(XRAN_DIR)/test/common
59 USER_DIR = $(XRAN_DIR)/lib/src
60 USER_ETH = $(XRAN_DIR)/lib/ethernet
61 USER_API = $(XRAN_DIR)/lib/api
63 # Flags passed to the preprocessor.
64 # Set Google Test's header directory as a system directory, such that
65 # the compiler doesn't generate warnings in Google Test headers.
66 CPPFLAGS += -isystem $(GTEST_ROOT)/include
68 # Flags passed to the C++ compiler.
69 CXXFLAGS += -g -std=c++14 -Wall -Wextra -pthread -mcmodel=large -I$(USER_API) -I$(USER_DIR) -I$(USER_ETH) -I$(MLOG_DIR)/source -I $(COMMON_TEST_DIR) -I$(RTE_INC)
71 # All tests produced by this Makefile. Remember to add new tests you
72 # created to the list.
75 # All Google Test headers. Usually you shouldn't change this
77 GTEST_HEADERS = $(GTEST_ROOT)/include/gtest/*.h \
78 $(GTEST_ROOT)/include/gtest/internal/*.h
80 CFLAGS += -std=gnu11 -Wall -Wno-deprecated-declarations \
85 -Wimplicit-function-declaration \
88 -I$(USER_API) -I$(USER_DIR) -I$(USER_ETH) -I$(MLOG_DIR)/source -I$(RTE_INC)
92 $(USER_ETH)/ethernet.c \
93 $(USER_DIR)/xran_up_api.c \
94 $(USER_DIR)/xran_sync_api.c \
95 $(USER_DIR)/xran_timer.c \
96 $(USER_DIR)/xran_cp_api.c \
97 $(USER_DIR)/xran_transport.c \
98 $(USER_DIR)/xran_common.c \
99 $(USER_DIR)/xran_ul_tables.c \
100 $(USER_DIR)/xran_frame_struct.c \
101 $(USER_DIR)/xran_app_frag.c \
102 $(USER_DIR)/xran_dev.c \
103 $(USER_DIR)/xran_rx_proc.c \
104 $(USER_DIR)/xran_tx_proc.c \
105 $(USER_DIR)/xran_cp_proc.c \
106 $(USER_DIR)/xran_cb_proc.c \
107 $(USER_DIR)/xran_mem_mgr.c \
108 $(USER_DIR)/xran_main.c \
109 $(USER_DIR)/xran_delay_measurement.c
112 $(COMMON_TEST_DIR)/xranlib_unit_test_main.cc \
115 prach_functional.cc \
116 prach_performance.cc \
117 u_plane_functional.cc \
118 u_plane_performance.cc \
119 init_sys_functional.cc \
120 compander_functional.cc \
121 mod_compression_unit_test.cc \
124 # u_plane_performance.cc \
126 CPP_SRC = $(COMMON_TEST_DIR)/common.cpp \
127 $(USER_DIR)/xran_compression.cpp \
128 $(USER_DIR)/xran_bfp_ref.cpp \
129 $(USER_DIR)/xran_bfp_cplane8.cpp \
130 $(USER_DIR)/xran_bfp_cplane16.cpp \
131 $(USER_DIR)/xran_bfp_cplane32.cpp \
132 $(USER_DIR)/xran_bfp_cplane64.cpp \
133 $(USER_DIR)/xran_bfp_uplane_9b16rb.cpp \
134 $(USER_DIR)/xran_bfp_uplane.cpp \
135 $(USER_DIR)/xran_mod_compression.cpp
137 CPP_SRC_SNC = $(USER_DIR)/xran_compression_snc.cpp \
138 $(USER_DIR)/xran_bfp_cplane8_snc.cpp \
139 $(USER_DIR)/xran_bfp_cplane16_snc.cpp \
140 $(USER_DIR)/xran_bfp_cplane32_snc.cpp \
141 $(USER_DIR)/xran_bfp_cplane64_snc.cpp \
142 $(USER_DIR)/xran_bfp_uplane_snc.cpp
145 C_OBJS := $(patsubst %.c,%.o,$(C_SRC))
146 CC_OBJS := $(patsubst %.cc,%.o,$(CC_SRC))
147 CPP_OBJS := $(patsubst %.cpp,%.o,$(CPP_SRC))
148 CPP_SNC_OBJS := $(patsubst %.cpp,%.o,$(CPP_SRC_SNC))
150 CPPFLAGS += -I$(USER_DIR) -I$(USER_API)
152 #-qopt-report=5 -qopt-matmul -qopt-report-phase=all
153 CPP_COMP := -O3 -DNDEBUG -xcore-avx512 -fPIE -restrict -fasm-blocks
154 CPP_COMP_SNC := -O3 -DNDEBUG -march=icelake-server -fPIE -restrict -fasm-blocks
156 CPP_COMP := $(CPP_COMP)
157 CPP_COMP_SNC := $(CPP_COMP_SNC)
160 CPP_ASMS := $(patsubst %.cpp,%.asm,$(CPP_SRC))
161 CPP_SNC_ASMS := $(patsubst %.cpp,%.asm,$(CPP_SRC_SNC))
162 CPP_COMP += -qopt-report=5 -qopt-matmul -qopt-report-phase=all
163 CPP_COMP_SNC += -qopt-report=5 -qopt-matmul -qopt-report-phase=all
166 PROJECT_DEP_FILE := $(TESTS).dep
168 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
171 C_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(C_SRC)))
172 CC_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CC_SRC)))
173 CPP_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CPP_SRC)))
174 CPP_SNC_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CPP_SRC_SNC)))
175 GENERATE_DEPS := generate_deps
179 # House-keeping build targets.
180 all : echo_start_build $(GENERATE_DEPS) $(TESTS)
184 @$(RM) -f $(TESTS) *.o $(COMMON_TEST_DIR)/*.o $(USER_DIR)/*.o $(USER_ETH)/*.o \
185 *.asm $(COMMON_TEST_DIR)/*.asm $(USER_DIR)/*.asm $(USER_ETH)/*.asm \
186 *.asm $(COMMON_TEST_DIR)/*.asm2 $(USER_DIR)/*.asm2 $(USER_ETH)/*.asm2 \
187 *.optrpt $(COMMON_TEST_DIR)/*.optrpt $(USER_DIR)/*.optrpt $(USER_ETH)/*.optrpt;\
188 $(RM) $(PROJECT_DEP_FILE)
195 @$(RM) $(PROJECT_DEP_FILE)
196 @echo [DEP] $(PROJECT_DEP_FILE)
199 @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.c,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CFLAGS) >> $(PROJECT_DEP_FILE)
202 @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cc,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) >> $(PROJECT_DEP_FILE)
205 @$(CPP) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cpp,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) >> $(PROJECT_DEP_FILE)
208 @$(CPP) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(patsubst %.cpp,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) >> $(PROJECT_DEP_FILE)
210 .PHONY : generate_deps
211 generate_deps : clear_dep $(C_DEPS) $(CC_DEPS) $(CPP_DEPS) $(CPP_SNC_DEPS)
213 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
215 include $(PROJECT_DEP_FILE)
219 .PHONY : echo_start_build
221 @echo Build Tests with
225 $(CC_OBJS) : $(CC_SRC)
227 @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o"$@" $(patsubst %.o,%.cc,$@)
230 @echo "[CPP->ASM] $@"
231 @$(CXX) -S $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) -fsource-asm -save-temps -o"$@" $(patsubst %.asm,%.cpp,$@)
232 @cat $@ | grep -v '^..LN' |grep -v ' .loc' > $@2
234 $(CPP_OBJS) : $(CPP_ASMS)
236 @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP) -o"$@" $(patsubst %.o,%.cpp,$@)
239 @echo "[CPP-SNC->ASM] $@"
240 @$(CXX) -S $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) -fsource-asm -save-temps -o"$@" $(patsubst %.asm,%.cpp,$@)
241 @cat $@ | grep -v '^..LN' |grep -v ' .loc' > $@2
243 $(CPP_SNC_OBJS) : $(CPP_SNC_ASMS)
245 @$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(CPP_COMP_SNC) -o"$@" $(patsubst %.o,%.cpp,$@)
249 @$(CC) -c $(CFLAGS) -o"$@" $(patsubst %.o,%.c,$@)
251 $(TESTS) : $(CC_OBJS) $(CPP_OBJS) $(CPP_SNC_OBJS) $(C_OBJS) $(GTEST_ROOT)/libgtest.a
253 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -L$(MLOG_DIR)/bin -Wl, $(RTE_LIBS) -lpthread -lnuma $^ -o $@