##### this file is sourced not run
PKGVER=17.2.6
PKGBUILD=1
PKGARCH=i686

# source: BLFS 7.5 updated to latest
TARBALL=mesa-$PKGVER.tar.xz
MD5SUM=862f2b7e2a08554570b192a89f723b6f
SRC_URL=https://mesa.freedesktop.org/archive/$TARBALL
BUNDLE=

SLACKREQ='libdrm32 expat32 libxml2_32 libX11_32 libelf32 libpthread-stubs32' # build-time: elfutils32 llvm32
SLACKDESC="mesa32: mesa $PKGVER (open source OpenGL library)  
mesa32:  
mesa32: Mesa is an OpenGL compatible 3D graphics library.  
mesa32: 
mesa32: This contains 32-bit version of the library.
mesa32: 
mesa32: 
mesa32: 
mesa32: 
mesa32: 
mesa32:
"

### default pkg_download
### prepare
pkg_prepare() {
	pkg_prepare_default &&
	cd tmp/mesa* &&
	patch -Np1 -i $CHROOT_DIR/tmp/pkg/MesaLib-add_xdemos-1.patch
	patch -Np1 -i $CHROOT_DIR/tmp/pkg/fix-missing-memfd-header.patch
}

### package - only collect the libraries
pkg_package() {
	rm -rf usr/include usr/share
}

### build
pkg_build() {
	cd /tmp/mesa*
	# LFS 7.5 build parameters
	autoreconf --force --install
	export CC="gcc ${BUILD32}" CXX="g++ ${BUILD32}"
	export CFLAGS="-O2" CXXFLAGS="-O2"
	export PKG_CONFIG_PATH="$PKG_CONFIG_PATH32"
	export USE_ARCH=32
	./autogen.sh CFLAGS=-O2 CXXFLAGS=-O2 $XORG_CONFIG \
			--build=${CLFS_TARGET32} --host=${CLFS_TARGET32} \
            --enable-texture-float         \
            --enable-gles1                 \
            --enable-gles2                 \
            --enable-gallium-osmesa       \
            --enable-xa                    \
            --disable-vdpau                 \
            --enable-gbm                   \
            --enable-shared-glapi          \
            --enable-glx-tls               \
            --disable-llvm-shared-libs      \
            --with-egl-platforms=drm,x11   \
            --with-gallium-drivers="r300,r600,nouveau,radeonsi,svga,swrast" \
            --with-vulkan-drivers="intel, radeon"   \
            --with-dri-drivers="i965,i915" &&
            
    make $MAKEFLAGS && make $MAKEINSTALLFLAGS install &&

    # glxgears, glxinfo
    make -C xdemos DEMOS_PREFIX=$XORG_PREFIX CC="$CC" &&
    make -C xdemos DEMOS_PREFIX=$XORG_PREFIX CC="$CC" install &&
    mv /usr/bin/glxgears /usr/bin/glxgears-32 &&
    mv /usr/bin/glxinfo /usr/bin/glxinfo-32 &&

	# desc
	pkg_build_slackdesc
}

<< "EOF"
sh-4.3# ./configure --help
`configure' configures Mesa 11.0.6 to adapt to many kinds of systems.

Usage: ./configure [OPTION]... [VAR=VALUE]...

To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE.  See below for descriptions of some of the useful variables.

Defaults for the options are specified in brackets.

Configuration:
  -h, --help              display this help and exit
      --help=short        display options specific to this package
      --help=recursive    display the short help of all the included packages
  -V, --version           display version information and exit
  -q, --quiet, --silent   do not print `checking ...' messages
      --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache      alias for `--cache-file=config.cache'
  -n, --no-create         do not create output files
      --srcdir=DIR        find the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR            user executables [EPREFIX/bin]
  --sbindir=DIR           system admin executables [EPREFIX/sbin]
  --libexecdir=DIR        program executables [EPREFIX/libexec]
  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
  --libdir=DIR            object code libraries [EPREFIX/lib]
  --includedir=DIR        C header files [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
  --infodir=DIR           info documentation [DATAROOTDIR/info]
  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR            man documentation [DATAROOTDIR/man]
  --docdir=DIR            documentation root [DATAROOTDIR/doc/mesa]
  --htmldir=DIR           html documentation [DOCDIR]
  --dvidir=DIR            dvi documentation [DOCDIR]
  --pdfdir=DIR            pdf documentation [DOCDIR]
  --psdir=DIR             ps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIX            prepend PREFIX to installed program names
  --program-suffix=SUFFIX            append SUFFIX to installed program names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names

System types:
  --build=BUILD     configure for building on BUILD [guessed]
  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
  --target=TARGET   configure for building compilers for TARGET [HOST]

Optional Features:
  --disable-option-checking  ignore unrecognized --enable/--with options
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --enable-silent-rules   less verbose build output (undo: "make V=1")
  --disable-silent-rules  verbose build output (undo: "make V=0")
  --enable-dependency-tracking
                          do not reject slow dependency extractors
  --disable-dependency-tracking
                          speeds up one-time build
  --disable-largefile     omit support for large files
  --enable-static[=PKGS]  build static libraries [default=no]
  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-fast-install[=PKGS]
                          optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
  --enable-debug          use debug compiler flags and macros
                          [default=disabled]
  --enable-mangling       enable mangled symbols and library name
                          [default=disabled]
  --enable-texture-float  enable floating-point textures and renderbuffers
                          [default=disabled]
  --disable-asm           disable assembly usage [default=enabled on supported
                          plaforms]
  --enable-selinux        Build SELinux-aware Mesa [default=disabled]
  --disable-opengl        disable support for standard OpenGL API
                          [default=enabled]
  --disable-gles1         disable support for OpenGL ES 1.x API
                          [default=enabled]
  --disable-gles2         disable support for OpenGL ES 2.x API
                          [default=enabled]
  --enable-dri            enable DRI modules [default=enabled]
  --enable-dri3           enable DRI3 [default=auto]
  --enable-glx            enable GLX library [default=enabled]
  --enable-osmesa         enable OSMesa library [default=disabled]
  --enable-gallium-osmesa enable Gallium implementation of the OSMesa library
                          [default=disabled]
  --disable-egl           disable EGL library [default=enabled]
  --enable-xa             enable build of the XA X Acceleration API
                          [default=disabled]
  --enable-gbm            enable gbm library [default=auto]
  --enable-nine           enable build of the nine Direct3D9 API [default=no]
  --enable-xvmc           enable xvmc library [default=auto]
  --enable-vdpau          enable vdpau library [default=auto]
  --enable-omx            enable OpenMAX library [default=disabled]
  --enable-va             enable va library [default=auto]
  --enable-opencl         enable OpenCL library [default=disabled]
  --enable-opencl-icd     Build an OpenCL ICD library to be loaded by an ICD
                          implementation [default=disabled]
  --enable-xlib-glx       make GLX library Xlib-based instead of DRI-based
                          [default=disabled]
  --enable-r600-llvm-compiler
                          Enable experimental LLVM backend for graphics
                          shaders [default=disabled]
  --enable-gallium-tests  Enable optional Gallium tests) [default=disabled]
  --enable-shared-glapi   Enable shared glapi for OpenGL [default=enabled]
  --enable-sysfs          enable /sys PCI identification [default=disabled]
  --disable-driglx-direct disable direct rendering in GLX and EGL for DRI
                          [default=auto]
  --enable-glx-tls        enable TLS support in GLX [default=disabled]
  --enable-glx-read-only-text
                          Disable writable .text section on x86 (decreases
                          performance) [default=disabled]
  --enable-gallium-llvm   build gallium LLVM support [default=enabled on
                          x86/x86_64]
  --enable-llvm-shared-libs
                          link with LLVM shared libraries [default=enabled]

Optional Packages:
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --with-pic[=PKGS]       try to use only PIC/non-PIC objects [default=use
                          both]
  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
  --with-sysroot=DIR Search for dependent libraries within DIR
                        (or the compiler's sysroot if not specified).
  --with-gl-lib-name[=NAME]
                          specify GL library name [default=GL]
  --with-osmesa-lib-name[=NAME]
                          specify OSMesa library name [default=OSMesa]
  --with-gallium-drivers[=DIRS...]
                          comma delimited Gallium drivers list, e.g.
                          "i915,ilo,nouveau,r300,r600,radeonsi,freedreno,svga,swrast,vc4"
                          [default=r300,r600,svga,swrast]
  --with-dri-driverdir=DIR
                          directory for the DRI drivers [${libdir}/dri]
  --with-dri-searchpath=DIRS...
                          semicolon delimited DRI driver search directories
                          [${libdir}/dri]
  --with-dri-drivers[=DIRS...]
                          comma delimited classic DRI drivers list, e.g.
                          "swrast,i965,radeon" [default=auto]
  --with-osmesa-bits=BITS OSMesa channel bits and library name: 8, 16, 32
                          [default=8]
  --with-clang-libdir     Path to Clang libraries [default=llvm-config
                          --libdir]
  --with-egl-platforms[=DIRS...]
                          comma delimited native platforms libEGL supports,
                          e.g. "x11,drm" [default=auto]
  --with-llvm-prefix      Prefix for LLVM installations in non-standard
                          locations
  --with-xvmc-libdir=DIR  directory for the XVMC libraries [default=${libdir}]
  --with-vdpau-libdir=DIR directory for the VDPAU libraries
                          [default=${libdir}/vdpau]
  --with-omx-libdir=DIR   directory for the OMX libraries
  --with-va-libdir=DIR    directory for the VA libraries [${libdir}/dri]
  --with-d3d-libdir=DIR   directory for the D3D modules [${libdir}/d3d]

Some influential environment variables:
  CC          C compiler command
  CFLAGS      C compiler flags
  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
              nonstandard directory <lib dir>
  LIBS        libraries to pass to the linker, e.g. -l<library>
  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
              you have headers in a nonstandard directory <include dir>
  CPP         C preprocessor
  CXX         C++ compiler command
  CXXFLAGS    C++ compiler flags
  CCAS        assembler compiler command (defaults to CC)
  CCASFLAGS   assembler compiler flags (defaults to CFLAGS)
  CXXCPP      C++ preprocessor
  YACC        The `Yet Another Compiler Compiler' implementation to use.
              Defaults to the first program found out of: `bison -y', `byacc',
              `yacc'.
  YFLAGS      The list of arguments that will be passed by default to $YACC.
              This script will default YFLAGS to the empty string to avoid a
              default value of `-d' given by some make applications.
  PKG_CONFIG  path to pkg-config utility
  PKG_CONFIG_PATH
              directories to add to pkg-config's search path
  PKG_CONFIG_LIBDIR
              path overriding pkg-config's built-in search path
  SELINUX_CFLAGS
              C compiler flags for SELINUX, overriding pkg-config
  SELINUX_LIBS
              linker flags for SELINUX, overriding pkg-config
  LIBDRM_CFLAGS
              C compiler flags for LIBDRM, overriding pkg-config
  LIBDRM_LIBS linker flags for LIBDRM, overriding pkg-config
  LIBUDEV_CFLAGS
              C compiler flags for LIBUDEV, overriding pkg-config
  LIBUDEV_LIBS
              linker flags for LIBUDEV, overriding pkg-config
  XLIBGL_CFLAGS
              C compiler flags for XLIBGL, overriding pkg-config
  XLIBGL_LIBS linker flags for XLIBGL, overriding pkg-config
  GLPROTO_CFLAGS
              C compiler flags for GLPROTO, overriding pkg-config
  GLPROTO_LIBS
              linker flags for GLPROTO, overriding pkg-config
  DRI2PROTO_CFLAGS
              C compiler flags for DRI2PROTO, overriding pkg-config
  DRI2PROTO_LIBS
              linker flags for DRI2PROTO, overriding pkg-config
  DRI3PROTO_CFLAGS
              C compiler flags for DRI3PROTO, overriding pkg-config
  DRI3PROTO_LIBS
              linker flags for DRI3PROTO, overriding pkg-config
  PRESENTPROTO_CFLAGS
              C compiler flags for PRESENTPROTO, overriding pkg-config
  PRESENTPROTO_LIBS
              linker flags for PRESENTPROTO, overriding pkg-config
  XF86VIDMODE_CFLAGS
              C compiler flags for XF86VIDMODE, overriding pkg-config
  XF86VIDMODE_LIBS
              linker flags for XF86VIDMODE, overriding pkg-config
  DRIGL_CFLAGS
              C compiler flags for DRIGL, overriding pkg-config
  DRIGL_LIBS  linker flags for DRIGL, overriding pkg-config
  EXPAT_CFLAGS
              C compiler flags for EXPAT, overriding pkg-config
  EXPAT_LIBS  linker flags for EXPAT, overriding pkg-config
  INTEL_CFLAGS
              C compiler flags for INTEL, overriding pkg-config
  INTEL_LIBS  linker flags for INTEL, overriding pkg-config
  NVVIEUX_CFLAGS
              C compiler flags for NVVIEUX, overriding pkg-config
  NVVIEUX_LIBS
              linker flags for NVVIEUX, overriding pkg-config
  RADEON_CFLAGS
              C compiler flags for RADEON, overriding pkg-config
  RADEON_LIBS linker flags for RADEON, overriding pkg-config
  VL_CFLAGS   C compiler flags for VL, overriding pkg-config
  VL_LIBS     linker flags for VL, overriding pkg-config
  XVMC_CFLAGS C compiler flags for XVMC, overriding pkg-config
  XVMC_LIBS   linker flags for XVMC, overriding pkg-config
  VDPAU_CFLAGS
              C compiler flags for VDPAU, overriding pkg-config
  VDPAU_LIBS  linker flags for VDPAU, overriding pkg-config
  OMX_CFLAGS  C compiler flags for OMX, overriding pkg-config
  OMX_LIBS    linker flags for OMX, overriding pkg-config
  VA_CFLAGS   C compiler flags for VA, overriding pkg-config
  VA_LIBS     linker flags for VA, overriding pkg-config
  WAYLAND_SCANNER_CFLAGS
              C compiler flags for WAYLAND_SCANNER, overriding pkg-config
  WAYLAND_SCANNER_LIBS
              linker flags for WAYLAND_SCANNER, overriding pkg-config
  WAYLAND_CFLAGS
              C compiler flags for WAYLAND, overriding pkg-config
  WAYLAND_LIBS
              linker flags for WAYLAND, overriding pkg-config
  XCB_DRI2_CFLAGS
              C compiler flags for XCB_DRI2, overriding pkg-config
  XCB_DRI2_LIBS
              linker flags for XCB_DRI2, overriding pkg-config
  AMDGPU_CFLAGS
              C compiler flags for AMDGPU, overriding pkg-config
  AMDGPU_LIBS linker flags for AMDGPU, overriding pkg-config
  NOUVEAU_CFLAGS
              C compiler flags for NOUVEAU, overriding pkg-config
  NOUVEAU_LIBS
              linker flags for NOUVEAU, overriding pkg-config
  FREEDRENO_CFLAGS
              C compiler flags for FREEDRENO, overriding pkg-config
  FREEDRENO_LIBS
              linker flags for FREEDRENO, overriding pkg-config

Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.

See docs/autoconf.html for more details on the options for Mesa.

Report bugs to <https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa>.
EOF
 
