xref: /aosp_15_r20/external/libnl/configure.ac (revision 4dc78e53d49367fa8e61b07018507c90983a077d)
1# SPDX-License-Identifier: LGPL-2.1-only
2
3#
4# Copyright (c) 2003-2013 Thomas Graf <[email protected]>
5#
6
7# copied from glib
8m4_define([libnl_major_version], [3])
9m4_define([libnl_minor_version], [10])
10m4_define([libnl_micro_version], [0])
11m4_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 ])])
12
13
14# 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:
17#
18# 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.
22#
23# 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.
31
32m4_define([libnl_lt_current],    [226])
33m4_define([libnl_lt_revision],   [0])
34m4_define([libnl_lt_age],        [26])
35
36m4_define([libnl_version],
37	  [libnl_major_version.libnl_minor_version.libnl_micro_version])
38
39AC_INIT([libnl],[libnl_version],[],[],[http://www.infradead.org/~tgr/libnl/])
40AC_CONFIG_HEADERS([include/config.h])
41AC_CONFIG_AUX_DIR([build-aux])
42AC_CONFIG_MACRO_DIR([m4])
43AM_INIT_AUTOMAKE([-Wall -Wno-portability foreign subdir-objects])
44m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)], [])
45m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
46
47MAJ_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)
53LIBNL_GIT_SHA=libnl_git_sha
54LIBNL_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)
63
64AC_USE_SYSTEM_EXTENSIONS
65
66AC_PROG_CC
67AM_PROG_CC_C_O
68AC_PROG_CXX
69AC_PROG_INSTALL
70LT_INIT
71AC_PROG_MKDIR_P
72AC_CHECK_PROGS(FLEX, 'flex')
73AC_CHECK_PROGS(YACC, 'bison -y')
74
75AC_C_CONST
76AC_C_INLINE
77
78AC_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
87PKG_CHECK_MODULES([CHECK], [check >= 0.9.0],
88	[has_check="yes"],
89	[AC_MSG_WARN([*** Disabling building of unit tests])
90	 has_check="no"])
91AM_CONDITIONAL(WITH_CHECK, [test "$has_check" = 'yes'])
92
93AC_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])
97
98AC_ARG_ENABLE([cli],
99	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]),
100	[enable_cli="$enableval"], [enable_cli="yes"])
101if 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"])
109
110AC_CHECK_HEADERS(dlfcn.h, [], [])
111
112AC_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"])
116if 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
121
122AM_CONDITIONAL([ENABLE_STATIC], [test "$enable_static" != "no"])
123
124AC_ARG_ENABLE([debug],
125        AS_HELP_STRING([--disable-debug], [Do not include debugging statements]),
126        [enable_debug="$enableval"], [enable_debug="yes"])
127if test "$enable_debug" = "yes"; then
128    AC_DEFINE([NL_DEBUG], [1], [Define to 1 to enable debugging])
129else
130    enable_debug=no
131    AC_DEFINE([NL_DEBUG], [0], [Define to 1 to enable debugging])
132fi
133
134AC_CONFIG_SUBDIRS([doc])
135
136AC_CHECK_FUNCS([strerror_l])
137
138AC_CHECK_DECLS([getprotobyname_r, getprotobynumber_r], [], [], [[
139    #include <netdb.h>
140]])
141
142AC_CONFIG_FILES([
143Makefile
144libnl-3.0.pc
145libnl-route-3.0.pc
146libnl-genl-3.0.pc
147libnl-nf-3.0.pc
148libnl-cli-3.0.pc
149libnl-xfrm-3.0.pc
150libnl-idiag-3.0.pc
151python/setup.py
152include/netlink/version.h
153])
154
155ac_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
160if test -z "$FLEX"; then
161    AC_MSG_WARN(flex not found. Please install before continuing.)
162    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
168AC_OUTPUT
169
170CXX_MSG="none"
171if test "x$CXX" != x ; then
172	CXX_MSG="[$CXX]"
173fi
174
175echo
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"
184echo "    CXX: $CXX_MSG (only used for tests)"
185echo
186