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