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