Skip to content

Commit 1f6fc56

Browse files
committed
Update for installation.
* INSTALL.md: rewrite for new design. * common/common.gpr: new. exports variable Paths, dependent on external RELEASE. * Makefile: new target 'clean'; merge targets. * arduino-due/Makefile: gprinstall with -f (because uninstalling is such a pain, and we don't want to force it on people who are installing locally). * stm32f4/Makefile: likewise. * stm32f429i/Makefile: likewise. * arduino-due/build_runtime.gpr (context): with ../common/common.gpr. (Source_Dirs): use Common.Paths. (Install): use external INSTALL_LOCALLY. * stm32f4/build_runtime.gpr: likewise. * stm32f429i/build_runtime.gpr: likewise. * test-arduino-due/testbed.gpr (Runtime): use runtime in ../local. (Builder): use Global_Compilation_Switches & Switches (new gprbuild behaviour). (IDE): new. * test-stm32f429i/testbed.gpr: likewise. (Linker): add -Wl,-gc-sections. * test-stm32f4/testbed.gpr: likewise (but already had IDE).
1 parent c1a97de commit 1f6fc56

File tree

12 files changed

+163
-168
lines changed

12 files changed

+163
-168
lines changed

INSTALL.md

Lines changed: 36 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,64 @@
1-
# Installing Cortex GNAT RTS #
1+
# Installing and using Cortex GNAT RTS #
22

3-
* [General](#general)
4-
* [Compiler compatibility](#compatibility)
5-
* [Target](#target)
6-
* [Run time system](#rts)
7-
* [In `$prefix/arm-eabi/lib/gnat`:](#with-compiler)
8-
* [In `$lib`:](#in-lib)
9-
* [In the build location:](#in-build)
10-
* [Link map file](#link-map)
3+
## Installing ##
114

12-
## General <a name="general"/> ##
5+
The runtimes are supplied unbuilt.
136

14-
The runtimes are supplied unbuilt. In order to build them, run `make
15-
all` at the top level (or, if you only want one runtime, run `make` in
16-
that runtime's subdirectory).
7+
In order to build them, run <tt>make&nbsp;RELEASE=<i>release</i>&nbsp;all</tt> at the top level (or, if you only want one runtime, run <tt>make&nbsp;RELEASE=<i>release</i></tt> in that runtime's subdirectory).
178

18-
You should always use gprbuild and a GNAT Project (GPR) to do
19-
cross-builds. Gnatmake (`arm-eabi-gnatmake`) doesn't work nearly so
20-
well, if at all.
9+
The point of the <tt>RELEASE=<i>release</i></tt> above is that, during compiler development, the interface between the compiler and the run time system it's generating code for changes.
2110

22-
* For GPS, in _Build>Settings>Targets_, in the _File_ tab change
23-
`gnatmake` and `builder` to `gprbuild`.
11+
Values for `RELEASE` are as below:
2412

25-
* for Emacs ada-mode, in the Ada Build group,
26-
* set _Ada Build Check Cmd_ to `gprbuild -p -P${gpr_file} -c -u -f
27-
${full_current}`
28-
* set _Ada Build Make Cmd_ to `gprbuild -p -P${gpr_file}`
29-
30-
## Compiler compatibility <a name="compatibility"/> ##
31-
32-
During compiler development, the interface between the compiler and
33-
the run time system it's generating code for changes.
34-
35-
This is managed here using different branches.
36-
37-
<!-- This renders OK at Github, but not with Markdown.pl. -->
38-
39-
| Compiler | Branch |
40-
| ---------|----------------------------------- |
13+
| Compiler | `RELEASE=` |
14+
| ---------|------------ |
4115
| FSF GCC 6 | `gcc6` |
42-
| FSF GCC 7 | `gcc7` (or `gcc7-finalization`) |
43-
| FSF GCC 8 | `gcc8` (or `gcc8-finalization`) |
16+
| FSF GCC 7 | `gcc7` |
17+
| FSF GCC 8 | `gcc8` |
4418
| GNAT GPL 2016 | `gcc6` |
4519
| GNAT GPL 2017 | `gnat-gpl-2017` |
4620

47-
## Target <a name="target"/> ##
48-
49-
You need to specify the target (`arm-eabi`). If you're only going to
50-
use the command line, you can specify `--target=arm-eabi` on the
51-
command line or in the GPR project-level attribute `Target`:
52-
53-
for Target use "arm-eabi";
54-
55-
If you're going to use GPS or Emacs ada-mode, use the `Target` attribute.
56-
57-
## Run time system <a name="rts"/> ##
21+
The runtimes must be installed. To install the runtime(s) with your compiler (you may need to use `sudo`),
5822

59-
The GNAT compiler running under `gprbuild` can find RTSs in various
60-
ways. An RTS usually contains an `adainclude/` directory with the
61-
source of the RTS and an `adalib/` directory with the corresponding
62-
library, linker script and `.ali` files (these defaults can be changed
63-
by listing the source directory, or colon-separated directories, in
64-
`ada_source_path`, and the object directory in `ada_object_path`).
23+
<pre>
24+
make RELEASE=<i>release</i> install
25+
</pre>
6526

66-
If not the default, the RTS can be named on the command using a
67-
`--RTS=` option. In a GPR, you can do this in package `Builder` (so
68-
it's applied during all phases of the build):
27+
either at top level for all runtimes, or in the individual runtime's subdirectory.
6928

70-
package Builder is
71-
for Default_Switches ("ada") use
72-
(
73-
"-g",
74-
"-O0",
75-
"--RTS=stm32f429i"
76-
);
77-
end Builder;
29+
It used to be possible to use a runtime from its build directory (for example, `--RTS=$HOME/cortex-gnat-rts/stm32f4`), but this isn't possible with the new multi-release structure. Instead, the runtimes must be installed locally:
7830

79-
or, with GPRBUILD GPL 2015 or later, via an attribute:
31+
<pre>
32+
make RELEASE=<i>release</i> INSTALL_LOCALLY=yes install
33+
</pre>
8034

81-
for Runtime ("ada") use "stm32f429i";
35+
allowing `--RTS=$HOME/cortex-gnat-rts/local/stm32f4`.
8236

83-
There are two places where RTSs can be installed:
37+
## Using ##
8438

85-
* in `$prefix/arm-eabi/lib/gnat`. This is the preferred location, and
86-
is where the `install` make target will place the RTS.
39+
You should always use `gprbuild` and a GNAT Project (GPR) to do cross-builds. Gnatmake (`arm-eabi-gnatmake`) doesn't work nearly so well, if at all.
8740

88-
* in the location indicated by the directory part of `arm-eabi-gcc
89-
-print-libgcc-file-name`; for GNAT GPL 2015, that would be
90-
`$prefix/lib/gcc/arm-eabi/4.9.3/`, referred to from here on as
91-
`$lib`.
41+
* For GPS, in _Build>Settings>Targets_, in the _File_ tab change `gnatmake` and `builder` to `gprbuild`.
9242

93-
You can also work with an RTS in its build location.
94-
95-
### In `$prefix/arm-eabi/lib/gnat`: <a name="with-compiler"/> ###
96-
97-
The directory containing the RTS is just called {name},
98-
e.g. `stm32f429i/`.
99-
100-
### In `$lib`: <a name="in-lib"/> ###
101-
102-
The directory containing the RTS should be called `rts-{name}`, for
103-
example `rts-stm32f429i`.
104-
105-
If the RTS is named `stm32f429i`, the compiler will treat it as the
106-
default RTS (and you need a default RTS) if
107-
108-
* `$lib/rts-stm32f429i` contains text files `ada_object_path`,
109-
`ada_source_path` containing the locations of the `adalib` and
110-
`adainclude` directories of the RTS respectively, and there are
111-
files `adainclude/system.ads` and there is at least one `.ali` file
112-
in `adalib/`; or
113-
114-
* `$lib/rts-stm32f429i` contains symbolic links named `adalib` and
115-
`adainclude` to the `adalib/` and `adainclude/` directories of the
116-
RTS respectively.
117-
118-
Alternative RTSs are found here if they are in directories named
119-
`rts-{name}`, for example `rts-stm32f429i/` corresponds to
120-
`--RTS=stm32f429i`.
43+
* for Emacs ada-mode, in the Ada Build group,
44+
* set _Ada Build Check Cmd_ to `gprbuild -p -P${gpr_file} -c -u -f ${full_current}`
45+
* set _Ada Build Make Cmd_ to `gprbuild -p -P${gpr_file}`
12146

122-
### In the build location: <a name="in-build"/> ###
47+
### Target ###
12348

124-
RTSs can also be located by giving the explicit path in the `Runtime
125-
("ada")` attribute or the `--RTS=` option (this has to be an absolute
126-
path with GPRBUILD GPL 2015):
49+
You need to specify the target (`arm-eabi`). If you're only going to use the command line, you can specify `--target=arm-eabi` on the command line, or in a GPR using the project-level attribute `Target`:
12750

128-
package Builder is
129-
for Default_Switches ("ada") use
130-
(
131-
"-g",
132-
"-O0",
133-
"--RTS=“ & Project’Project_Dir & "../stm32f429i"
134-
);
135-
end Builder;
51+
for Target use "arm-eabi";
13652

137-
or
53+
If you're going to use GPS or Emacs ada-mode, use the `Target` attribute.
13854

139-
for Runtime ("ada") use Project’Project_Dir & "../stm32f429i";
55+
### Run time system ###
14056

141-
## Link map file <a name="link-map"/> ##
57+
To use an RTS installed with the compiler, for example `stm32f4`, you can specify it on the command line, using `--RTS=stm32f4`, or with a recent `gprbuild` in the project file:
14258

143-
It can be very useful indeed to have a link map file. In case gprbuild
144-
doesn't support `--create-map-file` with a cross-compiler, a good way to
145-
specify this is in package `Linker` in the GPR:
59+
for Runtime ("ada") use "stm32f4";
14660

147-
package Linker is
148-
for Default_Switches ("ada") use
149-
(
150-
"-Wl,-Map," & Project'Project_Dir & Project'Name & ".map"
151-
);
152-
end Linker;
61+
If using a locally-installed RTS, use a relative or absolute path:
15362

154-
Note the use of `Project'Project_Dir` and `Project'Name`; the first is
155-
especially useful because the linker `arm-eabi-ld` runs in the GPR's
156-
Object_Dir, which is often a subdirectory of the project directory.
63+
for Runtime ("ada")
64+
use Project’Project_Dir & "../local/stm32f4";

Makefile

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,9 @@ first:
2222

2323
runtimes = arduino-due stm32f4 stm32f429i
2424

25-
all:
25+
all install clean:
2626
for f in $(runtimes); do \
27-
make -w -C $$f; \
27+
make -w -C $$f $@; \
2828
done
2929

30-
install:
31-
for f in $(runtimes); do \
32-
make -w -C $$f install; \
33-
done
34-
35-
.PHONY: first all install
30+
.PHONY: first all clean install

arduino-due/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ all:
2020
gprbuild -p -P build_runtime.gpr
2121

2222
install: all
23-
gprinstall -p -P build_runtime.gpr
23+
gprinstall -p -P build_runtime.gpr -f
2424

2525
clean:
2626
gprclean -P build_runtime.gpr

arduino-due/build_runtime.gpr

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
-- along with this program; see the file COPYING3. If not, see
1717
-- <http://www.gnu.org/licenses/>.
1818

19+
with "../common/common";
1920
with "../FreeRTOS";
2021

2122
library project Build_Runtime is
@@ -29,12 +30,10 @@ library project Build_Runtime is
2930
for Library_Dir use "adalib";
3031
for Object_Dir use ".build";
3132

32-
for Source_Dirs use
33+
for Source_Dirs use Common.Paths &
3334
(
3435
"adainclude",
3536
"atsam3x8e",
36-
"../common",
37-
"../common/math",
3837
FreeRTOS.Source,
3938
FreeRTOS.Portable_Base & "ARM_CM3"
4039
);
@@ -83,8 +82,17 @@ library project Build_Runtime is
8382
for Switches ("hardfault_handling.adb") use ALL_ADAFLAGS & ("-g", "-O0");
8483
end Compiler;
8584

85+
type Install_Locally is ("yes", "no");
86+
Local : Install_Locally := external ("INSTALL_LOCALLY", "no");
87+
8688
package Install is
87-
for Prefix use "arm-eabi/lib/gnat/arduino-due";
89+
case Local is
90+
when "no" =>
91+
for Prefix use "arm-eabi/lib/gnat/";
92+
when "yes" =>
93+
for Prefix use project'Project_Dir & "../local/";
94+
end case;
95+
for Prefix use Install'Prefix & "arduino-due";
8896
for Sources_Subdir use "adainclude";
8997
for Ali_Subdir use "adalib";
9098
for Lib_Subdir use "adalib";

common/common.gpr

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- Copyright (C) 2018 Free Software Foundation, Inc.
2+
3+
-- This file is part of the Cortex GNAT RTS package.
4+
--
5+
-- The Cortex GNAT RTS package is free software; you can redistribute
6+
-- it and/or modify it under the terms of the GNU General Public
7+
-- License as published by the Free Software Foundation; either
8+
-- version 3 of the License, or (at your option) any later version.
9+
--
10+
-- This program is distributed in the hope that it will be useful,
11+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13+
-- General Public License for more details.
14+
--
15+
-- You should have received a copy of the GNU General Public License
16+
-- along with this program; see the file COPYING3. If not, see
17+
-- <http://www.gnu.org/licenses/>.
18+
19+
abstract project Common is
20+
21+
type Compiler_Release is ("gcc6", "gnat-gpl-2017", "gcc7", "gcc8");
22+
Release : Compiler_Release := external ("RELEASE");
23+
24+
Paths := (project'Project_Dir,
25+
project'Project_Dir & "math",
26+
project'Project_Dir & Release);
27+
28+
end Common;

stm32f4/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ all:
2020
gprbuild -p -P build_runtime.gpr
2121

2222
install: all
23-
gprinstall -p -P build_runtime.gpr
23+
gprinstall -p -P build_runtime.gpr -f
2424

2525
clean:
2626
gprclean -P build_runtime.gpr

stm32f4/build_runtime.gpr

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
-- along with this program; see the file COPYING3. If not, see
1717
-- <http://www.gnu.org/licenses/>.
1818

19+
with "../common/common";
1920
with "../FreeRTOS";
2021

2122
library project Build_Runtime is
@@ -29,12 +30,10 @@ library project Build_Runtime is
2930
for Library_Dir use "adalib";
3031
for Object_Dir use ".build";
3132

32-
for Source_Dirs use
33+
for Source_Dirs use Common.Paths &
3334
(
3435
"adainclude",
3536
"stm32f40x",
36-
"../common",
37-
"../common/math",
3837
FreeRTOS.Source,
3938
FreeRTOS.Portable_Base & "ARM_CM4F"
4039
);
@@ -89,8 +88,17 @@ library project Build_Runtime is
8988
for Switches ("hardfault_handling.adb") use ALL_ADAFLAGS & ("-g", "-O0");
9089
end Compiler;
9190

91+
type Install_Locally is ("yes", "no");
92+
Local : Install_Locally := external ("INSTALL_LOCALLY", "no");
93+
9294
package Install is
93-
for Prefix use "arm-eabi/lib/gnat/stm32f4";
95+
case Local is
96+
when "no" =>
97+
for Prefix use "arm-eabi/lib/gnat/";
98+
when "yes" =>
99+
for Prefix use project'Project_Dir & "../local/";
100+
end case;
101+
for Prefix use Install'Prefix & "stm32f4";
94102
for Sources_Subdir use "adainclude";
95103
for Ali_Subdir use "adalib";
96104
for Lib_Subdir use "adalib";

stm32f429i/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ all:
2020
gprbuild -p -P build_runtime.gpr
2121

2222
install: all
23-
gprinstall -p -P build_runtime.gpr
23+
gprinstall -p -P build_runtime.gpr -f
2424

2525
clean:
2626
gprclean -P build_runtime.gpr

stm32f429i/build_runtime.gpr

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
-- along with this program; see the file COPYING3. If not, see
1717
-- <http://www.gnu.org/licenses/>.
1818

19+
with "../common/common";
1920
with "../FreeRTOS";
2021

2122
library project Build_Runtime is
@@ -29,12 +30,10 @@ library project Build_Runtime is
2930
for Library_Dir use "adalib";
3031
for Object_Dir use ".build";
3132

32-
for Source_Dirs use
33+
for Source_Dirs use Common.Paths &
3334
(
3435
"adainclude",
3536
"stm32f429x",
36-
"../common",
37-
"../common/math",
3837
FreeRTOS.Source,
3938
FreeRTOS.Portable_Base & "ARM_CM4F"
4039
);
@@ -83,8 +82,17 @@ library project Build_Runtime is
8382
for Switches ("hardfault_handling.adb") use ALL_ADAFLAGS & ("-g", "-O0");
8483
end Compiler;
8584

85+
type Install_Locally is ("yes", "no");
86+
Local : Install_Locally := external ("INSTALL_LOCALLY", "no");
87+
8688
package Install is
87-
for Prefix use "arm-eabi/lib/gnat/stm32f429i";
89+
case Local is
90+
when "no" =>
91+
for Prefix use "arm-eabi/lib/gnat/";
92+
when "yes" =>
93+
for Prefix use project'Project_Dir & "../local/";
94+
end case;
95+
for Prefix use Install'Prefix & "stm32f429i";
8896
for Sources_Subdir use "adainclude";
8997
for Ali_Subdir use "adalib";
9098
for Lib_Subdir use "adalib";

0 commit comments

Comments
 (0)