summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2012-12-30 13:34:21 +0100
committerAbdoulaye Walsimou Gaye <awg@embtoolkit.org>2012-12-30 13:34:21 +0100
commit590e50c7fcef1d5fed605c59f443301739a6d2dd (patch)
tree9b4c8f2bfe993e30b4e786431f915885001a22a8
parent0653f9ca027d0382195ed41d25b8d2b367c0848f (diff)
downloadembtoolkit-590e50c7fcef1d5fed605c59f443301739a6d2dd.tar.gz
embtoolkit-590e50c7fcef1d5fed605c59f443301739a6d2dd.tar.bz2
embtoolkit-590e50c7fcef1d5fed605c59f443301739a6d2dd.tar.xz
Toolchain: libc++: add initial build infrastructure
Signed-off-by: Abdoulaye Walsimou Gaye <awg@embtoolkit.org>
-rw-r--r--kconfig/libc++/libc++/libcxx.kconfig78
-rw-r--r--mk/libc++/libc++/Makefile124
-rw-r--r--mk/libc++/libc++/libcxx.mk59
3 files changed, 261 insertions, 0 deletions
diff --git a/kconfig/libc++/libc++/libcxx.kconfig b/kconfig/libc++/libc++/libcxx.kconfig
new file mode 100644
index 0000000..d9e105f
--- /dev/null
+++ b/kconfig/libc++/libc++/libcxx.kconfig
@@ -0,0 +1,78 @@
+################################################################################
+# Embtoolkit
+# Copyright(C) 2012 Abdoulaye Walsimou GAYE <awg@embtoolkit.org>.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+################################################################################
+#
+# \file libcxx.kconfig
+# \brief libcxx.kconfig of Embtoolkit
+# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
+# \date December 2012
+################################################################################
+
+config EMTK_HAVE_LIBCXX
+ bool
+ default y
+ select KEMBTK_UCLIBC_UCLIBC_HAS_LOCALE if EMBTK_CLIB_UCLIBC
+ select KEMBTK_UCLIBC_UCLIBC_HAS_XLOCALE if EMBTK_CLIB_UCLIBC
+
+#
+# libcxx version
+#
+choice
+ prompt "Version of libcxx you wish"
+ help
+ Version of libcxx you wish
+
+ config EMBTK_LIBCXX_VERSION_GIT
+ bool "Use libcxx git repository"
+ help
+ Answer Y here if you want to build your toolchain based on
+ libcxx sources from its GIT repository.
+endchoice
+
+#
+# GIT repository options
+#
+config EMBTK_LIBCXX_GIT_BRANCH
+ string "Branch to use"
+ default "master"
+ depends on EMBTK_LIBCXX_VERSION_GIT
+ help
+ The branch of the git repository to use, the default is master.
+
+config EMBTK_LIBCXX_GIT_REVISION
+ string "Checkout a specific revision instead of the latest"
+ depends on EMBTK_LIBCXX_VERSION_GIT
+ help
+ Chechout a specific revision instead of the latest.
+
+config EMBTK_LIBCXX_REFSPEC
+ string
+ default "toolchain"
+
+#
+# Versions strings for tarball packages.
+#
+config EMBTK_LIBCXX_VERSION_STRING
+ string
+ default "git" if EMBTK_LIBCXX_VERSION_GIT
+
+
+config EMBTK_LIBCXX_NEED_PATCH
+ bool
+config EMBTK_LIBCXX_NEED_AUTORECONF
+ bool
diff --git a/mk/libc++/libc++/Makefile b/mk/libc++/libc++/Makefile
new file mode 100644
index 0000000..a06508f
--- /dev/null
+++ b/mk/libc++/libc++/Makefile
@@ -0,0 +1,124 @@
+################################################################################
+# Copyright 2012 Abdoulaye Walsimou GAYE <awg@embtoolkit.org>. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+#
+# 1. Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# 2. Redistributions in binary form must reproduce the above copyright notice,
+# this list of conditions and the following disclaimer in the documentation
+# and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS
+# IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+################################################################################
+
+rootsrc ?= $(shell pwd)
+LIBDIR ?= lib
+
+CXX_SRCS := $(wildcard $(rootsrc)/src/*.cpp)
+
+OBJS := $(patsubst %.cpp,%.o,$(CXX_SRCS))
+POBJS := $(patsubst %.o,%.po,$(OBJS))
+SOBJS := $(patsubst %.o,%.So,$(OBJS))
+
+__HEADERS := $(wildcard $(rootsrc)/include/*)
+HEADERS := $(filter-out $(rootsrc)/include/support,$(__HEADERS))
+
+CC ?= gcc
+CXX ?= g++
+
+LIB := c++
+SHAREDLIB := $(LIB)
+SHAREDLIB_NAME := lib$(SHAREDLIB).so.1
+SHAREDLIB_LINK := lib$(SHAREDLIB).so
+SHAREDLIB_SONAME := $(SHAREDLIB_NAME)
+
+override LDFLAGS := $(LDFLAGS) -shared
+override LDFLAGS += -Wl,--fatal-warnings -Wl,--warn-shared-textrel -Wl,-x
+
+override CFLAGS := $(CFLAGS) -I$(rootsrc)/include
+override CFLAGS += -DLIBCXXRT -DNO_CATGETS_SUPPORT
+override CXXFLAGS := $(CXXFLAGS) $(CFLAGS) -nostdinc++ -std=c++0x
+
+LDADD := -lcxxrt -lpthread -lrt -lc
+
+ARADD := $(shell $(CC) --print-file-name=libcxxrt.a)
+ARADD += $(shell $(CC) --print-file-name=libpthread.a)
+ARADD += $(shell $(CC) --print-file-name=librt.a)
+
+ARADD_P := $(shell $(CC) --print-file-name=libcxxrt_p.a)
+#ARADD_P += $(shell $(CC) --print-file-name=libpthread_p.a)
+#ARADD_P += $(shell $(CC) --print-file-name=librt_p.a)
+
+ARADD_PIC := $(shell $(CC) --print-file-name=libcxxrt_pic.a)
+#ARADD_PIC += $(shell $(CC) --print-file-name=libpthread.a)
+#ARADD_PIC += $(shell $(CC) --print-file-name=librt.a)
+
+ARFLAGS := rvs
+
+define __lib_install
+ $(if $(SYSROOT),
+ mkdir -p $(SYSROOT)/usr
+ mkdir -p $(SYSROOT)/usr/include
+ mkdir -p $(SYSROOT)/usr/include/c++
+ mkdir -p $(SYSROOT)/usr/include/c++/v1
+ cp -R $(HEADERS) $(SYSROOT)/usr/include/c++/v1
+ chmod 755 $(SYSROOT)/usr/include/c++/v1
+ chmod 644 $(SYSROOT)/usr/include/c++/v1/*
+ chmod 755 $(SYSROOT)/usr/include/c++/v1/ext
+ chmod 644 $(SYSROOT)/usr/include/c++/v1/ext/*
+ mkdir -p $(SYSROOT)/$(LIBDIR)
+ cp -d $(SHAREDLIB_NAME) $(SYSROOT)/$(LIBDIR)/
+ cp -d $(SHAREDLIB_LINK) $(SYSROOT)/$(LIBDIR)/
+ cp lib$(LIB).a $(SYSROOT)/$(LIBDIR)/
+ cp lib$(LIB)_pic.a $(SYSROOT)/$(LIBDIR)/
+ cp lib$(LIB)_p.a $(SYSROOT)/$(LIBDIR)/)
+endef
+
+all: lib$(LIB).a lib$(LIB)_p.a lib$(LIB)_pic.a $(SHAREDLIB_NAME)
+ $(Q)true
+
+install: all
+ $(Q)$(__lib_install)
+ $(Q)true
+
+$(SHAREDLIB_NAME): $(SOBJS)
+ $(Q)$(CC) $(CFLAGS) $(LDFLAGS) -o $@ \
+ -Wl,-soname,$(SHAREDLIB_SONAME) $(SOBJS) $(LDADD)
+ $(Q)ln -fs $(SHAREDLIB_NAME) $(SHAREDLIB_LINK)
+
+lib$(LIB).a: $(OBJS)
+ $(Q)$(AR) $(ARFLAGS) $@ $(OBJS)
+
+lib$(LIB)_p.a: $(POBJS)
+ $(Q)$(AR) $(ARFLAGS) $@ $(POBJS)
+
+lib$(LIB)_pic.a: $(SOBJS)
+ $(Q)$(AR) $(ARFLAGS) $@ $(SOBJS)
+
+%.o: %.cpp
+ $(Q)$(CXX) $(CXXFLAGS) -c $< -o $@
+
+%.po: %.cpp
+ $(Q)$(CXX) $(CXXFLAGS) -pg -c $< -o $@
+
+%.So: %.cpp
+ $(Q)$(CXX) -fPIC -DPIC $(CXXFLAGS) -c $< -o $@
+
+clean:
+ $(Q)rm -rf $(OBJS) $(SOBJS) $(POBJS)
+ $(Q)rm -rf lib$(LIB).a lib$(LIB)_p.a lib$(LIB)_pic.a
+ $(Q)rm -rf $(SHAREDLIB_NAME) $(SHAREDLIB_LINK)
+
diff --git a/mk/libc++/libc++/libcxx.mk b/mk/libc++/libc++/libcxx.mk
new file mode 100644
index 0000000..2ef8d46
--- /dev/null
+++ b/mk/libc++/libc++/libcxx.mk
@@ -0,0 +1,59 @@
+################################################################################
+# Embtoolkit
+# Copyright(C) 2012 Abdoulaye Walsimou GAYE <awg@embtoolkit.org>.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+#
+################################################################################
+#
+# \file libcxx.mk
+# \brief libcxx.mk of Embtoolkit
+# \author Abdoulaye Walsimou GAYE <awg@embtoolkit.org>
+# \date December 2012
+################################################################################
+
+LIBCXX_NAME := libcxx
+LIBCXX_VERSION := $(call embtk_get_pkgversion,libcxx)
+LIBCXX_SITE := ftp://ftp.embtoolkit.org/embtoolkit.org/packages-mirror/$(LIBCXX_VERSION)
+#LIBCXX_GIT_SITE := http://llvm.org/git/libcxx.git
+LIBCXX_GIT_SITE := git://www.embtoolkit.org/libcxx.git
+LIBCXX_PACKAGE := libcxx-$(LIBCXX_VERSION).tar.bz2
+LIBCXX_SRC_DIR := $(embtk_toolsb)/libcxx-$(LIBCXX_VERSION)
+LIBCXX_BUILD_DIR := $(call __embtk_pkg_srcdir,libcxx)
+
+LIBCXX_DEPS := libcxxrt_install
+
+__embtk_libcxx_cflags := $(TARGET_CFLAGS)
+__embtk_libcxx_cflags += -I$(embtk_sysroot)/usr/include/c++/v1
+
+LIBCXX_MAKE_OPTS := CC="$(TARGETCC)" CFLAGS="$(__embtk_libcxx_cflags)"
+LIBCXX_MAKE_OPTS += CXX="$(TARGETCXX)" LIBDIR=$(LIBDIR)
+LIBCXX_MAKE_OPTS += AR=$(TARGETAR) RANLIB=$(TARGETRANLIB)
+LIBCXX_MAKE_OPTS += SYSROOT="$(embtk_sysroot)"
+
+define embtk_install_libcxx
+ $(call embtk_makeinstall_pkg,libcxx)
+endef
+
+define embtk_beforeinstall_libcxx
+ ln -sf $(EMBTK_ROOT)/mk/libc++/libc++/Makefile \
+ $(LIBCXX_BUILD_DIR)/Makefile
+endef
+
+define embtk_cleanup_libcxx
+ if [ -e $(LIBCXXRT_BUILD_DIR)/Makefile ]; then \
+ $(MAKE) -C $(LIBCXXRT_BUILD_DIR) clean; \
+ fi
+ rm -rf $(LIBCXXRT_BUILD_DIR)/Makefile
+endef