当前位置: 动力学知识库 > 问答 > 编程问答 >

build - Behavior of the all target in Makefile

问题描述:

I have the following makefile :

DESTFILES = build/test1 build/toto2

build/test1: test1

cp $< [email protected]

build/toto2: toto2

cp $< [email protected]

all: build/test1 build/toto2

The directory in which the Makefile resides contains the build subdirectory and the test1, toto2 empty files.

The aim is to copy the files to the build subdirectory (a la make install).

When I do a make all command, the files are copied appropriately in build.

But when I do just make only the first target of all, test1 is triggered and so only the first file is copied.

I am very suprised at this behavior. Can anyone enlighten me about this ?

This is with GNU Make 4.1 on Archlinux.

网友答案:

For GNU make, the default goal (the target that is done when you just type make) is the first one which name does not start with '.'. all is just a name, GNU make does not do anything special with it. If you want it to be the default, put it in first position or use the special .DEFAULT_GOALvariable:

.DEFAULT_GOAL := all
分享给朋友:
您可能感兴趣的文章:
随机阅读: