add STRIP to TARGET_CONFIGURE_OPTS (closes #606)
[oweals/openwrt.git] / openwrt / rules.mk
1 ifeq ($(DUMP),)
2 include $(TOPDIR)/.config
3 endif
4
5 SHELL=/bin/bash
6 export SHELL
7
8 ifdef V
9   ifeq ("$(origin V)", "command line")
10     KBUILD_VERBOSE = $(V)
11   endif
12 endif
13 ifndef KBUILD_VERBOSE
14   KBUILD_VERBOSE = 0
15 endif
16
17 ifneq ($(KBUILD_VERBOSE),0)
18   quiet =
19   Q =
20 else
21   quiet=quiet_
22   Q = @
23 endif
24
25
26 CP=cp -fpR
27 BUILD_MAKEFLAGS= V=$(V) $(EXTRA_MAKEFLAGS)
28 MAKEFLAGS=$(BUILD_MAKEFLAGS)
29 # Strip off the annoying quoting
30 ARCH:=$(strip $(subst ",, $(CONFIG_ARCH)))
31 WGET:=$(strip $(subst ",, $(CONFIG_WGET)))
32 TARGET_OPTIMIZATION:=$(strip $(subst ",, $(CONFIG_TARGET_OPTIMIZATION)))
33 #"))"))"))"))")) # for vim's broken syntax highlighting :)
34
35 ifeq ($(CONFIG_TAR_VERBOSITY),y)
36 TAR_OPTIONS=-xvf
37 else
38 TAR_OPTIONS=-xf
39 endif
40
41 ifneq ($(CONFIG_LARGEFILE),y)
42 DISABLE_LARGEFILE= --disable-largefile
43 endif
44 TARGET_CFLAGS:=$(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
45
46 OPTIMIZE_FOR_CPU=$(ARCH)
47 HOSTCC:=gcc
48 BASE_DIR:=$(TOPDIR)
49 INCLUDE_DIR:=$(TOPDIR)/include
50 DL_DIR:=$(BASE_DIR)/dl
51 BUILD_DIR:=$(BASE_DIR)/build_$(ARCH)
52 STAGING_DIR:=$(BASE_DIR)/staging_dir_$(ARCH)
53 SCRIPT_DIR:=$(BASE_DIR)/scripts
54 BIN_DIR:=$(BASE_DIR)/bin
55 STAMP_DIR:=$(BUILD_DIR)/stamp
56 PACKAGE_DIR:=$(BIN_DIR)/packages
57 STAMP_DIR:=$(BUILD_DIR)/stamp
58 TARGET_DIR:=$(BUILD_DIR)/root
59 TOOL_BUILD_DIR=$(BASE_DIR)/toolchain_build_$(ARCH)
60 TARGET_PATH=$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:/bin:/sbin:/usr/bin:/usr/sbin
61 IMAGE:=$(BUILD_DIR)/root_fs_$(ARCH)
62 REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
63 GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
64 KERNEL_CROSS:=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
65 TARGET_CROSS:=$(STAGING_DIR)/bin/$(OPTIMIZE_FOR_CPU)-linux-uclibc-
66 TARGET_CC:=$(TARGET_CROSS)gcc
67 STRIP:=$(STAGING_DIR)/bin/sstrip
68 PATCH=$(SCRIPT_DIR)/patch-kernel.sh
69 SED:=$(STAGING_DIR)/bin/sed -i -e
70 LINUX_DIR:=$(BUILD_DIR)/linux
71 LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
72
73
74 HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
75         -e 's/sparc.*/sparc/' \
76         -e 's/arm.*/arm/g' \
77         -e 's/m68k.*/m68k/' \
78         -e 's/ppc/powerpc/g' \
79         -e 's/v850.*/v850/g' \
80         -e 's/sh[234]/sh/' \
81         -e 's/mips-.*/mips/' \
82         -e 's/mipsel-.*/mipsel/' \
83         -e 's/cris.*/cris/' \
84         -e 's/i[3-9]86/i386/' \
85         )
86 GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
87 TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
88                 AR=$(TARGET_CROSS)ar \
89                 AS=$(TARGET_CROSS)as \
90                 LD=$(TARGET_CROSS)ld \
91                 NM=$(TARGET_CROSS)nm \
92                 CC=$(TARGET_CROSS)gcc \
93                 GCC=$(TARGET_CROSS)gcc \
94                 CXX=$(TARGET_CROSS)g++ \
95                 RANLIB=$(TARGET_CROSS)ranlib \
96                 STRIP=$(TARGET_CROSS)strip
97
98 ifeq ($(ENABLE_LOCALE),true)
99 DISABLE_NLS:=
100 else
101 DISABLE_NLS:=--disable-nls
102 endif
103
104 ifeq ($(CONFIG_ENABLE_MULTILIB),y)
105 MULTILIB:=--enable-multilib
106 endif
107
108 # invoke ipkg-build with some default options
109 IPKG_BUILD := PATH="$(TARGET_PATH)" ipkg-build -c -o root -g root
110 # where to build (and put) .ipk packages
111 IPKG_TARGET_DIR := $(PACKAGE_DIR)
112 IPKG:=IPKG_TMP=$(BUILD_DIR)/tmp IPKG_INSTROOT=$(TARGET_DIR) IPKG_CONF_DIR=$(STAGING_DIR)/etc IPKG_OFFLINE_ROOT=$(BUILD_DIR)/root $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
113 IPKG_STATE_DIR := $(TARGET_DIR)/usr/lib/ipkg
114
115 RSTRIP:=STRIP="$(STRIP)" STRIP_KMOD="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" $(SCRIPT_DIR)/rstrip.sh
116
117 all:
118 .PHONY: FORCE
119 FORCE: