Use new Samba 4 source location.
[kai/samba-autobuild/.git] / source3 / samba4-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)4: $(2) $(LIBREPLACE_OBJ) ;
23         @echo Linking $$@
24         @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)  $$(LIBS) $$(LIBREPLACE_OBJ)
25 clean::
26         @rm -f $(1)
27
28 binaries:: $(1)
29
30
31 endef
32
33 # Link a host-machine binary
34 # Arguments: target file, depends, flags
35 define host_binary_link_template
36 $(1)4: $(2) $(LIBREPLACE_OBJ) ;
37         @echo Linking $$@
38         @$$(HOSTLD) $$(HOSTLD_FLAGS) -L$${builddir}/bin/static -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBREPLACE_OBJ)
39
40 clean::
41         rm -f $(1)
42
43 binaries:: $(1)
44
45
46 endef
47
48 # Create a prototype header
49 # Arguments: header file, c files
50 define proto_header_template
51 echo:: ;
52         echo $(1) ;
53
54 proto:: $(1) ;
55
56 clean:: ;
57         rm -f $(1) ;
58
59 $(1): $(2) ;
60         @echo "Creating $$@"
61         @$$(PERL) $$(srcdir)/../source4/script/mkproto.pl --srcdir=$$(srcdir)/../source4 --builddir=$$(builddir)/../source4 --public=/dev/null --private=$$@ $$^
62 endef
63
64 # Shared module
65 # Arguments: Target, dependencies, objects
66 define shared_module_template
67
68 $(1): $(2) ;
69         @echo Linking $$@
70         @mkdir -p $$(@D)
71         @$$(MDLD) $$(LDFLAGS) $$(MDLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3)
72
73 PLUGINS += $(1)
74
75 endef
76
77 # Shared library
78 # Arguments: Target, dependencies, link flags, soname
79 define shared_library_template
80 $(1): $(2)
81         @echo Linking $$@
82         @mkdir -p $$(@D)
83         @$$(SHLD) $$(LDFLAGS) $$(SHLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) \
84                 $(3) \
85                 $$(if $$(SONAMEFLAG), $$(SONAMEFLAG)$(notdir $(4))) $$(LIBS)
86
87 ifneq ($(notdir $(1)),$(notdir $(4)))
88 $(4): $(1)
89         @echo "Creating symbolic link for $$@"
90         @ln -fs $$(<F) $$@
91 endif
92
93 ifneq ($(notdir $(1)),$(notdir $(5)))
94 $(5): $(1)
95         @echo "Creating symbolic link for $$@"
96         @ln -fs $$(<F) $$@
97 endif
98 endef
99
100 # Shared alias
101 # Arguments: Target, subsystem name, alias name
102 define shared_module_alias_template
103 bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1)
104         @ln -fs $$(<F) $$@
105
106 PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT)
107
108 uninstallplugins::
109         @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
110 installplugins::
111         @ln -fs $(1) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT)
112
113 endef
114
115 define shared_module_install_template
116 installplugins:: bin/modules/$(1)/$(2)
117         @echo Installing $(2) as $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
118         @mkdir -p $$(DESTDIR)$$(modulesdir)/$(1)/
119         @cp bin/modules/$(1)/$(2) $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
120 uninstallplugins::
121         @echo Uninstalling $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
122         @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2)
123
124 endef
125
126 # abspath for older makes
127 abspath = $(shell cd $(dir $(1)); pwd)/$(notdir $(1))
128
129 # Install a binary
130 # Arguments: path to binary to install
131 define binary_install_template
132 installbin:: $$(DESTDIR)$$(bindir)/$(notdir $(1))4
133
134 uninstallbin::
135         @echo "Removing $(notdir $(1))4"
136         @rm -f $$(DESTDIR)$$(bindir)/$(1)4
137 endef
138
139 define sbinary_install_template
140 installsbin:: $$(DESTDIR)$$(sbindir)/$(notdir $(1))4 installdirs
141                                 
142 uninstallsbin::
143         @echo "Removing $(notdir $(1))4"
144         @rm -f $$(DESTDIR)$$(sbindir)/$(1)4
145 endef