Fix missing symbols issues when building with shared libraries.
[Samba.git] / source3 / samba4.mk
blob3f4fff4d354a7c5d5ff2057f657993dad7fd29eb
1 # samba 4 bits
3 PROG_LD = $(LD)
4 BNLD = $(CC)
5 HOSTLD = $(CC)
6 PARTLINK = $(PROG_LD) -r
7 MDLD = $(SHLD)
8 MDLD_FLAGS = $(LDSHFLAGS)
10 samba4srcdir = $(srcdir)/../source4
12 # Flags used for the samba 4 files
13 # $(srcdir)/include is required for config.h
14 SAMBA4_CFLAGS = -I.. -I$(samba4srcdir) -I$(samba4srcdir)/include \
15 -I$(samba4srcdir)/../lib/replace -I$(samba4srcdir)/lib \
16 -I$(heimdalsrcdir)/lib/hcrypto -I$(tallocdir) \
17 -I$(srcdir)/include -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H
19 .SUFFIXES: .ho
21 # No cross compilation for now, thanks
22 .c.ho:
23 @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \
24 dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi
25 @if test -n "$(CC_CHECKER)"; then \
26 echo "Checking $*.c with '$(CC_CHECKER)'";\
27 $(CHECK_CC); \
29 @echo Compiling $*.c
30 @$(COMPILE) && exit 0;\
31 echo "The following command failed:" 1>&2;\
32 echo "$(subst ",\",$(COMPILE_CC))" 1>&2;\
33 $(COMPILE_CC) >/dev/null 2>&1
35 # The order really does matter here! GNU Make 3.80 will break if the more specific
36 # overrides are not specified first.
37 ifeq ($(MAKE_VERSION),3.81)
38 %.o: CFLAGS+=$(FLAGS)
39 ../librpc/gen_ndr/%_c.o: CFLAGS=$(SAMBA4_CFLAGS)
40 ../librpc/gen_ndr/py_%.o: CFLAGS=$(SAMBA4_CFLAGS)
41 $(samba4srcdir)/%.o: CFLAGS=$(SAMBA4_CFLAGS)
42 $(samba4srcdir)/%.ho: CFLAGS=$(SAMBA4_CFLAGS)
43 $(heimdalsrcdir)/%.o: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir)
44 $(heimdalsrcdir)/%.ho: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir)
45 else
46 $(heimdalsrcdir)/%.o: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir)
47 $(heimdalsrcdir)/%.ho: CFLAGS=-I$(heimdalbuildsrcdir) $(SAMBA4_CFLAGS) -I$(srcdir)
48 $(samba4srcdir)/%.o: CFLAGS=$(SAMBA4_CFLAGS)
49 $(samba4srcdir)/%.ho: CFLAGS=$(SAMBA4_CFLAGS)
50 ../librpc/gen_ndr/%_c.o: CFLAGS=$(SAMBA4_CFLAGS)
51 ../librpc/gen_ndr/py_%.o: CFLAGS=$(SAMBA4_CFLAGS)
52 %.o: CFLAGS+=$(FLAGS)
53 endif
55 # Create a static library
56 %.a:
57 @echo Linking $@
58 @rm -f $@
59 @mkdir -p $(@D)
60 @$(AR) -rc $@ $^
62 INTERN_LDFLAGS = -L${builddir}/bin/static -L${builddir}/bin/shared
64 pidldir = $(samba4srcdir)/../pidl
65 include $(pidldir)/config.mk
66 include samba4-config.mk
67 include samba4-templates.mk
69 zlibsrcdir := $(samba4srcdir)/../lib/zlib
70 dynconfigsrcdir := $(samba4srcdir)/dynconfig
71 heimdalsrcdir := $(samba4srcdir)/heimdal
72 dsdbsrcdir := $(samba4srcdir)/dsdb
73 smbdsrcdir := $(samba4srcdir)/smbd
74 clustersrcdir := $(samba4srcdir)/cluster
75 libnetsrcdir := $(samba4srcdir)/libnet
76 authsrcdir := $(samba4srcdir)/auth
77 nsswitchsrcdir := $(samba4srcdir)/../nsswitch
78 libsrcdir := $(samba4srcdir)/lib
79 libsocketsrcdir := $(samba4srcdir)/lib/socket
80 libcharsetsrcdir := $(samba4srcdir)/../lib/util/charset
81 ldb_sambasrcdir := $(samba4srcdir)/lib/ldb-samba
82 libtlssrcdir := $(samba4srcdir)/lib/tls
83 libregistrysrcdir := $(samba4srcdir)/lib/registry
84 libmessagingsrcdir := $(samba4srcdir)/lib/messaging
85 libteventsrcdir := $(samba4srcdir)/../lib/tevent
86 libeventssrcdir := $(samba4srcdir)/lib/events
87 libcmdlinesrcdir := $(samba4srcdir)/lib/cmdline
88 poptsrcdir := $(samba4srcdir)/../lib/popt
89 socketwrappersrcdir := $(samba4srcdir)/../lib/socket_wrapper
90 nsswrappersrcdir := $(samba4srcdir)/../lib/nss_wrapper
91 libstreamsrcdir := $(samba4srcdir)/lib/stream
92 libutilsrcdir := $(samba4srcdir)/../lib/util
93 libtdrsrcdir := $(samba4srcdir)/lib/tdr
94 libdbwrapsrcdir := $(samba4srcdir)/lib/dbwrap
95 libcryptosrcdir := $(samba4srcdir)/../lib/crypto
96 libtorturesrcdir := ../lib/torture
97 libcompressionsrcdir := $(samba4srcdir)/../lib/compression
98 libgencachesrcdir := $(samba4srcdir)/lib
99 paramsrcdir := $(samba4srcdir)/param
100 smb_serversrcdir := $(samba4srcdir)/smb_server
101 rpc_serversrcdir := $(samba4srcdir)/rpc_server
102 ldap_serversrcdir := $(samba4srcdir)/ldap_server
103 web_serversrcdir := $(samba4srcdir)/web_server
104 winbindsrcdir := $(samba4srcdir)/winbind
105 nbt_serversrcdir := $(samba4srcdir)/nbt_server
106 wrepl_serversrcdir := $(samba4srcdir)/wrepl_server
107 cldap_serversrcdir := $(samba4srcdir)/cldap_server
108 librpcsrcdir := $(samba4srcdir)/librpc
109 torturesrcdir := $(samba4srcdir)/torture
110 utilssrcdir := $(samba4srcdir)/utils
111 ntvfssrcdir := $(samba4srcdir)/ntvfs
112 ntptrsrcdir := $(samba4srcdir)/ntptr
113 clientsrcdir := $(samba4srcdir)/client
114 libclisrcdir := $(samba4srcdir)/libcli
115 libclinbtsrcdir := $(samba4srcdir)/../libcli/nbt
116 pyscriptsrcdir := $(samba4srcdir)/scripting/python
117 kdcsrcdir := $(samba4srcdir)/kdc
118 smbreadlinesrcdir := $(samba4srcdir)/lib/smbreadline
119 ntp_signdsrcdir := $(samba4srcdir)/ntp_signd
120 tdbsrcdir := $(samba4srcdir)/../lib/tdb
121 ldbsrcdir := $(samba4srcdir)/lib/ldb
122 tallocsrcdir := $(samba4srcdir)/../lib/talloc
123 comsrcdir := $(samba4srcdir)/lib/com
124 override ASN1C = bin/asn1_compile4
125 override ET_COMPILER = bin/compile_et4
126 include $(samba4srcdir)/build/make/python.mk
127 include samba4-data.mk
128 include $(samba4srcdir)/static_deps.mk
130 INSTALLPERMS = 0755
131 $(foreach SCRIPT,$(wildcard scripting/bin/*),$(eval $(call binary_install_template,$(SCRIPT))))
133 $(DESTDIR)$(bindir)/%4: bin/%4 installdirs
134 @mkdir -p $(@D)
135 @echo Installing $(@F) as $@
136 @if test -f $@; then rm -f $@.old; mv $@ $@.old; fi
137 @cp $< $@
138 @chmod $(INSTALLPERMS) $@
140 $(DESTDIR)$(sbindir)/%4: bin/%4 installdirs
141 @mkdir -p $(@D)
142 @echo Installing $(@F) as $@
143 @if test -f $@; then rm -f $@.old; mv $@ $@.old; fi
144 @cp $< $@
145 @chmod $(INSTALLPERMS) $@
147 clean::
148 @echo Removing samba 4 objects
149 @-find $(samba4srcdir) -name '*.o' -exec rm -f '{}' \;
150 @echo Removing samba 4 hostcc objects
151 @-find $(samba4srcdir) -name '*.ho' -exec rm -f '{}' \;
152 @echo Removing samba 4 libraries
153 @-rm -f $(STATIC_LIBS) $(SHARED_LIBS)
154 @-rm -f bin/static/*.a bin/shared/*.$(SHLIBEXT) bin/mergedobj/*.o
155 @echo Removing samba 4 modules
156 @-rm -f bin/modules/*/*.$(SHLIBEXT)
157 @-rm -f bin/*_init_module.c
158 @echo Removing samba 4 dummy targets
159 @-rm -f bin/.*_*
160 @echo Removing samba 4 generated files
161 @-rm -f bin/*_init_module.c
162 @-rm -rf $(samba4srcdir)/librpc/gen_*
164 proto:: $(PROTO_HEADERS)
165 modules:: $(PLUGINS)
167 pythonmods:: $(PYTHON_PYS) $(PYTHON_SO)
169 all:: bin/samba4 bin/regpatch4 bin/regdiff4 bin/regshell4 bin/regtree4 bin/smbclient4 bin/wbinfo4 pythonmods setup plugins
170 torture:: bin/smbtorture4
171 everything:: $(patsubst %,%4,$(BINARIES))
172 setup:
173 @ln -sf ../source4/setup setup
175 SELFTEST4 = $(LD_LIBPATH_OVERRIDE) $(PERL) $(selftestdir)/selftest.pl --prefix=st4 \
176 --builddir=$(builddir) --srcdir=$(samba4srcdir) \
177 --expected-failures=$(samba4srcdir)/selftest/knownfail \
178 --format=$(SELFTEST_FORMAT) \
179 --exclude=$(samba4srcdir)/selftest/skip --testlist="$(samba4srcdir)/selftest/tests.sh|" \
180 $(TEST4_OPTIONS)
182 SELFTEST4_NOSLOW_OPTS = --exclude=$(samba4srcdir)/selftest/slow
183 SELFTEST4_QUICK_OPTS = $(SELFTEST4_NOSLOW_OPTS) --quick --include=$(samba4srcdir)/selftest/quick
185 slowtest4:: everything
186 $(SELFTEST4) $(DEFAULT_TEST_OPTIONS) --immediate $(TESTS)
188 test4:: everything
189 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) $(DEFAULT_TEST_OPTIONS) --immediate \
190 $(TESTS)
192 testone4:: everything
193 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) $(DEFAULT_TEST_OPTIONS) --one $(TESTS)
195 test4-swrap:: everything
196 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --immediate $(TESTS)
198 test4-swrap-pcap:: everything
199 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper-pcap --immediate $(TESTS)
201 test4-swrap-keep-pcap:: everything
202 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper-keep-pcap --immediate $(TESTS)
204 test4-noswrap:: everything
205 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --immediate $(TESTS)
207 quicktest4:: all
208 $(SELFTEST4) $(SELFTEST4_QUICK_OPTS) --socket-wrapper --immediate $(TESTS)
210 quicktestone4:: all
211 $(SELFTEST4) $(SELFTEST4_QUICK_OPTS) --socket-wrapper --one $(TESTS)
213 testenv4:: everything
214 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
216 testenv4-%:: everything
217 SELFTEST_TESTENV=$* $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
219 test4-%::
220 $(MAKE) test TESTS=$*
222 valgrindtest4:: valgrindtest-all
224 valgrindtest4-quick:: all
225 SMBD_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
226 VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
227 $(SELFTEST4) $(SELFTEST4_QUICK_OPTS) --immediate --socket-wrapper $(TESTS)
229 valgrindtest4-all:: everything
230 SMBD_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
231 VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
232 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS)
234 valgrindtest4-env:: everything
235 SMBD_VALGRIND="xterm -n server -e $(selftestdir)/valgrind_run $(LD_LIBPATH_OVERRIDE)" \
236 VALGRIND="valgrind -q --num-callers=30 --log-file=${selftest_prefix}/valgrind.log" \
237 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
239 gdbtest4:: gdbtest4-all
241 gdbtest4-quick:: all
242 SMBD_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
243 $(SELFTEST4) $(SELFTEST4_QUICK_OPTS) --immediate --socket-wrapper $(TESTS)
245 gdbtest4-all:: everything
246 SMBD_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
247 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --immediate --socket-wrapper $(TESTS)
249 gdbtest4-env:: everything
250 SMBD_VALGRIND="xterm -n server -e $(selftestdir)/gdb_run $(LD_LIBPATH_OVERRIDE)" \
251 $(SELFTEST4) $(SELFTEST4_NOSLOW_OPTS) --socket-wrapper --testenv
253 plugins: $(PLUGINS)