O-RAN E Maintenance Release contribution for ODULOW
[o-du/phy.git] / wls_lib / testapp / 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 MYCUSTOMTAB='     '
20 MYCUSTOMSPACE='============================================================================================'
21 MYCUSTOMSPACE1='------------------------------------------------------------'
22
23 ##############################################################
24 #  Tools configuration
25 ##############################################################
26 CC  := icc
27 AS := as
28 AR := ar
29 LD := icc
30 OBJDUMP := objdump
31
32 ifeq ($(SHELL),cmd.exe)
33 MD := mkdir.exe -p
34 CP := cp.exe -f
35 RM := rm.exe -rf
36 else
37 MD := mkdir -p
38 CP := cp -f
39 RM := rm -rf
40 endif
41
42 PROJECT_NAME := wls_test
43 PROJECT_TYPE := elf
44 PROJECT_DIR  := ./
45 BUILDDIR := make
46 PROJECT_BINARY := $(PROJECT_NAME)
47
48 ifeq ($(RTE_SDK),)
49 $(error "Please define RTE_SDK environment variable")
50 endif
51
52 ifeq ($(MESON_BUILD),0)
53 RTE_INC := $(RTE_SDK)/$(RTE_TARGET)/include
54 RTE_LIBS := -L$(RTE_SDK)/$(RTE_TARGET)/lib -Wl,--whole-archive -Wl,-lrte_mempool_ring -Wl,-lrte_pci -Wl,-lrte_bus_pci -Wl,-lrte_bus_vdev -Wl,-lrte_net -Wl,-lrte_distributor -Wl,-lrte_reorder -Wl,-lrte_kni -Wl,-lrte_pipeline -Wl,-lrte_table -Wl,-lrte_timer -Wl,-lrte_hash -Wl,-lrte_jobstats -Wl,-lrte_lpm -Wl,-lrte_power -Wl,-lrte_acl -Wl,-lrte_meter -Wl,-lrte_sched -Wl,-lrte_vhost -Wl,--start-group -Wl,-lrte_kvargs -Wl,-lrte_mbuf -Wl,-lrte_ip_frag -Wl,-lrte_ethdev -Wl,-lrte_cryptodev -Wl,-lrte_mempool -Wl,-lrte_ring -Wl,-lrte_eal -Wl,-lrte_cmdline -Wl,-lrte_cfgfile -Wl,-lrte_pmd_bond -Wl,-lrte_pmd_vmxnet3_uio -Wl,-lrte_pmd_virtio -Wl,-lrte_pmd_cxgbe -Wl,-lrte_pmd_enic -Wl,-lrte_pmd_i40e -Wl,-lrte_pmd_fm10k -Wl,-lrte_pmd_ixgbe -Wl,-lrte_pmd_e1000 -Wl,-lrte_pmd_ring -Wl,-lrte_pmd_af_packet -Wl,-lrte_pmd_null -Wl,-lrt -Wl,-lm -Wl,-ldl -Wl,--end-group -Wl,--no-whole-archive
55 RTE_LIBS += -Wl,--whole-archive -Wl,/usr/lib64/libnuma.so -Wl,--no-whole-archive
56 else
57 RTE_INC := $(shell PKG_CONFIG_PATH=$(RTE_SDK)/build/meson-uninstalled pkg-config --cflags-only-I libdpdk)
58 RTE_LIBS := -Wl,--whole-archive -Wl,/usr/lib64/libnuma.so -Wl,--as-needed -pthread -L$(RTE_SDK)/build/drivers -L$(RTE_SDK)/build/lib -l:librte_common_cpt.a -l:librte_common_dpaax.a -l:librte_common_iavf.a -l:librte_common_octeontx.a -l:librte_common_octeontx2.a -l:librte_common_sfc_efx.a -l:librte_bus_dpaa.a -l:librte_bus_fslmc.a -l:librte_bus_ifpga.a -l:librte_bus_pci.a -l:librte_bus_vdev.a -l:librte_bus_vmbus.a -l:librte_mempool_bucket.a -l:librte_mempool_dpaa.a -l:librte_mempool_dpaa2.a -l:librte_mempool_octeontx.a -l:librte_mempool_octeontx2.a -l:librte_mempool_ring.a -l:librte_mempool_stack.a -l:librte_net_af_packet.a -l:librte_net_ark.a -l:librte_net_atlantic.a -l:librte_net_avp.a -l:librte_net_axgbe.a -l:librte_net_bond.a -l:librte_net_bnx2x.a -l:librte_net_bnxt.a -l:librte_net_cxgbe.a -l:librte_net_dpaa.a -l:librte_net_dpaa2.a -l:librte_net_e1000.a -l:librte_net_ena.a -l:librte_net_enetc.a -l:librte_net_enic.a -l:librte_net_failsafe.a -l:librte_net_fm10k.a -l:librte_net_i40e.a -l:librte_net_hinic.a -l:librte_net_hns3.a -l:librte_net_iavf.a -l:librte_net_ice.a -l:librte_net_igc.a -l:librte_net_ixgbe.a -l:librte_net_kni.a -l:librte_net_liquidio.a -l:librte_net_memif.a -l:librte_net_netvsc.a -l:librte_net_nfp.a -l:librte_net_null.a -l:librte_net_octeontx.a -l:librte_net_octeontx2.a -l:librte_net_pfe.a -l:librte_net_qede.a -l:librte_net_ring.a -l:librte_net_sfc.a -l:librte_net_tap.a -l:librte_net_thunderx.a -l:librte_net_txgbe.a -l:librte_net_vdev_netvsc.a -l:librte_net_vhost.a -l:librte_net_virtio.a -l:librte_net_vmxnet3.a -l:librte_raw_dpaa2_cmdif.a -l:librte_raw_dpaa2_qdma.a -l:librte_raw_ioat.a -l:librte_raw_ntb.a -l:librte_raw_octeontx2_dma.a -l:librte_raw_octeontx2_ep.a -l:librte_raw_skeleton.a -l:librte_crypto_bcmfs.a -l:librte_crypto_caam_jr.a -l:librte_crypto_dpaa_sec.a -l:librte_crypto_dpaa2_sec.a -l:librte_crypto_nitrox.a -l:librte_crypto_null.a -l:librte_crypto_octeontx.a -l:librte_crypto_octeontx2.a -l:librte_crypto_scheduler.a -l:librte_crypto_virtio.a -l:librte_compress_octeontx.a -l:librte_compress_zlib.a -l:librte_regex_octeontx2.a -l:librte_vdpa_ifc.a -l:librte_event_dlb.a -l:librte_event_dlb2.a -l:librte_event_dpaa.a -l:librte_event_dpaa2.a -l:librte_event_octeontx2.a -l:librte_event_opdl.a -l:librte_event_skeleton.a -l:librte_event_sw.a -l:librte_event_dsw.a -l:librte_event_octeontx.a -l:librte_node.a -l:librte_graph.a -l:librte_bpf.a -l:librte_flow_classify.a -l:librte_pipeline.a -l:librte_table.a -l:librte_fib.a -l:librte_ipsec.a -l:librte_vhost.a -l:librte_stack.a -l:librte_security.a -l:librte_sched.a -l:librte_reorder.a -l:librte_rib.a -l:librte_regexdev.a -l:librte_rawdev.a -l:librte_pdump.a -l:librte_power.a -l:librte_member.a -l:librte_lpm.a -l:librte_latencystats.a -l:librte_kni.a -l:librte_jobstats.a -l:librte_ip_frag.a -l:librte_gso.a -l:librte_gro.a -l:librte_eventdev.a -l:librte_efd.a -l:librte_distributor.a -l:librte_cryptodev.a -l:librte_compressdev.a -l:librte_cfgfile.a -l:librte_bitratestats.a -l:librte_bbdev.a -l:librte_acl.a -l:librte_timer.a -l:librte_hash.a -l:librte_metrics.a -l:librte_cmdline.a -l:librte_pci.a -l:librte_ethdev.a -l:librte_meter.a -l:librte_net.a -l:librte_mbuf.a -l:librte_mempool.a -l:librte_rcu.a -l:librte_ring.a -l:librte_eal.a -l:librte_telemetry.a -l:librte_kvargs.a -lelf -lrte_node -lrte_graph -lrte_bpf -lrte_flow_classify -lrte_pipeline -lrte_table -lrte_fib -lrte_ipsec -lrte_vhost -lrte_stack -lrte_security -lrte_sched -lrte_reorder -lrte_rib -lrte_regexdev -lrte_rawdev -lrte_pdump -lrte_power -lrte_member -lrte_lpm -lrte_latencystats -lrte_kni -lrte_jobstats -lrte_ip_frag -lrte_gso -lrte_gro -lrte_eventdev -lrte_efd -lrte_distributor -lrte_cryptodev -lrte_compressdev -lrte_cfgfile -lrte_bitratestats -lrte_bbdev -lrte_acl -lrte_timer -lrte_hash -lrte_metrics -lrte_cmdline -lrte_pci -lrte_ethdev -lrte_meter -lrte_net -lrte_mbuf -lrte_mempool -lrte_rcu -lrte_ring -lrte_eal -lrte_telemetry -lrte_kvargs -lm -ldl -lnuma -lz -Wl,--no-whole-archive
59 endif
60
61 CC_SRC = pool.c \
62         testapp.c
63
64 CC_FLAGS += -std=gnu11 -Wall -Wno-deprecated-declarations  \
65         -fdata-sections \
66         -ffunction-sections \
67         -g \
68         -Wall \
69         -Wimplicit-function-declaration \
70         -g -O3 -wd1786 -mcmodel=large
71
72 INC :=  -I../ -I$(RTE_INC)
73 DEF :=
74
75 WLS_LIB_DIR=../
76 LD_FLAGS += -L$(WLS_LIB_DIR) -lwls -lpthread -lhugetlbfs -lrt
77
78 LD_FLAGS += $(RTE_LIBS)
79
80 AS_FLAGS :=
81 AR_FLAGS := rc
82
83 PROJECT_OBJ_DIR := $(BUILDDIR)/obj
84
85 CC_OBJS := $(patsubst %.c,%.o,$(CC_SRC))
86 AS_OBJS := $(patsubst %.s,%.o,$(AS_SRC))
87 OBJS    := $(CC_OBJS) $(AS_OBJS) $(LIBS)
88 DIRLIST := $(addprefix $(PROJECT_OBJ_DIR)/,$(sort $(dir $(OBJS))))
89
90 CC_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(CC_OBJS))
91
92 AS_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(AS_OBJS))
93
94 CC_FLAGS_FULL  := $(CC_FLAGS)  $(INC) $(DEF)
95
96 AS_FLAGS := $(AS_FLAGS) $(INC)
97
98 PROJECT_DEP_FILE := $(PROJECT_OBJ_DIR)/$(PROJECT_NAME).dep
99
100 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
101 GENERATE_DEPS :=
102 else
103
104 CC_DEPS  := $(addprefix __dep__,$(subst ../,__up__,$(CC_SRC)))
105 GENERATE_DEPS := generate_deps
106 endif
107
108 all : welcome_line      $(PROJECT_BINARY)
109         @echo $(PROJECT_BINARY)
110
111 .PHONY : clear_dep
112 clear_dep:
113         @$(RM) $(PROJECT_DEP_FILE)
114         @echo [DEP]   $(subst $(PROJECT_OBJ_DIR)/,,$(PROJECT_DEP_FILE))
115
116 $(CC_DEPS) :
117         @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(PROJECT_OBJ_DIR)/$(patsubst %.c,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CC_FLAGS_FULL) >> $(PROJECT_DEP_FILE)
118
119 .PHONY : generate_deps
120 generate_deps : clear_dep $(CC_DEPS)
121
122
123 .PHONY : echo_start_build
124 echo_start_build :
125         @echo [BUILD] $(PROJECT_TYPE) : $(PROJECT_NAME)
126
127 $(DIRLIST) :
128         -@$(MD) $@
129
130 $(CC_OBJTARGETS) :
131         @echo [CC]    $(subst $(PROJECT_OBJ_DIR)/,,$@)
132         @$(CC) -c $(CC_FLAGS_FULL) -o"$@" $(patsubst %.o,%.c,$(subst $(PROJECT_OBJ_DIR)/,,$@))
133
134 $(AS_OBJTARGETS) :
135         @echo [AS]    $(subst $(PROJECT_OBJ_DIR)/,,$@)
136         @$(AS) $(AS_FLAGS) -o"$@" $(patsubst %.o,%.s,$(subst $(PROJECT_OBJ_DIR)/,,$@))
137
138 ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
139
140 include $(PROJECT_DEP_FILE)
141
142 endif
143
144 .PHONY: clean xclean
145 clean:
146         @echo [CLEAN]  : $(PROJECT_NAME)
147         @$(RM) $(CC_OBJTARGETS) $(AS_OBJTARGETS)
148 ifneq ($(wildcard $(PROJECT_DIR)/$(PROJECT_MAKE)),)
149         @echo [CLEAN] : $(PROJECT_NAME)
150         @$(RM) $(PROJECT_BINARY) $(PROJECT_BINARY_LIB) $(PROJECT_DEP_FILE)
151 endif
152
153 xclean: clean
154
155 .PHONY : welcome_line
156 welcome_line :
157         @echo $(MYCUSTOMSPACE)
158         @echo Building  $(PROJECT_BINARY)
159         @echo $(MYCUSTOMSPACE)
160
161
162 .PHONY : debug release
163
164 debug :  all
165 release :  all
166
167 $(PROJECT_BINARY): $(DIRLIST) echo_start_build $(GENERATE_DEPS) $(PRE_BUILD) $(CC_OBJTARGETS) $(AS_OBJTARGETS)
168         @echo "[LD] $@ "
169         @$(LD) -o $@ $(CC_OBJTARGETS) $(AS_OBJTARGETS) $(LD_FLAGS) -Wl,-L $(BUILDDIR)
170
171 #@echo [APP]   $@
172 #@$(OBJDUMP) -d $(PROJECT_BINARY) > $(PROJECT_BINARY).asm
173