pkg-bottom.mk 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  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 (${PKG_BUILD_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. @env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  119. ifneq ($(strip ${PKG_OPTS}),noremove)
  120. if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
  121. cd '${STAGING_DIR}'; \
  122. while read fn; do \
  123. rm -f "$$fn"; \
  124. done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  125. fi
  126. endif
  127. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'
  128. @cd ${WRKINST}; \
  129. 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 \
  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. echo "calling from pkg-bottom.mk"
  150. touch $@
  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-targets: clean-dev-generic
  196. clean-dev-generic:
  197. ifneq ($(strip ${PKG_OPTS}),noremove)
  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. endif
  205. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'