aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEinhard Leichtfuß <alguien@respiranto.de>2018-12-02 03:24:27 +0100
committerEinhard Leichtfuß <alguien@respiranto.de>2018-12-02 03:24:27 +0100
commit15dad2f4afaa7cecc2c35fa2867e8aadb31e477c (patch)
treeac4e743a619aac9a16504e0237c1977561746443
parentfb20323f9ea34b9edcde372be2f66a20e3b54d6b (diff)
Simplify configure.ac
- Remove unnecessary AC_SUBST. - AC_SUBST([default_confdir]) `- Simplify, paricularly get rid of sed. `- Use local variables. `- Fix prefix=/ resulting in //'s.
-rwxr-xr-xconfigure54
-rw-r--r--configure.ac58
2 files changed, 60 insertions, 52 deletions
diff --git a/configure b/configure
index 7201b7f..82d5c3f 100755
--- a/configure
+++ b/configure
@@ -1717,70 +1717,74 @@ ac_config_files="$ac_config_files ctct"
+# Do not use $(.) notation here, confdir shall allow for shell substitution.
-test -z "$confdir" && confdir='${sysconfdir}/$(TARGET)'
-
+test -z "$confdir" && confdir='${sysconfdir}/${TARGET}'
test -z "$bash_completion_dir" \
&& bash_completion_dir='${datarootdir}/bash-completion/completions'
-if test -z "$default_confdir"; then
- # Ugly, but works:
- # If $prefix is unset by the user, set it temporarily:
- test "$prefix" = NONE && prefix=/usr/local \
- && reset_prefix=true || reset_prefix=false
- _confdir="$(echo "$confdir" \
- | sed -E 's/\$(\(TARGET\)|\{TARGET\})/$PACKAGE_NAME/')"
- default_confdir="$_confdir"
- # Resolve $prefix recursively:
- # Vim has problems with '\"' in "doubled" double quotes after '!=':
- while test "$default_confdir" \
- != "$(eval "printf '%s\n' \"$default_confdir\"")"; do #"
- default_confdir="$(eval "printf '%s\n' \"$default_confdir\"")" #"
- done
- $reset_prefix && prefix=NONE
-fi
+# Used in manpage. Needs to be fully expanded.
+# Use a function to allow for local variables.
+fun() {
+ if test -z "$default_confdir"
+ then
-test -z "$default_datadir" && default_datadir='$HOME/.ctct'
+ # If $prefix is unset by the user, set it to autoconf's default value:
+ test "$prefix" = NONE && local prefix=/usr/local
+ # Prevent //.
+ test "$prefix" = / && local prefix=''
+ local TARGET="$PACKAGE_NAME"
+ default_confdir="$confdir"
-test -z "$default_fallback_editor" && default_fallback_editor=vi
+ # Resolve $confdir recursively (notably including $prefix):
+ while
+ eval "default_confdir_expand=\"$default_confdir\""
+ test "$default_confdir" != "$default_confdir_expand"
+ do
+ default_confdir="$default_confdir_expand"
+ done
+ fi
+}; fun
+test -z "$default_datadir" && default_datadir='$HOME/.ctct'
+
+
+test -z "$default_fallback_editor" && default_fallback_editor=vi
+
+
test -z "$default_user_config_dir" \
&& default_user_config_dir='$HOME/.config/'"$PACKAGE_NAME"
-
test -z "$default_input_program" \
&& default_input_program='cat'
-
test -z "$default_output_program" \
&& default_output_program='cat'
-
test -z "$default_visual_program" \
&& default_visual_program='cat'
-
test -z "$default_confirm_deletion" \
&& default_confirm_deletion=true
-
test -z "$default_confirm_default_yes" \
&& default_confirm_default_yes=false
+
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
diff --git a/configure.ac b/configure.ac
index 96f4cb6..f751d9c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,75 +27,79 @@ AC_CONFIG_FILES(
)
AC_CONFIG_FILES([ctct], [chmod +x ctct])
+
+# Do not use $(.) notation here, confdir shall allow for shell substitution.
AC_ARG_VAR([confdir], ['system wide configuration directory'])
-AC_SUBST([confdir])
-test -z "$confdir" && confdir='${sysconfdir}/$(TARGET)'
+test -z "$confdir" && confdir='${sysconfdir}/${TARGET}'
AC_ARG_VAR([bash_completion_dir],
['directory to store bash-completion script in'])
-AC_SUBST([bash_completion_dir])
test -z "$bash_completion_dir" \
&& bash_completion_dir='${datarootdir}/bash-completion/completions'
+
+# Used in manpage. Needs to be fully expanded.
AC_SUBST([default_confdir])
-if test -z "$default_confdir"; then
- # Ugly, but works:
- # If $prefix is unset by the user, set it temporarily:
- test "$prefix" = NONE && prefix=/usr/local \
- && reset_prefix=true || reset_prefix=false
- _confdir="$(echo "$confdir" \
- | sed -E 's/\$(\(TARGET\)|\{TARGET\})/$PACKAGE_NAME/')"
- default_confdir="$_confdir"
- # Resolve $prefix recursively:
- # Vim has problems with '\"' in "doubled" double quotes after '!=':
- while test "$default_confdir" \
- != "$(eval "printf '%s\n' \"$default_confdir\"")"; do #"
- default_confdir="$(eval "printf '%s\n' \"$default_confdir\"")" #"
- done
- $reset_prefix && prefix=NONE
-fi
+
+# Use a function to allow for local variables.
+fun() {
+ if test -z "$default_confdir"
+ then
+
+ # If $prefix is unset by the user, set it to autoconf's default value:
+ test "$prefix" = NONE && local prefix=/usr/local
+
+ # Prevent //.
+ test "$prefix" = / && local prefix=''
+
+ local TARGET="$PACKAGE_NAME"
+ default_confdir="$confdir"
+
+ # Resolve $confdir recursively (notably including $prefix):
+ while
+ eval "default_confdir_expand=\"$default_confdir\""
+ test "$default_confdir" != "$default_confdir_expand"
+ do
+ default_confdir="$default_confdir_expand"
+ done
+ fi
+}; fun
+
AC_ARG_VAR([default_datadir], ['directory to store contact data in'])
-AC_SUBST([default_datadir])
test -z "$default_datadir" && default_datadir='$HOME/.ctct'
AC_ARG_VAR([default_fallback_editor], ['editor to use if EDITOR is unset'])
-AC_SUBST([default_fallback_editor])
test -z "$default_fallback_editor" && default_fallback_editor=vi
AC_ARG_VAR([default_user_config_dir], ['user configuration directory'])
-AC_SUBST([default_user_config_dir])
test -z "$default_user_config_dir" \
&& default_user_config_dir='$HOME/.config/'"$PACKAGE_NAME"
AC_ARG_VAR([default_input_program],
['the program that newly created or edited contact files get passed to on stdin'])
-AC_SUBST([default_input_program])
test -z "$default_input_program" \
&& default_input_program='cat'
AC_ARG_VAR([default_output_program],
['the program that gets passed the contact files on stdin'])
-AC_SUBST([default_output_program])
test -z "$default_output_program" \
&& default_output_program='cat'
AC_ARG_VAR([default_visual_program],
['the program that is used to display the data'])
-AC_SUBST([default_visual_program])
test -z "$default_visual_program" \
&& default_visual_program='cat'
AC_ARG_VAR([default_confirm_deletion],
['whether to ask for confirmation upon deletion of a contact'])
-AC_SUBST([default_confirm_deletion])
test -z "$default_confirm_deletion" \
&& default_confirm_deletion=true
AC_ARG_VAR([default_confirm_default_yes],
['whether to consider "yes" as answer upon a not answered confirmation'])
-AC_SUBST([default_confirm_default_yes])
test -z "$default_confirm_default_yes" \
&& default_confirm_default_yes=false
+
AC_OUTPUT