vulkan-sdk.SlackBuild 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. #!/bin/sh
  2. # Slackware build script for vulkan-sdk
  3. # Copyright 2016, 2017 Heinz Wiesinger, Amsterdam, The Netherlands
  4. # Copyright 2016, 2017, 2018 Patrick J. Volkerding, Sebeka, MN, USA
  5. # Copyright 2019-2020 Hunter Sezen California, USA
  6. # All rights reserved.
  7. #
  8. # Redistribution and use of this script, with or without modification, is
  9. # permitted provided that the following conditions are met:
  10. #
  11. # 1. Redistributions of this script must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
  15. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  17. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  22. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  23. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. PRGNAM=vulkan-sdk
  25. VERSION=${VERSION:-1.2.162.0}
  26. BUILD=${BUILD:-1}
  27. TAG=${TAG:-_SBo}
  28. if [ -z "$ARCH" ]; then
  29. case "$( uname -m )" in
  30. i?86) ARCH=i586 ;;
  31. arm*) ARCH=arm ;;
  32. *) ARCH=$( uname -m ) ;;
  33. esac
  34. fi
  35. CWD=$(pwd)
  36. TMP=${TMP:-/tmp/SBo}
  37. PKG=$TMP/package-$PRGNAM
  38. SRC=$TMP/$PRGNAM-$VERSION
  39. OUTPUT=${OUTPUT:-/tmp}
  40. if [ "$ARCH" = "i586" ]; then
  41. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  42. LIBDIRSUFFIX=""
  43. elif [ "$ARCH" = "i686" ]; then
  44. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  45. LIBDIRSUFFIX=""
  46. elif [ "$ARCH" = "x86_64" ]; then
  47. SLKCFLAGS="-O2 -fPIC"
  48. LIBDIRSUFFIX="64"
  49. else
  50. SLKCFLAGS="-O2"
  51. LIBDIRSUFFIX=""
  52. fi
  53. set -eu
  54. # VulkanTools from LunarG doesn't support an external jsoncpp
  55. JSONCPP_VERSION=${JSONCPP_VERSION:-1.8.0}
  56. chdir () { cd -- "$SRC/$1"; printf %s\\n '' "Building $1" ''; }
  57. cmake_build () {
  58. mkdir -p build
  59. cd build
  60. cmake \
  61. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  62. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  63. -DCMAKE_INSTALL_PREFIX=/usr \
  64. -DCMAKE_INSTALL_LIBDIR=lib$LIBDIRSUFFIX \
  65. -DCMAKE_SKIP_RPATH=TRUE \
  66. -DCMAKE_BUILD_TYPE=Release \
  67. "${@:-}" ..
  68. make
  69. make install DESTDIR=$PKG
  70. }
  71. copydocs () {
  72. dir="$1"
  73. mkdir -p -- "$PKG/usr/doc/$PRGNAM-$VERSION/$dir"
  74. shift
  75. for i do
  76. cp -a -- "$dir-sdk-$VERSION/$i" "$PKG/usr/doc/$PRGNAM-$VERSION/$dir/"
  77. done
  78. }
  79. rm -rf $PKG
  80. mkdir -p $TMP $PKG $OUTPUT
  81. cd $TMP
  82. rm -rf $PRGNAM-$VERSION
  83. mkdir $PRGNAM-$VERSION
  84. cd $PRGNAM-$VERSION
  85. tar xvf $CWD/Vulkan-Loader-sdk-$VERSION.tar.gz
  86. tar xvf $CWD/Vulkan-ValidationLayers-sdk-$VERSION.tar.gz
  87. tar xvf $CWD/VulkanTools-sdk-$VERSION.tar.gz
  88. tar xvf $CWD/gfxreconstruct-sdk-$VERSION.tar.gz
  89. (
  90. cd VulkanTools-sdk-$VERSION/submodules
  91. tar xvf $CWD/jsoncpp-$JSONCPP_VERSION.tar.gz
  92. rm -rf jsoncpp
  93. mv jsoncpp-$JSONCPP_VERSION jsoncpp
  94. )
  95. chown -R root:root .
  96. find -L . \
  97. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  98. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  99. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  100. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  101. #####################
  102. ### vulkan-loader ###
  103. #####################
  104. chdir Vulkan-Loader-sdk-$VERSION
  105. # Require an older cmake version.
  106. sed -i 's/3.10.2/3.5.2/' CMakeLists.txt
  107. # cmake 3.5.2 does not have GREATER_EQUAL
  108. patch -p1 < $CWD/vulkan-loader-cmake.patch
  109. cmake_build \
  110. -DBUILD_TESTS=OFF \
  111. -DBUILD_WSI_XCB_SUPPORT=ON \
  112. -DBUILD_WSI_XLIB_SUPPORT=ON \
  113. -DBUILD_WSI_WAYLAND_SUPPORT=OFF \
  114. -DVULKAN_HEADERS_INSTALL_DIR=/usr
  115. ###############################
  116. ### vulkan-validationlayers ###
  117. ###############################
  118. chdir Vulkan-ValidationLayers-sdk-$VERSION
  119. # Require an older cmake version.
  120. sed -i 's/3.10.2/3.5.2/' CMakeLists.txt
  121. cmake_build \
  122. -DCMAKE_INSTALL_DATADIR=share \
  123. -DBUILD_LAYER_SUPPORT_FILES=ON \
  124. -DBUILD_TESTS=OFF \
  125. -DBUILD_WERROR=OFF \
  126. -DBUILD_WSI_XCB_SUPPORT=ON \
  127. -DBUILD_WSI_XLIB_SUPPORT=ON \
  128. -DBUILD_WSI_WAYLAND_SUPPORT=OFF \
  129. -DGLSLANG_INSTALL_DIR=/usr \
  130. -DSPIRV_HEADERS_INSTALL_DIR=/usr \
  131. -DVULKAN_HEADERS_INSTALL_DIR=/usr
  132. ###################
  133. ### vulkantools ###
  134. ###################
  135. chdir VulkanTools-sdk-$VERSION
  136. # Generate missing jsoncpp sources
  137. (
  138. cd submodules/jsoncpp
  139. python3 ./amalgamate.py
  140. )
  141. # Require an older cmake version.
  142. find . -type f -name CMakeLists.txt | xargs grep -l '3\.10\.2' |
  143. xargs sed -i 's/3.10.2/3.5.2/'
  144. cmake_build \
  145. -DBUILD_GMOCK=OFF \
  146. -DBUILD_WSI_XCB_SUPPORT=ON \
  147. -DBUILD_WSI_XLIB_SUPPORT=ON \
  148. -DBUILD_WSI_WAYLAND_SUPPORT=OFF \
  149. -DINSTALL_GTEST=OFF \
  150. -DVULKAN_HEADERS_INSTALL_DIR=/usr \
  151. -DVULKAN_LOADER_INSTALL_DIR=$PKG/usr \
  152. -DVULKAN_VALIDATIONLAYERS_INSTALL_DIR=$PKG/usr
  153. ######################
  154. ### gfxreconstruct ###
  155. ######################
  156. chdir gfxreconstruct-sdk-$VERSION
  157. # Require an older cmake version.
  158. sed -i 's/3.10.2/3.5.2/' CMakeLists.txt
  159. # cmake 3.5.2 does not have FILTER for the list command
  160. sed -i '/generate_target_source_files(/d' cmake/CodeStyle.cmake
  161. cmake_build \
  162. -DBUILD_WERROR=OFF \
  163. -DVULKAN_HEADER=/usr/include/vulkan
  164. cd -- "$SRC"
  165. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" |
  166. grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  167. copydocs Vulkan-Loader CODE_OF_CONDUCT.md CONTRIBUTING.md GOVERNANCE.md \
  168. LICENSE.txt README.md
  169. copydocs Vulkan-ValidationLayers CODE_OF_CONDUCT.md CONTRIBUTING.md \
  170. GOVERNANCE.md LAYER_CONFIGURATION.md LICENSE.txt README.md
  171. copydocs VulkanTools CONTRIBUTING.md GOVERNANCE.md LICENSE.txt README.md
  172. copydocs gfxreconstruct CONTRIBUTING.md LICENSE.txt LICENSE_ThirdParty.txt \
  173. README.md USAGE_android.md USAGE_desktop.md
  174. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  175. mkdir -p $PKG/install
  176. cat $CWD/slack-desc > $PKG/install/slack-desc
  177. cd $PKG
  178. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}