Problemas con mi Makefile

He descargado este Makefile and I'm having a hard time understanding how it works.

Estoy programando en Ocaml and for some module, I implemented an interface (.mli). Strangely, even when I add the .mli file before the corresponding .ml file, the Makefile seems to skip it; so I'm getting the error

could not find the X.cmi for the module X.

Worse, I added some file without the required .mli and strangely again the Makefile automatically added them to the list of sources.
estoy diciendo extrañamente but perhaps its perfectly normal to Makefiles expert.

I'm not an expert when it comes to Makefile, can anyone help me understanding how this Makefile works?

The compilation works fine, when I replace the line

$(EXEC): $(OBJS) 



and add the required .mli

preguntado el 31 de julio de 12 a las 14:07

This may take a few iterations. What happens when you make X.cmi? -

X.cmi doesn't exist at that moment, when I compile separatly with ocamlc, and make, the compilation is successful. X.cmi is the result of ocamlc -c X.mli -

Exactly; when you make X.cmi, you are telling Make to build X.cmi. Make sees that X.cmi does not exist, so it looks for a rule to build it, sees that X.mli is present, and runs ocamlc -c X.mli. (That's what debemos happen.) -

1 Respuestas


# Makefile


# Fichiers dans l'ordre
ML =
MLI = 


OCAMLLD = -ccopt -L.
OCAMLOPT = ocamlopt.opt
OCAMLC = ocamlc.opt
OCAMLDEP = ocamldep

    make clean

.SUFFIXES: .ml .mli .cmo .cmx .cmi


    ${OCAMLC} -c $<

    ${OCAMLC} -c $<

    rm -f *~ *.o *.cm? *mli

fullclean: clean
    rm -f .depend ${PRG}

depend: .depend
.depend: ${ML} ${MLI}
    rm -f .depend
    ${OCAMLDEP} ${ML} ${MLI} > .depend

include .depend

You'll have to setup PRG, ML, MLI, FLAGS, LD. :)

Respondido 31 Jul 12, 15:07

I'll try your solution and report back, merci! ;) - jose elcid

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.