Hello,
On Wed, Jul 12, 2006 at 08:52:54PM +0800, John Darrington wrote:
> On Wed, Jul 12, 2006 at 02:33:21PM +0200, Stepan Kasal wrote:
> Just omit "$(top_builddir)/" from all occurences.
>
> I can't do that. If I do, then it will fail to build from outside
> of the source tree.
no, this is not true.
You are confusing (top_)builddir with (top_)srcdir. The latter ones
are important for builds outside the source tree (so called ``VPATH
builds'').
$(top_builddir) just points to the top level _build_ directory, so it
is `..', `../..', or some such.
Since you adopted the non-recursive approach in the pspp package, you
have one huge makefile in the top level (even thought the Automake
sources, *.mk files, are scattered throughout the tree).
In that huge makefile, $(top_builddir) is just a dot.
Thus the prefix `$(top_builddir)/' is actually `./'--it's only effect
is that it confuses BSD make, which does not admit that `file' and
`./file' are the same.
> And if subdir/mystuff.x is not generated in any way, you can omit the
> "$(top_srcdir)/" prefix from it, too.
As mentioned above, (top_)srcdir has to be used in certain
situations, for the sake of vpath builds.
But remember that make searches the prerequisities according to
VPATH variable, so you do not have to use (top_)srcdir there.
Also note that in your huge top level makefile, $(top_srcdir) is the
same as $(srcdir). I would perhaps tend to use $(srcdir) in
*_CPPFLAGS and such, but it depends on individual taste.
> http://darrington.wattle.id.au/pspp-0.4.2.tar.gz if you feel like
I downloaded this tarball, made some changes, ran autoreconf and
verified that vpath build still works (on my Fedora GNU/Linux,
with GNU make).
Actually, I noticed more problems:
The file src/language/expressions/automake.mk contains:
src/language/expressions/src_language_expressions_libexpressions_a-evaluate.o: \
src/language/expressions/evaluate.h \
src/language/expressions/operations.h \
src/language/expressions/evaluate.inc
You cannot add dependencies this way; Automake does not notice that
this rule does not have any commands, and fails to emit the rule for
this target.
I understand that the pre-requisities are generated. The usual
solution is to list them in BUILT_SOURCES.
OTOH, your other usage of BUILT_SOURCES is not necessary, and should
be avoided (BUILT_SOURCES is kind of a hack). If you use old-style
implicit rule (`.q.c:'), then you can list *.q files in the *_SOURCES
variable. That simplifies src/language/data-io/automake.mk and
src/language/utilities/automake.mk significantly.
But the same simplification is not possible in
src/language/lexer/automake.mk, because of a bug in Automake: this
feature does not work in combination with per-target flags.
So nodist_src_language_stats_libstats_a_SOURCES is still needed.
BTW: you do not need the "PERL = @PERL@" line; Automake generates it.
And though it might seem weird, neither Makefile.in nor aclocal.m4
does belong to MAINTAINERCLEANFILES.
And in TESTS_ENVIRONMENT in tests/automake.mk, I'd use $(..), not
${..}, to emphasize the fact that the variable is expanded by make,
not by shell.
Automake distributes manu files automatically--there is no need to
list them in EXTRA_DIST.
Attached please find the resulting patch.
I have not explained every aspect of it, so feel free to ask about
the individual changes.
I hope this helps,
Stepan Kasal
diff -urpaN pspp-0.4.2.orig/Makefile.am pspp-0.4.2/Makefile.am
--- pspp-0.4.2.orig/Makefile.am 2006-07-12 13:10:02.000000000 +0200
+++ pspp-0.4.2/Makefile.am 2006-07-13 18:47:53.000000000 +0200
@@ -24,19 +24,18 @@ if msdos
AM_CFLAGS+=-D__MSDOS__
endif
-
-%.c: %.q $(top_builddir)/src/language/lexer/q2c$(EXEEXT)
+.q.c:
@mkdir -p `dirname [EMAIL PROTECTED]
- $(top_builddir)/src/language/lexer/q2c $< $@
+ ./src/language/lexer/q2c $< $@
+$(all_q_sources:.q=.c): src/language/lexer/q2c$(EXEEXT)
+all_q_sources =
pkgsysconfdir = $(sysconfdir)/@PACKAGE@
-EXTRA_DIST = AUTHORS NEWS ONEWS README TODO THANKS config.rpath \
-mkinstalldirs config.rpath configure pspp-mode.el
+EXTRA_DIST = ONEWS config.rpath pspp-mode.el
-MAINTAINERCLEANFILES = Makefile.in aclocal.m4
CLEANFILES =
ACLOCAL_AMFLAGS = -I m4 -I gl/m4
noinst_LIBRARIES=
diff -urpaN pspp-0.4.2.orig/doc/automake.mk pspp-0.4.2/doc/automake.mk
--- pspp-0.4.2.orig/doc/automake.mk 2006-07-12 12:26:30.000000000 +0200
+++ pspp-0.4.2/doc/automake.mk 2006-07-13 17:09:41.000000000 +0200
@@ -36,16 +36,16 @@ EXTRA_DIST += doc/pspp.man \
doc/get-commands.pl \
$(doc_pspp_TEXINFOS)
-CLEANFILES += doc/pspp.info doc/pspp.info-* $(top_builddir)/doc/ni.texi
+CLEANFILES += doc/pspp.info doc/pspp.info-* doc/ni.texi
#Kludge to overcome automake limitations
-doc/%.dvi: am__TEXINFO_TEX_DIR=$(top_builddir)/doc
+doc/%.dvi: am__TEXINFO_TEX_DIR=doc
-$(top_builddir)/doc/ni.texi: $(top_srcdir)/src/language/command.def
doc/get-commands.pl
+doc/ni.texi: src/language/command.def doc/get-commands.pl
@mkdir -p doc
@PERL@ $(top_srcdir)/doc/get-commands.pl
$(top_srcdir)/src/language/command.def > $@
-$(INFO_DEPS): $(top_builddir)/doc/ni.texi
-$(HTML_DEPS): $(top_builddir)/doc/ni.texi
+$(INFO_DEPS): doc/ni.texi
+$(HTML_DEPS): doc/ni.texi
diff -urpaN pspp-0.4.2.orig/src/language/data-io/automake.mk
pspp-0.4.2/src/language/data-io/automake.mk
--- pspp-0.4.2.orig/src/language/data-io/automake.mk 2006-05-02
01:35:46.000000000 +0200
+++ pspp-0.4.2/src/language/data-io/automake.mk 2006-07-13 17:33:08.000000000
+0200
@@ -1,16 +1,7 @@
## Process this file with automake to produce Makefile.in -*- makefile -*-
-
noinst_LIBRARIES += src/language/data-io/libdata_io.a
-src_language_data_io_q_sources_q = src/language/data-io/file-handle.q
src/language/data-io/list.q
-
-src_language_data_io_q_sources_c = src/language/data-io/file-handle.c
src/language/data-io/list.c
-
-EXTRA_DIST += $(src_language_data_io_q_sources_q)
-nodist_src_language_data_io_libdata_io_a_SOURCES =
$(src_language_data_io_q_sources_c)
-CLEANFILES += $(src_language_data_io_q_sources_c)
-
src_language_data_io_libdata_io_a_SOURCES = \
src/language/data-io/data-list.c \
src/language/data-io/get.c \
@@ -22,6 +13,9 @@ src_language_data_io_libdata_io_a_SOURCE
src/language/data-io/data-reader.h \
src/language/data-io/data-writer.c \
src/language/data-io/data-writer.h \
- src/language/data-io/file-handle.h
+ src/language/data-io/file-handle.h \
+ src/language/data-io/file-handle.q src/language/data-io/list.q
+
+all_q_sources += src/language/data-io/file-handle.q src/language/data-io/list.q
diff -urpaN pspp-0.4.2.orig/src/language/expressions/automake.mk
pspp-0.4.2/src/language/expressions/automake.mk
--- pspp-0.4.2.orig/src/language/expressions/automake.mk 2006-03-15
04:29:10.000000000 +0100
+++ pspp-0.4.2/src/language/expressions/automake.mk 2006-07-13
19:09:28.000000000 +0200
@@ -2,19 +2,9 @@
noinst_LIBRARIES += src/language/expressions/libexpressions.a
-$(top_builddir)/src/language/expressions/src_language_expressions_libexpressions_a-evaluate.o:
\
- $(top_builddir)/src/language/expressions/evaluate.h \
- $(top_builddir)/src/language/expressions/operations.h \
- $(top_builddir)/src/language/expressions/evaluate.inc
-
-$(top_builddir)/src/language/expressions/src_language_expressions_libexpressions_a-optimize.o:
\
- $(top_builddir)/src/language/expressions/optimize.inc
-
-$(top_builddir)/src/language/expressions/src_language_expressions_libexpressions_a-parse.o:
\
- $(top_builddir)/src/language/expressions/parse.inc
-
-
-CLEANFILES += $(expressions_built_sources)
+src_language_expressions_libexpressions_a_CPPFLAGS = $(AM_CPPFLAGS) \
+ -I src/language/expressions \
+ -I $(top_srcdir)/src/language/expressions
src_language_expressions_libexpressions_a_SOURCES = \
src/language/expressions/evaluate.c \
@@ -23,14 +13,7 @@ src_language_expressions_libexpressions_
src/language/expressions/optimize.c \
src/language/expressions/parse.c \
src/language/expressions/private.h \
- src/language/expressions/public.h \
- src/language/expressions/evaluate.inc.pl \
- src/language/expressions/generate.pl \
- src/language/expressions/operations.def \
- src/language/expressions/evaluate.h.pl \
- src/language/expressions/operations.h.pl \
- src/language/expressions/optimize.inc.pl \
- src/language/expressions/parse.inc.pl
+ src/language/expressions/public.h
expressions_built_sources= \
src/language/expressions/evaluate.h \
@@ -39,19 +22,22 @@ expressions_built_sources= \
src/language/expressions/optimize.inc \
src/language/expressions/parse.inc
-src_language_expressions_libexpressions_a_CPPFLAGS = $(AM_CPPFLAGS) \
- -I $(top_builddir)/src/language/expressions \
- -I $(top_srcdir)/src/language/expressions
-
-nodist_src_language_expressions_libexpressions_a_SOURCES =
$(expressions_built_sources)
+BUILT_SOURCES += $(expressions_built_sources)
+CLEANFILES += $(expressions_built_sources)
+helpers = src/language/expressions/generate.pl \
+ src/language/expressions/operations.def
-PERL = @PERL@
+$(expressions_built_sources): $(helpers)
+EXTRA_DIST += $(helpers) $(expressions_built_sources:=.pl)
-helpers = $(top_srcdir)/src/language/expressions/generate.pl \
- $(top_srcdir)/src/language/expressions/operations.def
+SUFFIXES = .h.pl .inc.pl
-%: %.pl $(helpers)
- @mkdir -p `dirname [EMAIL PROTECTED]
+generate_from_pl = mkdir -p `dirname [EMAIL PROTECTED] && \
$(PERL) -I $(top_srcdir)/src/language/expressions $< -o $@ -i
$(top_srcdir)/src/language/expressions/operations.def
+.h.pl.h:
+ $(generate_from_pl)
+
+.inc.pl.inc:
+ $(generate_from_pl)
diff -urpaN pspp-0.4.2.orig/src/language/lexer/automake.mk
pspp-0.4.2/src/language/lexer/automake.mk
--- pspp-0.4.2.orig/src/language/lexer/automake.mk 2006-06-28
07:54:58.000000000 +0200
+++ pspp-0.4.2/src/language/lexer/automake.mk 2006-07-13 19:00:55.000000000
+0200
@@ -16,9 +16,9 @@ src_language_lexer_liblexer_a_SOURCES =
EXTRA_DIST += src/language/lexer/q2c.c
-$(top_builddir)/src/language/lexer/q2c: $(top_srcdir)/src/language/lexer/q2c.c
+src/language/lexer/q2c: src/language/lexer/q2c.c
@mkdir -p `dirname [EMAIL PROTECTED]
$(CC) $(DEFAULT_INCLUDES) $(AM_CPPFLAGS) $< -o $@
-CLEANFILES+=$(top_builddir)/src/language/lexer/q2c
+CLEANFILES += src/language/lexer/q2c
diff -urpaN pspp-0.4.2.orig/src/language/stats/automake.mk
pspp-0.4.2/src/language/stats/automake.mk
--- pspp-0.4.2.orig/src/language/stats/automake.mk 2006-03-17
05:58:25.000000000 +0100
+++ pspp-0.4.2/src/language/stats/automake.mk 2006-07-13 19:05:08.000000000
+0200
@@ -1,20 +1,8 @@
## Process this file with automake to produce Makefile.in -*- makefile -*-
-
noinst_LIBRARIES += src/language/stats/libstats.a
-src_language_stats_q_sources_q = \
- src/language/stats/correlations.q \
- src/language/stats/crosstabs.q \
- src/language/stats/examine.q \
- src/language/stats/frequencies.q \
- src/language/stats/means.q \
- src/language/stats/oneway.q \
- src/language/stats/rank.q \
- src/language/stats/regression.q \
- src/language/stats/t-test.q
-
-src_language_stats_q_sources_c = \
+src_language_stats_built_sources = \
src/language/stats/correlations.c \
src/language/stats/crosstabs.c \
src/language/stats/examine.c \
@@ -25,10 +13,10 @@ src_language_stats_q_sources_c = \
src/language/stats/regression.c \
src/language/stats/t-test.c
-
-EXTRA_DIST += $(src_language_stats_q_sources_q)
-nodist_src_language_stats_libstats_a_SOURCES =
$(src_language_stats_q_sources_c)
-CLEANFILES += $(src_language_stats_q_sources_c)
+all_q_sources += $(src_language_stats_built_sources:.c=.q)
+EXTRA_DIST += $(src_language_stats_built_sources:.c=.q)
+nodist_src_language_stats_libstats_a_SOURCES =
$(src_language_stats_built_sources)
+CLEANFILES += $(src_language_stats_built_sources)
src_language_stats_libstats_a_CPPFLAGS = $(AM_CPPFLAGS) \
-I$(top_srcdir)/src/language/stats
diff -urpaN pspp-0.4.2.orig/src/language/utilities/automake.mk
pspp-0.4.2/src/language/utilities/automake.mk
--- pspp-0.4.2.orig/src/language/utilities/automake.mk 2006-07-12
13:09:03.000000000 +0200
+++ pspp-0.4.2/src/language/utilities/automake.mk 2006-07-13
17:30:42.000000000 +0200
@@ -1,25 +1,14 @@
## Process this file with automake to produce Makefile.in -*- makefile -*-
-
-src_language_utilities_q_sources_q = \
- $(top_srcdir)/src/language/utilities/set.q
-
-src_language_utilities_q_sources_c = \
- $(top_builddir)/src/language/utilities/set.c
-
-BUILT_SOURCES += $(src_language_utilities_q_sources_c)
-
noinst_LIBRARIES += src/language/utilities/libutilities.a
-EXTRA_DIST += $(src_language_utilities_q_sources_q)
-
-nodist_src_language_utilities_libutilities_a_SOURCES =
$(src_language_utilities_q_sources_c)
-
-CLEANFILES += $(src_language_utilities_q_sources_c)
-
src_language_utilities_libutilities_a_SOURCES = \
src/language/utilities/date.c \
src/language/utilities/echo.c \
src/language/utilities/title.c \
src/language/utilities/include.c \
- src/language/utilities/permissions.c
+ src/language/utilities/permissions.c \
+ src/language/utilities/set.q
+
+all_q_sources += \
+ src/language/utilities/set.q
diff -urpaN pspp-0.4.2.orig/src/ui/gui/automake.mk
pspp-0.4.2/src/ui/gui/automake.mk
--- pspp-0.4.2.orig/src/ui/gui/automake.mk 2006-06-24 11:08:50.000000000
+0200
+++ pspp-0.4.2/src/ui/gui/automake.mk 2006-07-13 17:09:41.000000000 +0200
@@ -10,19 +10,19 @@ src_ui_gui_psppire_LDFLAGS = \
src_ui_gui_psppire_LDADD = \
$(GTK_LIBS) \
$(GLADE_LIBS) \
- $(top_builddir)/lib/gtksheet/libgtksheet.a \
- $(top_builddir)/src/math/libpspp_math.a \
- $(top_builddir)/src/data/libdata.a \
- $(top_builddir)/src/libpspp/libpspp.a \
- $(top_builddir)/gl/libgl.a \
+ lib/gtksheet/libgtksheet.a \
+ src/math/libpspp_math.a \
+ src/data/libdata.a \
+ src/libpspp/libpspp.a \
+ gl/libgl.a \
@LIBINTL@ @LIBREADLINE@
src_ui_gui_psppiredir = $(pkgdatadir)
dist_src_ui_gui_psppire_DATA = \
- $(top_srcdir)/src/ui/gui/psppire.glade \
- $(top_srcdir)/src/ui/gui/psppicon.png \
- $(top_srcdir)/src/ui/gui/pspplogo.png
+ src/ui/gui/psppire.glade \
+ src/ui/gui/psppicon.png \
+ src/ui/gui/pspplogo.png
src_ui_gui_psppire_SOURCES = \
diff -urpaN pspp-0.4.2.orig/src/ui/terminal/automake.mk
pspp-0.4.2/src/ui/terminal/automake.mk
--- pspp-0.4.2.orig/src/ui/terminal/automake.mk 2006-06-27 17:23:30.000000000
+0200
+++ pspp-0.4.2/src/ui/terminal/automake.mk 2006-07-13 17:09:41.000000000
+0200
@@ -17,26 +17,26 @@ bin_PROGRAMS += src/ui/terminal/pspp
src_ui_terminal_pspp_SOURCES =
src_ui_terminal_pspp_LDADD = \
- $(top_builddir)/src/ui/terminal/libui.a \
- $(top_builddir)/src/language/liblanguage.a \
- $(top_builddir)/src/language/tests/libtests.a \
- $(top_builddir)/src/language/utilities/libutilities.a \
- $(top_builddir)/src/language/control/libcontrol.a \
- $(top_builddir)/src/language/expressions/libexpressions.a \
- $(top_builddir)/src/language/stats/libstats.a \
- $(top_builddir)/src/language/xforms/libxforms.a \
- $(top_builddir)/src/language/dictionary/libcmddict.a \
- $(top_builddir)/src/language/lexer/liblexer.a \
- $(top_builddir)/src/language/data-io/libdata_io.a \
- $(top_builddir)/src/output/charts/libcharts.a \
- $(top_builddir)/src/output/liboutput.a \
- $(top_builddir)/src/math/libpspp_math.a \
- $(top_builddir)/src/math/linreg/libpspp_linreg.a \
- $(top_builddir)/lib/linreg/liblinreg.a \
- $(top_builddir)/lib/gsl-extras/libgsl-extras.a \
- $(top_builddir)/src/data/libdata.a \
- $(top_builddir)/src/libpspp/libpspp.a \
- $(top_builddir)/gl/libgl.a \
+ src/ui/terminal/libui.a \
+ src/language/liblanguage.a \
+ src/language/tests/libtests.a \
+ src/language/utilities/libutilities.a \
+ src/language/control/libcontrol.a \
+ src/language/expressions/libexpressions.a \
+ src/language/stats/libstats.a \
+ src/language/xforms/libxforms.a \
+ src/language/dictionary/libcmddict.a \
+ src/language/lexer/liblexer.a \
+ src/language/data-io/libdata_io.a \
+ src/output/charts/libcharts.a \
+ src/output/liboutput.a \
+ src/math/libpspp_math.a \
+ src/math/linreg/libpspp_linreg.a \
+ lib/linreg/liblinreg.a \
+ lib/gsl-extras/libgsl-extras.a \
+ src/data/libdata.a \
+ src/libpspp/libpspp.a \
+ gl/libgl.a \
$(LIBICONV) \
@LIBINTL@ @LIBREADLINE@
diff -urpaN pspp-0.4.2.orig/tests/automake.mk pspp-0.4.2/tests/automake.mk
--- pspp-0.4.2.orig/tests/automake.mk 2006-07-08 10:56:54.000000000 +0200
+++ pspp-0.4.2/tests/automake.mk 2006-07-13 17:09:41.000000000 +0200
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in -*- makefile -*-
-TESTS_ENVIRONMENT = top_srcdir=${top_srcdir} top_builddir=${top_builddir}
+TESTS_ENVIRONMENT = top_srcdir='$(top_srcdir)' top_builddir='$(top_builddir)'
TESTS_ENVIRONMENT += PERL='@PERL@'
TESTS = \
tests/command/aggregate.sh \