maint: distinguish EOVERFLOW vs ERANGE better
[coreutils.git] / src / local.mk
blob8133925ac7c150fd702d0edfa8ba6738831dff8f
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/octhexdigits.h \
58 src/operand2sig.h \
59 src/prog-fprintf.h \
60 src/remove.h \
61 src/set-fields.h \
62 src/show-date.h \
63 src/statx.h \
64 src/system.h \
65 src/temp-stream.h \
66 src/uname.h \
67 src/wc.h
69 EXTRA_DIST += \
70 src/dcgen \
71 src/dircolors.hin \
72 src/primes.h \
73 src/tac-pipe.c \
74 src/extract-magic
76 CLEANFILES += $(SCRIPTS)
78 # Also remove these sometimes-built programs.
79 # For example, even when excluded, they're built via 'sc_check-AUTHORS'
80 # or 'dist'.
81 CLEANFILES += $(no_install__progs)
83 noinst_LIBRARIES += src/libver.a
84 nodist_src_libver_a_SOURCES = src/version.c src/version.h
86 # Tell the linker to omit references to unused shared libraries.
87 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
89 # Extra libraries needed by more than one program. Will be updated later.
90 copy_ldadd =
91 remove_ldadd =
93 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
94 # include modules defining variables like 'optind', so libcoreutils.a
95 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
96 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
97 # replacement functions defined in libcoreutils.a.
98 # Similarly for $(MBRTOWC_LIB).
99 LDADD = src/libver.a lib/libcoreutils.a $(LIBINTL) $(MBRTOWC_LIB) \
100 lib/libcoreutils.a
102 # First, list all programs, to make listing per-program libraries easier.
103 # See [ below.
104 src_arch_LDADD = $(LDADD)
105 src_base64_LDADD = $(LDADD)
106 src_base32_LDADD = $(LDADD)
107 src_basenc_LDADD = $(LDADD)
108 src_basename_LDADD = $(LDADD)
109 src_cat_LDADD = $(LDADD)
110 src_chcon_LDADD = $(LDADD)
111 # See chgrp_LDADD below
112 src_chmod_LDADD = $(LDADD)
113 src_chown_LDADD = $(LDADD)
114 src_chroot_LDADD = $(LDADD)
115 src_cksum_LDADD = $(LDADD)
116 src_comm_LDADD = $(LDADD)
117 src_nproc_LDADD = $(LDADD)
118 src_cp_LDADD = $(LDADD)
119 if !SINGLE_BINARY
120 src_coreutils_LDADD = $(LDADD)
121 endif
122 src_csplit_LDADD = $(LDADD)
123 src_cut_LDADD = $(LDADD)
124 src_date_LDADD = $(LDADD)
125 src_dd_LDADD = $(LDADD)
126 src_df_LDADD = $(LDADD)
127 # See dir_LDADD below
128 src_dircolors_LDADD = $(LDADD)
129 src_dirname_LDADD = $(LDADD)
130 src_du_LDADD = $(LDADD)
131 src_echo_LDADD = $(LDADD)
132 src_env_LDADD = $(LDADD)
133 src_expand_LDADD = $(LDADD)
134 src_expr_LDADD = $(LDADD)
135 src_factor_LDADD = $(LDADD)
136 src_false_LDADD = $(LDADD)
137 src_fmt_LDADD = $(LDADD)
138 src_fold_LDADD = $(LDADD)
139 src_getlimits_LDADD = $(LDADD)
140 src_ginstall_LDADD = $(LDADD)
141 src_groups_LDADD = $(LDADD)
142 src_head_LDADD = $(LDADD)
143 src_hostid_LDADD = $(LDADD)
144 src_hostname_LDADD = $(LDADD)
145 src_id_LDADD = $(LDADD)
146 src_join_LDADD = $(LDADD)
147 src_kill_LDADD = $(LDADD)
148 src_link_LDADD = $(LDADD)
149 src_ln_LDADD = $(LDADD)
150 src_logname_LDADD = $(LDADD)
151 src_ls_LDADD = $(LDADD)
153 # This must *not* depend on anything in lib/, since it is used to generate
154 # src/primes.h. If it depended on libcoreutils.a, that would pull all lib/*.c
155 # into BUILT_SOURCES.
156 src_make_prime_list_LDADD =
158 src_md5sum_LDADD = $(LDADD)
159 src_mkdir_LDADD = $(LDADD)
160 src_mkfifo_LDADD = $(LDADD)
161 src_mknod_LDADD = $(LDADD)
162 src_mktemp_LDADD = $(LDADD)
163 src_mv_LDADD = $(LDADD)
164 src_nice_LDADD = $(LDADD)
165 src_nl_LDADD = $(LDADD)
166 src_nohup_LDADD = $(LDADD)
167 src_numfmt_LDADD = $(LDADD)
168 src_od_LDADD = $(LDADD)
169 src_paste_LDADD = $(LDADD)
170 src_pathchk_LDADD = $(LDADD)
171 src_pinky_LDADD = $(LDADD)
172 src_pr_LDADD = $(LDADD)
173 src_printenv_LDADD = $(LDADD)
174 src_printf_LDADD = $(LDADD)
175 src_ptx_LDADD = $(LDADD)
176 src_pwd_LDADD = $(LDADD)
177 src_readlink_LDADD = $(LDADD)
178 src_realpath_LDADD = $(LDADD)
179 src_rm_LDADD = $(LDADD)
180 src_rmdir_LDADD = $(LDADD)
181 src_runcon_LDADD = $(LDADD)
182 src_seq_LDADD = $(LDADD)
183 src_sha1sum_LDADD = $(LDADD)
184 src_sha224sum_LDADD = $(LDADD)
185 src_sha256sum_LDADD = $(LDADD)
186 src_sha384sum_LDADD = $(LDADD)
187 src_sha512sum_LDADD = $(LDADD)
188 src_shred_LDADD = $(LDADD)
189 src_shuf_LDADD = $(LDADD)
190 src_sleep_LDADD = $(LDADD)
191 src_sort_LDADD = $(LDADD)
192 src_split_LDADD = $(LDADD)
193 src_stat_LDADD = $(LDADD)
194 src_stdbuf_LDADD = $(LDADD)
195 src_stty_LDADD = $(LDADD)
196 src_sum_LDADD = $(LDADD)
197 src_sync_LDADD = $(LDADD)
198 src_tac_LDADD = $(LDADD)
199 src_tail_LDADD = $(LDADD)
200 src_tee_LDADD = $(LDADD)
201 src_test_LDADD = $(LDADD)
202 src_timeout_LDADD = $(LDADD)
203 src_touch_LDADD = $(LDADD)
204 src_tr_LDADD = $(LDADD)
205 src_true_LDADD = $(LDADD)
206 src_truncate_LDADD = $(LDADD)
207 src_tsort_LDADD = $(LDADD)
208 src_tty_LDADD = $(LDADD)
209 src_uname_LDADD = $(LDADD)
210 src_unexpand_LDADD = $(LDADD)
211 src_uniq_LDADD = $(LDADD)
212 src_unlink_LDADD = $(LDADD)
213 src_uptime_LDADD = $(LDADD)
214 src_users_LDADD = $(LDADD)
215 # See vdir_LDADD below
216 src_wc_LDADD = $(LDADD)
217 src_who_LDADD = $(LDADD)
218 src_whoami_LDADD = $(LDADD)
219 src_yes_LDADD = $(LDADD)
221 # Synonyms. Recall that Automake transliterates '[' and '/' to '_'.
222 src___LDADD = $(src_test_LDADD)
223 src_dir_LDADD = $(src_ls_LDADD)
224 src_vdir_LDADD = $(src_ls_LDADD)
225 src_chgrp_LDADD = $(src_chown_LDADD)
227 src_cp_LDADD += $(copy_ldadd)
228 src_ginstall_LDADD += $(copy_ldadd)
229 src_mv_LDADD += $(copy_ldadd)
231 src_mv_LDADD += $(remove_ldadd)
232 src_rm_LDADD += $(remove_ldadd)
234 # for eaccess, euidaccess
235 copy_ldadd += $(EUIDACCESS_LIBGEN)
236 remove_ldadd += $(EUIDACCESS_LIBGEN)
237 src_sort_LDADD += $(EUIDACCESS_LIBGEN)
238 src_test_LDADD += $(EUIDACCESS_LIBGEN)
240 # for selinux use
241 copy_ldadd += $(LIB_SELINUX)
242 src_chcon_LDADD += $(LIB_SELINUX)
243 src_ginstall_LDADD += $(LIB_SELINUX)
244 src_id_LDADD += $(LIB_SELINUX)
245 src_id_LDADD += $(LIB_SMACK)
246 src_ls_LDADD += $(LIB_SELINUX)
247 src_ls_LDADD += $(LIB_SMACK)
248 src_mkdir_LDADD += $(LIB_SELINUX)
249 src_mkdir_LDADD += $(LIB_SMACK)
250 src_mkfifo_LDADD += $(LIB_SELINUX)
251 src_mkfifo_LDADD += $(LIB_SMACK)
252 src_mknod_LDADD += $(LIB_SELINUX)
253 src_mknod_LDADD += $(LIB_SMACK)
254 src_runcon_LDADD += $(LIB_SELINUX)
255 src_stat_LDADD += $(LIB_SELINUX)
257 # for nvlist_lookup_uint64_array
258 src_stat_LDADD += $(LIB_NVPAIR)
260 # for gettime, settime, tempname, utimecmp, utimens
261 copy_ldadd += $(CLOCK_TIME_LIB)
262 src_date_LDADD += $(CLOCK_TIME_LIB)
263 src_ginstall_LDADD += $(CLOCK_TIME_LIB)
264 src_ln_LDADD += $(CLOCK_TIME_LIB)
265 src_ls_LDADD += $(CLOCK_TIME_LIB)
266 src_mktemp_LDADD += $(CLOCK_TIME_LIB)
267 src_pr_LDADD += $(CLOCK_TIME_LIB)
268 src_sort_LDADD += $(CLOCK_TIME_LIB)
269 src_split_LDADD += $(CLOCK_TIME_LIB)
270 src_tac_LDADD += $(CLOCK_TIME_LIB)
271 src_timeout_LDADD += $(TIMER_TIME_LIB)
272 src_touch_LDADD += $(CLOCK_TIME_LIB)
274 # for gethrxtime
275 src_dd_LDADD += $(GETHRXTIME_LIB)
277 # for cap_get_file
278 src_ls_LDADD += $(LIB_CAP)
280 # for fdatasync
281 src_dd_LDADD += $(FDATASYNC_LIB)
282 src_shred_LDADD += $(FDATASYNC_LIB)
283 src_sync_LDADD += $(FDATASYNC_LIB)
285 # for xnanosleep
286 src_sleep_LDADD += $(NANOSLEEP_LIB)
287 src_sort_LDADD += $(NANOSLEEP_LIB)
288 src_tail_LDADD += $(NANOSLEEP_LIB)
290 # for various GMP functions
291 src_expr_LDADD += $(LIBGMP)
292 src_factor_LDADD += $(LIBGMP)
294 # for getloadavg
295 src_uptime_LDADD += $(GETLOADAVG_LIBS)
297 # for various ACL functions
298 copy_ldadd += $(LIB_ACL)
299 src_ls_LDADD += $(FILE_HAS_ACL_LIB)
301 # for various xattr functions
302 copy_ldadd += $(LIB_XATTR)
304 # for print_unicode_char
305 src_printf_LDADD += $(LIBICONV)
307 # for libcrypto hash routines
308 src_md5sum_LDADD += $(LIB_CRYPTO)
309 src_sort_LDADD += $(LIB_DL) $(LIB_CRYPTO)
310 src_sha1sum_LDADD += $(LIB_CRYPTO)
311 src_sha224sum_LDADD += $(LIB_CRYPTO)
312 src_sha256sum_LDADD += $(LIB_CRYPTO)
313 src_sha384sum_LDADD += $(LIB_CRYPTO)
314 src_sha512sum_LDADD += $(LIB_CRYPTO)
315 src_cksum_LDADD += $(LIB_CRYPTO)
317 # for canon_host
318 src_pinky_LDADD += $(GETADDRINFO_LIB)
319 src_who_LDADD += $(GETADDRINFO_LIB)
321 # for gethostname, uname
322 src_hostname_LDADD += $(GETHOSTNAME_LIB)
323 src_uname_LDADD += $(GETHOSTNAME_LIB)
325 # for read_utmp
326 src_pinky_LDADD += $(READUTMP_LIB)
327 src_uptime_LDADD += $(READUTMP_LIB)
328 src_users_LDADD += $(READUTMP_LIB)
329 src_who_LDADD += $(READUTMP_LIB)
331 # for strsignal
332 src_kill_LDADD += $(LIBTHREAD)
334 # for pthread-cond, pthread-mutex, pthread-thread
335 src_sort_LDADD += $(LIBPMULTITHREAD)
337 # for pthread_sigmask
338 src_sort_LDADD += $(PTHREAD_SIGMASK_LIB)
340 # Get the release year from lib/version-etc.c.
341 RELEASE_YEAR = \
342 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
343 $(top_srcdir)/lib/version-etc.c`
345 selinux_sources = \
346 src/selinux.c \
347 src/selinux.h
349 copy_sources = \
350 src/copy.c \
351 src/cp-hash.c \
352 src/force-link.c \
353 src/force-link.h
355 # Use 'ginstall' in the definition of PROGRAMS and in dependencies to avoid
356 # confusion with the 'install' target. The install rule transforms 'ginstall'
357 # to install before applying any user-specified name transformations.
359 # Don't apply prefix transformations to libstdbuf shared lib
360 # as that's not generally needed, and we need to reference the
361 # name directly in LD_PRELOAD etc. In general it's surprising
362 # that $(transform) is applied to libexec at all given that is
363 # for internal package naming, not privy to $(transform).
365 transform = s/ginstall/install/;/libstdbuf/!$(program_transform_name)
367 src_ginstall_SOURCES = src/install.c src/prog-fprintf.c $(copy_sources) \
368 $(selinux_sources)
370 # This is for the '[' program. Automake transliterates '[' and '/' to '_'.
371 src___SOURCES = src/lbracket.c
373 nodist_src_coreutils_SOURCES = src/coreutils.h
374 src_coreutils_SOURCES = src/coreutils.c
376 src_cp_SOURCES = src/cp.c $(copy_sources) $(selinux_sources)
377 src_date_SOURCES = src/date.c src/show-date.c
378 src_dir_SOURCES = src/ls.c src/ls-dir.c
379 src_du_SOURCES = src/du.c src/show-date.c
380 src_env_SOURCES = src/env.c src/operand2sig.c
381 src_vdir_SOURCES = src/ls.c src/ls-vdir.c
382 src_id_SOURCES = src/id.c src/group-list.c
383 src_groups_SOURCES = src/groups.c src/group-list.c
384 src_ls_SOURCES = src/ls.c src/ls-ls.c
385 src_ln_SOURCES = src/ln.c \
386 src/force-link.c src/force-link.h \
387 src/relpath.c src/relpath.h
388 src_chown_SOURCES = src/chown.c src/chown-core.c src/chown-chown.c
389 src_chgrp_SOURCES = src/chown.c src/chown-core.c src/chown-chgrp.c
390 src_kill_SOURCES = src/kill.c src/operand2sig.c
391 src_realpath_SOURCES = src/realpath.c src/relpath.c src/relpath.h
392 src_timeout_SOURCES = src/timeout.c src/operand2sig.c
394 src_mv_SOURCES = src/mv.c src/remove.c $(copy_sources) $(selinux_sources)
395 src_rm_SOURCES = src/rm.c src/remove.c
397 src_mkdir_SOURCES = src/mkdir.c src/prog-fprintf.c $(selinux_sources)
398 src_rmdir_SOURCES = src/rmdir.c src/prog-fprintf.c
400 src_mkfifo_SOURCES = src/mkfifo.c $(selinux_sources)
401 src_mknod_SOURCES = src/mknod.c $(selinux_sources)
403 src_df_SOURCES = src/df.c src/find-mount-point.c
404 src_stat_SOURCES = src/stat.c src/find-mount-point.c
406 src_uname_SOURCES = src/uname.c src/uname-uname.c
407 src_arch_SOURCES = src/uname.c src/uname-arch.c
409 src_cut_SOURCES = src/cut.c src/set-fields.c
410 src_numfmt_SOURCES = src/numfmt.c src/set-fields.c
412 src_split_SOURCES = src/split.c src/temp-stream.c
413 src_tac_SOURCES = src/tac.c src/temp-stream.c
415 src_tail_SOURCES = src/tail.c src/iopoll.c
416 src_tee_SOURCES = src/tee.c src/iopoll.c
418 src_sum_SOURCES = src/sum.c src/sum.h src/digest.c
419 src_sum_CPPFLAGS = -DHASH_ALGO_SUM=1 $(AM_CPPFLAGS)
421 src_md5sum_SOURCES = src/digest.c
422 src_md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
423 src_sha1sum_SOURCES = src/digest.c
424 src_sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
425 src_sha224sum_SOURCES = src/digest.c
426 src_sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
427 src_sha256sum_SOURCES = src/digest.c
428 src_sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
429 src_sha384sum_SOURCES = src/digest.c
430 src_sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
431 src_sha512sum_SOURCES = src/digest.c
432 src_sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
433 src_b2sum_CPPFLAGS = -DHASH_ALGO_BLAKE2=1 -DHAVE_CONFIG_H $(AM_CPPFLAGS)
434 src_b2sum_SOURCES = src/digest.c \
435 src/blake2/blake2.h src/blake2/blake2-impl.h \
436 src/blake2/blake2b-ref.c \
437 src/blake2/b2sum.c src/blake2/b2sum.h
439 src_cksum_SOURCES = $(src_b2sum_SOURCES) src/sum.c src/sum.h \
440 src/cksum.c src/cksum.h src/crctab.c
441 src_cksum_CPPFLAGS = -DHASH_ALGO_CKSUM=1 -DHAVE_CONFIG_H $(AM_CPPFLAGS)
442 if USE_PCLMUL_CRC32
443 noinst_LIBRARIES += src/libcksum_pclmul.a
444 src_libcksum_pclmul_a_SOURCES = src/cksum_pclmul.c src/cksum.h
445 cksum_pclmul_ldadd = src/libcksum_pclmul.a
446 src_cksum_LDADD += $(cksum_pclmul_ldadd)
447 src_libcksum_pclmul_a_CFLAGS = -mavx -mpclmul $(AM_CFLAGS)
448 endif
450 src_base64_SOURCES = src/basenc.c
451 src_base64_CPPFLAGS = -DBASE_TYPE=64 $(AM_CPPFLAGS)
452 src_base32_SOURCES = src/basenc.c
453 src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS)
454 src_basenc_SOURCES = src/basenc.c
455 src_basenc_CPPFLAGS = -DBASE_TYPE=42 $(AM_CPPFLAGS)
457 src_expand_SOURCES = src/expand.c src/expand-common.c
458 src_unexpand_SOURCES = src/unexpand.c src/expand-common.c
460 src_wc_SOURCES = src/wc.c
461 if USE_AVX2_WC_LINECOUNT
462 noinst_LIBRARIES += src/libwc_avx2.a
463 src_libwc_avx2_a_SOURCES = src/wc_avx2.c
464 wc_avx2_ldadd = src/libwc_avx2.a
465 src_wc_LDADD += $(wc_avx2_ldadd)
466 src_libwc_avx2_a_CFLAGS = -mavx2 $(AM_CFLAGS)
467 endif
469 # Ensure we don't link against libcoreutils.a as that lib is
470 # not compiled with -fPIC which causes issues on 64 bit at least
471 src_libstdbuf_so_LDADD = $(LIBINTL)
473 # Note libstdbuf is only compiled if GCC is available
474 # (as per the check in configure.ac), so these flags should be available.
475 # libtool is probably required to relax this dependency.
476 src_libstdbuf_so_LDFLAGS = -shared
477 src_libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS)
479 BUILT_SOURCES += src/coreutils.h
480 if SINGLE_BINARY
481 # Single binary dependencies
482 src_coreutils_CFLAGS = -DSINGLE_BINARY $(AM_CFLAGS)
483 #src_coreutils_LDFLAGS = $(AM_LDFLAGS)
484 src_coreutils_LDADD = $(single_binary_deps) $(LDADD) $(single_binary_libs)
485 EXTRA_src_coreutils_DEPENDENCIES = $(single_binary_deps)
487 include $(top_srcdir)/src/single-binary.mk
489 # Creates symlinks or shebangs to the installed programs when building
490 # coreutils single binary.
491 EXTRA_src_coreutils_DEPENDENCIES += src/coreutils_$(single_binary_install_type)
492 endif SINGLE_BINARY
494 CLEANFILES += src/coreutils_symlinks
495 src/coreutils_symlinks: Makefile
496 $(AM_V_GEN)touch $@
497 $(AM_V_at)${MKDIR_P} src
498 $(AM_V_at)for i in x $(single_binary_progs); do \
499 test $$i = x && continue; \
500 rm -f src/$$i$(EXEEXT) || exit $$?; \
501 $(LN_S) -s coreutils$(EXEEXT) src/$$i$(EXEEXT) || exit $$?; \
502 done
504 CLEANFILES += src/coreutils_shebangs
505 src/coreutils_shebangs: Makefile
506 $(AM_V_GEN)touch $@
507 $(AM_V_at)${MKDIR_P} src
508 $(AM_V_at)for i in x $(single_binary_progs); do \
509 test $$i = x && continue; \
510 rm -f src/$$i$(EXEEXT) || exit $$?; \
511 printf '#!%s --coreutils-prog-shebang=%s\n' \
512 $(abs_top_builddir)/src/coreutils$(EXEEXT) $$i \
513 >src/$$i$(EXEEXT) || exit $$?; \
514 chmod a+x,a-w src/$$i$(EXEEXT) || exit $$?; \
515 done
517 clean-local:
518 $(AM_V_at)for i in x $(single_binary_progs); do \
519 test $$i = x && continue; \
520 rm -f src/$$i$(EXEEXT) || exit $$?; \
521 done
524 BUILT_SOURCES += src/dircolors.h
525 src/dircolors.h: src/dcgen src/dircolors.hin
526 $(AM_V_GEN)rm -f $@ $@-t
527 $(AM_V_at)${MKDIR_P} src
528 $(AM_V_at)$(PERL) -w -- $(srcdir)/src/dcgen \
529 $(srcdir)/src/dircolors.hin > $@-t
530 $(AM_V_at)chmod a-w $@-t
531 $(AM_V_at)mv $@-t $@
533 # This file is built by maintainers. It's architecture-independent,
534 # and it needs to be built on a widest-known-int architecture, so it's
535 # built only if absent. It is not cleaned because we don't want to
536 # insist that maintainers must build on hosts that support the widest
537 # known ints (currently 128-bit).
538 BUILT_SOURCES += $(top_srcdir)/src/primes.h
539 $(top_srcdir)/src/primes.h:
540 $(AM_V_at)${MKDIR_P} src
541 $(MAKE) src/make-prime-list$(EXEEXT)
542 $(AM_V_GEN)rm -f $@ $@-t
543 $(AM_V_at)src/make-prime-list$(EXEEXT) 5000 > $@-t
544 $(AM_V_at)chmod a-w $@-t
545 $(AM_V_at)mv $@-t $@
547 # false exits nonzero even with --help or --version.
548 # test doesn't support --help or --version.
549 # Tell automake to exempt then from that installcheck test.
550 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = src/false src/test
552 # Compare fs.h with the list of file system names/magic-numbers in the
553 # Linux statfs man page. This target prints any new name/number pairs.
554 # Also compare against /usr/include/linux/magic.h
555 .PHONY: src/fs-magic-compare
556 src/fs-magic-compare: src/fs-magic src/fs-kernel-magic src/fs-def
557 @join -v1 -t@ src/fs-magic src/fs-def
558 @join -v1 -t@ src/fs-kernel-magic src/fs-def
560 CLEANFILES += src/fs-def
561 src/fs-def: src/fs.h
562 @grep '^# *define ' src/fs.h | $(ASSORT) > $@-t && mv $@-t $@
564 # Massage bits of the statfs man page and definitions from
565 # /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
566 fs_normalize_perl_subst = \
567 -e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
568 -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
569 -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
570 -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
571 -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
572 -e 's/CIFS_MAGIC_NUMBER/CIFS/;' \
573 -e 's/AFS_FS/KAFS/;' \
574 -e 's/(_SUPER)?_MAGIC//;' \
575 -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
576 -e 's/(\s+0x)(\X{2})\b/$${1}00$$2/;' \
577 -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
578 -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
579 -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
580 -e 's/^\s+//;' \
581 -e 's/^\043define\s+//;' \
582 -e 's/^_(XIAFS)/$$1/;' \
583 -e 's/^USBDEVICE/USBDEVFS/;' \
584 -e 's/NTFS_SB/NTFS/;' \
585 -e 's/^/\043 define S_MAGIC_/;' \
586 -e 's,\s*/\* .*? \*/,,;'
588 CLEANFILES += src/fs-magic
589 src/fs-magic: Makefile
590 @MANPAGER= man statfs \
591 |perl -ne '/File system types:/.../Nobody kno/ and print' \
592 |grep 0x | perl -p \
593 $(fs_normalize_perl_subst) \
594 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
595 | $(ASSORT) \
596 > $@-t && mv $@-t $@
598 DISTCLEANFILES += src/fs-latest-magic.h
599 # This rule currently gets the latest header, but probably isn't general
600 # enough to enable by default.
601 # @kgit='https://git.kernel.org/cgit/linux/kernel/git'; \
602 # wget -q $$kgit/torvalds/linux.git/plain/include/uapi/linux/magic.h \
603 # -O $@
604 src/fs-latest-magic.h:
605 @touch $@
607 CLEANFILES += src/fs-kernel-magic
608 src/fs-kernel-magic: Makefile src/fs-latest-magic.h
609 @perl -ne '/^#define.*0x/ and print' \
610 /usr/include/linux/magic.h src/fs-latest-magic.h \
611 | perl -p \
612 $(fs_normalize_perl_subst) \
613 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
614 | $(ASSORT) -u \
615 > $@-t && mv $@-t $@
617 BUILT_SOURCES += src/fs-is-local.h
618 src/fs-is-local.h: src/stat.c src/extract-magic
619 $(AM_V_GEN)rm -f $@
620 $(AM_V_at)${MKDIR_P} src
621 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
622 --local $(srcdir)/src/stat.c > $@t
623 $(AM_V_at)chmod a-w $@t
624 $(AM_V_at)mv $@t $@
626 BUILT_SOURCES += src/fs.h
627 src/fs.h: src/stat.c src/extract-magic
628 $(AM_V_GEN)rm -f $@
629 $(AM_V_at)${MKDIR_P} src
630 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
631 $(srcdir)/src/stat.c > $@t
632 $(AM_V_at)chmod a-w $@t
633 $(AM_V_at)mv $@t $@
635 BUILT_SOURCES += src/version.c
636 src/version.c: Makefile
637 $(AM_V_GEN)rm -f $@
638 $(AM_V_at)${MKDIR_P} src
639 $(AM_V_at)printf '#include <config.h>\n' > $@t
640 $(AM_V_at)printf '#include "version.h"\n' >> $@t
641 $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
642 $(AM_V_at)chmod a-w $@t
643 $(AM_V_at)mv $@t $@
645 BUILT_SOURCES += src/version.h
646 src/version.h: Makefile
647 $(AM_V_GEN)rm -f $@
648 $(AM_V_at)${MKDIR_P} src
649 $(AM_V_at)printf 'extern char const *Version;\n' > $@t
650 $(AM_V_at)chmod a-w $@t
651 $(AM_V_at)mv $@t $@
653 # Generates a list of macro invocations like:
654 # SINGLE_BINARY_PROGRAM(program_name_str, main_name)
655 # once for each program list on $(single_binary_progs). Note that
656 # for [ the macro invocation is:
657 # SINGLE_BINARY_PROGRAM("[", _)
658 DISTCLEANFILES += src/coreutils.h
659 src/coreutils.h: Makefile
660 $(AM_V_GEN)rm -f $@
661 $(AM_V_at)${MKDIR_P} src
662 $(AM_V_at)for prog in x $(single_binary_progs); do \
663 test $$prog = x && continue; \
664 prog=`basename $$prog`; \
665 main=`echo $$prog | tr '[' '_'`; \
666 echo "SINGLE_BINARY_PROGRAM(\"$$prog\", $$main)"; \
667 done | sort > $@t
668 $(AM_V_at)chmod a-w $@t
669 $(AM_V_at)mv $@t $@
671 DISTCLEANFILES += src/version.c src/version.h
672 MAINTAINERCLEANFILES += $(BUILT_SOURCES)
674 all_programs = \
675 $(bin_PROGRAMS) \
676 $(bin_SCRIPTS) \
677 $(EXTRA_PROGRAMS)
679 pm = progs-makefile
680 pr = progs-readme
681 # Ensure that the list of programs in README matches the list
682 # of programs we can build.
683 check-local: check-README check-duplicate-no-install
684 .PHONY: check-README
685 check-README:
686 $(AM_V_GEN)rm -rf $(pr) $(pm)
687 $(AM_V_at)echo $(all_programs) \
688 | tr -s ' ' '\n' \
689 | sed -e 's,$(EXEEXT)$$,,' \
690 -e 's,^src/,,' \
691 -e 's/^ginstall$$/install/' \
692 | sed /libstdbuf/d \
693 | $(ASSORT) -u > $(pm) && \
694 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
695 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
696 $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm)
698 # Ensure that a by-default-not-installed program (listed in
699 # $(no_install__progs) is not also listed as another $(EXTRA_PROGRAMS)
700 # entry, because if that were to happen, it *would* be installed
701 # by default.
702 .PHONY: check-duplicate-no-install
703 check-duplicate-no-install:
704 $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)' | tr ' ' '\n' | uniq -d`"
706 # Use the just-built 'ginstall', when not cross-compiling.
707 if CROSS_COMPILING
708 cu_install_program = @INSTALL@
709 else
710 cu_install_program = src/ginstall
711 endif
712 INSTALL = $(cu_install_program) -c