* Example OMakefile to package OCaml code as a C library
@ 2007-03-28 8:40 Joel Reymont
2007-03-30 16:27 ` Aleksey Nogin
0 siblings, 1 reply; 2+ messages in thread
From: Joel Reymont @ 2007-03-28 8:40 UTC (permalink / raw)
To: Caml List; +Cc: Aleksey Nogin
Does anyone have an example OMakefile that can be used to package
OCaml code as a C library?
This is along the lines of what I'm trying to accomplish:
ocamlopt -output-obj -o fibcaml.o fib.ml
ocamlopt -c fibwrap.c
cp /usr/local/lib/ocaml/libasmrun.a libfib.a
ar r libfib.a fibcaml.o fibwrap.o
Thanks, Joel
--
http://wagerlabs.com/
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Example OMakefile to package OCaml code as a C library
2007-03-28 8:40 Example OMakefile to package OCaml code as a C library Joel Reymont
@ 2007-03-30 16:27 ` Aleksey Nogin
0 siblings, 0 replies; 2+ messages in thread
From: Aleksey Nogin @ 2007-03-30 16:27 UTC (permalink / raw)
To: Joel Reymont; +Cc: Caml List, omake
On 28.03.2007 01:40, Joel Reymont wrote:
> Does anyone have an example OMakefile that can be used to package OCaml
> code as a C library?
>
> This is along the lines of what I'm trying to accomplish:
>
> ocamlopt -output-obj -o fibcaml.o fib.ml
> ocamlopt -c fibwrap.c
> cp /usr/local/lib/ocaml/libasmrun.a libfib.a
> ar r libfib.a fibcaml.o fibwrap.o
>
Joel,
The above seems relatively straightforward. I would imagine that you can
give ocamlopt a list of .cmx files instead of the .ml files (this should
make things more modular and incremental). So you just do something like:
-----------
LIB = fib
CFILES = fibwrap
MLFILES = fib
OCAMLLIB = $(dir $"$(shell $(OCAMLC) -where)")
$(LIB)caml$(EXT_OBJ): $(addsuffix .cmx, $(MLFILES))
$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -output-obj -o $@
$(OCamlLinkSort $+)
OBJS = $(addsuffix $(EXT_OBJ), $(LIB)caml $(CFILES))
lib$(LIB)$(EXT_LIB): $(OCAMLLIB)/libasmrun$(EXT_LIB) $(OBJS)
cp -f $< $@
ar q $@ $(OBJS)
----------
The above can also be easily made into a function that can be reused:
----------
OCAMLLIB = $(dir $"$(shell $(OCAMLC) -where)")
MakeWrapLib(LIB, MLFILES, CFILES) =
$(LIB)caml$(EXT_OBJ): $(addsuffix .cmx, $(MLFILES))
$(OCAMLOPT) $(OCAMLFLAGS) $(OCAMLOPTFLAGS) -output-obj -o $@
$(OCamlLinkSort $+)
OBJS = $(addsuffix $(EXT_OBJ), $(LIB)caml $(CFILES))
lib$(LIB)$(EXT_LIB): $(OCAMLLIB)/libasmrun$(EXT_LIB) $(OBJS)
cp -f $< $@
ar q $@ $(OBJS)
return lib$(LIB)$(EXT_LIB)
MakeWrapLib(fib, fib, fibwrap)
----------
Aleksey
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-03-30 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-28 8:40 Example OMakefile to package OCaml code as a C library Joel Reymont
2007-03-30 16:27 ` Aleksey Nogin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox