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