caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] Building O'Caml projects properly.
@ 2001-10-01  7:04 Jeremy Fincher
  2001-10-01  8:07 ` Markus Mottl
  0 siblings, 1 reply; 11+ messages in thread
From: Jeremy Fincher @ 2001-10-01  7:04 UTC (permalink / raw)
  To: caml-list

>If you want to do what I usually do, your project tree should look
>somewhat like this:
>
>   ./
>     Makefile
>     OcamlMakefile
>     lib/
>     libsrc/
>       lib1/...
>       lib2/...
>       lib3/...
>     src/
>       Makefile
>       src1.ml
>       src2.ml
>       ...

I have a similar directory structure to that one in my ~/src/ocaml/my
directory.  As far as lib/ and libsrc/ go, it's exactly the same.  Rather
than having a src/ directory, though, I'm not going to use a toplevel
Makefile and instead have my projects in their own directories at the same
level as lib/ and libsrc/.  Of course, I only have one project at the 
moment,
so it's not a huge deal, but when I get more it might matter :)

All the lib/* directories compile and install correctly using the following
Makefile:

---------------------------------------------------------------------------
OCAMLMAKEFILE = ../../OcamlMakefile

SOURCES = sformat.ml
RESULT = a.out
LIBDIRS = ../../lib
INCDIRS = ../../lib
LIBINSTALL_FILES = *.mli *.cmi *.cma *.cmo *.cmx *.cmxa *.a *.o
OCAML_LIB_INSTALL = ../../lib

all:	byte-code-library native-code-library

-include $(OCAMLMAKEFILE)
---------------------------------------------------------------------------

Everything works correctly *except* that after I make libinstall, it removes
the *.mli files from the directory, which I don't want it to do.

I do get hung up, however, when trying to compile my project, using this
Makefile:

----------------------------------------------------------------------------
OCAMLMAKEFILE = ../OcamlMakefile

SOURCES = calc_parser.mly calc_lexer.mll ircmsg.ml irclib.ml ircutils.ml 
logger.ml flusher.ml ircusers.ml factoids.ml help.ml privmsg_callbacks.ml 
callbacks.ml irctester.ml
RESULT = ircbot
LIBS = unix pcre
LIBDIRS = ../lib
INCDIRS = ../lib

all:	byte-code native-code

-include $(OCAMLMAKEFILE)
----------------------------------------------------------------------------

Everything compiles correctly, but when it gets to the linking stage, it 
tells
me this:

gmake[1]: Entering directory `/usr/home/jfincher/src/ocaml/my/ocamlbot'
ocamlc  -I ../lib      -ccopt -L../lib  unix.cma pcre.cma   -o ircbot \
                        calc_parser.cmo calc_lexer.cmo ircmsg.cmo irclib.cmo 
ircutils.cmo logger.cmo flusher.cmo ircusers.cmo factoids.cmo help.cmo 
privmsg_callbacks.cmo callbacks.cmo irctester.cmo
Error while linking ircmsg.cmo: Reference to undefined global `Py_string'
gmake[1]: *** [ircbot] Error 2
gmake[1]: Leaving directory `/usr/home/jfincher/src/ocaml/my/ocamlbot'
gmake: *** [byte-code] Error 2

And I have no idea what to do about it.  All the proper py_string.cm* files 
are
in the lib directory as they should be.

Any comments on the above Makefiles, either related to my specific questions
or not, are appreciated.

Jeremy


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
  2001-10-01  7:04 [Caml-list] Building O'Caml projects properly Jeremy Fincher
@ 2001-10-01  8:07 ` Markus Mottl
  0 siblings, 0 replies; 11+ messages in thread
From: Markus Mottl @ 2001-10-01  8:07 UTC (permalink / raw)
  To: Jeremy Fincher; +Cc: caml-list

On Mon, 01 Oct 2001, Jeremy Fincher wrote:
> Everything works correctly *except* that after I make libinstall, it
> removes the *.mli files from the directory, which I don't want it to do.

Remove .mli-files? The libinstall target doesn't remove any files
at all. It just copies them to the right directory. Or did you mean
anything else?

> ocamlc  -I ../lib      -ccopt -L../lib  unix.cma pcre.cma   -o ircbot \
>                         calc_parser.cmo calc_lexer.cmo ircmsg.cmo irclib.cmo 
> ircutils.cmo logger.cmo flusher.cmo ircusers.cmo factoids.cmo help.cmo 
> privmsg_callbacks.cmo callbacks.cmo irctester.cmo
> Error while linking ircmsg.cmo: Reference to undefined global `Py_string'

This is not surprising, because it obviously doesn't link against
"py_string.cmo". You can specify this using the "LIBS" variable. Just add
"py_string" and everything should be fine.

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
  2001-10-01 13:47     ` Markus Mottl
@ 2001-10-01 15:17       ` Julian Assange
  0 siblings, 0 replies; 11+ messages in thread
From: Julian Assange @ 2001-10-01 15:17 UTC (permalink / raw)
  To: Markus Mottl; +Cc: Hideo Bannai, Jeremy Fincher, caml-list

> Since I don't have access to any MacOS-box, I can only trust you here.

But you do! ssh cf.sourceforge.net, and choose "MacOSX".

> I have added this flag now and hope that this fixes this problem with
> exotic "install"-implementations.

Cheers,
Julian.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
@ 2001-10-01 14:02 Jeremy Fincher
  0 siblings, 0 replies; 11+ messages in thread
From: Jeremy Fincher @ 2001-10-01 14:02 UTC (permalink / raw)
  To: caml-list

> > Actually, it might be the difference in default behavior of the
> > `install' command. On my MacOS X, it moves the files by default,
> > where on my Linux box, they get copied.
>
>Ah, ok, I didn't expect that there are versions of the install command
>that actually move files by default (what a horrible idea!).
>
> > Adding `-c' option to the install command in OcamlMakefile would do
> > the trick I think.
>
>Since I don't have access to any MacOS-box, I can only trust you here.
>I have added this flag now and hope that this fixes this problem with
>exotic "install"-implementations.

I just checked the manpage for install on my box, and it's true -- -c
copies the file, instead of the default behavior which is to remove the
original file after creating the target.

This is a FreeBSD 4.3 box.  I think it's a peculiarity of the BSD
"install", since it's not localized to MacOS X.

Are there any known workarounds with the current OcamlMakefile, or will
there be a new version released shortly that compensates for this?

Also, you mentioned in your other email that I need to make a "real
library" out of my py_string.ml{,i} files.  Here's the exact Makefile
I'm using for that set of modules:

------------------
OCAMLMAKEFILE = ../../OcamlMakefile

SOURCES = py_string.ml py_os.ml py_fnmatch.ml py_glob.ml py_time.ml 
py_socket.ml py_asyncore.ml py_asynchat.ml
RESULT = a.out
LIBS = unix pcre
LIBDIRS = ../../lib
INCDIRS = ../../lib
LIBINSTALL_FILES = *.mli *.cmi *.cma *.cmo *.cmx *.cmxa *.a *.o
OCAML_LIB_INSTALL = ../../lib

all:	byte-code-library native-code-library

-include $(OCAMLMAKEFILE)
------------------

What do I need to add to make it compile a real library?

Thanks,
Jeremy


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
  2001-10-01 13:08   ` Hideo Bannai
@ 2001-10-01 13:47     ` Markus Mottl
  2001-10-01 15:17       ` Julian Assange
  0 siblings, 1 reply; 11+ messages in thread
From: Markus Mottl @ 2001-10-01 13:47 UTC (permalink / raw)
  To: Hideo Bannai; +Cc: Jeremy Fincher, caml-list

On Mon, 01 Oct 2001, Hideo Bannai wrote:
> Actually, it might be the difference in default behavior of the
> `install' command. On my MacOS X, it moves the files by default,
> where on my Linux box, they get copied.

Ah, ok, I didn't expect that there are versions of the install command
that actually move files by default (what a horrible idea!).

> Adding `-c' option to the install command in OcamlMakefile would do
> the trick I think.

Since I don't have access to any MacOS-box, I can only trust you here.
I have added this flag now and hope that this fixes this problem with
exotic "install"-implementations.

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
  2001-10-01 12:57 ` Markus Mottl
@ 2001-10-01 13:08   ` Hideo Bannai
  2001-10-01 13:47     ` Markus Mottl
  0 siblings, 1 reply; 11+ messages in thread
From: Hideo Bannai @ 2001-10-01 13:08 UTC (permalink / raw)
  To: Markus Mottl; +Cc: Jeremy Fincher, caml-list


Hello,

> On Mon, 01 Oct 2001, Jeremy Fincher wrote:
> > When I do a simple "gmake", it compiles all the files, and the directory
> > becomes filled with ".cmo" and ".cmx" files and so on.  After doing
> > a "make libinstall" and answering 'y' to the question it asks about
> > installation, the only things that remain in the directory are the
> > .ml files and the Makefile itself.  Somehow, given that Makefile,
> > it's removing all the files it installs.
> 
> I have never seen this happen and I really can't imagine how this could
> work. Could you please send me your Makefile? Maybe you have accidently
> added a dependency on the "clean"-target or similar.

Actually, it might be the difference in default behavior of the
`install' command. On my MacOS X, it moves the files by default,
where on my Linux box, they get copied.

Adding `-c' option to the install command in OcamlMakefile would do
the trick I think.

--
Hideo Bannai
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
  2001-10-01 11:46 Jeremy Fincher
@ 2001-10-01 12:57 ` Markus Mottl
  2001-10-01 13:08   ` Hideo Bannai
  0 siblings, 1 reply; 11+ messages in thread
From: Markus Mottl @ 2001-10-01 12:57 UTC (permalink / raw)
  To: Jeremy Fincher; +Cc: caml-list

On Mon, 01 Oct 2001, Jeremy Fincher wrote:
> When I do a simple "gmake", it compiles all the files, and the directory
> becomes filled with ".cmo" and ".cmx" files and so on.  After doing
> a "make libinstall" and answering 'y' to the question it asks about
> installation, the only things that remain in the directory are the
> .ml files and the Makefile itself.  Somehow, given that Makefile,
> it's removing all the files it installs.

I have never seen this happen and I really can't imagine how this could
work. Could you please send me your Makefile? Maybe you have accidently
added a dependency on the "clean"-target or similar.

> I added py_string to the LIBS line in that Makefile, but it complained about
> not being able to find "py_string.cma".

I had thought that "py_string" is a library (.cma-file). Maybe you have
only a .cmo-file there. You can either add "OCAMLLDFLAGS = py_string.cmo"
to your Makefile or make a real library out of "py_string". The last
alternative should definitely be preferred over the first one.

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
@ 2001-10-01 11:46 Jeremy Fincher
  2001-10-01 12:57 ` Markus Mottl
  0 siblings, 1 reply; 11+ messages in thread
From: Jeremy Fincher @ 2001-10-01 11:46 UTC (permalink / raw)
  To: caml-list

>Remove .mli-files? The libinstall target doesn't remove any files
>at all. It just copies them to the right directory. Or did you mean
>anything else?

When I do a simple "gmake", it compiles all the files, and the directory
becomes filled with ".cmo" and ".cmx" files and so on.  After doing a
"make libinstall" and answering 'y' to the question it asks about
installation, the only things that remain in the directory are the .ml
files and the Makefile itself.  Somehow, given that Makefile, it's
removing all the files it installs.

>This is not surprising, because it obviously doesn't link against
>"py_string.cmo". You can specify this using the "LIBS" variable. Just add
>"py_string" and everything should be fine.

I added py_string to the LIBS line in that Makefile, but it complained about
not being able to find "py_string.cma".

Jeremy


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
  2001-09-29 20:31 Jeremy Fincher
  2001-09-29 21:48 ` Julian Assange
@ 2001-09-29 22:08 ` Markus Mottl
  1 sibling, 0 replies; 11+ messages in thread
From: Markus Mottl @ 2001-09-29 22:08 UTC (permalink / raw)
  To: Jeremy Fincher; +Cc: caml-list

On Sat, 29 Sep 2001, Jeremy Fincher wrote:
> I'm not very experienced with make, so I've been using Markus Mottl's
> OcamlMakefile in my projects so far.  In one of my projects, I use
> source files from two other small libraries I've written; at present,
> I just have a whole lot of files in my SOURCES and a bunch of symlinks
> to the proper files in the proper directories.  However, I'd really
> like to be able to improve my build process, and I think a good way to
> do that is to isolate in directories the other libraries I've written.

"make" is notoriously bad at handling project dependencies across several
directories. This means that it imposes some work on the developers to
behave as they want it to.

If you want to do what I usually do, your project tree should look
somewhat like this:

  ./
    Makefile
    OcamlMakefile
    lib/
    libsrc/
      lib1/...
      lib2/...
      lib3/...
    src/
      Makefile
      src1.ml
      src2.ml
      ...

Your Makefile in the toplevel could contain something like this:

---------------------------------------------------------------------------
OCAML_LIB_INSTALL := $(shell echo `pwd`/lib)
LIBSRC := $(filter-out libsrc/CVS, $(wildcard libsrc/*))

all:    libsrc
	cd src; $(MAKE) all

.PHONY: libsrc
libsrc:
	for dir in $(LIBSRC); do (cd $$dir; yes | $(MAKE) install); done
---------------------------------------------------------------------------

If all your libraries follow the OcamlMakefile install conventions, they
will be installed in directory "lib". Then your Makefile in directory
"src" can refer to your libraries as usual:

---------------------------------------------------------------------------
OCAMLMAKEFILE = ../OcamlMakefile

SOURCES = src1.ml src2.ml ...
RESULT = myexe
LIBDIRS = ../lib
INCDIRS = ../lib

-include $(OCAMLMAKEFILE)
---------------------------------------------------------------------------

Enter "make" in the toplevel directory of your project, and everything
will be compiled. People usually do not edit their libraries all the
time so you only need to issue "make" in your "src"-directory in most
cases (very efficient).  When you change some library, issue a "make"
in the toplevel again and make sure that your "src"-tree will be rebuilt
correctly. If insure in the last case, a "make clean; make" in directory
"src" will do what you want.

I hope this will help you getting started with more complex projects!

Regards,
Markus Mottl

-- 
Markus Mottl                                             markus@oefai.at
Austrian Research Institute
for Artificial Intelligence                  http://www.oefai.at/~markus
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [Caml-list] Building O'Caml projects properly.
  2001-09-29 20:31 Jeremy Fincher
@ 2001-09-29 21:48 ` Julian Assange
  2001-09-29 22:08 ` Markus Mottl
  1 sibling, 0 replies; 11+ messages in thread
From: Julian Assange @ 2001-09-29 21:48 UTC (permalink / raw)
  To: Jeremy Fincher; +Cc: caml-list

> I'm not very experienced with make, so I've been using Markus Mottl's 
> OcamlMakefile in my projects so far.  In one of my projects, I use source 
> files from two other small libraries I've written; at present, I just have a 
> whole lot of files in my SOURCES and a bunch of symlinks to the proper files 
> in the proper directories.  However, I'd really like to be able to improve 
> my build process, and I think a good way to do that is to isolate in 
> directories the other libraries I've written.

Just factor out the common code into a seperate directory and use
OcamlMakefile to create a library out of it, for example:

kosha$ ls -F
CVS/            OcamlMakefile   erlang/         prog/
Makefile        doc/            lib/            sql/

kosha$ cat Makefile
SUBDIRS= lib prog/smtp_test prog/kosha

.PHONY: all
all:
        for dir in $(SUBDIRS); do (cd $$dir && $(MAKE)); done

.PHONY: clean
clean:
        for dir in $(SUBDIRS); do (cd $$dir && $(MAKE) clean); done


kosha$ cd lib
kosha/lib$ cat Makefile
#Note the two targets library dependencies for "all:"
OCAMLMAKEFILE=../OcamlMakefile

SOURCES=utils.ml mylist.ml mylist_test.ml io.ml
RESULT=klib
THREADS=yes

all:    debug-code-library native-code-library

LIBS=unix str netstring

-include $(OCAMLMAKEFILE)


kosha$ cd prog/kosha
kosha/prog/kosha$ cat Makefile
#Note well the two {LIB,INC}DIRS lines, and "klib" on the LIBS line
OCAMLMAKEFILE=../../OcamlMakefile

ocamlnet=ocnMisc.ml tokenize.ml mailmessage.ml

LIBDIRS += ../../lib
INCDIRS += ../../lib

SOURCES=$(ocamlnet) opt.ml match.ml db.ml canary.ml mailtype.ml\
        spamdb.ml mail.ml esmtp_parser.mly esmtp_lexer.mll\
        smtp_server.ml main.ml

RESULT=kosha
THREADS=yes

LIBS=unix str dbm pq netstring threads klib

all: dc

-include $(OCAMLMAKEFILE)

--
 Julian Assange        |If you want to build a ship, don't drum up people
                       |together to collect wood or assign them tasks and
 proff@iq.org          |work, but rather teach them to long for the endless
 proff@gnu.ai.mit.edu  |immensity of the sea. -- Antoine de Saint Exupery
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Caml-list] Building O'Caml projects properly.
@ 2001-09-29 20:31 Jeremy Fincher
  2001-09-29 21:48 ` Julian Assange
  2001-09-29 22:08 ` Markus Mottl
  0 siblings, 2 replies; 11+ messages in thread
From: Jeremy Fincher @ 2001-09-29 20:31 UTC (permalink / raw)
  To: caml-list

I'm not very experienced with make, so I've been using Markus Mottl's 
OcamlMakefile in my projects so far.  In one of my projects, I use source 
files from two other small libraries I've written; at present, I just have a 
whole lot of files in my SOURCES and a bunch of symlinks to the proper files 
in the proper directories.  However, I'd really like to be able to improve 
my build process, and I think a good way to do that is to isolate in 
directories the other libraries I've written.

The only catch is that I have no idea how to do so :)  If anyone has any 
examples of multi-directory projects, or projects that come with separate 
libraries they depend on, I would really like to find out how to clean up my 
build process.

Thanks,
Jeremy


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp

-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2001-10-01 15:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-10-01  7:04 [Caml-list] Building O'Caml projects properly Jeremy Fincher
2001-10-01  8:07 ` Markus Mottl
  -- strict thread matches above, loose matches on Subject: below --
2001-10-01 14:02 Jeremy Fincher
2001-10-01 11:46 Jeremy Fincher
2001-10-01 12:57 ` Markus Mottl
2001-10-01 13:08   ` Hideo Bannai
2001-10-01 13:47     ` Markus Mottl
2001-10-01 15:17       ` Julian Assange
2001-09-29 20:31 Jeremy Fincher
2001-09-29 21:48 ` Julian Assange
2001-09-29 22:08 ` Markus Mottl

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).