pkg-bottom.mk 9.0 KB

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