tail: with -f, use polling when a file is on an FS of unknown type
[coreutils.git] / src / Makefile.am
blobc12b9d986f220dfa47e5ff618619123c575cb1c7
1 ## Process this file with automake to produce Makefile.in -*-Makefile-*-
3 ## Copyright (C) 1990-1991, 1993-2011 Free Software Foundation, Inc.
5 ## This program is free software: you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, either version 3 of the License, or
8 ## (at your option) any later version.
9 ##
10 ## This program is distributed in the hope that it will be useful,
11 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 ## GNU General Public License for more details.
15 ## You should have received a copy of the GNU General Public License
16 ## along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 # These are the names of programs that are not installed by default.
19 # This list is *not* intended for programs like who, nice, chroot, etc.,
20 # that are built only when certain requisite system features are detected.
21 # Hence, if you want to install programs from this list anyway, say A and B,
22 # use --enable-install-program=A,B
23 no_install__progs = \
24   arch hostname su
26 build_if_possible__progs = \
27   chroot        \
28   df            \
29   hostid        \
30   libstdbuf.so  \
31   nice          \
32   pinky         \
33   stdbuf        \
34   stty          \
35   su            \
36   uptime        \
37   users         \
38   who
40 AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
42 EXTRA_PROGRAMS = \
43   $(no_install__progs) \
44   $(build_if_possible__progs) \
45   [             \
46   base64        \
47   basename      \
48   cat           \
49   chcon         \
50   chgrp         \
51   chmod         \
52   chown         \
53   cksum         \
54   comm          \
55   cp            \
56   csplit        \
57   cut           \
58   date          \
59   dd            \
60   dir           \
61   dircolors     \
62   dirname       \
63   du            \
64   echo          \
65   env           \
66   expand        \
67   expr          \
68   factor        \
69   false         \
70   fmt           \
71   fold          \
72   ginstall      \
73   groups        \
74   head          \
75   id            \
76   join          \
77   kill          \
78   link          \
79   ln            \
80   logname       \
81   ls            \
82   md5sum        \
83   mkdir         \
84   mkfifo        \
85   mknod         \
86   mktemp        \
87   mv            \
88   nl            \
89   nproc         \
90   nohup         \
91   od            \
92   paste         \
93   pathchk       \
94   pr            \
95   printenv      \
96   printf        \
97   ptx           \
98   pwd           \
99   readlink      \
100   rm            \
101   rmdir         \
102   runcon        \
103   seq           \
104   sha1sum       \
105   sha224sum     \
106   sha256sum     \
107   sha384sum     \
108   sha512sum     \
109   shred         \
110   shuf          \
111   sleep         \
112   sort          \
113   split         \
114   stat          \
115   sum           \
116   sync          \
117   tac           \
118   tail          \
119   tee           \
120   test          \
121   timeout       \
122   touch         \
123   tr            \
124   true          \
125   truncate      \
126   tsort         \
127   tty           \
128   uname         \
129   unexpand      \
130   uniq          \
131   unlink        \
132   vdir          \
133   wc            \
134   whoami        \
135   yes
137 bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
139 noinst_PROGRAMS = setuidgid getlimits
141 pkglibexec_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
143 noinst_HEADERS =        \
144   chown-core.h          \
145   copy.h                \
146   cp-hash.h             \
147   dircolors.h           \
148   fiemap.h              \
149   find-mount-point.h    \
150   fs.h                  \
151   fs-is-local.h         \
152   group-list.h          \
153   ioblksize.h           \
154   ls.h                  \
155   operand2sig.h         \
156   prog-fprintf.h        \
157   remove.h              \
158   system.h              \
159   wheel-size.h          \
160   wheel.h               \
161   uname.h
163 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
164   wheel-gen.pl extract-magic c99-to-c89.diff
165 BUILT_SOURCES =
166 CLEANFILES = $(SCRIPTS) su
168 # Also remove these sometimes-built programs.
169 # For example, even when excluded, they're built via _sc_check-AUTHORS.
170 CLEANFILES += $(no_install__progs)
172 AM_CPPFLAGS = -I$(top_srcdir)/lib
174 noinst_LIBRARIES = libver.a
175 nodist_libver_a_SOURCES = version.c version.h
177 # Tell the linker to omit references to unused shared libraries.
178 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
180 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
181 # include modules defining variables like `optind', so libcoreutils.a
182 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
183 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
184 # replacement functions defined in libcoreutils.a.
185 LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
187 # First, list all programs, to make listing per-program libraries easier.
188 # See [ below.
189 arch_LDADD = $(LDADD)
190 base64_LDADD = $(LDADD)
191 basename_LDADD = $(LDADD)
192 cat_LDADD = $(LDADD)
193 chcon_LDADD = $(LDADD)
194 chgrp_LDADD = $(LDADD)
195 chmod_LDADD = $(LDADD)
196 chown_LDADD = $(LDADD)
197 chroot_LDADD = $(LDADD)
198 cksum_LDADD = $(LDADD)
199 comm_LDADD = $(LDADD)
200 nproc_LDADD = $(LDADD)
201 cp_LDADD = $(LDADD)
202 csplit_LDADD = $(LDADD)
203 cut_LDADD = $(LDADD)
204 date_LDADD = $(LDADD)
205 dd_LDADD = $(LDADD)
206 df_LDADD = $(LDADD)
207 # See dir_LDADD below
208 dircolors_LDADD = $(LDADD)
209 dirname_LDADD = $(LDADD)
210 du_LDADD = $(LDADD)
211 echo_LDADD = $(LDADD)
212 env_LDADD = $(LDADD)
213 expand_LDADD = $(LDADD)
214 expr_LDADD = $(LDADD)
215 factor_LDADD = $(LDADD)
216 false_LDADD = $(LDADD)
217 fmt_LDADD = $(LDADD)
218 fold_LDADD = $(LDADD)
219 getlimits_LDADD = $(LDADD)
220 ginstall_LDADD = $(LDADD)
221 groups_LDADD = $(LDADD)
222 head_LDADD = $(LDADD)
223 hostid_LDADD = $(LDADD)
224 hostname_LDADD = $(LDADD)
225 id_LDADD = $(LDADD)
226 join_LDADD = $(LDADD)
227 kill_LDADD = $(LDADD)
228 link_LDADD = $(LDADD)
229 ln_LDADD = $(LDADD)
230 logname_LDADD = $(LDADD)
231 ls_LDADD = $(LDADD)
232 md5sum_LDADD = $(LDADD)
233 mkdir_LDADD = $(LDADD)
234 mkfifo_LDADD = $(LDADD)
235 mknod_LDADD = $(LDADD)
236 mktemp_LDADD = $(LDADD)
237 mv_LDADD = $(LDADD)
238 nice_LDADD = $(LDADD)
239 nl_LDADD = $(LDADD)
240 nohup_LDADD = $(LDADD)
241 od_LDADD = $(LDADD)
242 paste_LDADD = $(LDADD)
243 pathchk_LDADD = $(LDADD)
244 pinky_LDADD = $(LDADD)
245 pr_LDADD = $(LDADD)
246 printenv_LDADD = $(LDADD)
247 printf_LDADD = $(LDADD)
248 ptx_LDADD = $(LDADD)
249 pwd_LDADD = $(LDADD)
250 readlink_LDADD = $(LDADD)
251 rm_LDADD = $(LDADD)
252 rmdir_LDADD = $(LDADD)
253 runcon_LDADD = $(LDADD)
254 seq_LDADD = $(LDADD)
255 setuidgid_LDADD = $(LDADD)
256 sha1sum_LDADD = $(LDADD)
257 sha224sum_LDADD = $(LDADD)
258 sha256sum_LDADD = $(LDADD)
259 sha384sum_LDADD = $(LDADD)
260 sha512sum_LDADD = $(LDADD)
261 shred_LDADD = $(LDADD)
262 shuf_LDADD = $(LDADD)
263 sleep_LDADD = $(LDADD)
264 sort_LDADD = $(LDADD)
265 split_LDADD = $(LDADD)
266 stat_LDADD = $(LDADD)
267 stdbuf_LDADD = $(LDADD)
268 stty_LDADD = $(LDADD)
269 su_LDADD = $(LDADD)
270 sum_LDADD = $(LDADD)
271 sync_LDADD = $(LDADD)
272 tac_LDADD = $(LDADD)
273 tail_LDADD = $(LDADD)
274 tee_LDADD = $(LDADD)
275 test_LDADD = $(LDADD)
276 timeout_LDADD = $(LDADD)
277 touch_LDADD = $(LDADD)
278 tr_LDADD = $(LDADD)
279 true_LDADD = $(LDADD)
280 truncate_LDADD = $(LDADD)
281 tsort_LDADD = $(LDADD)
282 tty_LDADD = $(LDADD)
283 uname_LDADD = $(LDADD)
284 unexpand_LDADD = $(LDADD)
285 uniq_LDADD = $(LDADD)
286 unlink_LDADD = $(LDADD)
287 uptime_LDADD = $(LDADD)
288 users_LDADD = $(LDADD)
289 # See vdir_LDADD below
290 wc_LDADD = $(LDADD)
291 who_LDADD = $(LDADD)
292 whoami_LDADD = $(LDADD)
293 yes_LDADD = $(LDADD)
295 # Synonyms.  Recall that Automake transliterates '[' to '_'.
296 __LDADD = $(test_LDADD)
297 dir_LDADD = $(ls_LDADD)
298 vdir_LDADD = $(ls_LDADD)
300 # Shared files
301 copy_LDADD =
302 cp_LDADD += $(copy_LDADD)
303 ginstall_LDADD += $(copy_LDADD)
304 mv_LDADD += $(copy_LDADD)
306 remove_LDADD =
307 mv_LDADD += $(remove_LDADD)
308 rm_LDADD += $(remove_LDADD)
310 # for eaccess, euidaccess
311 copy_LDADD += $(LIB_EACCESS)
312 remove_LDADD += $(LIB_EACCESS)
313 test_LDADD += $(LIB_EACCESS)
315 # for selinux use
316 chcon_LDADD += $(LIB_SELINUX)
317 copy_LDADD += $(LIB_SELINUX)
318 ginstall_LDADD += $(LIB_SELINUX)
319 id_LDADD += $(LIB_SELINUX)
320 ls_LDADD += $(LIB_SELINUX)
321 mkdir_LDADD += $(LIB_SELINUX)
322 mkfifo_LDADD += $(LIB_SELINUX)
323 mknod_LDADD += $(LIB_SELINUX)
324 runcon_LDADD += $(LIB_SELINUX)
325 stat_LDADD += $(LIB_SELINUX)
327 # for gettime, settime, utimecmp, utimens
328 copy_LDADD += $(LIB_CLOCK_GETTIME)
329 date_LDADD += $(LIB_CLOCK_GETTIME)
330 ginstall_LDADD += $(LIB_CLOCK_GETTIME)
331 ls_LDADD += $(LIB_CLOCK_GETTIME)
332 pr_LDADD += $(LIB_CLOCK_GETTIME)
333 timeout_LDADD += $(LIB_TIMER_TIME)
334 touch_LDADD += $(LIB_CLOCK_GETTIME)
336 # for gethrxtime
337 dd_LDADD += $(LIB_GETHRXTIME)
339 # for cap_get_file
340 ls_LDADD += $(LIB_CAP)
342 # for fdatasync
343 dd_LDADD += $(LIB_FDATASYNC)
344 shred_LDADD += $(LIB_FDATASYNC)
346 # for xnanosleep
347 sleep_LDADD += $(LIB_NANOSLEEP)
348 sort_LDADD += $(LIB_NANOSLEEP)
349 tail_LDADD += $(LIB_NANOSLEEP)
351 # for various GMP functions
352 expr_LDADD += $(LIB_GMP)
353 factor_LDADD += $(LIB_GMP)
355 # for getloadavg
356 uptime_LDADD += $(GETLOADAVG_LIBS)
358 # for crypt
359 su_LDADD += $(LIB_CRYPT)
361 # for various ACL functions
362 copy_LDADD += $(LIB_ACL)
363 ls_LDADD += $(LIB_ACL)
365 # for various xattr functions
366 copy_LDADD += $(LIB_XATTR)
368 # for print_unicode_char, proper_name_utf8
369 cat_LDADD += $(LIBICONV)
370 cp_LDADD += $(LIBICONV)
371 df_LDADD += $(LIBICONV)
372 du_LDADD += $(LIBICONV)
373 getlimits_LDADD += $(LIBICONV)
374 printf_LDADD += $(LIBICONV)
375 ptx_LDADD += $(LIBICONV)
376 split_LDADD += $(LIBICONV)
377 stdbuf_LDADD += $(LIBICONV)
378 timeout_LDADD += $(LIBICONV)
379 truncate_LDADD += $(LIBICONV)
381 # for canon_host
382 pinky_LDADD += $(GETADDRINFO_LIB)
383 who_LDADD += $(GETADDRINFO_LIB)
385 # for gethostname, uname
386 hostname_LDADD += $(GETHOSTNAME_LIB)
387 uname_LDADD += $(GETHOSTNAME_LIB)
389 # for strsignal
390 kill_LDADD += $(LIBTHREAD)
392 # for pthread
393 sort_LDADD += $(LIB_PTHREAD)
395 $(PROGRAMS): ../lib/libcoreutils.a
397 # Get the release year from ../lib/version-etc.c.
398 RELEASE_YEAR = \
399   `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
400     $(top_srcdir)/lib/version-etc.c`
402 all-local: su$(EXEEXT)
404 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
406 setuid_root_mode = a=rx,u+s
408 install_su =                                            \
409   if test "$(INSTALL_SU)" = yes; then                   \
410     p=su;                                               \
411     echo " $(INSTALL_PROGRAM) $$p $(installed_su)";     \
412     $(INSTALL_PROGRAM) $$p $(installed_su);             \
413     echo " chown root $(installed_su)";                 \
414     chown root $(installed_su);                         \
415     echo " chmod $(setuid_root_mode) $(installed_su)";  \
416     chmod $(setuid_root_mode) $(installed_su);          \
417   else                                                  \
418     :;                                                  \
419   fi
421 install-root: su$(EXEEXT)
422         @$(install_su)
424 install-exec-hook: su$(EXEEXT)
425         @if test "$(INSTALL_SU)" = yes; then                    \
426           TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$;                 \
427           rm -f $$TMPFILE;                                      \
428           echo > $$TMPFILE;                                     \
429 ## See if we can create a setuid root executable in $(bindir).
430 ## If not, then don't even try to install su.
431           can_create_suid_root_executable=no;                   \
432           chown root $$TMPFILE > /dev/null 2>&1                 \
433             && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
434             && can_create_suid_root_executable=yes;             \
435           rm -f $$TMPFILE;                                      \
436           if test $$can_create_suid_root_executable = yes; then \
437             $(install_su);                                      \
438           else                                                  \
439             echo "WARNING: insufficient access; not installing su"; \
440             echo "NOTE: to install su, run 'make install-root' as root"; \
441             rm -f $(installed_su);                              \
442           fi;                                                   \
443         else :;                                                 \
444         fi
446 uninstall-local:
447 # Remove su only if it's one we installed.
448         @if test "$(INSTALL_SU)" = yes; then                    \
449           if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
450             echo "  rm -f $(installed_su)"; \
451             rm -f $(installed_su); \
452           else :; \
453           fi; \
454         fi
456 copy_sources = copy.c cp-hash.c extent-scan.c extent-scan.h
458 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
459 # confusion with the `install' target.  The install rule transforms `ginstall'
460 # to install before applying any user-specified name transformations.
462 transform = s/ginstall/install/; $(program_transform_name)
463 ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
465 # This is for the '[' program.  Automake transliterates '[' to '_'.
466 __SOURCES = lbracket.c
468 cp_SOURCES = cp.c $(copy_sources)
469 dir_SOURCES = ls.c ls-dir.c
470 vdir_SOURCES = ls.c ls-vdir.c
471 id_SOURCES = id.c group-list.c
472 groups_SOURCES = groups.c group-list.c
473 ln_SOURCES = ln.c
474 ls_SOURCES = ls.c ls-ls.c
475 chown_SOURCES = chown.c chown-core.c
476 chgrp_SOURCES = chgrp.c chown-core.c
477 kill_SOURCES = kill.c operand2sig.c
478 timeout_SOURCES = timeout.c operand2sig.c
480 mv_SOURCES = mv.c remove.c $(copy_sources)
481 rm_SOURCES = rm.c remove.c
483 mkdir_SOURCES = mkdir.c prog-fprintf.c
484 rmdir_SOURCES = rmdir.c prog-fprintf.c
486 df_SOURCES = df.c find-mount-point.c
487 stat_SOURCES = stat.c find-mount-point.c
489 uname_SOURCES = uname.c uname-uname.c
490 arch_SOURCES = uname.c uname-arch.c
491 nproc_SOURCES = nproc.c
493 md5sum_SOURCES = md5sum.c
494 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
495 sha1sum_SOURCES = md5sum.c
496 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
497 sha224sum_SOURCES = md5sum.c
498 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
499 sha256sum_SOURCES = md5sum.c
500 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
501 sha384sum_SOURCES = md5sum.c
502 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
503 sha512sum_SOURCES = md5sum.c
504 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
506 ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
508 # Ensure we don't link against libcoreutils.a as that lib is
509 # not compiled with -fPIC which causes issues on 64 bit at least
510 libstdbuf_so_LDADD =
512 # Note libstdbuf is only compiled if GCC is available
513 # (as per the check in configure.ac), so these flags should be available.
514 # libtool is probably required to relax this dependency.
515 libstdbuf_so_LDFLAGS = -shared
516 libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS)
518 editpl = sed -e 's,@''PERL''@,$(PERL),g'
520 BUILT_SOURCES += dircolors.h
521 dircolors.h: dcgen dircolors.hin
522         $(AM_V_GEN)rm -f $@ $@-t
523         $(AM_V_at)$(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
524         $(AM_V_at)chmod a-w $@-t
525         $(AM_V_at)mv $@-t $@
527 wheel_size = 5
529 BUILT_SOURCES += wheel-size.h
530 wheel-size.h: Makefile.am
531         $(AM_V_GEN)rm -f $@ $@-t
532         $(AM_V_at)echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
533         $(AM_V_at)chmod a-w $@-t
534         $(AM_V_at)mv $@-t $@
536 BUILT_SOURCES += wheel.h
537 wheel.h: wheel-gen.pl Makefile.am
538         $(AM_V_GEN)rm -f $@ $@-t
539         $(AM_V_at)$(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
540         $(AM_V_at)chmod a-w $@-t
541         $(AM_V_at)mv $@-t $@
543 # false exits nonzero even with --help or --version.
544 # test doesn't support --help or --version.
545 # Tell automake to exempt then from that installcheck test.
546 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
548 # Compare fs.h with the list of file system names/magic-numbers in the
549 # Linux statfs man page.  This target prints any new name/number pairs.
550 # Also compare against /usr/include/linux/magic.h
551 .PHONY: fs-magic-compare
552 fs-magic-compare: fs-magic fs-kernel-magic fs-def
553         join -v1 -t@ fs-magic fs-def
554         join -v1 -t@ fs-kernel-magic fs-def
556 CLEANFILES += fs-def
557 fs-def: fs.h
558         grep '^# *define ' $< | $(ASSORT) > $@-t && mv $@-t $@
560 # Massage bits of the statfs man page and definitions from
561 # /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
562 fs_normalize_perl_subst =                       \
563   -e 's/MINIX_SUPER_MAGIC\b/MINIX/;'            \
564   -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;'        \
565   -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;'        \
566   -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;'    \
567   -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;'        \
568   -e 's/CIFS_MAGIC_NUMBER/CIFS/;'               \
569   -e 's/(_SUPER)?_MAGIC//;'                     \
570   -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;'           \
571   -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;'           \
572   -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;'          \
573   -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;'           \
574   -e 's/^\s+//;'                                \
575   -e 's/^\043define\s+//;'                      \
576   -e 's/^_(XIAFS)/$$1/;'                        \
577   -e 's/^USBDEVICE/USBDEVFS/;'                  \
578   -e 's/NTFS_SB/NTFS/;'                         \
579   -e 's/^/\043 define S_MAGIC_/;'               \
580   -e 's,\s*/\* .*? \*/,,;'
582 CLEANFILES += fs-magic
583 fs-magic: Makefile
584         man statfs \
585           |perl -ne '/File system types:/.../Nobody kno/ and print'     \
586           |grep 0x | perl -p                                            \
587             $(fs_normalize_perl_subst)                                  \
588           | grep -Ev 'S_MAGIC_EXT[34]|STACK_END'                        \
589           | LC_ALL=C sort                                               \
590           > $@-t && mv $@-t $@
592 CLEANFILES += fs-kernel-magic
593 fs-kernel-magic: Makefile
594         perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h  \
595           | perl -p                                                     \
596             $(fs_normalize_perl_subst)                                  \
597           | grep -Ev 'S_MAGIC_EXT[34]|STACK_END'                        \
598           | LC_ALL=C sort                                               \
599           > $@-t && mv $@-t $@
601 BUILT_SOURCES += fs-is-local.h
602 fs-is-local.h: stat.c extract-magic
603         $(AM_V_GEN)rm -f $@
604         $(AM_V_at)$(PERL) $(srcdir)/extract-magic --local $(srcdir)/stat.c \
605           > $@t
606         $(AM_V_at)chmod a-w $@t
607         $(AM_V_at)mv $@t $@
609 BUILT_SOURCES += fs.h
610 fs.h: stat.c extract-magic
611         $(AM_V_GEN)rm -f $@
612         $(AM_V_at)$(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
613         $(AM_V_at)chmod a-w $@t
614         $(AM_V_at)mv $@t $@
616 BUILT_SOURCES += version.c
617 version.c: Makefile
618         $(AM_V_GEN)rm -f $@
619         $(AM_V_at)printf '#include <config.h>\n' > $@t
620         $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
621         $(AM_V_at)chmod a-w $@t
622         $(AM_V_at)mv $@t $@
624 BUILT_SOURCES += version.h
625 version.h: Makefile
626         $(AM_V_GEN)rm -f $@
627         $(AM_V_at)printf 'extern char const *Version;\n' > $@t
628         $(AM_V_at)chmod a-w $@t
629         $(AM_V_at)mv $@t $@
631 DISTCLEANFILES = version.c version.h
632 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
634 # Sort in traditional ASCII order, regardless of the current locale;
635 # otherwise we may get into trouble with distinct strings that the
636 # current locale considers to be equal.
637 ASSORT = LC_ALL=C sort
639 all_programs = \
640     $(bin_PROGRAMS) \
641     $(bin_SCRIPTS) \
642   $(EXTRA_PROGRAMS)
644 built_programs.list:
645         @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
646           | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
648 all_programs.list:
649         @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
650           | sed /libstdbuf/d \
651           | $(ASSORT) -u
653 # This is required because we have broken inter-directory dependencies:
654 # in order to generate all man pages, even those for which we don't
655 # install a binary, require that all programs be built at distribution time.
656 dist-hook: $(all_programs)
658 # Ensure that all programs are built so we can for example
659 # subsequently syntax check all man pages.
660 .PHONY: all_programs
661 all_programs: $(all_programs)
663 pm = progs-makefile
664 pr = progs-readme
665 # Ensure that the list of programs in README matches the list
666 # of programs we can build.
667 check: check-README check-duplicate-no-install
668 .PHONY: check-README
669 check-README:
670         $(AM_V_GEN)rm -rf $(pr) $(pm)
671         $(AM_V_at)echo $(all_programs) \
672          | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
673          | sed /libstdbuf/d \
674          | $(ASSORT) -u > $(pm) && \
675         sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
676           | sed -n '/^   */s///p' | tr -s ' ' '\n' > $(pr)
677         $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm)
679 # Ensure that a by-default-not-installed program (listed in
680 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
681 # if that were to happen, it *would* be installed by default.
682 .PHONY: check-duplicate-no-install
683 check-duplicate-no-install: tr
684         $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
686 # Ensure that the list of programs and author names is accurate.
687 # We need a UTF8 locale.  If a lack of locale support or a missing
688 # translation inhibits printing of UTF-8 names, just skip this test.
689 au_dotdot = authors-dotdot
690 au_actual = authors-actual
691 .PHONY: _sc_check-AUTHORS
692 _sc_check-AUTHORS: $(all_programs)
693         @locale=en_US.UTF-8;                            \
694         LC_ALL=$$locale ./cat --version                 \
695             | grep ' Torbjorn ' > /dev/null             \
696           && { echo "$@: skipping this check"; exit 0; }; \
697         rm -f $(au_actual) $(au_dotdot);                \
698         for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
699             | sed /libstdbuf/d                          \
700             | $(ASSORT) -u`; do                         \
701           test "$$i" = '[' && continue;                 \
702           exe=$$i;                                      \
703           if test "$$i" = install; then                 \
704             exe=ginstall;                               \
705           elif test "$$i" = test; then                  \
706             exe='[';                                    \
707           fi;                                           \
708           LC_ALL=$$locale ./$$exe --version             \
709             | perl -0 -pi -e 's/,\n/, /gm'              \
710             | sed -n -e '/Written by /{ s//'"$$i"': /;' \
711                   -e 's/,* and /, /; s/\.$$//; p; }';   \
712         done > $(au_actual) &&                          \
713         sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot) && \
714         diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
716 # Use the just-built ./ginstall, when not cross-compiling.
717 if CROSS_COMPILING
718 cu_install_program = @INSTALL_PROGRAM@
719 else
720 cu_install_program = ./ginstall
721 endif
722 INSTALL_PROGRAM = $(cu_install_program)