cp: fix the buffer size used when writing zeros
[coreutils/ericb.git] / src / Makefile.am
blobbf1d60a8869fc0ab99ef6fc58f1cd470ff3b912c
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 pkglib_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   group-list.h          \
152   ls.h                  \
153   operand2sig.h         \
154   prog-fprintf.h        \
155   remove.h              \
156   system.h              \
157   wheel-size.h          \
158   wheel.h               \
159   uname.h
161 EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
162   wheel-gen.pl extract-magic c99-to-c89.diff
163 BUILT_SOURCES =
164 CLEANFILES = $(SCRIPTS) su
166 # Also remove these sometimes-built programs.
167 # For example, even when excluded, they're built via sc_check-AUTHORS.
168 CLEANFILES += $(no_install__progs)
170 AM_CPPFLAGS = -I$(top_srcdir)/lib
172 noinst_LIBRARIES = libver.a
173 nodist_libver_a_SOURCES = version.c version.h
175 # Tell the linker to omit references to unused shared libraries.
176 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
178 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
179 # include modules defining variables like `optind', so libcoreutils.a
180 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
181 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
182 # replacement functions defined in libcoreutils.a.
183 LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
185 # First, list all programs, to make listing per-program libraries easier.
186 # See [ below.
187 arch_LDADD = $(LDADD)
188 base64_LDADD = $(LDADD)
189 basename_LDADD = $(LDADD)
190 cat_LDADD = $(LDADD)
191 chcon_LDADD = $(LDADD)
192 chgrp_LDADD = $(LDADD)
193 chmod_LDADD = $(LDADD)
194 chown_LDADD = $(LDADD)
195 chroot_LDADD = $(LDADD)
196 cksum_LDADD = $(LDADD)
197 comm_LDADD = $(LDADD)
198 nproc_LDADD = $(LDADD)
199 cp_LDADD = $(LDADD)
200 csplit_LDADD = $(LDADD)
201 cut_LDADD = $(LDADD)
202 date_LDADD = $(LDADD)
203 dd_LDADD = $(LDADD)
204 df_LDADD = $(LDADD)
205 # See dir_LDADD below
206 dircolors_LDADD = $(LDADD)
207 dirname_LDADD = $(LDADD)
208 du_LDADD = $(LDADD)
209 echo_LDADD = $(LDADD)
210 env_LDADD = $(LDADD)
211 expand_LDADD = $(LDADD)
212 expr_LDADD = $(LDADD)
213 factor_LDADD = $(LDADD)
214 false_LDADD = $(LDADD)
215 fmt_LDADD = $(LDADD)
216 fold_LDADD = $(LDADD)
217 getlimits_LDADD = $(LDADD)
218 ginstall_LDADD = $(LDADD)
219 groups_LDADD = $(LDADD)
220 head_LDADD = $(LDADD)
221 hostid_LDADD = $(LDADD)
222 hostname_LDADD = $(LDADD)
223 id_LDADD = $(LDADD)
224 join_LDADD = $(LDADD)
225 kill_LDADD = $(LDADD)
226 link_LDADD = $(LDADD)
227 ln_LDADD = $(LDADD)
228 logname_LDADD = $(LDADD)
229 ls_LDADD = $(LDADD)
230 md5sum_LDADD = $(LDADD)
231 mkdir_LDADD = $(LDADD)
232 mkfifo_LDADD = $(LDADD)
233 mknod_LDADD = $(LDADD)
234 mktemp_LDADD = $(LDADD)
235 mv_LDADD = $(LDADD)
236 nice_LDADD = $(LDADD)
237 nl_LDADD = $(LDADD)
238 nohup_LDADD = $(LDADD)
239 od_LDADD = $(LDADD)
240 paste_LDADD = $(LDADD)
241 pathchk_LDADD = $(LDADD)
242 pinky_LDADD = $(LDADD)
243 pr_LDADD = $(LDADD)
244 printenv_LDADD = $(LDADD)
245 printf_LDADD = $(LDADD)
246 ptx_LDADD = $(LDADD)
247 pwd_LDADD = $(LDADD)
248 readlink_LDADD = $(LDADD)
249 rm_LDADD = $(LDADD)
250 rmdir_LDADD = $(LDADD)
251 runcon_LDADD = $(LDADD)
252 seq_LDADD = $(LDADD)
253 setuidgid_LDADD = $(LDADD)
254 sha1sum_LDADD = $(LDADD)
255 sha224sum_LDADD = $(LDADD)
256 sha256sum_LDADD = $(LDADD)
257 sha384sum_LDADD = $(LDADD)
258 sha512sum_LDADD = $(LDADD)
259 shred_LDADD = $(LDADD)
260 shuf_LDADD = $(LDADD)
261 sleep_LDADD = $(LDADD)
262 sort_LDADD = $(LDADD)
263 split_LDADD = $(LDADD)
264 stat_LDADD = $(LDADD)
265 stdbuf_LDADD = $(LDADD)
266 stty_LDADD = $(LDADD)
267 su_LDADD = $(LDADD)
268 sum_LDADD = $(LDADD)
269 sync_LDADD = $(LDADD)
270 tac_LDADD = $(LDADD)
271 tail_LDADD = $(LDADD)
272 tee_LDADD = $(LDADD)
273 test_LDADD = $(LDADD)
274 timeout_LDADD = $(LDADD)
275 touch_LDADD = $(LDADD)
276 tr_LDADD = $(LDADD)
277 true_LDADD = $(LDADD)
278 truncate_LDADD = $(LDADD)
279 tsort_LDADD = $(LDADD)
280 tty_LDADD = $(LDADD)
281 uname_LDADD = $(LDADD)
282 unexpand_LDADD = $(LDADD)
283 uniq_LDADD = $(LDADD)
284 unlink_LDADD = $(LDADD)
285 uptime_LDADD = $(LDADD)
286 users_LDADD = $(LDADD)
287 # See vdir_LDADD below
288 wc_LDADD = $(LDADD)
289 who_LDADD = $(LDADD)
290 whoami_LDADD = $(LDADD)
291 yes_LDADD = $(LDADD)
293 # Synonyms.  Recall that Automake transliterates '[' to '_'.
294 __LDADD = $(test_LDADD)
295 dir_LDADD = $(ls_LDADD)
296 vdir_LDADD = $(ls_LDADD)
298 # Shared files
299 copy_LDADD =
300 cp_LDADD += $(copy_LDADD)
301 ginstall_LDADD += $(copy_LDADD)
302 mv_LDADD += $(copy_LDADD)
304 remove_LDADD =
305 mv_LDADD += $(remove_LDADD)
306 rm_LDADD += $(remove_LDADD)
308 # for eaccess, euidaccess
309 copy_LDADD += $(LIB_EACCESS)
310 remove_LDADD += $(LIB_EACCESS)
311 test_LDADD += $(LIB_EACCESS)
313 # for selinux use
314 chcon_LDADD += $(LIB_SELINUX)
315 copy_LDADD += $(LIB_SELINUX)
316 ginstall_LDADD += $(LIB_SELINUX)
317 id_LDADD += $(LIB_SELINUX)
318 ls_LDADD += $(LIB_SELINUX)
319 mkdir_LDADD += $(LIB_SELINUX)
320 mkfifo_LDADD += $(LIB_SELINUX)
321 mknod_LDADD += $(LIB_SELINUX)
322 runcon_LDADD += $(LIB_SELINUX)
323 stat_LDADD += $(LIB_SELINUX)
325 # for gettime, settime, utimecmp, utimens
326 copy_LDADD += $(LIB_CLOCK_GETTIME)
327 date_LDADD += $(LIB_CLOCK_GETTIME)
328 ginstall_LDADD += $(LIB_CLOCK_GETTIME)
329 ls_LDADD += $(LIB_CLOCK_GETTIME)
330 pr_LDADD += $(LIB_CLOCK_GETTIME)
331 touch_LDADD += $(LIB_CLOCK_GETTIME)
333 # for gethrxtime
334 dd_LDADD += $(LIB_GETHRXTIME)
336 # for cap_get_file
337 ls_LDADD += $(LIB_CAP)
339 # for fdatasync
340 dd_LDADD += $(LIB_FDATASYNC)
341 shred_LDADD += $(LIB_FDATASYNC)
343 # for xnanosleep
344 sleep_LDADD += $(LIB_NANOSLEEP)
345 sort_LDADD += $(LIB_NANOSLEEP)
346 tail_LDADD += $(LIB_NANOSLEEP)
348 # for various GMP functions
349 expr_LDADD += $(LIB_GMP)
350 factor_LDADD += $(LIB_GMP)
352 # for getloadavg
353 uptime_LDADD += $(GETLOADAVG_LIBS)
355 # for crypt
356 su_LDADD += $(LIB_CRYPT)
358 # for various ACL functions
359 copy_LDADD += $(LIB_ACL)
360 ls_LDADD += $(LIB_ACL)
362 # for various xattr functions
363 copy_LDADD += $(LIB_XATTR)
365 # for print_unicode_char, proper_name_utf8
366 cat_LDADD += $(LIBICONV)
367 cp_LDADD += $(LIBICONV)
368 df_LDADD += $(LIBICONV)
369 du_LDADD += $(LIBICONV)
370 getlimits_LDADD += $(LIBICONV)
371 printf_LDADD += $(LIBICONV)
372 ptx_LDADD += $(LIBICONV)
373 split_LDADD += $(LIBICONV)
374 stdbuf_LDADD += $(LIBICONV)
375 timeout_LDADD += $(LIBICONV)
376 truncate_LDADD += $(LIBICONV)
378 # for canon_host
379 pinky_LDADD += $(GETADDRINFO_LIB)
380 who_LDADD += $(GETADDRINFO_LIB)
382 # for gethostname, uname
383 hostname_LDADD += $(GETHOSTNAME_LIB)
384 uname_LDADD += $(GETHOSTNAME_LIB)
386 # for strsignal
387 kill_LDADD += $(LIBTHREAD)
389 # for pthread
390 sort_LDADD += $(LIB_PTHREAD)
392 $(PROGRAMS): ../lib/libcoreutils.a
394 # Get the release year from ../lib/version-etc.c.
395 RELEASE_YEAR = \
396   `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
397     $(top_srcdir)/lib/version-etc.c`
399 all-local: su$(EXEEXT)
401 installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
403 setuid_root_mode = a=rx,u+s
405 install_su =                                            \
406   if test "$(INSTALL_SU)" = yes; then                   \
407     p=su;                                               \
408     echo " $(INSTALL_PROGRAM) $$p $(installed_su)";     \
409     $(INSTALL_PROGRAM) $$p $(installed_su);             \
410     echo " chown root $(installed_su)";                 \
411     chown root $(installed_su);                         \
412     echo " chmod $(setuid_root_mode) $(installed_su)";  \
413     chmod $(setuid_root_mode) $(installed_su);          \
414   else                                                  \
415     :;                                                  \
416   fi
418 install-root: su$(EXEEXT)
419         @$(install_su)
421 install-exec-hook: su$(EXEEXT)
422         @if test "$(INSTALL_SU)" = yes; then                    \
423           TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$;                 \
424           rm -f $$TMPFILE;                                      \
425           echo > $$TMPFILE;                                     \
426 ## See if we can create a setuid root executable in $(bindir).
427 ## If not, then don't even try to install su.
428           can_create_suid_root_executable=no;                   \
429           chown root $$TMPFILE > /dev/null 2>&1                 \
430             && chmod $(setuid_root_mode) $$TMPFILE > /dev/null 2>&1 \
431             && can_create_suid_root_executable=yes;             \
432           rm -f $$TMPFILE;                                      \
433           if test $$can_create_suid_root_executable = yes; then \
434             $(install_su);                                      \
435           else                                                  \
436             echo "WARNING: insufficient access; not installing su"; \
437             echo "NOTE: to install su, run 'make install-root' as root"; \
438             rm -f $(installed_su);                              \
439           fi;                                                   \
440         else :;                                                 \
441         fi
443 uninstall-local:
444 # Remove su only if it's one we installed.
445         @if test "$(INSTALL_SU)" = yes; then                    \
446           if grep '$(PACKAGE_NAME)' $(installed_su) > /dev/null 2>&1; then \
447             echo "  rm -f $(installed_su)"; \
448             rm -f $(installed_su); \
449           else :; \
450           fi; \
451         fi
453 copy_sources = copy.c cp-hash.c extent-scan.c extent-scan.h
455 # Use `ginstall' in the definition of PROGRAMS and in dependencies to avoid
456 # confusion with the `install' target.  The install rule transforms `ginstall'
457 # to install before applying any user-specified name transformations.
459 transform = s/ginstall/install/; $(program_transform_name)
460 ginstall_SOURCES = install.c prog-fprintf.c $(copy_sources)
462 # This is for the '[' program.  Automake transliterates '[' to '_'.
463 __SOURCES = lbracket.c
465 cp_SOURCES = cp.c $(copy_sources)
466 dir_SOURCES = ls.c ls-dir.c
467 vdir_SOURCES = ls.c ls-vdir.c
468 id_SOURCES = id.c group-list.c
469 groups_SOURCES = groups.c group-list.c
470 ln_SOURCES = ln.c
471 ls_SOURCES = ls.c ls-ls.c
472 chown_SOURCES = chown.c chown-core.c
473 chgrp_SOURCES = chgrp.c chown-core.c
474 kill_SOURCES = kill.c operand2sig.c
475 timeout_SOURCES = timeout.c operand2sig.c
477 mv_SOURCES = mv.c remove.c $(copy_sources)
478 rm_SOURCES = rm.c remove.c
480 mkdir_SOURCES = mkdir.c prog-fprintf.c
481 rmdir_SOURCES = rmdir.c prog-fprintf.c
483 df_SOURCES = df.c find-mount-point.c
484 stat_SOURCES = stat.c find-mount-point.c
486 uname_SOURCES = uname.c uname-uname.c
487 arch_SOURCES = uname.c uname-arch.c
488 nproc_SOURCES = nproc.c
490 md5sum_SOURCES = md5sum.c
491 md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
492 sha1sum_SOURCES = md5sum.c
493 sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
494 sha224sum_SOURCES = md5sum.c
495 sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
496 sha256sum_SOURCES = md5sum.c
497 sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
498 sha384sum_SOURCES = md5sum.c
499 sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
500 sha512sum_SOURCES = md5sum.c
501 sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
503 ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
505 # Ensure we don't link against libcoreutils.a as that lib is
506 # not compiled with -fPIC which causes issues on 64 bit at least
507 libstdbuf_so_LDADD =
509 # Note libstdbuf is only compiled if GCC is available
510 # (as per the check in configure.ac), so these flags should be available.
511 # libtool is probably required to relax this dependency.
512 libstdbuf_so_LDFLAGS = -shared
513 libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS)
515 editpl = sed -e 's,@''PERL''@,$(PERL),g'
517 BUILT_SOURCES += dircolors.h
518 dircolors.h: dcgen dircolors.hin
519         $(AM_V_GEN)rm -f $@ $@-t
520         $(AM_V_at)$(PERL) -w -- $(srcdir)/dcgen $(srcdir)/dircolors.hin > $@-t
521         $(AM_V_at)chmod a-w $@-t
522         $(AM_V_at)mv $@-t $@
524 wheel_size = 5
526 BUILT_SOURCES += wheel-size.h
527 wheel-size.h: Makefile.am
528         $(AM_V_GEN)rm -f $@ $@-t
529         $(AM_V_at)echo '#define WHEEL_SIZE $(wheel_size)' > $@-t
530         $(AM_V_at)chmod a-w $@-t
531         $(AM_V_at)mv $@-t $@
533 BUILT_SOURCES += wheel.h
534 wheel.h: wheel-gen.pl Makefile.am
535         $(AM_V_GEN)rm -f $@ $@-t
536         $(AM_V_at)$(srcdir)/wheel-gen.pl $(wheel_size) > $@-t
537         $(AM_V_at)chmod a-w $@-t
538         $(AM_V_at)mv $@-t $@
540 # false exits nonzero even with --help or --version.
541 # test doesn't support --help or --version.
542 # Tell automake to exempt then from that installcheck test.
543 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
545 # Compare fs.h with the list of file system names/magic-numbers in the
546 # Linux statfs man page.  This target prints any new name/number pairs.
547 # Also compare against /usr/include/linux/magic.h
548 .PHONY: fs-magic-compare
549 fs-magic-compare: fs-magic fs-kernel-magic fs-def
550         join -v1 -t@ fs-magic fs-def
551         join -v1 -t@ fs-kernel-magic fs-def
553 CLEANFILES += fs-def
554 fs-def: fs.h
555         grep '^# *define ' $< | $(ASSORT) > $@-t && mv $@-t $@
557 # Massage bits of the statfs man page and definitions from
558 # /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
559 fs_normalize_perl_subst =                       \
560   -e 's/MINIX_SUPER_MAGIC\b/MINIX/;'            \
561   -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;'        \
562   -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;'        \
563   -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;'    \
564   -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;'        \
565   -e 's/CIFS_MAGIC_NUMBER/CIFS/;'               \
566   -e 's/(_SUPER)?_MAGIC//;'                     \
567   -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;'           \
568   -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;'           \
569   -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;'          \
570   -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;'           \
571   -e 's/^\s+//;'                                \
572   -e 's/^\#define\s+//;'                        \
573   -e 's/^_(XIAFS)/$$1/;'                        \
574   -e 's/^USBDEVICE/USBDEVFS/;'                  \
575   -e 's/NTFS_SB/NTFS/;'                         \
576   -e 's/^/\# define S_MAGIC_/;'                 \
577   -e 's,\s*/\* .*? \*/,,;'
579 CLEANFILES += fs-magic
580 fs-magic: Makefile
581         man statfs \
582           |perl -ne '/File system types:/.../Nobody kno/ and print'     \
583           |grep 0x | perl -p                                            \
584             $(fs_normalize_perl_subst)                                  \
585           | grep -Ev 'S_MAGIC_EXT[34]|STACK_END'                        \
586           | LC_ALL=C sort                                               \
587           > $@-t && mv $@-t $@
589 CLEANFILES += fs-kernel-magic
590 fs-kernel-magic: Makefile
591         perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h  \
592           | perl -p                                                     \
593             $(fs_normalize_perl_subst)                                  \
594           | grep -Ev 'S_MAGIC_EXT[34]|STACK_END'                        \
595           | LC_ALL=C sort                                               \
596           > $@-t && mv $@-t $@
598 BUILT_SOURCES += fs.h
599 fs.h: stat.c extract-magic
600         $(AM_V_GEN)rm -f $@
601         $(AM_V_at)$(PERL) $(srcdir)/extract-magic $(srcdir)/stat.c > $@t
602         $(AM_V_at)chmod a-w $@t
603         $(AM_V_at)mv $@t $@
605 BUILT_SOURCES += version.c
606 version.c: Makefile
607         $(AM_V_GEN)rm -f $@
608         $(AM_V_at)printf '#include <config.h>\n' > $@t
609         $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
610         $(AM_V_at)chmod a-w $@t
611         $(AM_V_at)mv $@t $@
613 BUILT_SOURCES += version.h
614 version.h: Makefile
615         $(AM_V_GEN)rm -f $@
616         $(AM_V_at)printf 'extern char const *Version;\n' > $@t
617         $(AM_V_at)chmod a-w $@t
618         $(AM_V_at)mv $@t $@
620 DISTCLEANFILES = version.c version.h
621 MAINTAINERCLEANFILES = $(BUILT_SOURCES)
623 # Sort in traditional ASCII order, regardless of the current locale;
624 # otherwise we may get into trouble with distinct strings that the
625 # current locale considers to be equal.
626 ASSORT = LC_ALL=C sort
628 all_programs = \
629     $(bin_PROGRAMS) \
630     $(bin_SCRIPTS) \
631   $(EXTRA_PROGRAMS)
633 built_programs.list:
634         @echo $(bin_PROGRAMS) $(bin_SCRIPTS) | tr ' ' '\n' \
635           | sed -e 's,$(EXEEXT)$$,,' | $(ASSORT) -u | tr '\n' ' '
637 all_programs.list:
638         @echo $(all_programs) | tr ' ' '\n' | sed -e 's,$(EXEEXT)$$,,' \
639           | sed /libstdbuf/d \
640           | $(ASSORT) -u
642 # This is required because we have broken inter-directory dependencies:
643 # in order to generate all man pages, even those for which we don't
644 # install a binary, require that all programs be built at distribution time.
645 dist-hook: $(all_programs)
647 # Ensure that all programs are built so we can for example
648 # subsequently syntax check all man pages.
649 .PHONY: all_programs
650 all_programs: $(all_programs)
652 pm = progs-makefile
653 pr = progs-readme
654 # Ensure that the list of programs in README matches the list
655 # of programs we can build.
656 check: check-README check-duplicate-no-install
657 .PHONY: check-README
658 check-README:
659         $(AM_V_GEN)rm -rf $(pr) $(pm)
660         $(AM_V_at)echo $(all_programs) \
661          | tr -s ' ' '\n' | sed -e 's,$(EXEEXT)$$,,;s/ginstall/install/' \
662          | sed /libstdbuf/d \
663          | $(ASSORT) -u > $(pm) && \
664         sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
665           | sed -n '/^   */s///p' | tr -s ' ' '\n' > $(pr)
666         $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm)
668 # Ensure that a by-default-not-installed program (listed in
669 # $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
670 # if that were to happen, it *would* be installed by default.
671 .PHONY: check-duplicate-no-install
672 check-duplicate-no-install: tr
673         $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"
675 # Ensure that the list of programs and author names is accurate.
676 # We need a UTF8 locale.  If a lack of locale support or a missing
677 # translation inhibits printing of UTF-8 names, just skip this test.
678 au_dotdot = authors-dotdot
679 au_actual = authors-actual
680 .PHONY: sc_check-AUTHORS
681 sc_check-AUTHORS: $(all_programs)
682         @locale=en_US.UTF-8;                            \
683         LC_ALL=$$locale ./cat --version         \
684             | grep ' Torbjorn ' > /dev/null             \
685           && { echo "$@: skipping this check"; exit 0; }; \
686         rm -f $(au_actual) $(au_dotdot);                \
687         for i in `ls $(all_programs) | sed -e 's,$(EXEEXT)$$,,' \
688             | sed /libstdbuf/d                          \
689             | $(ASSORT) -u`; do                         \
690           test "$$i" = '[' && continue;                 \
691           exe=$$i;                                      \
692           if test "$$i" = install; then                 \
693             exe=ginstall;                               \
694           elif test "$$i" = test; then                  \
695             exe='[';                                    \
696           fi;                                           \
697           LC_ALL=$$locale ./$$exe --version             \
698             | perl -0 -pi -e 's/,\n/, /gm'              \
699             | sed -n -e '/Written by /{ s//'"$$i"': /;' \
700                   -e 's/,* and /, /; s/\.$$//; p; }';   \
701         done > $(au_actual) &&                          \
702         sed -n '/^[^ ][^ ]*:/p' $(top_srcdir)/AUTHORS > $(au_dotdot) && \
703         diff $(au_actual) $(au_dotdot) && rm -f $(au_actual) $(au_dotdot)
705 # The following rule is not designed to be portable,
706 # and relies on tools that not everyone has.
708 # Most functions in src/*.c should have static scope.
709 # Any that don't must be marked with `extern', but `main'
710 # and `usage' are exceptions.  They're always extern, but
711 # don't need to be marked. Also functions starting with __
712 # are exempted due to possibly being added by the compiler
713 # (when compiled as a shared library for example).
715 # The second nm|grep checks for file-scope variables with `extern' scope.
716 .PHONY: sc_tight_scope
717 sc_tight_scope: $(bin_PROGRAMS)
718         @t=exceptions-$$$$;                                             \
719         trap 's=$$?; rm -f $$t; exit $$s' 0;                            \
720         am__exit='(exit $s); exit $s';                                  \
721         trap "s=129; $$am__exit" 1; trap "s=130; $$am__exit" 2;         \
722         trap "s=141; $$am__exit" 13; trap "s=143; $$am__exit" 15;       \
723         src=`for f in $(SOURCES); do                                    \
724                test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`;   \
725         hdr=`for f in $(noinst_HEADERS); do                             \
726                test -f $$f && d= || d=$(srcdir)/; echo $$d$$f; done`;   \
727         ( printf 'main\nusage\n_.*\n';                                  \
728           grep -h -A1 '^extern .*[^;]$$' $$src                          \
729             | grep -vE '^(extern |--)' | sed 's/ .*//';                 \
730           perl -ne '/^extern (?:enum )?\S+ (\S*) \(/ and print "$$1\n"' $$hdr; \
731         ) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t;                 \
732         nm -e *.$(OBJEXT)                                               \
733             | sed -n 's/.* T //p'                                       \
734             | sed 's/^_//'                                              \
735             | grep -Ev -f $$t &&                                        \
736           { echo 'the above functions should have static scope' 1>&2;   \
737             exit 1; } || : ;                                            \
738         ( printf '^program_name$$\n';                                   \
739           perl -ne '/^extern .*?\**(\w+);/ and print "^$$1\$$\n"'       \
740             $$hdr *.h ) | $(ASSORT) -u > $$t;                           \
741         nm -e *.$(OBJEXT)                                               \
742             | sed -n 's/.* [BD] //p'                                    \
743             | sed 's/^_//'                                              \
744             | grep -Ev -f $$t &&                                        \
745           { echo 'the above variables should have static scope' 1>&2;   \
746             exit 1; } || :
748 # Use the just-built ./ginstall, when not cross-compiling.
749 if CROSS_COMPILING
750 cu_install_program = @INSTALL_PROGRAM@
751 else
752 cu_install_program = ./ginstall
753 endif
754 INSTALL_PROGRAM = $(cu_install_program)