forked from CESNET/GPUJPEG
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
233 lines (194 loc) · 7.39 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
AC_PREREQ([2.65])
# change version also in CMakeLists.txt
AC_INIT([libgpujpeg],[0.25.6],[https://github.com/CESNET/GPUJPEG/issues],[libgpujpeg],[https://github.com/CESNET/GPUJPEG])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_HEADERS([libgpujpeg/gpujpeg_version.h])
COMMON_FLAGS="${COMMON_FLAGS:+$COMMON_FLAGS }-DHAVE_GPUJPEG_VERSION_H"
AC_DEFINE([GPUJPEG_VERSION_MAJOR], regexp(AC_PACKAGE_VERSION, [\([^.]*\)], [\1]), [GPUJPEG major version])
AC_DEFINE([GPUJPEG_VERSION_MINOR], regexp(AC_PACKAGE_VERSION, [[^.]*\.\([^.]*\)], [\1]), [GPUJPEG minor version])
AC_DEFINE([GPUJPEG_VERSION_PATCH], regexp(AC_PACKAGE_VERSION, [[^.]*\.[^.]*\.\([^.]*\)], [\1]), [GPUJPEG patch version])
GPUJPEG_LIBRARY_VERSION=0:1:0
AC_SUBST(GPUJPEG_LIBRARY_VERSION)
LT_PREREQ([2.2])
LT_INIT([disable-static])
# Checks for programs.
AC_PROG_CXX
AC_PROG_CC
AC_PROG_INSTALL
AM_PROG_CC_C_O
# debug
AC_ARG_ENABLE(debug, AS_HELP_STRING([--enable-debug], [compile with debug info]) )
if test x$enable_debug = x ; then
enable_debug=no
fi
AM_CONDITIONAL([STATIC], [test x$enable_static = xyes])
if test "$enable_static" = yes && test "$enable_shared" = yes; then
AC_MSG_ERROR([Currently only one of --enable-static/--enable-shared can be specified at once.])
fi
if test "$enable_static" = yes; then
pc_cflags="${pc_cflags:+$pc_cflags }-DGPUJPEG_STATIC"
pc_libs="${pc_libs:+$pc_libs }-lcudart"
fi
AC_SUBST(pc_cflags)
AC_ARG_VAR([CUDA_FLAGS], [Flags passed to nvcc])
if test x$enable_debug = xyes ; then
COMMON_FLAGS="$COMMON_FLAGS -g -D_DEBUG -O0"
CUDA_FLAGS="$CUDA_FLAGS -G"
else
COMMON_FLAGS="$COMMON_FLAGS -O2"
fi
# huffmann
AC_ARG_ENABLE(huffman-gpu-const-tables, AS_HELP_STRING([--enable-huffman-gpu-const-tables],[enable Huffman GPU decoder tables in constant memory]) )
if test x$enable_huffman_gpu_const_tables = xyes ; then
COMMON_FLAGS="$COMMON_FLAGS -DHUFFMAN_GPU_CONST_TABLES"
else
enable_huffman_gpu_const_tables=no
fi
# opengl
AC_ARG_ENABLE(opengl, AS_HELP_STRING([--enable-opengl],[enable opengl support]) )
if test x$enable_opengl = x ; then
enable_opengl=auto
fi
# OS X universal build
AC_ARG_ENABLE(osx-universal, AS_HELP_STRING([--enable-osx-universal],[enable OS X universal build]) )
if test x$enable_osx_universal = x ; then
enable_osx_universal=no
fi
opengl=no
opengl_context=none
if test $enable_opengl != no ; then
AC_CHECK_HEADER(GL/glew.h, FOUND_GLEW_H=yes)
AC_CHECK_LIB(GLEW, glewIsSupported, FOUND_GLEW_L=yes)
AC_CHECK_LIB(GL, glBindTexture, FOUND_GL_L=yes)
AC_CHECK_LIB(X11, XCreateWindow, FOUND_X11_L=yes)
AC_CHECK_HEADER(GL/glx.h, FOUND_GLX_H=yes)
AC_CHECK_LIB(glfw, glfwCreateWindow, FOUND_GLFW_L=yes)
AC_CHECK_HEADER(GLFW/glfw3.h, FOUND_GLFW_H=yes)
opengl=yes
if test "$FOUND_GLEW_L" != yes -o "$FOUND_GLEW_H" != yes -o "$FOUND_GL_L" != yes; then
opengl=no
elif test "$FOUND_X11_L" = yes -a "$FOUND_GLX_H" = yes; then
COMMON_FLAGS="$COMMON_FLAGS -DGPUJPEG_USE_GLX"
GPUJPEG_LIBS="${GPUJPEG_LIBS:+$GPUJPEG_LIBS }-lX11"
opengl_context=glx
elif test "$FOUND_GLFW_L" = yes -a "$FOUND_GLFW_H" = yes; then
COMMON_FLAGS="$COMMON_FLAGS -DGPUJPEG_USE_GLFW"
GPUJPEG_LIBS="${GPUJPEG_LIBS:+$GPUJPEG_LIBS }-lGLFW"
opengl_context=glfw
fi
if test $opengl = yes; then
COMMON_FLAGS="$COMMON_FLAGS -DGPUJPEG_USE_OPENGL"
GPUJPEG_LIBS="${GPUJPEG_LIBS:+$GPUJPEG_LIBS }-lGLEW -lGL"
fi
if test $enable_opengl = yes -a $opengl = no; then
AC_MSG_ERROR([OpenGL required but dependencies not found!])
fi
fi
# CUDA
CUDA_COMPUTE_ARGS=""
CUDA_COMPILER=""
AC_ARG_WITH(cuda,
AS_HELP_STRING([--with-cuda=DIR],[specify cuda root]),
CUDA_INSTALL_PATH=$withval
)
AC_PATH_PROG(CUDA, nvcc, nvcc_not_found, [${CUDA_INSTALL_PATH}/bin${PATH_SEPARATOR}$PATH${PATH_SEPARATOR}/opt/cuda/bin${PATH_SEPARATOR}/usr/local/cuda/bin])
if test "x$CUDA" = xnvcc_not_found ; then
AC_MSG_FAILURE([CUDA is required to build the gpujpeg library!])
fi
CUDA_COMPILER="$CUDA"
CUDA=`dirname "$CUDA"`
CUDA=`dirname "$CUDA"`
CUDA_INSTALL_PATH=$CUDA
LBITS=`getconf LONG_BIT`
if test $LBITS = 64 -a `uname -s` != 'Darwin'; then
CUDA_INSTALL_LIB="${CUDA_INSTALL_PATH}/lib64"
elif test $LBITS = 64 -a `uname -o` = 'Msys'; then
CUDA_INSTALL_LIB="${CUDA_INSTALL_PATH}/lib/x64"
else
CUDA_INSTALL_LIB="${CUDA_INSTALL_PATH}/lib"
fi
AM_CONDITIONAL([DARWIN], [test `uname -s` = Darwin])
if test $enable_osx_universal = yes; then
CFLAGS="$CFLAGS -arch x86_64 -arch i386"
CXXFLAGS="$CXXFLAGS -arch x86_64 -arch i386"
LIBGPUJPEG_CUDA_OBJS=" \
build/universal/gpujpeg_huffman_gpu_encoder.o \
build/universal/gpujpeg_dct_gpu.o \
build/universal/gpujpeg_postprocessor.o \
build/universal/gpujpeg_preprocessor.o \
build/universal/gpujpeg_huffman_gpu_decoder.o"
CUDA_FLAGS="$CUDA_FLAGS -Xcompiler -Wno-error=unused-command-line-argument-hard-error-in-future"
else
LIBGPUJPEG_CUDA_OBJS=" \
src/gpujpeg_huffman_gpu_encoder.cu.o \
src/gpujpeg_dct_gpu.cu.o \
src/gpujpeg_postprocessor.cu.o \
src/gpujpeg_preprocessor.cu.o \
src/gpujpeg_huffman_gpu_decoder.cu.o"
fi
AC_ARG_WITH(cuda-compiler,
AS_HELP_STRING([--with-cuda-compiler=compiler], [select compiler to compile cuda code with; suported: clang, nvcc; default: nvcc autodetected from cuda]),
[CUDA_COMPILER="$withval"])
case "$CUDA_COMPILER" in
*nvcc*)
;;
*clang*)
CUDA_COMPUTE_ARGS="--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35"
CUDA_FLAGS+=" --cuda-path=$CUDA_INSTALL_PATH"
;;
*)
AC_MSG_ERROR([Unsupported cuda compiler $CUDA_COMPILER])
;;
esac
# escape paths to remove potentially harmful spaces in paths on MSW
if test `uname -o` = 'Msys'; then
CUDA_INSTALL_PATH="\"$CUDA_INSTALL_PATH\""
CUDA_INSTALL_LIB="\"$CUDA_INSTALL_LIB\""
CUDA_COMPILER="\"$CUDA_COMPILER\""
fi
# CUDA host compiler
AC_ARG_WITH(cuda-host-compiler,
AS_HELP_STRING([--with-cuda-host-compiler=BINARY],[specify compiler used for building cuda host code]))
if test "x${with_cuda_host_compiler}" != "x" ; then
AC_CHECK_PROG([cuda_host_cc], [${with_cuda_host_compiler}],[yes])
if test "x${cuda_host_cc}" = "xyes" -o -x "${with_cuda_host_compiler}"; then
CUDA_FLAGS+=" -ccbin ${with_cuda_host_compiler}"
else
AC_MSG_FAILURE([Binary ${with_cuda_host_compiler} given as cuda host compiler, yet not found!])
fi
else
with_cuda_host_compiler="default"
fi
GPUJPEG_LDFLAGS="$GPUJPEG_LDFLAGS -L${CUDA_INSTALL_LIB}"
GPUJPEG_LIBS="$GPUJPEG_LIBS -lcudart"
COMMON_FLAGS="$COMMON_FLAGS -I. -I${CUDA_INSTALL_PATH}/include"
AC_SUBST(CUDA_EXTRA_ARCH)
AC_SUBST(CUDA_INSTALL_PATH)
AC_SUBST(CUDA_INSTALL_LIB)
AC_SUBST(COMMON_FLAGS)
AC_SUBST(GPUJPEG_CFLAGS)
AC_SUBST(GPUJPEG_LDFLAGS)
AC_SUBST(GPUJPEG_LIBS)
AC_SUBST(LIBGPUJPEG_CUDA_OBJS)
AC_SUBST(CUDA_FLAGS)
AC_SUBST(CUDA_COMPILER)
AC_SUBST(CUDA_COMPUTE_ARGS)
AC_CONFIG_FILES([Makefile libgpujpeg.pc test/memcheck/Makefile test/opengl_interop/Makefile ])
AC_OUTPUT
AC_MSG_RESULT([
Configuration summary:
Target ...................... $host
Prefix ...................... $prefix
Debug ....................... $enable_debug
Shared library .............. $enable_shared
Static library .............. $enable_static
Huffman const tables ........ $enable_huffman_gpu_const_tables
OpenGL ...................... $opengl ($opengl_context)
Host compiler ............... $with_cuda_host_compiler
Cuda compiler ............... $CUDA_COMPILER
CUDA root ................... $CUDA_INSTALL_PATH
])
# vi: set noexpandtab: