File: netatalk.m4

package info (click to toggle)
netatalk 3.1.12~ds-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 14,756 kB
  • sloc: ansic: 104,976; sh: 8,247; xml: 7,394; perl: 1,936; makefile: 1,430; python: 1,342; yacc: 309; lex: 49
file content (1273 lines) | stat: -rw-r--r-- 41,254 bytes parent folder | download
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
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
dnl Kitchen sink for configuration macros

dnl Check for docbook
AC_DEFUN(AX_CHECK_DOCBOOK, [
  # It's just rude to go over the net to build
  XSLTPROC_FLAGS=--nonet
  DOCBOOK_ROOT=
  XSLTPROC_WORKS=no

  AC_ARG_WITH(docbook,
    AS_HELP_STRING(
      [--with-docbook],
      [Path to Docbook XSL directory]
    ),
    [DOCBOOK_ROOT=$withval]
  )

  if test -n "$DOCBOOK_ROOT" ; then
    AC_CHECK_PROG(XSLTPROC,xsltproc,xsltproc,)
    if test -n "$XSLTPROC"; then
      AC_MSG_CHECKING([whether xsltproc works])
      DB_FILE="$DOCBOOK_ROOT/html/docbook.xsl"
      $XSLTPROC $XSLTPROC_FLAGS $DB_FILE >/dev/null 2>&1 << END
<?xml version="1.0" encoding='ISO-8859-1'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN" "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<book id="test">
</book>
END
      if test "$?" = 0; then
        XSLTPROC_WORKS=yes
      fi
      AC_MSG_RESULT($XSLTPROC_WORKS)
    fi
  fi

  AC_MSG_CHECKING([whether to build Docbook documentation])
  AC_MSG_RESULT($XSLTPROC_WORKS)

  AM_CONDITIONAL(HAVE_XSLTPROC, test x"$XSLTPROC_WORKS" = x"yes")
  AC_SUBST(XSLTPROC_FLAGS)
  AC_SUBST(DOCBOOK_ROOT)
  AC_SUBST(XSLTPROC)
])

dnl Check for dtrace
AC_DEFUN([AC_NETATALK_DTRACE], [
  AC_ARG_WITH(dtrace,
    AS_HELP_STRING(
      [--with-dtrace],
      [Enable dtrace probes (default: enabled if dtrace found)]
    ),
    [WDTRACE=$withval],
    [WDTRACE=auto]
  )
  if test "x$WDTRACE" = "xyes" -o "x$WDTRACE" = "xauto" ; then
    AC_CHECK_PROG([atalk_cv_have_dtrace], [dtrace], [yes], [no])
    if test "x$atalk_cv_have_dtrace" = "xno" ; then
      if test "x$WDTRACE" = "xyes" ; then
        AC_MSG_FAILURE([dtrace requested but not found])
      fi
      WDTRACE="no"
    else
      WDTRACE="yes"
    fi
  fi

  if test x"$WDTRACE" = x"yes" ; then
    AC_DEFINE([WITH_DTRACE], [1], [dtrace probes])
    DTRACE_LIBS=""
    if test x"$this_os" = x"freebsd" ; then
      DTRACE_LIBS="-lelf"
    fi
    AC_SUBST(DTRACE_LIBS)
  fi
  AM_CONDITIONAL(WITH_DTRACE, test "x$WDTRACE" = "xyes")
])

dnl Check for dbus-glib, for AFP stats
AC_DEFUN([AC_NETATALK_DBUS_GLIB], [
  atalk_cv_with_dbus=no

  AC_ARG_WITH(afpstats,
    AS_HELP_STRING(
      [--with-afpstats],
      [Enable AFP statistics via dbus (default: enabled if dbus found)]
    ),,[withval=auto]
  )

  if test x"$withval" != x"no" ; then
    PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.1, have_dbus=yes, have_dbus=no)
    PKG_CHECK_MODULES(DBUS_GLIB, dbus-glib-1, have_dbus_glib=yes, have_dbus_glib=no)
    PKG_CHECK_MODULES(DBUS_GTHREAD, gthread-2.0, have_dbus_gthread=yes, have_dbus_gthread=no)
    if test x$have_dbus_glib = xyes -a x$have_dbus = xyes -a x$have_dbus_gthread = xyes ; then
        saved_CFLAGS=$CFLAGS
        saved_LIBS=$LIBS
        CFLAGS="$CFLAGS $DBUS_GLIB_CFLAGS"
        LIBS="$LIBS $DBUS_GLIB_LIBS"
        AC_CHECK_FUNC([dbus_g_bus_get_private], [atalk_cv_with_dbus=yes], [atalk_cv_with_dbus=no])
        CFLAGS="$saved_CFLAGS"
        LIBS="$saved_LIBS"
    fi
  fi

  if test x"$withval" = x"yes" -a x"$atalk_cv_with_dbus" = x"no"; then
    AC_MSG_ERROR([afpstats requested but dbus-glib not found])
  fi

  AC_ARG_WITH(
      dbus-sysconf-dir,
      [AS_HELP_STRING([--with-dbus-sysconf-dir=PATH],[Path to dbus system bus security configuration directory (default: ${sysconfdir}/dbus-1/system.d/)])],
      ac_cv_dbus_sysdir=$withval,
      ac_cv_dbus_sysdir='${sysconfdir}/dbus-1/system.d'
  )
  DBUS_SYS_DIR=""
  if test x$atalk_cv_with_dbus = xyes ; then
      AC_DEFINE(HAVE_DBUS_GLIB, 1, [Define if support for dbus-glib was found])
      DBUS_SYS_DIR="$ac_cv_dbus_sysdir"
  fi

  AC_SUBST(DBUS_SYS_DIR)
  AC_SUBST(DBUS_CFLAGS)
  AC_SUBST(DBUS_LIBS)
  AC_SUBST(DBUS_GLIB_CFLAGS)
  AC_SUBST(DBUS_GLIB_LIBS)
  AC_SUBST(DBUS_GTHREAD_CFLAGS)
  AC_SUBST(DBUS_GTHREAD_LIBS)
  AM_CONDITIONAL(HAVE_DBUS_GLIB, test x$atalk_cv_with_dbus = xyes)
])

dnl Whether to enable developer build
AC_DEFUN([AC_DEVELOPER], [
    AC_MSG_CHECKING([whether to enable developer build])
    AC_ARG_ENABLE(
        developer,
        AS_HELP_STRING([--enable-developer], [whether to enable developer build (ABI checking)]),
        enable_dev=$enableval,
        enable_dev=no
    )
    AC_MSG_RESULT([$enable_dev])
    AM_CONDITIONAL(DEVELOPER, test x"$enable_dev" = x"yes")
])

dnl Tracker, for Spotlight
AC_DEFUN([AC_NETATALK_SPOTLIGHT], [
    ac_cv_have_tracker=no
    ac_cv_tracker_pkg_version_default=0.12
    ac_cv_tracker_pkg_version_min=0.12

    dnl Tracker SPARQL
    AC_ARG_WITH([tracker-pkgconfig-version],
      [AS_HELP_STRING([--with-tracker-pkgconfig-version=VERSION],[Version suffix of the Tracker SPARQL pkg-config (default: 0.12)])],
      [ac_cv_tracker_pkg_version=$withval],
      [ac_cv_tracker_pkg_version=$ac_cv_tracker_pkg_version_default]
    )

    AC_ARG_WITH([tracker-prefix],
      [AS_HELP_STRING([--with-tracker-prefix=PATH],[Prefix of Tracker (default: none)])],
      [ac_cv_tracker_prefix=$withval],
      [ac_cv_tracker_prefix="`pkg-config --variable=prefix tracker-sparql-$ac_cv_tracker_pkg_version`"]
    )

    AC_ARG_WITH([tracker-install-prefix],
      [AS_HELP_STRING([--with-tracker-install-prefix=PATH],[Install prefix for Tracker (default: none)])],
      [ac_cv_tracker_install_prefix=$withval],
      [ac_cv_tracker_install_prefix=$ac_cv_tracker_prefix]
    )

    AC_ARG_WITH([dbus-daemon],
      [AS_HELP_STRING([--with-dbus-daemon=PATH],[Path to DBus daemon (default: /bin/dbus-daemon)])],
      [ac_cv_dbus_daemon=$withval],
      [ac_cv_dbus_daemon=/bin/dbus-daemon]
    )
    DBUS_DAEMON_PATH=$ac_cv_dbus_daemon

    AC_ARG_VAR([PKG_CONFIG_PATH], [Path to additional pkg-config packages])
    PKG_CHECK_MODULES([TRACKER], [tracker-sparql-$ac_cv_tracker_pkg_version >= $ac_cv_tracker_pkg_version_min], [ac_cv_have_tracker_sparql=yes], [ac_cv_have_tracker_sparql=no])

    if test x"$ac_cv_have_tracker_sparql" = x"no" ; then
        if test x"$need_tracker_sparql" = x"yes" ; then
            AC_MSG_ERROR([$ac_cv_tracker_pkg not found])
        fi
    else
        ac_cv_have_tracker=yes
        AC_DEFINE(HAVE_TRACKER, 1, [Define if Tracker is available])
        AC_DEFINE_UNQUOTED(TRACKER_PREFIX, ["$ac_cv_tracker_install_prefix"], [Path to Tracker])
        AC_DEFINE_UNQUOTED([DBUS_DAEMON_PATH], ["$ac_cv_dbus_daemon"], [Path to dbus-daemon])
    fi

    dnl Tracker Managing Command
    if test x"$ac_cv_have_tracker" = x"yes" ; then
        AC_CHECK_PROGS(ac_cv_tracker_manage, tracker tracker-control, , ["$ac_cv_tracker_prefix"/bin])
        if test x"$ac_cv_tracker_manage" = x"tracker" ; then
           TRACKER_MANAGING_COMMAND="tracker daemon"
           AC_DEFINE(TRACKER_MANAGING_COMMAND, "tracker daemon", [tracker managing command])
        elif test x"$ac_cv_tracker_manage" = x"tracker-control" ; then
           TRACKER_MANAGING_COMMAND="tracker-control"
           AC_DEFINE(TRACKER_MANAGING_COMMAND, "tracker-control", [tracker managing command])
        else
           AC_MSG_ERROR([could find neither tracker command nor tracker-control command])
        fi
    fi

    AC_SUBST(TRACKER_CFLAGS)
    AC_SUBST(TRACKER_LIBS)
    AC_SUBST(TRACKER_MINER_CFLAGS)
    AC_SUBST(TRACKER_MINER_LIBS)
    AC_SUBST(DBUS_DAEMON_PATH)
    AM_CONDITIONAL(HAVE_TRACKER, [test x"$ac_cv_have_tracker" = x"yes"])
])

dnl Whether to disable bundled libevent
AC_DEFUN([AC_NETATALK_LIBEVENT], [
    AC_MSG_CHECKING([whether to use bundled libevent])
    AC_ARG_WITH(
        libevent,
        [AS_HELP_STRING([--with-libevent],[whether to use the bundled libevent (default: yes)])],
        use_bundled_libevent=$withval,
        use_bundled_libevent=yes
    )
    AC_ARG_WITH(
        libevent-header,
        [AS_HELP_STRING([--with-libevent-header],[path to libevent header files])],
        [use_bundled_libevent=no; LIBEVENT_CFLAGS=-I$withval]
    )
    AC_ARG_WITH(
        libevent-lib,
        [AS_HELP_STRING([--with-libevent-lib],[path to libevent library])],
        [use_bundled_libevent=no; LIBEVENT_LDFLAGS=-L$withval]
    )
    if test x"$LIBEVENT_CFLAGS" = x"-Iyes" -o x"$LIBEVENT_LDFLAGS" = x"-Lyes" ; then
        AC_MSG_ERROR([--with-libevent requires a path])
    fi
    AC_MSG_RESULT([$use_bundled_libevent])
    if test x"$use_bundled_libevent" = x"yes" ; then
        AC_CONFIG_SUBDIRS([libevent])
    fi
    AC_SUBST(LIBEVENT_CFLAGS)
    AC_SUBST(LIBEVENT_LDFLAGS)
    AM_CONDITIONAL(USE_BUILTIN_LIBEVENT, test x"$use_bundled_libevent" = x"yes")
])

dnl Whether to disable bundled tdb
AC_DEFUN([AC_NETATALK_TDB], [
    AC_ARG_WITH(
        tdb,
        [AS_HELP_STRING([--with-tdb],[whether to use the bundled tdb (default: yes)])],
        use_bundled_tdb=$withval,
        use_bundled_tdb=yes
    )
    AC_MSG_CHECKING([whether to use bundled tdb])
    AC_MSG_RESULT([$use_bundled_tdb])

    if test x"$use_bundled_tdb" = x"yes" ; then
        AC_DEFINE(USE_BUILTIN_TDB, 1, [Use internal tbd])
    else
        if test -z "$TDB_LIBS" ; then
            PKG_CHECK_MODULES(TDB, tdb, , [AC_MSG_ERROR([couldn't find tdb with pkg-config])])
        fi
        use_bundled_tdb=no
    fi        

    AC_SUBST(TDB_CFLAGS)
    AC_SUBST(TDB_LIBS)
    AM_CONDITIONAL(USE_BUILTIN_TDB, test x"$use_bundled_tdb" = x"yes")
])

dnl Whether to disable bundled talloc
AC_DEFUN([AC_NETATALK_TALLOC], [
    AC_ARG_WITH(
        talloc,
        [AS_HELP_STRING([--with-talloc],[whether to use the bundled talloc (default: yes)])],
        use_bundled_talloc=$withval,
        use_bundled_talloc=yes
    )
    AC_MSG_CHECKING([whether to use bundled talloc])
    AC_MSG_RESULT([$use_bundled_talloc])

    if test x"$use_bundled_talloc" = x"yes" ; then
        AC_DEFINE(USE_BUILTIN_TALLOC, 1, [Use internal talloc])
    else
        if test -z "$TALLOC_LIBS" ; then
            PKG_CHECK_MODULES(TALLOC, talloc, , [AC_MSG_ERROR([couldn't find talloc with pkg-config])])
        fi
        use_bundled_talloc=no
    fi

    AC_SUBST(TALLOC_CFLAGS)
    AC_SUBST(TALLOC_LIBS)
    AM_CONDITIONAL(USE_BUILTIN_TALLOC, test x"$use_bundled_talloc" = x"yes")
])

dnl Filesystem Hierarchy Standard (FHS) compatibility
AC_DEFUN([AC_NETATALK_FHS], [
AC_MSG_CHECKING([whether to use Filesystem Hierarchy Standard (FHS) compatibility])
AC_ARG_ENABLE(fhs,
	[  --enable-fhs            use Filesystem Hierarchy Standard (FHS) compatibility],[
	if test "$enableval" = "yes"; then
		bindir="/bin"
		sbindir="/sbin"
		sysconfdir="/etc"
		libdir="/lib"
		localstatedir="/var"
		mandir="/usr/share/man"
		uams_path="${libdir}/netatalk"
		PKGCONFDIR="${sysconfdir}"
		SERVERTEXT="${localstatedir}/netatalk/msg"
		use_pam_so=yes
		AC_DEFINE(FHS_COMPATIBILITY, 1, [Define if you want compatibily with the FHS])
		AC_MSG_RESULT([yes])
        atalk_cv_fhs_compat=yes
	else
		AC_MSG_RESULT([no])
        atalk_cv_fhs_compat=no
	fi
	],[
		AC_MSG_RESULT([no])
        atalk_cv_fhs_compat=no
])])

dnl netatalk lockfile path
AC_DEFUN([AC_NETATALK_LOCKFILE], [
    AC_MSG_CHECKING([netatalk lockfile path])
    AC_ARG_WITH(
        lockfile,
        [AS_HELP_STRING([--with-lockfile=PATH],[Path of netatalk lockfile])],
        ac_cv_netatalk_lock=$withval,
        ac_cv_netatalk_lock=""
    )
    if test -z "$ac_cv_netatalk_lock" ; then
        ac_cv_netatalk_lock=/var/spool/locks/netatalk
        if test x"$atalk_cv_fhs_compat" = x"yes" ; then
            ac_cv_netatalk_lock=/var/run/netatalk.pid
        else
            case "$host_os" in
            *freebsd*)
                ac_cv_netatalk_lock=/var/spool/lock/netatalk
                ;;
            *netbsd*|*openbsd*)
                ac_cv_netatalk_lock=/var/run/netatalk.pid
                ;;
            *linux*)
                ac_cv_netatalk_lock=/var/lock/netatalk
                ;;
            esac
        fi
    fi
    AC_DEFINE_UNQUOTED(PATH_NETATALK_LOCK, ["$ac_cv_netatalk_lock"], [netatalk lockfile path])
    AC_SUBST(PATH_NETATALK_LOCK, ["$ac_cv_netatalk_lock"])
    AC_MSG_RESULT([$ac_cv_netatalk_lock])
])

dnl 64bit platform check
AC_DEFUN([AC_NETATALK_64BIT_LIBS], [
AC_MSG_CHECKING([whether to check for 64bit libraries])
# Test if the compiler is in 64bit mode
echo 'int i;' > conftest.$ac_ext
atalk_cv_cc_64bit_output=no
if AC_TRY_EVAL(ac_compile); then
    case `/usr/bin/file conftest.$ac_objext` in
    *"ELF 64"*)
      atalk_cv_cc_64bit_output=yes
      ;;
    esac
fi
rm -rf conftest*

case $host_cpu:$atalk_cv_cc_64bit_output in
powerpc64:yes | s390x:yes | sparc*:yes | x86_64:yes | i386:yes)
    case $target_os in
    solaris2*)
        AC_MSG_RESULT([yes])
        atalk_libname="lib/64"
        ;;
    *bsd* | dragonfly*)
        AC_MSG_RESULT([no])
        atalk_libname="lib"
        ;;
    *)
        AC_MSG_RESULT([yes])
        atalk_libname="lib64"
        ;;
    esac
    ;;
*:*)
    AC_MSG_RESULT([no])
    atalk_libname="lib"
    ;;
esac
])

dnl Check for optional cracklib support
AC_DEFUN([AC_NETATALK_CRACKLIB], [
netatalk_cv_with_cracklib=no
AC_ARG_WITH(cracklib,
	[  --with-cracklib[[=DICT]]  enable/set location of cracklib dictionary [[no]]],[
	if test "x$withval" != "xno" ; then
		cracklib="$withval"
		AC_CHECK_LIB(crack, main, [
			AC_DEFINE(USE_CRACKLIB, 1, [Define if cracklib should be used])
			LIBS="$LIBS -lcrack"
			if test "$cracklib" = "yes"; then
				cracklib="/usr/$atalk_libname/cracklib_dict"
			fi
			AC_DEFINE_UNQUOTED(_PATH_CRACKLIB, "$cracklib",
				[path to cracklib dictionary])
			AC_MSG_RESULT([setting cracklib dictionary to $cracklib])
			netatalk_cv_with_cracklib=yes
			],[
			AC_MSG_ERROR([cracklib not found!])
			]
		)
	fi
	]
)
AC_MSG_CHECKING([for cracklib support])
AC_MSG_RESULT([$netatalk_cv_with_cracklib])
])

dnl Check whether to enable debug code
AC_DEFUN([AC_NETATALK_DEBUG], [
AC_MSG_CHECKING([whether to enable verbose debug code])
AC_ARG_ENABLE(debug,
	[  --enable-debug          enable verbose debug code],[
	if test "$enableval" != "no"; then
		if test "$enableval" = "yes"; then
			AC_DEFINE(DEBUG, 1, [Define if verbose debugging information should be included])
		else
			AC_DEFINE_UNQUOTED(DEBUG, $enableval, [Define if verbose debugging information should be included])
		fi 
		AC_MSG_RESULT([yes])
	else
		AC_MSG_RESULT([no])
        AC_DEFINE(NDEBUG, 1, [Disable assertions])
	fi
	],[
		AC_MSG_RESULT([no])
        AC_DEFINE(NDEBUG, 1, [Disable assertions])
	]
)
])

dnl Check whethe to disable tickle SIGALARM stuff, which eases debugging
AC_DEFUN([AC_NETATALK_DEBUGGING], [
AC_MSG_CHECKING([whether to enable debugging with debuggers])
AC_ARG_ENABLE(debugging,
	[  --enable-debugging      disable SIGALRM timers and DSI tickles (eg for debugging with gdb/dbx/...)],[
	if test "$enableval" != "no"; then
		if test "$enableval" = "yes"; then
			AC_DEFINE(DEBUGGING, 1, [Define if you want to disable SIGALRM timers and DSI tickles])
		else
			AC_DEFINE_UNQUOTED(DEBUGGING, $enableval, [Define if you want to disable SIGALRM timers and DSI tickles])
		fi 
		AC_MSG_RESULT([yes])
	else
		AC_MSG_RESULT([no])
	fi
	],[
		AC_MSG_RESULT([no])
	]
)

])

dnl Check for optional shadow password support
AC_DEFUN([AC_NETATALK_SHADOW], [
netatalk_cv_use_shadowpw=no
AC_ARG_WITH(shadow,
	[  --with-shadow           enable shadow password support [[auto]]],
	[netatalk_cv_use_shadowpw="$withval"],
	[netatalk_cv_use_shadowpw=auto]
)

if test "x$netatalk_cv_use_shadowpw" != "xno"; then
    AC_CHECK_HEADER([shadow.h])
    if test x"$ac_cv_header_shadow_h" = x"yes"; then
	netatalk_cv_use_shadowpw=yes
	AC_DEFINE(SHADOWPW, 1, [Define if shadow passwords should be used])
    else 
      if test "x$shadowpw" = "xyes"; then
        AC_MSG_ERROR([shadow support not available])
      else
       	netatalk_cv_use_shadowpw=no
      fi
    fi 
fi

AC_MSG_CHECKING([whether shadow support should be enabled])
if test "x$netatalk_cv_use_shadowpw" = "xyes"; then
	AC_MSG_RESULT([yes])
else
	AC_MSG_RESULT([no])
fi
])

dnl Check for optional valid-shell-check support
AC_DEFUN([AC_NETATALK_SHELL_CHECK], [
netatalk_cv_use_shellcheck=yes
AC_MSG_CHECKING([whether checking for a valid shell should be enabled])
AC_ARG_ENABLE(shell-check,
	[  --disable-shell-check   disable checking for a valid shell],[
	if test "$enableval" = "no"; then 
		AC_DEFINE(DISABLE_SHELLCHECK, 1, [Define if shell check should be disabled])
		AC_MSG_RESULT([no])
		netatalk_cv_use_shellcheck=no
	else
		AC_MSG_RESULT([yes])
	fi
	],[
		AC_MSG_RESULT([yes])
	]
)
])

dnl Check for optional initscript install
AC_DEFUN([AC_NETATALK_INIT_STYLE], [
    AC_ARG_WITH(init-style,
                [  --with-init-style       use OS specific init config [[redhat-sysv|redhat-systemd|suse-sysv|suse-systemd|gentoo-openrc|gentoo-systemd|netbsd|debian-sysv|debian-systemd|solaris|openrc|systemd]]],
                init_style="$withval", init_style=none
    )
    case "$init_style" in 
    "redhat")
	    AC_MSG_ERROR([--with-init-style=redhat is obsoleted. Use redhat-sysv or redhat-systemd.])
        ;;
    "redhat-sysv")
	    AC_MSG_RESULT([enabling redhat-style sysv initscript support])
	    ac_cv_init_dir="/etc/rc.d/init.d"
	    ;;
    "redhat-systemd")
	    AC_MSG_RESULT([enabling redhat-style systemd support])
	    ac_cv_init_dir="/usr/lib/systemd/system"
	    ;;
    "suse")
	    AC_MSG_ERROR([--with-init-style=suse is obsoleted. Use suse-sysv or suse-systemd.])
        ;;
    "suse-sysv")
	    AC_MSG_RESULT([enabling suse-style sysv initscript support])
	    ac_cv_init_dir="/etc/init.d"
	    ;;
    "suse-systemd")
	    AC_MSG_RESULT([enabling suse-style systemd support (>=openSUSE12.1)])
	    ac_cv_init_dir="/usr/lib/systemd/system"
	    ;;
    "gentoo")
	    AC_MSG_ERROR([--with-init-style=gentoo is obsoleted. Use gentoo-openrc or gentoo-systemd.])
        ;;
    "gentoo-openrc")
	    AC_MSG_RESULT([enabling gentoo-style openrc support])
	    ac_cv_init_dir="/etc/init.d"
        ;;
    "gentoo-systemd")
	    AC_MSG_RESULT([enabling gentoo-style systemd support])
	    ac_cv_init_dir="/usr/lib/systemd/system"
        ;;
    "netbsd")
	    AC_MSG_RESULT([enabling netbsd-style initscript support])
	    ac_cv_init_dir="/etc/rc.d"
        ;;
    "debian")
	    AC_MSG_ERROR([--with-init-style=debian is obsoleted. Use debian-sysv or debian-systemd.])
        ;;
    "debian-sysv")
	    AC_MSG_RESULT([enabling debian-style sysv initscript support])
	    ac_cv_init_dir="/etc/init.d"
        ;;
    "debian-systemd")
	    AC_MSG_RESULT([enabling debian-style systemd support])
	    ac_cv_init_dir="/lib/systemd/system"
	    ;;
    "solaris")
	    AC_MSG_RESULT([enabling solaris-style SMF support])
	    ac_cv_init_dir="/lib/svc/manifest/network/"
        ;;
    "openrc")
	    AC_MSG_RESULT([enabling general openrc support])
	    ac_cv_init_dir="/etc/init.d"
        ;;
    "systemd")
	    AC_MSG_RESULT([enabling general systemd support])
	    ac_cv_init_dir="/usr/lib/systemd/system"
        ;;
    "none")
	    AC_MSG_RESULT([disabling init-style support])
	    ac_cv_init_dir="none"
        ;;
    *)
	    AC_MSG_ERROR([illegal init-style])
        ;;
    esac
    AM_CONDITIONAL(USE_NETBSD, test x$init_style = xnetbsd)
    AM_CONDITIONAL(USE_REDHAT_SYSV, test x$init_style = xredhat-sysv)
    AM_CONDITIONAL(USE_SUSE_SYSV, test x$init_style = xsuse-sysv)
    AM_CONDITIONAL(USE_SOLARIS, test x$init_style = xsolaris)
    AM_CONDITIONAL(USE_OPENRC, test x$init_style = xopenrc || test x$init_style = xgentoo-openrc)
    AM_CONDITIONAL(USE_DEBIAN_SYSV, test x$init_style = xdebian-sysv)
    AM_CONDITIONAL(USE_SYSTEMD, test x$init_style = xsystemd || test x$init_style = xredhat-systemd || test x$init_style = xsuse-systemd || test x$init_style = xgentoo-systemd)
    AM_CONDITIONAL(USE_DEBIAN_SYSTEMD, test x$init_style = xdebian-systemd)
    AM_CONDITIONAL(USE_UNDEF, test x$init_style = xnone)

    AC_ARG_WITH(init-dir,
                [  --with-init-dir=PATH    path to OS specific init directory],
                ac_cv_init_dir="$withval", ac_cv_init_dir="$ac_cv_init_dir"
    )
    INIT_DIR="$ac_cv_init_dir"
    AC_SUBST(INIT_DIR, ["$ac_cv_init_dir"])
])

dnl OS specific configuration
AC_DEFUN([AC_NETATALK_OS_SPECIFIC], [
case "$host_os" in
	*aix*)				this_os=aix ;;
	*freebsd*) 			this_os=freebsd ;;
	*kfreebsd*)			this_os=kfreebsd ;;
	*hpux11*)			this_os=hpux11 ;;
	*irix*)				this_os=irix ;;
	*linux*)   			this_os=linux ;;
	*osx*)				this_os=macosx ;;
	*darwin*)			this_os=macosx ;;
	*netbsd*) 			this_os=netbsd ;;
	*openbsd*) 			this_os=openbsd ;;
	*osf*) 				this_os=tru64 ;;
	*solaris*) 			this_os=solaris ;;
esac

case "$host_cpu" in
	i386|i486|i586|i686|k7)		this_cpu=x86 ;;
	alpha)						this_cpu=alpha ;;
	mips)						this_cpu=mips ;;
	powerpc|ppc)				this_cpu=ppc ;;
esac

dnl --------------------- GNU source
case "$this_os" in
	linux)	AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
        ;;
	kfreebsd) AC_DEFINE(_GNU_SOURCE, 1, [Whether to use GNU libc extensions])
        ;;
esac

dnl --------------------- operating system specific flags (port from sys/*)

dnl ----- FreeBSD specific -----
if test x"$this_os" = "xfreebsd"; then 
	AC_MSG_RESULT([ * FreeBSD specific configuration])
	AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
	AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
    AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
fi

dnl ----- GNU/kFreeBSD specific -----
if test x"$this_os" = "xkfreebsd"; then
	AC_MSG_RESULT([ * GNU/kFreeBSD specific configuration])
	AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
	AC_DEFINE(FREEBSD, 1, [Define if OS is FreeBSD])
    AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EMLINK, errno returned by open with O_NOFOLLOW)
fi

dnl ----- Linux specific -----
if test x"$this_os" = "xlinux"; then 
	AC_MSG_RESULT([ * Linux specific configuration])
    AC_DEFINE(LINUX, 1, [OS is Linux])	
	dnl ----- check if we need the quotactl wrapper
    AC_CHECK_HEADERS(linux/dqblk_xfs.h,,
		[AC_CHECK_HEADERS(linux/xqm.h linux/xfs_fs.h)
        	AC_CHECK_HEADERS(xfs/libxfs.h xfs/xqm.h xfs/xfs_fs.h)]
	)


	dnl ----- as far as I can tell, dbtob always does the wrong thing
	dnl ----- on every single version of linux I've ever played with.
	dnl ----- see etc/afpd/quota.c
	AC_DEFINE(HAVE_BROKEN_DBTOB, 1, [Define if dbtob is broken])
fi

dnl ----- NetBSD specific -----
if test x"$this_os" = "xnetbsd"; then 
	AC_MSG_RESULT([ * NetBSD specific configuration])
	AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
	AC_DEFINE(NETBSD, 1, [Define if OS is NetBSD])
    AC_DEFINE(OPEN_NOFOLLOW_ERRNO, EFTYPE, errno returned by open with O_NOFOLLOW)

	CFLAGS="-I\$(top_srcdir)/sys/netbsd $CFLAGS"

	dnl ----- NetBSD does not have crypt.h, uses unistd.h -----
	AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
fi

dnl ----- OpenBSD specific -----
if test x"$this_os" = "xopenbsd"; then 
	AC_MSG_RESULT([ * OpenBSD specific configuration])
    AC_DEFINE(BSD4_4, 1, [BSD compatiblity macro])
	dnl ----- OpenBSD does not have crypt.h, uses unistd.h -----
	AC_DEFINE(UAM_DHX, 1, [Define if the DHX UAM modules should be compiled])
fi

dnl ----- Solaris specific -----
if test x"$this_os" = "xsolaris"; then 
	AC_MSG_RESULT([ * Solaris specific configuration])
	AC_DEFINE(__svr4__, 1, [Solaris compatibility macro])
	AC_DEFINE(_ISOC9X_SOURCE, 1, [Compatibility macro])
	AC_DEFINE(NO_STRUCT_TM_GMTOFF, 1, [Define if the gmtoff member of struct tm is not available])
	AC_DEFINE(SOLARIS, 1, [Solaris compatibility macro])
    AC_DEFINE(_XOPEN_SOURCE, 600, [Solaris compilation environment])
    AC_DEFINE(__EXTENSIONS__,  1, [Solaris compilation environment])
	init_style=solaris
fi

dnl Whether to run ldconfig after installing libraries
AC_PATH_PROG(NETA_LDCONFIG, ldconfig, , [$PATH$PATH_SEPARATOR/sbin$PATH_SEPARATOR/bin$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/usr/bin])
echo NETA_LDCONFIG = $NETA_LDCONFIG
AM_CONDITIONAL(RUN_LDCONFIG, test x"$this_os" = x"linux" -a x"$NETA_LDCONFIG" != x"")
])

dnl Check whether to enable rpath (the default on Solaris and NetBSD)
AC_DEFUN([AC_NETATALK_SET_RPATH], [
	AS_CASE("$this_os", [solaris|netbsd],
		[default_rpath=yes],
		[default_rpath=no])
	AS_CASE("$this_os", [linux|kfreebsd],
		[enable_dtags=yes],
		[enable_dtags=no])
	AC_ARG_ENABLE(rpath,
		AS_HELP_STRING([--enable-rpath],
			[enable RPATH/RUNPATH (default: $default_rpath)]),
		AS_CASE("$enableval",
			[yes], [enable_rpath=yes],
			[no], [enable_rpath=no],
			[AC_MSG_ERROR([bad value $enableval for --enable-rpath])]),
		[enable_rpath=$default_rpath])
	AC_MSG_RESULT([$enable_rpath])
])

dnl Check for building PGP UAM module
AC_DEFUN([AC_NETATALK_PGP_UAM], [
AC_MSG_CHECKING([whether the PGP UAM should be build])
AC_ARG_ENABLE(pgp-uam,
	[  --enable-pgp-uam        enable build of PGP UAM module],[
	if test "$enableval" = "yes"; then 
		if test "x$neta_cv_have_openssl" = "xyes"; then 
			AC_DEFINE(UAM_PGP, 1, [Define if the PGP UAM module should be compiled])
			compile_pgp=yes
			AC_MSG_RESULT([yes])
		else
			AC_MSG_RESULT([no])
		fi
	fi
	],[
		AC_MSG_RESULT([no])
	]
)
])

dnl Check for building Kerberos V UAM module
AC_DEFUN([AC_NETATALK_KRB5_UAM], [
netatalk_cv_build_krb5_uam=no
AC_ARG_ENABLE(krbV-uam,
	[  --enable-krbV-uam       enable build of Kerberos V UAM module],
	[
		if test x"$enableval" = x"yes"; then
			NETATALK_GSSAPI_CHECK([
				netatalk_cv_build_krb5_uam=yes
			],[
				AC_MSG_ERROR([need GSSAPI to build Kerberos V UAM])
			])
		fi
	]
	
)

AC_MSG_CHECKING([whether Kerberos V UAM should be build])
if test x"$netatalk_cv_build_krb5_uam" = x"yes"; then
	AC_MSG_RESULT([yes])
else
	AC_MSG_RESULT([no])
fi
AM_CONDITIONAL(USE_GSSAPI, test x"$netatalk_cv_build_krb5_uam" = x"yes")
])

dnl Check if we can directly use Kerberos 5 API, used for reading keytabs
dnl and automatically construction DirectoryService names from that, instead
dnl of requiring special configuration in afp.conf
AC_DEFUN([AC_NETATALK_KERBEROS], [
AC_MSG_CHECKING([for Kerberos 5 (necessary for GetSrvrInfo:DirectoryNames support)])
AC_ARG_WITH([kerberos],
    [AS_HELP_STRING([--with-kerberos], [Kerberos 5 support (default=auto)])],
    [],
    [with_kerberos=auto])
AC_MSG_RESULT($with_kerberos)

if test x"$with_kerberos" != x"no"; then
   have_krb5_header="no"
   AC_CHECK_HEADERS([krb5/krb5.h krb5.h kerberosv5/krb5.h], [have_krb5_header="yes"; break])
   if test x"$have_krb5_header" = x"no" && test x"$with_kerberos" != x"auto"; then
      AC_MSG_FAILURE([--with-kerberos was given, but no headers found])
   fi

   AC_PATH_PROG([KRB5_CONFIG], [krb5-config])
   AC_MSG_CHECKING([for krb5-config])
   if test -x "$KRB5_CONFIG"; then
      AC_MSG_RESULT([$KRB5_CONFIG])
      KRB5_CFLAGS="`$KRB5_CONFIG --cflags krb5`"
      KRB5_LIBS="`$KRB5_CONFIG --libs krb5`"
      AC_SUBST(KRB5_CFLAGS)
      AC_SUBST(KRB5_LIBS)
      with_kerberos="yes"
   else
      AC_MSG_RESULT([not found])
      if test x"$with_kerberos" != x"auto"; then
         AC_MSG_FAILURE([--with-kerberos was given, but krb5-config could not be found])
      fi
   fi
fi

if test x"$with_kerberos" = x"yes"; then
   AC_DEFINE([HAVE_KERBEROS], [1], [Define if Kerberos 5 is available])
fi

dnl Check for krb5_free_unparsed_name and krb5_free_error_message
save_CFLAGS="$CFLAGS"
save_LIBS="$LIBS"
CFLAGS="$KRB5_CFLAGS"
LIBS="$KRB5_LIBS"
AC_CHECK_FUNCS([krb5_free_unparsed_name krb5_free_error_message krb5_free_keytab_entry_contents krb5_kt_free_entry])
CFLAGS="$save_CFLAGS"
LIBS="$save_LIBS"
])

dnl Check for overwrite the config files or not
AC_DEFUN([AC_NETATALK_OVERWRITE_CONFIG], [
AC_MSG_CHECKING([whether configuration files should be overwritten])
AC_ARG_ENABLE(overwrite,
	[  --enable-overwrite      overwrite configuration files during installation],
	[OVERWRITE_CONFIG="${enable_overwrite}"],
	[OVERWRITE_CONFIG="no"]
)
AC_MSG_RESULT([$OVERWRITE_CONFIG])
AC_SUBST(OVERWRITE_CONFIG)
])

dnl Check for LDAP support, for client-side ACL visibility
AC_DEFUN([AC_NETATALK_LDAP], [
AC_MSG_CHECKING(for LDAP (necessary for client-side ACL visibility))
AC_ARG_WITH(ldap,
    [AS_HELP_STRING([--with-ldap[[=PATH]]],
        [LDAP support (default=auto)])],
        netatalk_cv_ldap=$withval,
        netatalk_cv_ldap=auto
        )
AC_MSG_RESULT($netatalk_cv_ldap)

save_CFLAGS="$CFLAGS"
save_LDFLAGS="$LDFLAGS"
save_LIBS="$LIBS"
CFLAGS=""
LDFLAGS=""
LIBS=""
LDAP_CFLAGS=""
LDAP_LDFLAGS=""
LDAP_LIBS=""

if test x"$netatalk_cv_ldap" != x"no" ; then
   if test x"$netatalk_cv_ldap" != x"yes" -a x"$netatalk_cv_ldap" != x"auto"; then
       CFLAGS="-I$netatalk_cv_ldap/include"
       LDFLAGS="-L$netatalk_cv_ldap/lib"
   fi
   	AC_CHECK_HEADER([ldap.h], netatalk_cv_ldap=yes,
        [ if test x"$netatalk_cv_ldap" = x"yes" ; then
            AC_MSG_ERROR([Missing LDAP headers])
        fi
		netatalk_cv_ldap=no
        ])
	AC_CHECK_LIB(ldap, ldap_init, netatalk_cv_ldap=yes,
        [ if test x"$netatalk_cv_ldap" = x"yes" ; then
            AC_MSG_ERROR([Missing LDAP library])
        fi
		netatalk_cv_ldap=no
        ])
fi

if test x"$netatalk_cv_ldap" = x"yes"; then
    LDAP_CFLAGS="$CFLAGS"
    LDAP_LDFLAGS="$LDFLAGS"
    LDAP_LIBS="-lldap"
	AC_DEFINE(HAVE_LDAP,1,[Whether LDAP is available])
fi

AC_SUBST(LDAP_CFLAGS)
AC_SUBST(LDAP_LDFLAGS)
AC_SUBST(LDAP_LIBS)
CFLAGS="$save_CFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
])

dnl Check for ACL support
AC_DEFUN([AC_NETATALK_ACL], [
ac_cv_have_acls=no
AC_MSG_CHECKING(whether to support ACLs)
AC_ARG_WITH(acls,
    [AS_HELP_STRING([--with-acls],
        [Include ACL support (default=auto)])],
    [ case "$withval" in
      yes|no)
          with_acl_support="$withval"
		  ;;
      *)
          with_acl_support=auto
          ;;
      esac ],
    [with_acl_support=auto])
AC_MSG_RESULT($with_acl_support)

if test x"$with_acl_support" = x"no"; then
	AC_MSG_RESULT(Disabling ACL support)
fi

# Platform specific checks
if test x"$with_acl_support" != x"no" ; then
	case "$host_os" in
	*solaris*)
		AC_MSG_NOTICE(Using solaris ACLs)
		AC_DEFINE(HAVE_SOLARIS_ACLS,1,[Whether Solaris ACLs are available])
		AC_DEFINE(HAVE_NFSV4_ACLS,1,[Whether NFSv4 ACLs are available])
		ACL_LIBS="$ACL_LIBS -lsec"
		ac_cv_have_acls=yes
		;;
	*freebsd*)
		AC_MSG_NOTICE(checking whether libsunacl is available)
		sunacl_include_path="/usr/local/include"
		sunacl_lib_path="/usr/local/lib"

		save_CPPFLAGS=$CPPFLAGS
		save_LDFLAGS=$LDFLAGS
		save_LIBS=$LIBS

		CPPFLAGS="-I$sunacl_include_path $CPPFLAGS"
		AC_CHECK_HEADER([sunacl.h])

		LDFLAGS="-L$sunacl_lib_path $LDFLAGS"
		AC_CHECK_LIB([sunacl], [acl])

		if test x"$ac_cv_header_sunacl_h" = x"yes" -a x"$ac_cv_lib_sunacl_acl" = x"yes" ; then
			AC_MSG_NOTICE([Enabling support for ZFS ACLs using libsunacl])
			ac_cv_have_acls=yes
			CFLAGS="-I$sunacl_include_path $CFLAGS"
			ACL_LIBS="$ACL_LIBS -L$sunacl_lib_path -lsunacl"
			AC_DEFINE(HAVE_FREEBSD_SUNACL, 1, [Whether FreeBSD ZFS ACLs with libsunacl are available])
			AC_DEFINE(HAVE_NFSV4_ACLS,1,[Whether NFSv4 ACLs are available])
		else
			AC_MSG_NOTICE([libsunacl not found, disabling ZFS ACL support])
		fi

		CPPFLAGS=$save_CPPFLAGS
		LDFLAGS=$save_LDFLAGS
		LIBS=$save_LIBS
		;;
	esac
fi

if test x"$with_acl_support" != x"no" -a x"$ac_cv_have_acls" != x"yes" ; then
	# Runtime checks for POSIX ACLs
	AC_CHECK_LIB(acl,acl_get_file,[ACL_LIBS="$ACL_LIBS -lacl"])
	case "$host_os" in
	*linux*)
		AC_CHECK_LIB(attr,getxattr,[ACL_LIBS="$ACL_LIBS -lattr"])
		;;
	esac

	AC_CACHE_CHECK([for POSIX ACL support],netatalk_cv_HAVE_POSIX_ACLS,[
		acl_LIBS=$LIBS
		LIBS="$LIBS $ACL_LIBS"
		AC_LINK_IFELSE([AC_LANG_PROGRAM([[
			#include <sys/types.h>
			#include <sys/acl.h>
		]], [[
			acl_t acl;
			int entry_id;
			acl_entry_t *entry_p;
			return acl_get_entry(acl, entry_id, entry_p);
		]])],
			[netatalk_cv_HAVE_POSIX_ACLS=yes; ac_cv_have_acls=yes],
			[netatalk_cv_HAVE_POSIX_ACLS=no; ac_cv_have_acls=no]
		)
		LIBS=$acl_LIBS
	])

	if test x"$netatalk_cv_HAVE_POSIX_ACLS" = x"yes"; then
		AC_MSG_NOTICE(Using POSIX ACLs)
		AC_DEFINE(HAVE_POSIX_ACLS,1,[Whether POSIX ACLs are available])

		AC_CACHE_CHECK([for acl_get_perm_np],netatalk_cv_HAVE_ACL_GET_PERM_NP,[
			acl_LIBS=$LIBS
			LIBS="$LIBS $ACL_LIBS"
			AC_LINK_IFELSE([AC_LANG_PROGRAM([[
				#include <sys/types.h>
				#include <sys/acl.h>
			]], [[
				acl_permset_t permset_d;
				acl_perm_t perm;
				return acl_get_perm_np(permset_d, perm);
			]])],[netatalk_cv_HAVE_ACL_GET_PERM_NP=yes],[netatalk_cv_HAVE_ACL_GET_PERM_NP=no])
			LIBS=$acl_LIBS
		])
		if test x"$netatalk_cv_HAVE_ACL_GET_PERM_NP" = x"yes"; then
			AC_DEFINE(HAVE_ACL_GET_PERM_NP,1,[Whether acl_get_perm_np() is available])
		fi

		AC_CACHE_CHECK([for acl_from_mode], netatalk_cv_HAVE_ACL_FROM_MODE,[
			acl_LIBS=$LIBS
			LIBS="$LIBS $ACL_LIBS"
			AC_CHECK_FUNCS(acl_from_mode,
				[netatalk_cv_HAVE_ACL_FROM_MODE=yes],
				[netatalk_cv_HAVE_ACL_FROM_MODE=no]
			)
			LIBS=$acl_LIBS
		])
		if test x"netatalk_cv_HAVE_ACL_FROM_MODE" = x"yes"; then
		   AC_DEFINE(HAVE_ACL_FROM_MODE,1,[Whether acl_from_mode() is available])
		fi
	fi
fi

if test x"$ac_cv_have_acls" = x"no" ; then
	if test x"$with_acl_support" = x"yes" ; then
		AC_MSG_ERROR(ACL support requested but not found)
	else
		AC_MSG_NOTICE(ACL support is not avaliable)
	fi
else
	AC_CHECK_HEADERS([acl/libacl.h])
	AC_DEFINE(HAVE_ACLS,1,[Whether ACLs support is available])
fi
AC_SUBST(ACL_LIBS)
])

dnl Check for Extended Attributes support
AC_DEFUN([AC_NETATALK_EXTENDED_ATTRIBUTES], [
neta_cv_eas="ad"
neta_cv_eas_sys_found=no
neta_cv_eas_sys_not_found=no

AC_CHECK_HEADERS(sys/attributes.h attr/xattr.h sys/xattr.h sys/extattr.h sys/uio.h sys/ea.h)

case "$this_os" in

  *osf*)
	AC_SEARCH_LIBS(getproplist, [proplist])
	AC_CHECK_FUNCS([getproplist fgetproplist setproplist fsetproplist],
                   [neta_cv_eas_sys_found=yes],
                   [neta_cv_eas_sys_not_found=yes])
	AC_CHECK_FUNCS([delproplist fdelproplist add_proplist_entry get_proplist_entry],,
                   [neta_cv_eas_sys_not_found=yes])
	AC_CHECK_FUNCS([sizeof_proplist_entry],,
                   [neta_cv_eas_sys_not_found=yes])
  ;;

  *solaris*)
	AC_CHECK_FUNCS([attropen],
                   [neta_cv_eas_sys_found=yes; AC_DEFINE(HAVE_EAFD, 1, [extattr API has full fledged fds for EAs])],
                   [neta_cv_eas_sys_not_found=yes])
  ;;

  'freebsd')
    AC_CHECK_FUNCS([extattr_delete_fd extattr_delete_file extattr_delete_link],
                   [neta_cv_eas_sys_found=yes],
                   [neta_cv_eas_sys_not_found=yes])
    AC_CHECK_FUNCS([extattr_get_fd extattr_get_file extattr_get_link],,
                   [neta_cv_eas_sys_not_found=yes])
    AC_CHECK_FUNCS([extattr_list_fd extattr_list_file extattr_list_link],,
                   [neta_cv_eas_sys_not_found=yes])
    AC_CHECK_FUNCS([extattr_set_fd extattr_set_file extattr_set_link],,
                   [neta_cv_eas_sys_not_found=yes])
  ;;

  *freebsd4* | *dragonfly* )
    AC_DEFINE(BROKEN_EXTATTR, 1, [Does extattr API work])
  ;;

  *)
	AC_SEARCH_LIBS(getxattr, [attr])

    if test "x$neta_cv_eas_sys_found" != "xyes" ; then
       AC_CHECK_FUNCS([getxattr lgetxattr fgetxattr listxattr llistxattr],
                      [neta_cv_eas_sys_found=yes],
                      [neta_cv_eas_sys_not_found=yes])
	   AC_CHECK_FUNCS([flistxattr removexattr lremovexattr fremovexattr],,
                      [neta_cv_eas_sys_not_found=yes])
	   AC_CHECK_FUNCS([setxattr lsetxattr fsetxattr],,
                      [neta_cv_eas_sys_not_found=yes])
    fi

    if test "x$neta_cv_eas_sys_found" != "xyes" ; then
	   AC_CHECK_FUNCS([getea fgetea lgetea listea flistea llistea],
                      [neta_cv_eas_sys_found=yes],
                      [neta_cv_eas_sys_not_found=yes])
	   AC_CHECK_FUNCS([removeea fremoveea lremoveea setea fsetea lsetea],,
                      [neta_cv_eas_sys_not_found=yes])
    fi

    if test "x$neta_cv_eas_sys_found" != "xyes" ; then
	   AC_CHECK_FUNCS([attr_get attr_list attr_set attr_remove],,
                      [neta_cv_eas_sys_not_found=yes])
       AC_CHECK_FUNCS([attr_getf attr_listf attr_setf attr_removef],,
                      [neta_cv_eas_sys_not_found=yes])
    fi
  ;;
esac

# Do xattr functions take additional options like on Darwin?
if test x"$ac_cv_func_getxattr" = x"yes" ; then
	AC_CACHE_CHECK([whether xattr interface takes additional options], smb_attr_cv_xattr_add_opt, [
		old_LIBS=$LIBS
		LIBS="$LIBS $ACL_LIBS"
		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
			#include <sys/types.h>
			#if HAVE_ATTR_XATTR_H
			#include <attr/xattr.h>
			#elif HAVE_SYS_XATTR_H
			#include <sys/xattr.h>
			#endif
		]], [[
			getxattr(0, 0, 0, 0, 0, 0);
		]])],[smb_attr_cv_xattr_add_opt=yes],[smb_attr_cv_xattr_add_opt=no;LIBS=$old_LIBS])
	])
	if test x"$smb_attr_cv_xattr_add_opt" = x"yes"; then
		AC_DEFINE(XATTR_ADD_OPT, 1, [xattr functions have additional options])
	fi
fi

if test "x$neta_cv_eas_sys_found" = "xyes" ; then
   if test "x$neta_cv_eas_sys_not_found" != "xyes" ; then
      neta_cv_eas="$neta_cv_eas | sys"
   fi
fi
AC_DEFINE_UNQUOTED(EA_MODULES,["$neta_cv_eas"],[Available Extended Attributes modules])
])

dnl Check for libsmbsharemodes from Samba for Samba/Netatalk access/deny/share modes interop
dnl Defines "neta_cv_have_smbshmd" to "yes" or "no"
dnl AC_SUBST's "SMB_SHAREMODES_CFLAGS" and "SMB_SHAREMODES_LDFLAGS"
dnl AM_CONDITIONAL's "USE_SMB_SHAREMODES"
AC_DEFUN([AC_NETATALK_SMB_SHAREMODES], [
    neta_cv_have_smbshmd=no
    AC_ARG_WITH(smbsharemodes-lib,
                [  --with-smbsharemodes-lib=PATH        PATH to libsmbsharemodes lib from Samba],
                [SMB_SHAREMODES_LDFLAGS="-L$withval -lsmbsharemodes"]
    )
    AC_ARG_WITH(smbsharemodes-include,
                [  --with-smbsharemodes-include=PATH    PATH to libsmbsharemodes header from Samba],
                [SMB_SHAREMODES_CFLAGS="-I$withval"]
    )
    AC_ARG_WITH(smbsharemodes,
                [AS_HELP_STRING([--with-smbsharemodes],[Samba interop (default is yes)])],
                [use_smbsharemodes=$withval],
                [use_smbsharemodes=yes]
    )

    if test x"$use_smbsharemodes" = x"yes" ; then
        AC_MSG_CHECKING([whether to enable Samba/Netatalk access/deny/share-modes interop])

        saved_CFLAGS="$CFLAGS"
        saved_LDFLAGS="$LDFLAGS"
        CFLAGS="$SMB_SHAREMODES_CFLAGS $CFLAGS"
        LDFLAGS="$SMB_SHAREMODES_LDFLAGS $LDFLAGS"

        AC_LINK_IFELSE(
            [#include <unistd.h>
             #include <stdio.h>
             #include <sys/time.h>
             #include <time.h>
             #include <stdint.h>
             /* From messages.h */
             struct server_id {
                 pid_t pid;
             };
             #include "smb_share_modes.h"
             int main(void) { (void)smb_share_mode_db_open(""); return 0;}],
            [neta_cv_have_smbshmd=yes]
        )

        AC_MSG_RESULT($neta_cv_have_smbshmd)
        AC_SUBST(SMB_SHAREMODES_CFLAGS, [$SMB_SHAREMODES_CFLAGS])
        AC_SUBST(SMB_SHAREMODES_LDFLAGS, [$SMB_SHAREMODES_LDFLAGS])
        CFLAGS="$saved_CFLAGS"
        LDFLAGS="$saved_LDFLAGS"
    fi

    AM_CONDITIONAL(USE_SMB_SHAREMODES, test x"$neta_cv_have_smbshmd" = x"yes")
])

dnl ------ Check for sendfile() --------
AC_DEFUN([AC_NETATALK_SENDFILE], [
netatalk_cv_search_sendfile=yes
AC_ARG_ENABLE(sendfile,
    [  --disable-sendfile       disable sendfile syscall],
    [if test x"$enableval" = x"no"; then
            netatalk_cv_search_sendfile=no
        fi]
)

if test x"$netatalk_cv_search_sendfile" = x"yes"; then
   case "$host_os" in
   *linux*)
        AC_DEFINE(SENDFILE_FLAVOR_LINUX,1,[Whether linux sendfile() API is available])
        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
        ;;

    *solaris*)
        AC_DEFINE(SENDFILE_FLAVOR_SOLARIS, 1, [Solaris sendfile()])
        AC_SEARCH_LIBS(sendfile, sendfile)
        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
        AC_CHECK_FUNCS([sendfilev])
        ;;

    *freebsd*)
        AC_DEFINE(SENDFILE_FLAVOR_BSD, 1, [Define if the sendfile() function uses BSD semantics])
        AC_CHECK_FUNC([sendfile], [netatalk_cv_HAVE_SENDFILE=yes])
        ;;

    *)
        ;;

    esac

    if test x"$netatalk_cv_HAVE_SENDFILE" = x"yes"; then
        AC_DEFINE(WITH_SENDFILE,1,[Whether sendfile() should be used])
    fi
fi
])

dnl ------ Check for recvfile() --------
AC_DEFUN([AC_NETATALK_RECVFILE], [
case "$host_os" in
*linux*)
    AC_CHECK_FUNCS([splice], [atalk_cv_use_recvfile=yes])
    ;;

*)
    ;;

esac

if test x"$atalk_cv_use_recvfile" = x"yes"; then
    AC_DEFINE(WITH_RECVFILE, 1, [Whether recvfile should be used])
fi
])

dnl --------------------- Check if realpath() takes NULL
AC_DEFUN([AC_NETATALK_REALPATH], [
AC_CACHE_CHECK([if the realpath function allows a NULL argument],
    neta_cv_REALPATH_TAKES_NULL, [
        AC_RUN_IFELSE([AC_LANG_SOURCE([[
            #include <stdio.h>
            #include <limits.h>
            #include <signal.h>

            void exit_on_core(int ignored) {
                 exit(1);
            }

            main() {
                char *newpath;
                signal(SIGSEGV, exit_on_core);
                newpath = realpath("/tmp", NULL);
                exit((newpath != NULL) ? 0 : 1);
            }]])],[neta_cv_REALPATH_TAKES_NULL=yes],[neta_cv_REALPATH_TAKES_NULL=no],[neta_cv_REALPATH_TAKES_NULL=cross
        ])
    ]
)

if test x"$neta_cv_REALPATH_TAKES_NULL" = x"yes"; then
    AC_DEFINE(REALPATH_TAKES_NULL,1,[Whether the realpath function allows NULL])
fi
])