xref: /aosp_15_r20/external/ethtool/configure.ac (revision 1b481fc3bb1b45d4cf28d1ec12969dc1055f555d)
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(ethtool, 6.5, [email protected])
3AC_PREREQ(2.52)
4AC_CONFIG_MACRO_DIR([m4])
5AC_CONFIG_SRCDIR([ethtool.c])
6AM_INIT_AUTOMAKE([gnu subdir-objects])
7AC_CONFIG_HEADERS([ethtool-config.h])
8
9AM_MAINTAINER_MODE
10
11dnl Checks for programs.
12AC_PROG_CC
13AC_PROG_GCC_TRADITIONAL
14AM_PROG_CC_C_O
15PKG_PROG_PKG_CONFIG
16
17AC_DEFUN([AX_CHECK_STDC],
18	 [AX_CHECK_COMPILE_FLAG([-std=gnu11],
19		[AX_APPEND_FLAG([-std=gnu11])],
20		[AX_CHECK_COMPILE_FLAG([-std=c11],
21			[AX_APPEND_FLAG([-std=c11])],
22			[AC_MSG_ERROR([$PACKAGE requires a C11 compiler])])
23		])
24	])
25AX_CHECK_STDC
26
27dnl Checks for libraries.
28
29dnl Checks for header files.
30
31dnl Checks for typedefs, structures, and compiler characteristics.
32
33dnl Checks for library functions.
34AC_HEADER_STDC
35AC_CHECK_FUNCS(socket)
36
37dnl Check for options
38AC_ARG_ENABLE(pretty-dump,
39	      [  --enable-pretty-dump	  enable registers, EEPROM and SFP pretty dumps (enabled by default)],
40	      ,
41	      enable_pretty_dump=yes)
42if test x$enable_pretty_dump = xyes; then
43    AC_DEFINE(ETHTOOL_ENABLE_PRETTY_DUMP, 1,
44	      [Define this to enable register, EEPROM and SFP pretty dumps.])
45fi
46AM_CONDITIONAL([ETHTOOL_ENABLE_PRETTY_DUMP], [test x$enable_pretty_dump = xyes])
47
48AC_ARG_WITH([bash-completion-dir],
49	    AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
50	                   [Install the bash-completion script in this directory. @<:@default=yes@:>@]),
51	    [],
52	    [with_bash_completion_dir=yes])
53AS_IF([test "x$with_bash_completion_dir" = xyes],
54      [AC_MSG_CHECKING([for bash-completion directory])
55       dnl Attempt to use pkg-config completionsdir variable with given $prefix.
56       dnl This matches distcheck expectation that all files install to $prefix.
57       dnl It works with /usr and /usr/local (for default $XDG_DATA_DIRS) but
58       dnl may install to directory not used by bash-completion in other cases.
59       dnl See: https://lore.kernel.org/netdev/20190417025333.GA28674@kevinolos/
60       AS_IF([test "x$PKG_CONFIG" != x \
61	      && bash_completion_prefix=`"$PKG_CONFIG" --print-errors --variable=prefix bash-completion 2>&AS_MESSAGE_LOG_FD` \
62	      && bash_completion_dir=`"$PKG_CONFIG" --print-errors --variable=completionsdir bash-completion 2>&AS_MESSAGE_LOG_FD`],
63	     [bash_completion_dir="${bash_completion_dir#"$bash_completion_prefix"}"
64	      bash_completion_dir="${bash_completion_dir#/}"
65	      BASH_COMPLETION_DIR='${prefix}'/"$bash_completion_dir"],
66	     [BASH_COMPLETION_DIR='${datadir}/bash-completion/completions'])
67       AC_MSG_RESULT([$BASH_COMPLETION_DIR])],
68      [BASH_COMPLETION_DIR="$with_bash_completion_dir"])
69AC_SUBST([BASH_COMPLETION_DIR])
70AM_CONDITIONAL([ENABLE_BASH_COMPLETION],
71	       [test "x$with_bash_completion_dir" != xno])
72
73AC_ARG_ENABLE(netlink,
74	      [  --enable-netlink	  enable netlink interface (enabled by default)],
75	      ,
76	      enable_netlink=yes)
77if test x$enable_netlink = xyes; then
78    PKG_PROG_PKG_CONFIG
79    PKG_CHECK_MODULES([MNL], [libmnl])
80    AC_DEFINE(ETHTOOL_ENABLE_NETLINK, 1,
81	      Define this to support netlink interface to talk to kernel.)
82fi
83AM_CONDITIONAL([ETHTOOL_ENABLE_NETLINK], [test x$enable_netlink = xyes])
84
85AC_CONFIG_FILES([Makefile ethtool.spec ethtool.8])
86AC_OUTPUT
87