fix pthread mklibs relinking by copying libpthread_so.a from uclibc instead of using...
[openwrt.git] / toolchain / uClibc / Makefile
1 #
2 # Copyright (C) 2006-2009 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 ($(CONFIG_UCLIBC_VERSION_NPTL),y)
13 PKG_SOURCE_URL:=git://git.busybox.net/uClibc
14 PKG_SOURCE_PROTO:=git
15 PKG_SOURCE_VERSION:=0949826e9501e9f08767aeb476ea1464bf95f218
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
18 LIBC_SO_VERSION:=0.9.30-svn
19 else
20 PKG_SOURCE_URL:=http://www.uclibc.org/downloads
21 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
22 LIBC_SO_VERSION:=$(PKG_VERSION)
23 endif
24 PATCH_DIR:=./patches-$(PKG_VERSION)
25 CONFIG_DIR:=./config-$(PKG_VERSION)
26
27 PKG_MD5SUM_0.9.30.1 = 1a4b84e5536ad8170563ffa88c34679c
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 $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) ./$(CONFIG_DIR)/$(ARCH)$(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD))
61
62 define Host/Prepare
63 $(call Host/SetToolchainInfo)
64 $(call Host/Prepare/Default)
65 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
66 $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config
67 $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include\",g' \
68 -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
69 -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
70 -e 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=$(if $(CONFIG_LARGEFILE),y,n),g' \
71 -e 's,^.*CONFIG_ARM_EABI.*,CONFIG_ARM_EABI=$(if $(CONFIG_EABI_SUPPORT),y,n),g' \
72 -e 's,^.*CONFIG_ARM_OABI.*,CONFIG_ARM_OABI=$(if $(CONFIG_EABI_SUPPORT),n,y),g' \
73 -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
74 $(HOST_BUILD_DIR)/.config
75 $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
76 PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
77 PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
78 DEVEL_PREFIX=/usr/ \
79 RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
80 HOSTCC="$(HOSTCC)" \
81 CC="$(TARGET_CC)" \
82 CPU_CFLAGS="$(TARGET_CFLAGS)" \
83 pregen \
84 install_headers
85 endef
86
87 define Host/Configure
88 endef
89
90 UCLIBC_MAKE = PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
91 $(TARGET_CONFIGURE_OPTS) \
92 DEVEL_PREFIX=/usr/ \
93 RUNTIME_PREFIX=/ \
94 HOSTCC="$(HOSTCC)" \
95 CPU_CFLAGS="$(TARGET_CFLAGS)" \
96 LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
97 DOSTRIP=""
98
99 define Host/Compile
100 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
101 $(UCLIBC_MAKE) PREFIX= all
102 $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
103 ln -sf ../../lib/libc.so.0 $(TOOLCHAIN_DIR)/usr/lib/libc.so
104 $(CP) $(HOST_BUILD_DIR)/libc/libc_so.a $(TOOLCHAIN_DIR)/usr/lib/
105 $(CP) $(HOST_BUILD_DIR)/libpthread/*/libpthread_so.a $(TOOLCHAIN_DIR)/usr/lib/
106 ( cd $(TOOLCHAIN_DIR) ; \
107 for d in lib usr/lib ; do \
108 for f in libc.so libpthread.so libgcc_s.so ; do \
109 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
110 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
111 fi \
112 done \
113 done \
114 )
115 endef
116
117 define Host/Install
118 $(UCLIBC_MAKE) PREFIX= utils
119 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/bin
120 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/usr/bin
121 $(INSTALL_BIN) \
122 $(HOST_BUILD_DIR)/utils/ldd \
123 $(TOOLCHAIN_DIR)/usr/bin/
124 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
125 $(INSTALL_BIN) \
126 $(HOST_BUILD_DIR)/utils/ldconfig \
127 $(TOOLCHAIN_DIR)/sbin/
128 endef
129
130 define Host/Clean
131 rm -rf \
132 $(HOST_BUILD_DIR) \
133 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
134 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
135 endef
136
137 $(eval $(call HostBuild))
This page took 0.043253 seconds and 5 git commands to generate.