large build system cleanup. added some stuff to control the verbosity level, but...
[oweals/openwrt.git] / openwrt / rules.mk
1 include $(TOPDIR)/.config
2 SHELL=/bin/bash
3 export SHELL
4
5 ifeq ($(V),)
6 V=99
7 endif
8
9 ifneq ($(V),0)
10 TRACE:=echo "---> "
11 else
12 TRACE:=:
13 endif
14
15 ifeq (${shell [ "$(V)" -ge 5 ] && echo 1},)
16 PKG_TRACE:=:
17 else
18 PKG_TRACE:=echo "------> "
19 endif
20
21 ifeq (${shell [ "$(V)" -ge 10 ] && echo 1},)
22 EXTRA_MAKEFLAGS:=-s
23 MAKE_TRACE:=>&/dev/null
24 else
25 MAKE_TRACE:=
26 EXTRA_MAKEFLAGS:=
27 TRACE:=:
28 PKG_TRACE:=:
29 endif
30
31 MAKE1=make
32 MAKEFLAGS=-j$(BR2_JLEVEL) V=$(V) $(EXTRA_MAKEFLAGS)
33 # Strip off the annoying quoting
34 ARCH:=$(strip $(subst ",, $(BR2_ARCH)))
35 WGET:=$(strip $(subst ",, $(BR2_WGET)))
36 GCC_VERSION:=$(strip $(subst ",, $(BR2_GCC_VERSION)))
37 GCC_USE_SJLJ_EXCEPTIONS:=$(strip $(subst ",, $(BR2_GCC_USE_SJLJ_EXCEPTIONS)))
38 TARGET_OPTIMIZATION:=$(strip $(subst ",, $(BR2_TARGET_OPTIMIZATION)))
39 #"))"))"))"))")) # for vim's broken syntax highlighting :)
40
41
42 ifeq ($(BR2_SOFT_FLOAT),y)
43 # gcc 3.4.x soft float configuration is different than previous versions.
44 ifeq ($(findstring 3.4.,$(GCC_VERSION)),3.4.)
45 SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
46 else
47 SOFT_FLOAT_CONFIG_OPTION:=--without-float
48 endif
49 TARGET_SOFT_FLOAT:=-msoft-float
50 ARCH_FPU_SUFFIX:=_nofpu
51 else
52 SOFT_FLOAT_CONFIG_OPTION:=
53 TARGET_SOFT_FLOAT:=
54 ARCH_FPU_SUFFIX:=
55 endif
56
57
58 ifeq ($(BR2_TAR_VERBOSITY),y)
59 TAR_OPTIONS=-xvf
60 else
61 TAR_OPTIONS=-xf
62 endif
63
64 ifneq ($(BR2_LARGEFILE),y)
65 DISABLE_LARGEFILE= --disable-largefile
66 endif
67 TARGET_CFLAGS:=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
68
69 OPTIMIZE_FOR_CPU=$(ARCH)
70 HOSTCC:=gcc
71 BASE_DIR:=$(TOPDIR)
72 DL_DIR:=$(BASE_DIR)/dl
73 BUILD_DIR:=$(BASE_DIR)/build_$(ARCH)$(ARCH_FPU_SUFFIX)
74 STAGING_DIR:=$(BASE_DIR)/staging_dir_$(ARCH)$(ARCH_FPU_SUFFIX)
75 SCRIPT_DIR:=$(BASE_DIR)/scripts
76 BIN_DIR:=$(BASE_DIR)/bin
77 STAMP_DIR:=$(BUILD_DIR)/stamp
78 PACKAGE_DIR:=$(BIN_DIR)/packages
79 STAMP_DIR:=$(BUILD_DIR)/stamp
80 TARGET_DIR:=$(BUILD_DIR)/root
81 TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)$(ARCH_FPU_SUFFIX)
82 TARGET_PATH=$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
83 IMAGE:=$(BUILD_DIR)/root_fs_$(ARCH)$(ARCH_FPU_SUFFIX)
84 REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
85 GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
86 KERNEL_CROSS:=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
87 TARGET_CROSS:=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
88 TARGET_CC:=$(TARGET_CROSS)gcc
89 STRIP:=$(STAGING_DIR)/bin/sstrip
90 PATCH=$(SCRIPT_DIR)/patch-kernel.sh
91 SED:=$(STAGING_DIR)/bin/sed -i -e
92 LINUX_DIR:=$(BUILD_DIR)/linux
93 LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
94
95
96 HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
97         -e 's/sparc.*/sparc/' \
98         -e 's/arm.*/arm/g' \
99         -e 's/m68k.*/m68k/' \
100         -e 's/ppc/powerpc/g' \
101         -e 's/v850.*/v850/g' \
102         -e 's/sh[234]/sh/' \
103         -e 's/mips-.*/mips/' \
104         -e 's/mipsel-.*/mipsel/' \
105         -e 's/cris.*/cris/' \
106         -e 's/i[3-9]86/i386/' \
107         )
108 GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
109 TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
110                 AR=$(TARGET_CROSS)ar \
111                 AS=$(TARGET_CROSS)as \
112                 LD=$(TARGET_CROSS)ld \
113                 NM=$(TARGET_CROSS)nm \
114                 CC=$(TARGET_CROSS)gcc \
115                 GCC=$(TARGET_CROSS)gcc \
116                 CXX=$(TARGET_CROSS)g++ \
117                 RANLIB=$(TARGET_CROSS)ranlib
118
119 ifeq ($(ENABLE_LOCALE),true)
120 DISABLE_NLS:=
121 else
122 DISABLE_NLS:=--disable-nls
123 endif
124
125 ifeq ($(BR2_ENABLE_MULTILIB),y)
126 MULTILIB:=--enable-multilib
127 endif
128
129 # invoke ipkg-build with some default options
130 IPKG_BUILD := PATH="$(TARGET_PATH)" ipkg-build -c -o root -g root
131 # where to build (and put) .ipk packages
132 IPKG_TARGET_DIR := $(PACKAGE_DIR)
133 IPKG:=IPKG_TMP=$(BUILD_DIR)/tmp IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(STAGING_DIR)/etc $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
134 IPKG_STATE_DIR := $(TARGET_DIR)/usr/lib/ipkg
135
136 RSTRIP:=STRIP="$(STRIP)" $(SCRIPT_DIR)/rstrip.sh
137 RSTRIP_KMOD:=STRIP="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" $(SCRIPT_DIR)/rstrip.sh
138