Debian Codegraph @

setup.sh

raw symbols SCIP
1 #! /bin/sh
2 #
3 # Setup PATH and LD_LIBRARY_PATH for command line work
4 #
5 # When you run "make test" CMake obviously runs the correct binaries
6 # from the build directory. And so does the top level Makefile. But
7 # when you want to run a test manually PATH and LD_LIBRARY_PATH need
8 # to be set, and it is tedious and error prone to remember that all
9 # the time.
10 #
11 # The follwing sets up the current shell in the same way, so that a
12 # developer can just source this script and then always get the ones
13 # in the build tree wihtout thinking about it.
14 #
15
16 # Ensure that the script is sourced:
17 if [ $_ = $0 ]; then
18 echo "You should really source this, like in '. $0'"
19 fi
20
21 contains() {
22 string="$1"
23 substring="$2"
24 if test "${string#*$substring}" != "$string"
25 then
26 return 0 # $substring is in $string
27 else
28 return 1 # $substring is not in $string
29 fi
30 }
31
32 # Add the appropriate directories in the build tree to PATH et al.
33 if contains "$PATH" "$PWD/build/tools" ; then
34 echo "You already have the appropriate directories in your PATH and LD_LIBRARY_PATH."
35 else
36 # And here's the meat given that you have the standard build tree
37 export PATH="$PWD/build/tools":$PATH
38
39 # On linux we need LD_LIBRARY_PATH...
40 export LD_LIBRARY_PATH="$PWD/build/src":$PATH
41
42 # MacOS..
43 export DYLD_LIBRARY_PATH="$PWD/build/src":$PATH
44
45 # ...but on Cygwin DLL:s are searched using the path...
46 export PATH="$PWD/build/src":$PATH
47 fi
48
49 # Let's also create symbolic links to build/tools and build/src to emulate typical
50 # FHS include/bin/lib structure. This makes it easy to switch between various versions of
51 # cgreen. E.g. in a Makefile you can do
52 #
53 # CGREEN_ROOT=/usr/local
54 # CGREEN_INCLUDE=$(CGREEN_ROOT)/include
55 # CGREEN_LIB=$(CGREEN_ROOT)/lib
56 # CGREEN_BIN=$(CGREEN_ROOT)/bin
57 # ...
58 # LD_LIBRARY_PATH=$(CGREEN_LIB):. $(CGREEN_BIN)/bin/cgreen-runner <libs>
59 # ...
60 # %.so: %.c
61 # g++ -o $@ -shared -g -I$(CGREEN_INCLUDE) -fPIC $^ -L $(CGREEN_LIBDIR) -lcgreen
62 #
63 # To switch to your current development version just change CGREEN_ROOT.
64 #
65 # So simulate that build/tools (where cgreen-runner is) is bin, and build/src (where
66 # the cgreen library is built) is lib
67 [ -e bin ] || ln -s build/tools bin
68 [ -e lib ] || ln -s build/src lib