| 1 | #!/bin/sh |
| 2 | |
| 3 | SOURCE_DIR="$1" |
| 4 | OUTPUT="$2" |
| 5 | DEPFILE="$3" |
| 6 | |
| 7 | if test -z "$SOURCE_DIR" || ! test -d "$SOURCE_DIR" || test -z "$OUTPUT" |
| 8 | then |
| 9 | echo >&2 "USAGE: $0 <SOURCE_DIR> <OUTPUT> [<DEPFILE>]" |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | print_config_list () { |
| 14 | cat <<EOF |
| 15 | static const char *config_name_list[] = { |
| 16 | EOF |
| 17 | sed -e ' |
| 18 | /^`*[a-zA-Z].*\..*`*::$/ { |
| 19 | /deprecated/d; |
| 20 | s/::$//; |
| 21 | s/`//g; |
| 22 | s/^.*$/ "&",/; |
| 23 | p;}; |
| 24 | d' \ |
| 25 | "$SOURCE_DIR"/Documentation/*config.adoc \ |
| 26 | "$SOURCE_DIR"/Documentation/config/*.adoc | |
| 27 | sort |
| 28 | cat <<EOF |
| 29 | NULL, |
| 30 | }; |
| 31 | EOF |
| 32 | } |
| 33 | |
| 34 | { |
| 35 | echo "/* Automatically generated by generate-configlist.sh */" |
| 36 | echo |
| 37 | echo |
| 38 | print_config_list |
| 39 | } >"$OUTPUT" |
| 40 | |
| 41 | if test -n "$DEPFILE" |
| 42 | then |
| 43 | QUOTED_OUTPUT="$(printf '%s\n' "$OUTPUT" | sed 's,[&/\],\\&,g')" |
| 44 | { |
| 45 | printf '%s' "$QUOTED_OUTPUT: " |
| 46 | printf '%s\n' "$SOURCE_DIR"/Documentation/*config.adoc \ |
| 47 | "$SOURCE_DIR"/Documentation/config/*.adoc | |
| 48 | sed -e 's/[# ]/\\&/g' | |
| 49 | tr '\n' ' ' |
| 50 | printf '\n' |
| 51 | printf '%s:\n' "$SOURCE_DIR"/Documentation/*config.adoc \ |
| 52 | "$SOURCE_DIR"/Documentation/config/*.adoc | |
| 53 | sed -e 's/[# ]/\\&/g' |
| 54 | } >"$DEPFILE" |
| 55 | fi |