@@ -499,7 +499,7 @@ unless ( eval { ExtUtils::MakeMaker->VERSION(6.52) } ) {
499
499
500
500
# See lib/ExtUtils/MakeMaker.pm for details of how to
501
501
# influence content of the Makefile that is written.
502
- WriteMakefile(%WriteMakefile );
502
+ my $mm = WriteMakefile(%WriteMakefile );
503
503
504
504
# ###############################################################################
505
505
# extend EU::MM to compile additional LibSass tools
@@ -516,9 +516,22 @@ my @targets;
516
516
my @cleanups ;
517
517
my @commands ;
518
518
my $static = 0;
519
+ my $reported = 0;
520
+
521
+ # http://perldoc.perl.org/ExtUtils/MakeMaker.html#make-install
522
+ sub inst_lib {
523
+ my ($mm ) = @_ ;
524
+ warn " Installing as a " , $mm -> {INSTALLDIRS }, " module\n "
525
+ unless $reported ; $reported = 1;
526
+ return ' $(INSTALLARCHLIB)' if $mm -> {INSTALLDIRS } eq " perl" ;
527
+ return ' $(INSTALLSITEARCH)' if $mm -> {INSTALLDIRS } eq " site" ;
528
+ return ' $(INSTALLVENDORLIB)' if $mm -> {INSTALLDIRS } eq " vendor" ;
529
+ die " invalid INSTALLDIRS setting, abort" ;
530
+ }
531
+
519
532
520
533
sub compile_lib {
521
- my ($name ) = @_ ;
534
+ my ($mm , $ name ) = @_ ;
522
535
my @args = (
523
536
' $(LD) $(OPTIMIZE) -lstdc++ -shared' , " -o ${name} " ,
524
537
);
@@ -534,7 +547,7 @@ sub compile_lib {
534
547
# add explicit path to libsass lib
535
548
# needed to resolve lib from plugins
536
549
unless ($^O eq ' MSWin32' && $Config {cc } =~ / ^cl/ ) {
537
- push @args , ' -Wl,-rpath,$(INSTALLARCHLIB) ' ;
550
+ push @args , ' -Wl,-rpath,' . inst_lib( $mm ) ;
538
551
}
539
552
# -static-libgcc -static-libstdc++
540
553
return join (' ' , @args , @libs );
@@ -560,7 +573,7 @@ sub libsass_sassc
560
573
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHLIB) -lsass' )
561
574
. ' $(OPTIMIZE) -lstdc++ -std=c++0x ' . join (" " , @libs )
562
575
. ($^O eq " linux" ? ' -ldl' : ' ' )
563
- . ' -Wl,-rpath,$(INSTALLARCHLIB) ' ;
576
+ . ' -Wl,-rpath,' . inst_lib( $_ [0]) ;
564
577
}
565
578
# add target to virtual "pure_all"
566
579
push @cleanups , ' $(SASSC_OBJ)' ;
@@ -579,7 +592,7 @@ sub libsass_lib
579
592
# create the target for the makefile
580
593
push @ret , ' $(LIBSASS_LIB): $(LIBSASS_OBJ)' ;
581
594
# create the libsass shared library by linking against all objects
582
- push @ret , " \t " . compile_lib(' $(LIBSASS_LIB)' ) . ' $(LIBSASS_OBJ)' ;
595
+ push @ret , " \t " . compile_lib($_ [0], ' $(LIBSASS_LIB)' ) . ' $(LIBSASS_OBJ)' ;
583
596
# add target to virtual "pure_all"
584
597
push @cleanups , ' $(LIBSASS_OBJ)' ;
585
598
push @cleanups , ' $(LIBSASS_LIB)' ;
@@ -598,7 +611,7 @@ sub libsass_plugin_math
598
611
# make sure the plugin path exists for output
599
612
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/math' ;
600
613
# create the libsass shared library by linking against all objects
601
- push @ret , " \t " . compile_lib(' $(MATH_LIB)' ) . ' $(MATH_OBJ)'
614
+ push @ret , " \t " . compile_lib($_ [0], ' $(MATH_LIB)' ) . ' $(MATH_OBJ)'
602
615
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHLIB) -lsass' );
603
616
# add target to virtual "pure_all"
604
617
push @cleanups , ' $(MATH_OBJ)' ;
@@ -618,7 +631,7 @@ sub libsass_plugin_img_size
618
631
# make sure the plugin path exists for output
619
632
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/img-size' ;
620
633
# create the libsass shared library by linking against all objects
621
- push @ret , " \t " . compile_lib(' $(IMG_SIZE_LIB)' ) . ' $(IMG_SIZE_OBJ)'
634
+ push @ret , " \t " . compile_lib($_ [0], ' $(IMG_SIZE_LIB)' ) . ' $(IMG_SIZE_OBJ)'
622
635
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHLIB) -lsass' );
623
636
# add target to virtual "pure_all"
624
637
push @cleanups , ' $(IMG_SIZE_OBJ)' ;
@@ -643,7 +656,7 @@ sub libsass_plugin_digest
643
656
# make sure the plugin path exists for output
644
657
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/digest' ;
645
658
# create the libsass shared library by linking against all objects
646
- push @ret , " \t " . compile_lib(' $(DIGEST_LIB)' ) . ' $(DIGEST_OBJ)'
659
+ push @ret , " \t " . compile_lib($_ [0], ' $(DIGEST_LIB)' ) . ' $(DIGEST_OBJ)'
647
660
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHLIB) -lsass' );
648
661
# add target to virtual "pure_all"
649
662
push @cleanups , ' $(DIGEST_OBJ)' ;
@@ -668,7 +681,7 @@ sub libsass_plugin_glob
668
681
# make sure the plugin path exists for output
669
682
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/glob' ;
670
683
# create the libsass shared library by linking against all objects
671
- push @ret , " \t " . compile_lib(' $(GLOB_LIB)' ) . ' $(GLOB_OBJ)'
684
+ push @ret , " \t " . compile_lib($_ [0], ' $(GLOB_LIB)' ) . ' $(GLOB_OBJ)'
672
685
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHLIB) -lsass' );
673
686
# add target to virtual "pure_all"
674
687
push @cleanups , ' $(GLOB_OBJ)' ;
@@ -683,22 +696,22 @@ sub runOnce
683
696
{
684
697
return if $ran ;
685
698
# get instance
686
- my $self = shift ;
699
+ my $mm = shift ;
687
700
# collect Makefile commands
688
701
@commands = (
689
702
# call parent class first
690
- $self -> SUPER::postamble,
703
+ $mm -> SUPER::postamble,
691
704
);
692
705
if ($install_plugins || $install_sassc ) {
693
- push @commands , ' ' , libsass_lib();
706
+ push @commands , ' ' , libsass_lib($mm );
694
707
}
695
708
if ($install_sassc ) {
696
- push @commands , ' ' , libsass_sassc();
709
+ push @commands , ' ' , libsass_sassc($mm );
697
710
}
698
711
if ($install_plugins ) {
699
- push @commands , ' ' , libsass_plugin_glob();
700
- push @commands , ' ' , libsass_plugin_math();
701
- push @commands , ' ' , libsass_plugin_img_size();
712
+ push @commands , ' ' , libsass_plugin_glob($mm );
713
+ push @commands , ' ' , libsass_plugin_math($mm );
714
+ push @commands , ' ' , libsass_plugin_img_size($mm );
702
715
# needs a few C-API changes not yet released
703
716
# push @commands, '', libsass_plugin_digest();
704
717
}
@@ -712,8 +725,8 @@ sub runOnce
712
725
sub postamble
713
726
{
714
727
# get instance
715
- my $self = shift ;
716
- runOnce($self );
728
+ my $mm = shift ;
729
+ runOnce($mm );
717
730
# return code for Makefile
718
731
return join " \n " , @commands ;
719
732
}
@@ -722,9 +735,9 @@ sub postamble
722
735
sub clean
723
736
{
724
737
# get instance
725
- my $self = shift ;
726
- runOnce($self );
738
+ my $mm = shift ;
739
+ runOnce($mm );
727
740
# collect parent clean targets
728
- return $self -> SUPER::clean . " \t - \$ (RM_F) \\\n "
741
+ return $mm -> SUPER::clean . " \t - \$ (RM_F) \\\n "
729
742
. join (" \n " , map { " \t $_ \\ " } @cleanups );
730
743
}
0 commit comments