link.perl
#!/usr/bin/perl
#*******************************************************************************#
#                                                                               #
# link.perl: a gcc wrapper script                                               #
#                                                                               #
#*******************************************************************************#

#***************************************************************************************************
#                                                                                                  *
#     Copyright (C) 2004 Joerg Kunze                                                               *
#                                                                                                  *
#     This file is part of siliconBrain.                                                           *
#                                                                                                  *
#     siliconBrain 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.                                                          *
#                                                                                                  *
#     siliconBrain 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                    *
#                                                                                                  *
#***************************************************************************************************
$release       = '$siliconBrainRelease: 0.2.3 $';
$rcsIdentifier = '$Id: link.perl,v 1.6 2004/12/14 23:31:26 joerg Exp $';
$saveStamp     = '$siliconBrainSaveStamp: 2004/12/14 22:25:44, Joerg Kunze$';

use File::Basename;

$packageName      = $ENV{ "siliconBrainPackageName" };
$CC               = $ENV{ "CC"                      };
$CFLAGS           = $ENV{ "CFLAGS"                  };
$LOADLIBES        = $ENV{ "LOADLIBES"               };
$LDLIBS           = $ENV{ "LDLIBS"                  };
$siliconBrainPath = $ENV{ "siliconBrainPath"        };

$source = shift;
$target = shift;

$targetBasename = basename( $target );

$sed = 's/distribution\/lib\(.*\)\.a/-l\1/g';

$packageLibs = `ls distribution/*.a 2> /dev/null | sed '$sed'`;

$siliconBrain = "-lsiliconBrain" if( -e "$siliconBrainPath/libsiliconBrain.a" );

$packageLib   = "-l$packageName" if( $packageName ne 'siliconBrain' && -e "distribution/lib$packageName.a" );

print `$CC $CFLAGS  $source  $LDLIBS $packageLib $siliconBrain $LOADLIBES -o $target -Xlinker --print-map 2>&1 | makeDependenciesBinary $target > temporary/$targetBasename.d`;

$rc = $? >> 8;

exit $rc;

# $Log: link.perl,v $
# Revision 1.6  2004/12/14 23:31:26  joerg
# published for new release 0.2.3
#
# Revision 1.5  2004/12/14 23:17:05  joerg
# published for new release 0.2.2
#
# Revision 1.4  2004/12/14 22:42:23  joerg
# allFiles: all sources have a Log CVS keyword at the end now.
#