pkg-bottom.mk 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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 autotool,${CONFIGURE_STYLE}),)
  20. cd ${WRKBUILD}; \
  21. autoreconf -vif $(MAKE_TRACE)
  22. endif
  23. ifneq ($(filter autoconf,${CONFIGURE_STYLE}),)
  24. cd ${WRKBUILD}; \
  25. autoconf $(MAKE_TRACE)
  26. endif
  27. ifneq ($(filter gnu,${CONFIGURE_STYLE}),)
  28. @$(CMD_TRACE) "configuring... "
  29. @cd ${WRKBUILD}; \
  30. for i in $$(find . -name config.sub);do \
  31. if [ -f $$i ]; then \
  32. ${CP} $$i $$i.bak; \
  33. ${CP} ${SCRIPT_DIR}/config.sub $$i; \
  34. fi; \
  35. done; \
  36. for i in $$(find . -name config.guess);do \
  37. if [ -f $$i ]; then \
  38. ${CP} $$i $$i.bak; \
  39. ${CP} ${SCRIPT_DIR}/config.guess $$i; \
  40. fi; \
  41. done;
  42. cd ${WRKBUILD}; rm -f config.{cache,status}; \
  43. env ${CONFIGURE_ENV} \
  44. ${BASH} ${WRKSRC}/configure \
  45. --build=${GNU_HOST_NAME} \
  46. --host=${GNU_TARGET_NAME} \
  47. --target=${GNU_TARGET_NAME} \
  48. --program-prefix= \
  49. --program-suffix= \
  50. --prefix=/usr \
  51. --datadir=/usr/share \
  52. --mandir=/usr/share/man \
  53. --libexecdir=/usr/sbin \
  54. --localstatedir=/var \
  55. --sysconfdir=/etc \
  56. --disable-nls \
  57. --enable-shared \
  58. --enable-static \
  59. --disable-dependency-tracking \
  60. --disable-libtool-lock \
  61. ${CONFIGURE_ARGS} $(MAKE_TRACE)
  62. else ifeq ($(filter-out manual,${CONFIGURE_STYLE}),)
  63. env ${CONFIGURE_ENV} ${MAKE} do-configure $(MAKE_TRACE)
  64. else
  65. @echo "Invalid CONFIGURE_STYLE '${CONFIGURE_STYLE}'" >&2
  66. @exit 1
  67. endif
  68. @${MAKE} post-configure $(MAKE_TRACE)
  69. touch $@
  70. # do a parallel build if requested && package doesn't force disable it
  71. ifeq (${ADK_MAKE_PARALLEL},y)
  72. ifeq ($(strip ${PKG_NOPARALLEL}),)
  73. MAKE_FLAGS+= -j${ADK_MAKE_JOBS}
  74. endif
  75. endif
  76. pre-build:
  77. do-build:
  78. post-build:
  79. ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
  80. @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
  81. @$(CMD_TRACE) "compiling... "
  82. ifneq ($(filter auto,${BUILD_STYLE}),)
  83. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  84. ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
  85. else ifneq ($(filter manual,${BUILD_STYLE}),)
  86. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  87. else ifeq ($(strip ${BUILD_STYLE}),)
  88. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  89. else
  90. @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
  91. @exit 1
  92. endif
  93. @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
  94. touch $@
  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. @for a in ${WRKINST}/usr/{bin/*-config,lib/pkgconfig/*.pc}; do \
  115. [[ -e $$a ]] || continue; \
  116. $(SED) "s,^prefix=.*,prefix=${STAGING_DIR}/usr," $$a; \
  117. done
  118. ifeq (,$(filter libonly,${PKG_OPTS}))
  119. @env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  120. endif
  121. ifeq (,$(filter noremove,${PKG_OPTS}))
  122. @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
  123. cd '${STAGING_DIR}'; \
  124. while read fn; do \
  125. rm -f "$$fn"; \
  126. done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  127. fi
  128. endif
  129. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'
  130. @cd ${WRKINST}; \
  131. 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 \
  132. find lib \( -name lib\*.so\* -o -name lib\*.a \) \
  133. -exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
  134. ' fix this!' >&2 \; -quit 2>/dev/null; fi;\
  135. find usr ! -type d 2>/dev/null | \
  136. grep -v -e '^usr/share' -e '^usr/man' -e '^usr/info' | \
  137. tee '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
  138. cpio -apdlmu --quiet '${STAGING_DIR}'
  139. @cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$' \
  140. '${STAGING_PARENT}/pkg/${PKG_NAME}' | while read fn; do \
  141. chmod u+w $$fn; \
  142. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" $$fn; \
  143. done
  144. ifeq (,$(filter noscripts,${PKG_OPTS}))
  145. @cd '${STAGING_DIR}'; grep 'usr/s*bin/' \
  146. '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
  147. while read fn; do \
  148. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  149. [[ $$b = '#!' ]] || continue; \
  150. cp "$$fn" scripts/; \
  151. echo "scripts/$$(basename "$$fn")" \
  152. >>'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  153. done
  154. endif
  155. touch $@
  156. ${_IPKGS_COOKIE}:
  157. @clean=0; \
  158. for f in ${ALL_IPKGS}; do \
  159. [[ -e $$f ]] && clean=1; \
  160. done; \
  161. [[ $$clean = 0 ]] || ${MAKE} clean
  162. exec ${MAKE} package
  163. package: ${ALL_IPKGS}
  164. @cd ${WRKDIR}/fake-${CPU_ARCH} || exit 1; \
  165. y=; sp=; for x in ${ALL_IDIRS}; do \
  166. y="$$y$$sp$${x#$(WRKDIR)/fake-${CPU_ARCH}/}"; \
  167. sp=' '; \
  168. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  169. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  170. while read sum name; do \
  171. inode=$$(ls -i "$$name"); \
  172. echo "$$sum $${inode%% *} $$name"; \
  173. done | sort | while read sum inode name; do \
  174. if [[ $$sum = $$ls ]]; then \
  175. [[ $$li = $$inode ]] && continue; \
  176. case $$x in \
  177. 1) echo 'WARNING: duplicate files found in' \
  178. 'package "${PKG_NAME}"! Fix them.' >&2; \
  179. echo -n "> $$ln "; \
  180. ;; \
  181. 2) echo -n "> $$ln "; \
  182. ;; \
  183. 3) echo -n ' '; \
  184. ;; \
  185. esac; \
  186. echo -n "$$name"; \
  187. x=3; \
  188. else \
  189. case $$x in \
  190. 3) echo; \
  191. x=2; \
  192. ;; \
  193. esac; \
  194. fi; \
  195. ls=$$sum; \
  196. ln=$$name; \
  197. li=$$inode; \
  198. done
  199. touch ${_IPKGS_COOKIE}
  200. clean-targets: clean-dev-generic
  201. clean-dev-generic:
  202. ifeq (,$(filter noremove,${PKG_OPTS}))
  203. @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
  204. cd '${STAGING_DIR}'; \
  205. while read fn; do \
  206. rm -f "$$fn"; \
  207. done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  208. fi
  209. endif
  210. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'