File: configure.ac

package info (click to toggle)
mathicgb 1.0~git20170104-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,708 kB
  • ctags: 3,297
  • sloc: cpp: 22,171; sh: 217; makefile: 120
file content (193 lines) | stat: -rwxr-xr-x 7,596 bytes parent folder | download | duplicates (2)
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
dnl AC_INIT sets up autoconf and must be first macro.
AC_INIT([mathicgb], [1.0]) # package, version, bug-report-email

# set up information about directories
AC_CONFIG_MACRO_DIR([build/autotools/m4]) # directory of extra autoconf macroes
AC_CONFIG_AUX_DIR([build/autotools]) # directory for auxiliary build tools (install-sh etc)

# check that source directory is correct
dnl  if autoconf is told the source code is in a directory that does not
dnl  contain this file then it knows that the directory is wrong.
AC_CONFIG_SRCDIR([src/mathicgb.h])

# Check availability and location of dependencies
# PKG_CHECK_MODULES([MEMTAILOR], [memtailor])
# PKG_CHECK_MODULES([MATHIC], [mathic])

# Locate the C++ compiler.
AC_PROG_CXX
AC_LANG([C++])

# Require C++11 support
AX_CXX_COMPILE_STDCXX_11(, [mandatory])

AM_PROG_AR

dnl ----- The gtest dependency

AC_ARG_WITH([gtest], AS_HELP_STRING(
    [--with-gtest], [use gtest, which is required for running the unit tests
      with make check. Per the recommendation
      of the gtest documentation, gtest is compiled with the tests, so an
      installed gtest is not usable - you need the gtest source. GTEST_PATH
      indicates where to look for gtest and it is also where gtest
      will be downloaded to if not found. The default path is srcdir/libs so
      that gtest needs to be at srcdir/libs/gtest/ where srcdir is the
      base of the directory being configured from.]
))

AC_MSG_CHECKING([for gtest])
AS_IF([test "x$GTEST_PATH" == "x"], [GTEST_PATH="$srcdir/libs"])
AS_IF([test "x$GTEST_VERSION" == "x"], [GTEST_VERSION="1.6.0"])
AS_IF([test "x$with_gtest" == "x"], [with_gtest="download"])

AS_IF([test "x$with_gtest" == "xdownload"],
  [with_gtest="yes"; AC_CHECK_FILE([$GTEST_PATH/src/gtest-all.cc], [], [
    echo "downloading of gtest disabled" >&2; exit 1
    mkdir -p "$GTEST_PATH";
    (
      cd $GTEST_PATH;
      rm -rf gtest-$GTEST_VERSION.zip
      wget http://googletest.googlecode.com/files/gtest-$GTEST_VERSION.zip;
      unzip gtest-$GTEST_VERSION.zip;
      rm gtest-$GTEST_VERSION.zip
      rm -rf gtest/
      mv gtest-$GTEST_VERSION/ gtest/
    );
    if test ! -e "$GTEST_PATH/src/gtest-all.cc"; then
      AC_MSG_WARN([Failed to download or extract gtest.]);
      with_gtest="no";
    else
      with_gtest="yes";
    fi
  ])],
  [test "x$with_gtest" == "xyes"], [
    AC_CHECK_FILE([$GTEST_PATH/src/gtest-all.cc], [], [
      AC_MSG_ERROR([could not find gtest source at path $GTEST_PATH.])
    ])
  ],
  [test "x$with_gtest" == "xno"], [],
  [AC_MSG_ERROR([invalid value $with_gtest for with_gtest.])]
)
AS_IF([test "x$with_gtest" == "xyes"],
  [GTEST_CFLAGS="-I$GTEST_PATH/include -I$GTEST_PATH"]);
AM_CONDITIONAL(with_gtest, test "x$with_gtest" == "xyes")

dnl ----- The TBB dependency
AC_ARG_WITH([tbb], AS_HELP_STRING(
    [--with-tbb], [use TBB, which is required for multithreading. The value
      detect, which is the default, enables TBB if it can be found and
      otherwise prints a warning and continues the build without
      multithreading support. TBB is not available for Cygwin (last checked
      March 2013).]
))
AS_IF([test "x$with_tbb" == "x"], [with_tbb="detect"])
AS_IF(
  [test "x$with_tbb" == "xdetect"],
  [PKG_CHECK_MODULES([TBB], [tbb], [with_tbb="yes"], [with_tbb="no";
    AC_MSG_WARN([TBB not detected. Compiling without multithreading and without precise timing.])
  ])],
  [test "x$with_tbb" == "xyes"], [PKG_CHECK_MODULES([TBB], [tbb])],    
  [test "x$with_tbb" == "xno"], [],
  [AC_MSG_ERROR([invalid value $with_tbb for with_tbb.])]
)
AS_IF([test "x$with_tbb" == "xno"], [TBB_CFLAGS="-DMATHICGB_NO_TBB"])

dnl ----- The librt dependency
dnl On Linux TBB calls clock_gettime, which requires librt, but librt is not
dnl linked in automatically. So we need to check for that.

dnl the first AC_LINK_IFELSE causes tests for lots of C++ related things,
dnl and these print out messages. So to avoid those messages appearing
dnl after "if librt..." and before the result for that test, we do an
dnl empty AC_LINK_IFELSE. Probably there is a better way.
AC_LINK_IFELSE([AC_LANG_SOURCE([[]])], [], [])

dnl We check if -lrt is necessary. We need librt if we are building with TBB,
dnl if linking and compiling works when linking with librt but it doesn't
dnl without linking with librt.
AS_IF([test "x$with_tbb" == "xyes"],
  [AC_MSG_CHECKING([if librt is needed to support TBB on this platform]);
  oldLIBS=$LIBS;
  LIBS="$TBB_LIBS -lrt $LIBS";
  oldCFLAGS=$CFLAGS;
  CFLAGS="$CFLAGS $TBB_CFLAGS";
  AC_LINK_IFELSE(
    [AC_LANG_PROGRAM(
      [[#]include [<]tbb/tbb.h[>]], [[tbb::tick_count::now();]]
    )],
    [LIBS=$oldLibs; AC_LINK_IFELSE(
      [AC_LANG_PROGRAM(
        [[#]include [<]tbb/tbb.h[>]], [[tbb::tick_count::now();]]
      )],
      [AC_MSG_RESULT([no])],
      [AC_MSG_RESULT([yes]); RT_LIBS="-lrt"]
    )],
    [AC_MSG_RESULT([no])]
  )];
  LIBS=$oldLIBS;
  CFLAGS=$oldCFLAGS;
)

DEPS_CFLAGS="$MEMTAILOR_CFLAGS $MATHIC_CFLAGS $TBB_CFLAGS $GTEST_CFLAGS"
DEPS_LIBS="$MEMTAILOR_LIBS $MATHIC_LIBS $TBB_LIBS $GTEST_LIBS $RT_LIBS"

AC_SUBST(DEPS_CFLAGS)
AC_SUBST(DEPS_LIBS)

# Enable optional maintainer mode (off by default)
dnl AM_MAINTAINER_MODE turns off automatic reconstruction of the build
dnl files if the source build files have changed. A developer will want
dnl those automatic reconstructions to happen so that changes to the
dnl build system are actually carried out. However, a user might not
dnl have the tools required to reconfigure and the need for
dnl reconstruction might be spurious if the last-modified date is set
dnl incorrectly on the build files.
dnl
dnl Passing the option [enable] to AM_MAINTAINER_MODE makes the
dnl non-reconstruction feature available, but only when turned on by
dnl passing the option –disable-maintainer-mode. This option is
dnl apparently useful to some package distributors.
AM_MAINTAINER_MODE([enable])

# Set up Automake
dnl foreign: do not create the GNU-specific file COPYING and do not complain
dnl   that GNU-specific files like NEWS, README, AUTHORS and ChangeLog are
dnl   missing.
dnl -Wall: set Automake to emit all warnings it can. Is NOT RELATED to setting
dnl   warnings for other tools. For example, it wil not make the compiler
dnl   get a -Wall option.
dnl subdir-objects: Put object files in a directory structure based on
dnl   the directory structure of the source files. This way, two source
dnl   files with the same name in different directories do not conflict.
AM_INIT_AUTOMAKE([foreign subdir-objects -Wall])

# if --enable-silent-rules is passed to ./configure or if V=0 is passed
# to make, then the compilation output will be much less verbose making
# it possible to spot warnings and errors as they go by.
AM_SILENT_RULES()

# Set up the $(LN_S) macro, which creates symbolic links
AC_PROG_LN_S

# set output variable INSTALL to the name of a BSD-compatible install program.
# Requires install-sh to be present as a fallback, even on systems where
# the fallback is not used.
AC_PROG_INSTALL

# Set up LibTool
LT_INIT([disable-shared])

dnl Set the version for the library -- this concerns compatibility of the
dnl source and binary interface of the library and is not the same as the
dnl version of the project.
AC_SUBST([MATHICGB_SO_VERSION], [0:0:0])

dnl Set up AC_OUTPUT to create each file by copying an input file
dnl while substituting the output variable values.
AC_CONFIG_FILES([Makefile
  build/autotools/mathicgb.pc:build/autotools/mathicgb.pc.in])

dnl Macro that is required to be at the end of any Autoconf script.
dnl Creates config.status and launches it.
AC_OUTPUT