1
0

pkg-bottom.mk 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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} \
  73. --build=${GNU_HOST_NAME} \
  74. --host=${GNU_TARGET_NAME} \
  75. --target=${GNU_TARGET_NAME} \
  76. --program-prefix= \
  77. --program-suffix= \
  78. --prefix=/usr \
  79. --bindir=/usr/bin \
  80. --datadir=/usr/share \
  81. --mandir=/usr/share/man \
  82. --libexecdir=/usr/libexec \
  83. --localstatedir=/var \
  84. --sysconfdir=/etc \
  85. --disable-nls \
  86. --enable-shared \
  87. --enable-static \
  88. --disable-dependency-tracking \
  89. --disable-libtool-lock \
  90. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  91. else
  92. @echo "Invalid CONFIG_STYLE '${CONFIG_STYLE}'" >&2
  93. @exit 1
  94. endif
  95. @${MAKE} post-configure $(MAKE_TRACE)
  96. touch $@
  97. # do a parallel build if requested && package doesn't force disable it
  98. ifeq (${ADK_MAKE_PARALLEL},y)
  99. ifeq ($(strip ${PKG_NOPARALLEL}),)
  100. MAKE_FLAGS+= -j${ADK_MAKE_JOBS}
  101. endif
  102. endif
  103. pre-build:
  104. do-build:
  105. post-build:
  106. ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
  107. @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
  108. @$(CMD_TRACE) "compiling... "
  109. ifneq ($(filter manual,${BUILD_STYLE}),)
  110. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  111. else ifeq ($(strip ${BUILD_STYLE}),)
  112. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  113. ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
  114. else
  115. @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
  116. @exit 1
  117. endif
  118. @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
  119. touch $@
  120. pre-install:
  121. do-install:
  122. post-install:
  123. spkg-install: ${ALL_POSTINST}
  124. ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
  125. -rm -f ${_ALL_CONTROLS}
  126. @mkdir -p '${STAGING_PKG_DIR}' ${WRKINST} '${STAGING_DIR}/scripts'
  127. @${MAKE} ${_ALL_CONTROLS} $(MAKE_TRACE)
  128. @env ${MAKE_ENV} ${MAKE} pre-install $(MAKE_TRACE)
  129. ifneq ($(filter manual,${INSTALL_STYLE}),)
  130. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  131. else ifeq ($(strip ${INSTALL_STYLE}),)
  132. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  133. DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE)
  134. ifeq (,$(filter libonly,${PKG_OPTS}))
  135. env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  136. endif
  137. else
  138. @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
  139. @exit 1
  140. endif
  141. @for a in ${WRKINST}/usr/bin/*-config; do \
  142. [[ -e $$a ]] || continue; \
  143. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  144. ${STAGING_DIR}/usr/bin/$$(basename $$a); \
  145. chmod u+x ${STAGING_DIR}/usr/bin/$$(basename $$a); \
  146. [[ "$$(basename $$a)" != "pkg-config" ]] && cp ${STAGING_DIR}/usr/bin/$$(basename $$a) ${STAGING_DIR}/scripts; \
  147. echo "scripts/$$(basename $$a)" \
  148. >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
  149. done
  150. @for a in ${WRKINST}/usr/lib/pkgconfig/*.pc; do \
  151. [[ -e $$a ]] || continue; \
  152. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  153. ${STAGING_DIR}/usr/lib/pkgconfig/$$(basename $$a); \
  154. done
  155. env ${MAKE_ENV} ${MAKE} spkg-install $(MAKE_TRACE)
  156. ifeq (,$(filter noremove,${PKG_OPTS}))
  157. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  158. cd '${STAGING_DIR}'; \
  159. while read fn; do \
  160. rm -f "$$fn"; \
  161. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  162. fi
  163. endif
  164. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  165. @-cd ${WRKINST}; \
  166. 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 \
  167. find lib \( -name lib\*.so\* -o -name lib\*.a \) \
  168. -exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
  169. ' fix this!' >&2 \; -quit 2>/dev/null; fi;\
  170. find usr ! -type d 2>/dev/null | \
  171. grep -E -v -e '^usr/share' -e '^usr/man' -e '^usr/info' -e '^usr/lib/libc.so' -e '^usr/lib/pkgconfig' -e '^usr/bin/[a-z0-9-]+-config' | \
  172. tee '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  173. $(TOOLS_DIR)/cpio -padlmu '${STAGING_DIR}'
  174. @cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$' \
  175. '${STAGING_PKG_DIR}/${PKG_NAME}' | while read fn; do \
  176. chmod u+w $$fn; \
  177. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_TARGET_DIR)/usr/lib,g" $$fn; \
  178. done
  179. ifeq (,$(filter noscripts,${PKG_OPTS}))
  180. @cd '${STAGING_DIR}'; grep 'usr/s*bin/' \
  181. '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  182. while read fn; do \
  183. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  184. [[ $$b = '#!' ]] || continue; \
  185. cp "$$fn" scripts/; \
  186. echo "scripts/$$(basename "$$fn")" \
  187. >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  188. done
  189. endif
  190. -@test -e '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
  191. cat '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' || echo
  192. touch $@
  193. ${_IPKGS_COOKIE}:
  194. @clean=0; \
  195. for f in ${ALL_IPKGS}; do \
  196. [[ -e $$f ]] && clean=1; \
  197. done; \
  198. [[ $$clean = 0 ]] || ${MAKE} clean
  199. exec ${MAKE} package
  200. package: ${ALL_IPKGS}
  201. @cd ${WRKDIR}/fake-${CPU_ARCH} || exit 1; \
  202. y=; sp=; for x in ${ALL_IDIRS}; do \
  203. y="$$y$$sp$${x#$(WRKDIR)/fake-${CPU_ARCH}/}"; \
  204. sp=' '; \
  205. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  206. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  207. while read sum name; do \
  208. inode=$$(ls -i "$$name"); \
  209. echo "$$sum $${inode%% *} $$name"; \
  210. done | sort | while read sum inode name; do \
  211. if [[ $$sum = $$ls ]]; then \
  212. [[ $$li = $$inode ]] && continue; \
  213. case $$x in \
  214. 1) echo 'WARNING: duplicate files found in' \
  215. 'package "${PKG_NAME}"! Fix them.' >&2; \
  216. echo -n "> $$ln "; \
  217. ;; \
  218. 2) echo -n "> $$ln "; \
  219. ;; \
  220. 3) echo -n ' '; \
  221. ;; \
  222. esac; \
  223. echo -n "$$name"; \
  224. x=3; \
  225. else \
  226. case $$x in \
  227. 3) echo; \
  228. x=2; \
  229. ;; \
  230. esac; \
  231. fi; \
  232. ls=$$sum; \
  233. ln=$$name; \
  234. li=$$inode; \
  235. done
  236. touch ${_IPKGS_COOKIE}
  237. clean-targets: clean-dev-generic
  238. clean-dev-generic:
  239. ifeq (,$(filter noremove,${PKG_OPTS}))
  240. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  241. cd '${STAGING_DIR}'; \
  242. while read fn; do \
  243. rm -f "$$fn"; \
  244. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  245. fi
  246. endif
  247. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'