summaryrefslogtreecommitdiffstats
path: root/source-builder/config/gcc-common-1.cfg
blob: 42c8a7b7b2cd9428f0fedf8327a65a7b6974eeb9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
#
# GCC Common Support.
#
# This configuration file configure's, make's and install's gcc. It uses
# newlib, MPFR, MPC, and GMP in a one-tree build configuration.
#

%include %{_configdir}/checks.cfg

%ifn %{defined gcc_version_message}
%error No GCC Version message defined.
%endif

#
# The package description.
#
Name:      %{_target}-gcc-%{gcc_version}-newlib-%{newlib_version}-%{_host}-%{release}
Summary:   GCC v%{gcc_version} and Newlib v%{newlib_version} for target %{_target} on host %{_host}
Version:   %{gcc_version}
Release:   %{release}
URL: 	   http://gcc.gnu.org/

#
# Supports Candian Cross (Cxc).
#
%define allow_cxc

#
# The GCC library directory
#
%global _gcclibdir %{_prefix}/lib

#
# Default LTO to off.
#
%ifn %{defined with_lto}
 %define enable_lto 1
%endif

#
# The GCC version depends on the type of build we are doing.
#
%if %{rsb_released}
 %define rtems_gcc_version %{rsb_version}
%else
 %define rtems_gcc_version %{rtems_version}
%endif

#
# Packages GCC URLs, can be defined for older packages
#
%if %{!defined cloog_url}
 %define cloog_url https://gcc.gnu.org/pub/gcc/infrastructure
%endif
%if %{!defined isl_url}
 %define isl_url https://gcc.gnu.org/pub/gcc/infrastructure
%endif
%if %{!defined mpc_url}
 %define mpc_url https://gcc.gnu.org/pub/gcc/infrastructure
%endif
%if %{!defined mpfr_url}
 %define mpfr_url https://gcc.gnu.org/pub/gcc/infrastructure
%endif

#
# Packages GCC requires
#
%if %{defined cloog_version}
%source set cloog %{_url}/cloog-%{cloog_version}.tar.gz
%endif
%if %{defined isl_version}
%source set isl %{isl_url}/isl-%{isl_version}.tar.bz2
%endif
%source set mpc %{mpc_url}/mpc-%{mpc_version}.tar.gz
%source set mpfr %{mpfr_url}/mpfr-%{mpfr_version}.tar.bz2

#
# Prepare the source code.
#
%prep
  # save the build top directory and cd back to it rather than
  # using 'cd ..' because some shells change $PWD to a symlink's
  # target location and 'cd ..' fails.
  build_top=$(pwd)

  gcc_source=%{?gcc_external:%{gcc_expand_name}}%{!?gcc_external:"gcc-%{gcc_version}"}

  # gcc and optional the g++ core if separate packages
  source_dir_gcc=${gcc_source}
  %source setup gcc -q -n ${gcc_source}

  %patch setup gcc -p1
  cd ${build_top}

  # newlib
  source_dir_newlib=%{?newlib_external:%{newlib_expand_name}}%{!?newlib_external:"newlib-%{newlib_version}"}
  %source setup newlib -q -D -n ${source_dir_newlib}
  %patch setup newlib -p1
  cd ${build_top}

  # Link newlib into the gcc source tree
  %{__rmfile} ${source_dir_gcc}/newlib
  %{__ln_s} $PWD/${source_dir_newlib}/newlib ${source_dir_gcc}/newlib

%if %{defined cloog_version}
  # CLooG
  source_dir_cloog="cloog-%{cloog_version}"
  %source setup cloog -q -D -n cloog-%{cloog_version}
  %patch setup cloog -p1
  cd ${build_top}
  # Build CLooG one-tree style
  %{__rmfile} ${source_dir_gcc}/cloog
  %{__ln_s} $PWD/${source_dir_cloog} ${source_dir_gcc}/cloog
%endif

%if %{defined isl_version}
  # ISL
  source_dir_isl="isl-%{isl_version}"
  %source setup isl -q -D -n isl-%{isl_version}
  %patch setup isl -p1
  cd ${build_top}
  # Build ISL one-tree style
  %{__rmfile} ${source_dir_gcc}/isl
  %{__ln_s} $PWD/${source_dir_isl} ${source_dir_gcc}/isl
%endif

  # MPC
  source_dir_mpc="mpc-%{mpc_version}"
  %source setup mpc -q -D -n mpc-%{mpc_version}
  %patch setup mpc -p1
  cd ${build_top}
  # Build MPC one-tree style
  %{__rmfile} ${source_dir_gcc}/mpc
  %{__ln_s} $PWD/${source_dir_mpc} ${source_dir_gcc}/mpc

  # MPFR
  source_dir_mpfr="mpfr-%{mpfr_version}"
  %source setup mpfr -q -D -n mpfr-%{mpfr_version}
  %patch setup mpfr -p1
  cd ${build_top}
  # Build MPFR one-tree style
  %{__rmfile} ${source_dir_gcc}/mpfr
  %{__ln_s} $PWD/${source_dir_mpfr} ${source_dir_gcc}/mpfr

  echo "%{gcc_version_message}" > ${source_dir_gcc}/gcc/DEV-PHASE

  # Fix timestamps
  cd ${source_dir_gcc}
  contrib/gcc_update --touch
  cd ${build_top}

%build
  build_top=$(pwd)

  %if %{defined _internal_gsed_path}
    export PATH=%{_internal_gsed_path}/bin:$PATH
  %endif

  %{build_directory}

  mkdir -p ${build_dir}
  cd ${build_dir}

  # Languages.
  languages="c"
%if %{enable_cxx}
  languages="$languages,c++"
%endif
%if %{enable_ada}
  languages="$languages,ada"
%endif
%if %{enable_go}
  languages="$languages,go"
%endif
%if %{enable_fortran}
  languages="$languages,fortran"
%endif
%if %{enable_lto}
  languages="$languages,lto"
%endif

  %{host_build_flags}

  ../${source_dir_gcc}/configure \
    --prefix=%{_prefix} \
    --bindir=%{_bindir} \
    --exec_prefix=%{_exec_prefix} \
    --includedir=%{_includedir} \
    --libdir=%{_gcclibdir} \
    --libexecdir=%{_libexecdir} \
    --mandir=%{_mandir} \
    --infodir=%{_infodir} \
    --datadir=%{_datadir} \
    --build=%{_build} --host=%{_host} \
    --target=%{_target} \
    --disable-libstdcxx-pch \
    --with-gnu-as --with-gnu-ld --verbose \
    --with-newlib \
    --disable-nls --without-included-gettext \
    --disable-win32-registry \
    --disable-werror \
    --enable-version-specific-runtime-libs \
    --enable-newlib-io-c99-formats \
    %{?disable_MAKEINFO:MAKEINFO=missing} \
    %{?enable_newlib_tls:--enable-newlib-reent-thread-local} \
    %{?with_iconv:--enable-newlib-iconv} \
    %{?with_iconv:--enable-newlib-iconv-encodings=%{_newlib_iconv_encodings}} \
    %{?with_threads:--enable-threads}%{!?with_threads:--disable-threads} \
    %{?with_plugin:--enable-plugin}%{!?with_plugin:--disable-plugin} \
    %{?enable_obsolete:--enable-obsolete} \
    %{?with_libgomp:--enable-libgomp} \
    %{?gcc_configure_extra_options:%{gcc_configure_extra_options}} \
    --enable-languages="$languages"

  if test "%_host" != "%_build" ; then
    # Bug in gcc-3.2.1:
    # Somehow, gcc doesn't get syslimits.h right for Cdn-Xs
    mkdir -p gcc/include
    cp ../${source_dir_gcc}/gcc/gsyslimits.h gcc/include/syslimits.h
  fi

  %{__make} -w %{?_smp_mflags} all

  cd ${build_top}

%install
  build_top=$(pwd)

  %{__rmdir} $SB_BUILD_ROOT

  cd ${build_dir}
  %{__make} DESTDIR=$SB_BUILD_ROOT install
  cd ${build_top}

  # libiberty doesn't honor --libdir, but always installs to a
  # magically guessed _libdir
  %{__rmfile} ${SB_BUILD_ROOT}%{_libdir}/libiberty.a

  # We use the version from binutils
  %{__rmfile} $SB_BUILD_ROOT%{_bindir}/%{_target}-c++filt%{_exeext}

  # We don't ship info/dir
  %{__rmfile} $SB_BUILD_ROOT%{_infodir}/dir

  # Don't want libffi's man-pages
  %{__rmfile} $SB_BUILD_ROOT%{_mandir}/man3/*ffi*

  # Clean the symlinks away incase the source is a repo
  # Note, delete as a directory because of MSYS2 support on Windows.
  %{__rmdir} ${source_dir_gcc}/newlib
  %{__rmdir} ${source_dir_gcc}/mpfr
  %{__rmdir} ${source_dir_gcc}/mpc
  %{__rmdir} ${source_dir_gcc}/gmp

%testing
  # Add testing here.
  export RUNTESTFLAGS=--target_board=%{_target}-run