2 # Copyright (C) 2006-2007 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 all: $(if
$(DUMP
),dumpinfo
,compile
)
10 PKG_BUILD_DIR ?
= $(BUILD_DIR
)/$(PKG_NAME
)$(if
$(PKG_VERSION
),-$(PKG_VERSION
))
11 PKG_INSTALL_DIR ?
= $(PKG_BUILD_DIR
)/ipkg-install
14 include $(INCLUDE_DIR
)/prereq.mk
15 include $(INCLUDE_DIR
)/host.mk
16 include $(INCLUDE_DIR
)/unpack.mk
17 include $(INCLUDE_DIR
)/depends.mk
19 STAMP_PREPARED
=$(PKG_BUILD_DIR
)/.prepared
$(if
$(QUILT
)$(DUMP
),,_
$(shell $(call find_md5
,${CURDIR} $(PKG_FILE_DEPEND
),)))
20 STAMP_CONFIGURED
:=$(PKG_BUILD_DIR
)/.configured
21 STAMP_BUILT
:=$(PKG_BUILD_DIR
)/.built
22 STAMP_INSTALLED
:=$(STAGING_DIR
)/stamp
/.
$(PKG_NAME
)_installed
24 include $(INCLUDE_DIR
)/download.mk
25 include $(INCLUDE_DIR
)/quilt.mk
26 include $(INCLUDE_DIR
)/package-defaults.mk
27 include $(INCLUDE_DIR
)/package-dumpinfo.mk
28 include $(INCLUDE_DIR
)/package-ipkg.mk
29 include $(INCLUDE_DIR
)/package-bin.mk
30 include $(INCLUDE_DIR
)/autotools.mk
33 export CONFIG_SITE
:=$(INCLUDE_DIR
)/site
/$(REAL_GNU_TARGET_NAME
)
35 ifeq ($(DUMP
)$(filter prereq
clean refresh update
,$(MAKECMDGOALS
)),)
36 ifneq ($(if
$(QUILT
),,$(CONFIG_AUTOREBUILD
)),)
37 define Build
/Autoclean
38 $(PKG_BUILD_DIR
)/.dep_files
: $(STAMP_PREPARED
)
39 $(call rdep
,${CURDIR} $(PKG_FILE_DEPEND
),$(STAMP_PREPARED
),$(PKG_BUILD_DIR
)/.dep_files
,-x
"*/.dep_*")
40 $(if
$(filter prepare
,$(MAKECMDGOALS
)),,$(call rdep
,$(PKG_BUILD_DIR
),$(STAMP_BUILT
),,-x
"*/.dep_*" -x
"*/ipkg*"))
45 define Download
/default
47 URL
:=$(PKG_SOURCE_URL
)
48 SUBDIR
:=$(PKG_SOURCE_SUBDIR
)
49 PROTO
:=$(PKG_SOURCE_PROTO
)
50 VERSION
:=$(PKG_SOURCE_VERSION
)
58 define Build
/DefaultTargets
59 $(if
$(QUILT
),$(Build
/Quilt
))
60 $(if
$(strip $(PKG_SOURCE_URL
)),$(call Download
,default
))
61 $(call Build
/Autoclean
)
64 @
-rm -rf
$(PKG_BUILD_DIR
)
65 @mkdir
-p
$(PKG_BUILD_DIR
)
66 $(foreach hook
,$(Hooks
/Prepare
/Pre
),$(call
$(hook
))$(sep
))
68 $(foreach hook
,$(Hooks
/Prepare
/Post
),$(call
$(hook
))$(sep
))
71 $(STAMP_CONFIGURED
): $(STAMP_PREPARED
)
72 $(foreach hook
,$(Hooks
/Configure
/Pre
),$(call
$(hook
))$(sep
))
74 $(foreach hook
,$(Hooks
/Configure
/Post
),$(call
$(hook
))$(sep
))
77 $(STAMP_BUILT
): $(STAMP_CONFIGURED
)
78 $(foreach hook
,$(Hooks
/Compile
/Pre
),$(call
$(hook
))$(sep
))
80 $(foreach hook
,$(Hooks
/Compile
/Post
),$(call
$(hook
))$(sep
))
83 $(STAMP_INSTALLED
): $(STAMP_BUILT
)
84 $(NO_TRACE_MAKE
) clean-staging
85 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
86 mkdir
-p
$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
$(STAGING_DIR
)/packages
$(STAGING_DIR_HOST
)/packages
87 $(call Build
/InstallDev
,$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)
88 if
[ -d
$(TMP_DIR
)/stage-
$(PKG_NAME
) ]; then \
89 (cd
$(TMP_DIR
)/stage-
$(PKG_NAME
); find .
/ > $(STAGING_DIR
)/packages
/$(PKG_NAME
).list
); \
90 $(CP
) $(TMP_DIR
)/stage-
$(PKG_NAME
)/* $(STAGING_DIR
)/; \
92 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
95 ifdef Build
/InstallDev
96 compile
: $(STAMP_INSTALLED
)
99 define Build
/DefaultTargets
102 prepare
: $(STAMP_PREPARED
)
103 configure
: $(STAMP_CONFIGURED
)
107 $(eval
$(Package
/Default
))
108 $(eval
$(Package
/$(1)))
111 $$(error DESCRIPTION
:= is obselete
, use Package
/PKG_NAME
/description
)
114 ifndef Package
/$(1)/description
115 define Package
/$(1)/description
120 $(foreach FIELD
, TITLE CATEGORY PRIORITY SECTION VERSION
,
122 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
126 $(call shexport
,Package
/$(1)/description
)
127 $(call shexport
,Package
/$(1)/config
)
132 $(if
$(Package
/$(1)/targets
),$(Package
/$(1)/targets
), \
133 $(if
$(PKG_TARGETS
),$(PKG_TARGETS
), ipkg
) \
134 ), $(BuildTarget
/$(target
)) \
137 $(if
$(DUMP
),,$(call Build
/DefaultTargets
,$(1)))
140 define pkg_install_files
141 $(foreach install_file
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_file)`; $(INSTALL_DATA
) $(2)/$(install_file
) $(3)/`dirname $(install_file)`;)
144 define pkg_install_bin
145 $(foreach install_apps
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_apps)`; $(INSTALL_BIN
) $(2)/$(install_apps
) $(3)/`dirname $(install_apps)`;)
149 $(call Build
/Prepare
/Default
,)
152 define Build
/Configure
153 $(call Build
/Configure
/Default
,)
157 $(call Build
/Compile
/Default
,)
170 rm -f
$(STAMP_INSTALLED
)
172 cd
"$(STAGING_DIR)"; \
173 if
[ -f packages
/$(PKG_NAME
).list
]; then \
174 cat packages
/$(PKG_NAME
).list | xargs
-r
rm -f
2>/dev
/null
; \
178 clean: clean-staging FORCE
179 $(call Build
/UninstallDev
,$(STAGING_DIR
),$(STAGING_DIR_HOST
))
181 rm -f
$(STAGING_DIR
)/packages
/$(PKG_NAME
).list
$(STAGING_DIR_HOST
)/packages
/$(PKG_NAME
).list
182 rm -rf
$(PKG_BUILD_DIR
)