Use more make constructions for shared library bits.
authorJelmer Vernooij <jelmer@samba.org>
Mon, 25 Feb 2008 21:10:59 +0000 (22:10 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Mon, 25 Feb 2008 21:10:59 +0000 (22:10 +0100)
(This used to be commit b2cd934d4d37516fe65a3b9c44d7c92622fecf99)

source4/build/smb_build/makefile.pm
source4/rules.mk

index e4ce48ee68a60c9f85c212d606e786feb71ff17a..bc1c9970da1a46c8c896ef5b4fa683b5b6662819 100644 (file)
@@ -204,7 +204,6 @@ sub SharedLibrary($$)
        $self->_prepare_list($ctx, "LINK_FLAGS");
 
        $self->output(<< "__EOD__"
-
 $ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
        \@echo Linking \$\@
        \@mkdir -p \$(\@D)
@@ -212,14 +211,14 @@ $ctx->{RESULT_SHARED_LIBRARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL
                \$($ctx->{NAME}\_FULL_OBJ_LIST) \\
                \$($ctx->{NAME}_LINK_FLAGS) \\
                \$(if \$(SONAMEFLAG), \$(SONAMEFLAG)$ctx->{LIBRARY_SONAME})
+ifneq ($ctx->{LIBRARY_REALNAME}, $ctx->{LIBRARY_SONAME})
+       \@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}
+endif
+ifdef $ctx->{NAME}_SOVERSION
+       \@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}
+endif
 __EOD__
 );
-       if ($ctx->{LIBRARY_REALNAME} ne $ctx->{LIBRARY_SONAME}) {
-               $self->output("\t\@test \$($ctx->{NAME}_VERSION) = \$($ctx->{NAME}_SOVERSION) || ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_SONAME}\n");
-       }
-       $self->output("ifdef $ctx->{NAME}_SOVERSION\n");
-       $self->output("\t\@ln -fs $ctx->{LIBRARY_REALNAME} $ctx->{SHAREDDIR}/$ctx->{LIBRARY_DEBUGNAME}\n");
-       $self->output("endif\n");
 }
 
 sub MergedObj($$)
@@ -285,25 +284,10 @@ sub Binary($$)
        $self->_prepare_list($ctx, "DEPEND_LIST");
        $self->_prepare_list($ctx, "LINK_FLAGS");
 
-$self->output(<< "__EOD__"
-$ctx->{RESULT_BINARY}: \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST)
-       \@echo Linking \$\@
-__EOD__
-       );
-
        if (defined($ctx->{USE_HOSTCC}) && $ctx->{USE_HOSTCC} eq "YES") {
-               $self->output(<< "__EOD__"
-       \@\$(HOSTLD) \$(HOSTLD_FLAGS) -L\${builddir}/bin/static -o \$\@ \$(INSTALL_LINK_FLAGS) \\
-               \$\($ctx->{NAME}_LINK_FLAGS)
-__EOD__
-               );
+$self->output("\$(call host_binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
        } else {
-               $self->output(<< "__EOD__"
-       \@\$(BNLD) \$(BNLD_FLAGS) \$(INTERN_LDFLAGS) -o \$\@ \$(INSTALL_LINK_FLAGS) \\
-               \$\($ctx->{NAME}_LINK_FLAGS) 
-
-__EOD__
-               );
+$self->output("\$(call binary_link_template, $ctx->{RESULT_BINARY}, \$($ctx->{NAME}_DEPEND_LIST) \$($ctx->{NAME}_FULL_OBJ_LIST), \$($ctx->{NAME}_LINK_FLAGS))\n");
        }
 }
 
@@ -355,9 +339,7 @@ sub ProtoHeader($$)
                $pub = "\$(addprefix $ctx->{BASEDIR}/, $ctx->{PUBLIC_PROTO_HEADER})";
        }
 
-       $self->output("$pub: $ctx->{MK_FILE} \$($ctx->{NAME}_OBJ_LIST:.o=.c) \$(srcdir)/script/mkproto.pl\n");
-       $self->output("\t\@echo \"Creating \$@\"\n");
-       $self->output("\t\@\$(PERL) \$(srcdir)/script/mkproto.pl --srcdir=\$(srcdir) --builddir=\$(builddir) --private=$priv --public=$pub \$($ctx->{NAME}_OBJ_LIST)\n\n");
+       $self->output("\$(call proto_header_template, $pub, $priv, \$($ctx->{NAME}_OBJ_LIST:.o=.c))\n");
 }
 
 sub write($$)
index 06f425df44350619a31ff8b9379400395cb904d2..d39910dafc609d42980a70f403a86b7459e8406c 100644 (file)
@@ -99,6 +99,30 @@ $(1): $(2)
        $(PARTLINK) -o $@ $^
 endef
 
+# Link a binary
+# Arguments: target file, depends, flags
+define binary_link_template
+$(1): $(2)
+       @echo Linking $@
+       @$(BNLD) $(BNLD_FLAGS) $(INTERN_LDFLAGS) -o $@ $(INSTALL_LINK_FLAGS) $(3)
+endef
+
+# Link a host-machine binary
+# Arguments: target file, depends, flags
+define host_binary_link_template
+$(1): $(2)
+       @echo Linking $@
+       @$(HOSTLD) $(HOSTLD_FLAGS) -L${builddir}/bin/static -o $@ $(INSTALL_LINK_FLAGS) $(3)
+endef
+
+# Create a prototype header
+# Arguments: proto header, private header, c files
+define proto_header_template
+$(1) $(2): $(3)
+       @echo "Creating $@"
+       @$(PERL) $(srcdir)/script/mkproto.pl --srcdir=$(srcdir) --builddir=$(builddir) --private=$(2) --public=$(1) $(3)
+endef
+
 ###############################################################################
 # File types
 ###############################################################################