This repository has been archived by the owner on Oct 19, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 33
/
configure.ac
311 lines (262 loc) · 8.12 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
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
dnl
dnl Configuration script for the ESP Package Manager (EPM).
dnl
dnl Copyright © 1999-2020 by Michael R Sweet
dnl Copyright © 1999-2007 by Easy Software Products, all rights reserved.
dnl
dnl This program is free software; you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License as published by
dnl the Free Software Foundation; either version 2, or (at your option)
dnl any later version.
dnl
dnl This program is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
AC_INIT([EPM],[4.5.1],[https://github.com/michaelrsweet/epm/issues],[epm],[https://www.msweet.org/epm])
AC_CONFIG_HEADER(config.h)
dnl Version number...
VERSION="AC_PACKAGE_VERSION"
VERNUMBER=450
AC_SUBST(VERSION)
AC_SUBST(VERNUMBER)
AC_DEFINE_UNQUOTED(EPM_VERSION, "ESP Package Manager v$VERSION")
dnl Get the build and host platforms and split the host_os value
AC_CANONICAL_BUILD
AC_CANONICAL_HOST
[host_os_name=`echo $host_os | sed -e '1,$s/[0-9.]*$//g'`]
dnl Clear default debugging options and set normal optimization by
dnl default unless the user asks for debugging specifically.
CFLAGS="${CFLAGS:=}"
CXXFLAGS="${CXXFLAGS:=}"
LDFLAGS="${LDFLAGS:=}"
AC_SUBST(LDFLAGS)
AC_ARG_WITH(archflags, [ --with-archflags=flags specify architecture flags [[default=none]]],
ARCHFLAGS="$withval",
ARCHFLAGS="${ARCHFLAGS:=}")
AC_SUBST(ARCHFLAGS)
AC_ARG_ENABLE(debug, [ --enable-debug turn on debugging, default=no])
AC_ARG_ENABLE(sanitizer, [ --enable-sanitizer build with AddressSanitizer, default=no])
if test "x$enable_debug" = xyes; then
OPTIM="-g"
CSFLAGS=""
else
OPTIM="-Os -g"
CSFLAGS="-o runtime"
fi
AC_SUBST(CSFLAGS)
AC_SUBST(OPTIM)
AC_ARG_ENABLE(gui, [ --enable-gui turn on GUI utilities, default=auto])
AC_ARG_WITH(docdir, [ --with-docdir=/dir set directory for documentation
[[default=${datadir}/doc/epm]]],
docdir="$withval",
docdir="\${datadir}/doc/epm")
AC_SUBST(docdir)
AC_ARG_WITH(softwaredir, [ --with-softwaredir=/dir set directory for EPM uninstall files and init scripts
[[default=/etc/software]]],
softwaredir="$withval",
softwaredir="")
dnl Checks for programs...
AC_PROG_CC(clang cc gcc)
AC_PROG_CXX(clang++ c++ g++)
AC_PROG_RANLIB
AC_PATH_PROG(AR,ar)
AC_PATH_PROG(CHMOD,chmod)
AC_PATH_PROGS(CODE_SIGN, codesign true)
AC_PATH_PROG(CP,cp)
AC_PATH_PROG(GZIP,gzip)
if test x$GZIP = x; then
AC_MSG_ERROR([GNU zip not found but required.])
fi
AC_PATH_PROGS(HTMLDOC, htmldoc echo)
AC_PROG_INSTALL
if test "$INSTALL" = "$ac_install_sh"; then
# Use full path to install-sh script...
INSTALL="`pwd`/install-sh -c"
fi
AC_PATH_PROG(MKDIR,mkdir)
AC_PATH_PROG(RM,rm)
AC_PATH_PROG(RPM,rpm)
AC_PATH_PROG(RPMBUILD,rpmbuild)
AC_PATH_PROG(STRIP,strip)
dnl Architecture checks...
AC_C_CONST
AC_C_CHAR_UNSIGNED
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_CHECK_HEADER(strings.h,AC_DEFINE(HAVE_STRINGS_H))
AC_CHECK_HEADER(sys/mount.h,AC_DEFINE(HAVE_SYS_MOUNT_H))
AC_CHECK_HEADER(sys/param.h,AC_DEFINE(HAVE_SYS_PARAM_H))
AC_CHECK_HEADER(sys/statfs.h,AC_DEFINE(HAVE_SYS_STATFS_H))
AC_CHECK_HEADER(sys/vfs.h,AC_DEFINE(HAVE_SYS_VFS_H))
dnl Checks for string functions.
AC_CHECK_FUNCS(strcasecmp strdup strlcat strlcpy strncasecmp)
AC_CHECK_FUNCS(snprintf vsnprintf)
AC_SEARCH_LIBS(gethostname, socket)
if test "x$enable_gui" != xno; then
AC_PATH_PROG(FLTKCONFIG,fltk-config)
else
FLTKCONFIG=""
fi
if test "x$FLTKCONFIG" = x; then
GUIS=""
GUILIBS=""
INSTALL_GUIS=""
INSTALL_OSX=""
AC_MSG_WARN([Sorry, setup GUI requires FLTK 1.1.x or later.])
else
CXXFLAGS="`$FLTKCONFIG --cflags` ${CXXFLAGS}"
GUIS="setup uninst"
GUILIBS="`$FLTKCONFIG --use-images --ldstaticflags`"
INSTALL_GUIS="install-guis"
if test "$host_os_name" = darwin; then
GUILIBS="$GUILIBS -framework Security"
INSTALL_OSX="install-macos"
else
INSTALL_OSX=""
fi
fi
AC_SUBST(INSTALL_GUIS)
AC_SUBST(INSTALL_OSX)
AC_SUBST(GUIS)
AC_SUBST(GUILIBS)
dnl Set the default compression value...
case "$host_os_name" in
darwin* | *bsd* | linux* | sunos*)
# macOS, *BSD, Linux, and Solaris come with gzip standard
AC_DEFINE(EPM_COMPRESS, 1)
;;
*)
# All other OS's do not.
AC_DEFINE(EPM_COMPRESS, 0)
;;
esac
dnl Update compiler options...
if test -n "$GCC"; then
if test x$enable_sanitizer = xyes; then
# Use -fsanitize=address with debugging...
OPTIM="-g -fsanitize=address"
else
# Otherwise use the Fortify enhancements to catch any unbounded
# string operations...
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2"
CXXFLAGS="$CXXFLAGS -D_FORTIFY_SOURCE=2"
fi
# Add useful warning options...
CFLAGS="-Wall -Wformat -Wno-format-y2k -Wunused $CFLAGS"
CXXFLAGS="-Wall -Wformat -Wno-format-y2k -Wunused $CXXFLAGS"
# See if GCC supports -Wno-format-truncation...
AC_MSG_CHECKING(if GCC supports -Wno-format-truncation)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -Werror -Wno-format-truncation"
AC_TRY_COMPILE(,,[
CFLAGS="$OLDCFLAGS -Wno-format-truncation"
CXXFLAGS="$CXXFLAGS -Wno-format-truncation"
AC_MSG_RESULT(yes)],[
AC_MSG_RESULT(no)
CFLAGS="$OLDCFLAGS"])
# See if GCC supports -fno-rtti...
AC_MSG_CHECKING(if GCC supports -fno-rtti)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-rtti"
AC_TRY_COMPILE(,,
CXXFLAGS="$CXXFLAGS -fno-rtti"
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
# See if GCC supports -fno-exceptions...
AC_MSG_CHECKING(if GCC supports -fno-exceptions)
OLDCFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fno-exceptions"
AC_TRY_COMPILE(,,
CXXFLAGS="$CXXFLAGS -fno-exceptions"
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no))
CFLAGS="$OLDCFLAGS"
fi
dnl Flags for "ar" command...
case $host_os_name in
darwin* | *bsd*)
ARFLAGS="-rc"
;;
*)
ARFLAGS="crs"
;;
esac
AC_SUBST(ARFLAGS)
dnl Fix "prefix" variable if it hasn't been specified...
if test "$prefix" = "NONE"; then
prefix="/usr/local"
fi
dnl Fix "exec_prefix" variable if it hasn't been specified...
if test "$exec_prefix" = "NONE"; then
exec_prefix="$prefix"
fi
dnl Fix "libdir" variable if it hasn't been specified...
if test "$libdir" = "\${exec_prefix}/lib"; then
libdir="$exec_prefix/lib"
fi
dnl Fix "datarootdir" variable if it hasn't been specified...
if test "$datarootdir" = "\${prefix}/share"; then
if test "$prefix" = "/"; then
datarootdir="/usr/share"
else
datarootdir="$prefix/share"
fi
fi
dnl Fix "datadir" variable if it hasn't been specified...
if test "$datadir" = "\${prefix}/share"; then
if test "$prefix" = "/"; then
datadir="/usr/share"
else
datadir="$prefix/share"
fi
elif test "$datadir" = "\${datarootdir}"; then
datadir="$datarootdir"
fi
dnl EPM_SOFTWARE needs special attention for the default location...
if test x$softwaredir = x; then
EPM_SOFTWARE="/etc/software"
else
EPM_SOFTWARE="$softwaredir"
fi
AC_DEFINE_UNQUOTED(EPM_SOFTWARE, "$EPM_SOFTWARE")
AC_SUBST(EPM_SOFTWARE)
AC_DEFINE_UNQUOTED(EPM_GZIP, "$GZIP")
AC_SUBST(EPM_GZIP)
AC_DEFINE_UNQUOTED(EPM_STRIP, "$STRIP")
AC_SUBST(EPM_STRIP)
AC_DEFINE_UNQUOTED(EPM_BINDIR, "$exec_prefix/bin")
AC_SUBST(EPM_BINDIR)
AC_DEFINE_UNQUOTED(EPM_LIBDIR, "$libdir/epm")
AC_SUBST(EPM_LIBDIR)
AC_DEFINE_UNQUOTED(EPM_DATADIR, "$datadir/epm")
AC_SUBST(EPM_DATADIR)
dnl Figure out the right option to use for the RPM build architecture...
if test "x$RPM" != x; then
# It would be nice if Red Hat could make up its mind...
rpmversion="`$RPM --version | awk '{print $3}' | awk -F. '{print $1 * 10000 + $2 * 100 + $3}'`"
if test $rpmversion -lt 30000; then
AC_DEFINE_UNQUOTED(EPM_RPMARCH, "--buildarch ")
else
if test $rpmversion -ge 40003; then
AC_DEFINE_UNQUOTED(EPM_RPMARCH, "--target ")
else
AC_DEFINE_UNQUOTED(EPM_RPMARCH, "--target=")
fi
fi
fi
if test "x$RPMBUILD" != x; then
AC_DEFINE_UNQUOTED(EPM_RPMBUILD, "$RPMBUILD")
AC_DEFINE(EPM_RPMTOPDIR)
else
if test "x$RPM" != x; then
AC_DEFINE_UNQUOTED(EPM_RPMBUILD, "$RPM")
else
AC_DEFINE_UNQUOTED(EPM_RPMBUILD, "rpm")
fi
fi
dnl Output the makefile, list file, and config header...
AC_OUTPUT(Makefile epm.list doc/Makefile)