OSX compatibility
[m6w6/btr] / configure.ac
1 AC_INIT([btr], [0.5.0], [mike@php.net])
2 AM_INIT_AUTOMAKE([foreign])
3 AM_SILENT_RULES
4 AC_CONFIG_SRCDIR([./share/btr/btr.sh])
5
6 AC_PATH_PROG([GETOPT], [getopt], [getopt])
7 AC_ARG_VAR([GETOPT], [location of gnu-getopt, see --with-gnu-getopt; e.g. /usr/local/opt/gnu-getopt/bin/getopt])
8 AC_ARG_WITH([gnu-getopt], [AS_HELP_STRING([--with-gnu-getopt=path], [
9 Location of the enhanced GNU getopt program])], [
10 ], [
11 with_gnu_getopt=$GETOPT
12 ])
13
14 AC_MSG_CHECKING([for GNU getopt])
15 $with_gnu_getopt --test >/dev/null
16 AS_IF([test $? -ne 4], [
17 AC_MSG_RESULT([no])
18 AC_MSG_ERROR([$with_gnu_getopt looks like the BSD version, please provide the path to the GNU version --with-gnu-getopt])
19 ], [
20 AC_MSG_RESULT([yes, $with_gnu_getopt])
21 AC_SUBST([GETOPT], [$with_gnu_getopt])
22 ])
23
24 AC_PROG_AWK
25 AC_PATH_PROG([AWK_PATH], [$AWK], [/bin/$AWK])
26
27 AC_CHECK_PROGS([SETSID], [setsid], [nothing])
28 AC_ARG_VAR([SETSID], [location of a setsid program; a simple replacement will be built if none found or provided])
29 AS_IF([test "$SETSID" = nothing], [
30 SETSID="\$BTR_BINDIR/btr-setsid"
31 AC_PROG_CC
32 AC_CONFIG_FILES([bin/Makefile])
33 ], [:]);
34
35 AC_CHECK_PROGS([NPROC], [nproc sysctl], [nothing])
36 AC_MSG_CHECKING([for number of cores])
37 AS_CASE([$NPROC],
38 [nproc], [
39 BTR_CPUS=$(nproc)
40 ],
41 [sysctl], [
42 BTR_CPUS=$(sysctl -n hw.ncpu 2>/dev/null || echo 1)
43 ],
44 [
45 BTR_CPUS=1
46 ]
47 )
48 AC_MSG_RESULT([$BTR_CPUS])
49 AC_SUBST([BTR_CPUS], [$BTR_CPUS])
50
51 AC_MSG_CHECKING([for bin/ scripts]);
52 BTR_BIN=$(find $srcdir/bin -type f -perm -a=x | sed 's/\.in$//' | xargs)
53 AC_MSG_RESULT([$BTR_BIN])
54 AC_SUBST([BTR_BIN], [$BTR_BIN])
55
56 AC_MSG_CHECKING([for share/ scripts])
57 BTR_SCRIPTS=$(find $srcdir/share/btr -type f -perm -a=x | sed 's/\.in$//' | xargs)
58 AC_MSG_RESULT([$BTR_SCRIPTS])
59 AC_SUBST([BTR_SCRIPTS], [$BTR_SCRIPTS])
60
61 AC_MSG_CHECKING([for share/ data])
62 BTR_SHARE=$(find $srcdir/share/btr -type f ! -perm -a=x | sed 's/\.in$//' | xargs)
63 AC_MSG_RESULT([$BTR_SHARE])
64 AC_SUBST([BTR_SHARE], [$BTR_SHARE])
65
66 AC_CONFIG_FILES([bin/btrd], [chmod +x bin/btrd])
67 AC_CONFIG_FILES([share/btr/opt.awk], [chmod +x share/btr/opt.awk])
68 AC_CONFIG_FILES([share/btr/common.sh], [chmod +x share/btr/common.sh])
69 AC_CONFIG_FILES([Makefile])
70 AC_OUTPUT
71
72 dnl vim: noet