dnl CF_GNAT_PROJECTS version: 2 updated: 2011/03/23 20:24:41
dnl ----------------
dnl GNAT projects are configured with ".gpr" project files.
dnl GNAT libraries are a further development, using the project feature.
AC_DEFUN([CF_GNAT_PROJECTS],
[
AC_REQUIRE([CF_GNAT_VERSION])

cf_gnat_libraries=no
cf_gnat_projects=no

AC_MSG_CHECKING(if GNAT supports project files)
case $cf_gnat_version in #(vi
3.[[0-9]]*) #(vi
	;;
*)
	case $cf_cv_system_name in #(vi
	cygwin*) #(vi
		;;
	*)
		mkdir conftest.src conftest.bin conftest.lib
		cd conftest.src
		rm -rf conftest* *~conftest*
		cat >>library.gpr <<CF_EOF
project Library is
  Kind := External ("LIB_KIND");
  for Library_Name use "ConfTest";
  for Object_Dir use ".";
  for Library_ALI_Dir use External("LIBRARY_DIR");
  for Library_Version use External ("SONAME");
  for Library_Kind use Kind;
  for Library_Dir use External("BUILD_DIR");
  Source_Dir := External ("SOURCE_DIR");
  for Source_Dirs use (Source_Dir);
  package Compiler is
     for Default_Switches ("Ada") use
       ("-g",
        "-O2",
        "-gnatafno",
        "-gnatVa",   -- All validity checks
        "-gnatwa");  -- Activate all optional errors
  end Compiler;
end Library;
CF_EOF
		cat >>confpackage.ads <<CF_EOF
package ConfPackage is
   procedure conftest;
end ConfPackage;
CF_EOF
		cat >>confpackage.adb <<CF_EOF
with Text_IO;
package body ConfPackage is
   procedure conftest is
   begin
      Text_IO.Put ("Hello World");
      Text_IO.New_Line;
   end conftest;
end ConfPackage;
CF_EOF
		if ( $cf_ada_make $ADAFLAGS \
				-Plibrary.gpr \
				-XBUILD_DIR=`cd ../conftest.bin;pwd` \
				-XLIBRARY_DIR=`cd ../conftest.lib;pwd` \
				-XSOURCE_DIR=`pwd` \
				-XSONAME=libConfTest.so.1 \
				-XLIB_KIND=static 1>&AC_FD_CC 2>&1 ) ; then
			cf_gnat_projects=yes
		fi
		cd ..
		if test -f conftest.lib/confpackage.ali
		then
			cf_gnat_libraries=yes
		fi
		rm -rf conftest* *~conftest*
		;;
	esac
	;;
esac
AC_MSG_RESULT($cf_gnat_projects)

if test $cf_gnat_projects = yes
then
	AC_MSG_CHECKING(if GNAT supports libraries)
	AC_MSG_RESULT($cf_gnat_libraries)
fi

if test "$cf_gnat_projects" = yes
then
	USE_OLD_MAKERULES="#"
	USE_GNAT_PROJECTS=""
else
	USE_OLD_MAKERULES=""
	USE_GNAT_PROJECTS="#"
fi

if test "$cf_gnat_libraries" = yes
then
	USE_GNAT_LIBRARIES=""
else
	USE_GNAT_LIBRARIES="#"
fi

AC_SUBST(USE_OLD_MAKERULES)
AC_SUBST(USE_GNAT_PROJECTS)
AC_SUBST(USE_GNAT_LIBRARIES)
])dnl
