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