A quick shell include for setting paths for programs installed in non-traditional locations

Tags: •  •  • 

A page in the Beyond Linux from Scratch manual describes environment variables that should be set when installing software in a non-traditional location (e.g. your home directory).

I've written a sh/bash include that can be included from .bashrc to set these variables, as well as PYTHON_PATH for separately installed Python libraries:

#!/bin/bash
PREFIX=$HOME/usr
export PATH="$PREFIX/bin:$PATH"
export PYTHONPATH="$PREFIX/lib/python2.4/site-packages:$PYTHON_PATH"
export MANPATH="$PREFIX/man:$MANPATH"
export INFOPATH="$PREFIX/info:$INFOPATH"
export LD_LIBRARY_PATH="$PREFIX/lib:$LD_LIBRARY_PATH"
export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PKG_CONFIG_PATH"
export CPPFLAGS="-I$PREFIX/includes $CPPFLAGS"
export LDFLAGS="-L$PREFIX/lib $LDFLAGS"

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

The CPPFLAGS seems bogus to

The CPPFLAGS seems bogus to me: should be

export        CPPFLAGS=-I$PREFIX/includes:$CPPFLAGS

Oh and there’s also

Oh and there’s also LDFLAGS; like CPPFLAGS, it’s unnecessary with libs that use pkg-config though. export LDFLAGS="-L$PREFIX/lib $LDFLGAGS"


CPPFLAGS fixed

Thanks for noticing the error with CPPFLAGS!

I’ve also added LDFLAGS. I usually put non-system libraries I’m linking to in CPPFLAGS, but after a quick web search LDFLAGS seems more appropriate.


Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text.
  • Images can be added to this post.
  • You may use [inline:xx] tags to display uploaded files or images inline.
More information about formatting options