m4 is now available, sorry for trouble
[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 m4 autoconf automake $(if $(CONFIG_CCACHE),ccache) bison $(if $(CONFIG_powerpc),dtc) quilt $(if $(CONFIG_GCC_VERSION_4_3),gmp mpfr) yaffs2
13
14 # builddir dependencies
15 $(curdir)/squashfs/compile := $(curdir)/lzma/install
16 $(curdir)/quilt/compile := $(curdir)/sed/install
17 $(curdir)/dtc/compile := $(curdir)/bison/install
18 $(curdir)/autoconf/compile := $(curdir)/m4/install
19 $(curdir)/automake/compile := $(curdir)/m4/install
20
21 # preparatory work
22 $(STAGING_DIR)/.prepared: $(TMP_DIR)/.build
23 @for dir in $(STAGING_DIR) $(STAGING_DIR_HOST); do ( \
24 set -x; \
25 mkdir -p "$$dir"; \
26 cd "$$dir"; \
27 mkdir -p bin lib include stamp; \
28 ); done
29 mkdir -p $(BUILD_DIR_HOST)/stamp $(BUILD_DIR)/stamp
30 $(INSTALL_DATA) $(TOPDIR)/tools/include/*.h $(STAGING_DIR_HOST)/include/
31 touch $@
32
33 define PrepareCommand
34 $(STAGING_DIR_HOST)/bin/$(1): $(STAGING_DIR)/.prepared
35 @mkdir -p "$$(dir $$@)"; rm -f "$$@"
36 @export FILE="$$$$(which $(2) 2>/dev/null | grep -v 'not found' | head -n1)"; [ -n "$$$$FILE" ] || { \
37 echo "Command $(1) not found."; false; \
38 }; ln -s "$$$$FILE" "$$@"
39
40 endef
41
42 $(eval $(call PrepareCommand,find,gfind find))
43 $(eval $(call PrepareCommand,md5sum,md5sum $(SCRIPT_DIR)/md5sum))
44 $(eval $(call PrepareCommand,cp,gcp cp))
45 $(eval $(call PrepareCommand,stat,gstat stat))
46
47 $(curdir)/cmddeps = $(patsubst %,$(STAGING_DIR_HOST)/bin/%,find md5sum cp stat)
48 $(curdir)//prepare = $(STAGING_DIR)/.prepared $($(curdir)/cmddeps)
49 $(curdir)//compile = $(STAGING_DIR)/.prepared $($(curdir)/cmddeps)
50
51 # prerequisites for the individual targets
52 $(curdir)/ := .config prereq
53 $(curdir)//install = $(1)/compile
54
55 $(eval $(call stampfile,$(curdir),tools,install))
56 $(eval $(call subdir,$(curdir)))