fix ccache build order
[openwrt/svn-archive/archive.git] / toolchain / Makefile
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 # Main makefile for the toolchain
8 #
9 include $(TOPDIR)/rules.mk
10
11 TARGETS-y:=kernel-headers
12 TARGETS-$(CONFIG_GDB) += gdb
13 TARGETS-$(CONFIG_CCACHE) += ccache
14 ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
15 TARGETS-y+=binutils gcc uClibc
16 endif
17
18 TARGETS_DOWNLOAD:=$(patsubst %,%-download,$(TARGETS-y))
19 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS-y))
20 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS-y))
21
22 all: install
23 download: $(TARGETS_DOWNLOAD)
24 install: $(TARGETS_INSTALL)
25 clean: $(TARGETS_CLEAN)
26 $(TARGETS_INSTALL): $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
27
28 ifeq ($(CONFIG_CCACHE),y)
29 uClibc-prepare: ccache-install
30 endif
31 uClibc-prepare: kernel-headers-prepare
32 ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
33 binutils-prepare: uClibc-prepare
34 gcc-prepare: binutils-install
35 uClibc-compile: gcc-compile
36 endif
37 gcc-install: uClibc-install
38
39 TOOLCHAIN_STAMP_DIR:=$(STAGING_DIR)/stampfiles
40
41 $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME):
42 @mkdir -p $@
43 @ln -sf ../lib $@/lib
44
45 $(TOOLCHAIN_STAMP_DIR):
46 mkdir -p $@
47
48 $(TOOLCHAIN_BUILD_DIR):
49 @mkdir -p $@
50
51 %-download: FORCE
52 $(MAKE) -C $(patsubst %-download,%,$@) download
53
54 %-prepare: $(TOOLCHAIN_STAMP_DIR) $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME) $(TOOLCHAIN_BUILD_DIR) FORCE
55 @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
56 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare; \
57 }
58 @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
59
60 %-compile: %-prepare
61 @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
62 $(MAKE) -C $(patsubst %-compile,%,$@) compile; \
63 }
64 @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
65
66 %-install: %-compile
67 @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
68 $(MAKE) -C $(patsubst %-install,%,$@) install; \
69 }
70 @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
71
72 %-clean: FORCE
73 @$(MAKE) -C $(patsubst %-clean,%,$@) clean
74 @rm -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$(patsubst %-clean,%,$@)-*
75