epic
[projects.git] / tools / make / c_configure.sh
1 #!/bin/bash
2
3 # util routines for a C/C++ - build
4
5 function check_arch {
6         case $1 in
7         armel) ;;
8         i386) ;;
9         *)      echo "unknown architecture $1"
10                 exit 1
11         esac
12 }
13
14 function install_cpp_make {
15 # $1: dir to install
16         src=$(pwd);
17         pushd $1
18         if [ -f makefile ]; then rm makefile; fi
19         if [ -L makefile ]; then rm makefile; fi
20         if [ -f make.post ]; then rm make.post; fi
21         ln -s $cwd/projects/tools/make/cpp.make makefile
22         echo "SOURCE = \\" > make.pre
23         for file in $(ls *.cpp)
24         do
25                 echo "  $file \\" >> make.pre
26         done
27         echo >> make.pre
28         if [ "$ARCH" = "armel" ]
29         then
30                 echo "CXX = arm-linux-gnueabi-g++" >> make.pre
31                 echo "CC = arm-linux-gnueabi-g++" >> make.pre
32                 echo "CXXFLAGS += -D_ARMEL" >> make.pre
33                 echo 'export PATH := /opt/eldk-5.0/armv5te/sysroots/i686-oesdk-linux/usr/bin/armv5te-linux-gnueabi/:/opt/eldk-5.0/armv5te/sysroots/i686-oesdk-linux/bin/armv5te-linux-gnueabi/:$(PATH)' >> make.pre
34         else
35                 echo "CXXFLAGS += -std=c++0x" >> make.pre
36         fi
37         popd
38 }
39
40 function append_dependency {
41 # adds another drectory, where a c++ compile is performed
42 # parameter:
43 # $1: main directory
44 # $2: dependency directory
45 # $3: dependency artefact
46
47         src=$(pwd)
48         echo "DEPS += $3" >> $1/make.pre
49         echo "$3:" >> $1/make.post
50         echo "  cd $src/$2 && make TARGET=$3" >> $1/make.post
51         echo "" >> $1/make.post
52 }
53
54 function add_include {
55 # adds a include directory
56 # parameter:
57 # $1: main directory
58 # $2: include dir
59
60         src=$(pwd)
61         echo "CXXFLAGS += -I$src/$2" >> $1/make.pre
62 }
63
64 function append_library {
65 # same as append_dependency. In addition a include statement + a link to the library is added to "main directory"
66 # parameter:
67 # $1: main directory
68 # $2: dependency directory
69 # $3: dependency artefact
70
71         src=$(pwd)
72         echo "DEPS += $3" >> $1/make.pre
73         echo "LDLIBS += $3" >> $1/make.pre
74         echo "CXXFLAGS += -I$src/$2" >> $1/make.pre
75         echo "$3:" >> $1/make.post
76         echo "  cd $src/$2 && make TARGET=$3" >> $1/make.post
77         echo "  ln -sf $src/$2/$3 ." >> $1/make.post
78         echo "" >> $1/make.post
79 }
80