summaryrefslogtreecommitdiffstats
path: root/acinclude.m4
blob: 816bd1fba58adf800cfdf3694f0fa3116237fef6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797



dnl ------------------------------------------------------------------------
dnl create a small program to test the settings of mISDNuser package
dnl ------------------------------------------------------------------------
# ported from the KDE project
AC_DEFUN([PBX_PRINT_MISDNUSER_PROGRAM],
[
cat > conftest.$ac_ext <<EOF
#ifdef __cplusplus
extern "C" {
#endif
#include <isdn_net.h>
#include <mISDNlib.h>
#ifdef __cplusplus
}
#endif

int main()
{
	/* TODO: try to reference some function here */
	return 0;
}
EOF
])

dnl ------------------------------------------------------------------------
dnl create a small program to test the settings of mISDN package
dnl ------------------------------------------------------------------------
# ported from the KDE project
AC_DEFUN([PBX_PRINT_MISDNKERNEL_PROGRAM],
[
cat > conftest.$ac_ext <<EOF
#ifdef __cplusplus
extern "C" {
#endif
#include <mISDNlib.h>
#include <linux/isdn_compat.h>
#include <linux/mISDNif.h>
#ifdef __cplusplus
}
#endif

#define MISDN_MAJOR_VERSION_TEST $misdn_kernel_major_version_demand
#define MISDN_MINOR_VERSION_TEST $misdn_kernel_minor_version_demand
#define MISDN_VERSION_TEST	((MISDN_MAJOR_VERSION_TEST<<16) | MISDN_MINOR_VERSION_TEST)
//#define MISDN_VERSION           ((MISDN_MAJOR_VERSION<<16) | MISDN_MINOR_VERSION)

#if (MISDN_VERSION < MISDN_VERSION_TEST)
# error mISDN version mismatch. Need at least $misdn_kernel_major_version_demand.$misdn_kernel_minor_version_demand
#endif


int main()
{
	static u16 sum1;
	/* access some constants from misdn kernel headers */
	u16 v1 = CMX_TXDATA_ON;
	u16 v2 = CMX_TXDATA_OFF;
	u16 v3 = CMX_DELAY;
	u16 v4 = CMX_TX_DATA;
	u16 v5 = CMX_JITTER;
	
	/* extend here more variables or function call
	 * to access more header information */
	 
	
	/* anti optimisation constuct */
	sum1 = v1 + v2 + v3 + v4 + v5;
	
	return 0;
}
EOF
])



dnl prints a program.
dnl $1 is the include file
dnl $2 is the prefix before include
dnl $3 is the suffix, e.g. some variable or class definitions
dnl $4 is the program body within main()
AC_DEFUN([PBX_PRINT_PROGRAM],
[AC_LANG_PROGRAM([$2
$1

$3],
[$4])
])



dnl ------------------------------------------------------------------------
dnl if --enable-debug, it disables optimisation and enables debugging symbols
dnl if --disable-debug (default) other way around
dnl ------------------------------------------------------------------------
AC_DEFUN([AC_CHECK_COMPILERS],
[# taken from KDE project

  # enable debugging options on demand
  DEBUGGING=
  AC_ARG_ENABLE([debug],
                [AS_HELP_STRING([--enable-debug],
                                [enable debugging symbols, turns off compiler optimisations (default=disable)])
                ],
                [use_debug_code="yes"],
                [use_debug_code="no"]
               )
  AM_CONDITIONAL(ENABLE_DEBUGGING, test "x$DEBUGGING" == "xyes" )
  AC_ARG_ENABLE(dummyoption,
                AC_HELP_STRING([--disable-debug],
                               [disables debugging symbols, turns on compiler optimisations]),
                [:],
                [:]
               )

  dnl this prevents stupid AC_PROG_CC to add "-g" to the default CFLAGS
  CFLAGS=" $CFLAGS"
  AC_PROG_CC
  AC_PROG_CPP
  
  if test "$GCC" = "yes" ; then
    if test "$use_debug_code" != "no"; then
      CFLAGS="-g -O0 $CFLAGS"
    else
      CFLAGS="-O2 $CFLAGS"
    fi
  fi
  
  if test -z "$LDFLAGS" && test "$use_debug_code" = "no" && test "$GCC" = "yes"; then
    LDFLAGS=""
  fi
  
  CXXFLAGS=" $CXXFLAGS"
  AC_PROG_CXX
  
  if test "$GXX" = "yes" ; then
    if test "$use_debug_code" != "no"; then
      CXXFLAGS="-g -O0 $CXXFLAGS"
    else
      CXXFLAGS="-O2 $CXXFLAGS"
    fi
  fi
  
])


dnl ------------------------------------------------------------------------
dnl Try to find the mISDN-user headers and libraries.
dnl $(MISDN_LDFLAGS) will be -Lmisdnliblocation (if needed)
dnl and $(MISDN_INCLUDES) will be -Imisdnhdrlocation (if needed)
dnl ------------------------------------------------------------------------
dnl
AC_DEFUN([AC_PATH_MISDNUSER],
[
dnl AC_REQUIRE([K_PATH_X])
dnl AC_REQUIRE([KDE_USE_MISDN])
dnl AC_REQUIRE([KDE_CHECK_LIB64])

dnl ------------------------------------------------------------------------
dnl Add configure flag to enable linking to MT version of mISDN-user library.
dnl ------------------------------------------------------------------------

dnl AC_ARG_ENABLE(
dnl   mt,
dnl   AC_HELP_STRING([--disable-mt],[link to non-threaded mISDN-user (deprecated)]),
dnl   pbx_use_misdn_mt=$enableval,
dnl   [
dnl     if test $pbx_misdnver = 3; then
dnl       pbx_use_misdn_mt=yes
dnl     else
dnl       pbx_use_misdn_mt=no
dnl     fi
dnl   ]
dnl )

dnl USING_MISDN_MT=""

dnl ------------------------------------------------------------------------
dnl If we not get --disable-misdn-mt then adjust some vars for the host.
dnl ------------------------------------------------------------------------

dnl KDE_MT_LDFLAGS=
dnl KDE_MT_LIBS=
dnl if test "x$pbx_use_misdn_mt" = "xyes"; then
dnl   KDE_CHECK_THREADING
dnl   if test "x$pbx_use_threading" = "xyes"; then
dnl     CPPFLAGS="$USE_THREADS -DMISDN_THREAD_SUPPORT $CPPFLAGS"
dnl     KDE_MT_LDFLAGS="$USE_THREADS"
dnl     KDE_MT_LIBS="$LIBPTHREAD"
dnl   else
dnl     pbx_use_misdn_mt=no
dnl   fi
dnl fi
dnl AC_SUBST(KDE_MT_LDFLAGS)
dnl AC_SUBST(KDE_MT_LIBS)

dnl pbx_misdn_was_given=yes

dnl ------------------------------------------------------------------------
dnl If we haven't been told how to link to mISDN-user, we work it out for ourselves.
dnl ------------------------------------------------------------------------
dnl if test -z "$LIBMISDN_GLOB"; then
dnl   if test "x$pbx_use_misdn_emb" = "xyes"; then
dnl     LIBMISDN_GLOB="libmisdne.*"
dnl   else
dnl     LIBMISDN_GLOB="libmisdn.*"
dnl   fi
dnl fi

dnl ------------------------------------------------------------
dnl If we got --enable-embedded then adjust the mISDN-user library name.
dnl ------------------------------------------------------------
dnl if test "x$pbx_use_misdn_emb" = "xyes"; then
dnl   misdnlib="misdne"
dnl else
   misdnlib="mISDN"
dnl fi

dnl pbx_int_misdn="-l$misdnlib"

dnl if test -z "$LIBQPE"; then
dnl ------------------------------------------------------------
dnl If we got --enable-palmtop then add -lqpe to the link line
dnl ------------------------------------------------------------
dnl   if test "x$pbx_use_misdn_emb" = "xyes"; then
dnl     if test "x$pbx_use_misdn_emb_palm" = "xyes"; then
dnl       LIB_QPE="-lqpe"
dnl     else
dnl       LIB_QPE=""
dnl     fi
dnl   else
dnl     LIB_QPE=""
dnl   fi
dnl fi

dnl ------------------------------------------------------------------------
dnl If we got --enable-misdn-mt then adjust the mISDN-user library name for the host.
dnl ------------------------------------------------------------------------

dnl if test "x$pbx_use_misdn_mt" = "xyes"; then
dnl   LIBMISDN="-l$misdnlib-mt"
dnl   pbx_int_misdn="-l$misdnlib-mt"
dnl   LIBMISDN_GLOB="lib$misdnlib-mt.*"
dnl   USING_MISDN_MT="using -mt"
dnl else
dnl   LIBMISDN="-l$misdnlib"
dnl fi

dnl if test $pbx_misdnver != 1; then

dnl   AC_REQUIRE([AC_FIND_PNG])
dnl   AC_REQUIRE([AC_FIND_JPEG])
dnl   LIBMISDN="$LIBMISDN $LIBPNG $LIBJPEG"
dnl fi

dnl if test $pbx_misdnver = 3; then
dnl   AC_REQUIRE([KDE_CHECK_LIBDL])
dnl   LIBMISDN="$LIBMISDN $LIBDL"
dnl fi

dnl probably there could be a whole installation of misdn
pbx_misdn_dirs="/usr/local/mISDNuser /usr/local/misdn /usr/lib/mISDNuser /usr/lib/misdn"


AC_MSG_CHECKING([for mISDN-user])
LIBMISDN="-l$misdnlib -lisdnnet"

dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
dnl LIBMISDN="$LIBMISDN $X_PRE_LIBS -lXext -lX11 $LIBSM $LIBSOCKET"
dnl fi
ac_misdnuser_includes=NO ac_misdnuser_libraries=NO ac_misdnuser_bindir=NO
misdnuser_libraries=""
misdnuser_includes=""
AC_ARG_WITH(misdnuser-dir,
    AC_HELP_STRING([--with-misdnuser-dir=DIR],[where the root of mISDN-user is installed]),
    [  ac_misdnuser_includes="$withval"/include
       ac_misdnuser_libraries="$withval"/lib
       ac_misdnuser_bindir="$withval"/bin
    ])

AC_ARG_WITH(misdnuser-includes,
    AC_HELP_STRING([--with-misdnuser-includes=DIR],[where the mISDN-user includes are (default=$with-misdnuser-dir/include)]),
    [
       ac_misdnuser_includes="$withval"
    ])

pbx_misdn_libs_given=no

AC_ARG_WITH(misdnuser-libraries,
    AC_HELP_STRING([--with-misdnuser-libraries=DIR],[where the mISDN-user library is installed (default=$with-misdnuser-dir/lib)]),
    [  ac_misdnuser_libraries="$withval"
       pbx_misdn_libs_given=yes
    ])

AC_CACHE_VAL(ac_cv_have_misdn,
[#try to guess mISDN-user locations

misdn_incdirs=""
for dir in $pbx_misdn_dirs; do
   misdn_incdirs="$misdn_incdirs $dir/include $dir"
done
misdn_incdirs="$MISDNINC $misdn_incdirs /usr/include/mISDNuser /usr/include/misdn /usr/include"
if test ! "$ac_misdnuser_includes" = "NO"; then
   misdn_incdirs="$ac_misdnuser_includes $misdn_incdirs"
fi

dnl if test "$pbx_misdnver" != "1"; then
  pbx_misdn_header=mISDNlib.h
dnl  ->  und auch "isdn_net.h"
dnl else
dnl  pbx_misdn_header=qglobal.h
dnl fi

AC_FIND_FILE($pbx_misdn_header, $misdn_incdirs, misdn_incdir)
ac_misdnuser_includes="$misdn_incdir"

misdn_libdirs=""
for dir in $pbx_misdn_dirs; do
   misdn_libdirs="$misdn_libdirs $dir/lib $dir"
done
misdn_libdirs="$MISDNLIB $misdn_libdirs /usr/lib /usr/local/lib"
if test ! "$ac_misdnuser_libraries" = "NO"; then
  misdn_libdir=$ac_misdnuser_libraries
else
  misdn_libdirs="$ac_misdnuser_libraries $misdn_libdirs"
  # if the mISDN-user was given, the chance is too big that libmisdn.* doesn't exist
  misdn_libdir=NONE
  for dir in $misdn_libdirs; do
    try="ls -1 $dir/${LIBMISDN_GLOB}"
    if test -n "`$try 2> /dev/null`"; then misdn_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
  done
fi
for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
  if test -e "$a"; then
    LIBMISDN="$LIBMISDN ${pbx_int_misdn}_incremental"
    break
  fi
done

ac_misdnuser_libraries="$misdn_libdir"

AC_LANG_SAVE
AC_LANG_CPLUSPLUS

ac_cxxflags_safe="$CXXFLAGS"
ac_ldflags_safe="$LDFLAGS"
ac_libs_safe="$LIBS"

CXXFLAGS="$CXXFLAGS -I$misdn_incdir $all_includes"
LDFLAGS="$LDFLAGS -L$misdn_libdir $all_libraries $USER_LDFLAGS"
LIBS="$LIBS $LIBMISDN"

PBX_PRINT_MISDNUSER_PROGRAM

if AC_TRY_EVAL(ac_link) && test -s conftest; then
  rm -f conftest*
else
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
  ac_misdnuser_libraries="NO"
fi
rm -f conftest*
CXXFLAGS="$ac_cxxflags_safe"
LDFLAGS="$ac_ldflags_safe"
LIBS="$ac_libs_safe"

AC_LANG_RESTORE
if test "$ac_misdnuser_includes" = NO || test "$ac_misdnuser_libraries" = NO; then
  ac_cv_have_misdn="have_misdn=no"
  ac_misdnuser_notfound=""
  missing_misdn_mt=""
  if test "$ac_misdnuser_includes" = NO; then
    if test "$ac_misdnuser_libraries" = NO; then
      ac_misdnuser_notfound="(headers and libraries)";
    else
      ac_misdnuser_notfound="(headers)";
    fi
  else
dnl     if test "x$pbx_use_misdn_mt" = "xyes"; then
dnl        missing_misdn_mt="Make sure that you have compiled mISDN-user with thread support!"
dnl        ac_misdnuser_notfound="(library $misdnlib-mt)";
dnl     else
       ac_misdnuser_notfound="(library $misdnlib)";
dnl     fi
  fi

  AC_MSG_ERROR([mISDN-user ($pbx_misdn_minversion) $ac_misdnuser_notfound not found. Please check your installation!
For more details about this problem, look at the end of config.log.$missing_misdn_mt])
else
  have_misdn="yes"
fi
])


eval "$ac_cv_have_misdn"

if test "$have_misdn" != yes; then
  AC_MSG_RESULT([$have_misdn]);
else
  ac_cv_have_misdn="have_misdn=yes \
    ac_misdnuser_includes=$ac_misdnuser_includes ac_misdnuser_libraries=$ac_misdnuser_libraries"
  AC_MSG_RESULT([libraries $ac_misdnuser_libraries, headers $ac_misdnuser_includes $USING_MISDN_MT])

  misdnuser_libraries="$ac_misdnuser_libraries"
  misdnuser_includes="$ac_misdnuser_includes"
fi

dnl if test ! "$pbx_misdn_libs_given" = "yes" && test ! "$pbx_misdnver" = 3; then
dnl      KDE_CHECK_MISDN_DIRECT(misdnuser_libraries= ,[])
dnl fi

AC_SUBST(misdnuser_libraries)
AC_SUBST(misdnuser_includes)

if test -z "$misdnuser_includes"; then
 MISDN_INCLUDES=""
else
 MISDN_INCLUDES="-I$misdnuser_includes"
 all_includes="$MISDN_INCLUDES $all_includes"
fi

if test -z "$misdnuser_libraries"; then
 MISDN_LDFLAGS=""
else
 MISDN_LDFLAGS="-L$misdnuser_libraries"
 all_libraries="$MISDN_LDFLAGS $all_libraries"
fi
dnl test -z "$KDE_MT_LDFLAGS" || all_libraries="$all_libraries $KDE_MT_LDFLAGS"

AC_SUBST(MISDN_INCLUDES)
AC_SUBST(MISDN_LDFLAGS)
dnl AC_PATH_MISDN_MOC_UIC

dnl KDE_CHECK_MISDN_JPEG

dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG) -lXext $(LIB_X11) $(LIBSM)'
dnl else
dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG)'
dnl fi
dnl test -z "$KDE_MT_LIBS" || LIB_MISDN="$LIB_MISDN $KDE_MT_LIBS"
dnl for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
dnl   if test -e "$a"; then
dnl      LIB_MISDN="$LIB_MISDN ${pbx_int_misdn}_incremental"
dnl      break
dnl   fi
dnl done

AC_SUBST(LIB_MISDN)
dnl AC_SUBST(LIB_QPE)

AC_SUBST(pbx_misdnver)

])



dnl ------------------------------------------------------------------------
dnl Try to find the mISDN-kernel headers.
dnl $(MISDNKERNEL_INCLUDES) will be -Imisdnkernelhdrlocation (if needed)
dnl ------------------------------------------------------------------------
dnl
AC_DEFUN([AC_PATH_MISDNKERNEL],
[

   misdnlib="mISDN"
misdn_kernel_major_version_demand=6
misdn_kernel_minor_version_demand=0
lcr_misdn_kernel_minversion=$misdn_kernel_major_version_demand.$misdn_kernel_minor_version_demand

dnl ## TODO !! convert misdnuser variables to misdn kernel header variables

dnl probably there could be a whole installation of misdn
kernel_ver=$(uname -r)
misdn_kernelheader_dirs="/lib/modules/$kernel_ver/source/include /usr/src/linux/include/"


AC_MSG_CHECKING([for mISDN-kernel])
dnl LIBMISDN="-l$misdnlib -lisdnnet"
dnl 
dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
dnl LIBMISDN="$LIBMISDN $X_PRE_LIBS -lXext -lX11 $LIBSM $LIBSOCKET"
dnl fi
dnl ac_misdnkernel_includes=NO ac_misdnkernel_libraries=NO ac_misdnkernel_bindir=NO
ac_misdnkernel_includes=NO
dnl misdnkernel_libraries=""
misdnkernel_includes=""
dnl AC_ARG_WITH(misdnkernel-dir,
dnl     AC_HELP_STRING([--with-misdnkernel-dir=DIR],[where the mISDN-headers are installed ]),
dnl     [  ac_misdnkernel_includes="$withval"/include
dnl        ac_misdnkernel_libraries="$withval"/lib
dnl        ac_misdnkernel_bindir="$withval"/bin
dnl     ])

AC_ARG_WITH(misdnkernel-includes,
    AC_HELP_STRING([--with-misdnkernel-includes=DIR],[where the mISDN-kernel includes are. Used if enable-socket-misdn]),
    [
       ac_misdnkernel_includes="$withval"
    ])

dnl pbx_misdn_libs_given=no

dnl AC_ARG_WITH(misdnkernel-libraries,
dnl     AC_HELP_STRING([--with-misdnkernel-libraries=DIR],[where the mISDN-kernel library is installed.]),
dnl     [  ac_misdnkernel_libraries="$withval"
dnl        pbx_misdn_libs_given=yes
dnl     ])

AC_CACHE_VAL(ac_cv_have_misdnkernel,
[#try to guess mISDN-user locations

misdnkernel_incdirs=""
for dir in $misdn_kernelheader_dirs; do
   misdnkernel_incdirs="$misdnkernel_incdirs $dir/include $dir"
done
misdnkernel_incdirs="$MISDNKERNELINC $misdnkernel_incdirs /usr/include/mISDNuser /usr/include/misdn /usr/include"
if test ! "$ac_misdnkernel_includes" = "NO"; then
   misdnkernel_incdirs="$ac_misdnkernel_includes $misdnkernel_incdirs"
fi

  pbx_misdn_kernel_header=linux/mISDNif.h

AC_FIND_FILE($pbx_misdn_kernel_header, $misdnkernel_incdirs, misdnkernel_incdir)
ac_misdnkernel_includes="$misdnkernel_incdir"

dnl misdn_libdirs=""
dnl for dir in $misdn_kernelheader_dirs; do
dnl    misdn_libdirs="$misdn_libdirs $dir/lib $dir"
dnl done
dnl misdn_libdirs="$MISDNLIB $misdn_libdirs /usr/lib /usr/local/lib"
dnl if test ! "$ac_misdnkernel_libraries" = "NO"; then
dnl   misdn_libdir=$ac_misdnkernel_libraries
dnl else
dnl   misdn_libdirs="$ac_misdnkernel_libraries $misdn_libdirs"
dnl   # if the mISDN-user was given, the chance is too big that libmisdn.* doesn't exist
dnl   misdn_libdir=NONE
dnl   for dir in $misdn_libdirs; do
dnl     try="ls -1 $dir/${LIBMISDN_GLOB}"
dnl     if test -n "`$try 2> /dev/null`"; then misdn_libdir=$dir; break; else echo "tried $dir" >&AC_FD_CC ; fi
dnl   done
dnl fi
dnl for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
dnl   if test -e "$a"; then
dnl     LIBMISDN="$LIBMISDN ${pbx_int_misdn}_incremental"
dnl     break
dnl   fi
dnl done
dnl 
dnl ac_misdnkernel_libraries="$misdn_libdir"
dnl 
AC_LANG_SAVE
AC_LANG_CPLUSPLUS

ac_cxxflags_safe="$CXXFLAGS"
ac_ldflags_safe="$LDFLAGS"
ac_libs_safe="$LIBS"

CXXFLAGS="$CXXFLAGS -I$misdnkernel_incdir $all_includes"
LDFLAGS="$LDFLAGS -L$misdn_libdir $all_libraries $USER_LDFLAGS"
LIBS="$LIBS $LIBMISDN"

PBX_PRINT_MISDNKERNEL_PROGRAM

if AC_TRY_EVAL(ac_compile) && test -s conftest.o; then
  rm -f conftest*
else
  echo "configure: failed program was:" >&AC_FD_CC
  cat conftest.$ac_ext >&AC_FD_CC
  ac_misdnkernel_includes="NO"
dnl   ac_misdnkernel_libraries="NO"
fi
rm -f conftest*
CXXFLAGS="$ac_cxxflags_safe"
LDFLAGS="$ac_ldflags_safe"
LIBS="$ac_libs_safe"

AC_LANG_RESTORE
dnl if test "$ac_misdnkernel_includes" = NO || test "$ac_misdnkernel_libraries" = NO; then
if test "$ac_misdnkernel_includes" = NO; then
  ac_cv_have_misdnkernel="have_misdnkernel=no"
  ac_misdnkernel_notfound=""
  missing_misdn_mt=""
dnl  if test "$ac_misdnkernel_includes" = NO; then
dnl    if test "$ac_misdnkernel_libraries" = NO; then
dnl      ac_misdnkernel_notfound="(headers and libraries)";
dnl    else
      ac_misdnkernel_notfound="(headers)";
dnl    fi
dnl  else
dnl    ac_misdnkernel_notfound="(library $misdnlib)";
dnl  fi

  AC_MSG_ERROR([mISDN kernel header (version >= $lcr_misdn_kernel_minversion) not found. Please check your installation!
For more details about this problem, look at the end of config.log.$missing_misdn_mt])
else
  have_misdnkernel="yes"
fi
])

dnl check cache content
dnl TODO: maybe move this to beginning (before compilation test?)
eval "$ac_cv_have_misdnkernel"

if test "$have_misdnkernel" != yes; then
  AC_MSG_RESULT([$have_misdnkernel]);
else
  ac_cv_have_misdnkernel="have_misdnkernel=yes \
   ac_misdnkernel_includes=$ac_misdnkernel_includes"
dnl    ac_misdnkernel_libraries=$ac_misdnkernel_libraries"
  AC_MSG_RESULT([headers $ac_misdnkernel_includes])

dnl   misdnkernel_libraries="$ac_misdnkernel_libraries"
  misdnkernel_includes="$ac_misdnkernel_includes"
fi

dnl if test ! "$pbx_misdn_libs_given" = "yes" && test ! "$pbx_misdnver" = 3; then
dnl      KDE_CHECK_MISDN_DIRECT(misdnkernel_libraries= ,[])
dnl fi

dnl AC_SUBST(misdnkernel_libraries)
AC_SUBST(misdnkernel_includes)

if test -z "$misdnkernel_includes"; then
 MISDNKERNEL_INCLUDES=""
else
 MISDNKERNEL_INCLUDES="-I$misdnkernel_includes"
 all_includes="$MISDNKERNEL_INCLUDES $all_includes"
fi

dnl if test -z "$misdnkernel_libraries"; then
dnl  MISDN_LDFLAGS=""
dnl else
dnl  MISDN_LDFLAGS="-L$misdnkernel_libraries"
dnl  all_libraries="$MISDN_LDFLAGS $all_libraries"
dnl fi
dnl test -z "$KDE_MT_LDFLAGS" || all_libraries="$all_libraries $KDE_MT_LDFLAGS"

AC_SUBST(MISDNKERNEL_INCLUDES)
dnl AC_SUBST(MISDN_LDFLAGS)
dnl AC_PATH_MISDN_MOC_UIC

dnl KDE_CHECK_MISDN_JPEG

dnl if test "x$pbx_use_misdn_emb" != "xyes" && test "x$pbx_use_misdn_mac" != "xyes"; then
dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG) -lXext $(LIB_X11) $(LIBSM)'
dnl else
dnl LIB_MISDN="$pbx_int_misdn $LIBJPEG_MISDN "'$(LIBZ) $(LIBPNG)'
dnl fi
dnl test -z "$KDE_MT_LIBS" || LIB_MISDN="$LIB_MISDN $KDE_MT_LIBS"
dnl for a in $misdn_libdir/lib`echo ${pbx_int_misdn} | sed 's,^-l,,'`_incremental.*; do
dnl   if test -e "$a"; then
dnl      LIB_MISDN="$LIB_MISDN ${pbx_int_misdn}_incremental"
dnl      break
dnl   fi
dnl done

dnl AC_SUBST(LIB_MISDN)
dnl AC_SUBST(LIB_QPE)

AC_SUBST(pbx_misdnver)

])



dnl ------------------------------------------------------------------------
dnl Find a file (or one of more files in a list of dirs)
dnl ------------------------------------------------------------------------
AC_DEFUN([AC_FIND_FILE],
[
$3=NO
for i in $2;
do
  for j in $1;
  do
    echo "configure: __oline__: $i/$j" >&AC_FD_CC
    if test -r "$i/$j"; then
      echo "taking that" >&AC_FD_CC
      $3=$i
      break 2
    fi
  done
done
])



dnl ------------------------------------------------------------------------
dnl Taken from http://autoconf-archive.cryp.to/ac_define_dir.html
dnl Copyright © 2006 Stepan Kasal <kasal@ucw.cz>
dnl Copyright © 2006 Andreas Schwab <schwab@suse.de>
dnl Copyright © 2006 Guido U. Draheim <guidod@gmx.de>
dnl Copyright © 2006 Alexandre Oliva
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.
dnl 
dnl This macro sets VARNAME to the expansion of the DIR variable, taking care
dnl  of fixing up ${prefix} and such.
dnl ------------------------------------------------------------------------
AC_DEFUN([AC_DEFINE_DIR], [
  prefix_NONE=
  exec_prefix_NONE=
  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
dnl refers to ${prefix}.  Thus we have to use `eval' twice.
  eval ac_define_dir="\"[$]$2\""
  eval ac_define_dir="\"$ac_define_dir\""
  AC_SUBST($1, "$ac_define_dir")
  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
  test "$prefix_NONE" && prefix=NONE
  test "$exec_prefix_NONE" && exec_prefix=NONE
])


dnl ------------------------------------------------------------------------
dnl taken from http://autoconf-archive.cryp.to/ax_ext_check_header.html
dnl Copyright © 2005 Duncan Simpson <dps@simpson.demon.co.uk>
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.
dnl 
dnl Checks locations of headers in various places
dnl Extended by Jörg Habenicht
dnl ------------------------------------------------------------------------
AC_DEFUN([AX_EXT_HAVE_HEADER],
[AC_LANG_PUSH(C)
 AC_CHECK_HEADER($1, [$3 got="yes"], [$4 got="no"], [$5])
 hdr=`echo $1 | $as_tr_sh`
 for dir in $2
 do
  if test "x${got}" = "xno"; then
   ext_hashdr_cvdir=`echo $dir | $as_tr_sh`
   AC_CACHE_CHECK([for $1 header with -I$dir],
    [ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}],
    [ext_have_hdr_save_cflags=${CFLAGS}
     CFLAGS="${CFLAGS} -I${dir}"
     AC_COMPILE_IFELSE(
      [AC_LANG_PROGRAM([#include <$1>])],
      [got="yes"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="yes"],
      [got="no"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="no"])
     CFLAGS=$ext_have_hdr_save_cflags])
   if eval `echo 'test x${'ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}'}' = "xyes"`; then
    CFLAGS="${CFLAGS} -I${dir}"
    CPPFLAGS="${CPPFLAGS} -I${dir}"
    got="yes";
    hdr=`echo $1 | $as_tr_cpp`
    AC_DEFINE_UNQUOTED(HAVE_${hdr}, 1,
     [Define this if you have the $1 header])
   fi; 
  fi; 
 done
AC_LANG_POP])


dnl ------------------------------------------------------------------------
dnl taken from http://autoconf-archive.cryp.to/ax_ext_check_header.html
dnl Copyright © 2005 Duncan Simpson <dps@simpson.demon.co.uk>
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.
dnl 
dnl Checks locations of headers in various places
dnl Extended by Jörg Habenicht
dnl ------------------------------------------------------------------------
dnl $1 include file name
dnl $2 directory list
dnl $3 action yes
dnl $4 action no
dnl $5 include prefix
dnl $6 include suffix
dnl $7 main() body content
AC_DEFUN([PBX_EXT_HAVE_CXX_HEADER],
[AC_LANG_PUSH(C++)
 AC_CHECK_HEADER($1, [$3 got="yes"], [$4 got="no"], [$5])
 hdr=`echo $1 | $as_tr_sh`
 for dir in $2 ;  do
  if test "x${got}" = "xno"; then
   ext_hashdr_cvdir=`echo $dir | $as_tr_sh`
   AC_CACHE_CHECK([for $1 header with -I$dir],
    [ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}],
    [ext_have_hdr_save_cxxflags=${CXXFLAGS}
     CXXFLAGS="${CXXFLAGS} -I${dir}"
     AC_COMPILE_IFELSE(
      [PBX_PRINT_PROGRAM([#include <$1>],[$5],[$6],[$7])],
      [$3 got="yes"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="yes"],
      [$4 got="no"; eval "ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}"="no"])
     CXXFLAGS=$ext_have_hdr_save_cxxflags])
   if eval `echo 'test x${'ext_cv${ext_hashdr_cvdir}_hashdr_${hdr}'}' = "xyes"`; then
    CXXFLAGS="${CXXFLAGS} -I${dir}"
    CPPFLAGS="${CPPFLAGS} -I${dir}"
    got="yes";
    hdr=`echo $1 | $as_tr_cpp`
    AC_DEFINE_UNQUOTED(HAVE_${hdr}, 1,
     [Define this if you have the $1 header])
   fi; 
  fi; 
 done
AC_LANG_POP])