]> git.lyx.org Git - lyx.git/blob - sigc++/configure.in
ws change
[lyx.git] / sigc++ / configure.in
1 ## (C) 1998 Stephan Kulow
2 ## Modified by Tero Pulkkinen
3 ## Modified by Karl Nelson
4 ## Modified by makeLyXsigc.sh (Allan Rae)
5
6 AC_INIT(slot.cc)
7
8 AC_DEFUN(LYX_FIX_MAKEFILE_IN,[
9 ## modify Makefile.in if need be -- since we still use automake
10 for dir in $srcdir $srcdir/macros ; do
11 ( cd $dir ;
12   sed < Makefile.in > Makefile_tmp \
13         -e 's/all: all-redirect/all: all-@USE_INCLUDED_SIGC@\
14 all-yes: all-redirect\
15 all-no:/' ;
16   mv Makefile_tmp Makefile.in )
17 done
18 ])
19
20 LYX_FIX_MAKEFILE_IN
21
22 define(AC_PUSH_LIB,[dnl
23 ifdef([__LIB__],,[define([__LIB__],0)])dnl
24 ac_save_LIBS[]__LIB__="$LIBS"
25 define([__LIB__],builtin(eval,(__LIB__ + 1)))dnl
26 LIBS="$1"])
27 define(AC_POP_LIB,[dnl
28 define([__LIB__],builtin(eval,(__LIB__ - 1)))dnl
29 LIBS="$ac_save_LIBS[]__LIB__"])
30
31
32 dnl
33 dnl Source packaging numbers
34 SIGC_MAJOR_VERSION=1
35 SIGC_MINOR_VERSION=0
36 SIGC_MICRO_VERSION=3
37
38 dnl Library extension
39 SIGC_RELEASE=1.0
40
41 SIGC_VERSION=$SIGC_MAJOR_VERSION.$SIGC_MINOR_VERSION.$SIGC_MICRO_VERSION
42
43 #
44 # +1 : ? : +1  == new interface that does not break old one
45 # +1 : ? : 0   == new interface that breaks old one
46 #  ? : ? : 0   == no new interfaces, but breaks apps
47 #  ? :+1 : ?   == just some internal changes, nothing breaks but might work 
48 #                 better
49 # CURRENT : REVISION : AGE
50 LIBSIGC_SO_VERSION=0:0:0
51 AC_SUBST(LIBSIGC_SO_VERSION, $LIBSIGC_SO_VERSION)
52
53 AC_SUBST(SIGC_RELEASE, $SIGC_RELEASE)
54 AC_SUBST(SIGC_VERSION)
55
56 AC_DEFINE_UNQUOTED(SIGC_MAJOR_VERSION, $SIGC_MAJOR_VERSION)
57 AC_DEFINE_UNQUOTED(SIGC_MINOR_VERSION, $SIGC_MINOR_VERSION)
58 AC_DEFINE_UNQUOTED(SIGC_MICRO_VERSION, $SIGC_MICRO_VERSION)
59
60 AC_CONFIG_AUX_DIR(../config)
61
62 dnl For automake.
63 VERSION=$SIGC_VERSION
64 PACKAGE=libsigc++
65
66 dnl Initialize automake stuff
67 AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
68
69 dnl Specify a configuration file
70 AM_CONFIG_HEADER(sigc++config.h)
71
72 AC_ARG_WITH([included-libsigc],
73   [  --without-included-libsigc
74                              Use the libsigc++ installed on the system
75                              Used when libsigc++ is bundled with applications],
76   [sigc_use_included_libsigc=$withval],
77   [sigc_use_included_libsigc=yes])
78 if test x$sigc_use_included_libsigc = xno; then
79   ## just change the setting for the Makefile
80   USE_INCLUDED_SIGC=no
81   AC_SUBST(USE_INCLUDED_SIGC)
82 else
83 ###
84 ### This else..fi goes till the end of the file!
85 ###
86   USE_INCLUDED_SIGC=yes
87   AC_SUBST(USE_INCLUDED_SIGC)
88
89 AC_ARG_ENABLE(threads,
90 [  --enable-threads       enables support threading.],
91 enable_threads=$enableval,enable_threads="no")
92 AC_ARG_ENABLE(checks,
93 [  --disable-checks        disables unnecessary tests needed for bug reports.],
94 enable_checks=$enableval,enable_checks="yes"
95 )
96
97 AC_PROG_CC
98 AC_PROG_CPP
99
100
101 AM_DISABLE_SHARED
102
103 dnl Instruct build of dll for cygwin (libtool 1.3)
104 dnl   Exports screw up badly on libtool 1.3, backing off to 1.2f
105 dnl A C_LIBTOOL_WIN32_DLL  
106
107 dnl libtool does all checks with $CC, not with $CXX
108 dnl maybe this should be fixed in libtool, not here
109 AM_PROG_LIBTOOL
110
111 dnl On FreeBSD 3.0 (and perhaps some other systems) GNU m4 is
112 dnl called `gm4' where `m4' is the system's own m4.
113 AC_CHECK_PROGS(M4, gm4 m4, m4)
114
115 AC_PROG_CXX
116 AC_LANG_CPLUSPLUS
117
118 dnl Checking if linker supports global constructors
119 dnl This is largely information for me if someone files a bug report
120 if test "X$enable_checks" = "Xyes"; then
121 AC_MSG_CHECKING([if linker supports global constructors])
122 cat > mylib.$ac_ext <<EOF
123 #include <stdio.h>
124
125 struct A
126   {A() {printf("PASS\n");}
127   };
128
129 A a;
130
131 int foo()
132   {return 1;}
133
134 EOF
135 cat > mytest.$ac_ext <<EOF
136 #include <stdio.h>
137
138 extern int foo();
139
140 int main(int argc,char **argv)
141   {
142    int i=foo();
143    if (i!=1) printf("FAIL\n");
144   }
145
146 EOF
147 sh libtool --mode=compile $CXX -c mylib.$ac_ext >&5
148 sh libtool --mode=link $CXX -o libtest.la -rpath / -version-info 0 mylib.lo  >&5
149 $CXX -c $CFLAGS $CPPFLAGS mytest.$ac_ext >&5
150 sh libtool --mode=link $CXX -o mytest mytest.o libtest.la >&5 2>/dev/null
151 if test -x mytest; then
152 myresult=`./mytest`
153 if test "X$myresult" = "XPASS"; then
154 AC_MSG_RESULT(yes)
155 else
156 AC_MSG_RESULT(no)
157 AC_MSG_WARN([
158 ===================================================================
159 WARNING: This platform lacks support of construction of global 
160 objects in shared librarys.  Although not required by this library, 
161 this is a serious problem for building C++ libraries.  You will not 
162 be able to use any shared libraries that contain global objects with 
163 contructors.
164
165 See ftp://rtfm.mit.edu/pub/usenet/news.answers/g++-FAQ/plain
166 for details about this problem.  Also for possible solutions
167 http://www.informatik.uni-frankfurt.de/~fp/Tcl/tcl-c++/tcl-c++.html
168 ===================================================================
169 ])
170 fi
171 else
172 AC_MSG_RESULT(unknown)
173 fi
174 rm -f mylib.* mytest.* libtest.la .libs/libtest* mytest .libs/mytest >&5
175 fi
176
177 AC_MSG_CHECKING(if C++ compiler uses std namespace )
178 AC_TRY_COMPILE(
179 [
180 #include <iostream>
181 namespace std{ void kludge(); }
182 using namespace std;
183 ],[
184 cout << "test" << endl;
185 ],[
186  ac_std_namespace=yes
187  AC_MSG_RESULT([yes])
188 ],[
189  ac_std_namespace=maybe
190 ])
191 if test "x$ac_std_namespace" = xmaybe ; then
192 AC_TRY_COMPILE(
193 [
194 #include <iostream.h>
195 namespace std{ void kludge(); }
196 using namespace std;
197 ],[
198 cout << "test" << endl;
199 ],[
200  ac_std_namespace=yes
201  AC_MSG_RESULT([yes])
202  AC_MSG_WARN([
203 ===================================================================
204 WARNING: This compiler platform does not have the iostream library
205 in the std namespace.  This presents a problem for writing portable
206 STL code.  To run the demos, you will need to place a file with the
207 following in a file called "iostream" in your include directory.
208
209 ---------------------------iostream--------------------------------
210 #ifndef IOSTREAM_KLUDGE
211 #define IOSTREAM_KLUDGE
212 #include <iostream.h>
213 namespace std { void iostream_kludge(); };
214 #endif
215 ===================================================================
216 ])
217 ],[
218  ac_std_namespace=no
219  AC_MSG_RESULT([no])
220  AC_MSG_WARN([
221 ===================================================================
222 WARNING: This compiler platform does not support iostream 
223 or namespaces.  You will not be able to run the demos as they
224 use STL.  This does not affect use of the library, only the demos.
225 ===================================================================
226 ])
227 ])
228 fi
229
230
231
232 dnl
233 dnl C++ compiler feature check start here
234
235 AC_MSG_CHECKING(if C++ compiler supports bool (required))
236 AC_TRY_COMPILE(
237 [
238 ],[
239    bool b=true;
240    bool b1=false;
241 ],[
242   ac_bool=yes
243   AC_MSG_RESULT([$ac_bool])
244 ],[
245   config_error=yes
246   AC_MSG_RESULT([$ac_bool])
247   AC_WARN(bool type is not supported by your compiler)
248 ]) 
249
250 AC_MSG_CHECKING([if C++ compiler supports const_cast<> (required)])
251 AC_TRY_COMPILE(
252 [
253    class foo;
254 ],[
255    const foo *c=0;
256    foo *c1=const_cast<foo*>(c);
257 ],[
258   ac_const_cast=yes
259   AC_MSG_RESULT([$ac_const_cast])
260 ],[
261   AC_MSG_RESULT([$ac_const_cast])
262   AC_WARN(C++ compiler const_cast<> does not work)
263   config_error=yes
264 ]) 
265
266 # Member function templates
267 AC_MSG_CHECKING(if C++ compiler supports member function templates)
268 AC_TRY_COMPILE(
269 [
270 class foo
271 {
272 public:
273   template <class T> void method(T t);
274 };
275
276 template <class T> void foo::method(T t) {t = 0;}
277 ],[
278 ],[
279    ac_member_func_templates=yes
280    AC_DEFINE(SIGC_CXX_MEMBER_FUNC_TEMPLATES)
281    AC_MSG_RESULT([$ac_member_func_templates])
282 ],[
283   ac_member_func_templates=no
284   AC_MSG_RESULT([$ac_member_func_templates])
285   config_error=yes
286   AC_MSG_WARN([Test for member templates failed. This disables some methods that requires member template support. If your compiler should support member templates, see config.log to figure out why the test failed.])
287 ])
288
289
290
291 # Member class templates
292 AC_MSG_CHECKING(if C++ compiler supports member class templates)
293 AC_TRY_COMPILE(
294 [
295 struct S
296 {
297   template <class T> struct A {};
298   template <class T> struct B {};
299 };
300 ],[
301 ],[
302    ac_member_class_templates=yes
303    AC_DEFINE(SIGC_CXX_MEMBER_CLASS_TEMPLATES)
304    AC_MSG_RESULT([$ac_member_class_templates])
305 ],[
306   ac_member_class_templates=no
307   AC_MSG_RESULT([$ac_member_class_templates])
308   AC_MSG_WARN([Test for member templates failed. This disables some methods that requires member template support. If your compiler should support member templates, see config.log to figure out why the test failed.])
309 ])
310
311
312
313 # Mutable
314 AC_MSG_CHECKING(if C++ compiler supports mutable)
315 AC_TRY_COMPILE(
316 [
317 class k {       
318         mutable char *c;
319 public:
320    void foo() const { c=0; }
321 };
322 ],[
323 ],[
324   ac_cxx_mutable=yes
325   AC_DEFINE(SIGC_CXX_MUTABLE)
326 ],[
327   ac_cxx_mutable=no
328 ]) 
329 AC_MSG_RESULT([$ac_cxx_mutable])
330
331
332 # Partial Specialization
333 AC_MSG_CHECKING([if C++ compiler supports partial specialization(required)])
334 AC_TRY_COMPILE(
335 [
336 template<class T, class K>
337 class k {       
338 public:
339 };
340 template<class T> class k<void,T> { };
341 ],[
342   k<float, float> b;
343   k<void,void> a;
344 ],[
345   ac_cxx_partial_specialization=yes
346   AC_MSG_RESULT([$ac_cxx_partial_specialization])
347   AC_DEFINE(SIGC_CXX_PARTIAL_SPEC)
348 ],[
349   config_error=yes
350   ac_cxx_partial_specialization=no
351   AC_MSG_RESULT([$ac_cxx_partial_specialization])
352   AC_MSG_WARN([Partial specialization is needed for signal templates.])
353 ]) 
354
355
356 AC_MSG_CHECKING(if C++ compiler supports name spaces)
357 AC_TRY_COMPILE(
358 [
359 namespace Check
360   {
361    int i;
362   }
363 ],[
364   Check::i=1;
365 ],[
366   ac_cxx_namespaces=yes
367   AC_MSG_RESULT([$ac_cxx_namespaces])
368   AC_DEFINE(SIGC_CXX_NAMESPACES)
369 ],[
370   ac_cxx_namespaces=no
371   AC_MSG_RESULT([$ac_cxx_namespaces])
372   AC_MSG_WARN([Without namespaces all classes will be global.])
373 ]) 
374
375
376 AC_MSG_CHECKING(if C++ compiler supports friend template)
377 AC_TRY_COMPILE(
378 [
379 struct A
380   {
381    template <class T>
382      friend T* gen();
383   };
384 ],[
385 ],[
386   ac_cxx_friend_templates=yes
387   AC_MSG_RESULT([$ac_cxx_friend_templates])
388   AC_DEFINE(SIGC_CXX_FRIEND_TEMPLATES)
389 ],[
390   ac_cxx_friend_templates=no
391   AC_MSG_RESULT([$ac_cxx_friend_templates])
392   AC_MSG_WARN([Access to dynamic will not be controlled.])
393 ]) 
394
395
396 AC_MSG_CHECKING(if C++ compiler has intrinsic constructors)
397 AC_TRY_COMPILE(
398 [
399 template<class T>
400   struct A
401     { T t;
402      A(): t() {}
403     };
404
405 A<int> i;
406 ],[
407 ],[
408   AC_DEFINE(SIGC_CXX_INT_CTOR)
409   ac_cxx_tmpl_intctor=yes
410 ],[
411   ac_cxx_tmpl_intctor=no
412 ])
413 AC_MSG_RESULT([$ac_cxx_tmpl_intctor])
414
415
416 AC_MSG_CHECKING(if C++ compiler uses template copy ctor)
417 AC_TRY_COMPILE(
418 [
419 template <class T>
420 struct A
421   {
422    A(const A&) {}
423    template <class T1>
424    A(const T1&) {}  
425   };
426 ],[
427 ],[
428   ac_cxx_template_cctor=no
429 ],[
430   AC_DEFINE(SIGC_CXX_TEMPLATE_CCTOR)
431   ac_cxx_template_cctor=yes
432 ])
433 AC_MSG_RESULT([$ac_cxx_template_cctor])
434
435
436 AC_MSG_CHECKING(if C++ compiler allows void returns)
437 AC_TRY_COMPILE(
438 [
439
440 void g(int *p)
441   {}
442
443 void h(int *p)
444   {return g(p);}
445
446 ],[
447 ],[
448   ac_cxx_void_return=yes
449   AC_DEFINE(SIGC_CXX_VOID_RETURN)
450 ],[
451   ac_cxx_void_return=no
452 ])
453 AC_MSG_RESULT([$ac_cxx_void_return])
454
455
456 AC_MSG_CHECKING(if C++ compiler allows specialization of references)
457 AC_TRY_COMPILE(
458 [
459 struct A {};
460 struct B {};
461
462 template <class T>
463 struct P
464   {
465    typedef A* ptr;
466   };
467
468 template <class T>
469 struct P<T&>
470   {
471    typedef B* ptr;
472   };
473
474 ],[
475     A* a;
476     B* b;
477     P<int>::ptr p=a;
478     P<int&>::ptr q=b;
479 ],[
480   ac_cxx_specialize_references=yes
481   AC_DEFINE(SIGC_CXX_SPECIALIZE_REFERENCES)
482 ],[
483   ac_cxx_specialize_references=no
484 ])
485 AC_MSG_RESULT([$ac_cxx_specialize_references])
486
487
488 dnl unused at the moment, disabled
489 dnl mirko, 99/1/15
490 dnl AC_MSG_CHECKING(if C++ compiler supports qualification of return types with templates)
491 dnl AC_TRY_COMPILE(
492 dnl [
493 dnl template<class T>
494 dnl class foo {
495 dnl public:
496 dnl   typedef int iterator;
497 dnl   iterator begin();
498 dnl };
499 dnl template<class T> foo<T>::iterator foo<T>::begin() { }
500 dnl ],[
501 dnl   foo<int> f;
502 dnl   f.begin();
503 dnl ],[
504 dnl   ac_template_qualification=yes
505 dnl ],[
506 dnl   AC_DEFINE(SIGC_CXX_NO_TEMPLATE_QUALIFICATION)
507 dnl   ac_template_qualification=no
508 dnl ]) 
509 dnl AC_MSG_RESULT([$ac_template_qualification])
510
511 dnl unused at the moment, disabled
512 dnl mirko, 99/1/15
513 dnl AC_MSG_CHECKING(if C++ compiler supports static data inside templates)
514 dnl AC_TRY_LINK(
515 dnl [
516 dnl template<class T>
517 dnl class foo { public: static T a; };
518 dnl template<class T>
519 dnl static T foo<T>::a=0;
520 dnl ],[
521 dnl   foo<int> b;
522 dnl ],[
523 dnl   ac_static_templates=yes
524 dnl ],[
525 dnl   AC_DEFINE(SIGC_CXX_NO_STATIC_TEMPLATES)
526 dnl   ac_static_templates=no
527 dnl ]) 
528 dnl AC_MSG_RESULT([$ac_static_templates])
529
530 AC_MSG_CHECKING(if C++ environment provides all required features)
531 if test "x$config_error" = xyes ; then
532   AC_MSG_RESULT([no])
533   AC_MSG_ERROR([Your compiler is not powerful enough to compile libsigc++. If it should be, see config.log for more information of why it failed.])
534 fi
535 AC_MSG_RESULT([yes])
536
537 dnl
538 dnl PTHREADS
539 dnl
540 AC_CHECK_HEADER(pthread.h,,[enable_threads="no"])
541 if test "x$enable_threads" = "xyes" ; then
542 enable_threads="no"
543 AC_CHECK_LIB(pthread,pthread_self,[enable_threads="yes";THREAD_LIB="-lpthread"])
544 AC_CHECK_LIB(cma,pthread_self,[enable_threads="yes";THREAD_LIB="-lcma"])
545 AC_PUSH_LIB($THREAD_LIB)
546 AC_CHECK_FUNC(pthread_keycreate,[AC_DEFINE(SIGC_PTHREAD_DCE)])
547 AC_POP_LIB()
548 AC_SUBST(THREAD_LIB)
549 fi
550
551 AC_MSG_CHECKING(if should compile with pthreads)
552 if test "x$enable_threads" = "xyes" ; then
553 AC_DEFINE(SIGC_PTHREADS)
554 AC_MSG_RESULT([yes])
555 AC_MSG_CHECKING([sizes of threading elements])
556
557 # Check for size of threading elements so that we don't expose
558 # the implementation
559 AC_TRY_RUN([
560
561 #include <stdio.h>
562 #include <pthread.h>
563
564 #ifdef SIGC_PTHREAD_DCE
565 typedef pthread_condattr_t CondAttr;
566 typedef pthread_mutexattr_t MutexAttr;
567 typedef pthread_attr_t ThreadAttr;
568 #else
569 typedef pthread_condattr_t*  CondAttr;
570 typedef pthread_mutexattr_t* MutexAttr;
571 typedef pthread_attr_t*      ThreadAttr;
572 #endif
573 typedef pthread_mutex_t      MutexImpl;
574 typedef pthread_cond_t       CondImpl;
575 typedef pthread_key_t        KeyImpl;
576 typedef pthread_t            ThreadImpl;
577
578 int main()
579   {
580     FILE *fptr;
581     fptr=fopen("ac_thread.sh","w");
582     fprintf(fptr,"ac_thread_cond_attr_size=%d\n",sizeof(CondAttr));
583     fprintf(fptr,"ac_thread_cond_impl_size=%d\n",sizeof(CondImpl));
584     fprintf(fptr,"ac_thread_mutex_attr_size=%d\n",sizeof(MutexAttr));
585     fprintf(fptr,"ac_thread_mutex_impl_size=%d\n",sizeof(MutexImpl));
586     fprintf(fptr,"ac_thread_thread_attr_size=%d\n",sizeof(ThreadAttr));
587     fprintf(fptr,"ac_thread_thread_impl_size=%d\n",sizeof(ThreadImpl));
588     fprintf(fptr,"ac_thread_key_impl_size=%d\n",sizeof(KeyImpl));
589     return 0;
590   }
591 ],[
592  . ./ac_thread.sh
593  rm ac_thread.sh
594 AC_MSG_RESULT(found)
595 ],[
596 AC_MSG_RESULT(failed)
597  AC_ERROR(
598 [Could not compile a program with threads, please see config.log for details.
599 ])
600 ],
601 [
602 AC_MSG_RESULT(cross)
603   if test ! -f ac_thread.h; then
604     echo '
605 ac_thread_cond_attr_size=
606 ac_thread_cond_impl_size=
607 ac_thread_mutex_attr_size=
608 ac_thread_mutex_impl_size=
609 ac_thread_thread_attr_size=
610 ac_thread_thread_impl_size=
611 ac_thread_key_impl_size=
612 ' > ./ac_thread.sh
613    AC_MSG_ERROR(
614 [You are attempting a cross compile, but the necessary information regarding
615 your thread library is not available.  Please fill out the ac_thread.sh file.
616 ])
617   else
618     . ./ac_thread.sh
619   fi
620 ])
621   AC_DEFINE_UNQUOTED(SIGC_PTHREAD_COND_ATTR,$ac_thread_cond_attr_size)
622   AC_DEFINE_UNQUOTED(SIGC_PTHREAD_COND_IMPL,$ac_thread_cond_impl_size)
623   AC_DEFINE_UNQUOTED(SIGC_PTHREAD_MUTEX_ATTR,$ac_thread_mutex_attr_size)
624   AC_DEFINE_UNQUOTED(SIGC_PTHREAD_MUTEX_IMPL,$ac_thread_mutex_impl_size)
625   AC_DEFINE_UNQUOTED(SIGC_PTHREAD_THREAD_ATTR,$ac_thread_thread_attr_size)
626   AC_DEFINE_UNQUOTED(SIGC_PTHREAD_THREAD_IMPL,$ac_thread_thread_impl_size)
627   AC_DEFINE_UNQUOTED(SIGC_PTHREAD_KEY_IMPL,$ac_thread_key_impl_size)
628 else
629 AC_MSG_RESULT([no])
630 fi
631
632
633 ###
634 ### This is the end of the massive if..then..else..fi
635 ###
636 fi
637
638 AC_OUTPUT([Makefile 
639         sigc-config
640         macros/Makefile  
641 ],[chmod a+x sigc-config])