1 # Make coreutils programs. -*-Makefile-*-
2 # This is included by the top-level Makefile.am.
4 ## Copyright (C) 1990-2012 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
26 include $(srcdir)/src
/cu-progs.mk
29 $(no_install__progs
) \
30 $(build_if_possible__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.
49 src
/find-mount-point.h \
70 CLEANFILES
+= $(SCRIPTS
)
72 # Also remove these sometimes-built programs.
73 # For example, even when excluded, they're built via 'sc_check-AUTHORS'
75 CLEANFILES
+= $(no_install__progs
)
77 noinst_LIBRARIES
+= src
/libver.a
78 nodist_src_libver_a_SOURCES
= src
/version.c src
/version.h
80 # Tell the linker to omit references to unused shared libraries.
81 AM_LDFLAGS
= $(IGNORE_UNUSED_LIBRARIES_CFLAGS
)
83 # Extra libraries needed by more than one program. Will be updated later.
87 # Sometimes, the expansion of $(LIBINTL) includes -lc which may
88 # include modules defining variables like 'optind', so libcoreutils.a
89 # must precede $(LIBINTL) in order to ensure we use GNU getopt.
90 # But libcoreutils.a must also follow $(LIBINTL), since libintl uses
91 # replacement functions defined in libcoreutils.a.
92 LDADD
= src
/libver.a lib
/libcoreutils.a
$(LIBINTL
) lib
/libcoreutils.a
94 # First, list all programs, to make listing per-program libraries easier.
96 src_arch_LDADD
= $(LDADD
)
97 src_base64_LDADD
= $(LDADD
)
98 src_basename_LDADD
= $(LDADD
)
99 src_cat_LDADD
= $(LDADD
)
100 src_chcon_LDADD
= $(LDADD
)
101 src_chgrp_LDADD
= $(LDADD
)
102 src_chmod_LDADD
= $(LDADD
)
103 src_chown_LDADD
= $(LDADD
)
104 src_chroot_LDADD
= $(LDADD
)
105 src_cksum_LDADD
= $(LDADD
)
106 src_comm_LDADD
= $(LDADD
)
107 src_nproc_LDADD
= $(LDADD
)
108 src_cp_LDADD
= $(LDADD
)
109 src_csplit_LDADD
= $(LDADD
)
110 src_cut_LDADD
= $(LDADD
)
111 src_date_LDADD
= $(LDADD
)
112 src_dd_LDADD
= $(LDADD
)
113 src_df_LDADD
= $(LDADD
)
114 # See dir_LDADD below
115 src_dircolors_LDADD
= $(LDADD
)
116 src_dirname_LDADD
= $(LDADD
)
117 src_du_LDADD
= $(LDADD
)
118 src_echo_LDADD
= $(LDADD
)
119 src_env_LDADD
= $(LDADD
)
120 src_expand_LDADD
= $(LDADD
)
121 src_expr_LDADD
= $(LDADD
)
122 src_factor_LDADD
= $(LDADD
)
123 src_false_LDADD
= $(LDADD
)
124 src_fmt_LDADD
= $(LDADD
)
125 src_fold_LDADD
= $(LDADD
)
126 src_getlimits_LDADD
= $(LDADD
)
127 src_ginstall_LDADD
= $(LDADD
)
128 src_groups_LDADD
= $(LDADD
)
129 src_head_LDADD
= $(LDADD
)
130 src_hostid_LDADD
= $(LDADD
)
131 src_hostname_LDADD
= $(LDADD
)
132 src_id_LDADD
= $(LDADD
)
133 src_join_LDADD
= $(LDADD
)
134 src_kill_LDADD
= $(LDADD
)
135 src_link_LDADD
= $(LDADD
)
136 src_ln_LDADD
= $(LDADD
)
137 src_logname_LDADD
= $(LDADD
)
138 src_ls_LDADD
= $(LDADD
)
140 # This must *not* depend on anything in lib/, since it is used to generate
141 # src/primes.h. If it depended on libcoreutils.a, that would pull all lib/*.c
142 # into BUILT_SOURCES.
143 src_make_prime_list_LDADD
=
145 src_md5sum_LDADD
= $(LDADD
)
146 src_mkdir_LDADD
= $(LDADD
)
147 src_mkfifo_LDADD
= $(LDADD
)
148 src_mknod_LDADD
= $(LDADD
)
149 src_mktemp_LDADD
= $(LDADD
)
150 src_mv_LDADD
= $(LDADD
)
151 src_nice_LDADD
= $(LDADD
)
152 src_nl_LDADD
= $(LDADD
)
153 src_nohup_LDADD
= $(LDADD
)
154 src_od_LDADD
= $(LDADD
)
155 src_paste_LDADD
= $(LDADD
)
156 src_pathchk_LDADD
= $(LDADD
)
157 src_pinky_LDADD
= $(LDADD
)
158 src_pr_LDADD
= $(LDADD
)
159 src_printenv_LDADD
= $(LDADD
)
160 src_printf_LDADD
= $(LDADD
)
161 src_ptx_LDADD
= $(LDADD
)
162 src_pwd_LDADD
= $(LDADD
)
163 src_readlink_LDADD
= $(LDADD
)
164 src_realpath_LDADD
= $(LDADD
)
165 src_rm_LDADD
= $(LDADD
)
166 src_rmdir_LDADD
= $(LDADD
)
167 src_runcon_LDADD
= $(LDADD
)
168 src_seq_LDADD
= $(LDADD
)
169 src_setuidgid_LDADD
= $(LDADD
)
170 src_sha1sum_LDADD
= $(LDADD
)
171 src_sha224sum_LDADD
= $(LDADD
)
172 src_sha256sum_LDADD
= $(LDADD
)
173 src_sha384sum_LDADD
= $(LDADD
)
174 src_sha512sum_LDADD
= $(LDADD
)
175 src_shred_LDADD
= $(LDADD
)
176 src_shuf_LDADD
= $(LDADD
)
177 src_sleep_LDADD
= $(LDADD
)
178 src_sort_LDADD
= $(LDADD
)
179 src_split_LDADD
= $(LDADD
)
180 src_stat_LDADD
= $(LDADD
)
181 src_stdbuf_LDADD
= $(LDADD
)
182 src_stty_LDADD
= $(LDADD
)
183 src_sum_LDADD
= $(LDADD
)
184 src_sync_LDADD
= $(LDADD
)
185 src_tac_LDADD
= $(LDADD
)
186 src_tail_LDADD
= $(LDADD
)
187 src_tee_LDADD
= $(LDADD
)
188 src_test_LDADD
= $(LDADD
)
189 src_timeout_LDADD
= $(LDADD
)
190 src_touch_LDADD
= $(LDADD
)
191 src_tr_LDADD
= $(LDADD
)
192 src_true_LDADD
= $(LDADD
)
193 src_truncate_LDADD
= $(LDADD
)
194 src_tsort_LDADD
= $(LDADD
)
195 src_tty_LDADD
= $(LDADD
)
196 src_uname_LDADD
= $(LDADD
)
197 src_unexpand_LDADD
= $(LDADD
)
198 src_uniq_LDADD
= $(LDADD
)
199 src_unlink_LDADD
= $(LDADD
)
200 src_uptime_LDADD
= $(LDADD
)
201 src_users_LDADD
= $(LDADD
)
202 # See vdir_LDADD below
203 src_wc_LDADD
= $(LDADD
)
204 src_who_LDADD
= $(LDADD
)
205 src_whoami_LDADD
= $(LDADD
)
206 src_yes_LDADD
= $(LDADD
)
208 # Synonyms. Recall that Automake transliterates '[' and '/' to '_'.
209 src___LDADD
= $(src_test_LDADD
)
210 src_dir_LDADD
= $(src_ls_LDADD
)
211 src_vdir_LDADD
= $(src_ls_LDADD
)
213 src_cp_LDADD
+= $(copy_ldadd
)
214 src_ginstall_LDADD
+= $(copy_ldadd
)
215 src_mv_LDADD
+= $(copy_ldadd
)
217 src_mv_LDADD
+= $(remove_ldadd
)
218 src_rm_LDADD
+= $(remove_ldadd
)
220 # for eaccess, euidaccess
221 copy_ldadd
+= $(LIB_EACCESS
)
222 remove_ldadd
+= $(LIB_EACCESS
)
223 src_sort_LDADD
+= $(LIB_EACCESS
)
224 src_test_LDADD
+= $(LIB_EACCESS
)
227 copy_ldadd
+= $(LIB_SELINUX
)
228 src_chcon_LDADD
+= $(LIB_SELINUX
)
229 src_ginstall_LDADD
+= $(LIB_SELINUX
)
230 src_id_LDADD
+= $(LIB_SELINUX
)
231 src_ls_LDADD
+= $(LIB_SELINUX
)
232 src_mkdir_LDADD
+= $(LIB_SELINUX
)
233 src_mkfifo_LDADD
+= $(LIB_SELINUX
)
234 src_mknod_LDADD
+= $(LIB_SELINUX
)
235 src_runcon_LDADD
+= $(LIB_SELINUX
)
236 src_stat_LDADD
+= $(LIB_SELINUX
)
238 # for gettime, settime, utimecmp, utimens
239 copy_ldadd
+= $(LIB_CLOCK_GETTIME
)
240 src_date_LDADD
+= $(LIB_CLOCK_GETTIME
)
241 src_ginstall_LDADD
+= $(LIB_CLOCK_GETTIME
)
242 src_ls_LDADD
+= $(LIB_CLOCK_GETTIME
)
243 src_pr_LDADD
+= $(LIB_CLOCK_GETTIME
)
244 src_timeout_LDADD
+= $(LIB_TIMER_TIME
)
245 src_touch_LDADD
+= $(LIB_CLOCK_GETTIME
)
248 src_dd_LDADD
+= $(LIB_GETHRXTIME
)
251 src_ls_LDADD
+= $(LIB_CAP
)
254 src_dd_LDADD
+= $(LIB_FDATASYNC
)
255 src_shred_LDADD
+= $(LIB_FDATASYNC
)
258 src_sleep_LDADD
+= $(LIB_NANOSLEEP
)
259 src_sort_LDADD
+= $(LIB_NANOSLEEP
)
260 src_tail_LDADD
+= $(LIB_NANOSLEEP
)
262 # for various GMP functions
263 src_expr_LDADD
+= $(LIB_GMP
)
264 src_factor_LDADD
+= $(LIB_GMP
)
267 src_uptime_LDADD
+= $(GETLOADAVG_LIBS
)
269 # for various ACL functions
270 copy_ldadd
+= $(LIB_ACL
)
271 src_ls_LDADD
+= $(LIB_ACL
)
273 # for various xattr functions
274 copy_ldadd
+= $(LIB_XATTR
)
276 # for print_unicode_char, proper_name_utf8
277 src_cat_LDADD
+= $(LIBICONV
)
278 src_cp_LDADD
+= $(LIBICONV
)
279 src_df_LDADD
+= $(LIBICONV
)
280 src_du_LDADD
+= $(LIBICONV
)
281 src_factor_LDADD
+= $(LIBICONV
)
282 src_getlimits_LDADD
+= $(LIBICONV
)
283 src_printf_LDADD
+= $(LIBICONV
)
284 src_ptx_LDADD
+= $(LIBICONV
)
285 src_realpath_LDADD
+= $(LIBICONV
)
286 src_split_LDADD
+= $(LIBICONV
)
287 src_stdbuf_LDADD
+= $(LIBICONV
)
288 src_timeout_LDADD
+= $(LIBICONV
)
289 src_truncate_LDADD
+= $(LIBICONV
)
292 src_pinky_LDADD
+= $(GETADDRINFO_LIB
)
293 src_who_LDADD
+= $(GETADDRINFO_LIB
)
295 # for gethostname, uname
296 src_hostname_LDADD
+= $(GETHOSTNAME_LIB
)
297 src_uname_LDADD
+= $(GETHOSTNAME_LIB
)
300 src_kill_LDADD
+= $(LIBTHREAD
)
303 src_sort_LDADD
+= $(LIB_PTHREAD
)
305 # Get the release year from lib/version-etc.c.
307 `sed -n '/.*COPYRIGHT_YEAR = \([0-9][0-9][0-9][0-9]\) };/s//\1/p' \
308 $(top_srcdir)/lib/version-etc.c`
316 # Use 'ginstall' in the definition of PROGRAMS and in dependencies to avoid
317 # confusion with the 'install' target. The install rule transforms 'ginstall'
318 # to install before applying any user-specified name transformations.
320 transform
= s
/ginstall
/install/; $(program_transform_name
)
321 src_ginstall_SOURCES
= src
/install.c src
/prog-fprintf.c
$(copy_sources
)
323 # This is for the '[' program. Automake transliterates '[' and '/' to '_'.
324 src___SOURCES
= src
/lbracket.c
326 src_cp_SOURCES
= src
/cp.c
$(copy_sources
)
327 src_dir_SOURCES
= src
/ls.c src
/ls-dir.c
328 src_vdir_SOURCES
= src
/ls.c src
/ls-vdir.c
329 src_id_SOURCES
= src
/id.c src
/group-list.c
330 src_groups_SOURCES
= src
/groups.c src
/group-list.c
331 src_ls_SOURCES
= src
/ls.c src
/ls-ls.c
332 src_ln_SOURCES
= src
/ln.c src
/relpath.c src
/relpath.h
333 src_chown_SOURCES
= src
/chown.c src
/chown-core.c
334 src_chgrp_SOURCES
= src
/chgrp.c src
/chown-core.c
335 src_kill_SOURCES
= src
/kill.c src
/operand2sig.c
336 src_realpath_SOURCES
= src
/realpath.c src
/relpath.c src
/relpath.h
337 src_timeout_SOURCES
= src
/timeout.c src
/operand2sig.c
339 src_mv_SOURCES
= src
/mv.c src
/remove.c
$(copy_sources
)
340 src_rm_SOURCES
= src
/rm.c src
/remove.c
342 src_mkdir_SOURCES
= src
/mkdir.c src
/prog-fprintf.c
343 src_rmdir_SOURCES
= src
/rmdir.c src
/prog-fprintf.c
345 src_df_SOURCES
= src
/df.c src
/find-mount-point.c
346 src_stat_SOURCES
= src
/stat.c src
/find-mount-point.c
348 src_uname_SOURCES
= src
/uname.c src
/uname-uname.c
349 src_arch_SOURCES
= src
/uname.c src
/uname-arch.c
351 src_md5sum_CPPFLAGS
= -DHASH_ALGO_MD5
=1 $(AM_CPPFLAGS
)
352 src_sha1sum_SOURCES
= src
/md5sum.c
353 src_sha1sum_CPPFLAGS
= -DHASH_ALGO_SHA1
=1 $(AM_CPPFLAGS
)
354 src_sha224sum_SOURCES
= src
/md5sum.c
355 src_sha224sum_CPPFLAGS
= -DHASH_ALGO_SHA224
=1 $(AM_CPPFLAGS
)
356 src_sha256sum_SOURCES
= src
/md5sum.c
357 src_sha256sum_CPPFLAGS
= -DHASH_ALGO_SHA256
=1 $(AM_CPPFLAGS
)
358 src_sha384sum_SOURCES
= src
/md5sum.c
359 src_sha384sum_CPPFLAGS
= -DHASH_ALGO_SHA384
=1 $(AM_CPPFLAGS
)
360 src_sha512sum_SOURCES
= src
/md5sum.c
361 src_sha512sum_CPPFLAGS
= -DHASH_ALGO_SHA512
=1 $(AM_CPPFLAGS
)
363 src_ginstall_CPPFLAGS
= -DENABLE_MATCHPATHCON
=1 $(AM_CPPFLAGS
)
365 # Ensure we don't link against libcoreutils.a as that lib is
366 # not compiled with -fPIC which causes issues on 64 bit at least
367 src_libstdbuf_so_LDADD
=
369 # Note libstdbuf is only compiled if GCC is available
370 # (as per the check in configure.ac), so these flags should be available.
371 # libtool is probably required to relax this dependency.
372 src_libstdbuf_so_LDFLAGS
= -shared
373 src_libstdbuf_so_CFLAGS
= -fPIC
$(AM_CFLAGS
)
375 BUILT_SOURCES
+= src
/dircolors.h
376 src
/dircolors.h
: src
/dcgen src
/dircolors.hin
377 $(AM_V_GEN
)rm -f
$@
$@
-t
378 $(AM_V_at
)$(PERL
) -w
-- $(srcdir)/src
/dcgen \
379 $(srcdir)/src
/dircolors.hin
> $@
-t
380 $(AM_V_at
)chmod a-w
$@
-t
383 # This file is built by maintainers. It's architecture-independent,
384 # and it needs to be built on a widest-known-int architecture, so it's
385 # built only if absent. It is not cleaned because we don't want to
386 # insist that maintainers must build on hosts that support the widest
387 # known ints (currently 128-bit).
388 BUILT_SOURCES
+= $(top_srcdir
)/src
/primes.h
389 $(top_srcdir
)/src
/primes.h
:
390 $(MAKE
) src
/make-prime-list
$(EXEEXT
)
391 $(AM_V_GEN
)rm -f
$@
$@
-t
392 $(AM_V_at
)src
/make-prime-list
$(EXEEXT
) 5000 > $@
-t
393 $(AM_V_at
)chmod a-w
$@
-t
396 # false exits nonzero even with --help or --version.
397 # test doesn't support --help or --version.
398 # Tell automake to exempt then from that installcheck test.
399 AM_INSTALLCHECK_STD_OPTIONS_EXEMPT
= src
/false src
/test
401 # Compare fs.h with the list of file system names/magic-numbers in the
402 # Linux statfs man page. This target prints any new name/number pairs.
403 # Also compare against /usr/include/linux/magic.h
404 .PHONY
: src
/fs-magic-compare
405 src
/fs-magic-compare
: src
/fs-magic src
/fs-kernel-magic src
/fs-def
406 join -v1
-t@ src
/fs-magic src
/fs-def
407 join -v1
-t@ src
/fs-kernel-magic src
/fs-def
409 CLEANFILES
+= src
/fs-def
411 grep
'^# *define ' src
/fs.h |
$(ASSORT
) > $@
-t
&& mv
$@
-t
$@
413 # Massage bits of the statfs man page and definitions from
414 # /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
415 fs_normalize_perl_subst
= \
416 -e
's/MINIX_SUPER_MAGIC\b/MINIX/;' \
417 -e
's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
418 -e
's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
419 -e
's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
420 -e
's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
421 -e
's/CIFS_MAGIC_NUMBER/CIFS/;' \
422 -e
's/(_SUPER)?_MAGIC//;' \
423 -e
's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
424 -e
's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
425 -e
's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
426 -e
's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
428 -e
's/^\043define\s+//;' \
429 -e
's/^_(XIAFS)/$$1/;' \
430 -e
's/^USBDEVICE/USBDEVFS/;' \
431 -e
's/NTFS_SB/NTFS/;' \
432 -e
's/^/\043 define S_MAGIC_/;' \
433 -e
's,\s*/\* .*? \*/,,;'
435 CLEANFILES
+= src
/fs-magic
436 src
/fs-magic
: Makefile
438 |perl
-ne
'/File system types:/.../Nobody kno/ and print' \
440 $(fs_normalize_perl_subst
) \
441 | grep
-Ev
'S_MAGIC_EXT[34]|STACK_END' \
445 CLEANFILES
+= src
/fs-kernel-magic
446 src
/fs-kernel-magic
: Makefile
447 perl
-ne
'/^#define.*0x/ and print' /usr
/include/linux
/magic.h \
449 $(fs_normalize_perl_subst
) \
450 | grep
-Ev
'S_MAGIC_EXT[34]|STACK_END' \
454 BUILT_SOURCES
+= src
/fs-is-local.h
455 src
/fs-is-local.h
: src
/stat.c src
/extract-magic
457 $(AM_V_at
)$(PERL
) $(srcdir)/src
/extract-magic \
458 --local
$(srcdir)/src
/stat.c
> $@t
459 $(AM_V_at
)chmod a-w
$@t
462 BUILT_SOURCES
+= src
/fs.h
463 src
/fs.h
: src
/stat.c src
/extract-magic
465 $(AM_V_at
)$(PERL
) $(srcdir)/src
/extract-magic \
466 $(srcdir)/src
/stat.c
> $@t
467 $(AM_V_at
)chmod a-w
$@t
470 BUILT_SOURCES
+= src
/version.c
471 src
/version.c
: Makefile
473 $(AM_V_at
)printf
'#include <config.h>\n' > $@t
474 $(AM_V_at
)printf
'char const *Version = "$(PACKAGE_VERSION)";\n' >> $@t
475 $(AM_V_at
)chmod a-w
$@t
478 BUILT_SOURCES
+= src
/version.h
479 src
/version.h
: Makefile
481 $(AM_V_at
)printf
'extern char const *Version;\n' > $@t
482 $(AM_V_at
)chmod a-w
$@t
485 DISTCLEANFILES
+= src
/version.c src
/version.h
486 MAINTAINERCLEANFILES
+= $(BUILT_SOURCES
)
495 # Ensure that the list of programs in README matches the list
496 # of programs we can build.
497 check-local
: check-README check-duplicate-no-install
500 $(AM_V_GEN
)rm -rf
$(pr
) $(pm
)
501 $(AM_V_at
)echo
$(all_programs
) \
503 | sed
-e
's,$(EXEEXT)$$,,' \
505 -e
's/^ginstall$$/install/' \
507 |
$(ASSORT
) -u
> $(pm
) && \
508 sed
-n
'/^The programs .* are:/,/^[a-zA-Z]/p' $(top_srcdir
)/README \
509 | sed
-n
'/^ */s///p' | tr
-s
' ' '\n' > $(pr
)
510 $(AM_V_at
)diff
$(pm
) $(pr
) && rm -rf
$(pr
) $(pm
)
512 # Ensure that a by-default-not-installed program (listed in
513 # $(no_install__progs) is not also listed as another $(EXTRA_PROGRAMS)
514 # entry, because if that were to happen, it *would* be installed
516 .PHONY
: check-duplicate-no-install
517 check-duplicate-no-install
: src
/tr
518 $(AM_V_GEN
)test -z
"`echo '$(EXTRA_PROGRAMS)' | tr ' ' '\n' | uniq -d`"
520 # Use the just-built 'ginstall', when not cross-compiling.
522 cu_install_program
= @INSTALL_PROGRAM@
524 cu_install_program
= src
/ginstall
526 INSTALL_PROGRAM
= $(cu_install_program
)