xmake revision 493
493N/A#! /usr/perl5/bin/perl -w
493N/A
493N/A#
493N/A# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
493N/A# Use is subject to license terms.
493N/A#
493N/A# Permission is hereby granted, free of charge, to any person obtaining a
493N/A# copy of this software and associated documentation files (the
493N/A# "Software"), to deal in the Software without restriction, including
493N/A# without limitation the rights to use, copy, modify, merge, publish,
493N/A# distribute, and/or sell copies of the Software, and to permit persons
493N/A# to whom the Software is furnished to do so, provided that the above
493N/A# copyright notice(s) and this permission notice appear in all copies of
493N/A# the Software and that both the above copyright notice(s) and this
493N/A# permission notice appear in supporting documentation.
493N/A#
493N/A# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
493N/A# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
493N/A# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
493N/A# OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
493N/A# HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL
493N/A# INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING
493N/A# FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
493N/A# NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
493N/A# WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
493N/A#
493N/A# Except as contained in this notice, the name of a copyright holder
493N/A# shall not be used in advertising or otherwise to promote the sale, use
493N/A# or other dealings in this Software without prior written authorization
493N/A# of the copyright holder.
493N/A#
493N/A# ident "@(#)xmake 1.1 08/08/07 SMI"
493N/A#
493N/A
493N/Arequire 5.005; # minimal Perl version required
493N/Ause strict; #
493N/Ause diagnostics; #
493N/Ause File::Spec;
493N/Ause English qw( -nomatchvars );
493N/A
493N/A# Path to make sure we're running Solaris make instead of GNU make
493N/Amy $solaris_make = '/usr/ccs/bin/make';
493N/A
493N/A# save full path to current directory
493N/Amy $startdir = File::Spec->rel2abs(File::Spec->curdir());
493N/A
493N/A# climb the tree to find the open-src module directory we're in
493N/Amy @dirtree = File::Spec->splitdir($startdir);
493N/Amy $osdepth;
493N/A
493N/Afor my $n (1..$#dirtree) {
493N/A if ($dirtree[$n] eq 'open-src') {
493N/A if (-f File::Spec->catfile( @dirtree[0..$n], 'common/Makefile.inc')) {
493N/A $osdepth = $n;
493N/A last;
493N/A }
493N/A }
493N/A}
493N/A
493N/Aif (!defined($osdepth)) {
493N/A die "$0: Cannot find path to open-src/common/Makefile.inc from here";
493N/A}
493N/A
493N/A# if in top two levels, just run make
493N/Aif ($osdepth >= ($#dirtree - 2)) {
493N/A print join(' ', $solaris_make, @ARGV), "\n";
493N/A exec($solaris_make, @ARGV)
493N/A or die "$0: exec of $solaris_make failed: $OS_ERROR";
493N/A}
493N/A
493N/Amy $subdir_target = 'build-in-subdir';
493N/Afor my $f (@ARGV) {
493N/A if ($f =~ m{^install}ms) {
493N/A $subdir_target = 'install-in-subdir';
493N/A }
493N/A}
493N/A
493N/A# Otherwise get info from the module makefile
493N/Amy $moduledir = File::Spec->catdir( @dirtree[0..($osdepth+2)] );
493N/A
493N/Amy @makeargs = ($subdir_target, qq{subdir='$startdir'});
493N/Aif (scalar(@ARGV) > 0) {
493N/A push @makeargs, join(q{}, q{subdir_cmd='}, @ARGV, q{'});
493N/A}
493N/A
493N/Aprint join(' ', "(cd $moduledir ;\\\n", $solaris_make, @makeargs), ")\n";
493N/Achdir $moduledir
493N/A or die "$0: Can't chdir $moduledir: $OS_ERROR";
493N/Aexec($solaris_make, @makeargs)
493N/A or die "$0: exec of $solaris_make failed: $OS_ERROR";
493N/A
493N/A__END__
493N/A