# New Ticket Created by  Andy Dougherty 
# Please include the string:  [perl #30094]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org:80/rt3/Ticket/Display.html?id=30094 >


The following patch enables the user to control which compilers get
chosen by ICU's configure, and tries to chose sensible defaults if the
user does nothing.  By default, it runs ICU's configure with

        CC=$cc ./configure [options]

where $cc is the C compiler used to build parrot.  This is useful if ICU's
default choice of compiler isn't appropriate.

As an option, this patch allows you to specify the C++ compiler as well,
with something like

        perl Configure.pl --cxx=CC

where CC is the name of your C++ compiler.  With this Configure.pl
option, ICU's configure gets called with

        CXX=$cxx CC=$cc ./configure [options]

This is useful if ICU's default choice of a c++ compiler isn't
appropriate for you.

As a further refinement, I think the c++ searching ought to be moved
to parrot's Configure.pl so that the end result is stored in
Parrot::Config.pm, and a user wishing to extend or embed parrot will
know which c++ compiler to use.


diff -r -u parrot-current/Configure.pl parrot-andy/Configure.pl
--- parrot-current/Configure.pl Mon Apr 26 11:00:11 2004
+++ parrot-andy/Configure.pl    Mon Jun  7 13:05:44 2004
@@ -92,6 +92,10 @@

 Use the given compiler warning flags.

+=item C<--cxx=(compiler)>
+
+Specify which C++ compiler to use (for ICU).
+
 =item C<--libs=(libs)>

 Use the given libraries.
@@ -302,6 +306,7 @@
    --cc=(compiler)      Use the given compiler
    --ccflags=(flags)    Use the given compiler flags
    --ccwarn=(flags)     Use the given compiler warning flags
+   --cxx=(compiler)     Use the given C++ compiler
    --libs=(libs)        Use the given libraries
    --link=(linker)      Use the given linker
    --linkflags=(flags)  Use the given linker flags
diff -r -u parrot-current/config/gen/icu.pl parrot-andy/config/gen/icu.pl
--- parrot-current/config/gen/icu.pl    Mon May  3 11:00:19 2004
+++ parrot-andy/config/gen/icu.pl       Mon Jun  7 16:18:47 2004
@@ -56,7 +56,17 @@
   }
   else
   {
-         $icu_configure_command = "./configure";
+       # Try to build ICU with the same compiler as parrot.
+       # Also respect Configure.pl command-line arguments for c++.
+       $icu_configure_command = "./configure";
+       my $cc = Configure::Data->get('cc');
+       if ($cc ne '') {
+         $icu_configure_command = "CC=$cc $icu_configure_command";
+       }
+       my $cxx = Configure::Data->get('cxx');
+       if ($cxx ne '') {
+         $icu_configure_command = "CXX=$cxx $icu_configure_command";
+       }
   }

   Configure::Data->set( icudatadir => $icudatadir );
diff -r -u parrot-current/config/init/data.pl parrot-andy/config/init/data.pl
--- parrot-current/config/init/data.pl  Mon Apr 26 11:00:11 2004
+++ parrot-andy/config/init/data.pl     Mon Jun  7 13:01:17 2004
@@ -46,6 +46,15 @@
     ccflags       => $Config{ccflags},
     ccwarn        => exists($Config{ccwarn}) ? $Config{ccwarn} : '',

+    # C++ compiler -- used to compile parts of ICU.  ICU's configure
+    # will try to find a suitable compiler, but it prefers GNU c++ over
+    # a system c++, which might not be appropriate.  This setting
+    # allows you to override ICU's guess, but is otherwise currently
+    # unset.  Ultimately, it should be set to whatever ICU figures
+    # out, or parrot should look for it and always tell ICU what to
+    # use.
+    cxx            => '',
+
     # Linker, used to link object files (plus libraries) into
     # an executable.  It is usually $cc on Unix-ish systems.
     # VMS and Win32 might use "Link".
@@ -95,6 +104,8 @@
     make          => $Config{make},
     make_set_make => $Config{make_set_make},
     make_and      => '&&',
+    # make_c: Command to emulate GNU make's C<-C directory> option:  chdir
+    # to C<directory> before executing $(MAKE)
     make_c        => '$(PERL) -e \'chdir shift @ARGV; system q{$(MAKE)}, @ARGV; exit 
$$? >> 8;\'',

     platform_asm  => 0,                   # if platform has a .s file that needs to 
be assembled
diff -r -u parrot-current/config/inter/progs.pl parrot-andy/config/inter/progs.pl
--- parrot-current/config/inter/progs.pl        Thu Feb 26 03:00:08 2004
+++ parrot-andy/config/inter/progs.pl   Mon Jun  7 13:23:15 2004
@@ -22,16 +22,16 @@

 $description = 'Determining what C compiler and linker to use...';

[EMAIL PROTECTED] = qw(ask cc link ld ccflags ccwarn linkflags ldflags libs debugging
[EMAIL PROTECTED] = qw(ask cc cxx link ld ccflags ccwarn linkflags ldflags libs 
debugging
        lex yacc maintainer);

 sub runstep {
   my %args;
   @[EMAIL PROTECTED]@_;

-  my($cc, $link, $ld, $ccflags, $ccwarn, $linkflags, $ldflags, $libs, $lex,
+  my($cc, $cxx, $link, $ld, $ccflags, $ccwarn, $linkflags, $ldflags, $libs, $lex,
      $yacc) =
-       Configure::Data->get(qw(cc link ld ccflags ccwarn linkflags ldflags
+       Configure::Data->get(qw(cc cxx link ld ccflags ccwarn linkflags ldflags
                               libs lex yacc));
   $ccflags =~ s/-D((PERL|HAVE)_\w+\s*|USE_PERLIO)//g;
   $ccflags =~ s/-fno-strict-aliasing//g;
@@ -62,7 +62,7 @@
     $lex = $yacc = $null;
   }

-  for my $var(qw(cc link ld ccflags linkflags ldflags libs ccwarn lex yacc)) {
+  for my $var(qw(cc cxx link ld ccflags linkflags ldflags libs ccwarn lex yacc)) {
     #Symrefs to lexicals are a no-no, so we have to use eval STRING.  %MY, anyone?
     eval qq{ \$$var=integrate(\$$var, \$args{$var}) if defined \$args{$var} };
   }
@@ -89,6 +89,7 @@
     $linkflags=prompt("And your linker?", $linkflags);
     $ldflags=prompt("And your $ld for building shared libraries?", $ldflags);
     $libs=prompt("What libraries should your C compiler use?", $libs);
+    $cxx=prompt("What C++ compiler do you want to use?", $cxx);
     $debug=prompt("Do you want a debugging build of Parrot?", $debug);
     $lex=prompt("Do you have a lexical analyzer generator, like flex or lex?",$lex);
     $yacc=prompt("Do you have a parser generator, like bison or yacc?",$yacc);
@@ -104,6 +105,7 @@

   Configure::Data->set(
     cc      => $cc,
+    cxx      => $cxx,
     link    => $link,
     ld      => $ld,
     ccflags => $ccflags,

-- 
    Andy Dougherty              [EMAIL PROTECTED]

Reply via email to