e5d3c503d69ea3b0b0c8f9ff6b0171dac9ccbbec
[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-targets: $$(IPKG_$(1))
10 endif
11 ifneq ($(DEVELOPER),)
12 compile-targets: $$(IPKG_$(1))
13 endif
14 ifeq ($(BR2_PACKAGE_$(1)),y)
15 install-targets: $$(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
38 ifneq ($(strip $(PKG_SOURCE)),)
39 $(DL_DIR)/$(PKG_SOURCE):
40 @$(PKG_TRACE) Downloading...
41 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL) $(MAKE_TRACE)
42 endif
43
44 ifneq ($(strip $(PKG_CAT)),)
45 $(PKG_BUILD_DIR)/.prepared: $(DL_DIR)/$(PKG_SOURCE)
46 rm -rf $(PKG_BUILD_DIR)
47 mkdir -p $(PKG_BUILD_DIR)
48 $(PKG_CAT) $(DL_DIR)/$(PKG_SOURCE) | tar -C $(PKG_BUILD_DIR)/.. $(TAR_OPTIONS) -
49 if [ -d ./patches ]; then \
50 $(PATCH) $(PKG_BUILD_DIR) ./patches ; \
51 fi
52 touch $(PKG_BUILD_DIR)/.prepared
53 endif
54
55 all: compile
56
57 source: $(DL_DIR)/$(PKG_SOURCE)
58 prepare:
59 @[ -f $(PKG_BUILD_DIR)/.prepared ] || { \
60 $(PKG_TRACE) Preparing...; \
61 $(MAKE) $(PKG_BUILD_DIR)/.prepared $(MAKE_TRACE); \
62 }
63
64 configure:
65 @[ -f $(PKG_BUILD_DIR)/.configured ] || { \
66 $(PKG_TRACE) Configuring...; \
67 $(MAKE) $(PKG_BUILD_DIR)/.configured $(MAKE_TRACE); \
68 }
69
70 compile-targets:
71 compile:
72 @[ -f $(PKG_BUILD_DIR)/.configured ] || { \
73 $(PKG_TRACE) Configuring...; \
74 $(MAKE) $(PKG_BUILD_DIR)/.configured $(MAKE_TRACE); \
75 }
76 @[ -f $(PKG_BUILD_DIR)/.built ] || { \
77 $(PKG_TRACE) Compiling...; \
78 $(MAKE) compile-targets $(MAKE_TRACE); \
79 }
80
81 install-targets:
82 install:
83 @$(PKG_TRACE) Installing...
84 @$(MAKE) install-targets $(MAKE_TRACE)
85
86 mostlyclean:
87 rebuild:
88 $(PKG_TRACE) Rebuilding...
89 @-$(MAKE) mostlyclean 2>&1 >/dev/null
90 if [ -f $(PKG_BUILD_DIR)/.built ]; then \
91 $(MAKE) clean $(MAKE_TRACE); \
92 fi
93 $(MAKE) compile $(MAKE_TRACE)
94
95 $(PKG_BUILD_DIR)/.configured: prepare
96 $(PKG_BUILD_DIR)/.built: configure
97
98 $(PACKAGE_DIR):
99 mkdir -p $@
100
101 clean-targets:
102 clean:
103 @$(PKG_TRACE) Cleaning...
104 @$(MAKE) clean-targets $(MAKE_TRACE)
105 rm -rf $(PKG_BUILD_DIR)
106
107 .PHONY: all source prepare compile install clean
This page took 0.056504 seconds and 3 git commands to generate.