@@ -49,7 +49,7 @@ my $skip_manifest = env_option 'PSASS_SKIP_MANIFEST', 0;
4949my $skip_version = env_option ' PSASS_SKIP_VERSION' , 0;
5050my $update_deps = env_option ' PSASS_UPDATE_DEPS' , 0;
5151my $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;
5353my $skip_git = env_option ' PSASS_SKIP_GIT' , 0;
5454
5555# arrays for various switches
@@ -81,7 +81,7 @@ sub help
8181 print " --checkout-deps Checkout submodules at linked commit (needs git repo)\n " ;
8282 print " --get-versions Show versions of all perl package (.pm) files\n " ;
8383 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";
8585 print " --skip-git Do not try to use anything git related\n " ;
8686 print " \n " ;
8787 print " You may use environment variables to set any option\n " ;
@@ -163,7 +163,7 @@ GetOptions(
163163 ' --library!' => \$install_library ,
164164 ' --compiler:s' => \$compiler ,
165165 ' --profiling!' => \$profiling ,
166- ' --patch-gcc44' => \$patch_gcc44 ,
166+ # '--patch-gcc44' => \$patch_gcc44,
167167 ' --skip-git!' => \$skip_git ,
168168 ' --skip-version!' => \$skip_version ,
169169 ' --skip-manifest!' => \$skip_manifest ,
@@ -306,7 +306,7 @@ if ($install_sassc) {
306306 $sassc_version = <$fh > if (defined $fh );
307307 chomp ($sassc_version );
308308 print " Detected sassc $sassc_version \n " ;
309- # create compile flags to include the libsass version
309+ # create compile flags to include the sassc version
310310 push @defs , qq( SASSC_VERSION=\\ "$sassc_version \\ ") ;
311311 } else {
312312 # give a warning if the version could not be determined (probably not generated yet)
@@ -318,24 +318,29 @@ if ($install_sassc) {
318318# patch sources
319319# ###############################################################################
320320
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+ # }
334334
335335# ###############################################################################
336336# compiler configurations
337337# ###############################################################################
338338
339+ unless (defined $compiler ) {
340+ $compiler = $ENV {' CC' } || $ENV {' CXX' };
341+ $compiler =~ s /\+ +$// if $compiler ;
342+ }
343+
339344my $guess = ExtUtils::CppGuess-> new(
340345 (defined ($compiler ) ? (cc => $compiler ) : ()),
341346);
@@ -350,16 +355,37 @@ if ($guess->is_gcc) {
350355 $cc_version = sprintf (" %d .%d .%d " , $1 , $2 , $3 );
351356 $guess -> {' gcc_version' } = $cc_version ;
352357 print " Detected GCC compiler $cc_version ...\n " ;
353- if ($1 < 4 || ($1 == 4 && $2 < 4 )) {
358+ if ($1 < 4 || ($1 == 4 && $2 < 7 )) {
354359 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
357363 }
358364 }
359365 else {
360366 print " Detected GCC compiler (version unknown) ...\n " ;
361367 }
362368}
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+ }
363389# we never really tested compilation via MSVC yet ...
364390elsif ($guess -> is_msvc) { print " Detected MSVC compiler ...\n " ; }
365391else { print " Unknown compiler, trying anyway...\n " ; }
@@ -606,7 +632,7 @@ my $static = 0;
606632my $reported = 0;
607633
608634sub compile_lib {
609- my ($mm , $name ) = @_ ;
635+ my ($lib , $ mm , $name ) = @_ ;
610636 my @args = (
611637 ' $(LD) $(OPTIMIZE) -lstdc++ -shared' , " -o ${name} " ,
612638 );
@@ -624,6 +650,11 @@ sub compile_lib {
624650 unless ($^O eq ' MSWin32' && $Config {cc } =~ / ^cl/ ) {
625651 push @args , ' -Wl,-rpath,\\ $$ORIGIN/../..' ;
626652 }
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+ }
627658 # -static-libgcc -static-libstdc++
628659 return join (' ' , @args , @libs );
629660}
@@ -643,6 +674,10 @@ sub libsass_sassc
643674 }
644675 # otherwise we asume gcc
645676 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' ;
646681 # create the sassc executable by linking against sassc and libsass
647682 push @ret , " \t " . ' $(LD) -o $(SASSC_EXE) $(LDFLAGS) -lm $(SASSC_OBJ) $(LIBS)'
648683 . ' ' . ($static ? ' $(LIBSASS_OBJ)' : ' -L$(INST_ARCHAUTODIR) -lsass -lstdc++' )
@@ -667,7 +702,7 @@ sub libsass_lib
667702 # create the target for the makefile
668703 push @ret , ' $(LIBSASS_LIB): $(LIBSASS_OBJ)' ;
669704 # 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)' ;
671706 # add target to virtual "pure_all"
672707 push @cleanups , ' $(LIBSASS_OBJ)' ;
673708 push @cleanups , ' $(LIBSASS_LIB)' ;
@@ -686,8 +721,11 @@ sub libsass_plugin_math
686721 # make sure the plugin path exists for output
687722 push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/math' ;
688723 # 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)'
690725 . ' ' . ($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 );
691729 # add target to virtual "pure_all"
692730 push @cleanups , ' $(MATH_OBJ)' ;
693731 push @cleanups , ' $(MATH_LIB)' ;
@@ -706,8 +744,11 @@ sub libsass_plugin_img_size
706744 # make sure the plugin path exists for output
707745 push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/img-size' ;
708746 # 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)'
710748 . ' ' . ($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 );
711752 # add target to virtual "pure_all"
712753 push @cleanups , ' $(IMG_SIZE_OBJ)' ;
713754 push @cleanups , ' $(IMG_SIZE_LIB)' ;
@@ -731,8 +772,11 @@ sub libsass_plugin_digest
731772 # make sure the plugin path exists for output
732773 push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/digest' ;
733774 # 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)'
735776 . ' ' . ($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 );
736780 # add target to virtual "pure_all"
737781 push @cleanups , ' $(DIGEST_OBJ)' ;
738782 push @cleanups , ' $(DIGEST_LIB)' ;
@@ -756,8 +800,11 @@ sub libsass_plugin_glob
756800 # make sure the plugin path exists for output
757801 push @ret , " \t " . ' $(MKPATH) $(INST_ARCHAUTODIR)/plugins/glob' ;
758802 # 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)'
760804 . ' ' . ($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 );
761808 # add target to virtual "pure_all"
762809 push @cleanups , ' $(GLOB_OBJ)' ;
763810 push @cleanups , ' $(GLOB_LIB)' ;
0 commit comments