pkg-bottom.mk 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. REORDER_DEPENDENCIES= ${TOPDIR}/scripts/automake.dep
  14. pre-configure:
  15. do-configure:
  16. post-configure:
  17. ${_CONFIGURE_COOKIE}: ${_PATCH_COOKIE}
  18. @sed -e '/^#/d' ${REORDER_DEPENDENCIES} | \
  19. tsort | while read f; do \
  20. cd ${WRKSRC}; \
  21. case $$f in \
  22. /*) \
  23. find . -name "$${f#/}" -print | while read i; do \
  24. touch "$$i"; \
  25. done;; \
  26. *) \
  27. if test -e "$$f" ; then \
  28. touch "$$f"; \
  29. fi;; \
  30. esac; \
  31. done
  32. mkdir -p ${WRKBUILD}
  33. @${MAKE} pre-configure $(MAKE_TRACE)
  34. ifneq ($(filter manual,${CONFIG_STYLE}),)
  35. env ${CONFIGURE_ENV} ${MAKE} do-configure $(MAKE_TRACE)
  36. else ifneq ($(filter minimal,${CONFIG_STYLE}),)
  37. @$(CMD_TRACE) "configuring... "
  38. @cd ${WRKBUILD}; \
  39. for i in $$(find . -name config.sub);do \
  40. if [ -f $$i ]; then \
  41. ${CP} $$i $$i.bak; \
  42. ${CP} ${SCRIPT_DIR}/config.sub $$i; \
  43. fi; \
  44. done; \
  45. for i in $$(find . -name config.guess);do \
  46. if [ -f $$i ]; then \
  47. ${CP} $$i $$i.bak; \
  48. ${CP} ${SCRIPT_DIR}/config.guess $$i; \
  49. fi; \
  50. done;
  51. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  52. env ${CONFIGURE_ENV} \
  53. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} \
  54. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  55. else ifeq ($(strip ${CONFIG_STYLE}),)
  56. @$(CMD_TRACE) "configuring... "
  57. @cd ${WRKBUILD}; \
  58. for i in $$(find . -name config.sub);do \
  59. if [ -f $$i ]; then \
  60. ${CP} $$i $$i.bak; \
  61. ${CP} ${SCRIPT_DIR}/config.sub $$i; \
  62. fi; \
  63. done; \
  64. for i in $$(find . -name config.guess);do \
  65. if [ -f $$i ]; then \
  66. ${CP} $$i $$i.bak; \
  67. ${CP} ${SCRIPT_DIR}/config.guess $$i; \
  68. fi; \
  69. done;
  70. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  71. env ${CONFIGURE_ENV} \
  72. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
  73. --program-prefix= \
  74. --program-suffix= \
  75. --prefix=/usr \
  76. --bindir=/usr/bin \
  77. --datadir=/usr/share \
  78. --mandir=/usr/share/man \
  79. --libexecdir=/usr/libexec \
  80. --localstatedir=/var \
  81. --sysconfdir=/etc \
  82. --enable-shared \
  83. --enable-static \
  84. --disable-dependency-tracking \
  85. --disable-libtool-lock \
  86. $(NLS) \
  87. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  88. else
  89. @echo "Invalid CONFIG_STYLE '${CONFIG_STYLE}'" >&2
  90. @exit 1
  91. endif
  92. @${MAKE} post-configure $(MAKE_TRACE)
  93. touch $@
  94. # do a parallel build if requested && package doesn't force disable it
  95. ifeq (${ADK_MAKE_PARALLEL},y)
  96. ifeq ($(strip ${PKG_NOPARALLEL}),)
  97. MAKE_FLAGS+= -j${ADK_MAKE_JOBS}
  98. endif
  99. endif
  100. pre-build:
  101. do-build:
  102. post-build:
  103. ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
  104. @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
  105. @$(CMD_TRACE) "compiling... "
  106. ifneq ($(filter manual,${BUILD_STYLE}),)
  107. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  108. else ifeq ($(strip ${BUILD_STYLE}),)
  109. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  110. ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
  111. else
  112. @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
  113. @exit 1
  114. endif
  115. @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
  116. touch $@
  117. pre-install:
  118. do-install:
  119. post-install:
  120. spkg-install: ${ALL_POSTINST}
  121. ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
  122. -rm -f ${_ALL_CONTROLS}
  123. @mkdir -p '${STAGING_PKG_DIR}' ${WRKINST} '${STAGING_DIR}/scripts'
  124. @${MAKE} ${_ALL_CONTROLS} $(MAKE_TRACE)
  125. @env ${MAKE_ENV} ${MAKE} pre-install $(MAKE_TRACE)
  126. ifneq ($(filter manual,${INSTALL_STYLE}),)
  127. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  128. else ifeq ($(strip ${INSTALL_STYLE}),)
  129. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  130. DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE)
  131. ifeq (,$(filter libonly,${PKG_OPTS}))
  132. env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  133. endif
  134. else
  135. @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
  136. @exit 1
  137. endif
  138. @for a in ${WRKINST}/usr/bin/*-config*; do \
  139. [[ -e $$a ]] || continue; \
  140. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  141. ${STAGING_DIR}/usr/bin/$$(basename $$a); \
  142. chmod u+x ${STAGING_DIR}/usr/bin/$$(basename $$a); \
  143. [[ "$$(basename $$a)" != "pkg-config" ]] && cp ${STAGING_DIR}/usr/bin/$$(basename $$a) ${STAGING_DIR}/scripts; \
  144. echo "scripts/$$(basename $$a)" \
  145. >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
  146. done
  147. @for a in ${WRKINST}/usr/lib/pkgconfig/*.pc; do \
  148. [[ -e $$a ]] || continue; \
  149. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  150. ${STAGING_DIR}/usr/lib/pkgconfig/$$(basename $$a); \
  151. done
  152. env ${MAKE_ENV} ${MAKE} spkg-install $(MAKE_TRACE)
  153. ifeq (,$(filter noremove,${PKG_OPTS}))
  154. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  155. cd '${STAGING_DIR}'; \
  156. while read fn; do \
  157. rm -f "$$fn"; \
  158. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  159. fi
  160. endif
  161. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  162. @-cd ${WRKINST}; \
  163. if [ "${PKG_NAME}" != "uClibc" -a "${PKG_NAME}" != "eglibc" -a "${PKG_NAME}" != "glibc" -a "${PKG_NAME}" != "libpthread" -a "${PKG_NAME}" != "libstdcxx" -a "${PKG_NAME}" != "libgcc" -a "${PKG_NAME}" != "libthread-db" ];then \
  164. find lib \( -name lib\*.so\* -o -name lib\*.a \) \
  165. -exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
  166. ' fix this!' >&2 \; -quit 2>/dev/null; fi;\
  167. find usr ! -type d 2>/dev/null | \
  168. grep -E -v -e '^usr/lib/pkgconfig' -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' | \
  169. tee '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  170. $(TOOLS_DIR)/cpio -padlmu '${STAGING_DIR}'
  171. @cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$' \
  172. '${STAGING_PKG_DIR}/${PKG_NAME}' | while read fn; do \
  173. chmod u+w $$fn; \
  174. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_TARGET_DIR)/usr/lib,g" $$fn; \
  175. done
  176. ifeq (,$(filter noscripts,${PKG_OPTS}))
  177. @cd '${STAGING_DIR}'; grep 'usr/s*bin/' \
  178. '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  179. while read fn; do \
  180. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  181. [[ $$b = '#!' ]] || continue; \
  182. cp "$$fn" scripts/; \
  183. echo "scripts/$$(basename "$$fn")" \
  184. >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  185. done
  186. endif
  187. -@test -e '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
  188. cat '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' || echo
  189. touch $@
  190. ${_IPKGS_COOKIE}:
  191. @clean=0; \
  192. for f in ${ALL_IPKGS}; do \
  193. [[ -e $$f ]] && clean=1; \
  194. done; \
  195. [[ $$clean = 0 ]] || ${MAKE} clean
  196. exec ${MAKE} package
  197. package: ${ALL_IPKGS}
  198. @cd ${WRKDIR}/fake-${CPU_ARCH} || exit 1; \
  199. y=; sp=; for x in ${ALL_IDIRS}; do \
  200. y="$$y$$sp$${x#$(WRKDIR)/fake-${CPU_ARCH}/}"; \
  201. sp=' '; \
  202. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  203. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  204. while read sum name; do \
  205. inode=$$(ls -i "$$name"); \
  206. echo "$$sum $${inode%% *} $$name"; \
  207. done | sort | while read sum inode name; do \
  208. if [[ $$sum = $$ls ]]; then \
  209. [[ $$li = $$inode ]] && continue; \
  210. case $$x in \
  211. 1) echo 'WARNING: duplicate files found in' \
  212. 'package "${PKG_NAME}"! Fix them.' >&2; \
  213. echo -n "> $$ln "; \
  214. ;; \
  215. 2) echo -n "> $$ln "; \
  216. ;; \
  217. 3) echo -n ' '; \
  218. ;; \
  219. esac; \
  220. echo -n "$$name"; \
  221. x=3; \
  222. else \
  223. case $$x in \
  224. 3) echo; \
  225. x=2; \
  226. ;; \
  227. esac; \
  228. fi; \
  229. ls=$$sum; \
  230. ln=$$name; \
  231. li=$$inode; \
  232. done
  233. touch ${_IPKGS_COOKIE}
  234. clean-targets: clean-dev-generic
  235. clean-dev-generic:
  236. ifeq (,$(filter noremove,${PKG_OPTS}))
  237. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  238. cd '${STAGING_DIR}'; \
  239. while read fn; do \
  240. rm -f "$$fn"; \
  241. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  242. fi
  243. endif
  244. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'