busybox: fix installation of cron and ntpd scripts in the default config
[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/compile
11 # build & install binutils
12 # 2) toolchain/gcc/minimal/compile
13 # build & install a minimal gcc, needed for steps 3 & 4
14 # 3) toolchain/kernel-headers/compile
15 # install kernel headers, needed for step 4
16 # 4) toolchain/libc/headers/compile
17 # build & install libc headers & support files, needed for step 5
18 # 5) toolchain/gcc/initial/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/final/compile
23 # build & install the final gcc
24 # 8) toolchain/libc/utils/compile
25 # build & install libc utilities
26 #
27 # For musl, steps 2 and 4 are skipped, and step 3 is done after 5
28
29 curdir:=toolchain
30
31 # subdirectories to descend into
32 $(curdir)/builddirs := $(if $(CONFIG_GDB),gdb) $(if $(CONFIG_INSIGHT),insight) $(if $(CONFIG_EXTERNAL_TOOLCHAIN),wrapper,kernel-headers binutils gcc/initial gcc/final $(LIBC) fortify-headers) $(if $(CONFIG_YASM),yasm)
33 ifdef CONFIG_USE_UCLIBC
34 $(curdir)/builddirs += $(LIBC)/utils
35 endif
36
37 # builddir dependencies
38 ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
39 ifdef CONFIG_USE_MUSL
40 $(curdir)/kernel-headers/compile:=$(curdir)/gcc/initial/compile
41 $(curdir)/$(LIBC)/compile:=$(curdir)/kernel-headers/compile
42 else
43 $(curdir)/builddirs += $(LIBC)/headers gcc/minimal
44 $(curdir)/gcc/minimal/compile:=$(curdir)/binutils/compile
45 $(curdir)/kernel-headers/compile:=$(curdir)/gcc/minimal/compile
46 $(curdir)/$(LIBC)/headers/compile:=$(curdir)/kernel-headers/compile
47 $(curdir)/gcc/initial/compile:=$(curdir)/$(LIBC)/headers/compile
48 endif
49
50 $(curdir)/gcc/initial/compile+=$(curdir)/binutils/compile
51 $(curdir)/$(LIBC)/compile:=$(curdir)/gcc/initial/compile
52 $(curdir)/gcc/final/compile:=$(curdir)/$(LIBC)/compile
53 $(curdir)/$(LIBC)/utils/compile:=$(curdir)/gcc/final/compile
54 endif
55
56 ifndef DUMP_TARGET_DB
57 ifneq ($(ARCH),)
58 $(TOOLCHAIN_DIR)/info.mk: .config
59 @for dir in $(TOOLCHAIN_DIR); do ( \
60 $(if $(QUIET),,set -x;) \
61 mkdir -p "$$dir"; \
62 cd "$$dir"; \
63 ln -nsf lib lib64; \
64 ln -nsf lib lib32; \
65 mkdir -p stamp lib usr/include usr/lib ; \
66 ); done
67 @grep GCC_VERSION $@ >/dev/null 2>&1 || $(INSTALL_DATA) $(TOPDIR)/toolchain/info.mk $@
68 @touch $@
69 endif
70 endif
71
72 ifdef CONFIG_BUILDBOT
73 $(TOOLCHAIN_DIR)/stamp/.ver_check: $(TMP_DIR)/.build
74 cd "$(TOPDIR)"; git log --format=%h -1 toolchain > $(TMP_DIR)/.ver_check
75 cmp -s $(TMP_DIR)/.ver_check $@ || { \
76 rm -rf $(BUILD_DIR) $(STAGING_DIR) $(TOOLCHAIN_DIR) $(BUILD_DIR_TOOLCHAIN); \
77 mkdir -p $(TOOLCHAIN_DIR)/stamp; \
78 mv $(TMP_DIR)/.ver_check $@; \
79 }
80
81 $(TOOLCHAIN_DIR)/info.mk $(STAGING_DIR)/.prepared: $(TOOLCHAIN_DIR)/stamp/.ver_check
82 endif
83
84 # prerequisites for the individual targets
85 $(curdir)/ := .config prereq
86 $(curdir)//compile = $(STAGING_DIR)/.prepared $(TOOLCHAIN_DIR)/info.mk $(tools/stamp-compile)
87
88 ifndef DUMP_TARGET_DB
89 $(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed:
90 endif
91
92 $(curdir)/install: $(curdir)/compile
93
94 $(eval $(call stampfile,$(curdir),toolchain,compile,$(TOOLCHAIN_DIR)/stamp/.gcc-initial_installed,,$(TOOLCHAIN_DIR)))
95 $(eval $(call stampfile,$(curdir),toolchain,check,$(TMP_DIR)/.build))
96 $(eval $(call subdir,$(curdir)))
97