3 # util routines for a C/C++ - build
9 *) echo "unknown architecture $1"
14 function install_cpp_make {
18 if [ -f /usr/share/mbuild/cpp.make ]
20 makefile=/usr/share/mbuild/cpp.make
21 elif [ -f $cwd/projects/tools/make/cpp.make ]
23 makefile=$cwd/projects/tools/make/cpp.make
25 echo "cannot find cpp makefile." >&2
30 if [ -f makefile ]; then rm makefile; fi
31 if [ -L makefile ]; then rm makefile; fi
32 if [ -f make.post ]; then rm make.post; fi
33 ln -s $makefile makefile
34 echo "SOURCE = \\" > make.pre
35 for file in $(ls *.cpp)
37 echo " $file \\" >> make.pre
40 if [ "$ARCH" = "armel" ]
42 echo "CXX = arm-linux-gnueabi-g++" >> make.pre
43 echo "CC = arm-linux-gnueabi-g++" >> make.pre
44 echo "CXXFLAGS += -D_ARMEL" >> make.pre
45 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
47 echo "CXXFLAGS += -std=c++0x" >> make.pre
52 function append_dependency {
53 # adds another drectory, where a c++ compile is performed
56 # $2: dependency directory
57 # $3: dependency artefact
60 echo "DEPS += $3" >> $1/make.pre
61 echo "$3:" >> $1/make.post
62 echo " cd $src/$2 && make TARGET=$3" >> $1/make.post
63 echo "" >> $1/make.post
65 # check for shared library
66 if [ "${3##*.}" == "so" ]
68 echo "CXXFLAGS += -fPIC" >> $2/make.pre
72 function add_include {
73 # adds a include directory
79 echo "CXXFLAGS += -I$src/$2" >> $1/make.pre
82 function add_library {
83 # adds a extern library
86 # $2: library name (without l or lib )
87 # $3: library path (optional)
90 echo "EXTLIB += -l$2" >> $1/make.pre
94 if [ ${lib_path:0:1} != "/" ]
96 lib_path="$src/$lib_path"
98 echo "LDFLAGS += -L$lib_path" >> $1/make.pre
102 function append_library {
103 # same as append_dependency. In addition a include statement + a link to the library is added to "main directory"
106 # $2: dependency directory
107 # $3: dependency artefact
110 echo "DEPS += $3" >> $1/make.pre
111 echo "LDLIBS += $3" >> $1/make.pre
112 echo "CXXFLAGS += -I$src/$2" >> $1/make.pre
113 echo "$3:" >> $1/make.post
114 echo " cd $src/$2 && make TARGET=$3" >> $1/make.post
115 echo " ln -sf $src/$2/$3 ." >> $1/make.post
116 echo "" >> $1/make.post
118 # check for shared library
119 if [ "${3##*.}" == "so" ]
121 echo "CXXFLAGS += -fPIC" >> $2/make.pre