Need Help how to create a makefile??

Hello everyone here is my question that im assigned. now i truly have looked into my text book and im not quite sure how to go about this.

Create a makefile for one of the exercises in this assignment (your choice) that allows the user to type make for a production build of the program and make debug for a build of the program that includes debugging information.

Heres my assignment that i will be using:

#include <iostream>
#include <string>
#include <fstream>

using namespace std;

int main()


int wordcount = 0;
string filename = "TMA1Question1.cpp";
ifstream file("input.txt");
string word;

while (file >> word)

cout << "The file \"" << filename << "\" has " << wordcount << " words." << endl;

how would i create a makefile.?

from what i understood in the text would it be something like:

TMA1Question1.exe TMA1Question1.cpp
$(CPP) TMA1Question1.cpp

$(CPP) TMA1Question1d.cpp

need some help truly....
As best as I can tell this may be what you need?
CPP = gcc
TMA1Question1.exe : TMA1Question1.cpp
	$(CPP) -o TMA1Question1.exe TMA1Question1.cpp

.PHONY : debug
	$(CPP) -g TMA1Question1d.cpp

If you need help learning how to write makefiles, I recommend reading the makefile tutorial.
Topic archived. No new replies allowed.