forked from abraunegg/onedrive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
288 lines (254 loc) · 9.84 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
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
dnl configure.ac for OneDrive Linux Client
dnl Copyright 2019 Norbert Preining
dnl Licensed GPL v3 or later
dnl How to make a release
dnl - increase the version number in the AC_INIT call below
dnl - run autoconf which generates configure
dnl - commit the changed files (configure.ac, configure)
dnl - tag the release
AC_PREREQ([2.69])
AC_INIT([onedrive],[v2.4.13-dev], [https://github.com/abraunegg/onedrive], [onedrive])
AC_CONFIG_SRCDIR([src/main.d])
AC_ARG_VAR([DC], [D compiler executable])
AC_ARG_VAR([DCFLAGS], [flags for D compiler])
dnl necessary programs: install, pkg-config
AC_PROG_INSTALL
PKG_PROG_PKG_CONFIG
dnl Determine D compiler
dnl we check for dmd, dmd2, and ldc2 in this order
dnl furthermore, we set DC_TYPE to either dmd or ldc and export this into the
dnl Makefile so that we can adjust command line arguments
AC_CHECK_PROGS([DC], [dmd ldmd2 ldc2], NOT_FOUND)
DC_TYPE=
case $(basename $DC) in
dmd) DC_TYPE=dmd ;;
ldmd2) DC_TYPE=dmd ;;
ldc2) DC_TYPE=ldc ;;
NOT_FOUND) AC_MSG_ERROR(Could not find any compatible D compiler, 1)
esac
dnl dash/POSIX version of version comparison
vercomp () {
IFS=. read -r a0 a1 a2 aa <<EOF
$1
EOF
IFS=. read -r b0 b1 b2 bb <<EOF
$2
EOF
# leading 0 are ignored: 01 == 1, this also
# converts empty strings into 0: 1..2 == 1.0.2
a0=$(expr $a0 + 0)
a1=$(expr $a1 + 0)
a2=$(expr $a2 + 0)
b0=$(expr $b0 + 0)
b1=$(expr $b1 + 0)
b2=$(expr $b2 + 0)
#echo "$1 parsed to a=$a0 b=$a1 c=$a2 rest=$aa"
#echo "$2 parsed to a=$b0 b=$b1 c=$b2 rest=$bb"
if test $a0 -lt $b0
then
return 2
elif test $a0 -gt $b0
then
return 1
else
if test $a1 -lt $b1
then
return 2
elif test $a1 -gt $b1
then
return 1
else
if test $a2 -lt $b2
then
return 2
elif test $a2 -gt $b2
then
return 1
else
if test $aa '<' $bb
then
return 2
elif test $aa '>' $bb
then
return 1
else
return 0
fi
fi
fi
fi
}
DO_VERSION_CHECK=1
AC_ARG_ENABLE(version-check,
AS_HELP_STRING([--disable-version-check], [Disable checks of compiler version during configure time]))
AS_IF([test "x$enable_version_check" = "xno"], DO_VERSION_CHECK=0,)
AS_IF([test "$DO_VERSION_CHECK" = "1"],
[ dnl do the version check
AC_MSG_CHECKING([version of D compiler])
# check for valid versions
case $(basename $DC) in
ldmd2|ldc2)
# LDC - the LLVM D compiler (1.12.0): ...
VERSION=`$DC --version`
# remove everything up to first (
VERSION=${VERSION#* (}
# remove everthing after ):
VERSION=${VERSION%%):*}
# now version should be something like L.M.N
MINVERSION=1.12.0
;;
dmd)
# DMD64 D Compiler v2.085.1\n...
VERSION=`$DC --version | tr '\n' ' '`
VERSION=${VERSION#*Compiler v}
VERSION=${VERSION%% *}
# now version should be something like L.M.N
MINVERSION=2.083.1
;;
esac
AC_MSG_RESULT([$VERSION])
vercomp $MINVERSION $VERSION
if test $? = 1
then
AC_MSG_ERROR([Compiler version insufficient, current compiler version $VERSION, minimum version $MINVERSION], 1)
fi
#echo "MINVERSION=$MINVERSION VERSION=$VERSION"
])
AC_SUBST([DC_TYPE])
dnl In case the environment variable DCFLAGS is set, we export it to the
dnl generated Makefile at configure run:
AC_SUBST([DCFLAGS])
dnl The package date is only used in the man page onedrive.1.in
dnl we generate onedrive.1 from it during configure run, but we want
dnl to have the same date, namely the one when the configure script
dnl was generated from the configure.ac (i.e., on release time).
dnl this uses a call to the underlying m4 engine to call an external cmd
PACKAGE_DATE="m4_esyscmd([date "+%B %Y" | tr -d '\n'])"
AC_SUBST([PACKAGE_DATE])
dnl Check for required modules: curl and sqlite at the moment
PKG_CHECK_MODULES([curl],[libcurl])
PKG_CHECK_MODULES([sqlite],[sqlite3])
dnl
dnl systemd and unit file directories
dnl This is a bit tricky, because we want to allow for
dnl --with-systemdsystemunitdir=auto
dnl as well as =/path/to/dir
dnl The first step is that we check whether the --with options is passed to configure run
dnl if yes, we don't do anything (the ,, at the end of the next line), and if not, we
dnl set with_systemdsystemunitdir=auto, meaning we will try pkg-config to find the correct
dnl value.
AC_ARG_WITH([systemdsystemunitdir],
[AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd system service files])],,
[with_systemdsystemunitdir=auto])
dnl If no value is passed in (or auto/yes is passed in), then we try to find the correct
dnl value via pkg-config and put it into $def_systemdsystemunitdir
AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"],
[ dnl true part, so try to determine with pkg-config
def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
dnl if we cannot find it via pkg-config, *and* the user explicitely passed it in with,
dnl we warn, and in all cases we unset (set to no) the respective variable
AS_IF([test "x$def_systemdsystemunitdir" = "x"],
[ dnl we couldn't find the default value via pkg-config
AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemdsystemunitdir=no
],
[ dnl pkg-config found the value, use it
with_systemdsystemunitdir="$def_systemdsystemunitdir"
]
)
]
)
dnl finally, if we found a value, put it into the generated Makefile
AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
[AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
dnl Now do the same as above for systemduserunitdir!
AC_ARG_WITH([systemduserunitdir],
[AS_HELP_STRING([--with-systemduserunitdir=DIR], [Directory for systemd user service files])],,
[with_systemduserunitdir=auto])
AS_IF([test "x$with_systemduserunitdir" = "xyes" -o "x$with_systemduserunitdir" = "xauto"],
[
def_systemduserunitdir=$($PKG_CONFIG --variable=systemduserunitdir systemd)
AS_IF([test "x$def_systemduserunitdir" = "x"],
[
AS_IF([test "x$with_systemduserunitdir" = "xyes"],
[AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
with_systemduserunitdir=no
],
[
with_systemduserunitdir="$def_systemduserunitdir"
]
)
]
)
AS_IF([test "x$with_systemduserunitdir" != "xno"],
[AC_SUBST([systemduserunitdir], [$with_systemduserunitdir])])
dnl We enable systemd integration only if we have found both user/system unit dirs
AS_IF([test "x$with_systemduserunitdir" != "xno" -a "x$with_systemdsystemunitdir" != "xno"],
[havesystemd=yes], [havesystemd=no])
AC_SUBST([HAVE_SYSTEMD], $havesystemd)
dnl
dnl Notification support
dnl only check for libnotify if --enable-notifications is given
AC_ARG_ENABLE(notifications,
AS_HELP_STRING([--enable-notifications], [Enable desktop notifications via libnotify]))
AS_IF([test "x$enable_notifications" = "xyes"], [enable_notifications=yes], [enable_notifications=no])
dnl if --enable-notifications was given, check for libnotify, and disable if not found
dnl otherwise substitute the notifu
AS_IF([test "x$enable_notifications" = "xyes"],
[PKG_CHECK_MODULES(notify,libnotify,,enable_notifications=no)],
[AC_SUBST([notify_LIBS],"")])
AC_SUBST([NOTIFICATIONS],$enable_notifications)
dnl
dnl Completion support
dnl First determine whether completions are requested, pass that to Makefile
AC_ARG_ENABLE([completions],
AS_HELP_STRING([--enable-completions], [Install shell completions for bash, zsh, and fish]))
AS_IF([test "x$enable_completions" = "xyes"], [enable_completions=yes], [enable_completions=no])
AC_SUBST([COMPLETIONS],$enable_completions)
dnl if completions are enabled, search for the bash/zsh completion directory in the
dnl similar way as we did for the systemd directories
AS_IF([test "x$enable_completions" = "xyes"],[
AC_ARG_WITH([bash-completion-dir],
[AS_HELP_STRING([--with-bash-completion-dir=DIR], [Directory for bash completion files])],
,
[with_bash_completion_dir=auto])
AS_IF([test "x$with_bash_completion_dir" = "xyes" -o "x$with_bash_completion_dir" = "xauto"],
[
PKG_CHECK_VAR(bashcompdir, [bash-completion], [completionsdir], ,
bashcompdir="${sysconfdir}/bash_completion.d")
with_bash_completion_dir=$bashcompdir
])
AC_SUBST([BASH_COMPLETION_DIR], $with_bash_completion_dir)
AC_ARG_WITH([zsh-completion-dir],
[AS_HELP_STRING([--with-zsh-completion-dir=DIR], [Directory for zsh completion files])],,
[with_zsh_completion_dir=auto])
AS_IF([test "x$with_zsh_completion_dir" = "xyes" -o "x$with_zsh_completion_dir" = "xauto"],
[
with_zsh_completion_dir="/usr/local/share/zsh/site-functions"
])
AC_SUBST([ZSH_COMPLETION_DIR], $with_zsh_completion_dir)
AC_ARG_WITH([fish-completion-dir],
[AS_HELP_STRING([--with-fish-completion-dir=DIR], [Directory for fish completion files])],,
[with_fish_completion_dir=auto])
AS_IF([test "x$with_fish_completion_dir" = "xyes" -o "x$with_fish_completion_dir" = "xauto"],
[
with_fish_completion_dir="/usr/local/share/fish/completions"
])
AC_SUBST([FISH_COMPLETION_DIR], $with_fish_completion_dir)
])
dnl
dnl Debug support
AC_ARG_ENABLE(debug,
AS_HELP_STRING([--enable-debug], [Pass debug option to the compiler]))
AS_IF([test "x$enable_debug" = "xyes"], AC_SUBST([DEBUG],yes), AC_SUBST([DEBUG],no))
dnl generate necessary files
AC_CONFIG_FILES([
Makefile
contrib/pacman/PKGBUILD
contrib/spec/onedrive.spec
onedrive.1
contrib/systemd/onedrive.service
contrib/systemd/[email protected]
])
AC_OUTPUT