Hi All,
I have to frequently compile small program and run it. Since, it was tedious to write compile command g++ -W -Wall file.cpp -o out
everytime for each cpp file, I wrote one small scripts, which does the compiling.
Here is the script that I wrote
#!/bin/bash
g++ -W -Wall $1 -o $1.out
So, if I have to compile file.cpp, I will do compile file.cpp
and it will create file.cpp.out
executable for me.
And, such file.cpp dont have any header files or any other dependencies.
I know how to write makefile for particular file.cpp like this (very simple case)
file: file.cpp
g++ -W -Wall file.cpp -o file
but if I have to compile file2.cpp, I have to change above makefile again or write new. So, what I want to do is, when I give make file.cpp
command it will produce file as executable. And when I give make file2.cpp
it will produce file2 as executable, and similarly for other cpp files.