Programing

make :`all '을 위해 할 일이 없습니다.

lottogame 2020. 9. 18. 19:16
반응형

make :`all '을 위해 할 일이 없습니다.


예를 들어 pgm을 통해 make 파일을 만들겠습니다.

http://mrbook.org/tutorials/make/

내 폴더 eg_make_creation에는 다음 파일이 포함되어 있습니다.

desktop:~/eg_make_creation$ ls
factorial.c  functions.h  hello  hello.c  main.c  Makefile

Makefile

# I am a comment, and I want to say that the variable CC will be
# the compiler to use.
CC=gcc
# Hwy!, I am comment no.2. I want to say that CFLAGS will be the
#options I'll pass to the compiler
CFLAGS=-c -Wall

all:hello

hello:main.o factorial.o hello.o
  $(CC) main.o factorial.o hello.o -o hello

main.o:main.c
  $(CC) $(CFLAGS) main.c

factorial.o:factorial.c
  $(CC) $(CFLAGS) factorial.c

hello.o:hello.c
  $(CC) $(CFLAGS) hello.c

clean:
  rm -rf *o hello

오류:

desktop:~/eg_make_creation$ make all
make: Nothing to be done for `all'.

이 프로그램을 컴파일하는 것을 이해하도록 도와주세요.


때때로 "Nothing to be done for all"오류는 탭 대신 makefile 규칙의 명령 앞에 공백으로 인해 발생할 수 있습니다. 규칙 내부에 공백 대신 탭을 사용해야합니다.

all:
<\t>$(CC) $(CFLAGS) ...

대신에

all:
    $(CC) $(CFLAGS) ...

규칙 구문 설명은 GNU make 매뉴얼을 참조하십시오 : https://www.gnu.org/software/make/manual/make.html#Rule-Syntax


hello폴더 에서 파일을 제거하고 다시 시도하십시오.

The all target depends on the hello target. The hello target first tries to find the corresponding file in the filesystem. If it finds it and it is up to date with the dependent files—there is nothing to do.


When you just give make, it makes the first rule in your makefile, i.e "all". You have specified that "all" depends on "hello", which depends on main.o, factorial.o and hello.o. So 'make' tries to see if those files are present.

If they are present, 'make' sees if their dependencies, e.g. main.o has a dependency main.c, have changed. If they have changed, make rebuilds them, else skips the rule. Similarly it recursively goes on building the files that have changed and finally runs the top most command, "all" in your case to give you a executable, 'hello' in your case.

If they are not present, make blindly builds everything under the rule.

Coming to your problem, it isn't an error but 'make' is saying that every dependency in your makefile is up to date and it doesn't need to make anything!


Make is behaving correctly. hello already exists and is not older than the .c files, and therefore there is no more work to be done. There are four scenarios in which make will need to (re)build:

  • If you modify one of your .c files, then it will be newer than hello, and then it will have to rebuild when you run make.
  • If you delete hello, then it will obviously have to rebuild it
  • You can force make to rebuild everything with the -B option. make -B all
  • make clean all will delete hello and require a rebuild. (I suggest you look at @Mat's comment about rm -f *.o hello

That is not an error the make command in unix works based on the timestamps,i.e lets say if you have made certain changes to factorial.cpp and compile using make..then make shows the informarion that only the ** cc -o factorial.cpp ** command is executed .Next time if you execute the same command i.e make without making any changes to any file with .cpp extension then compiler says that the output file is up to date...the compiler gives this information until we make certain changes to any file.cpp. The advantage of the make file is that it reduces the recompiling time by compiling the only files that are modified and by using the object(.o) files of the unmodified files directly......


I think you missed a tab in 9th line. The line following all:hello must be a blank tab. Make sure that you have a blank tab in 9th line. It will make the interpreter understand that you want to use default recipe for makefile.


I arrived at this peculiar, hard-to-debug error through a different route. My trouble ended up being that I was using a pattern rule in a build step when the target and the dependency were located in distinct directories. Something like this:

foo/apple.o: bar/apple.c $(FOODEPS)

%.o: %.c
    $(CC) $< -o $@

I had several dependencies set up this way, and was trying to use one pattern recipe for them all. Clearly, a single substitution for "%" isn't going to work here. I made explicit rules for each dependency, and I found myself back among the puppies and unicorns!

foo/apple.o: bar/apple.c $(FOODEPS)
    $(CC) $< -o $@

Hope this helps someone!

참고URL : https://stackoverflow.com/questions/8561640/make-nothing-to-be-done-for-all

반응형