-
Notifications
You must be signed in to change notification settings - Fork 9
/
configure.ac
208 lines (182 loc) · 6.18 KB
/
configure.ac
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
AC_PREREQ([2.69])
AC_INIT([usbguard-notifier], [0.1.0], [[email protected]])
AC_CONFIG_SRCDIR([src/])
AC_CONFIG_AUX_DIR([config])
AC_CONFIG_MACRO_DIR([m4])
m4_pattern_allow([AC_MSG_FAILURE])
# if it's possible enable silent compilation
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
EXTERNAL_CXXFLAGS="$CXXFLAGS"
AM_INIT_AUTOMAKE([foreign subdir-objects tar-pax])
AC_PROG_MAKE_SET
AC_PROG_CXX
AC_PROG_CC_C99
AC_PROG_INSTALL
AC_PROG_MAKE_SET
LT_PREREQ([2.4.6])
LT_INIT
# Check for headers, typedefs, data structures
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
AC_CHECK_HEADERS([getopt.h unistd.h], [], [AC_MSG_ERROR([Required header file(s) not found])], [])
# As default each argument is stored temporiraly, however with this options it can be modified
notification_path="/tmp/usbguard-notifier"
AC_ARG_WITH(
[permanent-notifications],
AS_HELP_STRING([--with-permanent-notifications], [Select notifications path]),
[notification_path=$withval],
[notificaiton_path="/tmp/usbguard-notifier"]
)
# usbguard-devel
# Add the path to where your usbguard-devel includes are
# You might need this option when you want to package usbguard-notifier
# together with usbguard at the same time
AC_ARG_WITH(
[usbguard-devel],
AS_HELP_STRING([--with-usbguard-devel], [Select to compile notifier from source usbguard devel files(only top level directory)]),
[usbguard_CFLAGS="-I$withval/src/Library/public/"
usbguard_LIBS=""
usbguard_LA="$withval/libusbguard.la"
libusbguard_summary="$usbguard_CFLAGS $usbguard_LIBS"
AC_SUBST([usbguard_CFLAGS])
AC_SUBST([usbguard_LIBS])
AC_SUBST([usbguard_LA])
custom_usbguard_devel_enabled=yes
],
[
PKG_CHECK_MODULES(
[usbguard],
[libusbguard >= 0.7.2],
[libusbguard_summary="$usbguard_CFLAGS $usbguard_LIBS"],
[AC_MSG_FAILURE([libusbguard development files not found])]
)
]
)
# Build notifier-cli, default is yes
AC_ARG_ENABLE([notifier-cli],
[AC_HELP_STRING([--enable-notifier-cli], [enable notifier cli(default=yes)])],
[case "${enableval}" in
yes) notifier_cli_enabled=yes;;
no) notifier_cli_enabled=no;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-notifier-cli]) ;;
esac],
[notifier_cli_enabled=yes]
)
AC_ARG_ENABLE([systemd-systemunitdir],
[AC_HELP_STRING([--enable-systemd-systemunitdir], [enable systemd system unit dir(default=no)])],
[case "${enableval}" in
yes) systemd_systemunitdir=yes;;
no) systemd_systemunitdir=no;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-systemd-systemunitdir]) ;;
esac],
[systemd_systemunitdir=no]
)
# librsvg2
PKG_CHECK_MODULES(
[rsvg],
[librsvg-2.0 >= 2.0.0],
[librsvg_summary="$rsvg_CFLAGS $rsvg_LIBS"],
[AC_MSG_FAILURE([librsvg2 development files not found])]
)
# libnotify
PKG_CHECK_MODULES(
[notify],
[libnotify >= 0.7.0],
[libnotify_summary="$notify_CFLAGS $notify_LIBS"],
[AC_MSG_FAILURE([libnotify development files not found])]
)
# asciidoc
AC_CHECK_PROGS(A2X, [a2x])
if test -z "$A2X"; then
AC_MSG_FAILURE([Cannot detect documentation generator (asciidoc / a2x)])
fi
# systemd
if test "x$systemd_systemunitdir" = xyes; then
systemd_unit_dir="`$PKG_CONFIG systemd --variable=systemdsystemunitdir`"
else
systemd_unit_dir="`$PKG_CONFIG systemd --variable=systemduserunitdir`"
fi
if test "x$systemd_unit_dir" = x; then
AC_MSG_FAILURE([Cannot detect the systemd system unit dir])
fi
AC_SUBST(SYSTEMD_UNIT_DIR, $systemd_unit_dir)
AC_DEFINE([SYSTEMD_SUPPORT_ENABLED], [1], [Enable systemd support int the project])
AM_CONDITIONAL([SYSTEMD_SUPPORT_ENABLED], [test "x$systemd" = xyes ])
# Catch C++ library
AC_ARG_WITH([bundled-catch], AS_HELP_STRING([--with-bundled-catch],
[Build using the bundled Catch library]),
[with_bundled_catch=$withval], [with_bundled_catch=no])
if test "x$with_bundled_catch" = xyes; then
catch_CFLAGS="-I\$(top_srcdir)/src/ThirdParty/Catch2/single_include/catch2"
catch_LIBS=""
AC_MSG_NOTICE([Using bundled Catch library])
catch_summary="bundled; $catch_CFLAGS $catch_LIBS"
else
SAVE_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-std=c++11 $CPPFLAGS -I/usr/include/catch"
AC_LANG_PUSH([C++])
AC_CHECK_HEADER([catch.hpp], [], [AC_MSG_FAILURE(catch.hpp not found or not
usable. Re-run with --with-bundled-catch to use the bundled library.)])
AC_LANG_POP
catch_CFLAGS="-I/usr/include/catch"
catch_LIBS=""
CPPFLAGS=$SAVE_CPPFLAGS
catch_summary="system-wide;
$catch_CFLAGS $catch_LIBS"
fi
AC_SUBST([catch_CFLAGS])
AC_SUBST([catch_LIBS])
CXXFLAGS_DEBUG="-g -O2"
AC_ARG_ENABLE(
[debug-build],
[AC_HELP_STRING([--enable-debug-build], [enable debugging flags (default=no)])],
[case "${enableval}" in
yes) debug=yes ;;
no) debug=no ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug-build]) ;;
esac],
[debug=no]
)
CXXFLAGS=" $EXTERNAL_CXXFLAGS"
CXXFLAGS+=" -std=c++11"
CXXFLAGS+=" -pedantic"
CXXFLAGS+=" -Wno-unknown-pragmas"
CXXFLAGS+=" -Wall"
CXXFLAGS+=" -Wextra"
if test "x$debug" = xyes; then
CXXFLAGS="$CXXFLAGS $CXXFLAGS_DEBUG"
fi
AC_SUBST(CPPFLAGS, $CXXFLAGS)
AC_SUBST(config_PATH, $prefix/.config)
AC_SUBST(NOTIFICATION_PATH, $notification_path)
AM_CONDITIONAL([NOTIFIER_CLI_ENABLED], [test "x$notifier_cli_enabled" = xyes ])
AM_CONDITIONAL([CUSTOM_USBGUARD_DEVEL_ENABLED], [test "x$custom_usbguard_devel_enabled" = "xyes"])
AC_CONFIG_FILES([
Makefile
src/Tests/Makefile
])
AC_OUTPUT
echo ""
echo "============== MACROS ================="
echo " systemd: $systemd_unit_dir"
echo ""
echo "========== LINKER OPTIONS ============="
echo " Catch: $catch_summary"
echo " libnotify: $libnotify_summary"
echo " libusbguard: $libusbguard_summary"
echo " librsvg: $librsvg_summary"
echo " CXXFLAGS: $CXXFLAGS"
echo ""
echo "============= ARGUMENTS ==============="
echo " prefix: $prefix"
echo " config_file: $prefix/.conf"
echo "notification_path: $notification_path"
echo " notifier_cli: $notifier_cli_enabled"
echo ""