How to make a make file?

Hi, I don't understand these makefile things but now I finally have a code that requires one since there's 10+ files in my program so I guess it's time to learn. So I have these files; paper.cpp, paper.h, play_game.cpp, rock.cpp, rock.h, RPSgame.cpp, RPSgame.h, scissors.cpp, scissors.h, tool.cpp, and tool.h. The only thing I know is that there's apparently a complex way to make one, and an easy way. I'm fine with whatever the easy way is. Could someone please help me with this? I should mention that I have already searched and tried to read up on makefiles but I'm just not understanding. If you could dumb it down quite a bit for me that would be great too. I'm amazingly dumb with all this coding stuff.

Thanks in advance! :)
Hi, try this:

1
2
3
4
5
6
7
8
9
all: obj
	g++ -Wall -o exec *.o

obj:
	g++ -Wall -c *.cpp

clean:
	rm -f exec *.o *~
	


IMPORTANT NOTE: The blanks at the beginning of the lines are TABs and not just spaces!

So try placing this file (which you will save as 'Makefile', without any extension) beside your code, then open a shell and type 'make'. This should create an executable file called 'exec', which you can run with './exec'.

Hope this helps.
Topic archived. No new replies allowed.