1 | #!/bin/sh |
---|
2 | # $Id: yasm.SlackBuild,v 1.7 2009/05/12 20:24:31 root Exp root $ |
---|
3 | # Copyright (c) 2008 Eric Hameleers <alien@slackware.com> |
---|
4 | # Copyright 2010 Patrick Volkerding, Sebeka, MN, USA |
---|
5 | # All rights reserved. |
---|
6 | # |
---|
7 | # Permission to use, copy, modify, and distribute this software for |
---|
8 | # any purpose with or without fee is hereby granted, provided that |
---|
9 | # the above copyright notice and this permission notice appear in all |
---|
10 | # copies. |
---|
11 | # |
---|
12 | # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
---|
13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
---|
15 | # IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR |
---|
16 | # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
17 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
---|
18 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
---|
19 | # USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
---|
20 | # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
---|
21 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
---|
22 | # OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
---|
23 | # SUCH DAMAGE. |
---|
24 | # ----------------------------------------------------------------------------- |
---|
25 | # |
---|
26 | # Slackware SlackBuild script |
---|
27 | # =========================== |
---|
28 | # By: Eric Hameleers <alien@slackware.com> |
---|
29 | # For: yasm |
---|
30 | # Descr: complete rewrite of the NASM assembler |
---|
31 | # URL: http://www.tortall.net/projects/yasm/ |
---|
32 | # Needs: |
---|
33 | # Changelog: |
---|
34 | # 0.7.1-1: 16/Jun/2008 by Eric Hameleers <alien@slackware.com> |
---|
35 | # * Initial build. |
---|
36 | # 0.7.2-1: 08/dec/2008 by Eric Hameleers <alien@slackware.com> |
---|
37 | # * Update. |
---|
38 | # 0.8.0-1: 12/may/2009 by Eric Hameleers <alien@slackware.com> |
---|
39 | # * Update. |
---|
40 | # 1.1.0-1: 2010-08-31 by volkerdi@slackware.com |
---|
41 | # * Update. |
---|
42 | # 1.3.0-1: 2014-11-09 by Heinz Wiesinger <pprkut@slackware.com> |
---|
43 | # * Update. |
---|
44 | # |
---|
45 | # Run 'sh yasm.SlackBuild' to build a Slackware package. |
---|
46 | # The package (.txz) file is created in /tmp . |
---|
47 | # Install using 'installpkg'. |
---|
48 | # |
---|
49 | # ----------------------------------------------------------------------------- |
---|
50 | |
---|
51 | PKGNAM=yasm |
---|
52 | VERSION=${VERSION:-$(echo $PKGNAM-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
53 | BUILD=${BUILD:-1} |
---|
54 | |
---|
55 | # Automatically determine the architecture we're building on: |
---|
56 | if [ -z "$ARCH" ]; then |
---|
57 | case "$( uname -m )" in |
---|
58 | i?86) export ARCH=i486 ;; |
---|
59 | arm*) export ARCH=arm ;; |
---|
60 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
61 | *) export ARCH=$( uname -m ) ;; |
---|
62 | esac |
---|
63 | fi |
---|
64 | |
---|
65 | DOCS="ABOUT-NLS AUTHORS ChangeLog COPYING GNU_* NEWS README *.txt" |
---|
66 | |
---|
67 | # If you want to disable python bindings, set ENABLE_PYTHON to "NO". |
---|
68 | # Building python support requires Cython, which is not shipped with Slackware. |
---|
69 | ENABLE_PYTHON=${ENABLE_PYTHON:-"'NO"} |
---|
70 | |
---|
71 | # Where do we look for sources? |
---|
72 | SRCDIR=$(cd $(dirname $0); pwd) |
---|
73 | |
---|
74 | # Place to build (TMP) package (PKG) and output (OUTPUT) the program: |
---|
75 | TMP=${TMP:-/tmp/build} |
---|
76 | PKG=$TMP/package-$PKGNAM |
---|
77 | OUTPUT=${OUTPUT:-/tmp} |
---|
78 | |
---|
79 | # Exit the script on errors: |
---|
80 | set -e |
---|
81 | trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PKGNAM}.log' ERR |
---|
82 | # Catch unitialized variables: |
---|
83 | set -u |
---|
84 | P1=${1:-1} |
---|
85 | |
---|
86 | case "$ARCH" in |
---|
87 | i486) SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
88 | SLKLDFLAGS=""; LIBDIRSUFFIX="" |
---|
89 | ;; |
---|
90 | s390) SLKCFLAGS="-O2" |
---|
91 | SLKLDFLAGS=""; LIBDIRSUFFIX="" |
---|
92 | ;; |
---|
93 | powerpc) SLKCFLAGS="-O2" |
---|
94 | SLKLDFLAGS=""; LIBDIRSUFFIX="" |
---|
95 | ;; |
---|
96 | x86_64) SLKCFLAGS="-O2 -fPIC" |
---|
97 | SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64" |
---|
98 | ;; |
---|
99 | athlon-xp) SLKCFLAGS="-march=athlon-xp -O3 -pipe -fomit-frame-pointer" |
---|
100 | SLKLDFLAGS=""; LIBDIRSUFFIX="" |
---|
101 | ;; |
---|
102 | esac |
---|
103 | |
---|
104 | # Create working directories: |
---|
105 | mkdir -p $OUTPUT # place for the package to be saved |
---|
106 | mkdir -p $TMP/tmp-$PKGNAM # location to build the source |
---|
107 | mkdir -p $PKG # place for the package to be built |
---|
108 | rm -rf $PKG/* # always erase old package's contents |
---|
109 | rm -rf $TMP/tmp-$PKGNAM/* # remove the remnants of previous build |
---|
110 | |
---|
111 | # --- PACKAGE BUILDING --- |
---|
112 | |
---|
113 | echo "++" |
---|
114 | echo "|| $PKGNAM-$VERSION" |
---|
115 | echo "++" |
---|
116 | |
---|
117 | cd $TMP/tmp-$PKGNAM |
---|
118 | echo "Extracting the source archive(s) for $PKGNAM..." |
---|
119 | tar xvf $SRCDIR/$PKGNAM-$VERSION.tar.?z* |
---|
120 | cd ${PKGNAM}-${VERSION} |
---|
121 | chown -R root:root . |
---|
122 | chmod -R u+w,go+r-w,a-s . |
---|
123 | |
---|
124 | if [ "$ENABLE_PYTHON" = "YES" ]; then |
---|
125 | PYTHONSTUFF="--enable-python --enable-python-bindings" |
---|
126 | else |
---|
127 | PYTHONSTUFF="" |
---|
128 | fi |
---|
129 | |
---|
130 | echo Building ... |
---|
131 | LDFLAGS="$SLKLDFLAGS" \ |
---|
132 | CXXFLAGS="$SLKCFLAGS" \ |
---|
133 | CFLAGS="$SLKCFLAGS" \ |
---|
134 | ./configure --prefix=/usr \ |
---|
135 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
136 | --localstatedir=/var \ |
---|
137 | --sysconfdir=/etc \ |
---|
138 | --mandir=/usr/man \ |
---|
139 | ${PYTHONSTUFF} \ |
---|
140 | --program-prefix= \ |
---|
141 | --program-suffix= \ |
---|
142 | --build=$ARCH-slackware-linux |
---|
143 | |
---|
144 | make |
---|
145 | |
---|
146 | make DESTDIR=$PKG install |
---|
147 | |
---|
148 | # Add documentation: |
---|
149 | mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION |
---|
150 | cp -a $DOCS $PKG/usr/doc/$PKGNAM-$VERSION || true |
---|
151 | rm $PKG/usr/doc/$PKGNAM-$VERSION/CMakeLists.txt |
---|
152 | chown -R root:root $PKG/usr/doc/$PKGNAM-$VERSION |
---|
153 | find $PKG/usr/doc -type f -exec chmod 644 {} \; |
---|
154 | |
---|
155 | # Remove empty share directory: |
---|
156 | rmdir $PKG/usr/share || true |
---|
157 | |
---|
158 | # Compress the man page(s): |
---|
159 | if [ -d $PKG/usr/man ]; then |
---|
160 | find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \; |
---|
161 | for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done |
---|
162 | fi |
---|
163 | |
---|
164 | # Strip binaries: |
---|
165 | find $PKG | xargs file | grep -e "executable" -e "shared object" \ |
---|
166 | | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
167 | |
---|
168 | # Add a package description: |
---|
169 | mkdir -p $PKG/install |
---|
170 | cat $SRCDIR/slack-desc > $PKG/install/slack-desc |
---|
171 | |
---|
172 | # Build the package: |
---|
173 | cd $PKG |
---|
174 | makepkg --linkadd y --chown n $OUTPUT/${PKGNAM}-${VERSION}-${ARCH}-${BUILD}.txz |
---|
175 | |
---|