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