source: freewrt/package/rules.mk@ 54f72bc

freewrt_1_0 freewrt_2_0
Last change on this file since 54f72bc was 54f72bc, checked in by Thorsten Glaser <tg@…>, 19 years ago

(cd package/foo; TOPDIR=../.. gmake update-patches) # should now work

IMPORTANT: gmake TOPDIR=../.. foo *does not work* (since it overrides
the correct value which otherwise gets pulled from prereq.mk after it
has been found from the environment-TOPDIR value and gets preference)

git-svn-id: svn://www.freewrt.org/trunk/freewrt@404 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 3.0 KB
Line 
1# invoke ipkg with configuration in $(STAGING_DIR)/etc/ipkg.conf
2
3ifneq (${PKG_SOURCE_URL},)
4ifeq (${PKG_SOURCE},)
5PKG_SOURCE:= ${PKG_NAME}-${PKG_VERSION}.tar.gz
6endif
7endif
8ifneq (${PKG_SOURCE},)
9DISTFILES?= ${DL_DIR}/${PKG_SOURCE}
10endif
11
12WRKDIR?= ${BUILD_DIR}/w-${PKG_NAME}-${PKG_VERSION}-${PKG_RELEASE}
13WRKSRC?= ${WRKDIR}/${PKG_NAME}-${PKG_VERSION}
14WRKBUILD?= ${WRKSRC}
15WRKINST?= ${WRKDIR}/ipkg-install
16
17define PKG_template
18IPKG_$(1)= $(PACKAGE_DIR)/$(2)_$(3)_$(4).ipk
19IDIR_$(1)= $(WRKDIR)/ipkg/$(2)
20INFO_$(1)= $(IPKG_STATE_DIR)/info/$(2).list
21
22ifneq ($(FWRT_PACKAGE_$(1)),)
23compile-targets: $$(IPKG_$(1))
24endif
25ifneq ($(DEVELOPER),)
26compile-targets: $$(IPKG_$(1))
27endif
28ifeq ($(FWRT_PACKAGE_$(1)),y)
29install-targets: $$(INFO_$(1))
30endif
31
32IDEPEND_$(1):= $$(strip $(5))
33
34$$(IDIR_$(1))/CONTROL/control: $(WRKBUILD)/.prepared
35 $(SCRIPT_DIR)/make-ipkg-dir.sh $$(IDIR_$(1)) ./ipkg/$(2).control $(3) $(4)
36 [ -z "$$(IDEPEND_$(1))" ] || echo "Depends: $$(IDEPEND_$(1))" >>$$(IDIR_$(1))/CONTROL/control
37 for file in conffiles preinst postinst prerm postrm; do \
38 [ ! -f ./ipkg/$(2).$$$$file ] || cp ./ipkg/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file; \
39 done
40
41$$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $(WRKBUILD)/.built $(PACKAGE_DIR)
42
43$$(INFO_$(1)): $$(IPKG_$(1))
44 $(IPKG) install $$(IPKG_$(1))
45
46$(2)-clean:
47 rm -f $$(IPKG_$(1))
48clean: $(2)-clean
49endef
50
51
52ifneq (${PKG_SOURCE_URL},)
53$(DL_DIR)/$(PKG_SOURCE):
54 @$(CMD_TRACE) "downloading... "
55 $(SCRIPT_DIR)/download.pl "$(DL_DIR)" "$(PKG_SOURCE)" "$(PKG_MD5SUM)" $(PKG_SOURCE_URL) $(MAKE_TRACE)
56endif
57
58ifneq (${DISTFILES}${PKG_SOURCE},)
59$(WRKBUILD)/.prepared: ${DISTFILES}
60 rm -rf ${WRKSRC} ${WRKBUILD}
61 ${EXTRACT_CMD}
62 [ ! -d ./patches ] || $(PATCH) $(WRKSRC) ./patches
63 touch $(WRKBUILD)/.prepared
64endif
65
66all: compile
67
68source: ${DISTFILES}
69prepare: source
70 @[ -f $(WRKBUILD)/.prepared ] || { \
71 $(CMD_TRACE) "preparing... "; \
72 $(MAKE) $(WRKBUILD)/.prepared $(MAKE_TRACE); \
73 }
74
75configure: prepare
76 @[ -f $(WRKBUILD)/.configured ] || { \
77 $(CMD_TRACE) "configuring... "; \
78 $(MAKE) $(WRKBUILD)/.configured $(MAKE_TRACE); \
79 }
80
81compile-targets:
82compile: configure
83 @$(CMD_TRACE) "compiling... "
84 @$(MAKE) compile-targets $(MAKE_TRACE)
85
86install-targets:
87install:
88 @$(CMD_TRACE) "installing... "
89 @$(MAKE) install-targets $(MAKE_TRACE)
90
91$(WRKBUILD)/.configured:
92$(WRKBUILD)/.built:
93
94$(PACKAGE_DIR):
95 mkdir -p $@
96
97clean-targets:
98clean:
99 @$(CMD_TRACE) "cleaning... "
100 @$(MAKE) clean-targets $(MAKE_TRACE)
101 rm -rf ${WRKDIR}
102
103update-patches:
104 @test ! -d ${WRKDIR}.orig || rm -rf ${WRKDIR}.orig
105 @test ! -d ${WRKDIR}.orig
106 @$(MAKE) -s V=0 prepare WRKDIR=${WRKDIR}.orig PATCH=:
107 @toedit=$$(WRKDIST='${WRKSRC}' PATCHDIR=$$(pwd)/patches \
108 PATCH_LIST='patch-* *.patch' WRKDIR1='${WRKDIR}' \
109 ${BASH} ${TOPDIR}/scripts/update-patches); \
110 if [[ -n $$toedit && $$toedit != FAIL ]]; then \
111 echo -n 'edit patches: '; read i; \
112 cd patches && $${VISUAL:-$${EDITOR:-/usr/bin/vi}} $$toedit; \
113 fi; \
114 rm -rf ${WRKDIR}.orig; \
115 [[ $$toedit != FAIL ]]
116
117.PHONY: all source prepare compile install clean update-patches
Note: See TracBrowser for help on using the repository browser.