pkg-bottom.mk 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  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. ifeq ($(ADK_TARGET_USE_STATIC_LIBS),y)
  15. CONFIGURE_LIB:=--enable-static --disable-shared
  16. else
  17. CONFIGURE_LIB:=--enable-static --enable-shared
  18. endif
  19. pre-configure:
  20. do-configure:
  21. post-configure:
  22. ${_CONFIGURE_COOKIE}: ${_PATCH_COOKIE}
  23. ifneq (,$(filter bootstrap,${AUTOTOOL_STYLE}))
  24. @$(CMD_TRACE) "autotool configuring... "
  25. @cd ${WRKSRC}; env ${AUTOTOOL_ENV} $(BASH) bootstrap.sh $(MAKE_TRACE)
  26. endif
  27. ifneq (,$(filter autogen,${AUTOTOOL_STYLE}))
  28. @$(CMD_TRACE) "autotool configuring... "
  29. @cd ${WRKSRC}; env ${AUTOTOOL_ENV} $(BASH) autogen.sh $(MAKE_TRACE)
  30. endif
  31. ifneq (,$(filter autoconf,${AUTOTOOL_STYLE}))
  32. @$(CMD_TRACE) "autotool configuring... "
  33. @cd ${WRKSRC}; env ${AUTOTOOL_ENV} autoconf $(MAKE_TRACE)
  34. endif
  35. ifneq (,$(filter autoreconf,${AUTOTOOL_STYLE}))
  36. @$(CMD_TRACE) "autotool configuring... "
  37. @cd ${WRKSRC}; env ${AUTOTOOL_ENV} autoreconf -vif $(MAKE_TRACE)
  38. @rm -rf ${WRKSRC}/autom4te.cache
  39. @touch ${WRKDIR}/.autoreconf_done
  40. endif
  41. mkdir -p ${WRKBUILD}
  42. @${MAKE} pre-configure $(MAKE_TRACE)
  43. @cd ${WRKSRC}; \
  44. for i in $$(find . -name config.sub);do \
  45. if [ -f $$i ]; then \
  46. ${CP} ${SCRIPT_DIR}/config.sub $$i; \
  47. fi; \
  48. done; \
  49. for i in $$(find . -name config.guess);do \
  50. if [ -f $$i ]; then \
  51. ${CP} ${SCRIPT_DIR}/config.guess $$i; \
  52. fi; \
  53. done;
  54. ifneq ($(filter manual,${CONFIG_STYLE}),)
  55. env ${CONFIGURE_ENV} ${MAKE} do-configure $(MAKE_TRACE)
  56. else ifneq ($(filter minimal,${CONFIG_STYLE}),)
  57. @$(CMD_TRACE) "configuring... "
  58. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  59. env ${CONFIGURE_ENV} \
  60. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} \
  61. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  62. else ifneq ($(filter perl,${CONFIG_STYLE}),)
  63. @$(CMD_TRACE) "configuring perl module... "
  64. cd ${WRKBUILD}; \
  65. PATH='${HOST_PATH}' \
  66. PERL_MM_USE_DEFAULT=1 \
  67. PERL_AUTOINSTALL=--skipdeps \
  68. perl Makefile.PL $(PERL_ENV)
  69. else ifeq ($(strip ${CONFIG_STYLE}),)
  70. @$(CMD_TRACE) "configuring... "
  71. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  72. env ${CONFIGURE_ENV} \
  73. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
  74. --program-prefix= \
  75. --program-suffix= \
  76. --prefix=/usr \
  77. --bindir=/usr/bin \
  78. --datadir=/usr/share \
  79. --mandir=/usr/share/man \
  80. --libexecdir=/usr/libexec \
  81. --localstatedir=/var \
  82. --sysconfdir=/etc \
  83. --disable-dependency-tracking \
  84. --disable-libtool-lock \
  85. --disable-nls \
  86. ${CONFIGURE_LIB} \
  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. env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  132. else
  133. @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
  134. @exit 1
  135. endif
  136. env ${MAKE_ENV} ${MAKE} spkg-install $(MAKE_TRACE)
  137. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}.scripts'
  138. @for a in ${WRKINST}/usr/bin/*-config*; do \
  139. [[ -e $$a ]] || continue; \
  140. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  141. ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  142. chmod u+x ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  143. [[ "$$(basename $$a)" != "pkg-config" ]] && cp ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a) ${STAGING_TARGET_DIR}/scripts; \
  144. echo "scripts/$$(basename $$a)" \
  145. >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
  146. done
  147. ifeq (,$(filter noremove,${PKG_OPTS}))
  148. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  149. cd '${STAGING_TARGET_DIR}'; \
  150. while read fn; do \
  151. rm -f "$$fn"; \
  152. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  153. fi
  154. endif
  155. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  156. ifneq (,$(filter dev,${PKG_OPTS}))
  157. @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  158. @test -d ${WRKINST}/usr/include && cd ${WRKINST}/usr/include; \
  159. find . -name \*.h | \
  160. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  161. @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  162. @test -d ${WRKINST}/usr/lib/pkgconfig && cd ${WRKINST}/usr/lib/pkgconfig; \
  163. find . -name \*.pc | \
  164. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  165. @for a in ${WRKINST}/usr/bin/*-config*; do \
  166. [[ -e $$a ]] || continue; \
  167. mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  168. cp $$a $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  169. chmod 755 $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin/$$(basename $$a); \
  170. done
  171. endif
  172. ifeq (,$(filter nostaging,${PKG_OPTS}))
  173. @-cd ${WRKINST}; \
  174. find usr ! -type d 2>/dev/null | \
  175. grep -E -v -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' | \
  176. tee '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  177. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu '${STAGING_TARGET_DIR}'
  178. @cd '${STAGING_TARGET_DIR}'; grep 'usr/lib/.*\.la$$' \
  179. '${STAGING_PKG_DIR}/${PKG_NAME}' | while read fn; do \
  180. chmod u+w $$fn; \
  181. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_TARGET_DIR)/usr/lib,g" $$fn; \
  182. done
  183. endif
  184. ifeq (,$(filter noscripts,${PKG_OPTS}))
  185. @cd '${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
  186. '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  187. while read fn; do \
  188. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  189. [[ $$b = '#!' ]] || continue; \
  190. cp "$$fn" scripts/; \
  191. echo "scripts/$$(basename "$$fn")" \
  192. >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  193. done
  194. endif
  195. -@test -e '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
  196. cat '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' || :
  197. touch $@
  198. ${_IPKGS_COOKIE}:
  199. exec ${MAKE} package
  200. package: ${ALL_IPKGS}
  201. ifneq ($(DEVELOPER),)
  202. @cd ${WRKDIR}/fake-${ADK_TARGET_CPU_ARCH} || exit 1; \
  203. y=; sp=; for x in ${ALL_IDIRS}; do \
  204. y="$$y$$sp$${x#$(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/}"; \
  205. sp=' '; \
  206. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  207. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  208. while read sum name; do \
  209. inode=$$(ls -i "$$name"); \
  210. echo "$$sum $${inode%% *} $$name"; \
  211. done | sort | while read sum inode name; do \
  212. if [[ $$sum = $$ls ]]; then \
  213. [[ $$li = $$inode ]] && continue; \
  214. case $$x in \
  215. 1) echo 'WARNING: duplicate files found in' \
  216. 'package "${PKG_NAME}"! Fix them.' >&2; \
  217. echo -n "> $$ln "; \
  218. ;; \
  219. 2) echo -n "> $$ln "; \
  220. ;; \
  221. 3) echo -n ' '; \
  222. ;; \
  223. esac; \
  224. echo -n "$$name"; \
  225. x=3; \
  226. else \
  227. case $$x in \
  228. 3) echo; \
  229. x=2; \
  230. ;; \
  231. esac; \
  232. fi; \
  233. ls=$$sum; \
  234. ln=$$name; \
  235. li=$$inode; \
  236. done
  237. endif
  238. touch ${_IPKGS_COOKIE}
  239. clean-targets: clean-dev-generic
  240. clean-dev-generic:
  241. ifeq (,$(filter noremove,${PKG_OPTS}))
  242. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  243. cd '${STAGING_TARGET_DIR}'; \
  244. while read fn; do \
  245. rm -f "$$fn"; \
  246. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  247. fi
  248. endif
  249. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  250. ifneq (,$(filter autoreconf,${AUTOTOOL_STYLE}))
  251. DIFF_IGNOREFILES?= configure missing depcomp install-sh INSTALL \
  252. aclocal.m4 config.h.in Makefile.in */Makefile.in \
  253. config.sub config.guess */config.sub */config.guess
  254. else
  255. DIFF_IGNOREFILES?= config.sub config.guess */config.sub */config.guess
  256. endif