michael@320: ##
michael@320: ## gcc.spec -- OpenPKG RPM Package Specification
michael@320: ## Copyright (c) 2000-2010 OpenPKG Foundation e.V.
michael@320: ##
michael@320: ## Permission to use, copy, modify, and distribute this software for
michael@320: ## any purpose with or without fee is hereby granted, provided that
michael@320: ## the above copyright notice and this permission notice appear in all
michael@320: ## copies.
michael@320: ##
michael@320: ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
michael@320: ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
michael@320: ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
michael@320: ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
michael@320: ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
michael@320: ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
michael@320: ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
michael@320: ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
michael@320: ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
michael@320: ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
michael@320: ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
michael@320: ## SUCH DAMAGE.
michael@320: ##
michael@320:
michael@320: # package version
michael@320: %define V_full 4.5.2
michael@320: %define V_comp %nil
michael@320:
michael@320: # package information
michael@320: Name: gcc
michael@320: Summary: GNU Compiler Collection
michael@320: URL: http://gcc.gnu.org/
michael@320: Vendor: Free Software Foundation
michael@320: Packager: OpenPKG Foundation e.V.
michael@320: Distribution: OpenPKG Community
michael@320: Class: CORE
michael@320: Group: Compiler
michael@320: License: GPL
michael@320: Version: %{V_full}
michael@321: Release: 20110320
michael@320:
michael@320: # package options
michael@320: %option with_binutils yes
michael@320: %option with_cxx yes
michael@320: %option with_objc no
michael@320: %option with_java no
michael@320: %option with_fortran no
michael@320: %option with_optimize yes
michael@320: %option with_profile no
michael@320: %option with_threads yes
michael@320: %option with_multilib no
michael@320:
michael@320: # list of sources
michael@320: Source0: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-core-%{V_full}.tar.bz2
michael@320: Source1: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-g++-%{V_full}.tar.bz2
michael@320: Source2: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-objc-%{V_full}.tar.bz2
michael@320: Source3: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-java-%{V_full}.tar.bz2
michael@320: Source4: ftp://gcc.gnu.org/pub/gcc/releases/gcc-%{V_full}/gcc-fortran-%{V_full}.tar.bz2
michael@320: Patch0: gcc.patch
michael@320:
michael@320: # build information
michael@321: Prefix: %{l_prefix}
michael@321: BuildRoot: %{l_buildroot}
michael@322: BuildPreReq: OpenPKG, openpkg >= 20060823, make
michael@322: PreReq: OpenPKG, openpkg >= 20060823
michael@320: %if "%{with_binutils}" == "yes"
michael@320: BuildPreReq: binutils >= 2.14
michael@320: PreReq: binutils >= 2.14
michael@320: %endif
michael@320: BuildPreReq: mpc, mpfr, gmp
michael@320: PreReq: mpc, mpfr, gmp
michael@320: %if "%{with_cxx}" == "yes"
michael@320: BuildPreReq: libiconv
michael@320: PreReq: libiconv
michael@320: %endif
michael@320: %if "%{with_java}" == "yes"
michael@320: BuildPreReq: zlib
michael@320: PreReq: zlib
michael@320: %endif
michael@321: AutoReq: no
michael@321: AutoReqProv: no
michael@320:
michael@320: %description
michael@320: The GNU Compiler Collection (GCC) provides standard conforming and
michael@320: highly portable compilers for the ISO C, ISO C++, Objective-C,
michael@320: Fortran and Java languages.
michael@320:
michael@320: %track
michael@320: prog gcc = {
michael@320: version = %{V_full}
michael@320: url = ftp://gcc.gnu.org/pub/gcc/releases/
michael@320: regex = gcc-(4\.\d+\.\d+)
michael@320: url = ftp://gcc.gnu.org/pub/gcc/releases/gcc-__NEWVER__/
michael@320: regex = gcc-core-(\d+\.\d+\.\d+)\.tar\.bz2
michael@320: }
michael@320:
michael@320: %prep
michael@320: %setup -q
michael@320: %if "%{with_cxx}" == "yes"
michael@320: %setup -q -T -D -b 1
michael@320: %endif
michael@320: %if "%{with_objc}" == "yes"
michael@320: %setup -q -T -D -b 2
michael@320: %endif
michael@320: %if "%{with_java}" == "yes"
michael@320: %setup -q -T -D -b 3
michael@320: %endif
michael@320: %if "%{with_fortran}" == "yes"
michael@320: %setup -q -T -D -b 4
michael@320: %endif
michael@320: %patch -p0
michael@320: %{l_shtool} subst -v -s \
michael@320: -e 's;PREFIX_INCLUDE_DIR;PREFIX_INCLUDE_DIR_DISABLED;g' \
michael@320: gcc/configure
michael@320: if [ ".%{V_comp}" != . ]; then
michael@320: %{l_shtool} subst -v -s \
michael@320: -e 's;(libdir)/gcc/;(libdir)/gcc%{V_comp}/;' \
michael@320: `find . -name Makefile.in -type f -print`
michael@320: fi
michael@320: case "%{l_platform -t}" in
michael@320: amd64*-linux* )
michael@320: %{l_shtool} subst \
michael@320: -e 's/GLIBCXX_IS_NATIVE=false/GLIBCXX_IS_NATIVE=true/g' \
michael@320: -e 's/test x.gcc_no_link = xyes/false/g' \
michael@320: libstdc++-v3/configure
michael@320: ;;
michael@320: esac
michael@320: %{l_shtool} subst \
michael@320: -e 's;;"%{l_prefix}/include/iconv.h";' \
michael@320: libstdc++-v3/include/ext/codecvt_specializations.h
michael@320:
michael@320: %build
michael@320: # create build sub-directory
michael@320: %{l_shtool} mkdir -p obj
michael@320: cd obj
michael@320:
michael@322: # solve strange compatability problems
michael@322: case "%{l_platform -t}" in
michael@322: *-sunos* )
michael@322: %if "%{with_binutils}" == "no"
michael@322: ( echo "Building GCC on Solaris OS requires GNU as, however"
michael@322: echo "the OS native linker will be used in place of GNU ld."
michael@322: echo ""
michael@322: echo "To solve this problem, install the binutils package"
michael@322: echo "and build GCC again using the option 'with_binutils'."
michael@322: echo "OpenPKG will ignore GNU ld but use GNU as to build GCC."
michael@322: echo ""
michael@322: echo "Please note that this condition applies to OpenPKG"
michael@322: echo "building of the GCC package on Solaris only!"
michael@322: ) | %{l_rpmtool} msg -b -t warn
michael@322: exit 1;
michael@322: ;;
michael@322: %else
michael@322: # locate ld(1) and as(1), using the GNU assembler
michael@322: # but ignoring the presence of any OpenPKG linker
michael@322: LD=`PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/ccs/bin:/opt/bin:/opt/sbin \
michael@322: which ld`
michael@322: ;;
michael@322: %endif
michael@322: *-* )
michael@322: # determine ld(1) and as(1) usage, allowing either
michael@322: # one to be from the GNU distribution of binutils
michael@322: LD=%{l_tool_locate ld ld}
michael@322: ;;
michael@322: esac
michael@320: l_with_gnu_ld_as=""
michael@320: AS=%{l_tool_locate as as}
michael@322: echo $LD | grep '^/' >/dev/null && l_with_gnu_ld_as="--with-ld=$LD"
michael@320: echo $AS | grep '^/' >/dev/null && l_with_gnu_ld_as="${l_with_gnu_ld_as} --with-as=$AS"
michael@322: $LD --version /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"
michael@322: $AS --version /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"
michael@320:
michael@320: # determine threads usage
michael@320: %if "%{with_threads}" == "yes"
michael@320: l_enable_threads="posix"
michael@320: %else
michael@320: l_enable_threads="single"
michael@320: %endif
michael@320:
michael@320: # determine language usage
michael@320: l_enable_languages="c"
michael@320: %if "%{with_cxx}" == "yes"
michael@320: l_enable_languages="${l_enable_languages},c++"
michael@320: %endif
michael@320: %if "%{with_objc}" == "yes"
michael@320: l_enable_languages="${l_enable_languages},objc"
michael@320: %endif
michael@320: %if "%{with_java}" == "yes"
michael@320: l_enable_languages="${l_enable_languages},java"
michael@320: %endif
michael@320: %if "%{with_fortran}" == "yes"
michael@320: l_enable_languages="${l_enable_languages},f95"
michael@320: %endif
michael@320:
michael@320: # disable GNU iconv usage
michael@320: ( echo "am_cv_func_iconv=no"
michael@320: echo "am_cv_lib_iconv=no"
michael@320: ) >config.cache
michael@320:
michael@320: # configure the package
michael@322: LD="$LD" \
michael@322: AS="$AS" \
michael@320: CC="%{l_cc}" \
michael@320: CFLAGS="%{l_cflags}" \
michael@320: %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
michael@320: CPPFLAGS="%{l_cppflags}" \
michael@320: LDFLAGS="%{l_ldflags}" \
michael@320: %endif
michael@320: CONFIG_SHELL="%{l_bash}" \
michael@320: ../configure \
michael@320: --with-bugurl="http://openpkg.org/" \
michael@320: --with-pkgversion="%{l_openpkg_release -F "OpenPKG-%%t"}" \
michael@320: --cache-file=./config.cache \
michael@320: --srcdir=`pwd`/.. \
michael@320: --prefix=%{l_prefix} \
michael@320: --exec-prefix=%{l_prefix} \
michael@320: --mandir=%{l_prefix}/man \
michael@320: --infodir=%{l_prefix}/info \
michael@320: --includedir=%{l_prefix}/include/gcc%{V_comp} \
michael@320: --libexecdir=%{l_prefix}/libexec/gcc%{V_comp} \
michael@320: --with-gxx-include-dir=%{l_prefix}/include/g++%{V_comp} \
michael@320: --with-local-prefix=%{l_prefix}/lib/gcc%{V_comp} \
michael@320: --enable-languages="${l_enable_languages}" \
michael@320: --enable-threads="${l_enable_threads}" \
michael@320: --disable-maintainer-mode \
michael@320: --disable-shared \
michael@320: --disable-nls \
michael@320: %if "%{with_java}" == "yes"
michael@320: --with-system-zlib \
michael@320: %endif
michael@320: %if "%{with_multilib}" == "yes"
michael@320: --enable-multilib \
michael@320: %else
michael@320: --disable-multilib \
michael@320: %endif
michael@320: %if "%{with_cxx}" == "yes"
michael@320: --with-libiconv-prefix=%{l_prefix} \
michael@320: %endif
michael@320: --with-gmp=%{l_prefix} \
michael@320: --with-mpfr=%{l_prefix} \
michael@320: --with-mpc=%{l_prefix} \
michael@320: ${l_with_gnu_ld_as}
michael@320:
michael@320: # determine build flags
michael@320: l_ccisgcc=no
michael@320: if [ ".`(%{l_cc} -v; %{l_cc} --version) &1 | grep -i 'gcc'`" != . ]; then
michael@320: l_ccisgcc=yes
michael@320: fi
michael@320: l_cflags=""
michael@320: l_cxxflags=""
michael@320: l_boot_cflags=""
michael@320: l_libcflags="-g"
michael@320: l_libcxxflags="-g"
michael@320: # at least GNU as from GNU binutils supports -pipe always
michael@320: "$AS" --version /dev/null | grep "^GNU assembler " >/dev/null && {
michael@320: l_boot_cflags="$l_boot_cflags -pipe"
michael@320: l_libcxxflags="$l_libcxxflags -pipe"
michael@320: }
michael@320: %if "%{with_optimize}" == "yes"
michael@320: # conservatively optimize the generated program code
michael@320: # (also _tune_ for particular CPUs, but _without_ requiring these CPUs!)
michael@320: l_cflags="$l_cflags -O"
michael@320: l_boot_cflags="$l_boot_cflags -O2 -fomit-frame-pointer"
michael@320: case "%{l_platform -t}" in
michael@320: *i?86-* ) l_boot_cflags="$l_boot_cflags -mtune=pentium3" ;;
michael@320: *sun4[uv]-* ) l_boot_cflags="$l_boot_cflags -mtune=v9" ;;
michael@320: esac
michael@320: l_libcxxflags="$l_libcxxflags -O2 -fno-implicit-templates"
michael@320: %else
michael@320: # else do no optimizations at all to reduce problems to minimum in advance
michael@320: l_boot_cflags="$l_boot_cflags -O0"
michael@320: l_libcxxflags="$l_libcxxflags -O0"
michael@320: %endif
michael@320: maketarget="bootstrap2-lean"
michael@320: %if "%{with_profile}" == "yes"
michael@320: # GCC >= 3.4 supports a "profiledbootstrap" target to build an
michael@320: # optimized version of itself through profiling. Because this
michael@320: # requires a (bootstrapping) C compiler with 64-bit arithmetic,
michael@320: # the whole approach is currently supported only if already
michael@320: # building with GCC as the bootstrapping C compiler.
michael@320: if [ ".$l_ccisgcc" = .yes ]; then
michael@320: maketarget="profiledbootstrap"
michael@320: fi
michael@320: %endif
michael@320: case "%{l_platform -t}" in
michael@320: amd64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
michael@320: ia64-* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
michael@320: sparc64-freebsd* ) l_cflags="$l_cflags -fPIC"; l_cxxflags="$l_cxxflags -fPIC" ;;
michael@320: esac
michael@320: %if "%{with_java}" == "yes" || "%{with_fortran}" == "yes" || "%{with_cxx}" == "yes"
michael@320: l_cflags="$l_cflags %{l_cppflags}"
michael@320: l_cxxflags="$l_cxxflags %{l_cppflags}"
michael@320: l_libcflags="$l_libcflags %{l_cppflags}"
michael@320: l_libcxxflags="$l_libcxxflags %{l_cppflags}"
michael@320: %endif
michael@320:
michael@320: # build the package
michael@320: MAKE="%{l_make} %{l_mflags}" \
michael@320: %{l_make} %{l_mflags} \
michael@320: MAKE="%{l_make} %{l_mflags}" \
michael@320: BOOT_CFLAGS="${l_boot_cflags}" \
michael@320: CFLAGS="${l_cflags}" \
michael@320: CXXFLAGS="${l_cxxflags}" \
michael@320: LIBCFLAGS="${l_libcflags}" \
michael@320: LIBCXXFLAGS="${l_libcxxflags}" \
michael@320: $maketarget
michael@320:
michael@320: %install
michael@321: rm -rf $RPM_BUILD_ROOT
michael@320:
michael@320: # fetch GNU platform triple
michael@320: triple=`./config.guess`
michael@320:
michael@320: # perform the standard installation procedure
michael@320: ( cd obj
michael@320: %{l_make} %{l_mflags} install DESTDIR=$RPM_BUILD_ROOT
michael@320: ) || exit $?
michael@320:
michael@320: # cleanup installation tree
michael@320: mv $RPM_BUILD_ROOT%{l_prefix}/lib/{lib*.a,*.spec} \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
michael@320: >/dev/null 2>&1 || true
michael@320: mv $RPM_BUILD_ROOT%{l_prefix}/lib64/{lib*.a,*.spec} \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/ \
michael@320: >/dev/null 2>&1 || true
michael@320: dirs=""
michael@320: for multilib in `$RPM_BUILD_ROOT%{l_prefix}/bin/gcc --print-multi-lib`; do
michael@320: subdir=`echo "$multilib" | sed -e 's/;.*$//'`
michael@320: [ ".$subdir" = .. ] && continue
michael@320: mv $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir/lib*.a \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
michael@320: >/dev/null 2>&1 || true
michael@320: mv $RPM_BUILD_ROOT%{l_prefix}/lib64/$subdir/lib*.a \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/$subdir/ \
michael@320: >/dev/null 2>&1 || true
michael@320: dirs="$dirs $subdir"
michael@320: done
michael@320: for subdir in $dirs; do
michael@320: rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib/$subdir >/dev/null 2>&1 || true
michael@320: done
michael@320: mv $RPM_BUILD_ROOT%{l_prefix}/${triple}/include/* \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/include/ \
michael@320: >/dev/null 2>&1 || true
michael@320:
michael@320: # strip installation tree
michael@320: rm -rf $RPM_BUILD_ROOT%{l_prefix}/${triple}
michael@320: rm -f $RPM_BUILD_ROOT%{l_prefix}/info/dir
michael@320: rm -rf $RPM_BUILD_ROOT%{l_prefix}/man/man7 >/dev/null 2>&1 || true
michael@320: rm -f $RPM_BUILD_ROOT%{l_prefix}/lib/*.la >/dev/null 2>&1 || true
michael@320: rm -rf $RPM_BUILD_ROOT%{l_prefix}/lib64 >/dev/null 2>&1 || true
michael@320: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-gcc* >/dev/null 2>&1 || true
michael@320: %if "%{with_cxx}" == "yes"
michael@320: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-c++ >/dev/null 2>&1 || true
michael@320: rm -f $RPM_BUILD_ROOT%{l_prefix}/bin/*-g++ >/dev/null 2>&1 || true
michael@320: %endif
michael@320: strip $RPM_BUILD_ROOT%{l_prefix}/bin/* >/dev/null 2>&1 || true
michael@320: for prog in cc1 cc1plus collect2 cpp; do
michael@320: strip $RPM_BUILD_ROOT%{l_prefix}/lib/gcc%{V_comp}/${triple}/[0-9]*/${prog} \
michael@320: >/dev/null 2>&1 || true
michael@320: done
michael@320:
michael@320: # bump up installation tree
michael@320: ln $RPM_BUILD_ROOT%{l_prefix}/bin/gcc \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/bin/cc
michael@320: ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/gcc.1 \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/man/man1/cc.1
michael@320: %if "%{with_cxx}" == "yes"
michael@320: ln $RPM_BUILD_ROOT%{l_prefix}/man/man1/g++.1 \
michael@320: $RPM_BUILD_ROOT%{l_prefix}/man/man1/c++.1
michael@320: %endif
michael@320:
michael@320: # determine installation file list
michael@320: %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
michael@320:
michael@320: %files -f files
michael@320:
michael@320: %clean
michael@321: rm -rf $RPM_BUILD_ROOT
michael@320: