forked from CESNET/netopeer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
458 lines (390 loc) · 13.9 KB
/
configure.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
#
# Copyright (c) 2011 CESNET
#
# LICENSE TERMS
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of the Company nor the names of its contributors
# may be used to endorse or promote products derived from this
# software without specific prior written permission.
#
# ALTERNATIVELY, provided that this notice is retained in full, this
# product may be distributed under the terms of the GNU General Public
# License (GPL) version 2 or later, in which case the provisions
# of the GPL apply INSTEAD OF those given above.
#
# This software is provided ``as is'', and any express or implied
# warranties, including, but not limited to, the implied warranties of
# merchantability and fitness for a particular purpose are disclaimed.
# In no event shall the company or contributors be liable for any
# direct, indirect, incidental, special, exemplary, or consequential
# damages (including, but not limited to, procurement of substitute
# goods or services; loss of use, data, or profits; or business
# interruption) however caused and on any theory of liability, whether
# in contract, strict liability, or tort (including negligence or
# otherwise) arising in any way out of the use of this software, even
# if advised of the possibility of such damage.
#
# $Id$
#
# Process this file with autoconf to produce a configure script.
AC_INIT([netopeer-server], m4_esyscmd([cut -f1 ./VERSION | tr -d '\n']))
m4_include([m4/ax_pthread.m4])
m4_include([m4/ax_python_module.m4])
PACKAGE_VERSION=`cut -f1 ./VERSION | tr -d '\n'`
AC_SUBST(PACKAGE_VERSION)
RELEASE=1
AC_SUBST(RELEASE)
if test "`git show > /dev/null 2>&1;echo $?`" = "0"; then
CPPFLAGS="$CPPFLAGS -DRCSID=\\\"\$(IDGIT)\\\""
else
CPPFLAGS="$CPPFLAGS -DRCSID=\\\"\$(IDNOGIT)\\\""
fi
USERNAME=`git config --get user.name`
USERMAIL=`git config --get user.email`
AC_SUBST(USERNAME)
AC_SUBST(USERMAIL)
CONFIGURE_PWD=`pwd`
AC_SUBST(CONFIGURE_PWD)
# Check for pkg-config.
AC_PATH_PROG(PKG_CONFIG, [pkg-config], [no])
if test "x$PKG_CONFIG" = "xno"; then
AC_MSG_ERROR(['pkgconfig' not found.])
fi
# check for roff2html from groff
AC_PATH_PROG([ROFF2HTML], [roff2html], [no])
# expand libdir
expanded_libdir=`(
case $prefix in
NONE) prefix=$ac_default_prefix ;;
*) ;;
esac
case $exec_prefix in
NONE) exec_prefix=$prefix ;;
*) ;;
esac
eval echo $libdir
)`
# check for Linux distribution
AC_ARG_WITH([distro],
AC_HELP_STRING([--with-distro=DISTRO],[Compile for specific Linux distribution]),
DISTRO=`echo $withval | tr A-Z a-z`,
if test -n "`cat /proc/version | grep 'Red Hat'`"; then
DISTRO=redhat;
else
DISTRO=`cat /etc/*release | grep ^ID= | sed 's/.*=//'`;
fi
)
AC_MSG_CHECKING([for distro])
AC_MSG_RESULT([$DISTRO])
case $DISTRO in
rhel | redhat | centos | fedora )
# ok, supported distro
# pkg-config does not check /usr/local/*/pkgconfig, fix it
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$expanded_libdir/pkgconfig"
;;
opensuse | suse )
# ok, supported distros
;;
* )
# unknown
AC_MSG_WARN([Unsupported Linux distro \"$DISTRO\", only RHEL and SUSE are fully supported.])
;;
esac
CFLAGS="-Wall -Wextra"
# --enable-debug
AC_ARG_ENABLE([debug],
AC_HELP_STRING([--enable-debug],[Compile with debug options]),
CFLAGS="$CFLAGS -g -O0 -DDEBUG",
CFLAGS="$CFLAGS -O3"
)
# --enable-configurator
AC_ARG_ENABLE([configurator],
AC_HELP_STRING([--disable-configurator], [Compile without netopeer-configurator (python not required)]),
if test "$enableval" = "no"; then
NPCONF=no
CONFIGURE_PARAMS="$CONFIGURE_PARAMS --disable-configurator"
else
NPCONF=yes
fi
,
NPCONF=yes
)
# --enable-ssh
AC_ARG_ENABLE([ssh],
AC_HELP_STRING([--disable-ssh], [Compile without SSH transport]),
if test "$enableval" = "no"; then
SSH=no
CONFIGURE_PARAMS="$CONFIGURE_PARAMS --disable-ssh"
else
SSH=yes
fi
,
# SSH is on by default
SSH=yes
)
# --enable-tls
AC_ARG_ENABLE([tls],
AC_HELP_STRING([--enable-tls], [Compile with TLS transport]),
if test "$enableval" = "no"; then
TLS=no
else
TLS=yes
CONFIGURE_PARAMS="$CONFIGURE_PARAMS --enable-tls"
fi
,
TLS=no
)
AC_ARG_WITH([lnctool],
AC_HELP_STRING([--with-lnctool=PATH], [Set path of lnctool, otherwise $PATH will be used]),
LNCTOOL=$with_lnctool,
LNCTOOL=lnctool
)
AC_ARG_WITH([libnetconf],
AC_HELP_STRING([--with-libnetconf=PATH],[Set explicit installation prefix to the libnetconf library]),
[CPPFLAGS="-I$withval/include/ $CPPFLAGS"
LIBS="-L$withval/lib/ -Wl,-rpath,$withval/lib $LIBS"
CONFIGURE_PARAMS="$CONFIGURE_PARAMS --with-libnetconf=$withval"
LIBNETCONF_DATADIR="$withval/share/"
],[
# get info from pkg-config about installed package
PKG_CHECK_MODULES(LIBNETCONF, libnetconf)
CPPFLAGS="$LIBNETCONF_CFLAGS $CPPFLAGS"
LIBS="$LIBNETCONF_LIBS $LIBS"
LIBNETCONF_DATADIR="`$PKG_CONFIG --variable=datadir libnetconf`"]
)
REQS="$REQS libnetconf"
BUILDREQS="$BUILDREQS libnetconf-devel"
############################ Check for programs ################################
# in case of cross-compilation, try to gues cross-compiler if not set
if test "x$target" != "x$host" -a -z "`echo $CC | grep -e '-gcc'`";
then
AC_MSG_CHECKING(for cross-compiler)
which ${program_prefix}gcc >/dev/null 2>&1 && CC=${program_prefix}gcc
which ${target_cpu}-${target_os}-gcc >/dev/null 2>&1 \
&& CC=${target_cpu}-${target-os}-gcc
which ${target_cpu}-${target_vendor}-${target_os}-gcc >/dev/null 2>&1 \
&& CC=${target_cpu}-${target_vendor}-${target_os}-gcc
AC_MSG_RESULT($CC)
fi
# Check for architecture, only x86 and x86_64 are supported
if test -z "$target_cpu";
then
AC_CHECK_PROG([UNAME], [uname], [yes], [no])
if test "$UNAME" = "no"; then
AC_MSG_ERROR(["uname not found!"])
fi
target_cpu=`uname -m`
fi
AC_MSG_CHECKING([for host architecture])
case $target_cpu in
i?86 )
AC_MSG_RESULT($target_cpu)
;;
x86_64 )
libdir='${prefix}/lib64'
AC_MSG_RESULT($target_cpu)
;;
* )
AC_MSG_ERROR([unsupported architecture $target_cpu])
;;
esac
#Add the standard modules to a variable for pyang to find them
if test -d "/usr/local/share/yang/modules/"; then
export YANG_MODPATH=$YANG_MODPATH:/usr/local/share/yang/modules/
fi
if test -d "/usr/share/yang/modules/"; then
export YANG_MODPATH=$YANG_MODPATH:/usr/share/yang/modules/
fi
# Check for lnctool
if test "$LNCTOOL" = "lnctool"; then
AC_CHECK_PROG([LNCTOOL_EXISTS], [lnctool], [yes], [no])
if test "$LNCTOOL_EXISTS" = "no"; then
AC_MSG_ERROR(["lnctool not found!"])
fi
fi
# Check python for manager and configurator
AX_PYTHON_MODULE(os, fatal)
AX_PYTHON_MODULE(copy, fatal)
AX_PYTHON_MODULE(curses, fatal)
AX_PYTHON_MODULE(libxml2, fatal)
AX_PYTHON_MODULE(subprocess, fatal)
AX_PYTHON_MODULE(re, fatal)
AX_PYTHON_MODULE(string, fatal)
AX_PYTHON_MODULE(argparse, fatal)
AX_PYTHON_MODULE(xml, fatal)
BUILDREQS="$BUILDREQS python"
REQS="$REQS python"
# Check for rpmbuild
AC_CHECK_PROG(RPMBUILD, rpmbuild, rpmbuild)
# Check for standard programs
AC_PROG_CC(clang llvm-gcc gcc)
AC_PROG_INSTALL
############################ Check for libraries ###############################
export PKG_CONFIG_PATH=/usr/local/${libdir##*/}/pkgconfig:$PKG_CONFIG_PATH
### LibXML2 ###
# Test whether Libxml2 exist
if test -n "$with_libxml2_path" ; then
LIBS_LIB_XML="-lxml2"
LDFLAGS_LIB_XML="-L$with_libxml2_path/lib"
else
AC_CHECK_LIB([xml2], [main],
[ LIBS_LIB_XML="-lxml2"],
[ echo "Libxml2 not found - exiting! (use --with-libxml2-path=DIR if you has it in some other directory)" ; exit 1 ])
fi
AC_CHECK_PROG([XML2_CONFIG], [xml2-config], ["yes"], ["no"])
if test "$XML2_CONFIG" = "no"; then
echo "xml2-config not found - exiting!"
exit 1
fi
CPPFLAGS="$CPPFLAGS `xml2-config --cflags`"
LIBS="$LIBS $LIBS_LIB_XML"
LDFLAGS="$LDFLAGS $LDFLAGS_LIB_XML"
BUILDREQS="$BUILDREQS libxml2-devel"
REQS="$REQS libxml2"
# libnetconf
AC_SEARCH_LIBS([ncntf_dispatch_receive], [netconf], [], AC_MSG_ERROR([libnetconf not found or not supporting notifications!]))
if test "$SSH" = "yes"; then
AC_CHECK_LIB([netconf], [nc_session_accept_libssh_channel], [], [
AC_MSG_NOTICE(); AC_MSG_WARN([libnetconf does not support SSH, disabling it!]); AC_MSG_NOTICE(); SSH=no
])
fi
if test "$SSH" = "yes"; then
# libssh
AC_SEARCH_LIBS([ssh_pki_key_ecdsa_name], [ssh], [], [AC_MSG_ERROR([Missing the libssh library (>= 0.6.4).])])
# libcrypt
AC_SEARCH_LIBS([crypt], [crypt], [], [AC_MSG_ERROR([Missing the libcrypt library.])])
fi
if test "$TLS" = "yes"; then
AC_CHECK_LIB([netconf], [nc_session_accept_tls], [], [
AC_MSG_NOTICE(); AC_MSG_WARN([libnetconf does not support TLS, disabling it!]); AC_MSG_NOTICE(); TLS=no
])
fi
if test "$TLS" = "yes"; then
# libssl
AC_SEARCH_LIBS([SSL_library_init], [ssl], [], [AC_MSG_ERROR([Missing the libssl library.])])
# libcrypto
AC_SEARCH_LIBS([X509_free], [crypto], [], [AC_MSG_ERROR([Missing the libcrypto library.])])
# M2Crypto python module
AX_PYTHON_MODULE(M2Crypto, fatal)
fi
# pthread
AX_PTHREAD([
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"],
AC_MSG_ERROR([Missing POSIX threads support.])
)
# specify netopeer modules location
AC_ARG_WITH([modules-dir],
AC_HELP_STRING([--with-modules-dir=DIR],
[path to directory where netopeer modules configuration will be stored
($(sysconfdir)/netopeer/modules.conf.d/ by default)])
,
MODULESDIR="$withval"
,
MODULESDIR="${sysconfdir}/netopeer/modules.conf.d/"
)
# remove backup files
rm -f config/Netopeer.xml.orig
rm -f config/NETCONF-server.xml.orig
SERVER_LIBS=$LIBS
###################### Check for configure parameters ##########################
SERVER_TRANSPORT_SRCS=""
SERVER_TRANSPORT_HDRS=""
SERVER_TLS_CFGS=""
CLIENT_STRUCT_SIZE=""
NCSERVER_FEATURES=""
NETOPEER_FEATURES="<feature>dynamic-modules</feature>"
IETF_NETCONF_SERVER_FEATURES="--feature ietf-netconf-server:"
CFGNETOPEER_FEATURES="--feature netopeer-cfgnetopeer:dynamic-modules"
if test "$SSH" = "yes"; then
CFLAGS="$CFLAGS -DNP_SSH"
SERVER_TRANSPORT_SRCS="src/ssh/server_ssh.c src/ssh/cfgnetopeer_transapi_ssh.c src/ssh/netconf_server_transapi_ssh.c"
SERVER_TRANSPORT_HDRS="src/ssh/server_ssh.h src/ssh/cfgnetopeer_transapi_ssh.h src/ssh/netconf_server_transapi_ssh.h"
CLIENT_STRUCT_SIZE="sizeof(struct client_struct_ssh)"
NCSERVER_FEATURES="<feature>ssh</feature><feature>inbound-ssh</feature><feature>outbound-ssh</feature>"
NETOPEER_FEATURES="${NETOPEER_FEATURES}<feature>ssh</feature>"
IETF_NETCONF_SERVER_FEATURES="${IETF_NETCONF_SERVER_FEATURES}ssh,inbound-ssh,outbound-ssh"
CFGNETOPEER_FEATURES="${CFGNETOPEER_FEATURES},ssh"
fi
if test "$TLS" = "yes"; then
CFLAGS="$CFLAGS -DNP_TLS"
SERVER_TRANSPORT_SRCS="$SERVER_TRANSPORT_SRCS src/tls/server_tls.c src/tls/cfgnetopeer_transapi_tls.c src/tls/netconf_server_transapi_tls.c"
SERVER_TRANSPORT_HDRS="$SERVER_TRANSPORT_HDRS src/tls/server_tls.h src/tls/cfgnetopeer_transapi_tls.h src/tls/netconf_server_transapi_tls.h"
SERVER_TLS_CFGS="config/datastore.xml"
if test "$SSH" = "yes"; then
CLIENT_STRUCT_SIZE="sizeof(struct client_struct_tls) > sizeof(struct client_struct_ssh) ? sizeof(struct client_struct_tls) : sizeof(struct client_struct_ssh)"
else
CLIENT_STRUCT_SIZE="sizeof(struct client_struct_tls)"
fi
NCSERVER_FEATURES="${NCSERVER_FEATURES}<feature>tls</feature><feature>inbound-tls</feature><feature>outbound-tls</feature>"
NETOPEER_FEATURES="${NETOPEER_FEATURES}<feature>tls</feature>"
if test "$SSH" = "yes"; then
IETF_NETCONF_SERVER_FEATURES="${IETF_NETCONF_SERVER_FEATURES},"
fi
IETF_NETCONF_SERVER_FEATURES="${IETF_NETCONF_SERVER_FEATURES}tls,inbound-tls,outbound-tls"
CFGNETOPEER_FEATURES="${CFGNETOPEER_FEATURES},tls"
fi
if (test "$SSH" = "no") && (test "$TLS" = "no"); then
AC_MSG_ERROR([Cannot compile without any transport protocol!])
fi
# Generate correct validation files
AC_MSG_NOTICE([generating validation files...])
$LNCTOOL --model $PWD/config/ietf-netconf-server.yang $IETF_NETCONF_SERVER_FEATURES --search-path $PWD/config/ --output-dir $PWD/config/ validation;
if test "$?" != "0"; then
AC_MSG_ERROR([Generating validation files for ietf-netconf-server failed.])
fi
$LNCTOOL --model $PWD/config/netopeer-cfgnetopeer.yang $CFGNETOPEER_FEATURES --search-path $PWD/config/ --output-dir $PWD/config/ validation;
if test "$?" != "0"; then
AC_MSG_ERROR([Generating validation files for netopeer-cfgnetopeer failed.])
fi
######################### Checks for header files ##############################
AC_CHECK_HEADERS([stdlib.h string.h sys/time.h unistd.h])
AC_CHECK_HEADERS([libnetconf_xml.h libxml/tree.h])
######## Checks for typedefs, structures, and compiler characteristics #########
AC_TYPE_INT32_T
AC_TYPE_UINT32_T
######################## Checks for library functions ##########################
AC_FUNC_MALLOC
AC_CHECK_FUNCS([select strdup strerror])
############################### Set output #####################################
AC_SUBST(ROFF2HTML)
AC_SUBST(BUILDREQS)
AC_SUBST(REQS)
AC_SUBST(CONFIGURE_PARAMS)
AC_SUBST(LIBNETCONF_DATADIR)
AC_SUBST(DISTRO)
AC_SUBST(NPCONF)
AC_SUBST(SERVER_LIBS)
AC_SUBST(MODULESDIR)
AC_SUBST(SERVER_TRANSPORT_SRCS)
AC_SUBST(SERVER_TRANSPORT_HDRS)
AC_SUBST(SERVER_TLS_CFGS)
AC_SUBST(CLIENT_STRUCT_SIZE)
AC_SUBST(NCSERVER_FEATURES)
AC_SUBST(NETOPEER_FEATURES)
AC_SUBST(SSH)
AC_SUBST(TLS)
AC_SUBST(RPMBUILD)
if test -z "$RPMBUILD"; then
AC_MSG_WARN([Due to missing rpmbuild you will not be able to generate RPM package.])
fi
AC_CONFIG_FILES(Makefile)
AC_CONFIG_FILES(manager/netopeer-manager.tmp:manager/netopeer-manager.in)
AC_CONFIG_FILES(config/Netopeer.xml.tmp:config/Netopeer.xml.in)
AC_CONFIG_FILES(config/NETCONF-server.xml.tmp:config/NETCONF-server.xml.in)
AC_CONFIG_FILES(src/config.h)
AC_CONFIG_FILES(netopeer-server.spec)
AC_CONFIG_FILES(netopeer.rc)
if test "$NPCONF" = "yes"; then
AC_CONFIG_FILES(configurator/netopeer/config.py)
fi
AC_OUTPUT