source: trunk/rules.mk @ 8050

Last change on this file since 8050 was 8050, checked in by florian, 9 years ago

Add optionnal support for a BUILD_DIR suffix (#2057)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.5 KB
Line 
1#
2# Copyright (C) 2006 OpenWrt.org
3#
4# This is free software, licensed under the GNU General Public License v2.
5# See /LICENSE for more information.
6#
7
8ifeq ($(DUMP),)
9  -include $(TOPDIR)/.config
10endif
11include $(TOPDIR)/include/verbose.mk
12
13export SHELL=/usr/bin/env bash -c '. $(TOPDIR)/include/shell.sh; eval "$$2"' --
14
15ARCH:=$(strip $(subst ",, $(CONFIG_ARCH)))
16TARGET_OPTIMIZATION:=$(strip $(subst ",, $(CONFIG_TARGET_OPTIMIZATION)))
17BUILD_DIR_SUFFIX:=$(strip $(subst ",, $(CONFIG_BUILD_SUFFIX)))
18WGET:=$(strip $(subst ",, $(CONFIG_WGET)))
19#"))"))")) # fix vim's broken syntax highlighting
20
21OPTIMIZE_FOR_CPU:=$(ARCH)
22
23# DIRECTORIES #
24
25DL_DIR:=$(TOPDIR)/dl
26INCLUDE_DIR:=$(TOPDIR)/include
27SCRIPT_DIR:=$(TOPDIR)/scripts
28TOOL_BUILD_DIR:=$(TOPDIR)/tool_build
29TOOLCHAIN_BUILD_DIR:=$(TOPDIR)/toolchain_build_$(ARCH)
30STAGING_DIR:=$(TOPDIR)/staging_dir_$(ARCH)
31BIN_DIR:=$(TOPDIR)/bin
32PACKAGE_DIR:=$(BIN_DIR)/packages
33IPKG_TARGET_DIR:=$(PACKAGE_DIR)
34BUILD_DIR:=$(TOPDIR)/build_$(ARCH)$(BUILD_DIR_SUFFIX)
35TMP_DIR:=$(TOPDIR)/tmp
36STAMP_DIR:=$(BUILD_DIR)/stamp
37TARGET_DIR:=$(BUILD_DIR)/root
38IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/ipkg
39
40ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
41  REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
42  GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
43  TARGET_CROSS:=$(OPTIMIZE_FOR_CPU)-linux-uclibc-
44endif
45
46IMAGE:=$(BUILD_DIR)/root_fs_$(ARCH)
47
48TARGET_PATH:=$(STAGING_DIR)/usr/sbin:$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:$(PATH)
49TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)
50
51export PATH:=$(TARGET_PATH)
52
53LINUX_DIR:=$(BUILD_DIR)/linux
54LINUX_HEADERS_DIR:=$(TOOLCHAIN_BUILD_DIR)/linux
55
56# APPLICATIONS #
57HOSTCC:=gcc
58TARGET_CC:=$(TARGET_CROSS)gcc
59STRIP:=$(STAGING_DIR)/bin/sstrip
60PATCH:=$(SCRIPT_DIR)/patch-kernel.sh
61SED:=$(STAGING_DIR)/bin/sed -i -e
62CP:=cp -fpR
63
64INSTALL_BIN:=install -m0755
65INSTALL_DIR:=install -d -m0755
66INSTALL_DATA:=install -m0644
67INSTALL_CONF:=install -m0600
68
69ifneq ($(CONFIG_CCACHE),)
70  # FIXME: move this variable to a better location
71  export CCACHE_DIR=$(STAGING_DIR)/ccache
72  TARGET_CC:= ccache $(TARGET_CC)
73endif
74
75EXTRA_CPPFLAGS := -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
76EXTRA_CFLAGS := $(EXTRA_CPPFLAGS)
77EXTRA_LDFLAGS := -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
78
79TARGET_CONFIGURE_OPTS:= \
80  AR=$(TARGET_CROSS)ar \
81  AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
82  LD=$(TARGET_CROSS)ld \
83  NM=$(TARGET_CROSS)nm \
84  CC="$(TARGET_CC)" \
85  GCC="$(TARGET_CC)" \
86  CXX=$(TARGET_CROSS)g++ \
87  RANLIB=$(TARGET_CROSS)ranlib \
88  STRIP=$(TARGET_CROSS)strip \
89  OBJCOPY=$(TARGET_CROSS)objcopy \
90        OBJDUMP=$(TARGET_CROSS)objdump \
91        SIZE=$(TARGET_CROSS)size
92
93# strip an entire directory
94RSTRIP:= \
95  NM="$(TARGET_CROSS)nm" \
96  STRIP="$(STRIP)" \
97  STRIP_KMOD="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" \
98  $(SCRIPT_DIR)/rstrip.sh
99
100# where to build (and put) .ipk packages
101IPKG:= \
102  PATH="$(STAGING_DIR)/bin:$(PATH)" \
103  IPKG_TMP=$(BUILD_DIR)/tmp \
104  IPKG_INSTROOT=$(TARGET_DIR) \
105  IPKG_CONF_DIR=$(STAGING_DIR)/etc \
106  IPKG_OFFLINE_ROOT=$(BUILD_DIR)/root \
107  $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
108
109# invoke ipkg-build with some default options
110IPKG_BUILD:= \
111  ipkg-build -c -o 0 -g 0
112
113ifeq ($(CONFIG_ENABLE_LOCALE),true)
114  DISABLE_NLS:=
115else
116  DISABLE_NLS:=--disable-nls
117endif
118
119ifneq ($(CONFIG_LARGEFILE),y)
120  DISABLE_LARGEFILE= --disable-largefile
121endif
122
123ifeq ($(CONFIG_TAR_VERBOSITY),y)
124  TAR_OPTIONS:=-xvf -
125else
126  TAR_OPTIONS:=-xf -
127endif
128
129define shvar
130V_$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
131endef
132
133define shexport
134$(call shvar,$(1))=$$(call $(1))
135export $(call shvar,$(1))
136endef
137
138all:
139FORCE: ;
140.PHONY: FORCE
141%: ;
Note: See TracBrowser for help on using the repository browser.