-install-$(dir):
- mkdir -p $(DESTDIR)$(libdir)/
- install -m0644 $(dir)/$(LIBNAME) $(DESTDIR)$(libdir)/
- ln -sf $(LIBNAME) $(DESTDIR)$(libdir)/$(SONAME)
- ln -sf $(LIBNAME) $(DESTDIR)$(libdir)/$(LINKER_NAME)
- mkdir -p $(DESTDIR)$(includedir)
- install -m0644 $(dir)/notmuch.h $(DESTDIR)$(includedir)/
+# The (often-reused) $dir works fine within targets/pre-requisites,
+# but cannot be used reliably within commands, so copy its value to a
+# variable that is not reused.
+lib := $(dir)
+install-$(dir): $(dir)/$(LIBNAME)
+ mkdir -p "$(DESTDIR)$(libdir)/"
+ install -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
+ ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(SONAME)"
+ ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(LINKER_NAME)"
+ mkdir -p "$(DESTDIR)$(includedir)"
+ install -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"