| 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 | # |
|---|
| 31 | # section for generic compiler |
|---|
| 32 | # |
|---|
| 33 | ####################################################################### |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | function gen_gen_lib() |
|---|
| 37 | { |
|---|
| 38 | all_dep="$all_dep $subdir $subdir/$libname ./$subdir/lib$libname.so" |
|---|
| 39 | # |
|---|
| 40 | # set up section comments: |
|---|
| 41 | cat >> $tout << EOF |
|---|
| 42 | ######################################################## |
|---|
| 43 | # |
|---|
| 44 | # section for lib$libname.so |
|---|
| 45 | # |
|---|
| 46 | ######################################################## |
|---|
| 47 | EOF |
|---|
| 48 | # |
|---|
| 49 | # process source files: |
|---|
| 50 | all_obj="" |
|---|
| 51 | for file in $src |
|---|
| 52 | do |
|---|
| 53 | obj=`echo "$file" | sed 's/.*src\/\(.*\)cpp/\1o/g'` |
|---|
| 54 | obj="$subdir/$libname/$obj" |
|---|
| 55 | all_obj="$all_obj $obj" |
|---|
| 56 | echo "$obj: $file \$(ALL_HEADER)" >> $tout |
|---|
| 57 | echo " \$(CXX) \$(INCLUDES) -o $obj $opts \$(CXXFLAGS) $file" >> $tout |
|---|
| 58 | echo "" >> $tout |
|---|
| 59 | done |
|---|
| 60 | # |
|---|
| 61 | # now for the directories for this library: |
|---|
| 62 | echo "$subdir/$libname : " >> $tout |
|---|
| 63 | echo " mkdir -p $subdir/$libname" >> $tout |
|---|
| 64 | echo "" >> $tout |
|---|
| 65 | # |
|---|
| 66 | # now for the clean options for this library: |
|---|
| 67 | all_clean="$all_clean $libname""_clean" |
|---|
| 68 | echo "$libname"_clean : >> $tout |
|---|
| 69 | echo " rm -f $subdir/$libname/*.o" >> $tout |
|---|
| 70 | echo "" >> $tout |
|---|
| 71 | # |
|---|
| 72 | # now for the main target for this library: |
|---|
| 73 | echo ./$subdir/lib$libname.so : $all_obj >> $tout |
|---|
| 74 | echo " \$(LINKER) \$(LDFLAGS) -o $subdir/lib$libname.so $all_obj \$(LIBS)" >> $tout |
|---|
| 75 | echo "" >> $tout |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | function gen_gen() |
|---|
| 79 | { |
|---|
| 80 | out="generic.mak" |
|---|
| 81 | tout="temp" |
|---|
| 82 | iout="temp_install" |
|---|
| 83 | subdir="\$(DIRNAME)" |
|---|
| 84 | all_dep="" |
|---|
| 85 | all_clean="" |
|---|
| 86 | echo > $out |
|---|
| 87 | echo > $tout |
|---|
| 88 | echo > $iout |
|---|
| 89 | |
|---|
| 90 | libname="boost_regex" |
|---|
| 91 | opts="\$(C1)" |
|---|
| 92 | gen_gen_lib |
|---|
| 93 | |
|---|
| 94 | cat > $out << EOF |
|---|
| 95 | # copyright John Maddock 2006 |
|---|
| 96 | # Distributed under the Boost Software License, Version 1.0. |
|---|
| 97 | # (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 98 | # http://www.boost.org/LICENSE_1_0.txt. |
|---|
| 99 | # |
|---|
| 100 | # auto generated makefile for generic compiler |
|---|
| 101 | # |
|---|
| 102 | # usage: |
|---|
| 103 | # make |
|---|
| 104 | # brings libraries up to date |
|---|
| 105 | # make clean |
|---|
| 106 | # deletes temporary object files (but not archives). |
|---|
| 107 | # |
|---|
| 108 | |
|---|
| 109 | # |
|---|
| 110 | # the following environment variables are recognised: |
|---|
| 111 | # CXXFLAGS= extra compiler options - note applies to all build variants |
|---|
| 112 | # INCLUDES= additional include directories |
|---|
| 113 | # LDFLAGS= additional linker options |
|---|
| 114 | # LIBS= additional library files |
|---|
| 115 | # CXX= compiler to use |
|---|
| 116 | # LINKER= linker/archiver to use |
|---|
| 117 | # name of subdirectory to use for object/archive files: |
|---|
| 118 | DIRNAME=generic |
|---|
| 119 | |
|---|
| 120 | # |
|---|
| 121 | # default compiler options for release build: |
|---|
| 122 | # |
|---|
| 123 | C1=-c -O2 -I../../../ |
|---|
| 124 | |
|---|
| 125 | |
|---|
| 126 | EOF |
|---|
| 127 | echo "" >> $out |
|---|
| 128 | echo "ALL_HEADER=$header" >> $out |
|---|
| 129 | echo "" >> $out |
|---|
| 130 | echo "all : $subdir $all_dep" >> $out |
|---|
| 131 | echo >> $out |
|---|
| 132 | echo "$subdir :" >> $out |
|---|
| 133 | echo " mkdir -p $subdir" >> $out |
|---|
| 134 | echo >> $out |
|---|
| 135 | echo "clean : $all_clean" >> $out |
|---|
| 136 | echo >> $out |
|---|
| 137 | echo "install : all" >> $out |
|---|
| 138 | cat $iout >> $out |
|---|
| 139 | echo >> $out |
|---|
| 140 | cat $tout >> $out |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | . common.sh |
|---|
| 144 | |
|---|
| 145 | # |
|---|
| 146 | # generate generic makefile: |
|---|
| 147 | gen_gen |
|---|
| 148 | |
|---|
| 149 | # |
|---|
| 150 | # remove tmep files; |
|---|
| 151 | rm -f $tout $iout |
|---|
| 152 | |
|---|
| 153 | |
|---|
| 154 | |
|---|