Add support for enabling/disabling installation of specified programs.
authorJim Meyering <jim@meyering.net>
Tue, 10 Jul 2007 20:37:05 +0000 (22:37 +0200)
committerJim Meyering <jim@meyering.net>
Tue, 10 Jul 2007 20:55:15 +0000 (22:55 +0200)
* NEWS: Mention new configure-time options.
Mention that neither arch nor su is built/installed, by default.
* m4/include-exclude-prog.m4: New file.
* configure.ac: Use new macro, gl_ADD_PROG, rather than
manually appending to OPTIONAL_BIN_PROGS and MAN.
Move the code that adds "df" to the list of programs to build from
m4/jm-macros into this file.
Use gl_INCLUDE_EXCLUDE_PROG, then handle special cases: ginstall, [.
(NO_INSTALL_PROGS_DEFAULT): AC_SUBST it.  Used by man/Makefile.am.
* man/Makefile.am (dist_man_MANS): Remove from this list all man pages
corresponding to "bin" programs. Add $(MAN) instead.
(optional_mans): Remove all uses.
(check-x-vs-1): Adapt to work even though arch and su are typically
no longer built (and neither are their .1 files).
* src/Makefile.am (install_su): Rename from INSTALL_SU, now that
INSTALL_SU has a different meaning. Use the new $(INSTALL_SU) value.

ChangeLog
NEWS
configure.ac
m4/include-exclude-prog.m4 [new file with mode: 0644]
m4/jm-macros.m4
man/Makefile.am
src/Makefile.am

index 371caad..770a0e6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2007-07-10  Jim Meyering  <jim@meyering.net>
+
+       Add support for enabling/disabling installation of specified programs.
+       * NEWS: Mention new configure-time options.
+       Mention that neither arch nor su is built/installed, by default.
+       * m4/include-exclude-prog.m4: New file.
+       * configure.ac: Use new macro, gl_ADD_PROG, rather than
+       manually appending to OPTIONAL_BIN_PROGS and MAN.
+       Move the code that adds "df" to the list of programs to build from
+       m4/jm-macros into this file.
+       Use gl_INCLUDE_EXCLUDE_PROG, then handle special cases: ginstall, [.
+       (NO_INSTALL_PROGS_DEFAULT): AC_SUBST it.  Used by man/Makefile.am.
+       * man/Makefile.am (dist_man_MANS): Remove from this list all man pages
+       corresponding to "bin" programs. Add $(MAN) instead.
+       (optional_mans): Remove all uses.
+       (check-x-vs-1): Adapt to work even though arch and su are typically
+       no longer built (and neither are their .1 files).
+       * src/Makefile.am (install_su): Rename from INSTALL_SU, now that
+       INSTALL_SU has a different meaning. Use the new $(INSTALL_SU) value.
+
 2007-07-10  Karel Zak  <kzak@redhat.com>
 
        New program: arch
diff --git a/NEWS b/NEWS
index 7ae459b..5c83bfd 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,8 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** New programs
 
-  arch: equivalent to uname -m
+  arch: equivalent to uname -m, not installed by default
+  But don't install this program on Solaris systems.
 
 ** Changes in behavior
 
@@ -24,6 +25,17 @@ GNU coreutils NEWS                                    -*- outline -*-
   (though the word count will have no real meaning) rather than many
   error messages.
 
+** New build options
+
+  By default, "make install" no longer attempts to install (or even build) su.
+  To change that, use ./configure --enable-install-program=su.
+  If you also want to install the new "arch" program, do this:
+  ./configure --enable-install-program=arch,su.
+
+  You can inhibit the compilation and installation of selected programs
+  at configure time.  For example, to avoid installing "hostname" and
+  "uptime", use ./configure --enable-no-install-program=hostname,uptime
+
 ** Bug fixes
 
   cp no longer fails to write through a dangling symlink
index e6c3c4c..07e1484 100644 (file)
@@ -41,15 +41,13 @@ coreutils_MACROS
 
 AC_FUNC_FORK
 
+optional_bin_progs=
 AC_CHECK_FUNCS(uname,
-       OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS arch\$(EXEEXT) uname\$(EXEEXT)"
-       MAN="$MAN arch.1 uname.1")
+       gl_ADD_PROG([optional_bin_progs], [uname]))
 AC_CHECK_FUNCS(chroot,
-       OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS chroot\$(EXEEXT)"
-       MAN="$MAN chroot.1")
+       gl_ADD_PROG([optional_bin_progs], [chroot]))
 AC_CHECK_FUNCS(gethostid,
-       OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS hostid\$(EXEEXT)"
-       MAN="$MAN hostid.1")
+       gl_ADD_PROG([optional_bin_progs], [hostid]))
 
 gl_WINSIZE_IN_PTEM
 
@@ -130,18 +128,16 @@ if test $utils_cv_func_setpriority = no; then
 fi
 case $utils_cv_func_setpriority,$ac_cv_func_nice in
 *yes*)
-  OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS nice\$(EXEEXT)"
-  MAN="$MAN nice.1";;
+  gl_ADD_PROG([optional_bin_progs], [nice])
 esac
 
 AC_DEFUN([coreutils_DUMMY_1],
 [
   AC_REQUIRE([gl_READUTMP])
   if test $ac_cv_header_utmp_h = yes || test $ac_cv_header_utmpx_h = yes; then
-    OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS pinky\$(EXEEXT)"
-    OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS users\$(EXEEXT)"
-    OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS who\$(EXEEXT)"
-    MAN="$MAN pinky.1 users.1 who.1"
+    gl_ADD_PROG([optional_bin_progs], [who])
+    gl_ADD_PROG([optional_bin_progs], [users])
+    gl_ADD_PROG([optional_bin_progs], [pinky])
   fi
 ])
 coreutils_DUMMY_1
@@ -172,15 +168,13 @@ if test -z "$have_ut_host"; then
   fi
 fi
 
-GNULIB_BOOT_TIME(
-  [OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS uptime\$(EXEEXT)"
-  MAN="$MAN uptime.1"])
+GNULIB_BOOT_TIME([gl_ADD_PROG([optional_bin_progs], [uptime])])
 
 AC_SYS_POSIX_TERMIOS()
 gl_HEADER_TIOCGWINSZ_NEEDS_SYS_IOCTL
 
 if test $ac_cv_sys_posix_termios = yes; then
-  OPTIONAL_BIN_PROGS="$OPTIONAL_BIN_PROGS stty\$(EXEEXT)" MAN="$MAN stty.1"
+  gl_ADD_PROG([optional_bin_progs], [stty])
 
   AC_MSG_CHECKING(whether termios.h needs _XOPEN_SOURCE)
   AC_CACHE_VAL(su_cv_sys_termios_needs_xopen_source,
@@ -249,6 +243,61 @@ AC_CHECK_DECLS([strtoimax, strtoumax])
 
 cu_LIB_CHECK
 
+# Build df only if there's a point to it.
+if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
+  gl_ADD_PROG([optional_bin_progs], [df])
+fi
+
+############################################################################
+# Extract all literal names from the definition of $(EXTRA_PROGRAMS)
+# in src/Makefile.am, 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' $srcdir/src/Makefile.am \
+    | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
+    | tr -s '\012\\' '  '`; do
+  gl_ADD_PROG([optional_bin_progs], $gl_i)
+done
+
+# As above, extract literal names from the definition of $(no_install__progs)
+# in src/Makefile.am, but don't expand the variable references.
+v=no_install__progs
+t=`sed -n '/^'$v' =/,/[^\]$/p' $srcdir/src/Makefile.am \
+    | sed 's/^  *//;/^\$.*/d;/^'$v' =/d' \
+    | tr -s '\012\\' '  '`
+# Remove any trailing space.
+no_install_progs_default=`echo "$t"|sed 's/ $//'`
+
+# 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=...
+gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [$no_install_progs_default])
+
+# Set INSTALL_SU if su installation has been requested via
+# --enable-install-program=su.
+AC_SUBST([INSTALL_SU])
+case " $optional_bin_progs " in
+  *' su '*) INSTALL_SU=yes ;;
+  *)        INSTALL_SU=no ;;
+esac
+
+# Change ginstall.1 to "install.h" in $MAN.
+MAN=`echo "$MAN"|sed 's/\<ginstall\.1\>/install.1/'`
+
+# Remove [.1, since writing a portable rule for it in man/Makefile.am
+# is not practical.  The sed LHS below uses the autoconf quadrigraph
+# representing '['.
+MAN=`echo "$MAN"|sed 's/\@<:@\.1//'`
+
+OPTIONAL_BIN_PROGS=`echo "$optional_bin_progs "|sed 's/ /\$(EXEEXT) /;s/ $//'`
+AC_SUBST(OPTIONAL_BIN_PROGS)
+NO_INSTALL_PROGS_DEFAULT=$no_install_progs_default
+AC_SUBST(NO_INSTALL_PROGS_DEFAULT)
+############################################################################
+
 AM_GNU_GETTEXT([external], [need-formatstring-macros])
 AM_GNU_GETTEXT_VERSION([0.15])
 
diff --git a/m4/include-exclude-prog.m4 b/m4/include-exclude-prog.m4
new file mode 100644 (file)
index 0000000..c48c70b
--- /dev/null
@@ -0,0 +1,86 @@
+#serial 1
+dnl Copyright (C) 2007 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Jim Meyering.
+
+# Usage: gl_ADD_PROG([prog_list_var_name], [prog_name])
+AC_DEFUN([gl_ADD_PROG],
+[{
+  $1="$$1 $2"
+  MAN="$MAN $2.1"
+}])
+
+# Usage: gl_REMOVE_PROG([prog_list_var_name], [prog_name])
+AC_DEFUN([gl_REMOVE_PROG],
+[{
+  $1=`echo "$$1"|sed 's/\<'"$1"'//;s/  */ /g'`
+  MAN=`echo "$MAN"|sed 's/\<'"$1"'\.1//'`
+}])
+
+# Given the name of a variable containing a space-separated list of
+# install-by-default programs and the list of do-not-install-by-default
+# programs, modify the former variable to reflect "don't-install" and
+# "do-install" requests.
+#
+# Usage: gl_INCLUDE_EXCLUDE_PROG([prog_list_var_name], [NI_prog1])
+AC_DEFUN([gl_INCLUDE_EXCLUDE_PROG],
+[{
+  gl_no_install_progs_default=$2
+  AC_ARG_ENABLE([install-program],
+    [AS_HELP_STRING([--enable-install-program=PROG_LIST],
+                   [install the programs in PROG_LIST (comma-separated,
+                   default: none)])],
+    [gl_do_install_prog=$enableval],
+    [gl_do_install_prog=]
+  )
+
+  # If you want to refrain from installing programs A and B,
+  # use --enable-no-install-program=A,B
+  AC_ARG_ENABLE([no-install-program],
+    [AS_HELP_STRING([--enable-no-install-program=PROG_LIST],
+                   [do NOT install the programs in PROG_LIST (comma-separated,
+                   default: $gl_no_install_progs_default)])],
+    [gl_no_install_prog=$enableval],
+    [gl_no_install_prog=]
+  )
+
+  # For each not-to-be-installed program name, ensure that it's a
+  # valid name, remove it from the list of programs to build/install,
+  # as well as from the list of man pages to install.
+  extra_programs=
+  for gl_i in `echo "$gl_no_install_prog"|tr -s , ' '`; do
+
+    # Fail upon a request to install and not-install the same program.
+    case ",$gl_do_install_prog," in
+      *",$gl_i,"*) AC_MSG_ERROR(['$gl_i' is both included and excluded]) ;;
+    esac
+
+    gl_msg=
+    # Warn about a request not to install a program that is not being
+    # built (which may be because the systems lacks a required interface).
+    case " $$1 " in
+      *" $gl_i "*) gl_REMOVE_PROG([$1], $gl_i) ;;
+      *) gl_msg="'$gl_i' is already not being installed" ;;
+    esac
+
+    if test "$gl_msg" = ''; then
+      # Warn about a request not to install a program that is
+      # already on the default-no-install list.
+      case " $gl_no_install_progs_default " in
+       *" $gl_i "*) gl_msg="by default, '$gl_i' is not installed" ;;
+      esac
+    fi
+
+    test "$gl_msg" != '' && AC_MSG_WARN([$gl_msg])
+  done
+
+  for gl_i in `echo "$gl_do_install_prog"|tr -s , ' '`; do
+    case " $gl_no_install_progs_default " in
+      *" $gl_i "*) gl_ADD_PROG([$1], $gl_i) ;;
+      *) AC_MSG_WARN(['$gl_i' is not an optionally-installable program]) ;;
+    esac
+  done
+}])
index 8ba9aeb..81c7891 100644 (file)
@@ -2,8 +2,7 @@
 
 dnl Misc type-related macros for coreutils.
 
-# Copyright (C) 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software
-# Foundation, Inc.
+# Copyright (C) 1998, 2000-2007 Free Software Foundation, Inc.
 
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -29,9 +28,7 @@ AC_DEFUN([coreutils_MACROS],
   AC_SUBST(GNU_PACKAGE)
 
   AM_MISSING_PROG(HELP2MAN, help2man)
-  AC_SUBST(OPTIONAL_BIN_PROGS)
   AC_SUBST(MAN)
-  AC_SUBST(DF_PROG)
 
   dnl This macro actually runs replacement code.  See isc-posix.m4.
   AC_REQUIRE([AC_ISC_POSIX])dnl
@@ -104,11 +101,6 @@ AC_DEFUN([coreutils_MACROS],
     ])
 
   AC_REQUIRE([AM_LANGINFO_CODESET])
-
-  # Build df only if there's a point to it.
-  if test $gl_cv_list_mounted_fs = yes && test $gl_cv_fs_space = yes; then
-    DF_PROG='df$(EXEEXT)'
-  fi
 ])
 
 AC_DEFUN([gl_CHECK_ALL_HEADERS],
index bf240df..7ae4cbf 100644 (file)
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 # 02110-1301, USA.
 
-dist_man_MANS = \
-  base64.1 basename.1 cat.1 chcon.1 chgrp.1 chmod.1 chown.1 cksum.1 comm.1 \
-  cp.1 csplit.1 cut.1 date.1 dd.1 df.1 dir.1 dircolors.1 dirname.1 du.1 \
-  echo.1 env.1 expand.1 expr.1 factor.1 false.1 fmt.1 fold.1 groups.1 \
-  head.1 hostname.1 id.1 install.1 join.1 kill.1 \
-  link.1 ln.1 logname.1 \
-  ls.1 md5sum.1 mkdir.1 mkfifo.1 mknod.1 mv.1 nl.1 nohup.1 od.1 \
-  paste.1 pathchk.1 pr.1 printenv.1 printf.1 ptx.1 pwd.1 readlink.1 \
-  rm.1 rmdir.1 runcon.1 seq.1 \
-  sha1sum.1 sha224sum.1 sha256sum.1 sha384sum.1 sha512sum.1 \
-  shred.1 shuf.1 sleep.1 sort.1 split.1 stat.1 \
-  su.1 sum.1 sync.1 tac.1 tail.1 tee.1 test.1 touch.1 tr.1 true.1 tsort.1 \
-  tty.1 unexpand.1 uniq.1 unlink.1 vdir.1 wc.1 \
-  whoami.1 yes.1 $(MAN)
-optional_mans = \
-  arch.1 chroot.1 hostid.1 nice.1 pinky.1 stty.1 uname.1 uptime.1 users.1 who.1
-
-
-man_aux = $(dist_man_MANS:.1=.x) $(optional_mans:.1=.x)
-
-EXTRA_DIST = $(man_aux) help2man $(optional_mans)
+dist_man_MANS = groups.1 $(MAN)
+
+man_aux = $(dist_man_MANS:.1=.x)
+
+EXTRA_DIST = $(man_aux) $(NO_INSTALL_PROGS_DEFAULT:%=%.x) help2man
 MAINTAINERCLEANFILES = $(dist_man_MANS)
 
 # Depend on configure.ac to get version number changes.
@@ -189,13 +173,16 @@ ASSORT = LC_ALL=C sort
 
 # Ensure that for each .x file in this directory, there is a
 # corresponding .1 file in the definition of $(dist_man_MANS) above.
+# But since that expansion usually lacks programs like su and arch,
+# add them here manually.
 .PHONY: check-x-vs-1
 check-x-vs-1:
        PATH=../src$(PATH_SEPARATOR)$$PATH; export PATH;                \
        t=ls-files.$$$$;                                                \
        (cd $(srcdir) && ls -1 *.x) | sed 's/\.x$$//' | $(ASSORT) > $$t;\
-       echo $(dist_man_MANS) | tr -s ' ' '\n' | sed 's/\.1$$//'        \
-         | $(ASSORT) | diff - $$t || { rm $$t; exit 1; };              \
+       (echo $(dist_man_MANS) $(NO_INSTALL_PROGS_DEFAULT)              \
+         | tr -s ' ' '\n' | sed 's/\.1$$//')                           \
+         | $(ASSORT) -u | diff - $$t || { rm $$t; exit 1; };           \
        rm $$t
 
 all_programs =                                                         \
index 5a71bb3..c01806e 100644 (file)
 ## along with this program; if not, write to the Free Software Foundation,
 ## Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-EXTRA_PROGRAMS = chroot df hostid nice pinky stty su uname uptime users who \
-  arch
-
-bin_SCRIPTS = groups
-bin_PROGRAMS = [ chcon chgrp chown chmod cp dd dircolors du \
+# 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 su
+
+build_if_possible__progs = \
+  chroot df hostid nice pinky stty su uname uptime users who
+
+EXTRA_PROGRAMS = \
+  $(no_install__progs) \
+  $(build_if_possible__progs) \
+  [ chcon chgrp chown chmod cp dd dircolors du \
   ginstall link ln dir vdir ls mkdir \
   mkfifo mknod mv nohup readlink rm rmdir shred stat sync touch unlink \
   cat cksum comm csplit cut expand fmt fold head join md5sum \
@@ -30,8 +40,10 @@ bin_PROGRAMS = [ chcon chgrp chown chmod cp dd dircolors du \
   hostname id kill logname pathchk printenv printf pwd \
   runcon seq sleep tee \
   test true tty whoami yes \
-  base64 \
-  $(OPTIONAL_BIN_PROGS) $(DF_PROG)
+  base64
+
+bin_SCRIPTS = groups
+bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
 
 noinst_PROGRAMS = setuidgid
 
@@ -148,17 +160,21 @@ installed_su = $(DESTDIR)$(bindir)/`echo su|sed '$(transform)'`
 
 setuid_root_mode = a=rx,u+s
 
-INSTALL_SU = \
-  p=su; \
-  echo " $(INSTALL_PROGRAM) $$p $(installed_su)"; \
-  $(INSTALL_PROGRAM) $$p $(installed_su); \
-  echo " chown root $(installed_su)"; \
-  chown root $(installed_su); \
-  echo " chmod $(setuid_root_mode) $(installed_su)"; \
-  chmod $(setuid_root_mode) $(installed_su)
+install_su =                                           \
+  if test "$(INSTALL_SU)" = yes; then                  \
+    p=su;                                              \
+    echo " $(INSTALL_PROGRAM) $$p $(installed_su)";    \
+    $(INSTALL_PROGRAM) $$p $(installed_su);            \
+    echo " chown root $(installed_su)";                        \
+    chown root $(installed_su);                                \
+    echo " chmod $(setuid_root_mode) $(installed_su)"; \
+    chmod $(setuid_root_mode) $(installed_su)          \
+  else                                                 \
+    :;                                                 \
+  fi
 
 install-root: su$(EXEEXT)
-       @$(INSTALL_SU)
+       @$(install_su)
 
 install-exec-local: su$(EXEEXT)
        @TMPFILE=$(DESTDIR)$(bindir)/.su-$$$$; \
@@ -172,7 +188,7 @@ install-exec-local: su$(EXEEXT)
          && can_create_suid_root_executable=yes; \
        rm -f $$TMPFILE; \
        if test $$can_create_suid_root_executable = yes; then \
-         $(INSTALL_SU); \
+         $(install_su); \
        else \
          echo "WARNING: insufficient access; not installing su"; \
          echo "NOTE: to install su, run 'make install-root' as root"; \