Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- # Compile the 32-bit Mesa drivers from git. Works on all Linux distributions.
- #
- # Note: Must be run on a 32-bit OS/virtual machine. Assumes all dependencies already met.
- #
- # Supports:
- # radeon, intel, nouveau
- # Vulkan, Gallium Nine, Wayland
- #
- # Usage:
- # To run the build script with the defaults (master branch and LLVM 7):
- # bash ./build_mesa_32bit.sh
- #
- # or to override defaults:
- # MESA_BRANCH=18.3 LLVM_VER=8 bash ./build_mesa_32bit.sh
- #
- # or you can use any combination of the variables below.
- #
- # You should also edit the Vulkan, DRI, Gallium, and Platform drivers
- # to match your needs. The defaults includes everything to make the
- # script a little more robust.
- #
- # e.g. if you have an AMD Radeon RX 470/480/570/580/etc:
- #
- # VULKAN_DRIVERS=${VULKAN_DRIVERS:-"radeon"}
- # DRI_DRIVERS=${DRI_DRIVERS:-"radeon"}
- # GALLIUM_DRIVERS=${GALLIUM_DRIVERS:-"radeonsi swrast"}
- # PLATFORM_DRIVERS=${PLATFORM_DRIVERS:-"x11,surfaceless wayland drm"}
- #
- # or you can always pass the variables in when invoking the script.
- set -o errexit
- set -o pipefail
- ARCH_NAME=${ARCH_NAME:-"i386-linux-gnu"}
- MESA_BRANCH=${MESA_BRANCH:-"master"}
- LLVM_VER=${LLVM_VER:-"7"}
- OPTIMIZE_LEVEL=${OPTIMIZE_LEVEL:-"-O2"}
- OPTIMIZE_FLAGS=${OPTIMIZE_FLAGS:-"-march=native"}
- VULKAN_DRIVERS=${VULKAN_DRIVERS:-"intel radeon"}
- DRI_DRIVERS=${DRI_DRIVERS:-"nouveau i915 i965 r200 radeon"}
- GALLIUM_DRIVERS=${GALLIUM_DRIVERS:-"nouveau virgl svga r600 r300 radeonsi swrast"}
- PLATFORM_DRIVERS=${PLATFORM_DRIVERS:-"x11,surfaceless wayland drm"}
- SOURCE_URL=${SOURCE_URL:-"https://gitlab.freedesktop.org/mesa/mesa.git"}
- BUILD_DIR=${BUILD_DIR:-"${HOME}/mesa-build"}
- INSTALL_DIR=${INSTALL_DIR:-"${HOME}/mesa-${MESA_BRANCH}"}
- # Make sure we're on a 32-bit OS
- if [[ $(arch) != "i686" ]]; then
- printf "Must be run on a 32-bit OS. Exiting.\n"
- exit 1
- fi
- # Start fresh, remove previous build dir if it exists
- if [[ -d "${BUILD_DIR}" ]]; then
- rm -rf "${BUILD_DIR}"
- fi
- # Create build dir and clone from source
- mkdir -pv "${BUILD_DIR}"
- cd "${BUILD_DIR}"
- git clone --depth 1 --branch "${MESA_BRANCH}" "${SOURCE_URL}"
- cd mesa
- # Run the autogen script
- ./autogen.sh
- # Let's override the autogen defaults with our own
- ./configure --build=$(arch)-linux-gnu --prefix=${INSTALL_DIR} --includedir=\${prefix}/include --mandir=\${prefix}/share/man --infodir=\${prefix}/share/info --libdir=\${prefix}/lib/${ARCH_NAME} --libexecdir=\${prefix}/lib/${ARCH_NAME} --sysconfdir=/etc --localstatedir=/var --runstatedir=/run --disable-silent-rules --disable-dependency-tracking --disable-xvmc --disable-omx-bellagio --disable-gles1 --enable-gles2 --enable-libglvnd --enable-osmesa --enable-glx-tls --enable-shared-glapi --enable-driglx-direct --enable-gbm --enable-lmsensors --enable-xa --enable-llvm --enable-opencl --enable-opencl-icd --enable-vdpau --enable-va --enable-gallium-extra-hud --enable-nine --enable-dri --enable-dri3 ac_cv_path_LLVM_CONFIG=llvm-config-${LLVM_VER} "--with-dri-drivers=${DRI_DRIVERS}" "--with-dri-driverdir=/usr/lib/${ARCH_NAME}/dri" "--with-dri-searchpath=/usr/lib/${ARCH_NAME}/dri:\\\$\${ORIGIN}/dri:/usr/lib/dri" "--with-vulkan-drivers=${VULKAN_DRIVERS}" "--with-platforms=${PLATFORM_DRIVERS}" "--with-gallium-drivers=${GALLIUM_DRIVERS}" "CFLAGS=-g ${OPTIMIZE_LEVEL} ${OPTIMIZE_FLAGS} -fstack-protector-strong -Wformat -Werror=format-security -Wall" "CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2" "CXXFLAGS=-g ${OPTIMIZE_LEVEL} ${OPTIMIZE_FLAGS} -fstack-protector-strong -Wformat -Werror=format-security -Wall" "FCFLAGS=-g ${OPTIMIZE_LEVEL} -fstack-protector-strong" "FFLAGS=-g ${OPTIMIZE_LEVEL} ${OPTIMIZE_FLAGS} -fstack-protector-strong" "GCJFLAGS=-g ${OPTIMIZE_LEVEL} -fstack-protector-strong" "LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro" "OBJCFLAGS=-g ${OPTIMIZE_LEVEL} ${OPTIMIZE_FLAGS} -fstack-protector-strong -Wformat -Werror=format-security" "OBJCXXFLAGS=-g ${OPTIMIZE_LEVEL} ${OPTIMIZE_FLAGS} -fstack-protector-strong -Wformat -Werror=format-security"
- # Begin compiling
- make -j$(nproc)
- # Finished compiling, move gallium files up a dir to flatten
- mv -v "${ARCH_NAME}"/gallium/* "${ARCH_NAME}"
- rmdir -v "${ARCH_NAME}"/gallium
- # If we've installed Mesa drivers before, backup the current one
- if [ -d "${INSTALL_DIR}"/lib/"${ARCH_NAME}" ]; then
- rm -rf "${INSTALL_DIR}"/lib/"${ARCH_NAME}"-old
- mv -vf "${INSTALL_DIR}"/lib/"${ARCH_NAME}"{,-old}
- fi
- # Create the Mesa drivers directory and move libraries into it
- mkdir -pv "${INSTALL_DIR}"/lib/"${ARCH_NAME}"
- mv -v "${ARCH_NAME}"/* "${INSTALL_DIR}"/lib/"${ARCH_NAME}"
- # Copy over the Vulkan icd files as well
- if [[ ${VULKAN_DRIVERS} == *"intel"* ]]; then
- cp -v src/intel/vulkan/intel_icd.$(arch).json "${INSTALL_DIR}"/lib/"${ARCH_NAME}"
- fi
- if [[ ${VULKAN_DRIVERS} == *"radeon"* ]]; then
- cp -v src/amd/vulkan/radeon_icd.$(arch).json "${INSTALL_DIR}"/lib/"${ARCH_NAME}"
- fi
- # Create archive of the 32-bit drivers to be used on a 64-bit host
- tar czvf "${HOME}/mesa-${MESA_BRANCH}-${ARCH_NAME}.tar.gz" -C "${INSTALL_DIR}/lib" .
- # Cleanup
- rm -rf "${BUILD_DIR}"
- rm -rf "${INSTALL_DIR}"
- # Script complete. Change back into home directory and show help info
- cd
- VIEOPENGLINFO="LIBGL_DRIVERS_PATH=${INSTALL_DIR}/lib/${ARCH_NAME}\
- EGL_DRIVERS_PATH=${INSTALL_DIR}/lib/${ARCH_NAME} glxinfo | grep OpenGL"
- VIEWVULKANINFO="VK_ICD_FILENAMES=${INSTALL_DIR}/lib/${ARCH_NAME}\
- /radeon_icd.$(arch).json vulkaninfo | head -n 5"
- printf "\n✓ All done.\n\n"
- printf " To verify your 32-bit OpenGL drivers, copy and paste the following (requires glxinfo/mesa-utils): \n\n"
- printf "\t${VIEOPENGLINFO}\n\n"
- printf " To verify your 32-bit Vulkan drivers, copy and paste the following (requires vulkaninfo): \n\n"
- printf "\t${VIEWVULKANINFO}\n\n"
- printf " You'll now want to move the following archive: \n\n"
- printf "\t$HOME/mesa-${MESA_BRANCH}-${ARCH_NAME}.tar.gz\n\n"
- printf " to your 64-bit host machine and extract it to the appropriate location. e.g:\n\n"
- printf "\t32-bit drivers in: ${INSTALL_DIR}/lib/i386-linux-gnu\n\n"
- printf "\t64-bit drivers in: ${INSTALL_DIR}/lib/x86_64-linux-gnu\n\n"
Advertisement
Add Comment
Please, Sign In to add comment