GNOME Bugzilla – Bug 169768
gnome-doc-utils.make doesn't work in builddir != srcdir setup
Last modified: 2020-03-03 18:34:28 UTC
On configure: grep: Makefile.am: No such file or directory gnome-doc-utils.make should be added to EXTRA_DIST in Makefile.am On make in help/: (cd es/ && \ `which xml2po` -p es.po ../C/epiphany.xml > epiphany.xml) /bin/sh: line 0: cd: es/: Aucun fichier ou répertoire de ce type
Created attachment 38501 [details] [review] fix for the configure problem
This was applied on March 10. Closing.
This bug still exists; the configure patch was only part of the problem. With latest gnome-doc-utils, the lang directories are created in the builddir, but the xml2po call still thinks it runs in srcdir: if ! test -d es/; then mkdir es/; fi if ! test -f es/es.po; then \ (cd es/ && \ xml2po -e ../C/epiphany.xml > es.po); \ else \ (cd es/ && \ xml2po -e -u es ../C/epiphany.xml); \ fi Error: cannot open file '../C/epiphany.xml'.
All right, I fixed that bit and another part that was causing a problem. Are there any more problems?
It's better now, but still doesn't work completely right. This rule: $(_DOC_POFILES): $(_DOC_C_DOCS) if ! test -d $(dir $@); then mkdir $(dir $@); fi if test -f "$(_DOC_C_MODULE)"; then d="../"; else d="../$(srcdir)/"; fi; \ if ! test -f $@; then \ (cd $(dir $@) && \ $(_xml2po) -e $(_DOC_C_DOCS_NOENT:%=$${d}%) > $(notdir $@)); \ else \ (cd $(dir $@) && \ $(_xml2po) -e -u $(basename $(notdir $@)) $(_DOC_C_DOCS_NOENT:%=$${d}%)); \ fi will execute this commands: if ! test -d es/; then mkdir es/; fi if test -f "C/epiphany.xml"; then d="../"; else d="../../../help/"; fi; \ if ! test -f es/es.po; then \ (cd es/ && \ xml2po -e ${d}C/epiphany.xml > es.po); \ else \ (cd es/ && \ xml2po -e -u es ${d}C/epiphany.xml); \ fi The test for es/es.po is wrong: the po file will exist in the srcdir, not in the builddir. So instead of updating the po file from the .xml and the existing .po, it is instead created from only the .xml and doesn't contain any translations. Another problem is the generation of the translated .xml: $(_DOC_LC_DOCS) : $(_DOC_C_DOCS) if test -f "$(_DOC_C_MODULE)"; then d="../C/"; else d="../$(srcdir)/C/"; fi; \ (cd $(dir $@) && \ $(_xml2po) -e -p $(patsubst %/$(notdir $@),%,$@).po $${d}$(notdir $@) > $(notdir $@)) Redirecting the output directly to epiphany.xml can cause build failure: when something goes wrong, epiphany.xml may end up empty; and a following run of make will now think that epiphany.xml is up-to-date and will skip the es/ directory. Instead, it should redirect output to a temp file, and only on success move the file to the target, like this: $(_DOC_LC_DOCS) : $(_DOC_C_DOCS) if test -f "$(_DOC_C_MODULE)"; then d="../C/"; else d="../$(srcdir)/C/"; fi; \ (cd $(dir $@) && \ $(_xml2po) -e -p $(patsubst %/$(notdir $@),%,$@).po $${d}$(notdir $@) > gen-$(notdir $@) && \ cp gen-$(notdir $@) $(notdir $@) && \ rm -f gen-$(notdir $@)
Phew, all right. I've addressed these issues. Modules using gdu seem to build fine with builddir != srcdir now. There still seem to be problems building gdu itself in a separate builddir, but we can address those in #169324. I consider issues that affect other modules to be a much higher priority. Any more issues?
> Any more issues? Yes. $(_DOC_POFILES): $(_DOC_C_DOCS) if ! test -d $(srcdir)/$(dir $@); then mkdir $(srcdir)/$(dir $@); fi if ! test -f $(srcdir)/$@; then \ (cd $(srcdir)/$(dir $@) && \ $(_xml2po) -e $(_DOC_C_DOCS_NOENT:%=../%) > $(notdir $@)); \ else \ (cd $(srcdir)/$(dir $@) && \ $(_xml2po) -e -u $(basename $(notdir $@)) $(_DOC_C_DOCS_NOENT:%=../%)); \ fi will do this: if ! test -d ../../help/es/; then mkdir ../../help/es/; fi if ! test -f ../../help/es/es.po; then \ (cd ../../help/es/ && \ xml2po -e ../C/epiphany.xml > es.po); \ else \ (cd ../../help/es/ && \ xml2po -e -u es ../C/epiphany.xml); \ fi so it does: - create the es/ directory in $(srcdir) if it doesn't exist - if $(srcdir)/es/es.po exists, put a "es" file in $(srcdir)/es; else put "es.po" there Touching files and adding directories in $(srcdir) is not legal; $(srcdir) might not be writable.
The above problems are all resolved. However I found two more problems: Suppose that $(srcdir)/es/es.po is updated by the translator, so it's now newer than $(srcdir)/C/$app.xml. Doing "make es/es.po" in $(builddir) will say "make: `es/es.po' is up to date."; but $(builddir)/es/es.po does not even exist! And a minor problem: This rule: $(_DOC_LC_DOCS) : $(_DOC_C_DOCS) if ! test -d $(dir $@); then mkdir $(dir $@); fi if test -f "C/$(notdir $@)"; then d="../"; else d="../$(srcdir)/"; fi; \ (cd $(dir $@) && \ $(_xml2po) -e -p \ $${d}$(dir $@)$(patsubst %/$(notdir $@),%,$@).po \ $${d}C/$(notdir $@) > $(notdir $@).tmp && \ cp $(notdir $@).tmp $(notdir $@) && rm -f $(notdir $@).tmp) will use the pofile in $(srcdir)/es instead of the just created/updated one in $(builddir)/es.
This last part is tricky. In this case, make sees the po file in the srcdir, determines it's up-to-date, and never gives any of my code a chance to run. To make, the builddir and srcdir files are effectively the same thing. Not saying it's unsolvable. Just that I don't know the solution.
gnome-doc-utils has been superseded by yelp-xsl, yelp-tools, and itstool. gnome-doc-utils will not see any further development, hence closing as WONTFIX. See https://gitlab.gnome.org/Infrastructure/Infrastructure/issues/255