pkg-bottom.mk 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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 "manual" -> define a do-foo: target in the Makefile
  9. # * if you have a style -> define a pre-foo: and post-foo: if they
  10. # are required, but the do-foo: magic is done here
  11. # * we want to use styles (configure:gnu, build/install:auto), for
  12. # making the Makefiles of the packages more clear
  13. pre-configure:
  14. do-configure:
  15. post-configure:
  16. ${_CONFIGURE_COOKIE}: ${_PATCH_COOKIE}
  17. mkdir -p ${WRKBUILD}
  18. @${MAKE} pre-configure $(MAKE_TRACE)
  19. ifneq ($(filter autogen,${CONFIGURE_STYLE}),)
  20. cd ${WRKBUILD}; \
  21. ./autogen.sh $(MAKE_TRACE)
  22. endif
  23. ifneq ($(filter autotool,${CONFIGURE_STYLE}),)
  24. cd ${WRKBUILD}; \
  25. env AUTOCONF_VERSION=2.62 \
  26. AUTOMAKE_VERSION=1.9 \
  27. autoreconf -vif $(MAKE_TRACE)
  28. endif
  29. ifneq ($(filter autoconf,${CONFIGURE_STYLE}),)
  30. cd ${WRKBUILD}; \
  31. env AUTOCONF_VERSION=2.62 autoconf $(MAKE_TRACE)
  32. endif
  33. ifneq ($(filter gnu,${CONFIGURE_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 \
  51. --build=${GNU_HOST_NAME} \
  52. --host=${GNU_TARGET_NAME} \
  53. --target=${GNU_TARGET_NAME} \
  54. --program-prefix= \
  55. --program-suffix= \
  56. --prefix=/usr \
  57. --datadir=/usr/share \
  58. --mandir=/usr/share/man \
  59. --libexecdir=/usr/sbin \
  60. --localstatedir=/var \
  61. --sysconfdir=/etc \
  62. --disable-nls \
  63. --enable-shared \
  64. --enable-static \
  65. --disable-dependency-tracking \
  66. --disable-libtool-lock \
  67. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  68. else ifeq ($(filter-out manual,${CONFIGURE_STYLE}),)
  69. env ${CONFIGURE_ENV} ${MAKE} do-configure $(MAKE_TRACE)
  70. else
  71. @echo "Invalid CONFIGURE_STYLE '${CONFIGURE_STYLE}'" >&2
  72. @exit 1
  73. endif
  74. @${MAKE} post-configure $(MAKE_TRACE)
  75. touch $@
  76. # do a parallel build if requested && package doesn't force disable it
  77. ifeq (${ADK_MAKE_PARALLEL},y)
  78. ifeq ($(strip ${PKG_NOPARALLEL}),)
  79. MAKE_FLAGS+= -j${ADK_MAKE_JOBS}
  80. endif
  81. endif
  82. pre-build:
  83. do-build:
  84. post-build:
  85. ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
  86. @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
  87. @$(CMD_TRACE) "compiling... "
  88. ifneq ($(filter auto,${BUILD_STYLE}),)
  89. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  90. ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
  91. else ifneq ($(filter manual,${BUILD_STYLE}),)
  92. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  93. else ifeq ($(strip ${BUILD_STYLE}),)
  94. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  95. else
  96. @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
  97. @exit 1
  98. endif
  99. @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
  100. touch $@
  101. pre-install:
  102. do-install:
  103. post-install:
  104. ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
  105. -rm -f ${_ALL_CONTROLS}
  106. @mkdir -p '${STAGING_PARENT}/pkg' ${WRKINST} '${STAGING_DIR}/scripts'
  107. @${MAKE} ${_ALL_CONTROLS} $(MAKE_TRACE)
  108. @env ${MAKE_ENV} ${MAKE} pre-install $(MAKE_TRACE)
  109. ifneq ($(filter auto,${INSTALL_STYLE}),)
  110. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  111. DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE)
  112. else ifneq ($(filter manual,${INSTALL_STYLE}),)
  113. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  114. else ifeq ($(strip ${INSTALL_STYLE}),)
  115. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  116. else
  117. @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
  118. @exit 1
  119. endif
  120. @for a in ${WRKINST}/usr/{bin/*-config,lib/pkgconfig/*.pc}; do \
  121. [[ -e $$a ]] || continue; \
  122. $(SED) "s,^prefix=.*,prefix=${STAGING_DIR}/usr," $$a; \
  123. done
  124. ifeq (,$(filter libonly,${PKG_OPTS}))
  125. @env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  126. endif
  127. ifeq (,$(filter noremove,${PKG_OPTS}))
  128. @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
  129. cd '${STAGING_DIR}'; \
  130. while read fn; do \
  131. rm -f "$$fn"; \
  132. done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  133. fi
  134. endif
  135. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'
  136. @cd ${WRKINST}; \
  137. if [ "${PKG_NAME}" != "uClibc" -a "${PKG_NAME}" != "eglibc" -a "${PKG_NAME}" != "glibc" -a "${PKG_NAME}" != "libpthread" -a "${PKG_NAME}" != "libstdcxx" -a "${PKG_NAME}" != "libthread-db" ];then \
  138. find lib \( -name lib\*.so\* -o -name lib\*.a \) \
  139. -exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
  140. ' fix this!' >&2 \; -quit 2>/dev/null; fi;\
  141. find usr ! -type d 2>/dev/null | \
  142. grep -v -e '^usr/share' -e '^usr/man' -e '^usr/info' | \
  143. tee '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
  144. cpio -apdlmu '${STAGING_DIR}'
  145. @cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$' \
  146. '${STAGING_PARENT}/pkg/${PKG_NAME}' | while read fn; do \
  147. chmod u+w $$fn; \
  148. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" $$fn; \
  149. done
  150. ifeq (,$(filter noscripts,${PKG_OPTS}))
  151. @cd '${STAGING_DIR}'; grep 'usr/s*bin/' \
  152. '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
  153. while read fn; do \
  154. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  155. [[ $$b = '#!' ]] || continue; \
  156. cp "$$fn" scripts/; \
  157. echo "scripts/$$(basename "$$fn")" \
  158. >>'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  159. done
  160. endif
  161. touch $@
  162. ${_IPKGS_COOKIE}:
  163. @clean=0; \
  164. for f in ${ALL_IPKGS}; do \
  165. [[ -e $$f ]] && clean=1; \
  166. done; \
  167. [[ $$clean = 0 ]] || ${MAKE} clean
  168. exec ${MAKE} package
  169. package: ${ALL_IPKGS}
  170. @cd ${WRKDIR}/fake-${CPU_ARCH} || exit 1; \
  171. y=; sp=; for x in ${ALL_IDIRS}; do \
  172. y="$$y$$sp$${x#$(WRKDIR)/fake-${CPU_ARCH}/}"; \
  173. sp=' '; \
  174. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  175. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  176. while read sum name; do \
  177. inode=$$(ls -i "$$name"); \
  178. echo "$$sum $${inode%% *} $$name"; \
  179. done | sort | while read sum inode name; do \
  180. if [[ $$sum = $$ls ]]; then \
  181. [[ $$li = $$inode ]] && continue; \
  182. case $$x in \
  183. 1) echo 'WARNING: duplicate files found in' \
  184. 'package "${PKG_NAME}"! Fix them.' >&2; \
  185. echo -n "> $$ln "; \
  186. ;; \
  187. 2) echo -n "> $$ln "; \
  188. ;; \
  189. 3) echo -n ' '; \
  190. ;; \
  191. esac; \
  192. echo -n "$$name"; \
  193. x=3; \
  194. else \
  195. case $$x in \
  196. 3) echo; \
  197. x=2; \
  198. ;; \
  199. esac; \
  200. fi; \
  201. ls=$$sum; \
  202. ln=$$name; \
  203. li=$$inode; \
  204. done
  205. touch ${_IPKGS_COOKIE}
  206. clean-targets: clean-dev-generic
  207. clean-dev-generic:
  208. ifeq (,$(filter noremove,${PKG_OPTS}))
  209. @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
  210. cd '${STAGING_DIR}'; \
  211. while read fn; do \
  212. rm -f "$$fn"; \
  213. done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  214. fi
  215. endif
  216. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'