minor cleanup
[openwrt-10.03/.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
11
12 TARGETS_DOWNLOAD:=$(patsubst %,%-download,$(TARGETS-y))
13 TARGETS_INSTALL:=$(patsubst %,%-install,$(TARGETS-y))
14 TARGETS_CLEAN:=$(patsubst %,%-clean,$(TARGETS-y))
15
16 all: install
17 download: $(TARGETS_DOWNLOAD)
18 install: $(TARGETS_INSTALL)
19 clean: $(TARGETS_CLEAN)
20
21 squashfs-compile: lzma-install
22
23 TOOL_STAMP_DIR:=$(STAGING_DIR)/stampfiles
24
25 $(TOOL_STAMP_DIR):
26         mkdir -p $@
27
28 $(STAGING_DIR):
29         @mkdir -p $@/lib
30         @mkdir -p $@/include
31         @mkdir -p $@/include-host
32         $(CP) ./include/*.h $@/include-host/
33         @ln -sf ../lib $@/$(REAL_GNU_TARGET_NAME)/lib
34         @mkdir -p $@/$(REAL_GNU_TARGET_NAME)
35
36 $(TOOL_BUILD_DIR):
37         @mkdir -p $@
38
39 %-download: FORCE
40         $(MAKE) -C $(patsubst %-download,%,$@) download
41
42 %-prepare: $(TOOL_STAMP_DIR) $(STAGING_DIR) $(TOOL_BUILD_DIR) FORCE
43         @[ -f $(TOOL_STAMP_DIR)/.tool_$@ ] || { \
44                 $(MAKE) -C $(patsubst %-prepare,%,$@) prepare; \
45         }
46         @touch $(TOOL_STAMP_DIR)/.tool_$@
47
48 %-compile: %-prepare 
49         @[ -f $(TOOL_STAMP_DIR)/.tool_$@ ] || { \
50                 $(MAKE) -C $(patsubst %-compile,%,$@) compile; \
51         }
52         @touch $(TOOL_STAMP_DIR)/.tool_$@
53
54 %-install: %-compile
55         @[ -f $(TOOL_STAMP_DIR)/.tool_$@ ] || { \
56                 $(MAKE) -C $(patsubst %-install,%,$@) install; \
57         }
58         @touch $(TOOL_STAMP_DIR)/.tool_$@
59
60 %-clean: FORCE
61         @$(MAKE) -C $(patsubst %-clean,%,$@) clean
62         @rm -f $(TOOL_STAMP_DIR)/.tool_$(patsubst %-clean,%,$@)-*
63