@@ -633,7 +633,7 @@ my $static = 0;
633
633
my $reported = 0;
634
634
635
635
sub compile_lib {
636
- my ($lib , $mm , $name ) = @_ ;
636
+ my ($lib , $mm , $name , $isPlugin ) = @_ ;
637
637
my @args = (
638
638
' $(LD) $(OPTIMIZE) -lstdc++ -shared' , " -o ${name} " ,
639
639
);
@@ -646,10 +646,13 @@ sub compile_lib {
646
646
push @args , ' -Wl,--major-image-version,0.0.9' ;
647
647
push @args , ' -Wl,--minor-image-version,0.0.9' ;
648
648
}
649
- # add explicit path to libsass lib
650
- # needed to resolve lib from plugins
649
+ # add explicit relative path to resolve libsass library
650
+ # makes plugin.so look for -lsass in `../..` when loaded
651
+ # this may not be supported on all operating systems!
651
652
unless ($^O eq ' MSWin32' && $Config {cc } =~ / ^cl/ ) {
652
- push @args , ' -Wl,-rpath,\\ $$ORIGIN/../..' ;
653
+ # the `-z origin` seems needed for some BSD derivates!
654
+ push @args , ' -Wl,-z,origin' if $isPlugin && $^O ne ' MSWin32' ;
655
+ push @args , ' -Wl,-rpath,\\ $$ORIGIN/../..' if $isPlugin ;
653
656
}
654
657
# add explicit library name on OSX
655
658
if ($^O eq ' darwin' ) {
@@ -722,7 +725,7 @@ sub libsass_plugin_math
722
725
# make sure the plugin path exists for output
723
726
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/math' ;
724
727
# create the libsass shared library by linking against all objects
725
- push @ret , " \t " . compile_lib(' math.$(SO)' , $_ [0], ' $(MATH_LIB)' ) . ' $(MATH_OBJ)'
728
+ push @ret , " \t " . compile_lib(' math.$(SO)' , $_ [0], ' $(MATH_LIB)' , 1 ) . ' $(MATH_OBJ)'
726
729
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
727
730
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
728
731
push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
@@ -745,7 +748,7 @@ sub libsass_plugin_img_size
745
748
# make sure the plugin path exists for output
746
749
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/img-size' ;
747
750
# create the libsass shared library by linking against all objects
748
- push @ret , " \t " . compile_lib(' img-size.$(SO)' , $_ [0], ' $(IMG_SIZE_LIB)' ) . ' $(IMG_SIZE_OBJ)'
751
+ push @ret , " \t " . compile_lib(' img-size.$(SO)' , $_ [0], ' $(IMG_SIZE_LIB)' , 1 ) . ' $(IMG_SIZE_OBJ)'
749
752
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
750
753
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
751
754
push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
@@ -773,7 +776,7 @@ sub libsass_plugin_digest
773
776
# make sure the plugin path exists for output
774
777
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/digest' ;
775
778
# create the libsass shared library by linking against all objects
776
- push @ret , " \t " . compile_lib(' digest.$(SO)' , $_ [0], ' $(DIGEST_LIB)' ) . ' $(DIGEST_OBJ)'
779
+ push @ret , " \t " . compile_lib(' digest.$(SO)' , $_ [0], ' $(DIGEST_LIB)' , 1 ) . ' $(DIGEST_OBJ)'
777
780
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
778
781
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
779
782
push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
@@ -801,7 +804,7 @@ sub libsass_plugin_glob
801
804
# make sure the plugin path exists for output
802
805
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/glob' ;
803
806
# create the libsass shared library by linking against all objects
804
- push @ret , " \t " . compile_lib(' glob.$(SO)' , $_ [0], ' $(GLOB_LIB)' ) . ' $(GLOB_OBJ)'
807
+ push @ret , " \t " . compile_lib(' glob.$(SO)' , $_ [0], ' $(GLOB_LIB)' , 1 ) . ' $(GLOB_OBJ)'
805
808
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
806
809
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
807
810
push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
0 commit comments