Fixes and improves parsing of config file.
[lcr.git] / acinclude.m4
1
2
3
4 dnl ------------------------------------------------------------------------
5 dnl create a small program to test the settings of mISDNuser package
6 dnl ------------------------------------------------------------------------
7 # ported from the KDE project
8 AC_DEFUN([PBX_PRINT_MISDNUSER_PROGRAM],
9 [
10 cat > conftest.$ac_ext <<EOF
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 #include <isdn_net.h>
15 #include <mISDNlib.h>
16 #ifdef __cplusplus
17 }
18 #endif
19
20 int main()
21 {
22         /* TODO: try to reference some function here */
23         return 0;
24 }
25 EOF
26 ])
27
28 dnl ------------------------------------------------------------------------
29 dnl create a small program to test the settings of mISDN package
30 dnl ------------------------------------------------------------------------
31 # ported from the KDE project
32 AC_DEFUN([PBX_PRINT_MISDNKERNEL_PROGRAM],
33 [
34 cat > conftest.$ac_ext <<EOF
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 #include <mISDNlib.h>
39 #include <linux/isdn_compat.h>
40 #include <linux/mISDNif.h>
41 #ifdef __cplusplus
42 }
43 #endif
44
45 #define MISDN_MAJOR_VERSION_TEST $misdn_kernel_major_version_demand
46 #define MISDN_MINOR_VERSION_TEST $misdn_kernel_minor_version_demand
47 #define MISDN_VERSION_TEST      ((MISDN_MAJOR_VERSION_TEST<<16) | MISDN_MINOR_VERSION_TEST)
48 //#define MISDN_VERSION           ((MISDN_MAJOR_VERSION<<16) | MISDN_MINOR_VERSION)
49
50 #if (MISDN_VERSION < MISDN_VERSION_TEST)
51 # error mISDN version mismatch. Need at least $misdn_kernel_major_version_demand.$misdn_kernel_minor_version_demand
52 #endif
53
54
55 int main()
56 {
57         static u16 sum1;
58         /* access some constants from misdn kernel headers */
59         u16 v1 = CMX_TXDATA_ON;
60         u16 v2 = CMX_TXDATA_OFF;
61         u16 v3 = CMX_DELAY;
62         u16 v4 = CMX_TX_DATA;
63         u16 v5 = CMX_JITTER;
64         
65         /* extend here more variables or function call
66          * to access more header information */
67          
68         
69         /* anti optimisation constuct */
70         sum1 = v1 + v2 + v3 + v4 + v5;
71         
72         return 0;
73 }
74 EOF
75 ])
76
77
78
79 dnl prints a program.
80 dnl $1 is the include file
81 dnl $2 is the prefix before include
82 dnl $3 is the suffix, e.g. some variable or class definitions
83 dnl $4 is the program body within main()
84 AC_DEFUN([PBX_PRINT_PROGRAM],
85 [AC_LANG_PROGRAM([$2
86 $1
87
88 $3],
89 [$4])
90 ])
91
92
93
94 dnl ------------------------------------------------------------------------
95 dnl if --enable-debug, it disables optimisation and enables debugging symbols
96 dnl if --disable-debug (default) other way around
97 dnl ------------------------------------------------------------------------
98 AC_DEFUN([AC_CHECK_COMPILERS],
99 [# taken from KDE project
100
101   # enable debugging options on demand
102   DEBUGGING=
103   AC_ARG_ENABLE([debug],
104                 [AS_HELP_STRING([--enable-debug],
105                                 [enable debugging symbols, turns off compiler optimisations (default=disable)])
106                 ],
107                 [use_debug_code="yes"],
108                 [use_debug_code="no"]
109                )
110   AM_CONDITIONAL(ENABLE_DEBUGGING, test "x$DEBUGGING" == "xyes" )
111   AC_ARG_ENABLE(dummyoption,
112                 AC_HELP_STRING([--disable-debug],
113                                [disables debugging symbols, turns on compiler optimisations]),
114                 [:],
115                 [:]
116                )
117
118   dnl this prevents stupid AC_PROG_CC to add "-g" to the default CFLAGS
119   CFLAGS=" $CFLAGS"
120   AC_PROG_CC
121   AC_PROG_CPP
122   
123   if test "$GCC" = "yes" ; then
124     if test "$use_debug_code" != "no"; then
125       CFLAGS="-g -O0 $CFLAGS"
126     else
127       CFLAGS="-O2 $CFLAGS"
128     fi
129   fi
130   
131   if test -z "$LDFLAGS" && test "$use_debug_code" = "no" && test "$GCC" = "yes"; then
132     LDFLAGS=""
133   fi
134   
135   CXXFLAGS=" $CXXFLAGS"
136   AC_PROG_CXX
137   
138   if test "$GXX" = "yes" ; then
139     if test "$use_debug_code" != "no"; then
140       CXXFLAGS="-g -O0 $CXXFLAGS"
141     else
142       CXXFLAGS="-O2 $CXXFLAGS"
143     fi
144   fi
145   
146 ])
147
148
149 dnl ------------------------------------------------------------------------
150 dnl Try to find the mISDN-user headers and libraries.
151 dnl $(MISDN_LDFLAGS) will be -Lmisdnliblocation (if needed)
152 dnl and $(MISDN_INCLUDES) will be -Imisdnhdrlocation (if needed)
153 dnl ------------------------------------------------------------------------
154 dnl
155 AC_DEFUN([AC_PATH_MISDNUSER],
156 [
157 dnl AC_REQUIRE([K_PATH_X])
158 dnl AC_REQUIRE([KDE_USE_MISDN])
159 dnl AC_REQUIRE([KDE_CHECK_LIB64])
160
161 dnl ------------------------------------------------------------------------
162 dnl Add configure flag to enable linking to MT version of mISDN-user library.
163 dnl ------------------------------------------------------------------------
164
165 dnl AC_ARG_ENABLE(
166 dnl   mt,
167 dnl   AC_HELP_STRING([--disable-mt],[link to non-threaded mISDN-user (deprecated)]),
168 dnl   pbx_use_misdn_mt=$enableval,
169 dnl   [
170 dnl     if test $pbx_misdnver = 3; then
171 dnl       pbx_use_misdn_mt=yes
172 dnl     else
173 dnl       pbx_use_misdn_mt=no
174 dnl     fi
175 dnl   ]
176 dnl )
177
178 dnl USING_MISDN_MT=""
179
180 dnl ------------------------------------------------------------------------
181 dnl If we not get --disable-misdn-mt then adjust some vars for the host.
182 dnl ------------------------------------------------------------------------
183
184 dnl KDE_MT_LDFLAGS=
185 dnl KDE_MT_LIBS=
186 dnl if test "x$pbx_use_misdn_mt" = "xyes"; then
187 dnl   KDE_CHECK_THREADING
188 dnl   if test "x$pbx_use_threading" = "xyes"; then
189 dnl     CPPFLAGS="$USE_THREADS -DMISDN_THREAD_SUPPORT $CPPFLAGS"
190 dnl     KDE_MT_LDFLAGS="$USE_THREADS"
191 dnl     KDE_MT_LIBS="$LIBPTHREAD"
192 dnl   else
193 dnl     pbx_use_misdn_mt=no
194 dnl   fi
195 dnl fi
196 dnl AC_SUBST(KDE_MT_LDFLAGS)
197 dnl AC_SUBST(KDE_MT_LIBS)
198
199 dnl pbx_misdn_was_given=yes
200
201 dnl ------------------------------------------------------------------------
202 dnl If we haven't been told how to link to mISDN-user, we work it out for ourselves.
203 dnl ------------------------------------------------------------------------
204 dnl if test -z "$LIBMISDN_GLOB"; then
205 dnl   if test "x$pbx_use_misdn_emb" = "xyes"; then
206 dnl     LIBMISDN_GLOB="libmisdne.*"
207 dnl   else
208 dnl     LIBMISDN_GLOB="libmisdn.*"
209 dnl   fi
210 dnl fi
211
212 dnl ------------------------------------------------------------
213 dnl If we got --enable-embedded then adjust the mISDN-user library name.
214 dnl ------------------------------------------------------------
215 dnl if test "x$pbx_use_misdn_emb" = "xyes"; then
216 dnl   misdnlib="misdne"
217 dnl else
218    misdnlib="mISDN"
219 dnl fi
220
221 dnl pbx_int_misdn="-l$misdnlib"
222
223 dnl if test -z "$LIBQPE"; then
224 dnl ------------------------------------------------------------
225 dnl If we got --enable-palmtop then add -lqpe to the link line
226 dnl ------------------------------------------------------------
227 dnl   if test "x$pbx_use_misdn_emb" = "xyes"; then
228 dnl     if test "x$pbx_use_misdn_emb_palm" = "xyes"; then
229 dnl       LIB_QPE="-lqpe"
230 dnl     else
231 dnl       LIB_QPE=""
232 dnl     fi
233 dnl   else
234 dnl     LIB_QPE=""
235 dnl   fi
236 dnl fi
237
238 dnl ------------------------------------------------------------------------
239 dnl If we got --enable-misdn-mt then adjust the mISDN-user library name for the host.
240 dnl ------------------------------------------------------------------------
241
242 dnl if test "x$pbx_use_misdn_mt" = "xyes"; then
243 dnl   LIBMISDN="-l$misdnlib-mt"
244 dnl   pbx_int_misdn="-l$misdnlib-mt"
245 dnl   LIBMISDN_GLOB="lib$misdnlib-mt.*"
246 dnl   USING_MISDN_MT="using -mt"
247 dnl else
248 dnl   LIBMISDN="-l$misdnlib"
249 dnl fi
250
251 dnl if test $pbx_misdnver != 1; then
252
253 dnl   AC_REQUIRE([AC_FIND_PNG])
254 dnl   AC_REQUIRE([AC_FIND_JPEG])
255 dnl   LIBMISDN="$LIBMISDN $LIBPNG $LIBJPEG"
256 dnl fi
257
258 dnl if test $pbx_misdnver = 3; then
259 dnl   AC_REQUIRE([KDE_CHECK_LIBDL])
260 dnl   LIBMISDN="$LIBMISDN $LIBDL"
261 dnl fi
262
263 dnl probably there could be a whole installation of misdn
264 pbx_misdn_dirs="/usr/local/mISDNuser /usr/local/misdn /usr/lib/mISDNuser /usr/lib/misdn"
265
266
267 AC_MSG_CHECKING([for mISDN-user])
268 LIBMISDN="-l$misdnlib -lisdnnet"
269
270 dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
271 dnl LIBMISDN="$LIBMISDN $X_PRE_LIBS -lXext -lX11 $LIBSM $LIBSOCKET"
272 dnl fi
273 ac_misdnuser_includes=NO ac_misdnuser_libraries=NO ac_misdnuser_bindir=NO
274 misdnuser_libraries=""
275 misdnuser_includes=""
276 AC_ARG_WITH(misdnuser-dir,
277     AC_HELP_STRING([--with-misdnuser-dir=DIR],[where the root of mISDN-user is installed]),
278     [  ac_misdnuser_includes="$withval"/include
279        ac_misdnuser_libraries="$withval"/lib
280        ac_misdnuser_bindir="$withval"/bin
281     ])
282
283 AC_ARG_WITH(misdnuser-includes,
284     AC_HELP_STRING([--with-misdnuser-includes=DIR],[where the mISDN-user includes are (default=$with-misdnuser-dir/include)]),
285     [
286        ac_misdnuser_includes="$withval"
287     ])
288
289 pbx_misdn_libs_given=no
290
291 AC_ARG_WITH(misdnuser-libraries,
292     AC_HELP_STRING([--with-misdnuser-libraries=DIR],[where the mISDN-user library is installed (default=$with-misdnuser-dir/lib)]),
293     [  ac_misdnuser_libraries="$withval"
294        pbx_misdn_libs_given=yes
295     ])
296
297 AC_CACHE_VAL(ac_cv_have_misdn,
298 [#try to guess mISDN-user locations
299
300 misdn_incdirs=""
301 for dir in $pbx_misdn_dirs; do
302    misdn_incdirs="$misdn_incdirs $dir/include $dir"
303 done
304 misdn_incdirs="$MISDNINC $misdn_incdirs /usr/include/mISDNuser /usr/include/misdn /usr/include"
305 if test ! "$ac_misdnuser_includes" = "NO"; then
306    misdn_incdirs="$ac_misdnuser_includes $misdn_incdirs"
307 fi
308
309 dnl if test "$pbx_misdnver" != "1"; then
310   pbx_misdn_header=mISDNlib.h
311 dnl  ->  und auch "isdn_net.h"
312 dnl else
313 dnl  pbx_misdn_header=qglobal.h
314 dnl fi
315
316 AC_FIND_FILE($pbx_misdn_header, $misdn_incdirs, misdn_incdir)
317 ac_misdnuser_includes="$misdn_incdir"
318
319 misdn_libdirs=""
320 for dir in $pbx_misdn_dirs; do
321    misdn_libdirs="$misdn_libdirs $dir/lib $dir"
322 done
323 misdn_libdirs="$MISDNLIB $misdn_libdirs /usr/lib /usr/local/lib"
324 if test ! "$ac_misdnuser_libraries" = "NO"; then
325   misdn_libdir=$ac_misdnuser_libraries
326 else
327   misdn_libdirs="$ac_misdnuser_libraries $misdn_libdirs"
328   # if the mISDN-user was given, the chance is too big that libmisdn.* doesn't exist
329   misdn_libdir=NONE
330   for dir in $misdn_libdirs; do
331     try="ls -1 $dir/${LIBMISDN_GLOB}"
332     if test -n "`$try 2> /dev/null`"; then misdn_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
333   done
334 fi
335 for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
336   if test -e "$a"; then
337     LIBMISDN="$LIBMISDN ${pbx_int_misdn}_incremental"
338     break
339   fi
340 done
341
342 ac_misdnuser_libraries="$misdn_libdir"
343
344 AC_LANG_SAVE
345 AC_LANG_CPLUSPLUS
346
347 ac_cxxflags_safe="$CXXFLAGS"
348 ac_ldflags_safe="$LDFLAGS"
349 ac_libs_safe="$LIBS"
350
351 CXXFLAGS="$CXXFLAGS -I$misdn_incdir $all_includes"
352 LDFLAGS="$LDFLAGS -L$misdn_libdir $all_libraries $USER_LDFLAGS"
353 LIBS="$LIBS $LIBMISDN"
354
355 PBX_PRINT_MISDNUSER_PROGRAM
356
357 if AC_TRY_EVAL(ac_link) && test -s conftest; then
358   rm -f conftest*
359 else
360   echo "configure: failed program was:" >&AC_FD_CC
361   cat conftest.$ac_ext >&AC_FD_CC
362   ac_misdnuser_libraries="NO"
363 fi
364 rm -f conftest*
365 CXXFLAGS="$ac_cxxflags_safe"
366 LDFLAGS="$ac_ldflags_safe"
367 LIBS="$ac_libs_safe"
368
369 AC_LANG_RESTORE
370 if test "$ac_misdnuser_includes" = NO || test "$ac_misdnuser_libraries" = NO; then
371   ac_cv_have_misdn="have_misdn=no"
372   ac_misdnuser_notfound=""
373   missing_misdn_mt=""
374   if test "$ac_misdnuser_includes" = NO; then
375     if test "$ac_misdnuser_libraries" = NO; then
376       ac_misdnuser_notfound="(headers and libraries)";
377     else
378       ac_misdnuser_notfound="(headers)";
379     fi
380   else
381 dnl     if test "x$pbx_use_misdn_mt" = "xyes"; then
382 dnl        missing_misdn_mt="Make sure that you have compiled mISDN-user with thread support!"
383 dnl        ac_misdnuser_notfound="(library $misdnlib-mt)";
384 dnl     else
385        ac_misdnuser_notfound="(library $misdnlib)";
386 dnl     fi
387   fi
388
389   AC_MSG_ERROR([mISDN-user ($pbx_misdn_minversion) $ac_misdnuser_notfound not found. Please check your installation!
390 For more details about this problem, look at the end of config.log.$missing_misdn_mt])
391 else
392   have_misdn="yes"
393 fi
394 ])
395
396
397 eval "$ac_cv_have_misdn"
398
399 if test "$have_misdn" != yes; then
400   AC_MSG_RESULT([$have_misdn]);
401 else
402   ac_cv_have_misdn="have_misdn=yes \
403     ac_misdnuser_includes=$ac_misdnuser_includes ac_misdnuser_libraries=$ac_misdnuser_libraries"
404   AC_MSG_RESULT([libraries $ac_misdnuser_libraries, headers $ac_misdnuser_includes $USING_MISDN_MT])
405
406   misdnuser_libraries="$ac_misdnuser_libraries"
407   misdnuser_includes="$ac_misdnuser_includes"
408 fi
409
410 dnl if test ! "$pbx_misdn_libs_given" = "yes" && test ! "$pbx_misdnver" = 3; then
411 dnl      KDE_CHECK_MISDN_DIRECT(misdnuser_libraries= ,[])
412 dnl fi
413
414 AC_SUBST(misdnuser_libraries)
415 AC_SUBST(misdnuser_includes)
416
417 if test -z "$misdnuser_includes"; then
418  MISDN_INCLUDES=""
419 else
420  MISDN_INCLUDES="-I$misdnuser_includes"
421  all_includes="$MISDN_INCLUDES $all_includes"
422 fi
423
424 if test -z "$misdnuser_libraries"; then
425  MISDN_LDFLAGS=""
426 else
427  MISDN_LDFLAGS="-L$misdnuser_libraries"
428  all_libraries="$MISDN_LDFLAGS $all_libraries"
429 fi
430 dnl test -z "$KDE_MT_LDFLAGS" || all_libraries="$all_libraries $KDE_MT_LDFLAGS"
431
432 AC_SUBST(MISDN_INCLUDES)
433 AC_SUBST(MISDN_LDFLAGS)
434 dnl AC_PATH_MISDN_MOC_UIC
435
436 dnl KDE_CHECK_MISDN_JPEG
437
438 dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
439 dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG) -lXext $(LIB_X11) $(LIBSM)'
440 dnl else
441 dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG)'
442 dnl fi
443 dnl test -z "$KDE_MT_LIBS" || LIB_MISDN="$LIB_MISDN $KDE_MT_LIBS"
444 dnl for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
445 dnl   if test -e "$a"; then
446 dnl      LIB_MISDN="$LIB_MISDN ${pbx_int_misdn}_incremental"
447 dnl      break
448 dnl   fi
449 dnl done
450
451 AC_SUBST(LIB_MISDN)
452 dnl AC_SUBST(LIB_QPE)
453
454 AC_SUBST(pbx_misdnver)
455
456 ])
457
458
459
460 dnl ------------------------------------------------------------------------
461 dnl Try to find the mISDN-kernel headers.
462 dnl $(MISDNKERNEL_INCLUDES) will be -Imisdnkernelhdrlocation (if needed)
463 dnl ------------------------------------------------------------------------
464 dnl
465 AC_DEFUN([AC_PATH_MISDNKERNEL],
466 [
467
468    misdnlib="mISDN"
469 misdn_kernel_major_version_demand=6
470 misdn_kernel_minor_version_demand=0
471 lcr_misdn_kernel_minversion=$misdn_kernel_major_version_demand.$misdn_kernel_minor_version_demand
472
473 dnl ## TODO !! convert misdnuser variables to misdn kernel header variables
474
475 dnl probably there could be a whole installation of misdn
476 kernel_ver=$(uname -r)
477 misdn_kernelheader_dirs="/lib/modules/$kernel_ver/source/include /usr/src/linux/include/"
478
479
480 AC_MSG_CHECKING([for mISDN-kernel])
481 dnl LIBMISDN="-l$misdnlib -lisdnnet"
482 dnl 
483 dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
484 dnl LIBMISDN="$LIBMISDN $X_PRE_LIBS -lXext -lX11 $LIBSM $LIBSOCKET"
485 dnl fi
486 dnl ac_misdnkernel_includes=NO ac_misdnkernel_libraries=NO ac_misdnkernel_bindir=NO
487 ac_misdnkernel_includes=NO
488 dnl misdnkernel_libraries=""
489 misdnkernel_includes=""
490 dnl AC_ARG_WITH(misdnkernel-dir,
491 dnl     AC_HELP_STRING([--with-misdnkernel-dir=DIR],[where the mISDN-headers are installed ]),
492 dnl     [  ac_misdnkernel_includes="$withval"/include
493 dnl        ac_misdnkernel_libraries="$withval"/lib
494 dnl        ac_misdnkernel_bindir="$withval"/bin
495 dnl     ])
496
497 AC_ARG_WITH(misdnkernel-includes,
498     AC_HELP_STRING([--with-misdnkernel-includes=DIR],[where the mISDN-kernel includes are. Used if enable-socket-misdn]),
499     [
500        ac_misdnkernel_includes="$withval"
501     ])
502
503 dnl pbx_misdn_libs_given=no
504
505 dnl AC_ARG_WITH(misdnkernel-libraries,
506 dnl     AC_HELP_STRING([--with-misdnkernel-libraries=DIR],[where the mISDN-kernel library is installed.]),
507 dnl     [  ac_misdnkernel_libraries="$withval"
508 dnl        pbx_misdn_libs_given=yes
509 dnl     ])
510
511 AC_CACHE_VAL(ac_cv_have_misdnkernel,
512 [#try to guess mISDN-user locations
513
514 misdnkernel_incdirs=""
515 for dir in $misdn_kernelheader_dirs; do
516    misdnkernel_incdirs="$misdnkernel_incdirs $dir/include $dir"
517 done
518 misdnkernel_incdirs="$MISDNKERNELINC $misdnkernel_incdirs /usr/include/mISDNuser /usr/include/misdn /usr/include"
519 if test ! "$ac_misdnkernel_includes" = "NO"; then
520    misdnkernel_incdirs="$ac_misdnkernel_includes $misdnkernel_incdirs"
521 fi
522
523   pbx_misdn_kernel_header=linux/mISDNif.h
524
525 AC_FIND_FILE($pbx_misdn_kernel_header, $misdnkernel_incdirs, misdnkernel_incdir)
526 ac_misdnkernel_includes="$misdnkernel_incdir"
527
528 dnl misdn_libdirs=""
529 dnl for dir in $misdn_kernelheader_dirs; do
530 dnl    misdn_libdirs="$misdn_libdirs $dir/lib $dir"
531 dnl done
532 dnl misdn_libdirs="$MISDNLIB $misdn_libdirs /usr/lib /usr/local/lib"
533 dnl if test ! "$ac_misdnkernel_libraries" = "NO"; then
534 dnl   misdn_libdir=$ac_misdnkernel_libraries
535 dnl else
536 dnl   misdn_libdirs="$ac_misdnkernel_libraries $misdn_libdirs"
537 dnl   # if the mISDN-user was given, the chance is too big that libmisdn.* doesn't exist
538 dnl   misdn_libdir=NONE
539 dnl   for dir in $misdn_libdirs; do
540 dnl     try="ls -1 $dir/${LIBMISDN_GLOB}"
541 dnl     if test -n "`$try 2> /dev/null`"; then misdn_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
542 dnl   done
543 dnl fi
544 dnl for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
545 dnl   if test -e "$a"; then
546 dnl     LIBMISDN="$LIBMISDN ${pbx_int_misdn}_incremental"
547 dnl     break
548 dnl   fi
549 dnl done
550 dnl 
551 dnl ac_misdnkernel_libraries="$misdn_libdir"
552 dnl 
553 AC_LANG_SAVE
554 AC_LANG_CPLUSPLUS
555
556 ac_cxxflags_safe="$CXXFLAGS"
557 ac_ldflags_safe="$LDFLAGS"
558 ac_libs_safe="$LIBS"
559
560 CXXFLAGS="$CXXFLAGS -I$misdnkernel_incdir $all_includes"
561 LDFLAGS="$LDFLAGS -L$misdn_libdir $all_libraries $USER_LDFLAGS"
562 LIBS="$LIBS $LIBMISDN"
563
564 PBX_PRINT_MISDNKERNEL_PROGRAM
565
566 if AC_TRY_EVAL(ac_compile) && test -s conftest.o; then
567   rm -f conftest*
568 else
569   echo "configure: failed program was:" >&AC_FD_CC
570   cat conftest.$ac_ext >&AC_FD_CC
571   ac_misdnkernel_includes="NO"
572 dnl   ac_misdnkernel_libraries="NO"
573 fi
574 rm -f conftest*
575 CXXFLAGS="$ac_cxxflags_safe"
576 LDFLAGS="$ac_ldflags_safe"
577 LIBS="$ac_libs_safe"
578
579 AC_LANG_RESTORE
580 dnl if test "$ac_misdnkernel_includes" = NO || test "$ac_misdnkernel_libraries" = NO; then
581 if test "$ac_misdnkernel_includes" = NO; then
582   ac_cv_have_misdnkernel="have_misdnkernel=no"
583   ac_misdnkernel_notfound=""
584   missing_misdn_mt=""
585 dnl  if test "$ac_misdnkernel_includes" = NO; then
586 dnl    if test "$ac_misdnkernel_libraries" = NO; then
587 dnl      ac_misdnkernel_notfound="(headers and libraries)";
588 dnl    else
589       ac_misdnkernel_notfound="(headers)";
590 dnl    fi
591 dnl  else
592 dnl    ac_misdnkernel_notfound="(library $misdnlib)";
593 dnl  fi
594
595   AC_MSG_ERROR([mISDN kernel header (version >= $lcr_misdn_kernel_minversion) not found. Please check your installation!
596 For more details about this problem, look at the end of config.log.$missing_misdn_mt])
597 else
598   have_misdnkernel="yes"
599 fi
600 ])
601
602 dnl check cache content
603 dnl TODO: maybe move this to beginning (before compilation test?)
604 eval "$ac_cv_have_misdnkernel"
605
606 if test "$have_misdnkernel" != yes; then
607   AC_MSG_RESULT([$have_misdnkernel]);
608 else
609   ac_cv_have_misdnkernel="have_misdnkernel=yes \
610    ac_misdnkernel_includes=$ac_misdnkernel_includes"
611 dnl    ac_misdnkernel_libraries=$ac_misdnkernel_libraries"
612   AC_MSG_RESULT([headers $ac_misdnkernel_includes])
613
614 dnl   misdnkernel_libraries="$ac_misdnkernel_libraries"
615   misdnkernel_includes="$ac_misdnkernel_includes"
616 fi
617
618 dnl if test ! "$pbx_misdn_libs_given" = "yes" && test ! "$pbx_misdnver" = 3; then
619 dnl      KDE_CHECK_MISDN_DIRECT(misdnkernel_libraries= ,[])
620 dnl fi
621
622 dnl AC_SUBST(misdnkernel_libraries)
623 AC_SUBST(misdnkernel_includes)
624
625 if test -z "$misdnkernel_includes"; then
626  MISDNKERNEL_INCLUDES=""
627 else
628  MISDNKERNEL_INCLUDES="-I$misdnkernel_includes"
629  all_includes="$MISDNKERNEL_INCLUDES $all_includes"
630 fi
631
632 dnl if test -z "$misdnkernel_libraries"; then
633 dnl  MISDN_LDFLAGS=""
634 dnl else
635 dnl  MISDN_LDFLAGS="-L$misdnkernel_libraries"
636 dnl  all_libraries="$MISDN_LDFLAGS $all_libraries"
637 dnl fi
638 dnl test -z "$KDE_MT_LDFLAGS" || all_libraries="$all_libraries $KDE_MT_LDFLAGS"
639
640 AC_SUBST(MISDNKERNEL_INCLUDES)
641 dnl AC_SUBST(MISDN_LDFLAGS)
642 dnl AC_PATH_MISDN_MOC_UIC
643
644 dnl KDE_CHECK_MISDN_JPEG
645
646 dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
647 dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG) -lXext $(LIB_X11) $(LIBSM)'
648 dnl else
649 dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG)'
650 dnl fi
651 dnl test -z "$KDE_MT_LIBS" || LIB_MISDN="$LIB_MISDN $KDE_MT_LIBS"
652 dnl for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
653 dnl   if test -e "$a"; then
654 dnl      LIB_MISDN="$LIB_MISDN ${pbx_int_misdn}_incremental"
655 dnl      break
656 dnl   fi
657 dnl done
658
659 dnl AC_SUBST(LIB_MISDN)
660 dnl AC_SUBST(LIB_QPE)
661
662 AC_SUBST(pbx_misdnver)
663
664 ])
665
666
667
668 dnl ------------------------------------------------------------------------
669 dnl Find a file (or one of more files in a list of dirs)
670 dnl ------------------------------------------------------------------------
671 AC_DEFUN([AC_FIND_FILE],
672 [
673 $3=NO
674 for i in $2;
675 do
676   for j in $1;
677   do
678     echo "configure: __oline__: $i/$j" >&AC_FD_CC
679     if test -r "$i/$j"; then
680       echo "taking that" >&AC_FD_CC
681       $3=$i
682       break 2
683     fi
684   done
685 done
686 ])
687
688
689
690 dnl ------------------------------------------------------------------------
691 dnl Taken from http://autoconf-archive.cryp.to/ac_define_dir.html
692 dnl Copyright © 2006 Stepan Kasal <kasal@ucw.cz>
693 dnl Copyright © 2006 Andreas Schwab <schwab@suse.de>
694 dnl Copyright © 2006 Guido U. Draheim <guidod@gmx.de>
695 dnl Copyright © 2006 Alexandre Oliva
696 dnl Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
697 dnl 
698 dnl This macro sets VARNAME to the expansion of the DIR variable, taking care
699 dnl  of fixing up ${prefix} and such.
700 dnl ------------------------------------------------------------------------
701 AC_DEFUN([AC_DEFINE_DIR], [
702   prefix_NONE=
703   exec_prefix_NONE=
704   test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
705   test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
706 dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
707 dnl refers to ${prefix}.  Thus we have to use `eval' twice.
708   eval ac_define_dir="\"[$]$2\""
709   eval ac_define_dir="\"$ac_define_dir\""
710   AC_SUBST($1, "$ac_define_dir")
711   AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
712   test "$prefix_NONE" && prefix=NONE
713   test "$exec_prefix_NONE" && exec_prefix=NONE
714 ])
715
716
717 dnl ------------------------------------------------------------------------
718 dnl taken from http://autoconf-archive.cryp.to/ax_ext_check_header.html
719 dnl Copyright © 2005 Duncan Simpson <dps@simpson.demon.co.uk>
720 dnl Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
721 dnl 
722 dnl Checks locations of headers in various places
723 dnl Extended by Jörg Habenicht
724 dnl ------------------------------------------------------------------------
725 AC_DEFUN([AX_EXT_HAVE_HEADER],
726 [AC_LANG_PUSH(C)
727  AC_CHECK_HEADER($1, [$3 got="yes"], [$4 got="no"], [$5])
728  hdr=`echo $1 | $as_tr_sh`
729  for dir in $2
730  do
731   if test "x${got}" = "xno"; then
732    ext_hashdr_cvdir=`echo $dir | $as_tr_sh`
733    AC_CACHE_CHECK([for $1 header with -I$dir],
734     [ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}],
735     [ext_have_hdr_save_cflags=${CFLAGS}
736      CFLAGS="${CFLAGS} -I${dir}"
737      AC_COMPILE_IFELSE(
738       [AC_LANG_PROGRAM([#include <$1>])],
739       [got="yes"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="yes"],
740       [got="no"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="no"])
741      CFLAGS=$ext_have_hdr_save_cflags])
742    if eval `echo 'test x${'ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}'}' = "xyes"`; then
743     CFLAGS="${CFLAGS} -I${dir}"
744     CPPFLAGS="${CPPFLAGS} -I${dir}"
745     got="yes";
746     hdr=`echo $1 | $as_tr_cpp`
747     AC_DEFINE_UNQUOTED(HAVE_${hdr}, 1,
748      [Define this if you have the $1 header])
749    fi; 
750   fi; 
751  done
752 AC_LANG_POP])
753
754
755 dnl ------------------------------------------------------------------------
756 dnl taken from http://autoconf-archive.cryp.to/ax_ext_check_header.html
757 dnl Copyright © 2005 Duncan Simpson <dps@simpson.demon.co.uk>
758 dnl Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved.
759 dnl 
760 dnl Checks locations of headers in various places
761 dnl Extended by Jörg Habenicht
762 dnl ------------------------------------------------------------------------
763 dnl $1 include file name
764 dnl $2 directory list
765 dnl $3 action yes
766 dnl $4 action no
767 dnl $5 include prefix
768 dnl $6 include suffix
769 dnl $7 main() body content
770 AC_DEFUN([PBX_EXT_HAVE_CXX_HEADER],
771 [AC_LANG_PUSH(C++)
772  AC_CHECK_HEADER($1, [$3 got="yes"], [$4 got="no"], [$5])
773  hdr=`echo $1 | $as_tr_sh`
774  for dir in $2 ;  do
775   if test "x${got}" = "xno"; then
776    ext_hashdr_cvdir=`echo $dir | $as_tr_sh`
777    AC_CACHE_CHECK([for $1 header with -I$dir],
778     [ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}],
779     [ext_have_hdr_save_cxxflags=${CXXFLAGS}
780      CXXFLAGS="${CXXFLAGS} -I${dir}"
781      AC_COMPILE_IFELSE(
782       [PBX_PRINT_PROGRAM([#include <$1>],[$5],[$6],[$7])],
783       [$3 got="yes"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="yes"],
784       [$4 got="no"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="no"])
785      CXXFLAGS=$ext_have_hdr_save_cxxflags])
786    if eval `echo 'test x${'ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}'}' = "xyes"`; then
787     CXXFLAGS="${CXXFLAGS} -I${dir}"
788     CPPFLAGS="${CPPFLAGS} -I${dir}"
789     got="yes";
790     hdr=`echo $1 | $as_tr_cpp`
791     AC_DEFINE_UNQUOTED(HAVE_${hdr}, 1,
792      [Define this if you have the $1 header])
793    fi; 
794   fi; 
795  done
796 AC_LANG_POP])
797