f7b6d2be6a9a6635255f6b8aeed53fbc49cd09fc
[openwrt.git] / openwrt / toolchain / uClibc / uclibc.mk
1 #############################################################
2 #
3 # uClibc (the C library)
4 #
5 #############################################################
6
7 ifeq ($(BR2_UCLIBC_VERSION_SNAPSHOT),y)
8 # Be aware that this changes daily....
9 UCLIBC_DIR:=$(TOOL_BUILD_DIR)/uClibc
10 UCLIBC_SOURCE:=uClibc-$(strip $(subst ",, $(BR2_USE_UCLIBC_SNAPSHOT))).tar.bz2
11 #"
12 UCLIBC_SITE:=http://www.uclibc.org/downloads/snapshots
13 else
14 UCLIBC_DIR:=$(TOOL_BUILD_DIR)/uClibc-0.9.27
15 UCLIBC_SOURCE:=uClibc-0.9.27.tar.bz2
16 UCLIBC_SITE:=http://www.uclibc.org/downloads
17 endif
18
19 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
20 -e 's/i.86/i386/' \
21 -e 's/sparc.*/sparc/' \
22 -e 's/arm.*/arm/g' \
23 -e 's/m68k.*/m68k/' \
24 -e 's/ppc/powerpc/g' \
25 -e 's/v850.*/v850/g' \
26 -e 's/sh64/sh/' \
27 -e 's/sh[234].*/sh/' \
28 -e 's/mips.*/mips/' \
29 -e 's/mipsel.*/mips/' \
30 -e 's/cris.*/cris/' \
31 )
32
33
34 $(DL_DIR)/$(UCLIBC_SOURCE):
35 mkdir -p $(DL_DIR)
36 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(UCLIBC_SOURCE) x $(UCLIBC_SITE)
37
38 $(UCLIBC_DIR)/.unpacked: $(DL_DIR)/$(UCLIBC_SOURCE)
39 mkdir -p $(TOOL_BUILD_DIR)
40 bzcat $(DL_DIR)/$(UCLIBC_SOURCE) | tar -C $(TOOL_BUILD_DIR) $(TAR_OPTIONS) -
41 touch $(UCLIBC_DIR)/.unpacked
42
43 $(UCLIBC_DIR)/.configured: $(UCLIBC_DIR)/.unpacked
44 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(UCLIBC_DIR)/Rules.mak
45 ifeq ($(BR2_ENABLE_LOCALE),y)
46 cp ./uClibc.config-locale $(UCLIBC_DIR)/.config
47 else
48 cp ./uClibc.config $(UCLIBC_DIR)/.config
49 endif
50 $(SED) 's,^.*TARGET_$(UCLIBC_TARGET_ARCH).*,TARGET_$(UCLIBC_TARGET_ARCH)=y,g' \
51 $(UCLIBC_DIR)/.config
52 $(SED) 's,^TARGET_ARCH.*,TARGET_ARCH=\"$(UCLIBC_TARGET_ARCH)\",g' $(UCLIBC_DIR)/.config
53 $(SED) 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE=\"$(LINUX_HEADERS_DIR)\",g' \
54 $(UCLIBC_DIR)/.config
55 $(SED) 's,^RUNTIME_PREFIX=.*,RUNTIME_PREFIX=\"/\",g' \
56 $(UCLIBC_DIR)/.config
57 $(SED) 's,^DEVEL_PREFIX=.*,DEVEL_PREFIX=\"/usr/\",g' \
58 $(UCLIBC_DIR)/.config
59 $(SED) 's,^SHARED_LIB_LOADER_PREFIX=.*,SHARED_LIB_LOADER_PREFIX=\"/lib\",g' \
60 $(UCLIBC_DIR)/.config
61 ifeq ($(BR2_LARGEFILE),y)
62 $(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=y,g' $(UCLIBC_DIR)/.config
63 else
64 $(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=n,g' $(UCLIBC_DIR)/.config
65 endif
66 $(SED) 's,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g' $(UCLIBC_DIR)/.config
67 ifeq ($(BR2_SOFT_FLOAT),y)
68 $(SED) 's,.*HAS_FPU.*,HAS_FPU=n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,g' $(UCLIBC_DIR)/.config
69 endif
70 mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/usr/include
71 mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/usr/lib
72 mkdir -p $(TOOL_BUILD_DIR)/uClibc_dev/lib
73 $(MAKE1) -C $(UCLIBC_DIR) \
74 PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
75 DEVEL_PREFIX=/usr/ \
76 RUNTIME_PREFIX=$(TOOL_BUILD_DIR)/uClibc_dev/ \
77 HOSTCC="$(HOSTCC)" \
78 pregen install_dev;
79 touch $(UCLIBC_DIR)/.configured
80
81 $(UCLIBC_DIR)/lib/libc.a: $(UCLIBC_DIR)/.configured $(LIBFLOAT_TARGET)
82 $(MAKE1) -C $(UCLIBC_DIR) \
83 PREFIX= \
84 DEVEL_PREFIX=/ \
85 RUNTIME_PREFIX=/ \
86 HOSTCC="$(HOSTCC)" \
87 all
88 touch -c $(UCLIBC_DIR)/lib/libc.a
89
90 $(STAGING_DIR)/lib/libc.a: $(UCLIBC_DIR)/lib/libc.a
91 $(MAKE1) -C $(UCLIBC_DIR) \
92 PREFIX=$(STAGING_DIR)/ \
93 DEVEL_PREFIX=/ \
94 RUNTIME_PREFIX=/ \
95 install_runtime
96 $(MAKE1) -C $(UCLIBC_DIR) \
97 PREFIX=$(STAGING_DIR)/ \
98 DEVEL_PREFIX=/ \
99 RUNTIME_PREFIX=/ \
100 install_dev
101 # Build the host utils. Need to add an install target...
102 $(MAKE1) -C $(UCLIBC_DIR)/utils \
103 PREFIX=$(STAGING_DIR) \
104 HOSTCC="$(HOSTCC)" \
105 hostutils
106 touch -c $(STAGING_DIR)/lib/libc.a
107
108 ifneq ($(TARGET_DIR),)
109 $(TARGET_DIR)/lib/libc.so.0: $(STAGING_DIR)/lib/libc.a
110 $(MAKE1) -C $(UCLIBC_DIR) \
111 PREFIX=$(TARGET_DIR) \
112 DEVEL_PREFIX=/usr/ \
113 RUNTIME_PREFIX=/ \
114 install_runtime
115 touch -c $(TARGET_DIR)/lib/libc.so.0
116
117 $(TARGET_DIR)/usr/bin/ldd:
118 $(MAKE1) -C $(UCLIBC_DIR) $(TARGET_CONFIGURE_OPTS) \
119 PREFIX=$(TARGET_DIR) utils install_utils
120 touch -c $(TARGET_DIR)/usr/bin/ldd
121
122 UCLIBC_TARGETS=$(TARGET_DIR)/lib/libc.so.0
123 endif
124
125 uclibc-configured: $(UCLIBC_DIR)/.configured
126
127 uclibc: $(STAGING_DIR)/lib/libc.a \
128 $(UCLIBC_TARGETS)
129
130 uclibc-source: $(DL_DIR)/$(UCLIBC_SOURCE)
131
132 uclibc-configured-source: uclibc-source
133
134 uclibc-clean:
135 -$(MAKE1) -C $(UCLIBC_DIR) clean
136 rm -f $(UCLIBC_DIR)/.config
137
138 uclibc-toolclean:
139 rm -rf $(UCLIBC_DIR)
140
141 uclibc-target-utils: $(TARGET_DIR)/usr/bin/ldd
142
143 #############################################################
144 #
145 # uClibc for the target just needs its header files
146 # and whatnot installed.
147 #
148 #############################################################
149
150 $(TARGET_DIR)/usr/lib/libc.a: $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib/libc.a
151 $(MAKE1) -C $(UCLIBC_DIR) \
152 PREFIX=$(TARGET_DIR) \
153 DEVEL_PREFIX=/usr/ \
154 RUNTIME_PREFIX=/ \
155 install_dev
156 touch -c $(TARGET_DIR)/usr/lib/libc.a
157
158 uclibc_target: gcc uclibc $(TARGET_DIR)/usr/lib/libc.a $(TARGET_DIR)/usr/bin/ldd
159
160 uclibc_target-clean:
161 rm -f $(TARGET_DIR)/include
162
163 uclibc_target-dirclean:
164 rm -f $(TARGET_DIR)/include
165
This page took 0.044668 seconds and 3 git commands to generate.