简体   繁体   中英

ocamlbuild: Nothing to be done for `all'

I'm using ocamlbuild in makefile to build my code and want to recompile when there is any code change. But make returns with error message: make: Nothing to be done for `all'.

My makefile code:

all: test1 test2

test1:
    ocamlbuild $(INCLUDES) $(FLAGS) $(TEST1_BYTE)
    mv $(TEST1_BYTE) test1.out

test2:
    ocamlbuild $(INCLUDES) $(FLAGS) $(TEST2_BYTE)
    mv $(TEST2_BYTE) test2.out

clean:
    rm -f test1.out test2.out
    rm -rf _build

I expect make will do the recompilation instead of make clean; make make clean; make . It only works with make clean; make make clean; make now.

Make your targets phony then the make utility will always rebuild them. And ocamlbuild will track the dependencies with all the knowledge of the OCaml infrastructure, and will never rebuild anything unnecessary. Here's how to declare your targets phony, add this to your Makefile

   .PHONY: test1 test2

Also, it looks like that you're still learning both make and ocamlbuild utilities, and given that you're going to invest your time in learning the tools it is better to focus on something that is not that legacy. While getting accustomed to make could be considered as useful, the ocamlbuild tool is more or less deprecated with the newer, dune and much better documented. It is very easy, just create a new file named dune and put the following contents there,

(executable 
   (name test1))

(executable 
   (name test2))

Now you can build your targets with dune build test1.exe . You can still create a Makefile as a courtesy to those who don't know how to invoke dune . And as usual, don't forget to make your targets phony in the makefile.

This Makefile specifically says that test1 and test2 depend on nothing. As long as they both exist, make will say there's nothing to do.

I don't know anything about ocamlbuild , but I suspect you should be using it by itself rather than combining it with make, which is a separate (very flexible, but very old) build system.

For what it's worth, it seems to me that many current OCaml developers are switching to dune for a build system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM