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