~ssalley/ubuntu/maverick/likewise-open/likewise-open.fix627272

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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.59)
AC_INIT(lsass, 5.0.0, support@likewisesoftware.com)
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_MACRO_DIR([m4])

AM_CPPFLAGS=""
AM_CFLAGS=""
AM_LDFLAGS=""

COMPONENT_VERSION="5.0.0.0"

# Platform-specific stuff

MOD_EXT=".so"

# This note was originally in lsass/server/auth-providers/ad-provider/addef.h
# before the definition for the skeleton dirs on Darwin -- ssalley@likewise.com
#
#ISSUE-2008/10/03-dalmeida -- The only difference between this and the
# createhomedir utility is that the latter uses locale info and sets
# "AppleLocale" in ~/Library/Preferences/.GlobalPreferences.plist
# The latter is done by adding at the end of the <dict> section:
#
#   <key>AppleLocale</key>
#   <string>en_US</string>
#
# To determine the right thing to do wrt locale, verify createhomedir
# behavior wrt locale.
#
# Note that we must do the non-localized first then the localized to
# make sure that the localized files overwrite non-localized ones.
# This actually comes into play, at least on Mac OS X 10.5.
# Note that this does not handle ACLs (ls -le), which are normally
# present, at least on Mac OS X 10.5.  But the default ACLs do
# not appear to be useful.
default_skeldirs="/etc/skel"
default_homedir_prefix="/home"


CF_FRAMEWORK_LDFLAGS=""
SC_FRAMEWORK_LDFLAGS=""
DS_FRAMEWORK_LDFLAGS=""

AC_DEFINE(__LW_MOTD_FILE__, "/etc/motd", [File which contains the message of the day])
AC_DEFINE(__LW_MOTD_MAX_SIZE__, 4096, [The maximum number of bytes which will be displayed from the MOTD])

AC_USE_SYSTEM_EXTENSIONS

PLATFORM_AIX="false"

case "$host_os:$host_cpu" in
	linux*:i?86)
                echo "Detected Linux - i?86"
		nss_libdir="/lib"
		pam_libdir="/lib/security"
		NSS_SUBDIR="linux"
                ENABLE_NSS_ENUM_DEFAULT="no"
		AC_DEFINE([__LWI_LINUX__], [], [Define if OS is Linux])
		;;
	linux*:x86_64)
                echo "Detected Linux - x86_64"
		nss_libdir="/lib64"
		pam_libdir="/lib64/security"
		NSS_SUBDIR="linux"
                ENABLE_NSS_ENUM_DEFAULT="no"
		AC_DEFINE([__LWI_LINUX__], [], [Define if OS is Linux])
		;;
	linux*:s390*)
                echo "Detected Linux - s390*"
		nss_libdir="/lib64"
		pam_libdir="/lib64/security"
		NSS_SUBDIR="linux"
                ENABLE_NSS_ENUM_DEFAULT="no"
		AC_DEFINE([__LWI_LINUX__], [], [Define if OS is Linux])
		;;
	solaris*:i?86|solaris*:sparc*)
                echo "Detected Solaris SunOS"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/security"
		NSS_SUBDIR="solaris"
                ENABLE_NSS_ENUM_DEFAULT="no"
        default_homedir_prefix="/export/home"
		AC_DEFINE([__LWI_SOLARIS__], [], [Define if OS is Solaris])
		AC_DEFINE([_XOPEN_SOURCE], [500], [Define to desired XOPEN compliance level])
		;;
	darwin8.*:*)
                echo "Detected Mac OS X - Tiger"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/pam"
                NSS_SUBDIR="mac"
                ENABLE_NSS_ENUM_DEFAULT="yes"
        default_skeldirs="System/Library/User Template/Non_localized, /System/Library/User Template/English.lproj"
        default_homedir_prefix="/Users"
                CF_FRAMEWORK_LDFLAGS="-framework CoreFoundation"
                SC_FRAMEWORK_LDFLAGS="-framework SystemConfiguration"
                DS_FRAMEWORK_LDFLAGS="-framework DirectoryService"
		AC_DEFINE([__LWI_DARWIN__], [], [Define if OS is Darwin])
		;;
	darwin9.*:*)
                echo "Detected Mac OS X - Leopard"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/pam"
                NSS_SUBDIR="mac"
                ENABLE_NSS_ENUM_DEFAULT="yes"
        default_skeldirs="System/Library/User Template/Non_localized, /System/Library/User Template/English.lproj"
        default_homedir_prefix="/Users"
                CF_FRAMEWORK_LDFLAGS="-framework CoreFoundation"
                SC_FRAMEWORK_LDFLAGS="-framework SystemConfiguration"
                DS_FRAMEWORK_LDFLAGS="-framework DirectoryService"
		AC_DEFINE([__LWI_DARWIN__], [], [Define if OS is Darwin])
		;;
	darwin10.*:*)
                echo "Detected Mac OS X - Snow Leopard"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/pam"
                NSS_SUBDIR="mac"
                ENABLE_NSS_ENUM_DEFAULT="yes"
        default_skeldirs="System/Library/User Template/Non_localized, /System/Library/User Template/English.lproj"
        default_homedir_prefix="/Users"
                CF_FRAMEWORK_LDFLAGS="-framework CoreFoundation"
                SC_FRAMEWORK_LDFLAGS="-framework SystemConfiguration"
                DS_FRAMEWORK_LDFLAGS="-framework DirectoryService"
		AC_DEFINE([__LWI_DARWIN__], [], [Define if OS is Darwin - x64 Snow Leopard])
		AC_DEFINE([__LWI_DARWIN_X64__], [], [Define if OS is Darwin - x64 Snow Leopard])
		;;
	freebsd*:*)
                echo "Detected Free BSD OS"
		nss_libdir="/usr/local/lib"
		pam_libdir="/usr/local/lib"
		NSS_SUBDIR="freebsd"
                ENABLE_NSS_ENUM_DEFAULT="no"
		AC_DEFINE([__LWI_FREEBSD__], [], [Define if OS is FreeBSD])
		;;
	netbsd*:*)
                echo "Detected NetBSD OS"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/security"
		NSS_SUBDIR="freebsd"
                ENABLE_NSS_ENUM_DEFAULT="no"
		AC_DEFINE([__LWI_NETBSD__], [], [Define if OS is NetBSD])
		;;
	hpux*:hppa*)
                echo "Detected HPUX - hppa*"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/security"
		NSS_SUBDIR="hpux"
                ENABLE_NSS_ENUM_DEFAULT="no"
		NSS_SHR_EXT=""
		MOD_EXT=".sl"
		AC_SUBST(NSS_SHR_EXT)
		AC_DEFINE([__LWI_HP_UX__], [], [Define if OS is HP-UX])
        AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [Define on HP-UX])
		;;
	hpux*:ia64*)
                echo "Detected HPUX - ia64*"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/security"
		NSS_SUBDIR="hpux"
                ENABLE_NSS_ENUM_DEFAULT="no"
		NSS_SHR_EXT=".so"
		AC_SUBST(NSS_SHR_EXT)
		AC_DEFINE([__LWI_HP_UX__], [], [Define if OS is HP-UX])
        AC_DEFINE([_XOPEN_SOURCE_EXTENDED], [1], [Define on HP-UX])
		;;
	aix*:*)
                echo "Detected IBM AIX OS"
		nss_libdir="/usr/lib"
		pam_libdir="/usr/lib/security"
		NSS_SUBDIR="aix"
                ENABLE_NSS_ENUM_DEFAULT="no"
		NSS_SHR_EXT=""
		AC_SUBST(NSS_SHR_EXT)
		AC_DEFINE([__LWI_AIX__], [], [Define if OS is AIX])
                AC_DEFINE([_LINUX_SOURCE_COMPAT], [], [Enable Linux source compatibility on AIX])
		PLATFORM_AIX="true"
		;;
esac

AM_CONDITIONAL(PLATFORM_AIX, [$PLATFORM_AIX])

AC_SUBST(NSS_SUBDIR)
AC_SUBST(MOD_EXT)
AC_SUBST(default_skeldirs)
AC_SUBST(default_homedir_prefix)
AC_SUBST(CF_FRAMEWORK_LDFLAGS)
AC_SUBST(SC_FRAMEWORK_LDFLAGS)
AC_SUBST(DS_FRAMEWORK_LDFLAGS)
if test "$ENABLE_NSS_ENUM_DEFAULT" = "yes"
then
    ENABLE_NSS_ENUM_DEFAULT_DWORD="00000001"
else
    ENABLE_NSS_ENUM_DEFAULT_DWORD="00000000"
fi
AC_SUBST(ENABLE_NSS_ENUM_DEFAULT)
AC_SUBST(ENABLE_NSS_ENUM_DEFAULT_DWORD)

AC_DEFINE_UNQUOTED([MOD_EXT], ["$MOD_EXT"], [Extension of shared modules])
AC_DEFINE_UNQUOTED([ENABLE_NSS_ENUM_DEFAULT], ["$ENABLE_NSS_ENUM_DEFAULT"], [Default value for nss enumeration option])

# Package version

AC_ARG_WITH([version],
        [AC_HELP_STRING([--with-version=<comp-version>], [Component version <major>.<minor>.<build>.<revision>])],
        [
		COMPONENT_VERSION="$withval"
        ])
AC_DEFINE_UNQUOTED(COMPONENT_VERSION, "$COMPONENT_VERSION", [Component Version])

# lwreg

AC_ARG_WITH([lwreg],
        [AC_HELP_STRING([--with-lwreg=<dir>], [use lwreg located in prefix <dir>])],
        [
		LWREG_INCLUDES="-I$withval/include"
        LWREG_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([lwreg-includes],
        [AC_HELP_STRING([--with-lwreg-includes=<dir>], [use lwreg includes located in <dir>])],
        [
		LWREG_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([lwreg-libs],
        [AC_HELP_STRING([--with-lwreg-libs=<dir>], [use lwreg libs located in <dir>])],
        [
		LWREG_LDFLAGS="-L$withval"
        ])

LWREG_LIBS=-lregclient

# NSS and PAM

AC_ARG_WITH([nss-libdir],
        [AC_HELP_STRING([--with-nss-libdir=<dir>], [install nss modules into <dir>])],
        [
		nss_libdir="$withval"
        ])

AC_ARG_WITH([pam-libdir],
        [AC_HELP_STRING([--with-pam-libdir=<dir>], [install pam modules into <dir>])],
        [
		pam_libdir="$withval"
        ])

# krb5

AC_ARG_WITH([krb5],
        [AC_HELP_STRING([--with-krb5=<dir>], [use krb5 located in prefix <dir>])],
        [
		KRB5_INCLUDES="-I$withval/include"
                KRB5_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([krb5-includes],
        [AC_HELP_STRING([--with-krb5-includes=<dir>], [use krb5 includes located in <dir>])],
        [
		KRB5_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([krb5-libs],
        [AC_HELP_STRING([--with-krb5-libs=<dir>], [use krb5 libs located in <dir>])],
        [
		KRB5_LDFLAGS="-L$withval"
        ])

KRB5_LIBS="-lgssapi_krb5 -lkrb5 -lk5crypto"

AC_SUBST(KRB5_INCLUDES)
AC_SUBST(KRB5_LDFLAGS)
AC_SUBST(KRB5_LIBS)

# openldap

AC_ARG_WITH([openldap],
        [AC_HELP_STRING([--with-openldap=<dir>], [use openldap located in prefix <dir>])],
        [
		OPENLDAP_INCLUDES="-I$withval/include"
                OPENLDAP_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([openldap-includes],
        [AC_HELP_STRING([--with-openldap-includes=<dir>], [use openldap includes located in <dir>])],
        [
		OPENLDAP_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([openldap-libs],
        [AC_HELP_STRING([--with-openldap-libs=<dir>], [use openldap libs located in <dir>])],
        [
		OPENLDAP_LDFLAGS="-L$withval"
        ])

OPENLDAP_LIBS="-lldap_r -llber"

AC_SUBST(OPENLDAP_INCLUDES)
AC_SUBST(OPENLDAP_LDFLAGS)
AC_SUBST(OPENLDAP_LIBS)

# netapi

AC_ARG_WITH([netapi],
        [AC_HELP_STRING([--with-netapi=<dir>], [use netapi located in prefix <dir>])],
        [
		NETAPI_INCLUDES="-I$withval/include"
                NETAPI_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([netapi-includes],
        [AC_HELP_STRING([--with-netapi-includes=<dir>], [use netapi includes located in <dir>])],
        [
		NETAPI_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([netapi-libs],
        [AC_HELP_STRING([--with-netapi-libs=<dir>], [use netapi libs located in <dir>])],
        [
		NETAPI_LDFLAGS="-L$withval"
        ])

NETAPI_LIBS="-lnetapi"

AC_SUBST(NETAPI_INCLUDES)
AC_SUBST(NETAPI_LDFLAGS)
AC_SUBST(NETAPI_LIBS)

# libunistr

AC_ARG_WITH([libunistr],
        [AC_HELP_STRING([--with-libunistr=<dir>], [use libunistr located in prefix <dir>])],
        [
		LIBUNISTR_INCLUDES="-I$withval/include"
                LIBUNISTR_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([libunistr-includes],
        [AC_HELP_STRING([--with-libunistr-includes=<dir>], [use libunistr includes located in <dir>])],
        [
		LIBUNISTR_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([libunistr-libs],
        [AC_HELP_STRING([--with-libunistr-libs=<dir>], [use libunistr libs located in <dir>])],
        [
		LIBUNISTR_LDFLAGS="-L$withval"
        ])

LIBUNISTR_LIBS="-lunistr"

AC_SUBST(LIBUNISTR_INCLUDES)
AC_SUBST(LIBUNISTR_LDFLAGS)
AC_SUBST(LIBUNISTR_LIBS)

# lwmapsecurity

AC_ARG_WITH([lwmapsecurity],
        [AC_HELP_STRING([--with-lwmapsecurity=<dir>], [use lwmapsecurity located in prefix <dir>])],
        [
		LWMAPSECURITY_INCLUDES="-I$withval/include"
                LWMAPSECURITY_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([lwmapsecurity-includes],
        [AC_HELP_STRING([--with-lwmapsecurity-includes=<dir>], [use lwmapsecurity includes located in <dir>])],
        [
		LWMAPSECURITY_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([lwmapsecurity-libs],
        [AC_HELP_STRING([--with-lwmapsecurity-libs=<dir>], [use lwmapsecurity libs located in <dir>])],
        [
		LWMAPSECURITY_LDFLAGS="-L$withval"
        ])

LWMAPSECURITY_LIBS="-llwmapsecurity"

AC_SUBST(LWMAPSECURITY_INCLUDES)
AC_SUBST(LWMAPSECURITY_LDFLAGS)
AC_SUBST(LWMAPSECURITY_LIBS)

# lwmsg

AC_ARG_WITH([lwmsg],
        [AC_HELP_STRING([--with-lwmsg=<dir>], [use lwmsg located in prefix <dir>])],
        [
                LWMSG_INCLUDES="-I$withval/include"
                LWMSG_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([lwmsg-includes],
        [AC_HELP_STRING([--with-lwmsg-includes=<dir>], [use lwmsg includes located in <dir>])],
        [
                LWMSG_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([lwmsg-libs],
        [AC_HELP_STRING([--with-lwmsg-libs=<dir>], [use lwmsg libs located in <dir>])],
        [
                LWMSG_LDFLAGS="-L$withval"
        ])

# lwbase

AC_ARG_WITH([lwbase],
        [AC_HELP_STRING([--with-lwbase=<dir>], [use lwbase located in prefix <dir>])],
        [
		LWBASE_INCLUDES="-I$withval/include"
        LWBASE_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([lwbase-includes],
        [AC_HELP_STRING([--with-lwbase-includes=<dir>], [use lwbase includes located in <dir>])],
        [
		LWBASE_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([lwbase-libs],
        [AC_HELP_STRING([--with-lwbase-libs=<dir>], [use lwbase libs located in <dir>])],
        [
		LWBASE_LDFLAGS="-L$withval"
        ])

# crypto

AC_ARG_WITH([crypto],
        [AC_HELP_STRING([--with-crypto=<dir>], [use crypto located in prefix <dir>])],
        [
		CRYPTO_INCLUDES="-I$withval/include"
        CRYPTO_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([crypto-includes],
        [AC_HELP_STRING([--with-crypto-includes=<dir>], [use crypto includes located in <dir>])],
        [
		CRYPTO_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([crypto-libs],
        [AC_HELP_STRING([--with-crypto-libs=<dir>], [use crypto libs located in <dir>])],
        [
		CRYPTO_LDFLAGS="-L$withval"
        ])

CRYPTO_LIBS="-lcrypto"

AC_SUBST(CRYPTO_INCLUDES)
AC_SUBST(CRYPTO_LDFLAGS)
AC_SUBST(CRYPTO_LIBS)

# sqlite

AC_ARG_WITH([sqlite],
        [AC_HELP_STRING([--with-sqlite=<dir>], [use sqlite located in prefix <dir>])],
        [
		SQLITE_INCLUDES="-I$withval/include"
                SQLITE_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([sqlite-includes],
        [AC_HELP_STRING([--with-sqlite-includes=<dir>], [use sqlite includes located in <dir>])],
        [
		SQLITE_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([sqlite-libs],
        [AC_HELP_STRING([--with-sqlite-libs=<dir>], [use sqlite libs located in <dir>])],
        [
		SQLITE_LDFLAGS="-L$withval"
        ])

SQLITE_LIBS="-lsqlite3"

AC_SUBST(SQLITE_INCLUDES)
AC_SUBST(SQLITE_LDFLAGS)
AC_SUBST(SQLITE_LIBS)

# netlogon

AC_ARG_WITH([netlogon],
        [AC_HELP_STRING([--with-netlogon=<dir>], [use netlogon located in prefix <dir>])],
        [
		NETLOGON_INCLUDES="-I$withval/include"
                NETLOGON_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([netlogon-includes],
        [AC_HELP_STRING([--with-netlogon-includes=<dir>], [use netlogon includes located in <dir>])],
        [
		NETLOGON_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([netlogon-libs],
        [AC_HELP_STRING([--with-netlogon-libs=<dir>], [use netlogon libs located in <dir>])],
        [
		NETLOGON_LDFLAGS="-L$withval"
        ])

NETLOGON_LIBS="-llwnetclientapi"

AC_SUBST(NETLOGON_INCLUDES)
AC_SUBST(NETLOGON_LDFLAGS)
AC_SUBST(NETLOGON_LIBS)

# lwio

AC_ARG_WITH([lwio],
        [AC_HELP_STRING([--with-lwio=<dir>], [use lwio located in prefix <dir>])],
        [
                LWIO_INCLUDES="-I$withval/include"
        LWIO_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([lwio-includes],
        [AC_HELP_STRING([--with-lwio-includes=<dir>], [use lwio includes located in <dir>])],
        [
                LWIO_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([lwio-libs],
        [AC_HELP_STRING([--with-lwio-libs=<dir>], [use lwio libs located in <dir>])],
        [
                LWIO_LDFLAGS="-L$withval"
        ])

LWIO_LIBS="-llwioclient"

AC_SUBST(LWIO_INCLUDES)
AC_SUBST(LWIO_LDFLAGS)
AC_SUBST(LWIO_LIBS)

# lwadvapi

AC_ARG_WITH([lwadvapi],
        [AC_HELP_STRING([--with-lwadvapi=<dir>], [use lwadvapi located in prefix <dir>])],
        [
                LWADVAPI_INCLUDES="-I$withval/include"
                LWADVAPI_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([lwadvapi-includes],
        [AC_HELP_STRING([--with-lwadvapi-includes=<dir>], [use lwadvapi includes located in <dir>])],
        [
                LWADVAPI_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([lwadvapi-libs],
        [AC_HELP_STRING([--with-lwadvapi-libs=<dir>], [use lwadvapi libs located in <dir>])],
        [
                LWADVAPI_LDFLAGS="-L$withval"
        ])

LWADVAPI_LIBS="-llwadvapi"
LWADVAPI_NOTHR_LIBS="-llwadvapi_nothr"

AC_SUBST(LWADVAPI_INCLUDES)
AC_SUBST(LWADVAPI_LDFLAGS)
AC_SUBST(LWADVAPI_LIBS)
AC_SUBST(LWADVAPI_NOTHR_LIBS)

# pstore

AC_ARG_WITH([pstore],
        [AC_HELP_STRING([--with-pstore=<dir>], [use pstore located in prefix <dir>])],
        [
		PSTORE_INCLUDES="-I$withval/include"
                PSTORE_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([pstore-includes],
        [AC_HELP_STRING([--with-pstore-includes=<dir>], [use pstore includes located in <dir>])],
        [
		PSTORE_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([pstore-libs],
        [AC_HELP_STRING([--with-pstore-libs=<dir>], [use pstore libs located in <dir>])],
        [
		PSTORE_LDFLAGS="-L$withval"
        ])

PSTORE_LIBS="-llwpsapi"

AC_SUBST(PSTORE_INCLUDES)
AC_SUBST(PSTORE_LDFLAGS)
AC_SUBST(PSTORE_LIBS)

# eventlog

AC_ARG_WITH([eventlog],
        [AC_HELP_STRING([--with-eventlog=<dir>], [use eventlog located in prefix <dir>])],
        [
		EVENTLOG_INCLUDES="-I$withval/include"
        EVENTLOG_LDFLAGS="-L$withval/lib"
        ])

AC_ARG_WITH([eventlog-includes],
        [AC_HELP_STRING([--with-eventlog-includes=<dir>], [use eventlog includes located in <dir>])],
        [
		EVENTLOG_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([eventlog-libs],
        [AC_HELP_STRING([--with-eventlog-libs=<dir>], [use eventlog libs located in <dir>])],
        [
		EVENTLOG_LDFLAGS="-L$withval"
        ])

EVENTLOG_LIBS="-leventlog"

AC_SUBST(EVENTLOG_INCLUDES)
AC_SUBST(EVENTLOG_LDFLAGS)
AC_SUBST(EVENTLOG_LIBS)

# dcerpc

AC_ARG_WITH([dcerpc],
        [AC_HELP_STRING([--with-dcerpc=<dir>], [use dcerpc located in prefix <dir>])],
        [
		DCERPC_INCLUDES="-I$withval/include"
                DCERPC_LDFLAGS="-L$withval/lib"
                DCERPC_PATH="$withval/bin"
        ])

AC_ARG_WITH([dcerpc-includes],
        [AC_HELP_STRING([--with-dcerpc-includes=<dir>], [use dcerpc includes located in <dir>])],
        [
		DCERPC_INCLUDES="-I$withval"
        ])

AC_ARG_WITH([dcerpc-libs],
        [AC_HELP_STRING([--with-dcerpc-libs=<dir>], [use dcerpc libs located in <dir>])],
        [
		DCERPC_LDFLAGS="-L$withval"
        ])

DCERPC_LIBS="-ldcerpc"

AC_SUBST(DCERPC_INCLUDES)
AC_SUBST(DCERPC_LDFLAGS)
AC_SUBST(DCERPC_LIBS)

# minimal

AC_ARG_ENABLE([minimal], [AC_HELP_STRING([--enable-minimal], [build minimal lsass])])
AM_CONDITIONAL(ENABLE_MINIMAL, test x"$enable_minimal" = x"yes")
if test x"$enable_minimal" = x"yes"
then
        AC_DEFINE([ENABLE_MINIMAL], [], [Define if should build minimal lsass])
fi

# compat

ENABLE_COMPAT=false

AC_ARG_ENABLE([compat],
        [AC_HELP_STRING([--enable-compat], [enable compat-only build (default: disabled)])],
        [
                if test x"$enableval" = x"yes"
                then
			ENABLE_COMPAT=true
		else
			ENABLE_COMPAT=false
                fi
        ])

AM_CONDITIONAL(ENABLE_COMPAT, [$ENABLE_COMPAT])

# gss ntlm test provider

AC_ARG_ENABLE([testgssprovider],
        [AC_HELP_STRING([--enable-testgssprovider], [enable GSSNTLM test provider (default: disabled)])],
        [
                if test x"$enableval" = x"yes"
                then
		        	ENABLE_TESTGSSPROVIDER=true
		        	AC_DEFINE(ENABLE_TESTGSSPROVIDER, 1, [Define if the test gss provider must be included in runtime])
		        else
		        	ENABLE_TESTGSSPROVIDER=false
                fi
        ])

AM_CONDITIONAL(ENABLE_TESTGSSPROVIDER, [$ENABLE_TESTGSSPROVIDER])

AC_ARG_WITH([providers], [AC_HELP_STRING([--with-providers], [list of providers to build (ad local)])],
		       [], [with_providers="ad local"])

_IFS="${IFS}"
IFS=" ,"
for provider in $with_providers
do
	eval "enable_${provider}=yes"
done
IFS="${_IFS}"

AM_CONDITIONAL(ENABLE_AD, test x"$enable_ad" = x"yes")
if test x"$enable_ad" = x"yes"
then
	AC_DEFINE([ENABLE_AD], [], [Define if AD provider should be built])
fi

AM_CONDITIONAL(ENABLE_LOCAL, test x"$enable_local" = x"yes")
if test x"$enable_local" = x"yes"
then
	AC_DEFINE([ENABLE_LOCAL], [], [Define if local provider should be built])
fi

# Boolean settings

AC_ARG_ENABLE([static-providers], [AC_HELP_STRING([--enable-static-providers], [build providers directly into lsassd])])
AM_CONDITIONAL(ENABLE_STATIC_PROVIDERS, test x"$enable_static_providers" = x"yes")
if test x"$enable_static_providers" = x"yes"
then
	AC_DEFINE([ENABLE_STATIC_PROVIDERS], [], [Define if providers should be built directly into lsassd])
fi

AC_ARG_ENABLE([rpcserver], [AC_HELP_STRING([--enable-rpcserver], [build rpc server modules])],
              [], [enable_rpcserver="yes"])
AM_CONDITIONAL(ENABLE_RPCSERVER, test x"$enable_rpcserver" = x"yes")
if test x"$enable_rpcserver" = x"yes"
then
	AC_DEFINE([ENABLE_RPCSERVER], [], [Define if rpc server modules should be built])
fi

AC_ARG_ENABLE([static-rpcservers], [AC_HELP_STRING([--enable-static-rpcservers], [build rpc servers directly into lsassd])])
AM_CONDITIONAL(ENABLE_STATIC_RPCSERVERS, test x"$enable_static_rpcservers" = x"yes")
if test x"$enable_static_rpcservers" = x"yes"
then
	AC_DEFINE([ENABLE_STATIC_RPCSERVERS], [], [Define if rpc servers should be built directly into lsassd])
fi

AC_ARG_ENABLE([pidfile], [AC_HELP_STRING([--disable-pidfile], [disable pid file creation (default: enabled)])],
              [], [enable_pidfile="yes"])
if test x"$enable_pidfile" = x"yes"
then
	AC_DEFINE([ENABLE_PIDFILE], [], [Define if pid file should be created])
fi

AC_ARG_ENABLE([small-daemon], [AC_HELP_STRING([--enable-small-daemon], [build small lsassd])])
AM_CONDITIONAL(ENABLE_SMALL_DAEMON, test x"$enable_small_daemon" = x"yes")
if test x"$enable_small_daemon" = x"yes"
then
        AC_DEFINE([ENABLE_SMALL_DAEMON], [], [Define if lsassd should be small])
fi

# debugging

AC_ARG_ENABLE([debug],
        [AC_HELP_STRING([--enable-debug], [enable debugging (default: disabled)])],
        [
                if test x"$enableval" = x"yes"
                then
			AM_CFLAGS="$AM_CFLAGS -g -O0"
			AM_CPPFLAGS="$AM_CPPFLAGS -DDEBUG"			
                fi
        ])

AC_ARG_ENABLE([profiling],
        [AC_HELP_STRING([--enable-profiling], [enable profiling (default: disabled)])],
        [
                if test x"$enableval" = x"yes"
                then
			AM_CFLAGS="$AM_CFLAGS -fprofile-arcs -ftest-coverage"
			LDFLAGS="$LDFLAGS -fprofile-arcs -ftest-coverage"
                fi
        ])

CPPFLAGS="$CPPFLAGS -D_REENTRANT"

AM_CPPFLAGS="$AM_CPPFLAGS -I\$(top_srcdir)/include"
AM_CFLAGS="$AM_CFLAGS -Wall -Werror -fno-strict-aliasing"

AC_SUBST(AM_CPPFLAGS)
AC_SUBST(AM_CFLAGS)

lsassconfdir="$sysconfdir"
AC_SUBST(lsassconfdir)
AS_AC_EXPAND(CONFIGDIR, $lsassconfdir)
AC_DEFINE_UNQUOTED(CONFIGDIR, "$CONFIGDIR", [Config directory])

lsassregdir="$sysconfdir"
AC_SUBST(lsassregdir)


if test x"$localstatedir" = x"/var"; then
    lsasscachedir="$localstatedir/lib/likewise"
else
    lsasscachedir="$localstatedir"
fi
AC_SUBST(lsasscachedir)
AS_AC_EXPAND(CACHEDIR, $lsasscachedir)
AC_DEFINE_UNQUOTED(CACHEDIR, "$CACHEDIR", [Cache directory])

AS_AC_EXPAND(providerdir, $libdir)
AS_AC_EXPAND(rpcserverdir, $libdir)

AS_AC_EXPAND(SBINDIR, ["${sbindir}"])

testbindir='$(exec_prefix)/test'
AC_SUBST(testbindir)

testlibdir='$(exec_prefix)/test'
AC_SUBST(testlibdir)

AS_AC_EXPAND(PREFIXDIR, $prefix)
AC_DEFINE_UNQUOTED(PREFIXDIR, "$PREFIXDIR", [Prefix directory])

AS_AC_EXPAND(LIBDIR, $libdir)
AC_DEFINE_UNQUOTED(LIBDIR, "$LIBDIR", [Library directory])

AS_AC_EXPAND(pamlibdir, $pam_libdir)
AC_DEFINE_UNQUOTED(PAM_LIBDIR, "$pamlibdir", [PAM library directory])

AS_AC_EXPAND(nsslibdir, $nss_libdir)
AC_DEFINE_UNQUOTED(NSS_LIBDIR, "$nsslibdir", [NSS library directory])

AC_C_BIGENDIAN

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_LIBTOOL
AC_PROG_MKDIR_P

LW_USE_DOXYGEN([1.5.3])
AC_SUBST([DOXYGEN],[$DOXYGEN])
AM_CONDITIONAL([HAVE_DOXYGEN], [$HAVE_DOXYGEN])
AM_CONDITIONAL([HAVE_DOXYGEN_PDF], [$HAVE_DOXYGEN_PDF])

AC_CHECK_LIB([nsl], [gethostname], [NSL_LIBS="-lnsl"])
AC_CHECK_LIB([dl], [dlopen], [DL_LIBS="-ldl"])
AC_CHECK_LIB([resolv], [res_query], [RESOLV_LIBS="-lresolv"])
AC_CHECK_LIB([resolv], [__res_query], [RESOLV_LIBS="-lresolv"])
AC_CHECK_LIB([pthread], [pthread_self], [PTHREAD_LIBS="-lpthread"])
AC_CHECK_LIB([rt], [clock_settime], [RT_LIBS="-lrt"])
AC_CHECK_LIB([uuid], [uuid_copy], [UUID_LIBS="-luuid"])
AC_CHECK_LIB([socket], [bind], [SOCKET_LIBS="-lsocket"])
AC_CHECK_LIB([kvm], [kvm_open], [KVM_LIBS="-lkvm"])
AC_CHECK_LIB([proc], [openproc], [PROC_LIBS="-lproc"])

AC_CHECK_LIB([unistr], [mbstowc16s], [LIBUNISTR_LIBS="-lunistr"], [], [$LIBUNISTR_LDFLAGS])
AC_CHECK_LIB([crypto], [DES_set_key], [CRYPTO_LIBS="-lcrypto"], [], [$CRYPTO_LDFLAGS])
AC_CHECK_LIB([pam], [pam_start], [PAM_LIBS="-lpam"])

AC_SUBST(NSL_LIBS)
AC_SUBST(DL_LIBS)
AC_SUBST(RESOLV_LIBS)
AC_SUBST(PTHREAD_LIBS)
AC_SUBST(RT_LIBS)
AC_SUBST(UUID_LIBS)
AC_SUBST(SOCKET_LIBS)
AC_SUBST(PAM_LIBS)
AC_SUBST(KVM_LIBS)
AC_SUBST(PROC_LIBS)

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([inttypes.h arpa/inet.h fcntl.h limits.h netdb.h netinet/in.h])
AC_CHECK_HEADERS([stdint.h stdlib.h stdbool.h string.h strings.h sys/socket.h])
AC_CHECK_HEADERS([syslog.h unistd.h sys/types.h iconv.h sys/stat.h sys/pstat.h])
AC_CHECK_HEADERS([proc/readproc.h procfs.h sys/procfs.h kvm.h sys/utsname.h])
AC_CHECK_HEADERS([time.h sys/time.h sys/varargs.h sys/systeminfo.h])
AC_CHECK_HEADERS([nss.h nss_common.h nsswitch.h])
AC_CHECK_HEADERS([synch.h pthread.h wc16str.h wc16printf.h sys/param.h])
AC_CHECK_HEADERS([sys/sysctl.h sys/user.h pwd.h stdio.h grp.h sys/wait.h libgen.h])

AC_CHECK_HEADERS([security/pam_appl.h], ,
    [AC_CHECK_HEADERS([pam/pam_appl.h], ,
        [AC_MSG_ERROR([No PAM header files found])])])
AC_CHECK_HEADERS([execinfo.h sys/regset.h])

AC_PATH_PROG([IDL], [dceidl], [no], [$PATH:$DCERPC_PATH])

if test x"$IDL" = x"no" -a x"$ENABLE_COMPAT" = x"false"; then
    AC_MSG_ERROR([DCERPC IDL compiler not found])
fi

# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_HEADER_TIME
AC_STRUCT_TM

# Check for basic types
AC_CHECK_TYPES([int8, int16, int32, int64], [], [],
[#include <sys/types.h>
 #if __ia64
 #include <model.h>
 #endif])
AC_CHECK_TYPES([uint8, uint16, uint32, uint64])

AC_CHECK_TYPE(suseconds_t, [USEC_T="suseconds_t"], [USEC_T="long int"], [#include <sys/time.h>])
AC_DEFINE_UNQUOTED([USEC_T], [$USEC_T], [Type of tv_usec field of struct timeval])

AC_CHECK_SIZEOF([long long int])
AC_CHECK_SIZEOF([long int])

# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_SELECT_ARGTYPES
AC_TYPE_SIGNAL
AC_FUNC_STRFTIME
AC_FUNC_VPRINTF
AC_FUNC_STRERROR_R
old_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS $RT_LIBS"
AC_CHECK_FUNCS([atexit localtime_r memset select socket])
AC_CHECK_FUNCS([strtoll __strtoll strtoull __strtoull strtol strtoul])
AC_CHECK_FUNCS([strchr strerror strerror_r])
AC_CHECK_FUNCS([vsyslog rpl_realloc rpl_malloc])
AC_CHECK_FUNCS([clock_gettime clock_settime settimeofday gettimeofday timegm])
AC_CHECK_FUNCS([getgrouplist sysinfo backtrace])
LDFLAGS="$old_LDFLAGS"
AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
AC_CHECK_TYPES([wchar16_t], [], [], [AC_INCLUDES_DEFAULT
#ifdef HAVE_WC16STR_H
# include <wc16str.h>
#endif
])
AC_CHECK_MEMBERS([ucontext_t.uc_mcontext,
		  ucontext_t.uc_mcontext->__ss,
		  ucontext_t.uc_mcontext->__ss.__rip,
		  ucontext_t.uc_mcontext->__ss.__eip],
[], [], [AC_INCLUDES_DEFAULT
#ifdef HAVE_EXECINFO_H
# include <execinfo.h>
#endif
])

AC_CHECK_HEADER([reg/reg.h],,[AC_MSG_ERROR([Could not find lwreg headers])],
[[#include <stdarg.h>
]])
AC_SUBST(LWREG_INCLUDES)
AC_SUBST(LWREG_LDFLAGS)
AC_SUBST(LWREG_LIBS)

AC_CHECK_HEADER([lwmsg/lwmsg.h],,[AC_MSG_ERROR([Could not find lwmsg headers])])
AC_CHECK_LIB([lwmsg_nothr], [lwmsg_data_marshal], [LWMSG_NOTHR_LIBS="-llwmsg_nothr"], [AC_MSG_ERROR([Could not find liblwmsg_nothr])], [$LWMSG_LDFLAGS])
AC_CHECK_LIB([lwmsg], [lwmsg_peer_new], [LWMSG_LIBS="-llwmsg"], [AC_MSG_ERROR([Could not find liblwmsg])], [$LWMSG_LDFLAGS])

AC_SUBST(LWMSG_INCLUDES)
AC_SUBST(LWMSG_LDFLAGS)
AC_SUBST(LWMSG_NOTHR_LIBS)
AC_SUBST(LWMSG_LIBS)

AC_CHECK_HEADER([lw/base.h],,[AC_MSG_ERROR([Could not find lwbase headers])])
AC_CHECK_LIB([lwbase_nothr], [LwRtlMemoryAllocate], [LWBASE_NOTHR_LIBS="-llwbase_nothr"], [AC_MSG_ERROR([Could not find liblwbase_nothr])], [$LWBASE_LDFLAGS])
AC_CHECK_LIB([lwbase], [LwInterlockedIncrement], [LWBASE_LIBS="-llwbase"], [AC_MSG_ERROR([Could not find liblwbase])], [$LWBASE_LDFLAGS])

AC_SUBST(LWBASE_INCLUDES)
AC_SUBST(LWBASE_LDFLAGS)
AC_SUBST(LWBASE_NOTHR_LIBS)
AC_SUBST(LWBASE_LIBS)

AC_CHECK_TYPES([socklen_t], [], [], [AC_INCLUDES_DEFAULT
#include <sys/types.h>
#include <sys/socket.h>
])

AC_CHECK_TYPES([struct pam_repository], [], [], [AC_INCLUDES_DEFAULT
#include <security/pam_appl.h>
])

AC_CHECK_DECLS([PAM_BAD_ITEM], [], [], [AC_INCLUDES_DEFAULT
#include <security/pam_appl.h>
])

AC_CHECK_DECLS([kvm_open, kvm_getprocs], [], [], [
#if HAVE_FCNTL_H
#include <fcntl.h>
#endif
#if HAVE_KVM_H
#include <kvm.h>
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#if HAVE_SYS_USER_H
#include <sys/user.h>
#endif])

AC_CHECK_DECLS([isblank, pstat_getproc, KERN_PROC_PATHNAME], [], [], [
#include <ctype.h>
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif
#if HAVE_SYS_SYSCTL_H
#include <sys/sysctl.h>
#endif
#if HAVE_SYS_PSTAT_H
#include <sys/pstat.h>
#endif])

AC_CHECK_TYPES([struct psinfo], , , [
#if HAVE_PROCFS_H
#include <procfs.h>
#elif HAVE_SYS_PROCFS_H
#include <sys/procfs.h>
#endif
])

if test "$ac_cv_have_decl_pstat_getproc" = yes; then
AM_CPPFLAGS="$AM_CPPFLAGS -D_PSTAT64"
fi

saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Wall -Werror"

AC_MSG_CHECKING([if pthread_mutex_lock is available outside of libpthread])
AC_TRY_LINK_FUNC([pthread_mutex_lock], [
AC_MSG_RESULT([yes])
AC_DEFINE([HAVE_NONLIBPTHREAD_MUTEX_LOCK], [], [Define if pthread_mutex_lock is available outside of libpthread])],[
AC_MSG_RESULT([no])
])

AC_MSG_CHECKING([if getsockname takes socklen_t*])
AC_TRY_COMPILE([
#include <sys/types.h> 
#include <sys/socket.h>
],
[
int fd = -1;
struct sockaddr addr;
socklen_t addrlen;
(void) getsockname(fd, &addr, &addrlen);
], [
AC_MSG_RESULT([yes])
AC_DEFINE([GETSOCKNAME_TAKES_SOCKLEN_T], [], [Define if getsockname takes socklen_t as its third argument])],[
AC_MSG_RESULT([no])
])

case "$host_os:$host_cpu" in

    freebsd*:*|netbsd*:*)

        AC_MSG_CHECKING([if pam_get_data takes const void** as last argument])
        AC_TRY_COMPILE([
        #include <sys/types.h>
        #include <security/pam_appl.h>
        ],
        [
            const pam_handle_t * pamh = NULL;
            const char * module_data_name = NULL;
            const void * data = NULL;
            pam_get_data(pamh, module_data_name, &data);
        ], [
        AC_MSG_RESULT([yes])
        AC_DEFINE([PAM_GET_DATA_TAKES_CONST_DATA_ARG],
                  [],
            [Define if pam_get_data takes const void** as its third argument])],
            [AC_MSG_RESULT([no])])

        ;;

    *)
        ;;
esac

AC_MSG_CHECKING([if struct msghdr has msg_control])
AC_TRY_COMPILE([
#include <sys/types.h>
#include <sys/socket.h>
],
[
struct msghdr hdr;
hdr.msg_control = 0;
],
[
AC_MSG_RESULT([yes])
AC_DEFINE([MSGHDR_HAS_MSG_CONTROL], [], [Define if struct msghdr has the msg_control field])
],
[
AC_MSG_RESULT([no])
])

CFLAGS="$saved_CFLAGS"

AC_CONFIG_FILES([Makefile
                 common/Makefile
                 common/utils/Makefile
                 common/ipc/Makefile
                 common/ipc/api/Makefile
                 common/ipc/ad/Makefile
                 common/ipc/ntlm/Makefile
                 client/Makefile
                 client/api/Makefile
                 client/ad/Makefile
                 client/ntlm/Makefile
                 logging_r/Makefile
                 lsaunistr/Makefile
                 join/Makefile
                 interop/Makefile
                 interop/gssntlm/Makefile
                 interop/nsswitch/Makefile
                 interop/nsswitch/common/Makefile
                 interop/nsswitch/linux/Makefile
                 interop/nsswitch/freebsd/Makefile
                 interop/nsswitch/aix/Makefile
                 interop/nsswitch/hpux/Makefile
                 interop/nsswitch/solaris/Makefile
                 interop/nsswitch/mac/Makefile
                 interop/lwmapsecurity/Makefile
                 server/Makefile
                 server/api/Makefile
                 server/ntlm/Makefile
                 server/auth-providers/Makefile
                 server/auth-providers/ad-provider/addef.h
                 server/auth-providers/ad-provider/Makefile
                 server/auth-providers/local-provider/lpdefs.h
                 server/auth-providers/local-provider/Makefile
                 server/lsassd/Makefile
                 server/rpc/Makefile
                 server/rpc/lsa/Makefile
                 server/rpc/samr/Makefile
                 server/rpc/dssetup/Makefile
                 server/store/Makefile
                 server/store/samdb/Makefile
                 server/store/dsapi/Makefile
                 server/store/dsapi/dirdefs.h
                 interop/access/Makefile
                 interop/auth/Makefile
                 interop/auth/common/Makefile
                 interop/auth/pam/Makefile
                 interop/wbclient/Makefile
                 interop/lwicompat/Makefile
                 tools/Makefile
                 tools/lw-lsa/Makefile
                 etc/Makefile
                 etc/lsassd.reg
                 include/lsaregdef.h
                 include/Makefile
                 tests/Makefile
                 tests/test_headers/Makefile
                 tests/lsaclient/Makefile
                 tests/test_getgrgid/Makefile
                 tests/test_getpwuid/Makefile
                 tests/test_LsaGetNamesBySidList/Makefile
                 tests/test_getgrnam/Makefile
                 tests/test_LsaAllocSecurityIdentifierFromBinary/Makefile
                 tests/test_LsaGetSecurityIdentifierHashedRid/Makefile
                 tests/test_LsaAllocSecurityIdentifierFromString/Makefile
                 tests/test_getpwent/Makefile
                 tests/test_getpwnam/Makefile
                 tests/test_bitvector/Makefile
                 tests/test_memcache/Makefile
                 tests/test_perf/Makefile
                 tests/test_perf/lsassonly/Makefile
                 tests/test_authenticate/Makefile
                 tests/test_validate/Makefile
                 tests/test_changepasswd/Makefile
                 tests/test_session/Makefile
                 tests/test_checkuserinlist/Makefile
                 tests/test_openldap/Makefile
                 tests/ntlmapps/Makefile
                 tests/ntlmapps/ntlmclient/Makefile
                 tests/ntlmapps/ntlmserver/Makefile
                 scripts/Makefile
                 docs/Makefile
                 docs/Doxyfile])

AC_OUTPUT