f8f08781b5380e23f9d02a681a53ec6f23e64eb1
[openwrt.git] / tools / Makefile
1
2 # Copyright (C) 2006 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 include $(TOPDIR)/rules.mk
10 TARGETS-y:=sed sstrip ipkg-utils ext2fs squashfs mtd-utils lzma mkimage firmware-utils
11
12 TARGETS_DOWNLOAD:=$(patsubst %,%-download,$(TARGETS-y))
13 TARGETS_PREPARE:=$(patsubst %,%-prepare,$(TARGETS-y))
14 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS-y))
15 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS-y))
16
17 all: install
18 download: $(TARGETS_DOWNLOAD)
19 install: 
20         $(MAKE) install-targets
21 install-targets: $(TARGETS_INSTALL)
22 clean: $(TARGETS_CLEAN)
23
24 squashfs-compile: lzma-install
25
26 TOOL_STAMP_DIR:=$(STAGING_DIR)/stampfiles
27
28 $(TOOL_STAMP_DIR):
29         mkdir -p $@
30
31 $(STAGING_DIR)/include-host:
32         @mkdir -p $@
33         @$(CP) ./include/*.h $@/
34
35 $(TOOL_BUILD_DIR):
36         @mkdir -p $@
37
38 %-download: FORCE
39         $(MAKE) -C $(patsubst %-download,%,$@) download
40
41 %-prepare: $(TOOL_STAMP_DIR) $(STAGING_DIR)/include-host $(TOOL_BUILD_DIR) FORCE
42         @[ -f $(TOOL_STAMP_DIR)/.tool_$@ ] || { \
43                 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare; \
44         }
45         @touch $(TOOL_STAMP_DIR)/.tool_$@
46
47 %-compile: %-prepare 
48         @[ -f $(TOOL_STAMP_DIR)/.tool_$@ ] || { \
49                 $(MAKE) -C $(patsubst %-compile,%,$@) compile; \
50         }
51         @touch $(TOOL_STAMP_DIR)/.tool_$@
52
53 %-install: %-compile
54         @[ -f $(TOOL_STAMP_DIR)/.tool_$@ ] || { \
55                 $(MAKE) -C $(patsubst %-install,%,$@) install; \
56         }
57         @touch $(TOOL_STAMP_DIR)/.tool_$@
58
59 %-clean: FORCE
60         @$(MAKE) -C $(patsubst %-clean,%,$@) clean
61         @rm -f $(TOOL_STAMP_DIR)/.tool_$(patsubst %-clean,%,$@)-*
62
63 ifeq ($(MAKECMDGOALS),install-targets)
64 MAKEFLAGS:=$(MAKEFLAGS) -j$(CONFIG_JLEVEL)
65 else
66 .NOTPARALLEL:
67 endif