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