~mm-yuhu/gearmand/server-funcs

5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
1
# Gearman server and library
39 by Eric Day
Switched to BSD license, started cleaning up test suite.
2
# Copyright (C) 2008 Brian Aker, Eric Day
3
# All rights reserved.
4
#
5
# Use and distribution licensed under the BSD license.  See
6
# the COPYING file in this directory for full text.
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
7
8
AC_PREREQ(2.59)
96 by Eric Day
Upped version number for release.
9
AC_INIT(gearmand, [0.3.0], [https://launchpad.net/gearmand])
13 by Eric Day
Reworked libary and reverse_worker example. Non-blocking I/O is now supported, gearman_packet_st object introduced, cleaned up error reportingi, and other misc cleanup.
10
AC_CONFIG_SRCDIR(libgearman/gearman.c)
1 by Brian Aker
Import from HG
11
AC_CONFIG_AUX_DIR(config)
13 by Eric Day
Reworked libary and reverse_worker example. Non-blocking I/O is now supported, gearman_packet_st object introduced, cleaned up error reportingi, and other misc cleanup.
12
AC_CONFIG_HEADERS([config.h])
1 by Brian Aker
Import from HG
13
19.3.6 by Brian Aker
First pass through making RPM.
14
GEARMAN_MAJOR_VERSION=0
96 by Eric Day
Upped version number for release.
15
GEARMAN_MINOR_VERSION=3
4 by Eric Day
Did a lot of little cleanup, mostly cosmetic. Also updated configure.ac options and added -Werror. Made appropriate fixes so -Werror works.
16
GEARMAN_MICRO_VERSION=0
17
GEARMAN_VERSION=$GEARMAN_MAJOR_VERSION.$GEARMAN_MINOR_VERSION.$GEARMAN_MICRO_VERSION
18
GEARMAN_RELEASE=$GEARMAN_MAJOR_VERSION.$GEARMAN_MINOR_VERSION
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
19
GEARMAN_LIBRARY_VERSION=$GEARMAN_MAJOR_VERSION:$GEARMAN_MINOR_VERSION:$GEARMAN_MICRO_VERSION
20
19.3.6 by Brian Aker
First pass through making RPM.
21
PACKAGE=gearmand
4 by Eric Day
Did a lot of little cleanup, mostly cosmetic. Also updated configure.ac options and added -Werror. Made appropriate fixes so -Werror works.
22
VERSION=$GEARMAN_RELEASE
23
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
24
AC_SUBST(GEARMAN_VERSION)
25
AC_SUBST(GEARMAN_RELEASE)
4 by Eric Day
Did a lot of little cleanup, mostly cosmetic. Also updated configure.ac options and added -Werror. Made appropriate fixes so -Werror works.
26
AC_SUBST(GEARMAN_LIBRARY_VERSION)
1 by Brian Aker
Import from HG
27
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
28
# Setting CFLAGS here prevents AC_CANONICAL_TARGET from injecting them
29
SAVE_CFLAGS=${CFLAGS}
30
SAVE_CXXFLAGS=${CXXFLAGS}
31
CFLAGS=
32
CXXFLAGS=
33
34
AC_CANONICAL_TARGET
35
36
CFLAGS=${SAVE_CFLAGS}
37
CXXFLAGS=${SAVE_CXXFLAGS}
38
19.3.6 by Brian Aker
First pass through making RPM.
39
AM_INIT_AUTOMAKE($PACKAGE, $VERSION, "-Wall -Werror nostdinc subdir-objects")
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
40
41
if test "x${enable_dependency_tracking}" = "x"
42
then
43
  enable_dependency_tracking=yes
44
fi
45
99 by Eric Day
Updated PROTOCOL doc, added new protocol commands that were in Perl svn version, added new UNIQ grab/assign commands so worker can see client's unique ID as well (needed for persistent queues in workers).
46
if test -d ".bzr"
47
then
48
  building_from_bzr=yes
49
else
50
  building_from_bzr=no
51
fi
52
1 by Brian Aker
Import from HG
53
AC_PROG_CC
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
54
AM_PROG_CC_STDC
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
55
56
ACX_USE_SYSTEM_EXTENSIONS
57
58
AC_PROG_CPP
59
AM_PROG_CC_C_O
60
61
AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
62
ifdef([AC_PROG_CC_C99],[
63
    AC_PROG_CC_C99([$1],[$2],[$3])
64
],[
65
if "x$GCC" = "xyes"
66
then
67
  C99_SUPPORT_HACK="-std=gnu99"
68
fi
69
if "x$SUNCC" = "xyes"
70
then
71
  C99_SUPPORT_HACK="-xc99"
72
fi
73
])
74
AC_PROG_GCC_TRADITIONAL
75
19.2.11 by Monty Taylor
Change for older libtool.
76
# We use libtool
77
AC_PROG_LIBTOOL
19.3.6 by Brian Aker
First pass through making RPM.
78
AM_SANITY_CHECK
79
LIBTOOL="$LIBTOOL --preserve-dup-deps"
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
80
1 by Brian Aker
Import from HG
81
AC_C_BIGENDIAN
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
82
AC_C_CONST
83
AC_TYPE_SIZE_T
84
AC_TYPE_SSIZE_T
85
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
86
AC_MSG_CHECKING("C Compiler version")
87
if test "$GCC" = "yes"
88
then
89
  CC_VERSION=`$CC --version | sed 1q`
90
elif test "$SUNCC" = "yes"
91
then
92
  CC_VERSION=`$CC -V 2>&1 | sed 1q`
93
else
94
  CC_VERSION=""
95
fi
96
AC_MSG_RESULT("$CC_VERSION")
97
AC_SUBST(CC_VERSION)
98
99
AC_DEFINE([_THREAD_SAFE],[1],[Thread safe code])
100
AC_DEFINE([_REENTRANT],[1],[Re-entrant code])
101
102
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
103
AC_HEADER_TIME
40 by Eric Day
First pass at libevent interface, server interface, and gearmand.
104
AC_CHECK_HEADERS(assert.h errno.h fcntl.h netinet/tcp.h signal.h stdarg.h)
47 by Eric Day
Started adding job processing.
105
AC_CHECK_HEADERS(stdio.h stdlib.h string.h sys/socket.h sys/types.h)
106
AC_CHECK_HEADERS(sys/utsname.h unistd.h)
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
107
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
108
#--------------------------------------------------------------------
109
# Check for libevent
110
#--------------------------------------------------------------------
111
90 by Eric Day
Change autoconf to use better lib search macros.
112
AC_LIB_HAVE_LINKFLAGS(event,,
113
[
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
114
#include <sys/types.h>
115
#include <sys/time.h>
116
#include <stdlib.h>
90 by Eric Day
Change autoconf to use better lib search macros.
117
#include <event.h>
118
],[
119
  struct bufferevent bev;
120
  bufferevent_settimeout(&bev, 1, 1);
121
  event_init();
122
  event_loop(EVLOOP_ONCE);
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
123
])
90 by Eric Day
Change autoconf to use better lib search macros.
124
AS_IF([test x$ac_cv_libevent = xno],
98 by Eric Day
Oops, this is Gearman, not Drizzle.
125
      AC_MSG_ERROR([A recent libevent is required for Gearman. Check http://www.monkey.org/~provos/libevent ]))
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
126
91 by Eric Day
Fixed some more configure stuff.
127
save_LIBS="${LIBS}"
128
LIBS="${LIBS} ${LTLIBEVENT}"
129
AC_CHECK_FUNCS(event_base_new)
130
AC_CHECK_FUNCS(event_base_get_method)
131
LIBS="$save_LIBS"
132
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
133
#--------------------------------------------------------------------
134
# Check for libuuid
135
#--------------------------------------------------------------------
136
137
AC_CHECK_HEADERS(uuid/uuid.h)
138
if test "x$ac_cv_header_uuid_uuid_h" = "xno"
139
then
140
  AC_MSG_ERROR([Couldn't find uuid/uuid.h. Try installing libuuid development packages])
141
fi
90 by Eric Day
Change autoconf to use better lib search macros.
142
AC_LIB_HAVE_LINKFLAGS(uuid,,
143
[
144
#include <uuid/uuid.h>
145
],
146
[
147
  uuid_t uout;
148
  uuid_generate(uout);
149
])
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
150
151
#--------------------------------------------------------------------
152
# Check for tcmalloc
153
#--------------------------------------------------------------------
154
155
AC_ARG_ENABLE([tcmalloc],
156
    [AS_HELP_STRING([--enable-tcmalloc],
157
       [Enable linking with tcmalloc @<:@default=off@:>@])],
158
    [ac_enable_tcmalloc="$enableval"],
159
    [ac_enable_tcmalloc="no"])
160
161
if test "x$ac_enable_tcmalloc" != "xno"
162
then
163
  AC_CHECK_LIB(tcmalloc,malloc,[],[])
164
fi
165
166
if test "x$ac_cv_lib_tcmalloc_malloc" != "xyes"
167
then
168
  AC_CHECK_LIB(mtmalloc,malloc,[],[])
169
fi
170
171
172
# Build optimized or debug version ?
173
# First check for gcc and g++
174
SYMBOLS_CFLAGS="-g"
175
DEBUG_OPTIMIZE_CFLAGS=""
176
OPTIMIZE_CFLAGS="-O"
177
if test "$GCC" = "yes"
178
then
179
  SYMBOLS_CFLAGS="-ggdb3"
180
  DEBUG_OPTIMIZE_CFLAGS="-O0"
181
  OPTIMIZE_CFLAGS="-O3"
182
fi
183
if test "$SUNCC" = "yes"
184
then
185
  if test "$target_cpu" = "sparc"
186
  then
187
    MEMALIGN_FLAGS="-xmemalign=8s"
188
  fi
69 by Eric Day
Fixed some build configs, allow SO_SNDTIMEO/SO_RCVTIMEO setsockopt to fail if not supported.
189
  SYMBOLS_CFLAGS="-g"
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
190
  DEBUG_OPTIMIZE_CFLAGS=""
191
  OPTIMIZE_CFLAGS="-xO4 -xlibmil -xdepend -Xa -mt -xstrconst -D_FORTEC_ ${MEMALIGN_FLAGS}"
192
fi
193
194
dnl TODO: Remove this define once we are using 2.61 across the board.
195
# AX_HEADER_ASSERT
196
# ----------------
197
# Check whether to enable assertions.
198
AC_DEFUN([AX_HEADER_ASSERT],
199
[
200
  AC_MSG_CHECKING([whether to enable assertions])
201
  AC_ARG_ENABLE([assert],
202
    [AS_HELP_STRING([--disable-assert],
203
       [Turn off assertions])],
204
    [ac_cv_assert="no"],
205
    [ac_cv_assert="yes"])
206
  AC_MSG_RESULT([$ac_cv_assert])
207
])
208
AX_HEADER_ASSERT
209
210
CFLAGS="${SYMBOLS_CFLAGS} ${CFLAGS}"
11.1.1 by brian
Mostly working backgroup task scheduler (status is not working)
211
69 by Eric Day
Fixed some build configs, allow SO_SNDTIMEO/SO_RCVTIMEO setsockopt to fail if not supported.
212
AC_ARG_WITH([debug],
213
    [AS_HELP_STRING([--with-debug],
214
       [Add debug code/turns off optimizations (yes|no) @<:@default=no@:>@])],
215
    [with_debug=$withval],
216
    [with_debug=no])
217
if test "$with_debug" = "yes"
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
218
then
219
  # Medium debug.
69 by Eric Day
Fixed some build configs, allow SO_SNDTIMEO/SO_RCVTIMEO setsockopt to fail if not supported.
220
  CFLAGS="${DEBUG_OPTIMIZE_CFLAGS} ${CFLAGS} ${SAVE_CFLAGS} -DDEBUG"
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
221
else
222
  # Optimized version. No debug
223
  CFLAGS="${OPTIMIZE_CFLAGS} ${CFLAGS} ${SAVE_CFLAGS}"
224
fi
225
19.2.7 by Monty Taylor
Added a few more warnings from libdrizzle.
226
AC_ARG_ENABLE([profiling],
227
    [AS_HELP_STRING([--enable-profiling],
228
       [Toggle profiling @<:@default=off@:>@])],
229
    [ac_profiling="$enableval"],
230
    [ac_profiling="no"])
231
232
AC_ARG_ENABLE([coverage],
233
    [AS_HELP_STRING([--enable-coverage],
234
       [Toggle coverage @<:@default=off@:>@])],
235
    [ac_coverage="$enableval"],
236
    [ac_coverage="no"])
1 by Brian Aker
Import from HG
237
4 by Eric Day
Did a lot of little cleanup, mostly cosmetic. Also updated configure.ac options and added -Werror. Made appropriate fixes so -Werror works.
238
AC_ARG_ENABLE([fail],
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
239
  [AS_HELP_STRING([--disable-fail],
240
    [Turn warnings into failures @<:@default=yes@:>@])],
241
  [ac_warn_fail="$enableval"],
99 by Eric Day
Updated PROTOCOL doc, added new protocol commands that were in Perl svn version, added new UNIQ grab/assign commands so worker can see client's unique ID as well (needed for persistent queues in workers).
242
  [ac_warn_fail="$building_from_bzr"])
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
243
244
AC_ARG_ENABLE([pedantic-warnings],
245
  [AS_HELP_STRING([--disable-pedantic-warnings],
246
    [Toggle pedanticness @<:@default=yes@:>@])],
247
  [ac_warn_pedantic="$enableval"],
75 by Eric Day
Re-enabled pedantic/fail for dev, fixed bug #315652.
248
  [ac_warn_pedantic="yes"])
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
249
250
AC_ARG_ENABLE([unreachable],
251
  [AS_HELP_STRING([--enable-unreachable],
252
    [Enable warnings about unreachable code @<:@default=no@:>@])],
253
  [ac_warn_unreachable="$enableval"],
254
  [ac_warn_unreachable="no"])
255
1 by Brian Aker
Import from HG
256
if test "$GCC" = "yes"
257
then
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
258
4 by Eric Day
Did a lot of little cleanup, mostly cosmetic. Also updated configure.ac options and added -Werror. Made appropriate fixes so -Werror works.
259
  if test "$ac_warn_fail" = "yes"
260
  then
261
    W_FAIL="-Werror"
262
  fi
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
263
  BASE_WARNINGS="-W -Wall -Wextra -Winvalid-pch ${W_FAIL}"
264
19.2.7 by Monty Taylor
Added a few more warnings from libdrizzle.
265
  if test "$ac_profiling" = "yes"
266
  then
267
    GPROF_PROFILING="-pg"
268
  else
269
    GPROF_PROFILING=" "
270
  fi
4 by Eric Day
Did a lot of little cleanup, mostly cosmetic. Also updated configure.ac options and added -Werror. Made appropriate fixes so -Werror works.
271
19.2.7 by Monty Taylor
Added a few more warnings from libdrizzle.
272
  if test "$ac_coverage" = "yes"
1 by Brian Aker
Import from HG
273
  then
19.2.7 by Monty Taylor
Added a few more warnings from libdrizzle.
274
    GPROF_COVERAGE="-fprofile-arcs -ftest-coverage"
1 by Brian Aker
Import from HG
275
  else
19.2.7 by Monty Taylor
Added a few more warnings from libdrizzle.
276
    GPROF_COVERAGE=" "
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
277
  fi
278
279
  if test "$ac_warn_pedantic" = "yes"
280
  then
99 by Eric Day
Updated PROTOCOL doc, added new protocol commands that were in Perl svn version, added new UNIQ grab/assign commands so worker can see client's unique ID as well (needed for persistent queues in workers).
281
    W_PEDANTIC="-pedantic -Wundef -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wswitch-enum -Wcast-align"
282
    save_CFLAGS="$CFLAGS"
283
    CFLAGS="-Wlogical-op"
284
    AC_TRY_COMPILE([#include <stdio>],,W_PEDANTIC="${W_PEDANTIC} -Wlogical-op")
285
    CFLAGS="$save_CFLAGS"
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
286
  fi
287
288
  if test "$ac_warn_unreachable" = "yes"
289
  then
290
    W_UNREACHABLE="-Wunreachable-code"
291
  fi
292
19.2.7 by Monty Taylor
Added a few more warnings from libdrizzle.
293
  CC_WARNINGS="${C99_SUPPORT_HACK} ${BASE_WARNINGS} ${W_PEDANTIC} ${W_UNREACHABLE} ${GPROF_PROFILING} ${GPROF_COVERAGE} "
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
294
295
  NO_REDUNDANT_DECLS="-Wno-redundant-decls"
296
  CPPFLAGS="${CPPFLAGS} -fpch-deps"
297
fi
298
if test "$SUNCC" = "yes"
299
then
300
  CC_WARNINGS="-v -xc99=all -errtags=yes -errwarn=%all -erroff=E_INTEGER_OVERFLOW_DETECTED"
301
fi
302
303
304
AM_CFLAGS="${CC_WARNINGS} ${AM_CFLAGS}"
305
306
AC_SUBST(NO_REDUNDANT_DECLS)
307
308
AC_SUBST([GLOBAL_CPPFLAGS],['-I$(top_srcdir) -I$(top_builddir)'])
309
AC_SUBST([AM_CPPFLAGS],['${GLOBAL_CPPFLAGS}'])
310
AC_SUBST([AM_CFLAGS])
311
312
AC_CHECK_PROGS([DOXYGEN], [doxygen])
84 by Eric Day
Added man page support. Doxygen produced miserable pages, so a custom Perl seemed best. It understands just enough of the Doxygen style comments to produce some useful, nicely formatted pages.
313
AC_CHECK_PROGS([PERL], [perl])
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
314
1 by Brian Aker
Import from HG
315
40 by Eric Day
First pass at libevent interface, server interface, and gearmand.
316
AC_CONFIG_FILES(Makefile libgearman/Makefile gearmand/Makefile
19.3.4 by Brian Aker
Make sure files are built during configure. Ignore generated files.
317
                tests/Makefile examples/Makefile support/Makefile
19.5.1 by Chris Mooney
This is the start of the benchmark code to slap the server using different functions
318
                benchmark/Makefile support/gearmand.pc support/gearmand.spec)
5.1.1 by Eric Day
Cleaned up autoconf and added stricter build options (and fixed code so it builds with new options). Also added proper licensing headers to source files.
319
320
AC_OUTPUT
19.2.5 by Monty Taylor
Merged in all of my fancy stuff from libdrizzle and drizzle.
321
322
echo "---"
323
echo "Configuration summary for $PACKAGE_NAME version $VERSION"
324
echo ""
325
echo "   * Installation prefix:       $prefix"
326
echo "   * System type:               $host_vendor-$host_os"
327
echo "   * Host CPU:                  $host_cpu"
328
echo "   * C Compiler:                $CC_VERSION"
329
echo "   * Assertions enabled:        $ac_cv_assert"
330
echo "   * Debug enabled:             $ac_enable_debug"
331
echo "   * Warnings as failure:       $ac_warn_fail"
332
echo ""
333
echo "---"
334