summaryrefslogtreecommitdiffstats
path: root/configure.ac
blob: fa54eb2b64e9006eea58afbfa419ef22c6e61696 (plain)
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
#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

m4_define([ixion_major_version], [0])
m4_define([ixion_minor_version], [19])
m4_define([ixion_micro_version], [0])

m4_define([ixion_major_api_version], [0])
m4_define([ixion_minor_api_version], [18])

m4_define([ixion_version],
          [ixion_major_version.ixion_minor_version.ixion_micro_version])

m4_define([ixion_api_version],
          [ixion_major_api_version.ixion_minor_api_version])


AC_INIT([libixion],[ixion_version])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([1.11 foreign dist-bzip2 dist-xz])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
AX_CXX_COMPILE_STDCXX_17([noext], [mandatory])
CXXFLAGS="$CXXFLAGS -fvisibility=hidden -Wall -Wshadow -Wno-write-strings -pthread"

AC_CANONICAL_HOST

case $host_os in
    darwin*)
        _os=Darwin
        LDFLAGS="$LDFLAGS -L/usr/local/lib"
    ;;
    *)
        _os=
        LDFLAGS="$LDFLAGS -Wl,--no-as-needed -pthread -ldl"
    ;;
esac

# =====================
# Development Utilities
# =====================
AC_ARG_ENABLE(debug-utils,
        AS_HELP_STRING([--enable-debug-utils],[Build with extra checks useful during development.]),
        [enable_debug_utils="$enableval"],
        [enable_debug_utils=no]
)

AC_ARG_ENABLE([python],
    [AS_HELP_STRING([--disable-python], [Disable python bindings])],
    [enable_python="$enableval"],
    [enable_python=yes]
)

AC_ARG_ENABLE([threads],
    [AS_HELP_STRING([--disable-threads], [Disable threaded calculations])],
    [enable_threads="$enableval"],
    [enable_threads=yes]
)

AC_ARG_ENABLE([vulkan],
    [AS_HELP_STRING([--enable-vulkan], [Enable vulkan compute engine])],
    [enable_vulkan="$enableval"],
    [enable_vulkan=no]
)

IXION_VERSION=ixion_version
IXION_API_VERSION=ixion_api_version
IXION_MAJOR_VERSION=ixion_major_version
IXION_MINOR_VERSION=ixion_minor_version
IXION_MICRO_VERSION=ixion_micro_version
IXION_MAJOR_API_VERSION=ixion_major_api_version
IXION_MINOR_API_VERSION=ixion_minor_api_version
AC_SUBST(IXION_VERSION)
AC_SUBST(IXION_API_VERSION)
AC_SUBST(IXION_MAJOR_VERSION)
AC_SUBST(IXION_MINOR_VERSION)
AC_SUBST(IXION_MICRO_VERSION)
AC_SUBST(IXION_MAJOR_API_VERSION)
AC_SUBST(IXION_MINOR_API_VERSION)

AC_CONFIG_MACRO_DIR([m4])

m4_pattern_allow([^BOOST_])

for top_builddir in . .. ../.. $ac_auxdir $ac_auxdir/..; do
    test -f $top_builddir/configure && break
done


# Checks for programs.
AC_PROG_CXX
LT_INIT([win32-dll disable-static pic-only])
AC_CANONICAL_HOST

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([stdlib.h sys/time.h unistd.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_MODE_T
AC_TYPE_SIZE_T

# Checks for library functions.
AC_FUNC_STRTOD

AC_CHECK_SIZEOF([void *])
CXXFLAGS="$CXXFLAGS -DSIZEOF_VOID_P=$ac_cv_sizeof_void_p"

BOOST_REQUIRE([1.36])
BOOST_FILESYSTEM

# =====
# Debug
# =====
AC_ARG_ENABLE(debug,
	AS_HELP_STRING([--enable-debug], [Build with debug features in mind.])],
	[enable_debug="$enableval"],
	[enable_debug=no]
)
AS_IF([test "x$enable_debug" != "xno"], [
	CXXFLAGS="$CXXFLAGS -g -O0"
], [
	CXXFLAGS="$CXXFLAGS -O2"
	AC_DEFINE([NDEBUG], [], [Disable debugging information])
])

PKG_CHECK_MODULES([MDDS],[mdds-2.1 >= 2.0.99])

AC_ARG_ENABLE(log-debug,
	AS_HELP_STRING([--enable-log-debug], [Enable debug outputs.])],
	[enable_log_debug="$enableval"],
	[enable_log_debug=no    ]
)

AS_IF([test "x$enable_log_debug" != "xno"], [
        CXXFLAGS="$CXXFLAGS -DIXION_DEBUG_ON"
],)

AC_ARG_ENABLE(log-trace,
	AS_HELP_STRING([--enable-log-trace], [Enable trace outputs.])],
	[enable_log_trace="$enableval"],
	[enable_log_trace=no]
)

AS_IF([test "x$enable_log_trace" != "xno"], [
        CXXFLAGS="$CXXFLAGS -DIXION_TRACE_ON"
],)

# Check for python.
AS_IF([test "x$enable_python" != "xno"], [
    AM_PATH_PYTHON(3)
    PKG_CHECK_MODULES([PYTHON], [python3 >= 3.4])
])

AS_IF([test "x$enable_threads" != "xno"], [
        CXXFLAGS="$CXXFLAGS -DIXION_THREADS=1"
], [
        CXXFLAGS="$CXXFLAGS -DIXION_THREADS=0"
])

AS_IF([test "x$enable_debug_utils" != "xno"], [
        CXXFLAGS="$CXXFLAGS -DIXION_DEBUG_UTILS"
])

AS_IF([test "x$enable_vulkan" != "xno"], [
        PKG_CHECK_MODULES([VULKAN],[vulkan >= 1.2.0])
])

AM_CONDITIONAL([BUILD_PYTHON], [test "x$enable_python" != "xno"])
AM_CONDITIONAL([IXION_THREADS], [test "x$enable_threads" != "xno"])
AM_CONDITIONAL([BUILD_VULKAN], [test "x$enable_vulkan" != "xno"])
AM_CONDITIONAL([OSX], [test "x$_os" = "xDarwin"])

BOOST_PROGRAM_OPTIONS

# ==============
# Werror support
# ==============

# NB: This must come at the end of all the other header detections, as enabling
# it may cause some header detections to fail.

AC_ARG_ENABLE([werror],
	[AS_HELP_STRING([--enable-werror], [Treat all warnings as errors, useful for development])],
	[enable_werror="$enableval"],
	[enable_werror=no]
)
AS_IF([test x"$enable_werror" = "xyes"], [
	CXXFLAGS="$CXXFLAGS -Werror"
])

AC_CONFIG_FILES([Makefile
                 libixion-$IXION_API_VERSION.pc:libixion.pc.in
                 bin/env.sh
                 doc_example/Makefile
                 doc_example/section_examples/Makefile
                 include/Makefile
                 include/ixion/Makefile
                 include/ixion/interface/Makefile
                 misc/libixion.spec
                 src/Makefile
                 src/include/Makefile
                 src/libixion/Makefile
                 src/libixion/constants.inl
                 src/python/Makefile
                 src/test/Makefile
])
AC_OUTPUT

AC_MSG_NOTICE([
==============================================================================
Build configuration:
        debug-utils           $enable_debug_utils
        host os:              $host_os
        python:               $enable_python
        threads:              $enable_threads
        vulkan:               $enable_vulkan
        log (debug)           $enable_log_debug
        log (trace)           $enable_log_trace
==============================================================================
])