08f267001be7c3096a8e33c237acbd38a09f0e7b
[openwrt/svn-archive/archive.git] / toolchain / uClibc / Makefile
1 #
2 # Copyright (C) 2006 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:=0.9.28
12 PKG_EXTRAVERSION:=.2
13
14 PKG_SOURCE:=uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION).tar.bz2
15 PKG_SOURCE_URL:=http://www.uclibc.org/downloads
16 PKG_MD5SUM:=959f25286e317f0d9e2103445c5a14c2
17 PKG_CAT:=bzcat
18
19 STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
20 BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
21 PKG_BUILD_DIR:=$(BUILD_DIR_HOST)/uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION)
22
23 include $(INCLUDE_DIR)/host-build.mk
24
25 STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
26 STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc-utils_installed
27
28 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
29 -e 's/i.86/i386/' \
30 -e 's/sparc.*/sparc/' \
31 -e 's/arm.*/arm/g' \
32 -e 's/avr32.*/avr32/g' \
33 -e 's/m68k.*/m68k/' \
34 -e 's/ppc/powerpc/g' \
35 -e 's/v850.*/v850/g' \
36 -e 's/sh64/sh/' \
37 -e 's/sh[234].*/sh/' \
38 -e 's/mips.*/mips/' \
39 -e 's/mipsel.*/mips/' \
40 -e 's/cris.*/cris/' \
41 )
42
43 define Build/Prepare
44 $(call Build/Prepare/Default)
45 $(CP) config/$(ARCH)$(if $(wildcard config/$(ARCH).$(BOARD)),$(BOARD)) $(PKG_BUILD_DIR)/.config
46 $(SED) 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE=\"$(LINUX_HEADERS_DIR)\",g' \
47 -e 's,.*HAS_FPU.*,HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,n),g' \
48 -e 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=$(if $(CONFIG_LARGEFILE),y,n),g' \
49 -e 's,.*DO_C99_MATH.*,DO_C99_MATH=$(if $(CONFIG_C99_MATH),y,n),g' \
50 $(PKG_BUILD_DIR)/.config
51 mkdir -p $(BUILD_DIR_HOST)/uClibc_dev/usr/include
52 mkdir -p $(BUILD_DIR_HOST)/uClibc_dev/usr/lib
53 mkdir -p $(BUILD_DIR_HOST)/uClibc_dev/lib
54 PATH=$(TARGET_PATH) $(MAKE) -C $(PKG_BUILD_DIR) \
55 PREFIX=$(BUILD_DIR_HOST)/uClibc_dev/ \
56 DEVEL_PREFIX=/usr/ \
57 RUNTIME_PREFIX=$(BUILD_DIR_HOST)/uClibc_dev/ \
58 HOSTCC="$(HOSTCC)" \
59 CPU_CFLAGS="$(TARGET_CFLAGS)" \
60 pregen install_dev;
61 endef
62
63 define Build/Configure
64 endef
65
66 UCLIBC_MAKE := PATH=$(TARGET_PATH) $(MAKE) -C $(PKG_BUILD_DIR) \
67 $(TARGET_CONFIGURE_OPTS) \
68 DEVEL_PREFIX=/ \
69 RUNTIME_PREFIX=/ \
70 HOSTCC="$(HOSTCC)" \
71 CPU_CFLAGS="$(TARGET_CFLAGS)"
72
73 define Build/Compile
74 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(PKG_BUILD_DIR)/Rules.mak
75 $(UCLIBC_MAKE) PREFIX= all
76 $(UCLIBC_MAKE) PREFIX=$(STAGING_DIR_HOST)/ install_runtime install_dev
77 $(SED) 's,UCLIBC_VERSION=.*,UCLIBC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
78 $(SED) 's,UCLIBC_PATCHVER=.*,UCLIBC_PATCHVER=$(PKG_EXTRAVERSION),' $(TOOLCHAIN_DIR)/info.mk
79 endef
80
81 define Build/Install
82 $(UCLIBC_MAKE) PREFIX= utils
83 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/target-utils
84 $(INSTALL_BIN) \
85 $(PKG_BUILD_DIR)/utils/ldd \
86 $(PKG_BUILD_DIR)/utils/ldconfig \
87 $(TOOLCHAIN_DIR)/target-utils/
88 endef
89
90 define Build/Clean
91 rm -rf $(PKG_BUILD_DIR) $(BUILD_DIR_HOST)/uClibc_dev
92 endef
93
94 $(eval $(call HostBuild))