Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-wsgi
[sfrench/samba-autobuild/.git] / source4 / build / make / templates.mk
1 # Templates file for Samba 4
2 # This relies on GNU make.
3 #
4 # © 2008 Jelmer Vernooij <jelmer@samba.org>
5 #
6 ###############################################################################
7 # Templates
8 ###############################################################################
9
10 # Partially link
11 # Arguments: target object file, source object files
12 define partial_link_template 
13 $(1): $(2) ;
14         @echo Partially linking $$@
15         @mkdir -p $$(@D)
16         $$(PARTLINK) -o $$@ $$^
17 endef
18
19 # Link a binary
20 # Arguments: target file, depends, flags
21 define binary_link_template
22 $(1): $(2) ;
23         @echo Linking $$@
24         @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
25 endef
26
27 # Link a host-machine binary
28 # Arguments: target file, depends, flags
29 define host_binary_link_template
30 $(1): $(2) ;
31         @echo Linking $$@
32         @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
33 endef
34
35 # Create a prototype header
36 # Arguments: header file, c files
37 define proto_header_template
38
39 proto:: $(1) ;
40
41 clean:: ;
42         rm -f $(1)
43
44 $(1): $(2) ;
45         @echo "Creating $$@"
46         @$$(PERL) $$(srcdir)/script/mkproto.pl --srcdir=$$(srcdir) --builddir=$$(builddir) --public=/dev/null --private=$$@ $$^
47
48 endef
49
50 # Shared module
51 # Arguments: Target, dependencies, objects
52 define shared_module_template
53
54 $(1): $(2) ;
55         @echo Linking $$@
56         @mkdir -p $$(@D)
57         @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
58
59 endef
60
61 # Shared library
62 # Arguments: Target, dependencies, link flags, soname
63 define shared_library_template
64 $(1): $(2)
65         @echo Linking $$@
66         @mkdir -p $$(@D)
67         @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \
68                 $(3) \
69                 $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4)))
70
71 ifneq ($(notdir $(1)),$(notdir $(4)))
72 $(4): $(1)
73         @echo "Creating symbolic link for $$@"
74         @ln -fs $$(<F) $$@
75 endif
76
77 ifneq ($(notdir $(1)),$(notdir $(5)))
78 $(5): $(1)
79         @echo "Creating symbolic link for $$@"
80         @ln -fs $$(<F) $$@
81 endif
82 endef
83
84 # Shared alias
85 # Arguments: Target, subsystem name, alias name
86 define shared_module_alias_template
87 bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1)
88         @ln -fs $$(<F) $$@
89
90 PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT)
91
92 uninstallplugins::
93         @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
94 installplugins::
95         @ln -fs $(notdir $(1)) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
96
97 endef
98
99 define shared_module_install_template
100 installplugins:: bin/modules/$(1)/$(2)
101         @echo Installing $(2) as $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
102         @mkdir -p $$(DESTDIR)$$(modulesdir)/$(1)/
103         @cp bin/modules/$(1)/$(2) $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
104 uninstallplugins::
105         @echo Uninstalling $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
106         @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
107
108 endef