pkg-bottom.mk 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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* $(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. ifneq ($(filter manual,${CONFIG_STYLE}),)
  44. env ${CONFIGURE_ENV} ${MAKE} do-configure $(MAKE_TRACE)
  45. else ifneq ($(filter cmake,${CONFIG_STYLE}),)
  46. @$(CMD_TRACE) "configuring cmake.. "
  47. sed -e "s#@@TARGET_CC@@#$(TARGET_CC)#" \
  48. -e "s#@@TARGET_CXX@@#$(TARGET_CXX)#" \
  49. -e "s#@@TARGET_CFLAGS@@#$(TARGET_CFLAGS)#" \
  50. -e "s#@@TARGET_CXXFLAGS@@#$(TARGET_CXXFLAGS)#" \
  51. -e "s#@@TARGET_ARCH@@#$(ADK_TARGET_ARCH)#" \
  52. -e "s#@@STAGING_TARGET_DIR@@#$(STAGING_TARGET_DIR)#" \
  53. -e "s#@@STAGING_HOST_DIR@@#$(STAGING_HOST_DIR)#g" \
  54. $(SCRIPT_DIR)/toolchain.cmake.in > $(SCRIPT_DIR)/toolchain.cmake
  55. (cd ${WRKBUILD} && PATH='${HOST_PATH}' \
  56. cmake VERBOSE=1 -Wno-dev -DCMAKE_INSTALL_PREFIX:PATH=/usr \
  57. -DCMAKE_TOOLCHAIN_FILE="$(SCRIPT_DIR)/toolchain.cmake" \
  58. ${CMAKE_FLAGS} ${WRKSRC}) $(MAKE_TRACE)
  59. else ifneq ($(filter minimal,${CONFIG_STYLE}),)
  60. @$(CMD_TRACE) "configuring.. "
  61. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  62. env ${CONFIGURE_ENV} \
  63. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} \
  64. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  65. else ifneq ($(filter basic,${CONFIG_STYLE}),)
  66. @$(CMD_TRACE) "configuring.. "
  67. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  68. env ${CONFIGURE_ENV} \
  69. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
  70. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  71. else ifneq ($(filter perl,${CONFIG_STYLE}),)
  72. @$(CMD_TRACE) "configuring perl module.. "
  73. if [ -f ${WRKBUILD}/Makefile.PL ]; then \
  74. cd ${WRKBUILD}; \
  75. PATH='${HOST_PATH}' \
  76. PERL_MM_USE_DEFAULT=1 \
  77. PERL_AUTOINSTALL=--skipdeps \
  78. $(PERL_ENV) \
  79. perl-host Makefile.PL ${CONFIGURE_ARGS}; \
  80. else \
  81. cd ${WRKBUILD}; \
  82. PATH='${HOST_PATH}' \
  83. $(PERL_ENV) \
  84. perl-host Build.PL; \
  85. fi
  86. else ifeq ($(strip ${CONFIG_STYLE}),)
  87. @$(CMD_TRACE) "configuring.. "
  88. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  89. env ${CONFIGURE_ENV} \
  90. ${BASH} ${WRKSRC}/${CONFIGURE_PROG} ${CONFIGURE_TRIPLE} \
  91. --program-prefix= \
  92. --program-suffix= \
  93. --prefix=/usr \
  94. --bindir=/usr/bin \
  95. --datadir=/usr/share \
  96. --mandir=/usr/share/man \
  97. --libexecdir=/usr/libexec \
  98. --localstatedir=/var \
  99. --sysconfdir=/etc \
  100. --disable-dependency-tracking \
  101. --disable-libtool-lock \
  102. --disable-nls \
  103. ${CONFIGURE_LIB} \
  104. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  105. else
  106. @echo "Invalid CONFIG_STYLE '${CONFIG_STYLE}'" >&2
  107. @exit 1
  108. endif
  109. @${MAKE} post-configure $(MAKE_TRACE)
  110. @touch $@
  111. # do a parallel build if requested && package doesn't force disable it
  112. ifeq (${ADK_MAKE_PARALLEL},y)
  113. ifeq ($(strip ${PKG_NOPARALLEL}),)
  114. MAKE_FLAGS+= -j${ADK_MAKE_JOBS}
  115. endif
  116. endif
  117. pre-build:
  118. do-build:
  119. post-build:
  120. ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
  121. @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
  122. @$(CMD_TRACE) "compiling.. "
  123. ifneq ($(filter manual,${BUILD_STYLE}),)
  124. env ${MAKE_ENV} ${MAKE} ${MAKE_FLAGS} do-build $(MAKE_TRACE)
  125. else ifeq ($(strip ${BUILD_STYLE}),)
  126. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  127. ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
  128. else
  129. @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
  130. @exit 1
  131. endif
  132. @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
  133. touch $@
  134. pre-install:
  135. do-install:
  136. post-install:
  137. spkg-install: ${ALL_POSTINST}
  138. ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
  139. @-rm -f ${_ALL_CONTROLS}
  140. @mkdir -p '${STAGING_PKG_DIR}/stamps' ${WRKINST} '${STAGING_TARGET_DIR}/scripts'
  141. @${MAKE} ${_ALL_CONTROLS} $(MAKE_TRACE)
  142. @env ${MAKE_ENV} ${MAKE} pre-install $(MAKE_TRACE)
  143. ifneq ($(filter manual,${INSTALL_STYLE}),)
  144. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  145. else ifeq ($(strip ${INSTALL_STYLE}),)
  146. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  147. DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE)
  148. env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  149. else
  150. @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
  151. @exit 1
  152. endif
  153. env ${MAKE_ENV} ${MAKE} spkg-install $(MAKE_TRACE)
  154. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}.scripts'
  155. @for a in ${WRKINST}/usr/bin/*-config*; do \
  156. [[ -e $$a ]] || continue; \
  157. sed -e "s,^prefix=.*,prefix=${STAGING_TARGET_DIR}/usr," $$a > \
  158. ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  159. chmod u+x ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a); \
  160. [[ "$$(basename $$a)" != "pkg-config" ]] && cp ${STAGING_TARGET_DIR}/usr/bin/$$(basename $$a) ${STAGING_TARGET_DIR}/scripts; \
  161. echo "scripts/$$(basename $$a)" \
  162. >>'${STAGING_PKG_DIR}/${PKG_NAME}.scripts'; \
  163. done
  164. ifeq (,$(filter noremove,${PKG_OPTS}))
  165. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  166. cd '${STAGING_TARGET_DIR}'; \
  167. while read fn; do \
  168. rm -f "$$fn"; \
  169. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  170. fi
  171. endif
  172. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  173. ifneq (,$(filter dev,${PKG_OPTS}))
  174. @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  175. @test -d ${WRKINST}/usr/include && cd ${WRKINST}/usr/include; \
  176. find . -name \*.h | \
  177. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/include
  178. @mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  179. @test -d ${WRKINST}/usr/lib/pkgconfig && cd ${WRKINST}/usr/lib/pkgconfig; \
  180. find . -name \*.pc | \
  181. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/lib/pkgconfig
  182. @for a in ${WRKINST}/usr/bin/*-config*; do \
  183. [[ -e $$a ]] || continue; \
  184. mkdir -p $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  185. cp $$a $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin; \
  186. chmod 755 $(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/pkg-$(PKG_LIBNAME)-dev/usr/bin/$$(basename $$a); \
  187. done
  188. endif
  189. ifeq (,$(filter nostaging,${PKG_OPTS}))
  190. @-cd ${WRKINST}; \
  191. find usr ! -type d 2>/dev/null | \
  192. grep -E -v -e '^usr/share' -e '^usr/src' -e '^usr/doc' -e '^usr/local' -e '^usr/man' -e '^usr/info' \
  193. -e '^usr/lib/libc.so' -e '^usr/bin/[a-z0-9-]+-config*' -e '^usr/lib/.*\.la$$' \
  194. -e '^/usr/lib/libpthread_nonshared.a' | \
  195. tee '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  196. $(STAGING_HOST_DIR)/usr/bin/cpio -padlmu '${STAGING_TARGET_DIR}'
  197. endif
  198. ifeq (,$(filter noscripts,${PKG_OPTS}))
  199. @cd '${STAGING_TARGET_DIR}'; grep 'usr/s*bin/' \
  200. '${STAGING_PKG_DIR}/${PKG_NAME}' | \
  201. while read fn; do \
  202. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  203. [[ $$b = '#!' ]] || continue; \
  204. cp "$$fn" scripts/; \
  205. echo "scripts/$$(basename "$$fn")" \
  206. >>'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  207. done
  208. endif
  209. -@test -e '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' && \
  210. cat '${STAGING_PKG_DIR}/${PKG_NAME}.scripts' >> '${STAGING_PKG_DIR}/${PKG_NAME}' || :
  211. touch $@
  212. ${_IPKGS_COOKIE}:
  213. exec ${MAKE} package
  214. package: ${ALL_IPKGS}
  215. ifneq ($(DEVELOPER),)
  216. @cd ${WRKDIR}/fake-${ADK_TARGET_CPU_ARCH} || exit 1; \
  217. y=; sp=; for x in ${ALL_IDIRS}; do \
  218. y="$$y$$sp$${x#$(WRKDIR)/fake-${ADK_TARGET_CPU_ARCH}/}"; \
  219. sp=' '; \
  220. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  221. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  222. while read sum name; do \
  223. inode=$$(ls -i "$$name"); \
  224. echo "$$sum $${inode%% *} $$name"; \
  225. done | sort | while read sum inode name; do \
  226. if [[ $$sum = $$ls ]]; then \
  227. [[ $$li = $$inode ]] && continue; \
  228. case $$x in \
  229. 1) echo 'WARNING: duplicate files found in' \
  230. 'package "${PKG_NAME}"! Fix them.' >&2; \
  231. echo -n "> $$ln "; \
  232. ;; \
  233. 2) echo -n "> $$ln "; \
  234. ;; \
  235. 3) echo -n ' '; \
  236. ;; \
  237. esac; \
  238. echo -n "$$name"; \
  239. x=3; \
  240. else \
  241. case $$x in \
  242. 3) echo; \
  243. x=2; \
  244. ;; \
  245. esac; \
  246. fi; \
  247. ls=$$sum; \
  248. ln=$$name; \
  249. li=$$inode; \
  250. done
  251. endif
  252. touch ${_IPKGS_COOKIE}
  253. clean-targets: clean-dev-generic
  254. clean-dev-generic:
  255. ifeq (,$(filter noremove,${PKG_OPTS}))
  256. @if test -s '${STAGING_PKG_DIR}/${PKG_NAME}'; then \
  257. cd '${STAGING_TARGET_DIR}'; \
  258. while read fn; do \
  259. rm -f "$$fn"; \
  260. done <'${STAGING_PKG_DIR}/${PKG_NAME}'; \
  261. fi
  262. endif
  263. @rm -f '${STAGING_PKG_DIR}/${PKG_NAME}'
  264. ifneq (,$(filter autoreconf,${AUTOTOOL_STYLE}))
  265. DIFF_IGNOREFILES?= configure missing depcomp install-sh INSTALL \
  266. aclocal.m4 config.h.in Makefile.in */Makefile.in \
  267. config.sub config.guess */config.sub */config.guess
  268. else
  269. DIFF_IGNOREFILES?= config.sub config.guess */config.sub */config.guess
  270. endif