blob: b62a6b38de1ff5e5760af6fec65b3713c77868ff [file] [log] [blame]
Tomas Cejka50c076e2014-03-18 15:31:10 +01001# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
4AC_PREREQ([2.63])
Michal Vaskoa53ef882015-11-24 11:02:01 +01005AC_INIT([netopeerguid], [1.0.2], [mvasko@cesnet.cz])
Tomas Cejka50c076e2014-03-18 15:31:10 +01006AM_INIT_AUTOMAKE([silent-rules])
7AM_SILENT_RULES([yes])
8
9USERNAME=`git config --get user.name`
10USERMAIL=`git config --get user.email`
11AC_SUBST(USERNAME)
12AC_SUBST(USERMAIL)
13
14RELEASE=1
15AC_SUBST(RELEASE)
Tomas Cejka50c076e2014-03-18 15:31:10 +010016
Tomas Cejka04e08f42014-03-27 19:52:34 +010017AC_ARG_VAR(SU_USER, [Change UID of process according to username.])
18if test "x$SU_USER" == x; then
19 SU_USER=""
20fi
21AC_SUBST([SU_USER])
22
23AC_ARG_VAR(SU_GROUP, [Change GID of process according to groupname.])
24if test "x$SU_GROUP" == x; then
25 SU_GROUP=""
26fi
27AC_SUBST([SU_GROUP])
28
29AC_ARG_VAR(CHOWN_USER, [Use chown (user) on socket file.])
30if test "x$CHOWN_USER" == x; then
31 CHOWN_USER=""
32fi
33AC_SUBST([CHOWN_USER])
34
35AC_ARG_VAR(CHOWN_GROUP, [Use chown (group) on socket file.])
36if test "x$CHOWN_GROUP" == x; then
37 CHOWN_GROUP=""
38fi
39AC_SUBST([CHOWN_GROUP])
40
Tomas Cejka18e505a2016-03-14 09:43:46 -040041AC_DEFINE_DIR(absbindir, [bindir], [Path to binaries])
42
Tomas Cejka50c076e2014-03-18 15:31:10 +010043# Check for rpmbuild
44AC_CHECK_PROG(RPMBUILD, [rpmbuild], [rpmbuild], [""])
Tomas Cejka50c076e2014-03-18 15:31:10 +010045
Tomas Cejka50c076e2014-03-18 15:31:10 +010046# Check for rpmbuild
47AC_CHECK_PROG(RPMBUILD, rpmbuild, rpmbuild, [""])
48RPM_RELEASE=1
49AC_SUBST(RPM_RELEASE)
50AM_CONDITIONAL(MAKE_RPMS, test x$RPMBUILD != x)
51
52# Checks for libraries.
53# save clean LIBS and CFLAGS
54SAVEDTEMP_LIBS=$LIBS
55SAVEDTEMP_CFLAGS=$CFLAGS
Michal Vasko01a4f0e2016-03-15 16:19:59 +010056PKG_CHECK_MODULES([json], [json-c])
Michal Vaskof35ea502016-02-24 10:44:54 +010057PKG_CHECK_MODULES([netconf2], [libnetconf2])
Michal Vaskoda0ab5c2015-11-13 13:24:51 +010058PKG_CHECK_MODULES([yang], [libyang])
Michal Vaskoc3146782015-11-04 14:46:41 +010059AX_PTHREAD([CC="$PTHREAD_CC"], [AC_MSG_ERROR([pthread not found])])
Michal Vaskof35ea502016-02-24 10:44:54 +010060CFLAGS="-Wall -Wextra $json_CFLAGS $netconf2_CFLAGS $yang_FLAGS $PTHREAD_CFLAGS"
61LIBS="$json_LIBS $netconf2_LIBS $yang_LIBS $PTHREAD_LIBS"
Tomas Cejka50c076e2014-03-18 15:31:10 +010062
Michal Vasko4d9c0af2016-09-22 14:26:11 +020063AC_ARG_WITH([notifications],
64 [AC_HELP_STRING([--without-notifications], [Disable notifications])],
65 [AS_IF([test "x$with_notifications" == "xno"],[CFLAGS="$CFLAGS"],
66 [PKG_CHECK_MODULES([websockets], [libwebsockets],
67 [CFLAGS="$CFLAGS $websockets_CFLAGS -DWITH_NOTIFICATIONS" LIBS="$LIBS $websockets_LIBS"])])],
68 [PKG_CHECK_MODULES([websockets], [libwebsockets],
69 [CFLAGS="$CFLAGS $websockets_CFLAGS -DWITH_NOTIFICATIONS" LIBS="$LIBS $websockets_LIBS"])]
70)
71
Michal Vaskodd2c41d2016-09-06 11:25:57 +020072AC_ARG_WITH([cert-path],
73 AC_HELP_STRING([--with-cert-path], [Set notification server certificate]),
74 CERT_PATH="$withval",
Michal Vasko4d9c0af2016-09-22 14:26:11 +020075 [AS_IF([test "x$with_notifications" == "xno"], [], [AC_MSG_ERROR([Certificate path must be set.])])]
Michal Vaskodd2c41d2016-09-06 11:25:57 +020076)
77AC_SUBST([CERT_PATH])
78
79AC_ARG_WITH([private-key-path],
80 AC_HELP_STRING([--with-private-key-path], [Set notification server private key]),
81 PRIVKEY_PATH="$withval",
Michal Vasko4d9c0af2016-09-22 14:26:11 +020082 [AS_IF([test "x$with_notifications" == "xno"], [], [AC_MSG_ERROR([Private key path must be set.])])]
Michal Vaskodd2c41d2016-09-06 11:25:57 +020083)
84AC_SUBST([PRIVKEY_PATH])
85
Michal Vaskofb93be62016-03-11 09:52:14 +010086AC_ARG_ENABLE([debug],
87 AC_HELP_STRING([--enable-debug],[Compile with debug options]),
Michal Vaskoa7197102016-04-06 11:17:52 +020088 CFLAGS="$CFLAGS -g -O0 -DDBG"
Michal Vaskofb93be62016-03-11 09:52:14 +010089 CONFIGURE_PARAMS="--enable-debug $CONFIGURE_PARAMS",
90 CFLAGS="$CFLAGS -O3"
91)
92
Tomas Cejka50c076e2014-03-18 15:31:10 +010093# Checks for header files.
94AC_CHECK_HEADERS([fcntl.h stdlib.h string.h sys/socket.h sys/time.h unistd.h])
95
96# Checks for typedefs, structures, and compiler characteristics.
97AC_TYPE_INT64_T
98AC_TYPE_SIZE_T
99AC_TYPE_SSIZE_T
100
101# Checks for library functions.
102AC_FUNC_MALLOC
103AC_FUNC_REALLOC
104AC_CHECK_FUNCS([getdelim gettimeofday memset socket strdup strerror])
105
Tomas Cejkac95271a2016-03-02 09:07:19 +0100106# allow to skip systemd, enabled by default
107AC_ARG_WITH([systemd],
108 AC_HELP_STRING([--without-systemd], [Disable checking and usage of systemd]),
109 [if test "$withval" = "no"; then
110 withsystemd="no"
111 else
112 withsystemd="yes"
113 fi], [withsystemd="yes"])
114
115if test "x$withsystemd" = "xyes"; then
116 PKG_CHECK_MODULES([systemd], [systemd], [
117 SYSTEMD_UNIT_DIR=$(pkg-config --variable=systemdsystemunitdir systemd)
118 SYSTEMD_SERVICE_FILE="$SYSTEMD_UNIT_DIR/netopeerguid.service"
119 AC_SUBST(SYSTEMD_SERVICE_FILE)
120 AC_SUBST(SYSTEMD_UNIT_DIR)
121 AM_CONDITIONAL([HAVE_SYSTEMD], [true])
122 ], [AM_CONDITIONAL([HAVE_SYSTEMD], [false])])
123else
124 # disabled systemd
125 AM_CONDITIONAL([HAVE_SYSTEMD], [false])
126fi
127
128
Tomas Cejka50c076e2014-03-18 15:31:10 +0100129AC_CONFIG_FILES([Makefile
Tomas Cejka04e08f42014-03-27 19:52:34 +0100130 config.h
Michal Vaskoa53ef882015-11-24 11:02:01 +0100131 netopeerguid.spec
Tomas Cejkac95271a2016-03-02 09:07:19 +0100132 netopeerguid.service
Michal Vaskoa53ef882015-11-24 11:02:01 +0100133 src/netopeerguid.rc
Tomas Cejka50c076e2014-03-18 15:31:10 +0100134 src/Makefile
135 ])
136AC_OUTPUT
137
138echo
139echo
140echo "------------------------------------------------------------------------"
141echo "$PACKAGE $VERSION"
142echo "------------------------------------------------------------------------"
143echo
144echo
145echo "Configuration Options Summary:"
146echo
147echo "Documentation..........: ${build_doc}"
148echo
149echo "Compilation............: make (or gmake)"
Michal Vaskoc3146782015-11-04 14:46:41 +0100150echo " CC...................: $CC"
Tomas Cejka50c076e2014-03-18 15:31:10 +0100151echo " LIBS.................: $LIBS"
152echo " CFLAGS...............: $CFLAGS"
153echo
Tomas Cejka50c076e2014-03-18 15:31:10 +0100154echo "Installation...........: make install (as root if needed, with 'su' or 'sudo')"
155echo " prefix...............: $prefix"
Tomas Cejka04e08f42014-03-27 19:52:34 +0100156echo "Su user for process:...............: $SU_USER"
157echo "Su group for process:..............: $SU_GROUP"
158echo "Chown user for sock file:...............: $CHOWN_USER"
159echo "Chown group for sock file:..............: $CHOWN_GROUP"
Michal Vaskofd34e7f2016-09-06 11:37:10 +0200160echo "Notification server certificate:........: $CERT_PATH"
161echo "Notification server private key:........: $PRIVKEY_PATH"
Tomas Cejka50c076e2014-03-18 15:31:10 +0100162echo
163