Big Sharpie
Big Sharpie

Reputation: 849

Trouble with simple makefile in C

I am somewhat of a beginner in C and have a project due where I need to include a makefile to compile my single file program that uses pthreads and semaphores. My makefile looks like:

# Makefile for pizza program 
pizza: pizza.o
    gcc -lrt -lpthread -g -o pizza pizza.o

pizza.o: pizza.c
    gcc -lrt -lpthread -g -c pizza.o pizza.c

and I keep getting:

make: Nothing to be done for 'Makefile'.

I have done several makefiles before and have never gotten this message. I've tried different semantics in the makefile and have only gotten this same message. And yes, the command is tabbed after the target and dependency line.

Using gcc on tcsh. I have read other makefile posts on SO but I wasn't able to use any of the answers to figure it out for my case.

Any help would be greatly appreciated!

Upvotes: 0

Views: 55

Answers (1)

Etan Reisner
Etan Reisner

Reputation: 80921

The arguments to make are the targets to be built.

You are running make Makefile which is telling make to try to build the Makefile target.

There is no such target in your makefile, make has no built-in rule that applies to that target and the file exists (and is assumed to be up-to-date) which is what that message is telling you.

To run the default target (by default the first target listed) you can just run make (assuming you are using a default name like Makefile for your makefile).

You can also use the -f argument to make to select an alternate makefile name.

So make -f Makefile will in this case (since Makefile is a default searched name) do the same thing as make.

Upvotes: 1

Related Questions