uClibc: split the package into the main directory and the headers/ and utils/ subdire...
[openwrt/openwrt.git] / toolchain / Makefile
1 #
2 # Copyright (C) 2007-2009 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 # Steps:
10 # 1) toolchain/binutils/install
11 # build & install binutils
12 # 2) toolchain/gcc/prepare
13 # build & install a minimal gcc, needed for steps 3 & 4
14 # 3) toolchain/kernel-headers/install
15 # install kernel headers, needed for step 4
16 # 4) toolchain/libc/prepare
17 # build & install libc headers & support files, needed for step 5
18 # 5) toolchain/gcc/compile
19 # build & install an initial gcc, needed for step 6
20 # 6) toolchain/libc/compile
21 # build & install the final libc
22 # 7) toolchain/gcc/install
23 # build & install the final gcc
24 # 8) toolchain/libc/install
25 # build & install libc utilities
26 #
27
28 curdir:=toolchain
29
30 # subdirectories to descend into
31 $(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/minimal gcc/initial gcc/final $(LIBC))
32 ifdef CONFIG_USE_UCLIBC
33 $(curdir)/builddirs += $(LIBC)/headers
34 $(curdir)/builddirs += $(LIBC)/utils
35 endif
36 $(curdir)/builddirs-compile:=$($(curdir)/builddirs-prepare)
37 $(curdir)/builddirs-install:=$($(curdir)/builddirs-compile)
38
39 # builddir dependencies
40 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
41 $(curdir)/$(LIBC)/prepare:=$(curdir)/kernel-headers/install
42 $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/install
43 $(curdir)/kernel-headers/install:=$(curdir)/gcc/minimal/install
44 $(curdir)/gcc/initial/prepare:=$(curdir)/gcc/minimal/prepare
45 $(curdir)/gcc/final/prepare:=$(curdir)/gcc/initial/prepare
46
47 ifdef CONFIG_USE_UCLIBC
48 $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/install
49 $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/install
50 $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/install
51 $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/install
52 $(curdir)/$(LIBC)/prepare:=$(curdir)/$(LIBC)/headers/prepare
53 $(curdir)/$(LIBC)/utils/prepare:=$(curdir)/$(LIBC)/headers/prepare
54 else
55 $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/install
56 $(curdir)/$(LIBC)/install:=$(curdir)/gcc/final/install
57 $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/prepare
58 $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/compile
59 endif
60 endif
61
62 ifdef CONFIG_GCC_VERSION_LLVM
63 $(curdir)/builddirs += llvm
64 $(curdir)/gcc/minimal/compile += $(curdir)/llvm/install
65 endif
66
67 ifndef DUMP_TARGET_DB
68 ifneq ($(ARCH),)
69 $(TOOLCHAIN_DIR)/info.mk: .config
70 @for dir in $(TOOLCHAIN_DIR); do ( \
71 $(if $(QUIET),,set -x;) \
72 mkdir -p "$$dir"; \
73 cd "$$dir"; \
74 ln -sf lib lib64; \
75 mkdir -p stamp lib usr/include usr/lib ; \
76 ); done
77 @grep GCC_VERSION $@ >/dev/null 2>&1 || $(INSTALL_DATA) $(TOPDIR)/toolchain/info.mk $@
78 @touch $@
79 endif
80 endif
81
82 # prerequisites for the individual targets
83 $(curdir)/ := .config prereq
84 $(curdir)//prepare = $(STAGING_DIR)/.prepared $(TOOLCHAIN_DIR)/info.mk
85 $(curdir)//compile = $(1)/prepare
86 $(curdir)//install = $(1)/compile
87
88 ifndef DUMP_TARGET_DB
89 $(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed:
90 endif
91
92 $(eval $(call stampfile,$(curdir),toolchain,install,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed,,$(TOOLCHAIN_DIR)))
93 $(eval $(call subdir,$(curdir)))
94