#!/bin/bash

# Slackware build script for lammps

# Copyright 2023-2026 Giancarlo Dessi, Cagliari, IT
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=lammps
VERSION=${VERSION:-2026.09.30_update1}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
SRCNAM=lammps-stable
SRCVERSION=${SRCVERSION:-30Sep2026_update1}
PACEVERSION=v.2025.12.4.p1
OCLLVERSION=2022.01.04

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

# Detect if the system is -current or 15.0 Stable.
# Since the system Eigen3 in -current is not supported
# Eigen3 v. 3.4.0 must be downloaded as extrasource
# and compiled as bundle third part module
if [ $(/usr/bin/cmake --version |head -1 |cut -f3 -d' ') == "3.21.4" ]; then
 CURRENT=NO
 echo "export PATH for cmake-opt"
 export PATH="/opt/cmake-opt/bin/:$PATH"
else 
 CURRENT=YES
 # if found in -current SCAFACOS causes an unsolved failure at the end of
 # LAMMPS build so we have to disable this module
 SCAFACOS=no
fi


# These internal modules are enabled by default.
# If you do not require some of them you have to edit the conditions in this block 
# otherwise pass the respective environment variables set to "no" to the script
# for each module not desired
# (for example: AMOEBA=no ASPHERE=no ./lammps.SlackBuild)

amoeba="" [ "${AMOEBA:-yes}" = "yes" ] && amoeba="-DPKG_AMOEBA=yes "
asphere="" ; [ "${ASPHERE:-yes}" = "yes" ] && asphere="-DPKG_ASPHERE=yes "
atc="" ; [ "${ATC:-yes}" = "yes" ] && atc="-DPKG_ATC=yes "
awpmd="" ; [ "${AWPMD:-yes}" = "yes" ] && awpmd="-DPKG_AWPMD=yes "
bocs="" ; [ "${BOCS:-yes}" = "yes" ] && bocs="-DPKG_BOCS=yes "
body="" ; [ "${BODY:-yes}" = "yes" ] && body="-DPKG_BODY=yes "
bpm="" ; [ "${BPM:-yes}" = "yes" ] && bpm="-DPKG_BPM=yes "
brownian="" ; [ "${BROWNIAN:-yes}" = "yes" ] && brownian="-DPKG_BROWNIAN=yes "
cgdna="" ; [ "${CGDNA:-yes}" = "yes" ] && cgdna="-DPKG_CG-DNA=yes "
cgspica="" ; [ "${CGSPICA:-yes}" = "yes" ] && cgspica="-DPKG_CG-SPICA=yes "
class2="" ; [ "${CLASS2:-yes}" = "yes" ] && class2="-DPKG_CLASS2=yes "
colloid="" ; [ "${COLLOID:-yes}" = "yes" ] && colloid="-DPKG_COLLOID=yes "
colvars="" ; [ "${COLVARS:-yes}" = "yes" ] && colvars="-DPKG_COLVARS=yes "
compress="" ; [ "${COMPRESS:-yes}" = "yes" ] && compress="-DPKG_COMPRESS=yes "
coreshell="" ; [ "${CORESHELL:-yes}" = "yes" ] && coreshell="-DPKG_CORESHELL=yes "
dielectric="" ; [ "${DIELECTRIC:-yes}" = "yes" ] && dielectric="-DPKG_DIELECTRIC=yes "
diffraction="" ; [ "${DIFFRACTION:-yes}" = "yes" ] && diffraction="-DPKG_DIFFRACTION=yes "
dipole="" ; [ "${DIPOLE:-yes}" = "yes" ] && dipole="-DPKG_DIPOLE=yes "
dpdbasic="" ; [ "${DPDBASIC:-yes}" = "yes" ] && dpdbasic="-DPKG_DPD-BASIC=yes "
dpdmeso="" ; [ "${DPDMESO:-yes}" = "yes" ] && dpdmeso="-DPKG_DPD-MESO=yes "
dpdreact="" ; [ "${DPDREACT:-yes}" = "yes" ] && dpdreact="-DPKG_DPD-REACT=yes "
dpdsmooth="" ; [ "${DPDSMOOTH:-yes}" = "yes" ] && dpdsmooth="-DPKG_DPD-SMOOTH=yes "
drude="" ; [ "${DRUDE:-yes}" = "yes" ] && drude="-DPKG_DRUDE=yes "
eff="" ; [ "${EFF:-yes}" = "yes" ] && eff="-DPKG_EFF=yes "
electrode="" ; [ "${ELECTRODE:-yes}" = "yes" ] && electrode="-DPKG_ELECTRODE=yes "
extracompute="" ; [ "${EXTRACOMPUTE:-yes}" = "yes" ] && extracompute="-DPKG_EXTRA-COMPUTE=yes "
extradump="" ; [ "${EXTRADUMP:-yes}" = "yes" ] && extradump="-DPKG_EXTRA-DUMP=yes "
extrafix="" ; [ "${EXTRAFIX:-yes}" = "yes" ] && extrafix="-DPKG_EXTRA-FIX=yes "
extramolecule="" ; [ "${EXTRAMOLECULE:-yes}" = "yes" ] && extramolecule="-DPKG_EXTRA-MOLECULE=yes "
extrapair="" ; [ "${EXTRAPAIR:-yes}" = "yes" ] && extrapair="-DPKG_EXTRA-PAIR=yes "
fep="" ; [ "${FEP:-yes}" = "yes" ] && fep="-DPKG_FEP=yes "
granular="" ; [ "${GRANULAR:-yes}" = "yes" ] && granular="-DPKG_GRANULAR=yes "
intel="" ; [ "${INTEL:-yes}" = "yes" ] && intel="-DPKG_INTEL=yes "
interlayer="" ; [ "${INTERLAYER:-yes}" = "yes" ] && interlayer="-DPKG_INTERLAYER=yes "
kspace="" ; [ "${KSPACE:-yes}" = "yes" ] && kspace="-DPKG_KSPACE=yes "
lepton="" ; [ "${LEPTON:-yes}" = "yes" ] && lepton="-DPKG_LEPTON=yes "
machdyn="" ; [ "${MACHDYN:-yes}" = "yes" ] && machdyn="-DPKG_MACHDYN=yes "
manifold="" ; [ "${MANIFOLD:-yes}" = "yes" ] && manifold="-DPKG_MANIFOLD=yes "
manybody="" ; [ "${MANYBODY:-yes}" = "yes" ] && manybody="-DPKG_MANYBODY=yes "
mc="" ; [ "${MC:-yes}" = "yes" ] && mc="-DPKG_MC=yes "
meam="" ; [ "${MEAM:-yes}" = "yes" ] && meam="-DPKG_MEAM=yes "
mgpt="" ; [ "${MGPT:-yes}" = "yes" ] && mgpt="-DPKG_MGPT=yes "
misc="" ; [ "${MISC:-yes}" = "yes" ] && misc="-DPKG_MISC=yes "
mlpod="" ; [ "${MLPOD:-yes}" = "yes" ] && mlpod="-DPKG_ML-POD=yes "
mlrann="" ; [ "${MLRANN:-yes}" = "yes" ] && mlrann="-DPKG_ML-RANN=yes "
mlsnap="" ; [ "${MLSNAP:-yes}" = "yes" ] && mlsnap="-DPKG_ML-SNAP=yes "
mofff="" ; [ "${MOFFF:-yes}" = "yes" ] && mofff="-DPKG_MOFFF=yes "
molecule="" ; [ "${MOLECULE:-yes}" = "yes" ] && molecule="-DPKG_MOLECULE=yes "
opt="" ; [ "${OPT:-yes}" = "yes" ] && opt="-DPKG_OPT=yes "
orient="" ; [ "${ORIENT:-yes}" = "yes" ] && orient="-DPKG_ORIENT=yes "
peri="" ; [ "${PERI:-yes}" = "yes" ] && peri="-DPKG_PERI=yes "
phonon="" ; [ "${PHONON:-yes}" = "yes" ] && phonon="-DPKG_PHONON=yes "
plugin="" ; [ "${PLUGIN:-yes}" = "yes" ] && plugin="-DPKG_PLUGIN=yes "
poems="" ; [ "${POEMS:-yes}" = "yes" ] && poems="-DPKG_POEMS=yes "
ptm="" ; [ "${PTM:-yes}" = "yes" ] && ptm="-DPKG_PTM=yes "
qeq="" ; [ "${QEQ:-yes}" = "yes" ] && qeq="-DPKG_QEQ=yes "
qtb="" ; [ "${QTB:-yes}" = "yes" ] && qtb="-DPKG_QTB=yes "
reaction="" ; [ "${REACTION:-yes}" = "yes" ] && reaction="-DPKG_REACTION=yes "
reaxff="" ; [ "${REAXFF:-yes}" = "yes" ] && reaxff="-DPKG_REAXFF=yes "
replica="" ; [ "${REPLICA:-yes}" = "yes" ] && replica="-DPKG_REPLICA=yes "
rigid="" ; [ "${RIGID:-yes}" = "yes" ] && rigid="-DPKG_RIGID=yes "
shock="" ; [ "${SHOCK:-yes}" = "yes" ] && shock="-DPKG_SHOCK=yes "
smtbq="" ; [ "${SMTBQ:-yes}" = "yes" ] && smtbq="-DPKG_SMTBQ=yes "
sph="" ; [ "${SPH:-yes}" = "yes" ] && sph="-DPKG_SPH=yes "
spin="" ; [ "${SPIN:-yes}" = "yes" ] && spin="-DPKG_SPIN=yes "
srd="" ; [ "${SRD:-yes}" = "yes" ] && srd="-DPKG_SRD=yes "
tally="" ; [ "${TALLY:-yes}" = "yes" ] && tally="-DPKG_TALLY=yes "
uef="" ; [ "${UEF:-yes}" = "yes" ] && uef="-DPKG_UEF=yes "
yaff="" ; [ "${YAFF:-yes}" = "yes" ] && yaff="-DPKG_YAFF=yes "

# If OpenBLAS is installed ELECTRODE will be enabled using the system LAPACK
# otherwise a bundled linear algebra is used. To force the use of internal
# linear algebra edit the CMake flag setting "-DUSE_INTERNAL_LINALG=yes "
if [ "$electrode" = "-DPKG_ELECTRODE=yes " ]; then
 if pkg-config --exists openblas;  then 
   electrode=$electrode"-DUSE_INTERNAL_LINALG=no "
 fi
fi

if [ "${PYTHON:-yes}" = "yes" ]; then
  python="-DPKG_PYTHON=yes "
  if [ -d /usr/doc/python3-numpy* ]; then
   mliap="" ; [ "${MLIAP:-yes}" = "yes" ] && mliap="-DPKG_ML-IAP=yes -DMLIAP_ENABLE_PYTHON=autodetected "
  else
   mliap=""
  fi
else
  python=""
  mliap=""
fi

# The GPU module requires some basic settings that may be customized through environment
# variables. For advanced options requiring specific hardware configurations (GPU) see the
# documentation in lammps.org
# This module causes many issues depending on the hardware/software configuration (build 
# failure or segmentation fault) that require additional settings to be solved, so it is
# disabled by default. 
if [ "${GPU:-no}" = "yes" ]; then
  # by default the GPU module is enabled using bundled OpenCL ICD loader library/headers
  # but users may prefer the local opencl installed in the system
  opencl_loader="yes" ; [ "${STATIC_OCL:-no}" = "no" ] && opencl_loader="no"
  gpu="-DPKG_GPU=yes -DGPU_API=opencl -DUSE_STATIC_OPENCL_LOADER=${opencl_loader} "
else
  opencl_loader="" 
  gpu=""
fi     

# All required cmake flags related to modules are included in a single global variable
modules=$amoeba$asphere$atc$awpmd$bocs$body$bpm$brownian$cgdna$cgspica$class2$colloid\
$colvars$compress$coreshell$dielectric$diffraction$dipole$dpdbasic$dpdmeso$dpdreact\
$dpdsmooth$drude$eff$electrode$extracompute$extradump$extrafix$extramolecule$extrapair\
$fep$gpu$granular$intel$interlayer$kspace$lepton$machdyn$manifold\
$manybody$mc$meam$mgpt$misc$mliap$mlpod$mlrann$mlsnap$mofff\
$molecule$opt$orient$peri$phonon$plugin$poems$ptm$python$qeq$qtb\
$reaction$reaxff$replica$rigid$shock$smtbq$sph$spin$srd$tally$uef$yaff

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i586" -o "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=$ARCH -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" -o "$ARCH" = "aarch64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi
SLKCFLAGS+=" -DNDEBUG"

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf ${SRCNAM}_${SRCVERSION}
tar xvf $CWD/${SRCNAM}_${SRCVERSION}.tar.gz --no-same-owner
cd ${SRCNAM}_${SRCVERSION}

# Detect if some dependencies are installed or extrafiles downloaded. 
scafacos=""
mdi=""
mlpace=""
mlhdnnp=""
mesont=""
latboltz=""
openmp=""
kokkos=""
plumed=""
netcdf=""
h5md=""
scafacoswarn=""
# External ScaFaCos must be installed in the system
if pkg-config --exists scafacos;  then 
 scafacos="" ; [ "${SCAFACOS:-yes}" = "yes" ] \
               && scafacos="-DPKG_SCAFACOS=yes -DDOWNLOAD_SCAFACOS=OFF "
 if [ "$CURRENT" = "YES" ]; then
   scafacoswarn=YES 
 fi
else
 echo "Package scafacos not installed"
 echo "     > Module SCAFACOS will be disabled"
fi
# External MDI_Library must be installed in the system
if [ -f /usr/include/mdi.h ]; then
 mdi="" ; [ "${MDI:-yes}" = "yes" ] && mdi="-DPKG_MDI=yes -DDOWNLOAD_MDI=OFF "
else
 echo "Package MDI_Library not installed"
 echo "     > Module MDI will be disabled"
fi
# lammps-user-pace must be downloaded in $CWD
PACETARBALL=$CWD/lammps-user-pace-$PACEVERSION.tar.gz
if [ -f $PACETARBALL ]; then
  mlpace="" ; [ "${MLPACE:-yes}" = "yes" ] && mlpace="-DPKG_ML-PACE=yes "
else
 echo "Extra source lammps-user-pace not downloaded"
 echo "     > Module ML-PACE will be disabled"
fi
# N2P2 must be must be installed in the system
if [ -f /usr/bin/nnp-atomenv ]; then
 mlhdnnp="" ; [ "${MLHDNNP:-yes}" = "yes" ] && \
    mlhdnnp="-DPKG_ML-HDNNP=yes -DN2P2_DIR=/usr -DN2P2_INCLUDE_DIR=/usr/include/n2p2 \
             -DN2P2_CMAKE_EXTRA=/usr/share/lib/hdnnp/n2p2/lammps-extra.cmake -DDOWNLOAD_N2P2=OFF "
else
 echo "Package n2p2 not installed"
 echo "     > Module ML-HNDNNP will be disabled"
fi
# C_10_10.mesocnt extrafile data must be downloaded in $CWD
MESOCNT=$CWD/C_10_10.mesocnt
if [ -f $MESOCNT ]; then
 mesont="" ; [ "${MESONT:-yes}" = "yes" ] && mesont="-DPKG_MESONT=yes "
 cp -a $CWD/C_10_10.mesocnt ./potentials
 if [ "$molecule" = "" ]; then
   echo -e "\n\033[33mModule MESONT enabled. Since it requires also "
	echo -e "the module MOLECULE, the build of MOLECULE will be automatically enabled\033[0m\n"
	modules=$modules" -DPKG_MOLECULE=yes "
 fi
else
 echo "Extra source C_10_10.mesocnt not downloaded"
 echo "     > Module MESONT will be disabled"
fi
# External PLUMED must be installed in the system
if pkg-config --exists plumed; then
  plumed="" ; [ "${PLUMED:-yes}" = "yes" ] && plumed="-DPKG_PLUMED=yes -DDOWNLOAD_PLUMED=no "
else
 echo "Package PLUMED not installed"
 echo "     > Module PLUMED will be disabled"
fi
# External netcdf must be installed in the system
if pkg-config --exists netcdf;  then 
 netcdf="" ; [ "${NETCDF:-yes}" = "yes" ] && netcdf="-DPKG_NETCDF=yes "
else
 echo "Package netcdf not installed"
 echo "     > Module NETCDF will be disabled"
fi
# External hdf5 must be installed in the system
if [ -f /usr/bin/h5cc ]; then
 h5md="" ; [ "${H5MD:-yes}" = "yes" ] && h5md="-DPKG_H5MD=yes "
else
 echo "Package hdf5 not installed"
 echo "     > Module H5MD will be disabled"
fi

# Detect if openmpi or mpich are installed, so we can build LAMMPS with the 
# parallel computing and enable some modules
MP=""
mpi=""
if pkg-config --exists ompi;  then 
 MP="openmpi"; 
 mpi="-DBUILD_OMP=yes "
fi
if pkg-config --exists mpich;  then 
 MP="mpich"; 
 mpi="-DBUILD_MPI=yes "
fi
if [ "$MP" = "openmpi" ]; then 
 latboltz="" ; [ "${LATBOLTZ:-yes}" = "yes" ] && latboltz="-DPKG_LATBOLTZ=yes "
 openmp="" ; [ "${OPENMP:-yes}" = "yes" ] && openmp="-DPKG_OPENMP=yes "
 # Build of KOKKOS significantly extends the build times and absorbs many
 # resources so it can be enabled only in 64-bit architectures
 if [ "$ARCH" = "x86_64" ]; then
   kokkos="" ; [ "${KOKKOS:-yes}" = "yes" ] \
       && kokkos="-DPKG_KOKKOS=yes -DKokkos_ARCH_NATIVE=yes -DKokkos_ENABLE_OPENMP=yes "
 else 
   echo "Architecture 64-bit not detected"
   echo "     > Module KOKKOS will be disabled"
 fi
fi

if [ "$MP" = "mpich" ]; then
 latboltz="" ; [ "${LATBOLTZ:-yes}" = "yes" ] && latboltz="-DPKG_LATBOLTZ=yes "
 echo "Package openmpi or openmpi4 not installed"
 echo "      > Modules OPENMP and KOKKOS will be disabled"
fi

if [ "$MP" = "" ]; then
  echo "No API supporting MPI (mpich or openmpi) installed"
  echo "     > Modules OPENMP LABOLTZ and KOKKOS will be disabled"
  echo "       Other modules may work not optimally"
fi

modules=$modules$scafacos$mdi$mlpace$mlhdnnp$latboltz$kokkos$openmp$mpi\
$plumed$netcdf$h5md

# Prepare directories to move the extrafiles needed to build some modules
mkdir -p cmake/build

if [ "$opencl_loader" = "yes" ]; then
   if [ -f $CWD/opencl-loader-$OCLLVERSION.tar.gz ]; then
     mkdir -p cmake/build/_deps
     cp -a $CWD/opencl-loader-$OCLLVERSION.tar.gz cmake/build/_deps
   else
     echo "WARNING! Extra source opencl-loader not downloaded"
     echo "Please download it before launch the script with these settings"
     echo "The script will be stopped"
     exit 1
   fi     
fi

if [ "$mlpace" != "" ]; then
   cp -a $CWD/lammps-user-pace-$PACEVERSION.tar.gz cmake/build/libpace.tar.gz
fi

if [ "$CURRENT" = "YES" ]; then
 if [ -f $CWD/eigen-3.4.0.tar.gz ]; then
   mkdir -p cmake/build/Eigen3_build-prefix/src/
   cp -a $CWD/eigen-3.4.0.tar.gz cmake/build/Eigen3_build-prefix/src/eigen-3.4.0.tar.gz
   cmake_policy="-DCMAKE_POLICY_DEFAULT_CMP0218=OLD "
   echo "Slackware -current detected"
   echo "     > LAMMPS will use a bundle Eigen3 (v. 3.4.0)"
   if [ "$scafacoswarn" = "YES" ]; then
       echo "Package scafacos installed in the system but the build"
       echo "of LAMMPS against this dependency will fail in -current"
       echo "     > Module SCAFACOS will be disabled"
   fi
 else
   echo "WARNING! Extra source eigen-3.4.0 not downloaded"
   echo "Build of LAMMPS does not work with the Eigen3 of -current"
   echo "Please download eigen-3.4.0 before launch the script"
   echo "The script will be stopped"
   exit 1
 fi 
fi

echo -e "\nFLAGS FOR MODULES ENABLED:\n "$modules"\n"

find . ! -type l    -a \( \
  \(     -perm /111 -a ! -perm 755 -a -exec chmod -f 755 {} + \) -o \
  \(   ! -perm /111 -a ! -perm 644 -a -exec chmod -f 644 {} + \) \)

sed -i cmake/CMakeLists.txt -e "s:SET CMP0109 OLD:SET CMP0109 NEW:g"  
sed -i cmake/CMakeLists.txt -e "s:MPI QUIET COMPONENTS CXX:MPI COMPONENTS CXX:g"

echo $LIBDIRSUFFIX
# The Source has not a CMakeLists.txt file in the root directory we 
# need to change in the cmake directory
cd cmake
cd build
  cmake \
    -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_LIBDIR=/usr/lib$LIBDIRSUFFIX \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_SHARED_LIBS=ON \
    $cmake_policy \
    $modules \
    ..
  make VERBOSE=1 $NUMJOBS
  make install/strip  DESTDIR=$PKG
cd ..

#Since the build installs man in /usr/share we move the directory in /usr
mv -v $PKG/usr/share/man $PKG/usr
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done

#Since the build installs etc as subfolder of /usr (?), we move it in the root directory
mv -v $PKG/usr/etc $PKG

PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION
mkdir -p $PKGDOC
cd $TMP/${SRCNAM}_${SRCVERSION}
cp -a \
  LICENSE README \
  $PKGDOC
cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
