768f8786c6007910afa9750238d358a1ead97414
[openwrt/openwrt.git] / tools / Makefile
1 #
2 # Copyright (C) 2007 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 host tools
8 #
9 curdir:=tools
10
11 # subdirectories to descend into
12 $(curdir)/builddirs := sed sstrip ipkg-utils genext2fs squashfs mtd-utils lzma mkimage firmware-utils patch-cmdline pkg-config automake $(if $(CONFIG_CCACHE),ccache) bison $(if $(CONFIG_powerpc),dtc) lua quilt autoconf
13
14 ifeq ($(CONFIG_GCC_VERSION_4_3_1)$(CONFIG_GCC_VERSION_4_3_2),y)
15 $(curdir)/builddirs += gmp mpfr
16 endif
17
18 # builddir dependencies
19 $(curdir)/squashfs/compile := $(curdir)/lzma/install
20 $(curdir)/quilt/compile := $(curdir)/sed/install
21
22 # preparatory work
23 $(STAGING_DIR)/.prepared: $(TMP_DIR)/.build
24 @for dir in $(STAGING_DIR) $(STAGING_DIR_HOST); do ( \
25 set -x; \
26 mkdir -p "$$dir"; \
27 cd "$$dir"; \
28 mkdir -p bin lib include stamp; \
29 ); done
30 mkdir -p $(BUILD_DIR_HOST)/stamp $(BUILD_DIR)/stamp
31 $(INSTALL_DATA) $(TOPDIR)/tools/include/*.h $(STAGING_DIR_HOST)/include/
32 touch $@
33
34 $(STAGING_DIR_HOST)/bin/md5sum: $(STAGING_DIR)/.prepared
35 @MD5SUM=`which md5sum 2>/dev/null`; \
36 if [ "$@" != "$$MD5SUM" ]; then \
37 if [ -x "$$MD5SUM" ]; then \
38 ln -sf "$$MD5SUM" "$@"; \
39 else \
40 cp $(SCRIPT_DIR)/md5sum $(STAGING_DIR_HOST)/bin/; \
41 fi; \
42 fi
43
44 $(STAGING_DIR_HOST)/bin/find: $(STAGING_DIR)/.prepared
45 if [ -x "$(FIND)" -a "$(FIND)" != "$@" ]; then \
46 ln -sf "$(FIND)" $@; \
47 fi
48
49
50 $(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum)
51 $(curdir)//prepare = $(STAGING_DIR)/.prepared $($(curdir)/cmddeps)
52 $(curdir)//compile = $(STAGING_DIR)/.prepared $($(curdir)/cmddeps)
53
54 # prerequisites for the individual targets
55 $(curdir)/ := .config prereq
56 $(curdir)//install = $(1)/compile
57
58 $(eval $(call stampfile,$(curdir),tools,install))
59 $(eval $(call subdir,$(curdir)))