fix an uClibc compile error that only happens on rebuilds
[openwrt.git] / toolchain / uClibc / Makefile
1
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/target.mk
9
10 PKG_NAME:=uClibc
11 PKG_VERSION:=0.9.28
12 PKG_EXTRAVERSION:=.2
13
14 PKG_SOURCE:=uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION).tar.bz2
15 PKG_SOURCE_URL:=http://www.uclibc.org/downloads
16 PKG_MD5SUM:=959f25286e317f0d9e2103445c5a14c2
17 PKG_CAT:=bzcat
18
19 PKG_BUILD_DIR:=$(TOOLCHAIN_BUILD_DIR)/uClibc-$(PKG_VERSION)$(PKG_EXTRAVERSION)
20
21 include $(INCLUDE_DIR)/host-build.mk
22
23 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
24                 -e 's/i.86/i386/' \
25                 -e 's/sparc.*/sparc/' \
26                 -e 's/arm.*/arm/g' \
27                 -e 's/avr32.*/avr32/g' \
28                 -e 's/m68k.*/m68k/' \
29                 -e 's/ppc/powerpc/g' \
30                 -e 's/v850.*/v850/g' \
31                 -e 's/sh64/sh/' \
32                 -e 's/sh[234].*/sh/' \
33                 -e 's/mips.*/mips/' \
34                 -e 's/mipsel.*/mips/' \
35                 -e 's/cris.*/cris/' \
36 )
37
38 define Build/Prepare
39         $(call Build/Prepare/Default)
40         if [ -e config/$(ARCH).$(BOARD) ]; then \
41                 $(CP) config/$(ARCH).$(BOARD) $(PKG_BUILD_DIR)/.config; \
42         else \
43                 $(CP) config/$(ARCH) $(PKG_BUILD_DIR)/.config; \
44         fi
45         $(SED) 's,^KERNEL_SOURCE=.*,KERNEL_SOURCE=\"$(LINUX_HEADERS_DIR)\",g' \
46                 $(PKG_BUILD_DIR)/.config
47 ifeq ($(CONFIG_LARGEFILE),y)
48         $(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=y,g' $(PKG_BUILD_DIR)/.config
49 else
50         $(SED) 's,^.*UCLIBC_HAS_LFS.*,UCLIBC_HAS_LFS=n,g' $(PKG_BUILD_DIR)/.config
51 endif
52         $(SED) 's,.*UCLIBC_HAS_WCHAR.*,UCLIBC_HAS_WCHAR=y,g' $(PKG_BUILD_DIR)/.config
53 ifeq ($(CONFIG_SOFT_FLOAT),y)
54         $(SED) 's,.*HAS_FPU.*,HAS_FPU=n\nUCLIBC_HAS_FLOATS=y\nUCLIBC_HAS_SOFT_FLOAT=y,g' $(PKG_BUILD_DIR)/.config
55 endif
56 ifeq ($(CONFIG_C99_MATH),y)
57         $(SED) 's,.*DO_C99_MATH.*,DO_C99_MATH=y,g' $(PKG_BUILD_DIR)/.config
58 endif
59         mkdir -p $(TOOLCHAIN_BUILD_DIR)/uClibc_dev/usr/include
60         mkdir -p $(TOOLCHAIN_BUILD_DIR)/uClibc_dev/usr/lib
61         mkdir -p $(TOOLCHAIN_BUILD_DIR)/uClibc_dev/lib
62         PATH=$(TARGET_PATH) $(MAKE) -C $(PKG_BUILD_DIR) \
63                 PREFIX=$(TOOLCHAIN_BUILD_DIR)/uClibc_dev/ \
64                 DEVEL_PREFIX=/usr/ \
65                 RUNTIME_PREFIX=$(TOOLCHAIN_BUILD_DIR)/uClibc_dev/ \
66                 HOSTCC="$(HOSTCC)" \
67                 CPU_CFLAGS="$(TARGET_CFLAGS)" \
68                 pregen install_dev;
69 endef
70
71 define Build/Configure
72 endef
73
74 define Build/Compile
75         $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(PKG_BUILD_DIR)/Rules.mak
76         PATH=$(TARGET_PATH) $(MAKE) -j $(CONFIG_JLEVEL) -C $(PKG_BUILD_DIR) \
77                 PREFIX= \
78                 DEVEL_PREFIX=/ \
79                 RUNTIME_PREFIX=/ \
80                 HOSTCC="$(HOSTCC)" \
81                 CPU_CFLAGS="$(TARGET_CFLAGS)" \
82                 all
83 endef
84
85 define Build/Install
86         $(MAKE) -C $(PKG_BUILD_DIR) \
87                 PREFIX=$(STAGING_DIR)/ \
88                 DEVEL_PREFIX=/ \
89                 RUNTIME_PREFIX=/ \
90                 install_runtime
91         $(MAKE) -C $(PKG_BUILD_DIR) \
92                 PREFIX=$(STAGING_DIR)/ \
93                 DEVEL_PREFIX=/ \
94                 RUNTIME_PREFIX=/ \
95                 install_dev
96         echo $(PKG_VERSION) > $(STAGING_DIR)/uclibc_version
97         echo $(PKG_VERSION)$(PKG_EXTRAVERSION) > $(STAGING_DIR)/uclibc_extra_version
98 endef
99
100 define Build/Clean
101         rm -rf $(PKG_BUILD_DIR) $(TOOLCHAIN_BUILD_DIR)/uClibc_dev
102 endef
103
104 $(eval $(call HostBuild))