Root/rules.mk

Source at commit f104603657789697c8f9ca612a76c003cad41d6a created 8 years 11 months ago.
By Xiangfu Liu, automatic create /dev/rtc
1#
2# Copyright (C) 2006-2010 OpenWrt.org
3#
4# This is free software, licensed under the GNU General Public License v2.
5# See /LICENSE for more information.
6#
7
8ifneq ($(__rules_inc),1)
9__rules_inc=1
10
11ifeq ($(DUMP),)
12  -include $(TOPDIR)/.config
13endif
14include $(TOPDIR)/include/debug.mk
15include $(TOPDIR)/include/verbose.mk
16
17TMP_DIR:=$(TOPDIR)/tmp
18
19export SHELL=/usr/bin/env bash -c '. $(TOPDIR)/include/shell.sh; eval "$$2"' --
20
21qstrip=$(strip $(subst ",,$(1)))
22#"))
23
24empty:=
25space:= $(empty) $(empty)
26merge=$(subst $(space),,$(1))
27confvar=$(call merge,$(foreach v,$(1),$(if $($(v)),y,n)))
28strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1))
29
30_SINGLE=export MAKEFLAGS=$(space);
31CFLAGS:=
32ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH)))))
33ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES))
34BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD))
35TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION))
36TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX))
37BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
38SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
39
40OPTIMIZE_FOR_CPU=$(subst i386,i486,$(ARCH))
41
42ifeq ($(ARCH),powerpc)
43  FPIC:=-fPIC
44else
45  FPIC:=-fpic
46endif
47
48ARCH_SUFFIX:=
49ifneq ($(findstring -mips32r2,$(TARGET_OPTIMIZATION)),)
50  ARCH_SUFFIX:=_r2
51endif
52ifneq ($(findstring -march=armv4,$(TARGET_OPTIMIZATION)),)
53  ARCH_SUFFIX:=_v4
54endif
55ifneq ($(findstring -march=armv4t,$(TARGET_OPTIMIZATION)),)
56  ARCH_SUFFIX:=_v4t
57endif
58ifneq ($(findstring -march=armv5t,$(TARGET_OPTIMIZATION)),)
59  ARCH_SUFFIX:=_v5t
60endif
61ifneq ($(findstring -march=armv5te,$(TARGET_OPTIMIZATION)),)
62  ARCH_SUFFIX:=_v5te
63endif
64
65DL_DIR:=$(if $(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(TOPDIR)/dl)
66BIN_DIR:=$(TOPDIR)/bin/$(BOARD)
67INCLUDE_DIR:=$(TOPDIR)/include
68SCRIPT_DIR:=$(TOPDIR)/scripts
69BUILD_DIR_BASE:=$(TOPDIR)/build_dir
70BUILD_DIR_HOST:=$(BUILD_DIR_BASE)/host
71STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host
72ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
73  GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION))
74  LIBC:=$(call qstrip,$(CONFIG_LIBC))
75  LIBCV:=$(call qstrip,$(CONFIG_LIBC_VERSION))
76  REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux$(if $(TARGET_SUFFIX),-$(TARGET_SUFFIX))
77  GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux
78  DIR_SUFFIX:=_$(LIBC)-$(LIBCV)$(if $(CONFIG_EABI_SUPPORT),_eabi)
79  BUILD_DIR:=$(BUILD_DIR_BASE)/target-$(ARCH)$(ARCH_SUFFIX)$(DIR_SUFFIX)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
80  STAGING_DIR:=$(TOPDIR)/staging_dir/target-$(ARCH)$(ARCH_SUFFIX)$(DIR_SUFFIX)
81  BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
82  TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
83  PACKAGE_DIR:=$(BIN_DIR)/packages
84else
85  ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
86    GNU_TARGET_NAME=$(call qstrip,$(CONFIG_TARGET_NAME))
87  else
88    GNU_TARGET_NAME=$(shell gcc -dumpmachine)
89  endif
90  REAL_GNU_TARGET_NAME=$(GNU_TARGET_NAME)
91  BUILD_DIR:=$(BUILD_DIR_BASE)/target-$(GNU_TARGET_NAME)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
92  STAGING_DIR:=$(TOPDIR)/staging_dir/target-$(GNU_TARGET_NAME)
93  BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/toolchain-$(GNU_TARGET_NAME)
94  TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/toolchain-$(GNU_TARGET_NAME)
95  PACKAGE_DIR:=$(BIN_DIR)/packages
96endif
97STAMP_DIR:=$(BUILD_DIR)/stamp
98STAMP_DIR_HOST=$(BUILD_DIR_HOST)/stamp
99TARGET_ROOTFS_DIR?=$(if $(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(BUILD_DIR))
100TARGET_DIR:=$(TARGET_ROOTFS_DIR)/root-$(BOARD)
101STAGING_DIR_ROOT:=$(STAGING_DIR)/root-$(BOARD)
102BUILD_LOG_DIR:=$(TOPDIR)/logs
103
104TARGET_PATH:=$(STAGING_DIR_HOST)/bin:$(PATH)
105TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG), -g3)
106TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
107TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
108LIBGCC_S=$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so),-L$(TOOLCHAIN_DIR)/lib -lgcc_s,$(wildcard $(TOOLCHAIN_DIR)/usr/lib/gcc/*/*/libgcc.a))
109
110ifndef DUMP
111  ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
112    -include $(TOOLCHAIN_DIR)/info.mk
113    TARGET_CROSS:=$(if $(TARGET_CROSS),$(TARGET_CROSS),$(OPTIMIZE_FOR_CPU)-openwrt-linux$(if $(TARGET_SUFFIX),-$(TARGET_SUFFIX))-)
114    TARGET_CFLAGS+= -fhonour-copts
115    TARGET_CPPFLAGS+= -I$(TOOLCHAIN_DIR)/usr/include -I$(TOOLCHAIN_DIR)/include
116    TARGET_LDFLAGS+= -L$(TOOLCHAIN_DIR)/usr/lib -L$(TOOLCHAIN_DIR)/lib
117    TARGET_PATH:=$(TOOLCHAIN_DIR)/usr/bin:$(TARGET_PATH)
118  else
119    ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
120      TARGET_CROSS:=$(call qstrip,$(CONFIG_TOOLCHAIN_PREFIX))
121      TOOLCHAIN_ROOT_DIR:=$(call qstrip,$(CONFIG_TOOLCHAIN_ROOT))
122      TOOLCHAIN_BIN_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_BIN_PATH)))
123      TOOLCHAIN_INC_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH)))
124      TOOLCHAIN_LIB_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH)))
125      ifneq ($(TOOLCHAIN_BIN_DIRS),)
126        TARGET_PATH:=$(subst $(space),:,$(TOOLCHAIN_BIN_DIRS)):$(TARGET_PATH)
127      endif
128      ifneq ($(TOOLCHAIN_INC_DIRS),)
129        TARGET_CPPFLAGS+= $(patsubst %,-I%,$(TOOLCHAIN_INC_DIRS))
130      endif
131      ifneq ($(TOOLCHAIN_LIB_DIRS),)
132        TARGET_LDFLAGS+= $(patsubst %,-L%,$(TOOLCHAIN_LIB_DIRS))
133      endif
134    endif
135  endif
136endif
137TARGET_PATH_PKG:=$(STAGING_DIR)/host/bin:$(TARGET_PATH)
138
139ifeq ($(CONFIG_SOFT_FLOAT),y)
140  SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
141  TARGET_CFLAGS+= -msoft-float
142else
143  SOFT_FLOAT_CONFIG_OPTION:=
144endif
145
146export PATH:=$(TARGET_PATH)
147export STAGING_DIR
148export GCC_HONOUR_COPTS:=0
149
150PKG_CONFIG:=$(STAGING_DIR_HOST)/bin/pkg-config
151
152export PKG_CONFIG
153
154HOSTCC:=gcc
155HOST_CFLAGS:=-O2 -I$(STAGING_DIR_HOST)/include
156HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib
157
158TARGET_CC:=$(TARGET_CROSS)gcc
159TARGET_CXX:=$(if $(CONFIG_INSTALL_LIBSTDCPP),$(TARGET_CROSS)g++,no)
160PATCH:=$(SCRIPT_DIR)/patch-kernel.sh
161SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
162CP:=cp -fpR
163LN:=ln -sf
164
165INSTALL_BIN:=install -m0755
166INSTALL_DIR:=install -d -m0755
167INSTALL_DATA:=install -m0644
168INSTALL_CONF:=install -m0600
169
170ifneq ($(CONFIG_CCACHE),)
171  # FIXME: move this variable to a better location
172  export CCACHE_DIR=$(STAGING_DIR)/ccache
173  TARGET_CC:= ccache $(TARGET_CC)
174endif
175
176TARGET_CONFIGURE_OPTS = \
177  AR=$(TARGET_CROSS)ar \
178  AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
179  LD=$(TARGET_CROSS)ld \
180  NM=$(TARGET_CROSS)nm \
181  CC="$(TARGET_CC)" \
182  GCC="$(TARGET_CC)" \
183  CXX="$(TARGET_CXX)" \
184  RANLIB=$(TARGET_CROSS)ranlib \
185  STRIP=$(TARGET_CROSS)strip \
186  OBJCOPY=$(TARGET_CROSS)objcopy \
187  OBJDUMP=$(TARGET_CROSS)objdump \
188  SIZE=$(TARGET_CROSS)size
189
190# strip an entire directory
191ifneq ($(CONFIG_NO_STRIP),)
192  RSTRIP:=:
193  STRIP:=:
194else
195  ifneq ($(CONFIG_USE_STRIP),)
196    STRIP:=$(TARGET_CROSS)strip $(call qstrip,$(CONFIG_STRIP_ARGS))
197  else
198    ifneq ($(CONFIG_USE_SSTRIP),)
199      STRIP:=$(STAGING_DIR_HOST)/bin/sstrip
200    endif
201  endif
202  RSTRIP:= \
203    NM="$(TARGET_CROSS)nm" \
204    STRIP="$(STRIP)" \
205    STRIP_KMOD="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment --remove-section=.pdr --remove-section=.mdebug.abi32" \
206    $(SCRIPT_DIR)/rstrip.sh
207endif
208
209ifeq ($(CONFIG_ENABLE_LOCALE),true)
210  DISABLE_NLS:=--enable-nls
211else
212  DISABLE_NLS:=--disable-nls
213endif
214
215ifeq ($(CONFIG_IPV6),y)
216  DISABLE_IPV6:=
217else
218  DISABLE_IPV6:=--disable-ipv6
219endif
220
221ifeq ($(CONFIG_LARGEFILE),y)
222  DISABLE_LARGEFILE:=
223else
224  DISABLE_LARGEFILE:=--disable-largefile
225endif
226
227ifeq ($(CONFIG_TAR_VERBOSITY),y)
228  TAR_OPTIONS:=-xvf -
229else
230  TAR_OPTIONS:=-xf -
231endif
232
233define shvar
234V_$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
235endef
236
237define shexport
238$(call shvar,$(1))=$$(call $(1))
239export $(call shvar,$(1))
240endef
241
242define include_mk
243$(eval -include $(if $(DUMP),,$(STAGING_DIR)/mk/$(strip $(1))))
244endef
245
246# file extension
247ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))
248
249all:
250FORCE: ;
251.PHONY: FORCE
252
253endif #__rules_inc
254

Archive Download this file



interactive