standardize Makefile, remove dup description
[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=/bin/bash
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)/toolchain_build_$(ARCH)
26 STAGING_DIR:=$(TOPDIR)/staging_dir_$(ARCH)
27 BIN_DIR:=$(TOPDIR)/bin
28 PACKAGE_DIR:=$(BIN_DIR)/packages
29 IPKG_TARGET_DIR:=$(PACKAGE_DIR)
30 BUILD_DIR:=$(TOPDIR)/build_$(ARCH)
31 TMP_DIR:=$(BUILD_DIR)/tmp
32 STAMP_DIR:=$(BUILD_DIR)/stamp
33 TARGET_DIR:=$(BUILD_DIR)/root
34 IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/ipkg
35
36 ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
37 REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
38 GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
39 TARGET_CROSS:=$(OPTIMIZE_FOR_CPU)-linux-uclibc-
40 endif
41
42 IMAGE:=$(BUILD_DIR)/root_fs_$(ARCH)
43
44 TARGET_PATH:=$(STAGING_DIR)/usr/bin:$(STAGING_DIR)/bin:$(PATH)
45 TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)
46
47 export PATH:=$(TARGET_PATH)
48
49 LINUX_DIR:=$(BUILD_DIR)/linux
50 LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
51
52 # APPLICATIONS #
53 HOSTCC:=gcc
54 TARGET_CC:=$(TARGET_CROSS)gcc
55 STRIP:=$(STAGING_DIR)/bin/sstrip
56 PATCH:=$(SCRIPT_DIR)/patch-kernel.sh
57 SED:=$(STAGING_DIR)/bin/sed -i -e
58 CP:=cp -fpR
59
60 ifneq ($(CONFIG_CCACHE),)
61 # FIXME: move this variable to a better location
62 export CCACHE_DIR=$(TOPDIR)/ccache_$(ARCH)
63 TARGET_CC:= ccache $(TARGET_CC)
64 endif
65
66 HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
67 -e 's/sparc.*/sparc/' \
68 -e 's/arm.*/arm/' \
69 -e 's/m68k.*/m68k/' \
70 -e 's/ppc/powerpc/' \
71 -e 's/v850.*/v850/' \
72 -e 's/sh[234]/sh/' \
73 -e 's/mips-.*/mips/' \
74 -e 's/mipsel-.*/mipsel/' \
75 -e 's/cris.*/cris/' \
76 -e 's/i[3-9]86/i386/' \
77 )
78
79 GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
80
81 TARGET_CONFIGURE_OPTS:= \
82 AR=$(TARGET_CROSS)ar \
83 AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
84 LD=$(TARGET_CROSS)ld \
85 NM=$(TARGET_CROSS)nm \
86 CC="$(TARGET_CC)" \
87 GCC="$(TARGET_CC)" \
88 CXX=$(TARGET_CROSS)g++ \
89 RANLIB=$(TARGET_CROSS)ranlib \
90 STRIP=$(TARGET_CROSS)strip
91
92 # strip an entire directory
93 RSTRIP:= \
94 STRIP="$(STRIP)" \
95 STRIP_KMOD="$(TARGET_CROSS)strip --strip-unneeded --remove-section=.comment" \
96 $(SCRIPT_DIR)/rstrip.sh
97
98 # where to build (and put) .ipk packages
99 IPKG:= \
100 IPKG_TMP=$(BUILD_DIR)/tmp \
101 IPKG_INSTROOT=$(TARGET_DIR) \
102 IPKG_CONF_DIR=$(STAGING_DIR)/etc \
103 IPKG_OFFLINE_ROOT=$(BUILD_DIR)/root \
104 $(SCRIPT_DIR)/ipkg -force-defaults -force-depends
105
106 # invoke ipkg-build with some default options
107 IPKG_BUILD:= \
108 ipkg-build -c -o root -g root
109
110 ifeq ($(CONFIG_ENABLE_LOCALE),true)
111 DISABLE_NLS:=
112 else
113 DISABLE_NLS:=--disable-nls
114 endif
115
116 ifneq ($(CONFIG_LARGEFILE),y)
117 DISABLE_LARGEFILE= --disable-largefile
118 endif
119
120 ifeq ($(CONFIG_TAR_VERBOSITY),y)
121 TAR_OPTIONS=-xvf
122 else
123 TAR_OPTIONS=-xf
124 endif
125
126 all:
127 FORCE: ;
128 .PHONY: FORCE
129 %: ;
This page took 0.045035 seconds and 5 git commands to generate.