summaryrefslogtreecommitdiff
path: root/toolchain/llvm/libc++/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'toolchain/llvm/libc++/Makefile')
-rw-r--r--toolchain/llvm/libc++/Makefile98
1 files changed, 98 insertions, 0 deletions
diff --git a/toolchain/llvm/libc++/Makefile b/toolchain/llvm/libc++/Makefile
new file mode 100644
index 0000000..da95cab
--- /dev/null
+++ b/toolchain/llvm/libc++/Makefile
@@ -0,0 +1,98 @@
+################################################################################
+# 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))
+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 -Wl,--warn-shared-textrel -Wl,-x
+
+override CXXFLAGS := $(CXXFLAGS) $(CFLAGS) -nostdinc++ -std=c++11
+override CPPFLAGS := $(CPPFLAGS) -I$(rootsrc)/include
+override CPPFLAGS += -DLIBCXXRT -DNO_CATGETS_SUPPORT
+
+LDADD := $(shell $(CC) --print-file-name=libcxxrt_pic.a)
+LDADD += -lpthread -lrt -ldl -lc
+
+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)
+ tar -cf - *.so* | tar -xf - -C $(SYSROOT)/$(LIBDIR)/
+ cp lib$(LIB)_nonshared.a $(SYSROOT)/usr/$(LIBDIR)/)
+endef
+
+all: lib$(LIB)_nonshared.a $(SHAREDLIB_NAME)
+ $(Q)true
+
+install: all
+ $(Q)$(__lib_install)
+ $(Q)true
+
+$(SHAREDLIB_NAME): $(SOBJS)
+ $(Q)$(CC) $(LDFLAGS) -o $@ \
+ -Wl,-soname,$(SHAREDLIB_SONAME) $(SOBJS) $(LDADD)
+ $(Q)ln -fs $(SHAREDLIB_NAME) $(SHAREDLIB_LINK)
+
+lib$(LIB)_nonshared.a: $(OBJS)
+ $(Q)$(AR) $(ARFLAGS) $@ $(OBJS)
+
+%.o: %.cpp
+ $(Q)$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
+
+%.So: %.cpp
+ $(Q)$(CXX) -fPIC $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
+
+clean:
+ $(Q)rm -rf $(OBJS) $(SOBJS) lib$(LIB).a
+ $(Q)rm -rf $(SHAREDLIB_NAME) $(SHAREDLIB_LINK)
+