3 # util routines for a C/C++ - build
9 *) echo "unknown architecture $1"
14 function install_cpp_make {
16 # $2 (opt): if set to "lib" the fPIC flag is added
19 if [ -f /usr/share/mbuild/cpp.make ]
21 makefile=/usr/share/mbuild/cpp.make
22 elif [ -f $cwd/projects/tools/make/cpp.make ]
24 makefile=$cwd/projects/tools/make/cpp.make
26 echo "cannot find cpp makefile." >&2
31 if [ -f makefile ]; then rm makefile; fi
32 if [ -L makefile ]; then rm makefile; fi
33 if [ -f make.post ]; then rm make.post; fi
34 ln -s $makefile makefile
35 echo "SOURCE = \\" > make.pre
36 for file in $(ls *.cpp)
38 echo " $file \\" >> make.pre
41 if [ "$DEB_HOST_ARCH" != "$DEB_BUILD_ARCH" ]
44 echo "PREFIX = $DEB_HOST_GNU_TYPE-" >> make.pre
45 echo "SYSROOT = --sysroot=$HOME/cross" >> make.pre
48 if [ "$ARCH" = "armel" ]
50 echo "CXX = arm-linux-gnueabi-g++" >> make.pre
51 echo "CC = arm-linux-gnueabi-g++" >> make.pre
52 echo "CXXFLAGS += -D_ARMEL" >> make.pre
53 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
55 echo "CXXFLAGS += -std=c++0x" >> make.pre
58 # compilation of libraries need fPIC flag
61 echo "CXXFLAGS += -fPIC" >> make.pre
67 function append_dependency_common {
68 # common part of append_dependency and append_library
71 # $2: dependency directory
72 # $3: dependency artefact
75 echo "DEPS += $3" >> $1/make.pre
76 echo "$3:" >> $1/make.post
77 echo " cd $src/$2 && make TARGET=$3" >> $1/make.post
80 function append_dependency {
81 # adds another drectory, where a c++ compile is performed
82 append_dependency_common $*
83 echo "" >> $1/make.post
86 function add_include {
87 # adds a include directory
93 echo "CXXFLAGS += -I$src/$2" >> $1/make.pre
96 function add_library {
97 # adds a extern library
100 # $2: library name (without l or lib )
101 # $3: library path (optional)
104 echo "EXTLIB += -l$2" >> $1/make.pre
108 if [ ${lib_path:0:1} != "/" ]
110 lib_path="$src/$lib_path"
112 echo "LDFLAGS += -L$lib_path" >> $1/make.pre
116 function append_library {
117 # same as append_dependency. In addition a include statement + a link to the library is added to "main directory"
120 # $2: dependency directory
121 # $3: dependency artefact
123 append_dependency_common $*
124 echo " ln -sf $src/$2/$3 ." >> $1/make.post
125 echo "" >> $1/make.post
127 echo "LDLIBS += $3" >> $1/make.pre
128 echo "CXXFLAGS += -I$src/$2" >> $1/make.pre