Installing GNAT-GPL-2013 and ASIS-GNAT-2013 on Ubuntu

Pupose_

To prepare programming environment for Ada 2013 and Ada Semantic Interface Specification(ASIS, I installed Gnat-GPL-2013 and ASIS-GNAT-2013.

Useful Pages_

Environment_

Download_

Download from files of GNAT、ASIS、GNAT、GNATCOLL from following site.

Uncompress the downloaded files.

% mkdir Ada2013
% mv /tmp/AdaCore-Download-XXXXX.tar Ada2013
% cd Ada2013
% tar xvf AdaCore-Download-XXXXX.tar
% mv x86_64-linux/2013/* . 
% rm -rf x86_64-linux/

Current construction of ~/Ada2013 is as follows.

% cd ~/Ada2013
% tree

├── AdaCore-Download-2013-12-05_0553.tar
├── aunit
│   └── README
├── gnatcoll
│   ├── README
│   └── gnatcoll-gpl-2013-src.tgz
└── gnatgpl
    ├── README
    ├── gnat-gpl-2013-x86_64-pc-linux-gnu-bin.tar.gz
    └── sources
        └── asis-gpl-2013-src.tgz

Install GNAT_

% cd gnatgpl
% tar xvfz gnat-gpl-2013-x86_64-pc-linux-gnu-bin.tar.gz
% cd gnat-gpl-2013-x86_64-pc-linux-gnu-bin
% sudo ./doinstall (Use default directory "/usr/gnat".)

Configure Environment Variables_

We have to configure environment variables because of following reasons.

  1. To add /usr/gnat/bin into command search path, we modify an environment variable "PATH."
  2. In Debian and Ubuntu, to add sepecific directory of include files and library into search path, we modify "LD_LIBRARY_PATH", "LIBRARY_PATH", and "C_INCLUDE_PATH." (See comp.lang.ada: Gnattest under Debian/Ubuntu Linux/Linux Lint.)

Create /etc/profile.d/gnat.sh to modify the environment variables.

% sudo touch /etc/profile.d/gnat.sh

Contents of the file is as follows.

export PATH=/usr/gnat/bin:$PATH
export LD_LIBRARY_PATH=/usr/gnat/lib:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
export LIBRARY_PATH=/usr/gnat/lib:/usr/lib/x86_64-linux-gnu:$LIBRARY_PATH
export C_INCLUDE_PATH=/usr/include/x86_64-linux-gnu 
export ADA_PROJECT_PATH=/usr/gnat/lib/gnat 

Change permission of the file.

% sudo chmod 755 gnat.sh 

From next login, the environment variables are active automatically.

After the environment variables are active, check whether the installation succeeds or not.

% gnatmake --version
GNATMAKE GPL 2013 (20130314)

Install GNATCOLL_

Install GNATCOLL because ASIS-GNAT-2013 requries it.

Uncompress the file of GNATCOLL and install it.

% cd ~/Ada2013/gnatcoll
% tar xfz gnatcoll-gpl-2013-src.tgz 
% cd gnatcoll-gpl-2013
% ./configure --without-gtk --prefix=/usr/gnat --enable-shared \
  --without-python --disable-pygtk |& tee configure.log
% make |& tee make.log
% make test
% sudo make install

Install ASIS-for-GNAT 2013_

Uncompress the file of ASIS-for-GNAT 2013.

% cd ~/Ada2013/gnatgpl/sources
% tar xvfz asis-gpl-2013-src.tgz
% cd asis-gpl-2013-src

Vesion of ASIS-for-GNAT and GNAT-GPL should be same. So, check the version.

% gnatls -v

GNATLS GPL 2013 (20130314)
Copyright (C) 1997-2013, Free Software Foundation, Inc.

Source Search Path:
   <Current_Directory>
   /usr/gnat/lib/gcc/x86_64-pc-linux-gnu/4.7.4/adainclude/


Object Search Path:
   <Current_Directory>
   /usr/gnat/lib/gcc/x86_64-pc-linux-gnu/4.7.4/adalib/


Project Search Path:
   <Current_Directory>
   /usr/gnat/lib/gnat
   /usr/gnat/x86_64-pc-linux-gnu/lib/gnat
   /usr/gnat/share/gpr
   /usr/gnat/lib/gnat

Install ASIS-GNAT-2013

% make all install prefix=/usr/gnat

Then, check whether the installation succeeds or not by doing ASIS-for-GNAT User's Guide: 2.4 Building the Executable for an ASIS application. But, we face trouble.

% gnatmake example1.adb -largs -lasis
gcc -c example1.adb
example1.adb:5:06: file "asis.ads" not found
example1.adb:6:06: file "asis-implementation.ads" not found
example1.adb:7:06: file "asis-ada_environments.ads" not found
example1.adb:8:06: file "asis-compilation_units.ads" not found
example1.adb:9:06: file "asis-exceptions.ads" not found
example1.adb:10:06: file "asis-errors.ads" not found
gnatmake: "example1.adb" compilation error

The reasons of the trouble are two. The first one is search path. We have to configure environment variables related with the search path. Add following sentences into /etc/profile.d/gnat.sh.

export ADA_INCLUDE_PATH=/usr/gnat/include:/usr/gnat/include/asis:/usr/gnat/include/gnat_util
export ADA_OBJECTS_PATH=/usr/gnat/lib:/usr/gnat/lib/asis

The second one is lack of adb files. At first, move adb files in asis-gpl-2013-src/asis/*.adb to /usr/gnat/include/asis.

% sudo cp ~/Ada2013/gnatgpl/sources/asis-gpl-2013-src/asis/*.adb /usr/gnat/include/asis

And then, we have to add adb files into /usr/gnat/include/gnat_util. But, GNAT-GPL-2013 doesn't have adb files at gnat-gpl-2013-x86_64-pc-linux-gnu-bin/include/gnat_util/. So, we lend the adb files from GNAT-GPL-2012.

Download GNAT-GPL-2012 from LIBRE, and uncompress gnat-gpl-2012-x86_64-pc-linux-gnu-bin.tar.gz.

% cp gnat-gpl-2012-x86_64-pc-linux-gnu-bin.tar.gz ~/Ada2013
% tar xvfz gnat-gpl-2012-x86_64-pc-linux-gnu-bin.tar.gz
% cd gnat-gpl-2012-x86_64-pc-linux-gnu-bin/include/gnat_util/

I copied followin adb files at include/gnat_util/ in GNAT-GPL-2012 to /usr/gnat/include/gnat_util.

How to choose the files are as follows

  1. Same prefix of files in include/gnat_util, i.e., XXX.adb exists if XXX.ads exists.
  2. Filenames in include/gnat_util/ are same between GNAT-GPL-2012 and GNAT-GPL-2013.
  3. XXX.adb doesn't exist at include/gnat_util in GNAT-GPL-2013 while XXX.adb exists at include/gnat_util in GNAT-GPL-2012.
  4. The contents of an ads file are same between GNAT-GPL-2012 and 2013, or the differences of contents of an ads file between GNAT-GPL-2012 and 2013 are only definition of constant.
binderr.adb   gnatvsn.adb   prj-attr-pm.adb  prj-pp.adb    stylesw.adb
butil.adb     krunch.adb    prj-attr.adb     prj-proc.adb  switch-m.adb
debug.adb     mlib-fil.adb  prj-dect.adb     prj-strt.adb  tree_in.adb
fmap.adb      mlib-tgt.adb  prj-err.adb      sdefault.adb  tree_io.adb
fname-uf.adb  mlib-utl.adb  prj-ext.adb      sinput-c.adb  uname.adb
fname.adb     mlib.adb	    prj-nmsc.adb     stand.adb	   widechar.adb

I copied the above adb files to /usr/gnat/include/gnat_util, then compile the sample file. I succeeded that.

% gnatmake example1.adb -largs -lasis
== omit ==
% ./example1 
A Context contains the following compilation units:

   Standard (spec) - Ada predefined unit

% gcc -c -gnatct example1.adb
% ./example1 example1.adt
A Context contains the following compilation units:

   Standard (spec) - Ada predefined unit
   Example1 (body) - user-defined unit
   Ada (spec) - Ada predefined unit
   Ada.Wide_Text_IO (spec) - Ada predefined unit
   Ada.IO_Exceptions (spec) - Ada predefined unit
== omit ==

Appendix: difference between /usr/gnat/include/asis and ~/Ada2013/gnatgpl/sources/asis-gpl-2013-src/asis_

The difference between /usr/gnat/include/asis and ~/Ada2013/gnatgpl/sources/asis-gpl-2013-src/asis is as follows.

% ls -1 /usr/gnat/include/asis > installed_include_asis.txt
% cd ~/Ada2013/gnatgpl/sources/asis-gpl-2013-src/asis
% ls -1 *.ads *.adb > ../compiled_asis_adb_ads.txt
% diff installed_include_asis.txt compiled-asis_ads.txt | grep adb
> a4g-a_debug.adb
> a4g-a_elists.adb
> a4g-a_opt.adb
> a4g-a_osint.adb
> a4g-a_output.adb
> a4g-a_sem.adb
> a4g-a_sinput.adb
> a4g-a_types.adb
> a4g-asis_tables.adb
> a4g-contt-dp.adb
> a4g-contt-sd.adb
> a4g-contt-tt.adb
> a4g-cu_info2.adb
> a4g-dda_aux.adb
> a4g-decl_sem.adb
> a4g-defaults.adb
> a4g-encl_el.adb
> a4g-expr_sem.adb
> a4g-get_unit.adb
> a4g-gnat_int.adb
> a4g-itests.adb
> a4g-knd_conv.adb
> a4g-mapping.adb
> a4g-norm.adb
> a4g-queries.adb
> a4g-skip_tb.adb
> a4g-span_beginning.adb
> a4g-span_end.adb
> a4g-stand.adb
> a4g-u_conv.adb
> a4g-vcheck.adb
> asis-ada_environments-containers.adb
> asis-ada_environments.adb
> asis-clauses.adb
> asis-compilation_units-relations.adb
> asis-compilation_units-times.adb
> asis-compilation_units.adb
> asis-data_decomposition-aux.adb
> asis-data_decomposition-debug.adb
> asis-data_decomposition-set_get.adb
> asis-data_decomposition-vcheck.adb
> asis-declarations.adb
> asis-definitions.adb
> asis-elements.adb
> asis-expressions.adb
> asis-extensions-flat_kinds.adb
> asis-ids.adb
> asis-implementation-permissions.adb
> asis-implementation.adb
> asis-limited_views.adb
> asis-statements.adb
> asis-text-set_get.adb
> asis-text.adb

Appendix: difference between GNAT-GPL-2012 and GNAT-GPL2013_

% cd ~/Ada2013/gnat-gpl-2012-x86_64-pc-linux-gnu-bin/include/gnat_util
% ls -1 *.ads > ~/Ada2013/gnat-gpl-2012-include-ads.txt
% ls -1 *.adb > ~/Ada2013/gnat-gpl-2012-include-adb.txt

% cd ~/Ada2013/gnatgpl/gnat-gpl-2013-x86_64-pc-linux-gnu-bin/include/gnat_util
% ls -1 *.ads > ~/Ada2013/gnat-gpl-2013-include-ads.txt
% ls -1 *.adb > ~/Ada2013/gnat-gpl-2013-include-adb.txt

The difference of ads files at include/gnat_util.

% diff gnat-gpl-2012-include-ads.txt gnat-gpl-2013-include-ads.txt
27d26
< mlib-tgt-vms_common.ads
79a79
> xutil.ads

The difference of adb files at include/gnat_util. There are many differences.

% diff gnat-gpl-2012-include-adb.txt gnat-gpl-2013-include-adb.txt
2d1
< ali.adb
5,6d3
< binderr.adb
< butil.adb
9d5
< debug.adb
12,19d7
< errout.adb
< erroutc.adb
< errutil.adb
< fmap.adb
< fname-uf.adb
< fname.adb
< gnatvsn.adb
< krunch.adb
24,26d11
< mlib-fil.adb
< mlib-tgt-specific-vms-alpha.adb
< mlib-tgt-specific-vms-ia64.adb
28,31d12
< mlib-tgt-vms_common.adb
< mlib-tgt.adb
< mlib-utl.adb
< mlib.adb
35d15
< osint.adb
37,40d16
< prj-attr-pm.adb
< prj-attr.adb
< prj-conf.adb
< prj-dect.adb
42,48d17
< prj-err.adb
< prj-ext.adb
< prj-nmsc.adb
< prj-part.adb
< prj-pp.adb
< prj-proc.adb
< prj-strt.adb
56d24
< sdefault.adb
59d26
< sinput-c.adb
63d29
< stand.adb
66,67d31
< stylesw.adb
< switch-m.adb
70,73d33
< targparm.adb
< tempdir.adb
< tree_in.adb
< tree_io.adb
76d35
< uname.adb
78d36
< widechar.adb

Appendix: Script to support for choosing copied adb files._

I chose the copied adb files according to following procedure.

% cd ~/Ada2013
% mkdir diff-include
% cp -r gnat-gpl-2012-x86_64-pc-linux-gnu-bin/include/gnat_util diff-include/2012-gnat_util
% cp -r gnatgpl/gnat-gpl-2013-x86_64-pc-linux-gnu-bin/include/gnat_util diff-include/2013-gnat_util
% cd diff-include
% touch compare.sh
% chmod 755 compare.sh
% mkdir diff-adb

Contents of the compare.sh is as follows.

#/bin/sh
ADA2012DIR=/home/gotoh/Ada2013/diff-include/2012-gnat_util/
ADA2013DIR=/home/gotoh/Ada2013/diff-include/2013-gnat_util/
DIFDIR=/home/gotoh/Ada2013/diff-include/diff-adb

if test -d $ADA2012DIR
then
  cd $ADA2012DIR
  filelist="$ADA2012DIR*.ads"

  for filepath in ${filelist}
   do
    filename2012=`basename ${filepath}`
    prefixFilename=`basename ${filename2012} .ads`
    adbfilename2013=$ADA2013DIR${prefixFilename}.adb
    filename2013=$ADA2013DIR$filename2012
    if test -e ${prefixFilename}.adb
    then
      if test -e $filename2013
      then
       if ! test -e $adbfilename2013 
       then
         echo "diff 2012/$filename2012 2013/$filename2012"
         difference=`diff $filename2012 $filename2013`
         if test -z $difference
         then
           echo " $filename2012 can be copied to 2013"
           cp ${prefixFilename}.adb $DIFDIR
         else
           diff $filename2012 $filename2013
         fi
        echo "====="
       fi
      else
       echo "$filename2013 isn't in 2013\n"
      fi
    fi
   done
fi

Usage

% ./compare.sh > log.txt
% ls diff-adb/
debug.adb  fname.adb  krunch.adb  tree_in.adb  uname.adb  widechar.adb

And then, I checked log.txt, and choose files. The result of the selection is as follows.

binderr.adb   gnatvsn.adb   prj-attr-pm.adb  prj-pp.adb    stylesw.adb
butil.adb     krunch.adb    prj-attr.adb     prj-proc.adb  switch-m.adb
debug.adb     mlib-fil.adb  prj-dect.adb     prj-strt.adb  tree_in.adb
fmap.adb      mlib-tgt.adb  prj-err.adb      sdefault.adb  tree_io.adb
fname-uf.adb  mlib-utl.adb  prj-ext.adb      sinput-c.adb  uname.adb
fname.adb     mlib.adb	    prj-nmsc.adb     stand.adb	   widechar.adb

Links_