gcc/gcc.spec

Thu, 24 Mar 2011 19:02:24 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 24 Mar 2011 19:02:24 +0100
changeset 321
bbed90117468
parent 320
d8a8300afdc8
child 322
30c214982bd2
permissions
-rw-r--r--

Backport RPM boilerplate logic required by legacy OpenPKG scripts.

     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 >= 20100101, make
    64 PreReq:       OpenPKG, openpkg >= 20100101
    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;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
   113         gcc/configure
   114     if [ ".%{V_comp}" != . ]; then
   115         %{l_shtool} subst -v -s \
   116             -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
   117             `find . -name Makefile.in -type f -print`
   118     fi
   119     case "%{l_platform -t}" in
   120         amd64*-linux* )
   121             %{l_shtool} subst \
   122                 -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
   123                 -e 's/test x.gcc_no_link = xyes/false/g' \
   124                 libstdc++-v3/configure
   125             ;;
   126     esac
   127     %{l_shtool} subst \
   128         -e 's;<iconv\.h>;"%{l_prefix}/include/iconv.h";' \
   129         libstdc++-v3/include/ext/codecvt_specializations.h
   131 %build
   132     #   create build sub-directory
   133     %{l_shtool} mkdir -p obj
   134     cd obj
   136     #   determine ld(1) and as(1) usage
   137     l_with_gnu_ld_as=""
   138     LD=%{l_tool_locate ld ld}
   139     AS=%{l_tool_locate as as}
   140     echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-ld=$LD"
   141     echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
   142     $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"
   143     $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"
   144     unset LD
   145     unset AS
   147     #   determine threads usage
   148 %if "%{with_threads}" == "yes"
   149     l_enable_threads="posix"
   150 %else
   151     l_enable_threads="single"
   152 %endif
   154     #   determine language usage
   155     l_enable_languages="c"
   156 %if "%{with_cxx}" == "yes"
   157     l_enable_languages="${l_enable_languages},c++"
   158 %endif
   159 %if "%{with_objc}" == "yes"
   160     l_enable_languages="${l_enable_languages},objc"
   161 %endif
   162 %if "%{with_java}" == "yes"
   163     l_enable_languages="${l_enable_languages},java"
   164 %endif
   165 %if "%{with_fortran}" == "yes"
   166     l_enable_languages="${l_enable_languages},f95"
   167 %endif
   169     #   disable GNU iconv usage
   170     ( echo "am_cv_func_iconv=no"
   171       echo "am_cv_lib_iconv=no"
   172     ) >config.cache
   174     #   configure the package
   175     CC="%{l_cc}" \
   176     CFLAGS="%{l_cflags}" \
   177 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
   178     CPPFLAGS="%{l_cppflags}" \
   179     LDFLAGS="%{l_ldflags}" \
   180 %endif
   181     CONFIG_SHELL="%{l_bash}" \
   182     ../configure \
   183         --with-bugurl="http://openpkg.org/" \
   184         --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \
   185         --cache-file=./config.cache \
   186         --srcdir=`pwd`/.. \
   187         --prefix=%{l_prefix} \
   188         --exec-prefix=%{l_prefix} \
   189         --mandir=%{l_prefix}/man \
   190         --infodir=%{l_prefix}/info \
   191         --includedir=%{l_prefix}/include/gcc%{V_comp} \
   192         --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
   193         --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
   194         --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
   195         --enable-languages="${l_enable_languages}" \
   196         --enable-threads="${l_enable_threads}" \
   197         --disable-maintainer-mode \
   198         --disable-shared \
   199         --disable-nls \
   200 %if "%{with_java}" == "yes"
   201         --with-system-zlib \
   202 %endif
   203 %if "%{with_multilib}" == "yes"
   204         --enable-multilib \
   205 %else
   206         --disable-multilib \
   207 %endif
   208 %if "%{with_cxx}" == "yes"
   209         --with-libiconv-prefix=%{l_prefix} \
   210 %endif
   211         --with-gmp=%{l_prefix} \
   212         --with-mpfr=%{l_prefix} \
   213         --with-mpc=%{l_prefix} \
   214         ${l_with_gnu_ld_as}
   216     #   determine build flags
   217     l_ccisgcc=no
   218     if [ ".`(%{l_cc} -v; %{l_cc} --version) </dev/null 2>&1 | grep -i 'gcc'`" != . ]; then
   219         l_ccisgcc=yes
   220     fi
   221     l_cflags=""
   222     l_cxxflags=""
   223     l_boot_cflags=""
   224     l_libcflags="-g"
   225     l_libcxxflags="-g"
   226     #   at least GNU as from GNU binutils supports -pipe always
   227     AS="%{l_tool_locate as as}"
   228     "$AS" --version </dev/null 2>/dev/null | grep "^GNU assembler " >/dev/null && {
   229         l_boot_cflags="$l_boot_cflags -pipe"
   230         l_libcxxflags="$l_libcxxflags -pipe"
   231     }
   232 %if "%{with_optimize}" == "yes"
   233     #   conservatively optimize the generated program code
   234     #   (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
   235     l_cflags="$l_cflags -O"
   236     l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
   237     case "%{l_platform -t}" in
   238         *i?86-*     ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
   239         *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9"       ;;
   240     esac
   241     l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
   242 %else
   243     #   else do no optimizations at all to reduce problems to minimum in advance
   244     l_boot_cflags="$l_boot_cflags -O0"
   245     l_libcxxflags="$l_libcxxflags -O0"
   246 %endif
   247     maketarget="bootstrap2-lean"
   248 %if "%{with_profile}" == "yes"
   249     #   GCC >= 3.4 supports a "profiledbootstrap" target to build an
   250     #   optimized version of itself through profiling. Because this
   251     #   requires a (bootstrapping) C compiler with 64-bit arithmetic,
   252     #   the whole approach is currently supported only if already
   253     #   building with GCC as the bootstrapping C compiler.
   254     if [ ".$l_ccisgcc" = .yes ]; then
   255         maketarget="profiledbootstrap"
   256     fi
   257 %endif
   258     case "%{l_platform -t}" in
   259         amd64-*          ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
   260         ia64-*           ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
   261         sparc64-freebsd* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
   262     esac
   263 %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
   264     l_cflags="$l_cflags %{l_cppflags}"
   265     l_cxxflags="$l_cxxflags %{l_cppflags}"
   266     l_libcflags="$l_libcflags %{l_cppflags}"
   267     l_libcxxflags="$l_libcxxflags %{l_cppflags}"
   268 %endif
   270     #   build the package
   271     MAKE="%{l_make} %{l_mflags}" \
   272     %{l_make} %{l_mflags} \
   273         MAKE="%{l_make} %{l_mflags}" \
   274         BOOT_CFLAGS="${l_boot_cflags}" \
   275         CFLAGS="${l_cflags}" \
   276         CXXFLAGS="${l_cxxflags}" \
   277         LIBCFLAGS="${l_libcflags}" \
   278         LIBCXXFLAGS="${l_libcxxflags}" \
   279         $maketarget
   281 %install
   282     rm -rf $RPM_BUILD_ROOT
   284     #   fetch GNU platform triple
   285     triple=`./config.guess`
   287     #   perform the standard installation procedure
   288     ( cd obj
   289       %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
   290     ) || exit $?
   292     #   cleanup installation tree
   293     mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
   294        $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
   295        >/dev/null 2>&1 || true
   296     mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
   297        $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
   298        >/dev/null 2>&1 || true
   299     dirs=""
   300     for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
   301         subdir=`echo "$multilib" | sed -e 's/;.*$//'`
   302         [ ".$subdir" = .. ] && continue
   303         mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
   304            $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
   305            >/dev/null 2>&1 || true
   306         mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
   307            $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
   308            >/dev/null 2>&1 || true
   309         dirs="$dirs $subdir"
   310     done
   311     for subdir in $dirs; do
   312         rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
   313     done
   314     mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
   315        $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
   316            >/dev/null 2>&1 || true
   318     #   strip installation tree
   319     rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
   320     rm -f  $RPM_BUILD_ROOT%{l_prefix}/info/dir
   321     rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7   >/dev/null 2>&1 || true
   322     rm -f  $RPM_BUILD_ROOT%{l_prefix}/lib/*.la   >/dev/null 2>&1 || true
   323     rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64      >/dev/null 2>&1 || true
   324     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
   325 %if "%{with_cxx}" == "yes"
   326     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++  >/dev/null 2>&1 || true
   327     rm -f  $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++  >/dev/null 2>&1 || true
   328 %endif
   329     strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
   330     for prog in cc1 cc1plus collect2 cpp; do
   331         strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
   332             >/dev/null 2>&1 || true
   333     done
   335     #   bump up installation tree
   336     ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
   337        $RPM_BUILD_ROOT%{l_prefix}/bin/cc
   338     ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
   339        $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
   340 %if "%{with_cxx}" == "yes"
   341     ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
   342        $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
   343 %endif
   345     #   determine installation file list
   346     %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
   348 %files -f files
   350 %clean
   351     rm -rf $RPM_BUILD_ROOT

mercurial