背景
自分の環境では,$HOME/.opt下に以下のような感じでコマンドがインストールされている.
これには,見やすかったり削除が簡単だったり,また.opt直下をそのままコピペするだけで環境を移行できるっていった利点があります.
が,しかし,なにせ一個一個のコマンドにパスを通してやらないといけないのでめんどくさいやってられないので,一括でできるようにしてみました.
├── libevent
│ ├── bin
│ ├── include
│ └── lib
├── ncurses
│ ├── bin
│ ├── include
│ ├── lib
│ ├── man
│ └── share
├── python3
│ ├── bin
│ ├── include
│ ├── lib
│ └── share
├── tree
│ └── bin
└── zsh
├── bin
├── lib
└── share
結果
使ってるのはzshです.
以下のコマンドを実行,または.zshrcに記述すればよかです.
管理者権限ないとCPPFLAGSの設定やらをいちいちかかないといけないので結構楽になります
cflags=(); cppflags=(); ldflags=();
files=($HOME/.opt/*)
for filepath in $files; do
path=($filepath/bin(N-/) $path)
[ -d $filepath/include ] && cflags=(-I$filepath/include/ $cflags) || :
[ -d $filepath/include ] && cppflags=(-I$filepath/include/ $cppflags) || :
[ -d $filepath/lib ] && ldflags=(-L$filepath/lib/ $ldflags) || :
done
export CFLAGS="$cflags"
export CPPFLAGS="$cppflags"
export LDFLAGS="$ldflags"