Fix uninstalling of binaries.
[kai/samba.git] / source4 / build / make / templates.mk
index 48678c5603e111358124db6ee9afd47f00b93c73..f7eab6ce015da54cbca1727732be8d795ac7268a 100644 (file)
@@ -22,6 +22,12 @@ define binary_link_template
 $(1): $(2) ;
        @echo Linking $$@
        @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+
+clean::
+       @rm -f $(1)
+
+binaries:: $(1)
+
 endef
 
 # Link a host-machine binary
@@ -30,6 +36,12 @@ define host_binary_link_template
 $(1): $(2) ;
        @echo Linking $$@
        @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
+
+clean::
+       rm -f $(1)
+
+binaries:: $(1)
+
 endef
 
 # Create a prototype header
@@ -92,7 +104,7 @@ PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT)
 uninstallplugins::
        @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
 installplugins::
-       @ln -fs $(1) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
+       @ln -fs $(notdir $(1)) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
 
 endef
 
@@ -106,3 +118,24 @@ uninstallplugins::
        @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
 
 endef
+
+# abspath for older makes
+abspath = $(shell cd $(dir $(1)); pwd)/$(notdir $(1))
+
+# Install a binary
+# Arguments: path to binary to install
+define binary_install_template
+installbin:: $$(DESTDIR)$$(bindir)/$(notdir $(1)) installdirs
+
+uninstallbin::
+       @echo "Removing $(notdir $(1))"
+       @rm -f $$(DESTDIR)$$(bindir)/$(notdir $(1))
+endef
+
+define sbinary_install_template
+installsbin:: $$(DESTDIR)$$(sbindir)/$(notdir $(1)) installdirs
+
+uninstallsbin::
+       @echo "Removing $(notdir $(1))"
+       @rm -f $$(DESTDIR)$$(sbindir)/$(notdir $(1))
+endef