b55796b40f15128800e8718f79118e8dff6041f2
[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:=http://www.uclibc.org/svn/branches/uClibc-nptl
14 PKG_SOURCE_PROTO:=svn
15 PKG_SOURCE_VERSION:=25804
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-r$(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.29 = 61dc55f43b17a38a074f347e74095b20
28 PKG_MD5SUM_0.9.30.1 = 1a4b84e5536ad8170563ffa88c34679c
29 PKG_MD5SUM=$(PKG_MD5SUM_$(PKG_VERSION))
30
31 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
32
33 include $(INCLUDE_DIR)/toolchain-build.mk
34
35 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
36 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc-utils_installed
37
38 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
39 -e 's/i.86/i386/' \
40 -e 's/sparc.*/sparc/' \
41 -e 's/arm.*/arm/g' \
42 -e 's/avr32.*/avr32/g' \
43 -e 's/m68k.*/m68k/' \
44 -e 's/ppc/powerpc/g' \
45 -e 's/v850.*/v850/g' \
46 -e 's/sh64/sh/' \
47 -e 's/sh[234].*/sh/' \
48 -e 's/mips.*/mips/' \
49 -e 's/mipsel.*/mips/' \
50 -e 's/cris.*/cris/' \
51 )
52
53
54 define Host/SetToolchainInfo
55 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
56 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.uclibc.org/,' $(TOOLCHAIN_DIR)/info.mk
57 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
58 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(LIBC_SO_VERSION),' $(TOOLCHAIN_DIR)/info.mk
59 endef
60
61 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))
62
63 define Host/Prepare
64 $(call Host/SetToolchainInfo)
65 $(call Host/Prepare/Default)
66 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
67 $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config
68 $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include\",g' \
69 -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
70 -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
71 -e 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=$(if $(CONFIG_LARGEFILE),y,n),g' \
72 -e 's,^.*CONFIG_ARM_EABI.*,CONFIG_ARM_EABI=$(if $(CONFIG_EABI_SUPPORT),y,n),g' \
73 -e 's,^.*CONFIG_ARM_OABI.*,CONFIG_ARM_OABI=$(if $(CONFIG_EABI_SUPPORT),n,y),g' \
74 -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
75 $(HOST_BUILD_DIR)/.config
76 $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
77 PATH=$(TARGET_PATH) $(MAKE) -C $(HOST_BUILD_DIR) \
78 PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
79 DEVEL_PREFIX=/usr/ \
80 RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
81 HOSTCC="$(HOSTCC)" \
82 CC="$(TARGET_CC)" \
83 CPU_CFLAGS="$(TARGET_CFLAGS)" \
84 pregen \
85 install_headers
86 endef
87
88 define Host/Configure
89 endef
90
91 UCLIBC_MAKE = PATH=$(TARGET_PATH) $(MAKE) -C $(HOST_BUILD_DIR) \
92 $(TARGET_CONFIGURE_OPTS) \
93 DEVEL_PREFIX=/usr/ \
94 RUNTIME_PREFIX=/ \
95 HOSTCC="$(HOSTCC)" \
96 CPU_CFLAGS="$(TARGET_CFLAGS)" \
97 LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
98 DOSTRIP=""
99
100 define Host/Compile
101 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
102 $(UCLIBC_MAKE) PREFIX= all
103 $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
104 ln -sf ../../lib/libc.so.0 $(TOOLCHAIN_DIR)/usr/lib/libc.so
105 # ( cd $(TOOLCHAIN_DIR) ; \
106 # for d in lib usr/lib ; do \
107 # for f in libc.so libpthread.so libgcc_s.so ; do \
108 # if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
109 # $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
110 # fi \
111 # done \
112 # done \
113 # )
114 endef
115
116 define Host/Install
117 $(UCLIBC_MAKE) PREFIX= utils
118 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/usr/bin
119 $(INSTALL_BIN) \
120 $(HOST_BUILD_DIR)/utils/ldd \
121 $(TOOLCHAIN_DIR)/usr/bin/
122 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
123 $(INSTALL_BIN) \
124 $(HOST_BUILD_DIR)/utils/ldconfig \
125 $(TOOLCHAIN_DIR)/sbin/
126 endef
127
128 define Host/Clean
129 rm -rf \
130 $(HOST_BUILD_DIR) \
131 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
132 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
133 endef
134
135 $(eval $(call HostBuild))
This page took 0.048626 seconds and 3 git commands to generate.