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 [ "$ARCH" = "armel" ]
43 echo "CXX = arm-linux-gnueabi-g++" >> make.pre
44 echo "CC = arm-linux-gnueabi-g++" >> make.pre
45 echo "CXXFLAGS += -D_ARMEL" >> make.pre
46 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
48 echo "CXXFLAGS += -std=c++0x" >> make.pre
51 # compilation of libraries need fPIC flag
54 echo "CXXFLAGS += -fPIC" >> make.pre
60 function append_dependency_common {
61 # common part of append_dependency and append_library
64 # $2: dependency directory
65 # $3: dependency artefact
68 echo "DEPS += $3" >> $1/make.pre
69 echo "$3:" >> $1/make.post
70 echo " cd $src/$2 && make TARGET=$3" >> $1/make.post
73 function append_dependency {
74 # adds another drectory, where a c++ compile is performed
75 append_dependency_common $*
76 echo "" >> $1/make.post
79 function add_include {
80 # adds a include directory
86 echo "CXXFLAGS += -I$src/$2" >> $1/make.pre
89 function add_library {
90 # adds a extern library
93 # $2: library name (without l or lib )
94 # $3: library path (optional)
97 echo "EXTLIB += -l$2" >> $1/make.pre
101 if [ ${lib_path:0:1} != "/" ]
103 lib_path="$src/$lib_path"
105 echo "LDFLAGS += -L$lib_path" >> $1/make.pre
109 function append_library {
110 # same as append_dependency. In addition a include statement + a link to the library is added to "main directory"
113 # $2: dependency directory
114 # $3: dependency artefact
116 append_dependency_common $*
117 echo " ln -sf $src/$2/$3 ." >> $1/make.post
118 echo "" >> $1/make.post
120 echo "LDLIBS += $3" >> $1/make.pre
121 echo "CXXFLAGS += -I$src/$2" >> $1/make.pre