2 # Copyright (C) 2006 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 -include $(TOPDIR)/.config
9 include $(TOPDIR)/include/verbose.mk
11 export SHELL=/bin/bash
13 ARCH:=$(strip $(subst ",, $(CONFIG_ARCH)))
14 TARGET_OPTIMIZATION:=$(strip $(subst ",, $(CONFIG_TARGET_OPTIMIZATION)))
15 WGET:=$(strip $(subst ",, $(CONFIG_WGET)))
16 #"))"))")) # fix vim's broken syntax highlighting
18 OPTIMIZE_FOR_CPU:=$(ARCH)
23 INCLUDE_DIR:=$(TOPDIR)/include
24 SCRIPT_DIR:=$(TOPDIR)/scripts
25 TOOL_BUILD_DIR:=$(TOPDIR)/toolchain_build_$(ARCH)
26 STAGING_DIR:=$(TOPDIR)/staging_dir_$(ARCH)
27 BIN_DIR:=$(TOPDIR)/bin
28 PACKAGE_DIR:=$(BIN_DIR)/packages
29 IPKG_TARGET_DIR:=$(PACKAGE_DIR)
30 BUILD_DIR:=$(TOPDIR)/build_$(ARCH)
31 TMP_DIR:=$(BUILD_DIR)/tmp
32 STAMP_DIR:=$(BUILD_DIR)/stamp
33 TARGET_DIR:=$(BUILD_DIR)/root
34 IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/ipkg
36 REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
37 GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
38 TARGET_CROSS:=$(OPTIMIZE_FOR_CPU)-linux-uclibc-
39 IMAGE:=$(BUILD_DIR)/root_fs_$(ARCH)
41 TARGET_PATH:=$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:$(PATH)
42 TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)
44 export PATH:=$(TARGET_PATH)
46 LINUX_DIR:=$(BUILD_DIR)/linux
47 LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
51 TARGET_CC:=$(TARGET_CROSS)gcc
52 STRIP:=$(STAGING_DIR)/bin/sstrip
53 PATCH:=$(SCRIPT_DIR)/patch-kernel.sh
54 SED:=$(STAGING_DIR)/bin/sed -i -e
57 ifneq ($(CONFIG_CCACHE),)
58 # FIXME: move this variable to a better location
59 export CCACHE_DIR=$(TOPDIR)/ccache_$(ARCH)
60 TARGET_CC:= ccache $(TARGET_CC)
63 HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
64 -e 's/sparc.*/sparc/' \
70 -e 's/mips-.*/mips/' \
71 -e 's/mipsel-.*/mipsel/' \
73 -e 's/i[3-9]86/i386/' \
76 GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
78 TARGET_CONFIGURE_OPTS:= \
79 AR=$(TARGET_CROSS)ar \
80 AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
81 LD=$(TARGET_CROSS)ld \
82 NM=$(TARGET_CROSS)nm \
85 CXX=$(TARGET_CROSS)g++ \
86 RANLIB=$(TARGET_CROSS)ranlib \
87 STRIP=$(TARGET_CROSS)strip
89 # strip an entire directory
92 STRIP_KMOD="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" \
93 $(SCRIPT_DIR)/rstrip.sh
95 # where to build (and put) .ipk packages
97 IPKG_TMP=$(BUILD_DIR)/tmp \
98 IPKG_INSTROOT=$(TARGET_DIR) \
99 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
100 IPKG_OFFLINE_ROOT=$(BUILD_DIR)/root \
101 $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
103 # invoke ipkg-build with some default options
105 ipkg-build -c -o root -g root
107 ifeq ($(CONFIG_ENABLE_LOCALE),true)
110 DISABLE_NLS:=--disable-nls
113 ifneq ($(CONFIG_LARGEFILE),y)
114 DISABLE_LARGEFILE= --disable-largefile
117 ifeq ($(CONFIG_TAR_VERBOSITY),y)