summaryrefslogtreecommitdiff
path: root/academic/QtiPlot/QtiPlot.SlackBuild
blob: c5f8a4acf95aa85b6b281518c494d6f956780aa0 (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
#!/bin/sh

# Slackware build script for QtiPlot

# Copyright 2011-2012  Petar Petrov, ppetrov@paju.oulu.fi
# 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.

PRGNAM=QtiPlot
VERSION=${VERSION:-0.9.8.9}
BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}

SRCNAM=$(echo $PRGNAM | tr A-Z a-z)

QTEXENGINE=QTeXEngine-0.3-opensource
UNOFPLUGIN=importOPJ-20111106

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

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "i486" ]; then
  SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  QMAKESPEC="linux-g++"
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  QMAKESPEC="linux-g++"
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  QMAKESPEC="linux-g++-64"
else
  SLKCFLAGS="-O2"
  QMAKESPEC="linux-g++"
fi

# Define these here, as numbers change between Slackware releases. The
# folder names are used for some documentation path fixes, needed to
# generate the html manual later on.
DOCBOOK=dsssl-stylesheets-1.79
CHUNK=xsl-stylesheets-1.76.1
DOCBOOKX=xml-dtd-4.5

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
mkdir $PRGNAM-$VERSION
cd $PRGNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.tar.bz2
unzip $CWD/$QTEXENGINE.zip
tar xvf $CWD/$UNOFPLUGIN.tar.gz
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
 -exec chmod 755 {} \; -o \
 \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
 -exec chmod 644 {} \;

# Copy QTeXEngine and importOPJ to their locations to be built later
cp -a QTeXEngine $SRCNAM-$VERSION/3rdparty
cp -a $UNOFPLUGIN/qtiplot/src/plugins $SRCNAM-$VERSION/qtiplot/src
cp -a $UNOFPLUGIN/qtiplot/importOPJ.pro $SRCNAM-$VERSION/qtiplot
cd $SRCNAM-$VERSION

# Patches for recent libpng, sip etc
# thanks to slack_jack, Raveriux, ponce, Arch and Gentoo
patch -p0 -d 3rdparty/qwtplot3d < $CWD/qwtplot3d-libpng15.patch
patch -p1 < $CWD/sip-4.15.patch
patch -p1 < $CWD/qtiplot-0.9.8.9-private.patch
patch -p1 < $CWD/pyqt-4.11.patch

# Use the custom build.conf
cp $CWD/build.conf.slack build.conf

# Make qtiplot.pro aware of the unofficial importOPJ plugin. Thanks to
# the author of the plugin, Stephan Zevenhuizen. For more info visit
# this site: http://www.staff.science.uu.nl/~zeven101/qtiplot.html
patch -p1 -i $CWD/importOPJ.patch
sed -i "143 a Q_IMPORT_PLUGIN(FreeSoftwareQtiPlotImportOPJ);" qtiplot/src/core/main.cpp

# Fix qwtplot3d
sed -i "10 a #include <GL/glu.h>" 3rdparty/qwtplot3d/include/qwt3d_openglhelper.h

# Make a few path fixes to qtiplot.pro
sed -i "s:/usr/local:/usr/share:" qtiplot/qtiplot.pro
sed -i "s:/share/man:/man:" qtiplot/qtiplot.pro
sed -i "s:/share/doc/qtiplot:/doc/$PRGNAM-$VERSION:" qtiplot/qtiplot.pro

# Point to the right places of qt-assistant-compat, libreoffice (when
# installed), latex, java, the QtiPlot html manual and fitPlugins
sed -i "s:<QAssistantClient>:<QtAssistant/qassistantclient.h>:" qtiplot/src/core/ApplicationWindow.cpp
sed -i "s:/usr/bin/soffice:/usr/bin/libreoffice:" qtiplot/src/core/ApplicationWindow.cpp
sed -i "s:/usr/bin/latex:/usr/share/texmf/bin/latex:" qtiplot/src/core/ApplicationWindow.cpp
sed -i "s:/usr/bin/java:/usr/lib${LIBDIRSUFFIX}/java/bin/java:" qtiplot/src/core/ApplicationWindow.cpp
sed -i "s:/index.html:/html/index.html:" qtiplot/src/core/ApplicationWindow.cpp
sed -i "s:/local/qtiplot/fitPlugins:/lib${LIBDIRSUFFIX}/qtiplot/plugins:" qtiplot/src/core/ApplicationWindow.cpp

# Path fixes, needed to generate the html manual
sed -i "s:stylesheet/dsssl/modular:${DOCBOOK}:" manual/qtiplot.dsl
sed -i "s:stylesheet/nwalsh:${CHUNK}:" manual/qtiplot_html.xsl
sed -i "s:schema/dtd/4.4:${DOCBOOKX}:" manual/docbook-en/index.docbook

# Build QtiPlot's qwt
cd 3rdparty/qwt
qmake
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make -j1

# Build QtiPlot's qwtplot3d
cd ../qwtplot3d
qmake
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make -j1

# Build QTeXEngine
cd ../QTeXEngine
qmake
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make -j1

# Build importOPJ
cd ../../qtiplot
qmake importOPJ.pro
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make -j1

# Make the html manual. If you want to generate the handbook as a PDF,
# change "web" to "en" below and make sure you have installed dblatex.
cd ../manual
make -j1 web

# Build QtiPlot
cd ../qtiplot
qmake qtiplot.pro "QMAKESPEC=$QMAKESPEC"
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make -j1 "QMAKESPEC=$QMAKESPEC"
make -j1 install INSTALL_ROOT=$PKG

# Generate translations and copy them to their proper place
lrelease qtiplot.pro
mkdir -p $PKG/usr/share/qtiplot/translations
cp translations/*.qm $PKG/usr/share/qtiplot/translations

# Copy some python examples
mkdir -p $PKG/usr/share/qtiplot/python-examples
cp examples/python/* $PKG/usr/share/qtiplot/python-examples

# Build fitPlugins
cd ../fitPlugins
qmake "QMAKESPEC=$QMAKESPEC"
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
make -j1 "QMAKESPEC=$QMAKESPEC"
make -j1 install INSTALL_ROOT=$PKG
cd ..

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

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

# Menu item, icon and mime types. The .xml is from Arch
mkdir -p $PKG/usr/share/{pixmaps,applications,mime/packages}
cp qtiplot_logo.png $PKG/usr/share/pixmaps/qtiplot.png
cp $CWD/qtiplot.desktop $PKG/usr/share/applications
cp $CWD/qtiplot.xml $PKG/usr/share/mime/packages

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
  README.html gpl_licence.txt qtiplot.css qtiplot_logo.png \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
cat $CWD/build.conf.slack > $PKG/usr/doc/$PRGNAM-$VERSION/build.conf.slack

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

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