From 4f5481aed569efd8cbd6ae25abe57d1352701a75 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Thu, 7 Mar 2013 17:45:57 +0100
Subject: [PATCH v2 10/18] build: Fix out-of-tree builds
Status: obsolete

Change configure to place the generated version.h in the final place,
instead of doing it in two steps. Change rules to look for headers to
link and the helper genbuiltin script in the source dir.

Now something like:

  $ mkdir build-tree
  $ cd build-tree
  $ ../configure
  $ make

works.
---
 Makefile.am  | 12 ++++--------
 configure.ac |  2 +-
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 53ce9ca..e3aa303 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,7 +8,7 @@ include_HEADERS = include/types.h include/log.h include/plugin.h \
 			include/tlv.h include/setting.h include/device.h \
 			include/nfc_copy.h include/snep.h
 
-nodist_include_HEADERS = include/version.h
+nodist_include_HEADERS = include/near/version.h
 
 noinst_HEADERS = include/dbus.h
 
@@ -161,18 +161,14 @@ MAINTAINERCLEANFILES = Makefile.in \
 
 src/plugin.$(OBJEXT): src/builtin.h
 
-src/builtin.h: src/genbuiltin $(builtin_sources)
+src/builtin.h: $(srcdir)/src/genbuiltin $(builtin_sources)
 	$(AM_V_GEN)$(srcdir)/src/genbuiltin $(builtin_modules) > $@
 
 $(src_neard_OBJECTS) $(tools_nfctool_nfctool_OBJECTS) $(plugin_objects): $(local_headers)
 
-include/near/version.h: include/version.h
+include/near/%.h: $(abs_top_srcdir)/include/%.h
 	$(AM_V_at)$(MKDIR_P) include/near
-	$(AM_V_GEN)$(LN_S) $(abs_top_builddir)/$< $@
-
-include/near/%.h: include/%.h
-	$(AM_V_at)$(MKDIR_P) include/near
-	$(AM_V_GEN)$(LN_S) $(abs_top_srcdir)/$< $@
+	$(AM_V_GEN)$(LN_S) $< $@
 
 clean-local:
 	@$(RM) -rf include/near
diff --git a/configure.ac b/configure.ac
index 02dcd65..fafc78c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -133,5 +133,5 @@ AC_ARG_ENABLE(p2p, AS_HELP_STRING([--disable-p2p],
 				[enable_p2p=${enableval}])
 AM_CONDITIONAL(P2P, test "${enable_p2p}" != "no")
 
-AC_CONFIG_FILES([Makefile include/version.h neard.pc])
+AC_CONFIG_FILES([Makefile include/near/version.h:include/version.h.in neard.pc])
 AC_OUTPUT
-- 
1.8.3.1

