* [Caml-list] autoconf and caml
@ 2002-09-04 15:20 Kenneth Oksanen
2002-09-05 11:57 ` Xavier Leroy
0 siblings, 1 reply; 19+ messages in thread
From: Kenneth Oksanen @ 2002-09-04 15:20 UTC (permalink / raw)
To: caml-list
I'm writing a piece of software using O'Caml and GNU autoconf (among
others). In C the results of running `./configure' are conveniently
accessed with `#include "config.h"'. My current solution is to
preprocess also the O'Caml code, but this requires some clumsy hacks
in Makefiles etc. Is there a better way? If not, then I'ld suggest
some flag in O'Caml which would run the source files through cpp.
-=-
; Kenneth Oksanen, email: cessu@iki.fi, http://www.iki.fi/~cessu
((lambda(a) (a a((lambda(a)(lambda()(set! a(+ a 1))a))1)))(lambda(a c)
((lambda(b) (newline)(write b)(a a((lambda(c)(lambda()(c c)))(lambda(a)
((lambda(c) (if(=(modulo c b)0)(a a)c))(c))))))(c)))) ; Scheme me!
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-04 15:20 [Caml-list] autoconf and caml Kenneth Oksanen
@ 2002-09-05 11:57 ` Xavier Leroy
2002-09-05 12:23 ` Kenneth Oksanen
2002-09-06 9:42 ` Hendrik Tews
0 siblings, 2 replies; 19+ messages in thread
From: Xavier Leroy @ 2002-09-05 11:57 UTC (permalink / raw)
To: Kenneth Oksanen; +Cc: caml-list
> I'm writing a piece of software using O'Caml and GNU autoconf (among
> others). In C the results of running `./configure' are conveniently
> accessed with `#include "config.h"'. My current solution is to
> preprocess also the O'Caml code, but this requires some clumsy hacks
> in Makefiles etc. Is there a better way? If not, then I'ld suggest
> some flag in O'Caml which would run the source files through cpp.
The -pp flag to ocamlc and ocamlopt lets you do this easily:
ocamlc -pp /lib/cpp ...
- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-05 11:57 ` Xavier Leroy
@ 2002-09-05 12:23 ` Kenneth Oksanen
2002-09-05 12:53 ` Olivier Andrieu
2002-09-05 13:16 ` Lauri Alanko
2002-09-06 9:42 ` Hendrik Tews
1 sibling, 2 replies; 19+ messages in thread
From: Kenneth Oksanen @ 2002-09-05 12:23 UTC (permalink / raw)
To: xavier.leroy; +Cc: caml-list
>> I'm writing a piece of software using O'Caml and GNU autoconf (among
>> others). In C the results of running `./configure' are conveniently
>> accessed with `#include "config.h"'. My current solution is to
>> preprocess also the O'Caml code, but this requires some clumsy hacks
>> in Makefiles etc. Is there a better way? If not, then I'ld suggest
>> some flag in O'Caml which would run the source files through cpp.
>
>The -pp flag to ocamlc and ocamlopt lets you do this easily:
> ocamlc -pp /lib/cpp ...
True, and this had already been kindly pointed out by some other
camlers. A few remarks though:
This flag is not documented on the corresponding man-pages.
The flag does not exist in ocamlyacc and ocamllex.
ocamllex produces code that is not cpp-safe. It contains definitions
of the form
Lexing.lex_base =
"\000\000\255\255\254\255\002\000\248\255\001\000\247\255\246\255\
\250\255\252\255\245\255\251\255\249\255\077\000\244\255\003\000\
etc. At least when passed through GNU CPP version 2.96 20000731 (Red
Hat Linux 7.3 2.96-110) these become converted to
Lexing.lex_base =
"\000\000\255\255\254\255\002\000\248\255\001\000\247\255\246\255 \250\255\252\255\245\255\251\255\249\255\077\000\244\255\003\000 \030\000\031\000\160\000\235\000\054\001\129\001\204\001\023\002 \098\002\011\000\225\255\230\255\173\002\248\002\067\003\142\003 \217\003\036\004\111\004\186\004\005\005\080\005\155\005\230\005 \049\006\124\006\199\006\018\007\232\255\237\255\234\255\231\255 \236\255";
The extra whitespaces in the string constants are crucial. The intent
of the output of ocamllex was that they would *not* be included in the
strings, but cpp mangles those strings so that they are included in
the strings, thereby producing a broken lexer.
-=-
; Kenneth Oksanen, email: cessu@iki.fi, http://www.iki.fi/~cessu
((lambda(a) (a a((lambda(a)(lambda()(set! a(+ a 1))a))1)))(lambda(a c)
((lambda(b) (newline)(write b)(a a((lambda(c)(lambda()(c c)))(lambda(a)
((lambda(c) (if(=(modulo c b)0)(a a)c))(c))))))(c)))) ; Scheme me!
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-05 12:23 ` Kenneth Oksanen
@ 2002-09-05 12:53 ` Olivier Andrieu
2002-09-05 13:16 ` Lauri Alanko
1 sibling, 0 replies; 19+ messages in thread
From: Olivier Andrieu @ 2002-09-05 12:53 UTC (permalink / raw)
To: Kenneth Oksanen; +Cc: caml-list
Kenneth Oksanen [Thursday 5 September 2002] :
> The extra whitespaces in the string constants are crucial. The intent
> of the output of ocamllex was that they would *not* be included in the
> strings, but cpp mangles those strings so that they are included in
> the strings, thereby producing a broken lexer.
In fact there are other pitfalls : cpp only accept lexically correct C
input but ocaml lexical conventions are different. For instance 'a
(type variables) are rejected by cpp if there are an odd number of
them on a line ("missing terminating ' character").
--
Olivier
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-05 12:23 ` Kenneth Oksanen
2002-09-05 12:53 ` Olivier Andrieu
@ 2002-09-05 13:16 ` Lauri Alanko
2002-09-06 10:12 ` Kenneth Oksanen
1 sibling, 1 reply; 19+ messages in thread
From: Lauri Alanko @ 2002-09-05 13:16 UTC (permalink / raw)
To: caml-list
On Thu, Sep 05, 2002 at 03:23:17PM +0300, Kenneth Oksanen wrote:
> ocamllex produces code that is not cpp-safe.
Can't you use m4 or some other (marginally) less brain-dead preprocessor?
Lauri Alanko
la@iki.fi
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-05 13:16 ` Lauri Alanko
@ 2002-09-06 10:12 ` Kenneth Oksanen
2002-09-06 10:25 ` Jun P.FURUSE
2002-09-06 10:46 ` Yann Régis-Gianas
0 siblings, 2 replies; 19+ messages in thread
From: Kenneth Oksanen @ 2002-09-06 10:12 UTC (permalink / raw)
To: la; +Cc: caml-list
>On Thu, Sep 05, 2002 at 03:23:17PM +0300, Kenneth Oksanen wrote:
>> ocamllex produces code that is not cpp-safe.
>Can't you use m4 or some other (marginally) less brain-dead preprocessor?
I could use m4 or camlp4 or whatever, if GNU autoconf and assorted
auto* -tools would produce them.
People seem to have missed the actual problem I have posed: what is
the most convenient and hassle-free mechanism for transporting
information produced by running ./configure to O'Caml source code?
Such features include directory prefixes, auxiliary program paths,
various constants, features {en,dis}abled with --enable-X and alike.
I'm *NOT* trying to use the preprocessor for any weird syntactic
abstractions or anything of that kind.
>From the answers I've seen so far, no common, truly convenient and
completely hassle-free mechanism exists. Hopefully this problem will
find a clean solution some day. In the meantime I can live with -pp cpp
and bite a few small kludges, like adding a (*don't remove me*) ;-)
-=-
; Kenneth Oksanen, email: cessu@iki.fi, http://www.iki.fi/~cessu
((lambda(a) (a a((lambda(a)(lambda()(set! a(+ a 1))a))1)))(lambda(a c)
((lambda(b) (newline)(write b)(a a((lambda(c)(lambda()(c c)))(lambda(a)
((lambda(c) (if(=(modulo c b)0)(a a)c))(c))))))(c)))) ; Scheme me!
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 10:12 ` Kenneth Oksanen
@ 2002-09-06 10:25 ` Jun P.FURUSE
2002-09-06 10:46 ` Yann Régis-Gianas
1 sibling, 0 replies; 19+ messages in thread
From: Jun P.FURUSE @ 2002-09-06 10:25 UTC (permalink / raw)
To: cessu; +Cc: la, caml-list
Hello,
> People seem to have missed the actual problem I have posed: what is
> the most convenient and hassle-free mechanism for transporting
> information produced by running ./configure to O'Caml source code?
> Such features include directory prefixes, auxiliary program paths,
> various constants, features {en,dis}abled with --enable-X and alike.
> I'm *NOT* trying to use the preprocessor for any weird syntactic
> abstractions or anything of that kind.
>
> >From the answers I've seen so far, no common, truly convenient and
> completely hassle-free mechanism exists. Hopefully this problem will
> find a clean solution some day. In the meantime I can live with -pp cpp
> and bite a few small kludges, like adding a (*don't remove me*) ;-)
Do not AC_SUBST(VAR) and AC_OUTPUT(config.ml) solve your problem ?
You can find such examples of the combination of configure script
and .ml files like camlimages or advi:
http://pauillac.inria.fr/camlimages/
http://pauillac.inria.fr/advi/
Hopes this helps.
Jun
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 10:12 ` Kenneth Oksanen
2002-09-06 10:25 ` Jun P.FURUSE
@ 2002-09-06 10:46 ` Yann Régis-Gianas
2002-09-06 10:56 ` Yaron M. Minsky
1 sibling, 1 reply; 19+ messages in thread
From: Yann Régis-Gianas @ 2002-09-06 10:46 UTC (permalink / raw)
To: Kenneth Oksanen; +Cc: caml-list
On Fri, Sep 06, 2002 at 01:12:31PM +0300, Kenneth Oksanen wrote:
> I could use m4 or camlp4 or whatever, if GNU autoconf and assorted
> auto* -tools would produce them.
>
> People seem to have missed the actual problem I have posed: what is
> the most convenient and hassle-free mechanism for transporting
> information produced by running ./configure to O'Caml source code?
> Such features include directory prefixes, auxiliary program paths,
> various constants, features {en,dis}abled with --enable-X and alike.
> I'm *NOT* trying to use the preprocessor for any weird syntactic
> abstractions or anything of that kind.
>
What about using camlp4 to transform config.h file into a
valid Objective Caml module ? I'm using the autotools as a simple user
but config.h is a sequence of #define, is'nt it ? So, we can transform these macros into values declaration. For example:
config.hh
---
/* The ocaml compiler */
#define OCAMLC "ocamlc"
/* The ocaml includes path */
#define OCAMLINCPATH "/usr/lib/ocaml/"
Becomes:
config.ml
---
(* The ocaml compiler *)
let ocamlc = "ocamlc"
(* The ocaml includes path *)
let ocamlincpath = "/usr/lib/ocaml"
Perhaps, I did not understand your problem but I think that
autoconf is not the hardest autotool to bind to ocaml. For my part, I
am currently studying the integration of ocaml in Automake. It is a
real problem because of a lot of exotic features of ocaml development
system like extensions, byte/native code mode, camlp4 ...
--
Yann Régis-Gianas.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 10:46 ` Yann Régis-Gianas
@ 2002-09-06 10:56 ` Yaron M. Minsky
2002-09-06 11:07 ` Maxence Guesdon
2002-09-06 11:33 ` [Caml-list] autoconf and caml Yann Régis-Gianas
0 siblings, 2 replies; 19+ messages in thread
From: Yaron M. Minsky @ 2002-09-06 10:56 UTC (permalink / raw)
To: yann; +Cc: Kenneth Oksanen, caml-list
Yann Régis-Gianas wrote:
> On Fri, Sep 06, 2002 at 01:12:31PM +0300, Kenneth Oksanen wrote:
>
> What about using camlp4 to transform config.h file into a
> valid Objective Caml module ? I'm using the autotools as a simple user
> but config.h is a sequence of #define, is'nt it ? So, we can transform these macros into values declaration. For example:
>
Yes, but you actually don't really want simple values here, because
sometimes you want to use those values to do conditional compilation,
and ocaml values won't help you with that.
y
>
> config.hh
> ---
>
> /* The ocaml compiler */
> #define OCAMLC "ocamlc"
>
> /* The ocaml includes path */
> #define OCAMLINCPATH "/usr/lib/ocaml/"
>
>
> Becomes:
>
> config.ml
> ---
>
> (* The ocaml compiler *)
> let ocamlc = "ocamlc"
>
> (* The ocaml includes path *)
> let ocamlincpath = "/usr/lib/ocaml"
>
>
> Perhaps, I did not understand your problem but I think that
> autoconf is not the hardest autotool to bind to ocaml. For my part, I
> am currently studying the integration of ocaml in Automake. It is a
> real problem because of a lot of exotic features of ocaml development
> system like extensions, byte/native code mode, camlp4 ...
>
>
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 10:56 ` Yaron M. Minsky
@ 2002-09-06 11:07 ` Maxence Guesdon
2002-09-06 12:31 ` pa_ifdef [Was: Re: [Caml-list] autoconf and caml] Stefano Zacchiroli
2002-09-06 11:33 ` [Caml-list] autoconf and caml Yann Régis-Gianas
1 sibling, 1 reply; 19+ messages in thread
From: Maxence Guesdon @ 2002-09-06 11:07 UTC (permalink / raw)
To: Yaron M. Minsky; +Cc: yann, cessu, caml-list
On Fri, 06 Sep 2002 06:56:42 -0400
"Yaron M. Minsky" <yminsky@CS.Cornell.EDU> wrote:
> Yann Régis-Gianas wrote:
> > On Fri, Sep 06, 2002 at 01:12:31PM +0300, Kenneth Oksanen wrote:
> >
> > What about using camlp4 to transform config.h file into a
> > valid Objective Caml module ? I'm using the autotools as a simple user
> > but config.h is a sequence of #define, is'nt it ? So, we can transform these macros into values declaration. For example:
> >
>
> Yes, but you actually don't really want simple values here, because
> sometimes you want to use those values to do conditional compilation,
> and ocaml values won't help you with that.
The pa_ifdef parser included with camlp4 may help you.
Daniel, could you explain how to use it ? Or is a doc written ?
--
Maxence Guesdon
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* pa_ifdef [Was: Re: [Caml-list] autoconf and caml]
2002-09-06 11:07 ` Maxence Guesdon
@ 2002-09-06 12:31 ` Stefano Zacchiroli
2002-09-06 12:52 ` Daniel de Rauglaudre
0 siblings, 1 reply; 19+ messages in thread
From: Stefano Zacchiroli @ 2002-09-06 12:31 UTC (permalink / raw)
To: caml-list
On Fri, Sep 06, 2002 at 01:07:17PM +0200, Maxence Guesdon wrote:
> The pa_ifdef parser included with camlp4 may help you.
> Daniel, could you explain how to use it ? Or is a doc written ?
There is a bit (but enough to using it) of documentation about it in
Section 1.1 of the camlp4 manual.
BTW, last time I used it I was a bit annoyed because you can "ifdef"
only on type declaration or single "let" bindings IIRC while if you are
using such a tool you usually expect to be able to "ifdef" on a whole
block of code in a C-like fashion.
I don't know if such an extension to the pa_ifdef module is feasible
with camlp4 ...
Cheers.
--
Stefano Zacchiroli - undergraduate student of CS @ Univ. Bologna, Italy
zack@cs.unibo.it | ICQ# 33538863 | http://www.cs.unibo.it/~zacchiro
"I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant!" -- G.Romney
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: pa_ifdef [Was: Re: [Caml-list] autoconf and caml]
2002-09-06 12:31 ` pa_ifdef [Was: Re: [Caml-list] autoconf and caml] Stefano Zacchiroli
@ 2002-09-06 12:52 ` Daniel de Rauglaudre
2002-09-08 10:07 ` Stefano Zacchiroli
0 siblings, 1 reply; 19+ messages in thread
From: Daniel de Rauglaudre @ 2002-09-06 12:52 UTC (permalink / raw)
To: caml-list
Hi,
On Fri, Sep 06, 2002 at 02:31:17PM +0200, Stefano Zacchiroli wrote:
> BTW, last time I used it I was a bit annoyed because you can "ifdef"
> only on type declaration or single "let" bindings IIRC while if you are
> using such a tool you usually expect to be able to "ifdef" on a whole
> block of code in a C-like fashion.
>
> I don't know if such an extension to the pa_ifdef module is feasible
> with camlp4 ...
Yes, it is possible. In pa_ifdef.ml, there is a call to the grammar
entry Pcaml.str_item:
| si = Pcaml.str_item -> SdStr si
If you want it to work in "normal" syntax, just change the rule into:
| sil = LIST1 Pcaml.str_item ->
SdStr
(match sil with
[ [x] -> x
| _ -> <:str_item< declare $list:sil$ end >> ])
If you prefer the "revised syntax", the syntax rule must be:
| sil = LIST1 [ x = Pcaml.str_item; ";" -> x ] ->
I did not implement it in pa_ifdef.ml because of this difference
between "normal" and "revised" syntax.
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: pa_ifdef [Was: Re: [Caml-list] autoconf and caml]
2002-09-06 12:52 ` Daniel de Rauglaudre
@ 2002-09-08 10:07 ` Stefano Zacchiroli
2002-09-09 8:59 ` Daniel de Rauglaudre
0 siblings, 1 reply; 19+ messages in thread
From: Stefano Zacchiroli @ 2002-09-08 10:07 UTC (permalink / raw)
To: caml-list
On Fri, Sep 06, 2002 at 02:52:59PM +0200, Daniel de Rauglaudre wrote:
> Yes, it is possible. In pa_ifdef.ml, there is a call to the grammar
> entry Pcaml.str_item:
<snip>
> If you prefer the "revised syntax", the syntax rule must be:
> | sil = LIST1 [ x = Pcaml.str_item; ";" -> x ] ->
<snip>
Thanks for the hint.
> I did not implement it in pa_ifdef.ml because of this difference
> between "normal" and "revised" syntax.
BTW, isn't possible to discriminate inside camlp4 if you are using the
standard syntax or the revised one?
I really think that the 'normal' handling of conditional compilation is
a usefull feature to be distributed along with camlp4.
Cheers.
--
Stefano Zacchiroli - undergraduate student of CS @ Univ. Bologna, Italy
zack@cs.unibo.it | ICQ# 33538863 | http://www.cs.unibo.it/~zacchiro
"I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant!" -- G.Romney
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: pa_ifdef [Was: Re: [Caml-list] autoconf and caml]
2002-09-08 10:07 ` Stefano Zacchiroli
@ 2002-09-09 8:59 ` Daniel de Rauglaudre
0 siblings, 0 replies; 19+ messages in thread
From: Daniel de Rauglaudre @ 2002-09-09 8:59 UTC (permalink / raw)
To: caml-list
Hi,
On Sun, Sep 08, 2002 at 12:07:49PM +0200, Stefano Zacchiroli wrote:
> BTW, isn't possible to discriminate inside camlp4 if you are using the
> standard syntax or the revised one?
For the moment, no, but I could add something. I am thinking of adding
a string to "name" the current syntax. In this case, all Camlp4 syntaxes
should be named. For example, I added a Scheme-like syntax: it must be
named also.
The syntax "names" must be then "standardized" in Camlp4 if we want to
use these names in the syntax extensions.
--
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 10:56 ` Yaron M. Minsky
2002-09-06 11:07 ` Maxence Guesdon
@ 2002-09-06 11:33 ` Yann Régis-Gianas
2002-09-06 11:22 ` Yaron M. Minsky
1 sibling, 1 reply; 19+ messages in thread
From: Yann Régis-Gianas @ 2002-09-06 11:33 UTC (permalink / raw)
To: Yaron M. Minsky; +Cc: caml-list
On Fri, Sep 06, 2002 at 06:56:42AM -0400, Yaron M. Minsky wrote:
> Yes, but you actually don't really want simple values here, because
> sometimes you want to use those values to do conditional compilation,
> and ocaml values won't help you with that.
>
I think conditional compilation cannot be done since modules
are not first class citizens. The only way I see is to introduce
preprocessor comands with camlp4.
The question is : what kind of conditional compilation do you
want ? If you want something like:
let foo x =
#ifdef I_LOVE_FOO
"foo"
#else
"bar"
#endif
It can be replaced by:
open Config
let foo x = if i_love_foo then "foo" else "bar"
You will not pay a runtime cost because "i_love_foo" is a
static value and unused code will be trimmed by ocaml compiler.
--
Yann Régis-Gianas.
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 11:33 ` [Caml-list] autoconf and caml Yann Régis-Gianas
@ 2002-09-06 11:22 ` Yaron M. Minsky
2002-09-06 11:28 ` Jérôme Marant
0 siblings, 1 reply; 19+ messages in thread
From: Yaron M. Minsky @ 2002-09-06 11:22 UTC (permalink / raw)
To: yann; +Cc: caml-list
Yann Régis-Gianas wrote:
> On Fri, Sep 06, 2002 at 06:56:42AM -0400, Yaron M. Minsky wrote:
>
>>Yes, but you actually don't really want simple values here, because
>>sometimes you want to use those values to do conditional compilation,
>>and ocaml values won't help you with that.
>
> I think conditional compilation cannot be done since modules
> are not first class citizens. The only way I see is to introduce
> preprocessor comands with camlp4.
>
> The question is : what kind of conditional compilation do you
> want ? If you want something like:
>
> let foo x =
> #ifdef I_LOVE_FOO
> "foo"
> #else
> "bar"
> #endif
>
> It can be replaced by:
>
> open Config
>
> let foo x = if i_love_foo then "foo" else "bar"
>
> You will not pay a runtime cost because "i_love_foo" is a
> static value and unused code will be trimmed by ocaml compiler.
I personally need real conditional compilation, of the kind that
requires camlp4 or some other preprocessor. Sometimes you really need
that because different modules (and/or different external C code) is
required on different platforms.
y
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 11:22 ` Yaron M. Minsky
@ 2002-09-06 11:28 ` Jérôme Marant
2002-09-06 11:41 ` Yaron M. Minsky
0 siblings, 1 reply; 19+ messages in thread
From: Jérôme Marant @ 2002-09-06 11:28 UTC (permalink / raw)
To: caml-list
On Fri, Sep 06, 2002 at 07:22:36AM -0400, Yaron M. Minsky wrote:
> I personally need real conditional compilation, of the kind that
> requires camlp4 or some other preprocessor. Sometimes you really need
> that because different modules (and/or different external C code) is
> required on different platforms.
Why do you need conditional compilation, and how?
Parametric modules makes it possible to replace the need
for conditional compilation.
--
Jérôme Marant
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-06 11:28 ` Jérôme Marant
@ 2002-09-06 11:41 ` Yaron M. Minsky
0 siblings, 0 replies; 19+ messages in thread
From: Yaron M. Minsky @ 2002-09-06 11:41 UTC (permalink / raw)
To: Jérôme Marant; +Cc: caml-list
Maybe I'm wrong. There are two examples I've run up against. First, I
have some C-code that's needed on one platform (windows) but not others.
So on that platform, I want the function definition to include an
"external" reference. On the other platform, the C code doesn't even
compile, and so the C object file isn't there and there should be no
external reference.
The second example is using something like Numerix, where different
modules (Dlong, Slong, Clong) are provided on different platforms. Even
including the name of, say, module Slong when there is no Slong module
will cause a compilation error. Again, I don't see how to get around
this without conditional compilation.
y
Jérôme Marant wrote:
> On Fri, Sep 06, 2002 at 07:22:36AM -0400, Yaron M. Minsky wrote:
>
>
>>I personally need real conditional compilation, of the kind that
>>requires camlp4 or some other preprocessor. Sometimes you really need
>>that because different modules (and/or different external C code) is
>>required on different platforms.
>
>
> Why do you need conditional compilation, and how?
> Parametric modules makes it possible to replace the need
> for conditional compilation.
>
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [Caml-list] autoconf and caml
2002-09-05 11:57 ` Xavier Leroy
2002-09-05 12:23 ` Kenneth Oksanen
@ 2002-09-06 9:42 ` Hendrik Tews
1 sibling, 0 replies; 19+ messages in thread
From: Hendrik Tews @ 2002-09-06 9:42 UTC (permalink / raw)
To: caml-list
> I'm writing a piece of software using O'Caml and GNU autoconf (among
> others). In C the results of running `./configure' are conveniently
> accessed with `#include "config.h"'. My current solution is to
> preprocess also the O'Caml code, but this requires some clumsy hacks
> in Makefiles etc. Is there a better way? If not, then I'ld suggest
> some flag in O'Caml which would run the source files through cpp.
Why not writing Ocaml files directly through configure? Just set
your own variables and apply AC_SUBST to them. And if you need
conditional compilation use camlp4 and pa_ifdef.
In our Ocaml project I let configure write a shell script and
invoke the shell script immediately to write other files
(including ml files). The redirection via a shell script is
necessary because configure might output something like
prefix=/usr/local
libdir=${prefix}/lib
Here are fragments from the relevant files, you can inspect the
full source code at
http://wwwtcs.inf.tu-dresden.de/~tews/ccsl/#getandrun.
configure.in fragment
=============================
AC_OUTPUT(Makefile varsubst.sh, sh varsubst.sh)
=============================
varsubst.sh.in
========================================================================
files="Common/config.ml Doc/ccslc.1 Doc/ccslc.html"
prefix=/usr/local
exec_prefix=${prefix}
libdir=/home/tews/Privat/Coda/Work2/Lib/Pvs
echo writing files $files
for f in $files ; do
# echo sed -e "s%@mllibdir@%$libdir%" \< ${mlconfigfile}.in \> ${mlconfigfile}
echo writing $f
sed -e "s%@mllibdir@%$libdir%" < $f.in > $f
done
=======================================================================
Common/config.ml.in
===========================================================
let fixedpointlib = "@mllibdir@"
===========================================================
Bye,
Hendrik
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2002-09-09 8:59 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-04 15:20 [Caml-list] autoconf and caml Kenneth Oksanen
2002-09-05 11:57 ` Xavier Leroy
2002-09-05 12:23 ` Kenneth Oksanen
2002-09-05 12:53 ` Olivier Andrieu
2002-09-05 13:16 ` Lauri Alanko
2002-09-06 10:12 ` Kenneth Oksanen
2002-09-06 10:25 ` Jun P.FURUSE
2002-09-06 10:46 ` Yann Régis-Gianas
2002-09-06 10:56 ` Yaron M. Minsky
2002-09-06 11:07 ` Maxence Guesdon
2002-09-06 12:31 ` pa_ifdef [Was: Re: [Caml-list] autoconf and caml] Stefano Zacchiroli
2002-09-06 12:52 ` Daniel de Rauglaudre
2002-09-08 10:07 ` Stefano Zacchiroli
2002-09-09 8:59 ` Daniel de Rauglaudre
2002-09-06 11:33 ` [Caml-list] autoconf and caml Yann Régis-Gianas
2002-09-06 11:22 ` Yaron M. Minsky
2002-09-06 11:28 ` Jérôme Marant
2002-09-06 11:41 ` Yaron M. Minsky
2002-09-06 9:42 ` Hendrik Tews
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).