简体   繁体   English

ocamlbuild:“ all”不做任何事情

[英]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. 我在makefile使用ocamlbuild构建代码,并希望在发生代码更改时重新编译。 But make returns with error message: make: Nothing to be done for `all'. make错误消息的回报: make: Nothing to be done for `all'.

My makefile code: 我的makefile代码:

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可以重新编译而不是make clean; make make clean; make . make clean; make It only works with make clean; make 它只能与make clean; make make clean; make now. make clean; make了。

Make your targets phony then the make utility will always rebuild them. 将您的目标设为伪造,然后make实用程序将始终重建它们。 And ocamlbuild will track the dependencies with all the knowledge of the OCaml infrastructure, and will never rebuild anything unnecessary. ocamlbuild将使用OCaml基础结构的所有知识来跟踪依赖关系,并且永远不会重建任何不必要的东西。 Here's how to declare your targets phony, add this to your Makefile 这是声明目标伪音的方法,将其添加到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. 同样,您似乎仍在学习make和ocamlbuild实用程序,并且鉴于您将花费时间在学习工具上,因此最好将精力集中在非传统的东西上。 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. 虽然习惯于制作可以被认为是有用的,但ocamlbuild工具或多或少不推荐使用较新的, 沙丘的并且记录得更好。 It is very easy, just create a new file named dune and put the following contents there, 这很简单,只需创建一个名为dune的新文件,并将以下内容放在其中,

(executable 
   (name test1))

(executable 
   (name test2))

Now you can build your targets with dune build test1.exe . 现在,您可以使用dune build test1.exe构建目标。 You can still create a Makefile as a courtesy to those who don't know how to invoke dune . 对于那些不知道如何调用dune人,您仍然可以礼貌地创建Makefile。 And as usual, don't forget to make your targets phony in the makefile. 和往常一样,不要忘记在makefile中使目标成为伪造。

This Makefile specifically says that test1 and test2 depend on nothing. 这个Makefile特别指出test1test2依赖任何内容。 As long as they both exist, make will say there's nothing to do. 只要它们都存在,make就会说无事可做。

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. 我对ocamlbuild ,但我怀疑您应该单独使用它,而不是将其与make结合使用,make是一个单独的(非常灵活,但是非常旧的)构建系统。

For what it's worth, it seems to me that many current OCaml developers are switching to dune for a build system. 就其价值而言,在我看来,许多当前的OCaml开发人员都在为构建系统转换为沙丘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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