e9925848cced0a32556ef94828a9aa5a4c261662
[openwrt.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.29
12 PKG_EXTRAVERSION:=
13
14 PKG_SOURCE:=uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION).tar.bz2
15 PKG_SOURCE_URL:=http://www.uclibc.org/downloads
16 PKG_MD5SUM:=61dc55f43b17a38a074f347e74095b20
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_HEADERS=.*,KERNEL_HEADERS=\"$(LINUX_HEADERS_DIR)/include\",g' \
47 -e 's,.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,y),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 # if [ ! -f $(BUILD_DIR_HOST)/uClibc_dev/usr/include/linux/version.h ] ; then \
55 # cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/* $(BUILD_DIR_HOST)/uClibc_dev/usr/include/; \
56 # cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/* $(TOOLCHAIN_DIR)/include/ ; \
57 # cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/* $(PKG_BUILD_DIR)/include/ ; \
58 # fi;
59 if [ ! -f $(BUILD_DIR_HOST)/uClibc_dev/usr/include/linux/version.h ] ; then \
60 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm $(BUILD_DIR_HOST)/uClibc_dev/usr/include/; \
61 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-$(UCLIBC_TARGET_ARCH) $(BUILD_DIR_HOST)/uClibc_dev/usr/include/; \
62 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-generic $(BUILD_DIR_HOST)/uClibc_dev/usr/include/; \
63 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/linux $(BUILD_DIR_HOST)/uClibc_dev/usr/include/; \
64 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm $(TOOLCHAIN_DIR)/include/ ; \
65 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-$(UCLIBC_TARGET_ARCH) $(TOOLCHAIN_DIR)/include/ ; \
66 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-generic $(TOOLCHAIN_DIR)/include/ ; \
67 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/linux $(TOOLCHAIN_DIR)/include/ ; \
68 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm $(PKG_BUILD_DIR)/include/ ; \
69 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-$(UCLIBC_TARGET_ARCH) $(PKG_BUILD_DIR)/include/ ; \
70 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/asm-generic $(PKG_BUILD_DIR)/include/ ; \
71 cp -pLR $(BUILD_DIR_TOOLCHAIN)/linux/include/linux $(PKG_BUILD_DIR)/include/ ; \
72 fi;
73 PATH=$(TARGET_PATH) $(MAKE) -C $(PKG_BUILD_DIR) \
74 PREFIX=$(BUILD_DIR_HOST)/uClibc_dev/ \
75 DEVEL_PREFIX=/usr/ \
76 RUNTIME_PREFIX=$(BUILD_DIR_HOST)/uClibc_dev/ \
77 HOSTCC="$(HOSTCC)" \
78 CPU_CFLAGS="$(TARGET_CFLAGS)" \
79 pregen install_dev;
80 endef
81
82 define Build/Configure
83 endef
84
85 UCLIBC_MAKE := PATH=$(TARGET_PATH) $(MAKE) -C $(PKG_BUILD_DIR) \
86 $(TARGET_CONFIGURE_OPTS) \
87 DEVEL_PREFIX=/ \
88 RUNTIME_PREFIX=/ \
89 HOSTCC="$(HOSTCC)" \
90 CPU_CFLAGS="$(TARGET_CFLAGS)"
91
92 define Build/Compile
93 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(PKG_BUILD_DIR)/Rules.mak
94 $(UCLIBC_MAKE) PREFIX= all
95 $(UCLIBC_MAKE) PREFIX=$(STAGING_DIR_HOST)/ install_runtime install_dev
96 $(SED) 's,UCLIBC_VERSION=.*,UCLIBC_VERSION=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
97 $(SED) 's,UCLIBC_PATCHVER=.*,UCLIBC_PATCHVER=$(PKG_EXTRAVERSION),' $(TOOLCHAIN_DIR)/info.mk
98 rm -rf $(TOOLCHAIN_DIR)/lib/libc.so
99 ln -s $(TOOLCHAIN_DIR)/lib/libc.so.0 $(TOOLCHAIN_DIR)/lib/libc.so
100 endef
101
102 define Build/Install
103 $(UCLIBC_MAKE) PREFIX= utils
104 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/target-utils
105 $(INSTALL_BIN) \
106 $(PKG_BUILD_DIR)/utils/ldd \
107 $(PKG_BUILD_DIR)/utils/ldconfig \
108 $(TOOLCHAIN_DIR)/target-utils/
109 endef
110
111 define Build/Clean
112 rm -rf $(PKG_BUILD_DIR) $(BUILD_DIR_HOST)/uClibc_dev
113 endef
114
115 $(eval $(call HostBuild))
This page took 0.050665 seconds and 3 git commands to generate.