summaryrefslogtreecommitdiffstats
path: root/scripts-ada/gnatnewlib/gnatnewlib.spec.in
blob: 5462ca17ef32a9d86c36dd59906f0568334ccd81 (plain)
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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
#
# spec file for building gcc for rtems
# 
# Copyright  (c)  1999  OARCorp, Huntsville, AL
#
# please send bugfixes or comments to joel@OARcorp.com
#

Vendor:       OAR Corporation
Distribution: Linux
Name:         @target_alias@-gnat-newlib
Summary:      gnat, gcc, and newlib C Library for @target_alias@.
Group:	      gnatrtems
Release:      @Release@
License:      gcc is GPL/LGPL ; newlib no has restrictions on run-time usage

Provides:     	rtems-base-gnat @target_alias@-gnat 
Provides:       rtems-base-gnat-binutils @target_alias@-gnat-binutils
# Requires:     	@target_alias@-binutils

Autoreqprov:  	on
Packager:     	corsepiu@faw.uni-ulm.de and joel@OARcorp.com

Version:      	gnat@gnat_version@
Source0:	ftp://ftp.gnu.org/pub/gnu/gcc/gcc-@gcc_version@.tar.gz
Source1:	ftp://sourceware.cygnus/com/pub/newlib/newlib-@newlib_version@.tar.gz
Source2:	ftp://cs.nyu.edu/pub/gnat/gnat-@gnat_version@-src.tar.gz
Source3:      	ftp://ftp.gnu.org/pub/gnu/binutils/binutils-@binutils_version@.tar.gz
Patch0:		gcc-@gcc_version@-rtems-gnat-@gnat_version@-@gcc_patch_version@.diff
Patch1:		newlib-@newlib_version@-rtems-@newlib_patch_version@.diff
Patch2:		gnat-@gnat_version@-rtems-@gnat_patch_version@.diff
Patch3:		binutils-@binutils_version@-rtems-gnat-@gnat_version@-@binutils_patch_version@.diff
Patch4:		newlib-@newlib_version@-rtems-gnat-@gnat_version@-@newlib_patch_version@.diff
#
Buildroot:	/tmp

#
# The original sources are not included in the source RPM.
# If we included them, then the source RPMs for each target
# would duplicate MBs of source unnecessarily.  This is 
# a duplication of over 30 MBs of source for each of
# the more than 10 targets it is possible to build.
#
# You can get them yourself from the Internet and copy them to
# your /usr/src/redhat/SOURCES directory ($RPM_SOURCE_DIR).
# Or you can try the ftp options of rpm :-)
#
NoSource:	0
NoSource:	1
NoSource:	2
NoSource:	3

%description
RTEMS is an open source operating system for embedded systems.

This is gcc's and newlib C Library's sources with patches for RTEMS.

 The original sources are not included in the source RPM.
 If we included them, then the source RPMs for each target
 would duplicate MBs of source unnecessarily.  This is 
 a duplication of over 30 MBs of source for each of
 the more than 10 targets it is possible to build.

 You can get them yourself from the Internet and copy them to
 your /usr/src/redhat/SOURCES directory ($RPM_SOURCE_DIR).
 Or you can try the ftp options of rpm :-)

This version of GNAT/RTEMS RPMs is based on the following:

  + gnat-@gnat_version@-src
  + gcc-@gcc_version@
  + newlib-@newlib_version@
  + binutils-@binutils_version@

with appropriate patches.

%package -n rtems-base-gnat
Summary:      base package for rtems gnat, gcc, and newlib C Library
Group: gnatrtems

%description -n rtems-base-gnat

RTEMS is an open source operating system for embedded systems.

This is the files for gnat, gcc, and newlib that are shared by all targets.

%package -n rtems-base-gnat-binutils
Summary:      base package for rtems binutils
Group: gnatrtems

%description -n rtems-base-gnat-binutils

RTEMS is an open source operating system for embedded systems.

This is the base for binutils regardless of target CPU.

%package -n @target_alias@-gnat-binutils
Summary:      rtems binutils for @target_alias@
Group: gnatrtems
Requires: rtems-base-gnat-binutils

%description -n @target_alias@-gnat-binutils

RTEMS is an open source operating system for embedded systems.

This is the GNU binutils for RTEMS targetting @target_alias@.

%package -n @target_alias@-gnat
Summary:      rtems gnat, gcc, and newlib C Library for @target_alias@
Group: gnatrtems
Requires: @target_alias@-gnat-binutils rtems-base-gnat

%description -n @target_alias@-gnat
RTEMS is an open source operating system for embedded systems.

This is gnat, gcc, and newlib C Library for @target_alias@.

%prep
# untar the sources inside @target_alias@-gnat-newlib
%setup -c -n @target_alias@-gnat-newlib -a 0 -a 1 -a 2 -a 3

%patch0 -p0
%patch2 -p0
%patch3 -p0

# this patch needs to be applied with a -p1
cd newlib-@newlib_version@
%patch1 -p1
%patch4 -p1
cd ..

  # this 281 needs to be a variable. :(
  cd gcc-@gcc_version@
  patch -p0 <../gnat-@gnat_version@-src/src/gcc-281.dif
  
  mv ../gnat-@gnat_version@-src/src/ada .

  cd ada 
  touch treeprs.ads a-[es]info.h nmake.ad[bs]
  cd ../..    # now back at top 

  # Now we should be done patching everything.. build up a source tree

  # this sequence is VERY dependent on the versions involved
  #  When the gcc gets updated to 2.95.x or newer, this HAS to change.

  mkdir src
  cd src
  # configure scripts
  for f in config config.guess config.sub configure configure.in \
        config-ml.in include install-sh ltconfig ltmain.sh Makefile.in \
        move-if-change mkinstalldirs libiberty
  do
        # some packages have more configure scripts than others
        # our list is inclusive
	test -r ../binutils-@binutils_version@/$f && \
          mv ../binutils-@binutils_version@/$f .
  done

  # link in gcc
  mv ../gcc-@gcc_version@ gcc
 
  # link in binutils
  for f in bfd binutils gas gprof ld opcodes etc
  do
    mv ../binutils-@binutils_version@/$f .
  done

  # link in newlib
  mv ../newlib-@newlib_version@/newlib .
  cd ..

  # now we have a linked together source tree
  test -d build || mkdir build


%build
  cd build
  # after we switch off gcc 2.8.1, configure using gcc not a src directory
  # and build binutils separately.
  ../src/configure --target=@target_alias@ \
    --with-gnu-as --with-gnu-ld --with-newlib --verbose \
    --prefix=/opt/gnatrtems

  # for now we are building all the languages
  #  '--enable-languages=c,c++'

#  #  This is a hack that is only because gnat still uses gcc 2.8.1
#  test -d ${RPM_BUILD_ROOT}/opt/gnatrtems/@target_alias@ || 
#    mkdir -p ${RPM_BUILD_ROOT}/opt/gnatrtems/@target_alias@
#  for dir in ${RPM_BUILD_ROOT}/opt/gnatrtems/@target_alias@/include \
#             ${RPM_BUILD_ROOT}/opt/gnatrtems/@target_alias@/sys-include
#  do
#    test -d ${dir} || mkdir -p ${dir}
#    cp ../newlib-@newlib_version@/newlib/libc/sys/rtems/include/limits.h ${dir}
#  done

  make CC=gcc CFLAGS="-O2" LANGUAGES="c" all
  make CC=gcc CFLAGS="-O2" LANGUAGES="c" info
  # must be installed to allow gnat to continue to build
  make CC=gcc CFLAGS="-O2" LANGUAGES="c" install install-info
  make prefix=$RPM_BUILD_ROOT/opt/gnatrtems \
    CC=gcc CFLAGS="-O2" LANGUAGES="c" install install-info

#  When GNAT uses a gcc that finds the RTEMS limits.h, this will not
#  be needed.  This should not be needed if the limits.h trick above works.
#   cd gcc
#   rm -f stmp-multilib
#   find . -name "*.a" -print | xargs -e rm -f
#
#   make all
#   cd ..

####################     Ada from here down      ###################

    # Just so the log shows what directory we are in.
    pwd
    cd gcc
    echo "Starting build of GNAT proper."
    make CC=gcc CFLAGS="-O2" LANGUAGES="c ada gcov"

    echo "Starting build of cross GNAT tools"
    make CC=gcc CFLAGS="-O2 -g" LANGUAGES="c ada gcov" cross-gnattools

    echo "Starting build of ada.all.cross"
    make CC=gcc CFLAGS="-O2" LANGUAGES="c ada gcov" ada.all.cross

    # must have -gnato to pass validation
    # may want CC=gcc GNATLIBCFLAGS="-O3" GNATLIBFLAGS="-gnatpgn" gnatliy
    # NOTE:  gnatlib is not multilib'ed -- serious embedded flaw
    echo "Starting build of gnatlib"
    make CC=gcc GNATLIBCFLAGS="-O2 -g" gnatlib

%install
  cd build
  # Bug in gcc-2.95.1: It doesn't build this installation directory
  # If it doesn't find it, gcc doesn't install @target_alias@/bin/gcc
  # ../gcc-@gcc_version@/mkinstalldirs \
  #   $RPM_BUILD_ROOT/opt/gnatrtems/@target_alias@/bin

  cd gcc
  echo "Starting install of gnat"
  make prefix=$RPM_BUILD_ROOT/opt/gnatrtems \
     CC=gcc CFLAGS="-O2 -g -gnata -gnatp" LANGUAGES="c ada" install
  # GNAT has to be mostly installed to even build itself

#  hack to get rid of symlinks to dynamic libraries that don't exist
  find $RPM_BUILD_ROOT/opt/gnatrtems -name "*.so" | xargs -e rm -f

  make prefix=$RPM_BUILD_ROOT/opt/gnatrtems install-info

  # cd go back to build/
  pwd
  cd ..

  # gzip info files
  gzip -f $RPM_BUILD_ROOT/opt/gnatrtems/info/*.info 2>/dev/null
  gzip -f $RPM_BUILD_ROOT/opt/gnatrtems/info/*.info-? 2>/dev/null
  gzip -f $RPM_BUILD_ROOT/opt/gnatrtems/info/*.info-?? 2>/dev/null

  rm -f dirs ;
  echo "%dir /opt/gnatrtems/lib" >> dirs ;
  echo "%dir /opt/gnatrtems/lib/gcc-lib" >> dirs ;
  echo "%dir /opt/gnatrtems/lib/gcc-lib/@target_alias@" >> dirs ;

  touch ../files
  # if test -f $RPM_BUILD_ROOT/opt/gnatrtems/info/configure.info.gz;
  # then
# These common files are only present in binutils >= 2.9.5
  #   find $RPM_BUILD_ROOT/opt/gnatrtems/info -name 'configure.*' | \
  #     sed -e "s,^$RPM_BUILD_ROOT,,g" > ../files
  # else
  #   touch ../files
  # fi
# These target specific files are only present in binutils >= 2.9.5
  if test -f /opt/gnatrtems/bin/@target_alias@-readelf@exe_ext@;
  then
    echo /opt/gnatrtems/bin/@target_alias@-readelf@exe_ext@ > ../files.target
  else
    touch ../files.target
  fi

  # Collect multilib subdirectories
  TGTDIR="$RPM_BUILD_ROOT/opt/gnatrtems/lib/gcc-lib/@target_alias@/@gcc_version@"
  find $TGTDIR \
    \( -type d -a ! -path "$TGTDIR/include*" \) -print | \
    sed -e "s,^$RPM_BUILD_ROOT,%dir ,g" >> dirs

  # Collect files to go into different packages
  # NOTE: This is left in as a place holder to move the 2.95.x code into.
  cp dirs ../files.gcc

  f=`find $TGTDIR ! -type d -print | sed -e "s,^$RPM_BUILD_ROOT,,g"`;
  for i in $f; do
    case $i in
    *) echo "$i" >> ../files.gcc ;;
    esac
  done

%files -n rtems-base-gnat-binutils -f files
%dir /opt/gnatrtems/info
# %doc /opt/gnatrtems/info/dir
# %doc /opt/gnatrtems/info/as.info.gz
# %doc /opt/gnatrtems/info/as.info-?.gz
# %doc /opt/gnatrtems/info/bfd.info.gz
# %doc /opt/gnatrtems/info/bfd.info-?.gz
# %doc /opt/gnatrtems/info/binutils.info.gz
# %doc /opt/gnatrtems/info/binutils.info-?.gz
# %doc /opt/gnatrtems/info/ld.info.gz
# %doc /opt/gnatrtems/info/ld.info-?.gz
# %doc /opt/gnatrtems/info/gasp.info.gz
# %doc /opt/gnatrtems/info/standards.info.gz

%dir /opt/gnatrtems/man
%dir /opt/gnatrtems/man/man1

%dir /opt/gnatrtems/include
/opt/gnatrtems/include/bfd.h
/opt/gnatrtems/include/ansidecl.h
/opt/gnatrtems/include/bfdlink.h

%dir /opt/gnatrtems/lib
/opt/gnatrtems/lib/libbfd*
/opt/gnatrtems/lib/libiberty*
/opt/gnatrtems/lib/libopcodes*

# %dir /opt/gnatrtems/share
# %dir /opt/gnatrtems/share/locale

%files -n @target_alias@-gnat-binutils -f files.target
%doc /opt/gnatrtems/man/man1/@target_alias@-*.1

%dir /opt/gnatrtems/bin
/opt/gnatrtems/bin/@target_alias@-addr2line@exe_ext@
/opt/gnatrtems/bin/@target_alias@-ar@exe_ext@
/opt/gnatrtems/bin/@target_alias@-as@exe_ext@
/opt/gnatrtems/bin/@target_alias@-c++filt@exe_ext@
/opt/gnatrtems/bin/@target_alias@-gasp@exe_ext@
/opt/gnatrtems/bin/@target_alias@-ld@exe_ext@
/opt/gnatrtems/bin/@target_alias@-nm@exe_ext@
/opt/gnatrtems/bin/@target_alias@-objcopy@exe_ext@
/opt/gnatrtems/bin/@target_alias@-objdump@exe_ext@
/opt/gnatrtems/bin/@target_alias@-ranlib@exe_ext@
# readelf is not in older binutils so get it from file list
# /opt/gnatrtems/bin/@target_alias@-readelf@exe_ext@
/opt/gnatrtems/bin/@target_alias@-size@exe_ext@
/opt/gnatrtems/bin/@target_alias@-strings@exe_ext@
/opt/gnatrtems/bin/@target_alias@-strip@exe_ext@

%dir /opt/gnatrtems/@target_alias@
%dir /opt/gnatrtems/@target_alias@/bin
/opt/gnatrtems/@target_alias@/bin/ar@exe_ext@
/opt/gnatrtems/@target_alias@/bin/as@exe_ext@
/opt/gnatrtems/@target_alias@/bin/ld@exe_ext@
/opt/gnatrtems/@target_alias@/bin/nm@exe_ext@
/opt/gnatrtems/@target_alias@/bin/ranlib@exe_ext@
/opt/gnatrtems/@target_alias@/bin/strip@exe_ext@

%dir /opt/gnatrtems/@target_alias@/lib
/opt/gnatrtems/@target_alias@/lib/ldscripts
%files -n rtems-base-gnat 
%dir /opt/gnatrtems/info
# %doc /opt/gnatrtems/info/dir
%doc /opt/gnatrtems/info/cpp.info*
%doc /opt/gnatrtems/info/gcc.info*
%doc /opt/gnatrtems/info/libc.info*
%doc /opt/gnatrtems/info/libm.info*

# %dir /opt/gnatrtems/man
# %dir /opt/gnatrtems/man/man1
%doc /opt/gnatrtems/man/man1/cccp.1
%doc /opt/gnatrtems/man/man1/@target_alias@-gcc.1

%dir /opt/gnatrtems/bin
# /opt/gnatrtems/bin/cpp@exe_ext@
# /opt/gnatrtems/bin/gcov@exe_ext@
%dir /opt/gnatrtems/include
# /opt/gnatrtems/include/g++-3

%files -n @target_alias@-gnat -f files.gcc
/opt/gnatrtems/bin/@target_alias@-gcc@exe_ext@
/opt/gnatrtems/bin/@target_alias@-gnatbind
/opt/gnatrtems/bin/@target_alias@-gnatbl
/opt/gnatrtems/bin/@target_alias@-gnatchop
/opt/gnatrtems/bin/@target_alias@-gnatfind
/opt/gnatrtems/bin/@target_alias@-gnatkr
/opt/gnatrtems/bin/@target_alias@-gnatlink
/opt/gnatrtems/bin/@target_alias@-gnatls
/opt/gnatrtems/bin/@target_alias@-gnatmake
/opt/gnatrtems/bin/@target_alias@-gnatmem
/opt/gnatrtems/bin/@target_alias@-gnatprep
/opt/gnatrtems/bin/@target_alias@-gnatpsta
/opt/gnatrtems/bin/@target_alias@-gnatpsys
/opt/gnatrtems/bin/@target_alias@-gnatxref


%dir /opt/gnatrtems/lib/gcc-lib/@target_alias@/@gcc_version@/include

/opt/gnatrtems/@target_alias@

%post -n @target_alias@-gnat
  if test -d $RPM_INSTALL_PREFIX/rtems/info; 
  then
    rm -f $RPM_INSTALL_PREFIX/rtems/info/dir
    f=`find $RPM_INSTALL_PREFIX/rtems/info -name '*.info.gz'`
    test -n "$f" && for i in $f; do
      install-info $i $RPM_INSTALL_PREFIX/rtems/info/dir
    done
  fi

%postun -n @target_alias@-gnat
  if test -d $RPM_INSTALL_PREFIX/rtems/info; 
  then
    rm -f $RPM_INSTALL_PREFIX/rtems/info/dir
    f=`find $RPM_INSTALL_PREFIX/rtems/info -name '*.info.gz'`
    test -n "$f" && for i in $f; do
      install-info $i $RPM_INSTALL_PREFIX/rtems/info/dir
    done
  fi