[4f26bdb] | 1 | # |
---|
| 2 | # GCC Common Support. |
---|
| 3 | # |
---|
| 4 | # This configuration file configure's, make's and install's gcc. It uses |
---|
| 5 | # newlib, MPFR, MPC, and GMP in a one-tree build configuration. |
---|
| 6 | # |
---|
| 7 | |
---|
| 8 | %include %{_configdir}/checks.cfg |
---|
| 9 | |
---|
| 10 | %ifn %{defined gcc_version_message} |
---|
| 11 | %error No GCC Version message defined. |
---|
| 12 | %endif |
---|
| 13 | |
---|
[4ce931b] | 14 | # |
---|
| 15 | # The package description. |
---|
| 16 | # |
---|
[8197b8e] | 17 | Name: %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{_host}-%{release} |
---|
[4f26bdb] | 18 | Summary: GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host} |
---|
| 19 | Version: %{gcc_version} |
---|
| 20 | Release: %{release} |
---|
| 21 | URL: http://gcc.gnu.org/ |
---|
| 22 | BuildRoot: %{_tmppath}/%{name}-root-%(%{__id_u} -n) |
---|
| 23 | |
---|
| 24 | # |
---|
| 25 | # Supports Candian Cross (Cxc). |
---|
| 26 | # |
---|
| 27 | %define allow_cxc |
---|
| 28 | |
---|
| 29 | # |
---|
| 30 | # The GCC library directory |
---|
| 31 | # |
---|
| 32 | %global _gcclibdir %{_prefix}/lib |
---|
| 33 | |
---|
| 34 | # |
---|
| 35 | # Prepare the source code. |
---|
| 36 | # |
---|
| 37 | %prep |
---|
[b8b0f44] | 38 | # save the build top directory and cd back to it rather than |
---|
| 39 | # using 'cd ..' because some shells change $PWD to a symlink's |
---|
| 40 | # target location and 'cd ..' fails. |
---|
| 41 | build_top=$(pwd) |
---|
| 42 | |
---|
[d758ab9] | 43 | gcc_source=%{?gcc_external:%{gcc_expand_name}}%{!?gcc_external:"gcc-%{gcc_version}"} |
---|
| 44 | |
---|
[2b069dc] | 45 | # gcc and optional the g++ core if separate packages |
---|
[d758ab9] | 46 | source_dir_gcc=${gcc_source} |
---|
| 47 | %source setup gcc -q -n ${gcc_source} |
---|
| 48 | |
---|
[9a15c40] | 49 | %patch setup gcc -p1 |
---|
[b8b0f44] | 50 | cd ${build_top} |
---|
[4f26bdb] | 51 | |
---|
| 52 | # newlib |
---|
[9a15c40] | 53 | source_dir_newlib="newlib-%{newlib_version}" |
---|
| 54 | %source setup newlib -q -D -n newlib-%{newlib_version} |
---|
| 55 | %patch setup newlib -p1 |
---|
[b8b0f44] | 56 | cd ${build_top} |
---|
[2b069dc] | 57 | |
---|
[4f26bdb] | 58 | # Link newlib into the gcc source tree |
---|
[9a15c40] | 59 | %{__rmfile} ${source_dir_gcc}/newlib |
---|
| 60 | %{__ln_s} $PWD/${source_dir_newlib}/newlib ${source_dir_gcc}/newlib |
---|
[4f26bdb] | 61 | |
---|
| 62 | # MPFR |
---|
[9a15c40] | 63 | source_dir_mpfr="mpfr-%{mpfr_version}" |
---|
| 64 | %source setup mpfr -q -D -n mpfr-%{mpfr_version} |
---|
| 65 | %patch setup mpfr -p1 |
---|
[b8b0f44] | 66 | cd ${build_top} |
---|
[4f26bdb] | 67 | # Build MPFR one-tree style |
---|
[9a15c40] | 68 | %{__rmfile} ${source_dir_gcc}/mpfr |
---|
| 69 | %{__ln_s} $PWD/${source_dir_mpfr} ${source_dir_gcc}/mpfr |
---|
[4f26bdb] | 70 | |
---|
| 71 | # MPC |
---|
[9a15c40] | 72 | source_dir_mpc="mpc-%{mpc_version}" |
---|
| 73 | %source setup mpc -q -D -n mpc-%{mpc_version} |
---|
| 74 | %patch setup mpc -p1 |
---|
[b8b0f44] | 75 | cd ${build_top} |
---|
[4f26bdb] | 76 | # Build MPC one-tree style |
---|
[9a15c40] | 77 | %{__rmfile} ${source_dir_gcc}/mpc |
---|
| 78 | %{__ln_s} $PWD/${source_dir_mpc} ${source_dir_gcc}/mpc |
---|
[4f26bdb] | 79 | |
---|
| 80 | # GMP |
---|
[9a15c40] | 81 | source_dir_gmp="gmp-%{gmp_version}" |
---|
| 82 | %source setup gmp -q -D -n gmp-%{gmp_version} |
---|
| 83 | %patch setup gmp -p1 |
---|
[b8b0f44] | 84 | cd ${build_top} |
---|
[4f26bdb] | 85 | # Build GMP one-tree style |
---|
[9a15c40] | 86 | %{__rmfile} ${source_dir_gcc}/gmp |
---|
| 87 | %{__ln_s} $PWD/${source_dir_gmp} ${source_dir_gcc}/gmp |
---|
[4f26bdb] | 88 | |
---|
[9a15c40] | 89 | echo "%{gcc_version_message}" > ${source_dir_gcc}/gcc/DEV-PHASE |
---|
[4f26bdb] | 90 | |
---|
| 91 | # Fix timestamps |
---|
[9a15c40] | 92 | cd ${source_dir_gcc} |
---|
[4f26bdb] | 93 | contrib/gcc_update --touch |
---|
[b8b0f44] | 94 | cd ${build_top} |
---|
[4f26bdb] | 95 | |
---|
| 96 | %build |
---|
[b8b0f44] | 97 | build_top=$(pwd) |
---|
| 98 | |
---|
[db65c6a] | 99 | %{build_directory} |
---|
| 100 | |
---|
[4f26bdb] | 101 | mkdir -p ${build_dir} |
---|
| 102 | cd ${build_dir} |
---|
[649a64c] | 103 | |
---|
| 104 | # Languages. |
---|
[4f26bdb] | 105 | languages="c" |
---|
| 106 | %if %{enable_cxx} |
---|
| 107 | languages="$languages,c++" |
---|
| 108 | %endif |
---|
[649a64c] | 109 | %if %{enable_ada} |
---|
| 110 | languages="$languages,ada" |
---|
| 111 | %endif |
---|
| 112 | %if %{enable_go} |
---|
| 113 | languages="$languages,go" |
---|
| 114 | %endif |
---|
| 115 | %if %{enable_fortran} |
---|
| 116 | languages="$languages,fortran" |
---|
| 117 | %endif |
---|
| 118 | %if %{enable_java} |
---|
| 119 | languages="$languages,java" |
---|
| 120 | %endif |
---|
| 121 | %if %{enable_objc} |
---|
| 122 | languages="$languages,objc" |
---|
| 123 | %endif |
---|
| 124 | |
---|
[dd51e39] | 125 | %if %{_host_os} == mingw32 |
---|
| 126 | zlib_option="" |
---|
| 127 | %else |
---|
| 128 | zlib_option="--with-system-zlib" |
---|
| 129 | %endif |
---|
| 130 | |
---|
[db65c6a] | 131 | %{host_build_flags} |
---|
[649a64c] | 132 | |
---|
[9a15c40] | 133 | ../${source_dir_gcc}/configure \ |
---|
[4f26bdb] | 134 | --prefix=%{_prefix} \ |
---|
| 135 | --bindir=%{_bindir} \ |
---|
| 136 | --exec_prefix=%{_exec_prefix} \ |
---|
| 137 | --includedir=%{_includedir} \ |
---|
| 138 | --libdir=%{_gcclibdir} \ |
---|
| 139 | --libexecdir=%{_libexecdir} \ |
---|
| 140 | --mandir=%{_mandir} \ |
---|
| 141 | --infodir=%{_infodir} \ |
---|
| 142 | --datadir=%{_datadir} \ |
---|
| 143 | --build=%{_build} --host=%{_host} \ |
---|
| 144 | --target=%{_target} \ |
---|
| 145 | --disable-libstdcxx-pch \ |
---|
| 146 | --with-gnu-as --with-gnu-ld --verbose \ |
---|
| 147 | --with-newlib \ |
---|
[dd51e39] | 148 | "$zlib_option" \ |
---|
[4f26bdb] | 149 | --disable-nls --without-included-gettext \ |
---|
| 150 | --disable-win32-registry \ |
---|
| 151 | --enable-version-specific-runtime-libs \ |
---|
| 152 | --disable-lto \ |
---|
| 153 | --enable-newlib-io-c99-formats \ |
---|
| 154 | %{?with_iconv:--enable-newlib-iconv} \ |
---|
[27d6ea0] | 155 | %{?with_iconv:--enable-newlib-iconv-encodings=%{_newlib_iconv_encodings}} \ |
---|
[4f26bdb] | 156 | %{?with_threads:--enable-threads}%{!?with_threads:--disable-threads} \ |
---|
| 157 | %{?with_plugin:--enable-plugin}%{!?with_plugin:--disable-plugin} \ |
---|
| 158 | %{?enable_obsolete:--enable-obsolete} \ |
---|
[2f4bd55] | 159 | %{?gcc_configure_extra_options:%{gcc_configure_extra_options}} \ |
---|
| 160 | --enable-languages="$languages" |
---|
[4f26bdb] | 161 | |
---|
| 162 | if test "%_host" != "%_build" ; then |
---|
| 163 | # Bug in gcc-3.2.1: |
---|
| 164 | # Somehow, gcc doesn't get syslimits.h right for Cdn-Xs |
---|
| 165 | mkdir -p gcc/include |
---|
[9a15c40] | 166 | cp ../${source_dir_gcc}/gcc/gsyslimits.h gcc/include/syslimits.h |
---|
[4f26bdb] | 167 | fi |
---|
| 168 | |
---|
| 169 | %{__make} %{?_smp_mflags} all |
---|
[b8b0f44] | 170 | |
---|
| 171 | cd ${build_top} |
---|
[4f26bdb] | 172 | |
---|
| 173 | %install |
---|
[b8b0f44] | 174 | build_top=$(pwd) |
---|
| 175 | |
---|
[4f26bdb] | 176 | %{__rmdir} $SB_BUILD_ROOT |
---|
| 177 | |
---|
| 178 | cd ${build_dir} |
---|
| 179 | %{__make} DESTDIR=$SB_BUILD_ROOT install |
---|
[b8b0f44] | 180 | cd ${build_top} |
---|
[4f26bdb] | 181 | |
---|
| 182 | # libiberty doesn't honor --libdir, but always installs to a |
---|
| 183 | # magically guessed _libdir |
---|
| 184 | %{__rmfile} ${SB_BUILD_ROOT}%{_libdir}/libiberty.a |
---|
| 185 | |
---|
| 186 | # We use the version from binutils |
---|
| 187 | %{__rmfile} $SB_BUILD_ROOT%{_bindir}/%{_target}-c++filt%{_exeext} |
---|
| 188 | |
---|
| 189 | # We don't ship info/dir |
---|
| 190 | %{__rmfile} $SB_BUILD_ROOT%{_infodir}/dir |
---|
| 191 | |
---|
| 192 | # Don't want libffi's man-pages |
---|
| 193 | %{__rmfile} $SB_BUILD_ROOT%{_mandir}/man3/*ffi* |
---|
[b8ee74d] | 194 | |
---|
[649a64c] | 195 | # Clean the symlinks away incase the source is a repo |
---|
[d4eb08f] | 196 | # Note, delete as a directory because of MSYS2 support on Windows. |
---|
| 197 | %{__rmdir} ${source_dir_gcc}/newlib |
---|
| 198 | %{__rmdir} ${source_dir_gcc}/mpfr |
---|
| 199 | %{__rmdir} ${source_dir_gcc}/mpc |
---|
| 200 | %{__rmdir} ${source_dir_gcc}/gmp |
---|
[649a64c] | 201 | |
---|
[b8ee74d] | 202 | %testing |
---|
| 203 | # Add testing here. |
---|
| 204 | export RUNTESTFLAGS=--target_board=%{_target}-run |
---|