summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-09-01 01:46:39 +0200
committerJim Meyering <meyering@redhat.com>2012-09-01 21:25:13 +0200
commit4f2e62ba9fd482375fdc085de71a5c947741d140 (patch)
treed2af441afdd32f8f1167dab183ace72bbaeec2d6
parent1aaa8af9296c5bc7a05047f0114c9be7b3fdfea5 (diff)
downloadcoreutils-4f2e62ba9fd482375fdc085de71a5c947741d140.tar.xz
build: refactor how lists of coreutils programs are defined
This is in preparation of future changes. Still, this patch leaves the build system in a better shape; true, with more indirections, but also with less convoluted and brittle hacks. Unfortunately, this commit also makes some rebuild rules incomplete; that will son be fixed by follow-up patches. * build-aux/gen-lists-of-programs.sh: New, generates autoconf and automake input fragments that define "lists" of all coreutils programs, with further distinctions about how and when these programs should be built (by default; if the system is capable enough; only if the user asks for them explicitly). This is useful to avoid duplicating the definitions of these lists among several files (at least 'configure.ac' 'src/Makefile.am'); such duplication had proved a source of inconsistencies and bugs in the past. And the pre-existing way to avoid such duplication, as implemented in 'configure.ac' before this patch, was overly complex and brittle. * Makefile.am (EXTRA_DIST): Distribute the new script. * bootstrap.conf (bootstrap_post_import_hook): Run the new script to generate 'm4/cu-progs.m4' and 'src/cu-progs.mk'. * .gitignore: Ignore those files. * configure.ac: Include 'm4/cu-progs.m4', and decidedly simplify most of the program lists definition and processing accordingly. * src/Makefile.am: Similarly include 'src/cu-progs.mk', containing definition of variables $(default__progs), $(no_install__progs) and $(build_if_possible__progs). Accordingly ... (no_install__progs, build_if_possible__progs): ... remove. (EXTRA_DIST): Adjust definition. Adjust a comment.
-rw-r--r--.gitignore2
-rw-r--r--Makefile.am1
-rw-r--r--bootstrap.conf6
-rwxr-xr-xbuild-aux/gen-lists-of-programs.sh185
-rw-r--r--configure.ac62
-rw-r--r--src/Makefile.am125
6 files changed, 211 insertions, 170 deletions
diff --git a/.gitignore b/.gitignore
index aad59bd0b..56a9bf40e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -96,6 +96,7 @@
/m4/.cvsignore
/m4/.gitignore
/m4/codeset.m4
+/m4/cu-progs.m4
/m4/fcntl-o.m4
/m4/gettext.m4
/m4/glibc2.m4
@@ -150,6 +151,7 @@
/po/remove-potcdate.sed
/po/remove-potcdate.sin
/po/stamp-po
+/src/cu-progs.mk
/src/version.c
/src/version.h
/stamp-h1
diff --git a/Makefile.am b/Makefile.am
index b47b1c141..f3d6eda57 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -49,6 +49,7 @@ EXTRA_DIST = \
THANKStt.in \
bootstrap \
bootstrap.conf \
+ build-aux/gen-lists-of-programs.sh \
cfg.mk \
dist-check.mk \
maint.mk \
diff --git a/bootstrap.conf b/bootstrap.conf
index 4fc4e67e3..4ef3fc80d 100644
--- a/bootstrap.conf
+++ b/bootstrap.conf
@@ -327,7 +327,11 @@ xz -
bootstrap_post_import_hook ()
{
# Automake requires that ChangeLog exist.
- touch ChangeLog || exit 1
+ touch ChangeLog || return 1
+ # List of coreutils programs. See heading comments in the invoked
+ # script for more info.
+ build-aux/gen-lists-of-programs.sh --autoconf >m4/cu-progs.m4 || return 1
+ build-aux/gen-lists-of-programs.sh --automake >src/cu-progs.mk || return 1
}
bootstrap_epilogue()
diff --git a/build-aux/gen-lists-of-programs.sh b/build-aux/gen-lists-of-programs.sh
new file mode 100755
index 000000000..2db0745bc
--- /dev/null
+++ b/build-aux/gen-lists-of-programs.sh
@@ -0,0 +1,185 @@
+#!/bin/sh
+# Generate lists of all coreutils programs, to be fed both to Autoconf
+# and Automake, and with further distinctions about how and when these
+# programs should be built. This is useful to avoid duplicating the
+# definitions of these list among several files ('configure.ac' and
+# 'src/Makefile.am' at least); such duplication had proved a source of
+# inconsistencies and bugs in the past.
+
+set -u
+set -e
+
+# These are the names of programs that are neither built nor installed
+# by default. This list is *not* intended for programs like 'who',
+# 'nice', 'chroot', etc., that are built only when certain requisite
+# system features are detected.
+# If you would like to install programs from this list anyway, say A and B,
+# use "--enable-install-program=A,B" when invoking configure.
+disabled_by_default_progs='
+ arch
+ hostname
+'
+
+# Programs that can be built only when certain requisite system
+# features are detected. These prerequisites will be looked for
+# at configure runtime.
+build_if_possible_progs='
+ chroot
+ df
+ hostid
+ libstdbuf.so
+ nice
+ pinky
+ stdbuf
+ stty
+ uptime
+ users
+ who
+'
+
+# All the other programs, to be built by default, and that should
+# be buildable without problems on any target system.
+normal_progs='
+ [
+ base64
+ basename
+ cat
+ chcon
+ chgrp
+ chmod
+ chown
+ cksum
+ comm
+ cp
+ csplit
+ cut
+ date
+ dd
+ dir
+ dircolors
+ dirname
+ du
+ echo
+ env
+ expand
+ expr
+ factor
+ false
+ fmt
+ fold
+ ginstall
+ groups
+ head
+ id
+ join
+ kill
+ link
+ ln
+ logname
+ ls
+ md5sum
+ mkdir
+ mkfifo
+ mknod
+ mktemp
+ mv
+ nl
+ nproc
+ nohup
+ od
+ paste
+ pathchk
+ pr
+ printenv
+ printf
+ ptx
+ pwd
+ readlink
+ realpath
+ rm
+ rmdir
+ runcon
+ seq
+ sha1sum
+ sha224sum
+ sha256sum
+ sha384sum
+ sha512sum
+ shred
+ shuf
+ sleep
+ sort
+ split
+ stat
+ sum
+ sync
+ tac
+ tail
+ tee
+ test
+ timeout
+ touch
+ tr
+ true
+ truncate
+ tsort
+ tty
+ uname
+ unexpand
+ uniq
+ unlink
+ vdir
+ wc
+ whoami
+ yes
+'
+
+me=`echo "$0" | sed 's,.*/,,'`
+msg="Automatically generated by $me. DO NOT EDIT BY HAND!"
+
+case $#,$1 in
+ 1,--autoconf|1,--for-autoconf)
+ echo "dnl $msg"
+ for p in $normal_progs; do
+ test x"$p" = x"[" && p='@<:@'
+ echo "gl_ADD_PROG([optional_bin_progs], [$p])"
+ done
+ # Extra 'echo' to normalize whitespace.
+ echo "no_install_progs_default='`echo $disabled_by_default_progs`'"
+ sed 's/^ *//' <<END
+ # Given the name of a variable containing a space-separated
+ # list of install-by-default programs and the actual list
+ # do-not-install-by-default programs, modify the former variable
+ # to reflect any "do-install" and "don't-install" requests.
+ # That is, add any program specified via --enable-install-program,
+ # and remove any program specified via --enable-no-install-program.
+ # Note how the second argument below is a literal, with ","
+ # separators. That is required due to the way the macro works,
+ # and since the corresponding ./configure option argument is
+ # comma-separated on input.
+ gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [`\
+ echo $disabled_by_default_progs \
+ | sed 's/ /,/g'`])
+END
+ ;;
+ 1,--automake|1,--for-automake)
+ echo "## $msg"
+ echo no_install__progs =
+ for p in $disabled_by_default_progs; do
+ echo no_install__progs += $p
+ done
+ echo build_if_possible__progs =
+ for p in $build_if_possible_progs; do
+ echo build_if_possible__progs += $p
+ done
+ echo default__progs =
+ for p in $normal_progs; do
+ echo default__progs += $p
+ done
+ ;;
+ *)
+ echo "$0: invalid usage" >&2; exit 2
+ ;;
+esac
+
+exit 0
diff --git a/configure.ac b/configure.ac
index f93e65e9b..de0dea86b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -412,55 +412,13 @@ if test "$elf_sys" = "yes" && \
fi
############################################################################
-mk="$srcdir/src/Makefile.am"
-# Extract all literal names from the definition of $(EXTRA_PROGRAMS)
-# in $mk but don't expand the variable references.
-# Append each literal name to $optional_bin_progs.
-v=EXTRA_PROGRAMS
-for gl_i in `sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
- | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
- | tr -s '\\015\\012\\\\' ' '`; do
- gl_ADD_PROG([optional_bin_progs], $gl_i)
-done
-
-# As above, extract literal names from the definition of $(no_install__progs)
-# in $mk but don't expand the variable references.
-v=no_install__progs
-t=`sed -n '/^'$v' =/,/[[^\]]$/p' $mk \
- | sed 's/^ *//;/^\$.*/d;/^'$v' =/d' \
- | tr -s '\\015\\012\\\\' ' '`
-# Remove any trailing space.
-no_install_progs_default=`echo "$t"|sed 's/ $//'`
-
-# Unfortunately, due to the way autoconf's AS_HELP_STRING works, the list
-# of default-not-installed programs, "arch hostname", must appear in two
-# places: in this file below, and in $mk. Using "$no_install_progs_default"
-# below cannot work. And we can't substitute the names into $mk because
-# automake needs the literals, too.
-# The compromise is to ensure that the space-separated list extracted
-# above matches the literal 2nd argument below.
-c="$srcdir/configure.ac"
-re='^g''l_INCLUDE_EXCLUDE_PROG(.* [\[\(.*\)\]])'
-t=`sed -n '/'"$re"'/{s/'"$re"'/\1/;s/,/ /gp
-}' $c`
-case $t in
- $no_install_progs_default) ;;
- *) AC_MSG_ERROR([[internal error: g'l_INCLUDE_EXCLUDE_PROG's 2nd arg, $t,
- does not match the list of default-not-installed programs
- ($no_install_progs_default) also recorded in $mk]],
- 1) ;;
-esac
-# Given the name of a variable containing a space-separated list of
-# install-by-default programs and the actual list do-not-install-by-default
-# programs, modify the former variable to reflect any "do-install" and
-# "don't-install" requests.
-# I.e., add any program name specified via --enable-install-program=..., and
-# remove any program name specified via --enable-no-install-program=...
-# Note how the second argument below is a literal, with "," separators.
-# That is required due to the way the macro works, and since the
-# corresponding ./configure option argument is comma-separated on input.
-gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [arch,hostname])
+dnl Autogenerated by the 'gen-lists-of-programs.sh' auxiliary script.
+dnl Issue proper calls to the macros gl_INCLUDE_EXCLUDE_PROG and
+dnl gl_ADD_PROG (updating $optional_bin_progs), and generate the list
+dnl of coreutils programs to be built only upon explicit user request,
+dnl saving that list in the $no_install_progs_default shell variable.
+m4_include([m4/cu-progs.m4])
# Now that we know which programs will actually be built up, figure out
# which optional helper progs should be compiled.
@@ -483,19 +441,15 @@ MAN=`
# Normalize whitespace.
MAN=`echo $MAN`
+NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
+AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /g;s/ $//'`
AC_SUBST([OPTIONAL_BIN_PROGS])
OPTIONAL_PKGLIB_PROGS=`echo "$optional_pkglib_progs " | sed 's/ $//'`
AC_SUBST([OPTIONAL_PKGLIB_PROGS])
-NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
-AC_SUBST([NO_INSTALL_PROGS_DEFAULT])
AM_CONDITIONAL([CROSS_COMPILING], [test "$cross_compiling" = yes])
-# Arrange to rerun configure whenever the file, src/Makefile.am,
-# containing the list of program names changes.
-CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
-AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
############################################################################
# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
diff --git a/src/Makefile.am b/src/Makefile.am
index 9be3acfbc..3b0ef6593 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -15,124 +15,18 @@
## You should have received a copy of the GNU General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
-# These are the names of programs that are not installed by default.
-# This list is *not* intended for programs like who, nice, chroot, etc.,
-# that are built only when certain requisite system features are detected.
-# Hence, if you want to install programs from this list anyway, say A and B,
-# use --enable-install-program=A,B
-no_install__progs = \
- arch hostname
-
-build_if_possible__progs = \
- chroot \
- df \
- hostid \
- libstdbuf.so \
- nice \
- pinky \
- stdbuf \
- stty \
- uptime \
- users \
- who
-
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
+# The list of all programs (separated in different variables to express
+# the how and when they should be installed) is defined in this makefile
+# fragment, autogenerated by the 'gen-lists-of-programs.sh' auxiliary
+# script.
+include $(srcdir)/cu-progs.mk
+
EXTRA_PROGRAMS = \
$(no_install__progs) \
$(build_if_possible__progs) \
- [ \
- base64 \
- basename \
- cat \
- chcon \
- chgrp \
- chmod \
- chown \
- cksum \
- comm \
- cp \
- csplit \
- cut \
- date \
- dd \
- dir \
- dircolors \
- dirname \
- du \
- echo \
- env \
- expand \
- expr \
- factor \
- false \
- fmt \
- fold \
- ginstall \
- groups \
- head \
- id \
- join \
- kill \
- link \
- ln \
- logname \
- ls \
- md5sum \
- mkdir \
- mkfifo \
- mknod \
- mktemp \
- mv \
- nl \
- nproc \
- nohup \
- od \
- paste \
- pathchk \
- pr \
- printenv \
- printf \
- ptx \
- pwd \
- readlink \
- realpath \
- rm \
- rmdir \
- runcon \
- seq \
- sha1sum \
- sha224sum \
- sha256sum \
- sha384sum \
- sha512sum \
- shred \
- shuf \
- sleep \
- sort \
- split \
- stat \
- sum \
- sync \
- tac \
- tail \
- tee \
- test \
- timeout \
- touch \
- tr \
- true \
- truncate \
- tsort \
- tty \
- uname \
- unexpand \
- uniq \
- unlink \
- vdir \
- wc \
- whoami \
- yes
+ $(default__progs)
bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
@@ -620,8 +514,9 @@ check-README:
$(AM_V_at)diff $(pm) $(pr) && rm -rf $(pr) $(pm)
# Ensure that a by-default-not-installed program (listed in
-# $(no_install__progs) is not also listed in $(EXTRA_PROGRAMS), because
-# if that were to happen, it *would* be installed by default.
+# $(no_install__progs) is not also listed as another $(EXTRA_PROGRAMS)
+# entry, because if that were to happen, it *would* be installed
+# by default.
.PHONY: check-duplicate-no-install
check-duplicate-no-install: tr
$(AM_V_GEN)test -z "`echo '$(EXTRA_PROGRAMS)'| ./tr ' ' '\n' | uniq -d`"