summaryrefslogtreecommitdiff
path: root/source/xap/MPlayer/MPlayer.SlackBuild
blob: f7665207497592f70ad33fdd4fa5b0c925861ffd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
#!/bin/sh
# $Id: MPlayer.SlackBuild,v 1.27 2012/07/01 13:07:08 root Exp root $
# Copyright 2006, 2007, 2008, 2010, 2011, 2012  Eric Hameleers, Eindhoven, NL
# Copyright 2013  Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
#   Permission to use, copy, modify, and distribute this software for
#   any purpose with or without fee is hereby granted, provided that
#   the above copyright notice and this permission notice appear in all
#   copies.
#
#   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED 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 AUTHORS AND COPYRIGHT HOLDERS AND THEIR
#   CONTRIBUTORS 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.
# -----------------------------------------------------------------------------
#
# Slackware SlackBuild script 
# ===========================
# By:        Eric Hameleers <alien@slackware.com>
# For:       MPlayer
# Descr:     a movie player for LINUX
# URL:       http://www.mplayerhq.hu/
# Needs:     
# Changelog:
# 1.0rc1-1:   05/Nov/2006 by Eric Hameleers <alien@slackware.com>
#            * Initial build.
# 1.0rc1-2:   07/Nov/2006 by Eric Hameleers <alien@slackware.com>
#            * Removed MPlayer's internal libdvdcss code from the build, so
#              that MPlayer no longer plays encrypted DVD's by default (and the
#              package is now safe to upload to public repositories).
#              If it is allowed in your country, you can either install
#              libdvdcss (which is picked up automatically by MPlayer), or
#              rebuild MPlayer yourself using this SlackBuild - and set the
#              variable REMOVECSS="no" first (see further down).
#              Use this commandline if you can't or won't modify the script:
#                REMOVECSS="no" ./MPlayer.SlackBuild
# 1.0rc1-3:   08/Nov/2006 by Eric Hameleers <alien@slackware.com>
#             * Install the mplayer.conf into correct location '/etc/mplayer/'
# 1.0rc1-4:   15/mar/2007 by Eric Hameleers <alien@slackware.com>
#             * Differentiate between versions of X11 (modular X has another
#               install-prefix); update default skin; enable mplayer menu;
#               add security fix
# 1.0rc1-5:   07/jun/2007 by Eric Hameleers <alien@slackware.com>
#             * Add security fix.
# 1.0rc2-1:   09/oct/2007 by Eric Hameleers <alien@slackware.com>
#             * New version.
# 1.0rc2-2:   01/feb/2008 by Eric Hameleers <alien@slackware.com>
#             * Apply 4 security fixes.
# 1.0rc2-3:   10/mar/2008 by Eric Hameleers <alien@slackware.com>
#             * Apply a patch that allows compilation against the ivtv driver
#               in the 2.6.24.x kernels.
# r28148-1:   14/dec/2008 by Eric Hameleers <alien@slackware.com>
#             * Build SVN snapshot - remove support for *all* patented or
#               questionable software if "USE_PATENTS" is set to "NO" - think
#               of DECSS dvd decryption code, and mp3/aac/amr audio encoders.
# r28929-1:   10/mar/2009 by Eric Hameleers <alien@slackware.com>
#             * Update.
# r29301-1:   12/may/2009 by Eric Hameleers <alien@slackware.com>
#             * Update.
# r29301-1:   12/may/2009 by Eric Hameleers <alien@slackware.com>
#             * Update.
# 20100926-1: 26/sep/2010 by Eric Hameleers <alien@slackware.com>
#             * Slackware has MPlayer now of course, but it does not hurt
#               to have a full-featured binary package available. The 1.0rc3
#               was released recently but I prefer to build a snapshot.
# 20110624-1: 24/jun/2011 by Eric Hameleers <alien@slackware.com>
#             * Provide an up-to-date snapshot to be used in conjunction
#               with UMPlayer (a MPlayer GUI). New MPlayer source requires
#               a separate ffmpeg download.
# 20120514-1: 14/may/2012 by volkerdi@slackware.com
#             * Update.
# 1.1_20120701-1: 28/jun/2012 by alien@slackware.com
#             * Update to the 1.1 branch (essentially this is MPlayer-1.1 but
#               I like to check it out of SVN).
# 1.1_20130819-1: 19/aug/2013 by volkerdi@slackware.com
#             * Update to the latest 1.1 branch, and the same ffmpeg that was
#               shipped with the 1.1.1 tarball.  The official 1.1.1 release
#               did not start a new repo branch, so this is the latest.
# 
# Run 'sh MPlayer.SlackBuild' to build a Slackware package.
# The package (.txz) plus descriptive .txt file are created in /tmp .
# Install using 'installpkg'. 
#
# -----------------------------------------------------------------------------

# Set initial variables:

PRGNAM=MPlayer
VERSION=${VERSION:-20130819}
BRANCH=${BRANCH:-1.1}        # leave empty if you want to build MPlayer trunk
FFMPEG=${FFMPEG:-20130505}
BUILD=${BUILD:-2}
TAG=${TAG:-}

# Show the branch version in the package name if we build from a branch:
[ -n "$BRANCH" ] && PKGVERSION=${BRANCH}_${VERSION} || PKGVERSION=${VERSION}

DOCS="AUTHORS Changelog Copyright LICENSE README VERSION DOCS/HTML DOCS/tech"

# MPlayer repository characteristics:
MPURI="svn://svn.mplayerhq.hu/mplayer/"
if [ -n "$BRANCH" ]; then
  MPBRANCH="branches/$BRANCH"
else
  MPBRANCH="trunk"
fi

FFURI=git://git.videolan.org/ffmpeg.git

DEFSKIN=${DEFSKIN:-"Blue"}  # Download more skins at the following url:
SKINVER=${SKINVER:-"1.8"}   # http://www.mplayerhq.hu/design7/dload.html

# Available languages: all cs de en es fr hu it pl ru zh_CN
LANGUAGES="en,de,es,fr"

# Automatically determine the architecture we're building on:
MARCH=$( uname -m )
if [ -z "$ARCH" ]; then
  case "$MARCH" in
    i?86)    export ARCH=i486 ;;
    armv7hl) export ARCH=$MARCH ;;
    arm*)    export ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
    *)       export ARCH=$MARCH ;;
  esac
fi

if [ "$ARCH" = "x86_64" ]; then
  LIBDIRSUFFIX="64"
  # --enable-runtime-cpudetection is supported only for x86, x86_64, and PPC
  EXTRACONFIGUREOPTIONS="--enable-runtime-cpudetection"
elif [ "$ARCH" = "i486" -o \
       "$ARCH" = "i586" -o \
       "$ARCH" = "i686" ]; then
  LIBDIRSUFFIX=""
  EXTRACONFIGUREOPTIONS="--enable-runtime-cpudetection"
else
  LIBDIRSUFFIX=""
  EXTRACONFIGUREOPTIONS=""
fi

# Where the WIN32 codecs are expectedfor instance
CODECSDIR=/usr/lib${LIBDIRSUFFIX}/codecs

# ---------------------------------------------------------------------------
# -- PATENT ALERT! --
# MPlayer source contains an internal copy of 'libdvdcss' for reading DVD's.
# This is considered illegal software in some countries.
# Also, MPLayer can be built with MP3 (lame) and AMR audio encoders
# (needed for FLV and .3GP videos) but these libraries are 'contaminated'
# with patents from Fraunhofer and GGP.
# Also, the AAC encoder has patent issues.
# You can build these patended algorithms into ffmpeg, and if you are an
# ordinary end user, no one will bother you for using them.
# For the binaries based on this SlackBuild that I distribute, it is a
# different story. I am not allowed to distribute binary packages that
# incorporate patented code. So here you go. My Slackware package was
# built with "USE_PATENTS=NO" i.e. without using
# the lame mp3, faac, AMR and dvdcss libraries.
# This also means that this creates a version of MPlayer that is unable
# to play encrypted DVD's (which is most DVD's on the market). If it is
# allowed in your country to use libdvdcss, this is not a big problem though.
# Install a libdvdcss package and it will be picked up automatically by
# MPlayer's internal libdvdread library, so that MPlayer will again be able
# to play encrypted DVD's.
# ---------------------------------------------------------------------------
USE_PATENTS=${USE_PATENTS:-"NO"}

# MPlayer will try to use one of the TrueType fonts present on the target
# system for it's On Screen Display (OSD) font.
# Slackware 11.0 ships with the Vera and DejaVu fonts, you may want to add
# more fonts to this list. The first font found will be used by creating a
# symbolic link "/usr/share/mplayer/subfont.ttf" to it.
# The use of bitmapped fonts is considered deprecated, but you can still use
# those if you want. Read http://www.mplayerhq.hu/DOCS/HTML/en/fonts-osd.html
# if you want to know more about OSD font configuration.
OSDFONTS="LiberationSans-Regular.ttf \
          Arialuni.ttf arial.ttf \
          DejaVuSans.ttf Vera.ttf"

# We will work with a stripped-down source tarball, not containing libdvdcss:
[ "$USE_PATENTS" != "YES" ] && EXTRA="_nolibdvdcss" || EXTRA=""

# Where do we look for sources?
SRCDIR=$(cd $(dirname $0); pwd)

SOURCE[0]="$SRCDIR/${PRGNAM}${EXTRA}-${VERSION}.tar.xz"
SRCURL[0]=""

# The default skin to use (we need to add at least one)
SOURCE[1]="$SRCDIR/${DEFSKIN}-${SKINVER}.tar.bz2"
SRCURL[1]="http://www.mplayerhq.hu/MPlayer/skins/${DEFSKIN}-${SKINVER}.tar.bz2"

# Ffmpeg needs to be checked out separately now:
SOURCE[2]="$SRCDIR/ffmpeg-${FFMPEG}.tar.xz"
SRCURL[2]=""

# Use the src_checkout() function if no downloadable tarball exists.
# This function checks out sources from SVN/CVS and creates a tarball of them.
src_checkout() {
  # Param #1 : index in the SOURCE[] array.
  # Param #2 : full path to where SOURCE[$1] tarball should be created.
  # Determine the tarball extension:
  PEXT=$(echo "${2}" | sed -r -e 's/.*[^.].(tar.xz|tar.gz|tar.bz2|tgz).*/\1/')
  case "$PEXT" in
    "tar.xz") TARCOMP="J" ;;
    "tar.gz") TARCOMP="z" ;;
    "tgz") TARCOMP="z" ;;
    "tar.bz2") TARCOMP="j" ;;
    *) echo "Archive can only have extension 'tar.xz', '.tar.gz' '.tar.bz2' or '.tgz'" ; exit 1 ;;
  esac
  case ${1} in
  0) # mplayer
     if [ "$(echo ${VERSION}|cut -c1)" == 'r' ]; then # revision instead of date
       echo "Only supported VERSION is a date - yyyymmdd - or 'HEAD'"
     else
       REV="{${VERSION}}"
     fi
     mkdir MPlayer-${VERSION} \
       && cd MPlayer-${VERSION} \
       && svn checkout --revision $REV ${MPURI}/${MPBRANCH} . \
       && svn propget svn:externals | sed -e 's/[[:space:]].*$//g' | xargs svn up --revision $REV \
       && find . -type d -name '.svn' -depth | xargs rm -rf \
       && ([ "$USE_PATENTS" != "YES" ] && rm -rf libdvdcss || true) \
       && chown -R root:root . \
       && cd .. \
       && tar -${TARCOMP}cf ${2} MPlayer-${VERSION}
     rm -rf MPlayer-${VERSION}
     ;;
  2) # ffmpeg-${FFMPEG}
     mkdir ffmpeg_temp_checkout_$$ \
       && cd ffmpeg_temp_checkout_$$
       if [ "$FFMPEG" = "HEAD" ]; then
         # Checkout without downloading version history (fast!):
         echo "Checking out HEAD from '$FFURI':"
         git clone --depth=1 ${FFURI} ffmpeg
       else
         # Checkout code from a certain branch and/or date; this will take a
         # long time because we have to clone the complete git-repository first:
         echo "Checking out branch 'master' at date $FFMPEG from '$FFURI':"
         git clone ${FFURI} ffmpeg \
         && cd ffmpeg \
         && git checkout master \
         && git checkout $(git rev-list -n 1 --before="`date -d $FFMPEG`" master) \
         && cd ..
       fi
       chown -R root:root . \
       && tar --exclude .git -${TARCOMP}cf ${2} ffmpeg
     cd ..
     rm -rf ffmpeg_temp_checkout_$$
     ;;
  *) # Do nothing
     ;;
  esac
}

# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
TMP=${TMP:-/tmp/build}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

##
## --- with a little luck, you won't have to edit below this point --- ##
##

# Exit the script on errors:
set -e
trap 'echo "$0 FAILED at line $LINENO!" | tee $OUTPUT/error-${PRGNAM}.log' ERR
# Catch unitialized variables:
set -u
P1=${1:-1}

# Create working directories:
mkdir -p $TMP/tmp-$PRGNAM # location to build the source
rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build
mkdir -p $PKG             # place for the package to be built
rm -rf $PKG/*             # erase old package's contents
mkdir -p $OUTPUT          # place for the package to be saved

# Source file availability:
for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
  if ! [ -f ${SOURCE[$i]} ]; then
    echo "Source '$(basename ${SOURCE[$i]})' not available yet..."
    # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
    [ -w "$SRCDIR" ] || SOURCE[$i]="$OUTPUT/$(basename ${SOURCE[$i]})"
    if ! [ "x${SRCURL[$i]}" == "x" ]; then
      echo "Will download file to $(dirname $SOURCE[$i])"
      wget -nv -T 20 -O "${SOURCE[$i]}" "${SRCURL[$i]}" || true
      if [ $? -ne 0 -o ! -s "${SOURCE[$i]}" ]; then
        echo "Downloading '$(basename ${SOURCE[$i]})' failed.. aborting the build."
        mv -f "${SOURCE[$i]}" "${SOURCE[$i]}".FAIL
        exit 1
      fi
    else
      # Try if we have a SVN/CVS download routine for ${SOURCE[$i]}
      echo "Will checkout sources to $(dirname $SOURCE[$i])"
      src_checkout $i "${SOURCE[$i]}" 2>&1 > $OUTPUT/checkout-$(basename ${SOURCE[$i]}).log
    fi
    if [ ! -f "${SOURCE[$i]}" -o ! -s "${SOURCE[$i]}" ]; then
      echo "File '$(basename ${SOURCE[$i]})' not available.. aborting the build."
      exit 1
    fi
  fi
done

if [ "$P1" == "--download" ]; then
  echo "Download complete."
  exit 0
fi

# --- PACKAGE BUILDING ---

echo "++"
echo "|| $PRGNAM-$VERSION"
echo "++"

# Warn about libdvdread requirement:
if [ "$USE_PATENTS" != "YES" ]; then
  cat <<"EOT"
**
** Removing internal DECSS library.
** If you want to play encrypted DVD's you need to install libdvdcss separately.
**
** If you do not want to remove libdvdcss, then
** edit this SlackBuild script and change the line:
** USE_PATENTS=${USE_PATENTS:-"NO"}
** to:
** USE_PATENTS="YES"
**
EOT
  sleep 2
fi

cd $TMP/tmp-$PRGNAM
echo "Extracting the source archive(s) for $PRGNAM..."
tar -xvf ${SOURCE[0]}
# Extract the ffmpeg source inside the MPlayer directory:
( cd ${PRGNAM}-${VERSION} && tar -xvf ${SOURCE[2]} )

chown -R root:root *
chmod -R u+w,go+r-w,a+X-s *
cd ${PRGNAM}-${VERSION}

# Apply patch to fix subtitles:
zcat $SRCDIR/subreader-fix-srt-parsing.patch.gz | patch -p1 --verbose || exit 1

# Determine what X we're running (the modular X returns the prefix
# in the next command, while older versions stay silent):
XPREF=$(pkg-config --variable=prefix x11) || true
[ "$XPREF" == "" ] && XPREF='/usr/X11R6'

# Remove support for patent encumbered and possibly illegal code:
if [ "$USE_PATENTS" != "YES" ]; then
  DO_PATENTED="--disable-libdvdcss-internal \
               --disable-mp3lame --disable-mp3lame-lavc \
               --disable-libopencore_amrnb \
               --disable-libopencore_amrwb"
else
  DO_PATENTED=""
fi

echo Building ...
# MPlayer wants to automatically determine compiler flags,
# so we don't provide CFLAGS.
./configure \
  --prefix=/usr \
  --mandir=/usr/man \
  --confdir=/etc/mplayer \
  --enable-gui \
  --enable-menu \
  --disable-arts \
  --disable-bitmap-font \
  --codecsdir=${CODECSDIR} \
  --language="${LANGUAGES}" \
  ${EXTRACONFIGUREOPTIONS} \
  ${DO_PATENTED} \
  2>&1 | tee $OUTPUT/configure-${PRGNAM}.log
# So that MPlayer does not report "UNKNOWN" as it's version:
if [ ! -f VERSION ]; then
  echo $VERSION > VERSION
fi
make 2>&1 | tee $OUTPUT/make-${PRGNAM}.log
make DESTDIR=$PKG install 2>&1 |tee $OUTPUT/install-${PRGNAM}.log

# Build the html documentation (not all languages are available):
if [ "$LANGUAGES" = "all" ]; then
  # make html-chunked
  make html-single
else
  for i in $(echo $LANGUAGES | tr , ' ') ; do 
    # make html-chunked-$i ;
    make html-single-$i ;
  done
fi

# Prepare the configfile:
mkdir -p $PKG/etc/mplayer
cp etc/example.conf $PKG/etc/mplayer/mplayer.conf.new

# Install our default skin:
cd $PKG/usr/share/mplayer/skins
tar -xvf ${SOURCE[1]}
chown -R root:root *
chmod -R u+w,go+r-w,a+X-s *
ln -s ${DEFSKIN} default
cd -

# Add this to the doinst.sh:
mkdir -p $PKG/install
cat <<EOINS >> $PKG/install/doinst.sh
# Handle the incoming configuration files:
config() {
  for infile in \$1; do
    NEW="\$infile"
    OLD="\`dirname \$NEW\`/\`basename \$NEW .new\`"
    # If there's no config file by that name, mv it over:
    if [ ! -r \$OLD ]; then
      mv \$NEW \$OLD
    elif [ "\`cat \$OLD | md5sum\`" = "\`cat \$NEW | md5sum\`" ]; then
      # toss the redundant copy
      rm \$NEW
    fi
    # Otherwise, we leave the .new copy for the admin to consider...
  done
}

# Installing a bitmap font is considered deprecated; use a TTF font instead.
# We try to link to an installed TTF font at install time.
# Configure a default TrueType font to use for the OSD :
if [ ! -f usr/share/mplayer/subfont.ttf ]; then
  for font in ${OSDFONTS}; do
    if [ -f .${XPREF}/lib${LIBDIRSUFFIX}/X11/fonts/TTF/\${font} ]; then
      ( cd usr/share/mplayer/
        ln -sf ${XPREF}/lib${LIBDIRSUFFIX}/X11/fonts/TTF/\${font} subfont.ttf
      )
      break
    fi
  done
fi

# Prepare the new configuration file
config etc/mplayer/mplayer.conf.new

# Update the desktop database:
if [ -x usr/bin/update-desktop-database ]; then
  chroot . /usr/bin/update-desktop-database usr/share/applications 1> /dev/null 2> /dev/null
fi

# Update hicolor theme cache:
if [ -e usr/share/icons/hicolor/icon-theme.cache ]; then
  if [ -x usr/bin/gtk-update-icon-cache ]; then
    chroot . /usr/bin/gtk-update-icon-cache /usr/share/icons/hicolor >/dev/null 2>&1
  fi
fi

# Update the mime database:
if [ -x usr/bin/update-mime-database ]; then
  chroot . /usr/bin/update-mime-database usr/share/mime >/dev/null 2>&1
fi

EOINS

# Add documentation:
mkdir -p $PKG/usr/doc/$PRGNAM-$PKGVERSION
cp -a $DOCS $PKG/usr/doc/$PRGNAM-$PKGVERSION || true
cp -a $SRCDIR/$(basename $0) $PKG/usr/doc/$PRGNAM-$PKGVERSION/$PRGNAM.SlackBuild
mv $PKG/usr/doc/$PRGNAM-$PKGVERSION/HTML $PKG/usr/doc/$PRGNAM-$PKGVERSION/html
# Save a sample of all configuration files:
for i in etc/*.conf ; do
  cp $i $PKG/usr/doc/$PRGNAM-$PKGVERSION/$(basename $i)-sample
done
# Save a transcript of all configured options for this specific build:
if [ -n $OUTPUT/configure-${PRGNAM}.log ]; then
  cat $OUTPUT/configure-${PRGNAM}.log \
    | sed -n "/^Config files successfully generated/,/^'config.h' and 'config.mak' contain your configuration options./p" \
    > $PKG/usr/doc/$PRGNAM-$PKGVERSION/${PRGNAM}.configuration
fi
find $PKG/usr/doc -type f -exec chmod 644 {} \;

# Compress the man page(s):
if [ -d $PKG/usr/man ]; then
  find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \;
  for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
fi

# Strip binaries:
( find $PKG | xargs file | grep -e "executable" -e "shared object" \
  | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null )

# Add a package description:
mkdir -p $PKG/install
cat $SRCDIR/slack-desc > $PKG/install/slack-desc
if [ -f $SRCDIR/doinst.sh ]; then
  cat $SRCDIR/doinst.sh >> $PKG/install/doinst.sh
fi

# Build the package:
cd $PKG
makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${PKGVERSION}-${ARCH}-${BUILD}${TAG}.txz 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
cd $OUTPUT
md5sum ${PRGNAM}-${PKGVERSION}-${ARCH}-${BUILD}${TAG}.txz > ${PRGNAM}-${PKGVERSION}-${ARCH}-${BUILD}${TAG}.txz.md5
cd -
cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${PKGVERSION}-${ARCH}-${BUILD}${TAG}.txt

# Warn about libdvdcss requirement (again):
if [ "$USE_PATENTS" != "YES" ]; then
  cat <<"EOT"
**
** Internal DECSS library was not built.
** If you want to play encrypted DVD's you need to install libdvdcss separately.
**
** If you do not care about patent issues,
** and want to keep support for internal libdvdcss, then
** edit this SlackBuild script and change the line:
** USE_PATENTS=${USE_PATENTS:-"NO"}
** to:
** USE_PATENTS="YES"
**
EOT

fi