9

I have a Makefile.am for compiling Ocaml source code with ocamlbuild. However, even though I have

AM_INIT_AUTOMAKE([foreign no-dependencies])

in my configure.ac, automake thinks that a C compiler must be present to install exectuables. That is, if I put in Makefile.am a target executable under bin_PROGRAMS that is to be built with ocamlbuild, autoreconf (version 1.11.3) tells me:

Makefile.am: C source seen but `CC' is undefined
Makefile.am:   The usual way to define `CC' is to add `AC_PROG_CC'
Makefile.am:   to `configure.ac' and run `autoconf' again.
autoreconf: automake failed with exit status: 1

I do not want to include AC_PROG_CC because my source code includes no C. It is pure Ocaml. What can I do? (I have the same problem with libexec_PROGRAMS.)

Andrej Bauer
  • 2,458
  • 17
  • 26

2 Answers2

5

It may be unneeded, but will it hurt anything to simply add AC_PROG_CC to Makefile.am? Path of least resistance and all.

Working off this decade-old mailing list message:

http://lists.gnu.org/archive/html/automake/2003-01/msg00057.html

It sounds like you might need to define progname_SOURCES as empty. If I understand the post correctly, if you omit an explicit declaraction, progname_SOURCES will implicitly be defined as progname.c.

Multimedia Mike
  • 12,660
  • 5
  • 46
  • 62
  • `AC_PROG_CC` will probably add unneeded tests, slowing down `configure`. – ldav1s Mar 13 '12 at 23:27
  • This one is how things should be done. Just set `progname_SOURCES` to the empty value. So I am declaring that this one is the "accepted answer". – Andrej Bauer Mar 14 '12 at 11:20
  • I was struggling against a similar problem until I read this answer and realised that my "progname" contained invalid characters ('+'). Everything went fine after renaming my progname. – j4x Nov 29 '12 at 10:46
5

If you add AC_SUBST([CC]) to configure.ac, that will be enough to define the variable as far as Automake is concerned.

adl
  • 15,627
  • 6
  • 51
  • 65