b2eb0b7b2a78290f052b8e6322c1ccbe78852695
[people/pmueller/ipfire-2.x.git] / src / uClibc / make / uclibc.mk
1 #############################################################
2 #
3 # uClibc (the C library)
4 #
5 #############################################################
6 ifeq ($(USE_UCLIBC_SNAPSHOT),true)
7 # Be aware that this changes daily....
8 UCLIBC_DIR=$(TOOL_BUILD_DIR)/uClibc
9 UCLIBC_SOURCE=uClibc-snapshot.tar.gz
10 UCLIBC_SITE:=http://www.uclibc.org/downloads/snapshots
11 else
12 UCLIBC_DIR:=$(TOOL_BUILD_DIR)/uClibc-0.9.28
13 UCLIBC_SOURCE:=uClibc-0.9.28.tar.bz2
14 UCLIBC_SITE:=http://www.uclibc.org/downloads
15 endif
16 LINUX_DIR:=/usr/src/linux
17
18 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
19 -e 's/i.86/i386/' \
20 -e 's/sparc.*/sparc/' \
21 -e 's/arm.*/arm/g' \
22 -e 's/m68k.*/m68k/' \
23 -e 's/ppc/powerpc/g' \
24 -e 's/v850.*/v850/g' \
25 -e 's/sh64/sh/' \
26 -e 's/sh[234]/sh/' \
27 -e 's/mips.*/mips/' \
28 -e 's/mipsel.*/mips/' \
29 -e 's/cris.*/cris/' \
30 )
31
32
33 $(DL_DIR)/$(UCLIBC_SOURCE):
34 # $(WGET) -P $(DL_DIR) $(UCLIBC_SITE)/$(UCLIBC_SOURCE)
35
36 $(UCLIBC_DIR)/.unpacked: $(DL_DIR)/$(UCLIBC_SOURCE)
37 bzip2 -dc $(DL_DIR)/$(UCLIBC_SOURCE) | tar -C $(TOOL_BUILD_DIR) -xf -
38 sed -i -e 's/include <sys\/types.h>/include <sys\/types.h>\n#include <pthread.h>/' $(UCLIBC_DIR)/librt/kernel-posix-timers.h
39 touch $(UCLIBC_DIR)/.unpacked
40
41 $(UCLIBC_DIR)/.configured: $(UCLIBC_DIR)/.unpacked
42 $(MAKE) -C $(UCLIBC_DIR) defconfig;
43 cp $(SOURCE_DIR)/uClibc.config-$(MACHINE) $(UCLIBC_DIR)/.config
44 cp $(SOURCE_DIR)/locales.txt $(UCLIBC_DIR)/extra/locale
45 cp $(SOURCE_DIR)/codesets.txt $(UCLIBC_DIR)/extra/locale
46 $(MAKE) -C $(UCLIBC_DIR) PREFIX=$(STAGING_DIR) headers;
47 (cd $(UCLIBC_DIR)/extra/locale; \
48 patch -Np0 < /usr/src/src/patches/uClibc-gen_wctype-segfault.patch; \
49 $(MAKE); \
50 )
51 $(MAKE) -C $(UCLIBC_DIR) PREFIX=$(STAGING_DIR) install_dev;
52 rm -rf $(STAGING_DIR)/include
53 ln -s $(STAGING_DIR)/usr/include $(STAGING_DIR)/include
54 touch $(UCLIBC_DIR)/.configured
55
56 $(UCLIBC_DIR)/lib/libc.a: $(UCLIBC_DIR)/.configured $(LIBFLOAT_TARGET)
57 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(UCLIBC_DIR)/Rules.mak
58 $(MAKE) -C $(UCLIBC_DIR) oldconfig
59 $(MAKE) -C $(UCLIBC_DIR) headers
60 -$(MAKE) -C $(UCLIBC_DIR) pregen
61 (cd $(UCLIBC_DIR)/extra/locale; \
62 patch -Np0 < /usr/src/src/patches/uClibc-gen_wctype-segfault.patch; \
63 $(MAKE); \
64 )
65 $(MAKE) -C $(UCLIBC_DIR)
66
67 $(STAGING_DIR)/lib/libc.a: $(UCLIBC_DIR)/lib/libc.a
68 $(MAKE) -C $(UCLIBC_DIR) PREFIX=$(STAGING_DIR) install_dev install_runtime
69 $(MAKE) -C $(UCLIBC_DIR) PREFIX=$(STAGING_DIR) utils install_utils
70 # Clean up the host compiled utils...
71 $(MAKE) -C $(UCLIBC_DIR)/utils clean
72 (cd $(STAGING_DIR)/lib; \
73 ln -fs libc.so.0 libc.so; \
74 ln -fs libdl.so.0 libdl.so; \
75 ln -fs libcrypt.so.0 libcrypt.so; \
76 ln -fs libresolv.so.0 libresolv.so; \
77 ln -fs libutil.so.0 libutil.so; \
78 ln -fs libm.so.0 libm.so; \
79 ln -fs libpthread.so.0 libpthread.so; \
80 ln -fs libnsl.so.0 libnsl.so; \
81 ln -fs libthread_db.so.1 libthread_db.so; \
82 )
83
84 ifneq ($(TARGET_DIR),)
85 $(TARGET_DIR)/lib/libc.so.0: $(STAGING_DIR)/lib/libc.a
86 $(MAKE) -C $(UCLIBC_DIR) PREFIX=$(TARGET_DIR) install_runtime
87
88 $(TARGET_DIR)/usr/bin/ldd: $(TARGET_DIR)/lib/libc.so.0
89 $(MAKE) -C $(UCLIBC_DIR) $(TARGET_CONFIGURE_OPTS) \
90 PREFIX=$(TARGET_DIR) utils install_utils
91
92 UCLIBC_TARGETS=$(TARGET_DIR)/lib/libc.so.0 $(TARGET_DIR)/usr/bin/ldd
93 endif
94
95 uclibc-configured: $(UCLIBC_DIR)/.configured
96
97 uclibc: $(STAGING_DIR)/bin/$(ARCH)-linux-uclibc-gcc $(STAGING_DIR)/lib/libc.a \
98 $(UCLIBC_TARGETS)
99
100 uclibc-source: $(DL_DIR)/$(UCLIBC_SOURCE)
101
102 uclibc-configured-source: uclibc-source
103
104 uclibc-clean:
105 -$(MAKE) -C $(UCLIBC_DIR) clean
106 rm -f $(UCLIBC_DIR)/.config
107
108 uclibc-dirclean:
109 rm -rf $(UCLIBC_DIR)
110
111
112
113
114 #############################################################
115 #
116 # uClibc for the target just needs its header files
117 # and whatnot installed.
118 #
119 #############################################################
120
121 $(TARGET_DIR)/usr/lib/libc.a: $(STAGING_DIR)/lib/libc.a
122 $(MAKE) -C $(UCLIBC_DIR) $(TARGET_CONFIGURE_OPTS) \
123 PREFIX=$(TARGET_DIR) install_dev
124 (cd $(TARGET_DIR)/usr/lib; \
125 ln -fs /lib/libc.so.0 libc.so; \
126 ln -fs /lib/libdl.so.0 libdl.so; \
127 ln -fs /lib/libcrypt.so.0 libcrypt.so; \
128 ln -fs /lib/libresolv.so.0 libresolv.so; \
129 ln -fs /lib/libutil.so.0 libutil.so; \
130 ln -fs /lib/libm.so.0 libm.so; \
131 ln -fs /lib/libpthread.so.0 libpthread.so; \
132 ln -fs /lib/libnsl.so.0 libnsl.so; \
133 ln -fs /lib/libthread_db.so.1 libthread_db.so; \
134 )
135
136 ifeq ($(GCC_2_95_TOOLCHAIN),true)
137 uclibc_target: gcc2_95 uclibc $(TARGET_DIR)/usr/lib/libc.a
138 else
139 uclibc_target: gcc3_3 uclibc $(TARGET_DIR)/usr/lib/libc.a
140 endif
141
142 uclibc_target-clean:
143 rm -f $(TARGET_DIR)/include
144
145 uclibc_target-dirclean:
146 rm -f $(TARGET_DIR)/include
147