1
0

pkg-bottom.mk 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. pre-build:
  71. do-build:
  72. post-build:
  73. ${_BUILD_COOKIE}: ${_CONFIGURE_COOKIE}
  74. @env ${MAKE_ENV} ${MAKE} pre-build $(MAKE_TRACE)
  75. @$(CMD_TRACE) "compiling... "
  76. ifneq ($(filter auto,${BUILD_STYLE}),)
  77. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  78. ${MAKEJOBS} ${MAKE_FLAGS} ${ALL_TARGET} $(MAKE_TRACE)
  79. else ifneq ($(filter manual,${BUILD_STYLE}),)
  80. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  81. else ifeq ($(strip ${BUILD_STYLE}),)
  82. env ${MAKE_ENV} ${MAKE} do-build $(MAKE_TRACE)
  83. else
  84. @echo "Invalid BUILD_STYLE '${BUILD_STYLE}'" >&2
  85. @exit 1
  86. endif
  87. @env ${MAKE_ENV} ${MAKE} post-build $(MAKE_TRACE)
  88. touch $@
  89. pre-install:
  90. do-install:
  91. post-install:
  92. ${_FAKE_COOKIE}: ${_BUILD_COOKIE}
  93. -rm -f ${_ALL_CONTROLS}
  94. @mkdir -p '${STAGING_PARENT}/pkg' ${WRKINST} '${STAGING_DIR}/scripts'
  95. @${MAKE} ${_ALL_CONTROLS} $(MAKE_TRACE)
  96. @env ${MAKE_ENV} ${MAKE} pre-install $(MAKE_TRACE)
  97. ifneq ($(filter auto,${INSTALL_STYLE}),)
  98. cd ${WRKBUILD} && env ${MAKE_ENV} ${MAKE} -f ${MAKE_FILE} \
  99. DESTDIR='${WRKINST}' ${FAKE_FLAGS} ${INSTALL_TARGET} $(MAKE_TRACE)
  100. else ifneq ($(filter manual,${INSTALL_STYLE}),)
  101. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  102. else ifeq ($(strip ${INSTALL_STYLE}),)
  103. env ${MAKE_ENV} ${MAKE} do-install $(MAKE_TRACE)
  104. else
  105. @echo "Invalid INSTALL_STYLE '${INSTALL_STYLE}'" >&2
  106. @exit 1
  107. endif
  108. #ifneq ($(filter confprog,${INSTALL_STYLE}),)
  109. @for a in ${WRKINST}/usr/{bin/*-config,lib/pkgconfig/*.pc}; do \
  110. [[ -e $$a ]] || continue; \
  111. $(SED) "s,^prefix=.*,prefix=${STAGING_DIR}/usr," $$a; \
  112. done
  113. #endif
  114. @env ${MAKE_ENV} ${MAKE} post-install $(MAKE_TRACE)
  115. @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
  116. cd '${STAGING_DIR}'; \
  117. while read fn; do \
  118. rm -f "$$fn"; \
  119. done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  120. fi
  121. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'
  122. @cd ${WRKINST}; \
  123. if [ "${PKG_NAME}" != "uClibc" -a "${PKG_NAME}" != "glibc" -a "${PKG_NAME}" != "libpthread" -a "${PKG_NAME}" != "libstdcxx" -a "${PKG_NAME}" != "libthread-db" ];then \
  124. find lib \( -name lib\*.so\* -o -name lib\*.a \) \
  125. -exec echo 'WARNING: ${PKG_NAME} installs files in /lib -' \
  126. ' fix this!' >&2 \; -quit 2>/dev/null; fi;\
  127. find usr ! -type d 2>/dev/null | \
  128. grep -v -e '^usr/share' -e '^usr/man' -e '^usr/info' | \
  129. tee '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
  130. cpio -apdlmu --quiet '${STAGING_DIR}'
  131. @cd '${STAGING_DIR}'; grep 'usr/lib/.*\.la$$' \
  132. '${STAGING_PARENT}/pkg/${PKG_NAME}' | while read fn; do \
  133. chmod u+w $$fn; \
  134. $(SED) "s,\(^libdir='\| \|-L\|^dependency_libs='\)/usr/lib,\1$(STAGING_DIR)/usr/lib,g" $$fn; \
  135. done; grep 'usr/s*bin/' '${STAGING_PARENT}/pkg/${PKG_NAME}' | \
  136. while read fn; do \
  137. b="$$(dd if="$$fn" bs=2 count=1 2>/dev/null)"; \
  138. [[ $$b = '#!' ]] || continue; \
  139. cp "$$fn" scripts/; \
  140. echo "scripts/$$(basename "$$fn")" \
  141. >>'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  142. done
  143. touch $@
  144. ${_IPKGS_COOKIE}:
  145. @clean=0; \
  146. for f in ${ALL_IPKGS}; do \
  147. [[ -e $$f ]] && clean=1; \
  148. done; \
  149. [[ $$clean = 0 ]] || ${MAKE} clean
  150. exec ${MAKE} package
  151. package: ${ALL_IPKGS}
  152. @cd ${WRKDIR}/fake-${CPU_ARCH} || exit 1; \
  153. y=; sp=; for x in ${ALL_IDIRS}; do \
  154. y="$$y$$sp$${x#$(WRKDIR)/fake-${CPU_ARCH}/}"; \
  155. sp=' '; \
  156. done; ls=; ln=; x=1; [[ -z $$y ]] || \
  157. md5sum $$(find $$y -type f) | sed -e "s/*//" | \
  158. while read sum name; do \
  159. inode=$$(ls -i "$$name"); \
  160. echo "$$sum $${inode%% *} $$name"; \
  161. done | sort | while read sum inode name; do \
  162. if [[ $$sum = $$ls ]]; then \
  163. [[ $$li = $$inode ]] && continue; \
  164. case $$x in \
  165. 1) echo 'WARNING: duplicate files found in' \
  166. 'package "${PKG_NAME}"! Fix them.' >&2; \
  167. echo -n "> $$ln "; \
  168. ;; \
  169. 2) echo -n "> $$ln "; \
  170. ;; \
  171. 3) echo -n ' '; \
  172. ;; \
  173. esac; \
  174. echo -n "$$name"; \
  175. x=3; \
  176. else \
  177. case $$x in \
  178. 3) echo; \
  179. x=2; \
  180. ;; \
  181. esac; \
  182. fi; \
  183. ls=$$sum; \
  184. ln=$$name; \
  185. li=$$inode; \
  186. done
  187. touch ${_IPKGS_COOKIE}
  188. clean-targets: clean-dev-generic
  189. clean-dev-generic:
  190. @if test -s '${STAGING_PARENT}/pkg/${PKG_NAME}'; then \
  191. cd '${STAGING_DIR}'; \
  192. while read fn; do \
  193. rm -f "$$fn"; \
  194. done <'${STAGING_PARENT}/pkg/${PKG_NAME}'; \
  195. fi
  196. @rm -f '${STAGING_PARENT}/pkg/${PKG_NAME}'