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