Luis Farias | 9d66fca | 2020-05-28 19:01:58 -0700 | [diff] [blame] | 1 | ############################################################################### |
| 2 | # |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 3 | # Copyright (c) 2021 Intel. |
Luis Farias | 9d66fca | 2020-05-28 19:01:58 -0700 | [diff] [blame] | 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 | |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 19 | MYCUSTOMTAB=' ' |
| 20 | MYCUSTOMSPACE='============================================================================================' |
| 21 | MYCUSTOMSPACE1='------------------------------------------------------------' |
| 22 | |
| 23 | ############################################################## |
| 24 | # Tools configuration |
| 25 | ############################################################## |
Luis Farias | 892daba | 2022-06-22 13:59:47 -0700 | [diff] [blame^] | 26 | ifeq ($(WIRELESS_SDK_TOOLCHAIN),icc) |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 27 | CC := icc |
Luis Farias | 892daba | 2022-06-22 13:59:47 -0700 | [diff] [blame^] | 28 | CPP := icpc |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 29 | AS := as |
| 30 | AR := ar |
| 31 | LD := icc |
Luis Farias | 892daba | 2022-06-22 13:59:47 -0700 | [diff] [blame^] | 32 | else ifeq ($(WIRELESS_SDK_TOOLCHAIN),icx) |
| 33 | CC := icx |
| 34 | CPP := icx |
| 35 | AS := as |
| 36 | AR := ar |
| 37 | LD := icx |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 38 | else |
Luis Farias | 892daba | 2022-06-22 13:59:47 -0700 | [diff] [blame^] | 39 | $(error "Please define WIRELESS_SDK_TOOLCHAIN environment variable") |
| 40 | endif |
| 41 | |
| 42 | ifeq ($(WIRELESS_SDK_TARGET_ISA),sse) |
| 43 | TARGET_PROCESSOR := -xSSE4.2 |
| 44 | else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx2) |
| 45 | TARGET_PROCESSOR := -xCORE-AVX2 |
| 46 | else ifeq ($(WIRELESS_SDK_TARGET_ISA),avx512) |
| 47 | TARGET_PROCESSOR := -xCORE-AVX512 |
| 48 | else ifeq ($(WIRELESS_SDK_TARGET_ISA),snc) |
| 49 | TARGET_PROCESSOR := -xicelake-server |
| 50 | else ifeq ($(WIRELESS_SDK_TARGET_ISA),spr) |
| 51 | TARGET_PROCESSOR := -march=sapphirerapids |
| 52 | endif |
| 53 | |
| 54 | ifeq ($(TARGET_PROCESSOR),) |
| 55 | $(error "Please define valid WIRELESS_SDK_TARGET_ISA environment variable $(WIRELESS_SDK_TARGET_ISA)") |
| 56 | endif |
| 57 | |
| 58 | OBJDUMP := objdump |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 59 | MD := mkdir -p |
| 60 | CP := cp -f |
| 61 | RM := rm -rf |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 62 | |
| 63 | PROJECT_NAME := libwls |
| 64 | PROJECT_TYPE := lib |
| 65 | PROJECT_DIR := ./ |
| 66 | BUILDDIR := make |
| 67 | PROJECT_BINARY := $(PROJECT_NAME).so |
| 68 | |
Luis Farias | 9d66fca | 2020-05-28 19:01:58 -0700 | [diff] [blame] | 69 | ifeq ($(RTE_SDK),) |
| 70 | $(error "Please define RTE_SDK environment variable") |
| 71 | endif |
Luis Farias | 9d66fca | 2020-05-28 19:01:58 -0700 | [diff] [blame] | 72 | |
Luis Farias | 892daba | 2022-06-22 13:59:47 -0700 | [diff] [blame^] | 73 | RTE_INC := $(shell PKG_CONFIG_PATH=/usr/lib64/pkgconfig:$(RTE_SDK)/build/meson-uninstalled pkgconf --cflags-only-I libdpdk) |
Luis Farias | 601bdea | 2020-06-16 15:31:32 -0700 | [diff] [blame] | 74 | |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 75 | CC_SRC = wls_lib_dpdk.c \ |
| 76 | syslib.c |
| 77 | |
| 78 | CC_FLAGS += -std=gnu11 -Wall -Wno-deprecated-declarations \ |
| 79 | -fdata-sections \ |
| 80 | -ffunction-sections \ |
| 81 | -g \ |
| 82 | -fPIC \ |
| 83 | -Wall \ |
| 84 | -Wimplicit-function-declaration \ |
Luis Farias | 892daba | 2022-06-22 13:59:47 -0700 | [diff] [blame^] | 85 | -g -O3 -mcmodel=large $(TARGET_PROCESSOR) |
Luis Farias | 2de9752 | 2022-03-17 20:01:53 -0700 | [diff] [blame] | 86 | |
| 87 | INC := -I$(RTE_INC) |
| 88 | DEF := |
| 89 | |
| 90 | AS_FLAGS := |
| 91 | AR_FLAGS := rc |
| 92 | |
| 93 | PROJECT_OBJ_DIR := $(BUILDDIR)/obj |
| 94 | |
| 95 | CC_OBJS := $(patsubst %.c,%.o,$(CC_SRC)) |
| 96 | AS_OBJS := $(patsubst %.s,%.o,$(AS_SRC)) |
| 97 | OBJS := $(CC_OBJS) $(AS_OBJS) $(LIBS) |
| 98 | DIRLIST := $(addprefix $(PROJECT_OBJ_DIR)/,$(sort $(dir $(OBJS)))) |
| 99 | |
| 100 | CC_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(CC_OBJS)) |
| 101 | |
| 102 | AS_OBJTARGETS := $(addprefix $(PROJECT_OBJ_DIR)/,$(AS_OBJS)) |
| 103 | CC_FLAGS_FULL := $(CC_FLAGS) $(INC) $(DEF) |
| 104 | |
| 105 | AS_FLAGS := $(AS_FLAGS) $(INC) |
| 106 | |
| 107 | PROJECT_DEP_FILE := $(PROJECT_OBJ_DIR)/$(PROJECT_NAME).dep |
| 108 | |
| 109 | ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE)) |
| 110 | GENERATE_DEPS := |
| 111 | else |
| 112 | |
| 113 | CC_DEPS := $(addprefix __dep__,$(subst ../,__up__,$(CC_SRC))) |
| 114 | GENERATE_DEPS := generate_deps |
| 115 | endif |
| 116 | |
| 117 | all : welcome_line $(PROJECT_BINARY) |
| 118 | @echo $(PROJECT_BINARY) |
| 119 | |
| 120 | .PHONY : clear_dep |
| 121 | clear_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 |
| 129 | generate_deps : clear_dep $(CC_DEPS) |
| 130 | |
| 131 | |
| 132 | .PHONY : echo_start_build |
| 133 | echo_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 | |
| 147 | ifeq ($(wildcard $(PROJECT_DEP_FILE)),$(PROJECT_DEP_FILE)) |
| 148 | |
| 149 | include $(PROJECT_DEP_FILE) |
| 150 | |
| 151 | endif |
| 152 | |
| 153 | .PHONY: clean xclean |
| 154 | clean: |
| 155 | @echo [CLEAN] : $(PROJECT_NAME) |
| 156 | @$(RM) $(CC_OBJTARGETS) $(AS_OBJTARGETS) |
| 157 | ifneq ($(wildcard $(PROJECT_DIR)/$(PROJECT_MAKE)),) |
| 158 | @echo [CLEAN] : $(PROJECT_NAME) |
| 159 | @$(RM) $(PROJECT_BINARY) $(PROJECT_BINARY_LIB) $(PROJECT_DEP_FILE) |
| 160 | endif |
| 161 | |
| 162 | xclean: clean |
| 163 | |
| 164 | .PHONY : welcome_line |
| 165 | welcome_line : |
| 166 | @echo $(MYCUSTOMSPACE) |
| 167 | @echo Building $(PROJECT_BINARY) |
| 168 | @echo $(MYCUSTOMSPACE) |
| 169 | |
| 170 | .PHONY : debug release |
| 171 | |
| 172 | debug : all |
| 173 | release : 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 | |