forked from estraier/tkrzw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure.in
227 lines (198 loc) · 8.16 KB
/
configure.in
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
# Source of configuration for Tkrzw
#================================================================
# Generic Settings
#================================================================
# Package name
AC_INIT(tkrzw, 0.9.3)
# Package information
MYLIBVER=0
MYLIBREV=3
MYLIBFMT=0
# Targets
MYHEADERFILES="tkrzw_lib_common.h tkrzw_str_util.h tkrzw_cmd_util.h tkrzw_thread_util.h tkrzw_containers.h tkrzw_key_comparators.h tkrzw_file.h tkrzw_file_util.h tkrzw_file_mmap.h tkrzw_file_pos.h tkrzw_dbm.h tkrzw_dbm_common_impl.h tkrzw_dbm_hash_impl.h tkrzw_dbm_hash.h tkrzw_dbm_tree_impl.h tkrzw_dbm_tree.h tkrzw_dbm_skip_impl.h tkrzw_dbm_skip.h tkrzw_dbm_tiny.h tkrzw_dbm_baby.h tkrzw_dbm_cache.h tkrzw_dbm_std.h tkrzw_dbm_poly.h tkrzw_dbm_shard.h tkrzw_index.h"
MYLIBRARYFILES="libtkrzw.a"
MYLIBOBJFILES="tkrzw_lib_common.o tkrzw_str_util.o tkrzw_cmd_util.o tkrzw_thread_util.o tkrzw_file_util.o tkrzw_file_mmap.o tkrzw_file_pos.o tkrzw_dbm.o tkrzw_dbm_common_impl.o tkrzw_dbm_hash_impl.o tkrzw_dbm_hash.o tkrzw_dbm_tree_impl.o tkrzw_dbm_tree.o tkrzw_dbm_skip_impl.o tkrzw_dbm_skip.o tkrzw_dbm_tiny.o tkrzw_dbm_baby.o tkrzw_dbm_cache.o tkrzw_dbm_std.o tkrzw_dbm_poly.o tkrzw_dbm_shard.o"
MYCOMMANDFILES="tkrzw_build_util tkrzw_str_perf tkrzw_file_perf tkrzw_dbm_perf tkrzw_dbm_util"
MYTESTFILES="tkrzw_sys_config_test tkrzw_lib_common_test tkrzw_str_util_test tkrzw_cmd_util_test tkrzw_thread_util_test tkrzw_containers_test tkrzw_key_comparators_test tkrzw_file_util_test tkrzw_file_mmap_test tkrzw_file_pos_test tkrzw_dbm_common_impl_test tkrzw_dbm_hash_impl_test tkrzw_dbm_tree_impl_test tkrzw_dbm_tree_test tkrzw_dbm_hash_test tkrzw_dbm_skip_impl_test tkrzw_dbm_skip_test tkrzw_dbm_tiny_test tkrzw_dbm_baby_test tkrzw_dbm_cache_test tkrzw_dbm_std_test tkrzw_dbm_poly_test tkrzw_dbm_shard_test tkrzw_index_test"
MYPCFILES="tkrzw.pc"
# Building flags
MYCFLAGS="-pthread -Wall -ansi -pedantic -fPIC -fsigned-char -g0 -O2"
MYCXXFLAGS="-std=c++17 -pthread -Wall -fPIC -fsigned-char -g0 -O2"
MYCPPFLAGS="-I. -I\$(INCLUDEDIR) -I/usr/local/include"
MYCPPFLAGS="$MYCPPFLAGS -DNDEBUG -D_GNU_SOURCE=1 -D_ISOC99_SOURCE=1 -D_POSIX_C_SOURCE=200809L"
MYCPPFLAGS="$MYCPPFLAGS -D_FILE_OFFSET_BITS=64 -D_REENTRANT -D__EXTENSIONS__"
MYLDFLAGS="-L. -L\$(LIBDIR) -L/usr/local/lib"
MYCMDLDFLAGS="-L. -L\$(LIBDIR) -L/usr/local/lib"
MYCMDLIBS="-ltkrzw"
MYTESTLIBS="-lgtest -lgmock -lpthread"
MYLDLIBPATH=""
MYLDLIBPATHENV="LD_LIBRARY_PATH"
MYPOSTCMD="true"
# Building paths
PATH=".:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH"
CPATH=".:/usr/local/include:$CPATH"
LIBRARY_PATH=".:/usr/local/lib:$LIBRARY_PATH"
LD_LIBRARY_PATH=".:/usr/local/lib:$LD_LIBRARY_PATH"
PKG_CONFIG_PATH=".:/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH"
export PATH CPATH LIBRARY_PATH LD_LIBRARY_PATH PKG_CONFIG_PATH
#================================================================
# Options
#================================================================
# Internal variables
enables=""
is_static=""
# Debug mode
AC_ARG_ENABLE(debug,
AC_HELP_STRING([--enable-debug], [build for debugging]))
if test "$enable_debug" = "yes"
then
MYCFLAGS="-Wall -ansi -pedantic -fPIC -fsigned-char -g -O0"
MYCXXFLAGS="-std=c++17 -Wall -Wextra -Wno-unused-parameter -fPIC -fsigned-char -g -O0"
MYCPPFLAGS="$MYCPPFLAGS -UNDEBUG -D_TKRWX_DEBUG"
enables="$enables (debug)"
fi
# Disable optimization
AC_ARG_ENABLE(opt,
AC_HELP_STRING([--disable-opt], [build without optimization]))
if test "$enable_opt" = "no"
then
MYCFLAGS="$MYCFLAGS -O0"
MYCXXFLAGS="$MYCXXFLAGS -O0"
enables="$enables (no-opt)"
fi
# Profiling mode
AC_ARG_ENABLE(profile,
AC_HELP_STRING([--enable-profile], [build for profiling]))
if test "$enable_profile" = "yes"
then
MYCXXFLAGS="-std=c++17 -Wall -fPIC -fsigned-char -g -pg -O2 -fno-inline -pipe"
enables="$enables (profile)"
fi
# Optimize for the native architecture
AC_ARG_ENABLE(optarch,
AC_HELP_STRING([--enable-optarch], [build with optimization for the native architecture]))
if test "$enable_optarch" = "yes"
then
MYCFLAGS="$MYCFLAGS -O3 -march=native"
MYCXXFLAGS="$MYCXXFLAGS -O3 -march=native"
enables="$enables (optarch)"
fi
# Static mode
AC_ARG_ENABLE(static,
AC_HELP_STRING([--enable-static], [build by static linking]))
if test "$enable_static" = "yes"
then
is_static="yes"
enables="$enables (static)"
fi
# Disable shared object
AC_ARG_ENABLE(shared,
AC_HELP_STRING([--disable-shared], [avoid to build shared libraries]))
if test "$enable_shared" = "no"
then
enables="$enables (no-shared)"
fi
# Messages
printf '#================================================================\n'
printf '# Configuring Tkrzw version %s%s.\n' "$PACKAGE_VERSION" "$enables"
printf '#================================================================\n'
#================================================================
# Checking Commands and Libraries
#================================================================
# C and C++ compilers
AC_PROG_CC
AC_PROG_CXX
AC_LANG(C++)
# Reset variables
if test "$GCC" != "yes"
then
AC_MSG_WARN([another compiler except for GCC was detected])
MYCFLAGS=""
MYCXXFLAGS=""
fi
test -n "$CFLAGS" && MYCFLAGS="$CFLAGS $MYCFLAGS"
test -n "$CXXFLAGS" && MYCXXFLAGS="$CXXFLAGS $MYCXXFLAGS"
test -n "$CPPFLAGS" && MYCPPFLAGS="$CPPFLAGS $MYCPPFLAGS"
test -n "$LDFLAGS" && MYLDFLAGS="$LDFLAGS $MYLDFLAGS"
# Byte order
AC_C_BIGENDIAN(MYCPPFLAGS="$MYCPPFLAGS -D_TKRWX_BIGEND")
# Underlying libraries
AC_CHECK_LIB(c, main)
AC_CHECK_LIB(m, main)
AC_CHECK_LIB(pthread, main)
AC_CHECK_LIB(rt, main)
AC_CHECK_LIB(stdc++, main)
AC_CHECK_LIB(tkrzw, main, AC_MSG_WARN([old version of Tkrzw was detected]))
MYLDLIBPATH="$LD_LIBRARY_PATH"
# Necessary headers
AC_CHECK_HEADER(stdlib.h, true, AC_MSG_ERROR([stdlib.h is required]))
AC_CHECK_HEADER(stdint.h, true, AC_MSG_ERROR([stdint.h is required]))
AC_CHECK_HEADER(unistd.h, true, AC_MSG_ERROR([unistd.h is required]))
AC_CHECK_HEADER(fcntl.h, true, AC_MSG_ERROR([fcntl.h is required]))
AC_CHECK_HEADER(dirent.h, true, AC_MSG_ERROR([dirent.h is required]))
AC_CHECK_HEADER(pthread.h, true, AC_MSG_ERROR([pthread.h is required]))
AC_CHECK_HEADER(utility, true, AC_MSG_ERROR([utility is required]))
AC_CHECK_HEADER(string, true, AC_MSG_ERROR([string is required]))
AC_CHECK_HEADER(atomic, true, AC_MSG_ERROR([atomic is required]))
AC_CHECK_HEADER(mutex, true, AC_MSG_ERROR([mutex is required]))
AC_CHECK_HEADER(thread, true, AC_MSG_ERROR([thread is required]))
AC_CHECK_HEADER(regex, true, AC_MSG_ERROR([regex is required]))
AC_CHECK_HEADER(cstdint, true, AC_MSG_ERROR([cstdint is required]))
# Static linking
if test "$is_static" = "yes"
then
MYCMDLDFLAGS="$MYCMDLDFLAGS -static"
LIBS=`echo "${LIBS}" |\
sed -e 's/-lpthread/-Wl,--whole-archive -lpthread -Wl,--no-whole-archive/'`
fi
# As-needed linking
if uname | grep Linux >config.tmp
then
MYLDFLAGS="$MYLDFLAGS -Wl,-rpath-link,.:/usr/local/lib:$MYLDLIBPATH"
MYLDFLAGS="$MYLDFLAGS -Wl,--as-needed"
fi
# Shared libraries
if test "$enable_shared" != "no" && test "$enable_profile" != "yes"
then
if uname | grep Darwin >config.tmp
then
MYLIBRARYFILES="$MYLIBRARYFILES libtkrzw.$MYLIBVER.$MYLIBREV.0.dylib"
MYLIBRARYFILES="$MYLIBRARYFILES libtkrzw.$MYLIBVER.dylib"
MYLIBRARYFILES="$MYLIBRARYFILES libtkrzw.dylib"
MYLDLIBPATHENV="DYLD_LIBRARY_PATH"
else
MYLIBRARYFILES="$MYLIBRARYFILES libtkrzw.so.$MYLIBVER.$MYLIBREV.0"
MYLIBRARYFILES="$MYLIBRARYFILES libtkrzw.so.$MYLIBVER"
MYLIBRARYFILES="$MYLIBRARYFILES libtkrzw.so"
fi
fi
#================================================================
# Generic Settings
#================================================================
# Export variables
AC_SUBST(MYLIBVER)
AC_SUBST(MYLIBREV)
AC_SUBST(MYLIBFMT)
AC_SUBST(MYHEADERFILES)
AC_SUBST(MYLIBRARYFILES)
AC_SUBST(MYLIBOBJFILES)
AC_SUBST(MYCOMMANDFILES)
AC_SUBST(MYTESTFILES)
AC_SUBST(MYPCFILES)
AC_SUBST(MYCFLAGS)
AC_SUBST(MYCXXFLAGS)
AC_SUBST(MYCPPFLAGS)
AC_SUBST(MYLDFLAGS)
AC_SUBST(MYCMDLDFLAGS)
AC_SUBST(MYCMDLIBS)
AC_SUBST(MYTESTLIBS)
AC_SUBST(MYLDLIBPATH)
AC_SUBST(MYLDLIBPATHENV)
AC_SUBST(MYPOSTCMD)
# Targets
AC_OUTPUT(Makefile tkrzw.pc)
# Messages
printf '#================================================================\n'
printf '# Ready to make.\n'
printf '#================================================================\n'
# END OF FILE