aboutsummaryrefslogtreecommitdiffstats
path: root/mk
diff options
context:
space:
mode:
authorKonstantin Ananyev <konstantin.ananyev@intel.com>2021-09-30 10:05:39 +0000
committerKonstantin Ananyev <konstantin.ananyev@intel.com>2021-11-10 11:55:12 +0000
commitb792c1f27d58040f3a815da18183d329bd6bd84b (patch)
treedef302a01c2136211651fb90994806ae1ff0a32a /mk
parentf71107b4dd6a4b8b1cd28d7339c924f1b013cfa4 (diff)
tldk: swtich to use DPDK 20.11 LTS
As in DPDK 20.11 'make' is not supported any more, switch to use pkg-conf approach. Note that RTE_SDK now should point to your DPDK package installation path. Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com> Change-Id: I4a3c394758e183a3ddcdb45a0562a81583daaab6 Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Diffstat (limited to 'mk')
-rw-r--r--mk/tle.app.mk55
-rw-r--r--mk/tle.cpp-obj.mk97
-rw-r--r--mk/tle.cpp-pre.mk91
-rw-r--r--mk/tle.cpp-vars.mk45
-rw-r--r--mk/tle.lib.mk53
-rw-r--r--mk/tle.subdir.mk5
-rw-r--r--mk/tle.var.mk58
7 files changed, 135 insertions, 269 deletions
diff --git a/mk/tle.app.mk b/mk/tle.app.mk
index 602b870..60031da 100644
--- a/mk/tle.app.mk
+++ b/mk/tle.app.mk
@@ -11,26 +11,47 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-EXTLIB_BUILD := y
+APP_SHARED = $(APP_NAME)-shared
+APP_STATIC = $(APP_NAME)-static
-# we must create the output dir first and recall the same Makefile
-# from this directory
-ifeq ($(NOT_FIRST_CALL),)
+ifneq ($(LIB_DEPS),)
+ LDLIBS += -L$(RTE_OUTPUT)/lib
+ LDLIBS_SHARED += $(patsubst %,-l%,$(LIB_DEPS))
+ LDLIBS_STATIC += $(patsubst %,-l:lib%.a,$(LIB_DEPS))
+ LDFLAGS_SHARED += $(LDLIBS) $(LDLIBS_SHARED)
+ LDFLAGS_STATIC += $(LDLIBS) $(LDLIBS_STATIC)
+endif
+
+.PHONY: all clean static shared
+all: shared static
+shared: $(RTE_OUTPUT)/app/$(APP_SHARED)
+static: $(RTE_OUTPUT)/app/$(APP_STATIC)
+
+OBJS += $(patsubst %.c,$(BDIR)/%.o,$(SRCS-y))
-NOT_FIRST_CALL = 1
-export NOT_FIRST_CALL
+$(BDIR)/%.o: %.c Makefile $(PC_FILE)
+ @mkdir -p $(BDIR)
+ $(Q)$(CC) $(CFLAGS) $(CFLAGS_$(<)) -c $< -o $@
-BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR)
+SCRIPTS := $(patsubst %,$(RTE_OUTPUT)/app/%,$(SYMLINK-y-app))
-all:
- $(Q)mkdir -p $(BDIR)
- $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \
- S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
+$(RTE_OUTPUT)/app/%.py: %.py Makefile
+ $(Q)ln -s -f $(RTE_SRCDIR)/$< $@
+
+clean:
+ $(Q)rm -f $(RTE_OUTPUT)/app/$(APP_SHARED)
+ $(Q)rm -f $(RTE_OUTPUT)/app/$(APP_STATIC)
+ $(Q)rm -f $(RTE_OUTPUT)/app/$(APP_NAME)
+ $(Q)rm -f $(SCRIPTS)
+ $(Q)rm -rf $(BDIR)
+
+$(RTE_OUTPUT)/app/$(APP_SHARED): $(SCRIPTS) $(OBJS) Makefile $(PC_FILE)
+ifneq ($(OBJS),)
+ $(Q)$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_SHARED)
+endif
-%::
- $(Q)mkdir -p $(BDIR)
- $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \
- S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
-else
-include $(RTE_SDK)/mk/rte.app.mk
+$(RTE_OUTPUT)/app/$(APP_STATIC): $(SCRIPTS) $(OBJS) Makefile $(PC_FILE)
+ifneq ($(OBJS),)
+ $(Q)$(CC) $(OBJS) -o $@ $(LDFLAGS) $(LDFLAGS_STATIC)
+ $(Q)ln -s -f $@ $(RTE_OUTPUT)/app/$(APP_NAME)
endif
diff --git a/mk/tle.cpp-obj.mk b/mk/tle.cpp-obj.mk
deleted file mode 100644
index 4d8a484..0000000
--- a/mk/tle.cpp-obj.mk
+++ /dev/null
@@ -1,97 +0,0 @@
-# Copyright (c) 2016 Intel Corporation.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-include $(RTE_SDK)/mk/internal/rte.compile-pre.mk
-include $(RTE_SDK)/mk/internal/rte.install-pre.mk
-include $(RTE_SDK)/mk/internal/rte.clean-pre.mk
-include $(RTE_SDK)/mk/internal/rte.build-pre.mk
-include $(TLDK_ROOT)/mk/tle.cpp-pre.mk
-
-#
-# copy of rte.obj.mk starts here
-#
-
-# VPATH contains at least SRCDIR
-VPATH += $(SRCDIR)
-
-ifneq ($(OBJ),)
-_BUILD = $(OBJ)
-else
-_BUILD = $(OBJS-y)
-endif
-_INSTALL = $(INSTALL-FILES-y) $(SYMLINK-FILES-y)
-_CLEAN = doclean
-
-.PHONY: all
-all: install
-
-.PHONY: install
-install: build _postinstall
-
-_postinstall: build
-
-.PHONY: build
-build: _postbuild
-
-ifneq ($(OBJ),)
-exe2cmd = $(strip $(call dotfile,$(patsubst %,%.cmd,$(1))))
-
-O_TO_O = $(LD) $(CPU_LDFLAGS) -r -o $(OBJ) $(OBJS-y)
-O_TO_O_STR = $(subst ','\'',$(O_TO_O)) #'# fix syntax highlight
-O_TO_O_DISP = $(if $(V),"$(O_TO_O_STR)"," LD $(@)")
-O_TO_O_CMD = "cmd_$@ = $(O_TO_O_STR)"
-O_TO_O_DO = @set -e; \
- echo $(O_TO_O_DISP); \
- $(O_TO_O) && \
- echo $(O_TO_O_CMD) > $(call exe2cmd,$(@))
-
--include .$(OBJ).cmd
-
-#
-# Archive objects in .a file if needed
-#
-$(OBJ): $(OBJS-y) FORCE
- @[ -d $(dir $@) ] || mkdir -p $(dir $@)
- $(if $(D),\
- @echo -n "$< -> $@ " ; \
- echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
- echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(O_TO_O_STR))) " ; \
- echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
- echo "depfile_newer=$(call boolean,$(depfile_newer)) ")
- $(if $(or \
- $(file_missing),\
- $(call cmdline_changed,$(O_TO_O_STR)),\
- $(depfile_missing),\
- $(depfile_newer)),\
- $(O_TO_O_DO))
-endif
-
-#
-# Clean all generated files
-#
-.PHONY: clean
-clean: _postclean
-
-.PHONY: doclean
-doclean:
- @rm -rf $(OBJ) $(OBJS-all) $(DEPS-all) $(DEPSTMP-all) \
- $(CMDS-all) $(INSTALL-FILES-all)
- @rm -f $(_BUILD_TARGETS) $(_INSTALL_TARGETS) $(_CLEAN_TARGETS)
-
-include $(RTE_SDK)/mk/internal/rte.compile-post.mk
-include $(RTE_SDK)/mk/internal/rte.install-post.mk
-include $(RTE_SDK)/mk/internal/rte.clean-post.mk
-include $(RTE_SDK)/mk/internal/rte.build-post.mk
-
-.PHONY: FORCE
-FORCE:
diff --git a/mk/tle.cpp-pre.mk b/mk/tle.cpp-pre.mk
deleted file mode 100644
index ae7748b..0000000
--- a/mk/tle.cpp-pre.mk
+++ /dev/null
@@ -1,91 +0,0 @@
-# Copyright (c) 2016 Intel Corporation.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# convert source to obj file
-src2obj = $(strip $(patsubst %.cpp,%.o,\
- $(patsubst %.S,%_s.o,$(1))))
-
-# add a dot in front of the file name
-dotfile = $(strip $(foreach f,$(1),\
- $(join $(dir $f),.$(notdir $f))))
-
-# convert source/obj files into dot-dep filename (does not
-# include .S files)
-src2dep = $(strip $(call dotfile,$(patsubst %.cpp,%.o.d, \
- $(patsubst %.S,,$(1)))))
-obj2dep = $(strip $(call dotfile,$(patsubst %.o,%.o.d,$(1))))
-
-# convert source/obj files into dot-cmd filename
-src2cmd = $(strip $(call dotfile,$(patsubst %.cpp,%.o.cmd, \
- $(patsubst %.S,%_s.o.cmd,$(1)))))
-obj2cmd = $(strip $(call dotfile,$(patsubst %.o,%.o.cmd,$(1))))
-
-OBJS-y := $(call src2obj,$(SRCS-y))
-OBJS-n := $(call src2obj,$(SRCS-n))
-OBJS- := $(call src2obj,$(SRCS-))
-OBJS-all := $(filter-out $(SRCS-all),$(OBJS-y) $(OBJS-n) $(OBJS-))
-
-DEPS-y := $(call src2dep,$(SRCS-y))
-DEPS-n := $(call src2dep,$(SRCS-n))
-DEPS- := $(call src2dep,$(SRCS-))
-DEPS-all := $(DEPS-y) $(DEPS-n) $(DEPS-)
-DEPSTMP-all := $(DEPS-all:%.d=%.d.tmp)
-
-CMDS-y := $(call src2cmd,$(SRCS-y))
-CMDS-n := $(call src2cmd,$(SRCS-n))
-CMDS- := $(call src2cmd,$(SRCS-))
-CMDS-all := $(CMDS-y) $(CMDS-n) $(CMDS-)
-
--include $(DEPS-y) $(CMDS-y)
-
-# command to compile a .cpp file to generate an object
-ifeq ($(USE_HOST),1)
-CXX_TO_O = $(HOSTCXX) -Wp,-MD,$(call obj2dep,$(@)).tmp $(HOST_CXXFLAGS) \
- $(CXXFLAGS_$(@)) $(HOST_EXTRA_CXXFLAGS) -o $@ -c $<
-CXX_TO_O_STR = $(subst ','\'',$(CXX_TO_O)) #'# fix syntax highlight
-CXX_TO_O_DISP = $(if $(V),"$(CXX_TO_O_STR)"," HOSTCXX $(@)")
-else
-CXX_TO_O = $(CXX) -Wp,-MD,$(call obj2dep,$(@)).tmp $(CXXFLAGS) \
- $(CXXFLAGS_$(@)) $(EXTRA_CXXFLAGS) -o $@ -c $<
-CXX_TO_O_STR = $(subst ','\'',$(CXX_TO_O)) #'# fix syntax highlight
-CXX_TO_O_DISP = $(if $(V),"$(CXX_TO_O_STR)"," CXX $(@)")
-endif
-CXX_TO_O_CMD = 'cmd_$@ = $(CXX_TO_O_STR)'
-CXX_TO_O_DO = @set -e; \
- echo $(CXX_TO_O_DISP); \
- $(CXX_TO_O) && \
- echo $(CXX_TO_O_CMD) > $(call obj2cmd,$(@)) && \
- sed 's,'$@':,dep_'$@' =,' $(call obj2dep,$(@)).tmp > $(call obj2dep,$(@)) && \
- rm -f $(call obj2dep,$(@)).tmp
-
-#
-# Compile .cpp file if needed
-# Note: dep_$$@ is from the .d file and DEP_$$@ can be specified by
-# user (by default it is empty)
-#
-#.SECONDEXPANSION:
-%_cpp.o: %.cpp $$(wildcard $$(dep_$$@)) $$(DEP_$$(@)) FORCE
- @[ -d $(dir $@) ] || mkdir -p $(dir $@)
- $(if $(D),\
- @echo -n "$< -> $@ " ; \
- echo -n "file_missing=$(call boolean,$(file_missing)) " ; \
- echo -n "cmdline_changed=$(call boolean,$(call cmdline_changed,$(CXX_TO_O))) " ; \
- echo -n "depfile_missing=$(call boolean,$(depfile_missing)) " ; \
- echo "depfile_newer=$(call boolean,$(depfile_newer))")
- $(if $(or \
- $(file_missing),\
- $(call cmdline_changed,$(CXX_TO_O)),\
- $(depfile_missing),\
- $(depfile_newer)),\
- $(CXX_TO_O_DO))
-
diff --git a/mk/tle.cpp-vars.mk b/mk/tle.cpp-vars.mk
deleted file mode 100644
index 9cd2e2f..0000000
--- a/mk/tle.cpp-vars.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-# Copyright (c) 2016 Intel Corporation.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-ifeq ($(RTE_TOOLCHAIN), clang)
-CXX = $(CROSS)clang++
-ifeq ("$(origin CXX)", "command line")
-HOSTCXX = $(CXX)
-else
-HOSTCXX = clang++
-endif
-endif
-
-ifeq ($(RTE_TOOLCHAIN), icc)
-CXX = icc
-ifeq ("$(origin CXX)", "command line")
-HOSTCXX = $(CXX)
-else
-HOSTCXX = icc
-endif
-endif
-
-ifeq ($(RTE_TOOLCHAIN), gcc)
-CXX = $(CROSS)g++
-ifeq ("$(origin CXX)", "command line")
-HOSTCXX = $(CXX)
-else
-HOSTCXX = g++
-endif
-endif
-
-TOOLCHAIN_CXXFLAGS =
-
-CXXFLAGS := $(CFLAGS)
-
-export CXX CXXFLAGS TOOLCHAIN_CXXFLAGS
diff --git a/mk/tle.lib.mk b/mk/tle.lib.mk
index 7455585..90bc989 100644
--- a/mk/tle.lib.mk
+++ b/mk/tle.lib.mk
@@ -11,26 +11,45 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-EXTLIB_BUILD := y
+LIB_SHARED = $(LIB_NAME).so
+LIB_STATIC = $(LIB_NAME).a
-# we must create the output dir first and recall the same Makefile
-# from this directory
-ifeq ($(NOT_FIRST_CALL),)
+LDFLAGS += -Wl,--no-undefined $(LDFLAGS_SHARED)
-NOT_FIRST_CALL = 1
-export NOT_FIRST_CALL
+ifneq ($(LIB_DEPS),)
+ LDLIBS += -L$(RTE_OUTPUT)/lib
+ LDLIBS += $(patsubst %,-l%,$(LIB_DEPS))
+ LDFLAGS += $(LDLIBS)
+endif
+
+.PHONY: all clean static shared
+all: shared static
+shared: $(RTE_OUTPUT)/lib/$(LIB_SHARED)
+static: $(RTE_OUTPUT)/lib/$(LIB_STATIC)
+
+OBJS := $(patsubst %.c,$(BDIR)/%.o,$(SRCS-y))
+
+$(BDIR)/%.o: %.c Makefile $(HDRS) $(PC_FILE)
+ @mkdir -p $(BDIR)
+ $(Q)$(CC) $(CFLAGS) -c $< -o $@
-BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR)
+HDRS := $(patsubst %.h,$(RTE_OUTPUT)/include/%.h,$(SYMLINK-y-include))
-all:
- $(Q)mkdir -p $(BDIR)
- $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \
- S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
+$(RTE_OUTPUT)/include/%.h: %.h Makefile $(PC_FILE)
+ $(Q)ln -s -f $(RTE_SRCDIR)/$< $@
+
+clean:
+ $(Q)rm -f $(RTE_OUTPUT)/lib/$(LIB_SHARED)
+ $(Q)rm -f $(RTE_OUTPUT)/lib/$(LIB_STATIC)
+ $(Q)rm -f $(HDRS)
+ $(Q)rm -rf $(BDIR)
+
+$(RTE_OUTPUT)/lib/$(LIB_SHARED): $(HDRS) $(OBJS) Makefile $(PC_FILE)
+ifneq ($(OBJS),)
+ $(Q)$(CC) $(OBJS) -o $@ -shared $(LDFLAGS)
+endif
-%::
- $(Q)mkdir -p $(BDIR)
- $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) $@ \
- S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
-else
-include $(RTE_SDK)/mk/rte.lib.mk
+$(RTE_OUTPUT)/lib/$(LIB_STATIC): $(HDRS) $(OBJS) Makefile $(PC_FILE)
+ifneq ($(OBJS),)
+ $(Q)$(AR) -cr $@ $(OBJS) -o $@
endif
diff --git a/mk/tle.subdir.mk b/mk/tle.subdir.mk
index 772011a..ce45acb 100644
--- a/mk/tle.subdir.mk
+++ b/mk/tle.subdir.mk
@@ -19,11 +19,12 @@ clean: $(DIRS-y)
.PHONY: $(DIRS-y)
$(DIRS-y):
- @echo "== $@"
+ @echo "=> $@"
$(Q)$(MAKE) -C $(@) \
+ O=$(O) \
M=$(CURDIR)/$(@)/Makefile \
- CUR_SUBDIR=$(CUR_SUBDIR)/$(@) \
S=$(CURDIR)/$(@) \
RTE_TARGET=$(RTE_TARGET) \
$(filter-out $(DIRS-y),$(MAKECMDGOALS))
+ @echo "<= $@"
diff --git a/mk/tle.var.mk b/mk/tle.var.mk
new file mode 100644
index 0000000..673c1d0
--- /dev/null
+++ b/mk/tle.var.mk
@@ -0,0 +1,58 @@
+# Copyright (c) 2021 Intel Corporation.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at:
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ifeq ($(RTE_SDK),)
+$(error "Please define RTE_SDK environment variable")
+endif
+
+# Default target, can be overwritten by command line or environment
+RTE_TARGET ?= x86_64-native-linuxapp-gcc
+RTE_OUTPUT ?= $(O)
+RTE_SRCDIR ?= $(S)
+
+RTE_PKGCONF ?= $(RTE_SDK)/lib/x86_64-linux-gnu/pkgconfig
+
+PKGCONF = export PKG_CONFIG_PATH=$(RTE_PKGCONF); \
+ pkg-config
+ifneq ($(shell $(PKGCONF) --exists libdpdk && echo 0),0)
+$(error "no installation of DPDK found")
+endif
+
+CFLAGS += -O3
+CFLAGS += -fPIC
+CFLAGS += -m64 -pthread
+CFLAGS += -DALLOW_EXPERIMENTAL_API
+CFLAGS += -I$(RTE_OUTPUT)/include
+
+# compiler errors/warnings
+ifeq ($(CC), clang)
+CFLAGS += -Wall -Wextra -Werror
+CFLAGS += -Wno-missing-field-initializers -Wno-implicit-fallthrough
+CFLAGS += -Wno-address-of-packed-member -Wno-gnu-alignof-expression
+CFLAGS += -Wno-constant-conversion
+else
+CFLAGS += -Wall -Wextra -Werror
+CFLAGS += -Wno-missing-field-initializers -Wimplicit-fallthrough=2
+CFLAGS += -Wno-format-truncation -Wno-address-of-packed-member
+endif
+
+PC_FILE := $(shell $(PKGCONF) --path libdpdk 2>/dev/null)
+CFLAGS += $(shell $(PKGCONF) --cflags libdpdk)
+LDFLAGS_SHARED = $(shell $(PKGCONF) --libs libdpdk)
+LDFLAGS_STATIC = $(shell $(PKGCONF) --static --libs libdpdk)
+
+ifneq ($(APP_NAME),)
+ BDIR := $(RTE_OUTPUT)/build/$(APP_NAME)
+else
+ BDIR := $(RTE_OUTPUT)/build/$(LIB_NAME)
+endif