title: Makefile to compile lists of source files
body: <p>I have lists of files that I want my Makefile to compile, one list for each source language:</p>
  
  <pre><code>CFILES=  Src/Application/main.c  Src/Core/data.c  Lib/routines.c
  ASFILES= Src/Application/startup.s  Lib/sqrt.s
  </code></pre>
  
  <p>I want all the output in one directory:</p>
  
  <pre><code>OBJDIR= output
  </code></pre>
  
  <p>How do I do the equivalent of:</p>
  
  <pre><code>output/main.o     : Src/Application/main.c
      cc -c -o output/main.o Src/Application/main.c
  
  output/data.o     : Src/Core/data.c
      cc -c -o output/data.o Src/Core/data.c
  
  output/routines.o : Lib/routines.c
      cc -c -o output/routines.o Lib/routines.c
  
  output/startup.o  : Src/Application/startup.s
      as -o output/startup.o Src/Application/startup.s
  
  output/sqrt.o     : Lib/sqrt.s
      as -o output/sqrt.o  Lib/sqrt.s
  </code></pre>
  
  <p>The recipes are the same for every file in its list.</p>
  
  <p>The input files are in all sorts of different directories and it is not acceptable to just list their filenames and use a search path to find them, their explicit paths must be used.</p>
  
  <p>The output filename is the basename of the source file name with the extension changed to o.  There are no duplicated basenames between the lists for the different source languages.</p>
  
  <p>I do not want to have to list the object files, this should be derived from the source lists.</p>
  
  <p>I am using gnu make, but bonus points for a portable solution.</p>