~ubuntu-branches/ubuntu/trusty/xmedcon/trusty

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
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# filename: configure.in                                                  #
#                                                                         #
# UTIL Make   : Medical Image Conversion Utility                          #
#                                                                         #
# purpose     : configure script template (autoconf)                      #
#                                                                         #
# project     : (X)MedCon by Erik Nolf                                    #
#                                                                         #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# $Id: configure.in,v 1.130 2007/09/25 20:35:12 enlf Exp $

# Copyright (C) 1997-2007 by Erik Nolf

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

AC_INIT([XMedCon], [0.9.10], [enlf-at-users.sf.net], [xmedcon])


XMEDCON_MAJOR="0"
XMEDCON_MINOR="9"
XMEDCON_MICRO="10"
XMEDCON_PRGR="(X)MedCon"
XMEDCON_DATE="25-Sep-2007"
XMEDCON_VERSION="${XMEDCON_MAJOR}.${XMEDCON_MINOR}.${XMEDCON_MICRO}"
XMEDCON_LIBVERS="${XMEDCON_PRGR} ${XMEDCON_VERSION} by Erik Nolf"

dnl Do not use env variable, not set yet for this.
AC_PREFIX_DEFAULT( /usr/local/xmedcon ) 

dnl Do some specific configurations.
echo ""
echo "BEGIN SPECIFIC CONFIG:"

dnl Format Acr/Nema 2.0.
AC_ARG_ENABLE(acr,
[
  --enable-acr            enable  Acr/Nema 2.0 format (default).
  --disable-acr           disable Acr/Nema 2.0 format. ],
[
  case "$enableval" in 
	no)
		AC_CACHE_VAL(mdc_cv_include_acr,mdc_cv_include_acr=no)
		ENABLE_ACR=0
		;;
	*)
		AC_CACHE_VAL(mdc_cv_include_acr,mdc_cv_include_acr=yes)
		ENABLE_ACR=1
		;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_acr,mdc_cv_include_acr=yes)
  ENABLE_ACR=1
)
AC_MSG_RESULT([Format Acr/Nema 2.0     enabled? ${mdc_cv_include_acr}])

dnl Format Gif87a/89a.
AC_ARG_ENABLE(gif,
[
  --enable-gif            enable  Gif87a/89a format (default).
  --disable-gif           disable Gif87a/89a format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_gif,mdc_cv_include_gif=no)
                ENABLE_GIF=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_acr,mdc_cv_include_gif=yes)
                ENABLE_GIF=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_gif,mdc_cv_include_gif=yes)
  ENABLE_GIF=1
)
AC_MSG_RESULT([Format Gif87a/89a       enabled? ${mdc_cv_include_gif}])

dnl Format INW (RUG).
AC_ARG_ENABLE(inw,
[
  --enable-inw            enable  INW (RUG) format (default).
  --disable-inw           disable INW (RUG) format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_inw,mdc_cv_include_inw=no)
                ENABLE_INW=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_inw,mdc_cv_include_inw=yes)
                ENABLE_INW=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_inw,mdc_cv_include_inw=yes)
  ENABLE_INW=1
)
AC_MSG_RESULT([Format INW (RUG)        enabled? ${mdc_cv_include_inw}])

dnl Format Analyze (SPM).
AC_ARG_ENABLE(anlz,
[
  --enable-anlz           enable  Analyze (SPM) format (default).
  --disable-anlz          disable Analyze (SPM) format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_anlz,mdc_cv_include_anlz=no)
                ENABLE_ANLZ=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_anlz,mdc_cv_include_anlz=yes)
                ENABLE_ANLZ=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_anlz,mdc_cv_include_anlz=yes)
  ENABLE_ANLZ=1
)
AC_MSG_RESULT([Format Analyze (SPM)    enabled? ${mdc_cv_include_anlz}])

dnl Format Concorde microPET
AC_ARG_ENABLE(conc,
[
  --enable-conc           enable  Concorde microPET format (default).
  --disable-conc          disable Concorde microPET format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_conc,mdc_cv_include_conc=no)
                ENABLE_CONC=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_conc,mdc_cv_include_conc=yes)
                ENABLE_CONC=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_conc,mdc_cv_include_conc=yes)
  ENABLE_CONC=1
)
AC_MSG_RESULT([Format Concorde uPET    enabled? ${mdc_cv_include_conc}])

dnl Format CTI ECAT 6/7.
AC_ARG_ENABLE(ecat,
[
  --enable-ecat           enable  CTI ECAT 6/7 format (default).
  --disable-ecat          disable CTI ECAT 6/7 format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_ecat,mdc_cv_include_ecat=no)
                ENABLE_ECAT=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_ecat,mdc_cv_include_ecat=yes)
                ENABLE_ECAT=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_ecat,mdc_cv_include_ecat=yes)
  ENABLE_ECAT=1
)
AC_MSG_RESULT([Format CTI ECAT 6/7     enabled? ${mdc_cv_include_ecat}])

dnl Format InterFile 3.3.
AC_ARG_ENABLE(intf,
[
  --enable-intf           enable  InterFile 3.3 format (default).
  --disable-intf          disable InterFile 3.3 format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_intf,mdc_cv_include_intf=no)
                ENABLE_INTF=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_intf,mdc_cv_include_intf=yes)
                ENABLE_INTF=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_intf,mdc_cv_include_intf=yes)
  ENABLE_INTF=1
)
AC_MSG_RESULT([Format InterFile 3.3    enabled? ${mdc_cv_include_intf}])

dnl Format DICOM 3.0.
AC_ARG_ENABLE(dicom,
[
  --enable-dicom          enable  DICOM 3.0 format (default).
  --disable-dicom         disable DICOM 3.0 format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_dicm,mdc_cv_include_dicm=no)
                ENABLE_DICM=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_dicm,mdc_cv_include_dicm=yes)
                ENABLE_DICM=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_dicm,mdc_cv_include_dicm=yes)
  ENABLE_DICM=1
)
AC_MSG_RESULT([Format DICOM 3.0        enabled? ${mdc_cv_include_dicm}])
dnl DICOM needs Acr/Nema.
if test x$mdc_cv_include_dicm = xyes; then 
  if test x$mdc_cv_include_acr != xyes; then
    echo "***"
    echo "*** Oeps. DICOM needs Acr/Nema to be enabled."
    echo "*** Therefore rerun configure to do so ..."
    echo "***"
    rm -f config.cache
    exit 1
  fi
fi

dnl Format PNG, test later for required components
AC_ARG_ENABLE(png,
[
  --enable-png            enable  PNG format (default).
  --disable-png           disable PNG format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_png,mdc_cv_include_png=no)
                ENABLE_PNG=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_png,mdc_cv_include_png=yes)
                ENABLE_PNG=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_png,mdc_cv_include_png=yes)
  ENABLE_PNG=1
)
AC_MSG_RESULT([Format PNG              enabled? ${mdc_cv_include_png}])

dnl Format NIFTI, test later for required components
AC_ARG_ENABLE(nifti,
[
  --enable-nifti          enable  NIFTI format (default).
  --disable-nifti         disable NIFTI format. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_include_nifti,mdc_cv_include_nifti=no)
                ENABLE_NIFTI=0
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_nifti,mdc_cv_include_nifti=yes)
                ENABLE_NIFTI=1
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_nifti,mdc_cv_include_nifti=yes)
  ENABLE_NIFTI=1
)
AC_MSG_RESULT([Format NIFTI            enabled? ${mdc_cv_include_nifti}])

dnl DICOM LossLess JPEG ...
if test x$mdc_cv_include_dicm = xyes; then
AC_ARG_ENABLE(ljpg,
[
  --enable-ljpg           enable  DICOM lossless jpeg (default).
  --disable-ljpg          disable DICOM lossless jpeg. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_ljpg,mdc_cv_ljpg=no)
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_ljpg,mdc_cv_ljpg=yes)
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_ljpg,mdc_cv_ljpg=yes)
)
else
  AC_CACHE_VAL(mdc_cv_ljpg,mdc_cv_ljpg=no)
fi
AC_MSG_RESULT([Enable DICOM 3.0 lossless jpeg ? ${mdc_cv_ljpg}])

dnl TPC library for ecat7 writing, test later for required components
AC_ARG_ENABLE(tpc,
[
  --enable-tpc            enable  TPC ecat7 writing support.
  --disable-tpc           disable TPC ecat7 writing support (default). ],
[
  case "$enableval" in
        yes)
                AC_CACHE_VAL(mdc_cv_include_tpc,mdc_cv_include_tpc=yes)
                ENABLE_TPC=1
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_include_tpc,mdc_cv_include_tpc=no)
                ENABLE_TPC=0
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_include_tpc,mdc_cv_include_tpc=no)
  ENABLE_TPC=0
)
AC_MSG_RESULT([Enable TPC ecat7 write support ? ${mdc_cv_include_tpc}])

dnl glib library (availability tests later).
AC_ARG_ENABLE(glib,
[
  --enable-glib           enable  glib convience functions (default).
  --disable-glib          disable glib convience functions. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_glibsupport,mdc_cv_glibsupport=no)
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_glibsupport,mdc_cv_glibsupport=yes)
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_glibsupport,mdc_cv_glibsupport=yes)
)
AC_MSG_RESULT([Enable glib convenience func's ? ${mdc_cv_glibsupport}])

dnl GUI (Gtk+ toolkit availability tests later).
AC_ARG_ENABLE(gui,
[
  --enable-gui            enable  graphical user interface (default).
  --disable-gui           disable graphical user interface. ],
[
  case "$enableval" in
        no)
                AC_CACHE_VAL(mdc_cv_xsupport,mdc_cv_xsupport=no)
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_xsupport,mdc_cv_xsupport=yes)
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_xsupport,mdc_cv_xsupport=yes)
)
AC_MSG_RESULT([Enable graphical user interface? ${mdc_cv_xsupport}])

dnl Checks for long long type.
AC_ARG_ENABLE(llcheck,
[
  --enable-llcheck        enable  long long type check.
  --disable-llcheck       disable long long type check (default). ],
[
  case "$enableval" in
        yes)
                AC_CACHE_VAL(mdc_cv_lnglngcheck,mdc_cv_lnglngcheck=yes)
                ;;
        *)
                AC_CACHE_VAL(mdc_cv_lnglngcheck,mdc_cv_lnglngcheck=no)
                ;;
  esac ],
  AC_CACHE_VAL(mdc_cv_lnglngcheck,mdc_cv_lnglngcheck=no)
)
AC_MSG_RESULT([Enable check for long long type? ${mdc_cv_lnglngcheck}])

echo ""
echo "BEGIN AUTO CONFIG:"
AM_INIT_AUTOMAKE(xmedcon, ${XMEDCON_VERSION})
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL

dnl Checks for programs.
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S


AC_MSG_CHECKING([for native Win32])
case "$host" in
  *-*-mingw*)
    native_win32=yes
    ;;
  *)
    native_win32=no
    ;;
esac
AC_MSG_RESULT([$native_win32])
AM_CONDITIONAL(OS_WIN32, test "$native_win32" = yes)

AC_MSG_CHECKING([for Win32 platform in general])
case "$host" in
  *-*-mingw*|*-*-cygwin*)
    platform_win32=yes
    ;;
  *)
    platform_win32=no
    ;;
esac
AC_MSG_RESULT($platform_win32)
AM_CONDITIONAL(PLATFORM_WIN32, test "$platform_win32" = yes)

# Ensure MSVC-compatible struct packing convention is used when
# compiling for Win32 with gcc. GTK+ uses this convention, so we must, too.
# What flag to depends on gcc version: gcc3 uses "-mms-bitfields", while
# gcc2 uses "-fnative-struct".
if test x"$native_win32" = xyes; then
  if test x"$GCC" = xyes; then
    msnative_struct=''
    AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
    if test -z "$ac_cv_prog_CC"; then
      our_gcc="$CC"
    else
      our_gcc="$ac_cv_prog_CC"
    fi
    case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
      2.)
	if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
	  msnative_struct='-fnative-struct'
	fi
	;;
      *)
	if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
	  msnative_struct='-mms-bitfields'
	fi
	;;
    esac
    if test x"$msnative_struct" = x ; then
      AC_MSG_RESULT([no way])
      AC_MSG_WARN([produced libraries will be incompatible with prebuilt GTK+ DLLs])
    else
      CFLAGS="$CFLAGS $msnative_struct"
      AC_MSG_RESULT([${msnative_struct}])
    fi
  fi
fi


dnl Checks for libraries.
dnl Replace `main' with a function in -libs:
AC_CHECK_LIB(ibs, main)

dnl Check for libz
if test $ENABLE_PNG -gt 0 -o $ENABLE_NIFTI -gt 0; then
  AC_CHECK_LIB(z, uncompress, ZLIB_LDFLAGS="-lz", ZLIB_LDFLAGS="")

  if test x"$ZLIB_LDFLAGS" != "x"; then
    ZLIB_CFLAGS="-DHAVE_ZLIB"
  else
    ZLIB_CFLAGS=""
  fi
fi

dnl Check for libpng
prev_LDFLAGS="$LDFLAGS"
prev_CPPFLAGS="$CPPFLAGS"
AC_ARG_WITH(png-prefix,
   [  --with-png-prefix=PFX   Prefix where PNG library is installed (optional)]
 , png_prefix="$withval", png_prefix="")
if test x"$png_prefix" != "x"; then
    PNG_LDFLAGS="-L$png_prefix/lib -lpng"
    PNG_CFLAGS="-I$png_prefix/include"

    LDFLAGS="$LDFLAGS -lm $PNG_LDFLAGS $ZLIB_FLAGS"
    CPPFLAGS="$CPPFLAGS $PNG_CFLAGS"
else
    PNG_LDFLAGS="-lpng"
    PNG_CFLAGS=""
fi

if test x"$ZLIB_LDFLAGS" = "x"; then
  ENABLE_PNG=0;
fi

if test $ENABLE_PNG -gt 0; then
  AC_MSG_CHECKING(for PNG support)
  AC_MSG_RESULT
  failed=0;
  passed=0;
  AC_CHECK_HEADER(png.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
  AC_CHECK_LIB(png,png_read_png,passed=`expr $passed + 1`,failed=`expr $failed + 1`, $ZLIB_LDFLAGS)
  AC_MSG_CHECKING(if PNG package is complete)
  if test $passed -gt 0
  then
    if test $failed -gt 0
    then
      AC_MSG_RESULT(no)
      ENABLE_PNG=0
    else
      AC_MSG_RESULT(yes)
      ENABLE_PNG=1
    fi
  else 
    AC_MSG_RESULT(no)
    ENABLE_PNG=0
  fi
  if test $ENABLE_PNG -lt 1; then
    echo "***"
    echo "***  Oeps. Components required for PNG support are missing."
    echo "***  You will need to rerun the configure script with argument"
    echo "***  --disable-png or give a proper value to --with-png-prefix."
    echo "***"
    rm -f config.cache
    exit 1
  fi
fi
LDFLAGS="$prev_LDFLAGS"
CPPFLAGS="$prev_CPPFLAGS"

dnl Prepare build flags for libniftiio
prev_LDFLAGS="$LDFLAGS"
prev_CPPFLAGS="$CPPFLAGS"
AC_ARG_WITH(nifti-prefix,
   [  --with-nifti-prefix=PFX   Prefix where NIFTI library is installed (optional)]
 , nifti_prefix="$withval", nifti_prefix="")
if test x"$nifti_prefix" != "x"; then
    ZNZ_LDFLAGS="-L$nifti_prefix/lib -lznz"
    NIFTI_LDFLAGS="-L$nifti_prefix/lib -lniftiio $ZNZ_LDFLAGS"
    NIFTI_CFLAGS=""
    AC_CHECK_FILE($nifti_prefix/include/nifti/nifti1_io.h,NIFTI_CFLAGS="-I$nifti_prefix/include/nifti",NIFTI_CFLAGS="-I$nifti_prefix/include")
    LDFLAGS="$LDFLAGS -lm $NIFTI_LDFLAGS $ZLIB_LDFLAGS"
    CPPFLAGS="$CPPFLAGS $NIFTI_CFLAGS $ZLIB_LDFLAGS"
else
    ZNZ_LDFLAGS="-L../libs/nifti -lznz"
    NIFTI_LDFLAGS="-L../libs/nifti -lniftiio $ZNZ_LDFLAGS"
    NIFTI_CFLAGS="-I../libs/nifti"
fi

dnl Check for installed libniftiio
if test $ENABLE_NIFTI -gt 0 -a x"$nifti_prefix" != "x"; then
  AC_MSG_CHECKING(for NIFTI support)
  AC_MSG_RESULT
  failed=0;
  passed=0;
  AC_CHECK_HEADER(nifti1_io.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
  AC_CHECK_LIB(niftiio,nifti_read_header,passed=`expr $passed + 1`,failed=`expr $failed + 1`, $ZNZ_LDFLAGS)
  AC_MSG_CHECKING(if NIFTI package is complete)
  if test $passed -gt 0
  then
    if test $failed -gt 0
    then
      AC_MSG_RESULT(no)
      ENABLE_NIFTI=0
    else
      AC_MSG_RESULT(yes)
      ENABLE_NIFTI=1
    fi
  else 
    AC_MSG_RESULT(no)
    ENABLE_NIFTI=0
  fi
  if test $ENABLE_NIFTI -lt 1; then
    echo "***"
    echo "***  Oeps. Components required for NIFTI support are missing."
    echo "***  You will need to rerun the configure script with argument"
    echo "***  --disable-nifti or give a proper value to --with-nifti-prefix."
    echo "***"
    rm -f config.cache
    exit 1
  fi
fi
LDFLAGS="$prev_LDFLAGS"
CPPFLAGS="$prev_CPPFLAGS"

dnl Check for libtpcimgio and tpcmisc
prev_LDFLAGS="$LDFLAGS"
prev_CPPFLAGS="$CPPFLAGS"
AC_ARG_WITH(tpc-prefix,
   [  --with-tpc-prefix=PFX   Prefix where TPC library is installed (optional)]
 , tpc_prefix="$withval", tpc_prefix="")
if test x"$tpc_prefix" != "x"; then
    TPC_LDFLAGS="-L$tpc_prefix/lib -ltpcimgio -L$tpc_prefix/lib -ltpcmisc"
    TPC_CFLAGS="-I$tpc_prefix/include"
    LDFLAGS="$LDFLAGS $TPC_LDFLAGS"
    CPPFLAGS="$CPPFLAGS $TPC_CFLAGS"
else
    TPC_LDFLAGS="-ltpcimgio -ltpcmisc"
    TPC_CFLAGS=""
fi
if test $ENABLE_TPC -gt 0; then
  AC_MSG_CHECKING(for TPC ecat7 writing support)
  AC_MSG_RESULT
  failed=0;
  passed=0;
  AC_CHECK_HEADER(ecat7.h,passed=`expr $passed + 1`,failed=`expr $failed + 1`,)
  AC_CHECK_LIB(tpcimgio,ecat7Create,passed=`expr $passed + 1`,failed=`expr $failed + 1`, $TPC_LDFLAGS)
  AC_MSG_CHECKING(if TPC library is complete)
  if test $passed -gt 0
  then
    if test $failed -gt 0
    then
      AC_MSG_RESULT(no)
      ENABLE_TPC=0
    else
      AC_MSG_RESULT(yes)
      ENABLE_TPC=1
    fi
  else 
    AC_MSG_RESULT(no)
    ENABLE_TPC=0
  fi
  if test $ENABLE_TPC -lt 1; then
    echo "***"
    echo "***  Oeps. Components required for TPC ecat7 writing are missing."
    echo "***  You will need to rerun the configure script with argument"
    echo "***  --disable-tpc or give a proper value to --with-tpc-prefix."
    echo "***"
    rm -f config.cache
    exit 1
  fi
fi
LDFLAGS="$prev_LDFLAGS"
CPPFLAGS="$prev_CPPFLAGS"

dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(strings.h unistd.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST

dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(strptime)
AC_CHECK_FUNCS(localtime_r)
AC_CHECK_FUNCS(isnan)
AC_CHECK_FUNCS(isinf)

dnl Checks for glib supported medcon
if test x$mdc_cv_glibsupport = xyes; then
  AM_PATH_GLIB(1.2.0,[ac_cv_prog_glib=yes],[ac_cv_prog_glib=no])
fi
MDC_CHECK_GLIBSUPPORT($mdc_cv_glibsupport)

dnl Checks for X-supported MedCon.
if test x$mdc_cv_xsupport = xyes; then
  AM_PATH_GTK(1.2.0,[ac_cv_prog_gtk=yes],[ac_cv_prog_gtk=no])
  AM_PATH_GDK_PIXBUF(0.8.0,[ac_cv_prog_gdk_pixbuf=yes],[ac_cv_prog_gdk_pixbuf=no])
fi
MDC_CHECK_XSUPPORT($mdc_cv_xsupport)

AM_CONDITIONAL(DO_ACR,  test x$mdc_cv_include_acr = xyes)
AM_CONDITIONAL(DO_GIF,  test x$mdc_cv_include_gif = xyes)
AM_CONDITIONAL(DO_INW,  test x$mdc_cv_include_inw = xyes)
AM_CONDITIONAL(DO_ANLZ, test x$mdc_cv_include_anlz = xyes)
AM_CONDITIONAL(DO_CONC, test x$mdc_cv_include_conc = xyes)
AM_CONDITIONAL(DO_ECAT, test x$mdc_cv_include_ecat = xyes)
AM_CONDITIONAL(DO_INTF, test x$mdc_cv_include_intf = xyes)
AM_CONDITIONAL(DO_DICM, test x$mdc_cv_include_dicm = xyes)
AM_CONDITIONAL(DO_PNG,  test x$mdc_cv_include_png  = xyes)

AM_CONDITIONAL(DO_NIFTI,test x$mdc_cv_include_nifti = xyes)
AM_CONDITIONAL(DO_NIFTI_INTERNAL, test x"$nifti_prefix" = "x")

AM_CONDITIONAL(DO_TPC,  test x$mdc_cv_include_tpc = xyes)
AM_CONDITIONAL(DO_LJPG, test x$mdc_cv_ljpg = xyes)

AM_CONDITIONAL(DO_GLIBSUPPORT, test x$mdc_cv_glibsupport = xyes)

AM_CONDITIONAL(DO_XSUPPORT, test x$mdc_cv_xsupport = xyes)

dnl Make substitutions.
AC_SUBST(XMEDCON_MAJOR)
AC_SUBST(XMEDCON_MINOR)
AC_SUBST(XMEDCON_MICRO)
AC_SUBST(XMEDCON_PRGR)
AC_SUBST(XMEDCON_DATE)
AC_SUBST(XMEDCON_VERSION)
AC_SUBST(XMEDCON_LIBVERS)
AC_SUBST(ENABLE_ACR)
AC_SUBST(ENABLE_GIF)
AC_SUBST(ENABLE_INW)
AC_SUBST(ENABLE_ANLZ)
AC_SUBST(ENABLE_CONC)
AC_SUBST(ENABLE_ECAT)
AC_SUBST(ENABLE_INTF)
AC_SUBST(ENABLE_DICM)
AC_SUBST(ENABLE_PNG)
AC_SUBST(ENABLE_NIFTI)
AC_SUBST(ENABLE_TPC)

AC_SUBST(ZLIB_LDFLAGS)
AC_SUBST(ZLIB_CFLAGS)
AC_SUBST(PNG_LDFLAGS)
AC_SUBST(PNG_CFLAGS)
AC_SUBST(NIFTI_LDFLAGS)
AC_SUBST(NIFTI_CFLAGS)
AC_SUBST(TPC_LDFLAGS)
AC_SUBST(TPC_CFLAGS)

AC_SUBST(mdc_cv_include_gif)
AC_SUBST(mdc_cv_include_acr)
AC_SUBST(mdc_cv_include_inw)
AC_SUBST(mdc_cv_include_conc)
AC_SUBST(mdc_cv_include_ecat)
AC_SUBST(mdc_cv_include_intf)
AC_SUBST(mdc_cv_include_anlz)
AC_SUBST(mdc_cv_include_dicm)
AC_SUBST(mdc_cv_include_png)
AC_SUBST(mdc_cv_include_nifti)
AC_SUBST(mdc_cv_include_tpc)
AC_SUBST(mdc_cv_ljpg)
AC_SUBST(mdc_cv_glibsupport)
AC_SUBST(mdc_cv_xsupport)

AC_SUBST(GLIBSUPPORTED)
AC_SUBST(GLIBMDCETC)
AC_SUBST(XSUPPORTED)
AC_SUBST(XMDCETC)

dnl Checks for machine dependencies.
AC_C_BIGENDIAN
if test x$ac_cv_c_bigendian = xyes; then
	mdc_cv_bigendian=1
else
	mdc_cv_bigendian=0
fi
AC_CHECK_SIZEOF(short,2)
AC_CHECK_SIZEOF(int,4)
AC_CHECK_SIZEOF(long,4)
if test x$mdc_cv_lnglngcheck = xyes; then
	AC_CHECK_SIZEOF(long long,8) 
fi

dnl Checks for gzip or compress.
AC_CHECK_PROGS(DECOMPRESS, gunzip uncompress, none)

AM_CONFIG_HEADER(source/m-depend.h)

dnl Pass types for m-config.h
AC_SUBST(mdc_cv_bigendian)
AC_SUBST(ac_cv_sizeof_short)
AC_SUBST(ac_cv_sizeof_int)
AC_SUBST(ac_cv_sizeof_long)
if test x$mdc_cv_lnglngcheck = xyes; then
   mdc_cv_enable_lnglng=1
   AC_SUBST(ac_cv_sizeof_long_long)
else
   mdc_cv_enable_lnglng=0
fi
AC_SUBST(mdc_cv_enable_lnglng)

AC_OUTPUT([
 Makefile
 xmedcon-config
 libs/Makefile
 libs/ljpg/Makefile
 libs/dicom/Makefile
 libs/nifti/Makefile
 source/Makefile
 source/m-config.h
 etc/Makefile
 etc/xmedcon.spec
 etc/xmedcon-$VERSION-1.iss:etc/xmedcon.iss.in
 etc/xmedcon-$VERSION-1.info:etc/xmedcon.info.in
 etc/xmedcon-$VERSION.ebuild:etc/xmedcon.ebuild.in
 man/Makefile
])