1
0

package.mk 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. all: build-all-pkgs
  4. # does not change CONFIGURE_ARGS in minimal mode
  5. ifeq ($(filter minimal,${CONFIG_STYLE}),)
  6. ifneq ($(ADK_DEBUG),)
  7. CONFIGURE_ARGS+= --enable-debug
  8. endif
  9. endif
  10. AUTOTOOL_ENV+= PATH='${HOST_PATH}' \
  11. ${COMMON_ENV}
  12. CONFIGURE_ENV+= PATH='${TARGET_PATH}' \
  13. ${COMMON_ENV} \
  14. ${TARGET_ENV} \
  15. PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
  16. PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
  17. GCC_HONOUR_COPTS=s \
  18. ac_cv_func_realloc_0_nonnull=yes \
  19. ac_cv_func_malloc_0_nonnull=yes \
  20. cross_compiling=yes
  21. CONFIGURE_PROG?= configure
  22. MAKE_FILE?= Makefile
  23. # this is environment for 'make all' and 'make install'
  24. MAKE_ENV?=
  25. # this is arguments for 'make all' and 'make install'
  26. XAKE_FLAGS?=
  27. # this is arguments for 'make all' ONLY
  28. MAKE_FLAGS?=
  29. # this is arguments for 'make install' ONLY
  30. FAKE_FLAGS?=
  31. ALL_TARGET?= all
  32. INSTALL_TARGET?= install
  33. MAKE_ENV+= PATH='${TARGET_PATH}' \
  34. ${COMMON_ENV} \
  35. ${TARGET_ENV} \
  36. PKG_CONFIG_LIBDIR='${STAGING_TARGET_DIR}/usr/lib/pkgconfig:${STAGING_TARGET_DIR}/usr/share/pkgconfig' \
  37. PKG_CONFIG_SYSROOT_DIR='${STAGING_TARGET_DIR}' \
  38. $(GCC_CHECK) \
  39. WRKDIR='${WRKDIR}' WRKDIST='${WRKDIST}' \
  40. WRKSRC='${WRKSRC}' WRKBUILD='${WRKBUILD}'
  41. MAKE_FLAGS+= ${XAKE_FLAGS} V=1
  42. FAKE_FLAGS+= ${XAKE_FLAGS}
  43. ifeq ($(strip ${WRKDIR_BSD}),)
  44. WRKDIR_BASE:= ${BUILD_DIR}
  45. else
  46. WRKDIR_BASE:= $(shell pwd)
  47. endif
  48. _EXTRACT_COOKIE= ${WRKDIST}/.extract_done
  49. _PATCH_COOKIE= ${WRKDIST}/.prepared
  50. _CONFIGURE_COOKIE= ${WRKBUILD}/.configure_done
  51. _BUILD_COOKIE= ${WRKBUILD}/.build_done
  52. _FAKE_COOKIE= ${WRKINST}/.fake_done
  53. _IPKGS_COOKIE= ${STAGING_PKG_DIR}/stamps/${PKG_NAME}${PKG_VERSION}-${PKG_RELEASE}
  54. _IN_PACKAGE:= 1
  55. include ${ADK_TOPDIR}/mk/buildhlp.mk
  56. # defined in buildhlp.mk ('extract' can fail, use 'patch' then)
  57. extract: ${_EXTRACT_COOKIE}
  58. patch: ${_PATCH_COOKIE}
  59. # defined below (will be moved to pkg-bottom.mk!)
  60. configure: ${_CONFIGURE_COOKIE}
  61. build: ${_BUILD_COOKIE}
  62. fake: ${_FAKE_COOKIE}
  63. # our recursive build entry point
  64. build-all-pkgs: ${_IPKGS_COOKIE}
  65. # there are some parameters to the PKG_template function
  66. # 1.) Config.in identifier ADK_PACKAGE_$(1)
  67. # 2.) name of the package, for single package mostly $(PKG_NAME)
  68. # 3.) package version (upstream version) and package release (adk version),
  69. # always $(PKG_VERSION)-$(PKG_RELEASE)
  70. # 4.) dependencies to other packages, $(PKG_DEPENDS)
  71. # 5.) description for the package, $(PKG_DESCR)
  72. # 6.) section of the package, $(PKG_SECTION)
  73. # 7.) special package options $(PKG_OPTS)
  74. # noscripts -> do not install scripts to $(STAGING_TARGET_DIR)/scripts
  75. # (needed for example for autoconf/automake)
  76. # noremove -> do not remove files from $(STAGING_TARGET_DIR) while
  77. # cleaning (needed for toolchain packages like glibc)
  78. # nostaging -> do not install files to $(STAGING_TARGET_DIR)
  79. # dev -> create a development subpackage with headers and pkg-config files
  80. # devonly -> create a development package only
  81. # should be package format independent and modular in the future
  82. define PKG_template
  83. ALL_PKGOPTS+= $(1)
  84. PKGNAME_$(1)= $(2)
  85. PKGDEPS_$(1)= $(4)
  86. PKGDESC_$(1)= $(5)
  87. PKGSECT_$(1)= $(6)
  88. IPKG_$(1)= $(PACKAGE_DIR)/$(2)_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
  89. IPKG_$(1)_DEV= $(PACKAGE_DIR)/$(2)-dev_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
  90. IPKG_$(1)_DBG= $(PACKAGE_DIR)/$(2)-dbg_$(3)_${ADK_TARGET_CPU_ARCH}.${PKG_SUFFIX}
  91. IDIR_$(1)= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)
  92. IDIR_$(1)_DEV= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)-dev
  93. IDIR_$(1)_DBG= $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(2)-dbg
  94. ifneq (${ADK_PACKAGE_$(1)}${DEVELOPER},)
  95. ifneq (,$(filter dev,$(7)))
  96. ifneq ($(ADK_TARGET_USE_STATIC_LIBS),y)
  97. ALL_IPKGS+= $$(IPKG_$(1))
  98. ALL_IDIRS+= $${IDIR_$(1)}
  99. ALL_POSTINST+= $(2)-install
  100. $(2)-install:
  101. endif
  102. else
  103. ALL_IPKGS+= $$(IPKG_$(1))
  104. ALL_IDIRS+= $${IDIR_$(1)}
  105. ALL_POSTINST+= $(2)-install
  106. $(2)-install:
  107. endif
  108. endif
  109. INFO_$(1)= $(PKG_STATE_DIR)/info/$(2).list
  110. INFO_$(1)_DEV= $(PKG_STATE_DIR)/info/$(2)-dev.list
  111. INFO_$(1)_DBG= $(PKG_STATE_DIR)/info/$(2)-dbg.list
  112. ifeq ($(ADK_PACKAGE_$(1)),y)
  113. ifeq (,$(filter devonly,$(7)))
  114. ifeq ($(ADK_PACKAGE_$(1)_DBG),y)
  115. install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG)
  116. ifeq ($(ADK_PACKAGE_$(1)_DEV),y)
  117. install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG) $$(INFO_$(1)_DEV)
  118. else
  119. install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DBG)
  120. endif
  121. else
  122. ifeq ($(ADK_PACKAGE_$(1)_DEV),y)
  123. install-targets: $$(INFO_$(1)) $$(INFO_$(1)_DEV)
  124. else
  125. install-targets: $$(INFO_$(1))
  126. endif
  127. endif
  128. else
  129. install-targets: $$(INFO_$(1))
  130. endif
  131. endif
  132. IDEPEND_$(1):= $$(strip $(4))
  133. _ALL_CONTROLS+= $$(IDIR_$(1))/CONTROL/control
  134. ICONTROL_$(1)?= $(WRKDIR)/.$(2).control
  135. ICONTROL_$(1)_DEV?= $(WRKDIR)/.$(2)-dev.control
  136. ICONTROL_$(1)_DBG?= $(WRKDIR)/.$(2)-dbg.control
  137. $$(IDIR_$(1))/CONTROL/control: ${_PATCH_COOKIE}
  138. @echo "Package: $$(shell echo $(2) | tr '_' '-')" > $(WRKDIR)/.$(2).control
  139. @echo "Section: $(6)" >> $(WRKDIR)/.$(2).control
  140. @echo "Description: $(5)" >> $(WRKDIR)/.$(2).control
  141. @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)} $${ICONTROL_$(1)} $(3) ${ADK_TARGET_CPU_ARCH}
  142. @adeps='$$(strip $${IDEPEND_$(1)})'; if [[ -n $$$$adeps ]]; then \
  143. comma=; \
  144. deps=; \
  145. last=; \
  146. for dep in $$$$adeps; do \
  147. if [[ $$$$last = kernel && $$$$dep = \(* ]]; then \
  148. deps="$$$$deps $$$$dep"; \
  149. else \
  150. deps="$$$$deps$$$$comma$$$$dep"; \
  151. fi; \
  152. comma=", "; \
  153. last=$$$$dep; \
  154. done; \
  155. echo "Depends: $$$$deps" | tr '_' '-' >>$${IDIR_$(1)}/CONTROL/control; \
  156. fi
  157. @for file in conffiles preinst postinst prerm postrm; do \
  158. [ ! -f ./files/$(2).$$$$file ] || cp ./files/$(2).$$$$file $$(IDIR_$(1))/CONTROL/$$$$file; \
  159. done
  160. ifneq ($(ADK_DEBUG),y)
  161. @echo "Package: $$(shell echo $(2) | tr '_' '-')-dbg" > $(WRKDIR)/.$(2)-dbg.control
  162. @echo "Section: debug" >> $(WRKDIR)/.$(2)-dbg.control
  163. @echo "Description: debugging symbols for $(2)" >> $(WRKDIR)/.$(2)-dbg.control
  164. @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)_DBG} $${ICONTROL_$(1)_DBG} $(3) ${ADK_TARGET_CPU_ARCH}
  165. @echo "Depends: $$(shell echo $(2) | tr '_' '-')" >> $${IDIR_$(1)_DBG}/CONTROL/control
  166. endif
  167. ifneq (,$(filter dev,$(7)))
  168. @echo "Package: $$(shell echo $(2) | tr '_' '-')-dev" > $(WRKDIR)/.$(2)-dev.control
  169. @echo "Section: devel" >> $(WRKDIR)/.$(2)-dev.control
  170. @echo "Description: development files for $(2)" >> $(WRKDIR)/.$(2)-dev.control
  171. @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh $${IDIR_$(1)_DEV} $${ICONTROL_$(1)_DEV} $(3) ${ADK_TARGET_CPU_ARCH}
  172. @echo "Depends: $$(shell echo $(2) | tr '_' '-')" >> $${IDIR_$(1)_DEV}/CONTROL/control
  173. endif
  174. $$(IPKG_$(1)): $$(IDIR_$(1))/CONTROL/control $${_FAKE_COOKIE}
  175. ifeq ($(ADK_DEBUG),)
  176. @$${RSTRIP} $${IDIR_$(1)} $(MAKE_TRACE)
  177. endif
  178. ifeq ($(ADK_DEBUG_STRIP),y)
  179. @$${RSTRIP} $${IDIR_$(1)} $(MAKE_TRACE)
  180. endif
  181. ifeq (${ADK_LEAVE_ETC_ALONE}$(filter force_etc,$(7)),y)
  182. -rm -rf $${IDIR_$(1)}/etc
  183. else
  184. ifeq (${ADK_INSTALL_PACKAGE_INIT_SCRIPTS},y)
  185. @for file in $$$$(ls ./files/*.init 2>/dev/null); do \
  186. fname=$$$$(echo $$$$file| sed -e "s#.*/##" -e "s#.init##"); \
  187. check=$$$$(grep PKG $$$$file|cut -d ' ' -f 2); \
  188. if [ "$$$$check" == $(2) ];then \
  189. mkdir -p $$(IDIR_$(1))/etc/init.d && cp $$$$file $$(IDIR_$(1))/etc/init.d/$$$$fname; \
  190. fi; \
  191. done
  192. @cd $${IDIR_$(1)}; for script in etc/init.d/*; do \
  193. [[ -e $$$$script ]] || continue; \
  194. chmod 0755 "$$$$script"; \
  195. done
  196. endif
  197. ifneq (${ADK_INSTALL_PACKAGE_NETWORK_SCRIPTS},y)
  198. -rm -rf $${IDIR_$(1)}/etc/network
  199. endif
  200. endif
  201. @mkdir -p $${PACKAGE_DIR} '$${STAGING_PKG_DIR}/stamps' \
  202. '$${STAGING_TARGET_DIR}/scripts'
  203. ifeq (,$(filter noremove,$(7)))
  204. @if test -s '$${STAGING_PKG_DIR}/$(1)'; then \
  205. cd '$${STAGING_TARGET_DIR}'; \
  206. while read fn; do \
  207. rm -f "$$$$fn"; \
  208. done <'$${STAGING_PKG_DIR}/$(1)'; \
  209. fi
  210. endif
  211. @rm -f '$${STAGING_PKG_DIR}/$(1)'
  212. ifeq (,$(filter nostaging,$(7)))
  213. @-cd $${IDIR_$(1)}; \
  214. x=$$$$(find tmp var -mindepth 1 2>/dev/null); if [[ -n $$$$x ]]; then \
  215. echo 'WARNING: $${IPKG_$(1)} installs files into a' \
  216. 'ramdisk location:' >&2; \
  217. echo "$$$$x" | sed 's/^/- /' >&2; \
  218. fi; \
  219. find usr ! -type d 2>/dev/null | \
  220. grep -E -v -e '^usr/lib/pkgconfig' -e '^usr/share' -e '^usr/doc' -e '^usr/src' -e '^usr/man' -e '^usr/info' -e '^usr/lib/libc.so' -e '^usr/bin/[a-z0-9-]+-config' | \
  221. tee '$${STAGING_PKG_DIR}/$(1)' | \
  222. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu '$${STAGING_TARGET_DIR}'
  223. @cd '$${STAGING_TARGET_DIR}'; grep 'usr/lib/.*\.la$$$$' \
  224. '$${STAGING_PKG_DIR}/$(1)' | while read fn; do \
  225. chmod u+w $$$$fn; \
  226. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_TARGET_DIR)/usr/lib,g" $$$$fn; \
  227. done
  228. endif
  229. ifeq (,$(filter noscripts,$(7)))
  230. @cd '$${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
  231. '$${STAGING_PKG_DIR}/$(1)' | \
  232. while read fn; do \
  233. b="$$$$(dd if="$$$$fn" bs=2 count=1 2>/dev/null)"; \
  234. [[ $$$$b = '#!' ]] || continue; \
  235. cp "$$$$fn" scripts/; \
  236. echo "scripts/$$$$(basename "$$$$fn")" \
  237. >>'$${STAGING_PKG_DIR}/$(1)'; \
  238. done
  239. endif
  240. ifeq (,$(filter devonly,$(7)))
  241. $${PKG_BUILD} $${IDIR_$(1)} $${PACKAGE_DIR} $(MAKE_TRACE)
  242. ifneq ($(ADK_DEBUG),y)
  243. $${PKG_BUILD} $${IDIR_$(1)_DBG} $${PACKAGE_DIR} $(MAKE_TRACE)
  244. endif
  245. endif
  246. ifneq (,$(filter dev,$(7)))
  247. $${PKG_BUILD} $${IDIR_$(1)_DEV} $${PACKAGE_DIR} $(MAKE_TRACE)
  248. endif
  249. clean-targets: clean-dev-$(1)
  250. clean-dev-$(1):
  251. ifeq (,$(filter noremove,$(7)))
  252. @if test -s '$${STAGING_PKG_DIR}/$(1)'; then \
  253. cd '$${STAGING_TARGET_DIR}'; \
  254. while read fn; do \
  255. rm -f "$$$$fn"; \
  256. done <'$${STAGING_PKG_DIR}/$(1)'; \
  257. fi
  258. endif
  259. @rm -f '$${STAGING_PKG_DIR}/$(1)'
  260. $$(INFO_$(1)): $$(IPKG_$(1))
  261. $(PKG_INSTALL) $$(IPKG_$(1))
  262. $$(INFO_$(1)_DBG): $$(IPKG_$(1)_DBG)
  263. $(PKG_INSTALL) $$(IPKG_$(1)_DBG)
  264. ifneq ($(1),UCLIBC_NG)
  265. ifneq ($(1),UCLIBC)
  266. ifneq ($(1),GLIBC)
  267. ifneq ($(1),MUSL)
  268. $$(INFO_$(1)_DEV): $$(IPKG_$(1)_DEV)
  269. $(PKG_INSTALL) $$(IPKG_$(1)_DEV)
  270. endif
  271. endif
  272. endif
  273. endif
  274. endef
  275. install-targets:
  276. install:
  277. @$(CMD_TRACE) "installing... "
  278. @$(MAKE) install-targets $(MAKE_TRACE)
  279. clean-targets:
  280. clean:
  281. @$(CMD_TRACE) "cleaning... "
  282. @$(MAKE) clean-targets $(MAKE_TRACE)
  283. rm -rf ${WRKDIR} ${ALL_IPKGS} ${STAGING_PKG_DIR}/stamps/${PKG_NAME}${PKG_VERSION}
  284. distclean: clean
  285. rm -f ${FULLDISTFILES}
  286. .PHONY: all refetch extract patch configure \
  287. build fake package install clean build-all-pkgs