forked from openxpki/openca-tools-forked
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
451 lines (362 loc) · 11.4 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
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
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
dnl -*- mode: m4; -*-
dnl Process this file with autoconf to produce a configure script.
dnl Autoconf boilerplate/
AC_INIT(src/sv/sv.c)
AC_PREREQ(2.50)
AC_CONFIG_AUX_DIR(build)
AC_CONFIG_MACRO_DIR([m4])
VERSION=`cat VERSION`
DATE=`date +%Y%m%d`
PKGNAME="openca-tools"
MINOR="1"
dnl Binary Packages Variables
AC_SUBST(PKGNAME)
AC_SUBST(MINOR)
AC_SUBST(DATE)
# Export variables to prevent autoconf to use rpl_malloc instead
# of malloc (it won't link properly otherwise!) - needed for iPhone
# build (cross compiling)
jm_cv_func_working_malloc=yes
ac_cv_func_malloc_0_nonnull=yes
if [[ "x$iphone_build" = "xyes" ]] ; then
AC_MSG_RESULT([*** WARNING: iPhone Development Selected])
AC_MSG_RESULT([*** Selected SDK is ${sdkver}])
iphone_dev=/Developer/Platforms/iPhoneOS.platform/Developer
iphone_sdk=$iphone_dev/SDKs/iPhoneOS${sdkver}.sdk
iphone_include=$iphone_sdk/usr/include
iphone_bin=$iphone_dev/usr/bin
default_path=$iphone_bin
build_os=arm-apple-iphone
if ! [[ "$host" = "arm-apple-darwin" ]] ; then
AC_MSG_RESULT([*** ERROR: Please add the '--host=arm-apple-darwin' option (now used '$host') *** ])
fi
CC=$iphone_bin/arm-apple-darwin9-gcc-4.0.1
dnl CPP=$iphone_bin/arm-apple-darwin9-g++-4.0.1
CFLAGS="-arch armv6 -bundle -isysroot $iphone_sdk -miphoneos-version-min=2.0"
CXX=$iphone_bin/arm-apple-darwin9-g++-4.0.1
CXXFLAGS="-arch armv6 -bundle -isysroot $iphone_sdk -miphoneos-version-min=2.0 -std=c99"
LDFLAGS="-dead_strip -framework Foundation -framework UIKit -dynamic"
CPPFLAGS="$CFLAGS"
else
jm_cv_func_working_malloc=yes
ac_cv_func_malloc_0_nonnull=yes
fi
AC_CANONICAL_SYSTEM
AC_PROG_LIBTOOL
AC_PROG_EGREP
CPU=`uname -p`
AC_SUBST(CPU)
dnl Automake boilerplate.
AM_INIT_AUTOMAKE(openca-tools,`cat VERSION` )
if [[ "x$iphone_build" = "xno" ]] ; then
AM_PROG_CC_C_O
fi
AM_MAINTAINER_MODE
myarch=
dnl Select OS specific versions of source files.
shlext=so
case "${build_os}" in
*linux*) myarch=linux
shlext=so
;;
*bsd*) myarch=bsd
shlext=so
;;
*iphone*) myarch=iphone
shlext=dylib
;;
*darwin*) myarch=darwin
shlext=dylib
;;
*sun*) myarch=solaris
shlext=so
;;
*solaris*) myarch=solaris
enable_shared=yes
shlext=so
;;
*hpux*) myarch=hpux
shlext=so
;;
*) AC_MSG_ERROR([Operating system ${build_os} not supported]) ;;
esac
arch_target=
case "$target" in
i*86-*) arch_target=x86 ;;
sparc*-*) arch_target=Sparc ;;
powerpc*-*) arch_target=PowerPC ;;
*sparc*solaris*) arch_target=Sparc ;;
*arm*) arch_target=armv6 ;;
*) arch_target=Unknown ;;
esac
AC_SUBST(arch_target)
AM_CONDITIONAL(ARCH_LINUX, test x$myarch = xlinux)
AM_CONDITIONAL(ARCH_BSD, test x$myarch = xbsd)
AM_CONDITIONAL(ARCH_OSX, test x$myarch = xdarwin)
AM_CONDITIONAL(ARCH_SOLARIS, test x$myarch = xsolaris)
AM_CONDITIONAL(ARCH_HPUX, test x$myarch = xhpux)
AM_CONDITIONAL(ENABLE_IPHONE, test x$enable_iphone = xyes)
if [[ "x$myarch" = "xsolaris" ]] ; then
DIST_VERSION=`uname -r`
else
if [[ -f "/etc/issue" ]] ; then
DIST_VERSION=`$EGREP -o [[0-9.]]+ /etc/issue | head -n 1`
else
DIST_VERSION=`echo ${build_os} | $EGREP -o [[0-9.]]+`
fi
fi
AC_SUBST(DIST_VERSION)
if [[ -f "/etc/issue" ]] ; then
DIST_NAME=`head -n 1 /etc/issue | cut -f 1,1 -d ' '`
else
DIST_NAME=`echo ${build_os} | $EGREP -o [[A-Za-z]]+`
fi
AC_SUBST(DIST_NAME)
dnl Check for install program
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_AWK
dnl AC_PROG_CC
AC_PROG_MAKE_SET
dnl AC_PROG_RANLIB
dnl LT_INIT
if test x$arch = xlinux ; then
AC_DEFINE(TARGET_LINUX, 1, [Linux])
fi
if test x$arch = xbsd ; then
AC_DEFINE(TARGET_BSD, 1, [BSD])
fi
if test x$arch = xdarwin ; then
AC_DEFINE(TARGET_OSX, 1, [OSX])
fi
if test x$arch = xsolaris ; then
AC_DEFINE(TARGET_SOLARIS, 1, [Solaris])
fi
if test x$arch = xhpux ; then
AC_DEFINE(TARGET_HPUX, 1, [HP-UX])
fi
dnl Automatically update the libtool script if it becomes out-of-date.
AC_SUBST(LIBTOOL_DEPS)
dnl Setup dist stuff
AC_SUBST(ac_aux_dir)
if [[ "x$iphone_build" = "xno" ]] ; then
dnl check for libraries
dnl AC_CHECK_LIB(nsl, gethostbyname)
dnl AC_CHECK_LIB(socket, socket)
dnl AC_CHECK_LIB(resolv, res_query)
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS([stdlib.h string.h sys/socket.h syslog.h])
fi
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_PID_T
AC_STRUCT_TM
# Checks for library functions.
AC_FUNC_FORK
AC_FUNC_MALLOC
AC_CHECK_FUNCS([bzero memset setenv socket strcasecmp strchr strrchr strstr])
AC_CONFIG_HEADERS(include/openca/config.h)
## this is a really dirty hack to avoid NONE in paths
## if test x"$prefix" = xNONE; then prefix=${ac_default_prefix}; fi
if test x"$prefix" = xNONE; then prefix=/usr; fi
if test x"$exec_prefix" = xNONE; then exec_prefix=${prefix}; fi
## this is a hack to get a real exec_prefix path and not
## something like ${prefix}
EXEC_PREFIX=$exec_prefix
AC_SUBST(EXEC_PREFIX)
# EXTRA_CFLAGS = "-Wall -Wmissing-field-initializers -Wmissing-parameter-type -Wtype-limits -Wuninitialized -Wconversion"
dnl check for stack protection of gcc
if [[ "$CC" = "gcc" ]] ; then
AC_CHECK_C_OPTION(-fstack-check)
AC_CHECK_C_OPTION(-maccumulate-outgoing-args)
if [[ "x${extra_checks}" = "xyes" ]] ; then
AC_CHECK_C_OPTION(-Wall)
AC_CHECK_C_OPTION(-Wmissing-field-initializers)
AC_CHECK_C_OPTION(-Wmissing-parameter-type)
AC_CHECK_C_OPTION(-Wtype-limits)
AC_CHECK_C_OPTION(-Wuninitialized)
AC_CHECK_C_OPTION(-Wconversion)
AC_CHECK_C_OPTION(-Werror)
AC_CHECK_C_OPTION(-Wfatal-errors)
fi
dnl AC_CHECK_C_OPTION(-m64)
dnl AC_CHECK_C_OPTION(-rdynamic)
dnl AC_CHECK_C_OPTION(--export-dynamic)
dnl AC_CHECK_C_OPTION(--export-all-symbols)
fi
EXTRA_CFLAGS=$CFLAGS
dnl Check for package and related programs
AC_PATH_PROG(DATE, date)
AC_PATH_PROG(CHMOD, chmod)
AC_PATH_PROG(PKGMK, pkgmk)
AC_PATH_PROG(RPM, rpm)
if test -n "${PKGMK}"
then
PKGMK=package
else
if test -n "${RPM}"
then
PKGMK=rpm
fi
fi
AC_SUBST(PKGMK)
AC_PATH_PROG(PERL, perl)
AC_SUBST(PERL)
dnl AC_PROG_CC
dnl AC_PROG_CPP
dnl AC_PROG_INSTALL
dnl AC_PROG_MAKE_SET
dnl AC_PROG_LN_S
dnl Add libtool support.
dnl AM_PROG_LIBTOOL
dnl AC_PROG_LIBTOOL
dnl Automatically update the libtool script if it becomes out-of-date.
dnl AC_SUBST(LIBTOOL_DEPS)
dnl Setup dist stuff
AC_SUBST(ac_aux_dir)
AC_ARG_WITH( build-dir,
AC_HELP_STRING( [--with-build-dir=DIR], [sets the DEST_DIR var
(default is "")]),
build_dir=$withval, build_dir= )
AC_SUBST(build_dir)
if [[ "x${DESTDIR}" == "" ]] ; then
DESTDIR="${build_dir}"
fi
AC_SUBST(DESTDIR)
AC_ARG_WITH( openca-user,
AC_HELP_STRING( [--with-openca-user=ARG], [sets the OpenCA's user id (default is root)]),
openca_user=$withval, openca_user=root )
AC_SUBST(openca_user)
AC_ARG_WITH( openca-group,
AC_HELP_STRING( [--with-openca-group=ARG], [sets the OpenCA's group id (default is root)]),
openca_group=$withval, openca_group=root )
AC_SUBST(openca_group)
dnl Check for Pod2Man program
AC_PATH_PROG( POD2MAN, pod2man,pod2man,
$PATH:/sbin:/usr/sbin:/usr/local/sbin)
dnl OpenSSL prefix
AC_ARG_WITH( openssl-prefix,
AC_HELP_STRING( [--with-openssl-prefix=DIR], [openssl prefix]),
openssl_prefix=$withval, openssl_prefix= )
AC_SUBST(openssl_prefix)
openssl_path=$PATH:/sbin:/usr/sbin:/usr/local/ssl/bin
if [[ x$openssl_prefix != x ]]; then
openssl_path=$openssl_prefix/bin:openssl_path
fi
AC_PATH_PROG( OPENSSL, openssl, openssl,
$openssl_path)
AC_ARG_WITH( openca-prefix,
AC_HELP_STRING( [--with-openca-prefix=OPENCAPREFIX], [sets OpenCA install prefix (default is EPREFIX/OpenCA)]),
openca_prefix=$withval, openca_prefix=${exec_prefix}/OpenCA)
AC_SUBST(openca_prefix)
dnl This section may no longer be necessary...
# if [[ x$openssl_prefix != x ]]; then
# openssl_path=$openssl_prefix/bin
# AC_MSG_RESULT([openssl lib dir : $openssl_path])
# else
# AC_MSG_RESULT([openssl lib dir : default])
# fi
AM_CONDITIONAL(OPENSSL_PREFIX, test x$openssl_prefix != x )
### Setup for OpenSSL build flags ###
dnl Now we like the version of openssl. Let's construct
dnl the build flags for using it. If we find pkg-config
dnl on the system and openssl uses it, we will take
dnl our settings from there. If not, we'll make
dnl our best guess from what we do know.
dnl Defaults
openssl_cflags=
openssl_libs=" -lcrypto -lssl "
dnl Now see if the user specified openssl_prefix
if [[ x${openssl_prefix} != x ]]; then
openssl_cflags=[-I${openssl_prefix}/include]
openssl_libs=["-Wl,-rpath,${openssl_prefix}/lib -L${openssl_prefix}/lib -L${openssl_prefix} -lcrypto -lssl"]
openssl_setup=yes
AC_MSG_RESULT( [User specified --with-openssl-prefix])
dnl Check if the developer has the pkg-config macros
dnl for the autotools on their system
ifdef([PKG_CHECK_MODULES],
[
else dnl else of prefix...
dnl If so, we can check if the target system has
dnl (1) pkg-config support installed as well, and
dnl (2) has openssl 0.9.7 or greater installed
AC_CHECK_PROG( HAS_PKGCONF, pkg-config, yes, [] , $PATH)
if [[ x${HAS_PKGCONF} != x ]]; then
PKG_CHECK_MODULES( OPENSSL,openssl >= 0.9.7, [
AC_MSG_RESULT(
[openssl 0.9.7 or greater found via pkgconfig]
)
openssl_cflags=$OPENSSL_CFLAGS
openssl_libs=$OPENSSL_LIBS
openssl_setup=yes
fi
],
[
AC_MSG_RESULT( [good openssl not found via pkgconfig])
]
) dnl End of PKG_CHECK macro
],
[
## Skipping pkg-config macros...
]
)dnl End of check using pkg-config...
fi dnl End of prefix block
if [[ x${openssl_setup} != xyes ]]; then
AC_MSG_RESULT( [Assuming reasonable defaults for openssl...])
openssl_setup=yes
fi
dnl Export our openssl build settings
AC_SUBST(openssl_cflags)
AC_SUBST(openssl_libs)
## End of OpenSSL build settings section ##
dnl OpenSSL Engine Support
AC_ARG_ENABLE( openssl-engine,
[ --enable-engine enable openssl engine support (no)],
[case "${enableval}" in
yes) engine=true ;;
no) engine=false ;;
*) AC_MSG_ERROR([bad value ${engine} for --enable-engine]) ;;
esac], [engine=false])
AC_MSG_RESULT([enable engine support : $engine])
## there is general engine support in OpenSSL 0.9.7
## AM_CONDITIONAL(HAVE_ENGINE, test x$engine = xtrue)
dnl Debug option
AC_ARG_ENABLE(debug,
[ --enable-debug enable debug messages.],
[ case "${enableval}" in
yes)
debug=true ;;
no)
debug=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac], [debug=false])
AM_CONDITIONAL(ENABLED_DEBUG, test x$debug = xtrue)
AC_MSG_RESULT([enable debug messages : $debug])
if test x${debug} = xtrue ; then
AC_DEFINE(DEBUG, 1, [enable full Tools debug messaging.])
fi
if [[ x$prefix = xNONE ]]; then
prefix="/usr/local";
fi
prefix=${prefix}
AC_MSG_RESULT([install prefix : $prefix])
dnl ========================== Install Builder Path Search ===================
builder_path=$default_path:$HOME/installbuilder/bin:$HOME/installbuilder-5.4.10/bin:$HOME/installbuilder/bin/Builder.app/Contents/MacOS/
ibuilder="builder"
if [[ "x$DIST_NAME" = "xdarwin" ]] ; then
ibuilder="installbuilder.sh"
fi
AC_PATH_PROG( INSTALL_BUILDER, $ibuilder, , $builder_path )
AC_SUBST(INSTALL_BUILDER)
dnl AC_MSG_ERROR( [****** ($DIST_NAME) IBUILDER is : $ibuilder and INSTALL_BUILDER is $INSTALL_BUILDER] );
dnl Write Makefiles.
AC_OUTPUT(
Makefile
src/sv/Makefile
src/scep/Makefile
src/crmf/Makefile
docs/Makefile
contrib/install-builder/openca-tools.xml
contrib/install-builder/openca/tools.xml
)