From: Bruno Haible <bruno@clisp.org>
Date: Wed, 28 Apr 2010 17:17:54 +0000 (+0200)
Subject: getdate: Generate getdate.c in the source directory.
X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6c68019139b5480c2a66b390e55577f3b73a35a4;p=pspp

getdate: Generate getdate.c in the source directory.
---

diff --git a/ChangeLog b/ChangeLog
index 18c208732c..65d06efbfa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2010-04-28  Bruno Haible  <bruno@clisp.org>
+
+	getdate: Generate getdate.c in the source directory.
+	* modules/getdate (Makefile.am): Add rule for getdate.c. Augment
+	MOSTLYCLEANFILES.
+	Suggested by Daniel Richard G. <skunk@iskunk.org> and Ralf Wildenhues.
+
 2010-04-27  Andreas Gruenbacher  <agruen@suse.de>  (tiny change)
 
 	* lib/utimens.c: On Tru64, the timestamp parameter of utimens(2)
diff --git a/modules/getdate b/modules/getdate
index 1328c221f9..2f0fdb279c 100644
--- a/modules/getdate
+++ b/modules/getdate
@@ -25,8 +25,20 @@ configure.ac:
 gl_GETDATE
 
 Makefile.am:
+# This rule overrides the Automake generated .y.c rule, to ensure that the
+# getdate.c file gets generated in the source directory, not in the build
+# directory.
+getdate.c: getdate.y
+	$(AM_V_GEN)$(SHELL) $(YLWRAP) $(srcdir)/getdate.y \
+	                              y.tab.c getdate.c \
+	                              y.tab.h getdate.h \
+	                              y.output getdate.output \
+	                              -- $(YACC) $(YFLAGS) $(AM_YFLAGS) && \
+	mv getdate.c getdate.c-t && \
+	mv getdate.c-t $(srcdir)/getdate.c
 lib_SOURCES += getdate.y
 BUILT_SOURCES += getdate.c
+MOSTLYCLEANFILES += getdate.c-t
 MAINTAINERCLEANFILES += getdate.c
 EXTRA_DIST += getdate.c