1
0

pkg-bottom.mk 9.9 KB

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