1dnl Process this file with autoconf to produce a configure script.
2AC_INIT(ethtool, 5.3, netdev@vger.kernel.org)
3AC_PREREQ(2.52)
4AC_CONFIG_SRCDIR([ethtool.c])
5AM_INIT_AUTOMAKE([gnu])
6AC_CONFIG_HEADERS([ethtool-config.h])
7
8AM_MAINTAINER_MODE
9
10dnl Checks for programs.
11AC_PROG_CC
12AC_PROG_GCC_TRADITIONAL
13AM_PROG_CC_C_O
14PKG_PROG_PKG_CONFIG
15
16dnl Checks for libraries.
17
18dnl Checks for header files.
19
20dnl Checks for typedefs, structures, and compiler characteristics.
21AC_MSG_CHECKING([whether <linux/types.h> defines big-endian types])
22AC_TRY_COMPILE([#include <linux/types.h>],
23	       [__be16 foo;__be32 bar;],
24	       [AC_MSG_RESULT(yes)
25		AC_DEFINE([HAVE_BE_TYPES], [1],
26			  [Define to 1 if <linux/types.h> defines big-endian types])],
27	       [AC_MSG_RESULT(no)])
28
29dnl Checks for library functions.
30AC_HEADER_STDC
31AC_CHECK_FUNCS(socket strtol)
32
33dnl Check for options
34AC_ARG_ENABLE(pretty-dump,
35	      [  --enable-pretty-dump	  enable registers, EEPROM and SFP pretty dumps (enabled by default)],
36	      ,
37	      enable_pretty_dump=yes)
38if test x$enable_pretty_dump = xyes; then
39    AC_DEFINE(ETHTOOL_ENABLE_PRETTY_DUMP, 1,
40	      [Define this to enable register, EEPROM and SFP pretty dumps.])
41fi
42AM_CONDITIONAL([ETHTOOL_ENABLE_PRETTY_DUMP], [test x$enable_pretty_dump = xyes])
43
44AC_ARG_WITH([bash-completion-dir],
45	    AS_HELP_STRING([--with-bash-completion-dir[=PATH]],
46	                   [Install the bash-completion script in this directory. @<:@default=yes@:>@]),
47	    [],
48	    [with_bash_completion_dir=yes])
49AS_IF([test "x$with_bash_completion_dir" = xyes],
50      [AC_MSG_CHECKING([for bash-completion directory])
51       dnl Attempt to use pkg-config completionsdir variable with given $prefix.
52       dnl This matches distcheck expectation that all files install to $prefix.
53       dnl It works with /usr and /usr/local (for default $XDG_DATA_DIRS) but
54       dnl may install to directory not used by bash-completion in other cases.
55       dnl See: https://lore.kernel.org/netdev/20190417025333.GA28674@kevinolos/
56       AS_IF([test "x$PKG_CONFIG" != x \
57	      && bash_completion_prefix=`"$PKG_CONFIG" --print-errors --variable=prefix bash-completion 2>&AS_MESSAGE_LOG_FD` \
58	      && bash_completion_dir=`"$PKG_CONFIG" --print-errors --variable=completionsdir bash-completion 2>&AS_MESSAGE_LOG_FD`],
59	     [bash_completion_dir="${bash_completion_dir#"$bash_completion_prefix"}"
60	      bash_completion_dir="${bash_completion_dir#/}"
61	      BASH_COMPLETION_DIR='${prefix}'/"$bash_completion_dir"],
62	     [BASH_COMPLETION_DIR='${datadir}/bash-completion/completions'])
63       AC_MSG_RESULT([$BASH_COMPLETION_DIR])],
64      [BASH_COMPLETION_DIR="$with_bash_completion_dir"])
65AC_SUBST([BASH_COMPLETION_DIR])
66AM_CONDITIONAL([ENABLE_BASH_COMPLETION],
67	       [test "x$with_bash_completion_dir" != xno])
68
69AC_CONFIG_FILES([Makefile ethtool.spec ethtool.8])
70AC_OUTPUT
71