#!/afs/athena/contrib/perl/perl5
#
# $Header: /mit/gtk/share/rpathconf/rpathconf.pl,v 1.1 1998/04/21 05:05:17 nygren Exp $
#
# PROGRAM:  rpathconf
# AUTHOR:   Erik Nygren
#
# Trivial script to convert a list of command line
# arguments (which are paths) into a series of command line arguments
# to pass to gcc to tell it to create a binary that looks through
# those paths to find shared libraries.
#
# Example:
# 
#  rpathconf foo bar
#
# might return either:
#
#  -Wl,-rpath,foo:bar
#
# or
#
#  -Rfoo -Rbar
#
# depending on the platform.  This is useful for use in 
# scripts for building packages or running configure.
#

require 5.002;
use strict;

use vars qw/ $machtype /;

$machtype = `machtype`; 
chop $machtype;

if (   ($machtype eq "linux") 
    || ($machtype eq "sgi") ) {
    
    # -Wl,rpath form
    my $count=0;
    if (@ARGV) {
	print "-Wl,-rpath,";
    }
    for (@ARGV) {
	if ($count++!=0) { 
	    print ":"; 
	}
	print "$_";
	
    }

} elsif (   ($machtype eq "inbsd") 
	 || ($machtype eq "sun4") ) {

    # -R form

    for (@ARGV) {
	print "-R$_ ";
    }

} else { 
    print STDERR "Unknown platform \"$machtype\"\n";
}

print "\n";

