-
Notifications
You must be signed in to change notification settings - Fork 58
/
configure.ac
125 lines (92 loc) · 2.63 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
AC_INIT(TooN, version-3.0.0-beta1)
AC_COPYRIGHT([Copyright T. Drummond, E. Rosten, G. Reitmayr 2006--2015])
AC_LANG(C++)
AC_PROG_CXX
m4_include([m4/ax_cxx_compile_stdcxx_14.m4])
################################################################################
#
# Useful macros
#
dnl APPEND(var, value)
dnl This appends vale to a shell variable var
define(APPEND, [$1="$$1 $2"])
dnl TEST_AND_SET_CXXFLAG(flag, [program], [run])
dnl
dnl This attempts to compile a and run program with a certain compiler flag.
dnl If no program is given, then the minimal C++ program is compiled, and
dnl this tests just the validity of the compiler flag.
dnl
define([TEST_AND_SET_CXXFLAG],[
if test "$3" == ""
then
AC_MSG_CHECKING([if compiler flag $1 works])
else
AC_MSG_CHECKING([$3])
fi
save_CXXFLAGS="$CXXFLAGS"
APPEND(CXXFLAGS, [$1])
m4_if([$2],[],[pushdef(prog, [int main(){}])], [pushdef(prog, [$2])])
m4_if([$4],[run],
[AC_RUN_IFELSE([AC_LANG_SOURCE([prog])], [cvd_conf_test=1],[cvd_conf_test=0], [cvd_conf_test=0])],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([prog])], [cvd_conf_test=1],[cvd_conf_test=0])]
)
popdef([prog])
if test $cvd_conf_test = 1
then
AC_MSG_RESULT(yes)
ts_success=yes
else
AC_MSG_RESULT(no)
CXXFLAGS="$save_CXXFLAGS"
ts_success=no
fi
])
AX_CXX_COMPILE_STDCXX_14
#
# Test for Package Config
#
AC_PATH_PROG(PKG_CONFIG, pkg-config)
if test "x$PKG_CONFIG" = "x"; then
AC_MSG_WARN([Could not find pkg-config, will not create pc file.])
else
# we need sed to find the pkg-config lib directory
AC_CHECK_PROG(SED,sed,sed,AC_MSG_ERROR([You Must install sed]))
AC_MSG_CHECKING([for pkg-config library dir])
PKGCONFIG_LIBDIR="`echo $PKG_CONFIG | $SED -e 's~.*/bin/pkg-config$~~'`${libdir}/pkgconfig"
AC_MSG_RESULT($PKGCONFIG_LIBDIR)
AC_SUBST(PKGCONFIG_LIBDIR)
AC_CONFIG_FILES([ TooN.pc ])
# This will be put into the pc file
VERSION=AC_PACKAGE_VERSION()
AC_SUBST(VERSION)
fi
# See if we can find LAPACK
#ACX_LAPACK(
# LAPACK_LINKER_FLAGS="$LAPACK_LIBS $BLAS_LIBS $LIBS $FLIBS"
# AC_SUBST(LAPACK_LINKER_FLAGS)
# , AC_ERROR([Could not find LAPACK])
# )
#
typeof=check
AC_ARG_ENABLE(lapack, [AS_HELP_STRING([--enable-lapack],[Use LAPACK where optional])], [lapack=$enableval])
if test "$lapack" == ""
then
AC_CHECK_LIB(lapack, dgesvd_)
if test $ac_cv_lib_lapack_dgesvd_ = yes
then
lapack=yes
else
lapack=no
fi
fi
if test "$lapack" != "no"
then
AC_DEFINE([TOON_USE_LAPACK], [], [Use LAPACK])
AC_SUBST(use_lapack, yes)
fi
TEST_AND_SET_CXXFLAG(-Wall)
TEST_AND_SET_CXXFLAG(-Wextra)
TEST_AND_SET_CXXFLAG(-W)
TEST_AND_SET_CXXFLAG(-O3)
AC_CONFIG_HEADERS(TooN/internal/config.hh)
AC_OUTPUT(Makefile)