| 1 | #! /bin/bash |
|---|
| 2 | |
|---|
| 3 | # copyright John Maddock 2003 |
|---|
| 4 | # Distributed under the Boost Software License, Version 1.0. |
|---|
| 5 | # (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 6 | # http://www.boost.org/LICENSE_1_0.txt. |
|---|
| 7 | |
|---|
| 8 | libname="" |
|---|
| 9 | src="" |
|---|
| 10 | header="" |
|---|
| 11 | all_dep="" |
|---|
| 12 | |
|---|
| 13 | # current makefile: |
|---|
| 14 | out="" |
|---|
| 15 | # temporary file: |
|---|
| 16 | tout="" |
|---|
| 17 | # install target temp file: |
|---|
| 18 | iout="" |
|---|
| 19 | # debug flag: |
|---|
| 20 | debug="no" |
|---|
| 21 | # compile options: |
|---|
| 22 | opts="" |
|---|
| 23 | # main output sub-directory: |
|---|
| 24 | subdir="" |
|---|
| 25 | # vcl flag: |
|---|
| 26 | use_vcl="yes" |
|---|
| 27 | |
|---|
| 28 | ############################################################### |
|---|
| 29 | # |
|---|
| 30 | # gcc generator section: |
|---|
| 31 | # |
|---|
| 32 | ############################################################### |
|---|
| 33 | |
|---|
| 34 | gcc_shared="no" |
|---|
| 35 | |
|---|
| 36 | function gcc_gen_lib() |
|---|
| 37 | { |
|---|
| 38 | if test "$gcc_shared" == "yes"; then |
|---|
| 39 | obj_dir="$libname""_shared" |
|---|
| 40 | all_dep="$all_dep $subdir $subdir/$obj_dir ./$subdir/lib$libname.so" |
|---|
| 41 | else |
|---|
| 42 | obj_dir="$libname" |
|---|
| 43 | all_dep="$all_dep $subdir $subdir/$obj_dir ./$subdir/lib$libname.a" |
|---|
| 44 | fi |
|---|
| 45 | # |
|---|
| 46 | # set up section comments: |
|---|
| 47 | cat >> $tout << EOF |
|---|
| 48 | ######################################################## |
|---|
| 49 | # |
|---|
| 50 | # section for lib$libname.a |
|---|
| 51 | # |
|---|
| 52 | ######################################################## |
|---|
| 53 | EOF |
|---|
| 54 | # |
|---|
| 55 | # process source files: |
|---|
| 56 | all_obj="" |
|---|
| 57 | for file in $src |
|---|
| 58 | do |
|---|
| 59 | obj=`echo "$file" | sed 's/.*src\/\(.*\)cpp/\1o/g'` |
|---|
| 60 | obj="$subdir/$obj_dir/$obj" |
|---|
| 61 | all_obj="$all_obj $obj" |
|---|
| 62 | echo "$obj: $file \$(ALL_HEADER)" >> $tout |
|---|
| 63 | echo " \$(CXX) \$(INCLUDES) -o $obj $opts \$(CXXFLAGS) \$(ICU_CXXFLAGS) $file" >> $tout |
|---|
| 64 | echo "" >> $tout |
|---|
| 65 | done |
|---|
| 66 | # |
|---|
| 67 | # now for the directories for this library: |
|---|
| 68 | echo "$subdir/$obj_dir : " >> $tout |
|---|
| 69 | echo " mkdir -p $subdir/$obj_dir" >> $tout |
|---|
| 70 | echo "" >> $tout |
|---|
| 71 | # |
|---|
| 72 | # now for the clean options for this library: |
|---|
| 73 | all_clean="$all_clean $libname""_clean" |
|---|
| 74 | echo "$libname"_clean : >> $tout |
|---|
| 75 | echo " rm -f $subdir/$obj_dir/*.o" >> $tout |
|---|
| 76 | echo "" >> $tout |
|---|
| 77 | # |
|---|
| 78 | # now for the main target for this library: |
|---|
| 79 | if test "$gcc_shared" == "yes"; then |
|---|
| 80 | echo ./$subdir/lib$libname.so : $all_obj >> $tout |
|---|
| 81 | echo " \$(LINKER) -o $subdir/lib$libname.so \$(LDFLAGS) \$(ICU_LDFLAGS) $all_obj \$(ICU_LIBS) \$(LIBS)" >> $tout |
|---|
| 82 | else |
|---|
| 83 | echo ./$subdir/lib$libname.a : $all_obj >> $tout |
|---|
| 84 | echo " ar -r $subdir/lib$libname.a $all_obj" >> $tout |
|---|
| 85 | echo " -ar -s $subdir/lib$libname.a" >> $tout |
|---|
| 86 | fi |
|---|
| 87 | echo "" >> $tout |
|---|
| 88 | } |
|---|
| 89 | |
|---|
| 90 | function gcc_gen() |
|---|
| 91 | { |
|---|
| 92 | out="gcc.mak" |
|---|
| 93 | tout="temp" |
|---|
| 94 | iout="temp_install" |
|---|
| 95 | subdir="gcc" |
|---|
| 96 | all_dep="" |
|---|
| 97 | all_clean="" |
|---|
| 98 | echo > $out |
|---|
| 99 | echo > $tout |
|---|
| 100 | echo > $iout |
|---|
| 101 | |
|---|
| 102 | libname="boost_regex-gcc-${boost_version}" |
|---|
| 103 | opts="\$(C1)" |
|---|
| 104 | gcc_gen_lib |
|---|
| 105 | libname="boost_regex-gcc-d-${boost_version}" |
|---|
| 106 | opts="\$(C2)" |
|---|
| 107 | gcc_gen_lib |
|---|
| 108 | |
|---|
| 109 | |
|---|
| 110 | cat > $out << EOF |
|---|
| 111 | # copyright John Maddock 2006 |
|---|
| 112 | # Distributed under the Boost Software License, Version 1.0. |
|---|
| 113 | # (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 114 | # http://www.boost.org/LICENSE_1_0.txt. |
|---|
| 115 | # |
|---|
| 116 | # auto generated makefile for gcc compiler |
|---|
| 117 | # |
|---|
| 118 | # usage: |
|---|
| 119 | # make |
|---|
| 120 | # brings libraries up to date |
|---|
| 121 | # make clean |
|---|
| 122 | # deletes temporary object files (but not archives). |
|---|
| 123 | # |
|---|
| 124 | |
|---|
| 125 | # |
|---|
| 126 | # the following environment variables are recognised: |
|---|
| 127 | # ICU_PATH= Path to ICU installation. |
|---|
| 128 | # CXXFLAGS= extra compiler options - note applies to all build variants |
|---|
| 129 | # INCLUDES= additional include directories |
|---|
| 130 | # LDFLAGS= additional linker options |
|---|
| 131 | # LIBS= additional library files |
|---|
| 132 | |
|---|
| 133 | # compiler: |
|---|
| 134 | CXX=g++ |
|---|
| 135 | LINKER=g++ -shared |
|---|
| 136 | |
|---|
| 137 | # |
|---|
| 138 | # compiler options for release build: |
|---|
| 139 | # |
|---|
| 140 | C1=-c -O2 -I../../.. |
|---|
| 141 | # |
|---|
| 142 | # compiler options for debug build: |
|---|
| 143 | # |
|---|
| 144 | C2=-c -g -I../../.. |
|---|
| 145 | |
|---|
| 146 | ifeq "\$(ICU_PATH)" "" |
|---|
| 147 | \$(warning "Building Boost.Regex without ICU / Unicode support:") |
|---|
| 148 | \$(warning "Hint: set ICU_PATH on the nmake command line to point ") |
|---|
| 149 | \$(warning "to your ICU installation if you have one.") |
|---|
| 150 | else |
|---|
| 151 | ICU_CXXFLAGS= -DBOOST_HAS_ICU=1 -I\$(ICU_PATH)/include |
|---|
| 152 | ICU_LDFLAGS= -L\$(ICU_PATH)/lib |
|---|
| 153 | ICU_LIBS= -licui18n -licuuc |
|---|
| 154 | \$(warning "Building Boost.Regex with ICU in \$(ICU_PATH)") |
|---|
| 155 | endif |
|---|
| 156 | |
|---|
| 157 | EOF |
|---|
| 158 | echo "" >> $out |
|---|
| 159 | echo "ALL_HEADER=$header" >> $out |
|---|
| 160 | echo "" >> $out |
|---|
| 161 | echo "all : $subdir $all_dep" >> $out |
|---|
| 162 | echo >> $out |
|---|
| 163 | echo "$subdir :" >> $out |
|---|
| 164 | echo " mkdir -p $subdir" >> $out |
|---|
| 165 | echo >> $out |
|---|
| 166 | echo "clean : $all_clean" >> $out |
|---|
| 167 | echo >> $out |
|---|
| 168 | echo "install : all" >> $out |
|---|
| 169 | cat $iout >> $out |
|---|
| 170 | echo >> $out |
|---|
| 171 | cat $tout >> $out |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | function gcc_gen_shared() |
|---|
| 175 | { |
|---|
| 176 | out="gcc-shared.mak" |
|---|
| 177 | tout="temp" |
|---|
| 178 | iout="temp_install" |
|---|
| 179 | subdir="gcc" |
|---|
| 180 | all_dep="" |
|---|
| 181 | all_clean="" |
|---|
| 182 | echo > $out |
|---|
| 183 | echo > $tout |
|---|
| 184 | echo > $iout |
|---|
| 185 | |
|---|
| 186 | libname="boost_regex-gcc-${boost_version}" |
|---|
| 187 | opts="\$(C1)" |
|---|
| 188 | gcc_gen_lib |
|---|
| 189 | libname="boost_regex-gcc-d-${boost_version}" |
|---|
| 190 | opts="\$(C2)" |
|---|
| 191 | gcc_gen_lib |
|---|
| 192 | |
|---|
| 193 | |
|---|
| 194 | cat > $out << EOF |
|---|
| 195 | # |
|---|
| 196 | # auto generated makefile for gcc compiler |
|---|
| 197 | # |
|---|
| 198 | # usage: |
|---|
| 199 | # make |
|---|
| 200 | # brings libraries up to date |
|---|
| 201 | # make clean |
|---|
| 202 | # deletes temporary object files (but not archives). |
|---|
| 203 | # |
|---|
| 204 | |
|---|
| 205 | # |
|---|
| 206 | # the following environment variables are recognised: |
|---|
| 207 | # ICU_PATH= Path to ICU installation. |
|---|
| 208 | # CXXFLAGS= extra compiler options - note applies to all build variants |
|---|
| 209 | # INCLUDES= additional include directories |
|---|
| 210 | # LDFLAGS= additional linker options |
|---|
| 211 | # LIBS= additional library files |
|---|
| 212 | |
|---|
| 213 | # compiler: |
|---|
| 214 | CXX=g++ |
|---|
| 215 | LINKER=g++ -shared |
|---|
| 216 | |
|---|
| 217 | # |
|---|
| 218 | # compiler options for release build: |
|---|
| 219 | # |
|---|
| 220 | C1=-c -O2 -I../../.. -fPIC |
|---|
| 221 | # |
|---|
| 222 | # compiler options for debug build: |
|---|
| 223 | # |
|---|
| 224 | C2=-c -g -I../../.. -fPIC |
|---|
| 225 | |
|---|
| 226 | ifeq "\$(ICU_PATH)" "" |
|---|
| 227 | \$(warning "Building Boost.Regex without ICU / Unicode support:") |
|---|
| 228 | \$(warning "Hint: set ICU_PATH on the nmake command line to point ") |
|---|
| 229 | \$(warning "to your ICU installation if you have one.") |
|---|
| 230 | else |
|---|
| 231 | ICU_CXXFLAGS= -DBOOST_HAS_ICU=1 -I\$(ICU_PATH)/include |
|---|
| 232 | ICU_LDFLAGS= -L\$(ICU_PATH)/lib |
|---|
| 233 | ICU_LIBS= -licui18n -licuuc |
|---|
| 234 | \$(warning "Building Boost.Regex with ICU in \$(ICU_PATH)") |
|---|
| 235 | endif |
|---|
| 236 | |
|---|
| 237 | EOF |
|---|
| 238 | echo "" >> $out |
|---|
| 239 | echo "ALL_HEADER=$header" >> $out |
|---|
| 240 | echo "" >> $out |
|---|
| 241 | echo "all : $subdir $all_dep" >> $out |
|---|
| 242 | echo >> $out |
|---|
| 243 | echo "$subdir :" >> $out |
|---|
| 244 | echo " mkdir -p $subdir" >> $out |
|---|
| 245 | echo >> $out |
|---|
| 246 | echo "clean : $all_clean" >> $out |
|---|
| 247 | echo >> $out |
|---|
| 248 | echo "install : all" >> $out |
|---|
| 249 | cat $iout >> $out |
|---|
| 250 | echo >> $out |
|---|
| 251 | cat $tout >> $out |
|---|
| 252 | } |
|---|
| 253 | |
|---|
| 254 | # |
|---|
| 255 | # locate source files: |
|---|
| 256 | # |
|---|
| 257 | . common.sh |
|---|
| 258 | |
|---|
| 259 | # |
|---|
| 260 | # generate gcc makefile: |
|---|
| 261 | gcc_gen |
|---|
| 262 | gcc_shared="yes" |
|---|
| 263 | gcc_gen_shared |
|---|
| 264 | |
|---|
| 265 | |
|---|
| 266 | # |
|---|
| 267 | # remove tmep files; |
|---|
| 268 | rm -f $tout $iout |
|---|
| 269 | |
|---|
| 270 | |
|---|
| 271 | |
|---|
| 272 | |
|---|
| 273 | |
|---|