|
18 | 18 | done |
19 | 19 | } |
20 | 20 |
|
21 | | -check_for_application lex bison autoheader aclocal automake autoconf pkg-config |
22 | | - |
23 | | -libtoolize="" |
24 | | -libtoolize --version >/dev/null 2>/dev/null |
25 | | -if test $? -eq 0 |
26 | | -then |
27 | | - libtoolize=libtoolize |
28 | | -else |
29 | | - glibtoolize --version >/dev/null 2>/dev/null |
| 21 | +setup_libtool () |
| 22 | +{ |
| 23 | + libtoolize="" |
| 24 | + libtoolize --version >/dev/null 2>/dev/null |
30 | 25 | if test $? -eq 0 |
31 | 26 | then |
32 | | - libtoolize=glibtoolize |
| 27 | + libtoolize=libtoolize |
33 | 28 | else |
34 | | - cat >&2 <<EOF |
35 | | -WARNING: Neither \`libtoolize' nor \`glibtoolize' have been found! |
36 | | - Please make sure that one of them is installed and is in one of the |
37 | | - directories listed in the PATH environment variable. |
| 29 | + glibtoolize --version >/dev/null 2>/dev/null |
| 30 | + if test $? -eq 0 |
| 31 | + then |
| 32 | + libtoolize=glibtoolize |
| 33 | + else |
| 34 | + cat >&2 <<EOF |
| 35 | + WARNING: Neither \`libtoolize' nor \`glibtoolize' have been found! |
| 36 | + Please make sure that one of them is installed and is in one of the |
| 37 | + directories listed in the PATH environment variable. |
38 | 38 | EOF |
39 | | - GLOBAL_ERROR_INDICATOR=1 |
| 39 | + GLOBAL_ERROR_INDICATOR=1 |
| 40 | + fi |
| 41 | + fi |
| 42 | + |
| 43 | + if test "$GLOBAL_ERROR_INDICATOR" != "0" |
| 44 | + then |
| 45 | + exit 1 |
40 | 46 | fi |
41 | | - fi |
| 47 | +} |
42 | 48 |
|
43 | | -if test "$GLOBAL_ERROR_INDICATOR" != "0" |
44 | | -then |
45 | | - exit 1 |
46 | | -fi |
| 49 | +build () |
| 50 | +{ |
| 51 | + set -x |
| 52 | + autoheader \ |
| 53 | + && aclocal -I /usr/share/aclocal \ |
| 54 | + && $libtoolize --copy --force \ |
| 55 | + && automake --add-missing --copy \ |
| 56 | + && autoconf |
| 57 | +} |
| 58 | + |
| 59 | +build_linux () |
| 60 | +{ |
| 61 | + echo "Building for Linux..." |
| 62 | + check_for_application lex bison autoheader aclocal automake autoconf pkg-config |
| 63 | + setup_libtool |
| 64 | + build |
| 65 | +} |
| 66 | + |
| 67 | +build_windows () |
| 68 | +{ |
| 69 | + echo "Building for Windows..." |
| 70 | + check_for_application aclocal autoconf autoheader automake bison flex git make pkg-config x86_64-w64-mingw32-gcc |
| 71 | + setup_libtool |
| 72 | + |
| 73 | + set -e |
47 | 74 |
|
48 | | -set -x |
| 75 | + : ${INSTALL_DIR:="C:/PROGRA~1/collectd"} |
| 76 | + : ${LIBDIR:="${INSTALL_DIR}"} |
| 77 | + : ${BINDIR:="${INSTALL_DIR}"} |
| 78 | + : ${SBINDIR:="${INSTALL_DIR}"} |
| 79 | + : ${SYSCONFDIR:="${INSTALL_DIR}"} |
| 80 | + : ${LOCALSTATEDIR:="${INSTALL_DIR}"} |
| 81 | + : ${DATAROOTDIR:="${INSTALL_DIR}"} |
| 82 | + : ${DATADIR:="${INSTALL_DIR}"} |
| 83 | + |
| 84 | + echo "Installing collectd to ${INSTALL_DIR}." |
| 85 | + TOP_SRCDIR=$(pwd) |
| 86 | + MINGW_ROOT="/usr/x86_64-w64-mingw32/sys-root/mingw" |
| 87 | + GNULIB_DIR="${TOP_SRCDIR}/_build_aux/_gnulib/gllib" |
| 88 | + |
| 89 | + export CC="x86_64-w64-mingw32-gcc" |
| 90 | + |
| 91 | + mkdir -p _build_aux |
| 92 | + |
| 93 | + pushd _build_aux |
| 94 | + if [ -d "_gnulib" ]; then |
| 95 | + echo "Assuming that gnulib is already built, because _gnulib exists." |
| 96 | + else |
| 97 | + git clone git://git.savannah.gnu.org/gnulib.git |
| 98 | + cd gnulib |
| 99 | + git checkout 2f8140bc8ce5501e31dcc665b42b5df64f84c20c |
| 100 | + ./gnulib-tool --create-testdir \ |
| 101 | + --source-base=lib \ |
| 102 | + --dir=${TOP_SRCDIR}/_build_aux/_gnulib \ |
| 103 | + canonicalize-lgpl \ |
| 104 | + regex \ |
| 105 | + sys_socket \ |
| 106 | + nanosleep \ |
| 107 | + netdb \ |
| 108 | + net_if \ |
| 109 | + sendto \ |
| 110 | + gettimeofday \ |
| 111 | + getsockopt \ |
| 112 | + time_r \ |
| 113 | + sys_stat \ |
| 114 | + fcntl-h \ |
| 115 | + sys_resource \ |
| 116 | + sys_wait \ |
| 117 | + setlocale \ |
| 118 | + strtok_r \ |
| 119 | + poll \ |
| 120 | + recv \ |
| 121 | + net_if |
| 122 | + |
| 123 | + cd ${TOP_SRCDIR}/_build_aux/_gnulib |
| 124 | + ./configure --host="mingw32" LIBS="-lws2_32 -lpthread" |
| 125 | + make |
| 126 | + cd gllib |
| 127 | + |
| 128 | + # We have to rebuild libgnu.a to get the list of *.o files to build a dll later |
| 129 | + rm libgnu.a |
| 130 | + OBJECT_LIST=`make V=1 | grep "ar" | cut -d' ' -f4-` |
| 131 | + $CC -shared -o libgnu.dll $OBJECT_LIST -lws2_32 -lpthread |
| 132 | + rm libgnu.a # get rid of it, to use libgnu.dll |
| 133 | + fi |
| 134 | + popd |
| 135 | + |
| 136 | + build |
| 137 | + |
| 138 | + export LDFLAGS="-L${GNULIB_DIR}" |
| 139 | + export LIBS="-lgnu" |
| 140 | + export CFLAGS="-Drestrict=__restrict -I${GNULIB_DIR}" |
| 141 | + |
| 142 | + ./configure \ |
| 143 | + --prefix="${INSTALL_DIR}" \ |
| 144 | + --libdir="${LIBDIR}" \ |
| 145 | + --bindir="${BINDIR}" \ |
| 146 | + --sbindir="${SBINDIR}" \ |
| 147 | + --sysconfdir="${SYSCONFDIR}" \ |
| 148 | + --localstatedir="${LOCALSTATEDIR}" \ |
| 149 | + --datarootdir="${DATAROOTDIR}" \ |
| 150 | + --datarootdir="${DATADIR}" \ |
| 151 | + --disable-all-plugins \ |
| 152 | + --host="mingw32" \ |
| 153 | + --enable-logfile |
| 154 | + |
| 155 | + cp ${GNULIB_DIR}/../config.h src/gnulib_config.h |
| 156 | + echo "#include <config.h.in>" >> src/gnulib_config.h |
| 157 | + |
| 158 | + # TODO: find a sane way to set LTCFLAGS for libtool |
| 159 | + cp libtool libtool_bak |
| 160 | + sed -i "s%\$LTCC \$LTCFLAGS\(.*cwrapper.*\)%\$LTCC \1%" libtool |
| 161 | + |
| 162 | + make |
| 163 | + make install |
| 164 | + |
| 165 | + cp ".libs/libcollectd-0.dll" "${INSTALL_DIR}" |
| 166 | + cp "${GNULIB_DIR}/libgnu.dll" "${INSTALL_DIR}" |
| 167 | + cp "${MINGW_ROOT}/bin/zlib1.dll" "${INSTALL_DIR}" |
| 168 | + cp "${MINGW_ROOT}/bin/libwinpthread-1.dll" "${INSTALL_DIR}" |
| 169 | + cp "${MINGW_ROOT}/bin/libdl.dll" "${INSTALL_DIR}" |
| 170 | + |
| 171 | + echo "Done" |
| 172 | +} |
| 173 | + |
| 174 | +if test "${OSTYPE}" = "cygwin"; then |
| 175 | + build_windows |
| 176 | +else |
| 177 | + build_linux |
| 178 | +fi |
49 | 179 |
|
50 | | -autoheader \ |
51 | | -&& aclocal \ |
52 | | -&& $libtoolize --copy --force \ |
53 | | -&& automake --add-missing --copy \ |
54 | | -&& autoconf |
|
0 commit comments