This repository has been archived by the owner on Feb 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
configure.ac
408 lines (345 loc) · 14.1 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
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
# Copyright: (c) 2020 - 2021 Seagate Technology LLC and/or its its Affiliates,
# All Rights Reserved
#
# This software is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
# MIO version
m4_define([MIO_VERSION_MAJOR],[0])
m4_define([MIO_VERSION_MINOR],[1])
m4_define([MIO_VERSION_PATCH],[0])
m4_define([MIO_VERSION],[MIO_VERSION_MAJOR.MIO_VERSION_MINOR.MIO_VERSION_PATCH])
#
# Autoconf/Automake/Libtool configuration
#
AC_PREREQ(2.63)
AC_INIT([mio],[MIO_VERSION],[mio@seagate.com])
# The AC_PROG_CC macro sets CFLAGS to '-g -O2' by default if CFLAGS is not
# initialized by the user, we don't need this because we use a separate
# MIO_CFLAGS variable to control compiler's options while allowing user to
# override it via CFLAGS from command-line.
CFLAGS=${CFLAGS:=""}
AM_INIT_AUTOMAKE([-Wall -Werror nostdinc foreign subdir-objects silent-rules])
AM_SILENT_RULES([yes])
LT_INIT([disable-static])
AC_CONFIG_SRCDIR([src/mio.c])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
#
# Global variables
#
# PACKAGE_VERSION is a default autoconf variable, generated by AC_INIT from
# it's "version" argument
AC_SUBST([LT_RELEASE], [$PACKAGE_VERSION])
# The value passed to libtool's `-version-info` parameter.
#
# [https://autotools.io/libtool/version.html#idm46422828083360]
# |
# | To set the version of the library, libtool provides the `-version-info`
# | parameter, which accepts three numbers, separated by colons, that are
# | called respectively, _current_, _revision_ and _age_. Both their name
# | and their behaviour, nowadays, have to be considered fully arbitrary,
# | as the explanation provided in the official documentation is confusing
# | to say the least, and can be, in some cases, considered completely wrong.
# |
# | *Warning*
# |
# | A common mistake is to assume that the three values passed to
# | `-version-info` map directly into the three numbers at the end of
# | the library name. This is not the case, and indeed, current,
# | revision and age are applied differently depending on the operating
# | system that one is using.
#
# E.g., LT_VERSION=1:1:0 results in cortx-motr/.libs/libmotr.so.1.0.1 file.
#
# See also
# https://www.gnu.org/software/libtool/manual/libtool.html#Libtool-versioning
AC_SUBST([LT_VERSION], [MIO_VERSION_MAJOR:MIO_VERSION_MINOR:MIO_VERSION_PATCH])
# the following variables are only for internal use within this configure script
# external scripts should use collection of variables, which is automatically
# provided by autoconf:
#
# @srcdir@
# @top_srcdir@
# @abs_top_srcdir@
# @builddir@
# @top_builddir@
# @abs_top_builddir@
#
SRCDIR="$srcdir"
ABS_SRCDIR="$(cd $srcdir; pwd)"
ABS_BUILDDIR="$(pwd)"
AC_SUBST([ABS_BUILDDIR])
AC_SUBST([MIO_VERSION_CODE],
["$(( (MIO_VERSION_MAJOR << 24) + (MIO_VERSION_MINOR << 16) + (MIO_VERSION_PATCH << 8) ))U"]
)
BUILD_HOST=$(hostname)
AC_SUBST([BUILD_HOST])
AC_SUBST([BUILD_USER],["$(whoami)"])
AC_SUBST([BUILD_TIME],["$(date -u)"])
AC_SUBST([BUILD_GCC],["$(gcc -v 2>&1 | grep '^gcc version' | sed -e 's/(GCC)//')"])
#-------------------------------------------------------------------------------
# Checking for OS support
#-------------------------------------------------------------------------------
AC_MSG_CHECKING([for operating system])
AC_MSG_RESULT([$host_os])
AS_CASE([$host_os],
# supported operating systems:
[linux*], [],
# default action for unsupported OS is to abort with error
[AC_MSG_ERROR([Unsupported platform detected!])]
)
#-------------------------------------------------------------------------------
# Checking for CPU support
#-------------------------------------------------------------------------------
ARCH=
AC_CANONICAL_HOST
AS_CASE([$host_cpu],
[x86_64], [ARCH=x86_64],
[AC_MSG_ERROR("Only X86_64 platform is supported!")]
)
AS_IF([test x$ARCH = xx86_64],
[
AC_DEFINE([CONFIG_X86_64])
]
)
AC_SUBST([ARCH])
#------------------------------------------------------------------------------#
# Configuration options #
#------------------------------------------------------------------------------#
# Define macros
# Add include guards to config.h
AH_TOP([
#pragma once
#ifndef __MIO_CONFIG_H__
#define __MIO_CONFIG_H__
])
AH_TEMPLATE([ENABLE_DEBUG], [Enable debug info and disable optimizations.])
AH_TEMPLATE([MOTR_LIB], [Motr library directory])
AH_TEMPLATE([MOTR_INCLUDE], [Directory for Motr development header files])
AH_TEMPLATE([CONFIG_X86_64], [Support for X86_64 platform])
AH_BOTTOM([
#endif /* __MIO_CONFIG_H__ */
])
# Enable/disable options
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[enable debug information and disable optimizations])],
[], [enable_debug=no]
)
AM_CONDITIONAL([ENABLE_DEBUG],
[test "x$enable_debug" = xyes])
# libtelem_only == yes, build telemetry library only.
# libtelem_only == no, build MIO library and standalone telemetry library.
AC_ARG_ENABLE([libtelem-only],
[AS_HELP_STRING([--enable-libtelem-only], [build telemetry library only])],
[libtelem_only=yes], [libtelem_only=no]
)
AM_CONDITIONAL([BUILD_LIBTELEM_ONLY], [test "x$libtelem_only" = xyes])
AM_CONDITIONAL([BUILD_LIBMIO], [test "x$libtelem_only" = xno])
# Set directories for default or customized libmotr and Motr headers.
AC_ARG_WITH([libmotr],
[AS_HELP_STRING([--with-libmotr=path],
[set path to Motr library libmotr, default is /usr/lib64])],
[LIBMOTR=$with_libmotr],
[LIBMOTR=/usr/lib64]
)
AC_ARG_WITH([motr-headers],
[AS_HELP_STRING([--with-motr-headers=path],
[set path to Motr headers, default is /usr/include/motr])],
[MOTR_HEADERS=$with_motr_headers],
[MOTR_HEADERS=/usr/include/motr]
)
AC_ARG_WITH([motr-src],
[AS_HELP_STRING([--with-motr-src=path],
[build with Motr source])],
[
LIBMOTR=$with_motr_src/motr/.libs/
MOTR_HEADERS=$with_motr_src
GALOIS_HEADERS=$with_motr_src/extra-libs/galois/include/
],
[]
)
AC_MSG_NOTICE([LIBMOTR=$LIBMOTR])
AC_MSG_NOTICE([MOTR_HEADERS=$MOTR_HEADERS])
AS_IF([test "x$libtelem_only" = xno && (test -z "$LIBMOTR" || ! test -d "$LIBMOTR/")],
[AC_MSG_ERROR([libmotr not found! Please, install Motr package or \
provide the path to a directory using --with-libmotr option.])]
)
AS_IF([test "x$libtelem_only" = xno && (test -z "$MOTR_HEADERS" || ! test -d "$MOTR_HEADERS/")],
[AC_MSG_ERROR([Motr headers not found! Please, install Motr headers or \
provide the path to a directory using --with-motr-headers option.])]
)
AC_SUBST([LIBMOTR])
AC_SUBST([MOTR_HEADERS])
# enable or disable examples
AC_ARG_ENABLE(
[examples],
[AS_HELP_STRING([--enable-examples], [build the example programs
[default=yes]])],
[enable_examples="$enableval"],
[enable_examples="yes"]
)
AM_CONDITIONAL(ENABLE_EXAMPLES, [test "$enable_examples" = "yes"])
# enable embedded builds (libtool convenience archives not meant to be
# installed)
AC_ARG_ENABLE([embedded],
[AS_HELP_STRING([--enable-embedded],
[Enable embedded support (build convenience
library, no symbol versioning) @<:@default=no@:>@])
],
[ac_asm_symver_support=0],
[enable_embedded=no])
AM_CONDITIONAL([EMBEDDED], [test x"$enable_embedded" = x"yes"])
#
#------------------------------------------------------------------------------#
# Check required programs #
#------------------------------------------------------------------------------#
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_AWK
AC_PROG_SED
AC_PROG_LN_S
#------------------------------------------------------------------------------#
# Check for required header files #
#------------------------------------------------------------------------------#
AC_CHECK_HEADERS([fcntl.h malloc.h stdint.h stdlib.h string.h sys/time.h unistd.h])
AC_HEADER_STDBOOL
#------------------------------------------------------------------------------#
# Check required types #
#------------------------------------------------------------------------------#
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UID_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
#------------------------------------------------------------------------------#
# Checking compiler characteristics #
#------------------------------------------------------------------------------#
AC_CHECK_SIZEOF([long])
AC_MSG_CHECKING([whether target platform is a 64-bit one])
AS_IF([test $ac_cv_sizeof_long -eq 8],
[AC_MSG_RESULT([yes])],
[
AC_MSG_RESULT([no])
AC_MSG_ERROR([Only 64bit platforms are supported!])
]
)
AC_C_INLINE
#------------------------------------------------------------------------------#
# Check required library functions #
#------------------------------------------------------------------------------#
AC_CHECK_FUNCS([gettimeofday memset strchr strdup strstr strtoull])
# Check the following libraries only when building libmio (libtelem_only == no).
if test "x$libtelem_only" = xno; then
# pthread library is required for a subset of pthread_XXX funcs
AC_SEARCH_LIBS([pthread_create], [c pthread], [],
[pthread_create cannot be found! Try to install libc-devel or libpthread-devel.]
)
AC_CHECK_HEADERS([pthread.h], [], [AC_MSG_ERROR([pthread.h cannot be found!])])
AC_CHECK_TYPES([pthread_barrier_t], [], [], [[#include <pthread.h>]])
# Check libyaml
AC_SEARCH_LIBS([yaml_parser_initialize], [yaml], [],
[yaml_parser_initialize cannot be found! Try install yaml package])
AC_CHECK_HEADERS([yaml.h], [],
AC_MSG_ERROR([yaml.h is not found. Try to install libyaml-devel package]))
# Check for openssl (used by MIO examples)
if test "x$enable_examples" = xyes; then
AC_CHECK_LIB(crypto, CRYPTO_new_ex_data, [], [AC_MSG_ERROR([library 'crypto' is required for OpenSSL])])
FOUND_SSL_LIB="no"
AC_CHECK_LIB(ssl, OPENSSL_init_ssl, [FOUND_SSL_LIB="yes"])
AC_CHECK_LIB(ssl, SSL_library_init, [FOUND_SSL_LIB="yes"])
AS_IF([test "x$FOUND_SSL_LIB" = xno], [AC_MSG_ERROR([library 'ssl' is required for OpenSSL])])
AC_CHECK_HEADERS([openssl/md5.h], [],
AC_MSG_ERROR([md5.h is not found. Try to install openssl-devel package]))
# Check libedit
AC_SEARCH_LIBS([edit], [edit], [],
[libedit cannot be found! Try install libedit package])
AC_CHECK_HEADERS([editline/readline.h ], [],
AC_MSG_ERROR([readline.h is not found. Try to install
libedit (and libedit-devel) package]))
fi
# Check libmotr
#AC_SEARCH_LIBS([m0_motr_init], [motr], [],
# [m0_motr_init cannot be found! Try install libmotr package])
#AC_CHECK_HEADERS([motr/client.h], [],
# AC_MSG_ERROR([client.h is not found. Try to install libmotr package]))
fi
#------------------------------------------------------------------------------#
# Handle configuration options #
#------------------------------------------------------------------------------#
AS_IF([test x$enable_debug = xyes],
[
MIO_CPPFLAGS="-DDEBUG $MIO_CPPFLAGS"
MIO_CFLAGS="-g -O0 $MIO_CFLAGS"
AC_DEFINE([ENABLE_DEBUG])
],[
MIO_CFLAGS="-g -O2 $MIO_CFLAGS"
]
)
#------------------------------------------------------------------------------#
# Set up build variables #
#------------------------------------------------------------------------------#
if test "x$libtelem_only" = xyes; then
MIO_CPPFLAGS="-D_REENTRANT -D_GNU_SOURCE -iquote'$ABS_BUILDDIR' -iquote'$ABS_SRCDIR' "
else # Build MIO with IO, Motr and telemetry
MIO_CPPFLAGS="-D_REENTRANT -D_GNU_SOURCE -DM0_INTERNAL='' -DM0_EXTERN=extern \
-iquote'$ABS_BUILDDIR' -iquote'$ABS_SRCDIR' -include'config.h' \
-I$MOTR_HEADERS -I$GALOIS_HEADERS $MIO_CPPFLAGS"
fi
MIO_CPPFLAGS_DIST=$(echo "$MIO_CPPFLAGS" | grep -Po -e '-D\S+|-I/usr\S+' | xargs echo)
MIO_CFLAGS="-pipe -Wall -Werror -Wno-attributes -fno-strict-aliasing $MIO_CFLAGS"
MIO_CFLAGS="-fno-common $MIO_CFLAGS"
MIO_LDFLAGS="-rdynamic -L$LIBMOTR $MIO_LDFLAGS"
# trim spaces at the end of flags
MIO_CPPFLAGS=$(echo $MIO_CPPFLAGS | sed 's/[[[:blank:]]]*$//')
MIO_CFLAGS=$(echo $MIO_CFLAGS | sed 's/[[[:blank:]]]*$//')
MIO_LDFLAGS=$(echo $MIO_LDFLAGS | sed 's/[[[:blank:]]]*$//')
AC_SUBST([MIO_CPPFLAGS])
AC_SUBST([MIO_CPPFLAGS_DIST])
AC_SUBST([MIO_CFLAGS])
AC_SUBST([MIO_LDFLAGS])
AC_SUBST([BUILD_CONFIGURE_OPTS],["$ac_configure_args"])
AC_SUBST([BUILD_CFLAGS],["$MIO_CPPFLAGS $MIO_CFLAGS $CPPFLAGS $CFLAGS"])
AC_SUBST([BUILD_LDFLAGS],["$MIO_LDFLAGS"])
#
# Setup output files
#
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
#
# Display resulting values of some important build variables
#
echo ""
AS_IF([test "x$CFLAGS" != x],
[echo "CFLAGS : \"$CFLAGS\""])
AS_IF([test "x$CPPFLAGS" != x],
[echo "CPPFLAGS : \"$CPPFLAGS\""])
AS_IF([test "x$LDFLAGS" != x],
[echo "LDFLAGS : \"$LDFLAGS\""])
AS_IF([test "x$LIBS" != x],
[echo "LIBS : \"$LIBS\""])
echo ""
echo "MIO version : $PACKAGE_VERSION"
echo ""
echo "CONFIGURE_OPTS: $BUILD_CONFIGURE_OPTS"
echo ""
echo "LIBMOTR : \"$LIBMOTR\""
echo "MOTR_HEADERS : \"$MOTR_HEADERS\""
echo ""
echo "MIO_CPPFLAGS : \"$MIO_CPPFLAGS\""
echo "MIO_CFLAGS : \"$MIO_CFLAGS\""
echo "MIO_LDFLAGS : \"$MIO_LDFLAGS\""
echo ""
echo "Gcc : \"$BUILD_GCC\""
echo ""
echo 'Run `make` to build MIO or `make help` for other options'
# vim: tabstop=4 shiftwidth=4 expandtab textwidth=80 nowrap foldmethod=marker