PKGBUILD 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. # Maintainer: entschuld < edgar -a t . openmail.cc>
  2. _base=basix
  3. pkgname=fenics-"${_base}"-git
  4. pkgdesc="C++ interface of FEniCS for ordinary and partial differential equations (from git release)."
  5. pkgver=0.8.0_r1067.0ed41b0
  6. pkgrel=1
  7. arch=('i686' 'x86_64')
  8. url="https://github.com/FEniCS/${_base}"
  9. license=('MIT')
  10. groups=('fenics-git')
  11. depends=("blas-openblas" "petsc")
  12. makedepends=("boost" "gcc" "git" "pybind11" "python-build" "python-installer" "python-numpy" "python-scikit-build" "python-setuptools" "nanobind")
  13. checkdepends=("python-sympy")
  14. options=(!emptydirs)
  15. source=("git+${url}#branch=release")
  16. sha512sums=('SKIP')
  17. provides=("${_base}=${pkgver}"
  18. "fenics-${_base}=${pkgver}")
  19. replaces=("${provides}")
  20. conflicts=("${_base}" "fenics-${_base}")
  21. # From UPC: Building And Using Static And Shared "C"
  22. # Libraries.html
  23. # #+begin_QUOTE
  24. # we need that all jump calls ("goto", in assembly speak)
  25. # and subroutine calls will use relative addresses, and not
  26. # absolute addresses. Thus, we need to use ... ~-fPIC~ or
  27. # ~-fpic~
  28. # #+end_QUOTE
  29. #
  30. # From makepkg.conf
  31. # -march (or -mcpu) builds exclusively for an architecture
  32. # -mtune optimizes for an architecture, but builds for
  33. # whole processor family
  34. #
  35. # -O3 optimises
  36. #
  37. # -D-FORTIFY-SOURCE=2
  38. # | https://stackoverflow.com/a/16604146
  39. # |- man 7 feature_test_macros
  40. # checks to be performed to detect some buffer overflow
  41. # errors when employing various string and memory
  42. # manipulation functions ... some conforming programs
  43. # might fail
  44. #
  45. # -fcf-protection
  46. # | Info pages for gcc (gnu compiler collection)
  47. # intended to protect against such threats as
  48. # Return-oriented Programming (ROP), and similarly
  49. # call/jmp-oriented programming (COP/JOP)
  50. #
  51. # -pipe
  52. # | Info pages for gcc (controlling the kind of output)
  53. # Use pipes rather than temporary files for communication
  54. # between the various stages of compilation
  55. #
  56. # -fno-plt
  57. # | Info pages for gcc (code generation conventions)
  58. # leads to more efficient code by eliminating PLT stubs and
  59. # exposing GOT loads to optimizations
  60. #
  61. # -fopenmp
  62. # | Info pages for gcc (controlling c dialect)
  63. # Enable handling of OpenMP directives
  64. #
  65. safe_flags="-Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS"
  66. safe_flags+=" -fcf-protection -fno-plt"
  67. safe_flags+=" -fstack-clash-protection -Wformat"
  68. safe_flags+=" -Werror=format-security"
  69. generic_flags="-pipe -fno-plt -fPIC -fopenmp"
  70. generic_flags+=" -march=native"
  71. generic_flags+=" -mtune=native ${safe_flags}"
  72. opt_flags="${generic_flags} -O3"
  73. generic_flags="${generic_flags} -O2"
  74. export COPTFLAGS="${opt_flags}"
  75. export CXXOPTFLAGS="$COPTFLAGS"
  76. export FOPTFLAGS="$COPTFLAGS"
  77. export CPPFLAGS="$generic_flags"
  78. export CXXFLAGS="$CPPFLAGS"
  79. export CFLAGS="$generic_flags"
  80. export FFLAGS="$generic_flags"
  81. export FCFLAGS="$generic_flags"
  82. export F90FLAGS="$generic_flags"
  83. export F77FLAGS="$generic_flags"
  84. export CC=mpicc
  85. export CXX=mpicxx
  86. export FC=mpif90
  87. export F90=mpif90
  88. export LANG=en_IE.UTF-8
  89. export LC_ALL=en_IE.UTF-8
  90. _base_dir="${startdir}"/src/"${_base}"
  91. prepare() {
  92. cd "${_base_dir}"
  93. git -C "${_base_dir}" clean -dfx
  94. }
  95. pkgver() {
  96. cd "${_base_dir}"
  97. # One day, there will be a tag in the repo (or a single
  98. # file to analyse) and this will not be needed
  99. for i in pyproject.toml setup.cfg setup.py; do
  100. # Check if /version/ exists in any of these files
  101. if [[ -n $(grep 'version.*=' $i) ]]; then
  102. # Get version by removing " , ', spaces and =
  103. tag="$(grep -m 1 'version[[:space:]]*=' "${i}" |
  104. tr -d '", ' | tr -d "'" | cut -d'=' -f2)"
  105. break;
  106. fi;
  107. done
  108. printf "%s_r%s.%s" \
  109. ${tag%%.} \
  110. "$(git rev-list --count HEAD)" \
  111. "$(git rev-parse --short=7 HEAD)"
  112. }
  113. # # Skip tests
  114. # check (){
  115. # }
  116. build() {
  117. [ -n "$PETSC_DIR" ] && source /etc/profile.d/petsc.sh
  118. # May want to look at pyproject.toml, .github/workflows,
  119. # python/setup.py for inspiration
  120. cmake -DCMAKE_BUILD_TYPE="Release" \
  121. -B "${srcdir}"/build \
  122. -S "${_base_dir}" \
  123. -DCMAKE_INSTALL_PREFIX=/usr
  124. cmake --build "${srcdir}"/build
  125. }
  126. package() {
  127. # cd "${srcdir}"/"${_base}"/cpp
  128. cmake --install "${srcdir}"/build --prefix="${pkgdir}"/usr
  129. }