-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure.ac
113 lines (95 loc) · 3.26 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
## LibRdRand:
## an example of using Automake and Libtool to build a shared librar
AC_INIT([LibRdRand],[1.2.0],[[email protected]],[librdrand],[https://github.com/BroukPytlik/RdRand])
AM_INIT_AUTOMAKE([foreign -Wall -Werror])
# Add these lines for library support
AM_PROG_AR
LT_INIT
AC_PROG_CC
PKG_PROG_PKG_CONFIG
# Generate two configuration headers; one for building the library itself with
# an autogenerated template, and a second one that will be installed alongside
# the library.
AC_CONFIG_HEADERS([config.h rdrandconfig.h])
AC_PROG_CXX
AC_CONFIG_MACRO_DIRS([m4])
###################
# Check for OpenMP
AC_OPENMP
AC_SUBST(OPENMP_CFLAGS)
##################
##################
# Check for OpenSSL
AC_ARG_WITH([openssl],
[AS_HELP_STRING([--with-openssl=DIR],
[root of OpenSSL directory])],
[
# Check if specified directory exists
if test ! -d "$withval"; then
AC_MSG_ERROR([$withval: no such directory])
fi
OPENSSL_INCLUDES="-I$withval/include"
OPENSSL_LDFLAGS="-L$withval/lib"
OPENSSL_LIBS="-lssl -lcrypto"
],
[
# No explicit path specified, search in standard locations
PKG_CHECK_MODULES([OPENSSL], [openssl >= 1.0.1],
[OPENSSL_INCLUDES="$OPENSSL_CFLAGS"],
[
# Fallback to manual check if pkg-config fails
AC_CHECK_HEADERS([openssl/ssl.h openssl/err.h], [],
[AC_MSG_ERROR([OpenSSL headers not found. Install OpenSSL development package.])])
AC_CHECK_LIB([crypto], [EVP_EncryptInit],
[OPENSSL_LIBS="-lcrypto"],
[AC_MSG_ERROR([libcrypto not found. Install OpenSSL.])])
AC_CHECK_LIB([ssl], [SSL_new],
[OPENSSL_LIBS="$OPENSSL_LIBS -lssl"],
[AC_MSG_ERROR([libssl not found. Install OpenSSL.])],
[$OPENSSL_LIBS])
])
])
# Set final flags
AC_SUBST([OPENSSL_INCLUDES])
AC_SUBST([OPENSSL_LDFLAGS])
AC_SUBST([OPENSSL_LIBS])
##################
###########
# -mrdrnd
AC_MSG_CHECKING([whether CC supports -mrdrnd])
my_save_cflags="$CFLAGS"
CFLAGS="$CFLAGS -mrdrnd"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
[AC_MSG_RESULT([yes])]
[cc_supports_rdrnd=yes],
[AC_MSG_RESULT([no])]
[cc_supports_rdrnd=no])
CFLAGS="$my_save_cflags"
unset my_save_cflags
if test -z "$RDRND_FLAGS"
then
RDRND_TESTS='rdrnd${EXEEXT}'
if test "$cc_supports_rdrnd" = "yes"
then
RDRND_FLAGS="-mrdrnd"
else
RDRND_FLAGS=""
fi
else
RDRND_TESTS=""
fi
AC_SUBST([RDRND_FLAGS])
###########
LT_INIT([disable-static])
# Define these substitions here to keep all version information in one place.
# For information on how to properly maintain the library version information,
# refer to the libtool manual, section "Updating library version information":
# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
AC_SUBST([RDRAND_SO_VERSION], [1:2:0])
AC_SUBST([RDRAND_API_VERSION], [1.2.0])
# Override the template file name of the generated .pc file, so that there
# is no need to rename the template file when the API version changes.
#rdrand-${RDRAND_API_VERSION}.pc:rdrand.pc.in])
AC_CONFIG_FILES([Makefile
librdrand.pc:librdrand.pc.in])
AC_OUTPUT