2 # Copyright (C) 2006-2008 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-debug.mk
30 include $(INCLUDE_DIR
)/package-bin.mk
31 include $(INCLUDE_DIR
)/autotools.mk
34 CONFIG_SITE
:=$(INCLUDE_DIR
)/site
/$(REAL_GNU_TARGET_NAME
)
35 ifneq ($(CONFIG_LINUX_2_4
),)
36 CONFIG_SITE
:=$(subst linux-
,linux2.4
-,$(CONFIG_SITE
))
38 CUR_MAKEFILE
:=$(filter-out Makefile
,$(firstword $(MAKEFILE_LIST
)))
39 SUBMAKE
:=$(NO_TRACE_MAKE
) $(if
$(CUR_MAKEFILE
),-f
$(CUR_MAKEFILE
))
41 ifeq ($(DUMP
)$(filter prereq
clean refresh update
,$(MAKECMDGOALS
)),)
42 ifneq ($(if
$(QUILT
),,$(CONFIG_AUTOREBUILD
)),)
43 define Build
/Autoclean
44 $(PKG_BUILD_DIR
)/.dep_files
: $(STAMP_PREPARED
)
45 $(call rdep
,${CURDIR} $(PKG_FILE_DEPEND
),$(STAMP_PREPARED
),$(PKG_BUILD_DIR
)/.dep_files
,-x
"*/.dep_*")
46 $(if
$(filter prepare
,$(MAKECMDGOALS
)),,$(call rdep
,$(PKG_BUILD_DIR
),$(STAMP_BUILT
),,-x
"*/.dep_*" -x
"*/ipkg*"))
51 define Download
/default
53 URL
:=$(PKG_SOURCE_URL
)
54 SUBDIR
:=$(PKG_SOURCE_SUBDIR
)
55 PROTO
:=$(PKG_SOURCE_PROTO
)
56 $(if
$(PKG_SOURCE_MIRROR
),MIRROR
:=$(filter 1,$(PKG_MIRROR
)))
57 VERSION
:=$(PKG_SOURCE_VERSION
)
65 define Build
/DefaultTargets
66 $(if
$(QUILT
),$(Build
/Quilt
))
67 $(if
$(strip $(PKG_SOURCE_URL
)),$(call Download
,default
))
68 $(call Build
/Autoclean
)
70 $(STAMP_PREPARED
) : export PATH
=$$(TARGET_PATH_PKG
)
72 @
-rm -rf
$(PKG_BUILD_DIR
)
73 @mkdir
-p
$(PKG_BUILD_DIR
)
74 $(foreach hook
,$(Hooks
/Prepare
/Pre
),$(call
$(hook
))$(sep
))
76 $(foreach hook
,$(Hooks
/Prepare
/Post
),$(call
$(hook
))$(sep
))
79 $(STAMP_CONFIGURED
) : export PATH
=$$(TARGET_PATH_PKG
)
80 $(STAMP_CONFIGURED
) : export CONFIG_SITE
:=$$(CONFIG_SITE
)
81 $(STAMP_CONFIGURED
) : export PKG_CONFIG_PATH
=$$(STAGING_DIR
)/usr
/lib
/pkgconfig
82 $(STAMP_CONFIGURED
) : export PKG_CONFIG_LIBDIR
=$$(STAGING_DIR
)/usr
/lib
/pkgconfig
83 $(STAMP_CONFIGURED
): $(STAMP_PREPARED
)
84 $(foreach hook
,$(Hooks
/Configure
/Pre
),$(call
$(hook
))$(sep
))
86 $(foreach hook
,$(Hooks
/Configure
/Post
),$(call
$(hook
))$(sep
))
89 $(STAMP_BUILT
) : export PATH
=$$(TARGET_PATH_PKG
)
90 $(STAMP_BUILT
) : export CONFIG_SITE
:=$$(CONFIG_SITE
)
91 $(STAMP_BUILT
) : export PKG_CONFIG_PATH
=$$(STAGING_DIR
)/usr
/lib
/pkgconfig
:$$(STAGING_DIR_HOST
)/usr
/lib
/pkgconfig
92 $(STAMP_BUILT
) : export PKG_CONFIG_LIBDIR
=$$(STAGING_DIR
)/usr
/lib
/pkgconfig
93 $(STAMP_BUILT
): $(STAMP_CONFIGURED
)
94 $(foreach hook
,$(Hooks
/Compile
/Pre
),$(call
$(hook
))$(sep
))
96 $(foreach hook
,$(Hooks
/Compile
/Post
),$(call
$(hook
))$(sep
))
98 $(foreach hook
,$(Hooks
/Install
/Post
),$(call
$(hook
))$(sep
))
101 $(STAMP_INSTALLED
) : export PATH
=$$(TARGET_PATH_PKG
)
102 $(STAMP_INSTALLED
): $(STAMP_BUILT
)
103 $(SUBMAKE
) -j1 clean-staging
104 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
105 mkdir
-p
$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
$(STAGING_DIR
)/packages
$(STAGING_DIR_HOST
)/packages
106 $(foreach hook
,$(Hooks
/InstallDev
/Pre
),\
107 $(call
$(hook
),$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)$(sep
)\
109 $(call Build
/InstallDev
,$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)
110 $(foreach hook
,$(Hooks
/InstallDev
/Post
),\
111 $(call
$(hook
),$(TMP_DIR
)/stage-
$(PKG_NAME
),$(TMP_DIR
)/stage-
$(PKG_NAME
)/host
)$(sep
)\
113 if
[ -d
$(TMP_DIR
)/stage-
$(PKG_NAME
) ]; then \
114 (cd
$(TMP_DIR
)/stage-
$(PKG_NAME
); find .
/ > $(STAGING_DIR
)/packages
/$(PKG_NAME
).list
); \
115 $(CP
) $(TMP_DIR
)/stage-
$(PKG_NAME
)/* $(STAGING_DIR
)/; \
117 rm -rf
$(TMP_DIR
)/stage-
$(PKG_NAME
)
120 ifdef Build
/InstallDev
121 compile
: $(STAMP_INSTALLED
)
124 define Build
/DefaultTargets
127 prepare
: $(STAMP_PREPARED
)
128 configure
: $(STAMP_CONFIGURED
)
132 $(eval
$(Package
/Default
))
133 $(eval
$(Package
/$(1)))
136 $$(error DESCRIPTION
:= is obsolete
, use Package
/PKG_NAME
/description
)
139 ifndef Package
/$(1)/description
140 define Package
/$(1)/description
145 $(foreach FIELD
, TITLE CATEGORY PRIORITY SECTION VERSION
,
147 $$(error Package
/$(1) is missing the
$(FIELD
) field
)
151 $(call shexport
,Package
/$(1)/description
)
152 $(call shexport
,Package
/$(1)/config
)
157 $(if
$(Package
/$(1)/targets
),$(Package
/$(1)/targets
), \
158 $(if
$(PKG_TARGETS
),$(PKG_TARGETS
), ipkg
$(if
$(CONFIG_DEBUG_DIR
),debug
)) \
159 ), $(BuildTarget
/$(target
)) \
162 $(if
$(PKG_HOST_ONLY
)$(DUMP
),,$(call Build
/DefaultTargets
,$(1)))
165 define pkg_install_files
166 $(foreach install_file
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_file)`; $(INSTALL_DATA
) $(2)/$(install_file
) $(3)/`dirname $(install_file)`;)
169 define pkg_install_bin
170 $(foreach install_apps
,$(1),$(INSTALL_DIR
) $(3)/`dirname $(install_apps)`; $(INSTALL_BIN
) $(2)/$(install_apps
) $(3)/`dirname $(install_apps)`;)
173 Build
/Prepare
=$(call Build
/Prepare
/Default
,)
174 Build
/Configure
=$(call Build
/Configure
/Default
,)
175 Build
/Compile
=$(call Build
/Compile
/Default
,)
176 Build
/Install
=$(if
$(PKG_INSTALL
),$(call Build
/Install
/Default
,))
188 rm -f
$(STAMP_INSTALLED
)
190 cd
"$(STAGING_DIR)"; \
191 if
[ -f packages
/$(PKG_NAME
).list
]; then \
192 cat packages
/$(PKG_NAME
).list | xargs
-r
rm -f
2>/dev
/null
; \
196 clean: clean-staging FORCE
197 $(call Build
/UninstallDev
,$(STAGING_DIR
),$(STAGING_DIR_HOST
))
199 rm -f
$(STAGING_DIR
)/packages
/$(PKG_NAME
).list
$(STAGING_DIR_HOST
)/packages
/$(PKG_NAME
).list
200 rm -rf
$(PKG_BUILD_DIR
)