]> git.lyx.org Git - lyx.git/blob - boost/configure.in
cvsignore ++
[lyx.git] / boost / configure.in
1 dnl Process with autoconf to generate configure script   -*- sh -*-
2
3 AC_INIT(boost/config.hpp)
4 AC_PREREQ(2.13) dnl We want to use autoconf 2.13
5 AM_CONFIG_HEADER(boost/config.h)
6
7 dnl This is a trick to make autoheader do the right thing
8 dnl AM_CONFIG_HEADER(boost/config.h)
9
10 AC_CANONICAL_SYSTEM
11 AC_VALIDATE_CACHE_SYSTEM_TYPE
12
13 AM_INIT_AUTOMAKE(boost, 0.1lyx)
14
15 ### Check for programs
16 AC_PROG_MAKE_SET
17 AC_PROG_INSTALL
18
19 # Work around a problem in automake 1.4: when invoking install-strip,
20 # INSTALL_PROGRAM is changed to 'install -s', and since
21 # INSTALL_SCRIPT==INSTALL_PROGRAM, we get errors with fileutils-4.0
22 # which returns an error condition when stripping fails.
23 INSTALL_SCRIPT='${INSTALL}'
24
25 ### we will also need a C compiler to compile GNU gettext
26 AC_PROG_CC
27
28 ### check for special systems
29 AC_ISC_POSIX
30 AC_AIX
31
32 ### Check for program extensions (.exe or nothing)
33 AC_EXEEXT
34
35 ### Check for a C++ compiler
36 AC_LANG_CPLUSPLUS
37 AC_PROG_CXX
38 AC_PROG_CXXCPP
39 AC_DISABLE_SHARED
40 AC_LIBTOOL_WIN32_DLL
41 AM_PROG_LIBTOOL
42
43 ####################################################
44 ####################################################
45 ####################################################
46
47 AC_DEFINE(BOOST_RE_AUTO_CONFIGURE, [])
48 dnl Disable any caching here 
49 define([AC_CACHE_LOAD], )dnl
50 define([AC_CACHE_SAVE], )dnl
51
52 AC_MSG_RESULT(*** $0: regex++ configuration utility ***)
53 if test "${CXXFLAGS}" = ""; then 
54 AC_MSG_RESULT(* Note: for best reliability - try \"CXXFLAGS=-treat_warnings_as_errors\" $0 )
55 AC_MSG_RESULT(* Please don't forget specifying typical CXXFLAGS you'll be using - ) 
56 AC_MSG_RESULT(* such as that enabling exceptions handling, etc. )
57 AC_MSG_RESULT(* Add option forcing instantiation of all templates to CXXFLAGS if possible. )
58 AC_MSG_RESULT(* Add option enabling merging of template instances between translation units)
59 AC_MSG_RESULT(* to CXXFLAGS if possible. )
60 fi
61 AC_MSG_RESULT(Please stand by while exploring compiler capabilities...)
62 AC_MSG_RESULT(Be patient - this could take some time...)
63 AC_MSG_RESULT(***)
64
65 AC_ARG_ENABLE(extension,[--enable-extension=<ext>],
66 [
67 case "$enableval" in
68         no) AC_MSG_RESULT(Info :.cpp used as extension for tests) 
69             ac_ext=cpp 
70         ;;
71          *) AC_MSG_RESULT(Argument : .$enableval used as extension) 
72         ac_ext=$enableval
73 esac
74 ],
75 [AC_MSG_RESULT(Info : .cpp used as extension for tests) 
76         ac_ext=cpp
77 ]
78 )
79
80 AC_ARG_ENABLE(sizeof-short, [--enable-sizeof-short=<short size>], [], [enable_sizeof_short=2])
81 AC_ARG_ENABLE(sizeof-int, [--enable-sizeof-int=<int size>], [], [enable_sizeof_int=4])
82 AC_ARG_ENABLE(sizeof-long, [--enable-sizeof-long=<long size>], [], [enable_sizeof_long=4])
83 AC_ARG_ENABLE(force-cross, [--enable-force-cross forces cross compile mode])
84
85
86 # Save that, as it is being redefined several times 
87 use_ac_ext=$ac_ext
88
89 AC_LANG_CPLUSPLUS
90 ac_ext=$use_ac_ext
91
92 AC_MSG_CHECKING(for object file extention)
93 cat > "xyqtcz.$ac_ext" << EOF
94
95 int main()
96 {
97 }
98
99 EOF
100
101 if eval "$CXX $CXXFLAGS -c xyqtcz.$ac_ext"; then
102 rm -f "xyqtcz.$ac_ext"
103 ac_obj_ext=`find xyqtcz.* | sed 's/xyqtcz\(.*\)/\1/g'`
104 AC_MSG_RESULT(yes - $ac_obj_ext)
105 rm  -f "xyqtcz$ac_obj_ext"
106
107 else
108
109 AC_MSG_RESULT(no - could not create or find object file, defaulting to .o)
110 rm -f "xyqtcz.$ac_ext"
111 ac_obj_ext='.o'
112
113 fi
114
115 AC_MSG_CHECKING(for executable file extention)
116 ac_exe_ext=""
117 for file in /bin/sh.*
118 do
119
120 if test -x "$file"; then
121 ac_exe_ext=`echo "$file" | sed 's/\/bin\/sh\(.*\)/\1/g'`
122 fi
123
124 done
125
126 AC_MSG_RESULT(yes - $ac_exe_ext)
127 AC_SUBST(ac_exe_ext)
128 AC_SUBST(ac_obj_ext)
129
130
131 #
132 # determine machine word sizes
133 # and set BOOST_RE_INT32 to be the
134 # equivalent of intfast32_t in <inttypes.h>
135 #
136 if test "$enable_force_cross" = "yes"; then
137 cross_compiling="yes"
138 echo forced cross compilation mode turned on
139 fi
140
141 AC_CHECK_SIZEOF(short,"$enable_sizeof_short")
142 ac_ext=$use_ac_ext
143 AC_CHECK_SIZEOF(int,"$enable_sizeof_int")
144 ac_ext=$use_ac_ext
145 AC_CHECK_SIZEOF(long,"$enable_sizeof_long")
146 ac_ext=$use_ac_ext
147
148 AC_DEFINE_UNQUOTED(BOOST_RE_SIZEOF_SHORT, [$ac_cv_sizeof_short])
149 AC_DEFINE_UNQUOTED(BOOST_RE_SIZEOF_INT, [$ac_cv_sizeof_int])
150 AC_DEFINE_UNQUOTED(BOOST_RE_SIZEOF_LONG, [$ac_cv_sizeof_long])
151
152
153 if test "$ac_cv_sizeof_int" -lt 4; then
154     if test "$ac_cv_sizeof_long" -ge 4; then
155       AC_DEFINE(BOOST_RE_INT32_LONG)
156     else
157       AC_MSG_ERROR(Cannot find any 32-bit integer type for your compiler)
158     fi
159   ac_ext=$use_ac_ext
160 fi
161 ac_ext=$use_ac_ext
162
163
164 ac_ext=$use_ac_ext
165
166 dnl checking for compiler capabilities
167 AC_MSG_CHECKING(for basic template compatibility)
168 AC_TRY_LINK( [
169 template <class Arg1, class Arg2, class Result>
170 struct binary_function {
171     typedef Arg1 first_argument_type;
172     typedef Arg2 second_argument_type;
173     typedef Result result_type;
174 };      
175 template <class T>
176 struct plus : public binary_function<T, T, T> {
177     T operator()(const T& x, const T& y) const;
178 };
179
180 //
181 // non-inline
182 // link will fail if template is not instantiated
183 //
184 template <class T>
185 T plus<T>::operator()(const T& x, const T& y) const 
186 { return x + y; }
187
188 plus<int> p;
189 ],
190 [
191 // check member function is actually instantiated
192 int i, j, k;
193 i = p(k, j);
194 ], 
195 [ac_cv_compat="yes"],
196 [AC_MSG_ERROR(Your compiler won't be able to compile this implementation. Sorry.) 
197  ac_cv_compat="no"]
198 )
199 AC_MSG_RESULT($ac_cv_compat)
200
201 AC_MSG_CHECKING(for exception support)
202 AC_TRY_COMPILE(
203
204 #include <stdlib.h>
205
206 int f1()throw()
207 {
208  return 23;
209 }
210
211 void do_throw()
212 {
213  throw (int)25;
214 }
215 ],
216 [
217  try
218  {
219   f1();
220   do_throw();
221  }
222  catch(int i)
223  {
224  }
225  catch(...)
226  {
227  }
228 ],
229 [AC_MSG_RESULT(yes)],
230 [AC_MSG_RESULT(no)
231 AC_MSG_ERROR(Sorry, without exception handling you can't compile this library)])
232
233
234 AC_ARG_ENABLE(mutable, [--disable-mutable turns off mutable support])
235 if test "$enable_mutable" = "no"; then
236 AC_DEFINE(BOOST_RE_NO_MUTABLE, [])
237 else
238
239 AC_MSG_CHECKING(for mutable keyword)
240 AC_TRY_COMPILE(
241
242 #include <stdlib.h>
243
244 class foo
245 {
246  mutable int val;
247  public:
248  foo(int i) : val(i) {}
249  void set(int i)const;
250 };
251
252 void foo::set(int i)const
253 {
254  val = i;
255 }
256 ],
257 [
258  const foo f(4);
259  f.set(3);
260 ],
261 [AC_MSG_RESULT(yes)],
262 [AC_DEFINE(BOOST_RE_NO_MUTABLE, []) AC_MSG_RESULT(no)])
263 fi
264
265 AC_MSG_CHECKING(for default template parameter support)
266 AC_TRY_COMPILE(
267
268 #include <stdlib.h>
269
270 template <class T, class U = int>
271 struct foo
272 {
273  T val;
274  U alt;
275 };
276 ],
277 [
278  foo<int, double> f1;
279  foo<int, int> f2;
280  foo<double> f3;
281  foo<int> f4;
282 ],
283 [AC_MSG_RESULT(yes)],
284 [AC_MSG_ERROR(Sorry: you can't compile this library)])
285
286 AC_MSG_CHECKING(for derived default template parameter support)
287 AC_TRY_COMPILE(
288
289 #include <stdlib.h>
290
291 template <class T>
292 class inner
293 {
294 public:
295  typedef T inner_type;
296 };
297
298 template <class T, class U = inner<T> >
299 struct foo
300 {
301  T val;
302  U alt;
303 };
304 ],
305 [
306  foo<int, inner<double> > f1;
307  foo<int, inner<int> > f2;
308  foo<double> f3;
309  foo<int> f4;
310 ],
311 [AC_MSG_RESULT(yes)],
312 [AC_MSG_ERROR(Sorry, you can't compile this library)])
313
314
315 AC_MSG_CHECKING([for function template partial ordering])
316 AC_TRY_COMPILE(
317
318 #include <stdlib.h>
319
320 template <class T>
321 struct dummy{};
322
323 struct dummy2
324 {
325  int result()const { return 1; }
326 };
327
328 template <class T>
329 int foo(const T& t)
330 { return t.result(); }
331
332 template <class T>
333 int foo(const dummy<T>& )
334 { return 0; }
335
336 ],
337 [
338  dummy<double> d;
339  dummy2 d2;
340  int i = foo(d);
341  i = foo(d2);
342 ],
343 [AC_MSG_RESULT(yes)],
344 [AC_DEFINE(BOOST_RE_NO_PARTIAL_FUNC_SPEC, []) AC_MSG_RESULT(no)])
345
346 AC_MSG_CHECKING([for template friend functions])
347 AC_TRY_COMPILE(
348
349 #include <stdlib.h>
350
351 template <class T2>
352 void foo(T2 t);
353
354 template <class T>
355 struct dummy
356 {
357         template <class T2> friend void foo(T2);
358 private:
359         void foo2();
360         void foo3()const;
361 };
362
363 template <class T2>
364 void foo(T2 t)
365 {
366         dummy<T2> d1;
367         d1.foo2();
368         d1.foo3();
369         dummy<int> d2;
370         d2.foo2();
371         d2.foo3();
372 }
373
374
375 ],
376 [
377         foo(3);
378         foo(2.345);
379 ],
380 [AC_MSG_RESULT(yes)],
381 [AC_DEFINE(BOOST_RE_NO_TEMPLATE_FRIEND, []) AC_MSG_RESULT(no)])
382
383
384
385 AC_ARG_ENABLE(ms-windows, [--disable-ms-windows turns off native MS Windows support (when available)])
386 AC_ARG_ENABLE(threads, [--disable-threads turns off multi-threading support (when available)])
387 if test "$enable_ms_windows" != "no"; then
388
389 AC_MSG_CHECKING(for MS Windows)
390 AC_TRY_COMPILE(
391
392 #include <windows.h>
393
394 #if defined(__GNUC__) && (__GNUC_MINOR__ == 95) && (__GNUC__ == 2)
395 #error can't mix STL code with <windows.h> due to bug in gcc2.95.x
396 #endif
397
398
399 ],
400 [
401  int i = GetVersion();
402 ],
403 [iswin="true"
404 AC_DEFINE(BOOST_RE_PLATFORM_WINDOWS, []) 
405 AC_MSG_RESULT(yes)],
406 [AC_MSG_RESULT(no)
407 enable_ms_windows="no"]
408 )
409 fi
410
411 if test "$enable_ms_windows" != "no"; then
412 dnl Ok check for Win32, then linkage:
413 AC_MSG_CHECKING(for MS Win32)
414 AC_TRY_COMPILE(
415
416 #include <windows.h>
417
418 CRITICAL_SECTION cs;
419 ],
420 [
421  InitializeCriticalSection(&cs);
422  EnterCriticalSection(&cs);
423  LeaveCriticalSection(&cs);
424  DeleteCriticalSection(&cs);
425 ],
426 [AC_MSG_RESULT(yes)],
427 [AC_MSG_RESULT(no)
428 enable_ms_windows="no"]
429 )
430 fi
431
432 if test "$enable_ms_windows" != "no"; then
433
434 if test "$CXX" != "cl"; then
435 AC_CHECK_LIB(user32, main, [LIBS="$LIBS -luser32"], [])
436 AC_CHECK_LIB(kernel32, main, [LIBS="$LIBS -lkernel32"], [])
437 fi
438
439 AC_TRY_LINK(
440
441 #include <windows.h>
442
443 CRITICAL_SECTION cs;
444 ],
445 [
446  InitializeCriticalSection(&cs);
447  EnterCriticalSection(&cs);
448  LeaveCriticalSection(&cs);
449  DeleteCriticalSection(&cs);
450  HeapAlloc(0, 0, 20);
451  CharLower((LPTSTR)0);
452  LoadString(0, 0, 0, 0);
453 ],
454 [
455 if test "enable_threads" != "no"; then
456 # turn on threading support:
457 AC_MSG_CHECKING(for mult-thread support)
458 AC_MSG_RESULT("yes")
459 AC_DEFINE(BOOST_RE_THREADS, [])
460 AC_DEFINE(BOOST_RE_PLATFORM_W32, [])
461 fi
462 ],
463 [
464 # bu**er, windows is present but we can't link
465 AC_MSG_WARN([
466          MS Win32 seems to be present, but we can't link, 
467          or find the default library names for kernal32.dll
468          and user32.dll.
469          $0 is disabling MS Windows support, re-run $0 with
470          the environment variable "LIBS" set to the library 
471          files required to re-enable Win32 support.])
472 enable_ms_windows="no"
473 ]
474 )
475
476
477 fi
478
479
480 if test "$iswin" != "true"; then
481
482 AC_MSG_CHECKING(for MS DOS)
483 AC_TRY_COMPILE(
484
485 #include <dos.h>
486 ],
487 [
488  int i = _doserrno;
489 ],
490 [AC_DEFINE(BOOST_RE_PLATFORM_DOS, []) AC_MSG_RESULT(yes)],
491 [AC_MSG_RESULT(no)])
492
493 fi
494
495
496 AC_MSG_CHECKING(for bool support)
497 AC_TRY_COMPILE(
498
499 ],
500 [
501  bool i = true;
502 ],
503 [AC_MSG_RESULT(yes)],
504 [AC_DEFINE(BOOST_RE_NO_BOOL,[])
505 AC_MSG_RESULT(no)])
506
507
508 AC_ARG_ENABLE(wstring, [--disable-wstring turns off wide character string support])
509
510 if test "$enable_wstring" = "no"; then
511 AC_DEFINE(BOOST_RE_NO_WCHAR_H, [])
512 else
513
514 AC_MSG_CHECKING(for <cwchar>)
515 AC_TRY_LINK(
516
517 #include <cwchar>
518 ],
519 [
520 ],
521 [AC_MSG_RESULT(yes)],
522 [AC_DEFINE(BOOST_RE_NO_WCHAR_H,[])
523 AC_MSG_RESULT(no)]
524 )
525 fi
526
527 if test "$enable_wstring" = "no"; then
528 AC_DEFINE(BOOST_RE_NO_WCTYPE_H, [])
529 else
530
531 AC_MSG_CHECKING(for <cwctype>)
532 AC_TRY_LINK(
533
534 #include <cwctype>
535 ],
536 [
537 ],
538 [AC_MSG_RESULT(yes)],
539 [AC_DEFINE(BOOST_RE_NO_WCTYPE_H,[])
540 AC_MSG_RESULT(no)]
541 )
542 fi
543
544
545 if test "$enable_wstring" = "no"; then
546 AC_DEFINE(BOOST_RE_NO_WCSTRING, [])
547 else
548
549 AC_MSG_CHECKING(for wide string functions)
550 AC_TRY_LINK(
551 [
552 #include "confdefs.h"
553 #ifndef BOOST_RE_NO_WCHAR_H
554 #include <cwchar>
555 #endif
556 #ifndef BOOST_RE_NO_WCTYPE_H
557 #include <cwctype>
558 #endif 
559 #include <cstdlib>
560 #include <cstdio>
561 #include <cstring>
562 #include <cctype>
563 #include <string>
564 template class std::basic_string<wchar_t>;
565 ],
566 [
567  using namespace std;
568  wchar_t c[50];
569  char d[50];
570  wcscpy(c, L"abcd");
571  wcscmp(L"", L"");
572  wcslen(L"");
573  wcsxfrm(0, L"", 0);
574  wcstombs(d, L"", 0);
575  mbstowcs(c, "", 0);
576  iswlower(L'c');
577 ],
578 [AC_MSG_RESULT(yes)]
579 enable_wstring="yes",
580 [AC_DEFINE(BOOST_RE_NO_WCSTRING,[])
581 AC_MSG_RESULT(no)]
582 enable_wstring="no")
583 fi
584
585 if test "$enable_wstring" != "no"; then
586 AC_MSG_CHECKING(for swprintf support)
587 AC_TRY_LINK(
588
589 #include "confdefs.h"
590 #ifndef BOOST_RE_NO_WCHAR_H
591 #include <wchar.h>
592 #endif
593 #ifndef BOOST_RE_NO_WCTYPE_H
594 #include <wctype.h>
595 #endif
596 #include <string.h>
597 #include <stdio.h>
598 ],
599 [
600  wchar_t c[50];
601  swprintf(c, 50, L"abcd");
602 ],
603 [AC_MSG_RESULT(yes)],
604 [AC_DEFINE(BOOST_RE_NO_SWPRINTF,[])
605 AC_MSG_RESULT(no)]
606 enable_swprintf="no")
607 fi
608
609
610 AC_ARG_ENABLE(member-templates, [--disable-member-templates turns off member template class and function support])
611 if test "$enable_member_templates" = "no"; then
612 AC_DEFINE(BOOST_RE_NO_MEMBER_TEMPLATES, [])
613 else
614
615 AC_MSG_CHECKING(for member template classes and functions)
616 AC_TRY_COMPILE(
617
618
619 template <class T>
620 class alloc
621 {
622 public:
623  void* allocate(int);
624  void deallocate(void*);
625  alloc();
626  alloc(const alloc&);
627  template <class U>
628  alloc(const alloc<U>&) {}
629  alloc& operator=(const alloc&);
630  template <class U>
631  alloc& operator=(const alloc<U>&)
632  { return *this; }
633  
634  template <class U>
635  struct rebind
636  {
637   typedef alloc<U> other;
638  };
639 };
640
641 ],
642 [
643  alloc<int> ia;
644  alloc<double> da(ia);
645  alloc<float> fa;
646  fa.allocate(5);
647  fa = ia;
648 ],
649 [AC_MSG_RESULT(yes)],
650 [AC_DEFINE(BOOST_RE_NO_MEMBER_TEMPLATES,[])
651 AC_MSG_RESULT(no)])
652 fi
653
654
655 AC_ARG_ENABLE(template-returns, [--disable-template-returns turns off support for templates specialised by return type])
656 if test "$enable_template_returns" = "no"; then
657 AC_DEFINE(BOOST_RE_NO_TEMPLATE_RETURNS, [])
658 else
659
660 AC_MSG_CHECKING(for parameterised function returns)
661 AC_TRY_COMPILE(
662
663 template <class T>
664 T coerse(int i)
665 { return T(i); }
666 ],
667 [
668  double d = coerse<double>(5);
669  int i = coerse<int>(3);
670 ],
671 [AC_MSG_RESULT(yes)],
672 [AC_DEFINE(BOOST_RE_NO_TEMPLATE_RETURNS,[])
673 AC_MSG_RESULT(no)])
674 fi
675
676
677 AC_ARG_ENABLE(int64, [--disable-int64 turns off support for 64-bit integer types])
678 if test "$enable_int64" = "no"; then
679 AC_DEFINE(BOOST_RE_INT64_T_0)
680 else
681
682 AC_MSG_CHECKING(for 64-bit integral type)
683
684 if test "$ac_cv_sizeof_short" -eq 8; then
685 AC_DEFINE(BOOST_RE_INT64_T_1)
686 AC_MSG_RESULT(yes - short)
687 have_int64="true"
688 fi
689 if test "$ac_cv_sizeof_int" -eq 8 && test "$have_int64" != "true"; then
690 AC_DEFINE(BOOST_RE_INT64_T_2)
691 AC_MSG_RESULT(yes - int)
692 have_int64="true"
693 fi
694 if test "$ac_cv_sizeof_long" -eq 8 && test "$have_int64" != "true"; then
695 AC_DEFINE(BOOST_RE_INT64_T_3)
696 AC_MSG_RESULT(yes - long)
697 have_int64="true"
698 fi
699 if test "$have_int64" != "true"; then
700 AC_TRY_COMPILE(
701
702 #include <inttypes.h>
703
704 int64_t i = INT64_C(0x100000000);
705 ],
706 [
707 ],
708 [AC_MSG_RESULT(yes - int64_t)
709 have_int64="true"
710 AC_DEFINE(BOOST_RE_INT64_T_4)
711 ],
712 [])
713 fi
714
715 if test "$have_int64" != "true"; then
716
717 AC_TRY_COMPILE(
718
719 #include <stdlib.h>
720
721 long long i = 0x100000000LL;
722 ],
723 [
724 ],
725 [AC_MSG_RESULT(yes - long long)
726 have_int64="true"
727 AC_DEFINE(BOOST_RE_INT64_T_5)
728 ],
729 [])
730
731 fi
732
733 if test "$have_int64" != "true"; then
734
735 AC_TRY_COMPILE(
736
737 #include <stdlib.h>
738
739 __int64 i = 0x100000000i64;
740 ],
741 [
742 ],
743 [AC_MSG_RESULT(yes - __int64)
744 have_int64="true"
745 AC_DEFINE(BOOST_RE_INT64_T_6)
746 ],
747 [])
748 fi
749 if test "$have_int64" != "true"; then
750 AC_DEFINE(BOOST_RE_INT64_T,0)
751 AC_MSG_RESULT(no)
752 fi
753 fi
754
755
756 AC_ARG_ENABLE(messages, [--disable-messages turns off support for POSIX message categories, when available.])
757 if test "$enable_messages" = "no" || test "$enable_ms_windows" != "no"; then
758 AC_DEFINE(BOOST_RE_NO_CAT, [])
759 else
760
761 AC_CHECK_LIB(nl_types, catopen)
762 AC_CHECK_LIB(posix, catopen)
763
764 AC_MSG_CHECKING(for POSIX message categories)
765 AC_TRY_LINK(
766
767 #include <nl_types.h>
768
769 nl_catd message_cat = (nl_catd)-1;
770 ],
771 [
772  message_cat = catopen("some_name", 0);
773  catclose(message_cat);
774 ],
775 [AC_MSG_RESULT(yes)],
776 [AC_DEFINE(BOOST_RE_NO_CAT,[])
777 AC_MSG_RESULT(no)])
778
779 fi
780
781 if test "$enable_threads" != "no" && test "$enable_ms_windows" = "no"; then
782
783 AC_CHECK_LIB(pthread, pthread_mutex_init)
784 AC_CHECK_LIB(posix, pthread_mutex_init)
785
786 AC_MSG_CHECKING(for POSIX threads)
787 AC_TRY_LINK(
788
789 #include <pthread.h>
790
791 pthread_mutex_t m;
792
793 ],
794 [
795  pthread_mutex_init(&m, NULL);
796  pthread_mutex_lock(&m);
797  pthread_mutex_unlock(&m);
798  pthread_mutex_destroy(&m);
799 ],
800 [AC_MSG_RESULT(yes)
801 AC_DEFINE(BOOST_RE_THREADS, [])],
802 [AC_MSG_RESULT(no)])
803
804 fi
805
806
807 AC_ARG_ENABLE(nested-template-prefix, [--disable-nested-template-prefix turns off use of \"template\" as the nested template class access specifier.])
808 if test "$enable_nested_template_prefix" = "no" || test "$enable_member_templates" = "no"; then
809 AC_DEFINE(BOOST_RE_NESTED_TEMPLATE_DECL, [])
810 else
811
812 AC_MSG_CHECKING(for template nested class access)
813 AC_TRY_COMPILE(
814
815 template <class T>
816 class alloc
817 {
818 public:
819  void* allocate(int);
820  void deallocate(void*);
821  alloc();
822  alloc(const alloc&);
823  template <class U>
824  alloc(const alloc<U>&) {}
825  alloc& operator=(const alloc&);
826  template <class U>
827  alloc& operator=(const alloc<U>&)
828  { return *this; }
829  
830  template <class U>
831  struct rebind
832  {
833   typedef alloc<U> other;
834  };
835 };
836
837 ],
838 [
839  alloc<int> ia;
840  alloc<double> da(ia);
841  alloc<float> fa;
842  fa.allocate(5);
843  fa = ia;
844  alloc<int>::template rebind<double>::other da2(ia);
845 ],
846 [
847 AC_MSG_RESULT(yes)
848 AC_DEFINE(BOOST_RE_NESTED_TEMPLATE_DECL,template)
849 ],
850 [
851 AC_DEFINE(BOOST_RE_NESTED_TEMPLATE_DECL,[])
852 AC_MSG_RESULT(no)
853 ])
854
855 fi
856
857 AC_MSG_CHECKING(for explicit template instantiation)
858 AC_TRY_COMPILE(
859
860 #include "confdefs.h"
861 #include <stdlib.h>
862
863 template <class T>
864 class factorial
865 {
866 public:
867         factorial();
868         T operator()(T);
869 };
870
871 template <class T>
872 factorial<T>::factorial()
873 {
874 }
875
876 template <class T>
877 T factorial<T>::operator()(T t)
878 {
879         T result = 1;
880         for(T i = 1; i <= t; ++i)
881         {
882                 result *= i;
883         }
884         return result;
885 }
886
887 template class factorial<int>;
888 template class factorial<short>;
889 ],
890 [
891 ],
892 [
893 AC_MSG_RESULT(yes)
894 ],
895 [
896 AC_DEFINE(BOOST_RE_NO_TEMPLATE_INST,[])
897 AC_MSG_RESULT(no)
898 ])
899
900
901 AC_ARG_ENABLE(fastcall, [--disable-fastcall turns off use __fastcall and __stdcall.])
902 if test "$enable_fastcall" = "no" || test "$enable_ms_windows" != "no"; then
903 AC_DEFINE(BOOST_RE_CALL, [])
904 AC_DEFINE(BOOST_RE_CCALL, [])
905 else
906
907 AC_MSG_CHECKING(for __fastcall and __stdcall)
908 AC_TRY_COMPILE(
909
910 void __fastcall f1(int)
911 {
912 }
913
914 void __stdcall f2(int)
915 {
916 }
917
918 ],
919 [
920  f1(2);
921  f2(3);
922 ],
923 [AC_MSG_RESULT(yes)
924 AC_DEFINE(BOOST_RE_CALL, [__fastcall])
925 AC_DEFINE(BOOST_RE_CCALL, [__stdcall])
926 ],
927 [AC_DEFINE(BOOST_RE_CALL, [])
928 AC_DEFINE(BOOST_RE_CCALL, [])
929 AC_MSG_RESULT(no)])
930
931 fi
932
933 # move on to STL options:
934
935
936 AC_MSG_CHECKING(for standard library namespace)
937 AC_TRY_COMPILE(
938
939 #include <stddef.h>
940 #include <stdlib.h>
941 #include <list>
942 #include "confdefs.h"
943
944 namespace jm{
945
946 struct dummy{};
947
948 }; // namespace
949
950 jm::dummy d;
951
952 std::list<int> v;
953
954 ],
955 [
956 ],
957 [AC_MSG_RESULT(yes - std)
958 have_std_namespace="yes"
959 ],
960 [AC_MSG_RESULT(no - either STL is not present or in a non-standard namespace.)
961 AC_MSG_ERROR([Sorry, you can't compile this library unless the standard library is in namespace std.])])
962
963 AC_MSG_CHECKING(for <exception>)
964 AC_TRY_COMPILE(
965
966 #include <exception>
967 #include "confdefs.h"
968
969 class bad_expression : public std::exception
970 {
971    unsigned int code;
972 public:
973    bad_expression(unsigned int err) : code(err) {}
974    bad_expression(const bad_expression& e) : std::exception(e), code(e.code) {}
975    bad_expression& operator=(const bad_expression& e)
976    {
977       std::exception::operator=(e);
978       code = e.code;
979       return *this;
980    }
981    virtual const char* what()const throw();
982 };
983
984
985 std::exception e;
986 std::bad_exception e3;
987 ],
988 [
989 ],
990 [AC_MSG_RESULT(yes)
991 ],
992 [AC_MSG_RESULT(no)
993 AC_DEFINE(BOOST_RE_NO_EXCEPTION_H, [])
994 ])
995
996 AC_MSG_CHECKING(for <iterator>)
997 AC_TRY_COMPILE(
998
999 #include <iterator>
1000
1001 ],
1002 [
1003 ],
1004 [AC_MSG_RESULT(yes)
1005 ],
1006 [AC_MSG_RESULT(no)
1007 AC_DEFINE(BOOST_RE_NO_ITERATOR_H, [])
1008 ])
1009
1010 AC_MSG_CHECKING(for <algorithm>)
1011 AC_TRY_COMPILE(
1012
1013 #include <algorithm>
1014 #include "confdefs.h"
1015
1016 ],
1017 [
1018 ],
1019 [AC_MSG_RESULT(yes)
1020 ],
1021 [AC_MSG_RESULT(no)
1022 need_algo="yes"
1023 ])
1024
1025 if test "$enable_stl" != "no" && test "$need_algo" = "yes"; then
1026 AC_MSG_CHECKING(for <algo>)
1027 AC_TRY_COMPILE(
1028
1029 #include <algo>
1030
1031 ],
1032 [
1033 ],
1034 [AC_MSG_RESULT(yes)
1035 AC_DEFINE(BOOST_RE_USE_ALGO, [])
1036 ],
1037 [AC_MSG_RESULT(no - disabling STL support)
1038 AC_DEFINE(BOOST_RE_NO_STL, [])
1039 AC_DEFINE(BOOST_RE_NO_EXCEPTION_H, [])
1040 AC_DEFINE(BOOST_RE_NO_ITERATOR_H, [])
1041 AC_DEFINE(BOOST_RE_NO_MEMORY_H, [])
1042 AC_DEFINE(BOOST_RE_NO_LOCALE_H, [])
1043 AC_DEFINE(BOOST_RE_NO_STRING_H, [])
1044 enable_stl="no"
1045 ])
1046
1047 fi
1048
1049 AC_MSG_CHECKING(for <memory>)
1050 AC_TRY_COMPILE(
1051
1052 #include <memory>
1053 #include "confdefs.h"
1054
1055 std::allocator<char> a;
1056 std::allocator<double> d(a);
1057
1058 typedef std::allocator<char> alloc_type;
1059
1060 alloc_type::BOOST_RE_NESTED_TEMPLATE_DECL rebind<int>::other o(a);
1061 ],
1062 [
1063 ],
1064 [AC_MSG_RESULT(yes)
1065 ],
1066 [AC_MSG_RESULT(no)
1067 AC_DEFINE(BOOST_RE_NO_MEMORY_H, [])
1068 ])
1069
1070
1071 if test "$enable_stl" != "no"; then
1072 AC_MSG_CHECKING(for <string>)
1073 AC_TRY_COMPILE(
1074
1075 #include <string>
1076 #include "confdefs.h"
1077
1078 std::string a;
1079 //std::wstring ws;
1080
1081 ],
1082 [
1083 ],
1084 [AC_MSG_RESULT(yes)
1085 ],
1086 [AC_MSG_RESULT(no)
1087 AC_MSG_ERROR(Sorry: you can't compile this library without <string>)
1088 ])
1089
1090 fi
1091
1092 if test "$enable_stl" != "no"; then
1093 AC_MSG_CHECKING(for std::basic_string default arguments)
1094 AC_TRY_COMPILE(
1095
1096 #include <string>
1097 #include "confdefs.h"
1098
1099 std::basic_string<char> s1;
1100 std::basic_string<wchar_t> s2;
1101
1102 ],
1103 [
1104 ],
1105 [AC_MSG_RESULT(yes)
1106 ],
1107 [AC_MSG_RESULT(no)
1108 AC_DEFINE(BOOST_RE_NO_STRING_DEF_ARGS, [])
1109 ])
1110
1111 fi
1112
1113 ac_have_locale='no'
1114 if test "$enable_stl" != "no"; then
1115 AC_MSG_CHECKING(for <locale>)
1116 AC_TRY_COMPILE(
1117
1118 #include <locale>
1119 #include "confdefs.h"
1120
1121 std::locale l;
1122 ],
1123 [
1124 ],
1125 [AC_MSG_RESULT(yes)
1126 ac_have_locale='yes'
1127 ],
1128 [AC_MSG_RESULT(no)
1129 AC_DEFINE(BOOST_RE_NO_LOCALE_H, [])
1130 ])
1131
1132 fi
1133
1134 if test "$enable_stl" != "no"; then
1135 AC_MSG_CHECKING(for <iostream>)
1136 AC_TRY_COMPILE(
1137
1138 #include <iostream>
1139 #include <locale>
1140 #include "confdefs.h"
1141
1142 ],
1143 [
1144  std::locale l;
1145  std::cout.imbue(l);
1146  std::cout << "some text" << std::endl;
1147 ],
1148 [AC_MSG_RESULT(yes)
1149 ],
1150 [AC_MSG_RESULT(no)
1151 AC_DEFINE(BOOST_RE_OLD_IOSTREAM, [])
1152 ])
1153
1154 fi
1155
1156 AC_MSG_CHECKING(for std::distance)
1157 AC_TRY_COMPILE(
1158
1159 #include <iterator>
1160 #include "confdefs.h"
1161
1162 ],
1163 [
1164  int i, *j, *k;
1165  i = std::distance(j, k);
1166 ],
1167 [AC_MSG_RESULT(yes)
1168 AC_DEFINE(BOOST_RE_DISTANCE_T_1)
1169 have_dist="yes"
1170 ],
1171 [])
1172
1173 if test "$enable_stl" != "no" && test "$have_dist" != "yes"; then
1174 AC_TRY_COMPILE(
1175
1176 #include <iterator>
1177 #include "confdefs.h"
1178
1179 ],
1180 [
1181  int i, *j, *k;
1182  std::distance(j, k, i);
1183 ],
1184 [AC_MSG_RESULT(yes)
1185 AC_DEFINE(BOOST_RE_DISTANCE_T_2)
1186 have_dist="yes"
1187 ],
1188 [AC_MSG_RESULT(no)
1189 AC_DEFINE(BOOST_RE_DISTANCE_T_0)
1190 have_dist="yes"])
1191
1192 fi
1193
1194 if test "$enable_stl" != "no" && test "$have_si" != "yes"; then
1195 AC_MSG_CHECKING(for standard iterator syntax)
1196 AC_TRY_COMPILE(
1197
1198 #include <iterator>
1199 #include "confdefs.h"
1200
1201 ],
1202 [
1203  std::iterator<std::output_iterator_tag, char, std::ptrdiff_t, char*, char&> oi;
1204  std::iterator<std::input_iterator_tag, char, std::ptrdiff_t, char*, char&> ii;
1205  std::iterator<std::forward_iterator_tag, char, std::ptrdiff_t, char*, char&> fi;
1206  std::iterator<std::bidirectional_iterator_tag, char, std::ptrdiff_t, char*, char&> bi;
1207  std::iterator<std::random_access_iterator_tag, char, std::ptrdiff_t, char*, char&> ri;
1208 ],
1209 [AC_MSG_RESULT(yes)
1210 AC_DEFINE(BOOST_RE_ITERATOR_T_1)
1211 have_si="yes"
1212 have_oi="yes"
1213 have_ii="yes"
1214 have_fi="yes"
1215 have_bi="yes"
1216 have_ri="yes"
1217 ],
1218 [])
1219
1220 fi
1221
1222 if test "$enable_stl" != "no" && test "$have_si" != "yes"; then
1223 AC_TRY_COMPILE(
1224
1225 #include <iterator>
1226 #include "confdefs.h"
1227
1228 ],
1229 [
1230  std::iterator<std::output_iterator_tag, char, std::ptrdiff_t> oi;
1231  std::iterator<std::input_iterator_tag, char, std::ptrdiff_t> ii;
1232  std::iterator<std::forward_iterator_tag, char, std::ptrdiff_t> fi;
1233  std::iterator<std::bidirectional_iterator_tag, char, std::ptrdiff_t> bi;
1234  std::iterator<std::random_access_iterator_tag, char, std::ptrdiff_t> ri;
1235 ],
1236 [AC_MSG_RESULT(yes)
1237 AC_DEFINE(BOOST_RE_ITERATOR_T_2)
1238 have_si="yes"
1239 have_oi="yes"
1240 have_ii="yes"
1241 have_fi="yes"
1242 have_bi="yes"
1243 have_ri="yes"
1244 ],
1245 [AC_MSG_RESULT(no)])
1246 AC_DEFINE(BOOST_RE_ITERATOR_T_0)
1247
1248 fi
1249
1250
1251 if test "$have_oi" != "yes"; then
1252 AC_MSG_CHECKING(for output iterator syntax)
1253 AC_TRY_COMPILE(
1254
1255 #include <iterator>
1256 #include "confdefs.h"
1257
1258 ],
1259 [
1260  std::output_iterator oi;
1261 ],
1262 [AC_MSG_RESULT(yes)
1263 AC_DEFINE(BOOST_RE_OI_T_3)
1264 have_oi="yes"
1265 ],
1266 [AC_MSG_RESULT(no)
1267 AC_DEFINE(BOOST_RE_OI_T_0)
1268 have_oi="yes"])
1269
1270 fi
1271
1272 if test "$enable_stl" != "no" && test "$have_ii" != "yes"; then
1273 AC_MSG_CHECKING(for input iterator syntax)
1274 AC_TRY_COMPILE(
1275
1276 #include <iterator>
1277 #include "confdefs.h"
1278
1279 ],
1280 [
1281  std::input_iterator<char, std::ptrdiff_t> oi;
1282 ],
1283 [AC_MSG_RESULT(yes)
1284 AC_DEFINE(BOOST_RE_II_T_3)
1285 have_ii="yes"
1286 ],
1287 [])
1288
1289 fi
1290
1291 if test "$enable_stl" != "no" && test "$have_ii" != "yes"; then
1292 AC_TRY_COMPILE(
1293
1294 #include <iterator>
1295 #include "confdefs.h"
1296
1297 ],
1298 [
1299  std::input_iterator<char> oi;
1300 ],
1301 [AC_MSG_RESULT(yes)
1302 AC_DEFINE(BOOST_RE_II_T_4)
1303 have_ii="yes"
1304 ],
1305 [AC_MSG_RESULT(no)
1306 AC_DEFINE(BOOST_RE_II_T_0)
1307 have_ii="yes"])
1308
1309 fi
1310
1311 if test "$enable_stl" != "no" && test "$have_fi" != "yes"; then
1312 AC_MSG_CHECKING(for forward iterator syntax)
1313 AC_TRY_COMPILE(
1314
1315 #include <iterator>
1316 #include "confdefs.h"
1317
1318 ],
1319 [
1320  std::forward_iterator<int, std::ptrdiff_t> oi;
1321 ],
1322 [AC_MSG_RESULT(yes)
1323 AC_DEFINE(BOOST_RE_FI_T_3)
1324 have_fi="yes"
1325 ],
1326 [AC_MSG_RESULT(no)
1327 AC_DEFINE(BOOST_RE_FI_T_0)
1328 have_fi="yes"])
1329
1330 fi
1331
1332 if test "$enable_stl" != "no" && test "$have_bi" != "yes"; then
1333 AC_MSG_CHECKING(for bidirectional iterator syntax)
1334 AC_TRY_COMPILE(
1335
1336 #include <iterator>
1337 #include "confdefs.h"
1338
1339 ],
1340 [
1341  std::bidirectional_iterator<int, std::ptrdiff_t> oi;
1342 ],
1343 [AC_MSG_RESULT(yes)
1344 AC_DEFINE(BOOST_RE_BI_T_)
1345 have_bi="yes"
1346 ],
1347 [AC_MSG_RESULT(no)
1348 AC_DEFINE(BOOST_RE_BI_T_0)
1349 have_bi="yes"])
1350
1351 fi
1352
1353 if test "$enable_stl" != "no" && test "$have_ri" != "yes"; then
1354 AC_MSG_CHECKING(for random access iterator syntax)
1355 AC_TRY_COMPILE(
1356
1357 #include <iterator>
1358 #include "confdefs.h"
1359
1360 ],
1361 [
1362  std::random_access_iterator<int, std::ptrdiff_t> oi;
1363 ],
1364 [AC_MSG_RESULT(yes)
1365 AC_DEFINE(BOOST_RE_RI_T_3)
1366 have_ri="yes"
1367 ],
1368 [AC_MSG_RESULT(no)
1369 AC_DEFINE(BOOST_RE_RI_T_0)
1370 have_ri="yes"])
1371
1372 fi
1373
1374 if test "$enable_stl" != "no"; then
1375 AC_MSG_CHECKING(for output iterator assignment)
1376 AC_TRY_COMPILE(
1377
1378 #include "confdefs.h"
1379 #include <iterator>
1380 #ifdef BOOST_RE_OLD_IOSTREAM
1381 #include <iostream.h>
1382 std::ostream_iterator<char> a(cout);
1383 std::ostream_iterator<char> b(cout);
1384 #else
1385 #include <iostream>
1386 std::ostream_iterator<char> a(std::cout);
1387 std::ostream_iterator<char> b(std::cout);
1388 #endif
1389
1390 #include <list>
1391 #if !defined(BOOST_RE_NO_TRICKY_DEFAULT_PARAM) && !defined(BOOST_RE_NO_DEFAULT_PARAM)
1392 typedef std::list<int> list_type;
1393 #else
1394 typedef std::list<int, jm_def_alloc> list_type;
1395 #endif
1396
1397 list_type v;
1398
1399 std:: back_insert_iterator<list_type> c(v);
1400 std:: back_insert_iterator<list_type> d(v);
1401
1402 ],
1403 [
1404         a = b;
1405         c = d;
1406 ],
1407 [AC_MSG_RESULT(yes)
1408 ],
1409 [AC_MSG_RESULT(no)
1410 AC_DEFINE(BOOST_RE_NO_OI_ASSIGN, [])
1411 ])
1412
1413 fi
1414
1415
1416
1417
1418
1419 #
1420 # generate include dependencies
1421 #
1422 #ac_all_h=""
1423 #ac_all_dep=""
1424 #for file in ../../boost/re_detail/*.hpp
1425 #do
1426 #       if test "$file" != '../../boost/re_detail/*.hpp'; then
1427 #               ac_all_h="$ac_all_h ../$file"
1428 #               ac_all_dep="$ac_all_dep $file"
1429 #       fi
1430 #done
1431 #echo "$ac_all_h"
1432
1433 #
1434 # generate source dependencies
1435 #
1436 #ac_all_o=""
1437 #ac_rules=""
1438 #ac_all_cpp=""
1439 #cat ./lib/makefile.org > ./lib/makefile.in
1440 #for file in src/*.cpp src/*.c
1441 #do
1442 #       if test "$file" != 'src/*.cpp' && test "$file" != 'src/*.c'; then
1443 #               dnl echo source dependency found "$file"
1444 #               ac_all_dep="$ac_all_dep $file"
1445 #               ac_all_cpp="$ac_all_cpp $file"
1446 #               root=`echo "$file" | sed 's/src\/\(.*\)\..*/\1/g'`
1447 #               dnl echo root file name is "$root"
1448 #               ac_all_o="$ac_all_o $root$ac_obj_ext"
1449 #               echo >> ./lib/makefile.in
1450 #               echo >> ./lib/makefile.in
1451 #               echo "$root$ac_obj_ext"': $(ALL_H) '"../$file" >> ./lib/makefile.in
1452 #               echo '  $(CPP) $(CPP_PROJ)'" ../$file" >> ./lib/makefile.in
1453 #               echo '  $(AR) -rc lib$(LIBNAME).a'" $root$ac_obj_ext" >> ./lib/makefile.in
1454 #       fi
1455 #done
1456
1457 #echo "$ac_rules" >> ./lib/makefile.in
1458
1459 #AC_SUBST(ac_all_o)
1460 #AC_SUBST(ac_all_h)
1461 #AC_SUBST(ac_all_cpp)
1462 #AC_SUBST(ac_all_dep)
1463
1464 #ac_regress="$ac_regress r1$ac_exe_ext"
1465
1466 #if test "$enable_wstring" != "no"; then
1467 #ac_regress="$ac_regress r2$ac_exe_ext"
1468 #fi
1469
1470 #AC_SUBST(ac_regress)
1471
1472 if test "$enable_ms_windows" = "no"; then
1473 AC_DEFINE(BOOST_RE_NO_W32, [])
1474 fi
1475
1476
1477 #
1478 # OK final test for possible link time problems:
1479 #
1480 cat > conf2.h << EOF
1481
1482 #include "confdefs.h"
1483 #include <stdlib.h>
1484
1485 template <class T>
1486 class factorial
1487 {
1488 public:
1489         factorial();
1490         T operator()(T);
1491 };
1492
1493 template <class T>
1494 factorial<T>::factorial()
1495 {
1496 }
1497
1498 template <class T>
1499 T factorial<T>::operator()(T t)
1500 {
1501         T result = 1;
1502         for(T i = 1; i <= t; ++i)
1503         {
1504                 result *= i;
1505         }
1506         return result;
1507 }
1508
1509 int conf2_test();
1510
1511
1512 EOF
1513
1514 cat > conf2.cpp << EOF
1515
1516 #include "conf2.h"
1517
1518 int conf2_test()
1519 {
1520         factorial<int> f;
1521         return f(8);
1522 }
1523
1524 EOF
1525
1526 old_libs="$LIBS"
1527
1528 LIBS="conf2.cpp $old_libs"
1529
1530 AC_MSG_CHECKING(for link time template merging)
1531 AC_TRY_LINK( 
1532 [
1533 #include "conf2.h"
1534 ],
1535 [
1536         factorial<int> g;
1537         g(5);
1538         conf2_test();
1539 ], 
1540 [AC_MSG_RESULT(yes)],
1541 [AC_DEFINE(BOOST_RE_NO_TEMPLATE_MERGE, [])
1542 AC_MSG_RESULT(no)
1543 AC_MSG_RESULT([    Warning - $0 has determined that your compiler can not merge]) 
1544 AC_MSG_RESULT([    template instances, you may have problems linking to libregex++.a - ])
1545 AC_MSG_RESULT([    see the FAQ for further details.])
1546 ]
1547 )
1548
1549 if eval "$CXX $CXXFLAGS -c conf2.cpp" && eval "ar -rc libconf2.a conf2$ac_obj_ext"; then
1550 LIBS="-L./ -lconf2 $old_libs"
1551
1552 AC_MSG_CHECKING(for link time template merging from archive files)
1553 AC_TRY_LINK( 
1554 [
1555 #include "conf2.h"
1556 ],
1557 [
1558         factorial<int> g;
1559         g(5);
1560         conf2_test();
1561 ], 
1562 [AC_MSG_RESULT(yes)],
1563 [AC_DEFINE(BOOST_RE_NO_TEMPLATE_MERGE_A, [])
1564 AC_MSG_RESULT(no)
1565 AC_MSG_RESULT([    Warning - $0 has determined that your compiler can not merge ])
1566 AC_MSG_RESULT([    template instances, if these are located inside an archive file,])
1567 AC_MSG_RESULT([    you may have problems linking to libregex++.a - see the FAQ for])
1568 AC_MSG_RESULT([    further details.])
1569 ]
1570 )
1571
1572 else
1573
1574 AC_MSG_RESULT(Unable to create library archive, library may not be fully configured.)
1575
1576 fi
1577
1578
1579 #
1580 # cleanup
1581 #
1582 rm -f conf2.h
1583 rm -f conf2.cpp
1584 rm -f "conf2$ac_obj_ext"
1585 rm -f libconf2.a
1586 LIBS="$old_libs"
1587
1588 cat > conf2.h << EOF
1589
1590 #include "confdefs.h"
1591 #include <stdlib.h>
1592
1593 template <class T>
1594 class factorial
1595 {
1596 public:
1597         factorial();
1598         T operator()(T);
1599 };
1600
1601 template <class T>
1602 factorial<T>::factorial()
1603 {
1604 }
1605
1606 template <class T>
1607 T factorial<T>::operator()(T t)
1608 {
1609         T result = 1;
1610         switch(t)
1611         {
1612         case 2:
1613                 for(T i = 1; i <= 2; ++i)
1614                 {
1615                         result *= i;
1616                 }
1617                 return result;
1618         case 3:
1619                 for(T i = 1; i <= 3; ++i)
1620                 {
1621                         result *= i;
1622                 }
1623                 return result;
1624         case 4:
1625                 for(T i = 1; i <= 4; ++i)
1626                 {
1627                         result *= i;
1628                 }
1629                 return result;
1630         case 5:
1631                 for(T i = 1; i <= 5; ++i)
1632                 {
1633                         result *= i;
1634                 }
1635                 return result;
1636         case 6:
1637                 for(T i = 1; i <= 6; ++i)
1638                 {
1639                         result *= i;
1640                 }
1641                 return result;
1642         case 7:
1643                 for(T i = 1; i <= 7; ++i)
1644                 {
1645                         result *= i;
1646                 }
1647                 return result;
1648         default:
1649                 for(T i = 1; i <= t; ++i)
1650                 {
1651                         result *= i;
1652                 }
1653                 return result;
1654         }
1655         return 0;
1656 }
1657
1658 int conf2_test();
1659
1660
1661 EOF
1662
1663 cat > conf2.cpp << EOF
1664
1665 #include "conf2.h"
1666
1667 int conf2_test()
1668 {
1669         factorial<int> f;
1670         return f(8);
1671 }
1672
1673 EOF
1674
1675 old_libs="$LIBS"
1676
1677 LIBS="conf2.cpp $old_libs"
1678
1679 AC_MSG_CHECKING(for link time template merging of switch statements)
1680 AC_TRY_LINK( 
1681 [
1682 #include "conf2.h"
1683 ],
1684 [
1685         factorial<int> g;
1686         g(5);
1687         conf2_test();
1688 ], 
1689 [AC_MSG_RESULT(yes)],
1690 [AC_DEFINE(BOOST_RE_NO_TEMPLATE_SWITCH_MERGE, [])
1691 AC_MSG_RESULT(no)
1692 AC_MSG_RESULT([    Warning - $0 has determined that your compiler can not merge]) 
1693 AC_MSG_RESULT([    template instances, if those instances contain switch statements, ])
1694 AC_MSG_RESULT([    you may have problems linking to libregex++.a - ])
1695 AC_MSG_RESULT([    see the FAQ for further details.])
1696 ]
1697 )
1698
1699 #
1700 # cleanup
1701 #
1702 rm -f conf2.h
1703 rm -f conf2.cpp
1704 LIBS="$old_libs"
1705
1706
1707
1708 AC_DEFINE(BOOST_RE_AUTO_CONF)
1709
1710 #AC_MSG_RESULT(***)
1711 #AC_MSG_RESULT($0: setting up headers...)
1712 #AC_MSG_RESULT(***)
1713 #AC_OUTPUT(lib/makefile demo/jgrep/makefile demo/timer/makefile demo/regress/makefile makefile)
1714 #AC_MSG_RESULT(***)
1715 #AC_MSG_RESULT($0: regex++ package tuned for use with \"${CXX}\" compiler.)
1716 #AC_MSG_RESULT($0: To restore original settings - copy jm_opt.in to ../../boost/re_detail/regex_options.hpp)
1717 #AC_MSG_RESULT(***)
1718
1719 #post processing cleanup:
1720 #sed 's%^[      ]*#[    ]*undef[        ][      ]*\(.*\)[       ]*$%/* #define \1 */%' ../../boost/re_detail/regex_options.hpp > jm_opt.out
1721 #cat jm_opt.out > ../../boost/re_detail/regex_options.hpp
1722 #sed 's%\(#[    ]*\)undef[      ]%\1define %' ../../boost/re_detail/regex_options.hpp > jm_opt.out
1723 #cat jm_opt.out > ../../boost/re_detail/regex_options.hpp
1724 #rm -f jm_opt.out
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754 ####################################################
1755 ####################################################
1756 ####################################################
1757
1758 ### Finish the work.
1759 AC_OUTPUT([Makefile \
1760 ],  [])
1761
1762