clean up uclibc patch/config version handling a bit
[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 PKG_EXTRAVERSION:=$(call qstrip,$(CONFIG_UCLIBC_EXTRA_VERSION))
13 PKG_VERSION_SNAPSHOT:=$(call qstrip,$(CONFIG_UCLIBC_VERSION_SNAPSHOT))
14 ifeq ($(PKG_VERSION_SNAPSHOT),y)
15 PKG_SOURCE_URL:=http://www.uclibc.org/downloads/snapshots
16 PKG_SOURCE:=uClibc-snapshot.tar.bz2
17 else
18 PKG_SOURCE_URL:=http://www.uclibc.org/downloads
19 PKG_SOURCE:=uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION).tar.bz2
20 endif
21 PATCH_DIR:=$(firstword $(wildcard ./patches-$(PKG_VERSION)$(PKG_EXTRAVERSION) ./patches-$(PKG_VERSION)))
22 CONFIG_DIR:=$(firstword $(wildcard ./config-$(PKG_VERSION)$(PKG_EXTRAVERSION) ./config-$(PKG_VERSION)))
23
24 PKG_MD5SUM_0.9.28.2 = 959f25286e317f0d9e2103445c5a14c2
25 PKG_MD5SUM_0.9.28.3 = 428405a36b4662980d9343b32089b5a6
26 PKG_MD5SUM_0.9.29 = 61dc55f43b17a38a074f347e74095b20
27 PKG_MD5SUM_0.9.30 = e5766e2566e0297adebebbcc0aba1f2d
28 PKG_MD5SUM=$(PKG_MD5SUM_$(PKG_VERSION)$(PKG_EXTRAVERSION))
29
30 ifeq ($(PKG_VERSION_SNAPSHOT),y)
31 PATCH_DIR:=
32 CONFIG_DIR:=./config-0.9.30
33 PKG_MD5SUM:=
34 endif
35
36 ifeq ($(PKG_VERSION_SNAPSHOT),y)
37 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/uClibc-$(PKG_EXTRAVERSION)
38 else
39 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION)
40 endif
41
42 include $(INCLUDE_DIR)/toolchain-build.mk
43
44 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
45 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc-utils_installed
46
47 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
48 -e 's/i.86/i386/' \
49 -e 's/sparc.*/sparc/' \
50 -e 's/arm.*/arm/g' \
51 -e 's/avr32.*/avr32/g' \
52 -e 's/m68k.*/m68k/' \
53 -e 's/ppc/powerpc/g' \
54 -e 's/v850.*/v850/g' \
55 -e 's/sh64/sh/' \
56 -e 's/sh[234].*/sh/' \
57 -e 's/mips.*/mips/' \
58 -e 's/mipsel.*/mips/' \
59 -e 's/cris.*/cris/' \
60 )
61
62
63 define Host/SetToolchainInfo
64 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
65 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.uclibc.org/,' $(TOOLCHAIN_DIR)/info.mk
66 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
67 $(SED) 's,^\(LIBC_PATCHVER\)=.*,\1=$(PKG_EXTRAVERSION),' $(TOOLCHAIN_DIR)/info.mk
68 endef
69
70 define Host/Prepare/Snapshot
71 $(PKG_UNPACK)
72 rm -Rf $(HOST_BUILD_DIR)
73 ln -snf $(BUILD_DIR_TOOLCHAIN)/uClibc $(HOST_BUILD_DIR)
74 $(Host/Patch)
75 $(if $(QUILT),touch $(HOST_BUILD_DIR)/.quilt_used)
76 endef
77
78 define Host/Prepare/V_0_9_28
79 $(SED) 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE=\"$(BUILD_DIR_TOOLCHAIN)/linux\",g' \
80 $(HOST_BUILD_DIR)/.config
81 ifeq ($(CONFIG_SOFT_FLOAT),y)
82 $(SED) 's,.*HAS_FPU.*,HAS_FPU=n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,g' $(HOST_BUILD_DIR)/.config
83 endif
84 ifeq ($(CONFIG_C99_MATH),y)
85 $(SED) 's,.*DO_C99_MATH.*,DO_C99_MATH=y,g' $(HOST_BUILD_DIR)/.config
86 endif
87 endef
88
89 define Host/Prepare
90 $(call Host/SetToolchainInfo)
91 @echo prepare uClibc version $(PKG_VERSION)$(PKG_EXTRAVERSION)
92 ifeq ($(PKG_VERSION_SNAPSHOT),y)
93 $(call Host/Prepare/Snapshot)
94 else
95 $(call Host/Prepare/Default)
96 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
97 endif
98 $(CP) ./$(CONFIG_DIR)/$(ARCH)$(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD)) $(HOST_BUILD_DIR)/.config
99 ifeq ($(PKG_VERSION),0.9.28)
100 $(call Host/Prepare/V_0_9_28)
101 endif
102 $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include\",g' \
103 -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
104 -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
105 -e 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=$(if $(CONFIG_LARGEFILE),y,n),g' \
106 -e 's,^.*CONFIG_ARM_EABI.*,CONFIG_ARM_EABI=$(if $(CONFIG_EABI_SUPPORT),y,n),g' \
107 -e 's,^.*CONFIG_ARM_OABI.*,CONFIG_ARM_OABI=$(if $(CONFIG_EABI_SUPPORT),n,y),g' \
108 -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
109 $(HOST_BUILD_DIR)/.config
110 $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
111 PATH=$(TARGET_PATH) $(MAKE) -C $(HOST_BUILD_DIR) \
112 PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
113 DEVEL_PREFIX=/usr/ \
114 RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
115 HOSTCC="$(HOSTCC)" \
116 CC="$(TARGET_CC)" \
117 CPU_CFLAGS="$(TARGET_CFLAGS)" \
118 pregen \
119 $(if $(CONFIG_UCLIBC_VERSION_0_9_28),install_dev,install_headers)
120 endef
121
122 define Host/Configure
123 endef
124
125 UCLIBC_MAKE := PATH=$(TARGET_PATH) $(MAKE) -C $(HOST_BUILD_DIR) \
126 $(TARGET_CONFIGURE_OPTS) \
127 DEVEL_PREFIX=/usr/ \
128 RUNTIME_PREFIX=/ \
129 HOSTCC="$(HOSTCC)" \
130 CPU_CFLAGS="$(TARGET_CFLAGS)" \
131 DOSTRIP=""
132
133 define Host/Compile
134 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
135 $(UCLIBC_MAKE) PREFIX= all
136 $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
137 ln -sf ../../lib/libc.so.0 $(TOOLCHAIN_DIR)/usr/lib/libc.so
138 # ( cd $(TOOLCHAIN_DIR) ; \
139 # for d in lib usr/lib ; do \
140 # for f in libc.so libpthread.so libgcc_s.so ; do \
141 # if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
142 # $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
143 # fi \
144 # done \
145 # done \
146 # )
147 endef
148
149 define Host/Install
150 $(UCLIBC_MAKE) PREFIX= utils
151 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/usr/bin
152 $(INSTALL_BIN) \
153 $(HOST_BUILD_DIR)/utils/ldd \
154 $(TOOLCHAIN_DIR)/usr/bin/
155 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
156 $(INSTALL_BIN) \
157 $(HOST_BUILD_DIR)/utils/ldconfig \
158 $(TOOLCHAIN_DIR)/sbin/
159 endef
160
161 define Host/Clean
162 rm -rf \
163 $(HOST_BUILD_DIR) \
164 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
165 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
166 endef
167
168 $(eval $(call HostBuild))
This page took 0.043788 seconds and 5 git commands to generate.