1#!/bin/sh
2# Generate lists of all coreutils programs, to be fed both to Autoconf
3# and Automake, and with further distinctions about how and when these
4# programs should be built.  This is useful to avoid duplicating these
5# list definitions among several files ('configure.ac' and
6# 'src/local.mk' at least); such duplication had proved a source of
7# inconsistencies and bugs in the past.
8
9set -u
10set -e
11
12# These are the names of programs that are neither built nor installed
13# by default.  This list is *not* intended for programs like 'who',
14# 'nice', 'chroot', etc., that are built only when certain requisite
15# system features are detected.
16# If you would like to install programs from this list anyway, say A and B,
17# use "--enable-install-program=A,B" when invoking configure.
18disabled_by_default_progs='
19    arch
20    coreutils
21    hostname
22'
23
24# Programs that can be built only when certain requisite system
25# features are detected at configure time.
26build_if_possible_progs='
27    chroot
28    df
29    hostid
30    libstdbuf.so
31    nice
32    pinky
33    stdbuf
34    stty
35    timeout
36    users
37    who
38'
39
40# All the other programs, to be built by default, and that should
41# be buildable without problems on any target system.
42normal_progs='
43    [
44    b2sum
45    base64
46    base32
47    basenc
48    basename
49    cat
50    chcon
51    chgrp
52    chmod
53    chown
54    cksum
55    comm
56    cp
57    csplit
58    cut
59    date
60    dd
61    dir
62    dircolors
63    dirname
64    du
65    echo
66    env
67    expand
68    expr
69    factor
70    false
71    fmt
72    fold
73    ginstall
74    groups
75    head
76    id
77    join
78    kill
79    link
80    ln
81    logname
82    ls
83    md5sum
84    mkdir
85    mkfifo
86    mknod
87    mktemp
88    mv
89    nl
90    nproc
91    nohup
92    numfmt
93    od
94    paste
95    pathchk
96    pr
97    printenv
98    printf
99    ptx
100    pwd
101    readlink
102    realpath
103    rm
104    rmdir
105    runcon
106    seq
107    sha1sum
108    sha224sum
109    sha256sum
110    sha384sum
111    sha512sum
112    shred
113    shuf
114    sleep
115    sort
116    split
117    stat
118    sum
119    sync
120    tac
121    tail
122    tee
123    test
124    touch
125    tr
126    true
127    truncate
128    tsort
129    tty
130    uname
131    unexpand
132    uniq
133    unlink
134    uptime
135    vdir
136    wc
137    whoami
138    yes
139'
140
141me=`echo "$0" | sed 's,.*/,,'`
142msg="Automatically generated by $me.  DO NOT EDIT BY HAND!"
143
144case $#,$1 in
145  1,--autoconf|1,--for-autoconf)
146    echo "dnl $msg"
147    for p in $normal_progs; do
148      test x"$p" = x"[" && p='@<:@'
149      echo "gl_ADD_PROG([optional_bin_progs], [$p])"
150    done
151    # Extra 'echo' to normalize whitespace.
152    echo "no_install_progs_default='`echo $disabled_by_default_progs`'"
153    sed 's/^ *//' <<END
154        # Given the name of a variable containing a space-separated
155        # list of install-by-default programs and the actual list of
156        # do-not-install-by-default programs, modify the former variable
157        # to reflect any "do-install" and "don't-install" requests.
158        # That is, add any program specified via --enable-install-program,
159        # and remove any program specified via --enable-no-install-program.
160        # Note how the second argument below is a literal, with ","
161        # separators.  That is required due to the way the macro works,
162        # and since the corresponding ./configure option argument is
163        # comma-separated on input.
164        gl_INCLUDE_EXCLUDE_PROG([optional_bin_progs], [`\
165          echo $disabled_by_default_progs \
166                                    | sed 's/ /,/g'`])
167END
168    ;;
169  1,--automake|1,--for-automake)
170    echo "## $msg"
171    progsdir=src
172    echo no_install__progs =
173    for p in $disabled_by_default_progs; do
174      echo no_install__progs += $progsdir/$p
175    done
176    echo build_if_possible__progs =
177    for p in $build_if_possible_progs; do
178      echo build_if_possible__progs += $progsdir/$p
179    done
180    echo default__progs =
181    for p in $normal_progs; do
182      echo default__progs += $progsdir/$p
183    done
184    ;;
185  1,--list-progs)
186    for p in $disabled_by_default_progs $build_if_possible_progs \
187        $normal_progs; do
188      echo $p
189    done
190    ;;
191  *)
192    echo "$0: invalid usage" >&2; exit 2
193    ;;
194esac
195
196exit 0
197