7133a7ef3368ee1705a6bd4814e3d6b17a56c184
[openwrt/staging/dedeckeh.git] / package / libs / uclibc++ / Makefile
1 #
2 # Copyright (C) 2006-2012 OpenWrt.org
3 # Copyright (c) 2016 LEDE project
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=uclibc++
12 PKG_VERSION:=0.2.4
13 PKG_RELEASE:=3
14
15 PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.bz2
16 PKG_SOURCE_URL:=http://cxx.uclibc.org/src/
17 PKG_HASH:=be16fc6a6eb2e59df420ee41e7042f38e27ebaf5c2762d90e75803364a7b00db
18
19 PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION)
20 PKG_BUILD_PARALLEL:=1
21 PKG_USE_MIPS16:=0
22 PKG_LICENSE:=LGPL-2.1+
23
24 PKG_INSTALL:=1
25
26 include $(INCLUDE_DIR)/package.mk
27
28 define Package/uclibcxx
29 NAME:=uclibc++
30 SECTION:=libs
31 CATEGORY:=Libraries
32 TITLE:=C++ library for embedded systems
33 URL:=http://cxx.uclibc.org/src/
34 endef
35
36 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
37 -e 's/i.86/i386/' \
38 -e 's/sparc.*/sparc/' \
39 -e 's/m68k.*/m68k/' \
40 -e 's/ppc/powerpc/g' \
41 -e 's/v850.*/v850/g' \
42 -e 's/sh64/sh/' \
43 -e 's/sh[234].*/sh/' \
44 -e 's/mips.*/mips/' \
45 -e 's/mipsel.*/mips/' \
46 )
47
48 TARGET_CFLAGS += $(FPIC)
49
50 ifneq ($(CONFIG_CCACHE),)
51 TARGET_CXX=$(TARGET_CXX_NOCACHE)
52 endif
53
54 ifeq ($(CONFIG_USE_MUSL),y)
55 SSP_LIB=-lssp_nonshared
56 endif
57
58 MAKE_FLAGS:= \
59 TOPDIR="$(PKG_BUILD_DIR)/" \
60 $(TARGET_CONFIGURE_OPTS) \
61 CPU_CFLAGS="$(TARGET_CFLAGS)" \
62 CROSS="$(TARGET_CROSS)" \
63 LDFLAGS="-Wl,--warn-common -Wl,--warn-once -Wl,-z,combreloc -Wl,-z,defs $(TARGET_LDFLAGS)" \
64 CP="$(CP)" \
65 GEN_LIBS="-lc $(LIBGCC_S) $(SSP_LIB)" \
66 GEN_CFLAGS="-std=gnu++98 -nostdinc++" \
67 check_as_needed=
68
69 # check_as_needed overrides dependency on libgcc_s
70
71 define Build/Prepare
72 $(PKG_UNPACK)
73 $(SED) 's/\r$$$$//' $(PKG_BUILD_DIR)/include/unwind-cxx.h
74 $(Build/Patch)
75 endef
76
77 define Build/Configure
78 if [ -f ./files/config.$(UCLIBC_TARGET_ARCH) ]; then \
79 cp ./files/config.$(UCLIBC_TARGET_ARCH) $(PKG_BUILD_DIR)/.config; \
80 else \
81 cp ./files/config.default $(PKG_BUILD_DIR)/.config; \
82 fi
83 endef
84
85 define Build/InstallDev
86 $(INSTALL_DIR) $(2)/bin $(1)/usr/include/uClibc++ $(1)/usr/lib
87 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/
88 $(CP) $(PKG_INSTALL_DIR)/include/* $(1)/usr/include/uClibc++/
89 $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++*.{a,so}* $(1)/usr/lib/
90 $(SED) 's!\(^\|[[:space:]]\)-[IL]$(TOOLCHAIN_DIR)/[^[:space:]]*!!g' $(TOOLCHAIN_DIR)/bin/g++-uc
91 $(SED) 's|-I/include/|-I$$$${STAGING_DIR:-$(STAGING_DIR)}/usr/include/uClibc++/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
92 $(SED) 's|-L/lib/|-L$$$${STAGING_DIR:-$(STAGING_DIR)}/lib/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
93 # add another wrapper which links against both uClibc++ and libstdc++
94 $(INSTALL_BIN) $(TOOLCHAIN_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/g++-uc+std
95 $(SED) 's|^WRAPPER_INCLUDEDIR=.*||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
96 $(SED) 's|-luClibc++|-Wl,-Bdynamic,-luClibc++,-Bstatic,-lstdc++,-Bdynamic|g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
97 $(SED) 's|-nostdinc++||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
98 endef
99
100 define Package/uclibcxx/install
101 $(INSTALL_DIR) $(1)/usr/lib
102 $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++.so.* $(1)/usr/lib/
103 $(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++-*.so $(1)/usr/lib/
104 endef
105
106 $(eval $(call BuildPackage,uclibcxx))