large build system cleanup. added some stuff to control the verbosity level, but...
[openwrt-10.03/.git] / toolchain / Makefile
1 # Main makefile for the toolchain
2 include $(TOPDIR)/rules.mk
3 TARGETS:=sed utils binutils gcc uClibc ipkg-utils gdb libnotimpl
4
5 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS))
6 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS))
7
8 all: install
9 install: $(TARGETS_INSTALL)
10 clean: $(TARGETS_CLEAN)
11
12 uClibc-prepare: kernel-headers-prepare sed-install utils-install
13 binutils-prepare: uClibc-prepare
14 gcc-prepare: binutils-install
15 uClibc-compile: gcc-prepare
16 gcc-compile: uClibc-install
17
18 TOOLCHAIN_STAMP_DIR:=$(STAGING_DIR)/stampfiles
19
20 $(TOOLCHAIN_STAMP_DIR):
21         mkdir -p $(TOOLCHAIN_STAMP_DIR)
22
23 $(STAGING_DIR):
24         @mkdir -p $(STAGING_DIR)/lib
25         @mkdir -p $(STAGING_DIR)/include
26         @mkdir -p $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)
27         @ln -sf ../lib $(STAGING_DIR)/$(REAL_GNU_TARGET_NAME)/lib
28
29 $(TOOL_BUILD_DIR):
30         @mkdir -p $(TOOL_BUILD_DIR)
31
32 %-prepare: $(TOOLCHAIN_STAMP_DIR) $(STAGING_DIR) $(TOOL_BUILD_DIR)
33         @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
34                 $(TRACE) toolchain/$(patsubst %-prepare,%,$@)/prepare; \
35                 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare; \
36         }
37         @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
38
39 %-compile: %-prepare 
40         @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
41                 $(TRACE) toolchain/$(patsubst %-compile,%,$@)/compile; \
42                 $(MAKE) -C $(patsubst %-compile,%,$@) compile; \
43         }
44         @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
45
46 %-install: %-compile
47         @[ -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@ ] || { \
48                 $(TRACE) toolchain/$(patsubst %-install,%,$@)/install; \
49                 $(MAKE) -C $(patsubst %-install,%,$@) install; \
50         }
51         @touch $(TOOLCHAIN_STAMP_DIR)/.toolchain_$@
52
53 %-clean:
54         $(TRACE) toolchain/$(patsubst %-clean,%,$@)/clean
55         @$(MAKE) -C $(patsubst %-clean,%,$@) clean
56         @rm -f $(TOOLCHAIN_STAMP_DIR)/.toolchain_$(patsubst %-clean,%,$@)-*
57