From 5d0ab6ce9c41573a2c7c401a0efa8ea764c9d55a Mon Sep 17 00:00:00 2001 From: Konstantin Ananyev Date: Sat, 6 Aug 2016 20:43:20 +0100 Subject: Enable C++ files compilation Change-Id: I28b180a6c91165049cd7cc58a64f1e5e1698da61 Signed-off-by: Konstantin Ananyev --- mk/tle.app.mk | 36 ++++++++++++++++++++ mk/tle.cpp-obj.mk | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ mk/tle.cpp-pre.mk | 91 +++++++++++++++++++++++++++++++++++++++++++++++++ mk/tle.cpp-vars.mk | 45 +++++++++++++++++++++++++ mk/tle.lib.mk | 36 ++++++++++++++++++++ mk/tle.subdir.mk | 2 -- 6 files changed, 307 insertions(+), 2 deletions(-) create mode 100644 mk/tle.app.mk create mode 100644 mk/tle.cpp-obj.mk create mode 100644 mk/tle.cpp-pre.mk create mode 100644 mk/tle.cpp-vars.mk create mode 100644 mk/tle.lib.mk (limited to '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) \ -- cgit 1.2.3-korg