final fix for the profile selection
[openwrt.git] / rules.mk
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
8 -include $(TOPDIR)/.config
9 include $(TOPDIR)/include/verbose.mk
10
11 export SHELL=/usr/bin/env bash -c '. $(TOPDIR)/include/shell.sh; eval "$$2"' --
12
13 ARCH:=$(strip $(subst ",, $(CONFIG_ARCH)))
14 TARGET_OPTIMIZATION:=$(strip $(subst ",, $(CONFIG_TARGET_OPTIMIZATION)))
15 WGET:=$(strip $(subst ",, $(CONFIG_WGET)))
16 #"))"))")) # fix vim's broken syntax highlighting
17
18 OPTIMIZE_FOR_CPU:=$(ARCH)
19
20 # DIRECTORIES #
21
22 DL_DIR:=$(TOPDIR)/dl
23 INCLUDE_DIR:=$(TOPDIR)/include
24 SCRIPT_DIR:=$(TOPDIR)/scripts
25 TOOL_BUILD_DIR:=$(TOPDIR)/tool_build
26 TOOLCHAIN_BUILD_DIR:=$(TOPDIR)/toolchain_build_$(ARCH)
27 STAGING_DIR:=$(TOPDIR)/staging_dir_$(ARCH)
28 BIN_DIR:=$(TOPDIR)/bin
29 PACKAGE_DIR:=$(BIN_DIR)/packages
30 IPKG_TARGET_DIR:=$(PACKAGE_DIR)
31 BUILD_DIR:=$(TOPDIR)/build_$(ARCH)
32 TMP_DIR:=$(TOPDIR)/tmp
33 STAMP_DIR:=$(BUILD_DIR)/stamp
34 TARGET_DIR:=$(BUILD_DIR)/root
35 IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/ipkg
36
37 ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
38 REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
39 GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
40 TARGET_CROSS:=$(OPTIMIZE_FOR_CPU)-linux-uclibc-
41 endif
42
43 IMAGE:=$(BUILD_DIR)/root_fs_$(ARCH)
44
45 TARGET_PATH:=$(STAGING_DIR)/usr/sbin:$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:$(PATH)
46 TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)
47
48 export PATH:=$(TARGET_PATH)
49
50 LINUX_DIR:=$(BUILD_DIR)/linux
51 LINUX_HEADERS_DIR:=$(TOOLCHAIN_BUILD_DIR)/linux
52
53 # APPLICATIONS #
54 HOSTCC:=gcc
55 TARGET_CC:=$(TARGET_CROSS)gcc
56 STRIP:=$(STAGING_DIR)/bin/sstrip
57 PATCH:=$(SCRIPT_DIR)/patch-kernel.sh
58 SED:=$(STAGING_DIR)/bin/sed -i -e
59 CP:=cp -fpR
60
61 INSTALL_BIN:=install -m0755
62 INSTALL_DIR:=install -d -m0755
63 INSTALL_DATA:=install -m0644
64 INSTALL_CONF:=install -m0600
65
66 ifneq ($(CONFIG_CCACHE),)
67 # FIXME: move this variable to a better location
68 export CCACHE_DIR=$(STAGING_DIR)/ccache
69 TARGET_CC:= ccache $(TARGET_CC)
70 endif
71
72 EXTRA_CPPFLAGS := -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
73 EXTRA_CFLAGS := $(EXTRA_CPPFLAGS)
74 EXTRA_LDFLAGS := -L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
75
76 TARGET_CONFIGURE_OPTS:= \
77 AR=$(TARGET_CROSS)ar \
78 AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
79 LD=$(TARGET_CROSS)ld \
80 NM=$(TARGET_CROSS)nm \
81 CC="$(TARGET_CC)" \
82 GCC="$(TARGET_CC)" \
83 CXX=$(TARGET_CROSS)g++ \
84 RANLIB=$(TARGET_CROSS)ranlib \
85 STRIP=$(TARGET_CROSS)strip \
86 OBJCOPY=$(TARGET_CROSS)objcopy
87
88 # strip an entire directory
89 RSTRIP:= \
90 NM="$(TARGET_CROSS)nm" \
91 STRIP="$(STRIP)" \
92 STRIP_KMOD="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" \
93 $(SCRIPT_DIR)/rstrip.sh
94
95 # where to build (and put) .ipk packages
96 IPKG:= \
97 PATH="$(STAGING_DIR)/bin:$(PATH)" \
98 IPKG_TMP=$(BUILD_DIR)/tmp \
99 IPKG_INSTROOT=$(TARGET_DIR) \
100 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
101 IPKG_OFFLINE_ROOT=$(BUILD_DIR)/root \
102 $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
103
104 # invoke ipkg-build with some default options
105 IPKG_BUILD:= \
106 ipkg-build -c -o 0 -g 0
107
108 ifeq ($(CONFIG_ENABLE_LOCALE),true)
109 DISABLE_NLS:=
110 else
111 DISABLE_NLS:=--disable-nls
112 endif
113
114 ifneq ($(CONFIG_LARGEFILE),y)
115 DISABLE_LARGEFILE= --disable-largefile
116 endif
117
118 ifeq ($(CONFIG_TAR_VERBOSITY),y)
119 TAR_OPTIONS:=-xvf -
120 else
121 TAR_OPTIONS:=-xf -
122 endif
123
124 define shvar
125 V_$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
126 endef
127
128 define shexport
129 $(call shvar,$(1))=$$(call $(1))
130 export $(call shvar,$(1))
131 endef
132
133 # Default targets for subdirectory calls
134 # Parameters:
135 # 1: dependencies for the prepare step
136 define default_subtargets
137 %-download: FORCE
138 $$(MAKE) -C $$(patsubst %-download,%,$$@) download
139
140 %-prepare: $(1) FORCE
141 $$(MAKE) -C $$(patsubst %-prepare,%,$$@) prepare
142
143 %-compile: %-prepare
144 $$(MAKE) -C $$(patsubst %-compile,%,$$@) compile
145
146 %-install: %-compile
147 $$(MAKE) -C $$(patsubst %-install,%,$$@) install
148
149 %-clean: FORCE
150 @$$(MAKE) -C $$(patsubst %-clean,%,$$@) clean
151 endef
152
153
154 all:
155 FORCE: ;
156 .PHONY: FORCE
157 %: ;
This page took 0.045637 seconds and 5 git commands to generate.