[package] uhttpd: support building against openssl instead of cyassl, minor cleanups...
[openwrt.git] / toolchain / uClibc / Makefile
1 #
2 # Copyright (C) 2006-2011 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:=$(call qstrip,$(CONFIG_UCLIBC_VERSION))
12 ifeq ($(PKG_VERSION),0.9.32)
13 PKG_SOURCE_URL:=git://git.busybox.net/uClibc
14 PKG_SOURCE_PROTO:=git
15 PKG_SOURCE_VERSION:=f6450b67cc92027352367be299cc28dd29cd8486
16 PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
17 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-$(PKG_SOURCE_VERSION).tar.gz
18 LIBC_SO_VERSION:=$(PKG_VERSION)-rc3-git
19 else
20 PKG_SOURCE_URL:=http://www.uclibc.org/downloads
21 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
22 LIBC_SO_VERSION:=$(PKG_VERSION)
23 endif
24 PATCH_DIR:=./patches-$(PKG_VERSION)
25 CONFIG_DIR:=./config-$(PKG_VERSION)
26
27 PKG_MD5SUM=$(PKG_MD5SUM_$(PKG_VERSION))
28
29 HOST_BUILD_DIR:=$(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)-$(PKG_VERSION)
30
31 include $(INCLUDE_DIR)/toolchain-build.mk
32
33 HOST_STAMP_BUILT:=$(TOOLCHAIN_DIR)/stamp/.uclibc_installed
34 HOST_STAMP_INSTALLED:=$(TOOLCHAIN_DIR)/stamp/.uclibc-utils_installed
35
36 UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
37 -e 's/i.86/i386/' \
38 -e 's/sparc.*/sparc/' \
39 -e 's/arm.*/arm/g' \
40 -e 's/avr32.*/avr32/g' \
41 -e 's/m68k.*/m68k/' \
42 -e 's/ppc/powerpc/g' \
43 -e 's/v850.*/v850/g' \
44 -e 's/sh64/sh/' \
45 -e 's/sh[234].*/sh/' \
46 -e 's/mips.*/mips/' \
47 -e 's/mipsel.*/mips/' \
48 -e 's/cris.*/cris/' \
49 )
50
51
52 define Host/SetToolchainInfo
53 $(SED) 's,^\(LIBC_TYPE\)=.*,\1=$(PKG_NAME),' $(TOOLCHAIN_DIR)/info.mk
54 $(SED) 's,^\(LIBC_URL\)=.*,\1=http://www.uclibc.org/,' $(TOOLCHAIN_DIR)/info.mk
55 $(SED) 's,^\(LIBC_VERSION\)=.*,\1=$(PKG_VERSION),' $(TOOLCHAIN_DIR)/info.mk
56 $(SED) 's,^\(LIBC_SO_VERSION\)=.*,\1=$(LIBC_SO_VERSION),' $(TOOLCHAIN_DIR)/info.mk
57 endef
58
59 GEN_CONFIG=$(SCRIPT_DIR)/kconfig.pl -n \
60 $(if $(wildcard $(CONFIG_DIR)/common),'+' $(CONFIG_DIR)/common) \
61 $(if $(CONFIG_UCLIBC_ENABLE_DEBUG),$(if $(wildcard $(CONFIG_DIR)/debug),'+' $(CONFIG_DIR)/debug)) \
62 $(CONFIG_DIR)/$(ARCH)$(strip \
63 $(if $(wildcard $(CONFIG_DIR)/$(ARCH).$(BOARD)),.$(BOARD), \
64 $(if $(CONFIG_HAS_SPE_FPU),$(if $(wildcard $(CONFIG_DIR)/$(ARCH).e500),.e500))))
65
66 define Host/Prepare
67 $(call Host/Prepare/Default)
68 $(if $(strip $(QUILT)), \
69 cd $(HOST_BUILD_DIR); \
70 if $(QUILT_CMD) next >/dev/null 2>&1; then \
71 $(QUILT_CMD) push -a; \
72 fi
73 )
74 ln -snf $(PKG_NAME)-$(PKG_VERSION) $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME)
75 $(GEN_CONFIG) > $(HOST_BUILD_DIR)/.config
76 $(SED) 's,^KERNEL_HEADERS=.*,KERNEL_HEADERS=\"$(BUILD_DIR_TOOLCHAIN)/linux-dev/include\",g' \
77 -e 's,^.*UCLIBC_HAS_FPU.*,UCLIBC_HAS_FPU=$(if $(CONFIG_SOFT_FLOAT),n,y),g' \
78 -e 's,^.*UCLIBC_HAS_SOFT_FLOAT.*,UCLIBC_HAS_SOFT_FLOAT=$(if $(CONFIG_SOFT_FLOAT),y,n),g' \
79 -e 's,^.*UCLIBC_HAS_SHADOW.*,UCLIBC_HAS_SHADOW=$(if $(CONFIG_SHADOW_PASSWORDS),y,n),g' \
80 $(HOST_BUILD_DIR)/.config
81 $(MAKE) -C $(HOST_BUILD_DIR) oldconfig KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
82 $(MAKE) -C $(HOST_BUILD_DIR)/extra/config conf KBUILD_HAVE_NLS= HOSTCFLAGS="-DKBUILD_NO_NLS"
83 PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
84 PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
85 DEVEL_PREFIX=/ \
86 RUNTIME_PREFIX="$(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev/" \
87 HOSTCC="$(HOSTCC)" \
88 CC="$(TARGET_CC)" \
89 CPU_CFLAGS="$(TARGET_CFLAGS)" \
90 ARCH="$(CONFIG_ARCH)" \
91 pregen \
92 install_headers
93 endef
94
95 define Host/Configure
96 endef
97
98 CPU_CFLAGS = \
99 -funsigned-char -fno-builtin -fno-asm \
100 --std=gnu99 -ffunction-sections -fdata-sections \
101 $(TARGET_CFLAGS)
102
103 UCLIBC_MAKE = PATH='$(TARGET_PATH)' $(MAKE) -C $(HOST_BUILD_DIR) \
104 $(TARGET_CONFIGURE_OPTS) \
105 DEVEL_PREFIX=/ \
106 RUNTIME_PREFIX=/ \
107 HOSTCC="$(HOSTCC)" \
108 CPU_CFLAGS="$(CPU_CFLAGS)" \
109 ARCH="$(CONFIG_ARCH)" \
110 LIBGCC="$(subst libgcc.a,libgcc_initial.a,$(shell $(TARGET_CC) -print-libgcc-file-name))" \
111 DOSTRIP=""
112
113 define Host/Compile
114 $(SED) 's,^CROSS=.*,CROSS=$(TARGET_CROSS),g' $(HOST_BUILD_DIR)/Rules.mak
115 $(UCLIBC_MAKE) $(TOOLCHAIN_JOBS) PREFIX= all
116 $(UCLIBC_MAKE) PREFIX="$(TOOLCHAIN_DIR)/" install_runtime install_dev
117 $(CP) $(HOST_BUILD_DIR)/libc/libc_so.a $(TOOLCHAIN_DIR)/lib/
118 $(CP) $(HOST_BUILD_DIR)/libpthread/*/libpthread_so.a $(TOOLCHAIN_DIR)/lib/
119 ( cd $(TOOLCHAIN_DIR) ; \
120 for d in lib usr/lib ; do \
121 for f in libc.so libpthread.so libgcc_s.so ; do \
122 if [ -f $$$$d/$$$$f -a ! -L $$$$d/$$$$f ] ; then \
123 $(SED) 's,/usr/lib/,,g;s,/lib/,,g' $$$$d/$$$$f ; \
124 fi \
125 done \
126 done \
127 )
128 rm -f \
129 $(TOOLCHAIN_DIR)/lib/libresolv*.so* \
130 $(TOOLCHAIN_DIR)/lib/libnsl*.so*
131 endef
132
133 define Host/Install
134 $(call Host/SetToolchainInfo)
135 $(UCLIBC_MAKE) PREFIX= utils
136 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/bin
137 $(INSTALL_BIN) \
138 $(HOST_BUILD_DIR)/utils/ldd \
139 $(TOOLCHAIN_DIR)/bin/
140 $(INSTALL_DIR) $(TOOLCHAIN_DIR)/sbin
141 $(INSTALL_BIN) \
142 $(HOST_BUILD_DIR)/utils/ldconfig \
143 $(TOOLCHAIN_DIR)/sbin/
144 endef
145
146 define Host/Clean
147 rm -rf \
148 $(HOST_BUILD_DIR) \
149 $(BUILD_DIR_TOOLCHAIN)/$(PKG_NAME) \
150 $(BUILD_DIR_TOOLCHAIN)/$(LIBC)-dev
151 endef
152
153 $(eval $(call HostBuild))
This page took 0.054623 seconds and 5 git commands to generate.