pkg-bottom.mk 6.4 KB

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