summaryrefslogtreecommitdiff
path: root/configure.in
blob: 861938fcdc8341f6aedfe113909b4071224b44d0 (plain)
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
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
dnl Process this file with autoconf to produce a configure script.

# If porting the hal tarball to work well on a distribution search
# for the string "(distro-tweaks required)" for what to tweak.
#
# Patches for that is welcome.
#

AC_PREREQ(2.59c)
AC_INIT(hal, 0.5.15, david@fubar.dk)
AM_INIT_AUTOMAKE([gnu 1.9])
AM_MAINTAINER_MODE
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

glib_module="glib-2.0 >= 2.10.0 gobject-2.0 > 2.10.0 dbus-glib-1 >= 0.61"
dbus_module="dbus-1 >= 0.61"
blkid_module="blkid >= 2.15"
volume_id_module="libvolume_id >= 0.77"
polkit_module="polkit >= 0.5"

# libtool versioning - this applies to libhal and libhal-storage
#
# See http://sources.redhat.com/autobook/autobook/autobook_91.html#SEC91 for details
#
LT_CURRENT=1
LT_REVISION=0
LT_AGE=0
AC_SUBST(LT_CURRENT)
AC_SUBST(LT_REVISION)
AC_SUBST(LT_AGE)

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CXX
AM_PROG_CC_C_O
AC_HEADER_STDC
AC_PROG_LIBTOOL
AC_PROG_MAKE_SET
AC_PROG_LN_S
AC_SYS_LARGEFILE
PKG_PROG_PKG_CONFIG

AC_CHECK_HEADERS([sys/ioccom.h sys/inotify.h])

AC_ARG_WITH([os-type],
	    AS_HELP_STRING([--with-os-type=<os>],
			   [Distribution or OS (redhat)]))
AC_ARG_WITH([pid-file],
	    AS_HELP_STRING([--with-pid-file=<file>],
			   [PID file for HAL daemon]))

AC_ARG_WITH([hwdata],
	    AS_HELP_STRING([--with-hwdata=<dir>],
			   [Where PCI and USB IDs are found]))
AC_ARG_WITH([pci-ids],
	    AS_HELP_STRING([--with-pci-ids=<dir>],
			   [Where PCI IDs are found (overrides --with-hwdata)]))
AC_ARG_WITH([usb-ids],
	    AS_HELP_STRING([--with-usb-ids=<dir>],
			   [Where USB IDs are found (overrides --with-hwdata)]))

AC_ARG_ENABLE([pci-ids],
	      AS_HELP_STRING([--disable-pci-ids],
			     [Do not build with PCI IDs support]),
	      [enable_pci_ids=$enableval], [enable_pci_ids=yes])
AC_ARG_ENABLE([usb-ids],
	      AS_HELP_STRING([--disable-usb-ids],
			     [Do not build with USB IDs support]),
	      [enable_usb_ids=$enableval], [enable_usb_ids=yes])
AC_ARG_ENABLE([pnp-ids],
	      AS_HELP_STRING([--disable-pnp-ids],
			     [Do not build with PNP IDs support]),
	      [enable_pnp_ids=$enableval], [enable_pnp_ids=yes])

AC_ARG_WITH([socket-dir],
	    AS_HELP_STRING([--with-socket-dir=<dir>],
			   [Location of the HAL D-BUS listening sockets (auto)]))

AC_ARG_WITH(udev-prefix,
        AS_HELP_STRING([--with-udev-prefix=DIR], [add prefix to internal udev path names]),
        [], [with_udev_prefix='${exec_prefix}/lib'])
udev_prefix=$with_udev_prefix
AC_SUBST(udev_prefix)

if ! test -z "$with_hwdata" ; then
  PCI_IDS_DIR="$with_hwdata"
  USB_IDS_DIR="$with_hwdata"
fi
if ! test -z "$with_pci_ids" ; then
  PCI_IDS_DIR="$with_pci_ids"
fi
if ! test -z "$with_usb_ids" ; then
  USB_IDS_DIR="$with_usb_ids"
fi

if test "x$enable_pci_ids" = "xno" ; then
  USE_PCI_IDS=no
else
   if test -z "$PCI_IDS_DIR"; then
     for dir in /usr/share/hwdata /usr/share/misc /usr/share /var/lib/misc; do
       AC_CHECK_FILE([$dir/pci.ids], [PCI_IDS_DIR=$dir])
     done
     if test -z "$PCI_IDS_DIR"; then
       AC_MSG_ERROR([cannot find pci.ids. Use --with-pci-ids to specify location])
     else
       AC_MSG_WARN([autodetected pci.ids in $PCI_IDS_DIR])
     fi
   fi
   USE_PCI_IDS=yes
   AC_DEFINE([USE_PCI_IDS], [1], [Whether pci.ids is to be used])
fi

if test "x$enable_usb_ids" = "xno" ; then
  USE_USB_IDS=no
else 
   if test -z "$USB_IDS_DIR"; then
     for dir in /usr/share/hwdata /usr/share/misc /usr/share /var/lib/misc; do
       AC_CHECK_FILE([$dir/usb.ids], [USB_IDS_DIR=$dir])
     done
     if test -z "$USB_IDS_DIR"; then
       AC_MSG_ERROR([cannot find usb.ids. Use --with-usb-ids to specify location])
     else
       AC_MSG_WARN([autodetected usb.ids in $USB_IDS_DIR])
     fi
   fi
   USE_USB_IDS=yes
   AC_DEFINE([USE_USB_IDS], [1], [Whether usb.ids is to be used])
fi

if test "x$enable_pnp_ids" = "xno" ; then
  USE_PNP_IDS=no
else
  USE_PNP_IDS=yes
  AC_DEFINE([USE_PNP_IDS], [1], [Whether builtin PNP IDs are to be used])
fi

AC_SUBST(PCI_IDS_DIR)
AC_SUBST(USB_IDS_DIR)
AC_SUBST(USE_PCI_IDS)
AC_SUBST(USE_USB_IDS)
AC_SUBST(USE_PNP_IDS)


AC_ARG_WITH([hal_user],
	    AS_HELP_STRING([--with-hal-user=<user>],
	                   [User for running the HAL daemon (haldaemon)]))
if test -z "$with_hal_user" ; then
    HAL_USER=haldaemon
else
    HAL_USER=$with_hal_user
fi
AC_SUBST(HAL_USER)
AC_DEFINE_UNQUOTED(HAL_USER,"$HAL_USER", [User for running the HAL daemon])

AC_ARG_WITH([hal_group],
	    AS_HELP_STRING([--with-hal-group=<grp>],
	                   [Group for HAL (haldaemon)]))
if test -z "$with_hal_group" ; then
    HAL_GROUP=haldaemon
else
    HAL_GROUP=$with_hal_group
fi
AC_SUBST(HAL_GROUP)
AC_DEFINE_UNQUOTED(HAL_GROUP,"$HAL_GROUP", [Group for HAL])


# Taken from dbus
AC_ARG_ENABLE([ansi],
	      AS_HELP_STRING([--enable-ansi],
			     [enable -ansi -pedantic gcc flags]),
	      [enable_ansi=$enableval], [enable_ansi=no])
AC_ARG_ENABLE([verbose-mode],
	      AS_HELP_STRING([--enable-verbose-mode],
			     [support verbose debug mode]),
	      [enable_verbose_mode=$enableval],
	      [enable_verbose_mode=$USE_MAINTAINER_MODE])
AC_ARG_ENABLE([docbook-docs],
	      AS_HELP_STRING([--enable-docbook-docs],
			     [build documentation (requires xmlto)]),
	      [enable_docbook_docs=$enableval], [enable_docbook_docs=no])
AC_ARG_ENABLE([man-pages],
	      AS_HELP_STRING([--enable-man-pages],
			     [build manual pages]),
	      [enable_man_pages=$enableval], [enable_man_pages=yes])
AM_CONDITIONAL(MAN_PAGES_ENABLED, [test x$enable_man_pages = xyes])
AC_SUBST(MAN_PAGES_ENABLED)

## eject 
AC_ARG_WITH([eject],
	    AS_HELP_STRING([--with-eject=<path>],
			   [Specify eject program. (default /usr/bin/eject)]))
if test -z "$with_eject"; then
  EJECT_PROGRAM=/usr/bin/eject
else
  EJECT_PROGRAM=$with_eject
fi
AC_SUBST(EJECT_PROGRAM)
AC_DEFINE_UNQUOTED(EJECT_PROGRAM, "$EJECT_PROGRAM", [Eject program to use])

GTK_DOC_CHECK([1.3])

# ACPI event source
AC_ARG_ENABLE([acpi-acpid],
	      AS_HELP_STRING([--disable-acpi-acpid],
			     [Do not use ACPI daemon event source]),
	      [acpi_acpid=$enableval], [acpi_acpid=yes])
if test "x$acpi_acpid" = "xyes" ; then
   AC_DEFINE(ACPI_ACPID,1,[Common event source of ACPI events])
fi
AC_SUBST(ACPI_ACPID)
AM_CONDITIONAL(ACPI_ACPID, [test x$acpi_acpid != xyes])

AC_ARG_ENABLE([acpi-proc],
	      AS_HELP_STRING([--disable-acpi-proc],
			     [Do not use ACPI kernel-interface directly]),
	      [acpi_proc=$enableval], [acpi_proc=yes])
if test "x$acpi_proc" = "xyes" ; then
   AC_DEFINE(ACPI_PROC,1,[Direct kernel connection for ACPI events, the kernel interface is exclusive to one user only])
fi
AC_SUBST(ACPI_PROC)
AM_CONDITIONAL(ACPI_PROC, [test x$acpi_proc = xyes])

AC_ARG_ENABLE([acpi-ibm],
	      AS_HELP_STRING([--enable-acpi-ibm], [Forward IBM ACPI events]),
	      [acpi_ibm=$enableval], [acpi_ibm=no])
BUILD_ACPI_IBM=no
if test "x$acpi_ibm" = "xyes" ; then
  AC_DEFINE(BUILD_ACPI_IBM,1,[catch and forward IBM ACPI hotkey and button events])
  BUILD_ACPI_IBM=yes
fi
AC_SUBST(BUILD_ACPI_IBM)
AM_CONDITIONAL(BUILD_ACPI_IBM, [test x$acpi_ibm = xyes])

AC_ARG_ENABLE([acpi-toshiba],
	      AS_HELP_STRING([--enable-acpi-toshiba],
			     [Forward Toshiba ACPI events]),
	      [acpi_toshiba=$enableval], [acpi_toshiba=no])
BUILD_ACPI_TOSHIBA=no
if test "x$acpi_toshiba" = "xyes" ; then
  AC_DEFINE(BUILD_ACPI_TOSHIBA,1,[catch and forward Toshiba ACPI hotkey and button events])
  BUILD_ACPI_TOSHIBA=yes
fi
AC_SUBST(BUILD_ACPI_TOSHIBA)
AM_CONDITIONAL(BUILD_ACPI_TOSHIBA, [test x$acpi_toshiba = xyes])


dnl libparted
AC_ARG_ENABLE([parted],
	      AS_HELP_STRING([--enable-parted], [Use libparted]),
	      [use_parted=$enableval], [use_parted=no])
if test "x$use_parted" = "xyes" ; then
  USE_PARTED=yes
  AC_DEFINE(USE_PARTED,1,[Whether libparted is to be used])
  AC_CHECK_LIB(uuid, uuid_generate, [], AC_MSG_ERROR([*** uuid library (libuuid) not found]))
  AC_CHECK_LIB(dl, dlopen,          [], AC_MSG_ERROR([*** dl library (libdl) not found]))

  AC_MSG_CHECKING([for libparted == 1.7.1 or >= 1.8.0])
  if ! $PKG_CONFIG --atleast-version 1.8.0 libparted; then
    LDFLAGS=-lparted
    AC_RUN_IFELSE([AC_LANG_SOURCE([[
      #include <stdio.h>
      #include <parted/parted.h>
      int main ()
      {  
	int major ;
	int minor ;
	int micro ;

	if ( sscanf( ped_get_version(), "%d.%d.%d", &major, &minor, &micro ) == 3 )
	  printf( "Found libparted %s", ped_get_version() ) ;

	if ((major == 1 && minor == 7 && micro == 1) ||
	    (major == 1 && minor == 8 && micro >= 0))
	  return 0;

	return 1;
      }
    ]])], AC_MSG_RESULT([]), AC_MSG_ERROR([*** Requires libparted == 1.7.1 or >= 1.8.0]))

    PARTED_LIBS=-lparted
    LDFLAGS=
  else
    PKG_CHECK_MODULES(PARTED, libparted)
  fi
  AC_SUBST(PARTED_LIBS)
else
   USE_PARTED=no
fi
AC_SUBST(USE_PARTED)
AM_CONDITIONAL(USE_PARTED, [test x$use_parted = xyes])


#### gcc linker flags

if test "x$GCC" = "xyes"; then
  LDFLAGS="-Wl,--as-needed $LDFLAGS"
fi

#### gcc warning flags

if test "x$GCC" = "xyes"; then
  changequote(,)dnl
  case " $CFLAGS " in
  *[\ \	]-Wall[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wall" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wchar-subscripts[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wchar-subscripts" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wmissing-declarations[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wmissing-declarations" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wnested-externs[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wnested-externs" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wpointer-arith[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wpointer-arith" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wcast-align[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wcast-align" ;;
  esac

  case " $CFLAGS " in
  *[\ \	]-Wsign-compare[\ \	]*) ;;
  *) CFLAGS="$CFLAGS -Wsign-compare" ;;
  esac

  if test "x$enable_ansi" = "xyes"; then
    case " $CFLAGS " in
    *[\ \	]-ansi[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -ansi" ;;
    esac

    case " $CFLAGS " in
    *[\ \	]-D_POSIX_C_SOURCE*) ;;
    *) CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=199309L" ;;
    esac

    case " $CFLAGS " in
    *[\ \	]-D_BSD_SOURCE[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -D_BSD_SOURCE" ;;
    esac

    case " $CFLAGS " in
    *[\ \	]-pedantic[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -pedantic" ;;
    esac
  fi
  if test x$enable_gcov = xyes; then
    case " $CFLAGS " in
    *[\ \	]-fprofile-arcs[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -fprofile-arcs" ;;
    esac
    case " $CFLAGS " in
    *[\ \	]-ftest-coverage[\ \	]*) ;;
    *) CFLAGS="$CFLAGS -ftest-coverage" ;;
    esac

    ## remove optimization
    CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
  fi
  changequote([,])dnl
else
  if test x$enable_gcov = xyes; then
    AC_MSG_ERROR([--enable-gcov can only be used with gcc])
  fi
fi

AM_CONDITIONAL(GCOV, [test x$enable_gcov = xyes])


EXPAT_LIB=""
AC_ARG_WITH([expat],
	    AS_HELP_STRING([--with-expat=<dir>],
			   [Use expat from here]),
	    [expat=$withval
	     CPPFLAGS="$CPPFLAGS -I$withval/include"
	     LDFLAGS="$LDFLAGS -L$withval/lib"])
AC_CHECK_HEADERS([expat.h], [AC_DEFINE(HAVE_EXPAT_H)],
		 [AC_MSG_ERROR([Can't find expat.h. Please install expat.])])
AC_CHECK_LIB([expat], [XML_ParserCreate], [EXPAT_LIB="-lexpat"],
	     [AC_MSG_ERROR([Can't find expat library. Please install expat.])])
AC_SUBST(EXPAT_LIB)

dnl Check libusb
AC_ARG_ENABLE([usb],
	      AS_HELP_STRING([--disable-usb], [Do not use libusb]),
	      [use_usb=$enableval], [use_usb=yes])
if test "x$use_usb" = "xyes" ; then
	AC_CHECK_HEADERS([usb.h], [USE_LIBUSB=yes], [USE_LIBUSB=no])
	if test "x$USE_LIBUSB" = "xyes"; then
		AC_CHECK_LIB([usb], [usb_find_devices], [USE_LIBUSB=yes], [USE_LIBUSB=no])
	fi
else
    	USE_LIBUSB=no
fi
AM_CONDITIONAL([HAVE_LIBUSB],[test "x$USE_LIBUSB" = "xyes"])

dnl Check for libsmbios
AC_ARG_ENABLE([smbios],
	      AS_HELP_STRING([--disable-smbios], [Do not use libsmbios]),
	      [use_smbios=$enableval], [use_smbios=yes])
if test "x$use_smbios" = "xyes" ; then
	AC_LANG_PUSH([C++])
	AC_CHECK_LIB([smbios], [SMBIOSFreeMemory], [LIB_SMBIOS=yes], [LIB_SMBIOS=no])
	AC_LANG_POP([C++])
	if test "$LIB_SMBIOS" = "yes" ; then
   		AC_MSG_CHECKING([for libsmbios >= 0.13.4])
   		LIBS="$LIBS -lsmbios"
   		AC_RUN_IFELSE([AC_LANG_SOURCE([[
   		#include <smbios/version.h>
   		int main ()
   		{
        		int major ;
        		int minor ;
        		int micro ;

        		if ( sscanf( LIBSMBIOS_RELEASE_VERSION , "%d.%d.%d", &major, &minor, &micro ) == 3 ) {
	    		    if ((major == 0 && minor == 13 && micro >= 4) ||
               		       (major == 0 && minor > 13) ||
               		       (major > 0)) {
			         return 0;
	    		    }
			}
			return 1;
   		}]])], [USE_SMBIOS=yes; AC_MSG_RESULT(yes); AM_CONDITIONAL(HAVE_SMBIOS,true)],
       		[USE_SMBIOS=no; AC_MSG_RESULT(failed); AM_CONDITIONAL(HAVE_SMBIOS,false)])
	else
  		USE_SMBIOS=no
  		AM_CONDITIONAL(HAVE_SMBIOS, [false])
	fi
	# yes this is ugly, but there is AFAIK no other way to check for getPasswordStatus()
	if test "x$USE_SMBIOS" = "xyes" ; then
   		AC_MSG_CHECKING([for libsmbios >= 2.0.3])
   		AC_RUN_IFELSE([AC_LANG_SOURCE([[
   		#include <smbios/version.h>
   		int main ()
   		{
        		int major ;
        		int minor ;
        		int micro ;

        		if ( sscanf( LIBSMBIOS_RELEASE_VERSION , "%d.%d.%d", &major, &minor, &micro ) == 3 ) {
	    		    if ((major == 2 && minor == 0 && micro >= 3) ||
               		       (major == 2 && minor > 0) ||
               		       (major > 2)) {
			         return 0;
	    		    }
			}
			return 1;
   		}]])], [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SMBIOS_2_0_3, 1 , [Set to 1 if we have libsmbios >= v2.0.3])],
       		[AC_MSG_RESULT(failed)])
	fi
	
else
    	USE_SMBIOS=no
	AM_CONDITIONAL(HAVE_SMBIOS, [false])
fi

AC_ARG_WITH([libpci],
	    AS_HELP_STRING([--without-libpci], [Compile without pci support]),
	    [], [with_libpci=yes])

USE_LIBPCI="no"
if test "x$with_libpci" != xno ; then
  dnl check for libpci
  AC_CHECK_HEADERS([pci/pci.h],
                   [AC_CHECK_LIB([pci], [pci_init], [USE_LIBPCI="yes"], [], [-lz])])
fi 
AM_CONDITIONAL([HAVE_LIBPCI], [test "x$USE_LIBPCI" = "xyes"])

AC_CHECK_HEADERS([linux/videodev.h], [have_videodev_h=yes], [])
AM_CONDITIONAL(HAVE_V4L1, [test "x$have_videodev_h" = "xyes"])

AC_ARG_WITH([backend],
	    AS_HELP_STRING([--with-backend=<name>],
	                   [backend to use (linux/solaris/freebsd/dummy)]),
	    [backend=$withval])
if ! test -z "$with_backend" ; then
    HALD_BACKEND="$with_backend"
else
    case "$host" in
        *-*-solaris*)
		   HALD_BACKEND="solaris"
		   ;;
        *-*-freebsd* | *-*-kfreebsd*-gnu)
                   HALD_BACKEND="freebsd"
                   ;;
	*-linux*)
		   HALD_BACKEND="linux"
      		   ;;
        *)
		   HALD_BACKEND="dummy"
		   ;;
    esac
fi
AM_CONDITIONAL(HALD_COMPILE_DUMMY, [test x$HALD_BACKEND = xdummy], [Compiling for Dummy backend])
AM_CONDITIONAL(HALD_COMPILE_LINUX, [test x$HALD_BACKEND = xlinux], [Compiling for Linux])
AM_CONDITIONAL(HALD_COMPILE_FREEBSD, [test x$HALD_BACKEND = xfreebsd], [Compiling for FreeBSD])
AM_CONDITIONAL(HALD_COMPILE_SOLARIS, [test x$HALD_BACKEND = xsolaris], [Compiling for Solaris])
AC_SUBST(HALD_BACKEND)
if test "x$HALD_BACKEND" = "xfreebsd"; then
    AC_SEARCH_LIBS([clock_gettime], [rt])
    LIBUFS_LIBS=""
    AC_CHECK_HEADERS([libufs.h],
		     [AC_CHECK_LIB([libufs], [ufs_disk_fillout], [USE_LIBUFS="yes"], [], [])])
    if test "x$USE_LIBUFS" = "xyes"; then
	AC_DEFINE(HAVE_LIBUFS, 1, [Set if we have libufs])
	LIBUFS_LIBS="-lufs"
	AC_SUBST(LIBUFS_LIBS)
    fi
    USE_BSDLIBUSB20=no
    USE_BSDLIBUSB=no
    LIBUSB20_LIBS=""
    AC_CHECK_LIB([usb20], [libusb20_dev_get_info], [USE_BSDLIBUSB20=yes], [USE_BSDLIBUSB20=no])
    if test "x$USE_BSDLIBUSB20" = "xno"; then
        AC_CHECK_LIB([usb], [libusb20_dev_get_info], [USE_BSDLIBUSB=yes], [USE_BSDLIBUSB=no])
    fi
    AM_CONDITIONAL([HAVE_LIBUSB20],[test "x$USE_BSDLIBUSB20" = "xyes" -o "x$USE_BSDLIBUSB" = "xyes"])
    if test "x$USE_BSDLIBUSB20" = "xyes"; then
        AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libusb20])
        LIBUSB20_LIBS="-lusb20"
    elif test "x$USE_BSDLIBUSB" = "xyes"; then
        AC_DEFINE(HAVE_LIBUSB20, 1, [Set if we need libsub20])
        LIBUSB20_LIBS="-lusb"
    fi
    AC_SUBST(LIBUSB20_LIBS)
else
    AM_CONDITIONAL([HAVE_LIBUSB20], [false])
fi

dnl DBUS API is subject to changes
AC_DEFINE_UNQUOTED(DBUS_API_SUBJECT_TO_CHANGE, [], [DBUS API is subject to change])

# check for ConsoleKit
AM_CONDITIONAL(HAVE_CONKIT, false)
AC_ARG_ENABLE([console-kit], AS_HELP_STRING([--enable-console-kit], [Use ConsoleKit]), [enable_console_kit=$enableval], [enable_console_kit=yes])
msg_conkit=no
if test "x$enable_console_kit" != "xno"; then
   AM_CONDITIONAL(HAVE_CONKIT, true)
   AC_DEFINE(HAVE_CONKIT, [], [Set if we use ConsoleKit])
   msg_conkit=yes
   # yes this is ugly, but there is no other way to get the version of CK 
   AC_MSG_CHECKING([if ConsoleKit version 0.3.0 or newer])
   if $PKG_CONFIG --atleast-version=0.3.0 ck-connector; then
     AC_MSG_RESULT([yes])
     AC_DEFINE(HAVE_CK_0_3, 1, [Define to 1 if ConsoleKit is v0.3.0 or newer])
   else 
     if $PKG_CONFIG --max-version=0.2.10 ck-connector; then
       AC_MSG_RESULT([no])
     else
       #assume we have the latest version
       AC_MSG_WARN([Couldn't detect ConsoleKit version, install the devel package, assume for now you use >= 0.3.0])
       AC_DEFINE(HAVE_CK_0_3, 1, [Define to 1 if ConsoleKit is v0.3.0 or newer])
     fi
   fi
fi

AC_PATH_PROG(GPERF, [gperf], [no])
AC_MSG_CHECKING([whether to rebuild gperf header files])
if test x$GPERF = xno ; then
    have_gperf=no
else
    have_gperf=yes
fi
AC_SUBST(HAVE_GPERF)
AM_CONDITIONAL(HAVE_GPERF, [test x$have_gperf = xyes])

AC_ARG_WITH([keymaps], AS_HELP_STRING([--with-keymaps], [Re-map multimedia keys (auto)]))
BUILD_KEYMAPS=no
if test "x$with_keymaps" = "xyes"; then
   if test "x$have_gperf" = "xyes"; then
      BUILD_KEYMAPS=yes
   else
      BUILD_KEYMAPS=no
   fi
elif test "x$with_keymaps" = "x" ; then
  case "${HALD_BACKEND}" in
    linux)
      if test "x$have_gperf" = "xyes"; then
        BUILD_KEYMAPS=yes
      else
        BUILD_KEYMAPS=no
      fi
      ;;
    *)
      ;;
  esac
fi
AM_CONDITIONAL(BUILD_KEYMAPS, [test x$BUILD_KEYMAPS = xyes])

# check for PolicyKit
AM_CONDITIONAL(HAVE_POLKIT, [false])
AC_ARG_ENABLE([policy-kit],
	      AS_HELP_STRING([--enable-policy-kit], [Use PolicyKit]),
	      [enable_policy_kit=$enableval], [enable_policy_kit=yes])
msg_polkit=no
if test "x$enable_policy_kit" != "xno"; then
   if test "x$enable_console_kit" = "xno"; then
      AC_MSG_ERROR([PolicyKit support requires building with ConsoleKit support too])
   fi
   PKG_CHECK_MODULES([POLKIT], [$polkit_module],
			[AM_CONDITIONAL(HAVE_POLKIT, [true])
			 AC_DEFINE(HAVE_POLKIT, [], [Set if we use PolicyKit])]
			[msg_polkit=yes],
			[AM_CONDITIONAL(HAVE_POLKIT, [false])])
   AC_SUBST(POLKIT_CFLAGS)
   AC_SUBST(POLKIT_LIBS)
   if test "x$msg_polkit" != "xyes"; then
      AC_MSG_ERROR([PolicyKit not explicitly disabled and no PolicyKit found])
   fi

   AC_CHECK_PROG([POLKIT_POLICY_FILE_VALIDATE],
		 [polkit-policy-file-validate], [polkit-policy-file-validate])
   if test -z "$POLKIT_POLICY_FILE_VALIDATE"; then
      AC_MSG_ERROR([polkit-policy-file-validate not found])
   fi
fi

# check for ACL handling
AM_CONDITIONAL(HAVE_ACLMGMT, [false])
AC_ARG_ENABLE([acl-management],
	      AS_HELP_STRING([--enable-acl-management], [ACL management]),
	      [enable_acl_management=$enableval],
	      [enable_acl_management=no])
msg_aclmgmt=no
if test "x$enable_acl_management" != "xno"; then
   if test "x$enable_policy_kit" = "xno"; then
      AC_MSG_ERROR([ACL management support requires building with PolicyKit support])
   fi
   AM_CONDITIONAL(HAVE_ACLMGMT, [true])
   AC_DEFINE(HAVE_ACLMGMT, [], [Set if we manage ACL's])
   msg_aclmgmt=yes
fi

# check for umount.hal
AM_CONDITIONAL(HAVE_UMOUNT_HAL, [false])
AC_ARG_ENABLE([umount-helper],
	      AS_HELP_STRING([--enable-umount-helper],
			     [Provide umount.hal helper]),
	      [enable_umount_hal=$enableval], [enable_umount_hal=no])
msg_umount_hal=no
if test "x$enable_umount_hal" != "xno"; then
   AM_CONDITIONAL(HAVE_UMOUNT_HAL, [true])
   AC_DEFINE(HAVE_UMOUNT_HAL, [],
             [Set if we should provide and use the /sbin/umount.hal helper])
   msg_umount_hal=yes
fi

# what extra hotplug backends to use (ACPI, APM, PMU etc)
AC_ARG_ENABLE([acpi],
	      AS_HELP_STRING([--disable-acpi], [Build without ACPI support]))
msg_acpi=no
if test "x$enable_acpi" != "xno"; then
	msg_acpi=yes
  	AC_DEFINE(HAVE_ACPI, [], [Set if we have ACPI support])
fi
AM_CONDITIONAL(HAVE_ACPI, [test x$msg_acpi = xyes], [Compiling ACPI])
AC_ARG_ENABLE([apm],
	      AS_HELP_STRING([--disable-apm], [Build without APM support]))
msg_apm=no
if test "x$enable_apm" != "xno"; then
	msg_apm=yes
  	AC_DEFINE(HAVE_APM, [], [Set if we have APM support])
fi
AM_CONDITIONAL(HAVE_APM, [test x$msg_apm = xyes], [Compiling APM])
AC_ARG_ENABLE([pmu],
	      AS_HELP_STRING([--disable-pmu], [Build without PMU support]))
msg_pmu=no
if test "x$enable_pmu" != "xno"; then
	msg_pmu=yes
  	AC_DEFINE(HAVE_PMU, [], [Set if we have PMU support])
fi
AM_CONDITIONAL(HAVE_PMU, [test x$msg_pmu = xyes], [Compiling PMU])

AC_ARG_ENABLE([pci],
	      AS_HELP_STRING([--disable-pci], [Build without PCI support]))
msg_pci=no
if test "x$enable_pci" != "xno"; then
	msg_pci=yes
 	AC_DEFINE(HAVE_PCI, [], [Set if we have PCI support])
fi

AC_ARG_WITH([deprecated-keys], AS_HELP_STRING([--with-deprecated-keys], [Add fdi-file to support deprecated/removed keys]))
BUILD_DEPRECATED_KEYS=no
if test "x$with_deprecated_keys" = "xyes"; then
   BUILD_DEPRECATED_KEYS=yes
else
   BUILD_DEPRECATED_KEYS=no
fi
AM_CONDITIONAL(BUILD_DEPRECATED_KEYS, [test x$BUILD_DEPRECATED_KEYS = xyes])

# D-Bus libs
PKG_CHECK_MODULES(DBUS, [$dbus_module])
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)

# glib libs
PKG_CHECK_MODULES(GLIB, [$glib_module])
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

AC_MSG_CHECKING([if GLib is version 2.14.0 or newer])
if $PKG_CONFIG --atleast-version=2.14.0 glib-2.0; then
  have_glib_2_14=yes
  AC_DEFINE(HAVE_GLIB_2_14, 1, [Define to 1 if GLib is version 2.14 or newer])
else
  have_glib_2_14=no
fi
AC_MSG_RESULT($have_glib_2_14)

case "$host" in
    *-*-freebsd*)
        PKG_CHECK_MODULES(VOLUME_ID, [$volume_id_module])
	AC_SUBST(VOLUME_ID_CFLAGS)
	AC_SUBST(VOLUME_ID_LIBS)
	;;
    *)
        ;;
esac

# blkid (util-linux-ng)
case "$host" in
*-*-freebsd*)
        ;;
*-*-solaris*)
	;;
*)
	PKG_CHECK_MODULES(BLKID, [$blkid_module])
	AC_SUBST(BLKID_CFLAGS)
	AC_SUBST(BLKID_LIBS)
esac

# OS specific libs
case "$host" in
*-*-solaris*)
	HALD_OS_LIBS="-lsysevent -lnvpair -ldevinfo"
	AC_SUBST(HALD_OS_LIBS)
	;;
esac

# Check for BLKGETSIZE64
AC_CHECK_TYPE([pgoff_t], [],
	      [AC_DEFINE([pgoff_t], [unsigned long], [Index into the pagecache])],
	      [/usr/include/sys/types.h])
AC_MSG_CHECKING([for BLKGETSIZE64])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#include <linux/ioctl.h>
#include <linux/fs.h>
]],
[[int main(int argc, char *argv[])
{
	int fd = 0;
	unsigned long long int n;
	ioctl (fd, BLKGETSIZE64, &n);
	return 0;
}
]])], [have_size64=yes], [have_size64=no])
AC_MSG_RESULT([$have_size64])
if test x$have_size64 = xno; then
  case "$host" in
        *-*-linux*)
	     AC_MSG_ERROR([BLKGETSIZE64 is not defined])
		;;
        *)
		;;
  esac
fi

AC_CHECK_FUNCS(getgrouplist)
AC_CHECK_FUNCS(asprintf)
AC_CHECK_FUNCS(mallopt)
AC_CHECK_FUNCS(strndup)

# DocBook Documentation

AC_PATH_PROG(XMLTO, [xmlto], [no])
AC_MSG_CHECKING([whether to build DocBook documentation])

if test x$XMLTO = xno ; then
    have_xmlto=no
else
    have_xmlto=yes
fi

AC_PATH_PROG(XMLLINT, [xmllint], [no])

if test x$XMLLINT = xno ; then
    have_xmllint=no
else
    have_xmllint=yes
fi

if test x$enable_docbook_docs = xauto ; then
    if test x$have_xmlto = xno || test x$have_xmllint = xno ; then
        enable_docbook_docs=no
    else
        enable_docbook_docs=yes
    fi
fi

if test x$enable_docbook_docs = xyes; then
    if test x$have_xmlto = xno; then
        AC_MSG_ERROR([Building DocBook docs explicitly required, but xmlto not found])
    fi
    if test x$ve_xmllint = xno; then
        AC_MSG_ERROR([Building DocBook docs explicitly required, but xmllint not found])
    fi
fi

AM_CONDITIONAL(DOCBOOK_DOCS_ENABLED, [test x$enable_docbook_docs = xyes])
AC_MSG_RESULT(yes)


AC_ARG_WITH([dbus-sys],
	    AS_HELP_STRING([--with-dbus-sys=<dir>],
			   [where D-BUS system.d directory is]))

if ! test -z "$with_dbus_sys" ; then
    DBUS_SYS_DIR="$with_dbus_sys"
else
    DBUS_SYS_DIR="$sysconfdir/dbus-1/system.d"
fi
AC_SUBST(DBUS_SYS_DIR)

#### Check our operating system (distro-tweaks required)
operating_system=unknown
if test -f /etc/redhat-release || test -f SYSCONFDIR/redhat-release ; then
   operating_system=redhat
fi

#### Sort out OS (distro-tweaks required)

if test x$with_os_type = x; then
    if test x$operating_system = xredhat ; then
        with_os_type=redhat
    else
        with_os_type=unknown
    fi
fi

# (distro-tweaks required)
AM_CONDITIONAL(OS_TYPE_UNKNOWN, [test x$with_os_type = xunknown], [Running on unknown OS])
AM_CONDITIONAL(OS_TYPE_RED_HAT, [test x$with_os_type = xredhat], [Running on Red Hat OS'es])

#### Set up the pid file (distro-tweaks required)
if ! test -z "$with_pid_file"; then
   HALD_PID_FILE=$with_pid_file
elif test x$with_os_type = xredhat ; then
   HALD_PID_FILE=${localstatedir}/run/haldaemon.pid
else
   HALD_PID_FILE=${localstatedir}/run/hald/pid
fi

AC_SUBST(HALD_PID_FILE)

if ! test -z "$with_socket_dir"; then
    HALD_SOCKET_DIR=$with_socket_dir
else
    HALD_SOCKET_DIR=${localstatedir}/run/hald
fi

AC_SUBST(HALD_SOCKET_DIR)

dnl
dnl SUBSETTING START
dnl

dnl macbookpro utils
AC_ARG_WITH([macbookpro],
            AS_HELP_STRING([--with-macbookpro],
                           [Whether to build Macbook Pro utils (auto)]))
BUILD_MACBOOKPRO=no
if test "x$with_macbookpro" = "xyes" ; then
   BUILD_MACBOOKPRO=yes
elif test "x$with_macbookpro" = "x" ; then
  if test "x$USE_LIBPCI" != "xno" ; then
    case "${HALD_BACKEND}" in
      linux)
        case "${host}" in
	  i[[3456]]86-*-*|x86_64-*-*)
            BUILD_MACBOOKPRO=yes
	    ;;
	  *)
	    ;;
	esac
        ;;
      *)
        ;;
    esac
   fi
fi
AM_CONDITIONAL(BUILD_MACBOOKPRO, [test x$BUILD_MACBOOKPRO = xyes])

dnl macbook backlight support
AC_ARG_WITH([macbook],
	    AS_HELP_STRING([--with-macbook],
			   [Include support for Macbook backlight (auto)]))
BUILD_MACBOOK=no
if test "x$with_macbook" = "xyes" ; then
   BUILD_MACBOOK=yes
elif test "x$with_macbook" = "x" ; then
  if test "x$USE_LIBPCI" != "xno" ; then
    case "${HALD_BACKEND}" in
      linux)
        case "${host}" in
	  i[[3456]]86-*-*|x86_64-*-*)
            BUILD_MACBOOK=yes
	    ;;
	  *)
	    ;;
	esac
        ;;
      *)
        ;;
    esac
   fi
fi
AM_CONDITIONAL(BUILD_MACBOOK, [test x$BUILD_MACBOOK = xyes])

dnl imac backlight
AC_ARG_WITH([imac],
            AS_HELP_STRING([--with-imac],
                           [Whether to build iMac (x86 only) backlight (auto)]))
BUILD_IMAC=no
if test "x$with_imac" = "xyes" ; then
   BUILD_IMAC=yes
elif test "x$with_imac" = "x" ; then
    case "${HALD_BACKEND}" in
      linux) 
        case "${host}" in
          i[[3456]]86-*-*|x86_64-*-*)
            BUILD_IMAC=yes
            ;;
          *)
            ;;
        esac
        ;;
      *)
        ;;
    esac
fi
AM_CONDITIONAL(BUILD_IMAC, [test x$BUILD_IMAC = xyes])

AC_ARG_WITH([omap],
	    AS_HELP_STRING([--with-omap],
			   [Whether to build OMAP utils (auto)]))
BUILD_OMAP=no
if test "x$with_omap" = "xyes" ; then
    BUILD_OMAP=yes
elif test "x$with_omap" = "x" ; then
    case "${HALD_BACKEND}" in
    linux)
	case "${host}" in
	arm*-*-*)
	    BUILD_OMAP=yes
	    ;;
	*)
	    ;;
	esac
	;;
    *)
	;;
    esac
fi
AM_CONDITIONAL(BUILD_OMAP, [test x$BUILD_OMAP = xyes])

dnl cpufreq
AC_ARG_WITH([cpufreq],
	    AS_HELP_STRING([--with-cpufreq],
			   [Whether to build cpufreq utils (auto)]))
BUILD_CPUFREQ=no
if test "x$with_cpufreq" = "xyes" ; then
   BUILD_CPUFREQ=yes
elif test "x$with_cpufreq" = "x" ; then
  case "${HALD_BACKEND}" in
    linux)
      BUILD_CPUFREQ=yes
      ;;
    *)
      ;;
  esac
fi
AM_CONDITIONAL(BUILD_CPUFREQ, [test x$BUILD_CPUFREQ = xyes])

dnl USB CSR (for reading battery of USB wireless mice)
AC_ARG_WITH([usb-csr],
	    AS_HELP_STRING([--with-usb-csr],
			   [Whether to build addon for wireless USB mice (auto)]))
BUILD_USBCSR=no
if test "x${USE_LIBUSB}" = "xyes" ; then
   if test "x$with_usb_csr" = "xyes" ; then
      BUILD_USBCSR=yes
   elif test "x$with_usb_csr" = "x" ; then
      #only automatically build for Linux
      if test "${HALD_BACKEND}" = "linux" ; then
         BUILD_USBCSR=yes
      fi
   fi
fi
AM_CONDITIONAL(BUILD_USBCSR, [test x$BUILD_USBCSR = xyes])

dnl Dell backlight 
AC_ARG_WITH([dell-backlight],
	    AS_HELP_STRING([--with-dell-backlight],
			   [Whether to build Dell backlight support (auto)]))
BUILD_DELL=no
if test "x$with_dell_backlight" = "xyes" ; then
   BUILD_DELL=yes
elif test "x$with_dell_backlight" = "x" ; then
  if test "$USE_SMBIOS" = "yes" ; then
    case "${HALD_BACKEND}" in
      linux)
        case "${host}" in
	  i*86-*-*|x86_64-*-*)
            BUILD_DELL=yes
	    ;;
	  *)
	    ;;
	esac
        ;;
      *)
        ;;
    esac
   fi
fi
AM_CONDITIONAL(BUILD_DELL, [test x$BUILD_DELL = xyes])

dnl Sony PIC support
AC_ARG_ENABLE(sonypic,
	      AS_HELP_STRING([--enable-sonypic], [Build with Sony PIC support]),
	      [case "${enableval}" in
	       yes) ENABLE_SONYPIC=yes ;;
	       no) ENABLE_SONYPIC=no ;;
	       *) AC_MSG_ERROR([bad value ${enableval} for --enable-sonypic]) ;;
	       esac
	      ], [ENABLE_SONYPIC=auto]) dnl Default value

have_sonypic=no
if test x$ENABLE_SONYPIC != "xno" ; then
	AC_COMPILE_IFELSE([
		#include <linux/sonypi.h>
		int main(int argc,char **argv) {
			return 0;
		}
	], [have_sonypic=yes])
	AC_MSG_CHECKING([for Sony PIC headers])
	AC_MSG_RESULT([$have_sonypic])

	if test "x$ENABLE_SONYPIC" = "xyes" && test "x$have_sonypic" != "xyes" ; then
		AC_MSG_ERROR([Sony PIC support explicitly requested but no support found])
	fi
fi
if test x"$have_sonypic" = "xyes" ; then
        AC_DEFINE(HAVE_SONYPIC, 1, [Set if we have Sony PIC support])
fi
msg_sonypic=$have_sonypic
AM_CONDITIONAL(HAVE_SONYPIC, [test x$msg_sonypic = xyes], [Compiling Sony PIC])

dnl use non-system input.h
AC_ARG_WITH([linux-input-header],
	    AS_HELP_STRING([--with-linux-input-header=<path>],
			   [Use an given Linux input.h rather than that installed on the system (<linux/input.h>)]))
if test "x$with_linux_input_header" != "x"; then
	AC_DEFINE_UNQUOTED(HAL_LINUX_INPUT_HEADER_H, "$with_linux_input_header", [If set, the header to use instead of <linux/input.h>])
	LINUX_INPUT_H=$with_linux_input_header
else
	LINUX_INPUT_H=/usr/include/linux/input.h
fi
AC_SUBST(LINUX_INPUT_H)

dnl
dnl SUBSETTING END
dnl

AC_CONFIG_HEADERS([config.h])

AC_CONFIG_FILES([
hal.pc
hal-storage.pc
hal.conf
Makefile
hald/Makefile
hald/dummy/Makefile
hald/linux/Makefile
hald/linux/probing/Makefile
hald/linux/addons/Makefile
hald/solaris/Makefile
hald/solaris/probing/Makefile
hald/solaris/addons/Makefile
hald/freebsd/Makefile
hald/freebsd/probing/Makefile
hald/freebsd/libprobe/Makefile
hald/freebsd/addons/Makefile
hald-runner/Makefile
libhal/Makefile
libhal-storage/Makefile
tools/Makefile
tools/freebsd/Makefile
tools/linux/Makefile
partutil/Makefile
policy/Makefile
fdi/Makefile
fdi/information/Makefile
fdi/information/10freedesktop/Makefile
fdi/information/20thirdparty/Makefile
fdi/policy/Makefile
fdi/policy/10osvendor/Makefile
fdi/policy/20thirdparty/Makefile
fdi/preprobe/Makefile
fdi/preprobe/10freedesktop/Makefile
fdi/preprobe/20thirdparty/Makefile
doc/Makefile
doc/api/Makefile
doc/api/libhal/Makefile
doc/api/libhal/version.xml
doc/api/libhal-storage/Makefile
doc/api/libhal-storage/version.xml
doc/spec/Makefile
doc/spec/hal-spec.xml.in
doc/man/Makefile
])

AC_OUTPUT

dnl ==========================================================================
echo "
                    HAL $VERSION
                  ==============

        prefix:                           ${prefix}
        libdir:                           ${libdir}
        libexecdir:                       ${libexecdir}
        bindir:                           ${bindir}
        sbindir:                          ${sbindir}
        datadir:                          ${datadir}
        sysconfdir:                       ${sysconfdir}
        localstatedir:                    ${localstatedir}
        docdir:                           ${docdir}
        dbus-1 system.d dir:              ${DBUS_SYS_DIR}
        pci.ids dir:                      ${PCI_IDS_DIR}
        usb.ids dir:                      ${USB_IDS_DIR}
	udev prefix:            	  ${udev_prefix}

        compiler:                         ${CC}
        cflags:                           ${CFLAGS}
        ldflags:                          ${LDFLAGS}
        cppflags:                         ${CPPFLAGS}
        xmlto:                            ${XMLTO}
        xmllint:                          ${XMLLINT}
        User for HAL:                     ${HAL_USER}
        Group for HAL:                    ${HAL_GROUP}
        hald pidfile:                     ${HALD_PID_FILE}
        hald socket dir:                  ${HALD_SOCKET_DIR}
        eject program:                    ${EJECT_PROGRAM}

        OS backend:                       ${HALD_BACKEND}

        use acpi kernel interface:        ${acpi_proc}
        use acpid interface:              ${acpi_acpid}
        use libusb:                       ${USE_LIBUSB}
        use libpci:                       ${USE_LIBPCI}
        use libparted:                    ${USE_PARTED}
        use gperf:                        ${have_gperf}
        use PolicyKit:                    ${msg_polkit}
        use ConsoleKit:                   ${msg_conkit}
        use ACL management:               ${msg_aclmgmt}
        use umount.hal helper:            ${msg_umount_hal}
        use ACPI:                         ${msg_acpi}
        use PMU:                          ${msg_pmu}
        use APM:                          ${msg_apm}
        use Sony PIC:                     ${msg_sonypic}

        Macbook backlight support:        ${BUILD_MACBOOK} (Linux only, x86 only, requires libpci)
        Macbook Pro utils:                ${BUILD_MACBOOKPRO} (Linux only, x86 only, requires libpci)
        iMac backlight support:           ${BUILD_IMAC} (Linux only, x86)
        OMAP utils:                       ${BUILD_OMAP} (Linux only, arm only)
        CPU frequency scaling:            ${BUILD_CPUFREQ} (Linux only)
        Re-map multimedia keys:           ${BUILD_KEYMAPS} (Linux only, requires gperf)
        Forward IBM ACPI events:          ${BUILD_ACPI_IBM} (Linux only)
        Forward Toshiba ACPI events:      ${BUILD_ACPI_TOSHIBA} (Linux only)
	USB wireless mouse power:         ${BUILD_USBCSR} (Linux only, requires libusb)
	Dell Backlight:                   ${BUILD_DELL} (Linux only, requires libsmbios >= 0.13.4)

	Support deprecated(removed) keys: ${BUILD_DEPRECATED_KEYS} (via a FDI-file)

        Maintainer mode:                  ${USE_MAINTAINER_MODE}
        Building verbose mode:            ${enable_verbose_mode}
        Building api docs:                ${enable_gtk_doc}
        Building docs:                    ${enable_docbook_docs}
        Building man pages:               ${enable_man_pages}
"

if test x${msg_polkit} = xno; then
   echo "WARNING: PolicyKit is disabled. You need to manually edit the hal.conf"
   echo "         file to lock down the service. Failure to do so allows any"
   echo "         caller to make hald do work on their behalf which may be"
   echo "         a huge SECURITY HOLE. I repeat: YOU NEED TO EDIT THE FILE"
   echo "         hal.conf to match your distro/site to avoid NASTY SECURITY HOLES."
   echo ""
fi

if test x$BUILD_ACPI_IBM = xyes; then
   echo "NOTE: Future Linux kernels may provide IBM ACPI events via a kernel."
   echo "      input device resulting in HAL emitting twice as many events as it"
   echo "      should. Make sure to rebuild HAL without --enable-acpi-ibm if"
   echo "      you use such a kernel."
   echo
fi

if test x$BUILD_ACPI_TOSHIBA = xyes; then
   echo "NOTE: Future Linux kernels may provide Toshiba ACPI events via a kernel."
   echo "      input device resulting in HAL emitting twice as many events as it"
   echo "      should. Make sure to rebuild HAL without --enable-acpi-toshiba if"
   echo "      you use such a kernel."
   echo
fi


if test x$enable_umount_hal = xyes; then
   echo "NOTE: Without a patched umount(8) --enable-umount-helper have no effect."
   echo "      See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=188193"
   echo "      for a suitable patch for util-linux. "
   echo
fi

if test x$enable_verbose_mode = xyes; then
   echo "NOTE: building with verbose mode increases library size, may slightly "
   echo "      increase security risk, and decreases performance."
   echo
fi

# (distro-tweaks required)
if test x$with_os_type = xredhat; then
   echo "NOTE: Red Hat style init scripts and policy will be installed"
else
   echo "NOTE: You have to install init scripts yourself and tweak your own policy"
fi
echo

echo "NOTE: Remember to create user ${HAL_USER} and group ${HAL_GROUP} before make install"
echo

echo "NOTE: For development, use run-hald.sh and debug-hald.sh scripts in hald/ to "
echo "      use programs (callouts, probers, addons) and device information files "
echo "      from build directories. You may still need 'make install' to"
echo "      install the udev rule to receive events from udev."
echo