Allow extracting in non-standard PKG_BUILD_DIR
[openwrt/svn-archive/archive.git] / openwrt / package / rules.mk
1 define PKG_template
2 IPKG_$(1):=$(PACKAGE_DIR)/$(2)_$(3)_$(4).ipk
3 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(2)
4 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(2).list
5
6 ifneq ($(BR2_PACKAGE_$(1)),)
7 compile: $$(IPKG_$(1))
8 endif
9 ifeq ($(BR2_PACKAGE_$(1)),y)
10 install: $$(INFO_$(1))
11 endif
12
13 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
14 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(IDIR_$(1)) ./ipkg/$(2).control $(3) $(4)
15 for file in conffiles preinst postinst prerm postrm; do \
16 [ -f ./ipkg/$(2).$$$$file ] && cp ./ipkg/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
17 done
18
19 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built $(PACKAGE_DIR)
20
21 $$(INFO_$(1)): $$(IPKG_$(1))
22 $(IPKG) install $$(IPKG_$(1))
23
24 $(2)-clean:
25 rm -f $$(IPKG_$(1))
26 clean: $(2)-clean
27
28 endef
29
30 ifneq ($(strip $(PKG_SOURCE)),)
31 $(DL_DIR)/$(PKG_SOURCE):
32 $(SCRIPT_DIR)/download.pl $(DL_DIR) $(PKG_SOURCE) $(PKG_MD5SUM) $(PKG_SOURCE_URL)
33 endif
34
35 ifneq ($(strip $(PKG_CAT)),)
36 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
37 rm -rf $(PKG_BUILD_DIR)
38 mkdir -p $(PKG_BUILD_DIR)
39 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
40 if [ -d ./patches ]; then \
41 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
42 fi
43 touch $(PKG_BUILD_DIR)/.prepared
44 endif
45
46 all: compile
47
48 source: $(DL_DIR)/$(PKG_SOURCE)
49 prepare: $(PKG_BUILD_DIR)/.prepared
50 compile:
51 install:
52
53 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
54 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
55
56 $(PACKAGE_DIR):
57 mkdir -p $@
58
59
60 clean:
61 rm -rf $(PKG_BUILD_DIR)
62
63 .PHONY: all source prepare compile install clean