Add safety check for local --remove-source-files.
[rsync.git] / Makefile.in
1 # The Makefile for rsync (configure creates it from Makefile.in).
2
3 prefix=@prefix@
4 datarootdir=@datarootdir@
5 exec_prefix=@exec_prefix@
6 bindir=@bindir@
7 libdir=@libdir@/rsync
8 mandir=@mandir@
9 with_rrsync=@with_rrsync@
10
11 LIBS=@LIBS@
12 CC=@CC@
13 AWK=@AWK@
14 CFLAGS=@CFLAGS@
15 CPPFLAGS=@CPPFLAGS@
16 CXX=@CXX@
17 CXXFLAGS=@CXXFLAGS@
18 EXEEXT=@EXEEXT@
19 LDFLAGS=@LDFLAGS@
20 LIBOBJDIR=lib/
21
22 INSTALLCMD=@INSTALL@
23 INSTALLMAN=@INSTALL@
24
25 srcdir=@srcdir@
26 MKDIR_P=@MKDIR_P@
27 VPATH=$(srcdir)
28 SHELL=/bin/sh
29
30 .SUFFIXES:
31 .SUFFIXES: .c .o
32
33 ROLL_SIMD_x86_64=simd-checksum-x86_64.o
34 ROLL_ASM_x86_64=simd-checksum-avx2.o
35 MD5_ASM_x86_64=lib/md5-asm-x86_64.o
36
37 GENFILES=configure.sh aclocal.m4 config.h.in rsync.1 rsync.1.html \
38          rsync-ssl.1 rsync-ssl.1.html rsyncd.conf.5 rsyncd.conf.5.html \
39          @GEN_RRSYNC@
40 HEADERS=byteorder.h config.h errcode.h proto.h rsync.h ifuncs.h itypes.h inums.h \
41         lib/pool_alloc.h lib/mdigest.h lib/md-defines.h
42 LIBOBJ=lib/wildmatch.o lib/compat.o lib/snprintf.o lib/mdfour.o lib/md5.o \
43         lib/permstring.o lib/pool_alloc.o lib/sysacls.o lib/sysxattrs.o @LIBOBJS@
44 zlib_OBJS=zlib/deflate.o zlib/inffast.o zlib/inflate.o zlib/inftrees.o \
45         zlib/trees.o zlib/zutil.o zlib/adler32.o zlib/compress.o zlib/crc32.o
46 OBJS1=flist.o rsync.o generator.o receiver.o cleanup.o sender.o exclude.o \
47         util1.o util2.o main.o checksum.o match.o syscall.o log.o backup.o delete.o
48 OBJS2=options.o io.o compat.o hlink.o token.o uidlist.o socket.o hashtable.o \
49         usage.o fileio.o batch.o clientname.o chmod.o acls.o xattrs.o
50 OBJS3=progress.o pipe.o @MD5_ASM@ @ROLL_SIMD@ @ROLL_ASM@
51 DAEMON_OBJ = params.o loadparm.o clientserver.o access.o connection.o authenticate.o
52 popt_OBJS=popt/findme.o  popt/popt.o  popt/poptconfig.o \
53         popt/popthelp.o popt/poptparse.o
54 OBJS=$(OBJS1) $(OBJS2) $(OBJS3) $(DAEMON_OBJ) $(LIBOBJ) @BUILD_ZLIB@ @BUILD_POPT@
55
56 TLS_OBJ = tls.o syscall.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/permstring.o lib/sysxattrs.o @BUILD_POPT@
57
58 # Programs we must have to run the test cases
59 CHECK_PROGS = rsync$(EXEEXT) tls$(EXEEXT) getgroups$(EXEEXT) getfsdev$(EXEEXT) \
60         testrun$(EXEEXT) trimslash$(EXEEXT) t_unsafe$(EXEEXT) wildtest$(EXEEXT)
61
62 CHECK_SYMLINKS = testsuite/chown-fake.test testsuite/devices-fake.test testsuite/xattrs-hlink.test
63
64 # Objects for CHECK_PROGS to clean
65 CHECK_OBJS=tls.o testrun.o getgroups.o getfsdev.o t_stub.o t_unsafe.o trimslash.o wildtest.o
66
67 # note that the -I. is needed to handle config.h when using VPATH
68 .c.o:
69 @OBJ_SAVE@
70         $(CC) -I. -I$(srcdir) $(CFLAGS) $(CPPFLAGS) -c $< @CC_SHOBJ_FLAG@
71 @OBJ_RESTORE@
72
73 all: Makefile rsync$(EXEEXT) stunnel-rsyncd.conf @MAKE_RRSYNC@ @MAKE_MAN@
74 .PHONY: all
75
76 .PHONY: install
77 install: all
78         -$(MKDIR_P) $(DESTDIR)$(bindir)
79         $(INSTALLCMD) $(INSTALL_STRIP) -m 755 rsync$(EXEEXT) $(DESTDIR)$(bindir)
80         $(INSTALLCMD) -m 755 $(srcdir)/rsync-ssl $(DESTDIR)$(bindir)
81         -$(MKDIR_P) $(DESTDIR)$(mandir)/man1
82         -$(MKDIR_P) $(DESTDIR)$(mandir)/man5
83         if test -f rsync.1; then $(INSTALLMAN) -m 644 rsync.1 $(DESTDIR)$(mandir)/man1; fi
84         if test -f rsync-ssl.1; then $(INSTALLMAN) -m 644 rsync-ssl.1 $(DESTDIR)$(mandir)/man1; fi
85         if test -f rsyncd.conf.5; then $(INSTALLMAN) -m 644 rsyncd.conf.5 $(DESTDIR)$(mandir)/man5; fi
86         if test "$(with_rrsync)" = yes; then \
87             $(INSTALLCMD) -m 755 rrsync $(DESTDIR)$(bindir); \
88             if test -f rrsync.1; then $(INSTALLMAN) -m 644 rrsync.1 $(DESTDIR)$(mandir)/man1; fi; \
89         fi
90
91 install-ssl-daemon: stunnel-rsyncd.conf
92         -$(MKDIR_P) $(DESTDIR)/etc/stunnel
93         $(INSTALLCMD) -m 644 stunnel-rsyncd.conf $(DESTDIR)/etc/stunnel/rsyncd.conf
94         @if ! ls /etc/rsync-ssl/certs/server.* >/dev/null 2>/dev/null; then \
95             echo "Note that you'll need to install the certificate used by /etc/stunnel/rsyncd.conf"; \
96         fi
97
98 install-all: install install-ssl-daemon
99
100 install-strip:
101         $(MAKE) INSTALL_STRIP='-s' install
102
103 rsync$(EXEEXT): $(OBJS)
104         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $(LIBS)
105
106 rrsync: support/rrsync
107         cp -p $(srcdir)/support/rrsync rrsync
108
109 $(OBJS): $(HEADERS)
110 $(CHECK_OBJS): $(HEADERS)
111 tls.o xattrs.o: lib/sysxattrs.h
112 usage.o: version.h latest-year.h help-rsync.h help-rsyncd.h git-version.h default-cvsignore.h
113 loadparm.o: default-dont-compress.h daemon-parm.h
114
115 flist.o: rounding.h
116
117 default-cvsignore.h default-dont-compress.h: rsync.1.md define-from-md.awk
118         $(AWK) -f $(srcdir)/define-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md
119
120 help-rsync.h help-rsyncd.h: rsync.1.md help-from-md.awk
121         $(AWK) -f $(srcdir)/help-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md
122
123 daemon-parm.h: daemon-parm.txt daemon-parm.awk
124         $(AWK) -f $(srcdir)/daemon-parm.awk $(srcdir)/daemon-parm.txt
125
126 rounding.h: rounding.c rsync.h proto.h
127         @for r in 0 1 3; do \
128             if $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o rounding -DEXTRA_ROUNDING=$$r -I. $(srcdir)/rounding.c >rounding.out 2>&1; then \
129                 echo "#define EXTRA_ROUNDING $$r" >rounding.h; \
130                 if test -f "$$HOME/build_farm/build_test.fns"; then \
131                     echo "EXTRA_ROUNDING is $$r" >&2; \
132                 fi; \
133                 break; \
134             fi; \
135         done
136         @rm -f rounding
137         @if test -f rounding.h; then : ; else \
138             cat rounding.out 1>&2; \
139             echo "Failed to create rounding.h!" 1>&2; \
140             exit 1; \
141         fi
142         @rm -f rounding.out
143
144 git-version.h: ALWAYS_RUN
145         $(srcdir)/mkgitver
146
147 .PHONY: ALWAYS_RUN
148 ALWAYS_RUN:
149
150 simd-checksum-x86_64.o: simd-checksum-x86_64.cpp
151         @$(srcdir)/cmd-or-msg disable-roll-simd $(CXX) -I. $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/simd-checksum-x86_64.cpp
152
153 simd-checksum-avx2.o: simd-checksum-avx2.S
154         @$(srcdir)/cmd-or-msg disable-roll-asm $(CC) $(CFLAGS) -I. @NOEXECSTACK@ -c -o $@ $(srcdir)/simd-checksum-avx2.S
155
156 lib/md5-asm-x86_64.o: lib/md5-asm-x86_64.S lib/md-defines.h
157         @$(srcdir)/cmd-or-msg disable-md5-asm $(CC) -I. @NOEXECSTACK@ -c -o $@ $(srcdir)/lib/md5-asm-x86_64.S
158
159 tls$(EXEEXT): $(TLS_OBJ)
160         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TLS_OBJ) $(LIBS)
161
162 testrun$(EXEEXT): testrun.o
163         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ testrun.o
164
165 getgroups$(EXEEXT): getgroups.o
166         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ getgroups.o $(LIBS)
167
168 getfsdev$(EXEEXT): getfsdev.o
169         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ getfsdev.o $(LIBS)
170
171 TRIMSLASH_OBJ = trimslash.o syscall.o util2.o t_stub.o lib/compat.o lib/snprintf.o
172 trimslash$(EXEEXT): $(TRIMSLASH_OBJ)
173         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TRIMSLASH_OBJ) $(LIBS)
174
175 T_UNSAFE_OBJ = t_unsafe.o syscall.o util1.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/wildmatch.o
176 t_unsafe$(EXEEXT): $(T_UNSAFE_OBJ)
177         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(T_UNSAFE_OBJ) $(LIBS)
178
179 .PHONY: conf
180 conf: configure.sh config.h.in
181
182 .PHONY: gen
183 gen: conf proto.h man git-version.h
184
185 .PHONY: gensend
186 gensend: gen
187         if ! diff git-version.h $(srcdir)/gists/rsync-git-version.h >/dev/null; then \
188             ./rsync -ai git-version.h $(srcdir)/gists/rsync-git-version.h && \
189             (cd $(srcdir)/gists && git commit --allow-empty-message -m '' rsync-git-version.h && git push) ; \
190         fi
191         rsync -aic $(GENFILES) git-version.h $${SAMBA_HOST-samba.org}:/home/ftp/pub/rsync/generated-files/ || true
192
193 aclocal.m4: $(srcdir)/m4/*.m4
194         aclocal -I $(srcdir)/m4
195
196 configure.sh config.h.in: configure.ac aclocal.m4
197         @if test -f configure.sh; then cp -p configure.sh configure.sh.old; else touch configure.sh.old; fi
198         @if test -f config.h.in; then cp -p config.h.in config.h.in.old; else touch config.h.in.old; fi
199         autoconf -o configure.sh
200         autoheader && touch config.h.in
201         @if diff configure.sh configure.sh.old >/dev/null 2>&1; then \
202             echo "configure.sh is unchanged."; \
203             rm configure.sh.old; \
204         else \
205             echo "configure.sh has CHANGED."; \
206         fi
207         @if diff config.h.in config.h.in.old >/dev/null 2>&1; then \
208             echo "config.h.in is unchanged."; \
209             rm config.h.in.old; \
210         else \
211             echo "config.h.in has CHANGED."; \
212         fi
213         @if test -f configure.sh.old || test -f config.h.in.old; then \
214             if test "$(MAKECMDGOALS)" = reconfigure; then \
215                 echo 'Continuing with "make reconfigure".'; \
216             else \
217                 echo 'You may need to run:'; \
218                 echo '  make reconfigure'; \
219                 exit 1; \
220             fi \
221         fi
222
223 .PHONY: reconfigure
224 reconfigure: configure.sh
225         ./config.status --recheck
226         ./config.status
227
228 .PHONY: restatus
229 restatus:
230         ./config.status
231
232 Makefile: Makefile.in config.status configure.sh config.h.in
233         @if test -f Makefile; then cp -p Makefile Makefile.old; else touch Makefile.old; fi
234         @./config.status
235         @if diff Makefile Makefile.old >/dev/null 2>&1; then \
236             echo "Makefile is unchanged."; \
237             rm Makefile.old; \
238         else \
239             if test "$(MAKECMDGOALS)" = reconfigure; then \
240                 echo 'Continuing with "make reconfigure".'; \
241             else \
242                 echo "Makefile updated -- rerun your make command."; \
243                 exit 1; \
244             fi \
245         fi
246
247 stunnel-rsyncd.conf: $(srcdir)/stunnel-rsyncd.conf.in Makefile
248         sed 's;\@bindir\@;$(bindir);g' <$(srcdir)/stunnel-rsyncd.conf.in >stunnel-rsyncd.conf
249
250 .PHONY: proto
251 proto: proto.h-tstamp
252
253 proto.h: proto.h-tstamp
254         @if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi
255
256 proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c daemon-parm.h
257         $(AWK) -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c daemon-parm.h
258
259 .PHONY: man
260 man: rsync.1 rsync-ssl.1 rsyncd.conf.5 @MAKE_RRSYNC_1@
261
262 rsync.1: rsync.1.md md-convert version.h Makefile
263         @$(srcdir)/maybe-make-man rsync.1.md
264
265 rsync-ssl.1: rsync-ssl.1.md md-convert version.h Makefile
266         @$(srcdir)/maybe-make-man rsync-ssl.1.md
267
268 rsyncd.conf.5: rsyncd.conf.5.md md-convert version.h Makefile
269         @$(srcdir)/maybe-make-man rsyncd.conf.5.md
270
271 rrsync.1: support/rrsync.1.md md-convert Makefile
272         @$(srcdir)/maybe-make-man support/rrsync.1.md
273
274 .PHONY: clean
275 clean: cleantests
276         rm -f *~ $(OBJS) $(CHECK_PROGS) $(CHECK_OBJS) $(CHECK_SYMLINKS) @MAKE_RRSYNC@ \
277                 git-version.h rounding rounding.h *.old rsync*.1 rsync*.5 @MAKE_RRSYNC_1@ \
278                 *.html daemon-parm.h help-*.h default-*.h proto.h proto.h-tstamp
279
280 .PHONY: cleantests
281 cleantests:
282         rm -rf ./testtmp*
283
284 # We try to delete built files from both the source and build
285 # directories, just in case somebody previously configured things in
286 # the source directory.
287 .PHONY: distclean
288 distclean: clean
289         for dir in $(srcdir) . ; do \
290             (cd "$$dir" && rm -rf Makefile config.h config.status stunnel-rsyncd.conf \
291              lib/dummy popt/dummy zlib/dummy config.cache config.log shconfig \
292              $(GENFILES) autom4te.cache) ; \
293         done
294
295 # this target is really just for my use. It only works on a limited
296 # range of machines and is used to produce a list of potentially
297 # dead (ie. unused) functions in the code. (tridge)
298 .PHONY: finddead
299 finddead:
300         nm *.o */*.o |grep 'U ' | awk '{print $$2}' | sort -u > nmused.txt
301         nm *.o */*.o |grep 'T ' | awk '{print $$3}' | sort -u > nmfns.txt
302         comm -13 nmused.txt nmfns.txt
303         @rm nmused.txt nmfns.txt
304
305 # 'check' is the GNU name, 'test' is the name for everybody else :-)
306 .PHONY: test
307 test: check
308
309 # There seems to be no standard way to specify some variables as
310 # exported from a Makefile apart from listing them like this.
311
312 # This depends on building rsync; if we need any helper programs it
313 # should depend on them too.
314
315 # We try to run the scripts with POSIX mode on, in the hope that will
316 # catch Bash-isms earlier even if we're running on GNU.  Of course, we
317 # might lose in the future where POSIX diverges from old sh.
318
319 .PHONY: check
320 check: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
321         rsync_bin=`pwd`/rsync$(EXEEXT) $(srcdir)/runtests.sh
322
323 .PHONY: check29
324 check29: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
325         rsync_bin=`pwd`/rsync$(EXEEXT) $(srcdir)/runtests.sh --protocol=29
326
327 .PHONY: check30
328 check30: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
329         rsync_bin=`pwd`/rsync$(EXEEXT) $(srcdir)/runtests.sh --protocol=30
330
331 wildtest.o: wildtest.c t_stub.o lib/wildmatch.c rsync.h config.h
332 wildtest$(EXEEXT): wildtest.o lib/compat.o lib/snprintf.o @BUILD_POPT@
333         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ wildtest.o lib/compat.o lib/snprintf.o @BUILD_POPT@ $(LIBS)
334
335 testsuite/chown-fake.test:
336         ln -s chown.test $(srcdir)/testsuite/chown-fake.test
337
338 testsuite/devices-fake.test:
339         ln -s devices.test $(srcdir)/testsuite/devices-fake.test
340
341 testsuite/xattrs-hlink.test:
342         ln -s xattrs.test $(srcdir)/testsuite/xattrs-hlink.test
343
344 # This does *not* depend on building or installing: you can use it to
345 # check a version installed from a binary or some other source tree,
346 # if you want.
347
348 .PHONY: installcheck
349 installcheck: $(CHECK_PROGS) $(CHECK_SYMLINKS)
350         POSIXLY_CORRECT=1 TOOLDIR=`pwd` rsync_bin="$(bindir)/rsync$(EXEEXT)" srcdir="$(srcdir)" $(srcdir)/runtests.sh
351
352 # TODO: Add 'dist' target; need to know which files will be included
353
354 # Run the SPLINT (Secure Programming Lint) tool.  <www.splint.org>
355 .PHONY: splint
356 splint:
357         splint +unixlib +gnuextensions -weak rsync.c
358
359 .PHONY: doxygen
360 doxygen:
361         cd $(srcdir) && rm dox/html/* && doxygen
362
363 # for maintainers only
364 .PHONY: doxygen-upload
365 doxygen-upload:
366         rsync -avzv $(srcdir)/dox/html/ --delete \
367         $${SAMBA_HOST-samba.org}:/home/httpd/html/rsync/doxygen/head/