blob: 2f8e4b269c1e2f543a024ed88d3dcf66558673d5 [file] [log] [blame]
Luis Farias9d66fca2020-05-28 19:01:58 -07001###############################################################################
2#
Luis Farias2de97522022-03-17 20:01:53 -07003# Copyright (c) 2021 Intel.
Luis Farias9d66fca2020-05-28 19:01:58 -07004#
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
Luis Farias2de97522022-03-17 20:01:53 -070019MYCUSTOMTAB=' '
20MYCUSTOMSPACE='============================================================================================'
21MYCUSTOMSPACE1='------------------------------------------------------------'
22
23##############################################################
24# Tools configuration
25##############################################################
Luis Farias892daba2022-06-22 13:59:47 -070026ifeq ($(WIRELESS_SDK_TOOLCHAIN),icc)
Luis Farias2de97522022-03-17 20:01:53 -070027CC := icc
Luis Farias892daba2022-06-22 13:59:47 -070028 CPP := icpc
Luis Farias2de97522022-03-17 20:01:53 -070029AS := as
30AR := ar
31LD := icc
Luis Farias892daba2022-06-22 13:59:47 -070032else ifeq ($(WIRELESS_SDK_TOOLCHAIN),icx)
33 CC := icx
34 CPP := icx
35 AS := as
36 AR := ar
37 LD := icx
Luis Farias2de97522022-03-17 20:01:53 -070038else
Luis Farias892daba2022-06-22 13:59:47 -070039 $(error "Please define WIRELESS_SDK_TOOLCHAIN environment variable")
40endif
41
42ifeq ($(WIRELESS_SDK_TARGET_ISA),sse)
43 TARGET_PROCESSOR := -xSSE4.2
44else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx2)
45 TARGET_PROCESSOR := -xCORE-AVX2
46else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx512)
47 TARGET_PROCESSOR := -xCORE-AVX512
48else ifeq ($(WIRELESS_SDK_TARGET_ISA),snc)
49 TARGET_PROCESSOR := -xicelake-server
50else ifeq ($(WIRELESS_SDK_TARGET_ISA),spr)
51 TARGET_PROCESSOR := -march=sapphirerapids
52endif
53
54ifeq ($(TARGET_PROCESSOR),)
55 $(error "Please define valid WIRELESS_SDK_TARGET_ISA environment variable $(WIRELESS_SDK_TARGET_ISA)")
56endif
57
58OBJDUMP := objdump
Luis Farias2de97522022-03-17 20:01:53 -070059MD := mkdir -p
60CP := cp -f
61RM := rm -rf
Luis Farias2de97522022-03-17 20:01:53 -070062
63PROJECT_NAME := libwls
64PROJECT_TYPE := lib
65PROJECT_DIR := ./
66BUILDDIR := make
67PROJECT_BINARY := $(PROJECT_NAME).so
68
Luis Farias9d66fca2020-05-28 19:01:58 -070069ifeq ($(RTE_SDK),)
70$(error "Please define RTE_SDK environment variable")
71endif
Luis Farias9d66fca2020-05-28 19:01:58 -070072
Luis Farias892daba2022-06-22 13:59:47 -070073RTE_INC := $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --cflags-only-I libdpdk)
Luis Farias601bdea2020-06-16 15:31:32 -070074
Luis Farias2de97522022-03-17 20:01:53 -070075CC_SRC = wls_lib_dpdk.c \
76 syslib.c
77
78CC_FLAGS += -std=gnu11 -Wall -Wno-deprecated-declarations \
79 -fdata-sections \
80 -ffunction-sections \
81 -g \
82 -fPIC \
83 -Wall \
84 -Wimplicit-function-declaration \
Luis Farias892daba2022-06-22 13:59:47 -070085 -g -O3 -mcmodel=large $(TARGET_PROCESSOR)
Luis Farias2de97522022-03-17 20:01:53 -070086
87INC := -I$(RTE_INC)
88DEF :=
89
90AS_FLAGS :=
91AR_FLAGS := rc
92
93PROJECT_OBJ_DIR := $(BUILDDIR)/obj
94
95CC_OBJS := $(patsubst %.c,%.o,$(CC_SRC))
96AS_OBJS := $(patsubst %.s,%.o,$(AS_SRC))
97OBJS := $(CC_OBJS) $(AS_OBJS) $(LIBS)
98DIRLIST := $(addprefix $(PROJECT_OBJ_DIR)/,$(sort $(dir $(OBJS))))
99
100CC_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(CC_OBJS))
101
102AS_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(AS_OBJS))
103CC_FLAGS_FULL := $(CC_FLAGS) $(INC) $(DEF)
104
105AS_FLAGS := $(AS_FLAGS) $(INC)
106
107PROJECT_DEP_FILE := $(PROJECT_OBJ_DIR)/$(PROJECT_NAME).dep
108
109ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
110GENERATE_DEPS :=
111else
112
113CC_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CC_SRC)))
114GENERATE_DEPS := generate_deps
115endif
116
117all : welcome_line $(PROJECT_BINARY)
118 @echo $(PROJECT_BINARY)
119
120.PHONY : clear_dep
121clear_dep:
122 @$(RM) $(PROJECT_DEP_FILE)
123 @echo [DEP] $(subst $(PROJECT_OBJ_DIR)/,,$(PROJECT_DEP_FILE))
124
125$(CC_DEPS) :
126 @$(CC) -MM $(subst __up__,../,$(subst __dep__,,$@)) -MT $(PROJECT_OBJ_DIR)/$(patsubst %.c,%.o,$(subst __up__,../,$(subst __dep__,,$@))) $(CC_FLAGS_FULL) >> $(PROJECT_DEP_FILE)
127
128.PHONY : generate_deps
129generate_deps : clear_dep $(CC_DEPS)
130
131
132.PHONY : echo_start_build
133echo_start_build :
134 @echo [BUILD] $(PROJECT_TYPE) : $(PROJECT_NAME)
135
136$(DIRLIST) :
137 -@$(MD) $@
138
139$(CC_OBJTARGETS) :
140 @echo [CC] $(subst $(PROJECT_OBJ_DIR)/,,$@)
141 @$(CC) -c $(CC_FLAGS_FULL) -o"$@" $(patsubst %.o,%.c,$(subst $(PROJECT_OBJ_DIR)/,,$@))
142
143$(AS_OBJTARGETS) :
144 @echo [AS] $(subst $(PROJECT_OBJ_DIR)/,,$@)
145 @$(AS) $(AS_FLAGS) -o"$@" $(patsubst %.o,%.s,$(subst $(PROJECT_OBJ_DIR)/,,$@))
146
147ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE))
148
149include $(PROJECT_DEP_FILE)
150
151endif
152
153.PHONY: clean xclean
154clean:
155 @echo [CLEAN] : $(PROJECT_NAME)
156 @$(RM) $(CC_OBJTARGETS) $(AS_OBJTARGETS)
157ifneq ($(wildcard $(PROJECT_DIR)/$(PROJECT_MAKE)),)
158 @echo [CLEAN] : $(PROJECT_NAME)
159 @$(RM) $(PROJECT_BINARY) $(PROJECT_BINARY_LIB) $(PROJECT_DEP_FILE)
160endif
161
162xclean: clean
163
164.PHONY : welcome_line
165welcome_line :
166 @echo $(MYCUSTOMSPACE)
167 @echo Building $(PROJECT_BINARY)
168 @echo $(MYCUSTOMSPACE)
169
170.PHONY : debug release
171
172debug : all
173release : all
174
175$(PROJECT_BINARY) : $(DIRLIST) echo_start_build $(GENERATE_DEPS) $(PRE_BUILD) $(CC_OBJTARGETS) $(AS_OBJTARGETS)
176 @echo [AR] $(subst $(BUILDDIR)/,,$@)
177 @$(CC) $(CC_OBJTARGETS) $(AS_OBJTARGETS) -shared -fPIC -o $@
178