[Samba] Patch for relocatable installs

William R. Knox
Wed, 19 Mar 2003 15:28:58 -0000

I remember seeing a patch here a long while back that I thought was going
to be committed for making the install relocatable (i.e. allowing for a
DESTDIR to be specified during a "make install"). I can't find it,
and I'm
not sure I am remembering correctly, anyway, so here is a shot at it.
Tested both the install and uninstall, run as "make install
DESTDIR=/new/top/level". I find the ability to do this invaluable for
creating packages, so would love to see it in any new versions (I didn't
check HEAD - maybe it's already there, so this would only apply to users
of 2.2.X). Have fun with it. Any bugs, while my fault, are not my problem.
;-)

			Bill Knox
			Senior Operating Systems Programmer/Analyst
			The MITRE Corporation

--- Makefile	Mon Mar 17 10:45:27 2003
+++ Makefile.old	Mon Mar 17 10:45:27 2003
@@ -4,8 +4,6 @@
 # Copyright Andrew Tridgell 1992-1998
 ###########################################################################

-DESTDIR-
 prefix=/usr/local
 exec_prefix=${prefix}
 mandir=${prefix}/man
@@ -704,29 +702,29 @@
 install: installbin installman installscripts installcp installswat

 installdirs:
-	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(DESTDIR)/$(BASEDIR)
-	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(DESTDIR)/$(SBINDIR)
-	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(DESTDIR)/$(BINDIR)
-	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(DESTDIR)/$(LIBDIR)
-	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(DESTDIR)/$(VARDIR)
-	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(DESTDIR)/$(PIDDIR)
-	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(DESTDIR)/$(CODEPAGEDIR)
+	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(BASEDIR)
+	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(SBINDIR)
+	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(BINDIR)
+	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(LIBDIR)
+	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(VARDIR)
+	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(PIDDIR)
+	$(SHELL) $(srcdir)/install-sh -d -m $(INSTALLPERMS) $(CODEPAGEDIR)

 installservers: all installdirs
-	@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)/$(BASEDIR)
$(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(LIBDIR) $(DESTDIR)/$(VARDIR) $(SPROGS)
+	@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR)
$(LIBDIR) $(VARDIR) $(SPROGS)

 installbin: all installdirs
-	@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)/$(BASEDIR)
$(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(LIBDIR) $(DESTDIR)/$(VARDIR) $(SPROGS)
$(WINBIND_SPROGS)
-	@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(DESTDIR)/$(BASEDIR)
$(DESTDIR)/$(BINDIR) $(DESTDIR)/$(LIBDIR) $(DESTDIR)/$(VARDIR) $(PROGS)
$(WINBIND_PROGS)
+	@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(SBINDIR)
$(LIBDIR) $(VARDIR) $(SPROGS) $(WINBIND_SPROGS)
+	@$(SHELL) $(srcdir)/script/installbin.sh $(INSTALLPERMS) $(BASEDIR) $(BINDIR)
$(LIBDIR) $(VARDIR) $(PROGS) $(WINBIND_PROGS)

 installscripts: installdirs
-	@$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS)
$(DESTDIR)/$(BINDIR) $(SCRIPTS)
+	@$(SHELL) $(srcdir)/script/installscripts.sh $(INSTALLPERMS) $(BINDIR)
$(SCRIPTS)

 installcp: installdirs installbin
-	@$(SHELL) $(srcdir)/script/installcp.sh $(srcdir) $(DESTDIR)/$(LIBDIR)
$(DESTDIR)/$(CODEPAGEDIR) $(DESTDIR)/$(BINDIR) $(CODEPAGELIST)
+	@$(SHELL) $(srcdir)/script/installcp.sh $(srcdir) $(LIBDIR) $(CODEPAGEDIR)
$(BINDIR) $(CODEPAGELIST)

 installswat: installdirs
-	@$(SHELL) $(srcdir)/script/installswat.sh $(DESTDIR)/$(SWATDIR) $(srcdir)
+	@$(SHELL) $(srcdir)/script/installswat.sh $(SWATDIR) $(srcdir)

 installclientlib:
 	-$(INSTALLCLIENTCMD_SH) bin/libsmbclient.so
@@ -736,26 +734,26 @@

 # revert to the previously installed version
 revert:
-	@$(SHELL) $(srcdir)/script/revert.sh $(DESTDIR)/$(SBINDIR) $(SPROGS)
${WINBIND_SPROGS}
-	@$(SHELL) $(srcdir)/script/revert.sh $(DESTDIR)/$(BINDIR) $(PROGS) $(SCRIPTS)
${WINBIND_PROGS}
+	@$(SHELL) $(srcdir)/script/revert.sh $(SBINDIR) $(SPROGS) ${WINBIND_SPROGS}
+	@$(SHELL) $(srcdir)/script/revert.sh $(BINDIR) $(PROGS) $(SCRIPTS)
${WINBIND_PROGS}

 installman:
-	@$(SHELL) $(srcdir)/script/installman.sh $(DESTDIR)/$(MANDIR) $(srcdir)
""
+	@$(SHELL) $(srcdir)/script/installman.sh $(MANDIR) $(srcdir) ""

 uninstall: uninstallman uninstallbin uninstallscripts uninstallcp

 uninstallman:
-	@$(SHELL) $(srcdir)/script/uninstallman.sh $(DESTDIR)/$(MANDIR) $(srcdir)
+	@$(SHELL) $(srcdir)/script/uninstallman.sh $(MANDIR) $(srcdir)

 uninstallbin:
-	@$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS)
$(DESTDIR)/$(BASEDIR) $(DESTDIR)/$(SBINDIR) $(DESTDIR)/$(LIBDIR)
$(DESTDIR)/$(VARDIR) $(SPROGS) $(WINBIND_SPROGS)
-	@$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS)
$(DESTDIR)/$(BASEDIR) $(DESTDIR)/$(BINDIR) $(DESTDIR)/$(LIBDIR)
$(DESTDIR)/$(VARDIR) $(PROGS) $(WINBIND_PROGS)
+	@$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(BASEDIR)
$(SBINDIR) $(LIBDIR) $(VARDIR) $(SPROGS) $(WINBIND_SPROGS)
+	@$(SHELL) $(srcdir)/script/uninstallbin.sh $(INSTALLPERMS) $(BASEDIR)
$(BINDIR) $(LIBDIR) $(VARDIR) $(PROGS) $(WINBIND_PROGS)

 uninstallscripts:
-	@$(SHELL) $(srcdir)/script/uninstallscripts.sh $(INSTALLPERMS)
$(DESTDIR)/$(BINDIR) $(SCRIPTS)
+	@$(SHELL) $(srcdir)/script/uninstallscripts.sh $(INSTALLPERMS) $(BINDIR)
$(SCRIPTS)

 uninstallcp:
-	@$(SHELL) $(srcdir)/script/uninstallcp.sh $(DESTDIR)/$(CODEPAGEDIR)
$(CODEPAGELIST)
+	@$(SHELL) $(srcdir)/script/uninstallcp.sh $(CODEPAGEDIR) $(CODEPAGELIST)

 clean:
 	-rm -f core */*~ *~ */*.o */*.po */*.po32 */*.so* */*.a