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