source: trunk/toolchain/make/target/uclibc/uclibc.mk @ 6384

Letzte Änderung dieser Datei seit 6384 war 6384, erstellt von er13 vor 8 Jahren

toolchain:

  • exclude kernel-headers from the download-toolchain
  • install the right ones at the build-time
  • refs #842, refs #348
Dateigröße: 9.1 KB
Zeile 
1UCLIBC_VERSION:=$(TARGET_TOOLCHAIN_UCLIBC_VERSION)
2UCLIBC_DIR:=$(TARGET_TOOLCHAIN_DIR)/uClibc-$(UCLIBC_VERSION)
3UCLIBC_MAKE_DIR:=$(TOOLCHAIN_DIR)/make/target/uclibc
4UCLIBC_SOURCE:=uClibc-$(UCLIBC_VERSION).tar.bz2
5UCLIBC_SOURCE_SITE:=http://www.uclibc.org/downloads
6ifeq ($(strip $(UCLIBC_VERSION)),0.9.28)
7UCLIBC_SOURCE_SITE:=http://www.uclibc.org/downloads/old-releases
8endif
9ifeq ($(strip $(UCLIBC_VERSION)),0.9.29)
10UCLIBC_SOURCE_SITE:=http://www.uclibc.org/downloads/old-releases
11endif
12
13UCLIBC_MD5_0.9.28 = 1ada58d919a82561061e4741fb6abd29
14UCLIBC_MD5_0.9.29 = 61dc55f43b17a38a074f347e74095b20
15UCLIBC_MD5_0.9.30.3 = 73a4bf4a0fa508b01a7a3143574e3d21
16UCLIBC_MD5_0.9.31   = 52fb8a494758630c8d3ddd7f1e0daafd
17UCLIBC_MD5=$(UCLIBC_MD5_$(UCLIBC_VERSION))
18
19UCLIBC_KERNEL_HEADERS_DIR:=$(KERNEL_HEADERS_DEVEL_DIR)
20
21UCLIBC_DEVEL_SUBDIR:=uClibc_dev
22
23# uClibc pregenerated locale data
24UCLIBC_LOCALE_DATA_SITE:=http://www.uclibc.org/downloads
25# TODO: FREETZ_TARGET_UCLIBC_REDUCED_LOCALE_SET is a REBUILD_SUBOPT
26ifeq ($(strip $(FREETZ_TARGET_UCLIBC_REDUCED_LOCALE_SET)),y)
27UCLIBC_LOCALE_DATA_FILENAME:=uClibc-locale-$(if $(FREETZ_TARGET_ARCH_BE),be,le)-32-de_DE-en_US.tar.gz
28else
29UCLIBC_LOCALE_DATA_FILENAME:=uClibc-locale-030818.tgz
30endif
31UCLIBC_COMMON_BUILD_FLAGS := LOCALE_DATA_FILENAME=$(UCLIBC_LOCALE_DATA_FILENAME)
32
33ifeq ($(strip $(FREETZ_VERBOSITY_LEVEL)),2)
34UCLIBC_COMMON_BUILD_FLAGS += V=1
35endif
36
37UCLIBC_HOST_CFLAGS:=$(TOOLCHAIN_HOST_CFLAGS) -U_GNU_SOURCE -fno-strict-aliasing
38
39$(DL_DIR)/$(UCLIBC_LOCALE_DATA_FILENAME): | $(DL_DIR)
40    $(DL_TOOL) $(DL_DIR) .config $(UCLIBC_LOCALE_DATA_FILENAME) $(UCLIBC_LOCALE_DATA_SITE)
41
42uclibc-source: $(DL_DIR)/$(UCLIBC_SOURCE)
43$(DL_DIR)/$(UCLIBC_SOURCE): | $(DL_DIR)
44    $(DL_TOOL) $(DL_DIR) .config $(UCLIBC_SOURCE) $(UCLIBC_SOURCE_SITE) $(UCLIBC_MD5)
45
46uclibc-unpacked: $(UCLIBC_DIR)/.unpacked
47$(UCLIBC_DIR)/.unpacked: $(DL_DIR)/$(UCLIBC_SOURCE) $(DL_DIR)/$(UCLIBC_LOCALE_DATA_FILENAME) | $(TARGET_TOOLCHAIN_DIR)
48    $(RM) -r $(UCLIBC_DIR)
49    tar -C $(TARGET_TOOLCHAIN_DIR) $(VERBOSE) -xjf $(DL_DIR)/$(UCLIBC_SOURCE)
50    set -e; \
51    for i in $(UCLIBC_MAKE_DIR)/$(UCLIBC_VERSION)/*.patch; do \
52        $(PATCH_TOOL) $(UCLIBC_DIR) $$i; \
53    done
54    cp -dpf $(DL_DIR)/$(UCLIBC_LOCALE_DATA_FILENAME) $(UCLIBC_DIR)/extra/locale/
55    touch $@
56
57$(UCLIBC_DIR)/.config: $(UCLIBC_DIR)/.unpacked
58    cp $(TOOLCHAIN_DIR)/make/target/uclibc/Config.$(TARGET_TOOLCHAIN_UCLIBC_REF).$(UCLIBC_VERSION) $(UCLIBC_DIR)/.config
59    $(call PKG_EDIT_CONFIG,CROSS=$(TARGET_MAKE_PATH)/$(TARGET_CROSS)) $(UCLIBC_DIR)/Rules.mak
60    $(call PKG_EDIT_CONFIG, \
61        $(if $(FREETZ_TARGET_UCLIBC_VERSION_0_9_28), \
62            KERNEL_SOURCE=\"$(UCLIBC_KERNEL_HEADERS_DIR)\" \
63        , \
64            KERNEL_HEADERS=\"$(UCLIBC_KERNEL_HEADERS_DIR)/include\" \
65            ARCH_WANTS_LITTLE_ENDIAN=$(if $(FREETZ_TARGET_ARCH_LE),y,n) \
66            ARCH_WANTS_BIG_ENDIAN=$(if $(FREETZ_TARGET_ARCH_LE),n,y) \
67        ) \
68        UCLIBC_HAS_IPV6=$(FREETZ_TARGET_IPV6_SUPPORT) \
69        UCLIBC_HAS_LFS=$(FREETZ_TARGET_LFS) \
70        UCLIBC_HAS_FOPEN_LARGEFILE_MODE=n \
71        UCLIBC_HAS_WCHAR=y \
72    ) $(UCLIBC_DIR)/.config
73
74    mkdir -p $(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/usr/include
75    mkdir -p $(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/usr/lib
76    mkdir -p $(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/lib
77    $(MAKE1) -C $(UCLIBC_DIR) \
78        $(UCLIBC_COMMON_BUILD_FLAGS) \
79        PREFIX=$(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/ \
80        DEVEL_PREFIX=/usr/ \
81        RUNTIME_PREFIX=$(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/ \
82        HOSTCC="$(TOOLCHAIN_HOSTCC) $(UCLIBC_HOST_CFLAGS)" \
83        oldconfig < /dev/null > /dev/null
84    touch $@
85
86$(UCLIBC_DIR)/.configured: $(UCLIBC_DIR)/.config
87    $(MAKE1) -C $(UCLIBC_DIR) \
88        $(UCLIBC_COMMON_BUILD_FLAGS) \
89        PREFIX=$(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/ \
90        DEVEL_PREFIX=/usr/ \
91        RUNTIME_PREFIX=$(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/ \
92        HOSTCC="$(TOOLCHAIN_HOSTCC) $(UCLIBC_HOST_CFLAGS)" headers \
93        $(if $(FREETZ_TARGET_UCLIBC_VERSION_0_9_28),install_dev,install_headers)
94    touch $@
95
96uclibc-menuconfig: $(UCLIBC_DIR)/.config
97    $(MAKE1) -C $(UCLIBC_DIR) \
98        $(UCLIBC_COMMON_BUILD_FLAGS) \
99        PREFIX=$(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/ \
100        DEVEL_PREFIX=/usr/ \
101        RUNTIME_PREFIX=$(TARGET_TOOLCHAIN_DIR)/$(UCLIBC_DEVEL_SUBDIR)/ \
102        HOSTCC="$(TOOLCHAIN_HOSTCC) $(UCLIBC_HOST_CFLAGS)" \
103        menuconfig && \
104    cp -f $^ $(TOOLCHAIN_DIR)/make/target/uclibc/Config.$(TARGET_TOOLCHAIN_UCLIBC_REF).$(UCLIBC_VERSION) && \
105    touch $^
106
107$(UCLIBC_DIR)/lib/libc.a: $(UCLIBC_DIR)/.configured $(GCC_BUILD_DIR1)/.installed
108    $(MAKE1) -C $(UCLIBC_DIR) \
109        $(UCLIBC_COMMON_BUILD_FLAGS) \
110        PREFIX= \
111        DEVEL_PREFIX=/ \
112        RUNTIME_PREFIX=/ \
113        HOSTCC="$(TOOLCHAIN_HOSTCC) $(UCLIBC_HOST_CFLAGS)" \
114        all
115ifeq ($(or $(strip $(FREETZ_TARGET_UCLIBC_VERSION_0_9_30)),$(strip $(FREETZ_TARGET_UCLIBC_VERSION_0_9_31))),y)
116    # At this point uClibc is compiled and there is no reason for us to recompile it.
117    # Remove some FORCE rule dependencies causing parts of uClibc to be recompiled (without a need)
118    # over and over again each time make is invoked within uClibc dir (the actual target doesn't matter).
119    # This is a bit dirty workaround we actually should get rid of as soon as we find a better solution.
120    for i in $(UCLIBC_DIR)/Makerules $(UCLIBC_DIR)/extra/locale/Makefile.in; do \
121        cp -a "$$i" "$$i-with-FORCE"; \
122        sed -i -r -e '/.*%[.]o[sS]:.*FORCE.*/s, FORCE , ,g' $$i; \
123    done;
124endif
125    touch -c $@
126
127ifeq ($(strip $(FREETZ_BUILD_TOOLCHAIN)),y)
128UCLIBC_PREREQ=$(GCC_BUILD_DIR1)/.installed
129$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib/libc.a: $(UCLIBC_DIR)/lib/libc.a
130    $(MAKE1) -C $(UCLIBC_DIR) \
131        $(UCLIBC_COMMON_BUILD_FLAGS) \
132        PREFIX=/ \
133        DEVEL_PREFIX=$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/ \
134        RUNTIME_PREFIX=$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/ \
135        install_runtime install_dev
136    # Copy some files to make mklibs happy
137ifneq ($(strip $(UCLIBC_VERSION)),0.9.28)
138    for f in libc_pic.a libdl_pic.a libpthread_pic.a; do \
139        $(RM) $(TARGET_TOOLCHAIN_STAGING_DIR)/lib/$$f; \
140    done; \
141    cp $(UCLIBC_DIR)/libc/libc_so.a $(TARGET_TOOLCHAIN_STAGING_DIR)/lib/libc_pic.a; \
142    cp $(UCLIBC_DIR)/libpthread/*/libpthread_so.a $(TARGET_TOOLCHAIN_STAGING_DIR)/lib/libpthread_pic.a ; \
143    cp $(UCLIBC_DIR)/ldso/libdl/libdl_so.a $(TARGET_TOOLCHAIN_STAGING_DIR)/lib/libdl_pic.a
144endif
145    # Build the host utils.
146    # Note: in order the host utils to work the __ELF_NATIVE_CLASS (= __WORDSIZE) of the host
147    # must match that of the target. That's the reason we hardcode the "-m32" option here.
148    $(MAKE1) -C $(UCLIBC_DIR)/utils \
149        $(UCLIBC_COMMON_BUILD_FLAGS) \
150        PREFIX=$(TARGET_TOOLCHAIN_STAGING_DIR) \
151        HOSTCC="$(TOOLCHAIN_HOSTCC) $(UCLIBC_HOST_CFLAGS) -m32" \
152        BUILD_LDFLAGS="$(if $(FREETZ_STATIC_TOOLCHAIN),-static)" \
153        hostutils
154    for i in ldd ldconfig; do \
155        install -c $(UCLIBC_DIR)/utils/$$i.host $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/$$i; \
156        $(HOST_STRIP) $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/$(REAL_GNU_TARGET_NAME)/bin/$$i; \
157        ln -sf ../$(REAL_GNU_TARGET_NAME)/bin/$$i $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/bin/$(REAL_GNU_TARGET_NAME)-$$i; \
158        ln -sf $(REAL_GNU_TARGET_NAME)-$$i $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/bin/$(GNU_TARGET_NAME)-$$i; \
159    done
160    touch -c $@
161
162$(TARGET_SPECIFIC_ROOT_DIR)/lib/libc.so.0: $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib/libc.a
163    $(MAKE1) -C $(UCLIBC_DIR) \
164        $(UCLIBC_COMMON_BUILD_FLAGS) \
165        PREFIX="$(FREETZ_BASE_DIR)/$(TARGET_SPECIFIC_ROOT_DIR)" \
166        DEVEL_PREFIX=/usr/ \
167        RUNTIME_PREFIX=/ \
168        install_runtime
169    touch -c $@
170else
171UCLIBC_PREREQ=$(TARGET_CROSS_COMPILER)
172$(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib/libc.a: $(TARGET_CROSS_COMPILER)
173    touch -c $@
174
175$(TARGET_SPECIFIC_ROOT_DIR)/lib/libc.so.0: $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib/libc.a
176    @$(RM) -r $(TARGET_SPECIFIC_ROOT_DIR)/lib
177    @mkdir -p $(TARGET_SPECIFIC_ROOT_DIR)/lib
178    for i in $(UCLIBC_FILES); do \
179        cp -a $(TARGET_TOOLCHAIN_STAGING_DIR)/lib/$$i $(TARGET_SPECIFIC_ROOT_DIR)/lib/$$i; \
180    done
181    ln -sf libuClibc-$(UCLIBC_VERSION).so $(TARGET_SPECIFIC_ROOT_DIR)/lib/libc.so
182    touch -c $@
183endif
184
185uclibc-configured: kernel-configured $(UCLIBC_DIR)/.configured
186
187uclibc: $(UCLIBC_PREREQ) $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib/libc.a $(TARGET_SPECIFIC_ROOT_DIR)/lib/libc.so.0
188
189uclibc-configured-source: uclibc-source
190
191uclibc-clean:
192    -$(MAKE1) -C $(UCLIBC_DIR) clean
193    $(RM) $(UCLIBC_DIR)/.config
194
195uclibc-dirclean:
196    $(RM) -r $(UCLIBC_DIR)
197
198.PHONY: uclibc-configured uclibc
199
200#############################################################
201#
202# uClibc for the target
203#
204#############################################################
205
206$(TARGET_UTILS_DIR)/usr/lib/libc.a: $(TARGET_TOOLCHAIN_STAGING_DIR)/usr/lib/libc.a
207    $(MAKE1) -C $(UCLIBC_DIR) \
208        $(UCLIBC_COMMON_BUILD_FLAGS) \
209        PREFIX=$(TARGET_UTILS_DIR) \
210        DEVEL_PREFIX=/usr/ \
211        RUNTIME_PREFIX=/ \
212        RUNTIME_PREFIX_LIB_FROM_DEVEL_PREFIX_LIB=/lib/ \
213        install_dev
214    # create two additional symlinks, required because libc.so is not really
215    # a shared lib, but a GNU ld script referencing the libs below
216    for f in libc.so.0 ld-uClibc.so.0; do \
217        ln -fs /lib/$$f $(TARGET_UTILS_DIR)/usr/lib/; \
218    done
219    $(call COPY_KERNEL_HEADERS,$(UCLIBC_KERNEL_HEADERS_DIR),$(TARGET_UTILS_DIR)/usr)
220    $(call REMOVE_DOC_NLS_DIRS,$(TARGET_UTILS_DIR))
221    touch -c $@
222
223uclibc_target: gcc uclibc $(TARGET_UTILS_DIR)/usr/lib/libc.a
224
225uclibc_target-clean: uclibc_target-dirclean
226    $(RM) $(TARGET_UTILS_DIR)/lib/libc.a
227
228uclibc_target-dirclean:
229    $(RM) -r $(TARGET_UTILS_DIR)/usr/include
Hinweis: Hilfe zum Repository-Browser finden Sie in TracBrowser.