Skip to content

Commit

Permalink
Extend ZPFX support over to CMake, autotools and the system library l…
Browse files Browse the repository at this point in the history
…oader.
  • Loading branch information
psprint committed Feb 17, 2023
1 parent e69cbdd commit 7dbc663
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
4 changes: 4 additions & 0 deletions share/config.site
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add directories carrying libs and headers to appropriate vars
export CPPFLAGS="-I$ZPFX/include $CPPFLAGS"
export LDFLAGS="-L$ZPFX/lib -L$ZPFX/lib64 $LDFLAGS"

28 changes: 24 additions & 4 deletions zinit.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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[@]}" )
Expand Down Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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}
Expand All @@ -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() {
Expand Down Expand Up @@ -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`.
Expand Down Expand Up @@ -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=(
Expand Down Expand Up @@ -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(|:*) ]]&&PKG_CONFIG_PATH="$ZPFX/lib/pkgconfig:$PKG_CONFIG_PATH"
[[ $CMAKE_PREFIX_PATH != (|*\;)$ZPFX(|\;*) ]]&&CMAKE_PREFIX_PATH="$ZPFX:$CMAKE_PREFIX_PATH"
[[ $LD_LIBRARY_PATH != (|*:)$ZPFX(|:*) ]]&&LD_LIBRARY_PATH="$ZPFX/lib:$LD_LIBRARY_PATH"

# Local Variables:
# mode: Shell-Script
# sh-indentation: 2
Expand Down

0 comments on commit 7dbc663

Please sign in to comment.