summaryrefslogtreecommitdiff
path: root/mk/uclibc.mk
blob: 35dcf74591aef3a41ec71cce9066985a3ae96199 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
################################################################################
# GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
# Copyright(C) 2009 GAYE Abdoulaye Walsimou. All rights reserved.
#
# This program is free software; you can distribute it and/or modify it
# under the terms of the GNU General Public License
# (Version 2 or later) published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
################################################################################
#
# \file         uclibc.mk
# \brief	uclibc.mk of Embtoolkit
# \author       GAYE Abdoulaye Walsimou, <walsimou@walsimou.com>
# \date         August 2009
################################################################################

UCLIBC_VERSION := $(subst ",,$(strip $(CONFIG_EMBTK_UCLIBC_VERSION_STRING)))
UCLIBC_SITE := http://www.uclibc.org/downloads
UCLIBC_PATCH_SITE := ftp://ftp.embtoolkit.org/embtoolkit.org/uclibc/$(UCLIBC_VERSION)
UCLIBC_GIT_SITE := http://git.busybox.net/uClibc
UCLIBC_GIT_BRANCH := $(subst ",,$(strip $(CONFIG_EMBTK_UCLIBC_GIT_BRANCH)))
UCLIBC_GIT_REVISION := $(subst ",,$(strip $(CONFIG_EMBTK_UCLIBC_GIT_REVISION)))
UCLIBC_PACKAGE := uClibc-$(UCLIBC_VERSION).tar.bz2
UCLIBC_BUILD_DIR := $(TOOLS_BUILD)/uClibc-$(UCLIBC_VERSION)

uclibc_install: $(UCLIBC_BUILD_DIR)/.installed

$(UCLIBC_BUILD_DIR)/.installed: uclibc_download \
	$(UCLIBC_BUILD_DIR)/.decompressed $(UCLIBC_BUILD_DIR)/.configured
	$(call EMBTK_GENERIC_MESSAGE,"Building and installing \
	uClibc-$(UCLIBC_VERSION) ...")
	$(MAKE) -C $(UCLIBC_BUILD_DIR) oldconfig
	$(MAKE) -C $(UCLIBC_BUILD_DIR) \
	CROSS_COMPILER_PREFIX="$(TOOLS)/bin/$(STRICT_GNU_TARGET)-" \
	SHARED_LIB_LOADER_PREFIX="/$(LIBDIR)/" \
	MULTILIB_DIR="/$(LIBDIR)/" \
	RUNTIME_PREFIX="/" DEVEL_PREFIX="/usr/" \
	KERNEL_HEADERS="$(SYSROOT)/usr/include/" \
	UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS) -pipe"
	$(MAKE) -C $(UCLIBC_BUILD_DIR) PREFIX=$(SYSROOT)/ \
	CROSS_COMPILER_PREFIX="$(TOOLS)/bin/$(STRICT_GNU_TARGET)-" \
	SHARED_LIB_LOADER_PREFIX="/$(LIBDIR)/" \
	MULTILIB_DIR="/$(LIBDIR)/" \
	RUNTIME_PREFIX="/" DEVEL_PREFIX="/usr/" \
	KERNEL_HEADERS="$(SYSROOT)/usr/include/" \
	UCLIBC_EXTRA_CFLAGS="$(TARGET_CFLAGS) -pipe" install

uclibc_download:
	$(call EMBTK_GENERIC_MESSAGE,"downloading uClibc-$(UCLIBC_VERSION) \
	if necessary ...")
ifeq ($(CONFIG_EMBTK_UCLIBC_VERSION_GIT),y)
	@test -e $(EMBTK_ROOT)/src/uClibc-git || \
	git clone $(UCLIBC_GIT_SITE) $(EMBTK)/src/uClibc-git
ifneq ($(UCLIBC_GIT_BRANCH),master)
	@-cd $(EMBTK_ROOT)/src/uClibc-git; \
	git checkout master; \
	git pull; \
	git branch -D $(UCLIBC_GIT_BRANCH); \
	git checkout -b $(UCLIBC_GIT_BRANCH) origin/$(UCLIBC_GIT_BRANCH)
endif
	@cd $(EMBTK_ROOT)/src/uClibc-git; \
	git pull; \
	git checkout $(UCLIBC_GIT_REVISION); \
	cd ..; \
	tar cjvf $(UCLIBC_PACKAGE) uClibc-$(UCLIBC_VERSION); \
	mv $(UCLIBC_PACKAGE) $(DOWNLOAD_DIR)
else
	@test -e $(DOWNLOAD_DIR)/$(UCLIBC_PACKAGE) || \
	wget $(UCLIBC_SITE)/$(UCLIBC_PACKAGE) \
	-O $(DOWNLOAD_DIR)/$(UCLIBC_PACKAGE)
endif
ifeq ($(CONFIG_EMBTK_UCLIBC_NEED_PATCH),y)
	@test -e $(DOWNLOAD_DIR)/uClibc-$(UCLIBC_VERSION).patch || \
	wget -O $(DOWNLOAD_DIR)/uClibc-$(UCLIBC_VERSION).patch \
	$(UCLIBC_PATCH_SITE)/uClibc-$(UCLIBC_VERSION)-*.patch
endif

$(UCLIBC_BUILD_DIR)/.decompressed:
	$(call EMBTK_GENERIC_MESSAGE,"Decompressing \
	uClibc-$(UCLIBC_VERSION) ...")
	$(Q)tar -C $(TOOLS_BUILD) -xjvf $(DOWNLOAD_DIR)/$(UCLIBC_PACKAGE)
ifeq ($(CONFIG_EMBTK_UCLIBC_NEED_PATCH),y)
	$(Q)cd $(UCLIBC_BUILD_DIR); \
	patch -p1 < $(DOWNLOAD_DIR)/uClibc-$(UCLIBC_VERSION).patch
endif

$(UCLIBC_BUILD_DIR)/.configured:
	$(call EMBTK_GENERIC_MESSAGE,"Configuring \
	uClibc-$(UCLIBC_VERSION) ...")
	$(Q)grep "CONFIG_KEMBTK_UCLIBC_" $(EMBTK_ROOT)/.config | \
	sed -e 's/CONFIG_KEMBTK_UCLIBC_*//g' \
	> $(UCLIBC_BUILD_DIR)/.config