source: trunk/toolchain/uClibc/Makefile @ 14397

Last change on this file since 14397 was 14397, checked in by nico, 8 years ago

[toolchain] cosmetic & coherency fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.8 KB
Line 
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#
7include $(TOPDIR)/rules.mk
8include $(INCLUDE_DIR)/target.mk
9
10PKG_NAME:=uClibc
11PKG_VERSION:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
12PKG_EXTRAVERSION:=$(call qstrip,$(CONFIG_UCLIBC_EXTRA_VERSION))
13PKG_VERSION_SNAPSHOT:=$(call qstrip,$(CONFIG_UCLIBC_VERSION_SNAPSHOT))
14ifeq ($(PKG_VERSION_SNAPSHOT),y)
15  PKG_SOURCE_URL:=http://www.uclibc.org/downloads/snapshots
16  PKG_SOURCE:=uClibc-snapshot.tar.bz2
17else
18  PKG_SOURCE_URL:=http://www.uclibc.org/downloads
19  PKG_SOURCE:=uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION).tar.bz2
20endif
21PATCH_DIR:=./patches/$(PKG_VERSION)$(PKG_EXTRAVERSION)
22CONFIG_DIR:=./config/$(PKG_VERSION)$(PKG_EXTRAVERSION)
23
24ifeq ($(PKG_VERSION),0.9.28)
25  ifeq ($(PKG_EXTRAVERSION),.2)
26    PKG_MD5SUM:=959f25286e317f0d9e2103445c5a14c2
27  endif
28  ifeq ($(PKG_EXTRAVERSION),.3)
29    PKG_MD5SUM:=428405a36b4662980d9343b32089b5a6
30  endif
31endif
32
33ifeq ($(PKG_VERSION),0.9.29)
34  ifeq ($(PKG_EXTRAVERSION),)
35    # currently the default version, no special sub-directory needed
36    PATCH_DIR:=./patches
37    CONFIG_DIR:=./config
38    PKG_MD5SUM:=61dc55f43b17a38a074f347e74095b20
39  endif
40endif
41
42ifeq ($(PKG_VERSION),0.9.30)
43  ifeq ($(PKG_EXTRAVERSION),)
44    PKG_MD5SUM:=e5766e2566e0297adebebbcc0aba1f2d
45  endif
46endif
47
48ifeq ($(PKG_VERSION_SNAPSHOT),y)
49  PATCH_DIR:=
50  CONFIG_DIR:=./config
51  PKG_MD5SUM:=
52endif
53
54STAGING_DIR_HOST:=$(TOOLCHAIN_DIR)
55BUILD_DIR_HOST:=$(BUILD_DIR_TOOLCHAIN)
56ifeq ($(PKG_VERSION_SNAPSHOT),y)
57  PKG_BUILD_DIR:=$(BUILD_DIR_HOST)/uClibc-$(PKG_EXTRAVERSION)
58else
59  PKG_BUILD_DIR:=$(BUILD_DIR_HOST)/uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION)
60endif
61
62override CONFIG_AUTOREBUILD=
63
64include $(INCLUDE_DIR)/host-build.mk
65
66STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
67STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc-utils_installed
68
69UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
70                -e 's/i.86/i386/' \
71                -e 's/sparc.*/sparc/' \
72                -e 's/arm.*/arm/g' \
73                -e 's/avr32.*/avr32/g' \
74                -e 's/m68k.*/m68k/' \
75                -e 's/ppc/powerpc/g' \
76                -e 's/v850.*/v850/g' \
77                -e 's/sh64/sh/' \
78                -e 's/sh[234].*/sh/' \
79                -e 's/mips.*/mips/' \
80                -e 's/mipsel.*/mips/' \
81                -e 's/cris.*/cris/' \
82)
83
84
85define Build/SetToolchainInfo
86        $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
87        $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.uclibc.org/,' $(TOOLCHAIN_DIR)/info.mk
88        $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
89        $(SED) 's,^\(LIBC_PATCHVER\)=.*,\1=$(PKG_EXTRAVERSION),' $(TOOLCHAIN_DIR)/info.mk
90endef
91
92define Build/Prepare/Snapshot
93        $(PKG_UNPACK)
94        rm -Rf $(PKG_BUILD_DIR)
95        ln -snf $(BUILD_DIR_TOOLCHAIN)/uClibc $(PKG_BUILD_DIR)
96        $(Build/Patch)
97        $(if $(QUILT),touch $(PKG_BUILD_DIR)/.quilt_used)
98endef
99
100define Build/Prepare/V_0_9_28
101        $(SED) 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE=\"$(BUILD_DIR_TOOLCHAIN)/linux\",g' \
102                $(PKG_BUILD_DIR)/.config
103 ifeq ($(CONFIG_SOFT_FLOAT),y)
104        $(SED) 's,.*HAS_FPU.*,HAS_FPU=n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,g' $(PKG_BUILD_DIR)/.config
105 endif
106 ifeq ($(CONFIG_C99_MATH),y)
107        $(SED) 's,.*DO_C99_MATH.*,DO_C99_MATH=y,g' $(PKG_BUILD_DIR)/.config
108 endif
109endef
110
111define Build/Prepare
112        $(call Build/SetToolchainInfo)
113        @echo prepare uClibc version $(PKG_VERSION)$(PKG_EXTRAVERSION) 
114 ifeq ($(PKG_VERSION_SNAPSHOT),y)
115        $(call Build/Prepare/Snapshot)
116 else
117        $(call Build/Prepare/Default)
118        ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
119 endif
120        $(CP) ./$(CONFIG_DIR)/$(ARCH)$(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD)) $(PKG_BUILD_DIR)/.config
121 ifeq ($(PKG_VERSION),0.9.28)
122        $(call Build/Prepare/V_0_9_28)
123 endif
124        $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/usr/include\",g' \
125                -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
126                -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
127                -e 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=$(if $(CONFIG_LARGEFILE),y,n),g' \
128                -e 's,^.*CONFIG_ARM_EABI.*,CONFIG_ARM_EABI=$(if $(CONFIG_EABI_SUPPORT),y,n),g' \
129                -e 's,^.*CONFIG_ARM_OABI.*,CONFIG_ARM_OABI=$(if $(CONFIG_EABI_SUPPORT),n,y),g' \
130                -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
131                $(PKG_BUILD_DIR)/.config
132        $(MAKE) -C $(PKG_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
133        PATH=$(TARGET_PATH) $(MAKE) -C $(PKG_BUILD_DIR) \
134                PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
135                DEVEL_PREFIX=/usr/ \
136                RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
137                HOSTCC="$(HOSTCC)" \
138                CC="$(TARGET_CC)" \
139                CPU_CFLAGS="$(TARGET_CFLAGS)" \
140                pregen \
141                $(if $(CONFIG_UCLIBC_VERSION_0_9_28),install_dev,install_headers)
142endef
143
144define Build/Configure
145endef
146
147UCLIBC_MAKE := PATH=$(TARGET_PATH) $(MAKE) -C $(PKG_BUILD_DIR) \
148        $(TARGET_CONFIGURE_OPTS) \
149        DEVEL_PREFIX=/usr/ \
150        RUNTIME_PREFIX=/ \
151        HOSTCC="$(HOSTCC)" \
152        CPU_CFLAGS="$(TARGET_CFLAGS)" \
153        DOSTRIP=""
154
155define Build/Compile
156        $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(PKG_BUILD_DIR)/Rules.mak
157        $(UCLIBC_MAKE) PREFIX= all
158        $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
159        ln -sf ../../lib/libc.so.0 $(TOOLCHAIN_DIR)/usr/lib/libc.so
160#       ( cd $(TOOLCHAIN_DIR) ; \
161#               for d in lib usr/lib ; do \
162#                 for f in libc.so libpthread.so libgcc_s.so ; do \
163#                   if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
164#                     $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
165#                   fi \
166#                 done \
167#               done \
168#       )
169endef
170
171define Build/Install
172        $(UCLIBC_MAKE) PREFIX= utils
173        $(INSTALL_DIR) $(TOOLCHAIN_DIR)/usr/bin
174        $(INSTALL_BIN) \
175                $(PKG_BUILD_DIR)/utils/ldd \
176                $(TOOLCHAIN_DIR)/usr/bin/
177        $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
178        $(INSTALL_BIN) \
179                $(PKG_BUILD_DIR)/utils/ldconfig \
180                $(TOOLCHAIN_DIR)/sbin/
181endef
182
183define Build/Clean
184        rm -rf \
185                $(PKG_BUILD_DIR) \
186                $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
187                $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
188endef
189
190$(eval $(call HostBuild))
Note: See TracBrowser for help on using the repository browser.