goldencheetah.SlackBuild 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. #!/bin/bash
  2. # Slackware build script for GoldenCheetah
  3. # Copyright 2018-2021 Kyle Guinn <elyk03@gmail.com>
  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. cd $(dirname $0) ; CWD=$(pwd)
  23. PRGNAM=goldencheetah
  24. SRCNAM=GoldenCheetah
  25. VERSION=${VERSION:-3.5}
  26. BUILD=${BUILD:-4}
  27. TAG=${TAG:-_SBo}
  28. PKGTYPE=${PKGTYPE:-tgz}
  29. if [ -z "$ARCH" ]; then
  30. case "$(uname -m)" in
  31. i?86) ARCH=i586 ;;
  32. arm*) ARCH=arm ;;
  33. *) ARCH=$(uname -m) ;;
  34. esac
  35. fi
  36. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  37. # the name of the created package would be, and then exit. This information
  38. # could be useful to other scripts.
  39. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  40. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  41. exit 0
  42. fi
  43. TMP=${TMP:-/tmp/SBo}
  44. PKG=$TMP/package-$PRGNAM-$VERSION
  45. OUTPUT=${OUTPUT:-/tmp}
  46. DOCS="COPYING doc/user/GC3-Manual.pdf doc/user/GC3-FAQ.pdf"
  47. if [ "$ARCH" = "i586" ]; then
  48. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  49. LIBDIRSUFFIX=""
  50. elif [ "$ARCH" = "i686" ]; then
  51. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  52. LIBDIRSUFFIX=""
  53. elif [ "$ARCH" = "x86_64" ]; then
  54. SLKCFLAGS="-O2 -fPIC"
  55. LIBDIRSUFFIX="64"
  56. else
  57. SLKCFLAGS="-O2"
  58. LIBDIRSUFFIX=""
  59. fi
  60. set -e
  61. rm -rf $PKG
  62. mkdir -p $TMP $PKG $OUTPUT
  63. cd $TMP
  64. rm -rf $SRCNAM-$VERSION
  65. tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
  66. cd $SRCNAM-$VERSION
  67. chown -R root:root .
  68. chmod -R u+w,go-w,a+rX-st .
  69. # Fixes from release_3.5.0 branch. 0003 and 0004 contain images treated as
  70. # text since `patch` doesn't decode git binary patches. Comment them out if
  71. # they won't apply.
  72. patch -p1 < $CWD/patches/0001-SEGV-on-Overview-Chart.patch
  73. patch -p1 < $CWD/patches/0002-View-on-Strava.patch
  74. patch -p1 < $CWD/patches/0003-Compatible-with-Strava.patch
  75. patch -p1 < $CWD/patches/0004-Connect-with-Strava.patch
  76. patch -p1 < $CWD/patches/0005-3.5-BUILD-INCREMENT.patch
  77. # GoldenCheetah statically links its own version of qwt, which is likely a fork
  78. # from around version 6.1.0 or 6.1.1. The build system uses -L/-l flags to
  79. # refer to the static lib, but due to other -L flags and symlinked directories,
  80. # it might find the system qwt instead. Replace the flags with a filename.
  81. sed -i 's|-L\(\$\${PWD}/\.\./qwt/lib\) -l\(qwtd\?\)|\1/lib\2.a|' src/src.pro
  82. # Fixes for qwt and Qt5 compatibility.
  83. patch -p1 < $CWD/patches/0001-Fix-Qwt-incompatibilities-with-Qt-5.15.0.patch
  84. # Use the system levmar if available.
  85. # Builtin copy is version 2.6 without lapack support.
  86. # TODO: Replace other builtins (qzip?, qxt, lmfit).
  87. if [ -f /usr/include/levmar/levmar.h ]; then
  88. sed -i 's|\.\./levmar[^ ]* *||g' src/src.pro
  89. echo "INCLUDEPATH += /usr/include/levmar" >> src/src.pro
  90. echo "LIBS += -llevmar" >> src/src.pro
  91. fi
  92. # We don't have a '-qt4' suffix on lrelease.
  93. sed -i 's|\(lrelease\)-qt4|\1|' src/src.pro
  94. # Copy the default config files, then modify them below.
  95. cp qwt/qwtconfig.pri.in qwt/qwtconfig.pri
  96. cp src/gcconfig.pri.in src/gcconfig.pri
  97. # Set up the build configuration.
  98. sed -i 's|^#\(CONFIG += release\)\>|\1|' src/gcconfig.pri
  99. sed -i 's|^#\(QMAKE_LEX = flex\)\>|\1|' src/gcconfig.pri
  100. sed -i 's|^#\(QMAKE_YACC = bison\)\>|\1|' src/gcconfig.pri
  101. # Use -b y to force bison >= 3.7 to copy y.tab.h's contents into y.tab.cpp
  102. # instead of #including it, since qmake's renaming to $base_yacc.{h,cpp}
  103. # breaks the #include.
  104. #echo "QMAKE_YACCFLAGS_MANGLE = -p $base -b y" >> src/gcconfig.pri
  105. #echo "QMAKE_YACC_HEADER = y.tab.h" >> src/gcconfig.pri
  106. #echo "QMAKE_YACC_SOURCE = y.tab.cpp" >> src/gcconfig.pri
  107. # But that breaks parallel builds (multiple build steps produce temporary files
  108. # with the same y.tab.{h,cpp} names). Make the files available by both names.
  109. sed -i 's|^#\( QMAKE_MOVE =\).*|\1 ln -sf|' src/gcconfig.pri
  110. # Enable optional dependencies found in stock Slackware.
  111. sed -i 's|^#\(ICAL_INSTALL =\).*|\1 /usr|' src/gcconfig.pri
  112. sed -i 's|^#\(LIBUSB_INSTALL =\).*|\1 /usr|' src/gcconfig.pri
  113. sed -i 's|^#\(LIBUSB_USE_V_1 = true\)\>|\1|' src/gcconfig.pri
  114. sed -i 's|^#\(SAMPLERATE_INSTALL =\).*|\1 /usr|' src/gcconfig.pri
  115. sed -i 's|^#\(CONFIG += link_pkgconfig\)\>|\1|' src/gcconfig.pri
  116. sed -i 's|^#\(PKGCONFIG =\).*|\1|' src/gcconfig.pri
  117. sed -i 's|^#\(LIBZ_INCLUDE =\).*|\1|' src/gcconfig.pri
  118. sed -i 's|^#\(LIBZ_LIBS = -lz\)\>|\1|' src/gcconfig.pri
  119. sed -i 's|^#\(HTPATH = \.\./httpserver\)\>|\1|' src/gcconfig.pri
  120. sed -i 's|^\(DEFINES += GC_VIDEO_NONE\)\>|#\1|' src/gcconfig.pri
  121. sed -i 's|^#\(DEFINES += GC_VIDEO_QT5\)\>|\1|' src/gcconfig.pri
  122. sed -i 's|^#\(DEFINES += NOWEBKIT\)\>|\1|' src/gcconfig.pri
  123. # Python support. Regenerate the SIP files.
  124. echo "DEFINES += GC_WANT_PYTHON" >> src/gcconfig.pri
  125. echo "PYTHONINCLUDES = $(pkg-config --cflags python3-embed)" >> src/gcconfig.pri
  126. echo "PYTHONLIBS = $(pkg-config --libs python3-embed)" >> src/gcconfig.pri
  127. make -C src/Python/SIP -f Makefile.hack clean
  128. make -C src/Python/SIP -f Makefile.hack
  129. # Optional KML support.
  130. if pkg-config --exists libkml; then
  131. sed -i 's|^#\(KML_INSTALL =\).*|\1 /usr|' src/gcconfig.pri
  132. fi
  133. # Optional R support.
  134. if pkg-config --exists libR; then
  135. sed -i 's|^#\(DEFINES += GC_WANT_R\)\>|\1|' src/gcconfig.pri
  136. fi
  137. qmake-qt5 \
  138. -recursive \
  139. QMAKE_CFLAGS_RELEASE="$SLKCFLAGS" \
  140. QMAKE_CXXFLAGS_RELEASE="$SLKCFLAGS" \
  141. make
  142. install -D -m0755 -s src/GoldenCheetah $PKG/usr/bin/GoldenCheetah
  143. install -D -m0644 src/Resources/linux/51-garmin-usb.rules $PKG/lib/udev/rules.d/51-garmin-usb.rules
  144. # Generate desktop icon set
  145. convert -size 512x512 xc:none -fill white -draw "roundrectangle 15,16 487,486 52,52" \
  146. src/Resources/images/gc.png -compose Over -composite -crop 475x473+14+15\! logo.png
  147. for RES in 16 22 24 32 48 64 128 256 512; do
  148. mkdir -p $PKG/usr/share/icons/hicolor/${RES}x${RES}/apps
  149. convert logo.png -resize ${RES}x${RES}\! $PKG/usr/share/icons/hicolor/${RES}x${RES}/apps/GoldenCheetah.png
  150. done
  151. mkdir -p $PKG/usr/share/applications
  152. cp $CWD/GoldenCheetah.desktop $PKG/usr/share/applications/
  153. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  154. cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION
  155. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  156. mkdir -p $PKG/install
  157. cat $CWD/slack-desc > $PKG/install/slack-desc
  158. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  159. cd $PKG
  160. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE