0

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!

5
  • 1
    Are you running make Makefile instead of just make? Also tcsh is apparently not a good (or usable) choice of shell for makefile usage (though this makefile doesn't actually seem to use tcsh for its rule execution). Commented Mar 4, 2015 at 1:41
  • @EtanReisner Yes, "make Makefile" is my command Commented Mar 4, 2015 at 1:42
  • That is telling make to try to run the target for Makefile... which doesn't exist so make can't do anything. You mean make to run the default target or make pizza to run the pizza target. Commented Mar 4, 2015 at 1:43
  • @EtanReisner Ok, I will try that. I thought in the past I always used "make makefile" or "make Makefile". Commented Mar 4, 2015 at 1:45
  • You might have used make -f Makefile since -f is "use this file as the makefile". Commented Mar 4, 2015 at 1:45

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.