[gcr] build: Split desktop file generation rules



commit 9964bd47188d095a245b91452c0e96cb63aae718
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sun Jun 16 16:27:41 2019 +0100

    build: Split desktop file generation rules
    
    You cannot use the Makefile automatic variable $< for rules that involve
    multiple files to mean "the dependency that triggered the rule". The $<
    automatic variable means:
    
      The name of the first prerequisite.
    
    So this:
    
        targets_in = foo.desktop.in bar.desktop.in
        targets = $(targets_in:.desktop.in=.desktop)
        $(targets): $(targets_in)
                do-something -o $@ $<
    
    Will *not* expand to two rules:
    
        foo.desktop: foo.desktop.in
                do-something -o foo.desktop foo.desktop.in
        bar.desktop: bar.desktop.in
                do-something -o bar.desktop bar.desktop.in
    
    It will, instead, expand to:
    
        foo.desktop: foo.desktop.in
                do-something -o foo.desktop foo.desktop.in
        bar.desktop: bar.desktop.in
                do-something -o bar.desktop foo.desktop.in
    
    Which is definitely not what we want.
    
    There is no automatic variable in Make that matches the Nth target to
    the Nth dependency, which means we need to add an explicit rule for each
    file.

 ui/Makefile.am | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)
---
diff --git a/ui/Makefile.am b/ui/Makefile.am
index d38e46a..29c33e7 100644
--- a/ui/Makefile.am
+++ b/ui/Makefile.am
@@ -189,13 +189,6 @@ pkgconfig_DATA += \
 gcr-ui-expected.abi: ui/gcr-ui.symbols
        $(AM_V_GEN) cpp -P $< | sort > $@
 
-desktopdir = $(datadir)/applications
-desktop_in_in_files = ui/gcr-viewer.desktop.in.in ui/gcr-prompter.desktop.in.in
-desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
-desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
-$(desktop_DATA): $(desktop_in_files)
-       $(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
-
 bin_PROGRAMS = gcr-viewer
 
 gcr_viewer_SOURCES = \
@@ -213,6 +206,12 @@ gcr_viewer_LDADD = \
        $(GLIB_LIBS) \
        $(GTK_LIBS)
 
+viewer_desktop_in_in = ui/gcr-viewer.desktop.in.in
+viewer_desktop_in = $(viewer_desktop_in_in:.desktop.in.in=.desktop.in)
+viewer_desktop = $(viewer_desktop_in:.desktop.in=.desktop)
+$(viewer_desktop): $(viewer_desktop_in)
+       $(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
+
 libexec_PROGRAMS += gcr-prompter
 
 gcr_prompter_SOURCES = \
@@ -229,12 +228,23 @@ gcr_prompter_LDADD = \
        libgck-@GCK_MAJOR@.la \
        $(GTK_LIBS)
 
+prompter_desktop_in_in = ui/gcr-prompter.desktop.in.in
+prompter_desktop_in = $(prompter_desktop_in_in:.desktop.in.in=.desktop.in)
+prompter_desktop = $(prompter_desktop_in:.desktop.in=.desktop)
+$(prompter_desktop): $(prompter_desktop_in)
+       $(AM_V_GEN) $(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
+
+desktop_in_files = $(desktop_in_in_files:.desktop.in.in=.desktop.in)
+desktopdir = $(datadir)/applications
+desktop_DATA = \
+       $(prompter_desktop) \
+       $(viewer_desktop)
+
 EXTRA_DIST += \
        ui/gcr.pc.in \
        ui/gcr-ui.pc.in \
        ui/gcr-ui.symbols \
        ui/gcr.gresource.xml \
-       $(desktop_in_in_files) \
        $(ui_RESOURCES) \
        $(mime_DATA) \
        ui/fixtures


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