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 12define partial_link_template 13$(1): $(2) ; 14 @echo Partially linking $$@ 15 @mkdir -p $$(@D) 16 @$$(PARTLINK) -o $$@ $$^ 17endef 18 19# Link a binary 20# Arguments: target file, depends, flags 21define binary_link_template 22$(1)4: $(2) ; 23 @echo Linking $$@ 24 @$$(BNLD) $$(BNLD_FLAGS) $$(INTERN_LDFLAGS) -o $$@ $$(INSTALL_LINK_FLAGS) $(3) $$(LIBS) 25clean:: 26 @rm -f $(1) 27 28everything:: $(1)4 29 30endef 31 32# Link a host-machine binary 33# Arguments: target file, depends, flags 34define 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 39clean:: 40 rm -f $(1) 41 42binaries:: $(1)4 43 44 45endef 46 47# Create a prototype header 48# Arguments: header file, c files 49define proto_header_template 50echo:: ; 51 echo $(1) ; 52 53proto:: $(1) ; 54 55clean:: ; 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=$$@ $$^ 61endef 62 63# Shared module 64# Arguments: Target, dependencies, objects 65define 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 72PLUGINS += $(1) 73 74endef 75 76# Shared library 77# Arguments: Target, dependencies, link flags, soname 78define 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 86ifneq ($(notdir $(1)),$(notdir $(4))) 87$(4): $(1) 88 @echo "Creating symbolic link for $$@" 89 @ln -fs $$(<F) $$@ 90endif 91 92ifneq ($(notdir $(1)),$(notdir $(5))) 93$(5): $(1) $(4) 94 @echo "Creating symbolic link for $$@" 95 @ln -fs $$(<F) $$@ 96endif 97endef 98 99# Shared alias 100# Arguments: Target, subsystem name, alias name 101define shared_module_alias_template 102bin/modules/$(2)/$(3).$$(SHLIBEXT): $(1) 103 @ln -fs $$(<F) $$@ 104 105PLUGINS += bin/modules/$(2)/$(3).$$(SHLIBEXT) 106 107uninstallplugins:: 108 @-rm $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT) 109installplugins:: 110 @ln -fs $(1) $$(DESTDIR)$$(modulesdir)/$(2)/$(3).$$(SHLIBEXT) 111 112endef 113 114define shared_module_install_template 115installplugins:: 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) 119uninstallplugins:: 120 @echo Uninstalling $$(DESTDIR)$$(modulesdir)/$(1)/$(2) 121 @-rm $$(DESTDIR)$$(modulesdir)/$(1)/$(2) 122 123endef 124 125# abspath for older makes 126abspath = $(shell cd $(dir $(1)); pwd)/$(notdir $(1)) 127 128# Install a binary 129# Arguments: path to binary to install 130define binary_install_template 131installbin:: $$(DESTDIR)$$(bindir)/$(notdir $(1))4 132 133uninstallbin:: 134 @echo "Removing $(notdir $(1))4" 135 @rm -f $$(DESTDIR)$$(bindir)/$(1)4 136endef 137 138define sbinary_install_template 139installsbin:: $$(DESTDIR)$$(sbindir)/$(notdir $(1))4 installdirs 140 141uninstallsbin:: 142 @echo "Removing $(notdir $(1))4" 143 @rm -f $$(DESTDIR)$$(sbindir)/$(1)4 144endef 145