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