1#serial 2 2dnl Copyright (C) 2007-2023 Free Software Foundation, Inc. 3dnl This file is free software; the Free Software Foundation 4dnl gives unlimited permission to copy and/or distribute it, 5dnl with or without modifications, as long as this notice is preserved. 6 7dnl From Jim Meyering. 8 9# Usage: gl_ADD_PROG([prog_list_var_name], [prog_name]) 10AC_DEFUN([gl_ADD_PROG], 11[{ 12 if test -z "$$1"; then 13 $1=$2 14 else 15 $1="$$1 $2" 16 fi 17}]) 18 19# Usage: gl_REMOVE_PROG([prog_list_var_name], [prog_name]) 20AC_DEFUN([gl_REMOVE_PROG], 21[{ 22 $1=`for gl_rem_i in $$1; do 23 test "$gl_rem_i" = "$2" || echo "$gl_rem_i" 24 done | tr '\012' ' ' | sed 's/ $//'; echo` 25}]) 26 27# Given the name of a variable containing a space-separated list of 28# install-by-default programs and the list of do-not-install-by-default 29# programs, modify the former variable to reflect "no-install" and 30# "do-install" requests. The names in the latter list should be comma- 31# separated. 32# 33# Usage: gl_INCLUDE_EXCLUDE_PROG([prog_list_var_name], [no_inst_prog_list]) 34AC_DEFUN([gl_INCLUDE_EXCLUDE_PROG], 35[{ 36 gl_no_install_progs_default=`echo '$2'|sed 's/,/ /g'` 37 AC_ARG_ENABLE([install-program], 38 [AS_HELP_STRING([--enable-install-program=PROG_LIST], 39 [install the programs in PROG_LIST (comma-separated, 40 default: none)])], 41 [gl_do_install_prog=$enableval], 42 [gl_do_install_prog=] 43 ) 44 45 # If you want to refrain from installing programs A and B, 46 # use --enable-no-install-program=A,B 47 AC_ARG_ENABLE([no-install-program], 48 [AS_HELP_STRING([--enable-no-install-program=PROG_LIST], 49 [do NOT install the programs in PROG_LIST 50 (comma-separated, default: $2)])], 51 [gl_no_install_prog=$enableval], 52 [gl_no_install_prog=] 53 ) 54 55 # Convert to space separated lists. 56 gl_do_install_prog=`echo "$gl_do_install_prog"|tr -s , ' '` 57 gl_no_install_prog=`echo "$gl_no_install_prog"|tr -s , ' '` 58 59 # For each not-to-be-installed program name, ensure that it's a 60 # valid name, remove it from the list of programs to build/install, 61 # as well as from the list of man pages to install. 62 for gl_i in $gl_no_install_prog; do 63 64 # Fail upon a request to install and not-install the same program. 65 case " $gl_do_install_prog " in 66 *" $gl_i "*) AC_MSG_ERROR(['$gl_i' is both included and excluded]) ;; 67 esac 68 69 gl_msg= 70 # Warn about a request not to install a program that is not being 71 # built (which may be because the systems lacks a required interface). 72 case " $$1 " in 73 *" $gl_i "*) gl_REMOVE_PROG([$1], $gl_i) ;; 74 *) gl_msg="'$gl_i' is already not being installed" ;; 75 esac 76 77 if test "$gl_msg" = ''; then 78 # Warn about a request not to install a program that is 79 # already on the default-no-install list. 80 case " $gl_no_install_progs_default " in 81 *" $gl_i "*) gl_msg="by default, '$gl_i' is not installed" ;; 82 esac 83 fi 84 85 test "$gl_msg" != '' && AC_MSG_WARN([$gl_msg]) 86 done 87 88 for gl_i in $gl_do_install_prog; do 89 case " $gl_no_install_progs_default " in 90 *" $gl_i "*) gl_ADD_PROG([$1], $gl_i) ;; 91 *) AC_MSG_WARN(['$gl_i' is not an optionally-installable program]) ;; 92 esac 93 done 94}]) 95