blob: 80518dbcfee88744ef5fb51e69ccb90dff39a7cf [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001# Copyright (C) 1999-2005 Open Source Telecom Corporation.
2# Copyright (C) 2006-2010 David Sugar, Tycho Softworks.
3#
4# This file is free software; as a special exception the author gives
5# unlimited permission to copy and/or distribute it, with or without
6# modifications, as long as this notice is preserved.
7#
8# This program is distributed in the hope that it will be useful, but
9# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
10# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
12AC_INIT(src/thread.cpp)
13AC_CONFIG_MACRO_DIR([m4])
14m4_pattern_allow(LT_VERSION)
15
16VERSION="1.8.1"
17LT_RELEASE="1.8"
18LT_VERSION="0:1"
19
20dnl this is a C++ library after all..
21AC_LANG(C++)
22
23# lsb build option
24
25ccincludedir=""
26ost_cv_thread_library="none"
27
28COMMON_FLAGS="-D_GNU_SOURCE"
29
30AC_ARG_WITH(lsb, [ --with-lsb=name Build lsb compliant package],[
31 if test ! -d "$prefix" ; then
32 prefix="/opt/$withval" ; fi
33 if test ! -d "$sysconfdir" ; then
34 sysconfdir="/etc$prefix" ; fi
35 if test ! -d "$localstatedir" ; then
36 localstatedir="/var$prefix" ; fi
37 AC_SUBST(prefix)
38 CC=/opt/lsbdev-cc/bin/lsbcc
39 AC_SUBST(CC)
40 CXX=/opt/lsbdev-cc/bin/lsbc++
41 AC_SUBST(CXX)
42 AC_SUBST(sysconfdir)
43 AC_SUBST(localstatedir)
44])
45
46case "$prefix" in
47/opt/*)
48 if test "$datadir" == '${prefix}/share' ; then
49 if test "$mandir" == '${datadir}/man' ; then
50 mandir='${prefix}/man' ; fi
51 if test "$infodir" == '${datadir}/info' ; then
52 infodir='${prefix}/info' ; fi
53 datadir='${prefix}'
54 fi
55 if test "$sysconfdir" == '${prefix}/etc' ; then
56 sysconfdir=/etc${prefix} ; fi
57 if test "$localstatedir" == '${prefix}/var' ; then
58 localstatedir=/var${prefix} ; fi
59 if test "$includedir" == '${prefix}/include' ; then
60 ccincludedir="$includedir" ; fi
61 AC_SUBST(mandir)
62 AC_SUBST(infodir)
63 AC_SUBST(sysconfdir)
64 AC_SUBST(localstatedir)
65 AC_SUBST(datadir)
66 AC_SUBST(prefix)
67 ;;
68esac
69
70if test -z "$ccincludedir" ; then
71 case "$includedir" in
72 */lib/*)
73 ccincludedir='${includedir}'
74 ;;
75 *)
76 ccincludedir='${includedir}/cc++2'
77 ;;
78 esac
79fi
80
81AC_SUBST(ccincludedir)
82
83AC_CONFIG_AUX_DIR(autoconf)
84AC_CANONICAL_SYSTEM
85AC_PROG_CPP
86AC_PROG_CC
87AC_PROG_CXXCPP
88AC_PROG_CXX
89OST_PROG_CC_POSIX
90NP_PROG_MSC
91AC_LIBTOOL_WIN32_DLL
92AM_PROG_LIBTOOL
93AM_INIT_AUTOMAKE(commoncpp2, [$VERSION])
94AM_CONFIG_HEADER(config.h)
95
96AC_C_RESTRICT
97AC_C_VOLATILE
98AC_C_INLINE
99
100AH_TOP(
101#ifndef CCXX_CONFIG_H_
102#define CCXX_CONFIG_H_
103#define __DLL
104#define __EXPORT_TEMPLATE(x)
105#undef CCXX_EMPTY
106#define CCXX_EMPTY
107
108#define COMMON_64_CLEAN
109#define COMMON_ASYNC_OVERRIDE
110#define COMMON_OST_NAMESPACE
111#define COMMON_THREAD_SLEEP
112#define COMMON_NET_DEVICES
113#define COMMON_THREAD_DEBUG
114#define COMMON_DEADLOCK_DEBUG
115#define COMMON_NAMED_MUTEX
116#define COMMON_PROCESS_ATTACH
117#define COMMON_XML_PARSING
118#define COMMON_TIMER_SLEEP
119
120#if __GNUC__ > 1 && !defined(__STRICT_ANSI__) && !defined(__PEDANTIC__)
121#define DYNAMIC_LOCAL_ARRAYS
122#endif
123
124#if defined(__CYGWIN__)
125#define _POSIX_REALTIME_SIGNALS
126#define _POSIX_THREADS
127#endif
128
129#if defined(__APPLE__) && defined(__MACH__)
130#ifndef MACOSX
131#define MACOSX
132#define _P1003_1B_VISIBLE
133#endif
134#ifndef _PTHREADS
135#define _PTHREADS 1
136#endif
137#endif
138
139#if defined(__FreeBSD__)
140#ifndef __BSD_VISIBLE
141#define __BSD_VISIBLE 1
142#endif
143#endif
144
145#ifdef _AIX
146#ifndef _ALL_SOURCE
147#define _ALL_SOURCE
148#endif
149#endif
150
151#ifdef __hpux
152#ifndef _XOPEN_SOURCE_EXTENDED
153#define _XOPEN_SOURCE_EXTENDED
154#endif
155#ifndef _INCLUDE_LONGLONG
156#define _INCLUDE_LONGLONG
157#endif
158#endif
159
160#define CCXX_PACKING
161#if defined(__GNUC__)
162#define CCXX_PACKED
163#elif !defined(__hpux) && !defined(_AIX)
164#define CCXX_PACKED
165#endif
166
167#if defined(__sun) || defined(__SUN__)
168#define __EXTENSIONS__ 1
169#endif
170
171#ifndef _REENTRANT
172#define _REENTRANT 1
173#endif
174
175#ifndef _THREAD_SAFE
176#define _THREAD_SAFE 1
177#endif
178
179#ifndef _GNU_SOURCE
180#define _GNU_SOURCE 1
181#endif
182
183#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) &&!defined(__OpenBSD__) && !defined(__MACH__) && !defined(__NetBSD__)
184#define _XOPEN_SOURCE 600
185#endif
186)
187
188if test "$prefix" != "/usr" ; then
189 if test -d "$prefix" ; then
190 bprefix="$prefix"
191 else if test "$GCC" = "no" ; then
192 bprefix=/usr/local ; fi
193 fi
194 if test -d $bprefix/include ; then
195 COMMON_FLAGS="$COMMON_FLAGS -I$bprefix/include"
196 fi
197 if test -d $bprefix/lib ; then
198 LIBS="$LIBS -L$bprefix/lib"
199 fi
200fi
201
202OST_PROG_COMMON
203OST_PROG_LIBVER
204OST_PROG_LIBRARY(CCXX,[$LT_VERSION])
205OST_AUTOMAKE_MODE
206OST_MAINTAINER_MODE
207OST_WINVER
208OST_WIN32
209OST_CC_FCNTL
210OST_CC_SYSTIME
211OST_CC_TYPES
212OST_CC_ENDIAN
213OST_CC_SIGNAL
214OST_CC_STRING
215OST_CC_GETOPT
216OST_CC_DYNAMIC
217OST_LIB_PTHREAD
218OST_LIB_REENTRANT
219OST_LIB_POLL
220OST_SYS_SOCKET
221
222ost_cv_ssl=no
223AC_ARG_WITH(monotonic, [ --without-monotonic Disable monotonic clock],
224 [],[AC_DEFINE(USE_MONOTONIC_TIMER, [1], [use monotonic])
225])
226
227AC_ARG_WITH(extras, [ --without-extras Disables extras lib],[
228 OST_LIB_NOZLIB
229 OST_LIB_NOXML
230 ost_cv_extras=no
231],[
232 ost_cv_extras=yes
233 AC_DEFINE(HAVE_EXTRAS, [1], [Enable extras])
234
235 AC_ARG_WITH(gnutls, [ --with-gnutls Enable gnutls support], [
236 AC_CHECK_HEADER(gnutls/gnutls.h,[
237 AC_CHECK_LIB(gnutls, gnutls_init, [
238 SSL_LIBS="-lgnutls -lgcrypt"
239 ost_cv_ssl=true
240 AC_DEFINE(CCXX_SSL, [GNUTLS], [defines ssl])
241 AC_DEFINE(CCXX_GNUTLS, [1], [define gnutls])
242 ])
243 ],[])
244],[
245 AC_ARG_WITH(openssl, [ --with-openssl Enable openssl support],
246 [OST_LIB_SSL],
247 [OST_LIB_NOSSL])
248 ])
249 AC_ARG_WITH(compression, [ --without-compression Disable libz compression],
250 [OST_LIB_NOZLIB],
251 [OST_LIB_ZLIB])
252])
253
254AC_ARG_WITH(memaudit, [ --with-memaudit Enable memory auditing],
255 [AC_DEFINE(COMMON_MEMORY_AUDIT, [1], [enable auditing])])
256
257AC_ARG_WITH(cppunit, [ --with-cppunit Build cppunit based test suite],[
258 if test "$withval" != "yes"; then
259 CPPUNIT_LIBS="-l$withval"
260 else
261 CPPUNIT_LIBS="-lcppunit"
262 fi
263],[
264 CPPUNIT_LIBS=" "
265])
266AC_SUBST(CPPUNIT_LIBS)
267
268AM_CONDITIONAL(WITH_CPPUNIT_TESTS, test "$CPPUNIT_LIBS" != " ")
269
270AC_CHECK_HEADERS(sys/file.h sys/param.h sys/wait.h syslog.h syslog.hposix_evlog.h ss.h ioctl.h)
271AC_CHECK_FUNCS(realpath lstat snprintf memmove strdup lockf waitpid wait4 gettimeofday)
272AC_CHECK_FUNCS(posix_memalign setegid setpgrp getpagesize)
273
274# C++ stuff must done after library and header
275# (some C++ define require some header)
276OST_CXX_PROGRAMMING
277
278# allow build of library without exception handling, for use in
279# dedicated targets, etc...
280
281AC_ARG_WITH(exceptions, [ --without-exceptions Disable exception handling],
282 [OST_CXX_NOEXCEPTIONS],
283 [OST_CXX_EXCEPTIONS]
284)
285
286OST_CXX_MUTABLE
287OST_CXX_NAMESPACE
288OST_CXX_IOSTREAM
289OST_CXX_NEW_INIT
290OST_SGI_STLPORT
291
292# Are we using the GNU compiler?
293if test "$GCC" = yes ; then
294 WARN_FLAGS="-pedantic -Wall"
295else
296 WARN_FLAGS=""
297fi
298AC_SUBST(WARN_FLAGS)
299
300OST_DEBUG
301
302if test $ost_cv_gnuwin32 = yes ; then
303 CCXX_DIR="\$(top_srcdir)/w32"
304else
305 if test $np_cv_prog_msc = yes ; then
306 CCXX_DIR="\$(top_srcdir)/w32"
307 else
308 CCXX_DIR="\$(top_srcdir)/inc"
309 fi
310fi
311KDOC_DIR="\$(top_srcdir)/doc"
312AC_SUBST(LT_RELEASE)
313AC_SUBST(KDOC_DIR)
314AC_SUBST(CCXX_DIR)
315AC_SUBST(incprefix)
316AM_CONDITIONAL(WIN32, test $ost_cv_gnuwin32 = yes)
317AM_CONDITIONAL(EXTRAS, test $ost_cv_extras = yes)
318AC_SUBST(ost_cv_dynloader)
319
320# some peculiar things needed for cygwin dll builds and the currently broken toolchain...
321
322SHARED_FLAGS=""
323MODULE_FLAGS="-module -shared -avoid-version"
324STAGE2=""
325BASE_LIB=""
326case "$target_os" in
327osf*)
328 COMMON_FLAGS="$COMMON_FLAGS -D_POSIX_C_SOURCE=1 -D_OSF_SOURCE=1 -D__USE_STD_IOSTREAM"
329 ;;
330cygwin*|mingw*)
331 BASE_LIB="../src/libccgnu2.la $XML_LIBS $ZSTREAM_LIBS $SSL_LIBS"
332 AC_DEFINE(CYGWIN_IMPORTS, [1], [cygwin environment])
333 SHARED_FLAGS="-no-undefined"
334 MODULE_FLAGS="-module -shared -avoid-version -no-undefined"
335 ;;
336darwin6*)
337 MODULE_FLAGS="-dynamic -bundle -undefined suppress -flat_namespace -read_only_relocs suppress"
338 STAGE2="macosx"
339 AC_DEFINE(_DARWIN6_, [1], [darwin6 environment])
340 ;;
341darwin*)
342 MODULE_FLAGS="-dynamic -bundle -undefined suppress -flat_namespace -read_only_relocs suppress"
343 ;;
344linux*)
345 BASE_LIB="../src/libccgnu2.la"
346 ;;
347esac
348
349AC_SUBST(COMMON_FLAGS)
350AC_SUBST(SHARED_FLAGS)
351AC_SUBST(MODULE_FLAGS)
352AC_SUBST(BASE_LIB)
353AC_SUBST(STAGE2)
354
355AC_SUBST(sysconfdir)
356AC_SUBST_DIR(etc_confdir, sysconfdir)
357
358if test "$sysconfdir" != '${prefix}/etc' ; then
359 AC_DEFINE_UNQUOTED(ETC_PREFIX, "$etc_confdir/", [system config prefix])
360elif test "$sysconfdir" != '/etc' ; then
361 AC_DEFINE_UNQUOTED(ETC_CONFDIR, "$etc_confdir/", [primary config prefix])
362fi
363
364AH_BOTTOM([
365
366#ifdef HAVE_SS_H
367#include <ss.h>
368#define COMMON_SECURE
369#endif
370
371#define COMMON_NAMESPACE ost
372#define NAMESPACE_COMMON namespace ost {
373#define END_NAMESPACE }
374
375#ifdef HAVE_VISIBILITY
376#define __EXPORT __attribute__ ((visibility("default")))
377#define __DLLRTL __attribute__ ((visibility("default")))
378#define __LOCAL __attribute__ ((visibility("hidden")))
379#else
380#define __EXPORT
381#define __DLLRTL
382#define __LOCAL
383#endif
384
385#ifndef ETC_PREFIX
386#ifdef WIN32
387#define ETC_PREFIX "C:\\WINDOWS\\"
388#endif
389
390#ifndef ETC_PREFIX
391#define ETC_PREFIX "/etc/"
392#endif
393#endif
394
395#endif
396
397])
398
399AC_PATH_PROG(DOXYGEN, doxygen, no)
400AC_SUBST(DOXYGEN)
401AM_CONDITIONAL(DOXY, test "$DOXYGEN" != "no")
402
403AM_CONDITIONAL(GETOPT_LONG, [test ! -z "$LIBGETOPTOBJS"])
404
405LIB_VERSION=`echo $LT_RELEASE | sed -e 's/[\.]/_/'`
406LIB_MAJOR=`echo $LT_VERSION | sed -e 's/[:].*$//'`
407
408AC_SUBST(LIB_VERSION)
409AC_SUBST(LIB_MAJOR)
410
411AC_OUTPUT([src/ccgnu2-config src/libccext2.pc src/libccgnu2.pc
412src/Makefile w32/Makefile w32/vs2008/Makefile w32/vs2008/ccext2.vcproj w32/vs2008/ccgnu2.vcproj w32/vs2008/common.sln m4/Makefile doc/Doxyfile
413doc/Makefile demo/Makefile inc/Makefile inc/cc++/Makefile Makefile
414commoncpp2.spec tests/Makefile commoncpp2.list w32/ccgnu2.dsp w32/ccext2.dsp w32/ccgnu2.vcproj w32/ccext2.vcproj])
415
416# if test ! -f inc/cc++/thread.h ; then
417# cp ${srcdir}/inc/cc++/*.h inc/cc++ ; fi
418
419cd inc
420rm -f config.tmp
421cp ../config.h config.tmp
422sed -e s!"@thrprefix@"!"$thrprefix"! -e s!"@USR_PREFIX@"!"$prefix"! \
423 -e s!PACKAGE!CCXX_PACKAGE! -e s!VERSION!CCXX_VERSION! <config.tmp >cc++/config.h
424cd ..
425#
426# Visual Studio
427#
428DLLVERSION=`echo "$LT_RELEASE" | sed -e 's/\.//'g`
429#
430# Visual Studio 2008
431#
432rm -f w32/vs2008/ccext2.vcproj.tmp w32/vs2008/ccgnu2.vcproj.tmp
433cp -p w32/vs2008/ccext2.vcproj w32/vs2008/ccext2.vcproj.tmp
434cp -p w32/vs2008/ccgnu2.vcproj w32/vs2008/ccgnu2.vcproj.tmp
435sed -e s/VCVERSION/$VERSION/g < w32/vs2008/ccext2.vcproj.tmp > w32/vs2008/ccext2.vcproj
436sed -e s/VCVERSION/$VERSION/g < w32/vs2008/ccgnu2.vcproj.tmp > w32/vs2008/ccgnu2.vcproj
437
438cp -p w32/vs2008/ccext2.vcproj w32/vs2008/ccext2.vcproj.tmp
439cp -p w32/vs2008/ccgnu2.vcproj w32/vs2008/ccgnu2.vcproj.tmp
440sed -e s/DLLVERSION/$DLLVERSION/g < w32/vs2008/ccext2.vcproj.tmp > w32/vs2008/ccext2.vcproj
441sed -e s/DLLVERSION/$DLLVERSION/g < w32/vs2008/ccgnu2.vcproj.tmp > w32/vs2008/ccgnu2.vcproj
442rm -f w32/vs2008/ccext2.vcproj.tmp w32/vs2008/ccgnu2.vcproj.tmp
443
444#
445# Visual Studio 2005
446#
447rm -f w32/ccext2.vcproj.tmp w32/ccgnu2.vcproj.tmp
448cp -p w32/ccext2.vcproj w32/ccext2.vcproj.tmp
449cp -p w32/ccgnu2.vcproj w32/ccgnu2.vcproj.tmp
450sed -e s/VCVERSION/$VERSION/g < w32/ccext2.vcproj.tmp > w32/ccext2.vcproj
451sed -e s/VCVERSION/$VERSION/g < w32/ccgnu2.vcproj.tmp > w32/ccgnu2.vcproj
452
453cp -p w32/ccext2.vcproj w32/ccext2.vcproj.tmp
454cp -p w32/ccgnu2.vcproj w32/ccgnu2.vcproj.tmp
455sed -e s/DLLVERSION/$DLLVERSION/g < w32/ccext2.vcproj.tmp > w32/ccext2.vcproj
456sed -e s/DLLVERSION/$DLLVERSION/g < w32/ccgnu2.vcproj.tmp > w32/ccgnu2.vcproj
457rm -f w32/ccext2.vcproj.tmp w32/ccgnu2.vcproj.tmp
458
459#
460# Visual Studio 6
461#
462rm -f w32/ccext2.dsp.tmp w32/ccgnu2.dsp.tmp
463cp -p w32/ccext2.dsp w32/ccext2.dsp.tmp
464cp -p w32/ccgnu2.dsp w32/ccgnu2.dsp.tmp
465sed -e s/VCVERSION/$VERSION/g < w32/ccext2.dsp.tmp > w32/ccext2.dsp
466sed -e s/VCVERSION/$VERSION/g < w32/ccgnu2.dsp.tmp > w32/ccgnu2.dsp
467
468cp -p w32/ccext2.dsp w32/ccext2.dsp.tmp
469cp -p w32/ccgnu2.dsp w32/ccgnu2.dsp.tmp
470sed -e s/DLLVERSION/$DLLVERSION/g < w32/ccext2.dsp.tmp > w32/ccext2.dsp
471sed -e s/DLLVERSION/$DLLVERSION/g < w32/ccgnu2.dsp.tmp > w32/ccgnu2.dsp
472rm -f w32/ccext2.dsp.tmp w32/ccgnu2.dsp.tmp
473