title: gcc/g++ option to place all object files into separate directory
body: <p>I am wondering why gcc/g++ doesn't have an option to place the generated object files into a specified directory.</p>
  
  <p>For example:</p>
  
  <pre><code>mkdir builddir
  mkdir builddir/objdir
  cd srcdir
  
  gcc -c file1.c file2.c file3.c **--outdir=**../builddir/objdir
  </code></pre>
  
  <p>I know that it's possible to achive this with separate -o options given to the compiler, e.g.:</p>
  
  <pre><code>gcc -c file1.c -o ../builddir/objdir/file1.o
  gcc -c file2.c -o ../builddir/objdir/file2.o
  gcc -c file3.c -o ../builddir/objdir/file3.o
  </code></pre>
  
  <p>... and I know that I can write Makefiles via VPATH and vpath directives to simplify this.</p>
  
  <p>But that's a lot of work in a complex build environment.</p>
  
  <p>I could also use</p>
  
  <pre><code>gcc -c file1.c file2.c file3.c
  </code></pre>
  
  <p>But when I use this approach my srcdir is full of .o garbage afterwards.</p>
  
  <p>So I think that an option with the semantics of --outdir would be very useful.</p>
  
  <p>What is your opinion?</p>
  
  <p><strong>EDIT</strong>: our Makefiles are written in such a way that .o files actually placed into  builddir/obj. But I am simply wondering if there might be a better approach.</p>
  
  <p><strong>EDIT</strong>: There are several approaches which place the burden to achieve the desired behavior to the build system (aka Make, CMake etc.). But I consider them all as being <em>workarounds</em> for a weakness of gcc (and other compilers too).</p>