pkg-bottom.mk 8.9 KB

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