newbie
newbie

Reputation: 161

make: Nothing to be done for 'makefile'

I try to learn creating makefile for java projects. I wrote a basic class as Hello.java. Then I wrote a makefile as below:

makefile:
JFLAGS = -g
JC = javac
.SUFFIXES: .java .class
%.class: %.java
    $(JC) $(JFLAGS) $^

CLASSES = \
     Hello.java

default: classes

classes: $(CLASSES:.java=.class)

clean:
    $(RM)*.class

When I try to run this file on cygwin, and type make -f makefile, I got an error like that: make:Nothing to be done for 'makefile'. How can I solve this problem?

Upvotes: 2

Views: 2942

Answers (3)

niekas
niekas

Reputation: 9097

I had a problem with the same error message make: Nothing to be done for 'makefile'.

In my case, the problem was that a directory with the target's name existed in makefile directory. Changing the target's name solved the problem.

Upvotes: 0

MadScientist
MadScientist

Reputation: 100856

If you run make with no arguments, it tries to rebuild the first target it finds in the makefile.

The first line in your makefile is:

makefile:

which defines a target makefile... so if you run make with no arguments it will try to build the makefile target. There are no rules to update the makefile target, and that file exists, so make declares that it's up to date and there's nothing to do to update it.

I don't know why you have that line there at all, but in any event you need to make sure that the first target in your makefile is the one you want to build when you run make; here it looks like you want default to be first.

Upvotes: 1

Hiroaki Machida
Hiroaki Machida

Reputation: 1090

I'm not sure, but I think you need add something like "javac blabla.java" below "default: classes"

Upvotes: 0

Related Questions