pkg-bottom.mk 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  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. # Comments:
  4. # * pre/do/post-foo are always defined here, but empty. This is so
  5. # that we can call it (BSD make has .if target(foo) but GNU not)
  6. # and it won't error out.
  7. # * ${_foo_COOKIE} are the actual targets
  8. # * default is "auto"
  9. # * define "manual" if you need your own method
  10. # -> define a do-foo: target in the Makefile
  11. # * if you have a style -> define a pre-foo: and post-foo: if they
  12. # are required, but the do-foo: magic is done here
  13. PKG_LIBNAME?= $(PKG_NAME)
  14. pre-configure:
  15. do-configure:
  16. post-configure:
  17. ${_CONFIGURE_COOKIE}: ${_PATCH_COOKIE}
  18. ifneq (,$(filter bootstrap,${AUTOTOOL_STYLE}))
  19. cd ${WRKSRC}; env ${AUTOTOOL_ENV} $(BASH) bootstrap.sh $(MAKE_TRACE)
  20. endif
  21. ifneq (,$(filter autogen,${AUTOTOOL_STYLE}))
  22. cd ${WRKSRC}; env ${AUTOTOOL_ENV} $(BASH) autogen.sh $(MAKE_TRACE)
  23. endif
  24. ifneq (,$(filter autoconf,${AUTOTOOL_STYLE}))
  25. cd ${WRKSRC}; env ${AUTOTOOL_ENV} autoconf $(MAKE_TRACE)
  26. endif
  27. ifneq (,$(filter autoreconf,${AUTOTOOL_STYLE}))
  28. @cd ${WRKSRC}; env ${AUTOTOOL_ENV} autoreconf -if $(MAKE_TRACE)
  29. @rm -rf ${WRKSRC}/autom4te.cache
  30. @touch ${WRKDIR}/.autoreconf_done
  31. endif
  32. mkdir -p ${WRKBUILD}
  33. @${MAKE} pre-configure $(MAKE_TRACE)
  34. @cd ${WRKSRC}; \
  35. for i in $$(find . -name config.sub);do \
  36. if [ -f $$i ]; then \
  37. ${CP} ${SCRIPT_DIR}/config.sub $$i; \
  38. fi; \
  39. done; \
  40. for i in $$(find . -name config.guess);do \
  41. if [ -f $$i ]; then \
  42. ${CP} ${SCRIPT_DIR}/config.guess $$i; \
  43. fi; \
  44. done;
  45. ifneq ($(filter manual,${CONFIG_STYLE}),)
  46. env ${CONFIGURE_ENV} ${MAKE} do-configure $(MAKE_TRACE)
  47. else ifneq ($(filter minimal,${CONFIG_STYLE}),)
  48. @$(CMD_TRACE) "configuring... "
  49. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  50. env ${CONFIGURE_ENV} \
  51. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} \
  52. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  53. else ifeq ($(strip ${CONFIG_STYLE}),)
  54. @$(CMD_TRACE) "configuring... "
  55. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  56. env ${CONFIGURE_ENV} \
  57. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
  58. --program-prefix= \
  59. --program-suffix= \
  60. --prefix=/usr \
  61. --bindir=/usr/bin \
  62. --datadir=/usr/share \
  63. --mandir=/usr/share/man \
  64. --libexecdir=/usr/libexec \
  65. --localstatedir=/var \
  66. --sysconfdir=/etc \
  67. --enable-shared \
  68. --enable-static \
  69. --disable-dependency-tracking \
  70. --disable-libtool-lock \
  71. --disable-nls \
  72. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  73. else
  74. @echo "Invalid CONFIG_STYLE '${CONFIG_STYLE}'" >&2
  75. @exit 1
  76. endif
  77. @${MAKE} post-configure $(MAKE_TRACE)
  78. touch $@
  79. # do a parallel build if requested && package doesn't force disable it
  80. ifeq (${ADK_MAKE_PARALLEL},y)
  81. ifeq ($(strip ${PKG_NOPARALLEL}),)
  82. MAKE_FLAGS+= -j${ADK_MAKE_JOBS}
  83. endif
  84. endif
  85. pre-build:
  86. do-build:
  87. post-build:
  88. ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
  89. @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
  90. @$(CMD_TRACE) "compiling... "
  91. ifneq ($(filter manual,${BUILD_STYLE}),)
  92. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  93. else ifeq ($(strip ${BUILD_STYLE}),)
  94. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  95. ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
  96. else
  97. @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
  98. @exit 1
  99. endif
  100. @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
  101. touch $@
  102. pre-install:
  103. do-install:
  104. post-install:
  105. spkg-install: ${ALL_POSTINST}
  106. ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
  107. @-rm -f ${_ALL_CONTROLS}
  108. @mkdir -p '${STAGING_PKG_DIR}/stamps' ${WRKINST} '${STAGING_TARGET_DIR}/scripts'
  109. @${MAKE} ${_ALL_CONTROLS} $(MAKE_TRACE)
  110. @env ${MAKE_ENV} ${MAKE} pre-install $(MAKE_TRACE)
  111. ifneq ($(filter manual,${INSTALL_STYLE}),)
  112. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  113. else ifeq ($(strip ${INSTALL_STYLE}),)
  114. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  115. DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE)
  116. env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  117. else
  118. @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
  119. @exit 1
  120. endif
  121. env ${MAKE_ENV} ${MAKE} spkg-install $(MAKE_TRACE)
  122. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}.scripts'
  123. @for a in ${WRKINST}/usr/bin/*-config*; do \
  124. [[ -e $$a ]] || continue; \
  125. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  126. ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  127. chmod u+x ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  128. [[ "$$(basename $$a)" != "pkg-config" ]] && cp ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a) ${STAGING_TARGET_DIR}/scripts; \
  129. echo "scripts/$$(basename $$a)" \
  130. >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
  131. done
  132. ifeq (,$(filter noremove,${PKG_OPTS}))
  133. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  134. cd '${STAGING_TARGET_DIR}'; \
  135. while read fn; do \
  136. rm -f "$$fn"; \
  137. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  138. fi
  139. endif
  140. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  141. ifneq (,$(filter dev,${PKG_OPTS}))
  142. @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  143. @test -d ${WRKINST}/usr/include && cd ${WRKINST}/usr/include; \
  144. find . -name \*.h | \
  145. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  146. @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  147. @test -d ${WRKINST}/usr/lib/pkgconfig && cd ${WRKINST}/usr/lib/pkgconfig; \
  148. find . -name \*.pc | \
  149. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  150. @for a in ${WRKINST}/usr/bin/*-config*; do \
  151. [[ -e $$a ]] || continue; \
  152. mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  153. cp $$a $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  154. chmod 755 $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin/$$(basename $$a); \
  155. done
  156. endif
  157. ifeq (,$(filter nostaging,${PKG_OPTS}))
  158. @-cd ${WRKINST}; \
  159. find usr ! -type d 2>/dev/null | \
  160. grep -E -v -e '^usr/share' -e '^usr/src' -e '^usr/doc' -e '^usr/local' -e '^usr/man' -e '^usr/info' -e '^usr/lib/libc.so' -e '^usr/bin/[a-z0-9-]+-config*' -e '^/usr/lib/libpthread_nonshared.a' | \
  161. tee '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  162. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu '${STAGING_TARGET_DIR}'
  163. @cd '${STAGING_TARGET_DIR}'; grep 'usr/lib/.*\.la$$' \
  164. '${STAGING_PKG_DIR}/${PKG_NAME}' | while read fn; do \
  165. chmod u+w $$fn; \
  166. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_TARGET_DIR)/usr/lib,g" $$fn; \
  167. done
  168. endif
  169. ifeq (,$(filter noscripts,${PKG_OPTS}))
  170. @cd '${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
  171. '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  172. while read fn; do \
  173. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  174. [[ $$b = '#!' ]] || continue; \
  175. cp "$$fn" scripts/; \
  176. echo "scripts/$$(basename "$$fn")" \
  177. >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  178. done
  179. endif
  180. -@test -e '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
  181. cat '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' || :
  182. touch $@
  183. ${_IPKGS_COOKIE}:
  184. exec ${MAKE} package
  185. package: ${ALL_IPKGS}
  186. ifneq ($(DEVELOPER),)
  187. @cd ${WRKDIR}/fake-${ADK_TARGET_CPU_ARCH} || exit 1; \
  188. y=; sp=; for x in ${ALL_IDIRS}; do \
  189. y="$$y$$sp$${x#$(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/}"; \
  190. sp=' '; \
  191. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  192. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  193. while read sum name; do \
  194. inode=$$(ls -i "$$name"); \
  195. echo "$$sum $${inode%% *} $$name"; \
  196. done | sort | while read sum inode name; do \
  197. if [[ $$sum = $$ls ]]; then \
  198. [[ $$li = $$inode ]] && continue; \
  199. case $$x in \
  200. 1) echo 'WARNING: duplicate files found in' \
  201. 'package "${PKG_NAME}"! Fix them.' >&2; \
  202. echo -n "> $$ln "; \
  203. ;; \
  204. 2) echo -n "> $$ln "; \
  205. ;; \
  206. 3) echo -n ' '; \
  207. ;; \
  208. esac; \
  209. echo -n "$$name"; \
  210. x=3; \
  211. else \
  212. case $$x in \
  213. 3) echo; \
  214. x=2; \
  215. ;; \
  216. esac; \
  217. fi; \
  218. ls=$$sum; \
  219. ln=$$name; \
  220. li=$$inode; \
  221. done
  222. endif
  223. touch ${_IPKGS_COOKIE}
  224. clean-targets: clean-dev-generic
  225. clean-dev-generic:
  226. ifeq (,$(filter noremove,${PKG_OPTS}))
  227. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  228. cd '${STAGING_TARGET_DIR}'; \
  229. while read fn; do \
  230. rm -f "$$fn"; \
  231. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  232. fi
  233. endif
  234. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  235. ifneq (,$(filter autoreconf,${AUTOTOOL_STYLE}))
  236. DIFF_IGNOREFILES?= configure missing depcomp install-sh INSTALL \
  237. aclocal.m4 config.h.in Makefile.in */Makefile.in \
  238. config.sub config.guess */config.sub */config.guess
  239. else
  240. DIFF_IGNOREFILES?= config.sub config.guess */config.sub */config.guess
  241. endif