summaryrefslogtreecommitdiff
path: root/graphics/qcad/qcad.SlackBuild
blob: 25fec1014f6e484d8fcf8a4a0107f63786b4633f (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
#!/bin/sh

# Slackware build script for qcad
# (2D Computer Aided Drafting)

# Written by Niels Horn <niels.horn@gmail.com>
# Revision date: 2010/06/01

PRGNAM=qcad
VERSION=${VERSION:-2.0.5.0}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}

# Version of source is a bit different:
SRCVERSION=${VERSION}-1-community.src

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i486 ;;
    arm*) ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
       *) ARCH=$( uname -m ) ;;
  esac
fi

# Language & Version of manual
#   When writing this Slackbuild, manuals were avaliable in cs/en/de/hu
MANLANG=${MANLANG:-en}
MANVERSION=${MANVERSION:-2.1.0.0}
SRCMAN=$MANLANG-$MANVERSION-1.html

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

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

set -e

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$SRCVERSION
tar xvf $CWD/$PRGNAM-$SRCVERSION.tar.gz
cd $PRGNAM-$SRCVERSION
chown -R root:root .
find . \
 \( -perm 777 -o -perm 775 -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 {} \;

### We'll do quite some patching here, but the sources are from 2005 and a lot has
### changed since then...

# Apply patch for gcc-4x
patch -p1 < $CWD/gcc4x.patch

# If 64-bits, apply patch needed for Slackware64
[ "$ARCH" = "x86_64" ] && patch -p1 < $CWD/slack64.patch

# Apply patch to show on-line help
#   (it needs to find the "assistant" from QT3)
patch -p1 < $CWD/help.patch
sed -i "s|@QTDIR@|$QTDIR|g" qcad/src/qc_applicationwindow.cpp

# And this is an ugly patch to force the compiler to use libpng12
#   This is needed as Slackware 13.1 uses libpng14 as the default, but Qt3
#   from extra/kde3-compat was still compiled with libpng12.
#   The *correct* solution would be to rebuild Qt3 against the new version
#   of libpng, but that might me a bit to steep for some users...
patch -p1 < $CWD/libpng.patch

# Make sure we'll use the qt3 tools to build qcad
sed -i "s|qmake|/opt/kde3/bin/qmake|g" scripts/build_qcad.sh

### End of patching ###

# Start the one-in-all build-script
( cd scripts
  CFLAGS="$SLKCFLAGS" \
  ./build_qcad.sh
)

# "Compile" all .ts files to .qm
find -name *.ts | while read FILE; do
  lrelease $FILE
done

# "Install" program
mkdir -p $PKG/opt/$PRGNAM
cp -a qcad/qcad $PKG/opt/$PRGNAM/

# "Install" data & translations
mkdir -p $PKG/opt/$PRGNAM/qm
cp -a qcad/data qcad/doc qcad/fonts qcad/library qcad/machines qcad/patterns \
  $PKG/opt/$PRGNAM/
find -name *.qm | while read FILE; do
  cp $FILE $PKG/opt/$PRGNAM/qm/
done

# "Install" manual
( cd $TMP
  rm -rf $PRGNAM-manual-$SRCMAN
  unzip $CWD/$PRGNAM-manual-$SRCMAN.zip
  cd $PRGNAM-manual-$SRCMAN
  cp -a * $PKG/opt/$PRGNAM/doc/
)

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

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
  qcad/README \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/usr/share/{applications,pixmaps}
cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop
cp qcad/src/xpm/qcad.xpm $PKG/usr/share/pixmaps/

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}_$MANLANG-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}