From 9826031711c6f4b1a87be1eae665411969dbce47 Mon Sep 17 00:00:00 2001 From: Sebastian Gniazdowski Date: Tue, 19 Jul 2022 20:48:49 +0200 Subject: [PATCH] feat: extend $zpfx support over to cmake, autotools and library loader --- share/config.site | 4 ++++ zinit.zsh | 28 ++++++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 share/config.site diff --git a/share/config.site b/share/config.site new file mode 100644 index 000000000..2d0f79ffb --- /dev/null +++ b/share/config.site @@ -0,0 +1,4 @@ +# Prepend directories carrying libs and headers to appropriate vars +export CPPFLAGS="-I$ZPFX/include $CPPFLAGS" +export LDFLAGS="-L$ZPFX/lib -L$ZPFX/lib64 $LDFLAGS" + \ No newline at end of file diff --git a/zinit.zsh b/zinit.zsh index a68f3b613..cabb881c7 100644 --- a/zinit.zsh +++ b/zinit.zsh @@ -143,6 +143,7 @@ export ZPFX=${~ZPFX} ZSH_CACHE_DIR="${ZSH_CACHE_DIR:-${XDG_CACHE_HOME:-$HOME/.ca PMSPEC=0uUpiPsf [[ -z ${path[(re)$ZPFX/bin]} ]] && [[ -d "$ZPFX/bin" ]] && path=( "$ZPFX/bin" "${path[@]}" ) [[ -z ${path[(re)$ZPFX/sbin]} ]] && [[ -d "$ZPFX/sbin" ]] && path=( "$ZPFX/sbin" "${path[@]}" ) +typeset -gU PATH path # Add completions directory to fpath. [[ -z ${fpath[(re)${ZINIT[COMPLETIONS_DIR]}]} ]] && fpath=( "${ZINIT[COMPLETIONS_DIR]}" "${fpath[@]}" ) @@ -1267,7 +1268,7 @@ builtin setopt noaliases # For compaudit. command chmod go-w "${ZINIT[HOME_DIR]}" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir 2>/dev/null -p $ZPFX/bin $ZPFX/share } [[ ! -d ${ZINIT[PLUGINS_DIR]}/_local---zinit ]] && { command rm -rf "${ZINIT[PLUGINS_DIR]:-${TMPDIR:-/tmp}/132bcaCAB}/_local---zplugin" @@ -1276,7 +1277,7 @@ builtin setopt noaliases command ln -s "${ZINIT[BIN_DIR]}/_zinit" "${ZINIT[PLUGINS_DIR]}/_local---zinit" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir 2>/dev/null -p $ZPFX/bin $ZPFX/share (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 (( ${+functions[.zinit-confirm]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-autoload.zsh" || return 1 @@ -1292,7 +1293,7 @@ builtin setopt noaliases command ln -s "${ZINIT[PLUGINS_DIR]}/_local---zinit/_zinit" "${ZINIT[COMPLETIONS_DIR]}" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir 2>/dev/null -p $ZPFX/bin $ZPFX/share (( ${+functions[.zinit-setup-plugin-dir]} )) || builtin source "${ZINIT[BIN_DIR]}/zinit-install.zsh" || return 1 .zinit-compinit &>/dev/null @@ -1307,7 +1308,7 @@ builtin setopt noaliases command chmod go-w "${ZINIT[SERVICES_DIR]}" # Also set up */bin and ZPFX in general. - command mkdir 2>/dev/null -p $ZPFX/bin + command mkdir 2>/dev/null -p $ZPFX/bin $ZPFX/share } [[ ! -d ${~ZINIT[MAN_DIR]}/man9 ]] && { # Create ZINIT[MAN_DIR]/man{1..9} @@ -1319,6 +1320,11 @@ builtin setopt noaliases command mkdir -p $ZINIT[MAN_DIR]/man1 command cp -f $ZINIT[BIN_DIR]/doc/zinit.1 $ZINIT[MAN_DIR]/man1 } + # Copy Autotools compilation options setting + [[ ! -f $ZPFX/share/config.site ]] && { + command mkdir -p $ZPFX/share + command cp $ZINIT[BIN_DIR]/share/config.site $ZPFX/share + } } # ]]] # FUNCTION: .zinit-load-object [[[ .zinit-load-object() { @@ -1367,6 +1373,9 @@ builtin setopt noaliases local -a opts zparseopts -E -D -a opts f -command || { +zinit-message "{u-warn}Error{b-warn}:{rst} Incorrect options (accepted ones: {opt}-f{rst}, {opt}--command{rst})."; return 1; } local url="$1" limit="$3" + # Ensure that configuration prepared for configure script + local -x CONFIG_SITE="$ZPFX/share/config.site" + [[ -n ${ICE[teleid]} ]] && url="${ICE[teleid]}" # Hide arguments from sourced scripts. Without this calls our "$@" are visible as "$@" # within scripts that we `source`. @@ -1723,6 +1732,9 @@ builtin setopt noaliases builtin set -- [[ -o ksharrays ]] && ___correct=1 + # Configuration prepared for configure script + local -x CONFIG_SITE="$ZPFX/share/config.site" + [[ -n ${ICE[(i)(\!|)(sh|bash|ksh|csh)]}${ICE[opts]} ]] && { local -a ___precm ___precm=( @@ -3325,6 +3337,14 @@ zle -N zi-browse-symbol-pforwards zi-browse-symbol zstyle -s ':zinit:browse-symbol' key ZINIT_TMP || ZINIT_TMP='\eQ' [[ -n $ZINIT_TMP ]] && bindkey $ZINIT_TMP zi-browse-symbol +# Add $ZPFX/lib/pkg-config to PKG_CONFIG_PATH, so that libraries +# installed locally can be found by autotools and cmake. There +# is also $ZPFX/share/config.site file with autotools settings. + +[[ $PKG_CONFIG_PATH != (|*:)$ZPFX/lib(|64)/pkgconfig(|:*) ]]&&PKG_CONFIG_PATH="$ZPFX/lib/pkgconfig:$ZPFX/lib64/pkgconfig:$PKG_CONFIG_PATH" +[[ $CMAKE_PREFIX_PATH != (|*\;)$ZPFX(|\;*) ]]&&CMAKE_PREFIX_PATH="$ZPFX:$CMAKE_PREFIX_PATH" +[[ $LD_LIBRARY_PATH != (|*:)$ZPFX/lib(|64)(|:*) ]]&&LD_LIBRARY_PATH="$ZPFX/lib:$ZPFX/lib64:$LD_LIBRARY_PATH" + # Local Variables: # mode: Shell-Script # sh-indentation: 2