source: npl/overig/libsodium/libsodium.SlackBuild.orig @ f33f781

Last change on this file since f33f781 was f33f781, checked in by Edwin Eefting <edwin@datux.nl>, 3 years ago

php7 and deps

  • Property mode set to 100755
File size: 4.4 KB
Line 
1#!/bin/bash
2
3# Copyright 2017, 2018  Patrick J. Volkerding, Sebeka, Minnesota, USA
4# All rights reserved.
5#
6# Redistribution and use of this script, with or without modification, is
7# permitted provided that the following conditions are met:
8#
9# 1. Redistributions of this script must retain the above copyright
10#    notice, this list of conditions and the following disclaimer.
11#
12#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
13#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
15#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
16#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
18#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
19#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
20#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
21#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22
23cd $(dirname $0) ; CWD=$(pwd)
24
25PKGNAM=libsodium
26VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
27BUILD=${BUILD:-3}
28
29# Automatically determine the architecture we're building on:
30if [ -z "$ARCH" ]; then
31  case "$(uname -m)" in
32    i?86) ARCH=i586 ;;
33    arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;;
34    # Unless $ARCH is already set, use uname -m for all other archs:
35    *) ARCH=$(uname -m) ;;
36  esac
37  export ARCH
38fi
39
40# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
41# the name of the created package would be, and then exit. This information
42# could be useful to other scripts.
43if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
44  echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz"
45  exit 0
46fi
47
48NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}
49
50if [ "$ARCH" = "i586" ]; then
51  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
52  LIBDIRSUFFIX=""
53elif [ "$ARCH" = "i686" ]; then
54  SLKCFLAGS="-O2 -march=i686"
55  LIBDIRSUFFIX=""
56elif [ "$ARCH" = "s390" ]; then
57  SLKCFLAGS="-O2"
58  LIBDIRSUFFIX=""
59elif [ "$ARCH" = "x86_64" ]; then
60  SLKCFLAGS="-O2 -fPIC"
61  LIBDIRSUFFIX="64"
62elif [ "$ARCH" = "armv7hl" ]; then
63  SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16"
64  LIBDIRSUFFIX=""
65else
66  SLKCFLAGS="-O2"
67  LIBDIRSUFFIX=""
68fi
69
70TMP=${TMP:-/tmp}
71PKG=$TMP/package-$PKGNAM
72
73rm -rf $PKG
74mkdir -p $TMP $PKG
75
76cd $TMP
77rm -rf $PKGNAM-$VERSION
78tar xvf $CWD/$PKGNAM-$VERSION.tar.?z || exit 1
79cd $PKGNAM-$VERSION || exit 1
80
81chown -R root:root .
82find . \
83  \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
84  -exec chmod 755 {} \+ -o \
85  \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
86  -exec chmod 644 {} \+
87
88# Configure:
89CFLAGS="$SLKCFLAGS" \
90./configure \
91  --prefix=/usr \
92  --sysconfdir=/etc \
93  --libdir=/usr/lib${LIBDIRSUFFIX} \
94  --mandir=/usr/man \
95  --infodir=/usr/info \
96  --disable-static \
97  --build=$ARCH-slackware-linux || exit 1
98
99# Build and install:
100make $NUMJOBS || make || exit 1
101make install DESTDIR=$PKG || exit 1
102
103# Don't ship .la files:
104rm -f $PKG/usr/lib${LIBDIRSUFFIX}/*.la
105
106# Strip binaries:
107( cd $PKG
108  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
109  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
110) || true
111
112# Add a documentation directory:
113mkdir -p $PKG/usr/doc/${PKGNAM}-$VERSION
114cp -a \
115  AUTHORS ChangeLog COPYING* LICENSE* NEWS README* THANKS TODO \
116  $PKG/usr/doc/${PKGNAM}-$VERSION || true
117
118# Compress and link manpages, if any:
119if [ -d $PKG/usr/man ]; then
120  ( cd $PKG/usr/man
121    for manpagedir in $(find . -type d -name "man*") ; do
122      ( cd $manpagedir
123        for eachpage in $( find . -type l -maxdepth 1 | grep -v '\.gz$') ; do
124          ln -s $( readlink $eachpage ).gz $eachpage.gz
125          rm $eachpage
126        done
127        gzip -9 *.?
128      )
129    done
130  )
131fi
132
133# If there's a ChangeLog, installing at least part of the recent history
134# is useful, but don't let it get totally out of control:
135if [ -r ChangeLog ]; then
136  DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION)
137  cat ChangeLog | head -n 2000 > $DOCSDIR/ChangeLog
138  touch -r ChangeLog $DOCSDIR/ChangeLog
139fi
140
141mkdir -p $PKG/install
142cat $CWD/slack-desc > $PKG/install/slack-desc
143
144cd $PKG
145/sbin/makepkg -l y -c n $TMP/$PKGNAM-$VERSION-$ARCH-$BUILD.txz
146
Note: See TracBrowser for help on using the repository browser.