blob: 91d4ae34dda785dc056d3c8ff0abe1225bcb8440 [file] [log] [blame]
Thomas Haller13891882020-04-16 12:47:42 +02001# SPDX-License-Identifier: LGPL-2.1-only
2
Thomas Graf44d36242007-09-15 01:28:01 +02003#
Thomas Graf83c762d2013-01-24 15:00:26 +01004# Copyright (c) 2003-2013 Thomas Graf <tgraf@suug.ch>
Thomas Graf44d36242007-09-15 01:28:01 +02005#
6
Thomas Graf4c210ad2011-09-13 22:58:08 +02007# copied from glib
8m4_define([libnl_major_version], [3])
Thomas Hallerfa05d582024-07-19 11:34:51 +02009m4_define([libnl_minor_version], [10])
Thomas Hallerbcdf8742017-03-06 21:28:49 +010010m4_define([libnl_micro_version], [0])
Thomas Haller94e13452014-07-04 19:58:04 +020011m4_define([libnl_git_sha], [m4_esyscmd([ ( [ -d ./.git/ ] && [ "$(readlink -f ./.git/)" = "$(readlink -f "$(git rev-parse --git-dir 2>/dev/null)" 2>/dev/null)" ] && git rev-parse --verify -q HEAD 2>/dev/null ) || true ])])
Thomas Grafad5d2b72012-04-26 11:22:49 +020012
13
Thomas Grafb6afd0b2013-01-24 14:34:22 +010014# The following explanation may help to understand the above rules a bit
15# better: consider that there are three possible kinds of reactions from
16# users of your library to changes in a shared library:
Thomas Grafad5d2b72012-04-26 11:22:49 +020017#
Thomas Grafb6afd0b2013-01-24 14:34:22 +010018# 1. Programs using the previous version may use the new version as drop-in
19# replacement, and programs using the new version can also work with the
20# previous one. In other words, no recompiling nor relinking is needed.
21# In this case, bump revision only, don't touch current nor age.
Thomas Grafad5d2b72012-04-26 11:22:49 +020022#
Thomas Grafb6afd0b2013-01-24 14:34:22 +010023# 2. Programs using the previous version may use the new version as drop-in
24# replacement, but programs using the new version may use APIs not
25# present in the previous one. In other words, a program linking against
26# the new version may fail with “unresolved symbols” if linking against
27# the old version at runtime: set revision to 0, bump current and age.
28#
29# 3. Programs may need to be changed, recompiled, relinked in order to use
30# the new version. Bump current, set revision and age to 0.
Thomas Grafad5d2b72012-04-26 11:22:49 +020031
Thomas Hallere01b9df2017-09-20 10:58:20 +020032m4_define([libnl_lt_current], [226])
Thomas Hallerc033ee82016-12-12 15:10:21 +010033m4_define([libnl_lt_revision], [0])
Thomas Hallere01b9df2017-09-20 10:58:20 +020034m4_define([libnl_lt_age], [26])
Thomas Graf4c210ad2011-09-13 22:58:08 +020035
36m4_define([libnl_version],
Thomas Haller3fe34542017-10-09 13:14:55 +020037 [libnl_major_version.libnl_minor_version.libnl_micro_version])
Thomas Graf4c210ad2011-09-13 22:58:08 +020038
Thomas Hallere4402a42023-08-29 10:12:38 +020039AC_INIT([libnl],[libnl_version],[],[],[http://www.infradead.org/~tgr/libnl/])
Thomas Haller8952ce6f2023-08-02 16:00:37 +020040AC_CONFIG_HEADERS([include/config.h])
Jan Engelhardtf3cd3fe2012-11-26 20:51:51 +010041AC_CONFIG_AUX_DIR([build-aux])
Jan Engelhardtbf4fd3a2009-06-23 01:12:53 +020042AC_CONFIG_MACRO_DIR([m4])
Thomas Haller5761b6a2023-08-29 10:05:28 +020043AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
Reuben Hawkinsb5c474e2011-02-17 21:28:50 -080044m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)], [])
Jan Engelhardt9d925642012-11-26 20:49:02 +010045m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
Thomas Graf44d36242007-09-15 01:28:01 +020046
Thomas Graf4c210ad2011-09-13 22:58:08 +020047MAJ_VERSION=libnl_major_version
48AC_SUBST(MAJ_VERSION)
49MIN_VERSION=libnl_minor_version
50AC_SUBST(MIN_VERSION)
51MIC_VERSION=libnl_micro_version
52AC_SUBST(MIC_VERSION)
Thomas Haller94e13452014-07-04 19:58:04 +020053LIBNL_GIT_SHA=libnl_git_sha
Thomas Graf4c210ad2011-09-13 22:58:08 +020054LIBNL_VERSION=libnl_version
55AC_SUBST(LIBNL_VERSION)
56
57LT_CURRENT=libnl_lt_current
58AC_SUBST(LT_CURRENT)
59LT_REVISION=libnl_lt_revision
60AC_SUBST(LT_REVISION)
61LT_AGE=libnl_lt_age
62AC_SUBST(LT_AGE)
Thomas Grafd8d67c02011-03-16 13:46:41 +010063
Thomas Haller94518422024-05-29 16:10:53 +020064AC_USE_SYSTEM_EXTENSIONS
65
Thomas Graf44d36242007-09-15 01:28:01 +020066AC_PROG_CC
Jan Engelhardtbf4fd3a2009-06-23 01:12:53 +020067AM_PROG_CC_C_O
Thomas Haller18b74e02024-05-06 10:39:30 +020068AC_PROG_CXX
Thomas Graf44d36242007-09-15 01:28:01 +020069AC_PROG_INSTALL
Thomas Hallere4402a42023-08-29 10:12:38 +020070LT_INIT
Michał Górny4dc72462014-05-25 11:49:19 +020071AC_PROG_MKDIR_P
Thomas Graf0a9d5fc2012-11-23 16:40:14 +010072AC_CHECK_PROGS(FLEX, 'flex')
Richard Marshalla2c4bd82012-11-19 20:20:22 -080073AC_CHECK_PROGS(YACC, 'bison -y')
Thomas Graf44d36242007-09-15 01:28:01 +020074
75AC_C_CONST
76AC_C_INLINE
77
Thomas Haller18b74e02024-05-06 10:39:30 +020078AC_LANG_PUSH([C++])
79AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
80 [[#ifndef __cplusplus
81 #error "broken C++"
82 #endif]])],,
83 [CXX=;])
84AC_LANG_POP([C++])
85AM_CONDITIONAL([HAS_CXX], [test "x$CXX" != x])
86
Thomas Grafead4cde2013-04-27 14:27:10 +020087PKG_CHECK_MODULES([CHECK], [check >= 0.9.0],
Thomas Haller7b375952017-02-26 21:25:28 +010088 [has_check="yes"],
Thomas Grafead4cde2013-04-27 14:27:10 +020089 [AC_MSG_WARN([*** Disabling building of unit tests])
Thomas Haller7b375952017-02-26 21:25:28 +010090 has_check="no"])
91AM_CONDITIONAL(WITH_CHECK, [test "$has_check" = 'yes'])
Thomas Grafe09e7f12013-03-14 16:25:17 +010092
Jan Engelhardtbf4fd3a2009-06-23 01:12:53 +020093AC_ARG_WITH([pkgconfigdir], AS_HELP_STRING([--with-pkgconfigdir=PATH],
94 [Path to the pkgconfig directory [[LIBDIR/pkgconfig]]]),
95 [pkgconfigdir="$withval"], [pkgconfigdir='${libdir}/pkgconfig'])
96AC_SUBST([pkgconfigdir])
Thomas Graf44d36242007-09-15 01:28:01 +020097
Karl Hiramoto018c2972010-06-16 16:33:51 +020098AC_ARG_ENABLE([cli],
Thomas Hallerff19c782015-03-18 15:20:28 +010099 AS_HELP_STRING([--enable-cli=yes|no|no-inst|bin|sbin], [Whether to build command line interface utils. Defaults to 'yes' which is a synonym for 'bin'. 'no-inst' means only build, not installing. 'bin'/'sbin' means installing to bin/sbin directory]),
Karl Hiramoto018c2972010-06-16 16:33:51 +0200100 [enable_cli="$enableval"], [enable_cli="yes"])
Thomas Hallerff19c782015-03-18 15:20:28 +0100101if test "$enable_cli" != "no" &&
102 test "$enable_cli" != "no-inst" &&
103 test "$enable_cli" != "sbin"; then
104 enable_cli="bin"
105fi
106AM_CONDITIONAL([ENABLE_CLI], [test "$enable_cli" != "no"])
107AM_CONDITIONAL([ENABLE_CLI_INSTALL_BIN], [test "$enable_cli" = "bin"])
108AM_CONDITIONAL([ENABLE_CLI_INSTALL_SBIN], [test "$enable_cli" = "sbin"])
Karl Hiramoto018c2972010-06-16 16:33:51 +0200109
Thomas Hallerc881a272017-05-12 12:47:19 +0200110AC_CHECK_HEADERS(dlfcn.h, [], [])
111
Rich Foughta8ef3522012-10-26 12:19:26 -0700112AC_ARG_ENABLE([pthreads],
113 AS_HELP_STRING([--disable-pthreads], [Disable pthreads support]),
114 [enable_pthreads="$enableval"], [enable_pthreads="yes"])
115AM_CONDITIONAL([DISABLE_PTHREADS], [test "$enable_pthreads" = "no"])
Rich Foughta8ef3522012-10-26 12:19:26 -0700116if test "x$enable_pthreads" = "xno"; then
117 AC_DEFINE([DISABLE_PTHREADS], [1], [Define to 1 to disable pthreads])
118else
119 AC_CHECK_LIB([pthread], [pthread_mutex_lock], [], AC_MSG_ERROR([libpthread is required]))
120fi
Thomas Graf44d36242007-09-15 01:28:01 +0200121
Thomas Hallerfa7f97f2022-04-15 13:29:49 +0200122AM_CONDITIONAL([ENABLE_STATIC], [test "$enable_static" != "no"])
123
Thomas Hallerf0af5d52017-02-28 00:34:46 +0100124AC_ARG_ENABLE([debug],
Thomas Hallere592dd82024-04-22 08:51:58 +0200125 AS_HELP_STRING([--disable-debug], [Do not include debugging statements]),
126 [enable_debug="$enableval"], [enable_debug="yes"])
127if test "$enable_debug" = "yes"; then
Thomas Grafff567102013-04-02 11:39:30 +0200128 AC_DEFINE([NL_DEBUG], [1], [Define to 1 to enable debugging])
Thomas Hallere592dd82024-04-22 08:51:58 +0200129else
130 enable_debug=no
131 AC_DEFINE([NL_DEBUG], [0], [Define to 1 to enable debugging])
Thomas Grafff567102013-04-02 11:39:30 +0200132fi
133
Thomas Grafdb138432012-10-19 16:16:06 +0200134AC_CONFIG_SUBDIRS([doc])
135
Alexey Brodkine15966a2017-03-10 17:44:22 +0300136AC_CHECK_FUNCS([strerror_l])
137
Thomas Haller40578a62023-08-18 12:38:40 +0200138AC_CHECK_DECLS([getprotobyname_r, getprotobynumber_r], [], [], [[
139 #include <netdb.h>
140]])
141
Thomas Graf4c210ad2011-09-13 22:58:08 +0200142AC_CONFIG_FILES([
143Makefile
144libnl-3.0.pc
145libnl-route-3.0.pc
146libnl-genl-3.0.pc
147libnl-nf-3.0.pc
Jiří Župkaf90dc632011-10-04 16:06:22 +0200148libnl-cli-3.0.pc
Sruthi Yellamraju91715442014-07-20 15:57:33 +0200149libnl-xfrm-3.0.pc
Sébastien Barré15780952014-09-18 12:17:39 +0200150libnl-idiag-3.0.pc
Thomas Graf4c210ad2011-09-13 22:58:08 +0200151python/setup.py
Thomas Graf4c210ad2011-09-13 22:58:08 +0200152include/netlink/version.h
153])
154
Richard Marshalla2c4bd82012-11-19 20:20:22 -0800155ac_errcount=0
156if test -z "$YACC"; then
157 AC_MSG_WARN(bison not found. Please install before continuing.)
158 ac_errcount=$((ac_errcount + 1))
159fi
Thomas Graf0a9d5fc2012-11-23 16:40:14 +0100160if test -z "$FLEX"; then
161 AC_MSG_WARN(flex not found. Please install before continuing.)
Richard Marshalla2c4bd82012-11-19 20:20:22 -0800162 ac_errcount=$((ac_errcount + 1))
163fi
164if test $ac_errcount -gt 0; then
165 AC_MSG_ERROR(Required packages are missing. Please install them and rerun ./configure)
166fi
167
Jan Engelhardtbf4fd3a2009-06-23 01:12:53 +0200168AC_OUTPUT
Thomas Graf6e5332b2011-09-13 11:49:41 +0200169
Thomas Haller18b74e02024-05-06 10:39:30 +0200170CXX_MSG="none"
171if test "x$CXX" != x ; then
172 CXX_MSG="[$CXX]"
173fi
174
Thomas Haller1558bd62023-08-29 10:32:04 +0200175echo
176echo "libnl $LIBNL_VERSION configuration${LIBNL_GIT_SHA:+ (git:$LIBNL_GIT_SHA)}:"
177echo " --enable-pthreads=$enable_pthreads"
178echo " --enable-static=$enable_static"
179echo
180echo " --enable-debug=$enable_debug"
181echo " --enable-cli=$enable_cli"
182echo
183echo " check: $has_check"
Thomas Haller18b74e02024-05-06 10:39:30 +0200184echo " CXX: $CXX_MSG (only used for tests)"
Thomas Haller1558bd62023-08-29 10:32:04 +0200185echo