b6ba70393a49a9595564d1cd0c743ee960a6a67f
[o-du/phy.git] / wls_lib / test / mac / 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 ORANDIR           := $(DIR_WIRELESS_ORAN)
59 WLSDIR            := $(DIR_WIRELESS_WLS)
60 BUILDDIR          := ../build/mac
61 SRCDIR            := $(CURDIR)
62
63 wls_mac_app_dep_file = $(BUILDDIR)/dep_file
64
65 APP := ../bin/mac/mac_app
66
67 INC := \
68  $(WLSDIR) \
69  $(SRCDIR) \
70  $(RTE_SDK)/$(RTE_TARGET)/include \
71  $(ORANDIR)/include \
72  $(ORANDIR) \
73  #$(FLEXRANDIR)/source/nr5g/api \
74  #$(FLEXRANDIR)/source/common \
75
76 INC := $(addprefix -I,$(INC))
77  
78 DEFS := USE_WO_LOCK _GNU_SOURCE NR5G 
79
80 ifneq ($(PRINTDBG),)
81 DEFS := $(DEFS) PRINTF_DBG_OK
82 endif
83
84 ifeq ($(DEBUG_MODE),true)
85 DEFS := $(DEFS) DEBUG_MODE
86 endif
87
88 DEFS := $(addprefix -D,$(DEFS))
89
90 CFLAGS := -g -Wall -wd9 -Wno-deprecated-declarations -Wimplicit-function-declaration -fasm-blocks $(DEFS) $(INC)
91
92 ifeq ($(PRINTDBG),)
93 CFLAGS := $(CFLAGS) -Werror
94 endif
95
96 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
97 LDFLAGS := -g  -Wl,-lrt -Wl,-lpthread -Wl,-lhugetlbfs -Wl,-lm -Wl,-lnuma -L $(WLSDIR) -lwls
98
99 LINUX_WLS_MAC_APP_SRC := \
100         $(SRCDIR)/mac_main.c \
101         $(SRCDIR)/mac_wls.c \
102
103 OBJS := $(LINUX_WLS_MAC_APP_SRC:.c=.o)
104
105 PROJECT_OBJ_DIR = $(BUILDDIR)
106
107 OBJS := $(addprefix $(PROJECT_OBJ_DIR)/,$(OBJS))
108
109 DIRLIST := $(sort $(dir $(OBJS)))
110
111 CC_DEPS := $(addprefix __dep__,$(LINUX_WLS_MAC_APP_SRC))
112
113 GEN_DEP :=
114 ifeq ($(wildcard $(wls_mac_app_dep_file)),)
115 GEN_DEP := regenerate_dep
116 endif
117
118 .PHONY: $(APP)
119 $(APP): $(DIRLIST) echo_options $(GEN_DEP) $(OBJS)
120         @echo [LD] $(APP)
121         @$(CC) -o $(APP) $(OBJS) $(RTE_LIBS) $(LDFLAGS)
122 #       $(OBJDUMP) -d $(APP) > $(APP).asm
123
124 .PHONY : echo_options
125 echo_options:
126         @echo [CFLAGS]  $(CFLAGS)
127         @echo [LDFAGS]  $(LDFLAGS)
128
129
130 ifneq ($(wildcard $(wls_mac_app_dep_file)),)
131 include $(wls_mac_app_dep_file)
132 endif
133
134 $(DIRLIST) :
135         -@$(MD) $@
136
137 .PHONY : regenerate_dep
138 regenerate_dep : clean_dep echo_regeenrate_dep  $(CC_DEPS)
139
140 .PHONY: clean_dep
141 clean_dep:
142         $(RM) $(wls_mac_app_dep_file)
143
144 .PHONY : echo_regeenrate_dep
145 echo_regeenrate_dep:
146         @echo regenerating dep files
147
148
149 .PHONY : CC_DEPS
150 $(CC_DEPS):
151         @$(CC) -MM $(subst __dep__,,$@) -MT $(addprefix $(PROJECT_OBJ_DIR)/,$(patsubst %.c,%.o,$(subst __dep__,,$@))) $(CFLAGS) >> $(wls_mac_app_dep_file)
152
153 $(OBJS) : $(PROJECT_OBJ_DIR)/%.o: %.c
154         @echo [CC]    $(subst $(PROJECT_OBJ_DIR)/,,$@)
155         @echo "";echo $@
156         @echo "";echo $(subst $(PROJECT_OBJ_DIR)/,,$@)
157         @echo "";echo $(patsubst %.o,%.c,$(subst $(PROJECT_OBJ_DIR)/,,$@))
158         @echo ""
159         $(CC) -c $(CFLAGS) -o"$@" $(patsubst %.o,%.c,$(subst $(PROJECT_OBJ_DIR)/,,$@))
160
161
162 .PHONY: xclean
163 xclean : clean_dep
164         @$(RM) $(OBJS)
165         @$(RM) $(APP)
166         @$(RM) $(BUILDDIR)
167
168 .PHONY: clean
169 clean :
170         @$(RM) $(OBJS)
171         @$(RM) $(APP)
172