ptx: fix an invalid heap reference with short --width
[coreutils.git] / src / local.mk
blob36dfa4e3023f7b675b2c54358b5812e1dbc31925
1 # Make coreutils programs. -*-Makefile-*-
2 # This is included by the top-level Makefile.am.
4 ## Copyright (C) 1990-2016 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 <http://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-core.h \
44 src/copy.h \
45 src/cp-hash.h \
46 src/die.h \
47 src/dircolors.h \
48 src/expand-common.h \
49 src/fiemap.h \
50 src/find-mount-point.h \
51 src/fs.h \
52 src/fs-is-local.h \
53 src/group-list.h \
54 src/ioblksize.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/system.h \
62 src/uname.h
64 EXTRA_DIST += \
65 src/dcgen \
66 src/dircolors.hin \
67 src/primes.h \
68 src/tac-pipe.c \
69 src/extract-magic
71 CLEANFILES += $(SCRIPTS)
73 # Also remove these sometimes-built programs.
74 # For example, even when excluded, they're built via 'sc_check-AUTHORS'
75 # or 'dist'.
76 CLEANFILES += $(no_install__progs)
78 noinst_LIBRARIES += src/libver.a
79 nodist_src_libver_a_SOURCES = src/version.c src/version.h
81 # Tell the linker to omit references to unused shared libraries.
82 AM_LDFLAGS = $(IGNORE_UNUSED_LIBRARIES_CFLAGS)
84 # Extra libraries needed by more than one program. Will be updated later.
85 copy_ldadd =
86 remove_ldadd =
88 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
89 # include modules defining variables like 'optind', so libcoreutils.a
90 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
91 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
92 # replacement functions defined in libcoreutils.a.
93 LDADD = src/libver.a lib/libcoreutils.a $(LIBINTL) lib/libcoreutils.a
95 # First, list all programs, to make listing per-program libraries easier.
96 # See [ below.
97 src_arch_LDADD = $(LDADD)
98 src_base64_LDADD = $(LDADD)
99 src_base32_LDADD = $(LDADD)
100 src_basename_LDADD = $(LDADD)
101 src_cat_LDADD = $(LDADD)
102 src_chcon_LDADD = $(LDADD)
103 src_chgrp_LDADD = $(LDADD)
104 src_chmod_LDADD = $(LDADD)
105 src_chown_LDADD = $(LDADD)
106 src_chroot_LDADD = $(LDADD)
107 src_cksum_LDADD = $(LDADD)
108 src_comm_LDADD = $(LDADD)
109 src_nproc_LDADD = $(LDADD)
110 src_cp_LDADD = $(LDADD)
111 if !SINGLE_BINARY
112 src_coreutils_LDADD = $(LDADD)
113 endif
114 src_csplit_LDADD = $(LDADD)
115 src_cut_LDADD = $(LDADD)
116 src_date_LDADD = $(LDADD)
117 src_dd_LDADD = $(LDADD)
118 src_df_LDADD = $(LDADD)
119 # See dir_LDADD below
120 src_dircolors_LDADD = $(LDADD)
121 src_dirname_LDADD = $(LDADD)
122 src_du_LDADD = $(LDADD)
123 src_echo_LDADD = $(LDADD)
124 src_env_LDADD = $(LDADD)
125 src_expand_LDADD = $(LDADD)
126 src_expr_LDADD = $(LDADD)
127 src_factor_LDADD = $(LDADD)
128 src_false_LDADD = $(LDADD)
129 src_fmt_LDADD = $(LDADD)
130 src_fold_LDADD = $(LDADD)
131 src_getlimits_LDADD = $(LDADD)
132 src_ginstall_LDADD = $(LDADD)
133 src_groups_LDADD = $(LDADD)
134 src_head_LDADD = $(LDADD)
135 src_hostid_LDADD = $(LDADD)
136 src_hostname_LDADD = $(LDADD)
137 src_id_LDADD = $(LDADD)
138 src_join_LDADD = $(LDADD)
139 src_kill_LDADD = $(LDADD)
140 src_link_LDADD = $(LDADD)
141 src_ln_LDADD = $(LDADD)
142 src_logname_LDADD = $(LDADD)
143 src_ls_LDADD = $(LDADD)
145 # This must *not* depend on anything in lib/, since it is used to generate
146 # src/primes.h. If it depended on libcoreutils.a, that would pull all lib/*.c
147 # into BUILT_SOURCES.
148 src_make_prime_list_LDADD =
150 src_md5sum_LDADD = $(LDADD)
151 src_mkdir_LDADD = $(LDADD)
152 src_mkfifo_LDADD = $(LDADD)
153 src_mknod_LDADD = $(LDADD)
154 src_mktemp_LDADD = $(LDADD)
155 src_mv_LDADD = $(LDADD)
156 src_nice_LDADD = $(LDADD)
157 src_nl_LDADD = $(LDADD)
158 src_nohup_LDADD = $(LDADD)
159 src_numfmt_LDADD = $(LDADD)
160 src_od_LDADD = $(LDADD)
161 src_paste_LDADD = $(LDADD)
162 src_pathchk_LDADD = $(LDADD)
163 src_pinky_LDADD = $(LDADD)
164 src_pr_LDADD = $(LDADD)
165 src_printenv_LDADD = $(LDADD)
166 src_printf_LDADD = $(LDADD)
167 src_ptx_LDADD = $(LDADD)
168 src_pwd_LDADD = $(LDADD)
169 src_readlink_LDADD = $(LDADD)
170 src_realpath_LDADD = $(LDADD)
171 src_rm_LDADD = $(LDADD)
172 src_rmdir_LDADD = $(LDADD)
173 src_runcon_LDADD = $(LDADD)
174 src_seq_LDADD = $(LDADD)
175 src_sha1sum_LDADD = $(LDADD)
176 src_sha224sum_LDADD = $(LDADD)
177 src_sha256sum_LDADD = $(LDADD)
178 src_sha384sum_LDADD = $(LDADD)
179 src_sha512sum_LDADD = $(LDADD)
180 src_shred_LDADD = $(LDADD)
181 src_shuf_LDADD = $(LDADD)
182 src_sleep_LDADD = $(LDADD)
183 src_sort_LDADD = $(LDADD)
184 src_split_LDADD = $(LDADD)
185 src_stat_LDADD = $(LDADD)
186 src_stdbuf_LDADD = $(LDADD)
187 src_stty_LDADD = $(LDADD)
188 src_sum_LDADD = $(LDADD)
189 src_sync_LDADD = $(LDADD)
190 src_tac_LDADD = $(LDADD)
191 src_tail_LDADD = $(LDADD)
192 src_tee_LDADD = $(LDADD)
193 src_test_LDADD = $(LDADD)
194 src_timeout_LDADD = $(LDADD)
195 src_touch_LDADD = $(LDADD)
196 src_tr_LDADD = $(LDADD)
197 src_true_LDADD = $(LDADD)
198 src_truncate_LDADD = $(LDADD)
199 src_tsort_LDADD = $(LDADD)
200 src_tty_LDADD = $(LDADD)
201 src_uname_LDADD = $(LDADD)
202 src_unexpand_LDADD = $(LDADD)
203 src_uniq_LDADD = $(LDADD)
204 src_unlink_LDADD = $(LDADD)
205 src_uptime_LDADD = $(LDADD)
206 src_users_LDADD = $(LDADD)
207 # See vdir_LDADD below
208 src_wc_LDADD = $(LDADD)
209 src_who_LDADD = $(LDADD)
210 src_whoami_LDADD = $(LDADD)
211 src_yes_LDADD = $(LDADD)
213 # Synonyms. Recall that Automake transliterates '[' and '/' to '_'.
214 src___LDADD = $(src_test_LDADD)
215 src_dir_LDADD = $(src_ls_LDADD)
216 src_vdir_LDADD = $(src_ls_LDADD)
218 src_cp_LDADD += $(copy_ldadd)
219 src_ginstall_LDADD += $(copy_ldadd)
220 src_mv_LDADD += $(copy_ldadd)
222 src_mv_LDADD += $(remove_ldadd)
223 src_rm_LDADD += $(remove_ldadd)
225 # for eaccess, euidaccess
226 copy_ldadd += $(LIB_EACCESS)
227 remove_ldadd += $(LIB_EACCESS)
228 src_sort_LDADD += $(LIB_EACCESS)
229 src_test_LDADD += $(LIB_EACCESS)
231 # for selinux use
232 copy_ldadd += $(LIB_SELINUX)
233 src_chcon_LDADD += $(LIB_SELINUX)
234 src_ginstall_LDADD += $(LIB_SELINUX)
235 src_id_LDADD += $(LIB_SELINUX)
236 src_id_LDADD += $(LIB_SMACK)
237 src_ls_LDADD += $(LIB_SELINUX)
238 src_ls_LDADD += $(LIB_SMACK)
239 src_mkdir_LDADD += $(LIB_SELINUX)
240 src_mkdir_LDADD += $(LIB_SMACK)
241 src_mkfifo_LDADD += $(LIB_SELINUX)
242 src_mkfifo_LDADD += $(LIB_SMACK)
243 src_mknod_LDADD += $(LIB_SELINUX)
244 src_mknod_LDADD += $(LIB_SMACK)
245 src_runcon_LDADD += $(LIB_SELINUX)
246 src_stat_LDADD += $(LIB_SELINUX)
248 # for nvlist_lookup_uint64_array
249 src_stat_LDADD += $(LIB_NVPAIR)
251 # for gettime, settime, utimecmp, utimens
252 copy_ldadd += $(LIB_CLOCK_GETTIME)
253 src_date_LDADD += $(LIB_CLOCK_GETTIME)
254 src_ginstall_LDADD += $(LIB_CLOCK_GETTIME)
255 src_ls_LDADD += $(LIB_CLOCK_GETTIME)
256 src_pr_LDADD += $(LIB_CLOCK_GETTIME)
257 src_timeout_LDADD += $(LIB_TIMER_TIME)
258 src_touch_LDADD += $(LIB_CLOCK_GETTIME)
260 # for gethrxtime
261 src_dd_LDADD += $(LIB_GETHRXTIME)
263 # for cap_get_file
264 src_ls_LDADD += $(LIB_CAP)
266 # for fdatasync
267 src_dd_LDADD += $(LIB_FDATASYNC)
268 src_shred_LDADD += $(LIB_FDATASYNC)
269 src_sync_LDADD += $(LIB_FDATASYNC)
271 # for xnanosleep
272 src_sleep_LDADD += $(LIB_NANOSLEEP)
273 src_sort_LDADD += $(LIB_NANOSLEEP)
274 src_tail_LDADD += $(LIB_NANOSLEEP)
276 # for various GMP functions
277 src_expr_LDADD += $(LIB_GMP)
278 src_factor_LDADD += $(LIB_GMP)
280 # for getloadavg
281 src_uptime_LDADD += $(GETLOADAVG_LIBS)
283 # for various ACL functions
284 copy_ldadd += $(LIB_ACL)
285 src_ls_LDADD += $(LIB_HAS_ACL)
287 # for various xattr functions
288 copy_ldadd += $(LIB_XATTR)
290 # for print_unicode_char, proper_name_utf8
291 src_factor_LDADD += $(LIBICONV)
292 src_printf_LDADD += $(LIBICONV)
293 src_ptx_LDADD += $(LIBICONV)
295 # for libcrypto hash routines
296 src_md5sum_LDADD += $(LIB_CRYPTO)
297 src_sort_LDADD += $(LIB_CRYPTO)
298 src_sha1sum_LDADD += $(LIB_CRYPTO)
299 src_sha224sum_LDADD += $(LIB_CRYPTO)
300 src_sha256sum_LDADD += $(LIB_CRYPTO)
301 src_sha384sum_LDADD += $(LIB_CRYPTO)
302 src_sha512sum_LDADD += $(LIB_CRYPTO)
304 # for canon_host
305 src_pinky_LDADD += $(GETADDRINFO_LIB)
306 src_who_LDADD += $(GETADDRINFO_LIB)
308 # for gethostname, uname
309 src_hostname_LDADD += $(GETHOSTNAME_LIB)
310 src_uname_LDADD += $(GETHOSTNAME_LIB)
312 # for strsignal
313 src_kill_LDADD += $(LIBTHREAD)
315 # for pthread
316 src_sort_LDADD += $(LIB_PTHREAD)
318 # Get the release year from lib/version-etc.c.
319 RELEASE_YEAR = \
320 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
321 $(top_srcdir)/lib/version-etc.c`
323 selinux_sources = \
324 src/selinux.c \
325 src/selinux.h
327 copy_sources = \
328 src/copy.c \
329 src/cp-hash.c \
330 src/extent-scan.c \
331 src/extent-scan.h
333 # Use 'ginstall' in the definition of PROGRAMS and in dependencies to avoid
334 # confusion with the 'install' target. The install rule transforms 'ginstall'
335 # to install before applying any user-specified name transformations.
337 # Don't apply prefix transformations to libstdbuf shared lib
338 # as that's not generally needed, and we need to reference the
339 # name directly in LD_PRELOAD etc. In general it's surprising
340 # that $(transform) is applied to libexec at all given that is
341 # for internal package naming, not privy to $(transform).
343 transform = s/ginstall/install/;/libstdbuf/!$(program_transform_name)
345 src_ginstall_SOURCES = src/install.c src/prog-fprintf.c $(copy_sources) \
346 $(selinux_sources)
348 # This is for the '[' program. Automake transliterates '[' and '/' to '_'.
349 src___SOURCES = src/lbracket.c
351 nodist_src_coreutils_SOURCES = src/coreutils.h
352 src_coreutils_SOURCES = src/coreutils.c
354 src_cp_SOURCES = src/cp.c $(copy_sources) $(selinux_sources)
355 src_dir_SOURCES = src/ls.c src/ls-dir.c
356 src_vdir_SOURCES = src/ls.c src/ls-vdir.c
357 src_id_SOURCES = src/id.c src/group-list.c
358 src_groups_SOURCES = src/groups.c src/group-list.c
359 src_ls_SOURCES = src/ls.c src/ls-ls.c
360 src_ln_SOURCES = src/ln.c src/relpath.c src/relpath.h
361 src_chown_SOURCES = src/chown.c src/chown-core.c
362 src_chgrp_SOURCES = src/chgrp.c src/chown-core.c
363 src_kill_SOURCES = src/kill.c src/operand2sig.c
364 src_realpath_SOURCES = src/realpath.c src/relpath.c src/relpath.h
365 src_timeout_SOURCES = src/timeout.c src/operand2sig.c
367 src_mv_SOURCES = src/mv.c src/remove.c $(copy_sources) $(selinux_sources)
368 src_rm_SOURCES = src/rm.c src/remove.c
370 src_mkdir_SOURCES = src/mkdir.c src/prog-fprintf.c $(selinux_sources)
371 src_rmdir_SOURCES = src/rmdir.c src/prog-fprintf.c
373 src_mkfifo_SOURCES = src/mkfifo.c $(selinux_sources)
374 src_mknod_SOURCES = src/mknod.c $(selinux_sources)
376 src_df_SOURCES = src/df.c src/find-mount-point.c
377 src_stat_SOURCES = src/stat.c src/find-mount-point.c
379 src_uname_SOURCES = src/uname.c src/uname-uname.c
380 src_arch_SOURCES = src/uname.c src/uname-arch.c
382 src_cut_SOURCES = src/cut.c src/set-fields.c
383 src_numfmt_SOURCES = src/numfmt.c src/set-fields.c
385 src_md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
386 src_sha1sum_SOURCES = src/md5sum.c
387 src_sha1sum_CPPFLAGS = -DHASH_ALGO_SHA1=1 $(AM_CPPFLAGS)
388 src_sha224sum_SOURCES = src/md5sum.c
389 src_sha224sum_CPPFLAGS = -DHASH_ALGO_SHA224=1 $(AM_CPPFLAGS)
390 src_sha256sum_SOURCES = src/md5sum.c
391 src_sha256sum_CPPFLAGS = -DHASH_ALGO_SHA256=1 $(AM_CPPFLAGS)
392 src_sha384sum_SOURCES = src/md5sum.c
393 src_sha384sum_CPPFLAGS = -DHASH_ALGO_SHA384=1 $(AM_CPPFLAGS)
394 src_sha512sum_SOURCES = src/md5sum.c
395 src_sha512sum_CPPFLAGS = -DHASH_ALGO_SHA512=1 $(AM_CPPFLAGS)
396 src_b2sum_CPPFLAGS = -include config.h -DHASH_ALGO_BLAKE2=1 \
397 $(AM_CPPFLAGS)
398 src_b2sum_SOURCES = src/md5sum.c \
399 src/blake2/blake2.h src/blake2/blake2-impl.h \
400 src/blake2/blake2b-ref.c \
401 src/blake2/b2sum.c src/blake2/b2sum.h
403 src_base64_CPPFLAGS = -DBASE_TYPE=64 $(AM_CPPFLAGS)
404 src_base32_SOURCES = src/base64.c
405 src_base32_CPPFLAGS = -DBASE_TYPE=32 $(AM_CPPFLAGS)
407 src_ginstall_CPPFLAGS = -DENABLE_MATCHPATHCON=1 $(AM_CPPFLAGS)
409 src_expand_SOURCES = src/expand.c src/expand-common.c
410 src_unexpand_SOURCES = src/unexpand.c src/expand-common.c
412 # Ensure we don't link against libcoreutils.a as that lib is
413 # not compiled with -fPIC which causes issues on 64 bit at least
414 src_libstdbuf_so_LDADD = $(LIBINTL)
416 # Note libstdbuf is only compiled if GCC is available
417 # (as per the check in configure.ac), so these flags should be available.
418 # libtool is probably required to relax this dependency.
419 src_libstdbuf_so_LDFLAGS = -shared
420 src_libstdbuf_so_CFLAGS = -fPIC $(AM_CFLAGS)
422 BUILT_SOURCES += src/coreutils.h
423 if SINGLE_BINARY
424 # Single binary dependencies
425 src_coreutils_CFLAGS = -DSINGLE_BINARY $(AM_CFLAGS)
426 #src_coreutils_LDFLAGS = $(AM_LDFLAGS)
427 src_coreutils_LDADD = $(single_binary_deps) $(LDADD) $(single_binary_libs)
428 src_coreutils_DEPENDENCIES = $(LDADD) $(single_binary_deps)
430 include $(top_srcdir)/src/single-binary.mk
432 # Creates symlinks or shebangs to the installed programs when building
433 # coreutils single binary.
434 EXTRA_src_coreutils_DEPENDENCIES = src/coreutils_$(single_binary_install_type)
435 endif SINGLE_BINARY
437 CLEANFILES += src/coreutils_symlinks
438 src/coreutils_symlinks: Makefile
439 $(AM_V_GEN)touch $@
440 $(AM_V_at)${MKDIR_P} src
441 $(AM_V_at)for i in x $(single_binary_progs); do \
442 test $$i = x && continue; \
443 rm -f src/$$i$(EXEEXT) || exit $$?; \
444 $(LN_S) -s coreutils$(EXEEXT) src/$$i$(EXEEXT) || exit $$?; \
445 done
447 CLEANFILES += src/coreutils_shebangs
448 src/coreutils_shebangs: Makefile
449 $(AM_V_GEN)touch $@
450 $(AM_V_at)${MKDIR_P} src
451 $(AM_V_at)for i in x $(single_binary_progs); do \
452 test $$i = x && continue; \
453 rm -f src/$$i$(EXEEXT) || exit $$?; \
454 printf '#!%s --coreutils-prog-shebang=%s\n' \
455 $(abs_top_builddir)/src/coreutils$(EXEEXT) $$i \
456 >src/$$i$(EXEEXT) || exit $$?; \
457 chmod a+x,a-w src/$$i$(EXEEXT) || exit $$?; \
458 done
460 clean-local:
461 $(AM_V_at)for i in x $(single_binary_progs); do \
462 test $$i = x && continue; \
463 rm -f src/$$i$(EXEEXT) || exit $$?; \
464 done
467 BUILT_SOURCES += src/dircolors.h
468 src/dircolors.h: src/dcgen src/dircolors.hin
469 $(AM_V_GEN)rm -f $@ $@-t
470 $(AM_V_at)${MKDIR_P} src
471 $(AM_V_at)$(PERL) -w -- $(srcdir)/src/dcgen \
472 $(srcdir)/src/dircolors.hin > $@-t
473 $(AM_V_at)chmod a-w $@-t
474 $(AM_V_at)mv $@-t $@
476 # This file is built by maintainers. It's architecture-independent,
477 # and it needs to be built on a widest-known-int architecture, so it's
478 # built only if absent. It is not cleaned because we don't want to
479 # insist that maintainers must build on hosts that support the widest
480 # known ints (currently 128-bit).
481 BUILT_SOURCES += $(top_srcdir)/src/primes.h
482 $(top_srcdir)/src/primes.h:
483 $(AM_V_at)${MKDIR_P} src
484 $(MAKE) src/make-prime-list$(EXEEXT)
485 $(AM_V_GEN)rm -f $@ $@-t
486 $(AM_V_at)src/make-prime-list$(EXEEXT) 5000 > $@-t
487 $(AM_V_at)chmod a-w $@-t
488 $(AM_V_at)mv $@-t $@
490 # false exits nonzero even with --help or --version.
491 # test doesn't support --help or --version.
492 # Tell automake to exempt then from that installcheck test.
493 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = src/false src/test
495 # Compare fs.h with the list of file system names/magic-numbers in the
496 # Linux statfs man page. This target prints any new name/number pairs.
497 # Also compare against /usr/include/linux/magic.h
498 .PHONY: src/fs-magic-compare
499 src/fs-magic-compare: src/fs-magic src/fs-kernel-magic src/fs-def
500 @join -v1 -t@ src/fs-magic src/fs-def
501 @join -v1 -t@ src/fs-kernel-magic src/fs-def
503 CLEANFILES += src/fs-def
504 src/fs-def: src/fs.h
505 grep '^# *define ' src/fs.h | $(ASSORT) > $@-t && mv $@-t $@
507 # Massage bits of the statfs man page and definitions from
508 # /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
509 fs_normalize_perl_subst = \
510 -e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
511 -e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
512 -e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
513 -e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
514 -e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
515 -e 's/CIFS_MAGIC_NUMBER/CIFS/;' \
516 -e 's/(_SUPER)?_MAGIC//;' \
517 -e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
518 -e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
519 -e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
520 -e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
521 -e 's/^\s+//;' \
522 -e 's/^\043define\s+//;' \
523 -e 's/^_(XIAFS)/$$1/;' \
524 -e 's/^USBDEVICE/USBDEVFS/;' \
525 -e 's/NTFS_SB/NTFS/;' \
526 -e 's/^/\043 define S_MAGIC_/;' \
527 -e 's,\s*/\* .*? \*/,,;'
529 CLEANFILES += src/fs-magic
530 src/fs-magic: Makefile
531 @MANPAGER= man statfs \
532 |perl -ne '/File system types:/.../Nobody kno/ and print' \
533 |grep 0x | perl -p \
534 $(fs_normalize_perl_subst) \
535 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
536 | $(ASSORT) \
537 > $@-t && mv $@-t $@
539 DISTCLEANFILES += src/fs-latest-magic.h
540 # This rule currently gets the latest header, but probably isn't general
541 # enough to enable by default.
542 # @kgit='https://git.kernel.org/cgit/linux/kernel/git'; \
543 # wget -q $$kgit/torvalds/linux.git/plain/include/uapi/linux/magic.h \
544 # -O $@
545 src/fs-latest-magic.h:
546 @touch $@
548 CLEANFILES += src/fs-kernel-magic
549 src/fs-kernel-magic: Makefile src/fs-latest-magic.h
550 @perl -ne '/^#define.*0x/ and print' \
551 /usr/include/linux/magic.h src/fs-latest-magic.h \
552 | perl -p \
553 $(fs_normalize_perl_subst) \
554 | grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
555 | $(ASSORT) -u \
556 > $@-t && mv $@-t $@
558 BUILT_SOURCES += src/fs-is-local.h
559 src/fs-is-local.h: src/stat.c src/extract-magic
560 $(AM_V_GEN)rm -f $@
561 $(AM_V_at)${MKDIR_P} src
562 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
563 --local $(srcdir)/src/stat.c > $@t
564 $(AM_V_at)chmod a-w $@t
565 $(AM_V_at)mv $@t $@
567 BUILT_SOURCES += src/fs.h
568 src/fs.h: src/stat.c src/extract-magic
569 $(AM_V_GEN)rm -f $@
570 $(AM_V_at)${MKDIR_P} src
571 $(AM_V_at)$(PERL) $(srcdir)/src/extract-magic \
572 $(srcdir)/src/stat.c > $@t
573 $(AM_V_at)chmod a-w $@t
574 $(AM_V_at)mv $@t $@
576 BUILT_SOURCES += src/version.c
577 src/version.c: Makefile
578 $(AM_V_GEN)rm -f $@
579 $(AM_V_at)${MKDIR_P} src
580 $(AM_V_at)printf '#include <config.h>\n' > $@t
581 $(AM_V_at)printf 'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
582 $(AM_V_at)chmod a-w $@t
583 $(AM_V_at)mv $@t $@
585 BUILT_SOURCES += src/version.h
586 src/version.h: Makefile
587 $(AM_V_GEN)rm -f $@
588 $(AM_V_at)${MKDIR_P} src
589 $(AM_V_at)printf 'extern char const *Version;\n' > $@t
590 $(AM_V_at)chmod a-w $@t
591 $(AM_V_at)mv $@t $@
593 # Generates a list of macro invocations like:
594 # SINGLE_BINARY_PROGRAM(program_name_str, main_name)
595 # once for each program list on $(single_binary_progs). Note that
596 # for [ the macro invocation is:
597 # SINGLE_BINARY_PROGRAM("[", _)
598 DISTCLEANFILES += src/coreutils.h
599 src/coreutils.h: Makefile
600 $(AM_V_GEN)rm -f $@
601 $(AM_V_at)${MKDIR_P} src
602 $(AM_V_at)for prog in x $(single_binary_progs); do \
603 test $$prog = x && continue; \
604 prog=`basename $$prog`; \
605 main=`echo $$prog | tr '[' '_'`; \
606 echo "SINGLE_BINARY_PROGRAM(\"$$prog\", $$main)"; \
607 done | sort > $@t
608 $(AM_V_at)chmod a-w $@t
609 $(AM_V_at)mv $@t $@
611 DISTCLEANFILES += src/version.c src/version.h
612 MAINTAINERCLEANFILES += $(BUILT_SOURCES)
614 all_programs = \
615 $(bin_PROGRAMS) \
616 $(bin_SCRIPTS) \
617 $(EXTRA_PROGRAMS)
619 pm = progs-makefile
620 pr = progs-readme
621 # Ensure that the list of programs in README matches the list
622 # of programs we can build.
623 check-local: check-README check-duplicate-no-install
624 .PHONY: check-README
625 check-README:
626 $(AM_V_GEN)rm -rf $(pr) $(pm)
627 $(AM_V_at)echo $(all_programs) \
628 | tr -s ' ' '\n' \
629 | sed -e 's,$(EXEEXT)$$,,' \
630 -e 's,^src/,,' \
631 -e 's/^ginstall$$/install/' \
632 | sed /libstdbuf/d \
633 | $(ASSORT) -u > $(pm) && \
634 sed -n '/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir)/README \
635 | sed -n '/^ */s///p' | tr -s ' ' '\n' > $(pr)
636 $(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm)
638 # Ensure that a by-default-not-installed program (listed in
639 # $(no_install__progs) is not also listed as another $(EXTRA_PROGRAMS)
640 # entry, because if that were to happen, it *would* be installed
641 # by default.
642 .PHONY: check-duplicate-no-install
643 check-duplicate-no-install: src/tr
644 $(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)' | tr ' ' '\n' | uniq -d`"
646 # Use the just-built 'ginstall', when not cross-compiling.
647 if CROSS_COMPILING
648 cu_install_program = @INSTALL_PROGRAM@
649 else
650 cu_install_program = src/ginstall
651 endif
652 INSTALL = $(cu_install_program) -c