@@ -49,7 +49,7 @@ my $skip_manifest = env_option 'PSASS_SKIP_MANIFEST', 0;
49
49
my $skip_version = env_option ' PSASS_SKIP_VERSION' , 0;
50
50
my $update_deps = env_option ' PSASS_UPDATE_DEPS' , 0;
51
51
my $checkout_deps = env_option ' PSASS_CHECKOUT_DEPS' , 0;
52
- my $patch_gcc44 = env_option ' PSASS_PATCH_GCC44' , 0;
52
+ # my $patch_gcc44 = env_option 'PSASS_PATCH_GCC44', 0;
53
53
my $skip_git = env_option ' PSASS_SKIP_GIT' , 0;
54
54
55
55
# arrays for various switches
@@ -81,7 +81,7 @@ sub help
81
81
print " --checkout-deps Checkout submodules at linked commit (needs git repo)\n " ;
82
82
print " --get-versions Show versions of all perl package (.pm) files\n " ;
83
83
print " --set-versions Set versions of all perl package (.pm) files\n " ;
84
- print " --patch-gcc44 Patch libsass for gcc44 compatibility\n " ;
84
+ # print " --patch-gcc44 Patch libsass for gcc44 compatibility\n";
85
85
print " --skip-git Do not try to use anything git related\n " ;
86
86
print " \n " ;
87
87
print " You may use environment variables to set any option\n " ;
@@ -163,7 +163,7 @@ GetOptions(
163
163
' --library!' => \$install_library ,
164
164
' --compiler:s' => \$compiler ,
165
165
' --profiling!' => \$profiling ,
166
- ' --patch-gcc44' => \$patch_gcc44 ,
166
+ # '--patch-gcc44' => \$patch_gcc44,
167
167
' --skip-git!' => \$skip_git ,
168
168
' --skip-version!' => \$skip_version ,
169
169
' --skip-manifest!' => \$skip_manifest ,
@@ -306,7 +306,7 @@ if ($install_sassc) {
306
306
$sassc_version = <$fh > if (defined $fh );
307
307
chomp ($sassc_version );
308
308
print " Detected sassc $sassc_version \n " ;
309
- # create compile flags to include the libsass version
309
+ # create compile flags to include the sassc version
310
310
push @defs , qq( SASSC_VERSION=\\ "$sassc_version \\ ") ;
311
311
} else {
312
312
# give a warning if the version could not be determined (probably not generated yet)
@@ -318,24 +318,29 @@ if ($install_sassc) {
318
318
# patch sources
319
319
# ###############################################################################
320
320
321
- if ($patch_gcc44 ) {
322
- my $cwd = Cwd::getcwd;
323
- chdir (" libsass" ) or die " pushd: $! " ;
324
- print " Patching libsass source for gcc compatibility\n " ;
325
- foreach my $patch (sort glob (" ../patches/*.patch" )) {
326
- print " applying $patch \n " ;
327
- # system "git", "am", "--abort";
328
- system " git" , " am" , " --3way" , " --keep-cr" ,
329
- " --ignore-space-change" , " --quiet" , $patch ;
330
- }
331
- system " perl" , " script/replace-range-for-loops.pl" ;
332
- chdir ($cwd ) or die " popd: $! " ;
333
- }
321
+ # if ($patch_gcc44) {
322
+ # my $cwd = Cwd::getcwd;
323
+ # chdir ("libsass") or die "pushd: $!";
324
+ # print "Patching libsass source for gcc compatibility\n";
325
+ # foreach my $patch (sort glob("../patches/*.patch")) {
326
+ # print "applying $patch\n";
327
+ # # system "git", "am", "--abort";
328
+ # system "git", "am", "--3way", "--keep-cr",
329
+ # "--ignore-space-change", "--quiet", $patch;
330
+ # }
331
+ # system "perl", "script/replace-range-for-loops.pl";
332
+ # chdir ($cwd) or die "popd: $!";
333
+ # }
334
334
335
335
# ###############################################################################
336
336
# compiler configurations
337
337
# ###############################################################################
338
338
339
+ unless (defined $compiler ) {
340
+ $compiler = $ENV {' CC' } || $ENV {' CXX' };
341
+ $compiler =~ s /\+ +$// if $compiler ;
342
+ }
343
+
339
344
my $guess = ExtUtils::CppGuess-> new(
340
345
(defined ($compiler ) ? (cc => $compiler ) : ()),
341
346
);
@@ -350,16 +355,37 @@ if ($guess->is_gcc) {
350
355
$cc_version = sprintf (" %d .%d .%d " , $1 , $2 , $3 );
351
356
$guess -> {' gcc_version' } = $cc_version ;
352
357
print " Detected GCC compiler $cc_version ...\n " ;
353
- if ($1 < 4 || ($1 == 4 && $2 < 4 )) {
358
+ if ($1 < 4 || ($1 == 4 && $2 < 7 )) {
354
359
warn " Your GCC Version is too old for LibSass!\n " ;
355
- warn " Needs at least gcc version 4.4 or higher!\n " ;
356
- die " Please consider upgrading your GCC compiler!\n " ;
360
+ warn " Needs at least gcc version 4.7 or higher!\n " ;
361
+ warn " Please consider upgrading your GCC compiler!\n " ;
362
+ exit 0; # avoid any CPAN Testers failure reports
357
363
}
358
364
}
359
365
else {
360
366
print " Detected GCC compiler (version unknown) ...\n " ;
361
367
}
362
368
}
369
+ elsif ($guess -> is_clang) {
370
+ # version not exposed by CppGuess!?
371
+ use Capture::Tiny ' capture_merged' ;
372
+ my $cmd = $guess -> {cc } . " --version" ;
373
+ my $cc_version = capture_merged { system ($cmd ) };
374
+ if ($cc_version =~ m / clang\s +(?:version)?\s +(\d +)\. (\d +)\. (\d +)\s +\( [^\) ] +\)\r ?\n / i ) {
375
+ $cc_version = sprintf (" %d .%d .%d " , $1 , $2 , $3 );
376
+ $guess -> {' gcc_version' } = $cc_version ;
377
+ print " Detected CLANG compiler $cc_version ...\n " ;
378
+ if ($1 < 3 || ($1 == 3 && $2 < 3)) {
379
+ warn " Your CLANG Version is too old for LibSass!\n " ;
380
+ warn " Needs at least clang version 3.3 or higher!\n " ;
381
+ warn " Please consider upgrading your clang compiler!\n " ;
382
+ exit 0; # avoid any CPAN Testers failure reports
383
+ }
384
+ }
385
+ else {
386
+ print " Detected CLANG compiler (version unknown) ...\n " ;
387
+ }
388
+ }
363
389
# we never really tested compilation via MSVC yet ...
364
390
elsif ($guess -> is_msvc) { print " Detected MSVC compiler ...\n " ; }
365
391
else { print " Unknown compiler, trying anyway...\n " ; }
@@ -606,7 +632,7 @@ my $static = 0;
606
632
my $reported = 0;
607
633
608
634
sub compile_lib {
609
- my ($mm , $name ) = @_ ;
635
+ my ($lib , $ mm , $name ) = @_ ;
610
636
my @args = (
611
637
' $(LD) $(OPTIMIZE) -lstdc++ -shared' , " -o ${name} " ,
612
638
);
@@ -624,6 +650,11 @@ sub compile_lib {
624
650
unless ($^O eq ' MSWin32' && $Config {cc } =~ / ^cl/ ) {
625
651
push @args , ' -Wl,-rpath,\\ $$ORIGIN/../..' ;
626
652
}
653
+ # add explicit library name on OSX
654
+ if ($^O eq ' darwin' ) {
655
+ push @args , ' -Wl,-install_name,' . $lib ;
656
+ # push @args, '-Wl,-rpath,@loader_path/../..';
657
+ }
627
658
# -static-libgcc -static-libstdc++
628
659
return join (' ' , @args , @libs );
629
660
}
@@ -643,6 +674,10 @@ sub libsass_sassc
643
674
}
644
675
# otherwise we asume gcc
645
676
else {
677
+ # On windows there is nothing like rpath for dll load paths
678
+ # So dll and sassc would need to be in same directory
679
+ # For now we just fall back to link sassc statically
680
+ my $static = $static || $^O eq ' MSWin32' ;
646
681
# create the sassc executable by linking against sassc and libsass
647
682
push @ret , " \t " . ' $(LD) -o $(SASSC_EXE) $(LDFLAGS) -lm $(SASSC_OBJ) $(LIBS)'
648
683
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' )
@@ -667,7 +702,7 @@ sub libsass_lib
667
702
# create the target for the makefile
668
703
push @ret , ' $(LIBSASS_LIB): $(LIBSASS_OBJ)' ;
669
704
# create the libsass shared library by linking against all objects
670
- push @ret , " \t " . compile_lib($_ [0], ' $(LIBSASS_LIB)' ) . ' $(LIBSASS_OBJ)' ;
705
+ push @ret , " \t " . compile_lib(' libsass.$(SO) ' , $_ [0], ' $(LIBSASS_LIB)' ) . ' $(LIBSASS_OBJ)' ;
671
706
# add target to virtual "pure_all"
672
707
push @cleanups , ' $(LIBSASS_OBJ)' ;
673
708
push @cleanups , ' $(LIBSASS_LIB)' ;
@@ -686,8 +721,11 @@ sub libsass_plugin_math
686
721
# make sure the plugin path exists for output
687
722
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/math' ;
688
723
# create the libsass shared library by linking against all objects
689
- push @ret , " \t " . compile_lib($_ [0], ' $(MATH_LIB)' ) . ' $(MATH_OBJ)'
724
+ push @ret , " \t " . compile_lib(' math.$(SO) ' , $_ [0], ' $(MATH_LIB)' ) . ' $(MATH_OBJ)'
690
725
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
726
+ # change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
727
+ push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
728
+ . ' $(MATH_LIB)' if ($^O eq ' darwin' && !$static );
691
729
# add target to virtual "pure_all"
692
730
push @cleanups , ' $(MATH_OBJ)' ;
693
731
push @cleanups , ' $(MATH_LIB)' ;
@@ -706,8 +744,11 @@ sub libsass_plugin_img_size
706
744
# make sure the plugin path exists for output
707
745
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/img-size' ;
708
746
# create the libsass shared library by linking against all objects
709
- push @ret , " \t " . compile_lib($_ [0], ' $(IMG_SIZE_LIB)' ) . ' $(IMG_SIZE_OBJ)'
747
+ push @ret , " \t " . compile_lib(' img-size.$(SO) ' , $_ [0], ' $(IMG_SIZE_LIB)' ) . ' $(IMG_SIZE_OBJ)'
710
748
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
749
+ # change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
750
+ push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
751
+ . ' $(IMG_SIZE_LIB)' if ($^O eq ' darwin' && !$static );
711
752
# add target to virtual "pure_all"
712
753
push @cleanups , ' $(IMG_SIZE_OBJ)' ;
713
754
push @cleanups , ' $(IMG_SIZE_LIB)' ;
@@ -731,8 +772,11 @@ sub libsass_plugin_digest
731
772
# make sure the plugin path exists for output
732
773
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/digest' ;
733
774
# create the libsass shared library by linking against all objects
734
- push @ret , " \t " . compile_lib($_ [0], ' $(DIGEST_LIB)' ) . ' $(DIGEST_OBJ)'
775
+ push @ret , " \t " . compile_lib(' digest.$(SO) ' , $_ [0], ' $(DIGEST_LIB)' ) . ' $(DIGEST_OBJ)'
735
776
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
777
+ # change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
778
+ push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
779
+ . ' $(DIGEST_LIB)' if ($^O eq ' darwin' && !$static );
736
780
# add target to virtual "pure_all"
737
781
push @cleanups , ' $(DIGEST_OBJ)' ;
738
782
push @cleanups , ' $(DIGEST_LIB)' ;
@@ -756,8 +800,11 @@ sub libsass_plugin_glob
756
800
# make sure the plugin path exists for output
757
801
push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/glob' ;
758
802
# create the libsass shared library by linking against all objects
759
- push @ret , " \t " . compile_lib($_ [0], ' $(GLOB_LIB)' ) . ' $(GLOB_OBJ)'
803
+ push @ret , " \t " . compile_lib(' glob.$(SO) ' , $_ [0], ' $(GLOB_LIB)' ) . ' $(GLOB_OBJ)'
760
804
. ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' );
805
+ # change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
806
+ push @ret , " \t " . ' install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
807
+ . ' $(GLOB_LIB)' if ($^O eq ' darwin' && !$static );
761
808
# add target to virtual "pure_all"
762
809
push @cleanups , ' $(GLOB_OBJ)' ;
763
810
push @cleanups , ' $(GLOB_LIB)' ;
0 commit comments