large build system cleanup. added some stuff to control the verbosity level, but...
[openwrt.git] / package / rules.mk
1 # invoke ipkg with configuration in $(STAGING_DIR)/etc/ipkg.conf 
2
3 define PKG_template
4 IPKG_$(1):=$(PACKAGE_DIR)/$(2)_$(3)_$(4).ipk
5 IDIR_$(1):=$(PKG_BUILD_DIR)/ipkg/$(2)
6 INFO_$(1):=$(IPKG_STATE_DIR)/info/$(2).list
7
8 ifneq ($(BR2_PACKAGE_$(1)),)
9 compile: $$(IPKG_$(1))
10 endif
11 ifneq ($(DEVELOPER),)
12 compile: $$(IPKG_$(1))
13 endif
14 ifeq ($(BR2_PACKAGE_$(1)),y)
15 install: $$(INFO_$(1))
16 endif
17
18 IDEPEND_$(1):=$$(strip $(5))
19
20 $$(IDIR_$(1))/CONTROL/control: $(PKG_BUILD_DIR)/.prepared
21         $(SCRIPT_DIR)/make-ipkg-dir.sh $$(IDIR_$(1)) ./ipkg/$(2).control $(3) $(4)
22         if [ "$$(IDEPEND_$(1))" != "" ]; then echo "Depends: $$(IDEPEND_$(1))" >> $$(IDIR_$(1))/CONTROL/control; fi
23         for file in conffiles preinst postinst prerm postrm; do \
24                 [ -f ./ipkg/$(2).$$$$file ] && cp ./ipkg/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file || true; \
25         done
26
27 $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(PKG_BUILD_DIR)/.built $(PACKAGE_DIR)
28
29 $$(INFO_$(1)): $$(IPKG_$(1))
30         $(IPKG) install $$(IPKG_$(1))
31
32 $(2)-clean:
33         rm -f $$(IPKG_$(1))
34 clean: $(2)-clean
35 endef
36
37 ifneq ($(strip $(PKG_SOURCE)),)
38 $(DL_DIR)/$(PKG_SOURCE):
39         $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL)
40 endif
41
42 ifneq ($(strip $(PKG_CAT)),)
43 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
44         rm -rf $(PKG_BUILD_DIR)
45         mkdir -p $(PKG_BUILD_DIR)
46         $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
47         if [ -d ./patches ]; then \
48                 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
49         fi
50         touch $(PKG_BUILD_DIR)/.prepared
51 endif
52
53 all: compile
54
55 source: $(DL_DIR)/$(PKG_SOURCE)
56 prepare: $(PKG_BUILD_DIR)/.prepared
57 compile:
58 install:
59 mostlyclean:
60 rebuild:
61         -$(MAKE) mostlyclean
62         if [ -f $(PKG_BUILD_DIR)/.built ]; then \
63                 $(MAKE) clean; \
64         fi
65         $(MAKE) compile
66
67 $(PKG_BUILD_DIR)/.configured: $(PKG_BUILD_DIR)/.prepared
68 $(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
69
70 $(PACKAGE_DIR):
71         mkdir -p $@
72
73 clean: 
74         rm -rf $(PKG_BUILD_DIR)
75
76 .PHONY: all source prepare compile install clean