gcclegacy494.SlackBuild 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. #!/bin/sh
  2. # Slackware build script for gcc-4.9.4
  3. # Copyright 2017 Vasily Sora 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. PRGNAM=gcclegacy494
  23. VERSION=${VERSION:-4.9.4}
  24. BUILD=${BUILD:-3}
  25. TAG=${TAG:-_SBo}
  26. INSTLOC=${INSTLOC:-/opt/$PRGNAM}
  27. if [ -z "$ARCH" ]; then
  28. case "$( uname -m )" in
  29. i?86) ARCH=i586 ;;
  30. arm*) ARCH=arm ;;
  31. *) ARCH=$( uname -m ) ;;
  32. esac
  33. fi
  34. CWD=$(pwd)
  35. TMP=${TMP:-/tmp/SBo}
  36. PKG=$TMP/package-$PRGNAM
  37. OUTPUT=${OUTPUT:-/tmp}
  38. if [ "$ARCH" = "i386" ]; then
  39. SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
  40. LIBDIRSUFFIX=""
  41. LIB_ARCH=i386
  42. elif [ "$ARCH" = "i486" ]; then
  43. SLKCFLAGS="-O2 -march=i486 -mtune=i686"
  44. LIBDIRSUFFIX=""
  45. LIB_ARCH=i386
  46. elif [ "$ARCH" = "i586" ]; then
  47. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  48. LIBDIRSUFFIX=""
  49. LIB_ARCH=i386
  50. elif [ "$ARCH" = "i686" ]; then
  51. SLKCFLAGS="-O2 -march=i686"
  52. LIBDIRSUFFIX=""
  53. LIB_ARCH=i386
  54. elif [ "$ARCH" = "s390" ]; then
  55. SLKCFLAGS="-O2"
  56. LIBDIRSUFFIX=""
  57. LIB_ARCH=s390
  58. elif [ "$ARCH" = "x86_64" ]; then
  59. SLKCFLAGS="-O2 -fPIC"
  60. LIBDIRSUFFIX="64"
  61. LIB_ARCH=amd64
  62. elif [ "$ARCH" = "armv7hl" ]; then
  63. SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16"
  64. LIBDIRSUFFIX=""
  65. LIB_ARCH=armv7hl
  66. else
  67. SLKCFLAGS="-O2"
  68. LIBDIRSUFFIX=""
  69. LIB_ARCH=$ARCH
  70. fi
  71. case "$ARCH" in
  72. arm*) TARGET=$ARCH-slackware-linux-gnueabi ;;
  73. *) TARGET=$ARCH-slackware-linux ;;
  74. esac
  75. if [ "$ARCH" = "x86_64" ]; then
  76. GCC_ARCHOPTS="--disable-multilib"
  77. else
  78. GCC_ARCHOPTS="--with-arch=$ARCH"
  79. fi
  80. set -e
  81. rm -rf $PKG
  82. mkdir -p $TMP $PKG $OUTPUT
  83. cd $TMP
  84. rm -rf gcc-$VERSION
  85. tar xvf $CWD/gcc-$VERSION.tar.gz
  86. cd gcc-$VERSION
  87. tar xjf $CWD/mpfr-2.4.2.tar.bz2
  88. ln -sf mpfr-2.4.2 mpfr
  89. tar xjf $CWD/gmp-4.3.2.tar.bz2
  90. ln -sf gmp-4.3.2 gmp
  91. tar xzf $CWD/mpc-0.8.1.tar.gz
  92. ln -sf mpc-0.8.1 mpc
  93. tar xjf $CWD/isl-0.12.2.tar.bz2
  94. ln -sf isl-0.12.2 isl
  95. tar xzf $CWD/cloog-0.18.1.tar.gz
  96. ln -sf cloog-0.18.1 cloog
  97. chown -R root:root .
  98. find -L . \
  99. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  100. -o -perm 511 \) -exec chmod 755 {} \; -o \
  101. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  102. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  103. # Do not run fixincludes
  104. cp -v gcc/Makefile.in{,.orig}
  105. sed 's@\./fixinc\.sh@-c true@' gcc/Makefile.in.orig > gcc/Makefile.in
  106. # Apply patches if we are compiling against glibc 2.26
  107. if [ "$(ldd --version | head -1)" = 'ldd (GNU libc) 2.26' ]; then
  108. patch -p1 -i "$CWD/942-asan-fix-missing-include-signal-h.patch"
  109. patch -p1 -i "$CWD/943-Use-ucontext_t-not-struct-ucontext-in-linux-unwind.h.patch"
  110. patch -p1 -i "$CWD/944-sanitizer-linux.patch"
  111. export glibcxx_cv_c99_math=yes
  112. fi
  113. rm -rf $TMP/objdir
  114. mkdir $TMP/objdir
  115. cd $TMP/objdir
  116. CFLAGS="$SLKCFLAGS" \
  117. CXXFLAGS="$SLKCFLAGS" \
  118. ../gcc-$VERSION/configure --prefix=$INSTLOC \
  119. --program-suffix=-$VERSION \
  120. --enable-languages=c,c++ \
  121. --with-system-zlib \
  122. --libdir=$INSTLOC/lib$LIBDIRSUFFIX \
  123. --enable-threads=posix \
  124. --disable-gtktest \
  125. --target=${TARGET} \
  126. --build=${TARGET} \
  127. --host=${TARGET} \
  128. $GCC_ARCHOPTS \
  129. --with-arch-directory=$LIB_ARCH \
  130. --enable-clocale=gnu \
  131. --with-gnu-ld \
  132. --enable-shared \
  133. --enable-__cxa_atexit
  134. make
  135. make DESTDIR=$PKG install-strip
  136. # Thank you to 'idlemoor'
  137. mkdir -p $PKG/usr/bin
  138. cd $PKG/usr/bin
  139. for COMPILER in gcc g++ ; do
  140. sed \
  141. -e "s~%LIBDIRSUFFIX%~$LIBDIRSUFFIX~" \
  142. -e "s~%COMPILER%~$COMPILER~" \
  143. -e "s~%INSTLOC%~$INSTLOC~" \
  144. < $CWD/wrapper.sh \
  145. > $PKG/usr/bin/$ARCH-slackware-linux-$COMPILER-$VERSION
  146. chmod ugo+x $PKG/usr/bin/$ARCH-slackware-linux-$COMPILER-$VERSION
  147. done
  148. ln -s $ARCH-slackware-linux-gcc-$VERSION $PKG/usr/bin/gcc-$VERSION
  149. ln -s $ARCH-slackware-linux-g++-$VERSION $PKG/usr/bin/g++-gcc-$VERSION
  150. mv -f $PKG$INSTLOC/share/man $PKG/usr/man
  151. cd $PKG/usr/man/man7
  152. # we do not need these; according to "diff" there is no difference between these files
  153. # and the ones Slackware ships with; except this man page named "gfdl.7"; which shall be
  154. # saved; and renamed so that it does not conflict with Slackware's.
  155. find . ! -name 'gfdl.7' -exec rm -rf {} \;
  156. mv gfdl.7 gfdl494.7
  157. find $PKG/usr/man -type f -exec gzip -9 {} \;
  158. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  159. mv -f $PKG$INSTLOC/share/info $PKG/usr/info
  160. rm -f $PKG/usr/info/dir
  161. cd $PKG/usr/info
  162. #rename the .info files so they do not conflict with Slackware's own .info files.
  163. for info in *.info; do mv "$info" "${info%.*}-$VERSION.info"; done
  164. gzip -9 $PKG/usr/info/*.info*
  165. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  166. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  167. mkdir -p $PKG/install
  168. cat $CWD/slack-desc > $PKG/install/slack-desc
  169. cd $PKG
  170. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}