tail: avoid infloop with -c on /dev/zero
[coreutils.git] / src / local.mk
blob96ee941ca521487726c1f1a0c8baccd416424076
1 # Make coreutils programs. -*-Makefile-*-
2 # This is included by the top-level Makefile.am.
4 ## Copyright (C) 1990-2024 Free Software Foundation, Inc.
6 ## This program is free software: you can redistribute it and/or modify
7 ## it under the terms of the GNU General Public License as published by
8 ## the Free Software Foundation, either version 3 of the License, or
9 ## (at your option) any later version.
11 ## This program is distributed in the hope that it will be useful,
12 ## but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ## GNU General Public License for more details.
16 ## You should have received a copy of the GNU General Public License
17 ## along with this program. If not, see <https://www.gnu.org/licenses/>.
19 # FIXME: once lib/ and gnulib-tests/ are also converted, hoist to Makefile.am
20 AM_CFLAGS = $(WERROR_CFLAGS)
22 # The list of all programs (separated in different variables to express
23 # the how and when they should be installed) is defined in this makefile
24 # fragment, autogenerated by the 'gen-lists-of-programs.sh' auxiliary
25 # script.
26 include $(srcdir)/src/cu-progs.mk
28 EXTRA_PROGRAMS = \
29 $(no_install__progs) \
30 $(build_if_possible__progs) \
31 $(default__progs)
33 # The user can tweak these lists at configure time.
34 bin_PROGRAMS = @bin_PROGRAMS@
35 pkglibexec_PROGRAMS = @pkglibexec_PROGRAMS@
37 # Needed by the testsuite.
38 noinst_PROGRAMS = \
39 src/getlimits \
40 src/make-prime-list
42 noinst_HEADERS = \
43 src/chown.h \
44 src/chown-core.h \
45 src/copy.h \
46 src/cp-hash.h \
47 src/dircolors.h \
48 src/expand-common.h \
49 src/find-mount-point.h \
50 src/fs.h \
51 src/fs-is-local.h \
52 src/group-list.h \
53 src/ioblksize.h \
54 src/iopoll.h \
55 src/longlong.h \
56 src/ls.h \
57 src/operand2sig.h \
58 src/prog-fprintf.h \
59 src/remove.h \
60 src/set-fields.h \
61 src/statx.h \
62 src/system.h \
63 src/temp-stream.h \
64 src/uname.h \
65 src/wc.h
67 EXTRA_DIST += \
68 src/dcgen \
69 src/dircolors.hin \
70 src/primes.h \
71 src/tac-pipe.c \
72 src/extract-magic
74 CLEANFILES += $(SCRIPTS)
76 # Also remove these sometimes-built programs.
77 # For example, even when excluded, they're built via 'sc_check-AUTHORS'
78 # or 'dist'.
79 CLEANFILES += $(no_install__progs)
81 noinst_LIBRARIES += src/libver.a
82 nodist_src_libver_a_SOURCES = src/version.c src/version.h
84 # Tell the linker to omit references to unused shared libraries.
85 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
87 # Extra libraries needed by more than one program. Will be updated later.
88 copy_ldadd =
89 remove_ldadd =
91 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
92 # include modules defining variables like 'optind', so libcoreutils.a
93 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
94 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
95 # replacement functions defined in libcoreutils.a.
96 # Similarly for $(MBRTOWC_LIB).
97 LDADD = src/libver.a lib/libcoreutils.a $(LIBINTL) $(MBRTOWC_LIB) \
98 lib/libcoreutils.a
100 # First, list all programs, to make listing per-program libraries easier.
101 # See [ below.
102 src_arch_LDADD = $(LDADD)
103 src_base64_LDADD = $(LDADD)
104 src_base32_LDADD = $(LDADD)
105 src_basenc_LDADD = $(LDADD)
106 src_basename_LDADD = $(LDADD)
107 src_cat_LDADD = $(LDADD)
108 src_chcon_LDADD = $(LDADD)
109 # See chgrp_LDADD below
110 src_chmod_LDADD = $(LDADD)
111 src_chown_LDADD = $(LDADD)
112 src_chroot_LDADD = $(LDADD)
113 src_cksum_LDADD = $(LDADD)
114 src_comm_LDADD = $(LDADD)
115 src_nproc_LDADD = $(LDADD)
116 src_cp_LDADD = $(LDADD)
117 if !SINGLE_BINARY
118 src_coreutils_LDADD = $(LDADD)
119 endif
120 src_csplit_LDADD = $(LDADD)
121 src_cut_LDADD = $(LDADD)
122 src_date_LDADD = $(LDADD)
123 src_dd_LDADD = $(LDADD)
124 src_df_LDADD = $(LDADD)
125 # See dir_LDADD below
126 src_dircolors_LDADD = $(LDADD)
127 src_dirname_LDADD = $(LDADD)
128 src_du_LDADD = $(LDADD)
129 src_echo_LDADD = $(LDADD)
130 src_env_LDADD = $(LDADD)
131 src_expand_LDADD = $(LDADD)
132 src_expr_LDADD = $(LDADD)
133 src_factor_LDADD = $(LDADD)
134 src_false_LDADD = $(LDADD)
135 src_fmt_LDADD = $(LDADD)
136 src_fold_LDADD = $(LDADD)
137 src_getlimits_LDADD = $(LDADD)
138 src_ginstall_LDADD = $(LDADD)
139 src_groups_LDADD = $(LDADD)
140 src_head_LDADD = $(LDADD)
141 src_hostid_LDADD = $(LDADD)
142 src_hostname_LDADD = $(LDADD)
143 src_id_LDADD = $(LDADD)
144 src_join_LDADD = $(LDADD)
145 src_kill_LDADD = $(LDADD)
146 src_link_LDADD = $(LDADD)
147 src_ln_LDADD = $(LDADD)
148 src_logname_LDADD = $(LDADD)
149 src_ls_LDADD = $(LDADD)
151 # This must *not* depend on anything in lib/, since it is used to generate
152 # src/primes.h. If it depended on libcoreutils.a, that would pull all lib/*.c
153 # into BUILT_SOURCES.
154 src_make_prime_list_LDADD =
156 src_md5sum_LDADD = $(LDADD)
157 src_mkdir_LDADD = $(LDADD)
158 src_mkfifo_LDADD = $(LDADD)
159 src_mknod_LDADD = $(LDADD)
160 src_mktemp_LDADD = $(LDADD)
161 src_mv_LDADD = $(LDADD)
162 src_nice_LDADD = $(LDADD)
163 src_nl_LDADD = $(LDADD)
164 src_nohup_LDADD = $(LDADD)
165 src_numfmt_LDADD = $(LDADD)
166 src_od_LDADD = $(LDADD)
167 src_paste_LDADD = $(LDADD)
168 src_pathchk_LDADD = $(LDADD)
169 src_pinky_LDADD = $(LDADD)
170 src_pr_LDADD = $(LDADD)
171 src_printenv_LDADD = $(LDADD)
172 src_printf_LDADD = $(LDADD)
173 src_ptx_LDADD = $(LDADD)
174 src_pwd_LDADD = $(LDADD)
175 src_readlink_LDADD = $(LDADD)
176 src_realpath_LDADD = $(LDADD)
177 src_rm_LDADD = $(LDADD)
178 src_rmdir_LDADD = $(LDADD)
179 src_runcon_LDADD = $(LDADD)
180 src_seq_LDADD = $(LDADD)
181 src_sha1sum_LDADD = $(LDADD)
182 src_sha224sum_LDADD = $(LDADD)
183 src_sha256sum_LDADD = $(LDADD)
184 src_sha384sum_LDADD = $(LDADD)
185 src_sha512sum_LDADD = $(LDADD)
186 src_shred_LDADD = $(LDADD)
187 src_shuf_LDADD = $(LDADD)
188 src_sleep_LDADD = $(LDADD)
189 src_sort_LDADD = $(LDADD)
190 src_split_LDADD = $(LDADD)
191 src_stat_LDADD = $(LDADD)
192 src_stdbuf_LDADD = $(LDADD)
193 src_stty_LDADD = $(LDADD)
194 src_sum_LDADD = $(LDADD)
195 src_sync_LDADD = $(LDADD)
196 src_tac_LDADD = $(LDADD)
197 src_tail_LDADD = $(LDADD)
198 src_tee_LDADD = $(LDADD)
199 src_test_LDADD = $(LDADD)
200 src_timeout_LDADD = $(LDADD)
201 src_touch_LDADD = $(LDADD)
202 src_tr_LDADD = $(LDADD)
203 src_true_LDADD = $(LDADD)
204 src_truncate_LDADD = $(LDADD)
205 src_tsort_LDADD = $(LDADD)
206 src_tty_LDADD = $(LDADD)
207 src_uname_LDADD = $(LDADD)
208 src_unexpand_LDADD = $(LDADD)
209 src_uniq_LDADD = $(LDADD)
210 src_unlink_LDADD = $(LDADD)
211 src_uptime_LDADD = $(LDADD)
212 src_users_LDADD = $(LDADD)
213 # See vdir_LDADD below
214 src_wc_LDADD = $(LDADD)
215 src_who_LDADD = $(LDADD)
216 src_whoami_LDADD = $(LDADD)
217 src_yes_LDADD = $(LDADD)
219 # Synonyms. Recall that Automake transliterates '[' and '/' to '_'.
220 src___LDADD = $(src_test_LDADD)
221 src_dir_LDADD = $(src_ls_LDADD)
222 src_vdir_LDADD = $(src_ls_LDADD)
223 src_chgrp_LDADD = $(src_chown_LDADD)
225 src_cp_LDADD += $(copy_ldadd)
226 src_ginstall_LDADD += $(copy_ldadd)
227 src_mv_LDADD += $(copy_ldadd)
229 src_mv_LDADD += $(remove_ldadd)
230 src_rm_LDADD += $(remove_ldadd)
232 # for eaccess, euidaccess
233 copy_ldadd += $(EUIDACCESS_LIBGEN)
234 remove_ldadd += $(EUIDACCESS_LIBGEN)
235 src_sort_LDADD += $(EUIDACCESS_LIBGEN)
236 src_test_LDADD += $(EUIDACCESS_LIBGEN)
238 # for selinux use
239 copy_ldadd += $(LIB_SELINUX)
240 src_chcon_LDADD += $(LIB_SELINUX)
241 src_ginstall_LDADD += $(LIB_SELINUX)
242 src_id_LDADD += $(LIB_SELINUX)
243 src_id_LDADD += $(LIB_SMACK)
244 src_ls_LDADD += $(LIB_SELINUX)
245 src_ls_LDADD += $(LIB_SMACK)
246 src_mkdir_LDADD += $(LIB_SELINUX)
247 src_mkdir_LDADD += $(LIB_SMACK)
248 src_mkfifo_LDADD += $(LIB_SELINUX)
249 src_mkfifo_LDADD += $(LIB_SMACK)
250 src_mknod_LDADD += $(LIB_SELINUX)
251 src_mknod_LDADD += $(LIB_SMACK)
252 src_runcon_LDADD += $(LIB_SELINUX)
253 src_stat_LDADD += $(LIB_SELINUX)
255 # for nvlist_lookup_uint64_array
256 src_stat_LDADD += $(LIB_NVPAIR)
258 # for gettime, settime, tempname, utimecmp, utimens
259 copy_ldadd += $(CLOCK_TIME_LIB)
260 src_date_LDADD += $(CLOCK_TIME_LIB)
261 src_ginstall_LDADD += $(CLOCK_TIME_LIB)
262 src_ln_LDADD += $(CLOCK_TIME_LIB)
263 src_ls_LDADD += $(CLOCK_TIME_LIB)
264 src_mktemp_LDADD += $(CLOCK_TIME_LIB)
265 src_pr_LDADD += $(CLOCK_TIME_LIB)
266 src_sort_LDADD += $(CLOCK_TIME_LIB)
267 src_split_LDADD += $(CLOCK_TIME_LIB)
268 src_tac_LDADD += $(CLOCK_TIME_LIB)
269 src_timeout_LDADD += $(TIMER_TIME_LIB)
270 src_touch_LDADD += $(CLOCK_TIME_LIB)
272 # for gethrxtime
273 src_dd_LDADD += $(GETHRXTIME_LIB)
275 # for cap_get_file
276 src_ls_LDADD += $(LIB_CAP)
278 # for fdatasync
279 src_dd_LDADD += $(FDATASYNC_LIB)
280 src_shred_LDADD += $(FDATASYNC_LIB)
281 src_sync_LDADD += $(FDATASYNC_LIB)
283 # for xnanosleep
284 src_sleep_LDADD += $(NANOSLEEP_LIB)
285 src_sort_LDADD += $(NANOSLEEP_LIB)
286 src_tail_LDADD += $(NANOSLEEP_LIB)
288 # for various GMP functions
289 src_expr_LDADD += $(LIBGMP)
290 src_factor_LDADD += $(LIBGMP)
292 # for getloadavg
293 src_uptime_LDADD += $(GETLOADAVG_LIBS)
295 # for various ACL functions
296 copy_ldadd += $(LIB_ACL)
297 src_ls_LDADD += $(FILE_HAS_ACL_LIB)
299 # for various xattr functions
300 copy_ldadd += $(LIB_XATTR)
302 # for print_unicode_char
303 src_printf_LDADD += $(LIBICONV)
305 # for libcrypto hash routines
306 src_md5sum_LDADD += $(LIB_CRYPTO)
307 src_sort_LDADD += $(LIB_DL) $(LIB_CRYPTO)
308 src_sha1sum_LDADD += $(LIB_CRYPTO)
309 src_sha224sum_LDADD += $(LIB_CRYPTO)
310 src_sha256sum_LDADD += $(LIB_CRYPTO)
311 src_sha384sum_LDADD += $(LIB_CRYPTO)
312 src_sha512sum_LDADD += $(LIB_CRYPTO)
313 src_cksum_LDADD += $(LIB_CRYPTO)
315 # for canon_host
316 src_pinky_LDADD += $(GETADDRINFO_LIB)
317 src_who_LDADD += $(GETADDRINFO_LIB)
319 # for gethostname, uname
320 src_hostname_LDADD += $(GETHOSTNAME_LIB)
321 src_uname_LDADD += $(GETHOSTNAME_LIB)
323 # for read_utmp
324 src_pinky_LDADD += $(READUTMP_LIB)
325 src_uptime_LDADD += $(READUTMP_LIB)
326 src_users_LDADD += $(READUTMP_LIB)
327 src_who_LDADD += $(READUTMP_LIB)
329 # for strsignal
330 src_kill_LDADD += $(LIBTHREAD)
332 # for pthread-cond, pthread-mutex, pthread-thread
333 src_sort_LDADD += $(LIBPMULTITHREAD)
335 # for pthread_sigmask
336 src_sort_LDADD += $(PTHREAD_SIGMASK_LIB)
338 # Get the release year from lib/version-etc.c.
339 RELEASE_YEAR = \
340 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
341 $(top_srcdir)/lib/version-etc.c`
343 selinux_sources = \
344 src/selinux.c \
345 src/selinux.h
347 copy_sources = \
348 src/copy.c \
349 src/cp-hash.c \
350 src/force-link.c \
351 src/force-link.h
353 # Use 'ginstall' in the definition of PROGRAMS and in dependencies to avoid
354 # confusion with the 'install' target. The install rule transforms 'ginstall'
355 # to install before applying any user-specified name transformations.
357 # Don't apply prefix transformations to libstdbuf shared lib
358 # as that's not generally needed, and we need to reference the
359 # name directly in LD_PRELOAD etc. In general it's surprising
360 # that $(transform) is applied to libexec at all given that is
361 # for internal package naming, not privy to $(transform).
363 transform = s/ginstall/install/;/libstdbuf/!$(program_transform_name)
365 src_ginstall_SOURCES = src/install.c src/prog-fprintf.c $(copy_sources) \
366 $(selinux_sources)
368 # This is for the '[' program. Automake transliterates '[' and '/' to '_'.
369 src___SOURCES = src/lbracket.c
371 nodist_src_coreutils_SOURCES = src/coreutils.h
372 src_coreutils_SOURCES = src/coreutils.c
374 src_cp_SOURCES = src/cp.c $(copy_sources) $(selinux_sources)
375 src_dir_SOURCES = src/ls.c src/ls-dir.c
376 src_env_SOURCES = src/env.c src/operand2sig.c
377 src_vdir_SOURCES = src/ls.c src/ls-vdir.c
378 src_id_SOURCES = src/id.c src/group-list.c
379 src_groups_SOURCES = src/groups.c src/group-list.c
380 src_ls_SOURCES = src/ls.c src/ls-ls.c
381 src_ln_SOURCES = src/ln.c \
382 src/force-link.c src/force-link.h \
383 src/relpath.c src/relpath.h
384 src_chown_SOURCES = src/chown.c src/chown-core.c src/chown-chown.c
385 src_chgrp_SOURCES = src/chown.c src/chown-core.c src/chown-chgrp.c
386 src_kill_SOURCES = src/kill.c src/operand2sig.c
387 src_realpath_SOURCES = src/realpath.c src/relpath.c src/relpath.h
388 src_timeout_SOURCES = src/timeout.c src/operand2sig.c
390 src_mv_SOURCES = src/mv.c src/remove.c $(copy_sources) $(selinux_sources)
391 src_rm_SOURCES = src/rm.c src/remove.c
393 src_mkdir_SOURCES = src/mkdir.c src/prog-fprintf.c $(selinux_sources)
394 src_rmdir_SOURCES = src/rmdir.c src/prog-fprintf.c
396 src_mkfifo_SOURCES = src/mkfifo.c $(selinux_sources)
397 src_mknod_SOURCES = src/mknod.c $(selinux_sources)
399 src_df_SOURCES = src/df.c src/find-mount-point.c
400 src_stat_SOURCES = src/stat.c src/find-mount-point.c
402 src_uname_SOURCES = src/uname.c src/uname-uname.c
403 src_arch_SOURCES = src/uname.c src/uname-arch.c
405 src_cut_SOURCES = src/cut.c src/set-fields.c
406 src_numfmt_SOURCES = src/numfmt.c src/set-fields.c
408 src_split_SOURCES = src/split.c src/temp-stream.c
409 src_tac_SOURCES = src/tac.c src/temp-stream.c
411 src_tail_SOURCES = src/tail.c src/iopoll.c
412 src_tee_SOURCES = src/tee.c src/iopoll.c
414 src_sum_SOURCES = src/sum.c src/sum.h src/digest.c
415 src_sum_CPPFLAGS = -DHASH_ALGO_SUM=1 $(AM_CPPFLAGS)
417 src_md5sum_SOURCES = src/digest.c
418 src_md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
419 src_sha1sum_SOURCES = src/digest.c
420 src_sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
421 src_sha224sum_SOURCES = src/digest.c
422 src_sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
423 src_sha256sum_SOURCES = src/digest.c
424 src_sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
425 src_sha384sum_SOURCES = src/digest.c
426 src_sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
427 src_sha512sum_SOURCES = src/digest.c
428 src_sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
429 src_b2sum_CPPFLAGS = -DHASH_ALGO_BLAKE2=1 -DHAVE_CONFIG_H $(AM_CPPFLAGS)
430 src_b2sum_SOURCES = src/digest.c \
431 src/blake2/blake2.h src/blake2/blake2-impl.h \
432 src/blake2/blake2b-ref.c \
433 src/blake2/b2sum.c src/blake2/b2sum.h
435 src_cksum_SOURCES = $(src_b2sum_SOURCES) src/sum.c src/sum.h \
436 src/cksum.c src/cksum.h src/crctab.c
437 src_cksum_CPPFLAGS = -DHASH_ALGO_CKSUM=1 -DHAVE_CONFIG_H $(AM_CPPFLAGS)
438 if USE_PCLMUL_CRC32
439 noinst_LIBRARIES += src/libcksum_pclmul.a
440 src_libcksum_pclmul_a_SOURCES = src/cksum_pclmul.c src/cksum.h
441 cksum_pclmul_ldadd = src/libcksum_pclmul.a
442 src_cksum_LDADD += $(cksum_pclmul_ldadd)
443 src_libcksum_pclmul_a_CFLAGS = -mavx -mpclmul $(AM_CFLAGS)
444 endif
446 src_base64_SOURCES = src/basenc.c
447 src_base64_CPPFLAGS = -DBASE_TYPE=64 $(AM_CPPFLAGS)
448 src_base32_SOURCES = src/basenc.c
449 src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS)
450 src_basenc_SOURCES = src/basenc.c
451 src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS)
453 src_expand_SOURCES = src/expand.c src/expand-common.c
454 src_unexpand_SOURCES = src/unexpand.c src/expand-common.c
456 src_wc_SOURCES = src/wc.c
457 if USE_AVX2_WC_LINECOUNT
458 noinst_LIBRARIES += src/libwc_avx2.a
459 src_libwc_avx2_a_SOURCES = src/wc_avx2.c
460 wc_avx2_ldadd = src/libwc_avx2.a
461 src_wc_LDADD += $(wc_avx2_ldadd)
462 src_libwc_avx2_a_CFLAGS = -mavx2 $(AM_CFLAGS)
463 endif
465 # Ensure we don't link against libcoreutils.a as that lib is
466 # not compiled with -fPIC which causes issues on 64 bit at least
467 src_libstdbuf_so_LDADD = $(LIBINTL)
469 # Note libstdbuf is only compiled if GCC is available
470 # (as per the check in configure.ac), so these flags should be available.
471 # libtool is probably required to relax this dependency.
472 src_libstdbuf_so_LDFLAGS = -shared
473 src_libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS)
475 BUILT_SOURCES += src/coreutils.h
476 if SINGLE_BINARY
477 # Single binary dependencies
478 src_coreutils_CFLAGS = -DSINGLE_BINARY $(AM_CFLAGS)
479 #src_coreutils_LDFLAGS = $(AM_LDFLAGS)
480 src_coreutils_LDADD = $(single_binary_deps) $(LDADD) $(single_binary_libs)
481 src_coreutils_DEPENDENCIES = $(LDADD) $(single_binary_deps)
483 include $(top_srcdir)/src/single-binary.mk
485 # Creates symlinks or shebangs to the installed programs when building
486 # coreutils single binary.
487 EXTRA_src_coreutils_DEPENDENCIES = src/coreutils_$(single_binary_install_type)
488 endif SINGLE_BINARY
490 CLEANFILES += src/coreutils_symlinks
491 src/coreutils_symlinks: Makefile
492 $(AM_V_GEN)touch $@
493 $(AM_V_at)${MKDIR_P} src
494 $(AM_V_at)for i in x $(single_binary_progs); do \
495 test $$i = x && continue; \
496 rm -f src/$$i$(EXEEXT) || exit $$?; \
497 $(LN_S) -s coreutils$(EXEEXT) src/$$i$(EXEEXT) || exit $$?; \
498 done
500 CLEANFILES += src/coreutils_shebangs
501 src/coreutils_shebangs: Makefile
502 $(AM_V_GEN)touch $@
503 $(AM_V_at)${MKDIR_P} src
504 $(AM_V_at)for i in x $(single_binary_progs); do \
505 test $$i = x && continue; \
506 rm -f src/$$i$(EXEEXT) || exit $$?; \
507 printf '#!%s --coreutils-prog-shebang=%s\n' \
508 $(abs_top_builddir)/src/coreutils$(EXEEXT) $$i \
509 >src/$$i$(EXEEXT) || exit $$?; \
510 chmod a+x,a-w src/$$i$(EXEEXT) || exit $$?; \
511 done
513 clean-local:
514 $(AM_V_at)for i in x $(single_binary_progs); do \
515 test $$i = x && continue; \
516 rm -f src/$$i$(EXEEXT) || exit $$?; \
517 done
520 BUILT_SOURCES += src/dircolors.h
521 src/dircolors.h: src/dcgen src/dircolors.hin
522 $(AM_V_GEN)rm -f $@ $@-t
523 $(AM_V_at)${MKDIR_P} src
524 $(AM_V_at)$(PERL) -w -- $(srcdir)/src/dcgen \
525 $(srcdir)/src/dircolors.hin > $@-t
526 $(AM_V_at)chmod a-w $@-t
527 $(AM_V_at)mv $@-t $@
529 # This file is built by maintainers. It's architecture-independent,
530 # and it needs to be built on a widest-known-int architecture, so it's
531 # built only if absent. It is not cleaned because we don't want to
532 # insist that maintainers must build on hosts that support the widest
533 # known ints (currently 128-bit).
534 BUILT_SOURCES += $(top_srcdir)/src/primes.h
535 $(top_srcdir)/src/primes.h:
536 $(AM_V_at)${MKDIR_P} src
537 $(MAKE) src/make-prime-list$(EXEEXT)
538 $(AM_V_GEN)rm -f $@ $@-t
539 $(AM_V_at)src/make-prime-list$(EXEEXT) 5000 > $@-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 = src/false src/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: src/fs-magic-compare
552 src/fs-magic-compare: src/fs-magic src/fs-kernel-magic src/fs-def
553 @join -v1 -t@ src/fs-magic src/fs-def
554 @join -v1 -t@ src/fs-kernel-magic src/fs-def
556 CLEANFILES += src/fs-def
557 src/fs-def: src/fs.h
558 @grep '^# *define ' src/fs.h | $(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/AFS_FS/KAFS/;' \
570 -e 's/(_SUPER)?_MAGIC//;' \
571 -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
572 -e 's/(\s+0x)(\X{2})\b/$${1}00$$2/;' \
573 -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
574 -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
575 -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
576 -e 's/^\s+//;' \
577 -e 's/^\043define\s+//;' \
578 -e 's/^_(XIAFS)/$$1/;' \
579 -e 's/^USBDEVICE/USBDEVFS/;' \
580 -e 's/NTFS_SB/NTFS/;' \
581 -e 's/^/\043 define S_MAGIC_/;' \
582 -e 's,\s*/\* .*? \*/,,;'
584 CLEANFILES += src/fs-magic
585 src/fs-magic: Makefile
586 @MANPAGER= man statfs \
587 |perl -ne '/File system types:/.../Nobody kno/ and print' \
588 |grep 0x | perl -p \
589 $(fs_normalize_perl_subst) \
590 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
591 | $(ASSORT) \
592 > $@-t && mv $@-t $@
594 DISTCLEANFILES += src/fs-latest-magic.h
595 # This rule currently gets the latest header, but probably isn't general
596 # enough to enable by default.
597 # @kgit='https://git.kernel.org/cgit/linux/kernel/git'; \
598 # wget -q $$kgit/torvalds/linux.git/plain/include/uapi/linux/magic.h \
599 # -O $@
600 src/fs-latest-magic.h:
601 @touch $@
603 CLEANFILES += src/fs-kernel-magic
604 src/fs-kernel-magic: Makefile src/fs-latest-magic.h
605 @perl -ne '/^#define.*0x/ and print' \
606 /usr/include/linux/magic.h src/fs-latest-magic.h \
607 | perl -p \
608 $(fs_normalize_perl_subst) \
609 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
610 | $(ASSORT) -u \
611 > $@-t && mv $@-t $@
613 BUILT_SOURCES += src/fs-is-local.h
614 src/fs-is-local.h: src/stat.c src/extract-magic
615 $(AM_V_GEN)rm -f $@
616 $(AM_V_at)${MKDIR_P} src
617 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
618 --local $(srcdir)/src/stat.c > $@t
619 $(AM_V_at)chmod a-w $@t
620 $(AM_V_at)mv $@t $@
622 BUILT_SOURCES += src/fs.h
623 src/fs.h: src/stat.c src/extract-magic
624 $(AM_V_GEN)rm -f $@
625 $(AM_V_at)${MKDIR_P} src
626 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
627 $(srcdir)/src/stat.c > $@t
628 $(AM_V_at)chmod a-w $@t
629 $(AM_V_at)mv $@t $@
631 BUILT_SOURCES += src/version.c
632 src/version.c: Makefile
633 $(AM_V_GEN)rm -f $@
634 $(AM_V_at)${MKDIR_P} src
635 $(AM_V_at)printf '#include <config.h>\n' > $@t
636 $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
637 $(AM_V_at)chmod a-w $@t
638 $(AM_V_at)mv $@t $@
640 BUILT_SOURCES += src/version.h
641 src/version.h: Makefile
642 $(AM_V_GEN)rm -f $@
643 $(AM_V_at)${MKDIR_P} src
644 $(AM_V_at)printf 'extern char const *Version;\n' > $@t
645 $(AM_V_at)chmod a-w $@t
646 $(AM_V_at)mv $@t $@
648 # Generates a list of macro invocations like:
649 # SINGLE_BINARY_PROGRAM(program_name_str, main_name)
650 # once for each program list on $(single_binary_progs). Note that
651 # for [ the macro invocation is:
652 # SINGLE_BINARY_PROGRAM("[", _)
653 DISTCLEANFILES += src/coreutils.h
654 src/coreutils.h: Makefile
655 $(AM_V_GEN)rm -f $@
656 $(AM_V_at)${MKDIR_P} src
657 $(AM_V_at)for prog in x $(single_binary_progs); do \
658 test $$prog = x && continue; \
659 prog=`basename $$prog`; \
660 main=`echo $$prog | tr '[' '_'`; \
661 echo "SINGLE_BINARY_PROGRAM(\"$$prog\", $$main)"; \
662 done | sort > $@t
663 $(AM_V_at)chmod a-w $@t
664 $(AM_V_at)mv $@t $@
666 DISTCLEANFILES += src/version.c src/version.h
667 MAINTAINERCLEANFILES += $(BUILT_SOURCES)
669 all_programs = \
670 $(bin_PROGRAMS) \
671 $(bin_SCRIPTS) \
672 $(EXTRA_PROGRAMS)
674 pm = progs-makefile
675 pr = progs-readme
676 # Ensure that the list of programs in README matches the list
677 # of programs we can build.
678 check-local: check-README check-duplicate-no-install
679 .PHONY: check-README
680 check-README:
681 $(AM_V_GEN)rm -rf $(pr) $(pm)
682 $(AM_V_at)echo $(all_programs) \
683 | tr -s ' ' '\n' \
684 | sed -e 's,$(EXEEXT)$$,,' \
685 -e 's,^src/,,' \
686 -e 's/^ginstall$$/install/' \
687 | sed /libstdbuf/d \
688 | $(ASSORT) -u > $(pm) && \
689 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
690 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
691 $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm)
693 # Ensure that a by-default-not-installed program (listed in
694 # $(no_install__progs) is not also listed as another $(EXTRA_PROGRAMS)
695 # entry, because if that were to happen, it *would* be installed
696 # by default.
697 .PHONY: check-duplicate-no-install
698 check-duplicate-no-install:
699 $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)' | tr ' ' '\n' | uniq -d`"
701 # Use the just-built 'ginstall', when not cross-compiling.
702 if CROSS_COMPILING
703 cu_install_program = @INSTALL@
704 else
705 cu_install_program = src/ginstall
706 endif
707 INSTALL = $(cu_install_program) -c