Makefile problems

Ok, so this is the second clean installation of mingw I've done. Set the path right and now I tried doing makefiles again...still won't work.

Now first the code:

TEST.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>

int main()
{
  using namespace std;
  ifstream fin;
  fin.open("tobuy.txt");
  if (fin.is_open() == false)
  {
        cerr << "Can't open file. Bye.\n";
        exit(EXIT_FAILURE);
  }
  string item;
  int count = 0;
  getline(fin, item, ':');
  while (fin)
  {
        ++count;
        cout << count << ": " << item << endl;
        getline(fin, item, ':');
  }
  cout << "Done\n";
  fin.close();
  return 0;
}


MAKEFILE.MAK
1
2
3
4
5
6
7
8
9
10
Test: Test.o
g++ Test.o -o Test

Test.o: Test.cpp
g++ -c -Wall Test.cpp

clean:
rm -f *.o core
distclean:
rm -f *.o core Test


Also the titles are not capitalized and the makefile is tabbed.

I've tried different approaches so let me break them down:

1) Using plain old make gave me this error: mingw32-make: *** No targets specified and no makefile found. Stop.

2) Using make makefile.mak gave me this error: mingw32-make: Nothing to be done for 'makefile.mak'.

3) Using make "F:\Text Editor Programs\C++\Test\makefile.mak" at first worked before I reinstalled but now proudly gives me this error: mingw32-make: Nothing to be done for 'F:\Text Editor Programs\C++\Test\makefile.mak'

Also note that I did change the cpp file before trying to make so it is not that the program indeed has 'nothing to be done for'.

How do I fix this?
Remember that you need a tab in front of any commands you want the makefile to run. And the name should just be makefile if you want simple make to work (no extensions).
As stated I did put a tabs in the actual makefile but what do you mean that the makefile should have no extensions? do you mean there shouldn't be a .mak at the end of the file name?
If you are running just 'make' with no arguments, it looks for 'makefile' with no extension.
So what extension do I give the makefile? What should it be named makefile.????????
Don't give it an extension.
WOW. So it worked when I named the makefile...makefile. And under notepad++ used the extension all types *.*

Now if you all don't mind answering a second question why do I get this error when I type make clean.

process_begin: CreateProcess(NULL, rm -rf *.o Test, ...) failed.
make (e=2): The system cannot find the file specified.
makefile:8: recipe for target 'clean' failed
mingw32-make: *** [clean] Error 2
'clean' is not a standard makefile command. You'll need to provide it yourself.
Sorry to ask but how? I can't seem to find a definitive source for learning makefiles and i'm new to cmd/terminals.
Seems like the problem is that mingw doesn't support rm command. It works with del for some reason but not rm. If anyone could give me an explanation on this that would be great.
I would also like to say thank you firedraco for all your help.
rm has nothing to do with mingw. rm is a UNIX command that probably doesn't exist on Windows.
Sorry for bringing back a dead post but thank you Peter. It seems the makefile tutorial I was looking at was a unix tutorial and for some reason I thought rm was rd.
Topic archived. No new replies allowed.