gcc/gcc.spec

Fri, 25 Mar 2011 20:28:34 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 25 Mar 2011 20:28:34 +0100
changeset 328
aee811db821a
parent 322
30c214982bd2
child 332
2289d64c2123
permissions
-rw-r--r--

Back out ineffective correction and reformat AS/LD detection logic.
Additionally, explicitly link libm when using libmpc to avoid errors.

     1 ##
     2 ##  gcc.spec -- OpenPKG RPM Package Specification
     3 ##  Copyright (c) 2000-2010 OpenPKG Foundation e.V. <http://openpkg.net/>
     4 ##
     5 ##  Permission to use, copy, modify, and distribute this software for
     6 ##  any purpose with or without fee is hereby granted, provided that
     7 ##  the above copyright notice and this permission notice appear in all
     8 ##  copies.
     9 ##
    10 ##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    11 ##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    12 ##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
    13 ##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
    14 ##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    15 ##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    16 ##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
    17 ##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
    18 ##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
    19 ##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
    20 ##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    21 ##  SUCH DAMAGE.
    22 ##
    24 #   package version
    25 %define       V_full         4.5.2
    26 %define       V_comp         %nil
    28 #   package information
    29 Name:         gcc
    30 Summary:      GNU Compiler Collection
    31 URL:          http://gcc.gnu.org/
    32 Vendor:       Free Software Foundation
    33 Packager:     OpenPKG Foundation e.V.
    34 Distribution: OpenPKG Community
    35 Class:        CORE
    36 Group:        Compiler
    37 License:      GPL
    38 Version:      %{V_full}
    39 Release:      20110320
    41 #   package options
    42 %option       with_binutils  yes
    43 %option       with_cxx       yes
    44 %option       with_objc      no
    45 %option       with_java      no
    46 %option       with_fortran   no
    47 %option       with_optimize  yes
    48 %option       with_profile   no
    49 %option       with_threads   yes
    50 %option       with_multilib  no
    52 #   list of sources
    53 Source0:      ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-core-%{V_full}.tar.bz2
    54 Source1:      ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-g++-%{V_full}.tar.bz2
    55 Source2:      ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-objc-%{V_full}.tar.bz2
    56 Source3:      ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-java-%{V_full}.tar.bz2
    57 Source4:      ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-fortran-%{V_full}.tar.bz2
    58 Patch0:       gcc.patch
    60 #   build information
    61 Prefix:       %{l_prefix}
    62 BuildRoot:    %{l_buildroot}
    63 BuildPreReq:  OpenPKG, openpkg >= 20060823, make, libtool
    64 PreReq:       OpenPKG, openpkg >= 20060823
    65 %if "%{with_binutils}" == "yes"
    66 BuildPreReq:  binutils >= 2.14
    67 PreReq:       binutils >= 2.14
    68 %endif
    69 BuildPreReq:  mpc, mpfr, gmp
    70 PreReq:       mpc, mpfr, gmp
    71 %if "%{with_cxx}" == "yes"
    72 BuildPreReq:  libiconv
    73 PreReq:       libiconv
    74 %endif
    75 %if "%{with_java}" == "yes"
    76 BuildPreReq:  zlib
    77 PreReq:       zlib
    78 %endif
    79 AutoReq:      no
    80 AutoReqProv:  no
    82 %description
    83     The GNU Compiler Collection (GCC) provides standard conforming and
    84     highly portable compilers for the ISO C, ISO C++, Objective-C,
    85     Fortran and Java languages.
    87 %track
    88     prog gcc = {
    89         version   = %{V_full}
    90         url       = ftp://gcc.gnu.org/pub/gcc/releases/
    91         regex     = gcc-(4\.\d+\.\d+)
    92         url       = ftp://gcc.gnu.org/pub/gcc/releases/gcc-__NEWVER__/
    93         regex     = gcc-core-(\d+\.\d+\.\d+)\.tar\.bz2
    94     }
    96 %prep
    97     %setup -q
    98 %if "%{with_cxx}" == "yes"
    99     %setup -q -T -D -b 1
   100 %endif
   101 %if "%{with_objc}" == "yes"
   102     %setup -q -T -D -b 2
   103 %endif
   104 %if "%{with_java}" == "yes"
   105     %setup -q -T -D -b 3
   106 %endif
   107 %if "%{with_fortran}" == "yes"
   108     %setup -q -T -D -b 4
   109 %endif
   110     %patch -p0
   111     %{l_shtool} subst -v -s \
   112         -e 's;\(gmplibs="-lmpc\) \(-lmpfr -lgmp\);\1 -lm \2;' \
   113         configure
   114     %{l_shtool} subst -v -s \
   115         -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
   116         gcc/configure
   117     if [ ".%{V_comp}" != . ]; then
   118         %{l_shtool} subst -v -s \
   119             -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
   120             `find . -name Makefile.in -type f -print`
   121     fi
   122     case "%{l_platform -t}" in
   123         amd64*-linux* )
   124             %{l_shtool} subst \
   125                 -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
   126                 -e 's/test x.gcc_no_link = xyes/false/g' \
   127                 libstdc++-v3/configure
   128             ;;
   129     esac
   130     %{l_shtool} subst \
   131         -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \
   132         libstdc++-v3/include/ext/codecvt_specializations.h
   134 %build
   135     #   create build sub-directory
   136     %{l_shtool} mkdir -p obj
   137     cd obj
   139     #   solve strange compatability problems
   140 %if "%{with_binutils}" == "yes"
   141     #   determine ld(1) and as(1) usage, allowing either
   142     #   one to be from the GNU distribution of binutils
   143     LD=%{l_tool_locate ld ld}
   144     AS=%{l_tool_locate as as}
   145 %else
   146     #   locate ld(1) and as(1), using the GNU assembler
   147     #   but ignoring the presence of any OpenPKG linker
   148     LD=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin which ld`
   149     AS=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin which as`
   150 %endif
   151     l_with_gnu_ld_as=""
   152     echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="--with-ld=$LD"
   153     echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
   154     $LD --version </dev/null 2>/dev/null | grep "^GNU ld "        >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-ld" || l_with_gnu_ld_as="${l_with_gnu_ld_as} --without-gnu-ld"
   155     $AS --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-gnu-as" || l_with_gnu_ld_as="${l_with_gnu_ld_as} --without-gnu-as"
   157     #   determine threads usage
   158 %if "%{with_threads}" == "yes"
   159     l_enable_threads="posix"
   160 %else
   161     l_enable_threads="single"
   162 %endif
   164     #   determine language usage
   165     l_enable_languages="c"
   166 %if "%{with_cxx}" == "yes"
   167     l_enable_languages="${l_enable_languages},c++"
   168 %endif
   169 %if "%{with_objc}" == "yes"
   170     l_enable_languages="${l_enable_languages},objc"
   171 %endif
   172 %if "%{with_java}" == "yes"
   173     l_enable_languages="${l_enable_languages},java"
   174 %endif
   175 %if "%{with_fortran}" == "yes"
   176     l_enable_languages="${l_enable_languages},f95"
   177 %endif
   179     #   disable GNU iconv usage
   180     ( echo "am_cv_func_iconv=no"
   181       echo "am_cv_lib_iconv=no"
   182     ) >config.cache
   184     #   configure the package
   185     LD="$LD" \
   186     AS="$AS" \
   187     CC="%{l_cc}" \
   188     CFLAGS="%{l_cflags}" \
   189 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
   190     CPPFLAGS="%{l_cppflags}" \
   191     LDFLAGS="%{l_ldflags}" \
   192 %endif
   193     CONFIG_SHELL="%{l_bash}" \
   194     ../configure \
   195         --with-bugurl="http://openpkg.org/" \
   196         --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \
   197         --cache-file=./config.cache \
   198         --srcdir=`pwd`/.. \
   199         --prefix=%{l_prefix} \
   200         --exec-prefix=%{l_prefix} \
   201         --mandir=%{l_prefix}/man \
   202         --infodir=%{l_prefix}/info \
   203         --includedir=%{l_prefix}/include/gcc%{V_comp} \
   204         --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
   205         --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
   206         --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
   207         --enable-languages="${l_enable_languages}" \
   208         --enable-threads="${l_enable_threads}" \
   209         --disable-maintainer-mode \
   210         --disable-shared \
   211         --disable-nls \
   212 %if "%{with_java}" == "yes"
   213         --with-system-zlib \
   214 %endif
   215 %if "%{with_multilib}" == "yes"
   216         --enable-multilib \
   217 %else
   218         --disable-multilib \
   219 %endif
   220 %if "%{with_cxx}" == "yes"
   221         --with-libiconv-prefix=%{l_prefix} \
   222 %endif
   223         --with-gmp=%{l_prefix} \
   224         --with-mpfr=%{l_prefix} \
   225         --with-mpc=%{l_prefix} \
   226         ${l_with_gnu_ld_as}
   228     #   determine build flags
   229     l_ccisgcc=no
   230     if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
   231         l_ccisgcc=yes
   232     fi
   233     l_cflags=""
   234     l_cxxflags=""
   235     l_boot_cflags=""
   236     l_libcflags="-g"
   237     l_libcxxflags="-g"
   238     #   at least GNU as from GNU binutils supports -pipe always
   239     "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && {
   240         l_boot_cflags="$l_boot_cflags -pipe"
   241         l_libcxxflags="$l_libcxxflags -pipe"
   242     }
   243 %if "%{with_optimize}" == "yes"
   244     #   conservatively optimize the generated program code
   245     #   (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
   246     l_cflags="$l_cflags -O"
   247     l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
   248     case "%{l_platform -t}" in
   249         *i?86-*     ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
   250         *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9"       ;;
   251     esac
   252     l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
   253 %else
   254     #   else do no optimizations at all to reduce problems to minimum in advance
   255     l_boot_cflags="$l_boot_cflags -O0"
   256     l_libcxxflags="$l_libcxxflags -O0"
   257 %endif
   258     maketarget="bootstrap2-lean"
   259 %if "%{with_profile}" == "yes"
   260     #   GCC >= 3.4 supports a "profiledbootstrap" target to build an
   261     #   optimized version of itself through profiling. Because this
   262     #   requires a (bootstrapping) C compiler with 64-bit arithmetic,
   263     #   the whole approach is currently supported only if already
   264     #   building with GCC as the bootstrapping C compiler.
   265     if [ ".$l_ccisgcc" = .yes ]; then
   266         maketarget="profiledbootstrap"
   267     fi
   268 %endif
   269     case "%{l_platform -t}" in
   270         amd64-*          ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
   271         ia64-*           ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
   272         sparc64-freebsd* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
   273     esac
   274 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
   275     l_cflags="$l_cflags %{l_cppflags}"
   276     l_cxxflags="$l_cxxflags %{l_cppflags}"
   277     l_libcflags="$l_libcflags %{l_cppflags}"
   278     l_libcxxflags="$l_libcxxflags %{l_cppflags}"
   279 %endif
   281     #   build the package
   282     MAKE="%{l_make} %{l_mflags}" \
   283     %{l_make} %{l_mflags} \
   284         MAKE="%{l_make} %{l_mflags}" \
   285         BOOT_CFLAGS="${l_boot_cflags}" \
   286         CFLAGS="${l_cflags}" \
   287         CXXFLAGS="${l_cxxflags}" \
   288         LIBCFLAGS="${l_libcflags}" \
   289         LIBCXXFLAGS="${l_libcxxflags}" \
   290         $maketarget
   292 %install
   293     rm -rf $RPM_BUILD_ROOT
   295     #   fetch GNU platform triple
   296     triple=`./config.guess`
   298     #   perform the standard installation procedure
   299     ( cd obj
   300       %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
   301     ) || exit $?
   303     #   cleanup installation tree
   304     mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
   305        $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
   306        >/dev/null 2>&1 || true
   307     mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
   308        $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
   309        >/dev/null 2>&1 || true
   310     dirs=""
   311     for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
   312         subdir=`echo "$multilib" | sed -e 's/;.*$//'`
   313         [ ".$subdir" = .. ] && continue
   314         mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
   315            $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
   316            >/dev/null 2>&1 || true
   317         mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
   318            $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
   319            >/dev/null 2>&1 || true
   320         dirs="$dirs $subdir"
   321     done
   322     for subdir in $dirs; do
   323         rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
   324     done
   325     mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
   326        $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
   327            >/dev/null 2>&1 || true
   329     #   strip installation tree
   330     rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
   331     rm -f  $RPM_BUILD_ROOT%{l_prefix}/info/dir
   332     rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7   >/dev/null 2>&1 || true
   333     rm -f  $RPM_BUILD_ROOT%{l_prefix}/lib/*.la   >/dev/null 2>&1 || true
   334     rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64      >/dev/null 2>&1 || true
   335     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
   336 %if "%{with_cxx}" == "yes"
   337     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++  >/dev/null 2>&1 || true
   338     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++  >/dev/null 2>&1 || true
   339 %endif
   340     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
   341     for prog in cc1 cc1plus collect2 cpp; do
   342         strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
   343             >/dev/null 2>&1 || true
   344     done
   346     #   bump up installation tree
   347     ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
   348        $RPM_BUILD_ROOT%{l_prefix}/bin/cc
   349     ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
   350        $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
   351 %if "%{with_cxx}" == "yes"
   352     ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
   353        $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
   354 %endif
   356     #   determine installation file list
   357     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
   359 %files -f files
   361 %clean
   362     rm -rf $RPM_BUILD_ROOT

mercurial