From 05f14c574052038d3c17a8a953c5df867982d702 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Thu, 7 Mar 2013 17:45:57 +0100
Subject: [PATCH 10/15] 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 b4b4947..b9d110c 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
 
-nodist_include_HEADERS = include/version.h
+nodist_include_HEADERS = include/near/version.h
 
 noinst_HEADERS = include/dbus.h
 
@@ -144,18 +144,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) $(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 8b7055d..77816ea 100644
--- a/configure.ac
+++ b/configure.ac
@@ -122,5 +122,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.2.rc2

