title: How to create a Makefile for a program which takes in command line argument
body: <p>I need to create a Makefile for a program which takes in a file as input via command line.</p>
  
  <p>Here is what I mean:</p>
  
  <p>A program has function main which looks like this:</p>
  
  <pre><code>int main(long argc, char **argv) //'argument command' and 'argument vector'respectively
  {
    some code;
  }
  </code></pre>
  
  <p>You compile this C language source code file</p>
  
  <pre><code>gcc main.c function1.c function2.c -o execute
  </code></pre>
  
  <p>Which creates an executable program called 'execute'. Then you pass in an argument into this program:</p>
  
  <pre><code>./execute filename
  </code></pre>
  
  <p>The makefile I've created has the contents:</p>
  
  <pre><code>all: xsd
  
  xsd: main.o function1.o function2.o
      gcc -o xsd main. function1.o function2.o
  
  main.o: main.c
      gcc -c -o main.o main.c
  
  function1.o: function1.c
      gcc -c -o function1.c
  
  function2.o: function2.c
      gcc -c -o function2.c
  
  clean:
      rm -rf *o xsd
  </code></pre>
  
  <p>So how do I create a proper makefile which accomodates for the input file passed in via the command line? Perhaps something like this:</p>
  
  <pre><code>./{argv}
  </code></pre>
  
  <p>Anybody know how to do this?</p>