#! /bin/sh # $Id: gnatpmake,v 1.5 1999/01/23 21:35:47 simon Exp $ # Copyright (C) 1997-1999 Simon Wright . # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA # 02111-1307, USA. # Runs gnatmake, having set up the Ada paths according to the contents # of any .adapath files found in the *current* directory and in any # referenced Ada library directories. Note, gnatmake itself looks in # the directory in which the program to be compiled is found. # I expect gnatmake is on your path! .. GNATMAKE=gnatmake checkpath() { # the first parameter is a proposed path component. # the second parameter is the path so far. # return 0 if the proposed component isn't already in the path. for pc in `echo $2 | tr ':' ' '`; do if [ "$1" = "$pc" ]; then return 1 fi done return 0 } getpath() { # the first parameter, which may be empty, is the current path result=$1 # the second parameter, which may be empty, is the directory to # search for the .adapath file if [ -z "$2" ]; then start=. else start=$2 fi cd $start if [ -r .adapath ]; then # if we can read a .adapath file, process each component for c in `tr ':' ' ' < .adapath`; do if [ -n "$c" ] && [ -d "$c" ]; then # work out the full path, allowing for relative specs path=`(cd $c; pwd)` # if we've no result so far, make this the result; otherwise, append if [ -z "$result" ]; then result=$path result=`getpath $result $path` else if ( checkpath $path $result ); then result=$result:$path result=`getpath $result $path` fi fi fi done fi echo $result } include=`getpath $ADA_INCLUDE_PATH` objects=`getpath $ADA_OBJECTS_PATH` ADA_INCLUDE_PATH=$include; export ADA_INCLUDE_PATH ADA_OBJECTS_PATH=$objects; export ADA_OBJECTS_PATH #echo ADA_INCLUDE_PATH=$ADA_INCLUDE_PATH #echo ADA_OBJECTS_PATH=$ADA_OBJECTS_PATH exec $GNATMAKE $*