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.
9 -include $(TOPDIR
)/.config
11 include $(TOPDIR
)/include/verbose.mk
13 export SHELL
=/usr
/bin
/env bash
-c
'. $(TOPDIR)/include/shell.sh; eval "$$2"' --
15 ARCH
:=$(strip $(subst ",, $(CONFIG_ARCH)))
16 TARGET_OPTIMIZATION:=$(strip $(subst ",, $(CONFIG_TARGET_OPTIMIZATION
)))
17 BUILD_DIR_SUFFIX
:=$(strip $(subst ",, $(CONFIG_BUILD_SUFFIX)))
18 WGET:=$(strip $(subst ",, $(CONFIG_WGET
)))
19 #"))"))")) # fix vim's broken syntax highlighting
21 OPTIMIZE_FOR_CPU
:=$(ARCH
)
26 INCLUDE_DIR
:=$(TOPDIR
)/include
27 SCRIPT_DIR
:=$(TOPDIR
)/scripts
28 TOOL_BUILD_DIR
:=$(TOPDIR
)/tool_build
29 TOOLCHAIN_BUILD_DIR
:=$(TOPDIR
)/toolchain_build_
$(ARCH
)
30 STAGING_DIR
:=$(TOPDIR
)/staging_dir_
$(ARCH
)
31 BIN_DIR
:=$(TOPDIR
)/bin
32 PACKAGE_DIR
:=$(BIN_DIR
)/packages
33 IPKG_TARGET_DIR
:=$(PACKAGE_DIR
)
34 BUILD_DIR
:=$(TOPDIR
)/build_
$(ARCH
)$(BUILD_DIR_SUFFIX
)
35 TMP_DIR
:=$(TOPDIR
)/tmp
36 STAMP_DIR
:=$(BUILD_DIR
)/stamp
37 TARGET_DIR
:=$(BUILD_DIR
)/root
38 IPKG_STATE_DIR
:=$(TARGET_DIR
)/usr
/lib
/ipkg
40 ifeq ($(CONFIG_NATIVE_TOOLCHAIN
),)
41 REAL_GNU_TARGET_NAME
=$(OPTIMIZE_FOR_CPU
)-linux-uclibc
42 GNU_TARGET_NAME
=$(OPTIMIZE_FOR_CPU
)-linux
43 TARGET_CROSS
:=$(OPTIMIZE_FOR_CPU
)-linux-uclibc-
46 IMAGE
:=$(BUILD_DIR
)/root_fs_
$(ARCH
)
48 TARGET_PATH
:=$(STAGING_DIR
)/usr
/sbin
:$(STAGING_DIR
)/usr
/bin
:$(STAGING_DIR
)/bin
:$(PATH
)
49 TARGET_CFLAGS
:=$(TARGET_OPTIMIZATION
)
51 export PATH
:=$(TARGET_PATH
)
53 LINUX_DIR
:=$(BUILD_DIR
)/linux
54 LINUX_HEADERS_DIR
:=$(TOOLCHAIN_BUILD_DIR
)/linux
58 TARGET_CC
:=$(TARGET_CROSS
)gcc
59 STRIP
:=$(STAGING_DIR
)/bin
/sstrip
60 PATCH
:=$(SCRIPT_DIR
)/patch-kernel.sh
61 SED
:=$(STAGING_DIR
)/bin
/sed
-i
-e
64 INSTALL_BIN
:=install -m0755
65 INSTALL_DIR
:=install -d
-m0755
66 INSTALL_DATA
:=install -m0644
67 INSTALL_CONF
:=install -m0600
69 ifneq ($(CONFIG_CCACHE
),)
70 # FIXME: move this variable to a better location
71 export CCACHE_DIR
=$(STAGING_DIR
)/ccache
72 TARGET_CC
:= ccache
$(TARGET_CC
)
75 EXTRA_CPPFLAGS
:= -I
$(STAGING_DIR
)/usr
/include -I
$(STAGING_DIR
)/include
76 EXTRA_CFLAGS
:= $(EXTRA_CPPFLAGS
)
77 EXTRA_LDFLAGS
:= -L
$(STAGING_DIR
)/usr
/lib
-L
$(STAGING_DIR
)/lib
79 TARGET_CONFIGURE_OPTS
:= \
80 AR
=$(TARGET_CROSS
)ar \
81 AS
="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
82 LD
=$(TARGET_CROSS
)ld \
83 NM
=$(TARGET_CROSS
)nm \
86 CXX
=$(TARGET_CROSS
)g
++ \
87 RANLIB
=$(TARGET_CROSS
)ranlib \
88 STRIP
=$(TARGET_CROSS
)strip \
89 OBJCOPY
=$(TARGET_CROSS
)objcopy \
90 OBJDUMP
=$(TARGET_CROSS
)objdump \
91 SIZE
=$(TARGET_CROSS
)size
93 # strip an entire directory
95 NM
="$(TARGET_CROSS)nm" \
97 STRIP_KMOD
="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" \
98 $(SCRIPT_DIR
)/rstrip.sh
100 # where to build (and put) .ipk packages
102 PATH
="$(STAGING_DIR)/bin:$(PATH)" \
103 IPKG_TMP
=$(BUILD_DIR
)/tmp \
104 IPKG_INSTROOT
=$(TARGET_DIR
) \
105 IPKG_CONF_DIR
=$(STAGING_DIR
)/etc \
106 IPKG_OFFLINE_ROOT
=$(BUILD_DIR
)/root \
107 $(SCRIPT_DIR
)/ipkg
-force-defaults
-force-depends
109 # invoke ipkg-build with some default options
111 ipkg-build
-c
-o
0 -g
0
113 ifeq ($(CONFIG_ENABLE_LOCALE
),true
)
116 DISABLE_NLS
:=--disable-nls
119 ifneq ($(CONFIG_LARGEFILE
),y
)
120 DISABLE_LARGEFILE
= --disable-largefile
123 ifeq ($(CONFIG_TAR_VERBOSITY
),y
)
130 V_
$(subst .
,_
,$(subst -,_
,$(subst /,_
,$(1))))
134 $(call shvar
,$(1))=$$(call
$(1))
135 export $(call shvar
,$(1))