forked from jedwing/CHMLib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
189 lines (157 loc) · 4.28 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
dnl Process this file with autoconf to produce a configure script.
AC_INIT([chmlib],[0.40])
dnl,[Jed Wing <[email protected]>])
AC_CONFIG_SRCDIR(src/chm_lib.c)
AM_INIT_AUTOMAKE
AM_MAINTAINER_MODE
dnl Checks for programs.
AC_PROG_CC
AC_PROG_LD
AM_PROG_LIBTOOL
AC_PROG_INSTALL
dnl Checks for header files.
AC_CHECK_HEADERS(string.h strings.h unistd.h)
dnl Enable developer code (e.g. core dumps)
ac_devel_cflags="-g -Wall"
AC_ARG_ENABLE(devel,
[AC_HELP_STRING(
[--enable-devel],
[enable code of interest to developers])
],
[
if test x"$enableval" = xyes ; then
devel="yes"
else
devel="no"
fi
])
dnl default defines
CHM_MT="-DCHM_MT"
CHM_USE_PREAD="-DCHM_USE_PREAD"
CHM_USE_IO64="-DCHM_USE_IO64"
DMALLOC_DISABLE="-DDMALLOC_DISABLE"
dnl With chmLib
EXAMPLES="test_chmLib enum_chmLib enumdir_chmLib extract_chmLib"
LDFLAGS="$LDFLAGS"
AC_ARG_ENABLE(pthread,
[AC_HELP_STRING(
[--disable-pthread],
[disable pthreads and do not build thread safe library])
],
[
if test "$enableval" = "yes"; then
AC_CHECK_LIB(pthread,pthread_mutex_init)
EXAMPLES="$EXAMPLES chm_http"
LDFLAGS="$LDFLAGS -lpthread"
else
CHM_MT=""
AC_MSG_WARN(Thread safe mode turned off. chm_http will not be built)
fi
],
[
AC_CHECK_LIB(pthread,pthread_mutex_init)
EXAMPLES="$EXAMPLES chm_http"
LDFLAGS="$LDFLAGS -lpthread"
])
AC_ARG_ENABLE(io64,
[AC_HELP_STRING(
[--disable-io64],
[do not build chm_lib with support of 64-bit file I/O])
],
[
if test "$enableval" = "no"; then
CHM_USE_IO64=""
fi
])
AC_ARG_ENABLE(pread,
[AC_HELP_STRING(
[--disable-pread],
[do not build chm_lib to use pread/pread64 for all I/O])
],
[
if test "$enableval" = "no"; then
CHM_USE_PREAD=""
fi
])
AC_ARG_ENABLE(dmalloc,
[AC_HELP_STRING(
[--enable-dmalloc],
[enable dmalloc])
],
[
if test "$enableval" = "yes"; then
DMALLOC_DISABLE=""
fi
])
dnl check for availability of the functions we need
if test -n "$CHM_USE_IO64"; then
AC_CHECK_FUNC(lseek64,,[
AC_MSG_WARN([64-bit file offsets not available, huge files won't be supported.])
CHM_USE_IO64=""])
fi
if test -n "$CHM_USE_PREAD"; then
if test -n "$CHM_USE_IO64"; then
pread_func="pread64"
else
pread_func="pread"
fi
AC_CHECK_FUNC($pread_func,,[
AC_MSG_WARN([pread() not available, falling back to less efficient replacement])
CHM_USE_PREAD=""])
fi
AC_ARG_ENABLE([examples],
[ --enable-examples Build example programs that use chmlib],
[case "${enableval}" in
yes) build_examples=true;;
no) build_examples=false;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-examples]);;
esac], [build_examples=false])
AM_CONDITIONAL([EXAMPLES],[test "x$build_examples" = xtrue])
AC_SUBST(EXAMPLES)
AC_SUBST(CHM_MT)
AC_SUBST(CHM_USE_PREAD)
AC_SUBST(CHM_USE_IO64)
AC_SUBST(DMALLOC_DISABLE)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_SIZE_T
dnl Checks for library functions.
AC_FUNC_MALLOC
dnl Checks for installation user/group
if test x"$install_user" = x; then
if test "x$target_os" = "xcygwin"; then
install_user=Administrator
else
install_user=root
fi
fi
if test x"$install_group" = x ; then
install_group=`sed -n '/.*:.*:0:/{s/^\(.*\):.*:0:.*/\1/p;q;}' /etc/group 2>/dev/null`
fi
AC_SUBST(install_user)
AC_SUBST(install_group)
if test x"$devel" = xyes ; then
AC_DEFINE(USE_DEVEL)
if test x"$GCC" = xyes; then
dnl Remove any optimization flags from CFLAGS
CFLAGS=`echo "$CFLAGS" | sed -e 's/\-O2//'`
CFLAGS="$CFLAGS $ac_devel_cflags"
dnl Some C compilers (e.g. older gcc versions) may not accept these
dnl options. Check if they are supported. They will be added to
dnl CFLAGS if supported.
dnl PR_CHECK_CC_OPT(Wfloat-equal)
fi
dnl Do not strip symboles from developer object files.
INSTALL_STRIP=""
else
dnl Make sure to strip symbols from non-developer object files.
INSTALL_STRIP="-s"
fi
CFLAGS="$CFLAGS $CHM_MT $CHM_USE_PREAD $CHM_USE_IO64"
dnl AC_PROG_LIBTOOL
dnl AC_SUBST(LIBTOOL)
dnl AC_SUBST(LD)
AC_SUBST(INSTALL_STRIP)
dnl top_builddir=`pwd`
dnl AC_SUBST(top_builddir)
dnl AC_OUTPUT_COMMANDS([if test ! -d src; then mkdir src; fi])
AC_OUTPUT([Makefile src/Makefile])