Put git version in a file for between-release versioning.
[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
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 version.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         util.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         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 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 options.o: latest-year.h help-rsync.h help-rsyncd.h git-version.h
103 exclude.o: default-cvsignore.h
104 loadparm.o: default-dont-compress.h daemon-parm.h
105
106 flist.o: rounding.h
107
108 default-cvsignore.h default-dont-compress.h: rsync.1.md define-from-md.awk
109         $(AWK) -f $(srcdir)/define-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md
110
111 help-rsync.h help-rsyncd.h: rsync.1.md help-from-md.awk
112         $(AWK) -f $(srcdir)/help-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md
113
114 daemon-parm.h: daemon-parm.txt daemon-parm.awk
115         $(AWK) -f $(srcdir)/daemon-parm.awk $(srcdir)/daemon-parm.txt
116
117 rounding.h: rounding.c rsync.h proto.h
118         @for r in 0 1 3; do \
119             if $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o rounding -DEXTRA_ROUNDING=$$r -I. $(srcdir)/rounding.c >rounding.out 2>&1; then \
120                 echo "#define EXTRA_ROUNDING $$r" >rounding.h; \
121                 if test -f "$$HOME/build_farm/build_test.fns"; then \
122                     echo "EXTRA_ROUNDING is $$r" >&2; \
123                 fi; \
124                 break; \
125             fi; \
126         done
127         @rm -f rounding
128         @if test -f rounding.h; then : ; else \
129             cat rounding.out 1>&2; \
130             echo "Failed to create rounding.h!" 1>&2; \
131             exit 1; \
132         fi
133         @rm -f rounding.out
134
135 # While $(wildcard ...) is a GNU make idiom, at least other makes should just turn it into an
136 # empty string (we need something that will vanish if we're not building a git checkout).
137 # If you want an updated git version w/o GNU make, remove git-version.h after a pull.
138 git-version.h: mkgitver $(wildcard $(srcdir)/.git/logs/HEAD)
139         $(srcdir)/mkgitver
140
141 simd-checksum-x86_64.o: simd-checksum-x86_64.cpp
142         @$(srcdir)/cmdormsg disable-simd $(CXX) -I. $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $(srcdir)/simd-checksum-x86_64.cpp
143
144 lib/md5-asm-x86_64.o: lib/md5-asm-x86_64.S config.h lib/md-defines.h
145         @$(srcdir)/cmdormsg disable-asm $(CC) -I. @NOEXECSTACK@ -c -o $@ $(srcdir)/lib/md5-asm-x86_64.S
146
147 tls$(EXEEXT): $(TLS_OBJ)
148         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TLS_OBJ) $(LIBS)
149
150 testrun$(EXEEXT): testrun.o
151         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ testrun.o
152
153 getgroups$(EXEEXT): getgroups.o
154         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ getgroups.o $(LIBS)
155
156 getfsdev$(EXEEXT): getfsdev.o
157         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ getfsdev.o $(LIBS)
158
159 TRIMSLASH_OBJ = trimslash.o syscall.o t_stub.o lib/compat.o lib/snprintf.o
160 trimslash$(EXEEXT): $(TRIMSLASH_OBJ)
161         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(TRIMSLASH_OBJ) $(LIBS)
162
163 T_UNSAFE_OBJ = t_unsafe.o syscall.o util.o util2.o t_stub.o lib/compat.o lib/snprintf.o lib/wildmatch.o
164 t_unsafe$(EXEEXT): $(T_UNSAFE_OBJ)
165         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(T_UNSAFE_OBJ) $(LIBS)
166
167 .PHONY: conf
168 conf: configure.sh config.h.in
169
170 .PHONY: gen
171 gen: conf proto.h man
172
173 .PHONY: gensend
174 gensend: gen
175         rsync -aic $(GENFILES) $${SAMBA_HOST-samba.org}:/home/ftp/pub/rsync/generated-files/
176
177 aclocal.m4: $(srcdir)/m4/*.m4
178         aclocal -I $(srcdir)/m4
179
180 configure.sh config.h.in: configure.ac aclocal.m4
181         @if test -f configure.sh; then cp -p configure.sh configure.sh.old; else touch configure.sh.old; fi
182         @if test -f config.h.in; then cp -p config.h.in config.h.in.old; else touch config.h.in.old; fi
183         autoconf -o configure.sh
184         autoheader && touch config.h.in
185         @if diff configure.sh configure.sh.old >/dev/null 2>&1; then \
186             echo "configure.sh is unchanged."; \
187             rm configure.sh.old; \
188         else \
189             echo "configure.sh has CHANGED."; \
190         fi
191         @if diff config.h.in config.h.in.old >/dev/null 2>&1; then \
192             echo "config.h.in is unchanged."; \
193             rm config.h.in.old; \
194         else \
195             echo "config.h.in has CHANGED."; \
196         fi
197         @if test -f configure.sh.old -o -f config.h.in.old; then \
198             if test "$(MAKECMDGOALS)" = reconfigure; then \
199                 echo 'Continuing with "make reconfigure".'; \
200             else \
201                 echo 'You may need to run:'; \
202                 echo '  make reconfigure'; \
203                 exit 1; \
204             fi \
205         fi
206
207 .PHONY: reconfigure
208 reconfigure: configure.sh
209         ./config.status --recheck
210         ./config.status
211
212 .PHONY: restatus
213 restatus:
214         ./config.status
215
216 Makefile: Makefile.in config.status configure.sh config.h.in
217         @if test -f Makefile; then cp -p Makefile Makefile.old; else touch Makefile.old; fi
218         @./config.status
219         @if diff Makefile Makefile.old >/dev/null 2>&1; then \
220             echo "Makefile is unchanged."; \
221             rm Makefile.old; \
222         else \
223             if test "$(MAKECMDGOALS)" = reconfigure; then \
224                 echo 'Continuing with "make reconfigure".'; \
225             else \
226                 echo "Makefile updated -- rerun your make command."; \
227                 exit 1; \
228             fi \
229         fi
230
231 stunnel-rsyncd.conf: $(srcdir)/stunnel-rsyncd.conf.in Makefile
232         sed 's;\@bindir\@;$(bindir);g' <$(srcdir)/stunnel-rsyncd.conf.in >stunnel-rsyncd.conf
233
234 .PHONY: proto
235 proto: proto.h-tstamp
236
237 proto.h: proto.h-tstamp
238         @if test -f proto.h; then :; else cp -p $(srcdir)/proto.h .; fi
239
240 proto.h-tstamp: $(srcdir)/*.c $(srcdir)/lib/compat.c daemon-parm.h
241         $(AWK) -f $(srcdir)/mkproto.awk $(srcdir)/*.c $(srcdir)/lib/compat.c daemon-parm.h
242
243 .PHONY: man
244 man: rsync.1 rsync-ssl.1 rsyncd.conf.5
245
246 rsync.1: rsync.1.md md2man version.h Makefile
247         @$(srcdir)/maybe-make-man $(srcdir) rsync.1.md
248
249 rsync-ssl.1: rsync-ssl.1.md md2man version.h Makefile
250         @$(srcdir)/maybe-make-man $(srcdir) rsync-ssl.1.md
251
252 rsyncd.conf.5: rsyncd.conf.5.md md2man version.h Makefile
253         @$(srcdir)/maybe-make-man $(srcdir) rsyncd.conf.5.md
254
255 .PHONY: clean
256 clean: cleantests
257         rm -f *~ $(OBJS) $(CHECK_PROGS) $(CHECK_OBJS) $(CHECK_SYMLINKS) \
258                 rounding rounding.h *.old rsync*.1 rsync*.5 rsync*.html \
259                 daemon-parm.h help-*.h default-*.h proto.h proto.h-tstamp
260
261 .PHONY: cleantests
262 cleantests:
263         rm -rf ./testtmp*
264
265 # We try to delete built files from both the source and build
266 # directories, just in case somebody previously configured things in
267 # the source directory.
268 .PHONY: distclean
269 distclean: clean
270         for dir in $(srcdir) . ; do \
271             (cd "$$dir" && rm -rf Makefile config.h config.status stunnel-rsyncd.conf \
272              lib/dummy popt/dummy zlib/dummy config.cache config.log shconfig \
273              $(GENFILES) autom4te.cache) ; \
274         done
275
276 # this target is really just for my use. It only works on a limited
277 # range of machines and is used to produce a list of potentially
278 # dead (ie. unused) functions in the code. (tridge)
279 .PHONY: finddead
280 finddead:
281         nm *.o */*.o |grep 'U ' | awk '{print $$2}' | sort -u > nmused.txt
282         nm *.o */*.o |grep 'T ' | awk '{print $$3}' | sort -u > nmfns.txt
283         comm -13 nmused.txt nmfns.txt
284         @rm nmused.txt nmfns.txt
285
286 # 'check' is the GNU name, 'test' is the name for everybody else :-)
287 .PHONY: test
288 test: check
289
290 # There seems to be no standard way to specify some variables as
291 # exported from a Makefile apart from listing them like this.
292
293 # This depends on building rsync; if we need any helper programs it
294 # should depend on them too.
295
296 # We try to run the scripts with POSIX mode on, in the hope that will
297 # catch Bash-isms earlier even if we're running on GNU.  Of course, we
298 # might lose in the future where POSIX diverges from old sh.
299
300 .PHONY: check
301 check: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
302         rsync_bin=`pwd`/rsync$(EXEEXT) $(srcdir)/runtests.sh
303
304 .PHONY: check29
305 check29: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
306         rsync_bin=`pwd`/rsync$(EXEEXT) $(srcdir)/runtests.sh --protocol=29
307
308 .PHONY: check30
309 check30: all $(CHECK_PROGS) $(CHECK_SYMLINKS)
310         rsync_bin=`pwd`/rsync$(EXEEXT) $(srcdir)/runtests.sh --protocol=30
311
312 wildtest.o: wildtest.c t_stub.o lib/wildmatch.c rsync.h config.h
313 wildtest$(EXEEXT): wildtest.o lib/compat.o lib/snprintf.o @BUILD_POPT@
314         $(CC) $(CFLAGS) $(LDFLAGS) -o $@ wildtest.o lib/compat.o lib/snprintf.o @BUILD_POPT@ $(LIBS)
315
316 testsuite/chown-fake.test:
317         ln -s chown.test $(srcdir)/testsuite/chown-fake.test
318
319 testsuite/devices-fake.test:
320         ln -s devices.test $(srcdir)/testsuite/devices-fake.test
321
322 testsuite/xattrs-hlink.test:
323         ln -s xattrs.test $(srcdir)/testsuite/xattrs-hlink.test
324
325 # This does *not* depend on building or installing: you can use it to
326 # check a version installed from a binary or some other source tree,
327 # if you want.
328
329 .PHONY: installcheck
330 installcheck: $(CHECK_PROGS) $(CHECK_SYMLINKS)
331         POSIXLY_CORRECT=1 TOOLDIR=`pwd` rsync_bin="$(bindir)/rsync$(EXEEXT)" srcdir="$(srcdir)" $(srcdir)/runtests.sh
332
333 # TODO: Add 'dist' target; need to know which files will be included
334
335 # Run the SPLINT (Secure Programming Lint) tool.  <www.splint.org>
336 .PHONY: splint
337 splint:
338         splint +unixlib +gnuextensions -weak rsync.c
339
340 .PHONY: doxygen
341 doxygen:
342         cd $(srcdir) && rm dox/html/* && doxygen
343
344 # for maintainers only
345 .PHONY: doxygen-upload
346 doxygen-upload:
347         rsync -avzv $(srcdir)/dox/html/ --delete \
348         $${SAMBA_HOST-samba.org}:/home/httpd/html/rsync/doxygen/head/