pkg-bottom.mk 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  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 ,${AUTOTOOL_STYLE}))
  19. cd ${WRKSRC}; env ${AUTOTOOL_ENV} $(BASH) bootstrap $(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 -vif $(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. 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 ${WRKSRC}; \
  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 ${WRKSRC}; \
  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. --disable-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}/stamps' ${WRKINST} '${STAGING_TARGET_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. env ${MAKE_ENV} ${MAKE} spkg-install $(MAKE_TRACE)
  139. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}.scripts'
  140. @for a in ${WRKINST}/usr/bin/*-config*; do \
  141. [[ -e $$a ]] || continue; \
  142. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  143. ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  144. chmod u+x ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  145. [[ "$$(basename $$a)" != "pkg-config" ]] && cp ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a) ${STAGING_TARGET_DIR}/scripts; \
  146. echo "scripts/$$(basename $$a)" \
  147. >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
  148. done
  149. @for a in ${WRKINST}/usr/lib/pkgconfig/*.pc; do \
  150. [[ -e $$a ]] || continue; \
  151. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," \
  152. -e "s,^prefix = .*,prefix = ${STAGING_TARGET_DIR}/usr," $$a > \
  153. ${STAGING_TARGET_DIR}/usr/lib/pkgconfig/$$(basename $$a); \
  154. done
  155. ifeq (,$(filter noremove,${PKG_OPTS}))
  156. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  157. cd '${STAGING_TARGET_DIR}'; \
  158. while read fn; do \
  159. rm -f "$$fn"; \
  160. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  161. fi
  162. endif
  163. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  164. ifneq (,$(filter dev,${PKG_OPTS}))
  165. @mkdir -p $(WRKDIR)/fake-${CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  166. @test -d ${WRKINST}/usr/include && cd ${WRKINST}/usr/include; \
  167. find . -name \*.h | \
  168. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  169. @mkdir -p $(WRKDIR)/fake-${CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  170. @test -d ${WRKINST}/usr/lib/pkgconfig && cd ${WRKINST}/usr/lib/pkgconfig; \
  171. find . -name \*.pc | \
  172. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  173. @for a in ${WRKINST}/usr/bin/*-config*; do \
  174. [[ -e $$a ]] || continue; \
  175. mkdir -p $(WRKDIR)/fake-${CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  176. cp $$a $(WRKDIR)/fake-${CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  177. chmod 755 $(WRKDIR)/fake-${CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin/$$(basename $$a); \
  178. done
  179. endif
  180. @-cd ${WRKINST}; \
  181. if [ "${PKG_NAME}" != "uClibc" -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" -a "${PKG_NAME}" != "pam" ];then \
  182. find lib \( -name lib\*.so\* -o -name lib\*.a \) \
  183. -exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
  184. ' fix this!' >&2 \; -quit 2>/dev/null; fi;\
  185. find usr ! -type d 2>/dev/null | \
  186. 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' | \
  187. tee '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  188. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu '${STAGING_TARGET_DIR}'
  189. @cd '${STAGING_TARGET_DIR}'; grep 'usr/lib/.*\.la$$' \
  190. '${STAGING_PKG_DIR}/${PKG_NAME}' | while read fn; do \
  191. chmod u+w $$fn; \
  192. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_TARGET_DIR)/usr/lib,g" $$fn; \
  193. done
  194. ifeq (,$(filter noscripts,${PKG_OPTS}))
  195. @cd '${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
  196. '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  197. while read fn; do \
  198. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  199. [[ $$b = '#!' ]] || continue; \
  200. cp "$$fn" scripts/; \
  201. echo "scripts/$$(basename "$$fn")" \
  202. >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  203. done
  204. endif
  205. -@test -e '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
  206. cat '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' || echo
  207. touch $@
  208. ${_IPKGS_COOKIE}:
  209. exec ${MAKE} package
  210. package: ${ALL_IPKGS}
  211. ifneq ($(DEVELOPER),)
  212. @cd ${WRKDIR}/fake-${CPU_ARCH} || exit 1; \
  213. y=; sp=; for x in ${ALL_IDIRS}; do \
  214. y="$$y$$sp$${x#$(WRKDIR)/fake-${CPU_ARCH}/}"; \
  215. sp=' '; \
  216. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  217. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  218. while read sum name; do \
  219. inode=$$(ls -i "$$name"); \
  220. echo "$$sum $${inode%% *} $$name"; \
  221. done | sort | while read sum inode name; do \
  222. if [[ $$sum = $$ls ]]; then \
  223. [[ $$li = $$inode ]] && continue; \
  224. case $$x in \
  225. 1) echo 'WARNING: duplicate files found in' \
  226. 'package "${PKG_NAME}"! Fix them.' >&2; \
  227. echo -n "> $$ln "; \
  228. ;; \
  229. 2) echo -n "> $$ln "; \
  230. ;; \
  231. 3) echo -n ' '; \
  232. ;; \
  233. esac; \
  234. echo -n "$$name"; \
  235. x=3; \
  236. else \
  237. case $$x in \
  238. 3) echo; \
  239. x=2; \
  240. ;; \
  241. esac; \
  242. fi; \
  243. ls=$$sum; \
  244. ln=$$name; \
  245. li=$$inode; \
  246. done
  247. endif
  248. touch ${_IPKGS_COOKIE}
  249. clean-targets: clean-dev-generic
  250. clean-dev-generic:
  251. ifeq (,$(filter noremove,${PKG_OPTS}))
  252. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  253. cd '${STAGING_TARGET_DIR}'; \
  254. while read fn; do \
  255. rm -f "$$fn"; \
  256. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  257. fi
  258. endif
  259. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'