Merge branch 'master' of http://wagnertech.de/git/projects
[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 [ -f make.post ]; then rm make.post; fi
20         ln -s $cwd/Make/cpp.make makefile
21         echo "SOURCE = \\" > make.pre
22         for file in $(ls *.cpp)
23         do
24                 echo "  $file \\" >> make.pre
25         done
26         echo >> make.pre
27         if [ "$ARCH" = "armel" ]
28         then
29                 echo "CXX = arm-linux-gnueabi-g++" >> make.pre
30                 echo "CC = arm-linux-gnueabi-g++" >> make.pre
31                 echo "CXXFLAGS += -D_ARMEL" >> make.pre
32                 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
33         else
34                 echo "CXXFLAGS += -std=c++0x" >> make.pre
35         fi
36         echo "CXXFLAGS += -I$src/util" >> make.pre
37         popd
38 }
39
40 function append_dependency {
41 # parameter:
42 # $1: main directory
43 # $2: dependency directory
44 # $3: dependency artefact
45
46         src=$(pwd)
47         echo "DEPS += $3" >> $1/make.pre
48         echo "$3:" >> $1/make.post
49         echo "  cd $src/$2 && make TARGET=$3" >> $1/make.post
50         echo "" >> $1/make.post
51 }
52
53 function append_library {
54 # parameter:
55 # $1: main directory
56 # $2: dependency directory
57 # $3: dependency artefact
58
59         src=$(pwd)
60         echo "DEPS += $3" >> $1/make.pre
61         echo "LDLIBS += $3" >> $1/make.pre
62         echo "$3:" >> $1/make.post
63         echo "  cd $src/$2 && make TARGET=$3" >> $1/make.post
64         echo "  ln -sf $src/$2/$3 ." >> $1/make.post
65         echo "" >> $1/make.post
66 }
67