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