summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ananyev <konstantin.ananyev@intel.com>2016-08-06 20:43:20 +0100
committerMohammad Abdul Awal <mohammad.abdul.awal@intel.com>2016-10-06 13:26:45 +0100
commit5d0ab6ce9c41573a2c7c401a0efa8ea764c9d55a (patch)
tree137ec75052046e832a12e0a300d9b9efba04d629
parent95540c9eb8f0cc8c26e1b570e0aa8fe4990d0cbd (diff)
Enable C++ files compilation
Change-Id: I28b180a6c91165049cd7cc58a64f1e5e1698da61 Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
-rw-r--r--examples/udpfwd/Makefile2
-rw-r--r--lib/libtle_dring/Makefile2
-rw-r--r--lib/libtle_udp/Makefile2
-rw-r--r--mk/tle.app.mk36
-rw-r--r--mk/tle.cpp-obj.mk99
-rw-r--r--mk/tle.cpp-pre.mk91
-rw-r--r--mk/tle.cpp-vars.mk45
-rw-r--r--mk/tle.lib.mk36
-rw-r--r--mk/tle.subdir.mk2
-rw-r--r--test/dring/Makefile2
10 files changed, 311 insertions, 6 deletions
diff --git a/examples/udpfwd/Makefile b/examples/udpfwd/Makefile
index 496a3be..8945e88 100644
--- a/examples/udpfwd/Makefile
+++ b/examples/udpfwd/Makefile
@@ -43,4 +43,4 @@ EXTRA_CFLAGS += -O3
CFLAGS_parse.o += -D_GNU_SOURCE
CFLAGS_main.o += -D_GNU_SOURCE
-include $(RTE_SDK)/mk/rte.extapp.mk
+include $(TLDK_ROOT)/mk/tle.app.mk
diff --git a/lib/libtle_dring/Makefile b/lib/libtle_dring/Makefile
index 1f2c940..fa03e90 100644
--- a/lib/libtle_dring/Makefile
+++ b/lib/libtle_dring/Makefile
@@ -35,4 +35,4 @@ SRCS-y += dring.c
SYMLINK-y-include += tle_dring.h
-include $(RTE_SDK)/mk/rte.extlib.mk
+include $(TLDK_ROOT)/mk/tle.lib.mk
diff --git a/lib/libtle_udp/Makefile b/lib/libtle_udp/Makefile
index a834873..44cb6aa 100644
--- a/lib/libtle_udp/Makefile
+++ b/lib/libtle_udp/Makefile
@@ -42,4 +42,4 @@ SYMLINK-y-include += tle_event.h
# this lib dependencies
DEPDIRS-y += lib/libtle_dring
-include $(RTE_SDK)/mk/rte.extlib.mk
+include $(TLDK_ROOT)/mk/tle.lib.mk
diff --git a/mk/tle.app.mk b/mk/tle.app.mk
new file mode 100644
index 0000000..602b870
--- /dev/null
+++ b/mk/tle.app.mk
@@ -0,0 +1,36 @@
+# 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.
+
+EXTLIB_BUILD := y
+
+# we must create the output dir first and recall the same Makefile
+# from this directory
+ifeq ($(NOT_FIRST_CALL),)
+
+NOT_FIRST_CALL = 1
+export NOT_FIRST_CALL
+
+BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR)
+
+all:
+ $(Q)mkdir -p $(BDIR)
+ $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \
+ S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
+
+%::
+ $(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
+endif
diff --git a/mk/tle.cpp-obj.mk b/mk/tle.cpp-obj.mk
new file mode 100644
index 0000000..2d66d5a
--- /dev/null
+++ b/mk/tle.cpp-obj.mk
@@ -0,0 +1,99 @@
+# 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 $(RTE_SDK)/mk/internal/rte.depdirs-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
+include $(RTE_SDK)/mk/internal/rte.depdirs-post.mk
+
+.PHONY: FORCE
+FORCE:
diff --git a/mk/tle.cpp-pre.mk b/mk/tle.cpp-pre.mk
new file mode 100644
index 0000000..ae7748b
--- /dev/null
+++ b/mk/tle.cpp-pre.mk
@@ -0,0 +1,91 @@
+# 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
new file mode 100644
index 0000000..9cd2e2f
--- /dev/null
+++ b/mk/tle.cpp-vars.mk
@@ -0,0 +1,45 @@
+# 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
new file mode 100644
index 0000000..7455585
--- /dev/null
+++ b/mk/tle.lib.mk
@@ -0,0 +1,36 @@
+# 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.
+
+EXTLIB_BUILD := y
+
+# we must create the output dir first and recall the same Makefile
+# from this directory
+ifeq ($(NOT_FIRST_CALL),)
+
+NOT_FIRST_CALL = 1
+export NOT_FIRST_CALL
+
+BDIR := $(RTE_OUTPUT)/build/$(CUR_SUBDIR)
+
+all:
+ $(Q)mkdir -p $(BDIR)
+ $(Q)$(MAKE) -C $(BDIR) -f $(RTE_EXTMK) \
+ S=$(RTE_SRCDIR) O=$(RTE_OUTPUT) SRCDIR=$(RTE_SRCDIR)
+
+%::
+ $(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
+endif
diff --git a/mk/tle.subdir.mk b/mk/tle.subdir.mk
index 92c358b..772011a 100644
--- a/mk/tle.subdir.mk
+++ b/mk/tle.subdir.mk
@@ -22,8 +22,6 @@ $(DIRS-y):
@echo "== $@"
$(Q)$(MAKE) -C $(@) \
M=$(CURDIR)/$(@)/Makefile \
- O=$(BASE_OUTPUT) \
- BASE_OUTPUT=$(BASE_OUTPUT) \
CUR_SUBDIR=$(CUR_SUBDIR)/$(@) \
S=$(CURDIR)/$(@) \
RTE_TARGET=$(RTE_TARGET) \
diff --git a/test/dring/Makefile b/test/dring/Makefile
index 6822a1f..b4e7a70 100644
--- a/test/dring/Makefile
+++ b/test/dring/Makefile
@@ -39,4 +39,4 @@ LDLIBS += -ltle_dring
EXTRA_CFLAGS += -O3
-include $(RTE_SDK)/mk/rte.extapp.mk
+include $(TLDK_ROOT)/mk/tle.app.mk