automake
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: first attempt at ocaml support


From: Guillaume Rousse
Subject: Re: first attempt at ocaml support
Date: Tue, 19 Dec 2006 11:03:47 +0100
User-agent: Thunderbird 1.5.0.8 (X11/20061109)

Also sprach Ralf Wildenhues:
> Hello Guillaume,
> 
> Thanks for your work on this, and apologies for my lack of feedback.
> 
> * Guillaume Rousse wrote on Fri, Dec 15, 2006 at 06:23:36PM CET:
>> Here are the current issues:
>> Ocaml actually support two different compilation modes,  native and
>> bytecode. The current compilation command in the registration template
>> is for bytecode only, and I don't know if automake architecture allow to
>> define two compilation rules for each source file.
> 
> Hmm.  How would Automake know which one to use?  Is that a typical
> developer's choice, user's choice, or can Automake do as it likes?
It depends on the context. When building a library, you need both
versions, unless you have good reasons. When building a program, you
generally want the binary if possible, otherwise fallback to the
bytecode version.

The libtool model for building shared or static libs seems OK there: let
user select what he wants, and eventually let developper alter defaults.

>> AM_DEPENDENCIES(OCAML) actually try to find which type of computation is
>> suitable, using a C compiler-targeted test... and fails. Obvisouly, I
>> need to force it there.
> 
> For the patch to work at all, I need a definition of AC_PROG_OCAML.
> But my Autoconf does not have this.  Do you have a (possibly
> preliminary) patch for this?
Right, sorry. Here it is.
They are two stuff missings in the macro definition:
- computation of EXEEXT variable (I didn't found how to do it)
- declaration of compilation flags as 'precious' variable (I understood
it would allow to use ./configure --OCAMLFLAGS as already possible for
./configure --CFLAGS)

Also, I'm not really sure about exact variable naming. I'm using OCAMLIB
here for sake of consistency with other variables such as OCAMLVERSION,
but I'm a bit confused by the apparent use of lowercase for naming
directories in autoconf.

>> Last, once the patch applied, I can't build and install automake anymore:
>> address@hidden automake-1.10.ocaml]$ LC_ALL=C make
>>  cd . &&
>> perllibdir=/home/alceste/rousse/work/automake-1.10.ocaml"/lib:./lib"
>> /home/alceste/rousse/work/automake-1.10.ocaml/automake --libdir=lib --gnu
>> /bin/sh: line 4: /home/alceste/rousse/work/automake-1.10.ocaml/automake:
>> No such file or directory
>> make: *** [Makefile.in] Error 1
> 
> I don't even get this far:
> 
> | cd ../automake && perllibdir=/tmp/build"/lib:./lib" /tmp/build/aclocal 
> --acdir=m4 -I m4
> | configure.ac:37: error: defn: undefined macro: AC_PROG_OCAML
> | m4/options.m4:31: _AM_IF_OPTION is expanded from...
> | m4/init.m4:26: AM_INIT_AUTOMAKE is expanded from...
> | configure.ac:37: the top level
> | autom4te: /usr/bin/m4 failed with exit status: 1
> | aclocal: autom4te failed with exit status: 1
> 
> 
>> +# Objective Caml
>> +register_language ('name' => 'ocaml',
>> +                  'Name' => 'Objective Caml',
>> +                  'config_vars' => ['OCAMLDEP', 'OCAMLC'],
>> +              'flags' => ['OCAML_INCLUDES', 'OCAMLFLAGS'],
>> +              'compiler' => 'COMPILE',
> 
> Shouldn't this be something like OCAMLCOMPILE?
I must confess I didn't understood exaclty what it was supposed to do,
and I filled it just to avoid warnings :(

> FWIW, it's nicer if indented consistenly wrt. TABs.
> 
>> --- automake-1.10/lib/depcomp        2006-10-15 18:54:11.000000000 +0200
>> +++ automake-1.10.ocaml/lib/depcomp  2006-12-15 16:41:22.000000000 +0100
>> @@ -562,6 +562,10 @@
>>    rm -f "$tmpdepfile"
>>    ;;
>>  
>> +ocamldep)
>> +  "$@" "$source" > "$depfile"
> 
> If you output to "$tmpdepfile" and then mv that, there's no broken
> output that can confuse 'make' after an interrupted build.
OK, here is a better patch with nicer indentation, and suggested
improvement for depcomp.

> Another hint: it really helps with Automake (and other stuff obviously)
> if you start programming by writing tests: what should work.  That also
> helps others (like me) see what you'd like to see Automake do.
Right. I just need to really understand how dependencies are managed to
even think of implementing such a test.

> Thanks again,
Well... For the moment, I'm rather the one requesting help than the
opposite :)

Attachment: ocaml.m4
Description: application/m4

diff -Naur --exclude '.*' automake-1.10/automake.in 
automake-1.10.ocaml/automake.in
--- automake-1.10/automake.in   2006-10-15 18:19:37.000000000 +0200
+++ automake-1.10.ocaml/automake.in     2006-12-19 10:35:19.000000000 +0100
@@ -763,6 +763,24 @@
                   'pure' => 1,
                   'extensions' => ['.upc']);
 
+# Objective Caml
+register_language ('name' => 'ocaml',
+                 'Name' => 'Objective Caml',
+                 'config_vars' => ['OCAMLDEP', 'OCAMLC'],
+                 'flags' => ['OCAML_INCLUDES', 'OCAMLFLAGS'],
+                 'compiler' => 'COMPILE',
+                 'compile' => '$(OCAMLC) $(OCAML_INCLUDES) $(AM_OCAMLFLAGS) 
$(OCAMLFLAGS)',
+                 'compile_flag' => '-c',
+                 'output_flag' => '-o',
+                 'autodep' => 'OCAML',
+                 'output_extensions' => sub {
+                      (my $byt = $_[0]) =~ s/\.ml$/.cmo/;
+                      (my $opt = $_[0]) =~ s/\.ml$/.cmx/;
+                      return ($byt, $opt)
+                  },
+                 'pure' => 1, 
+                  'extensions' => ['.ml']);
+
 # Headers.
 register_language ('name' => 'header',
                   'Name' => 'Header',
@@ -5278,6 +5296,13 @@
     return &lang_sub_obj;
 }
 
+# Rewrite a single ocaml file.
+sub lang_ocaml_rewrite
+{
+    return &lang_sub_obj;
+}
+
+
 # Rewrite a single header file.
 sub lang_header_rewrite
 {
diff -Naur --exclude '.*' automake-1.10/lib/depcomp 
automake-1.10.ocaml/lib/depcomp
--- automake-1.10/lib/depcomp   2006-10-15 18:54:11.000000000 +0200
+++ automake-1.10.ocaml/lib/depcomp     2006-12-19 10:38:24.000000000 +0100
@@ -562,6 +562,11 @@
   rm -f "$tmpdepfile"
   ;;
 
+ocamldep)
+  "$@" "$source" > "$tmpdepfile"
+  mv -f "$tmpdepfile" "$depfile"
+  ;;
+
 none)
   exec "$@"
   ;;
diff -Naur --exclude '.*' automake-1.10/m4/depend.m4 
automake-1.10.ocaml/m4/depend.m4
--- automake-1.10/m4/depend.m4  2006-08-14 20:48:23.000000000 +0200
+++ automake-1.10.ocaml/m4/depend.m4    2006-12-15 18:02:38.000000000 +0100
@@ -35,6 +35,7 @@
        [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
        [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
        [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], OCAML,[depcc="$OCAMLDEP"  am_compiler_list='ocamldep'],
        [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
                    [depcc="$$1"   am_compiler_list=])
 
diff -Naur --exclude '.*' automake-1.10/m4/init.m4 
automake-1.10.ocaml/m4/init.m4
--- automake-1.10/m4/init.m4    2006-08-30 08:22:49.000000000 +0200
+++ automake-1.10.ocaml/m4/init.m4      2006-12-15 18:02:38.000000000 +0100
@@ -99,6 +99,10 @@
                   [_AM_DEPENDENCIES(OBJC)],
                   [define([AC_PROG_OBJC],
                           defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OCAML],
+                  [_AM_DEPENDENCIES(OCAML)],
+                  [define([AC_PROG_OCAML],
+                          defn([AC_PROG_OCAML])[_AM_DEPENDENCIES(OCAML)])])dnl
 ])
 ])
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]