title: Out of source build fails in autotools
body: <p>This might be a noobish question but I just recently started using autotools to simplify my requirements on things. Namely, I like the idea that the end user really doesn't need to go get anything to build my project on their local system.</p>
  
  <p>In order to keep my source directory kind of clean I have extra configuration files saved in a <code>config</code> directory and I want to <code>mkdir</code> a build directory to keep my configuration files for the build snugly kept away. Here's my current project tree:</p>
  
  <pre><code>.
  ├── aclocal.m4
  ├── AUTHORS
  ├── autom4te.cache
  │   ├── output.0
  │   ├── output.1
  │   ├── requests
  │   ├── traces.0
  │   └── traces.1
  ├── bin
  ├── build
  ├── Changelog
  ├── config
  │   ├── compile
  │   ├── install-sh
  │   └── missing
  ├── config.h.in
  ├── configure
  ├── configure.ac
  ├── doc
  ├── lib
  ├── Makefile.am
  ├── Makefile.in
  ├── NEWS
  ├── README
  ├── README.html
  ├── README.md
  ├── src
  │   ├── Makefile.am
  │   ├── main.c
  └── test
  </code></pre>
  
  <p><strong>Makefile.am</strong></p>
  
  <pre><code>SUBDIRS = src
  dist_doc_data = README
  </code></pre>
  
  <p><strong>src/Makefile.am</strong></p>
  
  <pre><code>bin_PROGRAMS = testprog
  testprog_SOURCES = main.c
  </code></pre>
  
  <p><strong>configure.ac</strong></p>
  
  <pre><code>AC_PREREQ(2.59)
  
  AC_INIT([testprog], [1.0], [myemail@example.com])
  
  AC_CONFIG_AUX_DIR([config])
  AM_INIT_AUTOMAKE([-Wall -Werror foreign])
  
  AC_CONFIG_HEADERS([config.h])
  
  AC_PROG_CC
  
  AC_CONFIG_FILES([Makefile])
  AC_OUTPUT
  </code></pre>
  
  <p>And finally the result of building:</p>
  
  <pre><code>mkdir build
  cd build
  ../configure
  make
  </code></pre>
  
  <p><strong>Configure output</strong></p>
  
  <pre><code>checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
  checking for gawk... gawk
  checking whether make sets $(MAKE)... yes
  checking whether make supports nested variables... yes
  checking for gcc... /usr/bin/clang
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables... 
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether /usr/bin/clang accepts -g... yes
  checking for /usr/bin/clang option to accept ISO C89... none needed
  checking whether /usr/bin/clang understands -c and -o together... yes
  checking for style of include used by make... GNU
  checking dependency style of /usr/bin/clang... none
  checking that generated files are newer than configure... done
  configure: creating ./config.status
  config.status: creating Makefile
  config.status: creating config.h
  config.status: executing depfiles commands
  </code></pre>
  
  <p><strong>Make output</strong></p>
  
  <pre><code>CDPATH="${ZSH_VERSION+.}:" &amp;&amp; cd .. &amp;&amp; /bin/sh /home/me/projects/testprog/config/missing aclocal-1.15 
   cd .. &amp;&amp; /bin/sh /home/me/projects/testprog/config/missing automake-1.15 --foreign
  CDPATH="${ZSH_VERSION+.}:" &amp;&amp; cd .. &amp;&amp; /bin/sh /home/me/projects/testprog/config/missing autoconf
  /bin/sh ./config.status --recheck
  running CONFIG_SHELL=/bin/sh /bin/sh ../configure CC=/usr/bin/clang --no-create --no-recursion
  checking for a BSD-compatible install... /usr/bin/install -c
  checking whether build environment is sane... yes
  checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
  checking for gawk... gawk
  checking whether make sets $(MAKE)... yes
  checking whether make supports nested variables... yes
  checking for gcc... /usr/bin/clang
  checking whether the C compiler works... yes
  checking for C compiler default output file name... a.out
  checking for suffix of executables... 
  checking whether we are cross compiling... no
  checking for suffix of object files... o
  checking whether we are using the GNU C compiler... yes
  checking whether /usr/bin/clang accepts -g... yes
  checking for /usr/bin/clang option to accept ISO C89... none needed
  checking whether /usr/bin/clang understands -c and -o together... yes
  checking for style of include used by make... GNU
  checking dependency style of /usr/bin/clang... none
  checking that generated files are newer than configure... done
  configure: creating ./config.status
   /bin/sh ./config.status
  config.status: creating Makefile
  config.status: creating config.h
  config.status: config.h is unchanged
  config.status: executing depfiles commands
  (CDPATH="${ZSH_VERSION+.}:" &amp;&amp; cd .. &amp;&amp; /bin/sh /home/me/projects/testprog/config/missing autoheader)
  rm -f stamp-h1
  touch ../config.h.in
  cd . &amp;&amp; /bin/sh ./config.status config.h
  config.status: creating config.h
  config.status: config.h is unchanged
  make  all-recursive
  make[1]: Entering directory '/home/me/projects/testprog/build'
  Making all in src
  /bin/sh: line 20: cd: src: No such file or directory
  make[1]: *** [Makefile:352: all-recursive] Error 1
  make[1]: Leaving directory '/home/me/projects/testprog/build'
  make: *** [Makefile:293: all] Error 2
  </code></pre>
  
  <p>I have purchased a copy of <a href="https://nostarch.com/autotools.htm" rel="nofollow noreferrer">Autotools</a> as well as followed the <a href="https://www.gnu.org/software/automake/manual/automake.html#Strictness" rel="nofollow noreferrer">Automake</a> canon on gnu.org. I'm unsure where to go and neither of these sources have helped me solve it.</p>
  
  <p>From what it appears it is looking for <code>src</code> inside of the <code>build</code> directory and naturally it does not exist. But every resource I look at for out of source builds doesn't seem to indicate this problem can even happen. What am I doing wrong?</p>