pkg-bottom.mk 10 KB

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