gcc: always explicitly link against libstdc++, fixes build errors on some hosts that...
[openwrt.git] / toolchain / uClibc / Makefile
1 #
2 # Copyright (C) 2006-2011 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/target.mk
9
10 PKG_NAME:=uClibc
11 PKG_VERSION:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
12 ifeq ($(PKG_VERSION),0.9.32)
13 PKG_SOURCE_URL:=git://git.busybox.net/uClibc
14 PKG_SOURCE_PROTO:=git
15 PKG_SOURCE_VERSION:=9152c4d67c763fde5712e2d181d92c0d7e1e2ab9
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
18 PKG_MIRROR_MD5SUM:=723dfa4f1f766cbd675d2c9a8238abb0
19 LIBC_SO_VERSION:=$(PKG_VERSION).1-git
20 else
21 PKG_SOURCE_URL:=http://www.uclibc.org/downloads
22 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
23 LIBC_SO_VERSION:=$(PKG_VERSION)
24 endif
25 PATCH_DIR:=./patches-$(PKG_VERSION)
26 CONFIG_DIR:=./config-$(PKG_VERSION)
27
28 PKG_MD5SUM=$(PKG_MD5SUM_$(PKG_VERSION))
29
30 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
31
32 include $(INCLUDE_DIR)/toolchain-build.mk
33
34 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
35 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc-utils_installed
36
37 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
38 -e 's/i.86/i386/' \
39 -e 's/sparc.*/sparc/' \
40 -e 's/arm.*/arm/g' \
41 -e 's/avr32.*/avr32/g' \
42 -e 's/m68k.*/m68k/' \
43 -e 's/ppc/powerpc/g' \
44 -e 's/v850.*/v850/g' \
45 -e 's/sh64/sh/' \
46 -e 's/sh[234].*/sh/' \
47 -e 's/mips.*/mips/' \
48 -e 's/mipsel.*/mips/' \
49 -e 's/cris.*/cris/' \
50 )
51
52
53 define Host/SetToolchainInfo
54 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
55 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.uclibc.org/,' $(TOOLCHAIN_DIR)/info.mk
56 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
57 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(LIBC_SO_VERSION),' $(TOOLCHAIN_DIR)/info.mk
58 endef
59
60 GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
61 $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
62 $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
63 $(CONFIG_DIR)/$(ARCH)$(strip \
64 $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
65 $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500))))
66
67 define Host/Prepare
68 $(call Host/Prepare/Default)
69 $(if $(strip $(QUILT)), \
70 cd $(HOST_BUILD_DIR); \
71 if $(QUILT_CMD) next >/dev/null 2>&1; then \
72 $(QUILT_CMD) push -a; \
73 fi
74 )
75 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
76 $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config
77 $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
78 -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
79 -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
80 -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
81 -e 's,^.*UCLIBC_HAS_LOCALE.*,UCLIBC_HAS_LOCALE=$(if $(CONFIG_BUILD_NLS),y,n),g' \
82 $(HOST_BUILD_DIR)/.config
83 $(MAKE) -C $(HOST_BUILD_DIR) oldconfig KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
84 $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
85 PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
86 PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
87 DEVEL_PREFIX=/ \
88 RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
89 HOSTCC="$(HOSTCC)" \
90 CC="$(TARGET_CC)" \
91 CPU_CFLAGS="$(TARGET_CFLAGS)" \
92 ARCH="$(CONFIG_ARCH)" \
93 pregen \
94 install_headers
95 endef
96
97 define Host/Configure
98 endef
99
100 CPU_CFLAGS = \
101 -funsigned-char -fno-builtin -fno-asm \
102 --std=gnu99 -ffunction-sections -fdata-sections \
103 $(TARGET_CFLAGS)
104
105 UCLIBC_MAKE = PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
106 $(TARGET_CONFIGURE_OPTS) \
107 DEVEL_PREFIX=/ \
108 RUNTIME_PREFIX=/ \
109 HOSTCC="$(HOSTCC)" \
110 CPU_CFLAGS="$(CPU_CFLAGS)" \
111 ARCH="$(CONFIG_ARCH)" \
112 LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
113 DOSTRIP=""
114
115 define Host/Compile
116 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
117 $(UCLIBC_MAKE) $(TOOLCHAIN_JOBS) PREFIX= all
118 $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
119 $(CP) $(HOST_BUILD_DIR)/libc/libc_so.a $(TOOLCHAIN_DIR)/lib/
120 $(CP) $(HOST_BUILD_DIR)/libpthread/*/libpthread_so.a $(TOOLCHAIN_DIR)/lib/
121 ( cd $(TOOLCHAIN_DIR) ; \
122 for d in lib usr/lib ; do \
123 for f in libc.so libpthread.so libgcc_s.so ; do \
124 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
125 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
126 fi \
127 done \
128 done \
129 )
130 rm -f \
131 $(TOOLCHAIN_DIR)/lib/libresolv*.so* \
132 $(TOOLCHAIN_DIR)/lib/libnsl*.so*
133 endef
134
135 define Host/Install
136 $(call Host/SetToolchainInfo)
137 $(UCLIBC_MAKE) PREFIX= utils
138 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/bin
139 $(INSTALL_BIN) \
140 $(HOST_BUILD_DIR)/utils/ldd \
141 $(TOOLCHAIN_DIR)/bin/
142 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
143 $(INSTALL_BIN) \
144 $(HOST_BUILD_DIR)/utils/ldconfig \
145 $(TOOLCHAIN_DIR)/sbin/
146 endef
147
148 define Host/Clean
149 rm -rf \
150 $(HOST_BUILD_DIR) \
151 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
152 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
153 endef
154
155 $(eval $(call HostBuild))
This page took 0.051977 seconds and 5 git commands to generate.