provide follow changes:
[o-du/phy.git] / fhi_lib / app / Makefile
1 #/******************************************************************************\r
2 #*\r
3 #*   Copyright (c) 2019 Intel.\r
4 #*\r
5 #*   Licensed under the Apache License, Version 2.0 (the "License");\r
6 #*   you may not use this file except in compliance with the License.\r
7 #*   You may obtain a copy of the License at\r
8 #*\r
9 #*       http://www.apache.org/licenses/LICENSE-2.0\r
10 #*\r
11 #*   Unless required by applicable law or agreed to in writing, software\r
12 #*   distributed under the License is distributed on an "AS IS" BASIS,\r
13 #*   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
14 #*   See the License for the specific language governing permissions and\r
15 #*   limitations under the License.\r
16 #*\r
17 #*******************************************************************************/\r
18 \r
19 MYCUSTOMTAB='     '\r
20 MYCUSTOMSPACE='============================================================================================'\r
21 MYCUSTOMSPACE1='------------------------------------------------------------'\r
22 \r
23 ##############################################################\r
24 #  Tools configuration\r
25 ##############################################################\r
26 CC  := icc\r
27 CPP := icpc\r
28 AS := as\r
29 AR := ar\r
30 LD := icc\r
31 OBJDUMP := objdump\r
32 \r
33 ifeq ($(SHELL),cmd.exe)\r
34 MD := mkdir.exe -p\r
35 CP := cp.exe -f\r
36 RM := rm.exe -rf\r
37 else\r
38 MD := mkdir -p\r
39 CP := cp -f\r
40 RM := rm -rf\r
41 endif\r
42 \r
43 PROJECT_NAME := sample-app\r
44 PROJECT_TYPE := elf\r
45 PROJECT_DIR  := $(XRAN_DIR)/app\r
46 BUILDDIR := ./build\r
47 PROJECT_BINARY := $(BUILDDIR)/$(PROJECT_NAME)\r
48 \r
49 ifeq ($(RTE_SDK),)\r
50     $(error "Please define RTE_SDK environment variable")\r
51 endif\r
52 \r
53 RTE_TARGET ?= x86_64-native-linuxapp-gcc\r
54 RTE_INC := $(RTE_SDK)/$(RTE_TARGET)/include\r
55 \r
56 API_DIR := $(XRAN_DIR)/lib/api\r
57 SRC_DIR := $(PROJECT_DIR)/src\r
58 \r
59 ifeq ($(MLOG),1)\r
60 ifeq ($(MLOG_DIR),)\r
61     MLOG_DIR=$(XRAN_DIR)/../mlog\r
62 endif\r
63 endif\r
64 \r
65 CC_SRC = $(SRC_DIR)/common.c \\r
66         $(SRC_DIR)/sample-app.c \\r
67         $(SRC_DIR)/config.c\r
68 \r
69 CC_FLAGS += -std=gnu11 -Wall -Wno-deprecated-declarations  \\r
70         -fdata-sections \\r
71         -ffunction-sections \\r
72         -g \\r
73         -Wall \\r
74         -Wimplicit-function-declaration \\r
75         -g -O3 -wd1786\r
76 \r
77 CPP_FLAGS := -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D_GNU_SOURCE -D_REENTRANT -pipe -no-prec-div \\r
78                 -no-prec-div -fp-model fast=2\\r
79                 -no-prec-sqrt  -falign-functions=16 -fast-transcendentals \\r
80         -Werror -Wno-unused-variable -std=c++11 -mcmodel=large\r
81 \r
82 INC :=  -I$(API_DIR) -I$(RTE_INC)\r
83 DEF :=\r
84 \r
85 ifeq ($(MLOG),1)\r
86         INC  += -I$(MLOG_DIR)/source\r
87         DEF += -DMLOG_ENABLED\r
88 else\r
89         DEF += -UMLOG_ENABLED\r
90 endif\r
91 \r
92 XRAN_LIB_DIR=$(XRAN_DIR)/lib/build\r
93 LD_FLAGS += -L$(XRAN_LIB_DIR) -lxran\r
94 \r
95 RTE_LIBS = -L$(RTE_SDK)/$(RTE_TARGET)/lib -Wl,-lrte_flow_classify -Wl,--whole-archive -Wl,-lrte_pipeline -Wl,--no-whole-archive -Wl,--whole-archive -Wl,-lrte_table -Wl,--no-whole-archive -Wl,--whole-archive -Wl,-lrte_port -Wl,--no-whole-archive -Wl,-lrte_pdump -Wl,-lrte_distributor -Wl,-lrte_ip_frag -Wl,-lrte_meter -Wl,-lrte_lpm -Wl,--whole-archive -Wl,-lrte_acl -Wl,--no-whole-archive -Wl,-lrte_jobstats -Wl,-lrte_metrics -Wl,-lrte_bitratestats -Wl,-lrte_latencystats -Wl,-lrte_power -Wl,-lrte_efd -Wl,-lrte_bpf -Wl,--whole-archive -Wl,-lrte_cfgfile -Wl,-lrte_gro -Wl,-lrte_gso -Wl,-lrte_hash -Wl,-lrte_member -Wl,-lrte_vhost -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_net -Wl,-lrte_ethdev -Wl,-lrte_bbdev -Wl,-lrte_cryptodev -Wl,-lrte_security -Wl,-lrte_compressdev -Wl,-lrte_eventdev -Wl,-lrte_rawdev -Wl,-lrte_timer -Wl,-lrte_mempool -Wl,-lrte_mempool_ring -Wl,-lrte_ring -Wl,-lrte_pci -Wl,-lrte_eal -Wl,-lrte_cmdline -Wl,-lrte_reorder -Wl,-lrte_sched -Wl,-lrte_kni -Wl,-lrte_common_octeontx -Wl,-lrte_bus_pci -Wl,-lrte_bus_vdev -Wl,-lrte_bus_dpaa -Wl,-lrte_bus_fslmc -Wl,-lrte_mempool_bucket -Wl,-lrte_mempool_stack -Wl,-lrte_mempool_dpaa -Wl,-lrte_mempool_dpaa2 -Wl,-lrte_pmd_af_packet -Wl,-lrte_pmd_ark -Wl,-lrte_pmd_avf -Wl,-lrte_pmd_avp -Wl,-lrte_pmd_axgbe -Wl,-lrte_pmd_bnxt -Wl,-lrte_pmd_bond -Wl,-lrte_pmd_cxgbe -Wl,-lrte_pmd_dpaa -Wl,-lrte_pmd_dpaa2 -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ena -Wl,-lrte_pmd_enic -Wl,-lrte_pmd_fm10k -Wl,-lrte_pmd_failsafe -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_kni -Wl,-lrte_pmd_lio -Wl,-lrte_pmd_nfp -Wl,-lrte_pmd_null -Wl,-lrte_pmd_qede -Wl,-lrte_pmd_ring -Wl,-lrte_pmd_softnic -Wl,-lrte_pmd_tap -Wl,-lrte_pmd_thunderx_nicvf -Wl,-lrte_pmd_vdev_netvsc -Wl,-lrte_pmd_virtio -Wl,-lrte_pmd_vhost -Wl,-lrte_pmd_ifc -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_bus_vmbus -Wl,-lrte_pmd_netvsc -Wl,-lrte_pmd_bbdev_null -Wl,-lrte_pmd_null_crypto -Wl,-lrte_pmd_crypto_scheduler -Wl,-lrte_pmd_dpaa2_sec -Wl,-lrte_pmd_dpaa_sec -Wl,-lrte_pmd_virtio_crypto -Wl,-lrte_pmd_octeontx_zip -Wl,-lrte_pmd_qat -Wl,-lrte_pmd_skeleton_event -Wl,-lrte_pmd_sw_event -Wl,-lrte_pmd_octeontx_ssovf -Wl,-lrte_pmd_dpaa_event -Wl,-lrte_pmd_dpaa2_event -Wl,-lrte_mempool_octeontx -Wl,-lrte_pmd_octeontx -Wl,-lrte_pmd_opdl_event -Wl,-lrte_pmd_skeleton_rawdev -Wl,-lrte_pmd_dpaa2_cmdif -Wl,-lrte_pmd_dpaa2_qdma -Wl,-lrte_bus_ifpga -Wl,-lrte_pmd_ifpga_rawdev -Wl,--no-whole-archive -Wl,-lrt -Wl,-lm -Wl,-lnuma -Wl,-ldl -Wl,\r
96 LD_FLAGS += $(RTE_LIBS)\r
97 \r
98 ifeq ($(MLOG),1)\r
99         LD_FLAGS +=  -L$(MLOG_DIR)/bin -lmlog\r
100 endif\r
101 \r
102 AS_FLAGS :=\r
103 AR_FLAGS := rc\r
104 \r
105 PROJECT_OBJ_DIR := build/obj\r
106 \r
107 CC_OBJS := $(patsubst %.c,%.o,$(CC_SRC))\r
108 CPP_OBJS := $(patsubst %.cpp,%.o,$(CPP_SRC))\r
109 AS_OBJS := $(patsubst %.s,%.o,$(AS_SRC))\r
110 OBJS    := $(CC_OBJS) $(CPP_OBJS) $(AS_OBJS) $(LIBS)\r
111 DIRLIST := $(addprefix $(PROJECT_OBJ_DIR)/,$(sort $(dir $(OBJS))))\r
112 \r
113 CC_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(CC_OBJS))\r
114 CPP_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(CPP_OBJS))\r
115 \r
116 AS_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(AS_OBJS))\r
117 \r
118 CC_FLAGS_FULL  := $(CC_FLAGS)  $(INC) $(DEF)\r
119 CPP_FLAGS_FULL := $(CPP_FLAGS) $(INC) $(DEF)\r
120 \r
121 AS_FLAGS := $(AS_FLAGS) $(INC)\r
122 \r
123 PROJECT_DEP_FILE := $(PROJECT_OBJ_DIR)/$(PROJECT_NAME).dep\r
124 \r
125 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))\r
126 GENERATE_DEPS :=\r
127 else\r
128 \r
129 CC_DEPS  := $(addprefix __dep__,$(subst ../,__up__,$(CC_SRC)))\r
130 CPP_DEPS  := $(addprefix __dep__,$(subst ../,__up__,$(CPP_SRC)))\r
131 GENERATE_DEPS := generate_deps\r
132 endif\r
133 \r
134 all : welcome_line      $(PROJECT_BINARY)\r
135         @echo $(PROJECT_BINARY)\r
136 \r
137 .PHONY : clear_dep\r
138 clear_dep:\r
139         @$(RM) $(PROJECT_DEP_FILE)\r
140         @echo [DEP]   $(subst $(PROJECT_OBJ_DIR)/,,$(PROJECT_DEP_FILE))\r
141 \r
142 $(CC_DEPS) :\r
143         @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(PROJECT_OBJ_DIR)/$(patsubst %.c,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CC_FLAGS_FULL) >> $(PROJECT_DEP_FILE)\r
144 \r
145 $(CPP_DEPS) :\r
146         @$(CPP) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(PROJECT_OBJ_DIR)/$(patsubst %.cpp,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CPP_FLAGS_FULL) >> $(PROJECT_DEP_FILE)\r
147 \r
148 .PHONY : generate_deps\r
149 generate_deps : clear_dep $(CC_DEPS) $(CPP_DEPS)\r
150 \r
151 \r
152 .PHONY : echo_start_build\r
153 echo_start_build :\r
154         @echo [BUILD] $(PROJECT_TYPE) : $(PROJECT_NAME)\r
155 \r
156 $(DIRLIST) :\r
157         -@$(MD) $@\r
158 \r
159 $(CC_OBJTARGETS) :\r
160         @echo [CC]    $(subst $(PROJECT_OBJ_DIR)/,,$@)\r
161         @$(CC) -c $(CC_FLAGS_FULL) -o"$@" $(patsubst %.o,%.c,$(subst $(PROJECT_OBJ_DIR)/,,$@))\r
162 \r
163 $(CPP_OBJTARGETS) :\r
164         @echo [CPP]    $(subst $(PROJECT_OBJ_DIR)/,,$@)\r
165         @$(CPP) -c $(CPP_FLAGS_FULL) -o"$@" $(patsubst %.o,%.cpp,$(subst $(PROJECT_OBJ_DIR)/,,$@))\r
166 \r
167 $(AS_OBJTARGETS) :\r
168         @echo [AS]    $(subst $(PROJECT_OBJ_DIR)/,,$@)\r
169         @$(AS) $(AS_FLAGS) -o"$@" $(patsubst %.o,%.s,$(subst $(PROJECT_OBJ_DIR)/,,$@))\r
170 \r
171 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))\r
172 \r
173 include $(PROJECT_DEP_FILE)\r
174 \r
175 endif\r
176 \r
177 .PHONY: clean xclean\r
178 clean:\r
179         @echo [CLEAN]  : $(PROJECT_NAME)\r
180         @$(RM) $(CC_OBJTARGETS) $(CPP_OBJTARGETS) $(AS_OBJTARGETS)\r
181 \r
182 xclean: clean\r
183 ifneq ($(wildcard $(PROJECT_DIR)/$(PROJECT_MAKE)),)\r
184         @echo [XCLEAN] : $(PROJECT_NAME)\r
185         @$(RM) $(PROJECT_BINARY) $(PROJECT_BINARY_LIB) $(PROJECT_DEP_FILE)\r
186 endif\r
187 \r
188 .PHONY : welcome_line\r
189 welcome_line :\r
190         @echo $(MYCUSTOMSPACE)\r
191         @echo Building  $(PROJECT_BINARY)\r
192         @echo $(MYCUSTOMTAB)RTE_TARGET           = $(RTE_TARGET)\r
193         @echo $(MYCUSTOMSPACE)\r
194 \r
195 \r
196 .PHONY : debug release\r
197 \r
198 debug :  all\r
199 release :  all\r
200 \r
201 $(PROJECT_BINARY): $(DIRLIST) echo_start_build $(GENERATE_DEPS) $(PRE_BUILD) $(CC_OBJTARGETS) $(CPP_OBJTARGETS) $(AS_OBJTARGETS)\r
202         @echo "[LD] $@ "\r
203         @$(LD) -o $@ $(CC_OBJTARGETS) $(CPP_OBJTARGETS) $(AS_OBJTARGETS) $(LD_FLAGS) -Wl,-L $(BUILDDIR) -lrt -lpthread\r
204 \r
205 #@echo [APP]   $@\r
206 #@$(OBJDUMP) -d $(PROJECT_BINARY) > $(PROJECT_BINARY).asm\r