Use make template for installing binaries.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 26 Jun 2008 09:39:59 +0000 (11:39 +0200)
committerJelmer Vernooij <jelmer@samba.org>
Thu, 26 Jun 2008 09:39:59 +0000 (11:39 +0200)
(This used to be commit 3fb35fc03d5cfb48d0d4f51564ef76e99e74f81c)

source4/Makefile
source4/build/make/rules.mk
source4/build/make/templates.mk
source4/build/smb_build/makefile.pm

index 8a8eef7b4d02f36bbd34a922f3b86a9bb9942cda..1a1a56fc63a1bdb1f8ebe99d07977a50208fdaa9 100644 (file)
@@ -106,8 +106,6 @@ ntp_signdsrcdir := ntp_signd
 
 include data.mk
 
-BINARIES += $(BIN_PROGS) $(SBIN_PROGS)
-
 pythonmods:: $(PYTHON_PYS) $(PYTHON_SO)
 
 DEP_FILES = $(patsubst %.ho,%.hd,$(patsubst %.o,%.d,$(ALL_OBJS))) \
@@ -136,7 +134,6 @@ endif
 DEFAULT_HEADERS = $(srcdir)/lib/util/dlinklist.h \
                  $(srcdir)/version.h
 
-binaries:: $(BINARIES)
 libraries:: $(STATIC_LIBS) $(SHARED_LIBS)
 modules:: $(PLUGINS)
 headers:: $(PUBLIC_HEADERS) $(DEFAULT_HEADERS)
@@ -213,20 +210,6 @@ installdirs::
                $(DESTDIR)$(sysconfdir) \
 
 installbin:: $(SBIN_PROGS) $(BIN_PROGS) $(TORTURE_PROGS) installdirs
-       @$(SHELL) $(srcdir)/script/installbin.sh \
-               $(INSTALLPERMS) \
-               $(DESTDIR)$(BASEDIR) \
-               $(DESTDIR)$(sbindir) \
-               $(DESTDIR)$(libdir) \
-               $(DESTDIR)$(localstatedir) \
-               $(SBIN_PROGS)
-       @$(SHELL) $(srcdir)/script/installbin.sh \
-               $(INSTALLPERMS) \
-               $(DESTDIR)$(BASEDIR) \
-               $(DESTDIR)$(bindir) \
-               $(DESTDIR)$(libdir) \
-               $(DESTDIR)$(localstatedir) \
-               $(BIN_PROGS)
        @$(SHELL) $(srcdir)/script/installtorture.sh \
                $(INSTALLPERMS) \
                $(DESTDIR)$(TORTUREDIR) \
index 27a214459a37f4f1884b6578327a1fbbf40ab9f1..f8df8f0b5353e3053f27b14323176a41d93b97e8 100644 (file)
@@ -43,8 +43,6 @@ clean:: clean_pch
        @-find . -name '*.o' -exec rm -f '{}' \;
        @echo Removing hostcc objects
        @-find . -name '*.ho' -exec rm -f '{}' \;
-       @echo Removing binaries
-       @-rm -f $(BIN_PROGS) $(SBIN_PROGS) $(BINARIES) $(TORTURE_PROGS)
        @echo Removing libraries
        @-rm -f $(STATIC_LIBS) $(SHARED_LIBS)
        @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
index 25bdde09b469a6eb7c53008a602c7a2551befc58..eb6b584af23eb87ccbe23b246d693982c755b0f2 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
@@ -109,3 +121,33 @@ endef
 
 # abspath for older makes
 abspath := $(shell cd $(1); pwd)
+
+define binary_install_template
+inst@allbin:: $(1) installdirs
+       @mkdir -p $$(DESTDIR)$$(bindir)
+       @$$(SHELL) $$(srcdir)/script/installbin.sh \
+               $$(INSTALLPERMS) \
+               $$(DESTDIR)$$(BASEDIR) \
+               $$(DESTDIR)$$(bindir) \
+               $$(DESTDIR)$$(libdir) \
+               $$(DESTDIR)$$(localstatedir) \
+               $$<
+                               
+uninstallbin::
+       @rm -f $$(DESTDIR)$$(bindir)/$(1)
+endef
+
+define sbinary_install_template
+installsbin:: $(1) installdirs
+       @mkdir -p $$(DESTDIR)$$(sbindir)
+       @$$(SHELL) $$(srcdir)/script/installbin.sh \
+               $$(INSTALLPERMS) \
+               $$(DESTDIR)$$(BASEDIR) \
+               $$(DESTDIR)$$(sbindir) \
+               $$(DESTDIR)$$(libdir) \
+               $$(DESTDIR)$$(localstatedir) \
+               $$<
+                               
+uninstallsbin::
+       @rm -f $$(DESTDIR)$$(sbindir)/$(1)
+endef
index 0ea31062f78b1bd6fc7ed4928fec2db7341f4e73..d9cbca061400fda1da25f8b6cd941c500efa966e 100644 (file)
@@ -196,11 +196,10 @@ sub Binary($$)
        my ($self,$ctx) = @_;
 
        unless (defined($ctx->{INSTALLDIR})) {
-               $self->output("BINARIES += $ctx->{TARGET_BINARY}\n");
        } elsif ($ctx->{INSTALLDIR} eq "SBINDIR") {
-               $self->output("SBIN_PROGS += $ctx->{RESULT_BINARY}\n");
+               $self->output("\$(eval \$(call sbinary_install_template,$ctx->{RESULT_BINARY}))\n");
        } elsif ($ctx->{INSTALLDIR} eq "BINDIR") {
-               $self->output("BIN_PROGS += $ctx->{RESULT_BINARY}\n");
+               $self->output("\$(eval \$(call binary_install_template,$ctx->{RESULT_BINARY}))\n");
        }
 
        $self->_prepare_list($ctx, "FULL_OBJ_LIST");
@@ -208,9 +207,9 @@ sub Binary($$)
        $self->_prepare_list($ctx, "LINK_FLAGS");
 
        if (defined($ctx->{USE_HOSTCC}) && $ctx->{USE_HOSTCC} eq "YES") {
-$self->output("\$(call host_binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_FULL_OBJ_LIST) \$($ctx->{NAME}_DEPEND_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
+$self->output("\$(eval \$(call host_binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_FULL_OBJ_LIST) \$($ctx->{NAME}_DEPEND_LIST), \$($ctx->{NAME}_LINK_FLAGS)))\n");
        } else {
-$self->output("\$(call binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_FULL_OBJ_LIST) \$($ctx->{NAME}_DEPEND_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
+$self->output("\$(eval \$(call binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_FULL_OBJ_LIST) \$($ctx->{NAME}_DEPEND_LIST), \$($ctx->{NAME}_LINK_FLAGS)))\n");
        }
 }