Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. # $OpenBSD: Makefile,v 1.44 2017/06/09 12:03:35 krw Exp $
  2. # snapshots are only available for amd64 and i386, for now
  3. ONLY_FOR_ARCHS = amd64 i386
  4. DPB_PROPERTIES = parallel
  5. COMMENT-main = compiler for Rust Language
  6. COMMENT-doc = html documentation for rustc
  7. V = 1.17.0
  8. REVISION = 0
  9. DISTNAME = rustc-${V}-src
  10. # rustc bootstrap version
  11. RBV-amd64 = 1.17.0-20170426
  12. RBV-i386 = 1.17.0-20170426
  13. RBV = ${RBV-${MACHINE_ARCH}}
  14. # cargo bootstrap version
  15. CBV-amd64 = 0.18.0-20170426
  16. CBV-i386 = 0.18.0-20170426
  17. CBV = ${CBV-${MACHINE_ARCH}}
  18. PKGNAME = rust-${V}
  19. PKGNAME-main = rust-${V}
  20. PKGNAME-doc = rust-doc-${V}
  21. MULTI_PACKAGES = -main -doc
  22. CATEGORIES = lang
  23. HOMEPAGE = http://www.rust-lang.org/
  24. MAINTAINER = Sebastien Marie <semarie@online.fr>
  25. # both MIT and Apache2.0
  26. # with portions covered by various BSD-like licenses
  27. PERMIT_PACKAGE_CDROM = Yes
  28. WANTLIB-main = ${WANTLIB} c m pthread z
  29. WANTLIB-doc =
  30. MASTER_SITES = https://static.rust-lang.org/dist/
  31. MASTER_SITES0 = http://kapouay.odns.fr/pub/rust/
  32. MASTER_SITES1 = http://kapouay.odns.fr/pub/cargo/
  33. DIST_SUBDIR = rust
  34. DISTFILES = ${DISTNAME}${EXTRACT_SUFX} \
  35. ${RBOOTSTRAP} \
  36. ${CBOOTSTRAP}
  37. RBOOTSTRAP = ${RBOOTSTRAP-${MACHINE_ARCH}}
  38. CBOOTSTRAP = ${CBOOTSTRAP-${MACHINE_ARCH}}
  39. .for m in ${ONLY_FOR_ARCHS}
  40. RBOOTSTRAP-$m = rustc-bootstrap-${m}-${RBV-$m}.tar.gz:0
  41. CBOOTSTRAP-$m = cargo-bootstrap-${m}-${CBV-$m}.tar.gz:1
  42. SUPDISTFILES += ${RBOOTSTRAP-$m} \
  43. ${CBOOTSTRAP-$m}
  44. .endfor
  45. # per MACHINE_ARCH configuration
  46. .if "${MACHINE_ARCH}" == "amd64"
  47. TRIPLE_ARCH = x86_64-unknown-openbsd
  48. PKG_ARGS += -Damd64=1 -Di386=0
  49. .elif "${MACHINE_ARCH}" == "i386"
  50. TRIPLE_ARCH = i686-unknown-openbsd
  51. PKG_ARGS += -Damd64=0 -Di386=1
  52. .endif
  53. MODULES += gcc4 \
  54. lang/python
  55. MODPY_RUNDEP = No
  56. BUILD_DEPENDS += devel/llvm \
  57. devel/cmake
  58. # libgcc.a path
  59. CONFIG = ${MACHINE_ARCH}-unknown-openbsd${OSREV}
  60. SYSV = 4.2.1
  61. SYSLIBPATH = /usr/lib/gcc-lib/${CONFIG}/${SYSV}
  62. # rustllvm need c++11
  63. MODGCC4_LANGS = c++
  64. MODGCC4_ARCHS = * # patches required for base clang
  65. # need to be keep in sync
  66. LIBESTDC_VERSION = 17.1
  67. # note: RUSTFLAGS extra flags passed to rust
  68. # -L modgcc-libs : disambiguate libestdc++.so
  69. MAKE_ENV = RUSTFLAGS="-L ${WRKDIR}/modgcc-libs"
  70. # build/configuration variables
  71. SEPARATE_BUILD = Yes
  72. USE_GMAKE = Yes
  73. # need for libbacktrace
  74. USE_LIBTOOL = gnu
  75. TEST_DEPENDS += ${FULLPKGNAME-main}:${BUILD_PKGPATH} \
  76. devel/git
  77. TEST_TARGET ?= src/test/run-pass \
  78. src/test/compile-fail \
  79. src/test/parse-fail \
  80. src/test/run-fail \
  81. src/test/mir-opt \
  82. src/test/incremental \
  83. src/test/ui \
  84. src/test/compile-fail-fulldeps \
  85. src/test/run-make \
  86. src/test/rustdoc \
  87. src/test/pretty \
  88. src/test/run-pass/pretty \
  89. src/test/run-fail/pretty \
  90. path/to/nowhere
  91. # - check datasize limit before configuring (and building)
  92. pre-configure:
  93. @if [ `ulimit -d` -lt 2097152 ]; then \
  94. echo datasize limit is too low - amd64 build takes approx 2GB; \
  95. exit 1; fi
  96. # - generate config.toml file
  97. # - copy libestdc++ from MODGCC4 to specific directory
  98. # in order to disambiguate version linking (having multiple libestdc++
  99. # at build time)
  100. do-configure:
  101. echo '[build]' >${WRKBUILD}/config.toml
  102. echo 'rustc = "${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${RBV}/bin/rustc"' \
  103. >>${WRKBUILD}/config.toml
  104. echo 'cargo = "${WRKDIR}/cargo-bootstrap-${MACHINE_ARCH}-${CBV}/cargo"' \
  105. >>${WRKBUILD}/config.toml
  106. echo 'prefix = "${LOCALBASE}"' >>${WRKBUILD}/config.toml
  107. echo 'vendor = true' >>${WRKBUILD}/config.toml
  108. echo '[rust]' >>${WRKBUILD}/config.toml
  109. echo 'channel = "stable"' >>${WRKBUILD}/config.toml
  110. echo 'codegen-tests = false' >>${WRKBUILD}/config.toml
  111. echo '[dist]' >>${WRKBUILD}/config.toml
  112. echo 'src-tarball = false' >>${WRKBUILD}/config.toml
  113. echo '[target.${TRIPLE_ARCH}]' >>${WRKBUILD}/config.toml
  114. echo 'llvm-config = "${LOCALBASE}/bin/llvm-config"' \
  115. >>${WRKBUILD}/config.toml
  116. rm -rf ${WRKDIR}/modgcc-libs
  117. mkdir -p ${WRKDIR}/modgcc-libs
  118. cp ${LOCALBASE}/lib/libestdc++.so.${LIBESTDC_VERSION} \
  119. ${WRKDIR}/modgcc-libs
  120. # hack to build doc using generated stage2 instead of with stage0
  121. # (rustdoc isn't included in our bootstrap)
  122. post-configure:
  123. echo '#!/bin/sh' > ${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${RBV}/bin/rustdoc
  124. echo 'LD_LIBRARY_PATH="${WRKBUILD}/build/${TRIPLE_ARCH}/stage2/lib" exec "${WRKBUILD}/build/${TRIPLE_ARCH}/stage2/bin/rustdoc" "$$@"' \
  125. >> ${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${RBV}/bin/rustdoc
  126. chmod 755 ${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${RBV}/bin/rustdoc
  127. BUILD_BIN = cd ${WRKBUILD} && exec ${SETENV} ${MAKE_ENV} \
  128. ${MODPY_BIN} ${WRKSRC}/src/bootstrap/bootstrap.py
  129. do-build:
  130. ${BUILD_BIN} dist --verbose --jobs=${MAKE_JOBS}
  131. COMPONENTS ?= rustc rust-std rust-docs
  132. do-install:
  133. rm -rf ${WRKBUILD}/_extractdist
  134. .for _c in ${COMPONENTS}
  135. mkdir ${WRKBUILD}/_extractdist
  136. cd ${WRKBUILD}/_extractdist && tar zxf \
  137. ${WRKBUILD}/build/dist/${_c}-${V}-${TRIPLE_ARCH}.tar.gz
  138. cd ${WRKBUILD}/_extractdist/${_c}-${V}-${TRIPLE_ARCH} && ./install.sh \
  139. --prefix="${PREFIX}" \
  140. --mandir="${PREFIX}/man"
  141. rm -rf ${WRKBUILD}/_extractdist
  142. .endfor
  143. for lib in ${PREFIX}/lib/lib*.* ; do \
  144. libname=$${lib##*/} ; \
  145. test -e ${PREFIX}/lib/rustlib/${TRIPLE_ARCH}/lib/$${libname} && \
  146. ln -fs rustlib/${TRIPLE_ARCH}/lib/$${libname} \
  147. ${PREFIX}/lib/$${libname} ; \
  148. done
  149. post-install:
  150. # cleanup
  151. rm ${PREFIX}/bin/rust-lldb \
  152. ${PREFIX}/lib/rustlib/{install.log,uninstall.sh,rust-installer-version} \
  153. ${PREFIX}/lib/rustlib/components \
  154. ${PREFIX}/lib/rustlib/manifest-*
  155. # make a link to libgcc.a inside rustlib
  156. ln -fs ${SYSLIBPATH}/libgcc.a \
  157. ${PREFIX}/lib/rustlib/${TRIPLE_ARCH}/lib
  158. do-test:
  159. ${BUILD_BIN} test --verbose --jobs=${MAKE_JOBS} ${TEST_TARGET}
  160. # bootstrap target permits to regenerate the bootstrap archive
  161. BOOTSTRAPDIR=${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${V}-new
  162. bootstrap: build
  163. rm -rf ${BOOTSTRAPDIR}
  164. mkdir -p ${BOOTSTRAPDIR}/{bin,lib}
  165. ${MAKE} clean=fake
  166. ${MAKE} fake \
  167. PREFIX="${BOOTSTRAPDIR}" \
  168. COMPONENTS="rustc rust-std" \
  169. FAKE_SETUP=""
  170. rm -rf ${BOOTSTRAPDIR}/{man,share} \
  171. ${BOOTSTRAPDIR}/bin/{rust-gdb,rustdoc}
  172. mv ${BOOTSTRAPDIR}/bin/rustc{,.bin}
  173. strip ${BOOTSTRAPDIR}/bin/rustc.bin \
  174. ${BOOTSTRAPDIR}/lib/lib*.so \
  175. ${BOOTSTRAPDIR}/lib/rustlib/${TRIPLE_ARCH}/lib/lib*.so
  176. cp ${WRKDIR}/rustc-bootstrap-${MACHINE_ARCH}-${RBV}/bin/rustc \
  177. ${BOOTSTRAPDIR}/bin/rustc
  178. LD_LIBRARY_PATH="${BOOTSTRAPDIR}/lib" \
  179. ldd ${BOOTSTRAPDIR}/bin/rustc.bin \
  180. | sed -ne 's,.* \(/.*/lib/lib.*\.so.[.0-9]*\)$$,\1,p' \
  181. | xargs -r -J % cp % \
  182. ${BOOTSTRAPDIR}/lib
  183. .include <bsd.port.mk>