pkg-bottom.mk 9.1 KB

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