[gimp-help-2] [make] Make 'make' make



commit 893ae5e6afcea516931c5c7c32df420537bcd32a
Author: Ulf-D. Ehlert <ulfehlert svn gnome org>
Date:   Mon Nov 30 20:24:47 2009 +0100

    [make] Make 'make' make
    
    * Fix 'make' and 'make install' if "builddir" != "srcdir" (bug #602659):
      - tools/make_image_links.pl:
        fix symlink paths which were constructed incorrectly due to a bug (?)
        in Perl module File::Spec:Unix.
      - Makefile.am:
        add special rule for making xml/LANG/authors.xml;
        clean-up some make rules and file lists;
        fix path to config.status (builddir, not srcdir).
    * Fix fallback feature in tools/make_image_links.pl.
    * Minor cleanups in Makefile.am.

 Makefile.am               |  139 ++++++++++++++++++++++++++-------------------
 tools/make_image_links.pl |   51 +++++++++--------
 2 files changed, 107 insertions(+), 83 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 57d3f0c..4c77227 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -5,7 +5,10 @@ SUBDIRS = quickreference
 # used for creating the ChangeLog
 LAST_RELEASE_TAG = GIMP_HELP_2_4_2
 
-# The GIMP manual languages
+########################################################################
+####            The GIMP manual languages                           ####
+########################################################################
+
 LANGUAGES = $(if $(LINGUAS), \
               $(filter $(ALL_LINGUAS),$(LINGUAS)), \
 	      $(ALL_LINGUAS))
@@ -23,11 +26,19 @@ DOC_LINGUAS = $(LINGUAS)
 # HIDE FROM AUTOMAKE #XML_LANG = en
 # HIDE FROM AUTOMAKE #PO_LANGS = $(filter-out $(XML_LANG), $(LANGUAGES))
 
+
+########################################################################
+####            External programs                                   ####
+########################################################################
+
 ## Essential external programs and their default options
 ## (some of these variables are provided via "configure" -- see configure.ac)
 ##
 ## XSLTPROC  = xsltproc
 ## XSLTFLAGS = --nonet
+# HIDE FROM AUTOMAKE #ifneq ($(srcdir),$(builddir))
+# HIDE FROM AUTOMAKE #XSLTFLAGS += --path $(builddir)
+# HIDE FROM AUTOMAKE #endif
 ##
 ## XMLLINT      = xmllint
 XMLLINTFLAGS = --nonet
@@ -54,11 +65,16 @@ DOCBOOK2ODFFLAGS =
 # Standard shell commands
 find_l = find -L
 
+# Standard shell commands
+echo_n = echo $(ECHO_N)
+
 # Calling make recursively
 RMAKE = $(MAKE) --no-print-directory
 
-# Standard shell commands
-echo_n = echo $(ECHO_N)
+
+########################################################################
+####            Files and directories                               ####
+########################################################################
 
 ### Find files and directories
 
@@ -95,6 +111,17 @@ AUTHORS_DOCBOOK_STYLESHEETS = \
 # HIDE FROM AUTOMAKE #            $(AUTHORS_DOCBOOK_XML)
 # HIDE FROM AUTOMAKE #endif
 
+# TODO?: rename "plainhtml.xsl" to "html.xsl" and use ...
+# ... HTML_STYLESHEETS = stylesheets/html*.xsl
+HTML_STYLESHEETS = stylesheets/plainhtml.xsl stylesheets/htmlalternate.xsl
+
+# This variable is used by "msgmerge";
+# use empty variable to disable the compendium option
+COMPENDIUM = Compendium.po
+
+
+### List of files for the autotools' "dist" rules
+
 # lists of PO files (translations)
 PO_FILES = $(shell cd $(srcdir) && $(find_l) po/ -type f)
 
@@ -135,10 +162,6 @@ EXTRA_DIST = \
 	$(XSL_FILES)		\
 	$(DIST_TOOLS)
 
-# TODO?: rename "plainhtml.xsl" to "html.xsl" and use ...
-# ... HTML_STYLESHEETS = stylesheets/html*.xsl
-HTML_STYLESHEETS = stylesheets/plainhtml.xsl stylesheets/htmlalternate.xsl
-
 #
 DISTCHECK_CONFIGURE_FLAGS = --without-gimp
 
@@ -146,15 +169,11 @@ DISTCHECK_CONFIGURE_FLAGS = --without-gimp
 ## remember that automake defines "srcdir"
 helpdir  = $(gimpdatadir)/help
 
-# This variable is used by "msgmerge";
-# use empty variable to disable the compendium option
-COMPENDIUM = Compendium.po
-
 
 ########################################################################
 ####            Control the amount of output messages               ####
 ########################################################################
-
+#
 # Usage of the "msg" and "cmd" variables:
 # In the command lines of the make rules, use
 #     $(msg) bla bla bla   instead of   @echo bla bla bla
@@ -314,9 +333,9 @@ copy = $(LN_S) $(abs_srcdir)/$(1) $(2)
 ####            Make pot files:  XML(en) --> POT                    ####
 ########################################################################
 #
-# xmldir/path/to/file/*.xml --> potdir/path/to/file.pot
+# src/path/to/file/*.xml --> pot/path/to/file.pot
 POT_FILES  = $(patsubst src/%,pot/%.pot,$(filter-out src src/,$(SRC_DIRS)))
-# Special case
+# Special case: src/*.xml --> pot/gimp.pot
 POT_FILES += pot/gimp.pot
 #
 # Special case
@@ -355,11 +374,11 @@ cleanup-pot:
 ########################################################################
 #
 # HIDE FROM AUTOMAKE #define MAKE_PO_RULES
-# HIDE FROM AUTOMAKE #$(1)_PO_FILES = $$(patsubst pot/%.pot, $$(srcdir)/po/$(1)/%.po, $$(POT_FILES))
+# HIDE FROM AUTOMAKE #$(1)_PO_FILES = $$(patsubst pot/%.pot, po/$(1)/%.po, $$(POT_FILES))
 # HIDE FROM AUTOMAKE #ifeq ($$(filter po/$(1)/%.po,$$(MAKECMDGOALS)),)
-# HIDE FROM AUTOMAKE #$$($(1)_PO_FILES): $$(srcdir)/po/$(1)/%.po : pot/%.pot
+# HIDE FROM AUTOMAKE #$$($(1)_PO_FILES): po/$(1)/%.po : pot/%.pot
 # HIDE FROM AUTOMAKE #else
-# HIDE FROM AUTOMAKE #$$($(1)_PO_FILES): $$(srcdir)/po/$(1)/%.po : pot/%.pot FORCE
+# HIDE FROM AUTOMAKE #$$($(1)_PO_FILES): po/$(1)/%.po : pot/%.pot FORCE
 # HIDE FROM AUTOMAKE #endif
 # HIDE FROM AUTOMAKE #	$$(cmd) $$(call make_target_dir,$$@)
 # HIDE FROM AUTOMAKE #	$$(msg) "[PO]  $$@"
@@ -398,11 +417,6 @@ todo-%: po-todo-% ;
 po-todo-%: po-%
 	$(cmd) perl $(srcdir)/tools/get_po_status.pl --todo po/$*
 
-# Force updating po file
-update-po/%.po:
-	$(msg) "Deprecated, use 'make po/$*.po instead'"
-	$(cmd) false
-
 
 ########################################################################
 ####            Generate XML prerequisites                          ####
@@ -425,15 +439,16 @@ update-po/%.po:
 # HIDE FROM AUTOMAKE #xml/$(1)/.deps.mk: $(AUTHORS_DOCBOOK_XML) $$(SRC_FILES)
 # HIDE FROM AUTOMAKE #	$$(cmd) $$(call make_target_dir,$$@)
 # HIDE FROM AUTOMAKE #	$$(msg) "[DEP] $$@"
-# HIDE FROM AUTOMAKE #	$$(cmd) touch $$@
-# HIDE FROM AUTOMAKE #	$$(cmd) for srcdir in $(SRC_DIRS); do \
-# HIDE FROM AUTOMAKE #		ls $$$${srcdir}/*.xml >/dev/null 2>&1 || continue; \
-# HIDE FROM AUTOMAKE #		srcdir=$$$${srcdir%/}; \
-# HIDE FROM AUTOMAKE #		xmldir=xml/$(1)$$$${srcdir#src}; \
-# HIDE FROM AUTOMAKE #		test "$$$${srcdir}" != "src" || srcdir="src/gimp"; \
-# HIDE FROM AUTOMAKE #		pofile=po/$(1)$$$${srcdir#src}.po; \
+# HIDE FROM AUTOMAKE #	$$(cmd) echo "first: all" > $$@
+# HIDE FROM AUTOMAKE #	$$(cmd) for path in $(SRC_DIRS); do \
+# HIDE FROM AUTOMAKE #		ls $$(srcdir)/$$$${path}/*.xml >/dev/null 2>&1 || \
+# HIDE FROM AUTOMAKE #		ls $$$${path}/*.xml >/dev/null 2>&1 || continue; \
+# HIDE FROM AUTOMAKE #		path=$$$${path%/}; \
+# HIDE FROM AUTOMAKE #		xmldir=xml/$(1)$$$${path#src}; \
+# HIDE FROM AUTOMAKE #		test "$$$${path}" != "src" || path="src/gimp"; \
+# HIDE FROM AUTOMAKE #		pofile=po/$(1)$$$${path#src}.po; \
 # HIDE FROM AUTOMAKE #		echo "$$$${xmldir}/*.xml: $$$${pofile}"; \
-# HIDE FROM AUTOMAKE #	done > $$@
+# HIDE FROM AUTOMAKE #	done >> $$@
 # HIDE FROM AUTOMAKE #endef
 # HIDE FROM AUTOMAKE #$(foreach LANG,$(PO_LANGS),$(eval $(call MAKE_DEP_RULES,$(LANG))))
 
@@ -454,6 +469,15 @@ update-po/%.po:
 # HIDE FROM AUTOMAKE #	test "$$$${stem}" != "$$$${stem%/*}" && stem=$$$${stem%/*} || stem=gimp; \
 # HIDE FROM AUTOMAKE #	pofile=$$(srcdir)/po/$(1)/$$$${stem}.po; \
 # HIDE FROM AUTOMAKE #	$(call po2xml,$$$${srcfile},$$$${pofile},$(1),$$@)
+# Special case: authors.xml
+# HIDE FROM AUTOMAKE #xml/$(1)/$(AUTHORS_DOCBOOK_XML:src/%=%): $(AUTHORS_DOCBOOK_XML)
+# HIDE FROM AUTOMAKE #	$$(msg) "[XML] $$@"
+# HIDE FROM AUTOMAKE #	$$(cmd) $$(call make_target_dir,$$@)
+# HIDE FROM AUTOMAKE #	$$(cmd) xmlfile=$$@; \
+# HIDE FROM AUTOMAKE #	srcfile=$(AUTHORS_DOCBOOK_XML); \
+# HIDE FROM AUTOMAKE #	stem=$$(dir $$(@:xml/$(1)/%=%)); \
+# HIDE FROM AUTOMAKE #	pofile=$$(srcdir)/po/$(1)/$$$${stem%/}.po; \
+# HIDE FROM AUTOMAKE #	$(call po2xml,$$$${srcfile},$$$${pofile},$(1),$$@)
 # HIDE FROM AUTOMAKE #
 # HIDE FROM AUTOMAKE ## This is indirectly used as HTML and PDF prerequisite:
 # HIDE FROM AUTOMAKE #xml/$(1): $$($(1)_XML_FILES) | xml/$(1)/images
@@ -464,27 +488,6 @@ update-po/%.po:
 # HIDE FROM AUTOMAKE #endef
 # HIDE FROM AUTOMAKE #$(foreach LANG,$(PO_LANGS),$(eval $(call MAKE_XML_RULES,$(LANG))))
 
-# TODO: test new image files structure;
-#   problem: how to ensure that $@ is up-to-date without forcing
-#   rebuild (which will also force e.g. html-% to be rebuilt 
-#   -- use (~1500) image files as prerequisites?
-xml/%/images: FORCE
-	$(cmd) if test -L $@; then rm -v $@; fi
-	$(cmd) if test -L xml/$*; then rm -v xml/$*; fi
-	$(cmd) if test -d $@; then rm -rf $@/*; fi
-	$(cmd) test -d $@ || $(MKDIR_P) $@
-	$(cmd) $(echo_n) "*** Copying images ($*) ..."
-if CYGWIN
-# Cygwin
-	$(cmd) perl $(srcdir)/tools/make_image_links.pl -v \
-	           --mode=hardlink,copy \
-	           $(srcdir)/images/{common,C} $@
-else
-# Default (non-Cygwin)
-	$(cmd) perl $(srcdir)/tools/make_image_links.pl -v \
-	           $(srcdir)/images/{common,C} $@
-endif
-
 # Special case: en
 
 en_XML_FILES = $(SRC_FILES:src/%=xml/en/%)
@@ -517,9 +520,15 @@ xml/%/images: $(IMAGE_PREREQ)
 	$(cmd) if test -d $@; then rm -rf $@/*; fi
 	$(cmd) test -d $@ || $(MKDIR_P) $@
 	$(cmd) $(echo_n) "Copying images ($*) ..."
+if CYGWIN
+# Cygwin
+	$(cmd) perl $(srcdir)/tools/make_image_links.pl -v \
+	           --mode=hardlink,copy \
+	           $(srcdir)/images/{common,C} $@
+else
 	$(cmd) perl $(srcdir)/tools/make_image_links.pl -v \
-	           $(srcdir)/images/common $(srcdir)/images/C \
-		   xml/$*
+	           $(srcdir)/images/{common,C} $@
+endif
 
 # remove stale xml files
 cleanup-xml-%:
@@ -605,6 +614,8 @@ html/%/index.html: xml/% $(HTML_STYLESHEETS) | html/%/images
 
 ####  HTML images  ####
 # TODO: check/enhance new image files structure
+html-images-%: html/%/images ;
+
 if CYGWIN
 # Cygwin
 html/%/images: FORCE
@@ -816,7 +827,9 @@ install-data-local:
 	echo .
 
 uninstall-local:
-	$(cmd) rm -rf $(DESTDIR)$(helpdir)/*
+	$(cmd) for lang in $(LANGUAGES); do \
+		rm -rf $(DESTDIR)$(helpdir)/$${lang}; \
+	done
 	$(cmd) dir=$(DESTDIR)$(helpdir); \
 	while [ -d "$${dir}" ]; do \
 		rmdir $${dir} 2>/dev/null \
@@ -904,17 +917,25 @@ dist-copy-images:
 	$(cmd) test -d "$(distdir)/images" && test ! -d "$(distdir)/images/.git"
 
 
-clean-local:
+mostlyclean-local:
 	$(cmd) rm -rf html
 	$(cmd) rm -rf odf
 	$(cmd) rm -rf pdf
 	$(cmd) rm -rf xml
-	$(cmd) rm -rf log
 	$(cmd) rm -rf pot
+# HIDE FROM AUTOMAKE #ifneq ($(srcdir),$(builddir))
+	$(cmd) rm -rf src
+	$(cmd) rm -rf po
+# HIDE FROM AUTOMAKE #else
+	$(cmd) rm -f $(AUTHORS_DOCBOOK_XML)
+# HIDE FROM AUTOMAKE #endif
 	$(cmd) rm -f $(tarball_prefix)-*
-	$(cmd) rm -f AUTHORS $(AUTHORS_DOCBOOK_XML) build-system.png
+	$(cmd) rm -f build-system.png
 	$(cmd) rm -f .xml2po.mo messages.mo
 
+clean-local: mostlyclean-local
+	$(cmd) rm -rf log
+	$(cmd) rm -f AUTHORS
 
 maintainer-clean-local:
 	$(cmd) rm -rf html
@@ -922,8 +943,8 @@ maintainer-clean-local:
 # Override automake-generated targets
 Makefile: $(srcdir)/Makefile.in $(srcdir)/Makefile.am $(srcdir)/configure.ac $(srcdir)/autogen.sh
 	$(msg) "!!! Updating '$@' running 'autogen.sh' ($? changed) !!!"
-	$(cmd) opt=`test -e $(srcdir)/config.status && \
-	     $(srcdir)/config.status --version | \
+	$(cmd) opt=`test -e $(builddir)/config.status && \
+	     $(builddir)/config.status --version | \
 	     sed -e 's/.*with options "//' \
 	         -e tmatch -e d -e :match -e 's/".*//' \
 		 -e "s/'\([^'=]*\)=\([^']*\)'/\1='\2'/"`; \
diff --git a/tools/make_image_links.pl b/tools/make_image_links.pl
index 923e3d1..1dc0f84 100755
--- a/tools/make_image_links.pl
+++ b/tools/make_image_links.pl
@@ -17,7 +17,7 @@ use strict;
 use Getopt::Long;
 use File::Find;
 use File::Path qw/mkpath/;
-use File::Spec::Functions qw/abs2rel splitpath catfile/;
+use File::Spec::Functions qw/abs2rel rel2abs splitpath catfile/;
 use File::Copy;
 
 
@@ -76,11 +76,10 @@ die "$Usage\n" if scalar @ARGV < 2;
 my $Destdir = pop;
 my @Srcdirs = @ARGV;
 
-# XXX: assuming destination = '(x|ht)ml/LANG[/images]
-if ($Destdir =~ s:((x|ht)ml)/([^/]+)(/images)?/?$:$1/$3:) {
-    $Language = $3;
-    $Language =~ /^[a-z]{2}(_[A-Z]{2})?$/
-        or die "Error: invalid language: $Language\n";
+# assuming destination = (x|ht)ml/LANG[/images]
+my $locale_re = qr/[a-z]{2}(?:_[A-Z]{2})?/;
+if ($Destdir =~ s!((?:x|ht)ml)/($locale_re)(?:/images/?)?$!$1/$2!) {
+    $Language = $2;
 } else {
     die "Error: invalid destination directory: $Destdir\n" .
         "  (should be '(x|ht)ml/LANG[/images]')\n";
@@ -112,13 +111,6 @@ my ($Count_all, $Count_i18n, $inc_i18n) = (0, 0, 0);
 # Should we look for localized images?
 my $Localize_images = ($Language ne "en") ? 1 : 0;
 
-# Simple check if we should try a fallback
-# if copying/linking image failed
-my $mode_is_known_to_work = 0;
-
-# Did last copy/link operation succeed?
-my $ok  = undef;
-
 # The appropriate method for linking/copying is
 # called via this reference to an (anonymous) subroutine
 my $exec_copy_command = undef;
@@ -133,9 +125,19 @@ my %method = ("symlink"  => sub { my ($s, $d) = @_; symlink($s, $d); },
 # to the specified parameter ("symlink", "hardlink", or "copy")
 sub get_copy_command {
     my $cur_mode = shift or die "Oops!?";
-    return sub { $method{$cur_mode}->(@_) and ++$mode_is_known_to_work
-                     or warn("Error: failed to make $cur_mode for $_[0]\n");
-               }
+    # Simple check if we should try a fallback or abort
+    # if copying/linking image failed
+    my $mode_is_known_to_work = 0;
+    return sub {
+        my $ok = $method{$cur_mode}->(@_);
+        if ($ok) {
+            ++$mode_is_known_to_work;
+        } else {
+            warn("Error: failed to make $cur_mode for $_[0]\n");
+            die("Abort.\n") if ($mode_is_known_to_work); # XXX: what else?
+        }
+        return $ok;
+    }
 }
 
 # Subroutine for (re)setting coyp/link mode
@@ -154,16 +156,18 @@ sub set_copy_mode {
 # Main routine:
 set_copy_mode();
 foreach my $srcdir (sort @Image_dirs) {
-    # Construct corresponding destination directory:
-    # XXX: assuming source = images/{C,common}
-    #      and destination = (x|ht)ml/LANG
+    # Construct corresponding destination directory,
+    # assuming source = [.../]images/{C,common}
+    #     destination = (x|ht)ml/LANG
     (my $dstdir = $srcdir) =~ s|(.*/)?images/[^/]+|$Destdir/images|o;
     -d $dstdir or mkpath $dstdir
         or die "Error: cannot mkpath $dstdir: $!\n";
     # Get relative path from $dstdir to (image source directory) $srcdir;
     # this path is needed if/when making relative symlinks.
-    my $save_path = my $dst_to_src_path = abs2rel($srcdir, $dstdir)
-        if $Mode[0] eq "symlink";
+    # FIXME: change this code, File::Spec::Unix is buggy(?!) --
+    # abs2rel($srcdir, $dstdir) doesn't work if $srcdir starts with "../"
+    my $dst_to_src_symlink_path =
+        abs2rel(rel2abs($srcdir), $dstdir) if $Mode[0] eq "symlink";
     foreach my $imgfile (glob "$srcdir/*.*") {
         next unless -f $imgfile;
         my $basename = (splitpath($imgfile))[2];  # (vol, dir, file)
@@ -177,16 +181,15 @@ foreach my $srcdir (sort @Image_dirs) {
         print STDERR "$destfile\n" if $Verbose > 2;
         # Special case symlinks:
         if ($Mode[0] eq "symlink") {
-            $dst_to_src_path = $save_path;
+            my $dst_to_src_path = $dst_to_src_symlink_path;
             # If necessary, change relative path too:
             $dst_to_src_path =~ s|/C/|/$Language/|o
                 if ($Localize_images && $imgfile =~ m|/$Language/|o);
             # Use a relative symlink to image file:
             $imgfile = catfile($dst_to_src_path, $basename);
         }
-        $ok = $exec_copy_command->($imgfile, $destfile);
+        my $ok = $exec_copy_command->($imgfile, $destfile);
         if (!$ok) {
-            die "Abort.\n" if ($mode_is_known_to_work); # XXX: what else?
             set_copy_mode();
             redo;
         }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]