From db99a747778a9fd3d22cc620ba1649e705cf7fd9 Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Thu, 20 Oct 2005 03:49:40 +0200 Subject: [PATCH] Add support for out-of-tree builds Involves prefixing with $(srcdir) to some of the build rule variables. For the builddir we create Makefiles which simply include the srcdir Makefile. Add list make rule to get list of Makefiles to generate (find will get it wrong for builddirs nested in srcdir). There are still a few minor issues like the file paths echoed during make install ... --- Makefile.lib | 10 +++++++--- configure.in | 13 +++++++++++++ doc/man/man1/Makefile | 2 +- doc/man/man5/Makefile | 2 +- po/Makefile | 2 +- src/intl/gettext/Makefile | 3 --- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Makefile.lib b/Makefile.lib index a0fda102..82d7004d 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -56,7 +56,7 @@ ifdef OBJS -include $(DEP_FILES) endif -%.o: %.c +%.o: $(srcdir)%.c $(call mcmd,compile) @-cp .deps/$(*F).pp .deps/$(*F).P; \ tr ' ' '\012' < .deps/$(*F).pp \ @@ -84,6 +84,9 @@ CLEAN += $(PROG) all-default: $(LIB_O) $(PROGS) $(MAN1) $(MAN5) +list-default: + @echo '$(RELPATH)Makefile' + clean-default: -test -z "$(CLEAN)" || $(RM) $(CLEAN) @@ -106,8 +109,8 @@ endif # Recursion: -.PHONY: all-recursive install-recursive clean-recursive -all-recursive install-recursive clean-recursive: +.PHONY: all-recursive install-recursive clean-recursive list-recursive +all-recursive install-recursive clean-recursive list-recursive: ifdef SUBDIRS @target=`echo $@ | sed s/-recursive//`; \ for subdir in $(sort $(SUBDIRS)); do \ @@ -118,6 +121,7 @@ endif all: all-recursive all-default all-local install: install-recursive install-default install-local clean: clean-recursive clean-default clean-local +list: list-recursive list-default all-local: install-local: diff --git a/configure.in b/configure.in index 24ac20fd..6cf279ec 100644 --- a/configure.in +++ b/configure.in @@ -1245,6 +1245,19 @@ AC_OUTPUT([ \ src/intl/gettext/ref-del.sed ]) +srcdir2="$(cd "$srcdir" && pwd)" +if test "$srcdir2" != "$builddir"; then + for i in $(make -C "$srcdir" list | grep Makefile); do + $MKINSTALLDIRS "$builddir/$(dirname $i)" + grep path_to_top= "$srcdir/$i" > "$builddir/$i" + case "$srcdir" in + /*) echo "include $srcdir/$i" >> "$builddir/$i" ;; + *) echo "include \$(path_to_top)/$srcdir/$i" >> "$builddir/$i" ;; + esac + echo "creating $builddir/$i" + done +fi + dnl =================================================================== dnl Configuration summary diff --git a/doc/man/man1/Makefile b/doc/man/man1/Makefile index be6bdd70..ea1e9332 100644 --- a/doc/man/man1/Makefile +++ b/doc/man/man1/Makefile @@ -1,7 +1,7 @@ path_to_top=../../.. include $(path_to_top)/Makefile.config -elinks.1: elinks.1.in $(top_srcdir)/configure.in +elinks.1: $(srcdir)/elinks.1.in $(top_srcdir)/configure.in cd $(top_srcdir) && \ CONFIG_FILES="$(RELPATH)$@" CONFIG_HEADERS= $(SHELL) ./config.status diff --git a/doc/man/man5/Makefile b/doc/man/man5/Makefile index 2f637df9..33124497 100644 --- a/doc/man/man5/Makefile +++ b/doc/man/man5/Makefile @@ -1,6 +1,6 @@ path_to_top=../../.. include $(path_to_top)/Makefile.config -MAN5 = elinks.conf.5 elinkskeys.5 +MAN5 = $(srcdir)/elinks.conf.5 $(srcdir)/elinkskeys.5 include $(top_srcdir)/Makefile.lib diff --git a/po/Makefile b/po/Makefile index 92acb414..45fa754a 100644 --- a/po/Makefile +++ b/po/Makefile @@ -15,7 +15,7 @@ POTFILES_ABS_LIST = potfiles.list SUFFIXES = .po .gmo .mo .SUFFIXES: .gmo .mo .po -%.gmo: %.po +%.gmo: $(srcdir)/%.po @file=`echo $* | sed 's,.*/,,'`.gmo \ && rm -f $$file && echo -n $*": " \ && $(GMSGFMT) --statistics -o $$file $< diff --git a/src/intl/gettext/Makefile b/src/intl/gettext/Makefile index 45750070..1bd98cfb 100644 --- a/src/intl/gettext/Makefile +++ b/src/intl/gettext/Makefile @@ -4,9 +4,6 @@ include $(path_to_top)/Makefile.config localedir = $(datadir)/locale builddir = $(top_builddir)/src/intl/gettext -# FIXME: Makefile.config gets this wrong -srcdir = $(top_srcdir)/src/intl/gettext - OBJS = \ bindtextdom.o \ dcgettext.o \